query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
Multi Fields generation in nested form > Start | def new
@dish = Dish.new
@dish_icons = @dish.dishes_icons.build
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nested_field_set(f, assoc, options = {})\n wrapper_partial = \"shared/nested_fields_wrapper\"\n options[:inner_partial] ||= \"#{f.object.class.model_name.route_key}/#{assoc.to_s.singularize}_fields\"\n options[:multiple] = true unless options.has_key?(:multiple)\n\n wrapper_classes = [\"nested-fields\"]\n wrapper_classes << \"no-label\" if options[:label] == false\n wrapper_classes << \"multiple\" if options[:multiple]\n\n f.input(assoc, options.slice(:required)) do\n content_tag(:div, class: \"nested-field-set\") do\n f.simple_fields_for(assoc, wrapper: :nested_fields) do |f2|\n render(wrapper_partial, f: f2, options: options, classes: wrapper_classes)\n end <<\n if options[:multiple]\n content_tag(:span) do\n link_to_add_association(t(\"cocoon.add_links.#{assoc}\"), f, assoc,\n partial: wrapper_partial,\n render_options: {\n wrapper: :nested_fields, # Simple form wrapper\n locals: {options: options, classes: wrapper_classes}\n }\n )\n end\n end\n end\n end\n end",
"def nested_forms\n []\n end",
"def dynamic_form_fields(builder)\n # Allow dynamic fields in our Project to be processed by form_for\n create_virtual_attributes!\n\n @object.fields.each do |field|\n h.haml_concat process_field(builder, field)\n end\n end",
"def fields_for_sti(form, many, add)\n object = form.object\n add.each{|klass| object.send(many).build :type => klass }\n\n index = -1\n form.fields_for many do |vf|\n index += 1\n yield vf, index\n end\n end",
"def form_fields\n @item_fields = @model.typus_fields_for('form')\n @item_has_many = @model.typus_relationships_for('has_many')\n @item_has_and_belongs_to_many = @model.typus_relationships_for('has_and_belongs_to_many')\n end",
"def fields_for(record_or_name_or_array, *args, &block) #:nodoc:\n opts = args.extract_options!\n opts.merge!(:builder => Transit::Builders::FormBuilder)\n args.push(opts)\n super(record_or_name_or_array, *args, &block)\n end",
"def add_fields_to(formtastic_form)\n fields = {}\n formtastic_form.inputs admin_fieldset_title do\n ingredients.each do |i_id, i|\n sheet = formtastic_form.object\n content = sheet.content_for i.content_key\n #debugger\n fields[i.content_key] = formtastic_form.fields_for(content) do |i_form|\n i_form.input :text\n end\n #i.add_fields_to(formtastic_form) if i.kind_of? ActiveAdmin::Cms::Recipe::Ingredient\n end\n end\n sections.each do |s_id, s|\n fields[s_id] = s.add_fields_to(formtastic_form) if s.kind_of? ActiveAdmin::Cms::Recipe::Section\n end\n\n #debugger\n\n formtastic_form.inputs\n\n end",
"def tabular_fields(form, attr, options = {})\n obj = form.object\n title = I18n.t(\"formtastic.titles.#{attr}\", :default => '')\n hint = I18n.t(\"formtastic.hints.#{obj.class.name.underscore}.#{attr}\",\n :default => '')\n outer_options = {\n :class => (obj.is_repeatable?(attr) ? 'repeatable ' : '') + 'with-table'\n }\n outer_options[:name] = title unless title.blank?\n outer_options[:name] = options[:name] if options.has_key?(:name)\n if obj.subfields(attr).blank?\n options[:label] = outer_options[:name] unless options.has_key? :label\n outer_options.delete(:name)\n end\n \n form.inputs outer_options do\n concat(content_tag('li') do\n concat(content_tag('table') do\n concat(table_header(form, attr, options))\n concat(content_tag('tbody') do\n concat(form.fields_for(\"#{attr}_items\".to_sym) do |f|\n concat(content_tag('tr') do\n form.object.subfields_for_nesting(attr).each do |field|\n as = get_option(options, field, :as) ||\n form.send(:default_input_type, field)\n concat(content_tag('td', :class => as) do\n input_options = field_options(form, attr, field, options)\n concat f.input(field, input_options)\n end)\n end\n end)\n end)\n end)\n end)\n unless hint.blank?\n concat(content_tag('p', hint, :class => 'inline-hints'))\n end\n concat(content_tag('li', form.errors_on(attr)))\n end)\n end\n end",
"def new_child_fields_template(form_builder, association, content_type=:div, options = {})\n options[:object] ||= form_builder.object.class.reflect_on_association(association).klass.new\n options[:partial] ||= form_builder.object.class.to_s.underscore.pluralize + \"/\"+ association.to_s.singularize\n options[:form_builder_local] ||= :f\n #content_for :jstemplates do\n content_tag(content_type, :id => \"#{association}_fields_template\", :class => \"hide\") do\n form_builder.fields_for(association, options[:object], :child_index => \"new_#{association}\") do |f|\n render(:partial => options[:partial], :locals => {options[:form_builder_local] => f, :aux_builder => form_builder})\n end\n end\n end",
"def custom_fields\n if debug?\n channel_fields = ChannelFieldForm.new\n channel_fields.create_field(\n group_id: 1,\n type: 'Checkboxes',\n label: 'Checkboxes',\n fields: {\n field_list_items: \"Yes\\nNo\\nMaybe\"\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Radio Buttons',\n label: 'Radio Buttons',\n fields: {\n field_list_items: \"Left\\nCenter\\nRight\"\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Multi Select',\n label: 'Multi Select',\n fields: {\n field_list_items: \"Red\\nGreen\\nBlue\"\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Select Dropdown',\n label: 'Select Dropdown',\n fields: {\n field_list_items: \"Mac\\nWindows\\nLinux\"\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Select Dropdown',\n label: 'Prepopulated',\n fields: {\n field_pre_populate: 'y'\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Rich Text Editor',\n label: 'Rich Text Editor',\n fields: {\n field_ta_rows: 20,\n field_text_direction: 'Right to left'\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Toggle',\n label: 'Toggle'\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Text Input',\n label: 'Text Input',\n fields: {\n field_maxl: 100,\n field_fmt: 'None',\n field_show_fmt: 'y',\n field_text_direction: 'Right to left',\n field_content_type: 'Decimal',\n field_show_smileys: 'y',\n field_show_file_selector: 'y'\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Textarea',\n label: 'Textarea',\n fields: {\n field_ta_rows: 20,\n field_fmt: 'None',\n field_show_fmt: 'y',\n field_text_direction: 'Right to left',\n field_show_formatting_btns: 'y',\n field_show_smileys: 'y',\n field_show_file_selector: 'y'\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'URL',\n label: 'URL Field',\n fields: {\n url_scheme_placeholder: '// (Protocol Relative URL)'\n }\n ) do |page|\n page.all('input[name=\"allowed_url_schemes[]\"]').each do |element|\n element.click unless element.checked?\n end\n end\n\n @page.load\n else\n $db.query(IO.read('channel_sets/custom-fields.sql'))\n clear_db_result\n end\n end",
"def build_subline_form(action,caption)\n\n\tline_config_codes = LineConfig.find_by_sql('select distinct line_config_code from line_configs').map{|g|[g.line_config_code]}\n\tline_config_codes.unshift(\"<empty>\")\n#\t---------------------------------\n#\t Define fields to build form from\n#\t---------------------------------\n\t field_configs = Array.new\n\t field_configs[0] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'subline_code'}\n\n\t field_configs[1] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'subline_description'}\n\n#\t----------------------------------------------------------------------------------------------\n#\tCombo fields to represent foreign key (line_config_id) on related table: line_configs\n#\t----------------------------------------------------------------------------------------------\n\tfield_configs[2] = {:field_type => 'DropDownField',\n\t\t\t\t\t\t:field_name => 'line_config_code',\n\t\t\t\t\t\t:settings => {:list => line_config_codes}}\n\n\tbuild_form(nil,field_configs,action,'subline',caption)\n\nend",
"def new_child_fields_template(form_builder, association, options = {})\n options[:object] ||= form_builder.object.class.reflect_on_association(association.to_sym).klass.new\n options[:partial] ||= association.to_s.singularize\n options[:form_builder_local] ||= :f\n\n content_tag(:div, :id => \"#{association}_fields_template\", :style => \"display: none\") do\n form_builder.fields_for(association, options[:object], :child_index => \"new_#{association}\") do |f|\n render(:partial => options[:partial], :locals => { options[:form_builder_local] => f })\n end\n end\n end",
"def forms; end",
"def create_multiple_complex_registry_field(form,\n value,\n form_prefix,\n property_name,\n label,\n field_id,\n select_values,\n locale,\n parent_id,\n schema_id,\n required: false,\n validation: nil,\n html_class: nil,\n readonly: false,\n ttip: nil,\n default_value: nil,\n overridable: nil)\n render partial: 'dynamic_form/fields/registry/multiple_complex',\n locals: {\n f: form,\n value:,\n form_prefix:,\n property_name:,\n field_label: label,\n select_values:,\n locale:,\n parent_id:,\n schema_id:,\n field_class: html_class,\n field_id:,\n readonly:,\n required:,\n validation:,\n ttip:,\n default_value:,\n overridable:\n }\n end",
"def nested_form_field label_text, form, method, field, *args\n if form.is_a? Array\n if form.length > 1\n form.shift.fields_for form.first do |builder|\n form[0] = builder\n nested_form_field label_text, form, method, field, *args\n end\n else\n nested_form_field label_text, form.first, method, field, *args\n end\n else\n if label_text.nil?\n form.send method, field, *args\n else\n %Q(<div class=row>\n <div class=span4>#{label_text}</div>\n #{ form.send method, field, *args }\n </div>).html_safe\n end\n end\n end",
"def semantic_fields_for(name, *args, &block)\n use_semantic_builder(:fields_for, name, *args, &block)\n end",
"def typus_form_externals\n html = \"\"\n if @form_fields_externals\n @form_fields_externals.each do |field|\n model_to_relate = field.singularize.camelize.constantize\n # FIXME: The admin shouldn't be hardcoded.\n html << \"<h2 style=\\\"margin: 20px 0px 10px 0px;\\\"><a href=\\\"/admin/#{field}\\\">#{field.titleize}</a> <small>#{link_to \"Add new\", :model => field, :action => 'new', :btm => params[:model], :bti => params[:id], :bta => params[:action]}</small></h2>\"\n items_to_relate = (model_to_relate.find(:all) - @item.send(field))\n if items_to_relate.size > 0\n html << <<-HTML\n #{form_tag :action => \"relate\", :related => field, :id => params[:id]}\n <p>#{select \"model_id_to_relate\", :related_id, items_to_relate.map { |f| [f.name, f.id] }}\n #{submit_tag \"Add\"}\n </form></p>\n HTML\n end\n current_model = params[:model].singularize.camelize.constantize\n @items = current_model.find(params[:id]).send(field)\n html << typus_table(field, 'relationship') if @items.size > 0\n end\n end\n return html\n rescue Exception => error\n \"<p>There was an error when loading <code>config/typus.yml</code>.</p>\n <h3>Error</h3>\n <pre>#{error}</pre>\"\n end",
"def build_get_pallet_number_form()\n\n#\t---------------------------------\n#\t Define fields to build form from\n#\t---------------------------------\n\tfield_configs = Array.new\n\n field_configs[0] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'pallet_number'}\n\n\n\n\tbuild_form(nil,field_configs,'submit_mixed_pallet_id','pallet_number','submit')\n\nend",
"def fields_for_with_form_assistant(record_or_name_or_array, *args, &proc)\n options = args.extract_options!\n # hand control over to the original #fields_for()\n fields_for_without_form_assistant(record_or_name_or_array, *(args << options.merge!(:builder => self.class)), &proc)\n end",
"def each\n super do |fields|\n form = fields.delete(@@form)\n raise \"Missing #{@@form} value\" if form.nil?\n # Values missing from the final field in a row will be returned as\n # nil. Map them to empty string.\n fields.each { |f,v| fields[f] = \"\" if v.nil? }\n # Features with empty values are unspecified: remove them.\n fields.delete_if { |f,v| v.empty? }\n # Convert feature strings to symbols.\n features = {}\n fields.each {|f,v| features[f.to_sym] = v.to_sym}\n yield [form, features]\n end\n end",
"def each_field\n self.form.form_fields.each do |field|\n yield field, self.data[field.name.to_sym]\n end\n end",
"def link_to_add_fields(name, f, type)\n new_object = f.object.send \"build_#{type}\"\n id = \"new_#{type}\"\n fields = f.send(\"#{type}_fields\", new_object, child_index: id) do |builder|\n render(type.to_s + \"_fields\", f: builder)\n end\n link_to(name, '#', class: \"add_fields\", data: {id: id, fields: fields.gsub(\"\\n\", \"\")})\n end",
"def get_fields(template); end",
"def build_single_form(form_builder, phone, options = {})\n phone = {} unless phone.is_a? Hash\n phone = blank_phone.merge phone\n prefix_class = options[:prefix_class].presence || 'input-tiny form-control'\n code_class = options[:code_class].presence || 'input-mini form-control'\n number_class = options[:number_class].presence || 'input-small form-control'\n group_class = options[:group_class].presence || 'form-inline'\n delimiter = options[:delimiter].presence || '—'\n\n phone_form = []\n\n form_builder.fields_for(:value, index: '') do |phone_builder|\n phone_form << phone_builder.text_field(:prefix, class: prefix_class, value: phone['prefix'])\n phone_form << phone_builder.text_field(:code, class: code_class, value: phone['code'])\n phone_form << phone_builder.text_field(:number, class: number_class, value: phone['number'])\n end\n\n full_phone_form = [phone_form[0], delimiter, phone_form[1], delimiter, phone_form[2]].join\n\n sprintf '<p class=\"%s\">%s</p>', group_class, full_phone_form\n end",
"def addInputs(forms)\n forms.push( {\"description\"=>\"Config\",\n \"label\"=>\"Config\",\"name\"=>\"config\",\n \"property_inputs\"=>[{\"description\"=>\"Stack\",\"label\"=>\"Stack\",\"reference\"=>\".diego_cell\"+deploymentName+\".stack\"},\n {\"description\"=>\"Virtual IP\",\"label\"=>\"Virtual IP\",\"reference\"=>\".ha_proxy\"+deploymentName+\".keepalived_vip\"},\n {\"description\"=>\"Same Keepalived group share same virtual router ID \",\"label\"=>\"Virtual Router ID\",\"reference\"=>\".ha_proxy\"+deploymentName+\".keepalived_virtual_router_id\"}] });\nend",
"def lm_fields_for(name, *args, &block)\n raise ArgumentError, \"Missing block\" unless block_given?\n options = args.last.is_a?(Hash) ? args.pop : {}\n options = options.merge(:builder => LMFormBuilder)\n object = args.first\n yield((options[:builder] || FormBuilder).new(name, object, self, options, block))\n end",
"def build_line_form(line,action,caption,is_edit = nil)\n\n field_configs = Array.new\n\tfield_configs[0] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'line_code'}\n\n\tfield_configs[1] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'line_phc'}\n\n field_configs[field_configs.length()] = {:field_type=>'CheckBox', :field_name=>'is_dedicated'}\n\n\n build_form(line,field_configs,action,'line',caption,is_edit)\n\n\n end",
"def get_field_list_rtpl\n # TODO: revisit when implementing save/display of multiselct values\n # if(!@multiple.nil? && @multiple != '') then\n # multiple = @multiple\n # else multiple = ''\n # end\n\n field_string = '{%=' + @model_name + '[:' + @name + '_display]%}'\n # field_string = '{%=_'+@model_name+'[:options_list]['+@model_name+'[:'+@name+']]%}'\n field_string\n end",
"def format_forms(page)\n ret = {}\n page.forms.each do |form|\n ret[form.name] = []\n form.fields.each do |n|\n ret[form.name] << n.name\n end\n end\n return ret\nend",
"def link_to_add_fields(name,f,association)\n new_object = f.object.class.reflect_on_association(association).klass.new\n fields = f.fields_for(association,new_object, :child_index=>\"new_#{association}\") do |builder|\n render(association.to_s.pluralize+\"/\"+association.to_s.singularize + \"_fields\", :f => builder)\n end\n ui_link_to_function('add',name,\"add_fields(this,\\\"#{association}\\\", \\\"#{escape_javascript(fields)}\\\")\")\n end",
"def link_to_add_fields(name,f,association)\n new_object = f.object.class.reflect_on_association(association).klass.new\n fields = f.fields_for(association,new_object, :child_index=>\"new_#{association}\") do |builder|\n render(association.to_s.pluralize+\"/\"+association.to_s.singularize + \"_fields\", :f => builder)\n end\n ui_link_to_function('add',name,\"add_fields(this,\\\"#{association}\\\", \\\"#{escape_javascript(fields)}\\\")\")\n end",
"def field_set_and_list_wrapping(*args, &block) #:nodoc:\n contents = args.last.is_a?(::Hash) ? '' : args.pop.flatten\n html_options = args.extract_options!\n\n legend = html_options.delete(:name).to_s\n legend %= parent_child_index(html_options[:parent]) if html_options[:parent]\n legend = template.content_tag(:legend, template.content_tag(:span, legend)) unless legend.blank?\n\n if block_given?\n contents = if template.respond_to?(:is_haml?) && template.is_haml?\n template.capture_haml(&block)\n else\n template.capture(&block)\n end\n end\n\n # Ruby 1.9: String#to_s behavior changed, need to make an explicit join.\n contents = contents.join if contents.respond_to?(:join)\n fieldset = template.content_tag(:fieldset,\n legend << template.content_tag(:ol, contents),\n html_options.except(:builder, :parent)\n )\n\n template.concat(fieldset) if block_given?\n fieldset\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def build_fields(params_list)\n params_list = params_list.first.to_a if Hash === params_list.first\n \n params_list.map do |params|\n if Array === params\n params.flatten! if Array === params.second\n options = params.extract_options!\n name = params.first\n format = params.second\n else\n name = params\n options = {}\n end\n\n attributes = {format: format, collection: @current_collection}.merge(options)\n Field.new(name, attributes)\n end\n end",
"def semantic_fields_for(record_or_name_or_array, *args, &block)\n opts = args.extract_options!\n opts[:builder] ||= Formtastic::SemanticFormHelper.builder\n args.push(opts)\n fields_for(record_or_name_or_array, *args, &block)\n end",
"def ing_form; end",
"def fields_on_form() #:nodoc:\r\n fields = []\r\n if @form['form']['fields']\r\n# read only field elements (key is Fixnum)\r\n @form['form']['fields'].each {|key,options| fields << options if key.class == Fixnum }\r\n else\r\n @form['form']['tabs'].keys.each do |tab|\r\n @form['form']['tabs'][tab].each {|key,options| fields << options if key.class == Fixnum }\r\n end \r\n end\r\n fields\r\nend",
"def link_to_add_fields(name, f, association, divname, count_range, max_len, add_class)\n new_object = f.object.class.reflect_on_association(association).klass.new\n fields = f.fields_for(association, new_object, :child_index => \"new_#{association}\") do |builder|\n render(association.to_s.singularize + \"_fields\", :f => builder)\n end\n link_to_function(name, \"add_fields(this, \\\"#{association}\\\", \\\"#{escape_javascript(fields)}\\\", \\\"#{divname}\\\", \\\"#{count_range}\\\")\", :class => \"add_fields \"+ add_class, 'data-max_len'=> max_len )\n\n end",
"def layout_fields\n # Everything has a tag - or it BETTER!\n # Probably should refactor this or something.\n value = @stored_values[:tag] || @object.tag\n label = Label.new(\"Tag\")\n tagInput = InputField.new(value,30)\n @attr_to_field[:tag] = tagInput\n layout_field_button(label,tagInput,\"Auto\") do\n attemptName = nil\n if @attr_to_field[:name]\n attemptName = @attr_to_field[:name].text\n end\n tagInput.text = @rl.repository.generate_tag_for(@object,attemptName)\n end\n @fieldY = tagInput.rect.bottom + @spacing \n @object.class.attrs.sort.each do | attr |\n next if attr == :tag # We did tags ourselves\n display = true\n value = @stored_values[attr] || @object.send(attr)\n label = Label.new(attr.to_s)\n rows,cols = [0,0]\n size= @object.class.size_for(attr)\n input = nil\n if size\n rows,cols = size\n if rows > 1\n input = MultiLineInput.new(value)\n input.set_size(rows,cols)\n elsif rows == 0 || cols == 0\n display = false\n else\n input = InputField.new(value, cols)\n end\n else\n input = InputField.new(value,20)\n end \n \n if display\n if rows > 1\n scroller = Scroller.new(input)\n scroller.translate_to(*input.rect.topleft)\n layout_field(label,scroller)\n else\n layout_field(label,input)\n end\n @attr_to_field[attr] = input\n end\n check_max_button(attr,input) if input\n end\n \n # Booleans\n @object.class.booleans.each do | attr |\n value = @stored_values[attr] || @object.send(attr)\n checkbox = CheckBox.new(attr.to_s,value)\n checkbox.rect.topleft = [ @fieldX, @fieldY ] \n \n @fieldY = checkbox.rect.bottom + @spacing\n \n self << checkbox\n @bool_to_field[attr] = checkbox\n end\n \n # And now for the enums!\n @object.class.enumerations.each do | attr, valid |\n value = @stored_values[attr] || @object.send(attr)\n label = Label.new(attr.to_s)\n \n size = @object.class.size_for(attr)\n label.rect.topleft = [@fieldX, @fieldY]\n rows = size || valid.size\n \n input = ListBox.new\n input.rect.w = @mainRect.w / 2 - label.rect.w - @spacing * 3\n input.rect.h = input.height(rows)\n input.items = valid\n input.chosen = value\n \n input.translate_to(label.rect.right + @spacing, @fieldY)\n \n @fieldY = input.rect.bottom + @spacing\n self << label\n self << input\n @enum_to_field[attr] = input\n \n end\n end",
"def inputs_for_nested_attributes(*args, &block) #:nodoc:\n options = args.extract_options!\n args << options.merge!(:parent => { :builder => self, :for => options[:for] })\n\n fields_for_block = if block_given?\n raise ArgumentError, 'You gave :for option with a block to inputs method, ' <<\n 'but the block does not accept any argument.' if block.arity <= 0\n lambda do |f|\n contents = f.inputs(*args){ block.call(f) }\n template.concat(contents)\n end\n else\n lambda do |f|\n contents = f.inputs(*args)\n template.concat(contents)\n end\n end\n\n fields_for_args = [options.delete(:for), options.delete(:for_options) || {}].flatten\n semantic_fields_for(*fields_for_args, &fields_for_block)\n end",
"def fields_for(child_association, collection=nil, options={}, &block)\n default_collection = self.object.send(child_association)\n collection ||= default_collection\n include_index = default_collection.respond_to?(:each)\n\n nested_options = { :parent => self, :association => child_association }\n Array(collection).each_with_index.inject(SafeBuffer.new) do |all,(child_instance,index)|\n nested_options[:index] = options[:index] || (include_index ? index : nil)\n all << @template.fields_for(child_instance, { :nested => nested_options, :builder => self.class }, &block) << \"\\n\"\n end\n end",
"def display_fields\n @form.fields.each {|f| puts f.name}\n end",
"def forms_fields(form, action)\n section_fields = []\n form.form_sections.each do |section|\n if section['permissions'][\"#{current_user.role.short_name}\"][action] == '1'\n section_fields << section.section_fields.map do |field|\n if field.field_type.field_type.start_with?('select') && field.field_type.options['multivalue'] == '1'\n { field.id.to_s.to_sym => [] }\n else\n field.id.to_s.to_sym\n end\n end\n end\n end\n section_fields\n end",
"def add_full_set_link(form_builder)\n link_to_function 'Extra Full Set' do |page|\n form_builder.fields_for :equipment, Equipment.new, :child_index => 'NEW_RECORD' do |f|\n html = render(:partial => 'laptop', :locals => { :form => f })\n page << \"$('#equipment_list').append('#{escape_javascript(html)}'.replace(/NEW_RECORD/g, new Date().getTime()));\"\n end\n form_builder.fields_for :equipment, Equipment.new, :child_index => 'NEW_RECORD' do |f|\n html = render(:partial => 'interface_box', :locals => { :form => f })\n page << \"$('#equipment_list').append('#{escape_javascript(html)}'.replace(/NEW_RECORD/g, new Date().getTime()));\"\n end\n form_builder.fields_for :equipment, Equipment.new, :child_index => 'NEW_RECORD' do |f|\n html = render(:partial => 'pads', :locals => { :form => f })\n page << \"$('#equipment_list').append('#{escape_javascript(html)}'.replace(/NEW_RECORD/g, new Date().getTime()));\"\n end\n end\n end",
"def fields\n @fields ||= form.fields\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_subfields\n subfield = Struct.new(:code, :text)\n subfield_list = []\n @subfield_info.keys.sort.each { |k|\n code = @subfield_info[k][:code]\n value = @subfield_info[k][:value]\n subfield_list << subfield.new(code,value)\n }\n subfield_list\n end"
] | [
"0.702322",
"0.69084704",
"0.690355",
"0.66229945",
"0.651817",
"0.65178764",
"0.6386444",
"0.6330734",
"0.63272774",
"0.6269174",
"0.625008",
"0.62041116",
"0.61990696",
"0.61758083",
"0.614339",
"0.61265403",
"0.6052867",
"0.6048651",
"0.6043439",
"0.6034277",
"0.6008626",
"0.6007816",
"0.5997182",
"0.59371656",
"0.59162486",
"0.590426",
"0.5897225",
"0.5895608",
"0.58913404",
"0.5880027",
"0.5880027",
"0.5866206",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5863747",
"0.5855989",
"0.58444923",
"0.5822648",
"0.5818024",
"0.5817535",
"0.58060455",
"0.5800384",
"0.57915384",
"0.57882625",
"0.5786437",
"0.57751876",
"0.57751846",
"0.57542425",
"0.57510024"
] | 0.0 | -1 |
Multi Fields generation in nested form > End | def create
@dish = Dish.new(params[:dish])
if @dish.save
redirect_to @dish, notice: 'Dish was successfully created.'
else
render action: "new"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nested_forms\n []\n end",
"def nested_field_set(f, assoc, options = {})\n wrapper_partial = \"shared/nested_fields_wrapper\"\n options[:inner_partial] ||= \"#{f.object.class.model_name.route_key}/#{assoc.to_s.singularize}_fields\"\n options[:multiple] = true unless options.has_key?(:multiple)\n\n wrapper_classes = [\"nested-fields\"]\n wrapper_classes << \"no-label\" if options[:label] == false\n wrapper_classes << \"multiple\" if options[:multiple]\n\n f.input(assoc, options.slice(:required)) do\n content_tag(:div, class: \"nested-field-set\") do\n f.simple_fields_for(assoc, wrapper: :nested_fields) do |f2|\n render(wrapper_partial, f: f2, options: options, classes: wrapper_classes)\n end <<\n if options[:multiple]\n content_tag(:span) do\n link_to_add_association(t(\"cocoon.add_links.#{assoc}\"), f, assoc,\n partial: wrapper_partial,\n render_options: {\n wrapper: :nested_fields, # Simple form wrapper\n locals: {options: options, classes: wrapper_classes}\n }\n )\n end\n end\n end\n end\n end",
"def dynamic_form_fields(builder)\n # Allow dynamic fields in our Project to be processed by form_for\n create_virtual_attributes!\n\n @object.fields.each do |field|\n h.haml_concat process_field(builder, field)\n end\n end",
"def form_fields\n @item_fields = @model.typus_fields_for('form')\n @item_has_many = @model.typus_relationships_for('has_many')\n @item_has_and_belongs_to_many = @model.typus_relationships_for('has_and_belongs_to_many')\n end",
"def new_child_fields_template(form_builder, association, content_type=:div, options = {})\n options[:object] ||= form_builder.object.class.reflect_on_association(association).klass.new\n options[:partial] ||= form_builder.object.class.to_s.underscore.pluralize + \"/\"+ association.to_s.singularize\n options[:form_builder_local] ||= :f\n #content_for :jstemplates do\n content_tag(content_type, :id => \"#{association}_fields_template\", :class => \"hide\") do\n form_builder.fields_for(association, options[:object], :child_index => \"new_#{association}\") do |f|\n render(:partial => options[:partial], :locals => {options[:form_builder_local] => f, :aux_builder => form_builder})\n end\n end\n end",
"def fields_for_sti(form, many, add)\n object = form.object\n add.each{|klass| object.send(many).build :type => klass }\n\n index = -1\n form.fields_for many do |vf|\n index += 1\n yield vf, index\n end\n end",
"def build_subline_form(action,caption)\n\n\tline_config_codes = LineConfig.find_by_sql('select distinct line_config_code from line_configs').map{|g|[g.line_config_code]}\n\tline_config_codes.unshift(\"<empty>\")\n#\t---------------------------------\n#\t Define fields to build form from\n#\t---------------------------------\n\t field_configs = Array.new\n\t field_configs[0] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'subline_code'}\n\n\t field_configs[1] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'subline_description'}\n\n#\t----------------------------------------------------------------------------------------------\n#\tCombo fields to represent foreign key (line_config_id) on related table: line_configs\n#\t----------------------------------------------------------------------------------------------\n\tfield_configs[2] = {:field_type => 'DropDownField',\n\t\t\t\t\t\t:field_name => 'line_config_code',\n\t\t\t\t\t\t:settings => {:list => line_config_codes}}\n\n\tbuild_form(nil,field_configs,action,'subline',caption)\n\nend",
"def fields_for(record_or_name_or_array, *args, &block) #:nodoc:\n opts = args.extract_options!\n opts.merge!(:builder => Transit::Builders::FormBuilder)\n args.push(opts)\n super(record_or_name_or_array, *args, &block)\n end",
"def new_child_fields_template(form_builder, association, options = {})\n options[:object] ||= form_builder.object.class.reflect_on_association(association.to_sym).klass.new\n options[:partial] ||= association.to_s.singularize\n options[:form_builder_local] ||= :f\n\n content_tag(:div, :id => \"#{association}_fields_template\", :style => \"display: none\") do\n form_builder.fields_for(association, options[:object], :child_index => \"new_#{association}\") do |f|\n render(:partial => options[:partial], :locals => { options[:form_builder_local] => f })\n end\n end\n end",
"def add_fields_to(formtastic_form)\n fields = {}\n formtastic_form.inputs admin_fieldset_title do\n ingredients.each do |i_id, i|\n sheet = formtastic_form.object\n content = sheet.content_for i.content_key\n #debugger\n fields[i.content_key] = formtastic_form.fields_for(content) do |i_form|\n i_form.input :text\n end\n #i.add_fields_to(formtastic_form) if i.kind_of? ActiveAdmin::Cms::Recipe::Ingredient\n end\n end\n sections.each do |s_id, s|\n fields[s_id] = s.add_fields_to(formtastic_form) if s.kind_of? ActiveAdmin::Cms::Recipe::Section\n end\n\n #debugger\n\n formtastic_form.inputs\n\n end",
"def forms; end",
"def typus_form_externals\n html = \"\"\n if @form_fields_externals\n @form_fields_externals.each do |field|\n model_to_relate = field.singularize.camelize.constantize\n # FIXME: The admin shouldn't be hardcoded.\n html << \"<h2 style=\\\"margin: 20px 0px 10px 0px;\\\"><a href=\\\"/admin/#{field}\\\">#{field.titleize}</a> <small>#{link_to \"Add new\", :model => field, :action => 'new', :btm => params[:model], :bti => params[:id], :bta => params[:action]}</small></h2>\"\n items_to_relate = (model_to_relate.find(:all) - @item.send(field))\n if items_to_relate.size > 0\n html << <<-HTML\n #{form_tag :action => \"relate\", :related => field, :id => params[:id]}\n <p>#{select \"model_id_to_relate\", :related_id, items_to_relate.map { |f| [f.name, f.id] }}\n #{submit_tag \"Add\"}\n </form></p>\n HTML\n end\n current_model = params[:model].singularize.camelize.constantize\n @items = current_model.find(params[:id]).send(field)\n html << typus_table(field, 'relationship') if @items.size > 0\n end\n end\n return html\n rescue Exception => error\n \"<p>There was an error when loading <code>config/typus.yml</code>.</p>\n <h3>Error</h3>\n <pre>#{error}</pre>\"\n end",
"def custom_fields\n if debug?\n channel_fields = ChannelFieldForm.new\n channel_fields.create_field(\n group_id: 1,\n type: 'Checkboxes',\n label: 'Checkboxes',\n fields: {\n field_list_items: \"Yes\\nNo\\nMaybe\"\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Radio Buttons',\n label: 'Radio Buttons',\n fields: {\n field_list_items: \"Left\\nCenter\\nRight\"\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Multi Select',\n label: 'Multi Select',\n fields: {\n field_list_items: \"Red\\nGreen\\nBlue\"\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Select Dropdown',\n label: 'Select Dropdown',\n fields: {\n field_list_items: \"Mac\\nWindows\\nLinux\"\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Select Dropdown',\n label: 'Prepopulated',\n fields: {\n field_pre_populate: 'y'\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Rich Text Editor',\n label: 'Rich Text Editor',\n fields: {\n field_ta_rows: 20,\n field_text_direction: 'Right to left'\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Toggle',\n label: 'Toggle'\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Text Input',\n label: 'Text Input',\n fields: {\n field_maxl: 100,\n field_fmt: 'None',\n field_show_fmt: 'y',\n field_text_direction: 'Right to left',\n field_content_type: 'Decimal',\n field_show_smileys: 'y',\n field_show_file_selector: 'y'\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Textarea',\n label: 'Textarea',\n fields: {\n field_ta_rows: 20,\n field_fmt: 'None',\n field_show_fmt: 'y',\n field_text_direction: 'Right to left',\n field_show_formatting_btns: 'y',\n field_show_smileys: 'y',\n field_show_file_selector: 'y'\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'URL',\n label: 'URL Field',\n fields: {\n url_scheme_placeholder: '// (Protocol Relative URL)'\n }\n ) do |page|\n page.all('input[name=\"allowed_url_schemes[]\"]').each do |element|\n element.click unless element.checked?\n end\n end\n\n @page.load\n else\n $db.query(IO.read('channel_sets/custom-fields.sql'))\n clear_db_result\n end\n end",
"def tabular_fields(form, attr, options = {})\n obj = form.object\n title = I18n.t(\"formtastic.titles.#{attr}\", :default => '')\n hint = I18n.t(\"formtastic.hints.#{obj.class.name.underscore}.#{attr}\",\n :default => '')\n outer_options = {\n :class => (obj.is_repeatable?(attr) ? 'repeatable ' : '') + 'with-table'\n }\n outer_options[:name] = title unless title.blank?\n outer_options[:name] = options[:name] if options.has_key?(:name)\n if obj.subfields(attr).blank?\n options[:label] = outer_options[:name] unless options.has_key? :label\n outer_options.delete(:name)\n end\n \n form.inputs outer_options do\n concat(content_tag('li') do\n concat(content_tag('table') do\n concat(table_header(form, attr, options))\n concat(content_tag('tbody') do\n concat(form.fields_for(\"#{attr}_items\".to_sym) do |f|\n concat(content_tag('tr') do\n form.object.subfields_for_nesting(attr).each do |field|\n as = get_option(options, field, :as) ||\n form.send(:default_input_type, field)\n concat(content_tag('td', :class => as) do\n input_options = field_options(form, attr, field, options)\n concat f.input(field, input_options)\n end)\n end\n end)\n end)\n end)\n end)\n unless hint.blank?\n concat(content_tag('p', hint, :class => 'inline-hints'))\n end\n concat(content_tag('li', form.errors_on(attr)))\n end)\n end\n end",
"def create_multiple_complex_registry_field(form,\n value,\n form_prefix,\n property_name,\n label,\n field_id,\n select_values,\n locale,\n parent_id,\n schema_id,\n required: false,\n validation: nil,\n html_class: nil,\n readonly: false,\n ttip: nil,\n default_value: nil,\n overridable: nil)\n render partial: 'dynamic_form/fields/registry/multiple_complex',\n locals: {\n f: form,\n value:,\n form_prefix:,\n property_name:,\n field_label: label,\n select_values:,\n locale:,\n parent_id:,\n schema_id:,\n field_class: html_class,\n field_id:,\n readonly:,\n required:,\n validation:,\n ttip:,\n default_value:,\n overridable:\n }\n end",
"def nested_form_field label_text, form, method, field, *args\n if form.is_a? Array\n if form.length > 1\n form.shift.fields_for form.first do |builder|\n form[0] = builder\n nested_form_field label_text, form, method, field, *args\n end\n else\n nested_form_field label_text, form.first, method, field, *args\n end\n else\n if label_text.nil?\n form.send method, field, *args\n else\n %Q(<div class=row>\n <div class=span4>#{label_text}</div>\n #{ form.send method, field, *args }\n </div>).html_safe\n end\n end\n end",
"def link_to_add_fields(name, f, type)\n new_object = f.object.send \"build_#{type}\"\n id = \"new_#{type}\"\n fields = f.send(\"#{type}_fields\", new_object, child_index: id) do |builder|\n render(type.to_s + \"_fields\", f: builder)\n end\n link_to(name, '#', class: \"add_fields\", data: {id: id, fields: fields.gsub(\"\\n\", \"\")})\n end",
"def each\n super do |fields|\n form = fields.delete(@@form)\n raise \"Missing #{@@form} value\" if form.nil?\n # Values missing from the final field in a row will be returned as\n # nil. Map them to empty string.\n fields.each { |f,v| fields[f] = \"\" if v.nil? }\n # Features with empty values are unspecified: remove them.\n fields.delete_if { |f,v| v.empty? }\n # Convert feature strings to symbols.\n features = {}\n fields.each {|f,v| features[f.to_sym] = v.to_sym}\n yield [form, features]\n end\n end",
"def link_to_add_fields(name,f,association)\n new_object = f.object.class.reflect_on_association(association).klass.new\n fields = f.fields_for(association,new_object, :child_index=>\"new_#{association}\") do |builder|\n render(association.to_s.pluralize+\"/\"+association.to_s.singularize + \"_fields\", :f => builder)\n end\n ui_link_to_function('add',name,\"add_fields(this,\\\"#{association}\\\", \\\"#{escape_javascript(fields)}\\\")\")\n end",
"def link_to_add_fields(name,f,association)\n new_object = f.object.class.reflect_on_association(association).klass.new\n fields = f.fields_for(association,new_object, :child_index=>\"new_#{association}\") do |builder|\n render(association.to_s.pluralize+\"/\"+association.to_s.singularize + \"_fields\", :f => builder)\n end\n ui_link_to_function('add',name,\"add_fields(this,\\\"#{association}\\\", \\\"#{escape_javascript(fields)}\\\")\")\n end",
"def get_field_list_rtpl\n # TODO: revisit when implementing save/display of multiselct values\n # if(!@multiple.nil? && @multiple != '') then\n # multiple = @multiple\n # else multiple = ''\n # end\n\n field_string = '{%=' + @model_name + '[:' + @name + '_display]%}'\n # field_string = '{%=_'+@model_name+'[:options_list]['+@model_name+'[:'+@name+']]%}'\n field_string\n end",
"def field_set_and_list_wrapping(*args, &block) #:nodoc:\n contents = args.last.is_a?(::Hash) ? '' : args.pop.flatten\n html_options = args.extract_options!\n\n legend = html_options.delete(:name).to_s\n legend %= parent_child_index(html_options[:parent]) if html_options[:parent]\n legend = template.content_tag(:legend, template.content_tag(:span, legend)) unless legend.blank?\n\n if block_given?\n contents = if template.respond_to?(:is_haml?) && template.is_haml?\n template.capture_haml(&block)\n else\n template.capture(&block)\n end\n end\n\n # Ruby 1.9: String#to_s behavior changed, need to make an explicit join.\n contents = contents.join if contents.respond_to?(:join)\n fieldset = template.content_tag(:fieldset,\n legend << template.content_tag(:ol, contents),\n html_options.except(:builder, :parent)\n )\n\n template.concat(fieldset) if block_given?\n fieldset\n end",
"def fields_for(child_association, collection=nil, options={}, &block)\n default_collection = self.object.send(child_association)\n collection ||= default_collection\n include_index = default_collection.respond_to?(:each)\n\n nested_options = { :parent => self, :association => child_association }\n Array(collection).each_with_index.inject(SafeBuffer.new) do |all,(child_instance,index)|\n nested_options[:index] = options[:index] || (include_index ? index : nil)\n all << @template.fields_for(child_instance, { :nested => nested_options, :builder => self.class }, &block) << \"\\n\"\n end\n end",
"def link_to_add_fields(name, f, association, divname, count_range, max_len, add_class)\n new_object = f.object.class.reflect_on_association(association).klass.new\n fields = f.fields_for(association, new_object, :child_index => \"new_#{association}\") do |builder|\n render(association.to_s.singularize + \"_fields\", :f => builder)\n end\n link_to_function(name, \"add_fields(this, \\\"#{association}\\\", \\\"#{escape_javascript(fields)}\\\", \\\"#{divname}\\\", \\\"#{count_range}\\\")\", :class => \"add_fields \"+ add_class, 'data-max_len'=> max_len )\n\n end",
"def each_field\n self.form.form_fields.each do |field|\n yield field, self.data[field.name.to_sym]\n end\n end",
"def wrap_with_repeatable_ui\n # cocoon JS wants \"nested-fields\"\n template.content_tag(:div, class: \"nested-fields form-row\") do\n template.content_tag(:div, class: \"col\") do\n yield\n end +\n template.content_tag(:div, class: \"col-auto\") do\n remove_link\n end\n end\n end",
"def fields_for_with_form_assistant(record_or_name_or_array, *args, &proc)\n options = args.extract_options!\n # hand control over to the original #fields_for()\n fields_for_without_form_assistant(record_or_name_or_array, *(args << options.merge!(:builder => self.class)), &proc)\n end",
"def build_get_pallet_number_form()\n\n#\t---------------------------------\n#\t Define fields to build form from\n#\t---------------------------------\n\tfield_configs = Array.new\n\n field_configs[0] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'pallet_number'}\n\n\n\n\tbuild_form(nil,field_configs,'submit_mixed_pallet_id','pallet_number','submit')\n\nend",
"def format_forms(page)\n ret = {}\n page.forms.each do |form|\n ret[form.name] = []\n form.fields.each do |n|\n ret[form.name] << n.name\n end\n end\n return ret\nend",
"def ing_form; end",
"def add_full_set_link(form_builder)\n link_to_function 'Extra Full Set' do |page|\n form_builder.fields_for :equipment, Equipment.new, :child_index => 'NEW_RECORD' do |f|\n html = render(:partial => 'laptop', :locals => { :form => f })\n page << \"$('#equipment_list').append('#{escape_javascript(html)}'.replace(/NEW_RECORD/g, new Date().getTime()));\"\n end\n form_builder.fields_for :equipment, Equipment.new, :child_index => 'NEW_RECORD' do |f|\n html = render(:partial => 'interface_box', :locals => { :form => f })\n page << \"$('#equipment_list').append('#{escape_javascript(html)}'.replace(/NEW_RECORD/g, new Date().getTime()));\"\n end\n form_builder.fields_for :equipment, Equipment.new, :child_index => 'NEW_RECORD' do |f|\n html = render(:partial => 'pads', :locals => { :form => f })\n page << \"$('#equipment_list').append('#{escape_javascript(html)}'.replace(/NEW_RECORD/g, new Date().getTime()));\"\n end\n end\n end",
"def addInputs(forms)\n forms.push( {\"description\"=>\"Config\",\n \"label\"=>\"Config\",\"name\"=>\"config\",\n \"property_inputs\"=>[{\"description\"=>\"Stack\",\"label\"=>\"Stack\",\"reference\"=>\".diego_cell\"+deploymentName+\".stack\"},\n {\"description\"=>\"Virtual IP\",\"label\"=>\"Virtual IP\",\"reference\"=>\".ha_proxy\"+deploymentName+\".keepalived_vip\"},\n {\"description\"=>\"Same Keepalived group share same virtual router ID \",\"label\"=>\"Virtual Router ID\",\"reference\"=>\".ha_proxy\"+deploymentName+\".keepalived_virtual_router_id\"}] });\nend",
"def semantic_fields_for(name, *args, &block)\n use_semantic_builder(:fields_for, name, *args, &block)\n end",
"def get_fields(template); end",
"def user_form_and_fields(admin_form_id)\n\t\tcase_form_template = AdminForm.find(admin_form_id)\n\t\tfields = []\n\t\t\n\t\tcase_form_template.form_fields.each do |field_id|\n\t\t\tadmin_field = AdminField.find(field_id)\n\t\t\tfield = current_user.user_fields.find_or_initialize_by(field_name: admin_field.field_name,field_slug:admin_field.field_slug,field_type: admin_field.field_type)\n\t\t\tif admin_field.field_type == 'select' || admin_field.field_type == 'radio'\n\t\t\t\tfield.field_options = admin_field.field_options\n\t\t\tend\n\t\t\tfield.save\n\t\t\tfields << field.id.to_s\n\t\tend\n\n\t\ti=0\n\t\tform_field_count = 1\n\t\twhile i <= current_user.user_forms.count do\n\t\t form_name = \"#{case_form_template.form_name}-#{i}\"\n\t\t if !current_user.user_forms.where(:form_name => form_name).blank?\n\t\t form_field_count += 1\n\t\t end\n\t\t i +=1\n\t\tend\n\t\t\n\t\tform = current_user.user_forms.find_or_initialize_by(form_name: \"#{case_form_template.form_name}-#{form_field_count}\",form_name_slug:case_form_template.form_name_slug, form_fields:fields)\n\t\tform.form_fields=form.form_fields.to_a+params[:case_user_fields_ids].to_a\n\t\tform.save\n\t\treturn form\n\tend",
"def link_to_add_fields(name, f, association)\n new_object = f.object.send(association).klass.new\n id = new_object.object_id\n fields = f.fields_for(association, new_object, child_index: id) do |builder|\n render(association.to_s.singularize + \"_fields\", f: builder)\n end\n link_to(name, '#', class: \"add_fields btn btn-success btn-block\", data: {id: id, fields: fields.gsub(\"\\n\", \"\")})\n end",
"def link_to_add_fields(name, f, association)\n new_object = f.object.class.reflect_on_association(association).klass.new\n fields = f.fields_for(association, new_object,\n :child_index => \"new_#{association}\") do |builder| \n render(\"form_\" + association.to_s, :f => builder)\n end\n link_to_function(name, h(\"add_fields(this, \\\"#{association}\\\", \\\"#{escape_javascript(fields)}\\\")\"))\n end",
"def next_form\n json_form.next_form(parsed_json['id'])\n end",
"def display_fields\n @form.fields.each {|f| puts f.name}\n end",
"def build_single_form(form_builder, phone, options = {})\n phone = {} unless phone.is_a? Hash\n phone = blank_phone.merge phone\n prefix_class = options[:prefix_class].presence || 'input-tiny form-control'\n code_class = options[:code_class].presence || 'input-mini form-control'\n number_class = options[:number_class].presence || 'input-small form-control'\n group_class = options[:group_class].presence || 'form-inline'\n delimiter = options[:delimiter].presence || '—'\n\n phone_form = []\n\n form_builder.fields_for(:value, index: '') do |phone_builder|\n phone_form << phone_builder.text_field(:prefix, class: prefix_class, value: phone['prefix'])\n phone_form << phone_builder.text_field(:code, class: code_class, value: phone['code'])\n phone_form << phone_builder.text_field(:number, class: number_class, value: phone['number'])\n end\n\n full_phone_form = [phone_form[0], delimiter, phone_form[1], delimiter, phone_form[2]].join\n\n sprintf '<p class=\"%s\">%s</p>', group_class, full_phone_form\n end",
"def link_to_add_fields(name, f, association, params={})\n\t\tnew_object = f.object.class.reflect_on_association(association).klass.new\n\t\tfields = f.fields_for(association, new_object, :child_index => \"new_#{association}\") do |builder|\n\t\t\t#merge the params hash with the form builder being sent as a local variable to the partial\n\t \t\trender(association.to_s.singularize + \"_fields\", {:f => builder}.merge(params))\n\t\tend\n\t\tlink_to_function(name, \"add_fields(this, '#{association}', '#{escape_javascript(fields)}')\")\n\tend",
"def link_to_add_fields(name, f, association, params={})\n\t\tnew_object = f.object.class.reflect_on_association(association).klass.new\n\t\tfields = f.fields_for(association, new_object, :child_index => \"new_#{association}\") do |builder|\n\t\t\t#merge the params hash with the form builder being sent as a local variable to the partial\n\t \t\trender(association.to_s.singularize + \"_fields\", {:f => builder}.merge(params))\n\t\tend\n\t\tlink_to_function(name, \"add_fields(this, '#{association}', '#{escape_javascript(fields)}')\")\n\tend",
"def link_to_add_fields(name, f, association, fields_partial, modal, options = {})\n sel2NoMatch = t(\"select2.no_matches\")\n new_object = f.object.class.reflect_on_association(association).klass.new\n #fields = f.fields_for(association, new_object, :child_index => \"new_#{ association }\", :onsubmit => \"return $(this.)validate();\") do |builder|\n #fields = f.fields_for(association, new_object, :child_index => \"new_#{ fields_partial }\", :onsubmit => \"return $(this.)validate();\") do |builder|\n fields = f.simple_fields_for(association, new_object, :child_index => \"new_#{ fields_partial }\", :onsubmit => \"return $(this.)validate();\") do |builder|\n render(fields_partial, :f => builder)\n #render(association.to_s.singularize + \"_fields\", :f => builder)\n end\n #link_to_function(name, \"add_fields(this, \\\"#{ association }\\\", \\\"#{ escape_javascript(fields) }\\\")\", options)\n link_to_function(name, \"add_fields(this, \\\"#{ fields_partial }\\\", \\\"#{ modal }\\\", \\\"#{ escape_javascript(fields) }\\\", \\\"#{ sel2NoMatch }\\\")\", options)\n end",
"def fields_on_form() #:nodoc:\r\n fields = []\r\n if @form['form']['fields']\r\n# read only field elements (key is Fixnum)\r\n @form['form']['fields'].each {|key,options| fields << options if key.class == Fixnum }\r\n else\r\n @form['form']['tabs'].keys.each do |tab|\r\n @form['form']['tabs'][tab].each {|key,options| fields << options if key.class == Fixnum }\r\n end \r\n end\r\n fields\r\nend",
"def pe_many_collection_details(details, form)\n details.each_with_index do |detail_to_ids,idx|\n detail = detail_to_ids[0]\n detail_name_plural ||= detail.class.to_s.tableize\n detail_name ||= detail_name_plural.singularize\n if detail.person.user == current_user\n form.fields_for \"#{detail_name_plural}_attributes[]\", detail,\n :index => \"new_#{idx}\" do |form_detail|\n concat(render(:partial => 'people/'+detail_name, :object => form_detail))\n end\n else\n concat(self.send('p_'+detail_name, detail))\n end\n end\n end",
"def add_fields_link(name, f, association)\n if (name == nil or name == \"\" or f == nil or association == nil or association == \"\")\n return false\n end\n \n new_object = f.object.send(association).klass.new\n id = new_object.object_id\n metarows = f.fields_for(association, new_object, child_index: id) do |builder|\n render(association.to_s.singularize + \"_fields\", f: builder)\n end\n link_to(name, '#', class: \"add_fields btn btn-primary\", data: {id: id, metarows: metarows.gsub(\"\\n\", \"\")})\n \n #return true #gets displayed in view\n end",
"def show\n @vig= Vig.find(params[:vig_id])\n @member = @vig.member\n\n @formulario = Form.new( name: \"Javier\" )\n @test.questions.each do |q|\n case q.type\n when 'section'\n @input = @formulario.members.build type: 'section', name: q.content\n q.questions.each do |question|\n if question.type == 'check'\n @answer = @input.answers.build( type: 'checkbox', content: question.content, id_question: question.id )\n question.options_answers.each do |opt|\n @answer.answers << Answer.new(vig_id: @vig.id , type: 'radio', question: question, option: opt )\n end\n else\n @input.answers << Answer.new( note: nil, question: question, type: 'text_field' )\n end\n end\n when 'text', 'textarea'\n @input = @formulario.members.build type: 'text_field', name: q.content\n @input.answers << Answer.new( note: nil, question: q )\n when 'check'\n\n @input = @formulario.members.build type: 'checkbox', name: q.content, id_question:q.id\n q.options_answers.each do |question|\n @input.answers << Answer.new(vig_id: @vig.id , type: 'checkbox', question: q, option: question )\n end\n when 'nested'\n puts \"NESTED\"\n # create the input member\n @input = @formulario.members.build type: 'nested', name: q.content\n \n # create nested member\n q.questions.each do |question|\n member = @input.inputs.build( type:question.type, name:question.content, id_question: question.id )\n if member.type == 'section'\n question.questions.each do |a|\n member.answers << Answer.new( note: nil, question: question )\n end\n else \n question.options_answers.each do |opt|\n member.answers << Answer.new( vig_id: @vig.id, type:'radio', question:question, option: opt )\n end\n end\n end\n\n # added opt answers\n q.options_answers.each do |opt|\n @input.answers << Answer.new(vig_id: @vig.id , type: 'checkbox', question: q, option: opt )\n end\n else\n #puts @input.name\n end\n end\n\n #@questions= @test.questions\n #@answers = Array.new(@questions.count){Answer.new}\n #\n end",
"def lm_fields_for(name, *args, &block)\n raise ArgumentError, \"Missing block\" unless block_given?\n options = args.last.is_a?(Hash) ? args.pop : {}\n options = options.merge(:builder => LMFormBuilder)\n object = args.first\n yield((options[:builder] || FormBuilder).new(name, object, self, options, block))\n end",
"def build_line_form(line,action,caption,is_edit = nil)\n\n field_configs = Array.new\n\tfield_configs[0] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'line_code'}\n\n\tfield_configs[1] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'line_phc'}\n\n field_configs[field_configs.length()] = {:field_type=>'CheckBox', :field_name=>'is_dedicated'}\n\n\n build_form(line,field_configs,action,'line',caption,is_edit)\n\n\n end",
"def link_to_add_fields(name, f, association)\n new_object = f.object.send(association).klass.new\n id = new_object.object_id\n fields = f.fields_for(association, new_object, child_index: id) do |builder|\n render(association.to_s.singularize + \"_partial\", f: builder)\n end\n link_to(name, '#', class: \"add_fields\", data: {id: id, fields: fields.gsub(\"\\n\", \"\")})\n end",
"def link_to_add_fields(name, f, association, parent_container_query)\n new_object = f.object.class.reflect_on_association(association).klass.new\n fields = f.fields_for(association, new_object, :child_index => \"new_#{association}\") do |builder|\n render(association.to_s.singularize + \"_fields\", :f => builder)\n end\n link_to_function(name, \"add_fields(\\\"#{parent_container_query}\\\", \\\"#{association}\\\", \\\"#{escape_javascript(fields)}\\\")\")\n end",
"def fields\n @fields ||= form.fields\n end",
"def new\n\t\t@form = @client.forms.new\n\n \n 3.times do\n procedure = @form.procedures.build\n end\n 3.times do\n authemp = @form.authemps.build\n end\n\n\t\trespond_to do |format|\n \t\tformat.html # show.html.erb\n \t\tformat.json { render json: @form }\n \t\tend\n\tend",
"def inline_mtm_edit_forms(obj)\n assocs = model.inline_mtm_assocs(request)\n return if assocs.empty?\n\n t = String.new\n t << \"<div class='inline_mtm_add_associations'>\"\n assocs.each do |assoc|\n form_attr = form_attributes(:action=>url_for(\"mtm_update/#{model.primary_key_value(obj)}?association=#{assoc}&redir=edit\"), :class => 'mtm_add_associations', 'data-remove' => \"##{assoc}_remove_list\")\n t << Forme.form(obj, form_attr, form_opts(form_attr[:action])) do |f|\n opts = model.column_options_for(:mtm_edit, request, assoc)\n add_opts = opts[:add] ? opts.merge(opts.delete(:add)) : opts.dup\n add_opts = {:name=>'add[]', :id=>\"add_#{assoc}\"}.merge!(add_opts)\n if model.association_autocomplete?(assoc, request)\n f.input(assoc, {:type=>'text', :class=>'autoforme_autocomplete', :attr=>{'data-type'=>'association', 'data-column'=>assoc, 'data-exclude'=>model.primary_key_value(obj)}, :value=>''}.merge!(add_opts))\n else\n f.input(assoc, {:dataset=>model.unassociated_mtm_objects(request, assoc, obj), :multiple=>false, :add_blank=>true}.merge!(add_opts))\n end\n f.button(:value=>'Add', :class=>'btn btn-xs btn-primary')\n end\n end\n t << \"</div>\"\n t << \"<div class='inline_mtm_remove_associations'><ul>\"\n assocs.each do |assoc|\n mc = model.associated_model_class(assoc)\n t << \"<li>\"\n t << association_class_link(mc, assoc)\n t << \"<ul id='#{assoc}_remove_list'>\"\n obj.send(assoc).each do |assoc_obj|\n t << mtm_edit_remove(assoc, mc, obj, assoc_obj)\n end\n t << \"</ul></li>\"\n end\n t << \"</ul></div>\"\n end",
"def new\n @document_fedora = load_document_from_id(params[:asset_id])\n @datastream_name = params[:datastream_name]\n @fields = params[:fields]\n @field_label = params[:field_label]\n\n @next_field_index = eval '@document_fedora.datastreams[@datastream_name].find_by_terms(' + @fields + ').length'\n @content_type = params[:content_type]\n \n respond_to do |format|\n format.html { render :file=>\"multi_field/new.html\", :layout=>true}\n format.inline { render :partial=>\"multi_field/new.html\", :layout=>false }\n end\n end",
"def form_node; end",
"def layout_fields\n # Everything has a tag - or it BETTER!\n # Probably should refactor this or something.\n value = @stored_values[:tag] || @object.tag\n label = Label.new(\"Tag\")\n tagInput = InputField.new(value,30)\n @attr_to_field[:tag] = tagInput\n layout_field_button(label,tagInput,\"Auto\") do\n attemptName = nil\n if @attr_to_field[:name]\n attemptName = @attr_to_field[:name].text\n end\n tagInput.text = @rl.repository.generate_tag_for(@object,attemptName)\n end\n @fieldY = tagInput.rect.bottom + @spacing \n @object.class.attrs.sort.each do | attr |\n next if attr == :tag # We did tags ourselves\n display = true\n value = @stored_values[attr] || @object.send(attr)\n label = Label.new(attr.to_s)\n rows,cols = [0,0]\n size= @object.class.size_for(attr)\n input = nil\n if size\n rows,cols = size\n if rows > 1\n input = MultiLineInput.new(value)\n input.set_size(rows,cols)\n elsif rows == 0 || cols == 0\n display = false\n else\n input = InputField.new(value, cols)\n end\n else\n input = InputField.new(value,20)\n end \n \n if display\n if rows > 1\n scroller = Scroller.new(input)\n scroller.translate_to(*input.rect.topleft)\n layout_field(label,scroller)\n else\n layout_field(label,input)\n end\n @attr_to_field[attr] = input\n end\n check_max_button(attr,input) if input\n end\n \n # Booleans\n @object.class.booleans.each do | attr |\n value = @stored_values[attr] || @object.send(attr)\n checkbox = CheckBox.new(attr.to_s,value)\n checkbox.rect.topleft = [ @fieldX, @fieldY ] \n \n @fieldY = checkbox.rect.bottom + @spacing\n \n self << checkbox\n @bool_to_field[attr] = checkbox\n end\n \n # And now for the enums!\n @object.class.enumerations.each do | attr, valid |\n value = @stored_values[attr] || @object.send(attr)\n label = Label.new(attr.to_s)\n \n size = @object.class.size_for(attr)\n label.rect.topleft = [@fieldX, @fieldY]\n rows = size || valid.size\n \n input = ListBox.new\n input.rect.w = @mainRect.w / 2 - label.rect.w - @spacing * 3\n input.rect.h = input.height(rows)\n input.items = valid\n input.chosen = value\n \n input.translate_to(label.rect.right + @spacing, @fieldY)\n \n @fieldY = input.rect.bottom + @spacing\n self << label\n self << input\n @enum_to_field[attr] = input\n \n end\n end",
"def link_to_add_fields(name, form, association, this = nil)\n new_object = form.object.send(association).klass.new\n id = new_object.object_id\n\n fields = form.fields_for(association, new_object, child_index: id) do |builder|\n render(\"admin/partials/\" + association.to_s.singularize + \"_fields\", f: builder, resource: this)\n end\n\n link_to(name, \"#\", class: \"add-fields\", data: { id: id, fields: fields.gsub(\"\\n\", \"\")})\n end",
"def forms_fields(form, action)\n section_fields = []\n form.form_sections.each do |section|\n if section['permissions'][\"#{current_user.role.short_name}\"][action] == '1'\n section_fields << section.section_fields.map do |field|\n if field.field_type.field_type.start_with?('select') && field.field_type.options['multivalue'] == '1'\n { field.id.to_s.to_sym => [] }\n else\n field.id.to_s.to_sym\n end\n end\n end\n end\n section_fields\n end",
"def link_to_add_fields(name, f, association)\n new_object = f.object.send(association).klass.new\n id = new_object.object_id\n fields = f.fields_for(association, new_object, child_index: id) do |builder|\n render(association.to_s.singularize + \"_fields\", f: builder)\n end\n link_to(name, '#', class: \"add_fields\", data: { id: id, fields: fields.gsub(\"\\n\", \"\") })\n end",
"def get_field_edit_rtpl\n (!@multiple.nil? && @multiple != '') ? multiple = @multiple : multiple = ''\n\n select_str = '<select id=\"' + @id + '\" name=\"' + @name + '\" ' + multiple + '>'\n select_str << @option_str\n select_str << '</select>'\n\n select_str\n end",
"def link_to_add_fields(name, f, association)\n new_object = f.object.class.reflect_on_association(association).klass.new\n fields = f.fields_for(association, new_object, :child_index => \"new_#{association}\") do |builder|\n render(association.to_s.singularize + \"_fields\", :f => builder)\n end\n link_to_function(name, \"add_fields(this, \\\"#{association}\\\", \\\"#{escape_javascript(fields)}\\\")\")\n end",
"def link_to_add_fields(name, f, association)\n new_object = f.object.class.reflect_on_association(association).klass.new\n fields = f.fields_for(association, new_object, :child_index => \"new_#{association}\") do |builder|\n render(association.to_s.singularize + \"_fields\", :f => builder)\n end\n link_to_function(name, \"add_fields(this, \\\"#{association}\\\", \\\"#{escape_javascript(fields)}\\\")\")\n end",
"def form; end",
"def set_subfields\n subfield = Struct.new(:code, :text)\n subfield_list = []\n @subfield_info.keys.sort.each { |k|\n code = @subfield_info[k][:code]\n value = @subfield_info[k][:value]\n subfield_list << subfield.new(code,value)\n }\n subfield_list\n end",
"def form_fields\n [:description, :status, :magic]\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end",
"def set_Fields(value)\n set_input(\"Fields\", value)\n end"
] | [
"0.7029286",
"0.6964953",
"0.69032335",
"0.65125805",
"0.645006",
"0.64157134",
"0.634944",
"0.634421",
"0.62955743",
"0.6256891",
"0.62413335",
"0.62315226",
"0.6226325",
"0.6188444",
"0.6176591",
"0.6129178",
"0.6046312",
"0.6026328",
"0.60059804",
"0.60059804",
"0.5994267",
"0.59762406",
"0.5975738",
"0.5970371",
"0.5955844",
"0.59392464",
"0.5934896",
"0.59283847",
"0.5900639",
"0.58824766",
"0.5881296",
"0.58677727",
"0.5865929",
"0.5862599",
"0.58431804",
"0.5836952",
"0.5831465",
"0.5806811",
"0.58061916",
"0.5791782",
"0.5788135",
"0.5788135",
"0.578039",
"0.57687366",
"0.5766329",
"0.5749849",
"0.57485497",
"0.57433075",
"0.5736347",
"0.5722463",
"0.571568",
"0.57148653",
"0.5714196",
"0.5712953",
"0.57093626",
"0.5705562",
"0.5705312",
"0.5698576",
"0.56983",
"0.56933403",
"0.56926996",
"0.56903493",
"0.56903493",
"0.5687705",
"0.56786877",
"0.5676915",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686",
"0.5666686"
] | 0.0 | -1 |
returns a chromosome object | def chromosome(id=nil)
return if id.nil?
begin
self.chromosomes[id.intern]
rescue
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chromosome_group\n chromosome[0]\n end",
"def chromosomes\n # Cache for performance\n if @chromosomes.nil?\n s = Set.new\n self.each { |entry| s << entry.chr }\n @chromosomes = s.to_a\n end\n \n return @chromosomes\n end",
"def new_rand_chrom\n @genes.replace @genes.sort_by { rand }\n c = Chromosome.new\n @genes.each do |gene|\n c << gene.copy\n end\n c\n end",
"def copy\n c = Chromosome.new(0.0, @fitness_alg)\n genes.each do |gene|\n c << gene #push_back arreglo\n end\n c\n end",
"def chromosomes\n @index.collect { |contig_info| contig_info.chr }.uniq\n end",
"def chrom\n @data[:chrom]\n end",
"def add chromosome\n\t\t@arrayChromosomes << chromosome\n\tend",
"def best_chromosome()\n the_best = @population[0]\n @population.each do |chromosome|\n the_best = chromosome if chromosome.fitness > the_best.fitness\n end\n return the_best\n end",
"def hit_to; @genomic.to; end",
"def best_chromosome\n the_best = @population[0]\n @population.each do |chromosome|\n the_best = chromosome if chromosome.fitness > the_best.fitness\n end\n return the_best\n end",
"def init_chromosomes(pop_size, macro_cromosomes)\n (0...pop_size).each do |j|\n chromo = Chromosome.new\n each do |gene|\n chromo << macro_cromosomes[j][gene]\n end\n @chromosomes << chromo\n end\n @best_chromosomes_experiences = @chromosomes.clone\n end",
"def mutate(chromosome)\n gene_pos = (0...@num_genes).to_a.sample\n gene = chromosome[gene_pos]\n gene = gene.zero? ? 1 : 0\n chromosome[gene_pos] = gene\n chromosome\n end",
"def hit_from; @genomic.from; end",
"def to_s\n \"#{@chrom}:#{@chr_start}-#{@chr_end}\"\n end",
"def generate_optimal_chromosome(chromosome_x, chromosome_y)\n optimal_chromosome = Chromosome.new\n experiment_matrix = generate_experiment_matrix chromosome_x, chromosome_y\n # Calculate SNR values\n experiment_matrix.each_index do |i|\n calculate_snr experiment_matrix[i]\n end\n # Calculate the effects of the various factors\n (0...experiment_matrix[0].size).each do |j|\n sum_lvl_1 = 0.0\n sum_lvl_2 = 0.0\n (0...experiment_matrix.size).each do |i|\n if @taguchi_array[i][j] == 1\n sum_lvl_2 += experiment_matrix[i].snr\n else\n sum_lvl_1 += experiment_matrix[i].snr\n end\n end\n optimal_chromosome <<\n if sum_lvl_1 > sum_lvl_2\n chromosome_x[j]\n else\n chromosome_y[j]\n end\n end\n # Find the optimal fitness value\n evaluate_chromosome optimal_chromosome\n # Return the optimal chromosome\n optimal_chromosome\n end",
"def hit_strand; @genomic.strand; end",
"def mutate\n index = (rand * length).floor\n genes[index] = Chromosome.rand_hex\n end",
"def pep2genomic(pos)\n raise NotImplementedError\n end",
"def genomic\n unless defined?(@genomic)\n @genomic = SeqDesc.parse(@d0.find { |x| /^Genomic\\:/ =~ x })\n end\n @genomic\n end",
"def reproduce_with(other)\n c = Chromosome.new\n self.length.times do |i|\n c << ((rand > 0.5) ? self[i] : other[i])\n end\n c\n end",
"def init_population\n (0...@pop_size).each do\n chromosome = Chromosome.new\n (0...@num_genes).each do |i|\n if @beta_values == 'discrete'\n beta = rand(0..10) / 10.0\n elsif @beta_values == 'uniform distribution'\n beta = rand(0.0..1.0)\n end\n gene = @lower_bounds[i] + beta * (@upper_bounds[i] -\n @lower_bounds[i])\n # Wrong for discrete functions\n chromosome << (@continuous ? gene : gene.floor)\n end\n evaluate_chromosome chromosome\n @chromosomes << chromosome\n end\n end",
"def init_population\n (0...@pop_size).each do\n chromosome = Chromosome.new\n (0...@num_genes).each do |_i|\n gene = rand 0..1\n chromosome << gene\n end\n evaluate_chromosome chromosome\n @chromosomes << chromosome\n end\n end",
"def reproduce(chrmsm,chrmsm1, mutation)\n mask_conf = Configuration.new(@problem)\n @mask = mask_conf.conf\n child1_attrs = Array.new\n child2_attrs = Array.new\n for i in 0..@mask.size - 1\n if @mask[i] == 1\n child1_attrs.push(chrmsm.configuration.conf[i])\n child2_attrs.push(chrmsm1.configuration.conf[i])\n else\n child1_attrs.push(chrmsm1.configuration.conf[i])\n child2_attrs.push(chrmsm.configuration.conf[i])\n end\n end\n \n mutation.mutate(child1_attrs)\n mutation.mutate(child2_attrs)\n \n children=Array.new\n children.push(Chromosome.new(Configuration.new(child1_attrs, @problem)))\n children.push(Chromosome.new(Configuration.new(child2_attrs, @problem)))\n return children\n\n end",
"def copy\n Gene.new(@city, @lat, @lon)\n end",
"def chromosome_to_cyle(chromosome)\n <<-DOC\n ChromosomeToCycle(Chromosome)\n for j ← 1 to |Chromosome|\n i ← Chromosomej\n if i > 0\n Node(2j−1) ←2i−1\n Node(2j) ← 2i\n else\n Node(2j−1) ← -2i\n Node(2j) ← -2i−1\n return Nodes \n DOC\n\n node = []\n chromosome.each_index do |j|\n i = chromosome[j]\n j += 1 # For j = 0 we will have -ve index for node[]\n if i > 0\n node[2*j-1] = 2*i -1\n node[2*j] = 2*i\n else\n node[2*j-1] = -2*i\n node[2*j] = -2*i - 1\n end\n end\n node.shift # Lets remove the 0'th element in node array as it will always contain a null\n # Because we are starting at j = 1 and we we will always start filling up nodes 2*1 -1 and 2*1 and we never would've \n # used index 0 in node\n return node\n end",
"def hseq; @genomic.seq; end",
"def mutate(chromosome)\n beta = rand(0..10) / 10.0\n i = -1\n k = -1\n loop do\n i = rand(0...chromosome.size)\n k = rand(0...chromosome.size)\n break if i != k\n end\n gene_i = chromosome[i]\n gene_k = chromosome[k]\n if @continuous # Doesn't work for discrete functions\n chromosome[i] = (1 - beta) * gene_i + beta * gene_k\n chromosome[k] = beta * gene_i + (1 - beta) * gene_k\n else\n chromosome[i] = ((1 - beta) * gene_i + beta * gene_k).floor\n chromosome[k] = (beta * gene_i + (1 - beta) * gene_k).floor\n end\n chromosome\n end",
"def cds2genomic(pos)\n return self.cdna2genomic(pos + self.coding_region_cdna_start)\n end",
"def cycle_to_chromosome(nodes)\n <<-DOC\n CycleToChromosome(Nodes)\n for j ← 1 to |Nodes|/2\n if Node2j−1 < Node2j\n Chromosomej ← Node[2j] /2\n else\n Chromosomej ← −Node[2j−1]/2\n return Chromosome\n DOC\n chromosome = []\n\n (1..(nodes.length/2)).each do |j|\n val_2j_1 = 2*j-1 -1 \n val_2j = 2*j -1\n # puts val_2j_1\n # puts val_2j\n if nodes[val_2j_1] < nodes[val_2j]\n chromosome[j-1] = nodes[val_2j]/2\n else\n chromosome[j-1] = -nodes[val_2j_1]/2\n end\n end\n\n return chromosome\n end",
"def mutation(chromosome)\n # change one of the genoms randomly\n mutate_index = rand(chromosome.size)\n chromosome[mutate_index] = (1..chromosome[mutate_index].size).inject(\"\") do |new_gene, i|\n new_gene << rand(2).to_s\n end \n chromosome\n end",
"def init_population\n (0...@pop_size).each do\n chromosome = Chromosome.new\n (0...@num_genes).each do\n gene = rand 0..1\n chromosome << gene\n end\n evaluate_chromosome chromosome\n compare_func = @is_high_fit ? :> : :<\n if @best_fit.nil? ||\n chromosome.fitness.public_send(compare_func, @best_fit)\n @best_fit = chromosome.fitness\n end\n @chromosomes << chromosome\n end\n end",
"def chromatic_index(note)\n CHROMATICS[note.match(/^[A-G][#b]?/).to_s]\n end",
"def ref_chr_range(genome_range)\n chr_index = @seqs[0].index{|chr| chr[:end] > genome_range[0] }\n chr_index ||= @seqs[0].size - 1\n chr_start = chr_index > 0 ? @seqs[0][chr_index - 1][:end] : 1\n chr_size = @seqs[0][chr_index][:end] - chr_start\n [@seqs[0][chr_index][:name], [genome_range[0] - chr_start, 0].max, [genome_range[1] - chr_start, chr_size].min]\n end",
"def [](chr_id, &block)\n chr(chr_id, &block)\n end",
"def chr_contigs(query_chr)\n result = @index.select { |contig_info| contig_info.chr == query_chr }\n raise WigError, \"Wig does not include data for chromosome #{query_chr}\" unless result.length > 0\n return result\n end",
"def get_piece(pos)\n @grid[pos[0]][pos[1]]\n end",
"def companion\n companion = Probe.new\n companion.sequence_index = @sequence_index\n companion.side = @side == :start ? :end : :start\n return companion\n end",
"def seq\n \t# If we already accessed the sequence, we can just\n \t# call the instance variable. Otherwise, we'll have\n # to get the sequence first and create a Bio::Sequence::NA\n \t# object.\n if @seq.nil?\n # First check if the slice is on the seqlevel coordinate\n \t # system, otherwise project coordinates.\n if ! Ensembl::SESSION.seqlevel_id.nil? and self.seq_region.coord_system_id == Ensembl::SESSION.seqlevel_id\n @seq = Bio::Sequence::NA.new(self.seq_region.subseq(self.start, self.stop))\n else # we have to project coordinates\n seq_string = String.new\n \t @target_slices = self.project('seqlevel')\n @target_slices.each do |component|\n if component.class == Slice\n seq_string += component.seq # This fetches the seq recursively\n else # it's a Gap\n seq_string += 'N' * (component.length)\n end\n end\n \t @seq = Bio::Sequence::NA.new(seq_string)\n\n end\n\n if self.strand == -1\n \t @seq.reverse_complement!\n end\n\n end\n \treturn @seq\n\n end",
"def breed(chrom_a, chrom_b)\n len = chrom_a.chromosome.length\n x_i = [*0..len].sample\n head = chrom_a.chromosome.slice(0,x_i)\n tail = chrom_b.chromosome.slice(x_i,len)\n return chrom_a.class.new((head << tail).flatten)\n end",
"def seq\r\n \t# If we already accessed the sequence, we can just\r\n \t# call the instance variable. Otherwise, we'll have\r\n # to get the sequence first and create a Bio::Sequence::NA\r\n \t# object.\r\n if @seq.nil?\r\n # First check if the slice is on the seqlevel coordinate\r\n \t # system, otherwise project coordinates.\r\n if self.seq_region.coord_system.seqlevel?\r\n @seq = Bio::Sequence::NA.new(self.seq_region.subseq(self.start, self.stop))\r\n else # we have to project coordinates\r\n seq_string = String.new\r\n \t @target_slices = self.project('seqlevel')\r\n\r\n @target_slices.each do |component|\r\n if component.class == Slice\r\n seq_string += component.seq # This fetches the seq recursively (see 10 lines up)\r\n else # it's a Gap\r\n seq_string += 'N' * (component.length)\r\n end\r\n\r\n end\r\n \t @seq = Bio::Sequence::NA.new(seq_string)\r\n\r\n end\r\n\r\n if self.strand == -1\r\n \t @seq.reverse_complement!\r\n end\r\n\r\n end\r\n \treturn @seq\r\n\r\n end",
"def get_object\n next_x = @cur_x + DIRECTION[@hero_direction][0]\n next_y = @cur_y + DIRECTION[@hero_direction][1]\n return if next_x < 0 || next_x > 14 || next_y < 0 || next_y > 14\n #look at new square in room\n next_square = @room[next_x][next_y]\n if next_square == CHAR_POTION || next_square == CHAR_CHEST || next_square == CHAR_IDOL\n @room[next_x][next_y] = CHAR_FLOOR\n draw_map(next_x,next_y)\n @potions += 1 if next_square == CHAR_POTION\n @treasure += 1 if next_square == CHAR_CHEST\n @idol_found = true if next_square == CHAR_IDOL\n @stats[:experience] += 0.25\n end\n end",
"def fit ind; ind.chromosome.inject(0,:+); end",
"def find_start_base(chr, chr_length)\n # Start at the first base pair and look forwards\n bp = 1\n while bp <= chr_length\n start = bp\n stop = [start+CHUNK_SIZE-1, chr_length].min\n num_values = stop - start + 1\n begin\n result = UCSC.bigwig_summary(@data_file, chr, start, stop, num_values, 'coverage')\n return start + result.find_index('1')\n rescue UCSC::ToolsError\n end\n \n bp += CHUNK_SIZE\n end\n \n raise WigError, \"Could not find start base pair in BigWig file #{File.basename(@data_file)} for chromosome #{chr}\"\n end",
"def new_generation(population)\n population_size = population.size\n\n # check correct population size\n # TODO: disable this check in non-debugging mode\n raise ArgumentError, 'Population size error!' if population_size != @population_size\n\n # prepare children\n children = []\n\n # select members to reproduce through binary tournament\n selected = Array.new(@population_size) { |i| binary_tournament(population) }\n selected.shuffle!\n\n # reproduction\n selected.each_slice(2) do |p1, p2|\n # get two new samples...\n c1, c2 = @genotype_space.reproduce_from(p1, p2, @mutation_rv, @recombination_rv)\n\n # ...and add them to the children population\n children.push(c1, c2)\n\n # check correct population size\n # TODO: disable this check in non-debugging mode\n raise 'Children size error!' if children.size > population_size\n end\n\n return children\n end",
"def clone\n Chord::new self.to_hash\n end",
"def build_character(genome, name, surname=NEW_LINEAGE_SURNAME)\n Character.new(genome,\n @build_factory.build(genome.build_choices).stats,\n name,\n surname)\n end",
"def getSeq\n bioSeq = @gbkObj.to_biosequence\n sequence = Bio::Sequence.new(bioSeq)\n puts sequence.output_fasta(\"#{bioSeq.accessions[0]}\",60)\n end",
"def coverage\n if Experiment.find(params[:id]).uses_bam_file #return a pileup from samtools...\n\n else #return a position keyed hash of Positions objects\n features = Feature.find_in_range(params[:reference_id], params[:start], params[:end], params[:id])\n sequence = Reference.find(params[:reference_id]).sequence.sequence[params[:start].to_i - 1, (params[:end].to_i - params[:start].to_i)]\n positions = SimpleDepth.new(params[:start], params[:end], sequence, features)\n #comp_hash = {'A' => 'T', 'T' => 'A', 'G' => 'C', 'C' => 'G', 'N' => 'N'}\n #positions = Hash.new {|h,k| h[k] = {\n # '+' => {\n # 'A' => 0,\n # 'T' => 0,\n # 'G' => 0,\n # 'C' => 0,\n # 'N' => 0,\n # 'strand_total' => 0\n # },\n # '-' => {\n # 'A' => 0,\n # 'T' => 0,\n # 'G' => 0,\n # 'C' => 0,\n # 'N' => 0,\n # 'strand_total' => 0\n # },\n # 'position_total' => 0\n # }\n #}\n #positions['region_total'] = 0\n #positions['1'] = 1\n #features = Feature.find_in_range_no_overlap(params[:reference_id],params[:start],params[:end],params[:id])\n #features.each do |f|\n # if (f.sequence.match(/\\w/))\n # (f.start .. f.end - 1).each_with_index do |i, idx|\n # positions[i][f.strand][f.sequence[idx,1]] += 1\n # positions[i][f.strand]['strand_total'] += 1\n # positions[i]['position_total'] += 1\n # positions['region_total'] += 1\n # end\n # end\n end\n respond(positions)\n end",
"def build_chromosome_xml( query, filename )\n \n documents = {}\n \n # KOMP-DCC Biomart\n dcc_mart = Biomart.new(\n :url => \"http://htgt.internal.sanger.ac.uk:9002/dev/martsearch/htgtdev/biomart/martservice\",\n :http => @@http_agent,\n :dataset => \"dcc\",\n :attributes => [\n \"marker_symbol\",\n \"mgi_accession_id\",\n \"chromosome\",\n \"coord_start\",\n \"coord_end\",\n \"strand\",\n \"marker_type\",\n \"marker_names\",\n \"synonyms\",\n \"ensembl_gene_ids\",\n \"vega_gene_ids\",\n \"entrez_gene_ids\",\n \"ccds_ids\",\n \"omim_ids\",\n \"expired_marker_names\",\n \"expired_synonyms\",\n \"expired_ensembl_gene_ids\",\n \"expired_vega_gene_ids\",\n \"expired_entrez_gene_ids\",\n \"expired_ccds_ids\",\n \"expired_omim_ids\"\n ]\n )\n #dcc_data = dcc_mart.search( [\"chromosome\"], query )\n \n # Read in our temporarily hacked gene file, extract the gene info \n # for this chromosome, and proceed as normal...\n chr_data = ''\n file = File.open( 'genes.txt', 'r' ) do |file|\n while line = file.gets\n data_elements = line.split(\"\\t\")\n if data_elements[2] == query\n chr_data.insert( chr_data.length, line )\n end\n end\n end\n\n dcc_data = dcc_mart.tsv2array( chr_data )\n \n dcc_data.each { |data|\n document = documents[ data['marker_symbol'] ]\n\n if document == nil\n document = Document.new( data['marker_symbol'] )\n end\n\n # Put in the singular data...\n document.mgi_accession_id = data['mgi_accession_id']\n document.type = data['marker_type']\n document.chromosome = data['chromosome']\n document.coord_start = data['coord_start']\n document.coord_end = data['coord_end']\n document.strand = data['strand']\n\n # Now the multi-valued data...\n add_to_multivalued_field( data['marker_names'], document.marker_names, '; ' )\n add_to_multivalued_field( data['synonyms'], document.synonyms, ', ' )\n add_to_multivalued_field( data['ensembl_gene_ids'], document.ensembl_gene_ids, ',' )\n add_to_multivalued_field( data['vega_gene_ids'], document.vega_gene_ids, ',' )\n add_to_multivalued_field( data['entrez_gene_ids'], document.entrez_gene_ids, ',' )\n add_to_multivalued_field( data['ccds_ids'], document.ccds_ids, ',' )\n add_to_multivalued_field( data['omim_ids'], document.omim_ids, ',' )\n add_to_multivalued_field( data['expired_marker_names'], document.marker_names, '; ' )\n add_to_multivalued_field( data['expired_synonyms'], document.synonyms, ', ' )\n add_to_multivalued_field( data['expired_ensembl_gene_ids'], document.ensembl_gene_ids, ',' )\n add_to_multivalued_field( data['expired_vega_gene_ids'], document.vega_gene_ids, ',' )\n add_to_multivalued_field( data['expired_entrez_gene_ids'], document.entrez_gene_ids, ',' )\n add_to_multivalued_field( data['expired_ccds_ids'], document.ccds_ids, ',' )\n add_to_multivalued_field( data['expired_omim_ids'], document.omim_ids, ',' )\n \n documents[ data['marker_symbol'] ] = document\n }\n\n # Search the related marts for info...\n documents = search_product_marts( documents )\n\n output = \"<add>\\n\"\n documents.values.each { |doc|\n if doc.marker_symbol\n output += doc.xml\n end\n }\n output += \"</add>\\n\"\n\n File.open( filename, 'w' ) { |f| f.write(output) }\n\nend",
"def chin\n @chin ||= Chin.new self[:CHIN_LEFT_GONION],\n self[:CHIN_GNATHION],\n self[:CHIN_RIGHT_GONION]\n end",
"def select_next_generation\n if @is_high_fit\n # sort in decreasing order by fitness values\n @chromosomes.sort! do |left_chrom, right_chrom|\n right_chrom.fitness <=> left_chrom.fitness\n end\n else\n # sort in increasing order of fitness values\n @chromosomes.sort! do |left_chrom, right_chrom|\n left_chrom.fitness <=> right_chrom.fitness\n end\n end\n @chromosomes.slice!(@pop_size..@chromosomes.size)\n end",
"def to_a\n @poss\n end",
"def divs\n Div.where(\"chromosome = ? and position between ? and ?\",\n chromosome, start, stop)\n .order(\"position ASC\")\n end",
"def eql?(chrom)\n self == chrom\n end",
"def create_biosequence_from_feature(feature,rich_sequence_object, protein = false)\n location_string = location_string_from_feature(feature)\n cds_sequence = rich_sequence_object.seq.splice(location_string)\n cds_sequence = cds_sequence.translate(1,11) if protein\n query_sequence = Bio::Sequence.new(cds_sequence.to_s)\nend",
"def to_gpos\n Point[ self.x, self.y ]\n end",
"def new_generation\n # Incrementiamo il contatore di generazioni, per motivi di\n # studio e statistica, e poi generiamo una roulette propor-\n # zionale al fitness. \n # NOTA: non si può chiamare new_generation se non è stato\n # prima eseguito un test sul fitness.\n @current_generation += 1\n roulette = Roulette.new(@fitness_pool)\n \n # Ottenuta la roulette possiamo farla girare in modo da\n # estrarre coppie di cromosomi da riprodurre\n # Il loop viene eseguito popolazione / 2 volte perché ogni\n # accoppiamento produce due figli.\n # Esistono versioni alternative che da ogni accoppiamento\n # fanno nascere un solo figlio. \n new_population = []\n (@population.size / 2).times do\n mother = @population[roulette.extract]\n father = @population[roulette.extract]\n \n # Inseriamo i figli nella nuova popolazione\n Chromosome.mated_pair(mother, father).each do |chromosome|\n new_population << chromosome\n end\n end\n \n # Il vecchio lascia il posto al nuovo - è la legge della vita\n @population = new_population\n end",
"def room\n return Cave.roomInstance(@@currentRoom-1)\n end",
"def seq\n seq_region = nil\n if Ensembl::SESSION.seq_regions.has_key?(self.seq_region_id)\n seq_region = Ensembl::SESSION.seq_regions[self.seq_region_id]\n else\n seq_region = self.seq_region\n Ensembl::SESSION.seq_regions[seq_region.id] = seq_region\n end\n \tslice = Ensembl::Core::Slice.new(seq_region, seq_region_start, seq_region_end, seq_region_strand)\n return slice.seq\n end",
"def random_genome\n genome = \"\"\n (1..50).each do |i|\n genome += genome_map[rand(26)]\n end\n genome\n end",
"def sample_genome()\r\n\t\t# Randomly select an individual until it is accepted.\r\n\t\t# Individuals are accepted with a probability equal to\r\n\t\t# their fitness divided by the maximum fitness of the population.\r\n\t\tx = @population.sample\r\n\r\n\t\t# In the highly unlikely event that an entire generation goes by\r\n\t\t# without a single agent increasing its fitness from zero, we will\r\n\t\t# divide by 1.\r\n\t\tuntil rand(0..1) <= (x.fitness / (@best_fitness.zero? ? 1 : @best_fitness))\r\n\t\t\tx = @population.sample\r\n\t\tend\r\n\t\tx\r\n\tend",
"def find_organism\n return self.dnafrag.genome_db\n end",
"def room\n @map[@row][@col]\nend",
"def slice(start=0,stop=self.length,strand=1) \n self.genome_db.connect_to_genome_new\n seq_region = Ensembl::Core::SeqRegion.find_by_name(self.name)\n return Ensembl::Core::Slice.new(seq_region, start, stop, strand) \n end",
"def randomize!(genecount = 10)\n genecount.times.each { self << Chromosome.rand_hex }\n self\n end",
"def get_chrom_as_string( seq_fn )\n\tcontigs = Array.new\n\tpieces = Array.new\n\tIO.foreach(seq_fn) do |line|\n\t\tunless line =~ /^>/\n\t\t\tpieces.push(line.chomp)\n\t\tend\n\tend\n\twhole_seq = pieces.join\n\treturn whole_seq\nend",
"def slice \n if self.source_name == \"ENSEMBLGENE\"\n self.connect_to_genome\n return Ensembl::Core::Slice.fetch_by_gene_stable_id(self.stable_id)\n else\n return nil\n end \n end",
"def hc(row,col)\n build :cell, row: row, col: col\n end",
"def genome_map\n @genome_map ||= %w(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)\n end",
"def cdna2genomic(pos)\n #FIXME: Still have to check for when pos is outside of scope of cDNA.\n # Identify the exon we're looking at.\n exon_with_target = self.exon_for_cdna_position(pos)\n \n accumulated_position = 0\n ex = self.exons.sort_by {|e| e.seq_region_start}\n ex.reverse! if self.strand == -1\n ex.each do |exon| \n if exon == exon_with_target\n length_to_be_taken_from_exon = pos - (accumulated_position + 1)\n if self.strand == -1\n return exon.seq_region_end - length_to_be_taken_from_exon\n else\n return exon.seq_region_start + length_to_be_taken_from_exon\n end\n else\n accumulated_position += exon.length \n end\n end\n end",
"def get_slice \n start = self.dnafrag_start\n stop = self.dnafrag_end\n strand = self.dnafrag_strand \n self.dnafrag.genome_db.connect_to_genome \n return Ensembl::Core::Slice.new(Ensembl::Core::SeqRegion.find_by_name(self.dnafrag.name), start, stop, strand) \n end",
"def initialize(pts)\n @genes = Array.new\n for i in 0...pts.length\n pair = pts.shift\n x = pair.shift\n y = pair.shift\n @genes << Gene.new(\"Node #{i}\", x, y)\n end\n end",
"def crossover(p0, p1)\n children = []\n if rand < @rate\n c0, c1 = Chromosome.new, Chromosome.new\n min = [p0.length, p1.length].min\n index = rand(min)\n for i in index...min\n c0 << p0[i].copy\n c1 << p1[i].copy\n end\n children << fill(c0, p1)\n children << fill(c1, p0)\n end\n children\n end",
"def cell( row, col )\n Cell.new( self, indices_to_address( row, col ) )\n end",
"def getc\n raise NotImplementedError\n end",
"def chromatic_at(index, key=nil)\n CHROMATICS.detect{|k, v| v == index && (!key || k.start_with?(key))}.try(:[], 0)\n end",
"def query(chr, start = nil, stop = nil, type = 'mean')\n # Don't query off the ends of chromosomes\n start = chr_start(chr) if start.nil?\n stop = chr_stop(chr) if stop.nil?\n raise WigError, \"BigWig does not contain data for the interval #{chr}:#{start}-#{stop}\" if not include?(chr, start, stop)\n\n \n # bigWigSummary segfaults if query is too big, so use nice, bite-sized chunks\n query_start = start\n contig = Genomics::Contig.new(chr)\n while query_start <= stop\n query_stop = [query_start+CHUNK_SIZE-1, stop].min\n num_values = query_stop - query_start + 1\n begin\n chunk = UCSC.bigwig_summary(@data_file, chr, query_start, query_stop, num_values, type)\n rescue UCSC::ToolsError\n raise WigError, \"BigWig does not contain data for the interval #{chr}:#{start}-#{stop}\"\n end\n \n # Store the chunk of values in the Contig\n chunk.each_with_index do |value,i|\n next if value == 'n/a' or value == 'NaN'\n contig.set(query_start+i, value.to_f)\n end\n \n query_start = query_stop + 1\n end\n \n return contig\n end",
"def from row, col\n rect(col, row)\n end",
"def first_chr(num2 = 1, num1 = 0)\n self[num2,num1]\n end",
"def get_gene(ensembl_version=55) \n if self.source_name == \"ENSEMBLGENE\"\n self.genome_db.connect_to_genome(ensembl_version)\n return Ensembl::Core::Gene.find_by_stable_id(self.stable_id)\n else\n return nil\n end \n end",
"def getc()\n #This is a stub, used for indexing\n end",
"def to_position\n self\n end",
"def dup\n duplicate = Intelligence::Ec::Individual.new({\n algorithm: @algorithm,\n dimensions: @dimensions\n })\n duplicate.chromosome = @chromosome.dup\n duplicate.fitness = @fitness\n duplicate\n end",
"def show_casilla(i)\n return @genes[i]\n end",
"def chr_start(query_chr)\n chr_contigs(query_chr).collect { |contig_info| contig_info.start }.min\n end",
"def initialize(problem, population_size, mutation_rate, generations)\n @problem = problem\n @best_fitness = 0;\n @best_configuration = nil\n @error = 0\n @generations = generations\n \n @population_size = population_size\n @mutation_rate = mutation_rate\n \n \n if @population_size%2 != 0 || @population_size < 1\n raise(\"Population size must be even and higher than 1.\")\n end\n \n @population = Array.new\n for i in 0..@population_size - 1\n conf = Configuration.new(@problem)\n ch = Chromosome.new(conf)\n @population.push(ch)\n \n if @best_configuration == nil || @best_fitness < ch.fitness\n @best_configuration = ch.configuration.conf\n @best_fitness = ch.fitness\n end\n \n end\n \n @selection = TournamentSelection.new\n @reproduction = UniformReproduction.new(@problem)\n @mutation = SimpleMutation.new(@problem, @mutation_rate)\n \n \n end",
"def genomic_sequence\n genome_id = params[:genome][:id]\n reference_id = params[:reference]\n strand = params[:strand].presence || '+'\n\n ref = Reference.find(:first, :conditions => {:name => reference_id, :genome_id => genome_id})\n\n if ref.present?\n seq = Bio::Sequence::NA.new(\"#{ref.sequence.sequence.to_s}\")\n start = params[:start].presence || 1\n stop = params[:end].presence || seq.length\n @subseq = seq.subseq(start.to_i, stop.to_i)\n @subseq = @subseq.reverse_complement if strand == '-'\n end\n\n id = \"#{ref.name} #{start}..#{stop} #{strand}\"\n render :text => @subseq.to_fasta(id, 60), :content_type => 'text/plain'\n end",
"def initialize\n \n # @gene = []\n # @@current_generation = 1\n \n end",
"def getc() end",
"def getc() end",
"def getc() end",
"def evaluate_chromosome(chromosome)\n @num_evaluations += 1\n chromosome.fitness = @selected_func.call chromosome\n end",
"def getCell(row, column)\n\n\t\treturn @grid.getElement(row, column)\n\tend",
"def choria\n @_choria ||= Util::Choria.new\n end",
"def room\n return self\n end",
"def create_piece(row, col)\n if col == 0 || col == 7\n return Rook.new(row, col, row)\n elsif col == 1 || col == 6\n return Knight.new(row, col, row)\n elsif col == 2 || col == 5\n return Bishop.new(row, col, row)\n elsif col == 4\n return King.new(row, col, row)\n else\n return Queen.new(row, col, row)\n end\n end",
"def bam_get_cigar(b)\n b[:data] + b[:core][:l_qname]\n end",
"def gene_list\n answer = []\n self.homology_members.each { |hm| answer.push(hm.member)}\n return answer\n end",
"def getgenerate\n coind.getgenerate\n end",
"def ref_seq\n\n if _ref_seq\n _ref_seq\n else\n seq = Reference.ref_seq(chromosome, start, stop, strand)\n update_attributes(:_ref_seq => seq)\n seq\n end\n\n end"
] | [
"0.69087785",
"0.66675186",
"0.6616339",
"0.6476195",
"0.6351701",
"0.60748726",
"0.58518857",
"0.56697726",
"0.56495184",
"0.5591868",
"0.5515572",
"0.5507487",
"0.54251176",
"0.54151255",
"0.5386429",
"0.53572005",
"0.53010887",
"0.5288723",
"0.52870905",
"0.5265328",
"0.5237936",
"0.5220492",
"0.51904356",
"0.5153241",
"0.5144461",
"0.5104994",
"0.50634897",
"0.5026529",
"0.50262463",
"0.4996092",
"0.4966759",
"0.4949237",
"0.49491456",
"0.49405715",
"0.49320114",
"0.49193284",
"0.48867273",
"0.48721847",
"0.48679045",
"0.4864461",
"0.4852534",
"0.48383787",
"0.48331466",
"0.48315746",
"0.48144573",
"0.48134765",
"0.4806528",
"0.47881496",
"0.47814298",
"0.47661316",
"0.4765222",
"0.47547376",
"0.47529334",
"0.4743337",
"0.46997935",
"0.46973905",
"0.4678473",
"0.4655436",
"0.4655026",
"0.46525088",
"0.46507773",
"0.4640787",
"0.46261653",
"0.4617301",
"0.4616865",
"0.46125638",
"0.46043232",
"0.4584802",
"0.45810944",
"0.45744076",
"0.45693672",
"0.45672312",
"0.45544145",
"0.45542392",
"0.45406848",
"0.45388535",
"0.45386988",
"0.4535708",
"0.45311123",
"0.450492",
"0.45009464",
"0.4497747",
"0.4485198",
"0.44820002",
"0.44753522",
"0.44677877",
"0.44576448",
"0.44564041",
"0.44558793",
"0.44558793",
"0.44558793",
"0.44487315",
"0.4446788",
"0.44404307",
"0.44332546",
"0.4430677",
"0.44252852",
"0.4416659",
"0.44056103",
"0.4403471"
] | 0.7262938 | 0 |
puts b Shows error, not initialized outside block | def some_method
a = 4
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def b; end",
"def b; end",
"def run(b=new_toplevel)\n print self.result(b)\n end",
"def b=(value)\n @b = value\n end",
"def b\n return @b\n end",
"def f(b)\n b\n end",
"def runblock\r\n\t\t\t@b.call\r\n\t\tend",
"def runblock\r\n\t\t\t@b.call\r\n\t\tend",
"def a\n\tb\nend",
"def abc(x, y, &b)\n puts x \n y.call \n binding.pry # break point here\n b.call if block_given?\nend",
"def solution(x, b)\n puts x\nputs b\nend",
"def bbb\n puts \"bbb\"\n end",
"def setB(b)\r\n @b = b\r\n end",
"def cp_b\n end",
"def dong\n a = puts \"DONG...\"\n a\nend",
"def br\n puts\n end",
"def inc_b\n end",
"def create_first_block\n i = 0\n instance_variable_set(\"@b#{i}\", Block.first({from: \"Minou\", to: \"VINE\", what:\"BTC\", qty: \"1000000\"}))\n #instance_variable_set permet de passer d'une chaine de caractère à une variable\n LEDGER << @b0\n p \"==============================\"\n pp @b0\n p \"==============================\"\n add_block\nend",
"def main\r\n call_block {|str, num| puts str + ' ' + num.to_s}\r\n end",
"def result(b=new_toplevel)\n unless @_init.equal?(self.class.singleton_class)\n raise ArgumentError, \"not initialized\"\n end\n eval(@src, b, (@filename || '(erb)'), @lineno)\n end",
"def initialize\n #all the things\n @puts_variable\n\n end",
"def create_first_block\n\ti = 0\n\tinstance_variable_set( \"@b#{i}\", \n\t\t\t\t\t\t\t\t\t\t\t\t Block.first( \n\t\t\t\t\t\t\t\t\t\t\t\t\t{ from: \"Dutchgrown\", to: \"Vincent\", what: \"Tulip Bloemendaal Sunset\", qty: 10 },\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ from: \"Keukenhof\", to: \"Anne\", what: \"Tulip Semper Augustus\", qty: 7 } )\n\t\t\t\t\t\t\t\t\t\t\t )\n\tLEDGER << @b0\n\tpp @b0\n\tp \"============================\"\n\tadd_block\nend",
"def unboxed\n $stderr.puts \"I should never happen\"\n end",
"def interpret\n return @b\n end",
"def run\r\n\t\t\t@b.call\r\n\t\tend",
"def printIt(boomd)\n\tprint(boomd)\nend",
"def with_transitional_values\n a = b = 1\n 3.upto(@n) do\n c = a + b\n a = b\n b = c\n end\n\n #puts \"answer is %d\" % b\n end",
"def getB\r\n return @b\r\n end",
"def add_block\n i= 1\n loop do\n instance_variable_set(\"@b#{i}\", Block.next(instance_variable_get(\"@b#{i-1}\"), get_transaction))\n #dans cette loop en demande nouveau blockd'aller prendre les donnée du block précédant\n\n LEDGER << instance_variable_get(\"@b#{i}\")\n\n p \"==============================\"\n pp instance_variable_get(\"@b#{i}\")\n p \"==============================\"\n i += 1\n end\n\nend",
"def eat\n puts @a\n 'Eating the cookie!'\n end",
"def bs; end",
"def l_variable (str)\nb = str\n\nend",
"def b\n 12\nend",
"def sub_b\n end",
"def my_value(b)\n puts b[2]\n b[2] = '-' # this method initializes variable b local to my_value and points it to the value of a, \n # which is the string\"Xyzzy\". Strings are mutable, so when b[2] = '-' is called, \n # it also changes a\n puts b[2]\nend",
"def foo2\r\n puts '|a;x|'\r\n x = 1\r\n 1.times { |a;x|\r\n puts \"in-x = #{x}\"\r\n x = 2\r\n }\r\n \r\n puts \"x = #{x}\"\r\n puts\r\nend",
"def s(a, b)\n print s\nend",
"def b!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 14 )\n\n type = B\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 339:4: 'b'\n match( 0x62 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 14 )\n\n end",
"def print_result(&block)\n result_from_block = block.call()\n puts result_from_block\nend",
"def bagi(a,b)\n \n begin\n hasil = a/b \n rescue\n error = true\n end\n\n if error \n puts \"terjadi error\"\n else\n hasil\n end\n\nend",
"def bb_unconditional_branch\n @file.puts \" @current_block.left = arg1.basic_block\"\n @file.puts \" @current_block.close\"\n @file.puts \" @current_block = new_basic_block\"\n end",
"def foo1\r\n a = 1\r\n b = 2\r\n y = 3 \r\n 1.times { |a,b,x| # b,x are fresh locals here with the scope of the block; outer a is shadowed\r\n puts '|a,b,x|'\r\n puts \"inside\"\r\n puts \"a = #{a}\"\r\n puts \"b = #{b}\"\r\n puts \"x = #{x}\"\r\n puts \"y = #{y}\"\r\n puts\r\n \r\n z = 4\r\n x = 5\r\n b = 6\r\n }\r\n \r\n puts \"after\"\r\n puts \"a = #{a}\"\r\n puts \"b = #{b}\"\r\n puts \"x = #{x}\" rescue puts \"ERROR(x)\"\r\n puts \"y = #{y}\"\r\n puts \"z = #{z}\" rescue puts \"ERROR(z)\"\r\n puts\r\nend",
"def sum_num(a, b)\n ab = a + b\n puts \"#{ab}\"\nend",
"def bil\n v=1\n end",
"def addition(a,b)\n puts c = a + b\n end",
"def sisoku(a, b)\r\n puts a+b\r\n puts a-b\r\n puts a*b\r\n puts a/b\r\n end",
"def a\r\n b = fib(5)\r\n if b == 10\r\n 1\r\n else\r\n 3.0\r\n end\r\nend",
"def bsb_test\n bsb = BSB.new\n bsb.read(\"!Copyright 1999, Maptech Inc. All Rights Reserved.\nCRR/CERTIFICATE OF AUTHENTICITY\n This electronic chart was produced under the authority of the National\n Oceanic and Atmospheric Administration (NOAA). NOAA is the hydrographic\n office for the United States of America. The digital data provided by NOAA\n from which this electronic chart was produced has been certified by NOAA\n for navigation. 'NOAA' and the NOAA emblem are registered trademarks of\n the National Oceanic and Atmospheric Administration. 'Maptech' and the\n Maptech emblem are registered trademarks of Maptech, Inc. Copyright 1999\n Maptech, Inc. All rights reserved.\nCHT/NA=CHESAPEAKE BAY ENTRANCE,NU=12221\nCHF/COASTAL\nCED/SE=70,RE=01,ED=09/12/1998\nNTM/NE=70.00,ND=10/30/1999,BF=ON,BD=10/26/1999\nVER/3.0\nCHK/1,558\nCGD/5\nORG/USA-NOAA/NOS\nMFR/MAPTECH\nRGN/4,6\nK01/NA=CHESAPEAKE BAY ENTRANCE,NU=558,TY=BASE,FN=12221_1.KAP\")\n \n puts bsb\nend",
"def B(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def sbc_a_b\n end",
"def bagi(a,b)\n # begin\n # a / b\n # rescue\n # 0\n # end\n\n ##Kode di atas akan sama dengan, tapi konsekwensinya adalah rescue ini harus ada di bawah karena kita tidak bisa menambah kodingan lagi (solusi lebih baik adalah dengan begin ..... end)\n # a / b\n # rescue\n # 0\n\n begin\n hasil = a / b\n rescue => exception\n error = true\n end\n\n # dengan ada if ini maka hasilnya juga harus ditampilkan, makanya return nya kita tampung di variabel baru ditampilkan\n if error\n puts \"Terjadi error nih\"\n else\n hasil\n end\nend",
"def add (a, b)\n puts 1\n puts 2 \n (a+b)\n return result\n \nend",
"def eat\n # this will give an error because a isn't defined in the eat method\n # puts a\n puts \"Yummy!\"\n end",
"def a_method (b)\n puts(\"--- in a_method ---\")\n a = 'a_method'\n if block_given?\n puts \"Block passed to a_method\"\n yield a\n else\n puts \"No Block passed to a_method\"\n end\n puts \"in a_method, arg b = #{b}\"\n return \"returned by #{a}\"\nend",
"def initialize(a,b)\n c = a-b\n puts('test constructor:: '+ String(c))\n end",
"def print str, &block\n Kernel.print str\n puts_capture = Class.new do\n def self.puts str\n $did_puts = true\n Kernel.puts str\n end\n end\n\n puts_capture.instance_eval &block\n\n ensure\n puts unless $did_puts\n end",
"def bark\n say('ouah ouah')\n nil\n end",
"def demo(a,b)\n\ta = a+2\n\tb = b+ 3\nend",
"def i_take_an_explicit_block &block\n puts block.inspect\nend",
"def bellini; end",
"def add(a, b)\n #puts a + b\n return a + b\nend",
"def fungi_jalan()\n\tx=5\n\tputs \"tuk... tuk .. \"\n\tputs \"tuk... tuk .. \"\n\tputs \"tuk... tuk .. #{x}\"\nend",
"def berlioz; end",
"def set_block &b\n @block = b\n end",
"def checked_puts object = ''\n real_puts object\n @prev_printed = false\n end",
"def add(a,b)\n p (a + b)\nend",
"def alpha()\n beta()\n p a = 1\nend",
"def encode_block(state, buf)\n\t\tbuf\n\tend",
"def scream_b(words)\n words = words + \"!!!!!\"\n #return\n puts words\nend",
"def setbyte(i,b)\n raise \"A VoidCube cannot be modified.\"\n end",
"def this_has_error\n puts ''\n end",
"def fib (places)\n\n a = 0\n b = 1\n arr = 1..places\n arr = arr.to_a\n arr.each { |num|\n puts b\n a,b = b,a+b\n }\n\nend",
"def multiply(b)\n\tputs b * 15\nend",
"def bark_var(i)\n i.times do\n puts \"wow!\"\n end\n end",
"def bar\r\n a = 1\r\n foo {\r\n a\r\n }\r\nend",
"def br3ak\n raise RuntimeError, \"OMFG!!1!\"\n end",
"def output\n b = block.output\n self<< b\n b\n end",
"def bb_eval(str, b = get_binding)\n b.eval(str)\n rescue StandardError, ScriptError => e\n at = e.backtrace\n locations = []\n locations << \"#{at.shift}: #{e.class} Exception(#{e.message})\"\n locations += at.map { |path| \"\\tfrom #{path}\" }\n\n errmsg(pr('eval.exception', text_message: locations.join(\"\\n\")))\n nil\n end",
"def run &b # :yields: self\n setup &b if !@did_setup\n\n over=false\n until over\n over = read_turn\n yield self\n\n @stdout.puts 'go'\n @stdout.flush\n end\n end",
"def processa_bc\n # puts(format(\"%<n>4i ATTESTATIONS INSERIDAS #{BD}.eth2at\", n: apibc.novtx.empty? ? 0 : dml(eth2at_ins)))\n # puts(format(\"%<n>4i PROPOSALS INSERIDAS #{BD}.eth2pr\", n: apibc.novkx.empty? ? 0 : dml(eth2pr_ins)))\n puts(format(\"%<n>4i BALANCES\\tETH2\\t\\tINSERIDOS eth2bh\", n: apibc.nov.empty? ? 0 : dml(eth2bh_ins)))\n end",
"def method(a,b)\ntemp=a\na=b\nb=temp\nputs \"a = #{a}\"\nputs \"b = #{b}\"\nend",
"def create_var \n b = 12\n return b \n end",
"def process_dummy(exp)\n process_block(exp).chomp\n end",
"def echo(a)\n\ta\nend",
"def c\r\n b = fib(5)\r\n if b == 10\r\n 1\r\n else\r\n 3\r\n end\r\nend",
"def setup\n @a = '0b100010011010101111001101'\n end",
"def print_values a = 50, b = 100, c\n \n puts \"The value of \\'a\\' is #{a}\\.\"\n puts \"The value of \\'b\\' is #{b}\\.\"\n puts \"The value of \\'c\\' is #{c}\\.\"\n \n rescue => exception\n warn exception.message \n\nend",
"def puts(s)\n $output = s\nend",
"def function_a\n\tputs \"Hello hacker, what is your name?\"\n\tprint \"> \"\nend",
"def printA\n \"Show instance variable: #{@a}\"\n end",
"def buffer_from_block content_block\n context = content_block.binding\n result_variable = eval(Program::RESULT_VARIABLE_BACKDOOR, context)\n eval result_variable.to_s, context\n end",
"def sb(t, s, c)\n\n end",
"def boom\n raise \"boom\"\n end",
"def bagi(a,b)\n begin\n hasil = a/b\n rescue => pesan\n pesan\n end\nend",
"def a(b)\nend",
"def btest2() yield [1, 2] end",
"def g(&b)\n c = self\n return lambda { \n break false if !c.probe\n b.call(c.rcv)\n break true \n }\n end",
"def begin; end",
"def block_print\r\n\tputs \"Before the block!\"\r\n\tyield(10)\r\n\tputs \"After the block!\"\r\nend",
"def procedure_a(a,b)\n a=a+3\n b=b+4\n return a,b\nend",
"def initialize\n puts 'A, initialize'\n end"
] | [
"0.629755",
"0.629755",
"0.6157741",
"0.6142725",
"0.59497166",
"0.5856764",
"0.576168",
"0.576168",
"0.57318705",
"0.5727564",
"0.57033414",
"0.5675371",
"0.5672679",
"0.55991167",
"0.5590924",
"0.5554245",
"0.55517817",
"0.5549723",
"0.5539023",
"0.5527367",
"0.5387455",
"0.53752774",
"0.5349109",
"0.5346755",
"0.5345204",
"0.532905",
"0.5323279",
"0.53066736",
"0.5301634",
"0.52991694",
"0.5270771",
"0.51990837",
"0.5193941",
"0.51831084",
"0.5175988",
"0.5169578",
"0.51601636",
"0.51492405",
"0.514385",
"0.5129238",
"0.510899",
"0.5103191",
"0.50557",
"0.50256777",
"0.50098103",
"0.49984014",
"0.4991246",
"0.49908262",
"0.49902996",
"0.49855933",
"0.49777383",
"0.49748725",
"0.4971789",
"0.49665397",
"0.4954494",
"0.49474257",
"0.4937792",
"0.4929379",
"0.49228325",
"0.49172583",
"0.49062115",
"0.49045205",
"0.48684716",
"0.4860509",
"0.48565027",
"0.48452902",
"0.48424217",
"0.48368958",
"0.483649",
"0.48321718",
"0.48308685",
"0.48252496",
"0.48188627",
"0.48184395",
"0.48166123",
"0.4815369",
"0.48026326",
"0.47994998",
"0.4795153",
"0.47929806",
"0.47916192",
"0.47893682",
"0.47836342",
"0.47782975",
"0.47768146",
"0.47753102",
"0.4763605",
"0.47565168",
"0.47456557",
"0.4739283",
"0.47324008",
"0.4715265",
"0.47084364",
"0.47018075",
"0.46937302",
"0.46912903",
"0.4689907",
"0.46896544",
"0.46799293",
"0.46723616",
"0.4669473"
] | 0.0 | -1 |
Returns whether this is a new session or not. | def new?
!!@new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_session?\n new_session != false\n end",
"def new_session?\n new_session != false\n end",
"def new_session?\n new_session != false\n end",
"def session_is_new?\n session[:last_activity].nil?\n end",
"def is_new\n @values.fetch('ai.session.isNew') { \n @values['ai.session.isNew'] = nil\n }\n end",
"def opened?\n @session > -1 ? true : false\n end",
"def session?\n !@session.nil?\n end",
"def session_created?\n # Start bind handlers before checking session creation\n payload_instance.start_handler if handler_bind?\n\n (self.session_count > 0) ? true : false\n end",
"def has_session?\n session\n end",
"def alive?\n @session && @login_info\n end",
"def valid_session?\n self.active?\n end",
"def is_new=(value)\n if value == @defaults['ai.session.isNew']\n @values.delete 'ai.session.isNew' if @values.key? 'ai.session.isNew'\n else\n @values['ai.session.isNew'] = value\n end\n end",
"def new?\n @is_new\n end",
"def newproject?\n session.new?\n end",
"def session?\n !expires_at || discard\n end",
"def session?\n\t\treturn @session || self.request.session?\n\tend",
"def single_session?\n ENV['SINGLE_SESSION'].nil? ? false : ENV['SINGLE_SESSION'].upcase == 'TRUE'\n end",
"def session_valid?\n @session_expiry_time > Time.now if @session_expiry_time\n end",
"def session_enabled?\n @session_enabled\n end",
"def session?\n !! session['sinatra.session']\n end",
"def session_valid?\n @session_expiry_time > Time.now if @session_expiry_time\n end",
"def open?\n @session && @session.started?\n end",
"def isnew?\n if Client.new\n return false \n else\n return true \n end \n end",
"def session_valid?\n # can't use @session_valid ||= here because the method body will be\n # re-executed when the value is legitimately false. And we're trying to\n # be gentle with Oracle.\n unless instance_variables.include?('@session_valid')\n @session_valid = if current_member.fresh?\n true\n elsif current_member.indv?\n current_member.refresh!\n elsif current_member.inst?\n current_member.authenticate_ip\n end\n end\n @session_valid\n end",
"def new?\n status == STATUS_NEW\n end",
"def new?\n defined?(@new) ? @new : (@new = false)\n end",
"def new?\n defined?(@new) ? @new : (@new = false)\n end",
"def force_clear_saved_session?\n # URI parameters override to force-clear saved session information\n # http://server.domain/path/model?session_type=new\n if params.has_key? :session_type\n if params[:session_type]== 'new'\n return true\n end\n end\n return false\n end",
"def new?\n @new\n end",
"def session_loaded?\n\t\treturn @session || self.request.session_loaded?\n\tend",
"def get_new_session\n client = prepare_request(auth_url)\n\n login_response = do_request_and_handle_errors do\n client.request :login do |soap|\n soap.body = {:id => @user, :pw => @pass}\n end\n end\n\n @session = login_response.to_hash[:login_response][:login_return]\n @cookie = login_response.http.headers[\"Set-Cookie\"]\n\n false unless @session.instance_of? Nori::StringWithAttributes\n end",
"def active_session?\n return false unless self.active_session\n return false if self.active_session == nil\n return false unless self.active_session.is_a?(String)\n return false if self.active_session.empty?\n\n return true\n end",
"def new?\n @new\n end",
"def begin_session\n begin\n true if login\n rescue\n false\n end\n end",
"def new?\n @type == 'NEW'\n end",
"def session_exists?(env)\n value = current_session_id(env)\n value && !value.empty?\n end",
"def logged_in?\n !@session_id.nil?\n end",
"def loggedin?\n @session.nil? ? false : (return true)\n end",
"def logged_in?\n # An unlogged rforce binding has a session_id defined as nil\n # Does not handle session expiration however\n !!@rforce.instance_variable_get(:@session_id)\n end",
"def new?\n\t\treturn true if sign_in_count < 2 && Time.now-created_at < 2*60\n\t\tfalse\n\tend",
"def session?\n session[:user_id]\n end",
"def valid_session\r\n {}\r\n end",
"def needs_new_cookie?\n @_new_cookie\n end",
"def logged_in?\n !session[Casual.session_key].nil?\n end",
"def temporary_session?\n session[:user_id]\n end",
"def logged_in?\n auth_session.is_a?(Session)\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end",
"def valid_session\n {}\n end"
] | [
"0.9030406",
"0.90066814",
"0.9006021",
"0.83690375",
"0.7507616",
"0.745895",
"0.74235666",
"0.7306285",
"0.7297617",
"0.72503334",
"0.7155766",
"0.71184665",
"0.7114954",
"0.7091365",
"0.70851576",
"0.70477134",
"0.70157653",
"0.7007417",
"0.6987059",
"0.69829917",
"0.69824547",
"0.6890921",
"0.6881437",
"0.68298477",
"0.68167114",
"0.6810949",
"0.6810949",
"0.6799741",
"0.6793989",
"0.67750025",
"0.67650944",
"0.6760651",
"0.6749152",
"0.6724145",
"0.6703052",
"0.67013144",
"0.6661404",
"0.6649521",
"0.66365224",
"0.66147697",
"0.65985584",
"0.65826136",
"0.658174",
"0.65535253",
"0.65442497",
"0.6493686",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872",
"0.6489872"
] | 0.6540632 | 45 |
Returns true if a user is defined. | def user_defined?
!@user.nil? || !@user['userId'].nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user?(name)\n eval(USER_CHECK, binding, __FILE__, USER_CHECK_LINE)\n nil\nend",
"def custom?\n user_id.present? || is_a?(DSLDefined)\n end",
"def has_user?\n !user.nil?\n end",
"def user?\n get_mode == :user\n end",
"def is_potential_user?\n\t\ttrue\n\tend",
"def user_present?\n current_user.present?\n end",
"def user?\n type == :user_id\n end",
"def user?\n type == :user_id\n end",
"def _user? name\n\t\tuid = DB[:_user].filter(:name => name).get(:uid)\n\t\tuid ? true : false\n\tend",
"def hasuser? username\n\t\t@cf.usermanager.user? username\t\t\n\tend",
"def user?\n permissions == 'user'\n end",
"def has_users?\n username.present? || user_file.present? || userpass_file.present? || !additional_publics.empty?\n end",
"def is_user_specific?\n false\n end",
"def is_user?\n usertype == 'user'\n end",
"def user_present?\n user_token_present? && User.find_by(auth_token: user_token)\n end",
"def has_user?(name, options={})\n run(\"id #{name}\").success?\n end",
"def show_user_field?(field)\n return true unless @setup or current_user.blank?\n return true if @setup and current_user.required_profile_elements.include?(field)\n return false\n end",
"def user?(username)\n\t\t\t\tif(users.has_key?(username))\n\t\t\t\t\treturn(true)\n\t\t\t\tend\n\n\t\t\t\treturn(false)\n\t\t\tend",
"def is_user?\n user ? true : false\n end",
"def authed_user?\n return true unless @data['hasPhone'].nil?\n\n false\n end",
"def user?\n is_a?(Merit::User)\n end",
"def user_has? name\n\t\tuid = Sdb[:user_info].filter(:name => name).get(:uid)\n\t\tuid ? uid : nil\n\tend",
"def user_exists?(user)\n return !get_user(user).nil?\n end",
"def current_user_exists?\n return false if config.current_user.nil?\n return true\n end",
"def owned?\n user.present?\n end",
"def applies_to?(user); false end",
"def user?(user)\n\t\t\t\tif(users()[user] != nil)\n\t\t\t\t\tCfruby.controller.inform('debug', \"\\\"#{user}\\\" exists\")\n\t\t\t\t\treturn(true)\n\t\t\t\telse\n\t\t\t\t\tCfruby.controller.inform('debug', \"\\\"#{user}\\\" does not exist\")\n\t\t\t\t\treturn(false)\n\t\t\t\tend\n\t\t\tend",
"def user\n\t\tfalse\n\tend",
"def user_exists?\n return (session[:user_id] && User.find(session[:user_id])) ? true : false\n end",
"def user?\n has_role? :user\n end",
"def enabled?\n user.present?\n end",
"def first_user?\n return false unless options.keys.count == FIRST_USER_OPTIONS_COUNT\n return false unless options.key?(FIRST_USER_FLAG)\n\n Console::User.first_user?(options[FIRST_USER_FLAG])\n end",
"def has_user?(user)\n self.users.include?(user)\n end",
"def userExists(userName)\n user = loadUser(userName)\n #puts \"User::::#{user}\"\n if(user != nil && (!user.key?(\"BLOCKED\") || user[\"BLOCKED\"] == false))\n return true\n end\n return false\n end",
"def is_global_or_owned_by?(user)\n self.is_global? || self.user_id == user.id\n end",
"def user_exists?\n \t\tself.errors.add(:name, \"does not exist!\") unless self.user_id.present?\n \tend",
"def has_user?\n AutoAdmin::AutoAdminConfiguration.admin_model\n end",
"def user_registered?(user)\n user_key = \"users/#{user}\"\n @config[user_key] && @config[user_key][\"token\"] && @config[user_key][\"secret\"]\n end",
"def user_registered?(user)\n user_key = \"users/#{user}\"\n @config[user_key] && @config[user_key][\"token\"] && @config[user_key][\"secret\"]\n end",
"def public_user?\n \tcurrent_user.username.eql? \"public_user\"\n end",
"def dummy_user?\n (user_id.split('/').first == 'gofreerev')\n end",
"def dummy_user?\n (user_id.split('/').first == 'gofreerev')\n end",
"def _user? name\n\t\tuid = Sdb[:_user].filter(:name => name).get(:uid)\n\t\tuid ? uid : nil\n\tend",
"def user?(user)\n users.include? user\n end",
"def system?\n id == User::SYSTEM_USER_ID\n end",
"def system?\n id == User::SYSTEM_USER_ID\n end",
"def status_getuser?()\n return true if (@status == TAC_PLUS_AUTHEN_STATUS_GETUSER)\n return false\n end",
"def valid_user?\n client.valid_user?(user_repo, @options)\n end",
"def user_exists? env, username\n return false if config.nil? || config.empty?\n return true if config[env].has_key? username\n end",
"def user_key?\n key_type == KEY_TYPE_USER\n end",
"def username_target?\n flags.include?(:username_target)\n end",
"def exists?\n users(should_user, should_vhost)\n end",
"def user_exists?(name)\n @users.member?(name)\n end",
"def name_is_valid?(user, name)\n\t\tuser.respond_to? \"#{name}s_administrating\" and (this_is_offering?(name) || this_is_multisession?(name))\n\tend",
"def bot_user?\n !@email.nil?\n end",
"def owner_required?\n !Refinery::Multisites.user_class.nil?\n end",
"def defined?\n false\n end",
"def resolved?\n\t\t!self.user_id.nil?\n\tend",
"def canBeExecutedBy? user\n unless user.class == Modeles::User\n username = user.to_s\n user = Modeles::User.find_by_name username\n unless user\n @errors << \"User #{username} doesn't exists\"\n return false\n end\n end\n if user.isAdmin == 1\n return true\n elsif user.name == @user\n if @userRights == 1 or @userRights == 5 or @userRights == 7\n return true\n else\n return false\n end\n elsif isIncludedIn? user.groups, @group\n if @groupRights == 1 or @groupRights == 5 or @groupRights == 7\n return true\n else\n return false\n end\n else\n if @othersRights == 1 or @othersRights == 5 or @othersRights == 7\n return true\n else\n return false\n end\n end\n end",
"def is_userconstraint?(); @type == GRT_USERCONSTRAINT; end",
"def logged_in_normal_user?\n normal_user.present?\n end",
"def user_exists?(user)\n @users.key?(user)\n end",
"def is_user?\ncurrent_user.username == @userl.username\n end",
"def exists?(name)\n find_user(name)&.size != 0\n end",
"def has_user?(member)\n self[:users].member? member\n end",
"def has_users?\n\t\tself.users.size > 0\n\tend",
"def user_exists?(name)\n Etc.getpwnam(name).name == name\n rescue ArgumentError\n false\n end",
"def findlocal(user)\n\n if user_exists(user) then\n return true\n else\n return false\n end\n end",
"def defined?(name); end",
"def defined?(name); end",
"def user_exists?(username)\n Sys::Admin.get_user(username)\n true\n rescue\n false\n end",
"def username_reserved?\n ReservedUsernames.include?(username)\n end",
"def can_be_assigned?(_user)\n false # any user can complete operation\n end",
"def restricted?\n return ( self.user_type == User::USER_TYPE_NORMAL )\n end",
"def create?\n\t\t!@user.nil?\n\tend",
"def viewable_by?(user)\n Sugar.public_browsing? || user ? true : false\n end",
"def is_user_member? usr\n\t\tif usr\n\t \treturn is_member?(Role.find(usr.role.id))\n\t end\n\t return false\n\tend",
"def list_users?\n user.present? && user.admin?\n end",
"def user_exists?\n\t !User.find_by_email(email).nil? ? true : false\n\tend",
"def is_standard_user?(user)\n return false if Access::Core.is_guest?(user)\n\n user.has_role?(:user)\n end",
"def definition_required?\n # We have to distinguish the false value from the non\n # existence of the variable. Therefore the ||= operator\n # can't help us.\n if @definition_required.class.kind_of?(NilClass)\n\t @definition_required = true\n else\n @definition_required\n end\n end",
"def user_is_admin?\n\tbegin\n\t `gpresult /r /scope user`.split.include? \"Admin\"\n\trescue\n\t false\n\tend\n end",
"def writable?\n !(@settings[:user].nil?)\n end",
"def is_rollcall_user?\n has_application?(:rollcall)\n end",
"def valid?\n valid_user?(request.headers)\n end",
"def create?\n @user != nil\n end",
"def creatable_by?(user)\n true\n end",
"def valid_user?\n unless self.target_user.nil?\n if self.target_user.is_a? String\n !!(self.target_user == self.user)\n else\n !!(self.target_user == self.user(:id))\n end\n else\n # The user is OK if it wasn't specified\n return true\n end\n rescue ArgumentError => ex\n # The user is NOT OK if the user doesn't exist\n WarningShot::PermissionResolver.logger.error(\"User [#{self.target_user}] does not exist: #{ex.message}\")\n return false\n end",
"def shadow_user?\n return !session[:shadow_user_id].blank?\n end",
"def satisfied_by?(_user)\n raise NotImplementedError\n end",
"def user_check(resource)\n return true unless self[:name] == \"user\"\n return true unless self[:unless_system_user]\n\n resource[:audit] = :uid\n\n return false if system_users.include?(resource[:name])\n\n current_values = resource.retrieve_resource\n current_values[resource.property(:uid)] > self[:unless_system_user]\n end",
"def is_this_user\n\t\t@user.id == current_user.id\n\tend",
"def accessible_for?(user)\n user_id == user.id && !user.anonimous?\n end",
"def run_valid_user?\n\t\t\tif v.valid_user?(ev.user, ev.user_groups, \"railsdep\")\n\t\t\t\t$stdout.puts Rainbow(\"Success: '#{ev.user}' is member of 'railsdep' group\").green\n\t\t\telse\n\t\t\t\texit 1\n\t\t\tend\n\t\tend",
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def include?(user)\n BaseFilter.string_includes?(user.full_name, full_name) &&\n BaseFilter.string_matches?(user.user_is_current, user_is_current)\n end",
"def has_member?(user)\n users.include?(user)\n end",
"def check_user_type\n if self.user_type.present?\n self.contractor = self.user_type.to_s.downcase.include? \"contractor\"\n else\n self.contractor = false\n end\n end",
"def user_in_started_game?(input_user)\n self.started && self.playing_user_names.include?(input_user.nick)\n end",
"def app_user?\n member_type == MEMBER_TYPE[:app]\n end"
] | [
"0.74699235",
"0.72796094",
"0.71275294",
"0.71097934",
"0.704967",
"0.698266",
"0.69224554",
"0.69224554",
"0.6908096",
"0.6872325",
"0.6848843",
"0.6789121",
"0.6716347",
"0.66968864",
"0.6690535",
"0.66733754",
"0.66626996",
"0.665802",
"0.66425085",
"0.6585555",
"0.65685135",
"0.6562676",
"0.65482867",
"0.65447414",
"0.6519795",
"0.6491937",
"0.6489531",
"0.64893895",
"0.64875853",
"0.6479043",
"0.64612484",
"0.6450648",
"0.64456207",
"0.6419479",
"0.63939065",
"0.6382722",
"0.63471633",
"0.6347114",
"0.6347114",
"0.634665",
"0.6342474",
"0.6342474",
"0.6341992",
"0.63350946",
"0.63133633",
"0.63133633",
"0.63120943",
"0.6305497",
"0.6279054",
"0.6278353",
"0.62757933",
"0.62744373",
"0.626639",
"0.62653935",
"0.6257181",
"0.6250517",
"0.6244731",
"0.6238215",
"0.6231902",
"0.6226749",
"0.6224013",
"0.6216141",
"0.62048566",
"0.6193044",
"0.61916953",
"0.6190245",
"0.6188329",
"0.6187805",
"0.61794794",
"0.61794794",
"0.6171521",
"0.61619574",
"0.615904",
"0.61581326",
"0.6153094",
"0.6148088",
"0.6146879",
"0.6146872",
"0.614377",
"0.6130513",
"0.6129412",
"0.6123933",
"0.6117835",
"0.611781",
"0.6114642",
"0.61089677",
"0.61027986",
"0.6100712",
"0.6097815",
"0.6096912",
"0.6092563",
"0.6077457",
"0.6075599",
"0.60731536",
"0.6070877",
"0.6070547",
"0.6067731",
"0.6064088",
"0.606294",
"0.60535914"
] | 0.8091406 | 0 |
Check to see if attributes are present. | def has_attributes?
!@attributes.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attributes_exist?\n\tend",
"def attributes?\n attributes.length > 0\n end",
"def attributes_are_defined?\n # attributes are defined\n return false if @attributes == []\n @attributes.each do |a|\n return false unless a.class == RelationAttribute\n end\n true\n end",
"def check_required_attributes\n attributes = DSL.attributes.values.select(&:required?)\n attributes.each do |attr|\n value = spec.send(attr.name)\n unless value && (!value.respond_to?(:empty?) || !value.empty?)\n if attr.name == :license\n results.add_warning('attributes', 'Missing required attribute ' \\\n \"`#{attr.name}`.\")\n else\n results.add_error('attributes', 'Missing required attribute ' \\\n \"`#{attr.name}`.\")\n end\n end\n end\n end",
"def has_attributes?(dictname)\n self.attribute_dictionary(dictname) != nil\nend",
"def attribute_present?(attr_name)\n attr_name = attr_name.to_s\n value = _read_attribute(attr_name)\n !value.nil? && !(value.respond_to?(:empty?) && value.empty?)\n end",
"def checkAttributeRequirements\n if @valid_attributes.empty?\n @error_text = \"No valid attributes found\"\n return false\n elsif (@mandatory_attributes_from_db & @valid_attributes) != @mandatory_attributes_from_db\n missing_attr = @mandatory_attributes_from_db - (@mandatory_attributes_from_db & @valid_attributes)\n\n x_attr_txt = \"\"\n missing_attr.each {|x_attr| x_attr_txt += x_attr[:name] + \", \"}\n @error_text = \"Mandatory attributes #{x_attr_txt[0..-3]} is/are missing\"\n return false\n end\n\n return true\n end",
"def has_attributes?(dictname)\n self.attribute_dictionary(dictname) != nil || self.definition.attribute_dictionary(dictname) != nil\nend",
"def attributes_sufficient?(user_attributes)\n missing_required_attributes(user_attributes).empty?\n end",
"def has_attribute?(name)\n attributes.has_key?(name)\n end",
"def has_attributes?( *attributes )\n \n has_attributes = false\n \n attributes.each do |this_attribute|\n break unless has_attributes = has_key?( this_attribute )\n end\n \n return has_attributes\n \n end",
"def all_attributes_exists?(attribute_names)\n attribute_names.reduce(true) {|result, att| ALL_FIELDS.include? att or SUPPORTED_ALTS.include? att}\n end",
"def valid?\n MANDATORY_ATTRIBUTES.each{|a| return false unless self[a]}\n true\n end",
"def attrs_provided?(attrs)\n !attrs.empty?\n end",
"def has_attributes?(names)\n parts = composite_parts\n names.all?{|k| parts.key?(k)}\n end",
"def all_base_attributes_present?\n BASE_ATTRIBUTES.all? { |attribute| self.send(\"#{attribute}?\") }\n end",
"def any?\n REQUIRED_KEYS.any? do |key|\n attributes[key].any?\n end\n end",
"def has_attribute (attname)\n\n attname = OpenWFE::symbol_to_name(attname) if attname.is_a?(Symbol)\n\n (@attributes[attname] != nil)\n end",
"def has_attribute?(name)\n val = @attributes[name]\n val.nil? ? false : (not val.empty?)\n end",
"def validate_attributes!(attributes)\n return missing_required unless attributes.key?(:name)\n return missing_required unless defined_value?(attributes[:name])\n\n true\n end",
"def valid?\n MANDATORY_ATTRIBUTES.each { |a| return false unless self[a] }\n true\n end",
"def read_present\n @attrs.select { |k,v| !v.nil? }\n end",
"def has_attributes?\n a = @context.attributes.find{|a| @options.show_all || a.visibility == :public || a.visibility == :protected}\n a ? true : false\n end",
"def has_attribute?(attr_name)\n @attributes.has_key?(attr_name.to_s)\n end",
"def has_attribute?(attr_name)\n @attributes.has_key?(attr_name.to_sym)\n end",
"def valid_attributes?\n attribute_errors.empty?\n end",
"def has_attribute?(name)\n attribute_names.include?(name.to_str)\n end",
"def has_required_attrs(*attrs)\n self.class_variable_set('@@required_attrs', attrs)\n end",
"def attribute_present?(name)\n @ldap_entry.attribute_names.include?(name)\n end",
"def validate_attrs\n @target.present? && !@target.errors.any? && @actor.present? && @action_key.present?\n end",
"def presence(attrs)\n Array(attrs).each do |attr|\n value = @object.respond_to?(attr) ? @object.send(attr) : nil\n # TODO: write some tests\n # consider explicit `false` as an actual value (not blank)\n error(attr, 'is required') unless value == false || value && value != ''\n end\n end",
"def attributes_loaded?\n @attributes_loaded\n end",
"def mandatory?\n @declarer.mandatory_attributes.include?(attribute)\n end",
"def has_attr?(n)\n find_all do |q|\n q.has_attribute n\n end\n end",
"def _check_attribute_completeness\n documented_attributes = ATTRIBUTES.collect { |a| a['name'].to_s }\n # ^ The attributes documented in specdoc.yaml.\n coded_attributes = Gem::Specification.attribute_names.collect { |a| a.to_s }\n # ^ The attributes defined in specification.rb.\n missing = coded_attributes - documented_attributes\n unless missing.empty?\n STDERR.puts \"Defined attributes that are not documented:\"\n STDERR.puts ' ' + missing.join(', ')\n end\n missing = documented_attributes - coded_attributes\n unless missing.empty?\n STDERR.puts \"Documented attributes that are not defined:\"\n STDERR.puts ' ' + missing.join(', ')\n end\nend",
"def guard_required!\n required.each do |key|\n raise ArgumentError, \"Missing required attribute #{key}\" if self[key].nil?\n end\n end",
"def attr_need_validation? attr\n return false unless required_attributes\n required_attributes.include?(attr)\n end",
"def has_attribute?(name)\n @attributes.key?(name.to_s)\n end",
"def validate_required_attributes\n required = %i[currency_code direction epic force_open guaranteed_stop order_type size\n time_in_force]\n\n required.each do |attribute|\n raise ArgumentError, \"#{attribute} attribute must be set\" if attributes[attribute].nil?\n end\n end",
"def attribute_present?(attribute)\n value = read_attribute(attribute)\n !value.blank?\n end",
"def has_attribute?(attr_name)\n self.attribute_names.include?(attr_name.to_s)\n end",
"def attribute?(name)\n @attrs.has_key(name)\n end",
"def expensive_validate_presence_of_proper_attributes(attrs)\n attributes_list.each do |attr|\n unless attrs.delete(attr) || optional_attributes_list.include?(attr)\n raise BadAttributesError, \"Missing attribute '#{attr}'\"\n end\n end\n\n raise BadAttributesError, \"Unknown attributes #{attrs.inspect}\" unless attrs.empty?\n end",
"def _has_attribute?(attr_name)\n attribute_types.key?(attr_name)\n end",
"def _has_attribute?(attr_name)\n attribute_types.key?(attr_name)\n end",
"def attribute?(attrib)\n attributes.attribute?(attrib)\n end",
"def attribute_names_valid?\n if attribute_names.detect { |a| attribute_names.count(a) > 1 }\n return false\n end\n true\n end",
"def assert_needed_attributes *list_of_attributes\n list_of_attributes.collect { |attrib|\n attrib_needed!(attrib) unless attrib_ready?(attrib) || attrib_needed?(attrib)\n }.compact\n end",
"def attribute_present?(attribute)\n is_empty = read_attribute(attribute).respond_to?(\"empty?\") ? read_attribute(attribute).empty? : false\n @attributes.include?(attribute) && !@attributes[attribute].nil? && !is_empty\n end",
"def is_attribute?(line)\n (line =~ /(\\s+)attr_(writer|reader|accessor)\\s+:[a-zA-Z_0-9]+/) == 0\n end",
"def attrib_needed? attrib_sym = nil\n attrib_sym.nil? ? needed_attributes.present? : send(:\"#{attrib_sym}_needed\")\n end",
"def validate_attributes!(attributes)\n return attributes if attributes.blank?\n invalid_properties = attributes.keys.map(&:to_s) - self.attributes.keys\n invalid_properties.reject! { |name| self.respond_to?(\"#{name}=\") }\n fail UndefinedPropertyError, \"Undefined properties: #{invalid_properties.join(',')}\" if !invalid_properties.empty?\n end",
"def _check_required_attr(object_missing, attr_path, attr_options, fname)\n attr_obj = KeyPath.new(attr_path)\n\n attr_name = attr_obj.key\n case attr_options[:type]\n when :data\n _check_required_attr_data(attr_name, attr_options, fname)\n when :CloudObject\n if attr_options[:required] &&\n @object_data.type?(attr_name) != :DataObject\n object_missing << attr_name\n end\n end\n end",
"def description\n \"validate the presence of any of these attributes: #{attributes.join(', ')}\"\n end",
"def has_attribute?(attribute)\n attributes.keys.include?(attribute)\n end",
"def all_attributes_exists?(attribute_names)\n attribute_names.collect! {|n| n == 'id' ? '_id' : n}\n attribute_names.all? { |name| column_methods_hash.include?(name.to_sym) }\n end",
"def checkListingAttributeRequirements\n @mandatory_attributes_from_db.each do |mand_attr|\n @listing_data.each do |listing|\n if listing[mand_attr[:name].to_sym] == nil\n listing[mand_attr[:name].to_sym] = \"#mand_attr_missing\"\n listing[:invalid] = \"Mandatory attribute #{mand_attr[:name]} missing!\"\n @invalid_rows = true\n end\n\n # handle title\n if listing[:type] == \"renting\"\n end\n end\n end\n end",
"def validate_attributes!(attributes)\n invalid_properties = attributes.keys.map(&:to_s) - self.attributes.keys\n raise UndefinedPropertyError, \"Undefined properties: #{invalid_properties.join(',')}\" if invalid_properties.size > 0\n end",
"def valid?\n MANDATORY_ATTRIBUTES[type].each{|a| return false unless self[a]}\n true\n end",
"def required_attribute?(name, user=nil)\n required_attribute_names(user).include?(name.to_s)\n end",
"def has_attribute?(attr_name)\n attribute_types.key?(attr_name.to_s)\n end",
"def valid_attributes?\n true\n end",
"def _check_required_attr_data(attr_name, attr_options, fname)\n default = attr_options.rh_get(:default_value)\n\n return unless attr_options[:required]\n\n if attr_options.key?(:extract_from)\n unless @object_data.exist?(attr_options[:extract_from])\n PrcLib.runtime_fail(\"key '%s' was not extracted from '%s'\"\\\n \". '%s' requirement failed.\",\n attr_name, attr_options[:extract_from], fname)\n end\n elsif @config.get(attr_name, default).nil?\n section = Lorj.defaults.get_meta_section(attr_name)\n section = 'runtime' unless section\n PrcLib.runtime_fail(\"key '%s/%s' is not set. '%s' requirement\"\\\n ' failed.', section, attr_name, fname)\n end\n end",
"def attr_check(text)\n Log.message(\"Checking attributes contains <#{text}> for #{@name} >>\")\n\n if @title.include?(text) || @description.include?(text) || @skills.join(' ').include?(text)\n\n @title.include?(text) ? Log.message(\"Title attribute contains <#{text}>\") : Log.warning(\"Title attribute NOT contains <#{text}>\")\n @description.include?(text) ? Log.message(\"Description attribute contains <#{text}>\") : Log.warning(\"Description attribute NOT contains <#{text}>\")\n @skills.join(' ').include?(text) ? Log.message(\"Skills attribute contains <#{text}>\") : Log.warning(\"Skills attribute NOT contains <#{text}>\")\n\n true\n else\n\n Log.error(\"No one attribute contains <#{text}>\")\n\n false\n end\n end",
"def has_attribute?(attr_name)\n attr_name = attr_name.to_s\n attr_name = self.class.attribute_aliases[attr_name] || attr_name\n @attributes.key?(attr_name)\n end",
"def attribute?\n false\n end",
"def attrs_ok?\n return_value = true\n unless description.is_a? String\n Origen.log.error(\"Clock attribute 'description' must be a String!\")\n return_value = false\n end\n return_value = false unless frequencies_ok?\n return_value\n end",
"def attributes_available?\n @opened ? (@attr_dbf ? true : false) : nil\n end",
"def has_attribute?(attr_name)\n attr_name = attr_name.to_s\n attr_name = attribute_aliases[attr_name] || attr_name\n attribute_types.key?(attr_name)\n end",
"def attribute_present?(attribute)\n value = read_attribute(attribute)\n !value.blank? or value == 0\n end",
"def attribute_present?(attribute)\n value = respond_to?(attribute) ? send(attribute) : nil\n !value.nil? || (value.respond_to?(:empty?) && !value.empty?)\n end",
"def has_attribute?(name)\n current_attributes.has_key?(name)\n end",
"def assert_known_attributes(klass, attribute_hash); end",
"def check_attribute!(attribute)\n raise \"Unexpected attribute #{attribute} used\" unless self.class.attributes && self.class.attributes.include?(attribute)\n end",
"def check_attribute!(attribute)\n raise \"Unexpected attribute #{attribute} used\" unless self.class.attributes && self.class.attributes.include?(attribute)\n end",
"def attribute_method?(attr)\n super || attributes.keys.include?(attr)\n end",
"def empty?\n @attrs.empty?\n end",
"def validate_at_least_one_present(attributes)\n errs = []\n present = attributes.select { |attribute| !self[attribute].nil? }.count\n errs << \"At least one of #{attributes.join(', ')} must be defined\" unless present.positive?\n errs\n end",
"def optional_attributes\n fail NotImplementedError 'Please define #optional_attributes as a list of the '\\\n 'attributes on this resource that may not be present and thus should return nil' \\\n 'instead of raising a NoMethodError.'\n end",
"def attribute_required?(attribute)\n validates_presence?(attribute) || validates_inclusion?(attribute)\n end",
"def valid_attribute?( attroid )\n\t\treturn !self.valid_attribute_type( attroid ).nil?\n\tend",
"def empty?\n attributes.size == 0\n end",
"def validate_may_attributes\n\t\thash = (self.entry || {} ).merge( @values )\n\t\tattributes = hash.keys.map( &:to_sym ).uniq\n\t\tvalid_attributes = self.valid_attribute_oids +\n\t\t\tself.operational_attribute_oids +\n\t\t\tIGNORED_OPERATIONAL_ATTRS\n\n\t\tself.log.debug \"Validating MAY attributes: %p against the list of valid OIDs: %p\" %\n\t\t\t[ attributes, valid_attributes ]\n\t\tunknown_attributes = attributes - valid_attributes\n\t\tunknown_attributes.each do |oid|\n\t\t\tself.errors.add( oid, \"is not allowed by entry's objectClasses\" )\n\t\tend\n\tend",
"def caprese_is_attribute?(attribute_name)\n false\n end",
"def attribute?( attribute )\n send(attribute).present?\n end",
"def check_attrs(attr_list)\r\n attrs = []\r\n attr_list.each do |attr_sym|\r\n attr = assigns(attr_sym.to_sym)\r\n assert_not_nil attr, \"Attribute @#{attr_sym} should not be nil\"\r\n assert !attr.new_record?, \"Should have saved the @#{attr_sym} obj\" if attr.class == ActiveRecord\r\n attrs << attr\r\n end\r\n attrs.length > 1 ? attrs : attrs[0]\r\n end",
"def check_attrs(attr_list)\r\n attrs = []\r\n attr_list.each do |attr_sym|\r\n attr = assigns(attr_sym.to_sym)\r\n assert_not_nil attr, \"Attribute @#{attr_sym} should not be nil\"\r\n assert !attr.new_record?, \"Should have saved the @#{attr_sym} obj\" if attr.class == ActiveRecord\r\n attrs << attr\r\n end\r\n attrs.length > 1 ? attrs : attrs[0]\r\n end",
"def blank?\n attributes.values.all?(&:blank?)\n end",
"def blank?\n attributes.values.all?(&:blank?)\n end",
"def blank?\n attributes.values.all?(&:blank?)\n end",
"def blank?\n attributes.values.all?(&:blank?)\n end",
"def has_attributes?; end",
"def check_for_required_params!(attributes_hash)\n return if (\n missing_attributes = required_params - attributes_hash.keys\n ).empty?\n\n raise(\n UserEngage::CreateNotSuccessfulException,\n \"Missing attributes {#{missing_attributes.inspect}}\"\n )\n end",
"def has_attribute?(attr_name)\n attr_name = attr_name.to_s\n attr_name = self.class.attribute_aliases[attr_name] || attr_name\n attribute_types.key?(attr_name)\n end",
"def has_attribute?(attr_name)\n attr_name = attr_name.to_s\n attr_name = self.class.attribute_aliases[attr_name] || attr_name\n attribute_types.key?(attr_name)\n end",
"def attr_required(*attr_names)\n @required_attrs ||= []\n @required_attrs += attr_names\n attr_accessor(*attr_names)\n end",
"def required_attributes\n self.class::REQUIRED_ATTRIBUTES\n end",
"def core_attributes_valid\n core_attributes = [@rateable, @rater, @ratee, @rating_type]\n return if core_attributes.all? { |atr| atr.present? && atr.valid? }\n errors.add('message', 'Not all core attributes present and valid.')\n end",
"def valid_attrs?(*names)\n valid?\n names.inject(true) { |res, name| errors[name].blank? && res }\n end",
"def include_attr?(key)\n @attrs_hash.include?(key.intern)\n end"
] | [
"0.78843075",
"0.78615195",
"0.77598435",
"0.77466637",
"0.7591995",
"0.75661135",
"0.750503",
"0.74876285",
"0.7455706",
"0.7379565",
"0.7358541",
"0.7357248",
"0.73470753",
"0.7342278",
"0.7333776",
"0.73133004",
"0.72984457",
"0.72981244",
"0.7277732",
"0.7274257",
"0.72722685",
"0.7231161",
"0.7219294",
"0.7213057",
"0.7197993",
"0.7188904",
"0.7166748",
"0.7142661",
"0.71402514",
"0.7065895",
"0.70197463",
"0.70181817",
"0.7000763",
"0.6982315",
"0.69536257",
"0.69414717",
"0.6937652",
"0.693683",
"0.69229704",
"0.69210887",
"0.6918438",
"0.6903113",
"0.69012034",
"0.68947405",
"0.68947405",
"0.6859442",
"0.6837884",
"0.6828123",
"0.6825217",
"0.6805336",
"0.6797529",
"0.67927015",
"0.67876816",
"0.6772234",
"0.67426914",
"0.67359596",
"0.672991",
"0.6725583",
"0.67242914",
"0.6686864",
"0.66384417",
"0.6636738",
"0.66263336",
"0.6621308",
"0.6614119",
"0.6614061",
"0.6612941",
"0.6604488",
"0.658993",
"0.65821767",
"0.6580827",
"0.65607065",
"0.6559663",
"0.65581715",
"0.65581715",
"0.6546254",
"0.65405154",
"0.6532151",
"0.6524162",
"0.6522185",
"0.6486093",
"0.64665014",
"0.6459914",
"0.64548755",
"0.6445098",
"0.6437925",
"0.6437925",
"0.64347935",
"0.64347935",
"0.64347935",
"0.64347935",
"0.64321536",
"0.643062",
"0.64290506",
"0.64290506",
"0.6422217",
"0.63964826",
"0.6396124",
"0.6394583",
"0.63918924"
] | 0.769052 | 4 |
before_action :check_user, only: [:show] GET /users GET /users.json | def index
@users = User.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n check_user\n end",
"def show\n # not_found unless @user\n # @user = User.get(params[:id]) || not_found\n # authorize! :show, @user\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @user }\n end\n end",
"def show\n @user= set_user\n render json: @user, status: :ok\n\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n if @current_user and @current_user == @user\n format.json { render json: @user }\n else\n format.json { render :json => @user, :except => [:perishable_token, :persistence_token, :email, :single_access_token, :last_login_ip, :current_login_ip, :crypted_password, :password_salt] }\n end\n end\n end",
"def show\n @user = User.find(params[:id])\n if !(current_user.isAdmin? or current_user == @user) \n redirect_to home_path, notice: \"Unauthorized!\"\n return\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n\t\t#reactivate(params[:id])\n\t\t#print(\"we are here now\")\n\t\trender json: User.find(params[:id])\n\tend",
"def show\n @shown_user = User.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n\tif(filters)\n\t\tif(!session[:user_id])\n\t\t\tflash[:error] = \"Acceso denegado\"\n\t\t\tredirect_to home_path\n\t\t\treturn\n\t\tend\n\t\tif(!User.find(session[:user_id]).admin || !User.find(session[:user_id]).active)\n\t\t\tflash[:error] = \"Acceso denegado\"\n\t\t\tredirect_to home_path\n\t\t\treturn\n\t\tend\n\tend\n @user = User.find(params[:id])\n\n\tflash[:active_tab] = \"admin\"\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n if current_user && current_user.admin? \n @user = User.find(params[:id])\n respond_with user_path(@user)\n else\n flash[:notice] = 'You do not have Admin see users information'\n redirect_to :back\n end\n end",
"def show\n if (params[:id] == current_user.id)\n @user = current_user\n else\n @user = User.find(params[:id])\n end\n\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n if(params[:id].to_s() == User.find_by_userName(session[:userName]).id.to_s())\n @user = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n else\n flash[:notice] = \"Access denied.\"\n redirect_to users_notauthorized_path\n end\n end",
"def show\n authorize @user\n render json: @user\n end",
"def check_for_user\n if current_user\n @user = current_user\n else\n @user = {}\n end\n render json: @user\n end",
"def show\n if @oeuser.id.to_i == params[:id].to_i\n @user = User.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n else\n flash[:error] = \"Restricted Access, You need to be Admin\"\n redirect_to root_url\n end\n end",
"def show\n @title = \"showing user\"\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n verifica_user\n end",
"def show\n @user = Helpers.show_each_user(params[:id])\n check_user_nil('Success', 'User does not exist', @user)\n end",
"def show\n @user = User.find(params[:id]) if params[:id]\n \n respond_to do |format|\n format.html { render action: :show }\n format.json { render json: { status: \"OK\", data: { user: @user }, message: nil } }\n end\n end",
"def show\n # Pundit authorization can be skipped because\n # before_filter :authorize_user_index handles authorization\n skip_authorization\n\n @user = User.find_by_id(params[:id])\n\n if @user == nil\n @user = User.find_by_id(current_user.id)\n end\n\n respond_to do |format|\n format.html\n format.json { render :json => @user, status: 200 }\n end\n end",
"def user_check\n if user_signed_in?\n render status: :ok, json: current_user\n else\n render status: :forbidden, nothing: true\n end\n end",
"def show\n render json: @user, serializer: UserSerializer, root: false, status: 200\n end",
"def show\n user = User.find_by(uid: params[:id])\n if user\n puts 'USER FOUND'\n render json: user\n else\n puts 'NO USER'\n render json: 'no user'.to_json\n end\n end",
"def show\n if current_user\n @user = User.find(params[:id])\n if (current_user.username == 'Administrator')||(current_user.username == @user.username)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n\telse\n \tredirect_to root_url, :notice => 'Uwaga! Nie masz uprawnień!'\n \tend\n else\n redirect_to :login, :notice => 'Informacja! Zaloguj się aby obejrzeć!'\n end\n end",
"def show\n if user\n render json: user,serializer: Api::V1::MembersSerializer, :status => 201\n else\n render json: \"errors\", :status => 422\n end \n end",
"def show\n @user = current_user\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n @user = User.find(params[:id])\n @isAdmin = current_user.admin_rights\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n @test_user = current_user\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_user }\n end\n end",
"def show\n # When a http GET request to '/users/1' is received, have it show,\n # in json format, user 1's information.\n @id = params[:id]\n @user = User.find(@id)\n render json: @user\n end",
"def show\n # @user = User.find(params[:id])\n @user = current_user\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\r\n user = User.find(params[:id])\r\n if user.nil?\r\n render json: {error: true, message: \"User not found\"}\r\n else\r\n render json: user\r\n end\r\n end",
"def show\n @user = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.heml.erb\n format.json { render :json => @users }\n end\n end",
"def show\n @user = User.find(current_identity.user_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n logger.debug(\"user show\")\n @user = User.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n if params[:username]\n checkusername\n end\n end",
"def json_show_signed_user\n\n @current_user = current_user\n respond_to do |format|\n #format.json { render json: @current_user.as_json(only:[:id,:username]), status: :ok}\n if @current_user.nil?\n format.json { render json: 'user not found' , status: :not_found }\n else\n format.json { render json: @current_user.as_json(only:[:id,:username]), status: :ok}\n end\n\n\n end\n end",
"def show\n # сделать текущего пользователя адмиристратором\n #current_user.update_attribute :admin, true\n @user = User.find(params[:id])\n @title = @user.username\n #@user_internals = @user.user_internals.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n user = User.find(params[:id])\n render json: user\n end",
"def show\n user = User.find_by(id: session[:user_id])\n if user\n render json: user, status: :ok\n else\n render json: {errors: \"Not authorized\"}, status: :unauthorized\n end\n end",
"def index\n \n @user = User.find(current_user.id) \n\n respond_to do |format|\n format.html { render action: \"show\" }\n format.json { render json: @user }\n end\n end",
"def show\n # find the user by the user id in the route params\n # (this will likely be moved to its own before method)\n @user = User.find(params[:id])\n end",
"def show\n render json: user_json(@user)\n end",
"def show\n if @user.nil?\n render json: '{\"error\": \"No user with specified ID\"}'\n else\n render json: @user\n end\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def show\n if !current_user && params[:id] != current_user.id && current_user.is_admin == false\n \traise \"You are not authorized to access this function\"\n end\n @user = User.find(params[:id])\n respond_with(@user)\n end",
"def show\n @users = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @users }\n end\n end",
"def show\n respond_to do |format|\n format.json {\n render json: @user\n }\n format.html {\n\n }\n end\n end",
"def show\n respond_to do |format|\n format.json {\n render json: @user\n }\n end\n end",
"def show\n @current_user = current_user\n @user = User.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :_user }\n end\n end",
"def show\n \trender json: @user\n end",
"def show\n @user = User.find(params[:id])\n @authorized_user = User.find(session[:user_id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n json_response(@user)\n end",
"def show\n if check_user_read_access\n respond_to do |format|\n format.html { render :show }\n format.json { render json: user || {} }\n end\n end\n end",
"def show\n \t# get particular user here\n \t@user = User.find_by_id(params[:id])\n \t# if not @user\n \t# \tredirect_to \"/users\"\n \t# end\n end",
"def show\n @user = User.find(params[:id])\n if @user\n render json: {\n user: @user\n }\n else\n render json: {\n status: 500,\n errors: ['user not found']\n }\n end\n end",
"def show\n render json: User.find(params[:id])\n end",
"def show\n @user = User.find(params[:id])\n @action = 'Show'\n end",
"def show\n @user = User.find(current_user.id)\n\n respond_to do |format|\n format.html\n format.json { render json: @user }\n end\n end",
"def show\n unless @user\n render 'not_found_page'\n end\n end",
"def index\n #before_action :authenticate_user\n #if current_user.admin?\n @users = User.all\n render json: @users, status: :ok\n #else\n # render json: [], status: :unauthorized\n #end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n @user = params[:id].nil? ? current_user : User.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n user = User.find_by(id: params[:id])\n if user\n render json: {status: 200, user: user}\n else\n render json: {status: 500, message: user.errors.full_messages}\n end\n end",
"def show\n if params[:id].nil?\n render json: current_user,\n except: [\n :created_at,\n :updated_at,\n :admin_permissions\n ],\n include: {\n case_cortege: {},\n cortege: {},\n orchestra: {},\n orchestra_signup: {\n include: [\n :orchestra\n ]\n },\n funkis_application: {\n include: [\n funkis_shift_applications: {\n include: [\n funkis_shift: {\n include: [\n :funkis_category\n ],\n except: [\n :maximum_workers\n ]\n }\n ]\n }\n ],\n methods: [\n :steps_completed\n ]\n }\n },\n methods: [\n :is_lintek_member,\n :shopping_cart_count\n ]\n else\n require_admin_permission AdminPermission::LIST_USERS\n\n user = User.find(params[:id])\n if user.present?\n render json: user, include: [:funkis_application]\n else\n render :status => '404', :json => {:message => 'Användare kunde inte hittas'}\n end\n end\n end",
"def show\n @user = User.find(params[:id])\n @title = @user.name + \" \" + @user.surname\n if current_user == @user\n @this_user = true\n else\n @this_user = false\n end\n# @this_user = current_user == @user ? true : false\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n @user = AdminUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n render json: User.find(params[:id])\n end",
"def show\n @user = User.find(params[:id])\n render json:@user\n end",
"def show\n @user = User.find(params[:id])\n render json:@user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\nend",
"def show\n render json: @user, serializer: UserSerializer, status: 200\n end",
"def show\n\t\t@user = User.find(params[:id])\n\t\tauthorize @user\n\tend",
"def show \n user = User.find_by(id: session[:user_id])\n if user\n render json: user\n else \n render {error: \"Not authorized\"}, status: :unauthorized\n end\n end",
"def show\n render json: @user\n end",
"def show \n user = User.find_by(id: params[:id])\n if !user.blank?\n render status: 200, json: {\n message:\"Found User\",\n response: {\n name: user.name,\n email: user.email,\n id: user.id\n }\n }.to_json\n else \n render status: 404, json: {\n errors: \"Can't Find User\"\n }.to_json\n end \n end",
"def show\n load_user\n return if (@user.blank?)\n\n respond_to do|format|\n format.html\n end\n end",
"def show\n user = User.find(params[:id])\n render json: @user\nend",
"def show\n @user = User.find(params[:id])\n authorize @user\n end",
"def index\n @user = @current_user\n\n respond_to do |format|\n format.html { render action: \"show\" }\n format.json { render json: @user }\n end\n end",
"def show\n show_user\n end",
"def show\n @user = User.find(params[:id]) \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n\t\trender json: @user\n\tend",
"def show\n require_user()\n end",
"def show\n render json: @user\n end",
"def show\n render json: @user\n end",
"def show\n render json: @user\n end",
"def show\n render json: @user\n end",
"def show\n render json: @user\n end",
"def show\n render json: @user\n end",
"def show\n render json: @user\n end",
"def show\n render json: @user\n end",
"def show\n render json: @user\n end",
"def show\n render json: @user\n end",
"def show\n respond_to do |format|\n if @user\n format.html { render :show }\n format.json { render json: @user, status: :ok }\n else\n format.html { render(file: Rails.root.join('public', '204'), :formats => [:html], status: 204, layout: false) }\n format.json { head :no_content }\n end\n end\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end"
] | [
"0.75004846",
"0.74206525",
"0.73295814",
"0.72252816",
"0.70871323",
"0.70750296",
"0.70745564",
"0.7061335",
"0.70514286",
"0.70405805",
"0.7038469",
"0.70378447",
"0.7034503",
"0.70309144",
"0.7012312",
"0.70060533",
"0.69993234",
"0.699672",
"0.6991802",
"0.6981788",
"0.6980536",
"0.6976904",
"0.69767606",
"0.69763964",
"0.69687194",
"0.69659626",
"0.6960618",
"0.6956125",
"0.6954147",
"0.69483155",
"0.6946716",
"0.69410044",
"0.6934221",
"0.6928314",
"0.69266176",
"0.6923353",
"0.6921614",
"0.69137824",
"0.69116014",
"0.69089174",
"0.6908902",
"0.6901171",
"0.68954986",
"0.6894698",
"0.68915695",
"0.6890247",
"0.6882072",
"0.687639",
"0.6865504",
"0.6854899",
"0.68518203",
"0.6850944",
"0.68472815",
"0.6845649",
"0.68418866",
"0.68240494",
"0.68221724",
"0.6822044",
"0.68217736",
"0.68204975",
"0.68204975",
"0.68204975",
"0.68204975",
"0.68204975",
"0.6819233",
"0.6816633",
"0.6810829",
"0.68072593",
"0.67996806",
"0.6799269",
"0.67982185",
"0.67982185",
"0.6796271",
"0.67937434",
"0.6792975",
"0.6791921",
"0.679091",
"0.67878884",
"0.67861325",
"0.67853034",
"0.67851675",
"0.6772674",
"0.676934",
"0.676641",
"0.67646277",
"0.6761143",
"0.67588663",
"0.67588663",
"0.67588663",
"0.67588663",
"0.67588663",
"0.67588663",
"0.67588663",
"0.67588663",
"0.67588663",
"0.67588663",
"0.67563653",
"0.67556745",
"0.67556745",
"0.67556745",
"0.67556745"
] | 0.0 | -1 |
GET /users/1 GET /users/1.json | def show
if current_user == @user
@lender_loans = Loan.where(lender_id: @user)
@p_count = 0 #count of pending loans
@a_count = 0 #count of active loans
@c_count = 0 #count of completed loans
@lender_loans.each do |pending|
if pending.status == "Pending"
@p_count = @p_count + 1
end
end
@lender_loans.each do |active|
if active.status == "Active"
@a_count = @a_count + 1
end
end
@lender_loans.each do |completed|
if completed.status == "Completed"
@c_count = @c_count + 1
end
end
else
redirect_to profile_path(current_user)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end",
"def get \n render :json => User.find(params[:id])\n end",
"def GetUser id\n\n APICall(path: \"users/#{id}.json\")\n\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def show\n # When a http GET request to '/users/1' is received, have it show,\n # in json format, user 1's information.\n @id = params[:id]\n @user = User.find(@id)\n render json: @user\n end",
"def user\n render :json=> User.find(params[:id])\n end",
"def fetch_one_user_data\n get_url(\"/api/v1/users/#{@filter}\")\n end",
"def show\n user = User.find(params[:id])\n render json: @user\nend",
"def show\n user = User.find(params[:id])\n render json: user\n end",
"def show\n user = User.find(params[:id])\n\n render json: user\n end",
"def show\n render json: Users.find(params[\"id\"])\n end",
"def show\n user = User.find(params[:id])\n render json: user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n user = User.select(:id, :username, :email).find(params[:id])\n render :json => user\n end",
"def show\n render json: User.find(params[\"id\"])\n end",
"def show\n @users = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @users }\n end\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\nend",
"def user_info\n @user = @github.users.get user: params[:username]\n render json: Hash[@user]\n end",
"def show\n render json: User.find(params[:id])\n end",
"def show\n @user = User.find(params[:id])\n render json:@user\n end",
"def show\n @user = User.find(params[:id])\n render json:@user\n end",
"def get_by_id\n \n # the user_id param comes from our route\n user = User.find(params[:user_id])\n \n if user\n render json: user, status: :ok\n else\n render json: { errors: 'User not found' }, status: :not_found\n end\n end",
"def GetUsers params = {}\n\n params = params.merge(path: 'users.json')\n APICall(params)\n\n end",
"def get_user_details\n @user = User.find_by_id(params[:user_id])\n render json: @user\n end",
"def show\n render json: User.find(params[:id])\n end",
"def show\n user = User.find_by(id: params[:id])\n render json: user, status: :ok\n end",
"def user(id)\n self.class.get(\"/user/#{id}\", @options).parsed_response\n end",
"def show\n @user = User.find(params[:id])\n render json: {user: @user}\n end",
"def list_users\n self.class.get('/users')\n end",
"def show\n user = User.find(params[:id])\n render json: user\n end",
"def show\n user = User.friendly.find(params[:user_id]) \n render json: user\n end",
"def show\n render :json => User.find(params[:id])\n end",
"def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response[\"user\"]\n end",
"def index\n users = User.all\n json_response(users)\n end",
"def show\n @user = ActiveRecord::Base.connection.execute(\"\n SELECT * \n FROM users \n WHERE username = '#{params[:username].downcase}' \n LIMIT 1\").first\n\n respond_to do |format|\n format.html\n format.json {render json: User.find(@user[0])}\n end\n end",
"def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response.first[1]\n end",
"def show\n @users = User.all\n json_response(@users)\n end",
"def index\n json_response(User.all) \n end",
"def get(user_id:)\n path = '/users/{userId}'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::User\n )\n end",
"def index\n users = User.all\n render json: { users: users }, status: :ok\n end",
"def show\n # @user = User.first\n user = User.find(params[:id])\n render json: user\n end",
"def user(user_id, params = {})\n make_get_request(\"/users/#{user_id}\", params)\n end",
"def show_user_profile\n @user = User.find(username: params[:username])\n render json: @user\n end",
"def user(id = nil)\n id.to_i.zero? ? get('/user') : get(\"/users/#{id}\")\n end",
"def get_user id, options={}, headers={}\n @connection.get \"users/#{id}.json\", options, headers\n end",
"def user(user=nil)\n if user\n get(\"/users/#{user}\", {}, 3)\n else\n get(\"/user\", {}, 3)\n end\n end",
"def index\n \n @user = User.find(current_user.id) \n\n respond_to do |format|\n format.html { render action: \"show\" }\n format.json { render json: @user }\n end\n end",
"def show\n @user = User.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @user }\n end\n end",
"def get_user(user_id:)\n parse(JSON.parse(connection.get(\"users/#{user_id}\").body))\n end",
"def index\n user= User.all\n render json: {users:user}\n end",
"def index\r\n users = User.all\r\n render json: users\r\n end",
"def show\n # puts params[:id]\n render json: User.find(params[:id])\n end",
"def get_user_info\n id = params[\"id\"]\n error_list = []\n status = 1\n json_response = {}\n user = User.find_by(id: id)\n\n if user.nil?\n error_list.append(\"Error: The specified user doesn't exist.\")\n status = -1\n else\n json_response[\"user\"] = user.get_user_json_data\n end\n\n if status == -1\n json_response[\"errors\"] = error_list\n end\n\n json_response[\"status\"] = status\n\n # Format the json_response into proper JSON and respond with it\n json_response = json_response.to_json\n\n respond_to do |format|\n format.json { render json: json_response }\n end\n end",
"def show\n @user = User.find(params[:id])\n if @user\n render json: {\n user: @user\n }\n else\n render json: {\n status: 500,\n errors: ['user not found']\n }\n end\n end",
"def index\n users = User.all\n render json: users\n end",
"def index\n users = User.all\n render json: users\n end",
"def index\n users = User.all\n render json: users\n end",
"def index\n users = User.all\n render json: users\n end",
"def show\n @user = User.find(params[:id])\n render json: {\n username: @user.username,\n first_name: @user.first_name,\n last_name: @user.last_name,\n email: @user.email,\n phone_number: @user.phone_number,\n contacts: @user.contacts\n }, status: :ok\n end",
"def get_user(user_id)\n request(Route.new(:GET, '/users/%{user_id}', user_id: user_id))\n end",
"def show\n @user = User.find(params[:id])\n render 'api/v1/users/show'\n end",
"def index\n users = User.all\n\n render json: users, each_serializer: Api::V1::UsersSerializer\n end",
"def index\n users = User.all\n render json: users \n end",
"def user(user_id)\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n get(\"users/#{user_id}.json\", params)\n end",
"def index\n users = User.all \n render json: users \n end",
"def list\r\n users = User.all\r\n render json: users\r\n end",
"def json_show_user_profile_by_user_id\n @user = User.find(params[:user_id])\n\n respond_to do |format|\n format.json { render json: @user.as_json(only:[:email,:username]) }\n end\n end",
"def index\n\t\t# specifying json format in the URl\n\t uri = \"#{API_BASE_URL}/users.json\"\n\t # It will create new rest-client resource so that we can call different methods of it\n\t rest_resource = RestClient::Resource.new(uri, USERNAME, PASSWORD)\n\n\t # this next line will give you back all the details in json format, \n\t #but it will be wrapped as a string, so we will parse it in the next step.\n\t users = rest_resource.get \n\n\t # we will convert the return data into an array of hash. see json data parsing here\n\t @users = JSON.parse(users, :symbolize_names => true)\n\tend",
"def show\n user = User.find_by(uid: params[:id])\n if user\n puts 'USER FOUND'\n render json: user\n else\n puts 'NO USER'\n render json: 'no user'.to_json\n end\n end",
"def show\n render json: UserService.get_user(params[:id]), includes: 'questions, answers'\n end",
"def index\n @users = User.all(limit: 100)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users.as_json(user: current_user) }\n end\n end",
"def index\n render :json => User.all, status: 200\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users, status: :ok\n end",
"def show\n @users = User.find(params[:id])\n if @users\n respond_to do |format|\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n else\n head :not_found\n end\n end",
"def index\n @users = User.all\n\n render json: @users\n end",
"def index\n @users = User.all\n\n render json: @users\n end"
] | [
"0.81046426",
"0.7703556",
"0.77011716",
"0.76262826",
"0.7582106",
"0.74818",
"0.7461394",
"0.7446168",
"0.730656",
"0.7300699",
"0.72902125",
"0.72781444",
"0.72358584",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.72222257",
"0.72165024",
"0.72137505",
"0.72096044",
"0.71930283",
"0.7182953",
"0.7182144",
"0.7182144",
"0.7180289",
"0.71750754",
"0.7173851",
"0.71640617",
"0.71636444",
"0.71453786",
"0.7145053",
"0.7129776",
"0.71256554",
"0.71160513",
"0.7095665",
"0.70941204",
"0.70772994",
"0.7070785",
"0.7070607",
"0.7063351",
"0.70552826",
"0.7025071",
"0.7014598",
"0.70047677",
"0.6998373",
"0.69910055",
"0.6984177",
"0.6979766",
"0.6972448",
"0.6972228",
"0.6968384",
"0.69666255",
"0.6956339",
"0.69506294",
"0.6945614",
"0.6943135",
"0.69351804",
"0.6932212",
"0.6932212",
"0.6932212",
"0.6932212",
"0.6927094",
"0.69255126",
"0.6925136",
"0.6917375",
"0.6907744",
"0.68947464",
"0.6882589",
"0.6875701",
"0.68749416",
"0.68633634",
"0.6861618",
"0.6858055",
"0.6855495",
"0.68530583",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.6849599",
"0.6847195",
"0.6847074",
"0.6847074"
] | 0.0 | -1 |
POST /users POST /users.json | def create
@user = User.new(user_params)
return render action: 'new' unless @user.save
client = Dwolla.new
first_name = @user.first_name
last_name = @user.last_name
email = @user.email
type = "personal"
address = @user.address
city = @user.city
state = @user.state
postal_code = @user.postal_code
date_of_birth = @user.date_of_birth
last_four_of_ssn = @user.last_four_of_ssn
client.create_customer(first_name, last_name, email, type, address, city, state, postal_code, date_of_birth, last_four_of_ssn)
redirect_to user_path(@user), notice: 'Created user'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def post body=nil, headers={}\n @connection.post \"users.json\", body, headers\n end",
"def create\n # render json: params\n render json: Users.create(params[\"user\"])\n end",
"def create_user(params:)\n parse(JSON.parse(connection.post(\"users\", params.to_json).body))\n end",
"def create\n user = User.create(user_params) \n render json: user, status: :created\n end",
"def create\n user = User.new(user_params)\n if user.save\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(form_params)\n\n respond_to do |format|\n if @user.save\n format.json { render json: { users: @user }, status: :created }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.new(\n username: user_params[:username],\n password: user_params[:password])\n if user.save\n create_example_collection(user)\n render json: user, except: [:password_digest, :created_at, :updated_at]\n else\n render json: {errors: user.errors.full_messages}\n end\n end",
"def create\n user= User.create(user_params)\n render json: user\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\t@user = User.new(users_params)\n\t\tif @user.save\n\t\t\tjson_response(@user, \"User is created Successfully.\")\n\t\telse\n\t\t\trender json: {message: @user.errors.full_messages.join(\" \")}, status: 400\n\t\tend\t\t\n\tend",
"def create\n user = User.new(@user_info)\n if user.save && user.errors.empty?\n render json: { status: 200, data: UserSerializer.new(user).as_json }\n else\n render json: { status: 400, error: user.errors.full_messages }\n end\n end",
"def create\n user = User.create(user_params)\n if user.valid?\n render json: user\n else\n render json: user.errors, status: :unprocessable_entity\n end\n end",
"def create(options = {})\n request(:post, '/users.json', default_params(options))\n end",
"def create\n @user = User.new user_params(params[:user])\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new user_params(params[:user])\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.create user_params\n \n if @user.save\n respond_with(@user) do |format|\n format.json {render}\n end\n end\n end",
"def create\n @user = User.new(user_params(params))\n \n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params(params))\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params(params))\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create_user\n @user = User.new(user_params)\n if @user.save\n render json: UserSerializer.new(@user).serialized_json\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = @application.users.create(user_params)\n\n if @user.valid?\n render json: @user, status: :created, location: api_application_user_path(@application,@user)\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n user = User.create(user_params)\n if user.save\n render json: user\n else\n render json: user.errors, status: :bad\n end\n end",
"def create\n r = @api.create_user(user_params)\n respond_to do |format|\n if r.code == 201\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\n else\n response = JSON.parse(r.body)\n format.html { redirect_to users_url, alert: response['message']}\n end\n end\n end",
"def create\n\n puts '-----------------------create in user controller'\n\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: UserSerializer.new(@user).serialized_json\n else\n render json: { error: I18n.t('user_create_error') }, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n render json: { user: @user, success: 'User registration successful' }\n else\n render json: { error: 'User registration unsuccessful' }\n end\n end",
"def create\n @user = User.new(user_params)\n \n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\tputs user_params\n\t\tuser = User.new(user_params)\n\t\tif user.save\n\t\t\trender json: { user: user, status: :success }\n\t\telse\n\t\t\trender json: { status: :failure, errors: user.errors.full_messages.join('') }\n\t\tend\n\tend",
"def create\n\t\t@user = User.new(user_params)\n\t\tif @user.save\n\t\t\trender json: @user, status: :created, location: @user\n\t\telse\n\t\t\trender json: @user.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def add_user(name, value)\n self.class.post(\"/users/#{name}\",\n body: value,\n headers: {\n 'Content-Type' => 'application/json; charset=UTF-8',\n Connection: 'keep-alive',\n Accept: 'application/json, text/plain, */*'\n })\n end",
"def create\n user = User.new(user_params)\n\n respond_to do |format|\n if user.save\n render json: user, status: :ok\n else\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = current_user.users.build(user_params)\n\n if @user.save\n render json: @user\n else\n @user_items = []\n end\n end",
"def create\n user = User.new(user_params)\n render json: { status: 200, msg: 'User was created.', data: \"User Id #{user.id}\" } if user.save\n end",
"def create\n @users = User.new(params[:user])\n\n respond_to do |format|\n if @users.save\n format.html { redirect_to @users, notice: 'Regist was successfully created.' }\n format.json { render json: @users, status: :created, location: @users }\n else\n format.html { render action: \"new\" }\n format.json { render json: @users.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.new(user_params)\n if user.save\n render :json => user, :status => :created\n else\n render :json => {:ok => false, :message => user.errors}, :status => :unprocessable_entity\n end\n end",
"def create\n logger.debug user_params\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :ok\n else\n render json: @user.errors, status: :not_acceptable\n end\n end",
"def create\n user = User.create(user_params)\n render json: user, message: 'user succefully create', status: 200\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n\n up = user_params\n\n if up[:name].present?\n up[:first_name] = up[:name].split(' ')[0]\n up[:last_name] = up[:name].split(' ')[1]\n up.delete :name\n end\n @user = User.new(up)\n\n respond_to do |format|\n if @user.save\n # render json: {user: user, token: token}\n\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: api_user_url(@user)}\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.new(user_params)\n if user.save\n render json: {status: \"Se creo el usuario\"}, status: :ok\n else\n render json: {status: \"Error al crear el usuario\", errors: user.errors }, status: :unprocessable_entity\n end\n end",
"def create\n user = User.new(params[:user].permit(:username))\n if user.save\n render json: user\n else\n render json: user.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def create\n puts '>>> params:'\n puts params.inspect\n @user = User.new(params[:user])\n puts '>>> User:'\n puts @user.inspect\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n \tdata = { data: @user, status: :created, message: \"User was successfully created.\" }\n render :json => data\n else\n \tdata = { data: @user.errors, status: :unprocessable_entity }\n render :json => data\n end\n end",
"def create\n user_details = params.permit(:first_name, :last_name, :email)\n success = User.create(user_details)\n\n render json: { success: success }\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user.as_json(only: [:email, :authentication_token]), status: :created\n else\n head(:unprocessable_entity)\n end\n end",
"def create_user\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n post(\"users.json\", params)\n end",
"def create\n @user = User.new(params[:user])\n\n if @user.save\n respond_to do |format|\n format.json { render :json => @user.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { redirect_to :action => :index }\n end\n else\n respond_to do |format|\n format.json { render :text => \"Could not create user\", :status => :unprocessable_entity } # placeholder\n format.xml { head :ok }\n format.html { render :action => :new, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n render :ok, json: @user.to_json\n else\n @errors = @user.errors.full_messages\n render json: { message: @errors }, status: :unauthorized\n end\n end",
"def create\n puts params\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user.as_json(user: current_user), status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.new(user_params)\n if user.save\n render json: {status: 200, msg: 'User was created.'}\n else\n render json: {errors: user.errors.messages}\n end\n end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, :notice => 'User was successfully created.' }\n format.json { render :json => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new({name: params[:name], email: params[:email], password: params[:password], photo: params[:photo]})\n @user.save\n render json:@user\n end",
"def create\n user = User.create(user_params)\n\n if user.valid?\n render json: {user: UserSerializer.new(user), token: encode_token(user.id)}\n else\n render json: user.errors.full_messages\n end\n end",
"def create\n\t\tnew_user = User.new(user_params)\n\t\tif new_user.save\n\t\t render status: 200, json: {\n\t\t \tstatus: 200,\n\t\t message:\"New User Created\",\n\t\t response: {\n\t\t name: new_user.name,\n\t\t email: new_user.email,\n\t\t id: new_user.id,\n\t\t facebook_id: new_user.facebook_id,\n\t\t device_id: new_user.device_id,\n\t\t authentication_token: new_user.authentication_token\n\t\t }\n\t\t \n\t\t }.to_json\n\t\telse\n\t\t render status: 404, json: {\n\t\t \tstatus: 404,\n\t\t errors: new_user.errors\n\t\t }.to_json\n\t\tend\n\tend",
"def create\n\t\tresp = {} \n user = User.create(user_params)\n \tif user.valid?\n if user.save\n return render :json => user.as_json\n end\n end\n render json: user.errors.full_messages \n\tend",
"def post_users_with_http_info(users, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UsersApi.post_users ...'\n end\n # verify the required parameter 'users' is set\n if @api_client.config.client_side_validation && users.nil?\n fail ArgumentError, \"Missing the required parameter 'users' when calling UsersApi.post_users\"\n end\n # resource path\n local_var_path = '/users'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(users) \n\n # return_type\n return_type = opts[:return_type] || 'User' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UsersApi#post_users\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create_user(options = {})\n post \"/users\", options\n end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n user = User.new(user_params)\n\n if user.save\n\n render json: {status: 200, msg: 'User was created.'}\n\n else \n render json: {\n errors: user.errors.full_messages\n }, status: :unprocessable_entity\n\n end\n\n end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save \n format.html { redirect_to users_url, notice: \"User #{@user.name} was successfully created.\" }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_user(body)\n post 'create_user', body\n end",
"def create\n @user = User.new(user_params)\n @user.email = params[:email].downcase\n if @user.save\n render json: @user, status: 200\n else\n render json: { errors: @user.errors.full_messages }, status: 400\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json:@user\n elsif @user.errors\n render json: {error: {code: 400, server_message: @user.errors}}, status: :bad_request\n else\n render json: {error: {code: 500, message: \"Could not save user\", server_message: @user.errors}}, status: :internal_server_error\n end\n\n end",
"def create\n user = User.new(user_params)\n\n if user.valid?\n user.save\n render json: {user: user, token: encode_token({user_id: user.id})}\n else\n render json: {error: \"Failed to create the user\"}\n end\n end",
"def create\n @user = User.new(user_params)\n @user.save\n respond_with @user\n end",
"def create\n @user = User.new(user_params)\n render json: @user && return if @user.save\n\n render json: { error: \"Unable to save user: #{@user.errors.messages}\" }, status: 400\n end",
"def create\n params[:user][\"_id\"] = params[:user][:name]\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save()\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_user(attributes)\n post(\"/v1/users\", attributes)\n end",
"def create\n user = User.new(user_params)\n\n # if user is saved sucessfully it will return user and ith status 201 for created\n if user.save\n render json:user,status: :created\n #if request is properly served but data is wrong it ll give ubprocessable_entity with code 422\n else\n render json: user.errors, status: :unprocessable_entity\n end \n end",
"def create\r\n @user = User.new(params[:user])\r\n\r\n respond_to do |format|\r\n if @user.save\r\n format.html { redirect_to users_path, notice: 'Os dados do usuário foram salvos com sucesso!' }\r\n format.json { render json: @user, status: :created, location: @user }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @user.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @user = User.new(\n first_name: params[:first_name],\n last_name: params[:last_name],\n birth_date: params[:birth_date],\n height: params[:height],\n weight: params[:weight],\n user_name: params[:user_name],\n password: params[:password],\n password_confirmation: params[:password_confirmation],\n facebook_url: params[:facebook_url],\n twitter_url: params[:twitter_url],\n instagram_url: params[:instagram_url],\n address: params[:address],\n email: params[:email]\n ) \n if @user.save!\n render 'successful.json.jb', status: :created\n else\n render 'unsuccessful.json.jb', status: :bad_request\n end\n end",
"def post(hash)\n HttpClient::Preconditions.assert_class('hash', hash, Hash)\n @client.request(\"/users\").with_json(hash.to_json).post { |hash| Apidoc::Models::User.new(hash) }\n end",
"def create\n user = User.create!(user_params)\n session[:user_id] = user.id\n render json: user, status: :created\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: {message: \"user create successfuly\"}\n else\n render json: {message: \"Error\"}\n end \n end",
"def create\n # Insert new user in database\n user = User.new(user_params)\n\n if user.save\n # On success, send token information to authenticate user\n token = create_token(user.id, user.username)\n render json: {status: 200, token: token, user: user}\n # render json: @user, status: :created, location: @user\n else\n render json: user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(params[:user])\n @user.status = 'active'\n\n respond_to do |format|\n if @user.save\n format.json { render :json => @user, :status => :created }\n format.html { redirect_to(users_path) }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n respond_with(@user, location: users_url, notice: 'User was successfully created.')\n else\n respond_with(@user)\n end\n end",
"def create\n user = User.new(user_params)\n \n if user.save\n token = JsonWebToken.encode(user_id: user.id)\n render json: { auth_token: token, user: AuthUserSerializer.new(user).serializable_hash }, status: 201\n else \n render json: { errors: user.errors.full_messages }, status: 400\n end\n end",
"def create\n @user = User.new(params[:user])\n puts params[:user]\n respond_to do |format|\n if @user.save\n format.html { redirect_to :users, notice: 'Registration successful.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render :show, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render :show, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n user = User.create(user_params)\n if user.valid?\n user.username.downcase\n @token = issue_token(user)\n list = List.create(name: user.username)\n list.user_id = user.id\n user.save\n list.save\n render json: { user: UserSerializer.new(user), jwt: @token }, status: :created \n else \n render json: { error: user.errors.full_messages }, status: :not_acceptable\n end \n end",
"def create\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user_response = API::V1::Users.authenticate params.as_json\n if user_response.success?\n json = HashWithIndifferentAccess.new(user_response.parsed_response)\n auth_response = API::V1::Auth.issue json[:data]\n respond_with auth_response.body, auth_response.code\n else\n respond_with nil, :unauthorized\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render :json => { :status => 0 }\n else\n render :json => { :status => 1, :msg => @user.errors}\n end\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n auth_token = Knock::AuthToken.new payload: { sub: @user.id }\n render json: { username: @user.username, jwt: auth_token.token }, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n authorize :user, :create?\n @user = User.new(user_params)\n @user.save\n\n respond_to do |format|\n format.html\n format.json { render :json => @user, status: 200 }\n end\n end",
"def post_accounts(json_hash)\n @options = {:path => '/users.json',\n :body => json_hash[:json]}.merge(@options)\n\n request(\n :expects => 201,\n :method => :post,\n :body => @options[:body]\n )\n end",
"def create\n user = User.new(username: params[:username])\n if user.save\n payload = {'user_id': user.id}\n token = JWT.encode(payload, 'chatapp')\n render json: {\n user: user,\n token: token\n }\n else \n render json: { message: 'There was an error creating your account' }\n end\n end",
"def create\n user = User.create!(user_params)\n if user\n session[:user_id] = user.id\n render json: user, status: :created\n else\n render json: { errors: user.errors.full_messages }, status: :unprocessable_entity\n end\n end",
"def create\r\n @user = User.new user_params\r\n\r\n if @user.save\r\n render json: @user, serializer: SessionSerializer, root: nil\r\n else\r\n render json: { errors: @user.errors }, status: :unprocessable_entity\r\n end\r\n end",
"def create\n user = User.new(user_params)\n if user.save\n render json: { status: 'OK', msg: 'User was created.', error: 'nil' },\n status: :created\n else\n not_good(422)\n end\n end"
] | [
"0.77179813",
"0.75206673",
"0.73831296",
"0.72405374",
"0.719841",
"0.7140812",
"0.71038526",
"0.7058827",
"0.7041636",
"0.70236504",
"0.7003128",
"0.70021695",
"0.70021695",
"0.70021695",
"0.69936967",
"0.6990463",
"0.6980393",
"0.6979075",
"0.69788617",
"0.69788617",
"0.69762856",
"0.6962628",
"0.6952247",
"0.69454783",
"0.69454783",
"0.6920555",
"0.69181055",
"0.691467",
"0.6901315",
"0.6898759",
"0.689459",
"0.6889815",
"0.6880676",
"0.6880467",
"0.6880196",
"0.68797004",
"0.6877297",
"0.686924",
"0.6855058",
"0.6851115",
"0.6844058",
"0.6814104",
"0.6803589",
"0.6777842",
"0.6776859",
"0.67678535",
"0.6757897",
"0.67471397",
"0.6738628",
"0.6734963",
"0.6733872",
"0.6720612",
"0.6711659",
"0.6670256",
"0.66581875",
"0.66573423",
"0.6654514",
"0.6638977",
"0.66325235",
"0.66199607",
"0.6615226",
"0.66148156",
"0.65989614",
"0.65910506",
"0.65792614",
"0.6578957",
"0.6573529",
"0.6573351",
"0.6557221",
"0.6553408",
"0.6551572",
"0.65466446",
"0.6540912",
"0.65399504",
"0.6538697",
"0.6535891",
"0.6533581",
"0.6526114",
"0.65116656",
"0.65072525",
"0.6507116",
"0.6503024",
"0.6490388",
"0.6488653",
"0.64881754",
"0.6473845",
"0.64722794",
"0.64702916",
"0.64702916",
"0.6469406",
"0.64682525",
"0.6462379",
"0.64619774",
"0.646129",
"0.6455196",
"0.645272",
"0.6448271",
"0.6447503",
"0.64468706",
"0.64460355",
"0.6441883"
] | 0.0 | -1 |
PATCH/PUT /users/1 PATCH/PUT /users/1.json | def update
respond_to do |format|
if @user.update(user_params)
format.html { redirect_to @user, notice: 'User was successfully updated.' }
format.json { render :show, status: :ok, location: @user }
else
format.html { render :edit }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update \n user = User.find(params[:id])\n # byebug\n user.update(user_params)\n\n render json: user\n end",
"def update\n user = User.find(params[:id])\n\n # Use update with user_params to do a mass-assignment update and save. \n if user.update_attributes(user_params)\n render json: user\n else \n render json: user.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n user = User.find_by(id: params[:id])\n user.update(user_params)\n render json: user\n end",
"def update\n \trespond_to do |format|\n if @user.update(user_params)\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n\t \t\n end",
"def update\n user = find_user\n user.update!(user_params)\n render json: user\n end",
"def update\n if user.update(user_params)\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n end\n end",
"def update\n if @api_v1_user.update(api_v1_user_params)\n head :no_content\n else\n render json: @api_v1_user.errors, status: :unprocessable_entity\n end\n end",
"def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update\n @user = User.find(params[:id])\n\n if @user.update_attributes(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update_attributes(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update_user(options)\n patch(\"/user\", options, 3)\n end",
"def modify_user(user)\n query_api_object Model::User, '/rest/user', user.to_hash, 'PUT'\n end",
"def update\n user = User.find(params[:id])\n user.update(user_params)\n if user.valid?\n render json: user\n else\n render json: user.errors\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { render action: \"edit\"}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n \n end",
"def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.role = params[:type]\n @user.save\n render json:@user\n end",
"def update\n if @user.id == current_api_user.id\n if @user.update(user_params)\n render json: @user.as_json(except: [:updated_at]), status: :ok\n else\n render json: @user.errors, status: :bad_request\n end\n else\n render json: '', status: :forbidden\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user\n else\n render json: {error: \"Could not update user\"}\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n render json:@user\n else\n render json: { error: {code: 404, message: 'Invalid user' }}, status: :not_found\n end\n end",
"def update\n user = User.find(params[:id])\n if user.update(params_user)\n render json: user, status: 200\n else\n render json: user.errors, status: 422\n end\n\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update user_params(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def updateUser\n options = {\n :body => params.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n results = HTTParty.put(\"http://192.168.99.101:4051/users/\"+@current_user[\"id\"].to_s, options)\n render json: results.parsed_response, status: results.code\n end",
"def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.save\n render json:@user\n end",
"def update\n user = @user_service.update_user(params[:id])\n render json: user, status: :ok\n end",
"def update\n @user = User.find(params[:id]) \n \n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User #{@user.name} was successfully created.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user, status: 200\n else\n render json: @user.errors, status: 422\n end\n end",
"def update\n begin\n user = User.find(params[:user_id])\n if user.update(user_params)\n render json: { users: user }, status: :ok\n else\n render json: { errors: user.errors.messages }, status: 422\n end\n rescue => e\n render json: { errors: e.message }, status: 404\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if user.update(user_params)\n render json: user, status: :ok\n else\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params[:user]))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n @user.update_attributes(params[:user])\n respond_with @user\n end",
"def update\n @user = User.find(params[:id])\n @user.update_attributes(params[:user])\n respond_with @user\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User was successfully updated.' }\n\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes_from_api(params[:user])\n format.html { redirect_to @user, :notice => 'User was successfully updated.' }\n format.json { render_for_api :user, :json => @user }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @user = current_org.users.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch_user(user_id, body)\n raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?\n raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty? || body.empty?\n path = \"#{users_path}/#{user_id}\"\n patch(path, body)\n end",
"def update\n @user = User.find(params[:id])\n @user.update(user_params)\n render json: @current_user\n end",
"def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend",
"def update\n user = User.find(params[:id])\n render json: { status: 200, msg: 'User details have been updated.' } if user.update(user_params)\n end",
"def modify_user(user)\n query_api_object User, \"/rest/user\", user.dump(), \"PUT\"\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_path, :notice => 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n user = User.find(params[:id])\n if user.update(user_params)\n render json: user\n else\n render json: user.errors.full_messages\n end\n end",
"def update\n respond_to do |format|\n if @user.update(form_params)\n format.json { render json: { users: @user }, status: :ok, location: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user.update(user_params)\n respond_with @user\n end",
"def update\n @user = user.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'user was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_user\n @user = User.find(params[:id])\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = get_user(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to root_url, notice: \"User #{@user.login_name} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @v1_user.update(v1_user_params)\n format.html { redirect_to @v1_user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @v1_user }\n else\n format.html { render :edit }\n format.json { render json: @v1_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user, status: :ok\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, :notice => t('user.update_success') }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status=> :unprocessable_entity }\n end\n end\n end",
"def update\n @user.update(user_params_update)\n json_response(@user)\n end",
"def update\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to users_path }\n format.json { render :json => @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user.as_json(user: current_user), notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = selected_user\n if @user.update(users_params)\n render 'api/users/show'\n else\n render json: @user.errors.full_messages, status: 422\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.json { head :ok }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to root_path}\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = V1::User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'V1::User was successfully updated.'\n format.html { redirect_to(@user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update \n user = User.where(:id => current_user.user)\n if user.update(user_params)\n render :json => {:user => user }\n else\n render :json => {:error => user.errors.full_messages.first}\n end\nend",
"def update\n\t\tif @user.update(user_params)\n\t\t\trender json: @user\n\t\telse\n\t\t\trender json: @user.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def update\n @user = User.find(params[:id])\n \n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, :notice => 'User was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(id, params = {})\n request(:put, \"/users/#{id}\", body: params)\n end",
"def update\n @user = current_api_user\n unless @user.update(user_params)\n render json: { error: @user.errors.full_messages.to_sentence }, status: :not_found\n end\n end",
"def update\n # not_found unless @user\n # @user = User.get(params[:id]) || not_found\n\n respond_to do |format|\n if @user.update(params[:user])\n format.html { redirect_to @user, :notice => 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, :notice => \"This user was successfully updated!\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n user = User.find(params[:id])\n if user.update(user_params)\n render json: {\n status: 'OK',\n msg: 'User details have been updated.',\n error: 'nil'\n }, status: :accepted\n else\n not_good(406)\n end\n end",
"def update\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: I18n.t(:users_update) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = ::User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:todo][:id])\n if @todo.update_attributes(user_params)\n render json: @todo\n else\n render nothing: true, status: :bad_request\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to user_path(@user), notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n @current_user.update(user_params)\n render json: @current_user\n end",
"def update\n @user = User.find(params[:id])\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.72257185",
"0.71295637",
"0.7003568",
"0.69038403",
"0.68215626",
"0.6815601",
"0.67085636",
"0.66936487",
"0.6680699",
"0.6673503",
"0.6672789",
"0.6664273",
"0.6664273",
"0.6659702",
"0.6659702",
"0.66541827",
"0.66483825",
"0.6643504",
"0.6641462",
"0.6635027",
"0.66181755",
"0.6615335",
"0.6610045",
"0.6607319",
"0.65839815",
"0.6582307",
"0.6582292",
"0.65795493",
"0.6561565",
"0.6559083",
"0.6559083",
"0.65437686",
"0.6536952",
"0.6516334",
"0.65145",
"0.6506672",
"0.6505458",
"0.6505458",
"0.6501529",
"0.64681375",
"0.6466413",
"0.64641553",
"0.6452769",
"0.6449677",
"0.6443315",
"0.64419466",
"0.6437546",
"0.6428714",
"0.6428714",
"0.64277655",
"0.64271104",
"0.642709",
"0.64250064",
"0.64250064",
"0.64245033",
"0.6418738",
"0.6415706",
"0.64116204",
"0.64053607",
"0.6405239",
"0.6398179",
"0.63946134",
"0.639085",
"0.639033",
"0.6387682",
"0.6383899",
"0.6383842",
"0.6383141",
"0.63821733",
"0.63778895",
"0.6375148",
"0.63741225",
"0.63737106",
"0.63732696",
"0.63698816",
"0.6363365",
"0.6361188",
"0.6360844",
"0.6356603",
"0.6356219",
"0.6350419",
"0.63434243",
"0.6334365",
"0.63337606",
"0.63287985",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352",
"0.6327352"
] | 0.0 | -1 |
DELETE /users/1 DELETE /users/1.json | def destroy
@user.destroy
respond_to do |format|
format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete\n render json: Users.delete(params[\"id\"])\n end",
"def delete\n @user.destroy\n respond_to do |format|\n format.html { redirect_to v1_resources_users_all_path, notice: 'User was deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end",
"def destroy\n @user = V1::User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(v1_users_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n \"\"\"\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n \"\"\"\n end",
"def destroy\n debugger\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n user = User.find(params[:id]) # from url, nothing to do with table\n user.destroy\n render json: user\n end",
"def destroy\n @user.destroy\n format.json { head :no_content }\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find_by_id_or_username params[:id]\n @user.destroy\n render api_delete @user\n end",
"def delete_user\n @user = User.find(params[:id])\n if @user.destroy\n render :json => @user\n else\n render :json => @user.errors.full_messages\n end\n end",
"def destroy\n @user = user.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @v1_user.destroy\n respond_to do |format|\n format.html { redirect_to v1_users_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n \n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.7875409",
"0.7751816",
"0.7713785",
"0.76098853",
"0.74721044",
"0.74075884",
"0.74075884",
"0.7369372",
"0.7346144",
"0.7339956",
"0.7328181",
"0.7309978",
"0.73097116",
"0.73067564",
"0.7297328",
"0.72913545",
"0.7291246",
"0.72887707",
"0.72839034",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.72504604",
"0.7244771",
"0.72416055",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404",
"0.72317404"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
GET /songs/1 GET /songs/1.xml | def show
@song = Song.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def show\n @tags_songs = TagsSongs.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tags_songs }\n end\n end",
"def index\n @songs = Song.all(:order => :position)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @songs }\n end\n end",
"def show\n @song = Song.find(params[:id], :include=>[:artist, :album])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def artist_show_song\r\n\r\n\t\t#@artist = Artist.find(params[:id])\r\n\t\tsearchString = params[:url_slug]\r\n\t\t@artist = Artist.find_by_url_slug(searchString)\r\n\t\t@song = @artist.song.find.by_url_slug(params[:song_name])\r\n\r\n\t\trespond_to do |format|\r\n\t\t\tformat.html # show.html.erb\r\n\t\t\tformat.xml { render :xml => @artist }\r\n\t\tend\r\n\tend",
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @song }\n end\n end",
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @song }\n end\n end",
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @song }\n end\n end",
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @song }\n end\n end",
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @song }\n end\n end",
"def index\n @tone_library_songs = ToneLibrarySong.order(\"artist_name, title\")\n\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @tone_library_songs }\n end\n end",
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @song }\n end\n end",
"def song\n fetch('cowboy_bebop.song')\n end",
"def show\n @song = Song.find(params[:id])\n\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @playlist.to_xml }\n end\n end",
"def show\n @song = Song.find(:id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @song }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @song }\n end\n end",
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def show\n @playlist = Playlist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @playlist }\n end\n end",
"def songs\n MusicImporter.new(path).print_songs\n end",
"def index\n @playlists = Playlist.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @playlists.to_xml }\n end\n end",
"def show\n @song = Song.find(params[:id])\n render :show\n end",
"def getSong\n\t\tid = params[:songId]\n\t\tresult = GetSongFromSpotify.build.call(id)\n\t\trender json: result\n\tend",
"def index\n @songs = Song.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @songs }\n end\n end",
"def index\n @songs = Song.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @songs }\n end\n end",
"def show\n @play = Play.find(params[:id])\n\n respond_to do |format|\n format.html { redirect_to playlist_url(@play.playlist)}\n format.xml { render :xml => @play.to_xml }\n end\n end",
"def index\n \n @songs = Song.order 'id'\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @songs }\n end\n end",
"def song\n fetch('bossa_nova.songs')\n end",
"def index\n # @songs = Song.find_by_artist_id params[:artist_id]\n @songs = Song.find_all_by_artist_id params[:artist_id]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @songs }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def songs\n \t@songs = Album.find(params[:id])\n songs = RSpotify::Track.search(@songs.name)\n \t@songs = songs.map do |s_songs|\n \tSong.new_from_spotify_song(s_songs)\n end\n render json: {data:@songs}\n end",
"def index\n @song_requests = SongRequest.all\n end",
"def songs\n Song.all\n end",
"def show\n @musician = Musician.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @musician }\n end\n end",
"def songs\n Song.find_by_album(@id)\n end",
"def index\n @songs = Song.all\n @song = Song.new\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n @song = Song.all\n\n end",
"def index\n @sounds = Sound.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sounds }\n end\n end",
"def index\n @plays = Play.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @plays.to_xml }\n end\n end",
"def index\n @songs = @album.songs.all\n end",
"def show\n @song = Song.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @song }\n format.mp3 {\n file = File.read(@song.location)\n send_data(file, :type => \"audio/mpeg\", :filename => \"#{@song.id}.mp3\", :disposition => \"inline\")\n }\n end\n end",
"def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @player.to_xml(:include => :titles) }\n end\n end",
"def index\n @songs = Song.all\n end",
"def index\n @songs = Song.all\n end",
"def index\n @songs = Song.all\n end",
"def index\n @songs = Song.all\n end",
"def index\n @songs = Song.all\n end",
"def index\n @songs = Song.all\n end",
"def index\n @songs = Song.all\n end",
"def play_songs\n MusicImporter.new(path).play_song\n end",
"def songs\n Song.all\n end",
"def show\n @single_song = Song.where(id: params[:id])\n render :show\n end",
"def show\n @song = Song.find(params[:id])\n @yt_id = YoutubeSearch.search(\"#{@song.name} #{@song.artist.name}\").first['video_id']\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @song }\n end\n end",
"def show\n\t\t@artist = Artist.find(params[:id])\n\t\tdownloader = ScDownloader.new\n\t\t@tracks = downloader.get_tracks(@artist)\n\tend",
"def getQueueSongListFromSongIDs(songIDs)\n request('getQueueSongListFromSongIDs', {'songIDs' => songIDs})\nend",
"def all_songs\n end",
"def index\n @songs = Song.all\n end",
"def show\n @plays_on = PlaysOn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @plays_on }\n end\n end",
"def show\n @songs = Song.all\n end",
"def index\n @musicas = Musica.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @musicas }\n end\n end",
"def index\n @tracks = Track.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tracks }\n end\n end",
"def show\n @music = Music.friendly.find(URI.unescape(params[:id]))\n # select random genre from all the music\n # create a client object with your app credentials\n client = Soundcloud.new(:client_id => 'd99d78670c7f1d537d0ae3d67a7be95c')\n @embed_info = client.get('/oembed', :url => @music.song_api,:auto_play => true)\n end",
"def show\n @music = Music.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @music }\n end\n end",
"def index\n @songs = Song.all\n display @songs\n end",
"def show\n @songs = @set_list.songs\n end",
"def show\n @music = Music.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @music }\n end\n end",
"def songs\n @songs\nend",
"def show\n @sound = Sound.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sound }\n end\n end",
"def index\n puts \"===> MC.index 0\"\n @musicians = Musician.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @musicians }\n end\n end",
"def show\n @artist = Artist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @artist }\n end\n end",
"def song_plays\n SongPlay.where(:song_path => path)\n end",
"def show\n client_playlist = Soundcloud.new(:client_id => Rails.application.secrets.soundcloud_client_id,\n :client_secret => Rails.application.secrets.soundcloud_secret,\n :username => Rails.application.secrets.soundcloud_username,\n :password => Rails.application.secrets.soundcloud_password)\n client_track = SoundCloud.new(:client_id => Rails.application.secrets.soundcloud_client_id)\n # create an array of track ids\n track_url = Post.find(params[:id]).try(:track_url)\n # puts track_url.inspect\n embed_info = client_track.get('/oembed', :url => track_url)\n @song = embed_info['html']\n @track_id = client_track.get('/resolve', :url => track_url).id\n @playlists = client_playlist.get(\"/me/playlists\")\n end",
"def show\n @album = Album.find(params[:id])\n @potential_songs = Song.where(:artist_id => @album.artist.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end",
"def index\n if params[:q].present?\n @songs = Song.search(params[:q])\n else\n @songs = Song.all\n end\n end",
"def show\n @audio = Audio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @audio }\n end\n end",
"def show\n @play_list = PlayList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @play_list }\n end\n end",
"def index\r\n\t\t#not #nessisary\r\n\t\t#@s3_songs = AWS::S3::Bucket.find(BUCKET).objects\r\n\r\n\t\t#@songs = Song.all\r\n\t\t@artist = Artist.find_by_url_slug(params[:url_slug])\r\n\t\t@songs = @artist.songs\r\n\r\n\t\trespond_to do |format|\r\n\t\t\tformat.html # index.html.erb\r\n\t\t\tformat.xml { render :xml => @song }\r\n\t\t\tformat.json {\r\n\t\t\t\trender :json => {\r\n\t\t\t\t\t\t:success => true,\r\n\t\t\t\t\t\t:\"#content\" => render_to_string(\r\n\t\t\t\t\t\t\t\t:action => 'index.html.erb',\r\n\t\t\t\t\t\t\t\t:layout => false\r\n\t\t\t\t\t\t)\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\tend\r\n\tend",
"def list\n for song in self.songs\n puts song.name\n end\n end",
"def show\n @songs = @tag.songs\n end",
"def index\n @songs = Song.select('id, title').order('songs.created_at DESC').includes(:performers).limit(10)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @songs }\n end\n end",
"def index\n @albums = Album.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end",
"def xml_for_mp3 mp3\n m = /([^\\/]+\\/\\d{4}\\/\\d{2}\\/\\d{2}\\/\\d{4}\\s.*)\\.mp3$/.match mp3\n raise \"Ouch\" if m.nil?\n File.join 'stations', m[1] + \".xml\"\nend",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end"
] | [
"0.71872026",
"0.71872026",
"0.71872026",
"0.69846314",
"0.6810127",
"0.6683843",
"0.66091436",
"0.6525814",
"0.6518597",
"0.6518597",
"0.6518597",
"0.6518597",
"0.64852947",
"0.6483567",
"0.64577067",
"0.6454189",
"0.644389",
"0.64423215",
"0.6413461",
"0.63756496",
"0.6307959",
"0.6301814",
"0.6301479",
"0.62896854",
"0.62580603",
"0.6249335",
"0.62468153",
"0.62404066",
"0.6237154",
"0.6208978",
"0.61917806",
"0.61901146",
"0.61901146",
"0.61901146",
"0.61901146",
"0.61901146",
"0.61901146",
"0.61877954",
"0.6187014",
"0.6177155",
"0.61377585",
"0.6118241",
"0.61154157",
"0.6112318",
"0.6105116",
"0.60835266",
"0.60729426",
"0.6072608",
"0.6070279",
"0.60608983",
"0.60608983",
"0.60608983",
"0.60608983",
"0.60608983",
"0.60608983",
"0.60608983",
"0.6055795",
"0.603759",
"0.6036329",
"0.60167634",
"0.601449",
"0.60126317",
"0.59963334",
"0.59953177",
"0.59944874",
"0.59925896",
"0.5992329",
"0.59807616",
"0.5978636",
"0.59626395",
"0.59578717",
"0.5957088",
"0.595543",
"0.5949799",
"0.59493524",
"0.5935351",
"0.59254867",
"0.5925259",
"0.5922861",
"0.59196854",
"0.591705",
"0.59153366",
"0.59124595",
"0.5905795",
"0.5887686",
"0.5884695",
"0.5882081",
"0.5880577",
"0.58785546",
"0.5877021",
"0.5877021",
"0.5877021",
"0.58752745",
"0.58752745",
"0.58752745",
"0.58752745",
"0.58752745",
"0.58752745",
"0.58752745"
] | 0.64855474 | 13 |
GET /songs/new GET /songs/new.xml | def new
@song = Song.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @song }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @tags_songs = TagsSongs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tags_songs }\n end\n end",
"def new\n @song = @playlist.songs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @song }\n end\n end",
"def create\n @song = Song.new(params[:song])\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to(@song, :notice => 'Song was successfully created.') }\n format.xml { render :xml => @song, :status => :created, :location => @song }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @song.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @song = Song.new(params[:song])\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to(@song, :notice => 'Song was successfully created.') }\n format.xml { render :xml => @song, :status => :created, :location => @song }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @song.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @song = Song.new(params[:song])\n\n respond_to do |format|\n if @song.save\n flash[:note] = 'Song was successfully created.'\n format.html { redirect_to(@song) }\n format.xml { render :xml => @song, :status => :created, :location => @song }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @song.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n @playlist = Playlist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @playlist }\n end\n end",
"def new\n @artist = Artist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @artist }\n end\n end",
"def create\n @song = Song.new(params[:song])\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, :notice => 'Song was successfully created.' }\n format.json { render :json => @song, :status => :created, :location => @song }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @song.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @song = Song.new(params[:song])\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render json: @song, status: :created, location: @song }\n else\n format.html { render action: \"new\" }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n @song\n end",
"def new\n @song = Song.new\n @song.verses.build\n @song.regions.build\n\n @kinds = Kind.all()\n @regions = Region.all()\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song }\n end\n end",
"def create\n @tags_songs = TagsSongs.new(params[:tags_songs])\n\n respond_to do |format|\n if @tags_songs.save\n flash[:notice] = 'TagsSongs was successfully created.'\n format.html { redirect_to(@tags_songs) }\n format.xml { render :xml => @tags_songs, :status => :created, :location => @tags_songs }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tags_songs.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end",
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end",
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end",
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end",
"def create\n @song = Song.new(params[:song])\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render json: @song, status: :created, location: @song }\n else\n format.html { render action: \"new\" }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @song = Song.new(params[:song])\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render json: @song, status: :created, location: @song }\n else\n format.html { render action: \"new\" }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @musician = Musician.new\n @music = Music.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @musician }\n end\n end",
"def create\n @song = @artist.songs.new(song_params)\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render action: 'show', status: :created, location: @song }\n else\n format.html { render action: 'new' }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\r\n @song = Song.new\r\n end",
"def new\n @plays_on = PlaysOn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @plays_on }\n end\n end",
"def new\n @music = Music.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @music }\n end\n end",
"def new\n @song = Song.new\n end",
"def new\n @song = Song.new\n end",
"def new\n @song = Song.new\n end",
"def new\n @song = Song.new\n end",
"def new\n @track = Track.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @track }\n end\n end",
"def new\n @track = Track.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @track }\n end\n end",
"def new\n @music = Music.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @music }\n end\n end",
"def new\n @music = Music.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @music }\n end\n end",
"def new\n @music = Music.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @music }\n end\n end",
"def create\n @song = Song.new(song_params)\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render action: 'show', status: :created, location: @song }\n else\n format.html { render action: 'new' }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @noun = Noun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @noun }\n end\n end",
"def create\n @song = Song.new(song_params)\n\n if @song.save\n render :show, status: :created, location: @song\n else\n render json: @song.errors, status: :unprocessable_entity\n end\n end",
"def new \n @album = Album.new(params[:album])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end",
"def new\n @sound = Sound.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sound }\n end\n end",
"def create\n @song = Song.new(song_params)\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render :show, status: :created, location: @song }\n else\n format.html { render :new }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @song = Song.new(song_params)\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render :show, status: :created, location: @song }\n else\n format.html { render :new }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @song = Song.new(song_params)\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render :show, status: :created, location: @song }\n else\n format.html { render :new }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @play = Play.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @play }\n format.json { render :json => @play }\n end\n end",
"def create\n #@song = Song.new(song_params)\n @song = @artist.songs.new(song_params)\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render action: 'show', status: :created, location: @song }\n else\n format.html { render action: 'new' }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @song = Song.new(song_params)\n\n respond_to do |format|\n if @song.save\n flash[:success] = ' Song was successfully created.'\n format.html { redirect_to @song }\n format.json { render :show, status: :created, location: @song }\n else\n format.html { render :new }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def create\n @song = Song.new(song_params)\n @song.artist = get_artist(params)\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render :show, status: :created, location: @song }\n else\n format.html { render :new }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @song = Song.new(params[:song])\r\n if @song.save\r\n flash[:success] = \"\\\"#{@song.title}\\\" song has been added to the song library.\"\r\n redirect_to edit_song_path(@song)\r\n else\r\n render 'new'\r\n end\r\n end",
"def create\n if @song = Song.create(song_params)\n redirect_to songs_path\n else\n render :new\n end\n end",
"def new\n @music = Music.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @music }\n end\n \n end",
"def index\n @songs = Song.all\n @song = Song.new\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def new_releases\n api_call(\"https://api.spotify.com/\",\"/v1/browse/new-releases\")\n end",
"def new\n @fine_artist = FineArtist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fine_artist }\n end\n end",
"def create\n\t\tparams = song_params\n\t\tsongkey = params['song_key']\n\t\tparams.delete('song_key')\n\n songtags = params['tags']\n params.delete('tags')\n\n\t\t@song = Song.new(params)\n\n\t\trespond_to do |format|\n\t\t\tif @song.save\n\n\t\t\t\tif songkey.to_s.length > 0\n\t\t\t\t\t@song.song_keys << SongKey.find(songkey)\n\t\t\t\tend\n\n if !songtags.nil?\n @tags = []\n for tagid in songtags\n @tags.push(Tag.find(tagid))\n end\n @song.tags = @tags\n end\n\n#\t\t\t\tformat.html { redirect_to songs_url, notice: \"#{@song.name} was successfully added!\" }\n\t\t\t\tformat.html { redirect_to action: \"show\", id: @song.id, notice: \"#{@song.name} was successfully added!\" }\n\t\t\t\tformat.json { render :show, status: :created, location: @song }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @song.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n puts params[:song]\n @song = Song.new params[:song]\n create_song @song\n\n respond_to do |format|\n if @song.save\n format.html {\n render :json => [@song.to_jq_upload].to_json,\n :content_type => 'text/html',\n :layout => false\n }\n format.json { render json: [@song.to_jq_upload].to_json, status: :created, location: @song }\n else\n format.html { render action: \"new\" }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @song_like = SongLike.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song_like }\n end\n end",
"def new\n @thing = Thing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @artist_product }\n end\n end",
"def new\n @play_list = PlayList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @play_list }\n end\n end",
"def new\n @artists = Artist.find(:all)\n @features = Feature.find(:all)\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end",
"def new\n @playlist = Playlist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @playlist }\n end\n end",
"def new\n @playlist = Playlist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @playlist }\n end\n end",
"def new\n @album = current_account.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end",
"def create\n respond_to do |format|\n if create_song\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render :show, status: :created, location: @song }\n else\n format.html { render :new }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @playing = Playing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @playing }\n end\n end",
"def new\n @audio = Audio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @audio }\n end\n end",
"def create\n @song = Song.new(params[:song])\n \n\tputs \"getting read to do the respond_to\"\n respond_to do |format|\n \t puts \"prepping save\" \n \t save_result = @song.save\n \t puts \" . .. . have save_result #{save_result}\"\n if save_result\n \tputs \" save succesful\"\n format.html { redirect_to(@song, :notice => 'Song was successfully created.') }\n format.xml { render :xml => @song, :status => :created, :location => @song }\n else\n \tputs \"FAILURE for save!\"\n format.html { render :action => \"new\" }\n format.xml { render :xml => @song.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n # @playlist = Playlist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: { playlist: @playlist } }\n end\n end",
"def new\n @song_genre = SongGenre.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song_genre }\n end\n end",
"def new\n @thing_list = ThingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing_list }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def new\n @podcast = Podcast.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @podcast }\n end\n end",
"def new\n @podcast = Podcast.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @podcast }\n end\n end",
"def new\n @art = Art.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @art }\n end\n end",
"def create\n @song = Song.new(params[:song])\n @song.created_by = current_user\n @song.updated_by = current_user\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to(@song, :notice => 'Song was successfully created.') }\n format.xml { render :xml => @song, :status => :created, :location => @song }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @song.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @player = Player.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @player }\n end\n end",
"def new\n @player = Player.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @player }\n end\n end",
"def new\n @player = Player.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @player }\n end\n end",
"def new\n @player = Player.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @player }\n end\n end",
"def new\n @player = Player.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @player }\n end\n end",
"def create\n\n artist_id = artist_exist_or_new(params[:artist_name])\n\n album_id = album_exist_or_new(params[:album_name], params[:genre], artist_id)\n\n @song = Song.new(song_params)\n @song.album_id = album_id\n\n respond_to do |format|\n if @song.save\n format.html { render '/shared/created'}\n format.json { render action: 'show', status: :created, location: @song }\n else\n format.html { render action: 'new' }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @playlist_line = PlaylistLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @playlist_line }\n end\n end",
"def create\n @song = Song.new(autofill_vorbis_comments(song_params()))\n # artist = Artist.find_by(name: params[\"song\"][\"artist\"])\n # @song.artist = artist\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render :show, status: :created, location: @song }\n else\n format.html { render :new }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.js\n format.json { render json: @song }\n end\n end",
"def new\n @comment = @song.comments.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @song = Song.new\n save_referrer\n end",
"def new\n @title = Title.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @title }\n end\n end",
"def new\n @title = Title.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @title }\n end\n end"
] | [
"0.7286893",
"0.7229135",
"0.71294427",
"0.71294427",
"0.71294427",
"0.71294427",
"0.7113181",
"0.7113181",
"0.7089227",
"0.7089227",
"0.705693",
"0.691341",
"0.68660915",
"0.66852117",
"0.66736627",
"0.6627354",
"0.65915114",
"0.6588537",
"0.65839016",
"0.65839016",
"0.65839016",
"0.65839016",
"0.65693605",
"0.65693605",
"0.6552759",
"0.65362674",
"0.65345",
"0.6530548",
"0.6508225",
"0.65010595",
"0.65010595",
"0.65010595",
"0.65010595",
"0.64959955",
"0.64959955",
"0.64942867",
"0.64942867",
"0.64942867",
"0.64842546",
"0.6480096",
"0.6460552",
"0.64562774",
"0.6450351",
"0.64289826",
"0.64289826",
"0.64289826",
"0.6426854",
"0.6426769",
"0.6419642",
"0.6414557",
"0.6414557",
"0.6414557",
"0.64118797",
"0.6408531",
"0.63876945",
"0.6377032",
"0.63740134",
"0.6362686",
"0.6357527",
"0.63417536",
"0.6336995",
"0.6329225",
"0.6328684",
"0.63249683",
"0.6318051",
"0.6298973",
"0.6248979",
"0.62447554",
"0.62447554",
"0.62438196",
"0.62298095",
"0.62275803",
"0.62223387",
"0.62093645",
"0.6199083",
"0.61761206",
"0.6166877",
"0.61451477",
"0.6143736",
"0.61432254",
"0.6142976",
"0.61379665",
"0.6132122",
"0.6132122",
"0.6132122",
"0.6132122",
"0.6132122",
"0.6117097",
"0.61163867",
"0.61153984",
"0.6079944",
"0.60767823",
"0.6068548",
"0.60655147",
"0.60655147"
] | 0.7696563 | 4 |
DSL for 0arity predicates | def <<(goals); TempClause.new(@db, self, []) << goals; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nonzero?() end",
"def zero?()\n #This is a stub, used for indexing\n end",
"def zero?() end",
"def zero?() end",
"def nonzero?; end",
"def none?\n fail NotImplementedError\n end",
"def none?; end",
"def none?; end",
"def none?; end",
"def zero?; end",
"def zero?; end",
"def arity\n nil\n end",
"def zero?\n end",
"def nothing(_)\n end",
"def zero *args\n args.empty? ? 0.0 : args.first.curry[0.0]\nend",
"def arity\n -1\n end",
"def test_zero\r\n args = Args.new\r\n assert_equal false, args.check_args(0)\r\n end",
"def if_proc=(_arg0); end",
"def cond=(_arg0); end",
"def cond=(_arg0); end",
"def cond=(_arg0); end",
"def arity(*) end",
"def test_zero_prospectors\n\t\tassert check_args([1, 0])\n\tend",
"def empty?(*args, **_arg1, &block); end",
"def never?; end",
"def requirements=(_arg0); end",
"def requirements=(_arg0); end",
"def any; end",
"def conditionally(*) end",
"def conditionally(*) end",
"def positive?; end",
"def !@; LogicalLambda.new {|*args| !call(*args)}; end",
"def test_zero\n args = Arguments.new\n assert_equal false, args.check_args(0)\n end",
"def arity; 2; end",
"def not( arg ); { $not => arg } end",
"def nil?() end",
"def nil?() end",
"def policy1(*_)\n return true\nend",
"def arity() end",
"def arity() end",
"def returns_something?; @return_type || !@returned_arguments.empty? end",
"def optional; end",
"def test_emptySkill\n f = SkillFilter.new()\n new_list = [].find_all{|x| f.apply(x)}\n return new_list.size == 0\n end",
"def fallbacks=(_arg0); end",
"def test_kindArmorNullValue\n f = ArmorFilter.new(\"kind\")\n new_list = @baseItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end",
"def checks=(_arg0); end",
"def test_nonzero_arguments\n args_checker = ArgsChecker.new\n arr = [1]\n assert_equal false, args_checker.check_mode(arr)\n end",
"def not _args\n \"not _args;\" \n end",
"def strict_filters=(_arg0); end",
"def kind_of?(p0) end",
"def nothing; end",
"def test_emptyUsableItem\n f = UsableItemFilter.new()\n new_list = [].find_all{|x| f.apply(x)}\n return new_list.size == 0\n end",
"def nil?; false; end",
"def despined?(*)\n end",
"def none_of(*queries)\n raise ArgumentError, 'Called none_of() with no arguments.' if queries.none?\n\n AlternativeBuilder.new(:negative, @scope, *queries).build\n end",
"def assert_predicate(o1, op, msg = T.unsafe(nil)); end",
"def test_emptyArmor\n f = ArmorFilter.new()\n new_list = [].find_all{|x| f.apply(x)}\n return new_list.size == 0\n end",
"def returns=(_arg0); end",
"def true(_argvs)\n return nil\n end",
"def test_nonexistent_predicate\n assert_raises(ArgumentError) { @valid_source.predicate(:idontexist, \"something\") }\n end",
"def arity; end",
"def test_neither_element_is_zero\n\t\tp = Print.new\n\t\trefute(p.one_type_is_zero?([1,1]))\n\tend",
"def nothing(param1)\n end",
"def -(arg0)\n end",
"def -(arg0)\n end",
"def refute_predicate(o1, op, msg = T.unsafe(nil)); end",
"def non_polymorphic_collection?(param0 = T.unsafe(nil)); end",
"def apply; nil; end",
"def test_healingSkillNullValue\n f = SkillFilter.new(\"healing\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end",
"def noop\n -> { }\n end",
"def zero function = nil\n function ? function.call(0) : 0\n end",
"def test_negative_should_take_no_arguments\n assert_equal(0, cli_class.instance_method(:negative).arity)\n end",
"def test_both_are_zero\n\t\tp = Print.new\n\t\trefute(p.one_type_is_zero?([0,0]))\n\tend",
"def zero(*args)\n return 0.0 if args.length == 0\n eval \"0 #{args[0][0]} args[0][1]\"\nend",
"def policy=(_arg0); end",
"def inverse_of=(_arg0); end",
"def empty(r0)\n source, stop_index = r0.source, r0.stop_index\n factor_result(source, stop_index, stop_index)\n end",
"def negative?; end",
"def zero?(a)\n a == 0\n end",
"def base(criteria = T.unsafe(nil)); end",
"def have_none_of_selectors(...)\n Matchers::HaveNoSelectors.new(...)\n end",
"def nil?() true; end",
"def test_emptyBaseItem\n f = BaseItemFilter.new()\n new_list = [].find_all{|x| f.apply(x)}\n return new_list.size == 0\n end",
"def no? ; true ; end",
"def positive; end",
"def positive; end",
"def any\n '*'\n end",
"def blank_predicate_filters_must_search_any\n @query.filters.each { |f| f.op = :is_any if f.pred_uri.blank? }\n end",
"def void0(*args)\n return 0\n end",
"def is_a?(p0) end",
"def invertible_for?(_)\n false\n end",
"def zero?\n value == 0 \n end",
"def falsey()\n lambda { |obj| !obj }\nend",
"def |(arg0)\n end",
"def |(arg0)\n end",
"def |(arg0)\n end",
"def add_predicate; end",
"def test_no_argument_case\n result = interpret 'one=->(a) { true };%one(1)'\n assert result\n end",
"def nothing\nend",
"def may?(*args)\n true\n end",
"def discard=(_arg0); end"
] | [
"0.61447525",
"0.6110208",
"0.5971578",
"0.5971578",
"0.5879392",
"0.58148926",
"0.5774028",
"0.5774028",
"0.5774028",
"0.57738477",
"0.57738477",
"0.5749259",
"0.5728354",
"0.57214344",
"0.5711479",
"0.5698141",
"0.5668301",
"0.5642106",
"0.5608909",
"0.5608909",
"0.5608909",
"0.5594837",
"0.5584126",
"0.55791277",
"0.55789185",
"0.5577495",
"0.5577495",
"0.5562407",
"0.5555174",
"0.5555174",
"0.5525313",
"0.5498157",
"0.54969114",
"0.5489109",
"0.5487436",
"0.5470899",
"0.5470899",
"0.54664415",
"0.54452264",
"0.54452264",
"0.54388416",
"0.54386866",
"0.5426686",
"0.5416562",
"0.541239",
"0.53987277",
"0.5398379",
"0.5382399",
"0.53816515",
"0.5363392",
"0.53625184",
"0.5359045",
"0.5352281",
"0.5334996",
"0.5330965",
"0.5321141",
"0.53141975",
"0.53111726",
"0.529673",
"0.52959543",
"0.5291608",
"0.5284412",
"0.52835786",
"0.5256219",
"0.5256219",
"0.5243367",
"0.52419174",
"0.52367795",
"0.5232596",
"0.52311224",
"0.52077657",
"0.5201897",
"0.5192554",
"0.5189189",
"0.5184087",
"0.51817393",
"0.5180634",
"0.5180147",
"0.5171198",
"0.5167893",
"0.51457095",
"0.51454836",
"0.5142607",
"0.5136977",
"0.51291394",
"0.51291394",
"0.5128622",
"0.5126684",
"0.51261556",
"0.5115301",
"0.51071155",
"0.5105691",
"0.50920117",
"0.5088732",
"0.5088732",
"0.5088732",
"0.5076868",
"0.5073837",
"0.50729126",
"0.5067249",
"0.50600487"
] | 0.0 | -1 |
=> Launch the Application | def run(argv = ARGV)
# => Parse CLI Configuration
cli = Options.new
cli.parse_options(argv)
# => Parse JSON Config File (If Specified and Exists)
json_config = Util.parse_json_config(cli.config[:config_file] || Config.config_file)
# => Grab the Default Values
default = Config.options
# => Merge Configuration (CLI Wins)
config = [default, json_config, cli.config].compact.reduce(:merge)
# => Apply Configuration
Config.setup do |cfg|
cfg.config_file = config[:config_file]
cfg.cache_timeout = config[:cache_timeout].to_i
cfg.bind = config[:bind]
cfg.port = config[:port]
cfg.environment = config[:environment].to_sym.downcase
cfg.do_api_key = config[:do_api_key]
end
# => Launch the API
API.run!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def launch_app\n @bridge.launch_app\n end",
"def launch(app_name, *options)\n options = combine_options(*options)\n \n compatible_call :launch, app_name, options\n end",
"def launch(app_name, *options)\n options = combine_options(*options)\n\n ensure_window = nil\n begin\n ensure_window = send(\"ensure_window_for_#{ app_name.downcase }\")\n rescue\n end\n ensure_window ||= \"\"\n\n positioning = nil\n begin\n positioning = send(\"positioning_for_#{ app_name.downcase }\")\n rescue\n end\n unless positioning\n if options[:to]\n pos = \"#{options[:to][:left]}, #{options[:to][:top]}\"\n dims = \"#{options[:to][:left] + options[:to][:width]}, \" +\n \"#{options[:to][:top] + options[:to][:height]}\"\n if options[:to][:width]\n positioning = \"set bounds of front window to {#{pos}, #{dims}}\"\n else\n positioning = \"set position of front window to {#{pos}}\"\n end\n end\n end\n\n execute_applescript(%Q`\n tell application \"#{app_name}\"\n activate\n #{ensure_window}\n #{positioning}\n end tell\n `)\n end",
"def launch(url)\n Java::limelight.Context.instance.os.launch(url)\n end",
"def launch(app_id, args)\n runcmd 'launch', \"#{app_id} #{args}\" \n end",
"def launch(app_name, options)\n ensure_window = nil\n begin\n ensure_window = movie.send(\"ensure_window_for_#{ app_name.downcase }\")\n rescue\n end\n ensure_window ||= \"\"\n\n positioning = nil\n begin\n positioning = movie.send(\"positioning_for_#{ app_name.downcase }\")\n rescue\n end\n unless positioning\n if options[:to]\n pos = \"#{options[:to][:left]}, #{options[:to][:top]}\"\n dims = \"#{options[:to][:left] + options[:to][:width]}, \" +\n \"#{options[:to][:top] + options[:to][:height]}\"\n if options[:to][:width]\n positioning = \"set bounds of front window to {#{pos}, #{dims}}\"\n else\n positioning = \"set position of front window to {#{pos}}\"\n end\n end\n end\n\n execute_applescript(%Q`\n tell application \"#{app_name}\"\n activate\n #{ensure_window}\n #{positioning}\n end tell\n `)\n end",
"def launch\n install\n\n # If the app is the same, install will not launch the simulator.\n # In order to launch the app, the simulator needs to be running.\n # launch_simulator ensures that the sim is launched and will not\n # relaunch it.\n launch_simulator\n\n tries = app_launch_retries\n\n RunLoop.log_debug(\"Trying #{tries} times to launch #{app.bundle_identifier} on #{device}\")\n\n last_error = try_to_launch_app_n_times(tries)\n\n if last_error\n raise RuntimeError, %Q[\nCould not launch #{app.bundle_identifier} on #{device} after trying #{tries} times:\n\n#{last_error}:\n\n#{last_error.message}\n\n]\n end\n\n wait_for_app_launch\n end",
"def open\n app = heroku.info(extract_app)\n url = app[:web_url]\n display \"Opening #{url}\"\n Launchy.open url\n end",
"def run file_name \n\t\tapplication = select_app file_name \n\t\tsystem \"#{application} #{file_name}\" \n\tend",
"def app_mgmt_launch_app(screen, app)\r\n\r\n if (app == \"Eclipse\")\r\n\t\tspawn(\"sudo #{Cosmos::USERPATH}/../eclipse/eclipse/eclipse\")\r\n elsif (app == \"AppGen\")\r\n\t\tspawn(\"java -jar #{CFS_KIT_GEN_APP_DIR}/CreateApp.jar\")\r\n elsif (app == \"APP_SUMMARY\")\r\n display(\"CFS_KIT APP_SUMMARY_SCREEN\",50,50)\r\n else\r\n prompt(\"Error in screen definition file. Undefined commmand sent to app_mgmt_launch_app()\")\r\n end\r\n\r\nend",
"def launch(abort_on_error = false)\n begin\n raise \"See `miga -h`\" if action.nil?\n\n action.launch\n rescue => err\n $stderr.puts \"Exception: #{err}\"\n $stderr.puts ''\n err.backtrace.each { |l| $stderr.puts \"DEBUG: #{l}\" }\n abort if abort_on_error\n err\n end\n end",
"def run file_name\n\t\tapplication = select_app file_name\n\t\tsystem \"#{application} #{file_name}\"\n\tend",
"def launch_native\n if !File.exist? 'build/app'\n puts \"No native app built!\"\n exit\n end\n `( cd build && ./app )`\nend",
"def launch_native\n if !File.exists? 'build/app'\n puts \"No native app built!\"\n exit\n end\n `( cd build && ./app )`\nend",
"def run file_name \n application = select_app file_name \n system \"#{application} #{file_name}\" \n end",
"def simulatorDeviceLaunch\n\tsimulatorLaunch \nend",
"def cfs_kit_launch_app(screen, app)\n\n\n if (app == \"UPDATE_TUTORIAL\")\n # An exception will report any errors \n if cfs_kit_create_tutorial_screen\n prompt (\"Successfuly created tutorial screen file #{tutorial_scr_file}\\nusing #{tutorial_def_file}\")\n end\n elsif (app == \"PROTO_APPP\")\n #TODO - Investigate generic text table editor or tutorial screen\n\t Cosmos.run_process(\"ruby lib/OskCfeFileViewer -f '/mnt/hgfs/OpenSatKit/cosmos/cfs_kit/file_server/cfe_es_syslog.dat'\")\n\t #Cosmos.run_process(\"ruby lib/OskTxtFileViewer -f '/mnt/hgfs/OpenSatKit/cosmos/test.json'\")\n #require 'osk_tbl_editor'\n #Cosmos.run_process(\"ruby lib/OskTblEditor\")\n\t #require 'cfs_fcx_cmdgen'\n #Cosmos.run_process(\"ruby lib/CfsFcxCmdGen\")\n #Cosmos.run_process(\"ruby tools/ConfigEditor\")\n #Cosmos::OskTblEditor.run\n #Cosmos.run_cosmos_tool('ConfigEditor')\n\n elsif (app == \"TUTORIAL\")\n cfs_kit_launch_tutorial_screen\n end\n\nend",
"def run file_name\n application = select_app file_name\n system \"#{application} #{file_name}\"\n end",
"def run file_name\n application = select_app file_name\n system \"#{application} #{file_name}\"\n end",
"def launch_web\n if !File.exist? 'build/app.html'\n puts \"No web app built!\"\n exit\n end\n open_cmd = 'open'\n case RUBY_PLATFORM\n when /linux/\n open_cmd = \"xdg-#{open_cmd}\"\n when /mingw/\n open_cmd = \"start\"\n end\n system \"#{open_cmd} build/app.html\"\nend",
"def launch\n # To be overriden in subclass,\n # not implemented here.\n raise NotImplementedError\n end",
"def run( file_name )\n application = select_app( file_name )\n system( \"#{application} #{file_name}\" )\n end",
"def launch_web\n if !File.exists? 'build/app.html'\n puts \"No web app built!\"\n exit\n end\n open_cmd = 'open'\n case RUBY_PLATFORM\n when /linux/\n open_cmd = \"xdg-#{open_cmd}\"\n when /mingw/\n open_cmd = \"start\"\n end\n system \"#{open_cmd} build/app.html\"\nend",
"def run(file_name)\n application = select_app(file_name)\n system \"#{application} #{file_name}\"\n end",
"def start_app\n OSX.NSApplicationMain(0, nil) unless Rucola::RCApp.test? || ENV['DONT_START_RUBYCOCOA_APP']\n end",
"def roby_app_start(*args, silent: false, **options)\n pid = roby_app_spawn(*args, silent: silent, **options)\n interface = assert_roby_app_is_running(pid)\n [pid, interface]\n end",
"def launch_exe\n @game_info['launch_exe']\n end",
"def exe(*args)\r\n app.exe(self, args)\r\n end",
"def clickJSDialog_NewProcess(button = \"OK\" )\n\n myapp = \"#{@path_to_clicker}clickJSDialog.rb #{button}\"\n log \"Starting win clicker in a new process. Looking for button #{button}\"\n log \"Starting app: #{myapp}\"\n winsystem( \"start #{myapp}\" )\n\n #if winsystem( myapp ) == false\n # log \"Clicker failed to start...\" \n # log $? # some sort of lasterror ?????\n #end\n end",
"def lauch_mobile_app(app_package)\r\n stdout, stderr, status = adb_exec(\"shell monkey -p #{app_package.to_s.strip} -c android.intent.category.LAUNCHER 1\")\r\nrescue Exception => e\r\n raise(\"lauch_mobile_app => Error launching the app with package: #{app_package}.\r\n \\nException => #{e.message}\r\n \\nConsole output => #{[stdout, stderr, status]}\")\r\nend",
"def launch_apple(device)\n case device\n when 'ios'\n if !File.exist? 'build/ios/build/Release-iphonesimulator/MyApp.app'\n puts \"No iOS app built!\"\n exit\n end\n puts `simple2d simulator --open \"iPhone X\" &&\n simple2d simulator --install \"build/ios/build/Release-iphonesimulator/MyApp.app\" &&\n simple2d simulator --launch \"Ruby2D.MyApp\"`\n when 'tvos'\n if !File.exist? 'build/tvos/build/Release-appletvsimulator/MyApp.app'\n puts \"No tvOS app built!\"\n exit\n end\n puts `simple2d simulator --open \"Apple TV 4K\" &&\n simple2d simulator --install \"build/tvos/build/Release-appletvsimulator/MyApp.app\" &&\n simple2d simulator --launch \"Ruby2D.MyApp\"`\n end\nend",
"def launch_apple(device)\n case device\n when 'ios'\n if !File.exists? 'build/ios/build/Release-iphonesimulator/MyApp.app'\n puts \"No iOS app built!\"\n exit\n end\n puts `simple2d simulator --open \"iPhone XR\" &&\n simple2d simulator --install \"build/ios/build/Release-iphonesimulator/MyApp.app\" &&\n simple2d simulator --launch \"Ruby2D.MyApp\"`\n when 'tvos'\n if !File.exists? 'build/tvos/build/Release-appletvsimulator/MyApp.app'\n puts \"No tvOS app built!\"\n exit\n end\n puts `simple2d simulator --open \"Apple TV 4K\" &&\n simple2d simulator --install \"build/tvos/build/Release-appletvsimulator/MyApp.app\" &&\n simple2d simulator --launch \"Ruby2D.MyApp\"`\n end\nend",
"def launch!\n introduction\n # action loop\n result = nil\n until result == :quit do\n action, args = get_action\n result = do_action(action, args)\n end\n conclusion\n end",
"def launch(cmd, &block)\n\t\tself.class.launch(cmd, &block)\n\tend",
"def relaunch\n if ENV['NO_LAUNCH'].nil?\n Calabash::Cucumber::SimulatorHelper.relaunch(app_path,ENV['SDK_VERSION'],ENV['DEVICE'] || 'iphone')\n end\nend",
"def launch\n\n user = session[:user]\n\n lp_id = params[:id]\n\n lp = begin\n\n LaunchPermission.find lp_id\n\n rescue Exception => e\n\n return error_redirect(\"launch permission not found\")\n end\n\n if not lp.may_launch(user)\n #\n # preventing URLs from being fed directly to the webapp\n\n return error_redirect(\"not authorized to launch : #{lp.url}\")\n end\n\n fei = nil\n\n begin\n\n #fei = $openwferu_engine.launch(url)\n\n li = OpenWFE::LaunchItem.new\n li.workflow_definition_url = lp.real_url\n li.launcher = user.name\n fei = $openwferu_engine.launch li\n\n flash[:notice] = \"launched process '#{fei.workflow_instance_id}'\"\n\n session[:launched_fei] = fei\n\n rescue Exception => e\n\n #flash[:notice] = \"failed to launch : #{e.to_s}\"\n\n raise e\n end\n\n sleep 0.777\n #\n # give some time for the engine to proceed and store a potential workitem\n # for this user (the user doing the launch)\n\n wi = OpenWFE::Extras::Workitem.find_just_launched fei.wfid, user.name\n\n if wi\n #\n # follow\n #\n redirect_to :controller => :workitem, :action => :edit, :id => wi.id\n else\n #\n # else, stay in the launchp view\n #\n redirect_to :action => :index\n end\n end",
"def launch_browser(url)\n case RUBY_PLATFORM\n when /darwin/\n system \"open\", url\n when /mswin|mingw|cygwin/\n system \"start\", url\n else\n system \"xdg-open\", url\n end\n end",
"def open\n require \"launchy\"\n\n Launchy.open(BASE_URL)\n end",
"def start\n ucommand(:start)\n end",
"def open\n # Opening the simulator with a specific UDID will boot the device\n if booted\n shutdown\n end\n sim = %x[/usr/bin/xcode-select -p].gsub(\"\\n\", \"/Applications/iOS Simulator.app\")\n %x[open -g -a '#{sim}' --args -CurrentDeviceUDID #{self.id}]\n sleep 0.5\n end",
"def applicationDidFinishLaunching(notification)\n @app_name = NSBundle.mainBundle.infoDictionary['CFBundleDisplayName']\n setupMainPanel\n end",
"def secondDeviceLaunch\n\tsecondRealDeviceLaunch \nend",
"def main\n @app.main\n end",
"def default_start_program\n _init_command('start')\n end",
"def thridDeviceLaunch\n\tthirdRealDeviceLaunch \nend",
"def launch(opts)\n app_path = opts.delete(:path) || opts.delete(:app_path)\n dir_path = opts.delete(:dir) || opts.delete(:cd)\n args = opts.delete(:args) || opts.delete(:argv)\n\n launch_app app_path, dir_path, args\n\n defaults = {timeout: LAUNCH_TIMEOUT,\n raise: WinGui::Errors::InitError.new(\"Unable to launch App with #{opts.inspect}\")}\n find(defaults.merge opts)\n end",
"def run\r\n # Evaluate any launch params\r\n if ARGV.any?\r\n # Set data text to params joined by spaces\r\n @data_edit.set_text(ARGV.join ' ')\r\n end\r\n # Show main widget and execute application\r\n @main_widget.show\r\n self.exec\r\n end",
"def launch_sim(opts={})\n unless sim_is_running?\n default_opts = {:post_launch_wait => 2.0}\n merged_opts = default_opts.merge(opts)\n `xcrun open -g -a \"#{sim_app_path}\"`\n sleep(merged_opts[:post_launch_wait]) if merged_opts[:post_launch_wait]\n end\n end",
"def startApplication(app_name, show_std=true)\n if @app_contexts.find { |v| v.orig_name == app_name }\n run_application(app_name, show_std)\n else\n warn \"No application with name '#{app_name}' defined in group #{@name}. Nothing to start\"\n end\n end",
"def open()\n \n #note we would want to check for the browser bing open already\n #so we don't annoy people\n \n event(\"Pre\")\n require 'launchy'\n Launchy.open(\"http://local.general.dev/info.php\") #note this should be from setting file\n event(\"Post\")\n end",
"def main\n\tbaseURL = \"growl://plugin/preview/\"\n\tbundleIDs = [\n\t\t\"com.Growl.WebKit.Dangerous\",\n\t\t\"com.Growl.Bezel\",\n\t\t\"com.Growl.Brushed\",\n\t\t\"com.Growl.Bubbles\",\n\t\t\"com.Growl.WebKit.Candybars\",\n\t\t\"com.Growl.WebKit.Crystal\",\n\t\t\"com.Growl.WebKit.Darkroom\",\n\t\t\"com.Growl.WebKit.Garageband\",\n\t\t\"com.Growl.iCal\",\n\t\t\"com.Growl.MusicVideo\",\n\t\t\"com.Growl.Nano\",\n\t\t\"com.Growl.WebKit.NotifyOS9\",\n\t\t\"com.Growl.WebKit.NotifyOSX\",\n\t\t\"com.Growl.WebKit.Plain\",\n\t\t\"com.Growl.WebKit.Pseudo-Coda\",\n\t\t\"com.Growl.WebKit.Raaarr\",\n\t\t\"com.Growl.Smoke\",\n\t\t\"com.Growl.WebKit.Starwl\",\n\t\t\"com.Growl.WebKit.Whiteboard\"\n\t]\n\n\tbundleIDs.each do |value|\n\t\t#puts(\"testing #{value}\")\n\t\tsystem(\"open\", \"#{baseURL}#{value}\")\n\tend\nend",
"def launch (raw_exp, workitem)\n\n onotify(:launch, raw_exp.fei, workitem)\n\n apply(raw_exp, workitem)\n end",
"def start\n Command::Installer::Start.new(\n *command_params\n ).execute\n rescue => e\n catch_errors(e)\n end",
"def open_start\r\n\r\n @simulator = WIN32OLE.new('AutoItX3.Control')\r\n\r\n Dir.chdir(@sim_gui_path)\r\n Dir.pwd\r\n \r\n @simulator.Run(\"V4SingleSimulatorGUI.exe\")\r\n @simulator.WinWaitActive(\"Emerson (Copyright 2012)\")\r\n @simulator.ControlClick(\"Emerson (Copyright 2012)\",\"Remote Control on Port:\",\"WindowsForms10.BUTTON.app.0.bb8560_r15_ad11\")\r\n @simulator.Send(\"{F1}\")\r\n @simulator.WinWaitActive(\"Open\")\r\n @simulator.ControlSetText(\"Open\", \"\",\"Edit1\",@sim_path)\r\n @simulator.ControlClick(\"Open\",\"&Open\",\"Button1\")\r\n @simulator.WinWaitActive(\"SelectIPAddress\")\r\n @simulator.ControlClick(\"SelectIPAddress\",\"Select\",\"WindowsForms10.BUTTON.app.0.bb8560_r15_ad12\")\r\n \r\n #Start simulator\r\n @simulator.Send(\"{F5}\")\r\n\r\n end",
"def execute_app(app)\n $LOAD_PATH.unshift(Dir.pwd)\n Shoes.configuration.backend = :swt\n load app\n end",
"def launch (li, options={})\n\n result = @engine.launch(li, options)\n\n fei = result.is_a?(Array) ? result[2] : result\n\n result\n end",
"def applicationDidFinishLaunching\n #@window.makeKeyAndOrderFront(self)\n #@window.makeKeyWindow()\n #menu = NSMenu.new\n #item = NSMenuItem.new\n #item.title = \"Hello World!\"\n #menu.title = \"Karl's Menu\"\n #menu.display\n #print \"Added menu with item\"\n end",
"def run\r\n return puts(\"usage example: glimmer run tictactoe\") unless @name\r\n # Search for the filename (and add the .rb extension if not provided), and run it\r\n if File.exist?(\"#{@name}#{'.rb' unless @name =~ /.rb$/}\")\r\n command = \"#{JRUBY_COMMAND} \\\"#{@name.gsub(/\\\\/, '/')}#{'.rb' unless @name =~ /.rb$/}\\\"\"\r\n else\r\n # Search for all installed samples and try to run of those\r\n command = \"#{JRUBY_COMMAND} \\\"#{SAMPLES_PATH}/#{fetch_app(@name)}.rb\\\"\"\r\n end\r\n puts \"Starting the application with following command:\"\r\n puts command\r\n system command\r\n end",
"def click\n p [ :app_click ]\n view.click\n end",
"def open\n addon = args.shift\n app_addons = heroku.installed_addons(app).map { |a| a[\"name\"] }\n matches = app_addons.select { |a| a =~ /^#{addon}/ }\n\n case matches.length\n when 0 then\n if heroku.addons.any? {|a| a['name'] =~ /^#{addon}/ }\n error \"Addon not installed: #{addon}\"\n else\n error \"Unknown addon: #{addon}\"\n end\n when 1 then\n addon_to_open = matches.first\n display \"Opening #{addon_to_open} for #{app}...\"\n Launchy.open \"https://api.#{heroku.host}/myapps/#{app}/addons/#{addon_to_open}\"\n else\n error \"Ambiguous addon name: #{addon}\"\n end\n end",
"def launch(command={})\n action_view = \"android.intent.action.VIEW\"\n action_send = \"android.intent.action.SEND\"\n action_dial = \"android.intent.action.DIAL\"\n key_list = command.keys\n launch_intent = case\n when key_list.include?(:sms)\n sms_intent = Android::Content::Intent.new(action_view)\n sms_intent.setData(Android::Net::Uri.fromParts(\"sms\", command[:sms].to_s, nil))\n when key_list.include?(:email)\n email_intent = Android::Content::Intent.new(action_view)\n email_string = \"mailto:#{command[:email]}\"\n email_string += \"?subject=#{command[:subject].to_s}\"\n email_string += \"&body=#{command[:message].to_s}\"\n email_intent.setData(Android::Net::Uri.parse(email_string))\n when key_list.include?(:web)\n web_intent = Android::Content::Intent.new(action_view)\n web_intent.setData(Android::Net::Uri.parse(command[:web]))\n when key_list.include?(:tel)\n tel_intent = Android::Content::Intent.new(action_dial)\n tel_intent.setData(Android::Net::Uri.fromParts(\"tel\", command[:tel], nil))\n when key_list.include?(:chooser)\n message_intent = Android::Content::Intent.new(action_send)\n message_intent.type = \"text/plain\"\n message_intent.putExtra(\"android.intent.extra.TEXT\", command[:chooser].to_s) if command[:chooser]\n Android::Content::Intent.createChooser(message_intent, nil)\n else\n mp \"[BP Warning] Launch type unknown - '#{command.keys.inspect}'\"\n nil\n end\n\n find.activity.startActivity(launch_intent) if launch_intent\n end",
"def run_app(command, arguments)\nend",
"def open\n @is_running = true\n run_interpreter\n end",
"def open()\n \n #note we would want to check for the browser being open already\n #so we don't annoy people\n \n event(\"Pre\")\n require 'launchy'\n Launchy.open(\"http://store.mage.dev/admin\") #note this should be from setting file\n event(\"Post\")\n end",
"def launch!\n\t\tintroduction\n\t\t\taction = nil\n\t\t\tuntil action == :quit\n\t\t\t# action loop\n\t\t\t# what do you want to do? (list, find, add, quit)\n\t\t\tprint \"> \"\n\t\t\tuser_response = gets.downcase.strip!.split(' ')\n\t\t\t# do that action\n\t\t\taction,args = do_action(user_response[0],user_response[1])\n\t\tend\n\t\tconclusion\n\tend",
"def app_launched(notification)\n application = notification.userInfo.fetch('NSWorkspaceApplicationKey', nil)\n\n if application && application.localizedName == 'Hearthstone'\n start_tracking\n\n if @listeners[:app_running]\n @listeners[:app_running].each do |block|\n block.call(true) if block\n end\n end\n end\n end",
"def launch(destination)\n # instance variables declared using '@'\n # private scoped\n @destination = destination\n end",
"def start_apps\n check_apps\n remove_sockets\n _start_apps(ARGV[1])\nend",
"def start_app\nend",
"def launchd *args\n ruby = File.join RbConfig::CONFIG.values_at('bindir', 'ruby_install_name')\n env = ['/usr/bin/env', 'RUBYLIB=%s' % ENV['RUBYLIB']]\n cmd = [ruby, '-Eutf-8', '--', File.expand_path(__FILE__)]\n Plist::Emit.dump \\\n :Label => 'com.sungpae.macdriver',\n :RunAtLoad => true,\n :ProgramArguments => env + cmd + args\n end",
"def open_command\r\n if RbConfig::CONFIG[\"host_os\"] =~ /mswin|mingw/\r\n \"start\"\r\n elsif RbConfig::CONFIG[\"host_os\"] =~ /darwin/\r\n \"open\"\r\n else\r\n \"xdg-open\"\r\n end\r\nend",
"def windows_app_list\n Launchy.log \"#{self.class.name} : Using 'start' command on windows.\"\n %w[ start ]\n end",
"def launch(autoload: false)\n # Launch the game\n @idx_launch = 0 unless defined?(@idx_launch)\n if autoload\n log \"[ Game #{name} ] - Launch game (##{@idx_launch}) using AutoLoad #{autoload}...\"\n autoload_file = \"#{path}/Data/AutoLoad.cmd\"\n if File.exist?(autoload_file)\n run_cmd(\n {\n dir: path,\n exe: 'Data\\AutoLoad.cmd',\n args: [autoload]\n }\n )\n else\n log \"[ Game #{name} ] - Missing file #{autoload_file}. Can't use AutoLoad to load game automatically. Please install the AutoLoad mod.\"\n end\n else\n log \"[ Game #{name} ] - Launch game (##{@idx_launch}) using configured launcher (#{launch_exe})...\"\n run_cmd(\n {\n dir: path,\n exe: launch_exe\n }\n )\n end\n @idx_launch += 1\n # The game launches asynchronously, so just wait a little bit and check for the process existence\n sleep @game_info['min_launch_time_secs']\n tasklist_stdout = nil\n loop do\n tasklist_stdout = `tasklist | find \"#{running_exe}\"`.strip\n break unless tasklist_stdout.empty?\n\n log \"[ Game #{name} ] - #{running_exe} is not running. Wait for its startup...\"\n sleep 1\n end\n @pid = Integer(tasklist_stdout.split[1])\n log \"[ Game #{name} ] - #{running_exe} has started with PID #{@pid}\"\n end",
"def launch_simulator(options={})\n merged_options = {\n :wait_for_stable => true\n }.merge(options)\n\n if !simulator_requires_relaunch?\n RunLoop.log_debug(\"Simulator is running and does not require a relaunch.\")\n return\n end\n\n RunLoop::CoreSimulator.quit_simulator\n RunLoop::CoreSimulator.ensure_hardware_keyboard_connected(pbuddy)\n sim_keyboard.ensure_soft_keyboard_will_show\n sim_keyboard.ensure_keyboard_tutorial_disabled\n\n args = ['open', '-g', '-a', sim_app_path, '--args',\n '-CurrentDeviceUDID', device.udid,\n \"-ConnectHardwareKeyboard\", \"0\",\n \"-DeviceBootTimeout\", \"120\",\n # Yes, this is the argument even though it is not spelled correctly\n \"-DetatchOnAppQuit\", \"0\",\n \"-DetachOnWindowClose\", \"0\",\n \"LAUNCHED_BY_RUN_LOOP\"]\n\n RunLoop.log_debug(\"Launching #{device} with:\")\n RunLoop.log_unix_cmd(\"xcrun #{args.join(' ')}\")\n\n start_time = Time.now\n\n pid = Process.spawn('xcrun', *args)\n Process.detach(pid)\n\n options = { :timeout => 5, :raise_on_timeout => true }\n RunLoop::ProcessWaiter.new(sim_name, options).wait_for_any\n\n if merged_options[:wait_for_stable]\n device.simulator_wait_for_stable_state\n end\n\n elapsed = Time.now - start_time\n RunLoop.log_debug(\"Took #{elapsed} seconds to launch the simulator\")\n\n true\n end",
"def open_in_browser\n link = \"http://www.bandsintown.com/cities/pittsburgh-pa\"\n if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/\n system \"start #{link}\"\n elsif RbConfig::CONFIG['host_os'] =~ /darwin/\n system \"open #{link}\"\n elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/\n system \"xdg-open #{link}\"\n end\n end",
"def execute\n\n\t\t#raise \"You must define 'output' for #{self}\" if self.output == nil\n\t\t#raise \"You must define 'application_descriptor'\" if self.application_descriptor == nil || !File.exists?(self.application_descriptor)\n\t\t#raise \"You must define 'keystore' for #{self}\" if self.keystore == nil\n\t\t#raise \"You must define 'keystore_name' for #{self}\" if self.keystore_name == nil\n\t\t#raise \"You must define 'storepass' for #{self}\" if self.storepass == nil\n\t\t#raise \"You must define 'include_files' for #{self}\\neg: include_files << 'bin .'\" if self.include_files.length < 1\n\n\t\t# TODO: Somehow confirm that the initialWindow content is included in the build\n\t\t#app_xml = Nokogiri::XML(File.read(application_descriptor))\n\t\t#swf = app_xml.at_css(\"initialWindow > content\").content.to_s\n\t\t#swf = File.join(@output_dir, swf)\n\t\t#puts swf\n\n\t\tcommand = \"#{FlexSDK::adt}\"\n\t\tcommand << \" -package\"\n\t\tcommand << \" -tsa #{self.tsa}\" if self.tsa != nil\n\t\tcommand << \" -storetype #{self.storetype}\"\n\t\tcommand << \" -keystore #{self.keystore}\"\n\t\tcommand << \" -storepass #{self.storepass}\"\n\t\tcommand << \" -target #{target}\" if target != nil && target != \"air\"\n\t\tcommand << \" #{additional_args}\" if self.additional_args != nil\n\t\tcommand << \" #{self.output}\"\n\t\tcommand << \" #{self.application_descriptor}\"\n\t\tself.include_files.each {|entry| command << \" -C #{entry}\" }\n\t\t\n\t\tstatus = run command, false\n\n\t\tif status.exitstatus != 0\n\t\t\tcase status.exitstatus\n\t\t\twhen 2\n\t\t\t\traise \"Usage error\\n\" + \n\t\t\t\t\t \"Check the command line arguments for errors\"\n\t\t\twhen 5\n\t\t\t\traise \"Unknown error\\n\" +\n\t\t\t\t\t \"This error indicates a situation that cannot be explained by common error conditions.\\n\" +\n\t\t\t\t\t \"Possible root causes include incompatibility between ADT and the Java Runtime Environment,\\n\" +\n\t\t\t\t\t \"corrupt ADT or JRE installations, and programming errors within ADT.\"\n\t\t\twhen 6\n\t\t\t\traise \"Could not write to output directory\\n\" +\n\t\t\t\t\t \"Make sure that the specified (or implied) output directory is accessible and\\n\" +\n\t\t\t\t\t \"that the containing drive has sufficient disk space.\"\n\t\t\twhen 7\n\t\t\t\traise \"Could not access certificate\\n\" +\n\t\t\t\t\t \"Make sure that the path to the keystore is specified correctly: #{self.keystore}\\n\" +\n\t\t\t\t\t \"Make sure that the keystore password is correct: #{self.storepass}\"\n\t\t\t\t\t #\"Check that the certificate within the keystore can be accessed.\"\n\t\t\twhen 8\n\t\t\t\traise \"Invalid certificate\\n\" +\n\t\t\t\t\t \"The certificate file is malformed, modified, expired, or revoked.\"\n\t\t\twhen 9\n\t\t\t\traise \"Could not sign AIR file\\n\" +\n\t\t\t\t\t \"Verify the signing options passed to ADT.\"\n\t\t\twhen 10\n\t\t\t\traise \"Could not create time stamp\\n\" +\n\t\t\t\t\t \"ADT could not establish a connection to the timestamp server.\\n\" + \n\t\t\t\t\t \"If you connect to the internet through a proxy server, you may need to configure\\n\" + \n\t\t\t\t\t \"the JRE proxy settings. There have also been errors reported with Java 7: \\n\" +\n\t\t\t\t\t \"http://www.flashdevelop.org/community/viewtopic.php?p=41221\\n\" + \n\t\t\t\t\t \"You can disable checking a timestamp server by setting 'tsa' to 'none' in your task\"\n\t\t\twhen 11\n\t\t\t\traise \"Certificate creation error\\n\" +\n\t\t\t\t\t \"Verify the command line arguments used for creating signatures.\"\n\t\t\twhen 12\n\t\t\t\traise \"Invalid input\\n\" +\n\t\t\t\t\t \"Verify file paths and other arguments passed to ADT on the command line.\\n\" +\n\t\t\t\t\t \"Be sure the initial content in #{self.application_descriptor} is included in the build by\\n\" +\n\t\t\t\t\t \"appnding it to includ_files (eg, adt.include_files << 'bin .')\"\n\t\t\t\t\t #\"<initialWindow>\\n <content>#{swf}</content>\\n</initialWindow>\"\n\t\t\telse\n\t\t\t\traise \"Operation exited with status #{status.exitstatus}\"\n\t\t\tend\n\t\tend\n\tend",
"def open_command\n if RbConfig::CONFIG[\"host_os\"] =~ /mswin|mingw/\n \"start\"\n elsif RbConfig::CONFIG[\"host_os\"] =~ /darwin/\n \"open\"\n else\n \"xdg-open\"\n end\nend",
"def open_window(options = nil)\n window = terminal.make( :new => :terminal )\n window.launch_ :session => 'New session'\n end",
"def start_app\n response = show_menu\n response = show_menu while response < 1 || response > 7\n\n case response\n when 1\n list_books\n when 2\n list_people\n when 3\n create_person\n when 4\n create_book\n when 5\n create_rental\n when 6\n list_rentals_for_person_id\n when 7\n puts 'Thank you for using this app!'\n end\n\n puts \"\\n\"\n end",
"def startApplication(name)\n ctxt = @applications[name]\n raise OEDLIllegalArgumentException.new(:group, :name) unless ctxt\n ctxt.startApplication(self)\n \n# raise \"SHOULDN'T #{ctxt}\"\n# debug(\"Starting application '\", name, \"'\")\n# if (ctxt == nil)\n# raise \"Unknown application '#{name}' (#{@applications.keys.join(', ')})\"\n# end\n#\n# # With OMLv2 the collection server can be started as soon as EC is running\n# # Thus we comment this line and start the OML Server in the main nodehandler.rb file\n# #OmlApp.startCollectionServer\n#\n# app = ctxt[:app]\n# bindings = ctxt[:bindings]\n# env = ctxt[:env]\n# appDef = app.appDefinition\n# procName = \"app:#{name}\"\n# cmd = [procName, 'env', '-i']\n# if (env != nil)\n# env.each {|name, value|\n# cmd << \"#{name}=#{value}\"\n# }\n# end\n#\n# cmd << appDef.path\n# pdef = appDef.properties\n# # check if bindings contain unknown parameters\n# if (bindings != nil)\n# if (diff = bindings.keys - pdef.keys) != []\n# raise \"Unknown parameters '#{diff.join(', ')}'\" \\\n# + \" not in '#{pdef.keys.join(', ')}'.\"\n# end\n# cmd = appDef.getCommandLineArgs(procName, bindings, self, cmd)\n# end\n# send(:exec, *cmd)\n end",
"def run_main\n end",
"def start(appName)\n @put.normal \"Starting thin for #{appName}\"\n command = @system.execute( \"#{@thinPath} start -C /etc/thin/#{appName}.yml\" )\n if command.success?\n @put.confirm\n else\n @put.error \"Could not start Thin\"\n exit\n end\n end",
"def new(name)\n ARGV.shift\n #@log.debug \"command 'new' with arguments: #{ARGV.join(', ')}\"\n Generator::Application.start ARGV\n end",
"def run\n reconfigure\n setup_application\n run_application\n end",
"def tool_launch\n begin\n require 'bundler/setup'\n require 'cosmos'\n yield\n rescue Exception => error\n popup_error = error; popup_error = $cosmos_fatal_exception if defined? $cosmos_fatal_exception\n begin\n raise error if STDIN.isatty # Have a console\n raise error unless defined? $cosmos_fatal_exception or (error.class != SystemExit and error.class != Interrupt)\n case RUBY_PLATFORM\n when /mingw32/\n require 'fiddle'\n Fiddle::Function.new(Fiddle.dlopen('user32')['MessageBox'], [Fiddle::TYPE_LONG, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_LONG], Fiddle::TYPE_LONG).call(0, \"#{popup_error.class}:#{popup_error.message}\\n\\n#{popup_error.backtrace.join(\"\\n\")}\\n\\nNote: Ctrl-C will copy this information to the clipboard.\", \"Error Starting COSMOS Tool\", 0x50030)\n when /darwin/\n system(\"osascript -e 'display notification \\\"#{popup_error.class}:#{popup_error.message}:#{popup_error.backtrace[0].tr(\"'\\\"`<>\", '')}\\\" with title \\\"Error Starting COSMOS Tool\\\"'\")\n else\n message = \"#{popup_error.class}:#{popup_error.message}\\\\n\\\\n#{popup_error.backtrace.join(\"\\\\n\").tr(\"'\\\"`<>\", '')}\"\n command = \"zenity --info --text=\\\"#{message}\\\" --title=\\\"Error Starting COSMOS Tool\\\"\"\n success = system(command)\n system(\"notify-send \\\"Error Starting COSMOS Tool\\\" \\\"#{message}\\\"\") unless success\n end\n ensure\n raise error\n end\n end\nend",
"def run( arguments )\n\n\t\tif @application\n\n\t\t\tcase\n\n\t\t\t\twhen arguments.length == 0\n\t\t\t\t\tw = GUI::MyTixWindow.new( @application )\n\t\t\t\t\t@application.create\n\t\t\t\t\t@application.mainwindow = w\n\t\t\t\t\tw.show\n\t\t\t\t\t@application.run\n\t\t\t\t\texit 0\n\n\t\t\t\twhen arguments[0] == \"glist\"\n\t\t\t\t\tw = GUI::TicketListDialog.new( @application )\n\t\t\t\t\t@application.create\n\t\t\t\t\tw.show\n\t\t\t\t\t@application.run\n\t\t\t\t\texit 0\n\n\t\t\t\twhen arguments[0] == \"gadd\" \n\t\t\t\t\tt = nil\n\t\t\t\t\tt = BOM::Ticket.new( @options, arguments[1]) if arguments.length > 1\n\t\t\t\t\tw = GUI::TicketEditDialog.new( @application, t )\n\t\t\t\t\t@application.create\n\t\t\t\t\tw.show\n\t\t\t\t\t@application.run\n\t\t\t\t\texit 0\n\n\t\t\t\twhen arguments[0] == \"gedit\"\n\t\t\t\t\tth = TicketHandler.new( @options )\n\t\t\t\t\tif th.ready_to_run \n\t\t\t\t\t\tth.filter_by_id( arguments[1] ) do |t|\n\t\t\t\t\t\t\tw = GUI::TicketEditDialog.new( @application, t )\n\t\t\t\t\t\t\t@application.create\n\t\t\t\t\t\t\tw.show\n\t\t\t\t\t\t\t@application.run\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\texit 0\n\t\t\tend\n\n\t\tend\n\n\t\tcase\n\n\t\t\twhen arguments[0] == \"init\"\n\t\t\t\tFile.open( \".mytix.yaml\", File::WRONLY|File::TRUNC|File::CREAT) do |f|\n\t\t\t\t\tYAML.dump( @yamlconfig_defaults, f )\n\t\t\t\tend\n\t\t\t\texit 0\n\n\t\t\twhen arguments[0] == \"add\"\n\t\t\t\tt = BOM::Ticket.new( @options, arguments[ 1 ] ) \n\t\t\t\tt.save\n\t\t\t\texit 0\n\n\t\t\twhen arguments[0] == \"list\"\n\t\t\t\tth = TicketHandler.new( @options )\n\t\t\t\tif th.ready_to_run \n\t\t\t\t\tif th.length > 0\n\t\t\t\t\t\tprint \"Listing Tickets from #{@options.tickets_directory}\\n\"\n\t\t\t\t\t\tt = Console::Tabular.new( [ \"Id\", \"Name\", \"status\", \"created\", \"vote\" ] )\n\t\t\t\t\t\tth.each( arguments[1, arguments.length ] ) do |i|\n\t\t\t\t\t\t\tc = nil\n\t\t\t\t\t\t\tc = @options.console[\"colors\"][ i.data.severity ] if @options.console and @options.console[\"colors\"]\n\t\t\t\t\t\t\tt << { \"color\"=>c, \"cols\"=>[ i.idstring, i.data.name, i.data.status, i.data.created, i.data.vote ] }\n\t\t\t\t\t\tend\n\t\t\t\t\t\tt.print\n\t\t\t\t\telse\n\t\t\t\t\t\tputs \"No tickets in the database\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\texit 0\n\n\t\t\twhen arguments[0] == \"comment\"\n\t\t\t\tth = TicketHandler.new( @options )\n\t\t\t\tth.filter_by_id( arguments[1]) do |t|\n\t\t\t\t\tt.addComment( arguments[2] ) \n\t\t\t\t\tt.save() \n\t\t\t\tend\n\t\t\t\texit 0\n\n\t\t\twhen arguments[0] == \"attach\"\n\t\t\t\tth = TicketHandler.new( @options )\t\t\t\t\n\t\t\t\tth.filter_by_id( arguments[1]) do |t|\n\t\t\t\t\tt.addAttachments( arguments[2..arguments.length] ) \n\t\t\t\t\tt.save()\n\t\t\t\tend\n\t\t\t\texit 0\n\n\t\t\twhen arguments[0] == \"status\"\n\t\t\t\tth = TicketHandler.new( @options )\n\t\t\t\tth.filter_by_id( arguments[1] ) do |t|\n\t\t\t\t\tif t.setStatus( arguments[2] ) \n\t\t\t\t\t\tt.save() \n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\texit 0\n\n\t\t\twhen arguments[0] == \"vote\"\n\t\t\t\tth = TicketHandler.new( @options )\n\t\t\t\tth.filter_by_id( arguments[1] ) do |t|\n\t\t\t\t\tif t.data.vote += 1 \n\t\t\t\t\t\tt.save() \n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\texit 0\n\n\t\t\twhen arguments[0] == \"show\"\n\t\t\t\tth = TicketHandler.new( @options )\n\t\t\t\tth.filter_by_id( arguments[1] ) do |t|\n\t\t\t\t\tct = Console::Tabular.new( nil, [\"r\", \"l\"], 2 )\n\t\t\t\t\tc = @options.console[\"colors\"][ t.data.severity ] if @options.console and @options.console[\"colors\"]\n\t\t\t\t\tct << {\"cols\"=>[\"Id:\", t.idstring]}\n\t\t\t\t\tct << {\"cols\"=>[\"Name:\", t.data.name ]}\n\t\t\t\t\tct << {\"cols\"=>[\"Description:\", t.data.description ]}\n\t\t\t\t\tct << {\"cols\"=>[\"Status:\", t.data.status ]}\n\t\t\t\t\tct << {\"cols\"=>[\"Severity:\", t.data.severity ]}\n\t\t\t\t\tct << {\"cols\"=>[\"Votes:\", t.data.vote ]}\n\t\t\t\t\tct << {\"cols\"=>[\"Created by:\", t.data.created_by ]}\n\t\t\t\t\tct << {\"cols\"=>[\"Created:\", t.data.created ]}\n\t\t\t\t\tct << {\"cols\"=>[\"Updated:\", t.data.updated ]}\n\t\t\t\t\tct.print\n\n\t\t\t\t\tt.loadComments\n\t\t\t\t\tif t.comments.length>0\n\t\t\t\t\t\tputs \"\"\n\t\t\t\t\t\tputs \"Comments:\"\n\t\t\t\t\t\tct = Console::Tabular.new( [\"Comment\", \"Created\", \"Created by\"] )\n\t\t\t\t\t\tt.comments.each do | c |\n\t\t\t\t\t\t\tct << {\"cols\"=>[c.comment, c.created, c.created_by ]}\n\t\t\t\t\t\tend\n\t\t\t\t\t\tct.print\n\t\t\t\t\tend\n\n\t\t\t\t\tt.loadAttachments\n\t\t\t\t\tif t.attachments.length > 0\n\t\t\t\t\t\tputs \"\"\n\t\t\t\t\t\tputs \"Attachments:\"\n\t\t\t\t\t\tct = Console::Tabular.new( [ \"Id\", \"Attachment\", \"Attachment comment\", \"Created\", \"Created by\", \"Full path\"] )\n\t\t\t\t\t\tt.attachments.each do | a |\n\t\t\t\t\t\t\tp1 = Pathname.new( File.join( File.dirname(t.filename), \"attachments\", a.fileid, a.original_name ) )\n\t\t\t\t\t\t\tp2 = Pathname.new( Dir.pwd )\n\t\t\t\t\t\t\tct << {\"cols\"=>[a.fileid, a.original_name, a.comment, a.created, a.created_by, p1.relative_path_from( p2 ) ]}\n\t\t\t\t\t\tend\n\t\t\t\t\t\tct.print\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\texit 0\n\n\t\t\twhen (arguments[0] == \"-v\" or arguments[0] == \"--version\" )\n \t\t\tputs \"#{File.basename(__FILE__)} version #{VERSION}\"\n\t\t\t\texit 0\n\n\t\t\twhen ( arguments[0] == \"-h\" or arguments[0] == \"--help\" )\n \t\t\tputs \"#{File.basename(__FILE__)} version #{VERSION}\"\n \t\t\tRDoc::usage(\"usage\") #exits app\n\t\t\t\texit 0\n\t\tend\t\n end",
"def app\n no_autostart\n puts \"Running Plezi version: #{::Plezi::VERSION}\"\n Plezi::Base::Router.call_method\n end",
"def install_launcher!\n load_plist_info!\n ruby = config[:ruby] || \"/usr/bin/ruby\"\n include_dir = '-I'+File.expand_path('../../lib', __FILE__)\n launcher = File.expand_path('../../bin/timetap', __FILE__)\n\n puts \"\\nCreating launchd plist in\\n #{plist_path}\"\n\n File.open(plist_path, 'w') do |file|\n file << <<-PLIST\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>Label</key>\n\t<string>com.eliaesocietas.TimeTap</string>\n\n\t<key>Program</key>\n\t<string>#{ruby}</string>\n\n\t<key>ProgramArguments</key>\n\t<array>\n\t\t<string>#{ruby}</string>\n\t\t<string>#{include_dir}</string>\n\t\t<string>#{launcher}</string>\n\t\t<string>-f</string>\n\t</array>\n\n\t<key>OnDemand</key>\n\t<false/>\n\n\t<key>RunAtLoad</key>\n\t<true/>\n</dict>\n</plist>\n PLIST\n end\n end",
"def run\n Gtk.main\n end",
"def open_home_page\n open(configuration.browser_url)\n end",
"def run\r\n @log.debug \"Run the tester...\"\r\n settings = YAML::load_file(File.join(ResourceInfo.get_dir_appdata(), 'app_options.yaml'))\r\n dlg = NamesOptionsDlg.new(@main_app, settings, @main_app)\r\n dlg.execute\r\n end",
"def run\n job = handle_input(show_menu)\n\n # job = handle_input(get_menu_choice) # here we the menu choice and handle the choice together and return value will be the selected job or exit command\n\n # if job is a valid job instance then show details and offer to open in browser\n if job.class == FreelancerFinder::Job\n show_job_details(job)\n open_in_browser?(job)\n end\n # selected_job\n job\n end",
"def start!\n @window = Window.new width, height, fullscreen?\n window.caption = name\n window.scene = Scenes.generate(first_scene)\n window.show\n end",
"def game_start\n game_setup\n @console_delegate.show\n end",
"def open_url(url)\n if RbConfig::CONFIG['host_os'] =~ /darwin/\n system %(open \"#{url}\")\n elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/\n system %(xdg-open \"#{url}\")\n else\n puts 'Not Supported OS!'.red\n end\n end",
"def run_project(args)\n cmd = \"run #{args.join(' ')} 2>&1 | tee -a #{log}\"\n system %{trap 'killall -9 \"iPhone Simulator\"' INT ; #{bin} #{cmd}}\n end",
"def menu_press( menu_label )\n %x{osascript<<APPLESCRIPT\n activate application \"iPhone Simulator\"\n tell application \"System Events\"\n \tclick menu item \"#{menu_label}\" of menu \"#{Localize.t(:hardware)}\" of menu bar of process \"#{Localize.t(:iphone_simulator)}\"\n end tell\n APPLESCRIPT} \n end",
"def execute(args)\n raise BadUsageError.new(self) unless (args.length == 1) \n\n puts \"Adding [#{args.first}] to Railcar...\"\n if RCApplicationManager.new.add(args.first)\n puts \"Done!\"\n else\n puts\n puts \"That path (#{args.first}) doesn't appear to exist or be a Rails application.\"\n puts \"Make sure you've got the path right!\"\n puts\n end\n end",
"def execute(args)\n # Analyze arguments\n remaining_args = @options.parse(args)\n if @display_help\n puts @options\n elsif (remaining_args.size > 2)\n puts 'Please specify just 1 file to be loaded on startup.'\n puts @options\n else\n activate_log_debug(true) if @debug\n log_info 'Loading GUI libraries...'\n require 'gtk2'\n Gdk::Threads.init\n require 'ruby-serial'\n require 'filesrebuilder/Model/Data'\n require 'filesrebuilder/GUIFactory'\n require 'filesrebuilder/GUIcontroller'\n require 'filesrebuilder/_Gtk/_object'\n require 'rUtilAnts/Platform'\n RUtilAnts::Platform::install_platform_on_object\n gui_factory = GUIFactory.new\n gui_controller = GUIController.new(gui_factory)\n gui_factory.gui_controller = gui_controller\n Gtk::Settings.default.gtk_button_images = true\n log_info 'Executing application...'\n main_widget = gui_factory.new_widget('Main')\n gui_controller.set_main_widget(main_widget)\n main_widget.show\n gui_controller.run_callback_dirline_progress_bars\n gui_controller.load_from_file(remaining_args[0]) if (remaining_args.size == 1)\n Gtk.main\n log_info 'Quitting application...'\n end\n end",
"def launch!\n\t\tintroduction\n\n\t\tresult = nil\n\t\tuntil result == :quit\n\t\t\tprint \"> Choose one of these options: List, Sort, Find or Add.\\n\\n\"\n\t\t\tuser_response = gets.chomp\n\t\t\tresult = do_action(user_response)\n\t\tend\n\t\tconclusion\n\tend",
"def start_router opts ={}\n title = opts[:title] || ROUTER_TITLE\n path = opts[:path] || ROUTER_PATH\n dir = opts[:dir] || TEST_DIR\n args = opts[:args] || ROUTER_ARGS\n timeout = opts[:timeout] || 5\n if not WinGui::Window.find(:title => title) or opts[:force]\n WinGui::App.launch(:dir => dir, :path => path, :args => args,\n :title => title, :timeout => timeout)\n end\n sleep 1\nend"
] | [
"0.82850605",
"0.7305946",
"0.72759837",
"0.7255567",
"0.7212822",
"0.7182324",
"0.6942555",
"0.6926906",
"0.6914419",
"0.6867765",
"0.6804551",
"0.67725134",
"0.67444825",
"0.67325157",
"0.67190796",
"0.66492176",
"0.6647323",
"0.6612465",
"0.6612465",
"0.6594305",
"0.6580397",
"0.65538025",
"0.6539552",
"0.6514531",
"0.6453599",
"0.6412817",
"0.6340038",
"0.6336984",
"0.6331617",
"0.6328156",
"0.62818986",
"0.628015",
"0.62643087",
"0.6207455",
"0.6185034",
"0.6151205",
"0.61402327",
"0.60899526",
"0.608373",
"0.605809",
"0.60521996",
"0.6025288",
"0.60226566",
"0.60140496",
"0.60116214",
"0.59892184",
"0.5989072",
"0.5967594",
"0.5952698",
"0.5941589",
"0.5933153",
"0.5913285",
"0.59111106",
"0.5905175",
"0.58931524",
"0.5890253",
"0.58896863",
"0.5883545",
"0.5876505",
"0.587611",
"0.58547515",
"0.5831587",
"0.58281046",
"0.5827596",
"0.58192265",
"0.58151853",
"0.58120674",
"0.5805555",
"0.58033293",
"0.57736075",
"0.57529676",
"0.574431",
"0.5742672",
"0.5736659",
"0.57316995",
"0.57190174",
"0.5715662",
"0.57049614",
"0.57044744",
"0.56896126",
"0.56758434",
"0.5654206",
"0.5634614",
"0.563342",
"0.5618063",
"0.56098825",
"0.5606589",
"0.56033194",
"0.5588456",
"0.55825275",
"0.55744135",
"0.5561948",
"0.55556726",
"0.5551511",
"0.5547825",
"0.5545712",
"0.5540714",
"0.5534689",
"0.55286646",
"0.55266505",
"0.55239695"
] | 0.0 | -1 |
=begin problem: Complete the function that takes an array of words. You must concatenate the nth letter from each word to construct a new word which should be returned as a string, where n is the position of the word in the list. =end | def nth_char(arr)
arr.map.with_index { |word, idx| word[idx] }.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nth_char(words)\n final_word = []\n words.each_with_index { |word, index| \n final_word << word[index]\n }\n return final_word.join('')\nend",
"def get_word\n @lettercollection.push(@string_as_array[@i])\n @lettercollection.join('')\nend",
"def typoglycemiaWord(input)\n if input.length <= 3\n input\n end\n letters = input.chars\n last = letters.pop\n first = letters.shift\n letters.shuffle!\n letters << first\n letters.rotate!(-1)\n letters << last\n letters.join\nend",
"def create_index1(word)\n word.chars.sort!.join\n end",
"def sentence_maker(array_of_strings)\n result = \"\"\n last_word = array_of_strings.pop\n array_of_strings.each do |word|\n result += word.to_s + \" \"\n end\n result += last_word + \".\"\n return result.capitalize!\nend",
"def insertions word\n n = word.length\n new_words = []\n (n+1).times {|i| ('a'..'z').each {|l| new_words << word[0...i]+l.chr+word[i..-1] } }\n new_words\n end",
"def array_translate(array)\n repeatedWords = \"\"\n i = 0\n while i < array.length-1\n word = array[i]\n num = array[i+1]\n num.times { repeatedWords += word }\n i += 2\n end\n return repeatedWords\nend",
"def char_concat(word)\n (1..word.length/2).map {|i| word[i - 1] + word[-i] + i.to_s}.join\nend",
"def yell(words)\n i = 0\n while i < words.length\n words[i] = words[i] + \"!\"\n i+= 1\n end\n return words\nend",
"def code_name(word)\n#set a new word to an empty string, we are going to fill it using the rest of the loop:\n\tnew_word = \"\"\n#start index at 0\n\ti = 0\n#loop through the string:\n\twhile i < word.length\n#letter is going to be the index of the word put in, starting at the 0 position until the end of the word's length\n\tletter = word[i]\n#if a space is found, add a space to the new word\n\t\tif letter == ' '\n\t\tnew_word += ' '\n#everything else, find the next letter or the next vowel or next edge case, and add it to the new word\n\t\telse\n\t\t letter == letter.downcase\n\t\tnew_word += vowels_and_edges(letter)\n \t\tend\n \t\ti += 1\n end\n#should result in a new word, when all strings are pieced together \n new_word\nend",
"def sentence_maker (array)\n index = 0\n sentence = \"\"\n array = array.map {|x| x.to_s}\n\nuntil index == array.length-1\n sentence += array[index] + \" \"\n index += 1\nend\n\nsentence += array[-1] + \".\"\nreturn sentence.capitalize\n\nend",
"def sentence_maker(word_array)\n sentence = word_array.inject(\" \"){|words,element| words += element.to_s + \" \"}\n sentence.strip!.capitalize!\n sentence << \".\"\nend",
"def sentence_maker(word_array)\n sentence = word_array.inject(\" \"){|words,element| words+=element.to_s+\" \"}\n sentence.strip!.capitalize!\n sentence << \".\"\nend",
"def sentence_maker(array)\n sentence = array[0].capitalize\n for w in 1...array.length\n sentence = sentence + \" \" + array[w].to_s\n end\n return sentence + \".\"\nend",
"def add_s(array)\n array.each_with_index.collect do |word, index|\n index == 1 ? word : word+\"s\"\n end\nend",
"def replacements word\n n = word.length\n new_words = []\n n.times {|i| ('a'..'z').each {|l| new_words << word[0...i]+l.chr+word[i+1..-1] } }\n new_words\n end",
"def words(n)\n str = ''\n\n # process < 100\n if n.zero? || n < 20\n str = Words[n]\n else\n d, n = n / 10, n % 10\n str = Words[d*10]\n str += '-' + Words[n] unless n.zero?\n end\n \n str\n end",
"def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend",
"def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend",
"def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend",
"def titleize(string)\r\n words = string.split(\" \")\r\n array = []\r\n words.each_with_index do |word, index|\r\n if index == 0\r\n array << word.upcase[0] + word[1..-1]\r\n else\r\n if word.length > 3\r\n array << word.upcase[0] + word[1..-1]\r\n else\r\n array << word\r\n end\r\n end\r\n end\r\n return array.join(\" \")\r\nend",
"def start_of_word(input, letter_count)\n # Create new word using indexes of orginal\n input[0..(letter_count-1)]\nend",
"def add_s(array)\n array.each_with_index.collect{|word, i| i == 1 ? word : word + \"s\"}\nend",
"def yell(words)\n\ti = 0\n while i < words.length\n words[i] = words[i] + \"!\"\n i += 1\n end\n return words\nend",
"def array_translate(array)\n string = ''\n i = 0 \n while i < array.length\n word = array[i]\n num = array[i + 1]\n string += (word * num)\n\n i += 2\n end\n\n string\nend",
"def yell(words)\n i = 0\n new_words = []\n while i < words.length\n new_words << words[i] + '!'\n i += 1\n end\n return new_words\nend",
"def sentence_maker(arr)\n string = \"\"\n arr.each do |i|\n string += i.to_s + ' '\n end\n string[-1] = \".\"\n return string = string.capitalize\nend",
"def sentence_maker(word_array)\n\tsentence = word_array.join(\" \")\n\treturn sentence.capitalize + \".\"\nend",
"def recombiner (array_of_char)\n new_name = array_of_char.join.split(' ').reverse\n new_name.map! do | words |\n words.capitalize\n end\n new_name.join(' ')\nend",
"def eval_ele(word)\n\n formWord = []\n word.each_char.with_index do |let, idx|\n if idx == 0\n formWord << word[idx].upcase\n else\n formWord << word[idx].downcase\n end\n end\n\n return formWord.join(\"\")\n\nend",
"def yell(words)\n new = []\n\n i = 0\n\n while i < words.length\n old_word = words[i]\n new_word = old_word + '!'\n new << new_word\n i += 1\n end\n\n return new\nend",
"def kesha_maker(array)\n array.map do |elem|\n word_splice = elem.split(\"\")\n word_splice[2] = \"$\"\n word_splice.join\n end\nend",
"def add_s(array)\n array.each_with_index.collect do |word, index|\n index != 1 ? \"#{word}s\" : word\n end\nend",
"def make_a_sentence(words)\n words.join(' ') + \"!\"\nend",
"def sentence_maker(words)\n\n i = 0\n sentence = ''\n\n while i < words.length\n if i == 0\n sentence = sentence + words[0].to_s.capitalize + ' '\n end\n if i == words.length - 1\n sentence = sentence + words[(words.length - 1)].to_s + '.'\n end\n if (i != words.length - 1) && i != 0\n sentence = sentence + words[i].to_s + ' '\n end\n i += 1\n end\n return sentence\nend",
"def translate(word)\r\n vowels = \"aeio\".split('').to_a\r\n consonant = \"bcdfghjklmnpqrstuvwxyz\".split('').to_a \r\n answer = []\r\n \r\n while word.split(' ').length == 1 \r\n words = word.split('')\r\n until vowels.include?(words[0])\r\n words = words.rotate(1)\r\n end\r\n words << \"ay\"\r\n return words.join('')\r\n end # one word ^^\r\n \r\n if word.split(' ').length > 1 \r\n words = word.split(' ')\r\n end \r\n words.each do |i|\r\n if vowels.include?(i[0])\r\n i << \"ay\"\r\n answer << i\r\n #return answer\r\n end\r\n end\r\n \r\n words.each do |j|\r\n if consonant.include?(j[0])\r\n j = j.split('').rotate(1).join('') until vowels.include?(j[0])\r\n j = j + \"ay\"\r\n #return j\r\n #j << j #correct format for 1 consonant but it doesnt add to array\r\n answer << j\r\n end\r\n end\r\n \r\n return answer.join(' ')\r\n end",
"def translate words\n\tarray = words.split \n\ti = 0\n\ttotal = \"\"\n\twhile i < array.length\n\t\tstring = array[i]\n\t\tif string[0] =~ /[aeiou]/\n\t\t\tresult = string + \"ay\"\n\t\telse\n\t\t\tletters = \"\"\n\t\t\tcounter = 0\n\t\t\tnumberConsanants = 0\n\t\t\twhile counter < string.length\n\t\t\t\tif string[counter] =~ /[aeiou]/\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tletters = letters + string[counter]\n\t\t\t\t\tif string[counter] == 'q' && string[counter+1] == 'u'\n\t\t\t\t\t\tletters = letters + 'u'\n\t\t\t\t\t\tnumberConsanants = numberConsanants + 1\n\t\t\t\t\tend\n\t\t\t\t\tnumberConsanants = numberConsanants + 1\n\t\t\t\tend\n\t\t\t\tcounter = counter + 1\n\t\t\tend\n\t\t\tresult = string.slice(numberConsanants, string.length) + letters + \"ay\"\n\t\tend\n\t\ttotal = total + result\n\t\tif i != array.length - 1\n\t\t\ttotal = total + \" \"\n\t\tend\n\t\ti = i + 1\n\tend\n\ttotal\nend",
"def yeller(words) # words is var of an array of strings\n loud_arr = [] # empty array for strings\n i = 0 # the indice counter starting @ 0\n while i < words.length\n word = words[i] # can't store indice of an int, so keep value of the int \"which is string\"\n loud_word = (word + \"!\") # concat \"!\" to string store the result new word for each iteration\n loud_arr << loud_word # shovel result into the array\n i += 1 # next iteration\n end\n return loud_arr\n puts loud_arr\nend",
"def whisper_words(words)\nreturn words.map{ |elem| elem.downcase + \"...\"}\nend",
"def rotn(n, word)\n n.times do\n word.tr!('abcdefghijklmnopqrstuvwxyz',\n 'bcdefghijklmnopqrstuvwxyza')\n end\n word\nend",
"def summon_captain_planet(arr)\n arr.map {|word| word.capitalize + \"!\"}\nend",
"def reverberate(sent)\n new_arr = []\n words_arr = sent.split(\" \")\n vowels = \"aeiouAEIOU\"\n words_arr.each do |word|\n capt = false\n if word.capitalize == word\n capt = true\n end\n if word.length < 3\n new_arr << capt ? word.capitalize : word #new_arr << capt ? word.capitalize : word\n elsif vowels.include?(word[-1])\n new_arr << (capt ? (word * 2).capitalize : word * 2)\n elsif !vowels.include?(word[-1])\n rev_index = word.chars.reverse.index { |char| vowels.include?(char) }\n i = word.length - 1 - rev_index\n new_arr << (capt ? (word + word[i..-1]).capitalize : word + word[i..-1])\n end\n end\n new_arr.join(\" \")\nend",
"def capitalize_letter_of_each_word(str)\n return_string = \"\"\n words = str.split()\n\n index = 0\n words.each do |word|\n word[0] = word[0].upcase\n index += 1\n if index >= 2\n return_string = return_string + \" #{word}\"\n elsif index < 2\n return_string = word\n end\n end\n\n return return_string\nend",
"def create_index3(word)\n word.split('').sort!.join\n end",
"def add_s_alternate(array)\n array.each_with_index.map do |word, index|\n if index != 1\n word = word + \"s\"\n else\n word\n end\n end\nend",
"def capitalize_words(string)\n\t\n\t#split up string into old array of words \n\told_words_array = string.split\n\t\n\t#set up new array of words \n\tnew_words_array = []\n\t\n\t#loop to go through each word\n\ti = 0 \n\twhile (i < old_words_array.length)\n\t\n\t\t#separate each word into characters\n\t\tchars = old_words_array[i].scan /\\w/\n\t\t\n\t\t#shift off first char \n\t\tfirst_char = chars.shift\n\t\t\n\t\t#make first char uppercase \n\t\tfirst_char = first_char.upcase\n\t\t\n\t\t#join first char with the rest of the chars \n\t\tchars = chars.unshift(first_char)\n\t\t\n\t\t#make the chars back into a string \n\t\tcapitalized_word = chars.join\"\"\n\t\t\n\t\t#put the string into new words array of strings \n\t\tnew_words_array.push(capitalized_word)\n\t\t\n\t\t#increase i \n\t\ti += 1 \n\t\n\tend\n\t\n\t#join new words array back into single string\n\treturn new_words_array.join(\" \")\n\t\nend",
"def yell(words)\n\tnewWords = []\n\tfor i in 0..words.length-1\n newWord = words[i] + \"!\"\n \tnewWords << newWord\n end\n return newWords\nend",
"def sentence_maker(array)\n x=array.join(\" \")\n return x.capitalize + \".\"\n end",
"def english_translate\n pig_latin_arr = []\n pig_latin = []\n print \"What word would you like to translate? \"\n input = gets.chomp!.downcase\n \n pig_latin_word_to_translate = input.split(/ /)\n\n pig_latin_word_to_translate.each do |word|\n pig_latin_arr = word.split(//)\n\n first_letter = pig_latin_word_to_translate.delete_at(0)\n new_letters = english_word_to_translate.join\n\n word = new_letters + first_letter + \"ay\"\n\n pig_latin << word\n end\n \n puts pig_latin.join(' ').capitalize\nend",
"def add_letter(word, index, let)\n word.split(\"\").insert(index,let).join\nend",
"def sentence_maker(array_of_strings)\n sentence = array_of_strings[0].capitalize\n for i in array_of_strings[1..-1]\n sentence += \" \" + i\n end \n sentence + \".\"\nend",
"def translate(arr)\n vowels = %w{a e i o u y}\n consonants = %w{b c d f g h j k l m n p q r s t v w x y z}\n\n a = arr.split.map do |word| \n if vowels.include?(word[0])\n word + \"ay\"\n elsif word[0..1] == \"qu\"\n word[2..-1] + \"quay\"\n elsif word[0..2] == \"sch\"\n word[3..-1] + \"schay\"\n elsif word[0..2] == \"squ\"\n word[3..-1] + \"squay\"\n elsif consonants.include?(word[0]) && consonants.include?(word[1]) && consonants.include?(word[2])\n word[3..-1] + word[0..2] + \"ay\"\n elsif consonants.include?(word[0]) && consonants.include?(word[1])\n word[2..-1] + word[0..1] + \"ay\"\n elsif consonants.include?(word[0])\n word[1..-1] + word[0] + \"ay\"\n end\n end\n\n a.join(\" \")\nend",
"def convert_word(arr)\n return nil if arr.nil?\n return [] if arr.empty?\n\n word = ''\n arr.each do |n|\n return nil unless @nmap.key? n\n\n word += @nmap[n]\n end\n word\n end",
"def start_of_word(str,index)\n if str.length > 1\n str.slice(0,index)\n else\n alphabet= (\"a\"..\"z\").to_a\n alphabet_seq = (\"a\"..alphabet[index]).to_a\n alphabet_seq.join\n end\nend",
"def get_acronym(word)\n acronym_str = \"\" # Create return var\n\n split_words = word.split(\" \") # Split words into array\n\n split_words.each do |word| # Loop each word and shovel first letter in acronym_str\n acronym_str += word[0].upcase\n end\n\n return acronym_str\n\nend",
"def sentence_maker(array)\n combination = \"\"\n array.each {|x| combination = combination + x.to_s + \" \"}\n return combination.capitalize.chop + \".\"\nend",
"def sentence_maker(arraystring)\n fullsentence = ''\n length_of_arraystring = arraystring.length\n current_index_of_array = 0\n while current_index_of_array < length_of_arraystring\n if current_index_of_array == 0\n word = arraystring[current_index_of_array].to_s.capitalize\n fullsentence = fullsentence + word + ' '\n\n elsif current_index_of_array == length_of_arraystring - 1\n word = arraystring[current_index_of_array].to_s\n fullsentence = fullsentence + word + '.'\n else\n word = arraystring[current_index_of_array].to_s\n fullsentence = fullsentence + word + ' '\n end\n current_index_of_array = current_index_of_array + 1\n\n end\n# puts fullsentence\n return fullsentence\nend",
"def spell_out word6\n word6.downcase.split(\"\").join(\"-\")\nend",
"def random_word\n letters = ('a'..'z').to_a\n word = []\n length = (rand 15) + 1\n \n length.times do\n word << letters[rand(25)] \n end\n\n word.join ''\nend",
"def single_word(word)\n if word[0] =~ /[aeiou]/i\n word + \"way\"\n else\n # nueva condicionante para palabras de puras consonantes sin vocales. ej: by\n if word.split(/([aeiou].*)/).length > 1\n # Parte palabra en 2 y lo mete en un array. 1er elemento es de consonat(es) iniciales, 2o la parte restante de la palabra a partir de e incluyendo la primera vocal\n word.split(/([aeiou].*)/)[1] + word.split(/([aeiou].*)/)[0] + \"ay\"\n else\n word.split(/([aeiou].*)/)[0]\n end\n end\nend",
"def sentence_maker(string_array)\nnew_string = \"\"\nnew_array = []\n\nstring_array.each do |string|\n if string != string_array[-1]\n new_string += string.to_s + \" \"\n else\n new_string += string.to_s\n end\n \n new_array.push(new_string)\nend\nreturn new_array[-1].capitalize + \".\"\nend",
"def word\n @letters.join\n end",
"def sentence_maker(array)\n array.join(\" \")\n array(0,1).capitalize + array(1..-1) + \".\"\nend",
"def reverberate(str)\n reverberated = []\n vowels = \"aeiou\"\n\n str = str.split(\" \")\n str.each_with_index do |word, idx|\n if word.length < 3\n reverberated << word\n elsif vowels.include?(word[-1])\n reverberated << word + word.downcase\n else \n i = word.length - 1\n suffix = \"\"\n while i >= 0 \n if !vowels.include?(word[i])\n suffix += word[i]\n else\n suffix += word[i]\n suffix = suffix.reverse\n reverberated << (word + suffix)\n break\n end\n i -= 1\n end\n end\n end\n reverberated.join(\" \")\nend",
"def create_sentence(words)\n\n\tstr=\"\"\n\tfor i in 0..words.size-1 do\n\t\tstr+=words[i]\n\t\tstr+=\" \"\n\n\tend\n\nputs str\n\t\nend",
"def yell(words)\n newArr = []\n i = 0\n while i<words.length\n newWord = words[i] + \"!\"\n newArr << newWord\n i += 1\n end\n return newArr\n end",
"def whisper_words(words)\r\n return words.map { |ele| ele.downcase + \"...\" }\r\nend",
"def spinWords(string)\n string.split.map{|e|e.to_s}.map{|e| e.length >= 5 ? e.reverse : e}.join(' ').to_s\nend",
"def replace(word, letter, ind)\n (word[0...ind] || '') << letter << (word[ind+1..-1] || '')\nend",
"def aliass(full_name)\n\talphabet = \"bcdfghjklmnpqrstvwxyz\"\n\tvowels = \"aeiou\"\n\tnew_string = \"\"\n\n full_name.split('').each do |letter|\n \t\tif vowels.include?(letter)\n \t\t\tnew_string += vowel(letter)\n \t\telsif alphabet.include?(letter)\n \t\t\tnew_string += consonant(letter)\n \t\telse\n \t\t\tnew_string += letter\n \t\tend\nend\n#Transform this new string into an array\n#Swap first and second word in array\n#Turn new word into string\n#Create empty array outside of loop\nnew_word = new_string.split(' ')\n new_word.reverse!\n\nnew_word.map {|names| names.capitalize!}\nnew_string = new_word.join(\" \")\nend",
"def add_s(array)\n array.each_with_index.collect do |word,index|\n if index != 1 \n word + \"s\"\n else\n word\n end\n end\nend",
"def sentence_maker(words)\r\n\tsentence = ''\r\n\ti = 0\r\n\r\n\twhile i < words.length\r\n\t\tif i == 0 \r\n\t\t\tsentence = sentence + words[i].to_s.capitalize + ' '\r\n\t\t\ti += 1\r\n\t\telsif i == (words.length - 1)\r\n\t\t\tsentence = sentence + words[i].to_s + '.'\r\n\t\t\ti += 1\r\n\t\telse\r\n\t\t\tsentence = sentence + words[i].to_s + ' '\r\n\t\t\ti += 1\r\n\t\tend\r\n\tend\r\n\tp sentence\r\nend",
"def sentence_maker(array)\n\tcomplete = \"\"\n\tarray.each do |i|\n\t\tcomplete = complete + i.to_s + \" \"\n\tend\n\tcomplete.insert(-2, \".\")\n\treturn complete.strip.capitalize\nend",
"def add_s(array)\n array.each_with_index.collect do |word, index|\n if index == 1\n word\n else\n word << \"s\"\n end\n end\nend",
"def reverse_words(string)\n array = string.split.map do |element| \n if element.length >= 5\n element.reverse\n else \n element\n end\nend\narray.join(' ')\nend",
"def spinWords(string)\r\n \r\n var= string.split(' ') #[\"Hey\", \"fellow\", \"warriors\"]\r\n finalarry=[]\r\n var.each do |x|\r\n arry= x.split('') \r\n if arry.count >= 5\r\n finalarry << arry.reverse\r\n else\r\n finalarry<< arry\r\n end\r\n\r\n \r\n end\r\n \r\n lastarry=[]\r\n finalarry.each do |y|\r\n lastarry << y.join(\"\")\r\n \r\n end\r\n \r\n result= lastarry\r\n p result.join(' ')\r\n\r\n\r\n \r\n \r\nend",
"def add_s(array)\n array.each_with_index.collect do |word, index|\n if (index == 1)\n word = word\n else\n word = word + 's'\n end # if statement\n end # collect method\nend",
"def reverberate(sent) \n vowels = 'aeiou'\n words = sent.split\n new_words = []\n\n\n words.each do |word|\n if word.length < 3 \n new_words << word \n elsif vowels.include?(word[-1].downcase)\n new_words << word + word.downcase\n else\n i = word.length - 1\n while i >= 0 \n if vowels.include?(word[i]) \n new_words << word + word[i .. -1]\n break\n end \n\n i -= 1\n end \n end \n end \n\n new_words.join(' ')\n\nend",
"def staggered_case(words)\n mixed_chars = words.chars.each_with_index.map do |char, index|\n if index.even? && char =~ /[a-zA-Z]/\n char.upcase\n elsif index.odd? && char =~ /[a-zA-Z]/\n char.downcase\n else\n char\n end\n end\n mixed_chars.join\nend",
"def yell(words)\n yelling = []\n \n i = 0\n while i < words.length\n yelling << words[i] +\"!\"\n \n i += 1\n end\n \n return yelling\nend",
"def sentence_maker(strings)\n\n new_string = strings[0]\n i = 1\n while i < strings.length\n new_string = new_string + \" \" + strings[i].to_s\n i += 1\n end\n new_string = new_string + \".\"\n return new_string.capitalize\nend",
"def add_s(array)\n array.map.each_with_index do |word, index|\n if index != 1\n word + \"s\" \n else\n word \n end\n end\nend",
"def sentence_maker(array)\n result = array.join(' ')\n result = result.capitalize + \".\"\nend",
"def add_s(array)\n array.each_with_index.collect do |word, index|\n if index != 1\n word << \"s\"\n else\n word\n end\n end\nend",
"def yell(words)\n i = 0\n new_arr = []\n while i < words.length\n loud_words = words[i] + '!'\n new_arr << loud_words\n i += 1\n end\n return new_arr\nend",
"def sentence_maker (arr)\n\n arr[0] = arr[0].capitalize\n sentence = arr.join(\" \")\n\n return sentence + \".\"\nend",
"def sentence_maker(array)\n sentence = array.join(\" \")\n sentence = sentence.capitalize + \".\"\nend",
"def letterReverse (string_of_words)\n new_sentence = ''\n new_word = ''\n word_array = string_of_words.split(' ')\n word_array.each do |elem|\n new_word = elem.split('').reverse().join('')\n puts new_word\n new_sentence.concat(new_word + ' ')\n puts new_sentence.to_s\n end\n new_sentence\nend",
"def reverse_words(words)\n arr = words.split\n arr.each_with_index do |word, index|\n if word.size >= 5\n arr[index] = word.reverse\n end\n end \n arr.join(' ') \nend",
"def sentence_maker(array_of_strings)\n\n sentence = array_of_strings[0].capitalize\n \n for i in array_of_strings[1..-1]\n sentence += \" \" + i\n end \n p sentence + \".\"\n \nend",
"def smash(words)\n sentence = \"\"\n words.each do |w|\n sentence = sentence + \"#{w} \"\n end\n sentence[0..-2]\nend",
"def sentence_maker (array)\n array[0].capitalize!\n return array.join(\" \") + \".\"\nend",
"def add_s(array)\n array.each_with_index.collect do |word, index|\n if index != 1\n word << \"s\"\n else\n word\n end\n end\nend",
"def yell(words)\n\tnew_words = []\n\n\ti = 0\n\twhile i < words.length\n\t\twords[i] += \"!\"\n\t\tnew_words << words[i]\n\t\ti += 1\n end\n\t\n\treturn new_words\nend",
"def pig_latin_name(word)\n \n letters = word.split(\"\")\n \n final_array = letters.clone\n letters.each do |letter| #[p, l, u, m]\n \n \n if is_consonants?(letter)\n final_array.rotate! \n # #puts \".........#{removed_consonant}\"\n # #letters.push(removed_consonant)\n # puts \".........#{final_array}..#{letters}\"\n else \n # puts \"*****#{final_array}.... #{letters}\"\n final_array.push(\"ay\")\n return final_array.join\n end\n end\nend",
"def sentence_maker(arr)\n string = \"\"\n i = 1\n while i < arr.length-1\n string += arr[i].to_s + ' '\n i+=1\n end\n sentence = arr[0].capitalize! + \" \" + string + arr[-1] + \".\"\n return sentence\nend",
"def add_s(array)\n array.each_with_index.collect {|word, index| index != 1 ? word << \"s\" : word}\nend",
"def sentence_maker(array)\n sentence = \"\"\n array.each do |x|\n sentence = sentence + x.to_s + \" \"\n end\n\n sentence[0] = sentence[0].upcase\n sentence = sentence.rstrip\n sentence = sentence + \".\"\n return sentence\n\nend",
"def pig_latin_translate\n english_word_arr = []\n vowel_array = %w(a e i o u)\n \n print \"What word would you like to translate? \"\n input = gets.chomp!.downcase\n \n english_word_to_translate = input.split(/ /)\n \n english_word_to_translate.each do |word|\n english_word_arr = word.split(//)\n\n\n\n #split by words\n #split by character\n #Take first letter move to end\n #add 'Ay'\n #join and return word\n end\nend",
"def sentence_maker(words)\n if words.size != 0\n sentence = \"\"\n for w in 0...words.size\n word = words[w]\n if (word.is_a? String)\n sentence += word + \" \"\n else\n sentence += word.to_s + \" \"\n end\n end\n sentence.chomp!(\" \")\n sentence += \".\"\n sentence.downcase!\n sentence.capitalize!\n return sentence\n end\nend"
] | [
"0.7509894",
"0.7119066",
"0.70673037",
"0.7008157",
"0.70066255",
"0.6972385",
"0.69626737",
"0.69122255",
"0.68784577",
"0.6859578",
"0.6840821",
"0.68321276",
"0.6817684",
"0.6811018",
"0.68086755",
"0.678137",
"0.6767597",
"0.6749509",
"0.6749509",
"0.6749509",
"0.67368525",
"0.67334443",
"0.6726141",
"0.67243534",
"0.67168856",
"0.67138654",
"0.67089987",
"0.670659",
"0.66972363",
"0.6695916",
"0.66906464",
"0.6689677",
"0.668808",
"0.66875553",
"0.6686286",
"0.66806465",
"0.6674872",
"0.6673315",
"0.66707474",
"0.66551316",
"0.66522574",
"0.66324127",
"0.6625649",
"0.6624473",
"0.66116494",
"0.66010576",
"0.6599523",
"0.6590569",
"0.6586123",
"0.65861166",
"0.6582814",
"0.65824807",
"0.6578385",
"0.6573487",
"0.657313",
"0.6572407",
"0.6565445",
"0.656251",
"0.65624756",
"0.6560928",
"0.6552116",
"0.6543367",
"0.6539743",
"0.65386015",
"0.6535715",
"0.65326524",
"0.6528968",
"0.6526987",
"0.65243256",
"0.65216464",
"0.6512469",
"0.6501975",
"0.6501198",
"0.64967823",
"0.6496719",
"0.64949507",
"0.6490825",
"0.64898133",
"0.6485743",
"0.64835757",
"0.64820284",
"0.64814055",
"0.6469718",
"0.6467354",
"0.64655536",
"0.6462756",
"0.64597756",
"0.6458978",
"0.64553624",
"0.64548963",
"0.6454541",
"0.64519274",
"0.6451161",
"0.64490116",
"0.64484614",
"0.6446953",
"0.6446022",
"0.64459884",
"0.64405143",
"0.6440351"
] | 0.70846355 | 2 |
creating method to pick a random word from the list of possible game words & phrases. this could be refactured to combine within above method but left as the assignment specification had it. | def gensecretword
@wordtable.sample.gsub(/\s+/, "") # revoving all whitespaces as wordfile has phrases as possible secret words
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def selectWord\n\twords = [\n\t\t\"anvil\",\n\t\t\"black\",\n\t\t\"break\",\n\t\t\"clear\",\n\t\t\"doubt\",\n\t\t\"exist\",\n\t\t\"first\",\n\t\t\"girth\",\n\t\t\"heart\",\n\t\t\"icons\",\n\t\t\"joker\",\n\t\t\"loath\",\n\t\t\"mirth\",\n\t\t\"notch\",\n\t\t\"overt\",\n\t\t\"print\",\n\t\t\"qualm\",\n\t\t\"react\",\n\t\t\"solid\",\n\t\t\"trick\",\n\t\t\"until\",\n\t\t\"viola\",\n\t\t\"water\",\n\t\t\"young\",\n\t\t\"zebra\"\n\t]\n\treturn words[Random.rand(words.length)]\nend",
"def choose_word\n @words = read_words unless @words\n return @words [rand @words.size]\nend",
"def pick_random_word\n random_word = @words.sample.gsub!(/\\s+/, \"\")\n end",
"def select_word\r\n\r\n #Define an array of 40 words from which the game will randomly select\r\n words = [\"W I N D O W\", \"S T A T I O N\", \"H A M B U R G E R\",\r\n \"E X P R E S S I O N\", \"W A L L E T\", \"C A M E R A\",\r\n \"A I R P L A N E\", \"C A N D L E\", \"C O M P U T E R\",\r\n \"P I C T U R E\", \"F R A M E\", \"S H E L F\", \"B O W L I N G\",\r\n \"P O L I T E\", \"S T A T E M E N T\", \"N E G A T I V E\",\r\n \"M E T H O D\", \"F I S H I N G\", \"C O M P E N S A T E\",\r\n \"H A P P Y\", \"F O O T B A L L\", \"S A N D W I C H\",\r\n \"I L L U S I O N\", \"S K E L E T O N\", \"S P A G H E T T I\",\r\n \"P H O T O G R A P H\", \"P U R I F Y\", \"O T O M A N\",\r\n \"I N C E N S E\", \"S T A I R C A S E\", \"C O L O S S E U M\",\r\n \"H O N E Y\", \"S C U L P T U R E\", \"M E A T L O A F\",\r\n \"M O T O R C Y C L E\", \"R E V O L U T I O N\", \"B L A N K E T\",\r\n \"S L A U G H T E R\", \"K I T T E N\", \"S T A M P E D E\"]\r\n\r\n #Generate and return a random number between 0 and 39\r\n randomNo = rand(39)\r\n\r\n #Return a randomly selected word to the calling statement\r\n return words[randomNo]\r\n\r\n end",
"def chooseRandomWord() \n @randomWord = @wordsList[rand(0..@wordsList.size)]\n @randomWord.downcase\n \n #adding \"_\" to the letters array to display during the game\n randomWordSize = @randomWord.size - 1\n (1..randomWordSize).each do |i| \n @lettersDisplayArr.push(\" _ \")\n \n end\n beginGame()\n end",
"def get_random_word\r\n @word_list.sample\r\n end",
"def pick_random_word(dictionary)\n random_num = rand(dictionary.length)\n dictionary[random_num]\n end",
"def select_word(words)\n word_selected = words[rand(words.length)].strip\n word_selected\n end",
"def random_word\n\t\tLEGAL_WORDS.sample # Gets random element from array\n\tend",
"def choices\n return [\"hello\", \"goodbye\", \"yay\"] #FIXME\n #Randomly pick 3 other words that are not the same as the current word\n #FIXME: 1..20 should be the number of words we have\n selectedWordIds = (1..20).sort_by{rand}[1..4] # first four ids are our four words\n selectedWordIds.delete(self.wordid)\n selectedWords = selectedWordIds.map { |wordid| Word.findWord(java.lang.Integer.new(wordid)).first.first }\n selectedWords.shuffle\n return selectedWords\n end",
"def word_selector\n\t\t@game_word = @word.sample\n\tend",
"def pick_a_word\n\t\tbucket = @dictionary[@dictionary.keys[rand @dictionary.size]]\n\t\tpair = bucket[rand bucket.size]\n\t\tpair.last\n\tend",
"def pick_secret_word\n @word = dictionary.sample\n word\n end",
"def get_random_word(words)\n # rand method with an integer argument (the length of words) get a new integer between 0 & the length of words\n return words[rand(words.count)]\n end",
"def random_word\n wordpair = nil\n File.foreach(\"wordlist\").each_with_index do |line, number|\n wordpair = line if rand < 1.0/(number+1)\n end\n word = Word.new(wordpair.split(':')[0], wordpair.split(':')[1])\n return word\n end",
"def word\n options = []\n case @theme\n when \"default\"\n options = [\"cast\", \"puppy\", \"pineapple\", \"bananas\"]\n @word_to_guess = options.sample\n when \"food\"\n options = [\"mango\", \"papaya\", \"guava\", \"apples\", \"lychee\"]\n @word_to_guess = options.sample\n when \"hacker\"\n options = [\"bandwidth\", \"synthesize\", \"bypass\", \"cyberpunk\", \"firewall\"]\n @word_to_guess = options.sample\n when \"game of thrones\"\n options = [\"stark\", \"lannister\", \"arya\", \"hodor\", \"meereen\"]\n @word_to_guess = options.sample\n when \"lord of the rings\"\n options = [\"lothorien\", \"galadriel\", \"frodo\", \"bombadil\", \"goldberry\"]\n @word_to_guess = options.sample\n end\n end",
"def choose_word\n input = File.open(\"words.txt\", 'r')\n words = []\n input.readlines.each do |line|\n words.push(line.strip().downcase)\n end\n input.close()\n words[rand(words.length)]\n end",
"def select_word\r\n\t\t@answer = @words[rand(27)]\r\n\r\n\r\n\t\t# this would be a list of hashes\r\n\t\t@question = \"\"\r\n \t@tempque=\"\"\r\n\t\tfor x in 0..@answer.length\r\n\r\n\t\t\t@question=@question+\"#\"\r\n \t\t@tempque=@tempque+\"#\"\r\n\t\tend\r\n\t\treturn @answer\r\n\r\n\tend",
"def get_word\n word = @word_list[rand(@word_list.length)]\n @word = word.gsub(/\\s+/, \"\").downcase\n end",
"def get_word(key = '')\n words = self.words[key] || []\n extras = key == '' ? 2 : 3\n\n while true\n n = rand(words.length + extras)\n existing_word = words[n]\n return existing_word if existing_word\n\n new_word = make_word(key)\n bad = false\n self.words.each do |word|\n if word.include? new_word\n bad = true\n break\n end\n end\n next if bad\n words << new_word\n self.words[key] = words\n\n return new_word\n end\n end",
"def random_word\n word = WORDS[rand(WORDS.length)]\n word == \"\" ? random_word : word\nend",
"def pick_word\n @dictionary = File.readlines('dictionary.txt').map(&:chomp)\n @computer_word = @dictionary.sample\n end",
"def choose_word\n word_index = 0\n loop{\n word_index = rand(@text_file.length.to_i)\n if @text_file[word_index].length.to_i > 4 && @text_file[word_index].length.to_i < 12\n break\n end\n }\n @word = @text_file[word_index]\n end",
"def choose_word\n @word = @lines[rand(0..(@lines.length - 1))].chomp\n choose_word if @word.length < 5 || @word.length > 12\n end",
"def select_word\n uri = URI('https://random-word-api.herokuapp.com/word?number=5')\n words = Net::HTTP.get(uri) \n words = words.delete(\"[\").delete(\"]\").delete(\"\\\"\")\n words = words.split(\",\")\n index = rand(words.count - 1)\n return words[index]\n end",
"def random_word\n\t\tnumber = rand(@modified_dictionary.length)\n\t\t@modified_dictionary[number]\n\tend",
"def random_word\n words = @dictionary.dictionary.keys\n words[rand(words.length)]\n end",
"def pick_mystery_word\n @picked_word = self.dict.sample\n self.picked_word.length\n end",
"def random_word\n open('/usr/share/dict/words').read.split(/\\n/).sample\n end",
"def random_word\n @words.fetch(rand(@words.length)).chomp\n end",
"def word_picker\n dictionary = File.readlines('lib/5desk.txt')\n word = dictionary.sample(1)[0].chomp.downcase\n word = dictionary.sample(1)[0].chomp.downcase until word.length.between?(5, 12)\n word\n end",
"def get_word(difficulty)\n WORDS.select{|word| word.length == difficulty}.sample\nend",
"def GetRandomWord(wordArray)\n index = rand(wordArray.size)\n return wordArray[index]\nend",
"def draw_word\n @words.sample(random: Ibsenphrase::Random.prng)\n end",
"def catch_phrase\n translate('faker.company.buzzwords').collect { |list| sample(list) }.join(' ')\n end",
"def get_word\r\n\t # Variable initialization\r\n\t wordArray = []\r\n\t count = 0\r\n\t random_int = 0\r\n\t \r\n\t # Stores each word that is on a new line into an array\r\n\t f = File.open(\"5desk.txt\", \"r\")\r\n\t f.each_line{ |line| wordArray << line }\r\n\t f.close\r\n\t \r\n\t # Selects the random word between the desired length of between 5 and 12 characters. \r\n\t # Note that this includes an extra delimiter at the end of each word\r\n\t until wordArray[random_int].length > 5 && wordArray[random_int].length < 14 do\r\n\t random_int = Random.new.rand(0..61405)\r\n\t end\r\n\t wordArray[random_int].chomp!\r\n\tend",
"def random\n init if @words.empty?\n\n @words.pop\n end",
"def catch_phrase\n translate('faker.company.buzzwords').collect {|list| list.sample }.join(' ')\n end",
"def pick_dictionary_word(options={})\n min_length = (options[:exact] || options[:min] || 1).to_i\n max_length = (options[:exact] || options[:max] || 5).to_i\n \n language = (options[:language] || @@default_language).to_s\n validate_language(language)\n \n dictionary = options[:dictionary] || @@dictionaries[language] ||= load_dictionary(language)\n validate_dictionary(dictionary)\n \n sized_words = dictionary.select do |word|\n min_length <= word.length && word.length <= max_length\n end\n if !sized_words.empty?\n return sized_words[rand(sized_words.length)] \n else\n # TODO: How should an empty sized_words be handled?\n return \"\"\n end\n end",
"def get_word(word)\n chosen = \"\"\n\n if !@graph.words[word].nil? then\n \n # sum up all values in our word to get range\n total = 0\n @graph.words[word].map { |k,v| total += v }\n\n # grab some random val from said range\n sel = rand(total)\n\n # return the first word that has a\n # weight greater than our 'random number'\n # ensure we remove the weight from random\n # on each iteration\n @graph.words[word].each do |k,v|\n\n if v > sel then\n chosen = k\n break\n end\n\n sel -= v\n\n end\n\n return chosen\n end\n\n end",
"def random_word(lexicon)\n lexicon[rand(lexicon.length)] \n end",
"def pick_a_word(length)\n #remove sandwich code and change into map after it gets working\n words = get_words.split(\" \")\n filtered_wrds_by_length = []\n \n words.each do |wrd| #or select method\n if wrd.size == length.to_i\n filtered_wrds_by_length << wrd\n end\n end\n\n chosen_word = filtered_wrds_by_length.sample\n\nend",
"def generate_secret_word\n dictionary = File.open('5desk.txt', 'r').readlines\n legal_words = []\n\n dictionary.each do |line|\n word = line.chomp\n legal_words << word if legal_word?(word)\n end\n\n legal_words.sample\n end",
"def choose_code_word\n dictionary = []\n File.readlines(\"word_list.txt\").each do |word|\n if word.length > 4 && word.length < 13\n dictionary.push(word.strip.downcase)\n end\n end\n @code_word = dictionary[rand(dictionary.length)]\n end",
"def select_word\n words = File.readlines(\"5desk.txt\").select { |word| word.length.between?(5, 12) }\n words[rand(words.length)].strip\n end",
"def get(word)\r\n return \"\" if !@words[word]\r\n follow = @words[word]\r\n sum = follow.inject(0) { |sum,kv | sum +=kv[1] }\r\n random = rand(sum)+1\r\n part_sum = 0\r\n nextWord = follow.find do |word, count|\r\n part_sum += count\r\n part_sum >= random\r\n end.first\r\n nextWord\r\n\r\n end",
"def pick_random\n random_word = nil\n File.open(\"words.txt\") do |file|\n file_lines = file.readlines()\n random_word = file_lines[Random.rand(0...file_lines.size())]\n end\n return random_word\n end",
"def get_word\n\t\tselection = IO.readlines(\"colors.txt\")\n\t\t@word = selection[rand(selection.length)].downcase.chomp\n\t\t@word_array= @word.chars.to_a\n\t\tputs \"Here's the word cheaty, #{@word.upcase}\"\n\tend",
"def choose_word\n case @game_mode\n when \"computer guess\"\n puts \"Choose a word! (It must be in the dictionary)\"\n @word = gets.chomp\n when \"human guess\"\n @word = computer_guess\n end\n end",
"def weighted_random(lastword)\n # If word has no words in its dictionary (last word in source text file)\n # have it pick a random word to display instead.\n @dictionary.dictionary.fetch(lastword, NULL_OBJECT).sample\n end",
"def generate\n vocab_word = VocabWord.offset(rand(VocabWord.count)).first\n self.vocab_word = vocab_word\n VocabWord.with_same_type_as(vocab_word).except(vocab_word).sample(3).each do |word|\n self.choices << Choice.new(vocab_word: word)\n end\n self.choices << Choice.new(vocab_word: vocab_word)\n self\n end",
"def pick_secret_word\n\t\tFile.read(\"5desk.txt\").lines.select {|word| (4..9).cover?(word.size)}.sample.strip\n\tend",
"def guess_word(word_length)\n self.sample(dict.select { |word| word.length == word_length } )\n end",
"def new_game\n dictionary = File.readlines(\"assets/5desk.txt\").map {|word| word.chomp}\n dictionary.select! {|word| word.length >= 5 && word.length <= 12}\n @chosen_word = dictionary[(dictionary.size * rand).floor]\n\n puts \"A word has been chosen that is #{@chosen_word.length} letters long.\"\n puts \"You may guess the letters in that word one letter at a time,\"\n puts \"or you may guess the whole word, but a man's life \\\"hangs\\\" in\"\n puts \"the balance. So be careful not to make too many wrong guesses,\"\n puts \"because once his whole body and both of his eyes have been\"\n puts \"drawn, he's dead and you lose!\"\n puts \"\\n\"\n\n @word_guess = WordGuess.new(@chosen_word)\n @dead_man = DeadMan.new\n\n round\n end",
"def get_word\n words = File.readlines(\"lib/5desk.txt\")\n words.each { |word| word.chomp! }\n words_list = words.select { |word| word.length.between?(5, 12)}\n\n words_list.sample.downcase.split(\"\")\n end",
"def get_word(dictionary)\n word = dictionary[rand(dictionary.length)]\n # Ensure that the word is between 5 and 12 letters long.\n if word.length.between?(5,12)\n return word.downcase.strip\n else\n get_word(dictionary)\n end\n end",
"def select_word\n @answer = \"\"\n @word = \"\"\n while not is_valid?\n @word = IO.readlines(\"../5desk.txt\")[rand(61405)].chomp\n end\n @word.downcase!\n puts @word\n @word.scan(/./){@answer << '*'}\n puts @answer\n end",
"def choose_words(size: 4)\n chosen = words.sample(size)\n\n block_given? ? (yield chosen) : chosen\n end",
"def new_word\n\t\tdictionary = File.open(\"5desk.txt\", \"r\").readlines\n\t\tbegin \n\t\t\t@the_word = dictionary[rand(0..dictionary.length)]\n\t\tend while @the_word.length >= 12 || @the_word.length <=5\n\t\t@the_word\n\tend",
"def random_phrase(text_array)\n enable_start = @nr_of_words - @phrase_length\n start = rand(0..enable_start)\n text_array[start..(start+@phrase_length)].join(\" \")\n end",
"def pick_secret_word\n\t\t@secret_word = @dictionary.sample.chomp.downcase\n\t\t@secret_word.length\n\tend",
"def random_word(fandom_name_or_names = random_fandom)\r\n fandom_name = case fandom_name_or_names\r\n when Array\r\n validate_fandom_list fandom_name_or_names\r\n random_fandom_name_from fandom_name_or_names\r\n when String\r\n fandom_name_or_names\r\n else\r\n raise ArgumentError, \"Argument must be [Array, String] not #{fandom_name_or_names.class}\"\r\n end\r\n\r\n fetch_fandom fandom_name\r\n end",
"def random_word(msg)\n return if Variables::Constants::IGNORED_USERS.include?(msg.user.nick)\n word = LiterateRandomizer.word\n @last_words = [] if @last_words.nil?\n word = LiterateRandomizer.word while @last_words.include?(word)\n @last_words.prepend_capped(word, 5)\n msg.reply(word)\n end",
"def a_word\n return @random_word\n end",
"def dictionary_word\n dict = File.readlines(\"./data/5desk.txt\")\n word = dict[rand(dict.length)].strip while word.nil? || word.length <= 5 || word.length >= 12\n word\n end",
"def randomly( word )\n send( [ :point, :delete, :insert ].random, word )\n end",
"def make_word\n @secret_word = File.readlines('dictionary.txt').sample.chomp.downcase.split('')\n @working_word = Array.new(@secret_word.length) { \"_\" }\n end",
"def pick_another\n return @graph.words.keys[rand(@graph.words.size)]\n end",
"def choose_word\n words = File.readlines(\"5desk.txt\")\n words.map! { |word| word.chomp } # Remove newline characters from the file\n words.select! { |word| (word.size >= 5) && (word.size <= 12) }\n words.sample\n end",
"def get_the_word\n words = File.readlines(\"5desk.txt\")\n words = words.map do |word|\n word.strip\n end\n words = words.select do |word|\n (word.length > 4) && (word.length < 13)\n end\n words.sample.upcase.split(\"\")\n end",
"def get_word\n @word_to_guess.join\n end",
"def randomWord(smallest, largest)\n\t\tlist = to_a(smallest,largest)\n\t\tnumber = rand(list.size) + 1\n\t\tlist[number].downcase.chomp\n\tend",
"def get_random_word(filename)\n dictFile = File.open filename\n words = dictFile.readlines.reduce([]) do |words, word|\n if word.strip!.length >= 8\n words << word\n end\n words\n end\n words[(rand words.length)]\nend",
"def secret_word\n\t\tselected_text = []\n\t\ttext = File.open('5desk.txt').each do |line|\n\t\t\tif line.strip.size >=5 && line.strip.size <=12\n\t\t\t\tselected_text << line.strip\n\t\t\tend\n\t\tend\n\t\tselected_text[rand(selected_text.size)].downcase.chomp\n\tend",
"def choose_word\n file = File.open(\"hangman_words.txt\", \"r\")\n #Choose a random file line\n n = (file.readlines().size.to_i)\n i = rand(1..n)\n i-=1\n #Won't work if I don't close and reopen. Why??\n file.close \n file = File.open(\"hangman_words.txt\", \"r\")\n selected_line = file.readlines[i]\n file.close\n new_array = selected_line.split(',')\n @word = new_array[0].to_s\n @hint = new_array[1].to_s.strip\n \n # update word lines to correct length\n @word.size.times do\n @word_lines += \"_\" end\n end",
"def adv\n @words1 = Word.all.sample(1)[0].word\n @words2 = Word.all.sample(1)[0].word\n end",
"def random_capitalized_word\n attempts = 0\n # If you don't find a capitalized word after 15 attempts, just use\n # a lowercase word as there may be no capitals in the dicationary.\n until attempts > 15\n attempts += 1\n words = @dictionary.dictionary.keys\n random_choice = words[rand(words.length)]\n if random_choice[0] =~ /[A-Z]/\n return random_choice\n end\n end\n random_word\n end",
"def word_generator\ntotal_words = []\nFile.open(\"5desk.txt\", \"r\") do |f|\n f.each_line do |line|\n total_words << line \n end\n end\nwords_count = 61407\nrandom_number = rand(0...words_count)\nrandom_word = total_words[random_number]\n# random_word if random_word.length >= 5\nend",
"def get_random_word(dictionary, min_length, max_length)\n random_word = nil\n loop do\n random_index = rand(dictionary.length)\n random_word = dictionary[random_index]\n break if not random_word.nil? and\n (min_length..max_length).cover? random_word.length\n end\n return random_word\n end",
"def get_word\n dictionary_file = '5desk.txt'\n dictionary = File.readlines(dictionary_file)\n until @secret_word.length > 5 && @secret_word.length < 12\n @secret_word = dictionary.sample.rstrip.downcase\n end\n @secret_word\n end",
"def random_word(random_generator:, random_capitalize: true) # :nodoc:\n random_word = WORDSET[random_bits(random_generator: random_generator, n_bits: log2(WORDSET.length))].dup\n random_word.capitalize! if random_capitalize && (random_bits(random_generator: random_generator, n_bits: 1) == 1)\n random_word\n end",
"def pick_words \n if @num_words == 0\n @word_list = @tf_in_dataset.keys\n else\n @word_list = @tf_in_dataset.to_a.sort { |a, b| b[1] <=> a[1] }.take(@num_words).map { |a| a[0] }\n end\n end",
"def new_game\n\t\t# Get the full list of words\n\t\twords = File.readlines('wordlist.txt')\n\t\tvalid_words = []\n\t\twords.each do |w| \n\t\t\t# Take all new lines and returns out\n\t\t\tw.gsub!(/\\r\\n/, \"\")\n\t\t\t# Word is valid if it's between 5 and 12 characters and isn't a proper noun. (no fair using names and such!) \n\t\t\tvalid_words << w if w.length.between?(5,12) && w[0] != w[0].upcase\n\t\tend\n\t\t# Split secret word into an array of letters\n\t\t@word = valid_words.sample.split(\"\").to_a\n\t\t# This holds user's guess. Originally populated with \"_\" for each letter\n\t\t@guess = \"\"\n\t\t@word.length.times { @guess += \"_\"}\n\t\t# Holds user's wrong letters. Originally populated with 9 x \"_\"\n\t\t@wrong_letters = \"\"\n\t\t9.times { @wrong_letters += \"_\"}\n\t\t@turn = 0\n\t\tputs \"Your task is to guess the secret word, letter by letter.\"\n\t\tputs \"You have only 9 wrong letters before you lose, so guess carefully!\"\n\t\tputs\n\t\tputs \"Here is your word. Each _ is a letter.\"\n\t\tputs\n\t\tget_guess\n\tend",
"def random_word\n letters = ('a'..'z').to_a\n word = []\n length = (rand 15) + 1\n \n length.times do\n word << letters[rand(25)] \n end\n\n word.join ''\nend",
"def words(length)\n WORDS.sample(length)\nend",
"def getWord\n return RandomWord.adjs.next\nend",
"def prepare( word, m, chainlen, simto )\n xchain = m.bot.set.logic.maxchainlength\n nchain = m.bot.set.logic.minchainlength\n wid = -1\n oword = word\n \n # Rope our chain length into whatever config has it set as\n if not chainlen.is_a? Integer or chainlen <= 0\n chainlen = Random.new.rand nchain..xchain\n elsif chainlen > xchain\n chainlen = xchain\n elsif chainlen < nchain\n chainlen = nchain\n end\n\n if simto\n word = \"%#{word}%\"\n wid = m.getFirst_i_rand \"id\", \"words WHERE word SIMILAR TO ?\", word\n else\n wid = m.getFirst_i_rand \"id\", \"words WHERE word ILIKE ?\", word\n end\n \n if wid == nil or wid <= 0\n m.reply \"I don't know the word: \\\"#{oword}\\\"\"\n end\n\n return wid, chainlen\n end",
"def scrambled_words\n print \"Enter a word: \"\n response = gets.chomp\n scrambled_version = response[0] + response[1..-2].chars.shuffle.join + response[-1]\n puts \"Scrambled version: #{scrambled_version}\"\nend",
"def assignWord(level)\n if level == \"1\"\n begin\n @assignedword = Faker::Hipster.word\n end until @assignedword.length <= 6\n # infinte loop if database without words > 8 letters\n elsif level == \"2\"\n begin\n @assignedword = Faker::Hipster.word\n end until @assignedword.length > 6 && @assignedword.length <= 10\n elsif level == \"3\"\n begin\n @assignedword = Faker::Hipster.word\n end until @assignedword.length > 10\n end\n return @assignedword\n end",
"def random_weapon\n weapons = [\"sword\",\"bow and arrow\",\"laser gun\",\"Jungle Sword\",\"Lunar Cue\",\"Crimson Blaster\",\"Quake Hammer\",\"Drive Vortex\",\"Drive Defender\",\" Road Blaster\",\"Turbo Axe\",\"Rocket Blaster \"]\n weapon = weapons[rand(weapons.length)]\nend",
"def computer_letter_choice(current_word, turn_number)\n puts \"Computer is thinking...\"\n\n # node = @t.root\n # next_letter = \"\"\n\n # # Searches down the trie changing the node of the current word\n # current_word.split('').each do |char|\n # break unless node.walk!(char)\n # end\n\n # winning_node = recursive_winning_node_search(node)\n # unless winning_node.nil? # Winning node exists\n # next_letter = winning_node.state\n # else\n # words_array = []\n # @t.children(current_word).each do |word|\n # words_array << word\n # end\n\n # words_array = words_array.sort_by(&:length) # Sort words by length\n # longest_word = words_array[-1] # Choose longest word given current_word prefix\n\n # # Debugging output\n # puts \"Computer chose longest word: #{longest_word}\"\n\n # next_letter = longest_word[turn_number]\n # end\n\n # return next_letter\n\n # Old method of selecting winning words\n win_words = @t.children(current_word) \n odd_length_words = []\n even_length_words = []\n\n # Go through all winning words and separate into odd and even length strings\n win_words.each do |word|\n if word.length % 2 == 0\n even_length_words << word\n else\n odd_length_words << word if self.is_winning_word?(word)\n end\n end\n\n # Debugging output for 'n'\n # puts \"Winning player words\"\n # even_length_words.each do |word|\n # puts word if self.is_winning_word?(word)\n # end\n\n optimal_word = ''\n if odd_length_words.length > 0 # Winning word/strategy exists, choose randomly from\n optimal_word = odd_length_words.sample\n\n # Not sure about this line\n # if optimal_word.length == (turn_number + 1)\n # optimal_word = odd_length_words.sample\n # end\n elsif even_length_words.length > 0 # No winning word exists, stall\n even_length_words = even_length_words.sort_by(&:length) # Sort even length words by length\n optimal_word = even_length_words[-1] # Select last element of even length words (invariance guarantees longest string)\n else # No words left to choose from, admit defeat\n optimal_word = \"x\"\n end\n\n # Debugging output\n puts \"Computer chose word #{optimal_word}\"\n\n next_letter = (optimal_word.length > 1 ? optimal_word[turn_number] : optimal_word[0])\n\n return next_letter\n end",
"def correctly_picked(game_data)\n missing_letters = game_data.randomly_picked_word - game_data.chosen_letters\n display_array = []\n game_data.randomly_picked_word.each do |letter|\n display_array << if missing_letters.include? letter\n ' _ '\n else\n \" #{letter} \"\n end\n end\n display_array.join\n end",
"def existing_words\n draw_current = draw\n p \"The 7 letters drawn are:\"\n p draw_current\n p \"-\"*70\n\n combinations = combine(draw_current).flat_map{ |w| w.permutation.to_a}.uniq.map { |e| e.join }\n combinations.map{|i| search(i, UPPER_BOUND_INI, LOWER_BOUND_INI, NO_ITERATION_INI)}.flatten.reject{|x| x==nil}\nend",
"def set_word\n dic = File.read(\"dic.txt\").downcase.split\n dic.reject! {|word| word.length<5 || word.length>12}\n word = dic.sample\n end",
"def scramble_words(chars = WordChars)\n\t\tgsub(/(#{chars})(#{chars}+)(?=#{chars})/) { $1 + $2.randomize }\n\tend",
"def modified_word(word)\n idx = rand(-1...word.length)\n str = word[idx]\n tmp_word = if idx.even?\n word.insert(idx,str)\n else\n word.delete(str)\n end\n return tmp_word unless dictionary.dict.include?(tmp_word)\n modified_word(word)\n end",
"def buzzword\n sample(translate('faker.company.buzzwords').flatten)\n end",
"def scramble(word)\n\tfor i in 0..100\n\t\tone = rand(word.length-1)\n\t\ttwo = rand(word.length-1)\n\t\tword[one], word[two] = word[two], word[one]\n\tend\nend",
"def gensecretword\r\n\t\t \trand_index = rand(@wordtable.length)\r\n\t\t \t@secret_clue = @descr[rand_index]\r\n\t\t \t@num_words = @wordtable[rand_index].split(\" \").length\r\n\t\t return @wordtable[rand_index].upcase\r\n\t\t end",
"def catch_phrase\n [\n [\"ninja\",\"master\",\"student\"].rand, \n [\"\", \"\", \"\", \"\", \"\", \"\", \"weapons\", \"s' 3rd annual\",\"s' 5th annual\",\"s' 10th annual\", \"s' secret\"].rand,\n [\"gathering\",\"celebration\",\"meeting\",\"tournament\",\"competition\",\"party\",\"training camp\",\"sparring event\"].rand,\n [\"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"with Leonardo\", \"with Raphael\", \"with Michaelangelo\", \"with Donatello\"].rand\n ].join(' ').gsub(/ s\\'/,'s\\'').gsub(/\\s\\s/,' ').strip\n end",
"def print_random_text(next_words)\nend"
] | [
"0.82101005",
"0.8003725",
"0.7924125",
"0.7850692",
"0.7797546",
"0.7792975",
"0.7689707",
"0.76704293",
"0.7669795",
"0.759776",
"0.75835365",
"0.7569125",
"0.75547206",
"0.7539337",
"0.7502712",
"0.7484366",
"0.7456372",
"0.745609",
"0.74144137",
"0.7329093",
"0.7324742",
"0.72817534",
"0.7273124",
"0.72177434",
"0.72153777",
"0.71912277",
"0.7186144",
"0.71666723",
"0.7162441",
"0.71410453",
"0.70967984",
"0.70940435",
"0.7072577",
"0.70648015",
"0.7000605",
"0.6954611",
"0.69539386",
"0.6929254",
"0.69196755",
"0.6900302",
"0.6896722",
"0.68888",
"0.68766963",
"0.6851644",
"0.682621",
"0.68233514",
"0.68124515",
"0.68015873",
"0.6794732",
"0.6750869",
"0.67469984",
"0.6675008",
"0.6669317",
"0.66409963",
"0.66189057",
"0.6611617",
"0.66078955",
"0.66064644",
"0.65980744",
"0.6580967",
"0.6580505",
"0.65707314",
"0.6564826",
"0.6558762",
"0.65392894",
"0.65374815",
"0.65307486",
"0.6512734",
"0.6511904",
"0.6495866",
"0.64938855",
"0.64844847",
"0.64764655",
"0.64661485",
"0.645293",
"0.6448153",
"0.6435928",
"0.6422925",
"0.6421698",
"0.642008",
"0.6390858",
"0.6376003",
"0.63709277",
"0.636575",
"0.63599914",
"0.6355951",
"0.6349716",
"0.63468593",
"0.6344343",
"0.6339405",
"0.6314414",
"0.63119423",
"0.63044274",
"0.62847143",
"0.62835276",
"0.62748605",
"0.62744594",
"0.62662935",
"0.62640244",
"0.6260361",
"0.6259923"
] | 0.0 | -1 |
human readable description of modeling approach | def modeler_description
return ''
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modeler_description\n return 'Gather orientation and story specific construction, fenestration (including overhang) specific information'\n end",
"def modeler_description\n return \"Example use case is adding special loads like an elevator to a model as part of an analysis workflow\"\n end",
"def modeler_description\n return 'Currently this is just setup for design level calculation method, but it could be extended as needed..'\n end",
"def modeler_description\n return 'shift or/and adjust heaing and cooling setpoint'\n end",
"def modeler_description\n return 'This model replaces the existing HVAC system with a VRF + DOAS system.'\n end",
"def modeler_description\n return \"This uses the OpenStudio::Model::Space::fromFloorPrint method, and is very much like the Create Spaaces From Diagram tool in the OpenStudio SketchUp plugin, but lets you draw teh diagram in the tool of your choice, and then imports it into the OpenStudio application via a measure.\"\n end",
"def modeler_description\n return 'This can be used in apply measure now, or can be used in a parametric workflow to load in any custom user profiles or floor/ceiling values.'\n end",
"def modeler_description\n return \"Any generators and electric load center distribution objects are removed. An electric load center distribution object is added with a track schedule equal to the hourly output from SAM. A micro turbine generator object is add to the electric load center distribution object. The fuel used to make the electricity is zeroed out.\"\n end",
"def modeler_description\r\n return \"objective function\"\r\n end",
"def modeler_description\r\n return \"objective function\"\r\n end",
"def modeler_description\r\n return \"For each model, find every DX cooling and heating coil and increase the COP to 6. Since very little information about this technology is available, do not change performance curves or upper/lower operating temperature limits.\"\r\n end",
"def modeler_description\n return 'Modify the cooling setpoint of the HVAC system during a DR event'\n end",
"def modeler_description\n return 'This a test measure in relation with https://github.com/NREL/OpenStudio/issues/4156'\n end",
"def modeler_description\n return \"When have existing OSM wanted to be able to grab geometry from model vs. trying to enter on website. This is useful when there is no built structures yet to use as reference on the website.\"\n end",
"def modeler_description\n return \"Grey water tank overflow will be dirrected to drainage. \"\n end",
"def modeler_description\n return \"NOTE: This will load and respond slowly in the OS app, especially if you select * on a variable with many possible keys or you select timestep data. Suggest you open it in a web browser like Chrome instead.\"\n end",
"def modeler_description\n return 'HVAC system creation logic uses [openstudio-standards](https://github.com/NREL/openstudio-standards) and efficiency values are defined in the openstudio-standards Standards spreadsheet under the *NREL ZNE Ready 2017* template.'\n end",
"def description()\n\t\tself.namespaced_class(:ModelDescriptor).goal(self)\n\tend",
"def modeler_description\n 'NOTE: This will load and respond slowly in the OS app, especially if you select * on a variable with many possible keys or you select timestep data. Suggest you open it in a web browser like Chrome instead.'\n end",
"def modeler_description\n return 'Not sure how I will handle arguments. Maybe lump together all spaces on same sotry that have the same multilier value. This will have variable number of arguments basd on the model pased in. Alternative is to either only allo w one group to be chosen at at time, or allow a comlex string that describes everything. Also need to see how to define shirting. There is an offset but it may be above and below and may not be equal. In Some cases a mid floor is halfway betwen floors which makes just copying the base surfaces as shading multiple times probemeatic, since there is overlap. It coudl be nice to stretch one surface over many stories. If I check for vertial adn orthogonal surface that may work fine. '\n end",
"def modeler_description\n return \"It does not even send anything related to the model. It just sends a simple pagkage at the end of every run, just to test if things really work.\"\n end",
"def modeler_description\n return ['Adds', 'the', 'properties', 'for', 'the', 'MoisturePenetrationDepthConductionTransferFunction', 'or', 'effective', 'moisture', 'penetration', 'depth', '(EMPD)', 'Heat', 'Balance', 'Model', 'with', 'inputs', 'for', 'penetration', 'depths.', \"\\n\\n\", 'Leaving', 'Change', 'heat', 'balance', 'algorithm?', 'blank', 'will', 'use', 'the', 'current', 'OpenStudio', 'heat', 'balance', 'algorithm', 'setting.', \"\\n\\n\", 'At', 'least', '1', 'interior', 'material', 'needs', 'to', 'have', 'moisture', 'penetration', 'depth', 'properties', 'set', 'to', 'use', 'the', 'EMPD', 'heat', 'balance', 'algorithm.'].join(' ')\n end",
"def modeler_description\n return \"Change water heater efficiency and fuel type.\"\n end",
"def modeler_description\n return \"Assume that the starting point technology is primarily 90.1-2013 T8 lighting, with an efficacy of 90 lm/W. According to Table 5.2, LED Efficacy Improvement, in (1), 2015 LED luminaire efficacy is 145 lm/W. Calculate the total lighting power of the model and divide by this initial efficacy to determine the total number of lumens needed. Assuming that this same number of lumens should be provided by LED lighting, divide by the LED efficacy to determine the total wattage of LEDs that would be necessary to achieve the same lighting. Reduce the overall building lighting power by the resulting multiplier. IE new LPD = old LPD * (1 - 90 lm/W /145 lm/W). This is a very crude estimate of the impact of current LED technology. In order to perform a more nuanced analysis, lighting in the prototype buildings should be broken down by use type (general space lighting, task lighting, etc.) and by currently assumed technology (T12, T8, metal halide, etc.). If this breakdown were available, each type of lighting could be modified according to its own efficacy characteristics. Additionally, this measure does not account for the impact of LEDs on outdoor lighting.\"\n end",
"def modeler_description\n return 'For each model, find every DX cooling and heating coil and increase the COP to 6. Since very little information about this technology is available, do not change performance curves or upper/lower operating temperature limits.'\n end",
"def modeler_description\n return \"This measure will replicate the functionality described in the EnergyPlus Energy Management System Application Guide, Example 2., based on user input.\"\n end",
"def modeler_description\n return 'This measure assigns load and flow information to a selected plant loop load profile.'\n end",
"def modeler_description\n return \"This is intended to run on an empty model. It will create the proper model associate it with the proper weather file, and add in necessary output requests. Internally to the measure the test case argument will be mapped to the proper inputs needed to assemble the model. The measure will make some objects on the fly, other objects will be pulled from existing data resources. This measure creates cases described all of section 5.3.\"\n end",
"def modeler_description\n return \"Each DX cooling coil in the model is replaced by a membrane heat pump. To represent the membrane heat pump, the DX cooling coil COP is increased to 7.62 (26 EER). Additionally, add a water use equipment object to account for the 3 gallons of water used per ton*hr of sensible cooling process.\"\n end",
"def modeler_description\n 'For the most part consumption data comes from the tabular EnergyPlus results, however there are a few requests added for time series results. Space type and loop details come from the OpenStudio model. The code for this is modular, making it easy to use as a template for your own custom reports. The structure of the report uses bootstrap, and the graphs use dimple js.'\n end",
"def modeler_description\n return 'Adds typical refrigeration equipment to a building'\n end",
"def modeler_description\r\n return \"\"\r\n end",
"def modeler_description\n return \"E+ RESNET\"\n end",
"def modeler_description\n return \"Reads the model and sql file to pull out the necessary information and run the model checks. The check results show up as warning messages in the measure's output on the PAT run tab.\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"\"\n end",
"def modeler_description\n return \"A measure that will take Annual Building Utilty Performance tables, Demand End use Components summary table, Source Energy End Use Components Summary and produce an output Json\"\n end",
"def modeler_description\n return \"Reads the model and sql file to pull out the necessary information and run the model checks. The check results show up as Warning messages in the measure's output on the PAT run tab.\"\n end",
"def modeler_description\n return 'The goal of this measure is to create a single space type that represents the loads and schedules of a collection of space types in a model. When possible the measure will create mulitple load instances of a specific type in the resulting blended space type. This allows the original schedules to be used, and can allow for down stream EE measures on specific internal loads. Design Ventilation Outdoor Air objects will have to be merged into a single object. Will try to maintain the load design type (power, per area, per person) when possible. Need to account for zone multipliers when createding blended internal loads. Also address what happens to daylighting control objets. Original space types will be left in the model, some may still be assigned to spaces not included in the building area.'\n end",
"def modeler_description\n 'It will be used for calibration maximum flow rate, efficiency, pressure rise and motor efficiency. User can choose between a SINGLE Fan or ALL the Fans.'\n end",
"def modeler_description\n return 'This measure has optional arguments to apply recommendations from different sections of the Zero Energy Multifamily Design Guide.'\n end",
"def modeler_description\n 'It will be used for calibration of WaterHeaterMixed. User can choose between a SINGLE WaterHeaterMixed or ALL the WaterHeaterMixed objects.'\n end",
"def modeler_description\n return \"It will be used for calibration of inlet water temperatures, inlet and outlet air temperatures and design flowrates. User can choose between a SINGLE coil or ALL the Coils.\"\n end",
"def modeler_description\n return 'Find the exterior lighting template for the building, and assume the existing efficiency level in the model (low, medium, high). Find the desing level and multiplier for each category of the exterior lighting definition. Apply the lighting upgrades by reducing the design level associated with each outdoor lighting category by a percent (depends on starting and target efficiency levels).'\n end",
"def modeler_description\n return 'Change UrbanOpt Scenario CSV'\n end",
"def modeler_description\n return 'Calculate thermal capacitance and UA for surfaces, furniture, and spaces.'\n end",
"def modeler_description\n return 'Reports resilience metric(s) of interest.'\n end",
"def modeler_description\n return \"The default space types in the measure inputs are automatically filled by the spaces' standard space types. User can overwrite the default assumptions in the library.csv file in the measure's resources folder.\"\n end",
"def modeler_description\n return 'Find the interior lighting template for the building, and assume the existing efficiency level in the model (low, medium, high, very high). Find the LPD and LPD fractions for each space type. Apply the lighting upgrades by reducing the LPD associated with compact lighting by a percent (depends on starting and target efficiency levels).'\n end",
"def modeler_description\n 'Run a simulation to autosize HVAC equipment and then apply these autosized values back to the model.'\n end",
"def modeler_description\r\n return \"E+ measure to popolate the Kiva settings values\"\r\n end",
"def modeler_description\n return 'This method calculates the annualized coefficient of performance (Btu out / Btu in) of equipment in the model from the annual simulation. This is used in Scout as the equipment efficiency for the technology competition categories.'\n end",
"def modeler_description\n return 'This will only impact schedule rulesets. It will use methods in openstudio-standards to infer hours of operation, develop a parametric formula for all of the ruleset schedules, alter the hours of operation inputs to that formula and then re-apply the schedules. Input is expose to set ramp frequency of the resulting schedules. If inputs are such that no changes are requested, bypass the measure with NA so that it will not be parameterized. An advanced option for this measure would be bool to use hours of operation from OSM schedule ruleset hours of operation instead of inferring from standards. This should allow different parts of the building to have different hours of operation in the seed model.'\n end",
"def modeler_description\n return \"Replace this text with an explanation for the energy modeler specifically. It should explain how the measure is modeled, including any requirements about how the baseline model must be set up, major assumptions, citations of references to applicable modeling resources, etc. The energy modeler should be able to read this description and understand what changes the measure is making to the model and why these changes are being made. Because the Modeler Description is written for an expert audience, using common abbreviations for brevity is good practice.\"\n end",
"def modeler_description\n return \"Any supply components or baseboard convective electrics/waters are removed from any existing air/plant loops or zones. Any existing air/plant loops are also removed. A heating DX coil, cooling DX coil, electric supplemental heating coil, and an on/off supply fan are added to a unitary air loop. The unitary air loop is added to the supply inlet node of the air loop. This air loop is added to a branch for the living zone. A diffuser is added to the branch for the living zone as well as for the finished basement if it exists.\"\n end",
"def modeler_description\r\n return 'modify simulation timestep'\r\n end",
"def modeler_description\n return 'Will add the necessary UtilityCost objects and associated schedule into the model.'\n end",
"def modeler_description\n return 'Replace this text with an explanation for the energy modeler specifically. It should explain how the measure is modeled, including any requirements about how the baseline model must be set up, major assumptions, citations of references to applicable modeling resources, etc. The energy modeler should be able to read this description and understand what changes the measure is making to the model and why these changes are being made. Because the Modeler Description is written for an expert audience, using common abbreviations for brevity is good practice.'\n end",
"def modeler_description\n return 'Replace this text with an explanation for the energy modeler specifically. It should explain how the measure is modeled, including any requirements about how the baseline model must be set up, major assumptions, citations of references to applicable modeling resources, etc. The energy modeler should be able to read this description and understand what changes the measure is making to the model and why these changes are being made. Because the Modeler Description is written for an expert audience, using common abbreviations for brevity is good practice.'\n end",
"def modeler_description\n return 'Passes in all arguments from the options lookup, processes them, and then registers values to the runner to be used by other measures.'\n end",
"def modeler_description\n return 'Daylighting controls will physically add in daylighting controls to spaces in the building, while occupancy control will reduce lighting schedules by 10%.'\n end",
"def modeler_description\n return 'This measure is used to calibrate the BRICR baseline model.'\n end",
"def modeler_description\n return \"This EEM adds EMS logic to the model that actuates the infiltration, HVAC operation, cooling set point, and heating set point schedules. The measure first identifies the schedule HVAC stopping point by day of week (Saturday, Sunday, and Weekdays). Early HVAC system shutoff is determined entirely by the outdoor air temperature (OAT). If the OAT is less than or equal to 2C or greater than or equal to 18C, then no action is taken. The HVAC system is shut off one hour early when the OAT is between 12C and 18C. The HVAC system shut off time varies linearly with OAT from one hour to zero hours between 12C and 2C, and between 18C and 28C. AvailabilityManager:OptimumStart objects are inserted for each HVAC system in the model and use the AdaptiveASHRAE algorithm to dynamically adjust HVAC startup time each day.\"\n end",
"def modeler_description\n return \"This measure will demonstrate how an OpenStudio measure calling EMS functions can be used to model the performance of HVAC equipment that cannot be represented well by using single “standard” performance curve objects (cubic, quadratic, biquadratic, etc.) For example, properly characterizing some HVAC equipment objects requires using different performance curves that cover operation of different parts of the performance regime. This measure will alter (overwrite) the Coil Cooling DX Single Speed Cooling Capacity as a function of temperature performance curve object and attributes used by the simulation if the outdoor air temperature falls below a user defined threshold. This measure allows the user to define the biquadratic curve coefficients associated with the Coil Cooling DX Single Speed Cooling Capacity.\"\n end",
"def modeler_description\n return \"Multipliers for LPD, EPD, and people densities.\"\n end",
"def modeler_description\n return \"This measure takes the user selected standards space type and sets the interior lighting and equipment load definitions subcategory to match the space type name. \"\n end",
"def modeler_description\n return 'Will add the necessary UtilityCost objects into the model.'\n end",
"def modeler_description\n return \"This measure will demonstrate how an OpenStudio measure calling EMS functions can be used to override specified thermostat control logic and set alternate modes of operation. This EMS measure sets a specific (user defined) indoor VRF terminal unit to operate at a specific (user-defined) part load ratio, constrained by operate minimum and maximum outdoor temperature limits of the paired condenser unit. The main input objects that implement this example are the variable refrigerant flow actuators that control the VRF system and specific terminal unit. Note that the terminal unit PLR can be controlled without controlling the mode of the VRF condenser, however, the specific terminal unit will operate in whatever mode the existing operation control scheme chooses. This example program simply “sets” the operating mode and PLR, other more complex control algorithms can be developed by the user as needed\"\n end",
"def modeler_description\n return 'This measure swaps old cases with 2017 code compliant cases and more efficient ones.'\n end",
"def modeler_description\n return \"The example demonstrates the use of a thermostat schedule object as and EMS actuator object. The EMS program alters the scheduled values as a function of hour of day and day of week.\"\n end",
"def modeler_description\n 'This measure changes the Layer 0 properties of Thickness, Density, Thermal Absorptance, Solar Absorptance, Visible Absoptance, Thermal Conductivity, Specific Heat.'\n end",
"def modeler_description\n return \"The measure loops through the AirLoops associated with the model, and determines an occupancy weighted schedule with values of 1 or 0 based on the percent of peak occupancy at the timestep being above or below a set threshold value of 5 percent. The resulting occupancy schedule is applied to the airloop attribute for the availability schedule. The measure then loops through all thermal zones, examining if there are zone equipment objects attached. If there are one or more zone equipment object attached to the zone, a thermal zone occupancy weighted schedule with values of 1 or 0 based on the percent of peak occupancy at the timestep being above or below a set threshold value of 5 percent is generated. The schedule is then assigned to the availability schedule of the associated zone equipment. To prevent energy use by any corresponding plant loops, the pump control type attribute of Constant or Variable speed pump objects in the model are set to intermittent. The measure them adds heating and cooling unmet hours and Simplified ASHRAE Standard 55 warning reporting variable to each thermal zone. \"\n end",
"def modeler_description\r\n return \"This measure loops through the existing airloops, looking for loops that have a constant speed fan. (Note that if an object such as an AirloopHVAC:UnitarySystem is present in the model, that the measure will NOT identify that loop as either constant- or variable-speed, since the fan is located inside the UnitarySystem object.) The user can designate which constant-speed airloop they'd like to apply the measure to, or opt to apply the measure to all airloops. The measure then replaces the supply components on the airloop with an AirloopHVAC:UnitarySystem object. Any DX coils added to the UnitarySystem object are of the type CoilCoolingDXMultiSpeed / CoilHeatingDXMultiSpeed, with the number of stages set to either two or four, depending on user input. If the user opts for a gas furnace, an 80% efficient CoilHeatingGas object is added. Fan properties (pressure rise and total efficiency) are transferred automatically from the existing (but deleted) constant speed fan to the new variable-speed fan. Currently, this measure is only applicable to the Standalone Retail DOE Prototype building model, but it has been structured to facilitate expansion to other models with a minimum of effort.\"\r\n end",
"def modeler_description\n return \"The measure loops through the heating and cooling thermostat schedules associated each thermal zone. The existing heating and cooling schedules are cloned, and the all run period profiles are then modified by adding a +1.5 deg F shift to the all values of the cooling thermostat schedule and a -1.5 degree F shift to all values of the heating thermostat schedule. Design Day profiles are not modified. The modified thermostat schedules are then assigned to the thermal zone. For each Thermal Zone, ASHRAE 55 Thermal Comfort Warnings is also enabled. Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status output variables is also added to the model.\"\n end",
"def modeler_description\r\n return \"The Measure adds a Schedule Availability Manager to the Selected Plant Loop\"\r\n end",
"def modeler_description\n return 'Converts the OpenStudio model to vA3C JSON format and renders using Three.js, simulation data is applied to surfaces of the model'\n end",
"def make_and_model; end",
"def modeler_description\n return 'This energy efficiency measure (EEM) replaces all cooling tower objects in a model of the following types: (OS:CoolingTowerPerformanceCoolTools, OS:CoolingTowerPerformanceYorkCalc, OS:CoolingTowerSingleSpeed, OS:CoolingTowerTwoSpeed, or OS:CoolingTowerVariableSpeed) with a new OS:CoolingTower:VariableSpeed object. If an existing cooling tower is already configured for variable speed, the measure will inform the user. When replacing an existing tower object, the following values from the existing tower configuration will be reused: Design Inlet Air Wet Bulb Temp, Design Approach Temperature, Design Range Temperature, Design Water Flow Rate, Design Air Flow Rate, Design Fan Power, Fraction of Tower Capacity in the Free Convection Regime, Basin Heater Capacity, Basin Heater Setpoint Temperature, Basin Heater Operating Schedule, Number of Cells, Cell Control, Cell Minimum and Maximum Water Flow Rate Fractions and Sizing Factor. A performance curve relating fan power to tower airflow rates is used. The curve assumes the fan power ratio is directly proportional to the air flow rate ratio cubed. A Minimum Air Flow Rate Ratio of 20% will be set. To model minimal but realistic water consumption, the Evaporation Loss Mode for new Tower objects will be set to ?Saturated Exit? and Drift Loss Percent will be set to a value of 0.05% of the Design Water Flow. Blowdown water usage will be based on maintaining a Concentration Ratio of 3.0.'\n end",
"def modeler_description\n return 'Replaces exterior window constructions with a different construction from the model.'\n end",
"def modeler_description\n return \"This measure will demonstrate how EMS functions can be used to demonstrate how information from a sizing run can be used to select HVAC equipment from nominal product sizes where unit total capacity is directly related to the unit supply airflow (1 ton = 1200 cfm, 1.5 ton = 1600 cfm, etc.) of commercial packaged single-zone HVAC air systems. This measure is designed to work on AirLoops with packaged DX cooling equipment only. EMS functions will be used to extract the design supply airflow generated from system auto-sizing calculations. An interval variable is used to override the Sizing:System - 'Intermediate Air System Main Supply Volume Flow Rate' value variable. This measure approximates the manner that appropriate ‘real world’ equipment selections are made by HVAC design engineers. The table below will be used to map to the Maximum Flow rate of the packaged unit Fan:ConstantVolume object.\"\n end",
"def modeler_description\n return \"This measure will demonstrate how an OpenStudio measure calling EMS functions can be used to investigate dynamic envelope technologies such as emulating thermochromic window performance using EMS actuators and control types. This measure will replace the construction description of a user-selected window based on the outside surface temperature of that window, evaluated at each timestep\"\n end",
"def modeler_description\n return \"This measure adds active or passive chilled beam units to selected conditioned thermal zones. In addition the user can select an existing air loop to serve active beams, or create a new Dual Wheel DOAS. Users can also select an existing chilled water loop to provide chilled water to beams, or create a new high temperature chiller water loop. Users are highly encouraged to review and modify the control strategies that this measure creates, such that it reflects their modeling scenario of interest.\"\n end",
"def modeler_description\n return \"The difference between actual spaces and effective spaces takes into account the zone multipliers. The goal was to get average floor area assuming that each space represents a room vs. a collection of rooms. This was used to help determine average space sizes of different space types from the prototype buildings. In some cases I had to manaually adjust for where a space didn't map to a single room.\"\n end",
"def modeler_description\n return \"Any heating components or baseboard convective electrics/waters are removed from any existing air/plant loops or zones. A boiler along with constant speed pump and water baseboard coils are added to a hot water plant loop.\"\n end",
"def modeler_description\n return 'Thermal zones will be named after the spac with a prefix added'\n end",
"def inspect\n \"#<#{self.class.name} @model=#{model.name} @relation_name=#{relation_name} @repository=#{self.class.repository}>\"\n end",
"def inspect\n \"#<#{self.class.name} @model=#{model.inspect} @name=#{name.inspect}>\"\n end",
"def modeler_description\n return \"Reduces runtime fraction of lights by user-specified amount during the user-specified time period (typically daytime). This is an attempt to represent the impact of using the light collected on the roof instead of electric lighting. This modeling approach does not capture the impact of using a PV cell to turn the IR spectrum of the captured light into electricity.\"\n end",
"def modeler_description\n return 'This measure receives the AntiSweat heater Control from the user. Then it looks for refrigerated display cases; it loops through them; it checks the current AntiSweat heater Control of each case and it substitute it with the one chosen by the user.'\n end"
] | [
"0.7709673",
"0.76146215",
"0.7592412",
"0.7400973",
"0.7300466",
"0.7296075",
"0.72779685",
"0.7191089",
"0.71907765",
"0.71907765",
"0.70995873",
"0.7096783",
"0.70615566",
"0.70446914",
"0.704276",
"0.703993",
"0.7039482",
"0.70320314",
"0.7025324",
"0.701749",
"0.6986445",
"0.69803697",
"0.6949222",
"0.6940995",
"0.6934812",
"0.6925535",
"0.69074965",
"0.69023925",
"0.68917644",
"0.68865687",
"0.68656737",
"0.6864188",
"0.6863416",
"0.6858981",
"0.68510884",
"0.68510884",
"0.68510884",
"0.68510884",
"0.68510884",
"0.68510884",
"0.68510884",
"0.6832552",
"0.68219984",
"0.6805446",
"0.67905384",
"0.6778137",
"0.6773745",
"0.6750508",
"0.67235285",
"0.67211616",
"0.67162704",
"0.6707325",
"0.6702014",
"0.66888964",
"0.6687862",
"0.6671337",
"0.66621333",
"0.66491747",
"0.6642197",
"0.66338223",
"0.66330975",
"0.6621917",
"0.66147953",
"0.66147953",
"0.6609761",
"0.6599433",
"0.6587422",
"0.65864825",
"0.6586354",
"0.6583401",
"0.65633404",
"0.656008",
"0.65535855",
"0.65081",
"0.6490184",
"0.64754266",
"0.64661354",
"0.64622164",
"0.6449103",
"0.6443614",
"0.64387435",
"0.6432299",
"0.6430998",
"0.6425782",
"0.64204913",
"0.64201814",
"0.6417468",
"0.64152914",
"0.6408292",
"0.6406628",
"0.6406086",
"0.6404992",
"0.6399474",
"0.6368489"
] | 0.678705 | 51 |
define the arguments that the user will input | def arguments
args = OpenStudio::Measure::OSArgumentVector.new
# this measure does not require any user arguments, return an empty list
return args
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arguments; end",
"def arguments; end",
"def arguments; end",
"def arguments\n \"\"\n end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def get_input \n puts \"to save this game, input 's,filename'\"\n puts \"to load a game, input 'l,filename'\"\n puts \"input a coordinate to access. prefix with r for reveal or f for flag\"\n puts \"example 'f,1,2' places a flag at 1,2\"\n input = gets.chomp\n \n args = input.split(',')\n end",
"def args(*) end",
"def arguments(required, *optional)\n puts \"required: #{required}\"\n puts \"optional: #{optional}\"\nend",
"def args()\n #This is a stub, used for indexing\n end",
"def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n #make an argument for the variable name\n variable_name = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"variable_name\",true)\n variable_name.setDisplayName(\"Enter Variable Name.\")\n variable_name.setDescription(\"Valid values can be found in the eplusout.rdd file after a simulation is run.\")\n args << variable_name\n \n #make an argument for the electric tariff\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << \"Detailed\"\n reporting_frequency_chs << \"Timestep\"\n reporting_frequency_chs << \"Zone Timestep\"\n reporting_frequency_chs << \"Hourly\"\n reporting_frequency_chs << \"Daily\"\n reporting_frequency_chs << \"Monthly\"\n reporting_frequency_chs << \"Runperiod\"\n reporting_frequency = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName(\"Reporting Frequency.\")\n reporting_frequency.setDefaultValue(\"Hourly\")\n args << reporting_frequency\n\n #make an argument for the key_value\n key_value = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"key_value\",true)\n key_value.setDisplayName(\"Enter Key Name.\")\n key_value.setDescription(\"Enter * for all objects or the full name of a specific object to.\")\n key_value.setDefaultValue(\"*\")\n args << key_value\n \n env = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"env\", true)\n env.setDisplayName(\"availableEnvPeriods\")\n env.setDescription(\"availableEnvPeriods\")\n env.setDefaultValue(\"RUN PERIOD 1\")\n args << env\n \n return args\n end",
"def set_arguments (args)\n end",
"def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # make an argument for the variable name\n variable_name = OpenStudio::Measure::OSArgument.makeStringArgument('variable_name', true)\n variable_name.setDisplayName('Enter Variable Name.')\n variable_name.setDescription('Valid values can be found in the eplusout.rdd file after a simulation is run.')\n args << variable_name\n\n # make an argument for the electric tariff\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << 'Detailed'\n reporting_frequency_chs << 'Timestep'\n reporting_frequency_chs << 'Zone Timestep'\n reporting_frequency_chs << 'Hourly'\n reporting_frequency_chs << 'Daily'\n reporting_frequency_chs << 'Monthly'\n reporting_frequency_chs << 'Runperiod'\n reporting_frequency = OpenStudio::Measure::OSArgument.makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName('Reporting Frequency.')\n reporting_frequency.setDefaultValue('Hourly')\n args << reporting_frequency\n\n # make an argument for the key_value\n key_value = OpenStudio::Measure::OSArgument.makeStringArgument('key_value', true)\n key_value.setDisplayName('Enter Key Name.')\n key_value.setDescription('Enter * for all objects or the full name of a specific object to.')\n key_value.setDefaultValue('*')\n args << key_value\n\n env = OpenStudio::Measure::OSArgument.makeStringArgument('env', true)\n env.setDisplayName('availableEnvPeriods')\n env.setDescription('availableEnvPeriods')\n env.setDefaultValue('RUN PERIOD 1')\n args << env\n\n args\n end",
"def handle_arguments(args)\n if input_file.nil?\n print_usage\n true\n else\n args.help || args.version\n end\n end",
"def arguments=(_arg0); end",
"def command_line\r\n ARGV.each do |arg|\r\n if arg == \"instructions\"\r\n instructions\r\n elsif arg == \"calculator\"\r\n ask_for_digits\r\n else\r\n \r\n end\r\n end\r\n \r\n end",
"def prescreen_input(args)\n if ((args.nil?) || (args.empty?))\n ['-eq', Date.today.strftime('%Y-%m-%d')]\n elsif ((args.length == 1) && (args[0].is_date?))\n ['-eq', args[0]]\n else\n args\n end\nend",
"def varios_args(*args)\n puts \"Tamanho de args: #{args.size}\"\n args.each { |x| p x}\n end",
"def process_arguments\n @e_addr = @options.email\n @r_name = @options.run_names\n @m_name = @options.machine_names\n @action = @options.action\n @snfs = @options.snfs\n end",
"def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # url of the city database\n city_db_url = OpenStudio::Measure::OSArgument.makeStringArgument('city_db_url', true)\n city_db_url.setDisplayName('City Database Url')\n city_db_url.setDescription('Url of the City Database')\n city_db_url.setDefaultValue('')\n args << city_db_url\n\n # project id to update\n project_id = OpenStudio::Measure::OSArgument.makeStringArgument('project_id', true)\n project_id.setDisplayName('Project ID')\n project_id.setDescription('Project ID to generate reports for.')\n project_id.setDefaultValue('0')\n args << project_id\n\n # datapoint id to update\n datapoint_id = OpenStudio::Measure::OSArgument.makeStringArgument('datapoint_id', true)\n datapoint_id.setDisplayName('Datapoint ID')\n datapoint_id.setDescription('Datapoint ID to generate reports for.')\n datapoint_id.setDefaultValue('0')\n args << datapoint_id\n\n return args\n end",
"def validate_args (args)\n\t# todo\nend",
"def args() return @args end",
"def input=(_arg0); end",
"def process_inputs(args)\n @input = ((name = args[:in_file]) && (IO.read(name, mode: \"rb\"))) ||\n args[:in_str] ||\n fail(\"An input must be specified.\")\n\n @generator = args[:generator] ||\n ((key = args[:key]) && Generator.new(key)) ||\n fail(\"A key or generator must be specified.\")\n\n @window = args[:window] || 16\n\n #The filler value is for testing purposes only. It should\n #not be specified when secure operation is desired.\n @fill_value = args[:filler]\n end",
"def parse_args\r\n if(cmd.args =~ /\\=/)\r\n self.names = InputFormatter.titlecase_arg(cmd.args.before(\"=\"))\r\n self.action_args = cmd.args.after(\"=\")\r\n elseif (cmd.args && one_word_command)\r\n self.names = InputFormatter.titlecase_arg(cmd.args)\r\n self.action_args = \"\"\r\n else\r\n self.names = enactor.name\r\n self.action_args = cmd.args\r\n end\r\n\r\n self.names = self.names ? self.names.split(/[ ,]/) : nil\r\n\r\n self.combat_command = cmd.switch ? cmd.switch.downcase : nil\r\n end",
"def manage_args(*args)\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make an argument for your name\n user_name = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"user_name\",true)\n user_name.setDisplayName(\"What is your name?\")\n args << user_name\n\n #make an argument to add new space true/false\n add_space = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"add_space\",true)\n add_space.setDisplayName(\"Add a space to your model?\")\n add_space.setDefaultValue(true)\n args << add_space\n \n return args\n end",
"def greeting\n puts \"Hello, MTA rider! How can we help?\"\n puts \"please enter one of the following commands:\"\n puts \"lines / stops the_line / calculate Departing_Line Departing_Stop Arriving_Line Arriving_Stop\"\n user_call, *user_args = gets.chomp\n user_args.to_s\n # user_args.split(\" \")\n # puts user_input\n\n if user_call == lines\n show_lines()\n elsif user_call == stops\n show_stops(user_args[0])\n elsif user_call == calculate\n if user_args.length < 4\n puts 'please enter \"Departing_Line Departing_Stop Arriving_Line Arriving_Stop\"'\n puts 'or enter \"exit\" to return to the home screen' \n user_input = gets.chomp\n if user_input == \"exit\"\n greeting()\n end \n user_input = user_input.split(\" \")\n calculate(user_input[0], user_input[1], user_input[2], user_input[3])\n else\n calculate(user_args[0], user_args[1], user_args[2], user_args[3])\n end\n else\n \n end\nend",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n\n\n # Make an argument for evap effectiveness\n input_csv_path = OpenStudio::Measure::OSArgument::makeStringArgument(\"input_csv_folder_path\",true)\n input_csv_path.setDisplayName(\"raw_data_input_folder_path\")\n input_csv_path.setDefaultValue(\"data_file\")\n args << input_csv_path\n\n test_numbers = OpenStudio::StringVector.new\n test_numbers << 'Test_3'\n test_numbers << 'Test_6'\n test_numbers << 'Test_8'\n \n test_names = OpenStudio::StringVector.new\n test_names << 'UA_test'\n test_names << 'Cooling_test'\n test_names << 'Plenum_test'\n\n test_selections = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('test_data',test_numbers,test_names,true)\n\n \n test_selections.setDisplayName(\"Experiment\")\n test_selections.setDefaultValue(\"Test_3\")\n args << test_selections\n\n \n return args\n end",
"def arguments\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # URL of the DEnCity server that will be posted to\n hostname = OpenStudio::Ruleset::OSArgument::makeStringArgument('hostname', true)\n hostname.setDisplayName('URL of the DEnCity Server')\n hostname.setDefaultValue('http://www.dencity.org')\n args << hostname\n\n # DEnCity server user id at hostname\n user_id = OpenStudio::Ruleset::OSArgument::makeStringArgument('user_id',true)\n user_id.setDisplayName('User ID for DEnCity Server')\n args << user_id\n\n # DEnCIty server user id's password\n auth_code = OpenStudio::Ruleset::OSArgument::makeStringArgument('auth_code', true)\n auth_code.setDisplayName('Authentication code for User ID on DEnCity server')\n args << auth_code\n\n # Building type for DEnCity's metadata\n building_type = OpenStudio::Ruleset::OSArgument::makeStringArgument('building_type', false)\n building_type.setDisplayName('Building type')\n args << building_type\n\n # HVAC system for DEnCity's metadata\n primary_hvac = OpenStudio::Ruleset::OSArgument::makeStringArgument('primary_hvac', false)\n primary_hvac.setDisplayName('Primary HVAC system in building')\n args << primary_hvac\n\n args\n\n end",
"def arguments\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n #make choice argument for facade\r\n choices = OpenStudio::StringVector.new\r\n choices << \"MessagePack\"\r\n choices << \"CSV\"\r\n choices << \"Both\"\r\n output_format = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"output_format\", choices)\r\n output_format.setDisplayName(\"Output Format\")\r\n output_format.setDefaultValue(\"Both\")\r\n args << output_format\r\n\r\n args\r\n end",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\t\n #make an argument for entering furnace installed afue\n afue = OpenStudio::Measure::OSArgument::makeDoubleArgument(\"afue\",true)\n afue.setDisplayName(\"Installed AFUE\")\n afue.setUnits(\"Btu/Btu\")\n afue.setDescription(\"The installed Annual Fuel Utilization Efficiency (AFUE) of the furnace, which can be used to account for performance derating or degradation relative to the rated value.\")\n afue.setDefaultValue(1.0)\n args << afue\n\n #make an argument for entering furnace installed supply fan power\n fanpower = OpenStudio::Measure::OSArgument::makeDoubleArgument(\"fan_power_installed\",true)\n fanpower.setDisplayName(\"Installed Supply Fan Power\")\n fanpower.setUnits(\"W/cfm\")\n fanpower.setDescription(\"Fan power (in W) per delivered airflow rate (in cfm) of the indoor fan for the maximum fan speed under actual operating conditions.\")\n fanpower.setDefaultValue(0.5)\n args << fanpower\t\n\t\n #make a string argument for furnace heating output capacity\n furnacecap = OpenStudio::Measure::OSArgument::makeStringArgument(\"capacity\", true)\n furnacecap.setDisplayName(\"Heating Capacity\")\n furnacecap.setDescription(\"The output heating capacity of the furnace. If using '#{Constants.SizingAuto}', the autosizing algorithm will use ACCA Manual S to set the capacity.\")\n furnacecap.setUnits(\"kBtu/hr\")\n furnacecap.setDefaultValue(Constants.SizingAuto)\n args << furnacecap\n \n return args\n end",
"def greeting(args)\r\n greet = args[:greet] || \"Hi\"\r\n title = args[:title] || \"Citizen\"\r\n name = args[:name] \r\n puts \"#{greet} #{title} #{name}\"\r\nend",
"def parse_args\n\t\t@args = @args_a.each_slice(2).to_a.inject({}) { |h, k| h[k[0]] = k[1]; h }\n\t\tkeys = @skeys + @lkeys\n\t\t@args.each do |k, v|\n\t\t\tif !keys.include?(k)\n\t\t\t\tputs \"Unknown option `#{k}'\"\n\t\t\t\texit\n\t\t\tend\n\n\t\t\tif keys.include?(v)\n\t\t\t\tputs \"Missing values for `#{k}' and `#{v}'\"\n\t\t\t\texit\n\t\t\tend\n\n\t\t\tif v != nil\n\t\t\t\tif v.start_with?('-')\n\t\t\t\t\tputs \"Warning: Value of `#{k}' appears to be a flag\"\n\t\t\t\tend\n\n\t\t\t\tif @static.has_key?(k)\n\t\t\t\t\tif !@static[k].include?(v)\n\t\t\t\t\t\tputs \"Unknown option `#{v}' for `#{k}'\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t\n\t\tif remove_keys(@no_vals).has_blank?\n\t\t\tputs \"Missing argument(s)\"\n\t\t\texit\n\t\tend\t\t\t\n\tend",
"def command_line_arguments(array)\n array.size.times do\n if array.include?('-nc')\n colour_changer(:white)\n array.delete('-nc')\n elsif array.any? { |x| ['-d1', '-d2', '-d3', '-d4'].include? x }\n key = (array[0])[1, 2].to_sym\n @difficulty = DIFFICULTY[key]\n @promptarr = prompt_select(key)\n @intro = false\n end\n end\n end",
"def arguments()\n args = OpenStudio::Measure::OSArgumentVector.new\n \n #make an argument for the frequency\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << \"Detailed\"\n reporting_frequency_chs << \"Timestep\"\n reporting_frequency_chs << \"Hourly\"\n reporting_frequency_chs << \"Daily\"\n reporting_frequency_chs << \"Monthly\"\n reporting_frequency_chs << \"Runperiod\"\n reporting_frequency = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName(\"Reporting Frequency\")\n reporting_frequency.setDefaultValue(\"Hourly\")\n args << reporting_frequency\n \n # TODO: argument for subset of output meters\n \n return args\n end",
"def arguments()\n args = OpenStudio::Measure::OSArgumentVector.new\n\n #make an argument for the frequency\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << \"Timestep\"\n reporting_frequency_chs << \"Hourly\"\n reporting_frequency_chs << \"Daily\"\n reporting_frequency_chs << \"Monthly\"\n reporting_frequency_chs << \"RunPeriod\"\n arg = OpenStudio::Measure::OSArgument::makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n arg.setDisplayName(\"Reporting Frequency\")\n arg.setDefaultValue(\"Hourly\")\n args << arg\n\n #make an argument for including optional output variables\n arg = OpenStudio::Measure::OSArgument::makeBoolArgument(\"inc_output_variables\", true)\n arg.setDisplayName(\"Include Output Variables\")\n arg.setDefaultValue(false)\n args << arg\n\n return args\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n #make an argument for entering furnace installed afue\n userdefined_eff = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"userdefinedeff\",true)\n userdefined_eff.setDisplayName(\"Efficiency\")\n\tuserdefined_eff.setUnits(\"Btu/Btu\")\n\tuserdefined_eff.setDescription(\"The efficiency of the electric baseboard.\")\n userdefined_eff.setDefaultValue(1.0)\n args << userdefined_eff\n\n #make a choice argument for furnace heating output capacity\n cap_display_names = OpenStudio::StringVector.new\n cap_display_names << Constants.SizingAuto\n (5..150).step(5) do |kbtu|\n cap_display_names << \"#{kbtu} kBtu/hr\"\n end\n\n #make a string argument for furnace heating output capacity\n selected_baseboardcap = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"selectedbaseboardcap\", cap_display_names, true)\n selected_baseboardcap.setDisplayName(\"Heating Output Capacity\")\n selected_baseboardcap.setDefaultValue(Constants.SizingAuto)\n args << selected_baseboardcap\n\t\n return args\n end",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n #make an argument for entering baseboard efficiency\n baseboardeff = OpenStudio::Measure::OSArgument::makeDoubleArgument(\"efficiency\",true)\n baseboardeff.setDisplayName(\"Efficiency\")\n baseboardeff.setUnits(\"Btu/Btu\")\n baseboardeff.setDescription(\"The efficiency of the electric baseboard.\")\n baseboardeff.setDefaultValue(1.0)\n args << baseboardeff\n\n #make a string argument for baseboard heating output capacity\n baseboardcap = OpenStudio::Measure::OSArgument::makeStringArgument(\"capacity\", true)\n baseboardcap.setDisplayName(\"Heating Capacity\")\n baseboardcap.setDescription(\"The output heating capacity of the electric baseboard. If using '#{Constants.SizingAuto}', the autosizing algorithm will use ACCA Manual S to set the capacity.\")\n baseboardcap.setUnits(\"kBtu/hr\")\n baseboardcap.setDefaultValue(Constants.SizingAuto)\n args << baseboardcap\n\t\n return args\n end",
"def user_input_command_line_menu\n\tcommand_line_input = gets.strip.to_i\n\tcommand_line_input_logic(command_line_input)\nend",
"def cmdarg; end",
"def cmdarg; end",
"def cmdarg; end",
"def check_inputs_g(args)\n raise TypeError, Ajaila::Messager.warning(\"Nothing to generate...\") if args == []\n raise TypeError, Ajaila::Messager.warning(\"Only miners, selectors, presenters supported\\n(ex. miner SomeMiner, selector SomeSelector,\\n presenter SomePresenter, table SomeTable)\") if KNOWN_INSTANCES.include?(args[0]) == false\n raise TypeError, Ajaila::Messager.warning(\"Your #{args[0]} needs a name!\") if args[1] == nil\n raise TypeError, Ajaila::Messager.warning(\"Wrong format of the #{args[0]} name (use only A-Z and a-z symbols)\") if args[1][/^[A-Z]+$/i] == nil\n return 0\n end",
"def arguments\n parser.arguments\n end",
"def valid_args(type)\n case type\n when 'search' then %i[q format addressdetails extratags namedetails viewbox bounded exclude_place_ids limit accept-language email]\n when 'reverse' then %i[format lat lon zoom addressdetails extratags namedetails accept-language email]\n else []\n end\n end",
"def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n id = OpenStudio::Measure::OSArgument.makeStringArgument('feature_id', false)\n id.setDisplayName('Feature unique identifier')\n id.setDefaultValue('1')\n args << id\n\n name = OpenStudio::Measure::OSArgument.makeStringArgument('feature_name', false)\n name.setDisplayName('Feature scenario specific name')\n name.setDefaultValue('name')\n args << name\n\n feature_type = OpenStudio::Measure::OSArgument.makeStringArgument('feature_type', false)\n feature_type.setDisplayName('URBANopt Feature Type')\n feature_type.setDefaultValue('Building')\n args << feature_type\n\n feature_location = OpenStudio::Measure::OSArgument.makeStringArgument('feature_location', false)\n feature_location.setDisplayName('URBANopt Feature Location')\n feature_location.setDefaultValue('0')\n args << feature_location\n\n # make an argument for the frequency\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << 'Detailed'\n reporting_frequency_chs << 'Timestep'\n reporting_frequency_chs << 'Hourly'\n reporting_frequency_chs << 'Daily'\n # reporting_frequency_chs << 'Zone Timestep'\n reporting_frequency_chs << 'BillingPeriod' # match it to utility bill object\n ## Utility report here to report the start and end for each fueltype\n reporting_frequency_chs << 'Monthly'\n reporting_frequency_chs << 'Runperiod'\n\n reporting_frequency = OpenStudio::Measure::OSArgument.makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName('Reporting Frequency')\n reporting_frequency.setDescription('The frequency at which to report timeseries output data.')\n reporting_frequency.setDefaultValue('Timestep')\n args << reporting_frequency\n\n return args\n end",
"def madlib_inputs\n print \"Enter a noun: \" \n noun = gets.chomp\n print \"Enter a verb: \" \n verb = gets.chomp\n print \"Enter an adjective: \" \n adjective = gets.chomp\n print \"Enter an adverb: \" \n adverb = gets.chomp\n madlib_line(noun, verb, adjective, adverb)\nend",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make a start date argument\n start_date = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"start_date\",true)\n start_date.setDisplayName(\"Start date\")\n args << start_date\n \n #make an end date argument\n end_date = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"end_date\",true)\n end_date.setDisplayName(\"End date\")\n args << end_date\n \n return args\n end",
"def check_arguments\n convert_boolean_strings\n check_output\n check_log_level\n check_input_entry\n check_input_types\n end",
"def process_arguments\n # clean unsupport symbols, e.g. JieFang;\n # or error argument due to option typo, e.g. '-list' will put 'ist' into the array in this src.\n @support_newspapers = Array.new #TODO: move to elsewhere\n @support_newspapers << :XM\n @support_newspapers << :WHB\n @support_newspapers << :YZ\n # ATTENTION: command line input is an array of string, to be consistent, internally I use only symbol when using this symbol\n @options.newspapers = @options.newspapers.collect { | item | item.to_sym } & @support_newspapers\n \n if @options.newspapers.size == 0\n @support_newspapers.each do | sym |\n @options.newspapers << sym\n end\n end\n end",
"def args\n raw_args\n end",
"def argv; end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make an argument for your name\n code_choices = OpenStudio::StringVector.new \n code_choices << \"ASHRAE 90.1-2007\" \n code_choices << \"ASHRAE 90.1-2010\" \n energy_code = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('energy_code', code_choices, true)\n energy_code.setDisplayName(\"Code baseline\")\n energy_code.setDefaultValue(\"ASHRAE 90.1-2010\")\n args << energy_code\n \n #make an argument to add new space true/false\n leed_check = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"leed_check\",true)\n leed_check.setDisplayName(\"Perform typical LEED checks?\")\n leed_check.setDefaultValue(true)\n args << leed_check\n \n return args\n end",
"def arguments(model)\n #list of arguments as they will appear in the interface. They are available in the run command as\n @argument_array_of_arrays = [\n [ \"variable_name\", \"type\", \"required\", \"model_dependant\", \"display_name\", \"default_value\", \"min_value\", \"max_value\", \"string_choice_array\", \t\"os_object_type\"\t],\n [ \"weather_file_name\", \"STRING\", true, false, \"Weather File Name\", nil, nil, nil, nil, \t nil\t\t\t\t\t],\n #Default set for server weather folder.\n [ \"weather_directory\", \"STRING\", true, false, \"Weather Directory\", \"../../weather\", nil, nil, nil,\t nil\t\t\t\t\t]\n \n ]\n #set up arguments. \n args = OpenStudio::Ruleset::OSArgumentVector.new\n self.argument_setter(args)\n return args\n end",
"def inflamed _args\n \"inflamed _args;\" \n end",
"def more_options\n puts Rainbow(\"Specify your additional options for your search: 'release date', 'search history', or go back\").yellow.underline\n input = gets.chomp.downcase\n \n if input == \"release date\"\n option_release_date\n \n elsif input == \"search history\"\n game_history\n\n elsif input == \"go back\"\n continue_or_exit\n \n else \n puts \"Input not recognized please try again\"\n more_options\n end\n end",
"def cmd(options={})\n arguments\n end",
"def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # this measure will require arguments, but at this time, they are not known\n geometry_profile = OpenStudio::Ruleset::OSArgument::makeStringArgument('geometry_profile', true)\n geometry_profile.setDefaultValue(\"{}\")\n os_model = OpenStudio::Ruleset::OSArgument::makeStringArgument('os_model', true)\n os_model.setDefaultValue('multi-model mode')\n user_id = OpenStudio::Ruleset::OSArgument::makeStringArgument('user_id', true)\n user_id.setDefaultValue(\"00000000-0000-0000-0000-000000000000\")\n job_id = OpenStudio::Ruleset::OSArgument::makeStringArgument('job_id', true)\n #job_id.setDefaultValue(SecureRandom.uuid.to_s)\n ashrae_climate_zone = OpenStudio::Ruleset::OSArgument::makeStringArgument('ashrae_climate_zone', false)\n ashrae_climate_zone.setDefaultValue(\"-1\")\n building_type = OpenStudio::Ruleset::OSArgument::makeStringArgument('building_type', false)\n building_type.setDefaultValue(\"BadDefaultType\")\n\n args << geometry_profile\n args << os_model\n args << user_id\n args << job_id\n args << ashrae_climate_zone\n args << building_type\n\n return args\n end",
"def user_input\n\tgets\nend",
"def input\n @input ||= args.dig(:input)\n end",
"def parse_args\n require 'optimist'\n opts = Optimist.options do\n opt :source, \"Inventory Source UID\", :type => :string, :required => ENV[\"SOURCE_UID\"].nil?, :default => ENV[\"SOURCE_UID\"]\n opt :ingress_api, \"Hostname of the ingress-api route\", :type => :string, :default => ENV[\"INGRESS_API\"] || \"http://localhost:9292\"\n opt :config, \"Configuration file name\", :type => :string, :default => ENV[\"CONFIG\"] || \"default\"\n opt :data, \"Amount & custom values of generated items\", :type => :string, :default => ENV[\"DATA\"] || \"default\"\n end\n\n opts\nend",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # lat arg\n lat = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"lat\", true)\n lat.setDisplayName(\"Latitude\")\n lat.setDefaultValue(39.7392000000)\n args << lat\n\n # long arg\n lon = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"lon\", true)\n lon.setDisplayName(\"Longitude\")\n lon.setDefaultValue(-104.9903000000)\n args << lon\n\n return args\n end",
"def add args\n db = get_db\n if args.empty?\n print \"Enter a short summary: \"\n STDOUT.flush\n text = gets.chomp\n if text.empty?\n exit ERRCODE\n end\n else\n # if you add last arg as P1..P5, I'll update priority automatically\n if args.last =~ /P[1-5]/\n $default_priority = args.pop\n end\n text = args.join \" \"\n end\n # convert actual newline to C-a. slash n's are escapes so echo -e does not muck up.\n #atitle=$( echo \"$atitle\" | tr -cd '\\40-\\176' )\n text.tr! \"\\n\", '\u0001'\n title = text\n desc = nil\n if $prompt_desc\n # choice of vim or this XXX also how to store in case of error or abandon\n # and allow user to edit, so no retyping. This could be for mult fields\n message \"Enter a detailed description (. to exit): \"\n desc = Cmdapp.get_lines\n #message \"You entered #{desc}\"\n end\n type = $default_type || \"bug\"\n severity = $default_severity || \"normal\"\n status = $default_status || \"open\"\n priority = $default_priority || \"P3\"\n if $prompt_type\n type = Cmdapp._choice(\"Select type:\", %w[bug enhancement feature task] )\n #message \"You selected #{type}\"\n end\n if $prompt_priority\n #priority = Cmdapp._choice(\"Select priority:\", %w[normal critical moderate] )\n priority = ask_priority\n #message \"You selected #{severity}\"\n end\n if $prompt_severity\n severity = Cmdapp._choice(\"Select severity:\", %w[normal critical moderate] )\n #message \"You selected #{severity}\"\n end\n if $prompt_status\n status = Cmdapp._choice(\"Select status:\", %w[open started closed stopped canceled] )\n #message \"You selected #{status}\"\n end\n assigned_to = $default_assigned_to\n if $prompt_assigned_to\n message \"Assign to:\"\n #assigned_to = $stdin.gets.chomp\n assigned_to = Cmdapp._gets \"assigned_to\", \"assigned_to\", $default_assigned_to\n #message \"You selected #{assigned_to}\"\n end\n project = component = version = nil\n # project\n if $use_project\n project = Cmdapp.user_input('project', $prompt_project, nil, $valid_project, $default_project)\n end\n if $use_component\n component = Cmdapp.user_input('component', $prompt_component, nil, $valid_component, $default_component)\n end\n if $use_version\n version = Cmdapp.user_input('version', $prompt_version, nil, $valid_version, $default_version)\n end\n\n start_date = @now\n due_date = default_due_date\n comment_count = 0\n priority ||= \"P3\" \n description = desc\n fix = nil #\"Some long text\" \n #date_created = @now\n #date_modified = @now\n body = {}\n body[\"title\"]=title\n body[\"description\"]=description\n body[\"type\"]=type\n body[\"status\"]=status\n body[\"start_date\"]=start_date.to_s\n body[\"due_date\"]=due_date.to_s\n body[\"priority\"]=priority\n body[\"severity\"]=severity\n body[\"assigned_to\"]=assigned_to\n body[\"created_by\"] = $default_user\n # only insert if its wanted by user\n body[\"project\"]=project if $use_project\n body[\"component\"]=component if $use_component\n body[\"version\"]=version if $use_version\n\n rowid = db.table_insert_hash(\"bugs\", body)\n puts \"Issue #{rowid} created\"\n logid = db.sql_logs_insert rowid, \"create\", \"#{rowid} #{type}: #{title}\"\n body[\"id\"] = rowid\n mail_issue nil, body\n \n 0\n end",
"def arguments(model)\n #list of arguments as they will appear in the interface. They are available in the run command as\n @argument_array_of_arrays = [\n [ \"variable_name\", \"type\", \"required\", \"model_dependant\", \"display_name\", \"default_value\", \"min_value\", \"max_value\", \"string_choice_array\", \"os_object_type\"\t ],\n [ \"alternativeModel\", \"STRING\", true, false, \"Alternative Model\", 'FullServiceRestaurant.osm', nil, nil, nil, \t nil\t\t\t\t\t],\n [ \"osm_directory\", \"STRING\", true, false, \"OSM Directory\", \"../../lib/btap/resources/models/smart_archetypes\", nil, nil, nil,\t nil\t\t\t\t\t] \n ]\n #set up arguments. \n args = OpenStudio::Ruleset::OSArgumentVector.new\n self.argument_setter(args)\n return args\n end",
"def arguments(model)\n #list of arguments as they will appear in the interface. They are available in the run command as\n @argument_array_of_arrays = [\n [ \"variable_name\", \"type\", \"required\", \"model_dependant\", \"display_name\", \"default_value\", \"min_value\", \"max_value\", \"string_choice_array\", \"os_object_type\"\t ],\n [ \"alternativeModel\", \"STRING\", true, false, \"Alternative Model\", 'FullServiceRestaurant.osm', nil, nil, nil, \t nil\t\t\t\t\t],\n [ \"osm_directory\", \"STRING\", true, false, \"OSM Directory\", \"../../lib/btap/resources/models/smart_archetypes\", nil, nil, nil,\t nil\t\t\t\t\t] \n ]\n #set up arguments. \n args = OpenStudio::Ruleset::OSArgumentVector.new\n self.argument_setter(args)\n return args\n end",
"def arguments()\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n # the name of the sql file\r\n csv_name = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_name\", true)\r\n csv_name.setDisplayName(\"CSV file name\")\r\n csv_name.setDescription(\"CSV file name.\")\r\n csv_name.setDefaultValue(\"mtr.csv\")\r\n args << csv_name\r\n \r\n csv_time_header = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_time_header\", true)\r\n csv_time_header.setDisplayName(\"CSV Time Header\")\r\n csv_time_header.setDescription(\"CSV Time Header Value.\")\r\n csv_time_header.setDefaultValue(\"Date/Time\")\r\n args << csv_time_header\r\n \r\n csv_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var\", true)\r\n csv_var.setDisplayName(\"CSV variable name\")\r\n csv_var.setDescription(\"CSV variable name\")\r\n csv_var.setDefaultValue(\"Whole Building:Facility Total Electric Demand Power [W](TimeStep)\")\r\n args << csv_var\r\n \r\n csv_var_dn = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var_dn\", true)\r\n csv_var_dn.setDisplayName(\"CSV variable display name\")\r\n csv_var_dn.setDescription(\"CSV variable display name\")\r\n csv_var_dn.setDefaultValue(\"\")\r\n args << csv_var_dn\r\n \r\n years = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"year\", true)\r\n years.setDisplayName(\"Year in csv data\")\r\n years.setDescription(\"Year in csv data => mm:dd:yy or mm:dd\")\r\n years.setDefaultValue(true)\r\n args << years\r\n \r\n seconds = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"seconds\", true)\r\n seconds.setDisplayName(\"Seconds in csv data\")\r\n seconds.setDescription(\"Seconds in csv data => hh:mm:ss or hh:mm\")\r\n seconds.setDefaultValue(true)\r\n args << seconds\r\n \r\n sql_key = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_key\", true)\r\n sql_key.setDisplayName(\"SQL key\")\r\n sql_key.setDescription(\"SQL key\")\r\n sql_key.setDefaultValue(\"Whole Building\")\r\n args << sql_key \r\n\r\n sql_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_var\", true)\r\n sql_var.setDisplayName(\"SQL var\")\r\n sql_var.setDescription(\"SQL var\")\r\n sql_var.setDefaultValue(\"Facility Total Electric Demand Power\")\r\n args << sql_var \r\n \r\n norm = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"norm\", true)\r\n norm.setDisplayName(\"norm of the difference of csv and sql\")\r\n norm.setDescription(\"norm of the difference of csv and sql\")\r\n norm.setDefaultValue(1)\r\n args << norm \r\n\r\n find_avail = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"find_avail\", true)\r\n find_avail.setDisplayName(\"find_avail\")\r\n find_avail.setDescription(\"find_avail\")\r\n find_avail.setDefaultValue(true)\r\n args << find_avail \r\n\r\n compute_diff = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"compute_diff\", true)\r\n compute_diff.setDisplayName(\"compute_diff\")\r\n compute_diff.setDescription(\"compute_diff\")\r\n compute_diff.setDefaultValue(true)\r\n args << compute_diff\r\n \r\n verbose_messages = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"verbose_messages\", true)\r\n verbose_messages.setDisplayName(\"verbose_messages\")\r\n verbose_messages.setDescription(\"verbose_messages\")\r\n verbose_messages.setDefaultValue(true)\r\n args << verbose_messages \r\n\r\n return args\r\n end",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\t\t\n\n #Make a string argument for occupants (auto or number)\n num_occ = OpenStudio::Measure::OSArgument::makeStringArgument(\"num_occ\", false)\n num_occ.setDisplayName(\"Number of Occupants\")\n num_occ.setDescription(\"Specify the number of occupants. For a multifamily building, specify one value for all units or a comma-separated set of values (in the correct order) for each unit. A value of '#{Constants.Auto}' will calculate the average number of occupants from the number of bedrooms. Used to specify the internal gains from people only.\")\n num_occ.setDefaultValue(Constants.Auto)\n args << num_occ\n\n #Make a string argument for 24 weekday schedule values\n weekday_sch = OpenStudio::Measure::OSArgument::makeStringArgument(\"weekday_sch\", true)\n weekday_sch.setDisplayName(\"Weekday schedule\")\n weekday_sch.setDescription(\"Specify the 24-hour weekday schedule.\")\n weekday_sch.setDefaultValue(\"1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 0.88310, 0.40861, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.29498, 0.55310, 0.89693, 0.89693, 0.89693, 1.00000, 1.00000, 1.00000\")\n args << weekday_sch\n \n #Make a string argument for 24 weekend schedule values\n weekend_sch = OpenStudio::Measure::OSArgument::makeStringArgument(\"weekend_sch\", true)\n weekend_sch.setDisplayName(\"Weekend schedule\")\n weekend_sch.setDescription(\"Specify the 24-hour weekend schedule.\")\n weekend_sch.setDefaultValue(\"1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 0.88310, 0.40861, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.29498, 0.55310, 0.89693, 0.89693, 0.89693, 1.00000, 1.00000, 1.00000\")\n args << weekend_sch\n\n #Make a string argument for 12 monthly schedule values\n monthly_sch = OpenStudio::Measure::OSArgument::makeStringArgument(\"monthly_sch\", true)\n monthly_sch.setDisplayName(\"Month schedule\")\n monthly_sch.setDescription(\"Specify the 12-month schedule.\")\n monthly_sch.setDefaultValue(\"1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0\")\n args << monthly_sch\n\n return args\n end",
"def validate_arguments()\n usage unless ARGV.count > 0\nend",
"def input args\n if args.state.inputlist.length > 5\n args.state.inputlist.pop\n end\n\n should_process_special_move = (args.inputs.keyboard.key_down.j) ||\n (args.inputs.keyboard.key_down.k) ||\n (args.inputs.keyboard.key_down.a) ||\n (args.inputs.keyboard.key_down.d) ||\n (args.inputs.controller_one.key_down.y) ||\n (args.inputs.controller_one.key_down.x) ||\n (args.inputs.controller_one.key_down.left) ||\n (args.inputs.controller_one.key_down.right)\n\n if (should_process_special_move)\n if (args.inputs.keyboard.key_down.j && args.inputs.keyboard.key_down.k) ||\n (args.inputs.controller_one.key_down.x && args.inputs.controller_one.key_down.y)\n args.state.inputlist.unshift(\"shield\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) &&\n (args.state.inputlist[0] == \"forward-attack\") && ((args.state.tick_count - args.state.lastpush) <= 15)\n args.state.inputlist.unshift(\"dash-attack\")\n args.state.player.dx = 20\n elsif (args.inputs.keyboard.key_down.j && args.inputs.keyboard.a) ||\n (args.inputs.controller_one.key_down.x && args.inputs.controller_one.key_down.left)\n args.state.inputlist.unshift(\"back-attack\")\n elsif ( args.inputs.controller_one.key_down.x || args.inputs.keyboard.key_down.j)\n args.state.inputlist.unshift(\"forward-attack\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) &&\n (args.state.player.y > 128)\n args.state.inputlist.unshift(\"dair\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y)\n args.state.inputlist.unshift(\"up-attack\")\n elsif (args.inputs.controller_one.key_down.left || args.inputs.keyboard.key_down.a) &&\n (args.state.inputlist[0] == \"<\") &&\n ((args.state.tick_count - args.state.lastpush) <= 10)\n args.state.inputlist.unshift(\"<<\")\n args.state.player.dx = -15\n elsif (args.inputs.controller_one.key_down.left || args.inputs.keyboard.key_down.a)\n args.state.inputlist.unshift(\"<\")\n args.state.timeleft = args.state.tick_count\n elsif (args.inputs.controller_one.key_down.right || args.inputs.keyboard.key_down.d)\n args.state.inputlist.unshift(\">\")\n end\n\n args.state.lastpush = args.state.tick_count\n end\n\n if args.inputs.keyboard.space || args.inputs.controller_one.r2 # if the user presses the space bar\n args.state.player.jumped_at ||= args.state.tick_count # jumped_at is set to current frame\n\n # if the time that has passed since the jump is less than the player's jump duration and\n # the player is not falling\n if args.state.player.jumped_at.elapsed_time < args.state.player_jump_power_duration && !args.state.player.falling\n args.state.player.dy = args.state.player_jump_power # change in y is set to power of player's jump\n end\n end\n\n # if the space bar is in the \"up\" state (or not being pressed down)\n if args.inputs.keyboard.key_up.space || args.inputs.controller_one.key_up.r2\n args.state.player.jumped_at = nil # jumped_at is empty\n args.state.player.falling = true # the player is falling\n end\n\n if args.inputs.left # if left key is pressed\n if args.state.player.dx < -5\n args.state.player.dx = args.state.player.dx\n else\n args.state.player.dx = -5\n end\n\n elsif args.inputs.right # if right key is pressed\n if args.state.player.dx > 5\n args.state.player.dx = args.state.player.dx\n else\n args.state.player.dx = 5\n end\n else\n args.state.player.dx *= args.state.player_speed_slowdown_rate # dx is scaled down\n end\n\n if ((args.state.player.dx).abs > 5) #&& ((args.state.tick_count - args.state.lastpush) <= 10)\n args.state.player.dx *= 0.95\n end\nend",
"def arguments(model = nil)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n chs = OpenStudio::StringVector.new\n chs << 'Last OSM'\n chs << 'Last IDF'\n file_source = OpenStudio::Ruleset::OSArgument.makeChoiceArgument('file_source', chs, true)\n file_source.setDisplayName('Model Source')\n file_source.setDefaultValue('Last OSM')\n args << file_source\n\n chs = OpenStudio::StringVector.new\n chs << 'Timestep'\n chs << 'Hourly'\n reporting_frequency = OpenStudio::Ruleset::OSArgument.makeChoiceArgument('reporting_frequency', chs, true)\n reporting_frequency.setDisplayName('Reporting Frequency')\n reporting_frequency.setDefaultValue('Hourly')\n args << reporting_frequency\n\n variable1_name = OpenStudio::Ruleset::OSArgument.makeStringArgument('variable1_name', true)\n variable1_name.setDisplayName('Variable 1 Name')\n variable1_name.setDefaultValue('Surface Outside Face Temperature')\n args << variable1_name\n\n variable2_name = OpenStudio::Ruleset::OSArgument.makeStringArgument('variable2_name', true)\n variable2_name.setDisplayName('Variable 2 Name')\n variable2_name.setDefaultValue('Surface Inside Face Temperature')\n args << variable2_name\n\n variable3_name = OpenStudio::Ruleset::OSArgument.makeStringArgument('variable3_name', true)\n variable3_name.setDisplayName('Variable 3 Name')\n variable3_name.setDefaultValue('Zone Mean Radiant Temperature')\n args << variable3_name\n\n return args\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # Create a list of the names and handles of space types\n # used in the building.\n used_space_type_handles = OpenStudio::StringVector.new\n used_space_type_names = OpenStudio::StringVector.new\n model.getSpaceTypes.sort.each do |space_type|\n if space_type.spaces.size > 0 # only show space types used in the building\n used_space_type_handles << space_type.handle.to_s\n used_space_type_names << space_type.name.to_s\n end\n end\n\t\n # Make an argument for plenum space type\n ceiling_return_plenum_space_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"ceiling_return_plenum_space_type\", used_space_type_handles, used_space_type_names,false)\n ceiling_return_plenum_space_type.setDisplayName(\"This space type should be part of a ceiling return air plenum.\")\n args << ceiling_return_plenum_space_type\n\t\n # Make a bool argument to edit/not edit each space type\n\t\tmodel.getSpaceTypes.sort.each do |space_type|\n\t\t\tif space_type.spaces.size > 0 # only show space types used in the building\n\t\t\t\tspace_type_to_edit = OpenStudio::Ruleset::OSArgument::makeBoolArgument(space_type.name.get.to_s,false)\n\t\t\t\t# Make a bool argument for this space type\n\t\t\t\tspace_type_to_edit.setDisplayName(\"Add #{space_type.name.get} space type to GSHP system?\")\n\t\t\t\tspace_type_to_edit.setDefaultValue(false)\t\t\n\t\t\t\targs << space_type_to_edit\n\t\t\tend\n\t\tend\n\t \n\t\t# Heating COP of GSHP\n\t\tgshp_htg_cop = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"gshp_htg_cop\",false)\n\t\tgshp_htg_cop.setDisplayName(\"GSHP DX Heating Coil Heating COP\")\n\t\tgshp_htg_cop.setDefaultValue(4.0)\n\t\targs << gshp_htg_cop\n\t\t\n\t\t# Cooling EER of GSHP\n\t\tgshp_clg_eer = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"gshp_clg_eer\",false)\n\t\tgshp_clg_eer.setDisplayName(\"GSHP DX Cooling Coil Cooling EER\")\n\t\tgshp_clg_eer.setDefaultValue(14)\n\t\targs << gshp_clg_eer\n\t\t\n\t\t# GSHP Fan Type PSC or ECM\n\t\tfan_choices = OpenStudio::StringVector.new\n\t\tfan_choices << \"PSC\"\n\t\tfan_choices << \"ECM\"\n\t\tgshp_fan_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"gshp_fan_type\",fan_choices,true) # note ECM fan type may correspond to different set of heat pump performance curves\n\t\tgshp_fan_type.setDisplayName(\"GSHP Fan Type: PSC or ECM?\")\n\t\tgshp_fan_type.setDefaultValue(\"PSC\")\n args << gshp_fan_type\n\t\t\n\t\t# Condenser Loop Cooling Temperature\n\t\t# condLoopCoolingTemp = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"condLoopCoolingTemp\",false)\n\t\t# condLoopCoolingTemp.setDisplayName(\"Condenser Loop Cooling Temperature (F)\")\n\t\t# condLoopCoolingTemp.setDefaultValue(90)\n\t\t# args << condLoopCoolingTemp\n\t\t\n\t\t# Condenser Loop Heating Temperature\n\t\t# condLoopHeatingTemp = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"condLoopHeatingTemp\",false)\n\t\t# condLoopHeatingTemp.setDisplayName(\"Condenser Loop Heating Temperature (F)\")\n\t\t# condLoopHeatingTemp.setDefaultValue(60)\t\n\t\t# args << condLoopHeatingTemp\n\t\t\n\t\t# Vertical Bore HX\n\t\tbuilding_area = model.getBuilding.floorArea \n\t\tbuilding_cool_ton = building_area*10.7639/500\t\t# 500sf/ton estimated\n\t\tbore_hole_no = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"bore_hole_no\",false)\n\t\tbore_hole_no.setDisplayName(\"Number of Bore Holes\")\n\t\tbore_hole_no.setDefaultValue(building_cool_ton.to_i) \n\t\targs << bore_hole_no\n\n\t\t\n\t\tbore_hole_length = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"bore_hole_length\",false)\n\t\tbore_hole_length.setDisplayName(\"Bore Hole Length (ft)\")\n\t\tbore_hole_length.setDefaultValue(200)\n\t\targs << bore_hole_length\n\n\t\tbore_hole_radius = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"bore_hole_radius\",false)\n\t\tbore_hole_radius.setDisplayName(\"Bore Hole Radius (inch)\")\n\t\tbore_hole_radius.setDefaultValue(6.0)\n\t\targs << bore_hole_radius\n\t\t\n\t\tground_k_value = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"ground_k_value\",false)\n\t\tground_k_value.setDisplayName(\"Ground Conductivity (Btu/hr.F.R\")\n\t\tground_k_value.setDefaultValue(0.75)\n\t\targs << ground_k_value\n\t\t\n\t\tgrout_k_value = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"grout_k_value\",false)\n\t\tgrout_k_value.setDisplayName(\"Grout Conductivity (Btu/hr.F.R\")\n\t\tgrout_k_value.setDefaultValue(0.75)\n\t\targs << grout_k_value\n\t\t\n\t\tchs = OpenStudio::StringVector.new\n\t\tchs << \"Yes\"\n\t\tchs << \"No\"\n\t\tsupplemental_boiler = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"supplemental_boiler\",chs, true)\n\t\tsupplemental_boiler.setDisplayName(\"Supplemental Heating Boiler?\")\n\t\tsupplemental_boiler.setDefaultValue(\"No\")\n\t\targs << supplemental_boiler\n\t\t\n\t\t# Boiler Capacity\n\t\tboiler_cap = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"boiler_cap\",false)\n\t\tboiler_cap.setDisplayName(\"boiler normal capacity (MBtuh)\")\n\t\tboiler_cap.setDefaultValue(500.0)\n\t\targs << boiler_cap\n\t\t\t\t\n\t\t# Boiler Efficiency\n\t\tboiler_eff = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"boiler_eff\",false)\n\t\tboiler_eff.setDisplayName(\"Boiler Thermal Efficiency\")\n\t\tboiler_eff.setDefaultValue(0.9)\n\t\targs << boiler_eff\n\t\t\n\t\t# Boiler fuel Type\n\t\tfuel_choices = OpenStudio::StringVector.new\n\t\tfuel_choices << \"NaturalGas\"\n\t\tfuel_choices << \"PropaneGas\"\n\t\tfuel_choices << \"FuelOil#1\"\n\t\tfuel_choices << \"FuelOil#2\"\n\t\tfuel_choices << \"Electricity\"\n\t\tboiler_fuel_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"boiler_fuel_type\",fuel_choices,false) \n\t\tboiler_fuel_type.setDisplayName(\"Boiler Fuel Type\")\n\t\tboiler_fuel_type.setDefaultValue(\"NaturalGas\")\n\t\targs << boiler_fuel_type\n\t\t\n\t\t# boiler Hot water supply temperature\n\t\tboiler_hw_st = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"boiler_hw_st\",false)\n\t\tboiler_hw_st.setDisplayName(\"Boiler Design Heating Water Outlet Temperature (F)\")\n\t\tboiler_hw_st.setDefaultValue(120)\t\n\t\targs << boiler_hw_st\n\t\t\n\t\t# DOAS Fan Type\n\t\tdoas_fan_choices = OpenStudio::StringVector.new\n\t\tdoas_fan_choices << \"Constant\"\n\t\tdoas_fan_choices << \"Variable\"\n\t\tdoas_fan_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"doas_fan_type\",doas_fan_choices,true)\n\t\tdoas_fan_type.setDisplayName(\"DOAS Fan Flow Control - Variable means DCV controls\")\n\t\tdoas_fan_type.setDefaultValue(\"Variable\")\n\t\targs << doas_fan_type\n\t\t\n\t\t# DOAS Energy Recovery\n\t\terv_choices = OpenStudio::StringVector.new\n\t\terv_choices << \"plate w/o economizer lockout\"\n\t\terv_choices << \"plate w/ economizer lockout\"\n\t\terv_choices << \"rotary wheel w/o economizer lockout\"\n\t\terv_choices << \"rotary wheel w/ economizer lockout\"\n\t\terv_choices << \"none\"\n\t\tdoas_erv = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"doas_erv\",erv_choices,true)\n\t\tdoas_erv.setDisplayName(\"DOAS Energy Recovery?\")\n\t\tdoas_erv.setDefaultValue(\"none\")\n\t\targs << doas_erv\n\t\t\n\t\t# DOAS Evaporative Cooling\n\t\tevap_choices = OpenStudio::StringVector.new\n\t\tevap_choices << \"Direct Evaporative Cooler\"\n\t\tevap_choices << \"none\"\n\t\tdoas_evap = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"doas_evap\",evap_choices,true)\n\t\tdoas_evap.setDisplayName(\"DOAS Direct Evaporative Cooling?\")\n\t\tdoas_evap.setDefaultValue(\"none\")\n\t\targs << doas_evap\n\t\t\n\t\t# DOAS DX Cooling\n\t\tdoas_dx_eer = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"doas_dx_eer\",false)\n\t\tdoas_dx_eer.setDisplayName(\"DOAS DX Cooling EER\")\n\t\tdoas_dx_eer.setDefaultValue(10.0)\n\t\targs << doas_dx_eer\n\t\n # make an argument for material and installation cost\n # todo - I would like to split the costing out to the air loops weighted by area of building served vs. just sticking it on the building\n cost_total_hvac_system = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"cost_total_hvac_system\",true)\n cost_total_hvac_system.setDisplayName(\"Total Cost for HVAC System ($).\")\n cost_total_hvac_system.setDefaultValue(0.0)\n args << cost_total_hvac_system\n \n #make an argument to remove existing costs\n remake_schedules = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"remake_schedules\",true)\n remake_schedules.setDisplayName(\"Apply recommended availability and ventilation schedules for air handlers?\")\n remake_schedules.setDefaultValue(true)\n args << remake_schedules\n\n return args\n end",
"def arguments()\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n # the name of the sql file\r\n csv_name = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_name\", true)\r\n csv_name.setDisplayName(\"CSV file name\")\r\n csv_name.setDescription(\"CSV file name.\")\r\n csv_name.setDefaultValue(\"mtr.csv\")\r\n args << csv_name\r\n \r\n csv_time_header = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_time_header\", true)\r\n csv_time_header.setDisplayName(\"CSV Time Header\")\r\n csv_time_header.setDescription(\"CSV Time Header Value.\")\r\n csv_time_header.setDefaultValue(\"Date/Time\")\r\n args << csv_time_header\r\n \r\n csv_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var\", true)\r\n csv_var.setDisplayName(\"CSV variable name\")\r\n csv_var.setDescription(\"CSV variable name\")\r\n csv_var.setDefaultValue(\"Whole Building:Facility Total Electric Demand Power [W](TimeStep)\")\r\n args << csv_var\r\n \r\n csv_var_dn = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var_dn\", true)\r\n csv_var_dn.setDisplayName(\"CSV variable display name\")\r\n csv_var_dn.setDescription(\"CSV variable display name\")\r\n csv_var_dn.setDefaultValue(\"\")\r\n args << csv_var_dn\r\n \r\n years = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"year\", true)\r\n years.setDisplayName(\"Year in csv data\")\r\n years.setDescription(\"Year in csv data => mm:dd:yy or mm:dd\")\r\n years.setDefaultValue(true)\r\n args << years\r\n \r\n seconds = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"seconds\", true)\r\n seconds.setDisplayName(\"Seconds in csv data\")\r\n seconds.setDescription(\"Seconds in csv data => hh:mm:ss or hh:mm\")\r\n seconds.setDefaultValue(true)\r\n args << seconds\r\n \r\n sql_key = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_key\", true)\r\n sql_key.setDisplayName(\"SQL key\")\r\n sql_key.setDescription(\"SQL key\")\r\n sql_key.setDefaultValue(\"\")\r\n args << sql_key \r\n\r\n sql_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_var\", true)\r\n sql_var.setDisplayName(\"SQL var\")\r\n sql_var.setDescription(\"SQL var\")\r\n sql_var.setDefaultValue(\"Facility Total Electric Demand Power\")\r\n args << sql_var \r\n \r\n stp = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"stp\", true)\r\n stp.setDisplayName(\"Timeseries Timestep\")\r\n stp.setDescription(\"Timeseries Timestep\")\r\n stp.setDefaultValue(\"Zone Timestep\")\r\n args << stp\r\n \r\n env = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"env\", true)\r\n env.setDisplayName(\"availableEnvPeriods\")\r\n env.setDescription(\"availableEnvPeriods\")\r\n env.setDefaultValue(\"RUN PERIOD 1\")\r\n args << env\r\n \r\n norm = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"norm\", true)\r\n norm.setDisplayName(\"norm of the difference of csv and sql\")\r\n norm.setDescription(\"norm of the difference of csv and sql\")\r\n norm.setDefaultValue(1)\r\n args << norm \r\n\r\n scale = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"scale\", true)\r\n scale.setDisplayName(\"scale factor to apply to the difference\")\r\n scale.setDescription(\"scale factor to apply to the difference\")\r\n scale.setDefaultValue(1)\r\n args << scale \r\n\r\n find_avail = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"find_avail\", true)\r\n find_avail.setDisplayName(\"find_avail\")\r\n find_avail.setDescription(\"find_avail\")\r\n find_avail.setDefaultValue(true)\r\n args << find_avail \r\n\r\n compute_diff = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"compute_diff\", true)\r\n compute_diff.setDisplayName(\"compute_diff\")\r\n compute_diff.setDescription(\"compute_diff\")\r\n compute_diff.setDefaultValue(true)\r\n args << compute_diff\r\n \r\n verbose_messages = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"verbose_messages\", true)\r\n verbose_messages.setDisplayName(\"verbose_messages\")\r\n verbose_messages.setDescription(\"verbose_messages\")\r\n verbose_messages.setDefaultValue(true)\r\n args << verbose_messages \r\n \r\n algorithm_download = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"algorithm_download\", true)\r\n algorithm_download.setDisplayName(\"algorithm_download\")\r\n algorithm_download.setDescription(\"algorithm_download\")\r\n algorithm_download.setDefaultValue(false)\r\n args << algorithm_download \r\n \r\n plot_flag = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"plot_flag\", true)\r\n plot_flag.setDisplayName(\"plot_flag timeseries data\")\r\n plot_flag.setDescription(\"plot_flag timeseries data\")\r\n plot_flag.setDefaultValue(true)\r\n args << plot_flag\r\n \r\n plot_name = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"plot_name\", true)\r\n plot_name.setDisplayName(\"Plot name\")\r\n plot_name.setDescription(\"Plot name\")\r\n plot_name.setDefaultValue(\"\")\r\n args << plot_name\r\n \r\n warning_messages = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"warning_messages\", true)\r\n warning_messages.setDisplayName(\"warning_messages\")\r\n warning_messages.setDescription(\"warning_messages\")\r\n warning_messages.setDefaultValue(false)\r\n args << warning_messages\r\n\r\n return args\r\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # the name of the space to add to the model\n setpoint = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"setpoint_temperature\", true)\n setpoint.setUnits(\"Degrees Celsius\")\n setpoint.setDisplayName(\"Ambient Loop Temperature\")\n setpoint.setDefaultValue(20)\n setpoint.setDescription(\"Temperature setpoint for the ambient loop\")\n args << setpoint\n\n delta = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"design_delta\", true)\n delta.setUnits(\"Delta Temperature\")\n delta.setDefaultValue(5.55) # 10 Deg F default delta\n delta.setDisplayName(\"Delta Design Loop Temperature\")\n delta.setDescription(\"Delta design temperature for the ambient loop\")\n args << delta\n\n return args\n end",
"def arguments\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n return args\n end",
"def print_two_again(arg1, arg2) # Non-variable list of inputs it will accept\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def commander _args\n \"commander _args;\" \n end",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # make a string argument for furnace fuel type\n fuel_display_names = OpenStudio::StringVector.new\n fuel_display_names << Constants.FuelTypeGas\n fuel_display_names << Constants.FuelTypeOil\n fuel_display_names << Constants.FuelTypePropane\n fuel_display_names << Constants.FuelTypeElectric\n fuel_type = OpenStudio::Measure::OSArgument::makeChoiceArgument('fuel_type', fuel_display_names, true)\n fuel_type.setDisplayName('Fuel Type')\n fuel_type.setDescription('Type of fuel used for heating.')\n fuel_type.setDefaultValue(Constants.FuelTypeGas)\n args << fuel_type\n\n # make an argument for entering furnace installed afue\n afue = OpenStudio::Measure::OSArgument::makeDoubleArgument('afue', true)\n afue.setDisplayName('Installed AFUE')\n afue.setUnits('Btu/Btu')\n afue.setDescription('The installed Annual Fuel Utilization Efficiency (AFUE) of the furnace, which can be used to account for performance derating or degradation relative to the rated value.')\n afue.setDefaultValue(0.78)\n args << afue\n\n # make an argument for entering furnace installed supply fan power\n fan_power_installed = OpenStudio::Measure::OSArgument::makeDoubleArgument('fan_power_installed', true)\n fan_power_installed.setDisplayName('Installed Supply Fan Power')\n fan_power_installed.setUnits('W/cfm')\n fan_power_installed.setDescription('Fan power (in W) per delivered airflow rate (in cfm) of the indoor fan for the maximum fan speed under actual operating conditions.')\n fan_power_installed.setDefaultValue(0.5)\n args << fan_power_installed\n\n # make a string argument for furnace heating output capacity\n capacity = OpenStudio::Measure::OSArgument::makeStringArgument('capacity', true)\n capacity.setDisplayName('Heating Capacity')\n capacity.setDescription(\"The output heating capacity of the furnace. If using '#{Constants.SizingAuto}', the autosizing algorithm will use ACCA Manual S to set the capacity.\")\n capacity.setUnits('kBtu/hr')\n capacity.setDefaultValue(Constants.SizingAuto)\n args << capacity\n\n # make a string argument for distribution system efficiency\n dse = OpenStudio::Measure::OSArgument::makeStringArgument('dse', true)\n dse.setDisplayName('Distribution System Efficiency')\n dse.setDescription('Defines the energy losses associated with the delivery of energy from the equipment to the source of the load.')\n dse.setDefaultValue('NA')\n args << dse\n\n # make a bool argument for open hvac flue\n has_hvac_flue = OpenStudio::Measure::OSArgument::makeBoolArgument('has_hvac_flue', true)\n has_hvac_flue.setDisplayName('Air Leakage: Has Open HVAC Flue')\n has_hvac_flue.setDescription('Specifies whether the building has an open flue associated with the HVAC system.')\n has_hvac_flue.setDefaultValue(true)\n args << has_hvac_flue\n\n return args\n end",
"def args\n @args\n end",
"def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n return args\n end",
"def default_args(a,b,c=1)\n puts \"\\nValues of variables: \",a,b,c\nend",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n \n \t#Make a string argument for 24 weekday cooling set point values\n clg_wkdy = OpenStudio::Measure::OSArgument::makeStringArgument(\"clg_wkdy\", false)\n clg_wkdy.setDisplayName(\"Weekday Setpoint\")\n clg_wkdy.setDescription(\"Specify a single cooling setpoint or a 24-hour comma-separated cooling schedule for the weekdays.\")\n clg_wkdy.setUnits(\"degrees F\")\n clg_wkdy.setDefaultValue(\"76\")\n args << clg_wkdy \n \n \t#Make a string argument for 24 weekend cooling set point values\n clg_wked = OpenStudio::Measure::OSArgument::makeStringArgument(\"clg_wked\", false)\n clg_wked.setDisplayName(\"Weekend Setpoint\")\n clg_wked.setDescription(\"Specify a single cooling setpoint or a 24-hour comma-separated cooling schedule for the weekend.\")\n clg_wked.setUnits(\"degrees F\")\n clg_wked.setDefaultValue(\"76\")\n args << clg_wked\t\n\t\n return args\n end",
"def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n # this measure does not require any user arguments, return an empty list\n return args\n end"
] | [
"0.73753476",
"0.73753476",
"0.73753476",
"0.70890766",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.68296087",
"0.6826596",
"0.67602986",
"0.67480284",
"0.6589929",
"0.6581451",
"0.6579882",
"0.65468127",
"0.6503042",
"0.647451",
"0.64706385",
"0.64699155",
"0.6469245",
"0.64641875",
"0.64103556",
"0.6389132",
"0.637863",
"0.6374086",
"0.6373223",
"0.63639134",
"0.6358853",
"0.6347805",
"0.63475585",
"0.63470906",
"0.6329135",
"0.63280094",
"0.62932867",
"0.6289945",
"0.6271416",
"0.6257277",
"0.6257238",
"0.6239814",
"0.6235555",
"0.62354916",
"0.6221531",
"0.6221531",
"0.6221531",
"0.62026656",
"0.61958784",
"0.61795026",
"0.61696565",
"0.6168981",
"0.6167551",
"0.6165484",
"0.6161183",
"0.6146112",
"0.6128867",
"0.611614",
"0.6099537",
"0.609091",
"0.608763",
"0.6082464",
"0.60754794",
"0.6075173",
"0.60703015",
"0.6069249",
"0.6053929",
"0.60461015",
"0.6037139",
"0.6037139",
"0.603555",
"0.6028014",
"0.60276234",
"0.6026254",
"0.6021278",
"0.6006005",
"0.60050625",
"0.60002536",
"0.5998068",
"0.5990844",
"0.5986098",
"0.59826887",
"0.59739846",
"0.59692407",
"0.59684443",
"0.5966365",
"0.59595567"
] | 0.0 | -1 |
define the outputs that the measure will create | def outputs
outs = OpenStudio::Measure::OSOutputVector.new
# this measure does not produce machine readable outputs with registerValue, return an empty list
return outs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def outputs \n result = OpenStudio::Measure::OSOutputVector.new\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput('panel_rated_output') # w/m^2\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput('panel_rated_output_ip') # w/ft^2\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput('system_rated_output') # w\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput('pv_area_total_ip') # w\\ft^2\n result << OpenStudio::Measure::OSOutput.makeStringOutput('facade') # w\\ft^2\n return result\n end",
"def outputs\n outs = OpenStudio::Measure::OSOutputVector.new\n # this measure does not produce machine readable outputs with registerValue, return an empty list\n return outs\n end",
"def outputs\n buildstock_outputs = [\n \"total_site_energy_mbtu\",\n \"total_site_electricity_kwh\",\n \"total_site_natural_gas_therm\",\n \"total_site_other_fuel_mbtu\",\n \"net_site_energy_mbtu\", # Incorporates PV\n \"net_site_electricity_kwh\", # Incorporates PV\n \"electricity_heating_kwh\",\n \"electricity_cooling_kwh\",\n \"electricity_interior_lighting_kwh\",\n \"electricity_exterior_lighting_kwh\",\n \"electricity_interior_equipment_kwh\",\n \"electricity_fans_kwh\",\n \"electricity_pumps_kwh\",\n \"electricity_water_systems_kwh\",\n \"electricity_pv_kwh\",\n \"natural_gas_heating_therm\",\n \"natural_gas_interior_equipment_therm\",\n \"natural_gas_water_systems_therm\",\n \"other_fuel_heating_mbtu\",\n \"other_fuel_interior_equipment_mbtu\",\n \"other_fuel_water_systems_mbtu\",\n \"hours_heating_setpoint_not_met\",\n \"hours_cooling_setpoint_not_met\",\n \"hvac_cooling_capacity_w\",\n \"hvac_heating_capacity_w\",\n \"upgrade_name\",\n \"upgrade_cost_usd\",\n \"weight\"\n ]\n result = OpenStudio::Measure::OSOutputVector.new\n buildstock_outputs.each do |output|\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput(output)\n end\n return result\n end",
"def outputs\n data[:outputs]\n end",
"def flow_measurements(input, output)\n \n operations.output_collections[output].each do |outputPlate|\n log_info outputPlate\n # Creates a table that directs tech to reformat collection into a 96 Well format\n \n # Displays the transferring of cultures from 24W to 96W format\n transfer_to_96(input, output, outputPlate)\n \n # Instructs on how to apply settings in workspace for fluorescence measurements\n measuring_fluorescence(outputPlate)\n \n # From Upload_FC_Data Module - Gathers uploads and associates files to job and 96 file matrix\n upload_results(input, output, outputPlate)\n end\n end",
"def outputs()\n nil\n end",
"def outputs\n @outputs || []\n end",
"def measure; end",
"def total_output\n @outputs.inject(:+)\n end",
"def typical_electricity_output\n fetch(:typical_electricity_output) do\n typical_input * electricity_output_conversion\n end\n end",
"def outputs\n Hash[ FORMATS.map{ |format| [format, output(format)] } ]\n end",
"def flow_measurements(input, output)\n \n # Creates a hash that groups all the running operations to the input_collection_id it corresponds to\n grouped_by_collection = operations.running.group_by { |op| op.input(input).collection.id }\n \n log_info grouped_by_collection\n \n # takes output container/collection and iterates through the incoming collections\n operations.output_collections[output].each do |outputPlate|\n \n # Removes the first object and takes the first index of that object - input_item_id\n inputPlateID = grouped_by_collection.shift.first\n \n # Transfering culture from input 96 well plate to clear 96 well U-bottom plate for measurements \n transfer_cults(grouped_by_collection, outputPlate, inputPlateID)\n \n # Instruct on how to apply settings in workspace for fluorescence measurements\n measuring_fluorescence(outputPlate, inputPlateID)\n \n # Instruct on saving data and associating the data with collection\n exporting_FCS(outputPlate, input, output)\n \n end \n end",
"def outputValue\n\t\tend",
"def outputs\n [Graph::OperationOutput.from_index(self.value_handle, 0)]\n end",
"def genOutputLabelArray()\n return [\"timeIndex\",\n \"posIndex_x\", \"posIndex_y\", \"posIndex_z\",\n \"population\"] ;\n end",
"def get_outputs()\n return @outputs\n end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def outputs()\n @actor.outputs()\n end",
"def outputs\n inputs.map(&:output).compact\n end",
"def report_sim_output(runner, name, vals, os_units, desired_units, percent_of_val=1.0)\n total_val = 0.0\n vals.each do |val|\n next if val.empty?\n total_val += val.get * percent_of_val\n end\n if os_units.nil? or desired_units.nil? or os_units == desired_units\n valInUnits = total_val\n else\n valInUnits = OpenStudio::convert(total_val, os_units, desired_units).get\n end\n runner.registerValue(name,valInUnits)\n runner.registerInfo(\"Registering #{valInUnits.round(2)} for #{name}.\")\n end",
"def outputs data\n data.each do |data|\n #puts \"DATA: #{data.inspect}\"\n #puts \" data mapping: #{data.map}\"\n #puts \"-----\"\n data.output\n end\nend",
"def main\n pr = intro\n operations.group_by {|op| get_parameter(op: op, fv_str: MEASUREMENT_TYPE).to_sym}.each do |measurement_type, ops|\n new_mtype = true\n pr.measurement_type = measurement_type\n ops.group_by {|op| op.input(INPUT).sample.sample_type}.each do |st, ops|\n ops.group_by {|op| op.input(MEDIA).item}.each do |media_item, ops|\n ops.group_by {|op| get_uninitialized_output_object_type(op)}.each do |out_ot, ops|\n ops.make\n ops.group_by {|op| op.output(OUTPUT).collection}.each do |out_collection, ops|\n pr.setup_experimental_measurement(experimental_item: out_collection, output_fv: nil)\n new_mtype = setup_plate_reader_software_env(pr: pr, new_mtype: new_mtype)\n # Gather materials and items\n take_items = [media_item].concat([pr.experimental_item].flatten)\n gather_materials(empty_containers: [pr.measurement_item], transfer_required: pr.transfer_required, new_materials: ['P1000 Multichannel'], take_items: take_items)\n # Prep plate\n display_hash = get_transfer_display_hash(ops: ops, input_str: INPUT, output_str: OUTPUT, dilution_str: DILUTION)\n prefill_plate_w_media(collection: pr.measurement_item, media_sample: media_item.sample, media_vol_ul: nil, display_hash: display_hash) # media_vol_ul must be > 0 to run show block\n take ops.map {|op| op.input(INPUT).item}, interactive: true\n tech_transfer_cultures(collection: pr.measurement_item, display_hash: display_hash)\n tech_add_blanks(pr: pr, blanking_sample: media_item.sample, culture_vol_ul: 0.0, media_vol_ul: 300.0) # Cannot handle a plate without blanks, esp in processing of upload\n \n take_measurement_and_upload_data(pr: pr)\n \n dilution_factor_arr = ops.map {|op| get_dilution_factor(op: op, fv_str: DILUTION)}\n \n process_and_associate_data(pr: pr, ops: ops, blanking_sample: media_item.sample, dilution_factor: dilution_factor_arr)\n end\n keep_p_arr = ops.select {|op| op.input(KEEP_OUT_PLT).val.to_s.downcase == 'yes'}\n (keep_p_arr.empty?) ? pr.measurement_item.mark_as_deleted : pr.measurement_item.location = 'Bench'\n end\n end\n end\n end\n cleaning_up(pr: pr)\n end",
"def measurements\n []\n end",
"def measure=(_arg0); end",
"def generate_output\n write_average_fitness('output/average.txt')\n write_best_fitness('output/best.txt')\n write_survivors('output/survivors.txt')\n write_traits('output/traits.txt')\n end",
"def measure\n\t\t1\n\tend",
"def calculated; end",
"def combineMetricOutputs(output)\r\n output[:allMetrics] = output.values.collect { |v| v[:metrics] if v.is_a?(Hash) }.compact.flatten << \"--End-Metrics--\"\r\n output[:allNames] = output.values.collect { |v| v[:metricsNames] if v.is_a?(Hash) }.compact.flatten << \"--End-Names--\"\r\n output[:allPasses] = output.values.collect { |v| v[:metricsPass] if v.is_a?(Hash) }.compact.flatten << \"--End-Passes--\"\r\n output[:allComments] = output.values.collect { |v| v[:metricsComments] if v.is_a?(Hash) }.compact.flatten << \"--End-Comments--\"\r\n output[:allUsages] = output.values.collect { |v| v[:metricsUsage] if v.is_a?(Hash) }.compact.flatten << \"--End-Usage--\"\r\n output[:allDataSources] = output.values.collect { |v| v[:dataSource] if v.is_a?(Hash) }.compact.flatten\r\n end",
"def useful_output\n fetch(:useful_output) do\n [\n node.output(:electricity),\n node.output(:useable_heat),\n node.output(:steam_hot_water)\n ].map { |slot| slot and slot.conversion }.compact.sum\n end\n end",
"def output(data); end",
"def outputs\n output_vars = ['Zone Mean Air Temperature', 'Wetbulb Globe Temperature'] # possible list that the user can enter limits for; should get blank column for ones that aren't entered into output_vars arg\n buildstock_outputs = []\n thermal_zones.each do |zone|\n output_vars.each do |output_var|\n buildstock_outputs << \"#{OpenStudio::toUnderscoreCase(zone)}_#{OpenStudio::toUnderscoreCase(output_var)}_hours_below_lower_threshold\" # hours below lower threshold\n buildstock_outputs << \"#{OpenStudio::toUnderscoreCase(zone)}_#{OpenStudio::toUnderscoreCase(output_var)}_hours_above_upper_threshold\" # hours above upper threshold\n buildstock_outputs << \"#{OpenStudio::toUnderscoreCase(zone)}_#{OpenStudio::toUnderscoreCase(output_var)}_degree_hours_below_lower_threshold\" # degree-hours below lower threshold\n buildstock_outputs << \"#{OpenStudio::toUnderscoreCase(zone)}_#{OpenStudio::toUnderscoreCase(output_var)}_degree_hours_above_upper_threshold\" # degree-hours above upper threshold\n buildstock_outputs << \"#{OpenStudio::toUnderscoreCase(zone)}_#{OpenStudio::toUnderscoreCase(output_var)}_hours_until_lower_threshold\" # hours until lower threshold\n buildstock_outputs << \"#{OpenStudio::toUnderscoreCase(zone)}_#{OpenStudio::toUnderscoreCase(output_var)}_hours_until_upper_threshold\" # hours until upper threshold\n end\n # buildstock_outputs << \"#{OpenStudio::toUnderscoreCase(zone)}_#{OpenStudio::toUnderscoreCase(\"End Of Outage Indoor Drybulb Temperature\")}\"\n buildstock_outputs << \"#{OpenStudio::toUnderscoreCase(zone)}_#{OpenStudio::toUnderscoreCase('Maximum Wetbulb Globe Temperature During Outage')}\"\n buildstock_outputs << \"#{OpenStudio::toUnderscoreCase(zone)}_#{OpenStudio::toUnderscoreCase('Minimum Indoor Drybulb Temperature During Outage')}\"\n buildstock_outputs << \"#{OpenStudio::toUnderscoreCase(zone)}_#{OpenStudio::toUnderscoreCase('Maximum Indoor Drybulb Temperature During Outage')}\"\n end\n buildstock_outputs << 'outage_start_datetime'\n buildstock_outputs << 'outage_duration_hours'\n result = OpenStudio::Measure::OSOutputVector.new\n buildstock_outputs.each do |output|\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput(output)\n end\n return result\n end",
"def modeler_description\n return \"This measure loops through output_variables, EMS:output_variables and ExternalInterface objects and will create the variables.cfg xml file for BCVTB.\n Those variables need to be in cfg file, being used for data exchange.\"\n end",
"def build_final_output\n perf_output = \" | #{@perfdata.join(' ')}\"\n if @critical.any?\n crit_msg(@critical.join(', ') + perf_output)\n elsif @warning.any?\n warn_msg(@warning.join(', ') + perf_output)\n else\n ok_msg(@okays.join(', ') + perf_output)\n end\n end",
"def typical_heat_output\n fetch(:typical_heat_output) do\n typical_input * heat_and_cold_output_conversion\n end\n end",
"def measurements\n @measurements ||= []\n end",
"def outputs\n ports_with_capabilities(:output)\n end",
"def output\n @all[:output]\n end",
"def samples; end",
"def samples; end",
"def next_output_properties\n this_execute_count = $ant_execute_count\n $ant_execute_count += 1\n [ 'executer_output_%d' % this_execute_count, 'executer_error_%d' % this_execute_count, 'executer_result_code_%d' % this_execute_count ]\n end",
"def output(*instance_variable_names)\n instance_variable_names.each do |name|\n outputs[name.to_sym] = \"@#{name}\"\n end\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n reporting_frequency = runner.getStringArgumentValue(\"reporting_frequency\",user_arguments)\n inc_output_variables = runner.getBoolArgumentValue(\"inc_output_variables\",user_arguments)\n\n # Request the output for each end use/fuel type combination\n end_uses.each do |end_use|\n fuel_types.each do |fuel_type|\n variable_name = if end_use == 'Facility'\n \"#{fuel_type}:#{end_use}\"\n else\n \"#{end_use}:#{fuel_type}\"\n end\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{variable_name},#{reporting_frequency};\").get\n end\n end\n\n # Request the output for each end use subcategory/end use/fuel type combination\n end_use_subcats.each do |subcat|\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{subcat},#{reporting_frequency};\").get\n end\n\n # Request the output for each variable\n if inc_output_variables\n runner.registerInfo(\"Requesting Output Variables\")\n output_vars.each do |output_var|\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,#{output_var},#{reporting_frequency};\").get\n runner.registerInfo(\"Requesting Output:Variable,#{output_var},#{reporting_frequency};\")\n end\n end\n\n return result\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n return OpenStudio::IdfObjectVector.new if runner.halted\n\n # get the last model and sql file\n model = runner.lastOpenStudioModel\n if model.empty?\n runner.registerError('Cannot find last model.')\n return false\n end\n model = model.get\n\n output_meters = OutputMeters.new(model, runner, 'Timestep', include_enduse_subcategories = true)\n results = output_meters.create_custom_building_unit_meters\n\n # heat transfer outputs\n OsLib_HeatTransfer.heat_transfer_outputs.each do |output|\n results << OpenStudio::IdfObject.load(\"Output:Variable,,#{output},Timestep;\").get\n end\n\n # supply outputs\n results << OpenStudio::IdfObject.load('Output:Variable,,Zone Air System Sensible Heating Energy,RunPeriod;').get\n results << OpenStudio::IdfObject.load('Output:Variable,,Zone Air System Sensible Cooling Energy,RunPeriod;').get\n\n return results\n end",
"def wrestler_output\n\n\t\tputs \"Name: #{self.values[:name]}\"\n\t\tputs \"Set: #{self.values[:set]}\"\n\t\tputs \"Singles Priority: #{self.values[:prioritys]}\"\n\t\tputs \"Tag Team Priority: #{self.values[:priorityt]}\"\n\t\tputs \"TT Probability: #{self.statistics[:tt_probability]}\"\n\t\tputs \"Card Rating: #{self.statistics[:total_card_rating]}\"\n\t\tputs \"OC Probability: #{self.statistics[:oc_probability]}\"\n\t\tputs \"Total Points-Per-Round: #{self.statistics[:total_card_points_per_round]}\"\n\t\tputs \"DQ Probability-Per-Round: #{self.statistics[:dq_probability_per_round]}\"\n\t\tputs \"P/A Probability-Per-Round: #{self.statistics[:pa_probability_per_round]}\"\n\t\tputs \"Submission Roll Probability-Per-Round: #{self.statistics[:sub_probability_per_round]}\"\n\t\tputs \"XX Roll Probability-Per-Round: #{self.statistics[:xx_probability_per_round]}\"\n\t\tputs \"Submission Loss Probability: #{self.points[:sub_prob]}\"\n\t\tputs \"Tag Team Save Probability: #{self.points[:tag_prob]}\"\n\t\tputs \"\\n\"\n\n\t\ttt_probability = \"%.1f\" % (self.statistics[:tt_probability] * 100) + \"%\"\n\t\tcard_rating = \"%.1f\" % self.statistics[:total_card_rating]\n\t\toc_probability = \"%.1f\" % (self.statistics[:oc_probability] * 100) + \"%\"\n\t\ttotal_card_points_per_round = \"%.3f\" % self.statistics[:total_card_points_per_round]\n\t\tdq_probability_per_round = \"%.1f\" % (self.statistics[:dq_probability_per_round] * 100) + \"%\"\n\t\tpa_probability_per_round = \"%.1f\" % (self.statistics[:pa_probability_per_round] * 100) + \"%\"\n\t\tsub_probability_per_round = \"%.1f\" % (self.statistics[:sub_probability_per_round] * 100) + \"%\"\n\t\txx_probability_per_round = \"%.1f\" % (self.statistics[:xx_probability_per_round] * 100) + \"%\"\n\t\t\n\t\tsub_prob = \"%.1f\" % (self.points[:sub_prob] * 100) + \"%\"\n\t\ttag_prob = \"%.1f\" % (self.points[:tag_prob] * 100) + \"%\"\n\n\t\tf = File.new('files/results.csv', 'a')\n\t\tf.write(\"#{self.values[:name]},#{self.values[:set]}, #{self.values[:prioritys]}, #{self.values[:priorityt]}, #{tt_probability}, #{card_rating}, #{oc_probability}, #{total_card_points_per_round}, #{dq_probability_per_round}, #{pa_probability_per_round}, #{sub_probability_per_round}, #{xx_probability_per_round}, #{sub_prob}, #{tag_prob}, \\n\")\n\t\tf.close\n\tend",
"def output\n {\"Min\" => @min,\n \"FiveMin\" => @five_min,\n \"Hour\" => @hour,\n \"Main\" => @main_tray}\n end",
"def output\n send(\"output_#{@type}\")\n end",
"def initializeResultVariables()\n @totalReadsProduced = 0 # Total reads\n @numDuplicateReads = 0 # Num. duplicate reads\n @perDuplicateReads = 0 # Percentage of duplicate reads\n @numAlignedReads = 0 # Num. of reads aligned\n @perAlignedReads = 0 # Percentage of reads aligned\n @numReadsPaired = 0 # Total pairs of reads\n @numReadAndMatePaired = 0 # Read pairs with mapped mates\n @numBufferAlignedReads = 0 # Num. reads aligned on buffer\n @perBufferAlignedReads = 0 # Percentage of reads aligned on buffer\n @numTargetAlignedReads = 0 # Num. reads aligned on target\n @perTargetAlignedReads = 0 # Percentage of reads aligned on target\n @avgCoverage = 0 # Average coverage\n @numReadsTargetBuffer = 0 # Num. reads hitting target or buffer\n @perReadsTargetBuffer = 0 # Percentage of reads hitting target or buffer\n @totalExpAlignedReads = 0 # Total expected number of aligned reads\n @totalCalcAlignedReads = 0 # Total calculated number of aligned reads \n @numTargetsHit = 0 # Number of targets hit\n @perTargetsHit = 0 # Percentage of targets hit\n @numTargetBuffersHit = 0 # Num. target buffers hit\n @perTargetBuffersHit = 0 # Percentage of target buffers hit\n @numTotalTargets = 0 # Number of total targets\n @numNonTarget = 0 # Number of non-target hits with high coverage\n @numTargetedBases = 0 # Number of bases targeted\n @numBufferBases = 0 # Number of buffer bases\n @numBases1Coverage = 0 # Num. bases with 1+ coverage\n @perBases1Coverage = 0 # Percentage of bases with 1+ coverage\n @numBases4Coverage = 0 # Percentage of bases with 4+ coverage\n @perBases4Coverage = 0 # Percentage of bases with 4+ coverage\n @numBases10Coverage = 0 # Num. bases with 10+ coverage\n @perBases10Coverage = 0 # Percentage of bases with 10+ coverage\n @numBases20Coverage = 0 # Num. bases with 20+ coverage\n @perBases20Coverage = 0 # Percentage of bases with 20+ coverage\n @numBases40Coverage = 0 # Percentage of bases with 40+ coverage\n @perBases40Coverage = 0 # Percentage of bases with 40+ coverage\n end",
"def build_examples_output output\n output.join(\"\\n\\n\\t\")\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n return OpenStudio::IdfObjectVector.new if runner.halted\n\n reporting_frequency = runner.getStringArgumentValue('reporting_frequency', user_arguments)\n include_enduse_subcategories = runner.getBoolArgumentValue('include_enduse_subcategories', user_arguments)\n output_variables = runner.getOptionalStringArgumentValue('output_variables', user_arguments)\n output_vars = []\n if output_variables.is_initialized\n output_vars = output_variables.get\n output_vars = output_vars.split(',')\n output_vars = output_vars.collect { |x| x.strip }\n end\n\n # get the last model and sql file\n model = runner.lastOpenStudioModel\n if model.empty?\n runner.registerError('Cannot find last model.')\n return false\n end\n model = model.get\n\n output_meters = OutputMeters.new(model, runner, reporting_frequency, include_enduse_subcategories)\n results = output_meters.create_custom_building_unit_meters\n\n output_vars.each do |output_var_item|\n if output_var_item.include? '|'\n output_var, key_val = output_var_item.split('|')\n else\n key_val = '*'\n output_var = output_var_item\n end\n results << OpenStudio::IdfObject.load(\"Output:Variable,#{key_val},#{output_var},#{reporting_frequency};\").get\n end\n\n results << OpenStudio::IdfObject.load(\"Output:Meter,Electricity:Facility,#{reporting_frequency};\").get\n\n return results\n end",
"def report_sim_output(runner, name, total_val, os_units, desired_units, percent_of_val = 1.0)\n total_val *= percent_of_val\n if os_units.nil? || desired_units.nil? || (os_units == desired_units)\n valInUnits = total_val\n else\n valInUnits = UnitConversions.convert(total_val, os_units, desired_units)\n end\n runner.registerValue(name, valInUnits)\n runner.registerInfo(\"Registering #{valInUnits.round(2)} for #{name}.\")\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n \n result = OpenStudio::IdfObjectVector.new\n\n reporting_frequency = runner.getStringArgumentValue(\"reporting_frequency\",user_arguments)\n\n # Request the output for each end use/fuel type combination\n end_uses.each do |end_use|\n fuel_types.each do |fuel_type|\n variable_name = if end_use == 'Facility'\n \"#{fuel_type}:#{end_use}\"\n else\n \"#{end_use}:#{fuel_type}\"\n end\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{variable_name},#{reporting_frequency};\").get\n end\n end\n \n return result\n end",
"def getchart()\n # The value to display on the meter\n value = 4.75\n\n # Create an AugularMeter object of size 110 x 110 pixels, using silver background\n # color with a black 2 pixel 3D depressed border.\n m = ChartDirector::AngularMeter.new(110, 110, ChartDirector::silverColor(),\n 0x000000, -2)\n\n # Set meter appearance according to a parameter\n if params[\"img\"] == \"0\"\n # Set the meter center at bottom left corner (15, 95), with radius 85 pixels.\n # Meter spans from 90 - 0 degrees.\n m.setMeter(15, 95, 85, 90, 0)\n # Add a label to the meter centered at (35, 75)\n m.addText(35, 75, \"VDC\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at top right corner (103, 7)\n m.addText(103, 7, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::TopRight).setBackground(0, 0, -1)\n elsif params[\"img\"] == \"1\"\n # Set the meter center at top left corner (15, 15), with radius 85 pixels.\n # Meter spans from 90 - 180 degrees.\n m.setMeter(15, 15, 85, 90, 180)\n # Add a label to the meter centered at (35, 35)\n m.addText(35, 35, \"AMP\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at bottom right corner (103, 103)\n m.addText(103, 103, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::BottomRight).setBackground(0, 0, -1)\n elsif params[\"img\"] == \"2\"\n # Set the meter center at top right corner (15, 95), with radius 85 pixels.\n # Meter spans from 270 - 180 degrees.\n m.setMeter(95, 15, 85, 270, 180)\n # Add a label to the meter centered at (75, 35)\n m.addText(75, 35, \"KW\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at bottom left corner (7, 103)\n m.addText(7, 103, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::BottomLeft).setBackground(0, 0, -1)\n else\n # Set the meter center at bottom right corner (95, 95), with radius 85 pixels.\n # Meter spans from 270 - 360 degrees.\n m.setMeter(95, 95, 85, 270, 360)\n # Add a label to the meter centered at (75, 75)\n m.addText(75, 75, \"RPM\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at top left corner (7, 7)\n m.addText(7, 7, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::TopLeft).setBackground(0, 0, -1)\n end\n\n # Meter scale is 0 - 10, with a major tick every 2 units, and minor tick every 1\n # unit\n m.setScale(0, 10, 2, 1)\n\n # Set 0 - 6 as green (99ff99) zone, 6 - 8 as yellow (ffff00) zone, and 8 - 10 as\n # red (ff3333) zone\n m.addZone(0, 6, 0x99ff99, 0x808080)\n m.addZone(6, 8, 0xffff00, 0x808080)\n m.addZone(8, 10, 0xff3333, 0x808080)\n\n # Add a semi-transparent black (80000000) pointer at the specified value\n m.addPointer(value, 0x80000000)\n\n # Output the chart\n send_data(m.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def render outputs\n\n # Work through each brick in the current brick orientation\n @bricks[@rotation].each do |brick|\n\n outputs.primitives << {\n x: @board_origin_x + ( ( @grid_col + brick[1] ) * 32 ),\n y: @board_origin_y + ( ( @grid_row + brick[0] ) * 32 ),\n w: 32,\n h: 32,\n path: \"sprites/brick_#{@type.to_s}.png\"\n }.sprite\n\n end\n\n end",
"def output_report\n\t\toutput_start\n\t\toutput_head\n\t\toutput_body_start\n\t\toutput_body\n\t\toutput_body_end\n\t\toutput_end\n\tend",
"def defMeasurement(name,&block)\n mp = {:mp => name, :fields => []}\n @fields = []\n # call the block with ourserlves to process its 'defMetric' statements\n block.call(self) if block\n @fields.each { |f| mp[:fields] << f }\n define_measurement_point(mp)\n end",
"def output_descriptions\n @outputs.collect{|output| output.device_info.description }\n end",
"def run(model, runner, user_arguments)\r\n super(model, runner, user_arguments)\r\n \r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(model), user_arguments)\r\n return false\r\n end\r\n \r\n # Define the reporting frequency\r\n reporting_frequency = \"hourly\"\r\n \r\n # Define the variables to report\r\n variable_names = []\r\n variable_names << \"District Heating Rate\"\r\n variable_names << \"District Cooling Rate\"\r\n \r\n # Request each output variable\r\n variable_names.each do |variable_name|\r\n output_variable = OpenStudio::Model::OutputVariable.new(variable_name,model)\r\n output_variable.setReportingFrequency(reporting_frequency)\r\n runner.registerInfo(\"Requested output for '#{output_variable.variableName}' at the #{output_variable.reportingFrequency} timestep.\")\r\n end\r\n \r\n # Report the outlet node conditions for each plant loop in the model\r\n # Rename the outlet node so that it makes sense in the report\r\n outlet_node_variable_names = []\r\n outlet_node_variable_names << \"System Node Temperature\"\r\n outlet_node_variable_names << \"System Node Setpoint Temperature\"\r\n outlet_node_variable_names << \"System Node Mass Flow Rate\"\r\n model.getPlantLoops.each do |plant_loop|\r\n outlet_node = plant_loop.supplyOutletNode\r\n outlet_node_name = \"#{plant_loop.name} Supply Outlet Node\"\r\n outlet_node.setName(outlet_node_name)\r\n outlet_node_variable_names.each do |outlet_node_variable_name|\r\n output_variable = OpenStudio::Model::OutputVariable.new(outlet_node_variable_name,model)\r\n output_variable.setKeyValue(outlet_node_name) \r\n output_variable.setReportingFrequency(reporting_frequency) \r\n end\r\n end\r\n \r\n \r\n return true\r\n \r\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments, user_arguments)\n return result\n end\n\n result << OpenStudio::IdfObject.load('Output:Meter:MeterFileOnly,Electricity:Facility,Timestep;').get\n result << OpenStudio::IdfObject.load('Output:Meter:MeterFileOnly,ElectricityProduced:Facility,Timestep;').get\n result << OpenStudio::IdfObject.load('Output:Meter:MeterFileOnly,Gas:Facility,Timestep;').get\n\n timeseries = ['District Cooling Chilled Water Rate', 'District Cooling Mass Flow Rate',\n 'District Cooling Inlet Temperature', 'District Cooling Outlet Temperature',\n 'District Heating Hot Water Rate', 'District Heating Mass Flow Rate',\n 'District Heating Inlet Temperature', 'District Heating Outlet Temperature']\n\n timeseries.each do |ts|\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,#{ts},Timestep;\").get\n end\n\n return result\n end",
"def setup_metrics\n end",
"def setup_metrics\n end",
"def setup_metrics\n end",
"def full_output\n @output_targets.map do |t|\n @instructions[t] || 0\n end\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n reporting_frequency = runner.getStringArgumentValue('reporting_frequency', user_arguments)\n\n # Request the output for each end use/fuel type combination\n end_uses.each do |end_use|\n end_use, = end_use\n fuel_types.each do |fuel_type|\n fuel_type, = fuel_type\n variable_name = if end_use == 'Facility'\n \"#{fuel_type}:#{end_use}\"\n else\n \"#{end_use}:#{fuel_type}\"\n end\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{variable_name},#{reporting_frequency};\").get\n end\n end\n\n # Create a custom meter for OtherFuels\n other_fuel_uses = ['HeatRejection', 'Heating', 'WaterSystems', 'InteriorEquipment']\n custom_meter_facility = 'Meter:Custom,OtherFuels:Facility,OtherFuel2'\n other_fuel_uses.each do |end_use|\n custom_meter = \"Meter:Custom,#{end_use}:OtherFuels,OtherFuel2\"\n other_fuels.each do |other_fuel|\n other_fuel = other_fuel.gsub(' ', '')\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{end_use}:#{other_fuel},#{reporting_frequency};\").get\n custom_meter_facility += \",,#{end_use}:#{other_fuel}\"\n custom_meter += \",,#{end_use}:#{other_fuel}\"\n end\n custom_meter += ';'\n result << OpenStudio::IdfObject.load(custom_meter).get\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{end_use}:OtherFuels,#{reporting_frequency};\").get\n end\n result << OpenStudio::IdfObject.load(\"#{custom_meter_facility};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter,OtherFuels:Facility,#{reporting_frequency};\").get\n\n # Request the output for each end use/fuel type combination\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Electricity:Facility,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,ElectricityProduced:Facility,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,NaturalGas:Facility,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,DistrictCooling:Facility,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,DistrictHeating:Facility,#{reporting_frequency};\").get\n\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Cooling:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Heating:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,InteriorLights:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,ExteriorLights:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,InteriorEquipment:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Fans:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Pumps:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,WaterSystems:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Heating:NaturalGas,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,WaterSystems:NaturalGas,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,InteriorEquipment:NaturalGas,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Heating Coil Heating Rate,hourly; !- HVAC Average [W];').get\n # result << OpenStudio::IdfObject.load(\"Output:Variable,*,Exterior Equipment:Electric Vehicles,#{reporting_frequency};\").get\n\n timeseries_data = ['District Cooling Chilled Water Rate', 'District Cooling Mass Flow Rate',\n 'District Cooling Inlet Temperature', 'District Cooling Outlet Temperature',\n 'District Heating Hot Water Rate', 'District Heating Mass Flow Rate',\n 'District Heating Inlet Temperature', 'District Heating Outlet Temperature', 'Cooling Coil Total Cooling Rate',\n 'Heating Coil Heating Rate', 'ExteriorEquipment:Electricity']\n\n tes_timeseries_data = ['Ice Thermal Storage End Fraction', 'Cooling coil Ice Thermal Storage End Fraction']\n\n ev_timeseries_data = ['Exterior Equipment:Electric Vehicles']\n\n timeseries_data += tes_timeseries_data\n\n timeseries_data.each do |ts|\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,#{ts},#{reporting_frequency};\").get\n end\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments, user_arguments)\n return result\n end\n\n return result\n end",
"def show\n @inputs = @analysis_configuration.analysis_parameters.inputs\n @outputs = @analysis_configuration.analysis_parameters.outputs\n end",
"def save_output(operations)\n operations.make\n\n operations.each do |op|\n op.output(\"Primer Set\").item.associate :volume, default_job_params[:aliquot_vol]\n\n output_primer = op.output(\"Primer Set\").sample\n for i in 0..13 # makes 14 additional aliquots per op\n new_aliquot = output_primer.make_item(\"Primer Mix Aliquot\")\n new_aliquot.associate :volume, default_job_params[:aliquot_vol]\n link_output_item(operation: op, sample: output_primer, item: new_aliquot)\n end\n end\n end",
"def value_written; end",
"def communicate_measure_result(_ = nil, _ = nil); end",
"def communicate_measure_result(_ = nil, _ = nil); end",
"def modeler_description\n 'This measure changes the Layer 0 properties of Thickness, Density, Thermal Absorptance, Solar Absorptance, Visible Absoptance, Thermal Conductivity, Specific Heat.'\n end",
"def modeler_description\n return 'The measure performs the following functions: (1) IDs all chillers, (2) Locates their performance curves and outputs the data, (3) Adds reporting variables for chiller-related data.'\n end",
"def communicate_measure_result(_ = nil, _ = nil)\r\n end",
"def outputs\n constructions = [\n 'floor_fin_ins_unfin_attic', # unfinished attic floor\n 'floor_fin_ins_unfin', # interzonal or cantilevered floor\n 'floor_fin_unins_fin', # floor between 1st/2nd story living spaces\n 'floor_unfin_unins_unfin', # floor between garage and attic\n 'floor_fnd_grnd_fin_b', # finished basement floor\n 'floor_fnd_grnd_unfin_b', # unfinished basement floor\n 'floor_fnd_grnd_fin_slab', # finished slab\n 'floor_fnd_grnd_unfin_slab', # garage slab\n 'floor_unfin_b_ins_fin', # unfinished basement ceiling\n 'floor_cs_ins_fin', # crawlspace ceiling\n 'floor_pb_ins_fin', # pier beam ceiling\n 'floor_fnd_grnd_cs', # crawlspace floor\n 'roof_unfin_unins_ext', # garage roof\n 'roof_unfin_ins_ext', # unfinished attic roof\n 'roof_fin_ins_ext', # finished attic roof\n 'wall_ext_ins_fin', # living exterior wall\n 'wall_ext_ins_unfin', # attic gable wall under insulated roof\n 'wall_ext_unins_unfin', # garage exterior wall or attic gable wall under uninsulated roof\n 'wall_fnd_grnd_fin_b', # finished basement wall\n 'wall_fnd_grnd_unfin_b', # unfinished basement wall\n 'wall_fnd_grnd_cs', # crawlspace wall\n 'wall_int_fin_ins_unfin', # interzonal wall\n 'wall_int_fin_unins_fin', # wall between two finished spaces\n 'wall_int_unfin_unins_unfin', # wall between two unfinished spaces\n 'living_space_footing_construction', # living space footing construction\n 'garage_space_footing_construction', # garage space footing construction\n # \"window_construction\", # exterior window\n 'door', # exterior door\n 'res_furniture_construction_living_space', # furniture in living\n 'res_furniture_construction_living_space_story_2', # furniture in living, second floor\n 'res_furniture_construction_unfinished_basement_space', # furniture in unfinished basement\n 'res_furniture_construction_finished_basement_space', # furniture in finished basement\n 'res_furniture_construction_garage_space', # furniture in garage\n 'living_zone', # living space air\n 'garage_zone', # garage space air\n 'unfinished_basement_zone', # unfinished basement space air\n 'finished_basement_zone', # finished basement space air\n 'crawl_zone', # crawl space air\n 'unfinished_attic_zone' # unfinished attic space air\n ]\n\n result = OpenStudio::Measure::OSOutputVector.new\n metrics.each do |metric|\n constructions.each do |construction|\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput(\"#{metric}_#{construction}\")\n end\n end\n return result\n end",
"def output\n @output ||= report.display\n end",
"def build_metrics\n {}\n end",
"def output\n @output ||= Output.new\n end",
"def __output(*args, **opt, &block)\n __output_impl(*args, **opt, &block)\nend",
"def getMeasurement\n#measurements\n#TODO check that this needs to be called, currently it always calls it.\n#if @chartoptions[:measurement][0] || @chartoptions[:measurement][1] || @chartoptions[:measurement][2]\n\n\n @set5 = ChartItem.new(\"Measurement:Chest\")\n\n @set6 = ChartItem.new(\"Measurement:Upper Belly\")\n\n @set7 = ChartItem.new(\"Measurement:Hip\")\n \n @set8 = ChartItem.new(\"Measurement:Thigh\")\n\n @set10 = ChartItem.new(\"Measurement:Arm\")\n\n \n \n \n \n meas1, meas2, meas3, meas4, meas5, meas6, meas7, meas8, meas9, meas10, meas11, meas12, meas13 = [],[],[],[],[],[],[],[],[],[],[],[],[]\n \n meas1_avg, meas2_avg, meas3_avg, meas4_avg, meas5_avg, meas6_avg, meas7_avg, meas8_avg, meas9_avg, meas10_avg, meas11_avg, meas12_avg, meas13_avg = [],[],[],[],[],[],[],[],[],[],[],[],[]\n \n \n meas1_count, meas2_count, meas3_count, meas4_count, meas5_count, meas6_count, meas7_count, meas8_count, meas9_count, meas10_count, meas11_count, meas12_count, meas13_count = 0,0,0,0,0,0,0,0 ,0,0,0,0,0\n \n meas1_sum, meas2_sum, meas3_sum, meas4_sum, meas5_sum, meas6_sum, meas7_sum, meas8_sum , meas9_sum, meas10_sum, meas11_sum, meas12_sum, meas13_sum = 0,0,0,0,0,0,0,0,0,0,0,0,0 \n \n for measurement in @measurement\n \n \n if !(measurement.chest.nil? ) && ( @chartoptions[:measurement_chest][0] || @chartoptions[:measurement_chest][1] || @chartoptions[:measurement][0] || @chartoptions[:measurement][1]) \n meas6_count += 1 \n meas6_sum += measurement.chest \n @set5.addPoint(measurement.date.to_time.to_i * 1000,measurement.chest)\n \n end \n \n if !(measurement.belly_upper.nil? ) && ( @chartoptions[:measurement_upper_belly][0]) \n @set6.addPoint(measurement.date.to_time.to_i * 1000, measurement.belly_upper)\n end \n \n if !(measurement.hips.nil? ) && (@chartoptions[:measurement_hip][0] ) \n \n @set7.addPoint(measurement.date.to_time.to_i * 1000,measurement.hips)\n \n end \n \n\n if @chartoptions[:measurement_thigh][0]\n @set8.addPoint(measurement.date.to_time.to_i * 1000,measurement.thigh)\n end \n \n\n \n if !(measurement.arm.nil? && measurement.arm == 0 ) && (@chartoptions[:measurement_arm][0]) \n\n @set10.addPoint(measurement.date.to_time.to_i * 1000,measurement.arm)\n\n end \n\n \n \n end \n# ----------------------------------\n# now start adding them to the chart\n# ---------------------------------- \n #if @chartoptions[:measurement][0]\n \n if (@chartoptions[:measurement_chest][0] || @chartoptions[:measurement][0] )\n @chartable.add(@set5)\n end \n if (@chartoptions[:measurement_upper_belly][0] || @chartoptions[:measurement][0] )\n @chartable.add(@set6) \n end \n if (@chartoptions[:measurement_hip][0] || @chartoptions[:measurement][0] )\n @chartable.add(@set7)\n end \n\n if (@chartoptions[:measurement_thigh][0] || @chartoptions[:measurement][0] )\n @chartable.add(@set8)\n end \n\n if (@chartoptions[:measurement_arm][0] || @chartoptions[:measurement][0] )\n @chartable.add(@set10)\n end \n \n\n#end # if @chartoptions[:measurments] \nend",
"def create_output_collection(sample:, operations:)\n collection = make_new_plate(PLATE_OBJECT_TYPE, label_plate: true)\n size = collection.dimensions.reduce(:*)\n collection.add_samples(Array.new(size, sample))\n operations.each { |op| op.output(POOLED_PLATE).set(collection: collection) }\n collection\n end",
"def outputParameters\n \ti=0\n \t\twhile i < @parameters.paramsArr.length do\n \t\t\ttemparameter = @parameters.paramsArr[i]\n \t\t\telementlen = temparameter.elementsArr.length\n print \"parameters name :\"\n puts @parameters.paramsArr[i].paramname\n \t\t\tj=0\n print \"value \"\n print \"times \"\n \t\t\twhile j<elementlen.to_i do\n puts \" \"\n \t\t\t\tprint @parameters.paramsArr[i].elementsArr[j].value\n print \" \"\n puts @parameters.paramsArr[i].elementsArr[j].times\n \t\t\t\tj+=1\n \t\t\tend \n \t\t\ti+=1\n \t\tend\n end",
"def out; end",
"def measure(*args, &b)\n end",
"def output=(_arg0); end",
"def output=(_arg0); end",
"def output=(_arg0); end",
"def output=(_arg0); end",
"def output=(_arg0); end"
] | [
"0.7556974",
"0.70015025",
"0.68349844",
"0.65264237",
"0.63755965",
"0.628786",
"0.61429816",
"0.6112792",
"0.6083238",
"0.60332656",
"0.6021887",
"0.60021985",
"0.59786016",
"0.59681743",
"0.5928986",
"0.5898399",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5887987",
"0.5884363",
"0.5872085",
"0.5860437",
"0.5840549",
"0.58395994",
"0.58374274",
"0.58269507",
"0.58220094",
"0.5796791",
"0.57954454",
"0.57949716",
"0.5787615",
"0.5770089",
"0.5764882",
"0.57575315",
"0.5745378",
"0.5744186",
"0.5718763",
"0.5702323",
"0.56988996",
"0.5691542",
"0.5691542",
"0.56712186",
"0.5665029",
"0.56427467",
"0.56414837",
"0.56358665",
"0.5630282",
"0.562618",
"0.56222594",
"0.5621567",
"0.55980605",
"0.55971813",
"0.55919045",
"0.558498",
"0.55846435",
"0.55825406",
"0.55638224",
"0.55626506",
"0.5545433",
"0.5530648",
"0.55230623",
"0.55230623",
"0.55230623",
"0.552138",
"0.5511946",
"0.5501457",
"0.548653",
"0.54847974",
"0.54762274",
"0.54762274",
"0.547402",
"0.54727495",
"0.5470747",
"0.5461381",
"0.5458473",
"0.54584414",
"0.54555833",
"0.5448466",
"0.5434065",
"0.543287",
"0.5422297",
"0.54213196",
"0.5421111",
"0.5417979",
"0.5417979",
"0.5417979",
"0.5417979",
"0.5417979"
] | 0.68907607 | 2 |
return a vector of IdfObject's to request EnergyPlus objects needed by the run method Warning: Do not change the name of this method to be snake_case. The method must be lowerCamelCase. | def energyPlusOutputRequests(runner, user_arguments)
super(runner, user_arguments)
result = OpenStudio::IdfObjectVector.new
# use the built-in error checking
if !runner.validateUserArguments(arguments, user_arguments)
return result
end
request = OpenStudio::IdfObject.load('Output:Variable,,Site Outdoor Air Drybulb Temperature,Hourly;').get
result << request
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments, user_arguments)\n return result\n end\n\n result = OpenStudio::IdfObjectVector.new\n\n # request zone variables for the run period\n result << OpenStudio::IdfObject.load('Output:Variable,*,Zone Electric Equipment Electric Energy,RunPeriod;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Zone People Occupant Count,RunPeriod;').get\n\n # request service water heating use\n result << OpenStudio::IdfObject.load('Output:Variable,*,Water Use Connections Hot Water Volume,RunPeriod;').get\n\n # request coil and fan energy use for HVAC equipment\n result << OpenStudio::IdfObject.load('Output:Variable,*,Chiller COP,RunPeriod;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Chiller Evaporator Cooling Energy,RunPeriod;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Heating Coil Electric Energy,RunPeriod;').get # J\n result << OpenStudio::IdfObject.load('Output:Variable,*,Cooling Coil Electric Energy,RunPeriod;').get # J\n result << OpenStudio::IdfObject.load('Output:Variable,*,Heating Coil Heating Energy,RunPeriod;').get # J\n result << OpenStudio::IdfObject.load('Output:Variable,*,Cooling Coil Total Cooling Energy,RunPeriod;').get # J\n result << OpenStudio::IdfObject.load('Output:Variable,*,Air System Outdoor Air Flow Fraction,RunPeriod;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Air System Mixed Air Mass Flow Rate,RunPeriod;').get # kg/s\n\n #result << OpenStudio::IdfObject.load('Output:Variable,*,Fan Electric Energy,RunPeriod;').get # J\n #result << OpenStudio::IdfObject.load('Output:Variable,*,Humidifier Electric Energy,RunPeriod;').get # J\n #result << OpenStudio::IdfObject.load('Output:Variable,*,Evaporative Cooler Electric Energy,RunPeriod;').get # J\n #result << OpenStudio::IdfObject.load('Output:Variable,*,Baseboard Hot Water Energy,RunPeriod;').get # J\n #result << OpenStudio::IdfObject.load('Output:Variable,*,Baseboard Electric Energy,RunPeriod;').get # J\n\n return result\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments, user_arguments)\n return result\n end\n\n result << OpenStudio::IdfObject.load('Output:Meter:MeterFileOnly,Electricity:Facility,Timestep;').get\n result << OpenStudio::IdfObject.load('Output:Meter:MeterFileOnly,ElectricityProduced:Facility,Timestep;').get\n result << OpenStudio::IdfObject.load('Output:Meter:MeterFileOnly,Gas:Facility,Timestep;').get\n\n timeseries = ['District Cooling Chilled Water Rate', 'District Cooling Mass Flow Rate',\n 'District Cooling Inlet Temperature', 'District Cooling Outlet Temperature',\n 'District Heating Hot Water Rate', 'District Heating Mass Flow Rate',\n 'District Heating Inlet Temperature', 'District Heating Outlet Temperature']\n\n timeseries.each do |ts|\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,#{ts},Timestep;\").get\n end\n\n return result\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n # Request the day type to use in the peak demand window checks.\n result << OpenStudio::IdfObject.load('Output:Variable,*,Site Day Type Index,timestep;').get\n\n return result\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n # use the built-in error checking\n # if !runner.validateUserArguments(arguments(), user_arguments)\n # return false\n # end\n\n # log variable names\n out_var_names = []\n\n # HVAC equipment\n out_var_names << 'Boiler Heating Energy'\n out_var_names << 'Boiler Gas Energy'\n out_var_names << 'Chiller Evaporator Cooling Energy'\n out_var_names << 'Chiller Electric Energy'\n out_var_names << 'Cooling Coil Total Cooling Energy'\n out_var_names << 'Cooling Coil Electric Energy'\n out_var_names << 'Heating Coil Heating Energy'\n out_var_names << 'Heating Coil Electric Energy'\n out_var_names << 'Heating Coil Gas Energy'\n out_var_names << 'VRF Heat Pump COP'\n out_var_names << 'VRF Heat Pump Cooling COP'\n out_var_names << 'VRF Heat Pump Heating COP'\n out_var_names << 'VRF Heat Pump Cooling Electric Energy'\n out_var_names << 'VRF Heat Pump Heating Electric Energy'\n # out_var_names << 'Cooling Tower Fan Electric Energy'\n # out_var_names << 'Cooling Tower Fan Electric Power'\n # out_var_names << 'Cooling Tower Heat Transfer Rate'\n # out_var_names << 'Zone Water to Air Heat Pump Total Cooling Energy'\n # out_var_names << 'Zone Water to Air Heat Pump Total Heating Energy'\n # out_var_names << 'Zone Water to Air Heat Pump Electric Energy'\n\n # water heaters\n out_var_names << 'Water Heater Heating Energy'\n out_var_names << 'Water Heater Gas Energy'\n out_var_names << 'Water Heater Electric Energy'\n\n # refrigeration equipment\n out_var_names << 'Refrigeration System Total Compressor Electric Energy'\n out_var_names << 'Refrigeration System Total Transferred Load Heat Transfer Energy'\n out_var_names << 'Refrigeration System Total Cases and Walk Ins Heat Transfer Energy'\n out_var_names << 'Refrigeration Compressor Electric Energy'\n out_var_names << 'Refrigeration Compressor Heat Transfer Energy'\n out_var_names << 'Refrigeration System Condenser Heat Transfer Energy'\n out_var_names << 'Refrigeration System Condenser Fan Electric Energy'\n\n # request the variables\n out_var_names.each do |out_var_name|\n request = OpenStudio::IdfObject.load(\"Output:Variable,*,#{out_var_name},timestep;\").get\n result << request\n runner.registerInfo(\"Adding output variable for '#{out_var_name}' reporting timestep\")\n end\n\n return result\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n reporting_frequency = runner.getStringArgumentValue('reporting_frequency', user_arguments)\n\n # Request the output for each end use/fuel type combination\n end_uses.each do |end_use|\n end_use, = end_use\n fuel_types.each do |fuel_type|\n fuel_type, = fuel_type\n variable_name = if end_use == 'Facility'\n \"#{fuel_type}:#{end_use}\"\n else\n \"#{end_use}:#{fuel_type}\"\n end\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{variable_name},#{reporting_frequency};\").get\n end\n end\n\n # Create a custom meter for OtherFuels\n other_fuel_uses = ['HeatRejection', 'Heating', 'WaterSystems', 'InteriorEquipment']\n custom_meter_facility = 'Meter:Custom,OtherFuels:Facility,OtherFuel2'\n other_fuel_uses.each do |end_use|\n custom_meter = \"Meter:Custom,#{end_use}:OtherFuels,OtherFuel2\"\n other_fuels.each do |other_fuel|\n other_fuel = other_fuel.gsub(' ', '')\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{end_use}:#{other_fuel},#{reporting_frequency};\").get\n custom_meter_facility += \",,#{end_use}:#{other_fuel}\"\n custom_meter += \",,#{end_use}:#{other_fuel}\"\n end\n custom_meter += ';'\n result << OpenStudio::IdfObject.load(custom_meter).get\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{end_use}:OtherFuels,#{reporting_frequency};\").get\n end\n result << OpenStudio::IdfObject.load(\"#{custom_meter_facility};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter,OtherFuels:Facility,#{reporting_frequency};\").get\n\n # Request the output for each end use/fuel type combination\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Electricity:Facility,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,ElectricityProduced:Facility,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,NaturalGas:Facility,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,DistrictCooling:Facility,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,DistrictHeating:Facility,#{reporting_frequency};\").get\n\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Cooling:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Heating:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,InteriorLights:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,ExteriorLights:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,InteriorEquipment:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Fans:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Pumps:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,WaterSystems:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Heating:NaturalGas,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,WaterSystems:NaturalGas,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,InteriorEquipment:NaturalGas,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Heating Coil Heating Rate,hourly; !- HVAC Average [W];').get\n # result << OpenStudio::IdfObject.load(\"Output:Variable,*,Exterior Equipment:Electric Vehicles,#{reporting_frequency};\").get\n\n timeseries_data = ['District Cooling Chilled Water Rate', 'District Cooling Mass Flow Rate',\n 'District Cooling Inlet Temperature', 'District Cooling Outlet Temperature',\n 'District Heating Hot Water Rate', 'District Heating Mass Flow Rate',\n 'District Heating Inlet Temperature', 'District Heating Outlet Temperature', 'Cooling Coil Total Cooling Rate',\n 'Heating Coil Heating Rate', 'ExteriorEquipment:Electricity']\n\n tes_timeseries_data = ['Ice Thermal Storage End Fraction', 'Cooling coil Ice Thermal Storage End Fraction']\n\n ev_timeseries_data = ['Exterior Equipment:Electric Vehicles']\n\n timeseries_data += tes_timeseries_data\n\n timeseries_data.each do |ts|\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,#{ts},#{reporting_frequency};\").get\n end\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments, user_arguments)\n return result\n end\n\n return result\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n # Add output requests (consider adding to case hash instead of adding logic here)\n # this gather any non standard output requests. Analysis of output such as binning temps for FF will occur in reporting measure\n # Table 6-1 describes the specific day of results that will be used for testing\n hourly_variables = []\n\n # variables for all HE cases\n hourly_variables << 'Site Outdoor Air Drybulb Temperature'\n hourly_variables << 'Site Outdoor Air Wetbulb Temperature'\n hourly_variables << 'Site Outdoor Air Dewpoint Temperature'\n hourly_variables << 'Site Outdoor Air Enthalpy'\n hourly_variables << 'Site Outdoor Air Humidity Ratio'\n hourly_variables << 'Site Outdoor Air Relative Humidity'\n hourly_variables << 'Site Outdoor Air Density'\n hourly_variables << 'Site Outdoor Air Barometric Pressure'\n hourly_variables << 'Site Wind Speed'\n hourly_variables << 'Site Direct Solar Radiation Rate per Area'\n hourly_variables << 'Site Diffuse Solar Radiation Rate per Area'\n hourly_variables << 'Zone Mean Air Temperature'\n hourly_variables << 'Zone Air System Sensible Heating Energy'\n hourly_variables << 'Zone Air System Sensible Cooling Energy'\n hourly_variables << 'Zone Air Temperature,Hourly'\n hourly_variables << 'Zone Air Humidity Ratio'\n hourly_variables << 'Surface Inside face Temperature'\n hourly_variables << 'Surface Outside face Temperature'\n hourly_variables << 'Surface Inside Face Convection Heat Transfer Coefficient'\n hourly_variables << 'Surface Outside Face Convection Heat Transfer Coefficient'\n hourly_variables << 'Zone Air System Sensible Heating Energy'\n hourly_variables << 'Zone Air System Sensible Cooling Energy'\n hourly_variables << 'Zone Air Temperature'\n hourly_variables << 'Zone Total Internal Latent Gain Energy'\n hourly_variables << 'Zone Air Humidity Ratio'\n hourly_variables << 'Fan Electric Power'\n hourly_variables << 'Fan Rise in Air Temperature'\n hourly_variables << 'Fan Electric Energy'\n hourly_variables << 'Heating Coil Air Heating Energy'\n hourly_variables << 'Heating Coil Air Heating Rate'\n hourly_variables << 'Heating Coil Gas Energy'\n hourly_variables << 'Heating Coil Gas Rate'\n hourly_variables << 'Fan Runtime Fraction'\n hourly_variables << 'System Node Temperature'\n hourly_variables << 'System Node Mass Flow Rate'\n\n # parasitic heating coil output that represents draft fan\n hourly_variables << 'Heating Coil Electric Power'\n\n hourly_variables.each do |variable|\n result << OpenStudio::IdfObject.load(\"Output:Variable,,#{variable},hourly;\").get\n end\n\n result\n\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n \n result = OpenStudio::IdfObjectVector.new\n\n reporting_frequency = runner.getStringArgumentValue(\"reporting_frequency\",user_arguments)\n\n # Request the output for each end use/fuel type combination\n end_uses.each do |end_use|\n fuel_types.each do |fuel_type|\n variable_name = if end_use == 'Facility'\n \"#{fuel_type}:#{end_use}\"\n else\n \"#{end_use}:#{fuel_type}\"\n end\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{variable_name},#{reporting_frequency};\").get\n end\n end\n \n return result\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n reporting_frequency = runner.getStringArgumentValue(\"reporting_frequency\",user_arguments)\n inc_output_variables = runner.getBoolArgumentValue(\"inc_output_variables\",user_arguments)\n\n # Request the output for each end use/fuel type combination\n end_uses.each do |end_use|\n fuel_types.each do |fuel_type|\n variable_name = if end_use == 'Facility'\n \"#{fuel_type}:#{end_use}\"\n else\n \"#{end_use}:#{fuel_type}\"\n end\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{variable_name},#{reporting_frequency};\").get\n end\n end\n\n # Request the output for each end use subcategory/end use/fuel type combination\n end_use_subcats.each do |subcat|\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{subcat},#{reporting_frequency};\").get\n end\n\n # Request the output for each variable\n if inc_output_variables\n runner.registerInfo(\"Requesting Output Variables\")\n output_vars.each do |output_var|\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,#{output_var},#{reporting_frequency};\").get\n runner.registerInfo(\"Requesting Output:Variable,#{output_var},#{reporting_frequency};\")\n end\n end\n\n return result\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments, user_arguments)\n return result\n end\n\n # get the last model\n model = runner.lastOpenStudioModel\n if model.empty?\n puts 'Cannot find last model for output requests'\n runner.registerError('Cannot find last model.')\n return false\n end\n model = model.get\n\n run_qaqc = runner.getBoolArgumentValue('run_qaqc', user_arguments)\n unless run_qaqc\n return result\n end\n\n # Request output variables for air loop and plant loop supply outlet nodes\n variable_names = ['System Node Temperature', 'System Node Standard Density Volume Flow Rate']\n reporting_frequency = 'Timestep'\n node_names = []\n model.getAirLoopHVACs.each do |air_loop|\n node_names << air_loop.supplyOutletNode.name.to_s\n end\n model.getPlantLoops.each do |plant_loop|\n node_names << plant_loop.supplyOutletNode.name.to_s\n end\n node_names.uniq!\n node_names.each do |node_name|\n variable_names.each do |variable_name|\n result << OpenStudio::IdfObject.load(\"Output:Variable,#{node_name},#{variable_name},#{reporting_frequency};\").get\n end\n end\n\n # Request equipment part load ratios\n result << OpenStudio::IdfObject.load('Output:Variable,*,Boiler Part Load Ratio,Hourly;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Chiller Part Load Ratio,Hourly;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Cooling Tower Fan Electric Power,Hourly;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Cooling Coil Total Cooling Rate,Hourly;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Heating Coil Heating Rate,Hourly;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Heating Coil Air Heating Rate,Hourly;').get\n\n # Request the terminal reheat coil and terminal cooling rates for every VAV reheat terminal.\n model.getAirTerminalSingleDuctVAVReheats.each do |term|\n # Reheat coil heating rate\n rht_coil = term.reheatCoil\n rht_coil_name = rht_coil.name.get.to_s.upcase\n case rht_coil.iddObjectType.valueName.to_s\n when 'OS_Coil_Heating_Electric', 'OS_Coil_Heating_Gas'\n result << OpenStudio::IdfObject.load(\"Output:Variable,#{rht_coil_name},Heating Coil Air Heating Rate,Hourly;\").get\n when 'OS_Coil_Heating_Water'\n result << OpenStudio::IdfObject.load(\"Output:Variable,#{rht_coil_name},Heating Coil Heating Rate,Hourly;\").get\n end\n end\n\n # Zone Air Terminal Sensible Heating Rate\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,Zone Air Terminal Sensible Cooling Rate,Hourly;\").get\n\n # ventilation flow rates\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,Zone Mechanical Ventilation Standard Density Volume Flow Rate,#{reporting_frequency};\").get\n\n # Request the day type to use in the peak demand window checks.\n result << OpenStudio::IdfObject.load('Output:Variable,*,Site Day Type Index,timestep;').get\n\n return result\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n return OpenStudio::IdfObjectVector.new if runner.halted\n\n reporting_frequency = runner.getStringArgumentValue('reporting_frequency', user_arguments)\n include_enduse_subcategories = runner.getBoolArgumentValue('include_enduse_subcategories', user_arguments)\n output_variables = runner.getOptionalStringArgumentValue('output_variables', user_arguments)\n output_vars = []\n if output_variables.is_initialized\n output_vars = output_variables.get\n output_vars = output_vars.split(',')\n output_vars = output_vars.collect { |x| x.strip }\n end\n\n # get the last model and sql file\n model = runner.lastOpenStudioModel\n if model.empty?\n runner.registerError('Cannot find last model.')\n return false\n end\n model = model.get\n\n output_meters = OutputMeters.new(model, runner, reporting_frequency, include_enduse_subcategories)\n results = output_meters.create_custom_building_unit_meters\n\n output_vars.each do |output_var_item|\n if output_var_item.include? '|'\n output_var, key_val = output_var_item.split('|')\n else\n key_val = '*'\n output_var = output_var_item\n end\n results << OpenStudio::IdfObject.load(\"Output:Variable,#{key_val},#{output_var},#{reporting_frequency};\").get\n end\n\n results << OpenStudio::IdfObject.load(\"Output:Meter,Electricity:Facility,#{reporting_frequency};\").get\n\n return results\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(), user_arguments)\n return result\n end\n\n request = OpenStudio::IdfObject.load(\"Output:Variable,,Site Outdoor Air Drybulb Temperature,Hourly;\").get\n result << request\n\n return result\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n return OpenStudio::IdfObjectVector.new if runner.halted\n\n # get the last model and sql file\n model = runner.lastOpenStudioModel\n if model.empty?\n runner.registerError('Cannot find last model.')\n return false\n end\n model = model.get\n\n output_meters = OutputMeters.new(model, runner, 'Timestep', include_enduse_subcategories = true)\n results = output_meters.create_custom_building_unit_meters\n\n # heat transfer outputs\n OsLib_HeatTransfer.heat_transfer_outputs.each do |output|\n results << OpenStudio::IdfObject.load(\"Output:Variable,,#{output},Timestep;\").get\n end\n\n # supply outputs\n results << OpenStudio::IdfObject.load('Output:Variable,,Zone Air System Sensible Heating Energy,RunPeriod;').get\n results << OpenStudio::IdfObject.load('Output:Variable,,Zone Air System Sensible Cooling Energy,RunPeriod;').get\n\n return results\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n model = runner.lastOpenStudioModel\n if model.empty?\n runner.registerError('Cannot find OpenStudio model.')\n return false\n end\n model = model.get\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return result\n end\n\n output_vars = runner.getStringArgumentValue('output_vars', user_arguments).split(',')\n\n output_vars.each do |output_var|\n output_var.strip!\n if output_var == 'Wetbulb Globe Temperature'\n requests = wbgt_vars\n else\n requests = [output_var]\n end\n requests.each do |request|\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,#{request},Hourly;\").get\n end\n end\n\n return result\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n # assign the user inputs to variables\n args = OsLib_HelperMethods.createRunVariables(runner, @model, user_arguments, arguments)\n unless args\n return false\n end\n\n # only add terminalvariables if that check is enabled\n if args['check_simultaneous_heating_and_cooling']\n # get the last model\n model = runner.lastOpenStudioModel\n if model.empty?\n runner.registerError('Cannot find last model.')\n return false\n end\n model = model.get\n\n # Request the terminal reheat coil and\n # terminal cooling rates for every VAV\n # reheat terminal.\n model.getAirTerminalSingleDuctVAVReheats.each do |term|\n # Reheat coil heating rate\n rht_coil = term.reheatCoil\n result << OpenStudio::IdfObject.load(\"Output:Variable,#{rht_coil.name},Heating Coil Heating Rate,Hourly;\").get\n result << OpenStudio::IdfObject.load(\"Output:Variable,#{rht_coil.name},Heating Coil Air Heating Rate,Hourly;\").get\n\n # Zone Air Terminal Sensible Heating Rate\n result << OpenStudio::IdfObject.load(\"Output:Variable,ADU #{term.name},Zone Air Terminal Sensible Cooling Rate,Hourly;\").get\n end\n end\n\n return result\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n run_sim_settings_checks = runner.getBoolArgumentValue('run_sim_settings_checks', user_arguments)\n unless run_sim_settings_checks\n return result\n end\n\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,Site Day Type Index,Hourly;\").get\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,Site Daylight Saving Time Status,hourly;\").get\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,Site Outdoor Air Drybulb Temperature,timestep;\").get\n\n return result\n end",
"def get_all\n raise UnsupportedOperation\n end",
"def ole_methods\r\n @request.ole_methods\r\n end",
"def objects\n objects = []\n params[:format] = 'xml' unless params[:format]\n if !params[:overlap].nil? and params[:overlap] == \"true\" #if we want to include objects that can fall onto the edge of the range\n objects = Feature.find_in_range(params[:reference_id], params[:start], params[:end], params[:id])\n else #if we want to include only objects entirely within the range\n objects = Feature.find_in_range_no_overlap(params[:reference_id], params[:start], params[:end], params[:id])\n end\n objects.delete_if { |obj| obj.feature != params[:type] } if !params[:type].nil?\n #respond(objects, params[:format])\n respond objects\n end",
"def object_instances\n return [] if object_definition.blank?\n \n latest_version = ::AP::VoiceExtension::Voice::Config.instance.latest_version\n klazz = \"::#{latest_version.upcase}::#{object_definition.name}\".constantize\n query_scope = object_definition.query_scope\n objects = klazz.respond_to?(query_scope.to_sym) ? klazz.send(query_scope.to_sym) : []\n if objects.blank?\n return []\n else\n return objects\n end\n end",
"def features\n @inventory.features(self).to_a\n end",
"def enemy_fleet()\n enemy_fleet = Array.new\n for count in 1..6 do \n enemy_fleet.push(Ship.new(generateHull, generateFirepower, generateAccuracy))\n end\n return enemy_fleet\nend",
"def requests\n @requests_obj.list\n end",
"def features\n @features ||= Features.from_grpc @grpc\n end",
"def all\n response = RestClient::Request.execute({\n url: \"https://#{connection.path}/apiv1/Get\",\n method: :get,\n verify_ssl: false,\n headers: { params: { typeName: geotab_reference_name, credentials: connection.credentials, search: formatted_conditions }}\n })\n\n body = MultiJson.load(response.body).to_ostruct_recursive\n\n if MultiJson.load(response.body).has_key?(\"error\")\n if body.error.errors.first.message.start_with?(\"Incorrect MyGeotab login credentials\")\n raise IncorrectCredentialsError, body.error.errors.first.message\n else\n raise ApiError, body.error.errors.first.message\n end\n else\n attributes = body.result\n results = []\n\n if attributes && attributes.any?\n attributes.each do |result|\n results.push(new(result, connection))\n end\n end\n\n reset\n\n results\n end\n end",
"def getObjects\n readObjects\n\n return @Objects\n end",
"def operations()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Operations::OperationsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def functions()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::FunctionsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def get_all()\n raise \"Must be overridden\"\n end",
"def additions\n Array(@gapi.additions).map { |gapi| Record.from_gapi gapi }\n end",
"def objects; end",
"def feature_set\n @inventory.features(self)\n end",
"def index\n @energies = Energy.all\n end",
"def get_objects(target_class, table_name, inclusive = false)\n answer = Array.new\n\n coord_system_ids_with_features = nil\n # Get all the coord_systems with this type of features on them\n if Collection.check\n coord_system_ids_with_features = Collection.find_all_coord_by_table_name(table_name,self.seq_region.coord_system.species_id).collect{|mc| mc.coord_system_id}\n else\n coord_system_ids_with_features = MetaCoord.find_all_by_table_name(table_name).collect{|mc| mc.coord_system_id}\n end \n # Get the features of the original slice\n if coord_system_ids_with_features.include?(self.seq_region.coord_system_id)\n sql = ''\n if inclusive\n sql = <<SQL\nSELECT * FROM #{table_name}\nWHERE seq_region_id = #{self.seq_region.id.to_s}\nAND (( seq_region_start BETWEEN #{self.start.to_s} AND #{self.stop.to_s} )\nOR ( seq_region_end BETWEEN #{self.start.to_s} AND #{self.stop.to_s} )\nOR ( seq_region_start <= #{self.start.to_s} AND seq_region_end >= #{self.stop.to_s} )\n )\nSQL\n else\n sql = <<SQL\nSELECT * FROM #{table_name}\nWHERE seq_region_id = #{self.seq_region.id.to_s}\nAND seq_region_start >= #{self.start.to_s}\nAND seq_region_end <= #{self.stop.to_s} \nSQL\n end\n answer.push(target_class.find_by_sql(sql))\n coord_system_ids_with_features.delete(self.seq_region.coord_system_id)\n end\n\n # Transform the original slice to other coord systems and get those\n # features as well. At the moment, only 'direct' projections can be made.\n # Later, I'm hoping to add functionality for following a path from one\n # coord_system to another if they're not directly linked in the assembly\n # table.\n coord_system_ids_with_features.each do |target_coord_system_id|\n target_slices = self.project(CoordSystem.find(target_coord_system_id).name)\n target_slices.each do |slice|\n if slice.class == Slice\n if inclusive\n sql = <<SQL\nSELECT * FROM #{table_name}\nWHERE seq_region_id = #{slice.seq_region.id.to_s}\nAND (( seq_region_start BETWEEN #{slice.start.to_s} AND #{slice.stop.to_s} )\nOR ( seq_region_end BETWEEN #{slice.start.to_s} AND #{slice.stop.to_s} )\nOR ( seq_region_start <= #{slice.start.to_s} AND seq_region_end >= #{slice.stop.to_s} )\n )\nSQL\n else\n sql = <<SQL\nSELECT * FROM #{table_name}\nWHERE seq_region_id = #{slice.seq_region.id.to_s}\nAND seq_region_start >= #{slice.start.to_s}\nAND seq_region_end <= #{slice.stop.to_s} \nSQL\n end \n answer.push(target_class.find_by_sql(sql))\n end\n end\n end\n\n answer.flatten!\n answer.uniq!\n\n return answer\n end",
"def list_api\n return self.sendcmd(\"fldigi.list\")\n end",
"def all_features\r\n feature_objects.inject([]) {|r, obj| r + obj.features }\r\n end",
"def newDemandListForCycle()\n list = @innerFactory.newDemandListForCycle() ;\n list.each{|demand|\n selectParty().allocDemand(demand) ;\n }\n \n return list ;\n end",
"def allergens\n allergy_instances = Allergy.all.select do |allergy|\n self.ingredients.include?(allergy.ingredient)\n end \n end",
"def index\n @acquired_energies = AcquiredEnergy.all\n end",
"def get_results\n raise NotImplementedError.new\n end",
"def OPCItems()\r\n ret = _getproperty(0, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def OPCItems()\r\n ret = _getproperty(0, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def array\n self.allObjects\n end",
"def requests\n @requests ||= EbanqApi::Requests.new(self)\n end",
"def objects\n @objects ||= []\n end",
"def services()\n return MicrosoftGraph::Print::Services::ServicesRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def features\n validate_loaded\n resource = FEATURES % { id: @id }\n response = Request.new(client, :get, resource).perform\n response.body[:data]\n end",
"def requests\n REQUESTS\n end",
"def all(options = nil)\n request = Request.new(@client)\n path = \"/products\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n a = Array.new\n body = response.body\n for v in body['products']\n tmp = Product(@client)\n tmp.fill_with_data(v)\n a.push(tmp)\n end\n\n return_values.push(a)\n \n\n \n return_values[0]\n end",
"def my_requests()\n request_array = []\n self.problems.each do |problem|\n Request.where({ problem_id: problem.id}).each do |request|\n request_array.push(request)\n end\n end\n request_array\n end",
"def objects\n @objects ||= []\n end",
"def index\n @feature_requests = FeatureRequest.all\n end",
"def power()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Power::PowerRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def info_service\n @info_service ||= GeoWorks::Derivatives::Processors::Vector::Info.new(dataset_path)\n end",
"def get_objects(target_class, table_name, inclusive = false)\r\n answer = Array.new\r\n\r\n \r\n # Get all the coord_systems with this type of features on them\r\n coord_system_ids_with_features = MetaCoord.find_all_by_table_name(table_name).collect{|mc| mc.coord_system_id}\r\n\r\n # Get the features of the original slice\r\n if coord_system_ids_with_features.include?(self.seq_region.coord_system_id)\r\n sql = ''\r\n if inclusive\r\n sql = <<SQL\r\nSELECT * FROM #{table_name}\r\nWHERE seq_region_id = #{self.seq_region.id.to_s}\r\nAND (( seq_region_start BETWEEN #{self.start.to_s} AND #{self.stop.to_s} )\r\nOR ( seq_region_end BETWEEN #{self.start.to_s} AND #{self.stop.to_s} )\r\nOR ( seq_region_start <= #{self.start.to_s} AND seq_region_end >= #{self.stop.to_s} )\r\n )\r\nSQL\r\n else\r\n sql = <<SQL\r\nSELECT * FROM #{table_name}\r\nWHERE seq_region_id = #{self.seq_region.id.to_s}\r\nAND seq_region_start >= #{self.start.to_s}\r\nAND seq_region_end <= #{self.stop.to_s} \r\nSQL\r\n end\r\n answer.push(target_class.find_by_sql(sql))\r\n coord_system_ids_with_features.delete(self.seq_region.coord_system_id)\r\n end\r\n\r\n # Transform the original slice to other coord systems and get those\r\n # features as well. At the moment, only 'direct' projections can be made.\r\n # Later, I'm hoping to add functionality for following a path from one\r\n # coord_system to another if they're not directly linked in the assembly\r\n # table.\r\n coord_system_ids_with_features.each do |target_coord_system_id|\r\n target_slices = self.project(CoordSystem.find(target_coord_system_id).name)\r\n target_slices.each do |slice|\r\n if slice.class == Slice\r\n if inclusive\r\n sql = <<SQL\r\nSELECT * FROM #{table_name}\r\nWHERE seq_region_id = #{slice.seq_region.id.to_s}\r\nAND (( seq_region_start BETWEEN #{slice.start.to_s} AND #{slice.stop.to_s} )\r\nOR ( seq_region_end BETWEEN #{slice.start.to_s} AND #{slice.stop.to_s} )\r\nOR ( seq_region_start <= #{slice.start.to_s} AND seq_region_end >= #{slice.stop.to_s} )\r\n )\r\nSQL\r\n else\r\n sql = <<SQL\r\nSELECT * FROM #{table_name}\r\nWHERE seq_region_id = #{slice.seq_region.id.to_s}\r\nAND seq_region_start >= #{slice.start.to_s}\r\nAND seq_region_end <= #{slice.stop.to_s} \r\nSQL\r\n end \r\n answer.push(target_class.find_by_sql(sql))\r\n end\r\n end\r\n end\r\n\r\n answer.flatten!\r\n answer.uniq!\r\n\r\n return answer\r\n end",
"def requests\n\t\tRequest.find(:all)\n\tend",
"def request_problems()\n problem_array = []\n self.requests.each do |request|\n problem_array.push(Problem.find(request.problem_id))\n end\n problem_array\n end",
"def request_elements\n REQUEST_ELEMENTS\n end",
"def product_list()\n $tracer.trace(__method__)\n return GameStopProductList.new(ToolTag.new(div.className(create_ats_regex_string(\"products\")).div.className(\"/^product$/\"), __method__), self)\n end",
"def info_service\n GeoDerivatives::Processors::Vector::Info.new(@dataset_path)\n end",
"def get_enterable_products\n return call('Product.get_enterable_products')\n end",
"def retrieve_collection\n\n #same as query in products index, query_raw_material_with_relationship, should move to cmd ?\n special_type = ['seeds', 'purchased_clones']\n raw_material_ids = if special_type.include?(type)\n #find parent only one\n Inventory::Catalogue.raw_materials.where(\n key: type,\n ).pluck(:id)\n else\n #find catalogue for other than parent, parent will never have category type\n Inventory::Catalogue.raw_materials.where(\n category: type,\n ).pluck(:id)\n end\n\n if resource_shared?\n item_transactions = Inventory::ItemTransaction.includes(:catalogue, :facility, :facility_strain).where(\n :facility_id.in => @user.facilities,\n :event_type.in => @event_types,\n :catalogue_id.in => raw_material_ids,\n ).order(c_at: :desc)\n else\n item_transactions = Inventory::ItemTransaction.includes(:catalogue, :facility, :facility_strain).where(\n :facility_id => @facility_id,\n :event_type.in => @event_types,\n :catalogue_id.in => raw_material_ids,\n ).order(c_at: :desc)\n end\n\n vi_item_ids = item_transactions.\n where(ref_type: 'Inventory::VendorInvoiceItem').pluck(:ref_id)\n vendor_invoice_items = Inventory::VendorInvoiceItem.\n includes(:invoice).\n in(id: vi_item_ids)\n\n {\n item_transactions: item_transactions,\n vendor_invoice_items: vendor_invoice_items.to_a,\n }\n end",
"def get_requests\n @requests\n end",
"def product()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Product::ProductRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def get_glade_all(obj = self)\r\n get_glade_active_record(obj)\r\n get_glade_variables(obj)\r\n end",
"def results\n raise NotImplementedError\n end",
"def get_drivers\n return return_all_drivers\n end",
"def get_station_data(qty = 10)\n filter = { zip: @zip, limit: qty}\n EnergyService.new(filter).get_stations[:fuel_stations]\n end",
"def get_all\n @data\n end",
"def instances #:nodoc:\n r = []\n ObjectSpace.each_object(self) { |mod| r << mod }\n r\n end",
"def data\n fail NoMethodError, \"Engines need this method defined\"\n end",
"def flight_legs\n extract_flightlegs.map do |leg|\n PackageFlightLeg.new(leg)\n end\n end",
"def data\n raise NoMethodError, \"Engines need this method defined\"\n end",
"def list\n raise NotImplementedError\n end",
"def all_objects; end",
"def all\n @service.all\n end",
"def dproduct()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Dproduct::DproductRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def requests\n\t\tWmapRequest.find(:all)\n\tend",
"def objects\n return @objects unless @objects.nil?\n objs = []\n dict = @instance.getDictionary\n (0 ... dict.getChildCount).each do |i|\n obj = dict.getChildAt(i)\n objs << {\n :name => obj.getName,\n :qual => obj.getQualification.toString.downcase.to_sym,\n :type => obj.getType.toString.downcase.to_sym,\n :object => obj,\n }\n end\n @objects = objs\n end",
"def ship_object_creator()\n ship_object = []\n 2.times do |x|\n x = Ship.new(5,(x+1))\n ship_object << x\n end\n return ship_object\nend",
"def get_item_requests()\n @item_requests.values\n end",
"def methods\n main_service.methods.select(&:can_generate_rest?)\n end",
"def object\n @elements.map { |element| element.object }\n end",
"def exp()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Exp::ExpRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def get_objects(syncer, query, status)\n\t\traise \"getObjects: Not Implemented\"\n\t\t\n\t\t# object_list = []\n\t\t# #for each object that matches the query\n\t\t# # object = an active record database object that contains the information from the store object\n\t\t# # store_object_id = the object_id of the store object\n\t\t# object.set_dbID(syncer, self, store_object_id)\n\t\t# object_list.push(object)\n\t\t# #end\n\t\t# return object_list\n\tend",
"def index\n @request_services = RequestService.all\n end",
"def perform_request_with_objects(request_method, path, options, klass)\n perform_request(request_method, path, options).collect do |element|\n klass.new(element)\n end\n end",
"def requesters\n @requesters_arr = []\n current_user= User.where(id: self.id)\n requesters = current_user[0].friendship_requests\n requesters.each do |r|\n @requesters_arr.push(r.friendee)\n end\n\n @requesters_arr\n \n\n end",
"def software_oath_methods\n return @software_oath_methods\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = ElectricityUseResultSet.new(resp)\n return results\n end",
"def featured_offers_and_deals_list\n $tracer.trace(__method__)\n return GameStopProductContainerList.new(ToolTag.new(div.className(create_ats_regex_string(\"featuredoff\")).a.id(\"/aImageUrl/\"), __method__), self)\n end",
"def invokables\n []\n end",
"def instances\n Egi::Fedcloud::Vmhound::Log.info \"[#{self.class}] Retrieving active instances\"\n fetch_instances\n end",
"def folio_requests\n @patron_info['holds'].map { |request| Request.new(request) }\n end",
"def make_item_list\n @data = $game_temp.forge_shop.products\n end",
"def list_operations()\n\t\treturn @service.operations\n\tend",
"def objects\n @objects ||= []\n end",
"def all\n data = []\n if @ec2_main.settings.openstack \n conn = @ec2_main.environment.connection\n if conn != nil\n begin \n x = conn.flavors.all\n x.each do |y|\n vcpu = nil\n begin \n vcpu = y.vcpus\n rescue\n vcpu = nil \n end\n if vcpu != nil \n data.push(\"#{y.id} (#{y.name} Mem: #{y.ram}MB Disk: #{y.disk}GB VCPU: #{y.vcpus}VCPUs)\")\n else\n data.push(\"#{y.id} (#{y.name} Mem: #{y.ram}MB Disk: #{y.disk}GB)\") \n end\n end\n rescue\n puts \"ERROR: getting all flavors #{$!}\"\n end\n else \n raise \"Connection Error\" \n end \n elsif @ec2_main.settings.google \n conn = @ec2_main.environment.connection\n if conn != nil\n begin \n response = conn.list_machine_types($google_zone)\n\t\t\t if response.status == 200\n\t x = response.body['items']\n\t x.each do |r|\n\t\t\t\t data.push(\"#{r['name']} ( Mem: #{r['memoryMb']}MB Disks: #{r['maximumPersistentDisks']} Disk Size: #{r['maximumPersistentDisksSizeGb']}GB CPUs: #{r['guestCpus']})\")\n \t end\n\t else\n\t \t data = []\n end\n rescue\n puts \"ERROR: getting all flavors #{$!}\"\n end\n else \n raise \"Connection Error\" \n end \t\t\n\t else \n data.push('t1.micro (EBS only Micro 32 or 64-bit, 613 MB, up to 2 compute unit)') \n data.push('m1.small (Small 32 or 64-bit, 1.7 GB, 1 compute unit)')\n data.push('m1.medium (Medium 32 or 64-bit, 3.75 GB, 2 compute unit)')\n data.push('m1.large (Large 64-bit, 7.5 GB, 4 compute unit)')\n data.push('m1.xlarge (Extra Large 64-bit, 15 GB, 8 compute unit)')\n data.push('m3.xlarge (EBS Only Extra Large 64-bit, 15 GB, 13 compute unit)')\n data.push('m3.2xlarge (EBS Only Extra Double Large 64-bit, 30 GB, 26 compute unit)')\n data.push('m2.xlarge (High Memory Extra Large 64-bit, 17.1 GB, 6.5 compute unit)')\n data.push('m2.2xlarge (High Memory Double Extra Large 64-bit, 34.2 GB, 13 compute unit)')\n data.push('m2.4xlarge (High Memory Quadruple Large 64-bit, 68.4 GB, 26 compute unit)')\n data.push('c1.medium (Compute optimized CPU Medium 32 or 64-bit, 1.7 GB, 5 compute unit)')\n data.push('c1.xlarge (Compute optimized CPU Extra Large 64-bit, 7 GB, 20 compute unit)')\n data.push('c3.xlarge (Compute optimized Extra Large 64-bit, 3.75 GB, 7 compute unit)')\n data.push('c3.2xlarge (Compute optimized Double Extra Large 64-bit, 7 GB, 14 compute unit)')\n data.push('c3.4xlarge (Compute optimized Quadruple Large 64-bit, 15 GB, 28 compute unit)')\t\n data.push('c3.8xlarge (Compute optimized Eight Large 64-bit, 30 GB, 55 compute unit)')\n data.push('i2.xlarge\t\t (High I/O 1x800 GB SSD, 30.5 GB, 14 compute unit)')\n data.push('i2.2xlarge\t\t (High I/O 2x800 GB SSD, 61 GB, 27 compute unit)')\n data.push('i2.4xlarge\t\t (High I/O 4x800 GB SSD, 122 GB, 53 compute unit)')\n data.push('i2.8xlarge\t \t (High I/O 8x800 GB SSD, 244 GB, 104 compute unit)')\t\t \n data.push('cc1.4xlarge (Cluster Compute Quadruple Extra Large 64-bit, 23 GB, 33.5 compute unit. 10GBit network)')\n data.push('cc2.8xlarge (Cluster Compute Eight Extra Large 64-bit, 60.5 GB, 88 compute unit. 10GBit network)')\n\t\t data.push('g2.2xlarge (Cluster GPU Quadruple Extra Large 64-bit, 15 GB, 26compute unit.)') \n data.push('cg1.4xlarge (Cluster GPU Quadruple Extra Large 64-bit, 22 GB, 33.5 compute unit. 10GBit network)') \n data.push('hi1.4xlarge (High I/O Quadruple Extra Large 64-bit, 60.5 GB, 2x1024GB SSD, 35 compute unit. 10GBit network)')\n\t\t data.push('hs1.8xlarge (High I/O Quadruple Extra Large 64-bit, 117 GB, 24x2048GB SSD, 35 compute unit. 10GBit network)')\n \t\t\n end \n return data\n end",
"def instances\n end",
"def consumed_services\n\t\t\t\tdescription.consumed_services\n\t\t\tend",
"def get_all_products\n # Get all the products\n @server.call(\"call\", @session_id, \"catalog_product.list\")\n rescue XMLRPC::FaultException => exception\n return exception\n end"
] | [
"0.6318877",
"0.6308563",
"0.6292341",
"0.6276216",
"0.6094002",
"0.6020391",
"0.5965369",
"0.5955979",
"0.59372544",
"0.5885784",
"0.5860911",
"0.58062977",
"0.57539207",
"0.56363034",
"0.5428969",
"0.540341",
"0.53108454",
"0.5246608",
"0.5240743",
"0.5231769",
"0.52304673",
"0.51305515",
"0.5109133",
"0.5078765",
"0.5075219",
"0.5060627",
"0.50425786",
"0.5037567",
"0.5030298",
"0.50226134",
"0.50021344",
"0.49837628",
"0.49567133",
"0.4953537",
"0.49353015",
"0.49029046",
"0.4864722",
"0.48602742",
"0.48552552",
"0.48506978",
"0.48506978",
"0.48403284",
"0.48356277",
"0.4831302",
"0.48287255",
"0.48228478",
"0.48160294",
"0.48155376",
"0.4800497",
"0.4796617",
"0.47856465",
"0.47833854",
"0.47766954",
"0.4776274",
"0.47761258",
"0.4775914",
"0.47751465",
"0.47724465",
"0.47724044",
"0.47644153",
"0.47607931",
"0.47606114",
"0.47587982",
"0.475641",
"0.47418863",
"0.47410086",
"0.47391513",
"0.47388202",
"0.4735847",
"0.47345692",
"0.47330132",
"0.47320497",
"0.47268093",
"0.47224677",
"0.47188035",
"0.4714203",
"0.47134277",
"0.47109902",
"0.4710877",
"0.4710544",
"0.47057703",
"0.46927962",
"0.46922514",
"0.46868104",
"0.46800023",
"0.46781",
"0.46754596",
"0.46744773",
"0.46703312",
"0.4656166",
"0.4655267",
"0.4651208",
"0.46483898",
"0.4643835",
"0.46435216",
"0.4641423",
"0.46372038",
"0.4636031",
"0.463166",
"0.46310887"
] | 0.5924496 | 9 |
define what happens when the measure is run | def run(runner, user_arguments)
super(runner, user_arguments)
# use the built-in error checking
if !runner.validateUserArguments(arguments, user_arguments)
return false
end
# get the last model and sql file
model = runner.lastOpenStudioModel
if model.empty?
runner.registerError('Cannot find last model.')
return false
end
model = model.get
sql_file = runner.lastEnergyPlusSqlFile
if sql_file.empty?
runner.registerError('Cannot find last sql file.')
return false
end
sql_file = sql_file.get
model.setSqlFile(sql_file)
output_manager = OutputManager.new(model, sql_file)
output_manager.hydrate
json_out = File.open("../loads_out.json", "w")
json_out.write(output_manager.to_json)
# close the sql file
sql_file.close
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def measure; end",
"def measure=(_arg0); end",
"def measure\n\t\t1\n\tend",
"def measure(*args, &b)\n end",
"def communicate_measure_result(_ = nil, _ = nil); end",
"def communicate_measure_result(_ = nil, _ = nil); end",
"def called\n self.measurement.called\n end",
"def measure\n start = Time.now\n yield\n Time.now - start\n end",
"def measure\n start = Time.now\n yield\n Time.now - start\n end",
"def measure\n Measure.new(1, self)\n end",
"def measurement(n)\n @options[:before_hook].call(n)\n measure = measure(n, &@options[:fn])\n @options[:after_hook].call(n)\n measure\n end",
"def measure\n Measure.new(@counter+=1)\n end",
"def communicate_measure_result(_ = nil, _ = nil)\r\n end",
"def benchmark\nend",
"def calculated; end",
"def setup_metrics\n end",
"def setup_metrics\n end",
"def setup_metrics\n end",
"def run()\n\t\tputs \"#{@name} ran for #{@meters} meters in #{self.getTimeLapse} seconds\"\n\t\t# chiama funzione per stampare quante volte ha respirato\n\t\tself.breathe\n\tend",
"def runs; end",
"def statistics; end",
"def medical_use; end",
"def measure\n start_real = System.monotonic_time\n start_cpu = System.cpu_time\n retval = yield\n\n real_time = System.monotonic_time - start_real\n cpu_time = System.cpu_time - start_cpu\n\n @real_time += real_time\n @cpu_time += cpu_time\n @call_count += 1\n\n if call_measurement_enabled? && above_threshold?\n self.class.call_duration_histogram.observe(@transaction.labels.merge(labels), real_time / 1000.0)\n end\n\n retval\n end",
"def stats; end",
"def stats; end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n\n percent_runtime_reduction = runner.getDoubleArgumentValue(\"percent_runtime_reduction\",user_arguments)\n\n \n \n # Check arguments for reasonableness\n if percent_runtime_reduction >= 100\n runner.registerError(\"Percent runtime reduction must be less than 100.\")\n return false\n end\n\n # Find all the original schedules (before occ sensors installed)\n original_lts_schedules = []\n model.getLightss.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end \n\n # Make copies of all the original lights schedules, reduced to include occ sensor impact\n original_schs_new_schs = {}\n original_lts_schedules.uniq.each do |orig_sch|\n # Copy the original schedule\n new_sch = orig_sch.clone.to_ScheduleRuleset.get\n new_sch.setName(\"#{new_sch.name.get} with occ sensor\")\n # Reduce each value in each profile (except the design days) by the specified amount\n runner.registerInfo(\"Reducing values in '#{orig_sch.name}' schedule by #{percent_runtime_reduction}% to represent occ sensor installation.\")\n day_profiles = []\n day_profiles << new_sch.defaultDaySchedule\n new_sch.scheduleRules.each do |rule|\n day_profiles << rule.daySchedule\n end\n multiplier = (100 - percent_runtime_reduction)/100\n day_profiles.each do |day_profile|\n #runner.registerInfo(\"#{day_profile.name}\")\n times_vals = day_profile.times.zip(day_profile.values)\n #runner.registerInfo(\"original time/values = #{times_vals}\")\n times_vals.each do |time,val|\n day_profile.addValue(time, val * multiplier)\n end\n #runner.registerInfo(\"new time/values = #{day_profile.times.zip(day_profile.values)}\")\n end \n #log the relationship between the old sch and the new, reduced sch\n original_schs_new_schs[orig_sch] = new_sch\n end\n \n # Replace the old schedules with the new, reduced schedules\n spaces_sensors_added_to = []\n model.getLightss.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n \n # Report if the measure is not applicable\n num_sensors_added = spaces_sensors_added_to.uniq.size\n if spaces_sensors_added_to.size == 0\n runner.registerAsNotApplicable(\"This measure is not applicable because there were no lights in the building.\")\n return true\n end \n \n # Report final condition\n runner.registerFinalCondition(\"Added occupancy sensors to #{num_sensors_added} spaces in the building.\")\n\n return true\n\n end",
"def run\n\t\t\tsummary\n\t\tend",
"def quick_stats\n\tend",
"def stats\n \n end",
"def benchmark(reporter); end",
"def stats\n end",
"def stats\n end",
"def measure(name, &block)\n if self.running? name\n yield\n else\n result = nil\n self.results[name] ||= 0\n self.running << name\n self.results[name] += Benchmark.measure{result = yield}.real\n self.running.delete(name)\n result\n end\n end",
"def measure\n start_real = System.monotonic_time\n start_cpu = System.cpu_time\n retval = yield\n\n real_time = System.monotonic_time - start_real\n cpu_time = System.cpu_time - start_cpu\n\n @real_time += real_time\n @cpu_time += cpu_time\n @call_count += 1\n\n if above_threshold?\n self.class.gitlab_method_call_duration_seconds.observe(@transaction.labels.merge(labels), real_time)\n end\n\n retval\n end",
"def measure_code(model,runner)\n measure_folder = \"#{File.dirname(__FILE__)}/\"\n baseline_spreadsheet = \"#{File.dirname(__FILE__)}/baseline.csv\"\n #Note: place output folder locally to run faster! (e.g. your C drive)\n output_folder = \"#{File.dirname(__FILE__)}/tests/output\"\n create_models = true\n simulate_models = true\n create_annual_outputs = true\n create_hourly_outputs = true\n #This creates the measures object and collects all the csv information for the\n # measure_id variant.\n csv_measures = BTAP::Measures::CSV_OS_Measures.new(\n baseline_spreadsheet,\n measure_folder#script root folder where all the csv relative paths are used.\n )\n csv_measures.create_cold_lake_vintages(output_folder) unless create_models == false\n BTAP::SimManager::simulate_all_files_in_folder(output_folder) unless simulate_models == false\n BTAP::Reporting::get_all_annual_results_from_runmanger(output_folder) unless create_annual_outputs == false\n #convert eso to csv then create terminus file.\n BTAP::FileIO::convert_all_eso_to_csv(output_folder, output_folder).each {|csvfile| BTAP::FileIO::terminus_hourly_output(csvfile)} unless create_hourly_outputs == false\n\n end",
"def cpu_metrics\n super\n end",
"def instrument; end",
"def profiler; end",
"def profiler; end",
"def setup\n\t\n # create an instance of the measure\n @measure = VentilationQAQC.new\n \n #create an instance of the runner\n @runner = OpenStudio::Ruleset::OSRunner.new\t\n\t\n # get arguments \n @arguments = @measure.arguments()\n\n # make argument map\n make_argument_map\n\t\n # Make an empty model\n @model = OpenStudio::Model::Model.new\n\t@runner.setLastOpenStudioModel(@model)\n\t\n\t# Create a fake sql file - our measure will crash if @runner has no sql file set.\n\t# We don't get data from this file because we get data from our patched SqlFile class instead (see above)\n\tsqlFile = OpenStudio::SqlFile.new(OpenStudio::Path.new(sqlPath))\n\t@runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sqlPath))\n\t\n\t$serieses[\"Zone Mechanical Ventilation Mass Flow Rate|ZONE1\"] = OpenStudio::TimeSeries.new(OpenStudio::Date.new, OpenStudio::Time.new(1.0), (0..364).to_a.to_vector, \"m^3/s\")\n end",
"def monitor(*args, &bl)\n result = nil\n took = Benchmark.realtime {\n result = bl.call\n }\n Tools.info(args, op_took: took)\n result\n end",
"def measure_code(model,runner)\n ################ Start Measure code here ################################\n \n #Check weather directory Weather File\n unless (Pathname.new @lib_directory).absolute?\n @lib_directory = File.expand_path(File.join(File.dirname(__FILE__), @lib_directory))\n end\n lib_file = File.join(@lib_directory, @lib_file_name)\n if File.exists?(lib_file) and @lib_file_name.downcase.include? \".osm\"\n BTAP::runner_register(\"Info\",\"#{@lib_file_name} Found!.\", runner)\n else\n BTAP::runner_register(\"Error\",\"#{lib_file} does not exist or is not an .osm file.\", runner)\n return false\n end\n \n #load model and test.\n construction_set = BTAP::Resources::Envelope::ConstructionSets::get_construction_set_from_library( lib_file, @construction_set_name )\n #Set Construction Set.\n unless model.building.get.setDefaultConstructionSet( construction_set.clone( model ).to_DefaultConstructionSet.get )\n BTAP::runner_register(\"Error\",\"Could not set Default Construction #{@construction_set_name} \", runner)\n return false\n end\n BTAP::runner_register(\"FinalCondition\",\"Default Construction set to #{@construction_set_name} from #{lib_file}\",runner)\n ##########################################################################\n return true\n end",
"def run(workspace, runner, user_arguments)\n super(workspace, runner, user_arguments)\n\n # use the built-in error checking \n if !runner.validateUserArguments(arguments(workspace), user_arguments)\n return false\n end\n \n # Report that this is an anti-measure\n runner.registerValue('anti_measure',true) \n \n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n \n\t# Initialize counter variables\n\tno_economizer = 0\n\tfixed_dry_bulb = 0\n\tdifferential_dry_bulb = 0\t\n\tfixed_enthalpy = 0\n\tdifferential_enthalpy = 0\n\tfixed_dew_point_and_dry_bulb = 0\n\telectronic_enthalpy = 0\n\tdifferential_dry_bulb_and_enthalpy = 0\n\t\n\t# Retrieve all Controller:Outdoor air objects in the idf \t\n\toa_controllers = workspace.getObjectsByType(\"Controller:OutdoorAir\".to_IddObjectType)\n\t\n\t# Get the names of each Controller:Outdoor Air object\n\toa_controllers.each do |oa_controller|\n\n\t\toa_controller_name = oa_controller.getString(0).to_s #(0) is field Name\n\t\toa_controller_economizer_control_type = oa_controller.getString(7).to_s #(7) is field Economizer Control Type\n\t\n\t\t# test for presence No economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"NoEconomizer\" # or empty\n\t\t\trunner.registerInfo(\"The Controller:Outdoor air object named #{oa_controller_name} has a disabled airside economizer. Economizer sensor faults will not be added.\")\n\t\t\tno_economizer = no_economizer + 1\n\t\tend\n\t\t\n\t\t# test for presence of differential dry bulb economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"DifferentialDryBulb\"\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir \n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\tdifferential_dry_bulb = differential_dry_bulb + 1\n\t\t\t# info message\n\t\t\trunner.registerInfo(\"To model dry bulb sensor drift, a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg F has been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\t\n\n\t\tend # OA Controller Type DifferentialDryBulb\n\n\t\t# test for presence of fixed dry bulb economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"FixedDryBulb\"\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\trunner.registerInfo(\"To model dry bulb sensor drift, a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg F has been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tfixed_dry_bulb = fixed_dry_bulb + 1\n\t\t\t\n\t\tend # OA Controller Type = FixedDryBulb \t\t\n\t\t\n\t\t# test for presence of fixed enthalpy economizer controller setting \t\t\t\t\n\t\tif oa_controller_economizer_control_type == \"FixedEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\twworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model enthalpy sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tfixed_enthalpy = fixed_enthalpy + 1\n\t\tend # OA Controller Type = FixedEnthalpy \n\t\t\n\t\t# test for presence of differential enthalpy economizer controller setting \t\t\n\t\tif oa_controller_economizer_control_type == \"DifferentialEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model enthalpy sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tdifferential_enthalpy = differential_enthalpy + 1\n\t\t\t\n\t\tend # OA Controller Type =\"Differential Enthalpy\"\t\t\n\t\t\n\t\n\t\t# test for presence of electronic enthalpy economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"ElectronicEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model enthalpy sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\telectronic_enthalpy = electronic_enthalpy + 1\n\n\t\tend # OA Controller Type = \"ElectronicEnthalpy\" \t\t\n\t\t\n\t\t# test for presence of fixed dew point and dry bulb economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"FixedDewPointAndDryBulb\" \n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model both enthalpy and dry bulb sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb and a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tfixed_dew_point_and_dry_bulb = fixed_dew_point_and_dry_bulb + 1\n\n\t\tend # OA Controller Type = \"FixedDewPointAndDryBulb\" \n\t\n\t\t# test for presence of differential dry bulb and enthalpy economizer controller setting \t\t\n\t\tif oa_controller_economizer_control_type == \"DifferentialDryBulbAndEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\t\t\t\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model both enthalpy and dry bulb sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb and a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tdifferential_dry_bulb_and_enthalpy = differential_dry_bulb_and_enthalpy + 1\n\t\tend # OA Controller Type \"DifferentialDryBulbAndEnthalpy\"\n\t\t\n\t\t\t\t\n\tend # end loop through oa controller objects\n\n\t# reporting when N/A condition is appropriate\n\tif fixed_dry_bulb +\tdifferential_dry_bulb + fixed_enthalpy + differential_enthalpy + fixed_dew_point_and_dry_bulb +\telectronic_enthalpy + differential_dry_bulb_and_enthalpy == 0\n\t\trunner.registerAsNotApplicable(\"Measure not applicable because the model contains no OutdoorAir:Controller objects with operable economizers.\")\n\tend \n\t\n\ttotal = fixed_dry_bulb + differential_dry_bulb + fixed_enthalpy + differential_enthalpy + fixed_dew_point_and_dry_bulb + electronic_enthalpy + differential_dry_bulb_and_enthalpy\n\t\n\t# reporting initial condition of model\n\trunner.registerInitialCondition(\"The measure started with #{total} Outdoor Air Controllers configured for operational airside economizers. #{no_economizer} Outdoor Air Controller had the Economizer Contrrol Type set to 'NoEconomizer'.\")\n\t# reporting final condition of model\n\trunner.registerFinalCondition(\"The measure finished by adding outdoor and return air temperature and enthalpy sensor faults to #{total} economizer configurations.\")\n \n return true\n \n end",
"def calculation\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n # initialize variables\n affected_space_types = []\n affected_flag = false\n power_tot = 0\n power_tot_new = 0\n control_factor = 0.05 #90.1-2010 Table 9.6.2\n\n # standards space types\n affected_space_types << \"BreakRoom\"\n affected_space_types << \"Conference\"\n affected_space_types << \"Office\"\n affected_space_types << \"Restroom\"\n affected_space_types << \"Stair\"\n\n # get model objects\n space_types = model.getSpaceTypes\n\n # DO STUFF\n #TODO account for zone multipliers?\n space_types.each do |st|\n\n std_spc_typ = st.standardsSpaceType.to_s\n area = st.floorArea\n people = st.getNumberOfPeople(area)\n power = st.getLightingPower(area, people)\n power_tot += power\n\n #calcualte LPD\n lpd_area = power / area\n lpd_people = power / people\n\n affected_space_types.each do |ast|\n\n if ast == std_spc_typ\n\n #calculate adjustment and new power\n power_adj = power * control_factor\n power_new = power - power_adj\n\n lpd_area_new = power_new / area\n lpd_people_new = power_new / people\n\n #set new power\n if st.lightingPowerPerFloorArea.is_initialized\n\n runner.registerInfo(\"Adjusting interior lighting power for space type: #{st.name}\")\n st.setLightingPowerPerFloorArea(lpd_area_new)\n\n lpd_area_ip = OpenStudio.convert(lpd_area,\"ft^2\",\"m^2\").get\n lpd_area_new_ip = OpenStudio.convert(lpd_area_new,\"ft^2\",\"m^2\").get\n lpd_area_change = (1 - (lpd_area_new / lpd_area)) * 100\n\n runner.registerInfo(\"=> Initial interior lighting power = #{lpd_area_ip.round(2)} W/ft2\")\n runner.registerInfo(\"=> Final interior lighting power = #{lpd_area_new_ip.round(2)} W/ft2\")\n runner.registerInfo(\"=> Interior lighting power reduction = #{lpd_area_change.round(0)}%\")\n\n elsif st.lightingPowerPerPerson.is_initialized\n\n runner.registerInfo(\"Adjusting interior lighting power for space type: #{st.name}\")\n st.setLightingPowerPerPerson(lpd_people_new)\n\n lpd_people_change = (1 - (lpd_people_new / lpd_people)) * 100\n\n runner.registerInfo(\"=> Initial interior lighting power = #{lpd_people} W/person\")\n runner.registerInfo(\"=> Final interior lighting power = #{lpd_people_new} W/person\")\n runner.registerInfo(\"=> Interior lighting power reduction = #{lpd_people_change.round(0)}%\")\n\n else\n\n runner.registerWarning(\"Lighting power is specified using Lighting Level (W) for affected space type: #{st.name}\")\n\n end #set new power\n\n affected_flag = true\n\n end\n\n end #affected space types\n\n # calculate new total lighting power\n power = st.getLightingPower(area, people)\n power_tot_new += power\n\n end #space types\n\n # report not applicable\n if affected_flag == false\n runner.registerAsNotApplicable(\"No affected space types found\")\n end\n\n # report initial condition\n runner.registerInitialCondition(\"Total interior lighting power = #{power_tot.round(0)} W\")\n\n # report final condition\n runner.registerFinalCondition(\"Total interior lighting power = #{power_tot_new.round(0)} W\")\n\n return true\n\n end",
"def monitor; end",
"def measure key,value\n @context= {}\n @path = \"#{key}\" \n @context[:callcount] = 1\n @context[:firsttimestampoffset] = Time.now.to_f*1000 - value\n @context[:name] = @path\n @context[:responsetime] = value\n @context_list << @context\n end",
"def total_time=(_arg0); end",
"def run(workspace, runner, user_arguments)\n super(workspace, runner, user_arguments)\n\n #use the built-in error checking \n if not runner.validateUserArguments(arguments(workspace), user_arguments)\n return false\n end\n \n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n \n require 'json'\n \n # Get the last openstudio model\n model = runner.lastOpenStudioModel\n if model.empty?\n runner.registerError(\"Could not load last OpenStudio model, cannot apply measure.\")\n return false\n end\n model = model.get\n \n results = {}\n \n #get all DX coils in model\n dx_single = workspace.getObjectsByType(\"Coil:Cooling:DX:SingleSpeed\".to_IddObjectType)\n dx_two = workspace.getObjectsByType(\"Coil:Cooling:DX:TwoSpeed\".to_IddObjectType)\n \n dx_single.each do |dx|\n dx_name = {}\n coil_name = dx.getString(0).get\n runner.registerInfo(\"DX coil: #{coil_name} Initial COP: #{dx.getDouble(4).get}\")\n dx.setDouble(4,7.62)\n runner.registerInfo(\"DX coil: #{coil_name} Final COP: #{dx.getDouble(4).get}\")\n dx_name[:dxname] = \"#{coil_name}\"\n results[\"#{coil_name}\"] = dx_name\n end\n\n dx_two.each do |dx|\n dx_name = {}\n coil_name = dx.getString(0).get\n runner.registerInfo(\"DX coil: #{coil_name} Initial High COP: #{dx.getDouble(4).get}, Initial Low COP: #{dx.getDouble(16).get}\")\n dx.setDouble(4,7.62)\n dx.setDouble(16,7.62)\n runner.registerInfo(\"DX coil: #{coil_name} Final High COP: #{dx.getDouble(4).get}, Final Low COP: #{dx.getDouble(16).get}\")\n dx_name[:dxname] = \"#{coil_name}\"\n results[\"#{coil_name}\"] = dx_name\n end\n \n if results.empty?\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\n end\n \n #save airloop parsing results to ems_results.json\n runner.registerInfo(\"Saving ems_results.json\")\n FileUtils.mkdir_p(File.dirname(\"ems_results.json\")) unless Dir.exist?(File.dirname(\"ems_results.json\"))\n File.open(\"ems_results.json\", 'w') {|f| f << JSON.pretty_generate(results)}\n \n if results.empty?\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\n #save blank ems_membrane_heat_pump_cooling_only.ems file so Eplus measure does not crash\n ems_string = \"\"\n runner.registerInfo(\"Saving blank ems_membrane_heat_pump_cooling_only file\")\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\n f.write(ems_string)\n end\n return true\n end\n \n timeStep = model.getTimestep.numberOfTimestepsPerHour\n \n runner.registerInfo(\"Making EMS string for Membrane Heat Pump Cooling Only\")\n #start making the EMS code\n ems_string = \"\" #clear out the ems_string\n ems_string << \"\\n\" \n ems_string << \"Output:Variable,*,Cooling Coil Sensible Cooling Energy,timestep; !- HVAC Sum [J]\" + \"\\n\"\n ems_string << \"\\n\" \n \n results.each_with_index do |(key, value), i| \n ems_string << \"EnergyManagementSystem:Sensor,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}SensibleClgJ,\" + \"\\n\"\n ems_string << \" #{value[:dxname]},\" + \"\\n\"\n ems_string << \" Cooling Coil Sensible Cooling Energy;\" + \"\\n\"\n ems_string << \"\\n\" \n ems_string << \"WaterUse:Equipment,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUse, !- Name\" + \"\\n\"\n ems_string << \" Membrane HP Cooling, !- End-Use Subcategory\" + \"\\n\"\n ems_string << \" 0.003155, !- Peak Flow Rate {m3/s} = 3000 gal/hr\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule; !- Flow Rate Fraction Schedule Name\" + \"\\n\"\n ems_string << \"\\n\" \n ems_string << \"Schedule:Constant,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule, !- Name\" + \"\\n\"\n ems_string << \" , !- Schedule Type Limits Name\" + \"\\n\"\n ems_string << \" 1; !- Hourly Value\" + \"\\n\"\n ems_string << \"\\n\" \n ems_string << \"EnergyManagementSystem:Actuator,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseCtrl,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule,\" + \"\\n\"\n ems_string << \" Schedule:Constant,\" + \"\\n\"\n ems_string << \" Schedule Value;\" + \"\\n\"\n ems_string << \"\\n\" \n end\n ems_string << \"EnergyManagementSystem:ProgramCallingManager,\" + \"\\n\"\n ems_string << \" MembraneHPWaterUseProgramControl, !- Name\" + \"\\n\"\n ems_string << \" AfterPredictorBeforeHVACManagers, !- EnergyPlus Model Calling Point\" + \"\\n\"\n ems_string << \" MembraneHPWaterUseProgram; !- Program Name 1\" + \"\\n\"\n ems_string << \"\\n\"\n ems_string << \"EnergyManagementSystem:Program,\" + \"\\n\"\n ems_string << \" MembraneHPWaterUseProgram, !- Name\" + \"\\n\"\n ems_string << \" SET TimeStepsPerHr = #{timeStep}\" + \"\\n\"\n results.each_with_index do |(key, value), i|\n ems_string << \" SET MembraneHP#{i+1}SensibleClgTonHr = MembraneHP#{i+1}SensibleClgJ * 0.0000007898,\" + \"\\n\"\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGal = MembraneHP#{i+1}SensibleClgTonHr * 3.0,\" + \"\\n\"\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGalPerHr = MembraneHP#{i+1}SensibleWtrGal * TimeStepsPerHr,\" + \"\\n\"\n ems_string << \" SET MembraneHP#{i+1}WaterUseCtrl = MembraneHP#{i+1}SensibleWtrGalPerHr / 3000.0,\" + \"\\n\"\n end \n ems_string << \" SET UnusedLine = 0;\" + \"\\n\"\n \n #save EMS snippet\n runner.registerInfo(\"Saving ems_membrane_heat_pump_cooling_only file\")\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\n f.write(ems_string)\n end\n \n #unique initial conditions based on\n runner.registerInitialCondition(\"The building has #{results.size} DX coils for which this measure is applicable.\")\n\n #reporting final condition of model\n runner.registerFinalCondition(\"The efficiency of the following coils was increased to SEER 26 to reflect the replacement of these coils with membrane heatpumps: #{results.keys}\")\n \n ems_path = '../MembraneHeatPumpCoolingOnly/ems_membrane_heat_pump_cooling_only.ems'\n json_path = '../MembraneHeatPumpCoolingOnly/ems_results.json'\n if File.exist? ems_path\n ems_string = File.read(ems_path)\n if File.exist? json_path\n json = JSON.parse(File.read(json_path))\n end\n else\n ems_path2 = Dir.glob('../../**/ems_membrane_heat_pump_cooling_only.ems')\n ems_path1 = ems_path2[0]\n json_path2 = Dir.glob('../../**/ems_results.json')\n json_path1 = json_path2[0]\n if ems_path2.size > 1\n runner.registerWarning(\"more than one ems_membrane_heat_pump_cooling_only.ems file found. Using first one found.\")\n end\n if !ems_path1.nil? \n if File.exist? ems_path1\n ems_string = File.read(ems_path1)\n if File.exist? json_path1\n json = JSON.parse(File.read(json_path1))\n else\n runner.registerError(\"ems_results.json file not located\") \n end \n else\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\")\n end \n else\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\") \n end\n end\n if json.nil?\n runner.registerError(\"ems_results.json file not located\")\n return false\n end\n \n if json.empty?\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\n return true\n end\n \n idf_file = OpenStudio::IdfFile::load(ems_string, 'EnergyPlus'.to_IddFileType).get\n runner.registerInfo(\"Adding EMS code to workspace\")\n workspace.addObjects(idf_file.objects)\n \n return true\n\n end",
"def apply_measure_to_model(test_name, args, model_name = nil, result_value = 'Success', warnings_count = 0, info_count = nil)\n # create an instance of the measure\n measure = ChangeBuildingLocation.new\n\n # create an instance of a runner with OSW\n osw_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/test.osw')\n osw = OpenStudio::WorkflowJSON.load(osw_path).get\n runner = OpenStudio::Measure::OSRunner.new(osw)\n\n # get model\n if model_name.nil?\n # make an empty model\n model = OpenStudio::Model::Model.new\n else\n # load the test model\n translator = OpenStudio::OSVersion::VersionTranslator.new\n path = OpenStudio::Path.new(File.dirname(__FILE__) + '/' + model_name)\n model = translator.loadModel(path)\n assert(!model.empty?)\n model = model.get\n end\n\n # get arguments\n arguments = measure.arguments(model)\n argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)\n\n # populate argument with specified hash value if specified\n arguments.each do |arg|\n temp_arg_var = arg.clone\n if args.key?(arg.name)\n assert(temp_arg_var.setValue(args[arg.name]))\n end\n argument_map[arg.name] = temp_arg_var\n end\n\n # temporarily change directory to the run directory and run the measure (because of sizing run)\n start_dir = Dir.pwd\n begin\n unless Dir.exist?(run_dir(test_name))\n Dir.mkdir(run_dir(test_name))\n end\n Dir.chdir(run_dir(test_name))\n\n # run the measure\n measure.run(model, runner, argument_map)\n result = runner.result\n ensure\n Dir.chdir(start_dir)\n\n # delete sizing run dir\n FileUtils.rm_rf(run_dir(test_name))\n end\n\n # show the output\n puts \"measure results for #{test_name}\"\n show_output(result)\n\n # assert that it ran correctly\n if result_value.nil? then result_value = 'Success' end\n assert_equal(result_value, result.value.valueName)\n\n # check count of warning and info messages\n unless info_count.nil? then assert(result.info.size == info_count) end\n unless warnings_count.nil? then assert(result.warnings.size == warnings_count) end\n\n # if 'Fail' passed in make sure at least one error message (while not typical there may be more than one message)\n if result_value == 'Fail' then assert(result.errors.size >= 1) end\n\n # save the model to test output directory\n output_file_path = OpenStudio::Path.new(File.dirname(__FILE__) + \"/output/#{test_name}_test_output.osm\")\n model.save(output_file_path, true)\n end",
"def measure_code(model,runner)\n ################ Start Measure code here ################################\n # Argument will be passed as instance variable. So if your argument was height, your can access it using @height. \n\n # report initial condition\n site = model.getSite\n initial_design_days = model.getDesignDays\n if site.weatherFile.is_initialized\n weather = site.weatherFile.get\n runner.registerInitialCondition(\"The initial weather file path was '#{weather.path.get}' and the model had #{initial_design_days.size} design days.\")\n else\n runner.registerInitialCondition(\"The initial weather file has not been set and the model had #{initial_design_days.size} design days.\")\n end\n\n\n #Check form weather directory Weather File\n unless (Pathname.new @weather_directory).absolute?\n @weather_directory = File.expand_path(File.join(File.dirname(__FILE__), @weather_directory))\n end\n weather_file = File.join(@weather_directory, @weather_file_name)\n if File.exists?(weather_file) and @weather_file_name.downcase.include? \".epw\"\n BTAP::runner_register(\"Info\", \"The epw weather file #{weather_file} was found!\", runner)\n else\n BTAP::runner_register(\"Error\",\"'#{weather_file}' does not exist or is not an .epw file.\", runner)\n return false\n end\n\n begin\n weather = BTAP::Environment::WeatherFile.new(weather_file)\n #Set Weather file to model.\n weather.set_weather_file(model)\n #Store information about this run in the runner for output. This will be in the csv and R dumps.\n runner.registerValue( 'city',weather.city )\n runner.registerValue( 'state_province_region ',weather.state_province_region )\n runner.registerValue( 'country',weather.country )\n runner.registerValue( 'hdd18',weather.hdd18 )\n runner.registerValue( 'cdd18',weather.cdd18 )\n runner.registerValue( 'necb_climate_zone',BTAP::Compliance::NECB2011::get_climate_zone_name(weather.hdd18).to_s)\n runner.registerFinalCondition( \"Model ended with weatherfile of #{model.getSite.weatherFile.get.path.get}\" )\n rescue\n BTAP::runner_register(\"Error\",\"'#{weather_file}' could not be loaded into model.\", runner)\n\n return false\n end\n BTAP::runner_register(\"FinalCondition\",\"Weather file set to #{weather_file}\",runner)\n return true\n end",
"def run(workspace, runner, user_arguments)\r\n super(workspace, runner, user_arguments)\r\n\r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(workspace), user_arguments)\r\n return false\r\n end\r\n \r\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\r\n if run_measure == 0\r\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\r\n return true \r\n end\r\n \r\n require 'json'\r\n \r\n # Get the last openstudio model\r\n model = runner.lastOpenStudioModel\r\n if model.empty?\r\n runner.registerError(\"Could not load last OpenStudio model, cannot apply measure.\")\r\n return false\r\n end\r\n model = model.get\r\n \r\n results = {}\r\n #get all DX coils in model\r\n dx_single = model.getCoilCoolingDXSingleSpeeds \r\n dx_two = model.getCoilCoolingDXTwoSpeeds\r\n \r\n if !dx_single.empty?\r\n dx_single.each do |dx|\r\n dx_name = {}\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial COP: #{dx.ratedCOP.get}\")\r\n dx.setRatedCOP(OpenStudio::OptionalDouble.new(7.62))\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final COP: #{dx.ratedCOP.get}\")\r\n dx_name[:dxname] = \"#{dx.name.get}\"\r\n results[\"#{dx.name.get}\"] = dx_name\r\n end\r\n end\r\n if !dx_two.empty?\r\n dx_two.each do |dx|\r\n dx_name = {}\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial High COP: #{dx.ratedHighSpeedCOP.get} Low COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx.setRatedHighSpeedCOP(7.62)\r\n dx.setRatedLowSpeedCOP(7.62)\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final High COP: #{dx.ratedHighSpeedCOP.get} Final COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx_name[:dxname] = \"#{dx.name.get}\"\r\n results[\"#{dx.name.get}\"] = dx_name\r\n end\r\n end\r\n \r\n if results.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\r\n end\r\n \r\n #save airloop parsing results to ems_results.json\r\n runner.registerInfo(\"Saving ems_results.json\")\r\n FileUtils.mkdir_p(File.dirname(\"ems_results.json\")) unless Dir.exist?(File.dirname(\"ems_results.json\"))\r\n File.open(\"ems_results.json\", 'w') {|f| f << JSON.pretty_generate(results)}\r\n \r\n if results.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\r\n #save blank ems_membrane_heat_pump_cooling_only.ems file so Eplus measure does not crash\r\n ems_string = \"\"\r\n runner.registerInfo(\"Saving blank ems_membrane_heat_pump_cooling_only file\")\r\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\r\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\r\n f.write(ems_string)\r\n end\r\n return true\r\n end\r\n \r\n timeStep = model.getTimestep.numberOfTimestepsPerHour\r\n \r\n runner.registerInfo(\"Making EMS string for Membrane Heat Pump Cooling Only\")\r\n #start making the EMS code\r\n ems_string = \"\" #clear out the ems_string\r\n ems_string << \"\\n\" \r\n ems_string << \"Output:Variable,*,Cooling Coil Sensible Cooling Energy,timestep; !- HVAC Sum [J]\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n \r\n results.each_with_index do |(key, value), i| \r\n ems_string << \"EnergyManagementSystem:Sensor,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}SensibleClgJ,\" + \"\\n\"\r\n ems_string << \" #{value[:dxname]},\" + \"\\n\"\r\n ems_string << \" Cooling Coil Sensible Cooling Energy;\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n ems_string << \"WaterUse:Equipment,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUse, !- Name\" + \"\\n\"\r\n ems_string << \" Membrane HP Cooling, !- End-Use Subcategory\" + \"\\n\"\r\n ems_string << \" 0.003155, !- Peak Flow Rate {m3/s} = 3000 gal/hr\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule; !- Flow Rate Fraction Schedule Name\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n ems_string << \"Schedule:Constant,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule, !- Name\" + \"\\n\"\r\n ems_string << \" , !- Schedule Type Limits Name\" + \"\\n\"\r\n ems_string << \" 1; !- Hourly Value\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n ems_string << \"EnergyManagementSystem:Actuator,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseCtrl,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule,\" + \"\\n\"\r\n ems_string << \" Schedule:Constant,\" + \"\\n\"\r\n ems_string << \" Schedule Value;\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n end\r\n ems_string << \"EnergyManagementSystem:ProgramCallingManager,\" + \"\\n\"\r\n ems_string << \" MembraneHPWaterUseProgramControl, !- Name\" + \"\\n\"\r\n ems_string << \" AfterPredictorBeforeHVACManagers, !- EnergyPlus Model Calling Point\" + \"\\n\"\r\n ems_string << \" MembraneHPWaterUseProgram; !- Program Name 1\" + \"\\n\"\r\n ems_string << \"\\n\"\r\n ems_string << \"EnergyManagementSystem:Program,\" + \"\\n\"\r\n ems_string << \" MembraneHPWaterUseProgram, !- Name\" + \"\\n\"\r\n ems_string << \" SET TimeStepsPerHr = #{timeStep}\" + \"\\n\"\r\n results.each_with_index do |(key, value), i|\r\n ems_string << \" SET MembraneHP#{i+1}SensibleClgTonHr = MembraneHP#{i+1}SensibleClgJ * 0.0000007898,\" + \"\\n\"\r\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGal = MembraneHP#{i+1}SensibleClgTonHr * 3.0,\" + \"\\n\"\r\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGalPerHr = MembraneHP#{i+1}SensibleWtrGal * TimeStepsPerHr,\" + \"\\n\"\r\n ems_string << \" SET MembraneHP#{i+1}WaterUseCtrl = MembraneHP#{i+1}SensibleWtrGalPerHr / 3000.0,\" + \"\\n\"\r\n end \r\n ems_string << \" SET UnusedLine = 0;\" + \"\\n\"\r\n \r\n #save EMS snippet\r\n runner.registerInfo(\"Saving ems_membrane_heat_pump_cooling_only file\")\r\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\r\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\r\n f.write(ems_string)\r\n end\r\n \r\n #unique initial conditions based on\r\n runner.registerInitialCondition(\"The building has #{results.size} DX coils for which this measure is applicable.\")\r\n\r\n #reporting final condition of model\r\n runner.registerFinalCondition(\"The efficiency of the following coils was increased to SEER 26 to reflect the replacement of these coils with membrane heatpumps: #{results.keys}\")\r\n \r\n ems_path = '../MembraneHeatPumpCoolingOnlyEms/ems_membrane_heat_pump_cooling_only.ems'\r\n json_path = '../MembraneHeatPumpCoolingOnlyEms/ems_results.json'\r\n if File.exist? ems_path\r\n ems_string = File.read(ems_path)\r\n if File.exist? json_path\r\n json = JSON.parse(File.read(json_path))\r\n end\r\n else\r\n ems_path2 = Dir.glob('../../**/ems_membrane_heat_pump_cooling_only.ems')\r\n ems_path1 = ems_path2[0]\r\n json_path2 = Dir.glob('../../**/ems_results.json')\r\n json_path1 = json_path2[0]\r\n if ems_path2.size > 1\r\n runner.registerWarning(\"more than one ems_membrane_heat_pump_cooling_only.ems file found. Using first one found.\")\r\n end\r\n if !ems_path1.nil? \r\n if File.exist? ems_path1\r\n ems_string = File.read(ems_path1)\r\n if File.exist? json_path1\r\n json = JSON.parse(File.read(json_path1))\r\n else\r\n runner.registerError(\"ems_results.json file not located\") \r\n end \r\n else\r\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\")\r\n end \r\n else\r\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\") \r\n end\r\n end\r\n if json.nil?\r\n runner.registerError(\"ems_results.json file not located\")\r\n return false\r\n end\r\n \r\n if json.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n return true\r\n end\r\n \r\n idf_file = OpenStudio::IdfFile::load(ems_string, 'EnergyPlus'.to_IddFileType).get\r\n runner.registerInfo(\"Adding EMS code to workspace\")\r\n workspace.addObjects(idf_file.objects)\r\n \r\n return true\r\n\r\n end",
"def modeler_description\n return 'The measure performs the following functions: (1) IDs all chillers, (2) Locates their performance curves and outputs the data, (3) Adds reporting variables for chiller-related data.'\n end",
"def build_timing; end",
"def measure_gc\n return unless enabled?\n\n @raw_data << { fake: true }\n @total_time += 1.1\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # define if the measure should run to a specific time period or whole day\n apply_to_time = true\n\n # assign the user inputs to variables\n object = runner.getOptionalWorkspaceObjectChoiceValue('space_type', user_arguments, model)\n single_space_type = runner.getDoubleArgumentValue('single_space_type', user_arguments)\n occupied_space_type = runner.getDoubleArgumentValue('occupied_space_type', user_arguments)\n unoccupied_space_type = runner.getDoubleArgumentValue('unoccupied_space_type', user_arguments)\n starttime_winter2 = runner.getStringArgumentValue('starttime_winter2', user_arguments)\n endtime_winter2 = runner.getStringArgumentValue('endtime_winter2', user_arguments)\n starttime_winter1 = runner.getStringArgumentValue('starttime_winter1', user_arguments)\n endtime_winter1 = runner.getStringArgumentValue('endtime_winter1', user_arguments)\n starttime_summer = runner.getStringArgumentValue('starttime_summer', user_arguments)\n endtime_summer = runner.getStringArgumentValue('endtime_summer', user_arguments)\n auto_date = runner.getBoolArgumentValue('auto_date', user_arguments)\n alt_periods = runner.getBoolArgumentValue('alt_periods', user_arguments)\n demo_cost_initial_const=false\n\n winter_start_month1 = 1\n winter_end_month1 = 5\n summer_start_month = 6\n summer_end_month = 9\n winter_start_month2 = 10\n winter_end_month2 = 12\n\n######### GET CLIMATE ZONES ################\n if auto_date\n ashraeClimateZone = ''\n #climateZoneNUmber = ''\n climateZones = model.getClimateZones\n climateZones.climateZones.each do |climateZone|\n if climateZone.institution == 'ASHRAE'\n ashraeClimateZone = climateZone.value\n runner.registerInfo(\"Using ASHRAE Climate zone #{ashraeClimateZone}.\")\n end\n end\n\n if ashraeClimateZone == '' # should this be not applicable or error?\n runner.registerError(\"Please assign an ASHRAE Climate Zone to your model using the site tab in the OpenStudio application. The measure can't make AEDG recommendations without this information.\")\n return false # note - for this to work need to check for false in measure.rb and add return false there as well.\n # else\n # climateZoneNumber = ashraeClimateZone.split(//).first\n end\n # #runner.registerInfo(\"CLIMATE ZONE #{ashraeClimateZone}. Right now does not do anything.\")\n # if !['1', '2', '3', '4', '5', '6', '7', '8'].include? climateZoneNumber\n # runner.registerError('ASHRAE climate zone number is not within expected range of 1 to 8.')\n # return false # note - for this to work need to check for false in measure.rb and add return false there as well.\n # end\n\n if alt_periods\n if ashraeClimateZone == '3A'\n starttime_summer = '18:01:00'\n endtime_summer = '21:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '4A'\n starttime_summer = '18:01:00'\n endtime_summer = '21:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5A'\n starttime_summer = '14:01:00'\n endtime_summer = '17:59:00'\n starttime_winter1 = '18:01:00'\n endtime_winter1 = '21:59:00'\n starttime_winter2 = '18:01:00'\n endtime_winter2 = '21:59:00'\n elsif ashraeClimateZone == '6A'\n starttime_summer = '13:01:00'\n endtime_summer = '16:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n end\n else\n if ashraeClimateZone == '2A'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '2B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '3A'\n starttime_summer = '19:01:00'\n endtime_summer = '22:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '3B'\n starttime_summer = '18:01:00'\n endtime_summer = '21:59:00'\n starttime_winter1 = '19:01:00'\n endtime_winter1 = '22:59:00'\n starttime_winter2 = '19:01:00'\n endtime_winter2 = '22:59:00'\n elsif ashraeClimateZone == '3C'\n starttime_summer = '19:01:00'\n endtime_summer = '22:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '4A'\n starttime_summer = '12:01:00'\n endtime_summer = '15:59:00'\n starttime_winter1 = '16:01:00'\n endtime_winter1 = '19:59:00'\n starttime_winter2 = '16:01:00'\n endtime_winter2 = '19:59:00'\n elsif ashraeClimateZone == '4B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '4C'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5A'\n starttime_summer = '20:01:00'\n endtime_summer = '23:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5C'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '6A'\n starttime_summer = '16:01:00'\n endtime_summer = '19:59:00'\n starttime_winter1 = '18:01:00'\n endtime_winter1 = '21:59:00'\n starttime_winter2 = '18:01:00'\n endtime_winter2 = '21:59:00'\n elsif ashraeClimateZone == '6B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '7A'\n starttime_summer = '16:01:00'\n endtime_summer = '19:59:00'\n starttime_winter1 = '18:01:00'\n endtime_winter1 = '21:59:00'\n starttime_winter2 = '18:01:00'\n endtime_winter2 = '21:59:00'\n end\n end\n end \n\n # check the lighting power reduction percentages and for reasonableness\n if occupied_space_type > 100\n runner.registerError('Please Enter a Value less than or equal to 100 for the Electric Equipment Power Reduction Percentage.')\n return false\n elsif occupied_space_type == 0\n runner.registerInfo('No Electric Equipment power adjustment requested, but some life cycle costs may still be affected.')\n elsif (occupied_space_type < 1) && (occupied_space_type > -1)\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{occupied_space_type} percent is abnormally low.\")\n elsif occupied_space_type > 90\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{occupied_space_type} percent is abnormally high.\")\n elsif occupied_space_type < 0\n runner.registerInfo('The requested value for Electric Equipment power reduction percentage was negative. This will result in an increase in Electric Equipment power.')\n end\n\n # check the equipment_power_reduction_percent and for reasonableness\n if unoccupied_space_type > 100\n runner.registerError('Please Enter a Value less than or equal to 100 for the Electric Equipment Power Reduction Percentage.')\n return false\n elsif unoccupied_space_type == 0\n runner.registerInfo('No Electric Equipment power adjustment requested, but some life cycle costs may still be affected.')\n elsif (unoccupied_space_type < 1) && (unoccupied_space_type > -1)\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{unoccupied_space_type} percent is abnormally low.\")\n elsif unoccupied_space_type > 90\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{unoccupied_space_type} percent is abnormally high.\")\n elsif unoccupied_space_type < 0\n runner.registerInfo('The requested value for Electric Equipment power reduction percentage was negative. This will result in an increase in Electric Equipment power.')\n end\n\n # check the equipment_power_reduction_percent and for reasonableness\n if single_space_type > 100\n runner.registerError('Please Enter a Value less than or equal to 100 for the Electric Equipment Power Reduction Percentage.')\n return false\n elsif single_space_type == 0\n runner.registerInfo('No Electric Equipment power adjustment requested, but some life cycle costs may still be affected.')\n elsif (single_space_type < 1) && (single_space_type > -1)\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{single_space_type} percent is abnormally low.\")\n elsif single_space_type > 90\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{single_space_type} percent is abnormally high.\")\n elsif single_space_type < 0\n runner.registerInfo('The requested value for Electric Equipment power reduction percentage was negative. This will result in an increase in Electric Equipment power.')\n end\n\n # check the time periods for reasonableness\n if (starttime_winter1.to_f > endtime_winter1.to_f) && (starttime_winter2.to_f > endtime_winter2.to_f) && (starttime_summer.to_f > endtime_summer.to_f)\n runner.registerError('The end time should be larger than the start time.')\n return false\n end\n\n # check the space_type for reasonableness\n space_type = nil\n if object.empty?\n handle = runner.getStringArgumentValue('space_type', user_arguments)\n if handle.empty?\n runner.registerError('No space type was chosen.')\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !object.get.to_SpaceType.empty?\n space_type = object.get.to_SpaceType.get\n elsif !object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError('Script Error - argument not showing up as space type or building.')\n return false\n end\n end\n\n\n ############################################\n\n # assign the time duration when DR strategy is applied, from shift_time1 to shift_time2, only applied when apply_to_time is ture\n shift_time1 = OpenStudio::Time.new(starttime_winter1)\n shift_time2 = OpenStudio::Time.new(endtime_winter1)\n shift_time3 = OpenStudio::Time.new(0, 24, 0, 0)\n shift_time4 = OpenStudio::Time.new(starttime_summer)\n shift_time5 = OpenStudio::Time.new(endtime_summer)\n shift_time6 = OpenStudio::Time.new(starttime_winter2)\n shift_time7 = OpenStudio::Time.new(endtime_winter2)\n \n \n # get space types in model\n if apply_to_building\n space_types = model.getSpaceTypes\n else\n space_types = []\n space_types << space_type # only run on a single space type\n end\n\n # make a hash of old defs and new equipments and luminaire defs\n cloned_equi_defs = {}\n # loop through space types\n space_types.each do |space_type|\n\n equi_set_schs = {}\n if apply_to_building # measure will be applied differently to space types, based on whether the space type is occupied\n if !space_type.people.empty?\n equipment_power_reduction_percent = 1 - (occupied_space_type/100)\n else\n equipment_power_reduction_percent = 1 - (unoccupied_space_type/100)\n end\n runner.registerInitialCondition(\"Equipment power will be reduced by #{occupied_space_type}% in occupied spaces, and reduced by #{unoccupied_space_type}% in unoccupied spaces\")\n\n else\n equipment_power_reduction_percent = 1 - (single_space_type/100) # measure will be applied evenly to all zones\n runner.registerInitialCondition(\"Equipment power will be reduced by #{single_space_type}% to '#{space_type.name}'.\")\n end\n\n space_type_equipments = space_type.electricEquipment\n space_type_equipments.each do |space_type_equipment|\n #clone of not already in hash\n equi_set_sch = space_type_equipment.schedule\n if !equi_set_sch.empty?\n # clone of not already in hash\n if equi_set_schs.key?(equi_set_sch.get.name.to_s)\n new_equi_set_sch = equi_set_schs[equi_set_sch.get.name.to_s]\n else\n new_equi_set_sch = equi_set_sch.get.clone(model)\n new_equi_set_sch = new_equi_set_sch.to_Schedule.get\n new_equi_set_sch_name = new_equi_set_sch.setName(\"#{new_equi_set_sch.name} adjusted #{equipment_power_reduction_percent}\")\n # add to the hash\n equi_set_schs[new_equi_set_sch.name.to_s] = new_equi_set_sch\n end\n # hook up clone to equipment\n \n if space_type_equipment.name.to_s != \"OfficeLarge Data Center Elec Equip\" && space_type_equipment.name.to_s != \"OfficeLarge Main Data Center Elec Equip\"\n space_type_equipment.setSchedule(new_equi_set_sch)\n runner.registerInfo(\"#{space_type_equipment.name} has a new electric equipment schedule\")\n end\n else\n runner.registerWarning(\"#{space_type.equipments.name} doesn't have a schedule.\")\n end\n end\n \n if apply_to_time\n runner.registerFinalCondition(\" equipment power is reduced from #{shift_time1} to #{shift_time2}.\")\n runner.registerFinalCondition(\" equipment power is reduced from #{shift_time4} to #{shift_time5} during special between month #{summer_start_month} and #{summer_end_month}\")\n else\n runner.registerFinalCondition(\" equipment power is reduced all day.\")\n end\n\n \n # make equipment schedule adjustments and rename.\n equi_set_schs.each do |k, v| # old name and new object for schedule\n if !v.to_ScheduleRuleset.empty?\n\n schedule = v.to_ScheduleRuleset.get\n default_rule = schedule.defaultDaySchedule\n rules = schedule.scheduleRules\n\n days_covered = Array.new(7, false)\n\n if rules.length > 0\n rules.each do |rule|\n summerStartMonth = OpenStudio::MonthOfYear.new(summer_start_month)\n summerEndMonth = OpenStudio::MonthOfYear.new(summer_end_month)\n summerStartDate = OpenStudio::Date.new(summerStartMonth, 1)\n summerEndDate = OpenStudio::Date.new(summerEndMonth, 30)\n \n summer_rule = rule.clone(model).to_ScheduleRule.get\n summer_rule.setStartDate(summerStartDate)\n summer_rule.setEndDate(summerEndDate)\n\n allDaysCovered(summer_rule, days_covered)\n\n cloned_day_summer = rule.daySchedule.clone(model)\n cloned_day_summer.setParent(summer_rule)\n\n summer_day = summer_rule.daySchedule\n day_time_vector = summer_day.times\n day_value_vector = summer_day.values\n summer_day.clearValues\n \n summer_day = createDaySchedule(summer_day, day_time_vector, day_value_vector, shift_time4, shift_time5, equipment_power_reduction_percent)\n \n ##############################################\n winterStartMonth1 = OpenStudio::MonthOfYear.new(winter_start_month1)\n winterEndMonth1 = OpenStudio::MonthOfYear.new(winter_end_month1)\n winterStartDate1 = OpenStudio::Date.new(winterStartMonth1, 1)\n winterEndDate1 = OpenStudio::Date.new(winterEndMonth1, 31)\n \n winter_rule1 = rule #rule.clone(model).to_ScheduleRule.get\n winter_rule1.setStartDate(winterStartDate1)\n winter_rule1.setEndDate(winterEndDate1)\n\n\n cloned_day_winter = rule.daySchedule.clone(model)\n cloned_day_winter.setParent(winter_rule1)\n\n winter_day1 = winter_rule1.daySchedule\n day_time_vector = winter_day1.times\n day_value_vector = winter_day1.values\n winter_day1.clearValues\n \n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time6, shift_time7, equipment_power_reduction_percent)\n if shift_time1 != shift_time6 \n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time1, shift_time2, equipment_power_reduction_percent)\n end\n ###################################################\n winterStartMonth2 = OpenStudio::MonthOfYear.new(winter_start_month2)\n winterEndMonth2 = OpenStudio::MonthOfYear.new(winter_end_month2)\n winterStartDate2 = OpenStudio::Date.new(winterStartMonth2, 1)\n winterEndDate2 = OpenStudio::Date.new(winterEndMonth2, 31)\n \n winter_rule2 = winter_rule1.clone(model).to_ScheduleRule.get\n winter_rule2.setStartDate(winterStartDate2)\n winter_rule2.setEndDate(winterEndDate2)\n \n cloned_day_winter2 = winter_day1.clone(model)\n cloned_day_winter2.setParent(winter_rule2)\n end\n end\n #runner.registerInfo(\"BEFORE #{days_covered}\")\n if days_covered.include?(false)\n summerStartMonth = OpenStudio::MonthOfYear.new(summer_start_month)\n summerEndMonth = OpenStudio::MonthOfYear.new(summer_end_month)\n summerStartDate = OpenStudio::Date.new(summerStartMonth, 1)\n summerEndDate = OpenStudio::Date.new(summerEndMonth, 30)\n \n summer_rule = OpenStudio::Model::ScheduleRule.new(schedule)\n summer_rule.setStartDate(summerStartDate)\n summer_rule.setEndDate(summerEndDate)\n coverSomeDays(summer_rule, days_covered)\n allDaysCovered(summer_rule, days_covered)\n\n cloned_day_summer = default_rule.clone(model)\n cloned_day_summer.setParent(summer_rule)\n\n summer_day = summer_rule.daySchedule\n day_time_vector = summer_day.times\n day_value_vector = summer_day.values\n summer_day.clearValues\n \n summer_day = createDaySchedule(summer_day, day_time_vector, day_value_vector, shift_time4, shift_time5, equipment_power_reduction_percent)\n \n ##############################################\n winterStartMonth1 = OpenStudio::MonthOfYear.new(winter_start_month1)\n winterEndMonth1 = OpenStudio::MonthOfYear.new(winter_end_month1)\n winterStartDate1 = OpenStudio::Date.new(winterStartMonth1, 1)\n winterEndDate1 = OpenStudio::Date.new(winterEndMonth1, 31)\n \n winter_rule1 = summer_rule.clone(model).to_ScheduleRule.get #OpenStudio::Model::ScheduleRule.new(schedule)\n winter_rule1.setStartDate(winterStartDate1)\n winter_rule1.setEndDate(winterEndDate1)\n\n #coverSomeDays(winter_rule1, days_covered)\n #allDaysCovered(summer_rule, days_covered)\n\n cloned_day_winter = default_rule.clone(model)\n cloned_day_winter.setParent(winter_rule1)\n\n winter_day1 = winter_rule1.daySchedule\n day_time_vector = winter_day1.times\n day_value_vector = winter_day1.values\n winter_day1.clearValues\n \n\n\n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time6, shift_time7, equipment_power_reduction_percent)\n if shift_time1 != shift_time6 \n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time1, shift_time2, equipment_power_reduction_percent)\n end\n ###################################################\n winterStartMonth2 = OpenStudio::MonthOfYear.new(winter_start_month2)\n winterEndMonth2 = OpenStudio::MonthOfYear.new(winter_end_month2)\n winterStartDate2 = OpenStudio::Date.new(winterStartMonth2, 1)\n winterEndDate2 = OpenStudio::Date.new(winterEndMonth2, 31)\n \n winter_rule2 = winter_rule1.clone(model).to_ScheduleRule.get #OpenStudio::Model::ScheduleRule.new(schedule)\n winter_rule2.setStartDate(winterStartDate2)\n winter_rule2.setEndDate(winterEndDate2)\n \n cloned_day_winter2 = winter_day1.clone(model)\n cloned_day_winter2.setParent(winter_rule2)\n end\n #runner.registerInfo(\"AFTER Summer #{days_covered}\")\n else\n runner.registerWarning(\"Schedule '#{k}' isn't a ScheduleRuleset object and won't be altered by this measure.\")\n v.remove # remove un-used clone\n end\n end\n\n end\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assume the occ sensors will last the full analysis\n expected_life = 25\n \n #assign the user inputs to variables\n space_type_object = runner.getOptionalWorkspaceObjectChoiceValue(\"space_type\",user_arguments,model)\n percent_runtime_reduction = runner.getDoubleArgumentValue(\"percent_runtime_reduction\",user_arguments)\n material_and_installation_cost_per_space = runner.getDoubleArgumentValue(\"material_and_installation_cost_per_space\",user_arguments)\n\n #check the space_type for reasonableness and see if measure should run on space type or on the entire building\n apply_to_building = false\n space_type = nil\n if space_type_object.empty?\n handle = runner.getStringArgumentValue(\"space_type\",user_arguments)\n if handle.empty?\n runner.registerError(\"No space type was chosen.\")\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if not space_type_object.get.to_SpaceType.empty?\n space_type = space_type_object.get.to_SpaceType.get\n elsif not space_type_object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError(\"Script Error - argument not showing up as space type or building.\")\n return false\n end\n end\n \n #check arguments for reasonableness\n if percent_runtime_reduction >= 100\n runner.registerError(\"Percent runtime reduction must be less than 100.\")\n return false\n end\n\n #find all the original schedules (before occ sensors installed)\n original_lts_schedules = []\n if apply_to_building #apply to the whole building\n \n model.getLightss.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n space_type.lights.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n space.lights.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end \n end\n end\n \n #make copies of all the original lights schedules, reduced to include occ sensor impact\n original_schs_new_schs = {}\n original_lts_schedules.uniq.each do |orig_sch|\n #TODO skip non-schedule-ruleset schedules\n \n #copy the original schedule\n new_sch = orig_sch.clone.to_ScheduleRuleset.get\n #reduce each value in each profile (except the design days) by the specified amount\n runner.registerInfo(\"Reducing values in '#{orig_sch.name}' schedule by #{percent_runtime_reduction}% to represent occ sensor installation.\")\n day_profiles = []\n day_profiles << new_sch.defaultDaySchedule\n new_sch.scheduleRules.each do |rule|\n day_profiles << rule.daySchedule\n end\n multiplier = (100 - percent_runtime_reduction)/100\n day_profiles.each do |day_profile|\n #runner.registerInfo(\"#{day_profile.name}\")\n times_vals = day_profile.times.zip(day_profile.values)\n #runner.registerInfo(\"original time/values = #{times_vals}\")\n times_vals.each do |time,val|\n day_profile.addValue(time, val * multiplier)\n end\n #runner.registerInfo(\"new time/values = #{day_profile.times.zip(day_profile.values)}\")\n end \n #log the relationship between the old sch and the new, reduced sch\n original_schs_new_schs[orig_sch] = new_sch\n #runner.registerInfo(\"***\")\n end\n \n #replace the old schedules with the new schedules\n spaces_sensors_added_to = []\n if apply_to_building #apply to the whole building\n runner.registerInfo(\"Adding occupancy sensors to whole building\")\n model.getLightss.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n runner.registerInfo(\"Adding occupancy sensors to space type '#{space_type.name}'\")\n space_type.lights.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n runner.registerInfo(\"Adding occupancy sensors to space '#{space.name}\")\n space.lights.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end \n end\n end \n \n #report if the measure is not applicable\n num_sensors_added = spaces_sensors_added_to.uniq.size\n if spaces_sensors_added_to.size == 0\n runner.registerAsNotApplicable(\"This measure is not applicable because there were no lights in the specified areas of the building.\")\n return true\n end\n \n #report initial condition\n runner.registerInitialCondition(\"The building has several areas where occupancy sensors could be used to reduce lighting energy by turning off the lights while no occupants are present.\") \n \n #add cost of adding occ sensors\n if material_and_installation_cost_per_space != 0\n cost = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"Add #{material_and_installation_cost_per_space} Occ Sensors to the Building\", model.getBuilding, material_and_installation_cost_per_space * num_sensors_added, \"CostPerEach\", \"Construction\", expected_life, 0)\n if cost.empty?\n runner.registerError(\"Failed to add costs.\")\n end\n end \n \n #report final condition\n if apply_to_building\n runner.registerFinalCondition(\"Add occupancy sensors to #{num_sensors_added} spaces in the building. The total cost to perform this is $#{material_and_installation_cost_per_space.round} per space, for a total cost of $#{(material_and_installation_cost_per_space * num_sensors_added).round}\")\n else\n runner.registerFinalCondition(\"Add occupancy sensors to #{num_sensors_added} #{space_type.name} spaces in the building. The total cost to perform this is $#{material_and_installation_cost_per_space.round} per space, for a total cost of $#{(material_and_installation_cost_per_space * num_sensors_added).round}\")\n end\n \n return true\n \n end",
"def run(model, runner, user_arguments)\r\n super(model, runner, user_arguments)\r\n\r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(model), user_arguments)\r\n return false\r\n end\r\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\r\n if run_measure == 0\r\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\r\n return true \r\n end\r\n \r\n require 'json'\r\n \r\n results = {}\r\n dx_name = []\r\n #get all DX coils in model\r\n dx_single = model.getCoilCoolingDXSingleSpeeds \r\n dx_two = model.getCoilCoolingDXTwoSpeeds\r\n dx_heat = model.getCoilHeatingDXSingleSpeeds\r\n \r\n if !dx_single.empty?\r\n dx_single.each do |dx|\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial COP: #{dx.ratedCOP.get}\")\r\n dx.setRatedCOP(OpenStudio::OptionalDouble.new(6.0))\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final COP: #{dx.ratedCOP.get}\")\r\n dx_name << dx.name.get\r\n end\r\n end\r\n if !dx_two.empty?\r\n dx_two.each do |dx|\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial High COP: #{dx.ratedHighSpeedCOP.get} Low COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx.setRatedHighSpeedCOP(6.0)\r\n dx.setRatedLowSpeedCOP(6.0)\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final High COP: #{dx.ratedHighSpeedCOP.get} Final COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx_name << dx.name.get\r\n end\r\n end\r\n if !dx_heat.empty?\r\n dx_heat.each do |dx|\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial COP: #{dx.ratedCOP}\")\r\n dx.setRatedCOP(6.0)\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final COP: #{dx.ratedCOP}\")\r\n dx_name << dx.name.get\r\n end\r\n end\r\n \r\n if dx_name.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\r\n end\r\n \r\n #unique initial conditions based on\r\n runner.registerInitialCondition(\"The building has #{dx_name.size} DX coils for which this measure is applicable.\")\r\n\r\n #reporting final condition of model\r\n runner.registerFinalCondition(\"The COP of the following coils was increased to 6: #{dx_name}\")\r\n return true\r\n\r\n end",
"def around_perform_stats(*args)\n start = Time.now\n yield\n time_taken = Time.now - start\n statsd.timing(\"duration:#{self}\", time_taken)\n statsd.increment(\"total_successful:#{self}\")\n statsd.increment(\"total_successful\")\n run_hooks(:duration, :duration, args) {|key| statsd.timing(key, time_taken)}\n end",
"def defMeasurement(name,&block)\n mp = {:mp => name, :fields => []}\n @fields = []\n # call the block with ourserlves to process its 'defMetric' statements\n block.call(self) if block\n @fields.each { |f| mp[:fields] << f }\n define_measurement_point(mp)\n end",
"def measure(heading)\n start_time = Time.now\n print heading\n result = yield\n end_time = Time.now - start_time\n puts \" (#{end_time} s)\"\n result\nend",
"def measure() @measure ||= (nb_weight == 0.0 ? 0.0 : sum_weight / nb_weight) end",
"def update\n if @clock1_measure.nil?\n discipline_freq\n else\n elapsed = @clock1.time - @clock1_measure.local_time\n discipline_freq if elapsed > @frequency_discipline_interval\n end\n if @clock2_measure.nil?\n discipline_phase\n else\n elapsed = @clock2.time - @clock2_measure.local_time\n discipline_phase if elapsed > @phase_discipline_interval\n end\n end",
"def record_measure(label)\n $logger.debug(\n tms = Benchmark.measure(label) do\n yield\n end.format(\"%n: %10.6rreal %10.6u user %10.6y sys\")\n )\nend",
"def run_examination\n true\n end",
"def benchmark!\n @benchmark = true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n\n pct_red = runner.getDoubleArgumentValue(\"pct_red\",user_arguments)\n start_hr = runner.getDoubleArgumentValue(\"start_hr\",user_arguments)\n end_hr = runner.getDoubleArgumentValue(\"end_hr\",user_arguments)\n \n\n\n #check the fraction for reasonableness\n if not 0 <= pct_red and pct_red <= 100\n runner.registerError(\"Percent reduction value needs to be between 0 and 100.\")\n return false\n end\n\n #check start_hr for reasonableness and round to 15 minutes\n start_red_hr = nil\n start_red_min = nil\n if not 0 <= start_hr and start_hr <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24\")\n return false\n else\n rounded_start_hr = ((start_hr*4).round)/4.0\n if not start_hr == rounded_start_hr\n runner.registerInfo(\"Start time rounded to nearest 15 minutes: #{rounded_start_hr}\")\n end\n start_red_hr = rounded_start_hr.truncate\n start_red_min = (rounded_start_hr - start_red_hr)*60\n start_red_min = start_red_min.to_i\n end\n\n #check end_hr for reasonableness and round to 15 minutes\n end_red_hr = nil\n end_red_min = nil \n if not 0 <= end_hr and end_hr <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24.\")\n return false\n elsif end_hr > end_hr\n runner.registerError(\"Please enter an end time later in the day than end time.\")\n return false\n else\n rounded_end_hr = ((end_hr*4).round)/4.0\n if not end_hr == rounded_end_hr\n runner.registerInfo(\"End time rounded to nearest 15 minutes: #{rounded_end_hr}\")\n end\n end_red_hr = rounded_end_hr.truncate\n end_red_min = (rounded_end_hr - end_red_hr)*60\n end_red_min = end_red_min.to_i\n end\n\n # Translate the percent reduction into a multiplier\n red_mult = pct_red/100\n\n # Get schedules from all lights.\n original_lights_schs = []\n model.getLightss.each do |lights|\n if lights.schedule.is_initialized\n lights_sch = lights.schedule.get\n original_lights_schs << lights_sch\n end\n end\n\n # loop through the unique list of lights schedules, cloning\n # and reducing schedule fraction during the specified time range.\n original_lights_schs_new_schs = {}\n original_lights_schs.uniq.each do |lights_sch|\n if lights_sch.to_ScheduleRuleset.is_initialized\n new_lights_sch = lights_sch.clone(model).to_ScheduleRuleset.get\n new_lights_sch.setName(\"#{lights_sch.name} with Solar Cogeneration and Daylighting\")\n original_lights_schs_new_schs[lights_sch] = new_lights_sch\n new_lights_sch = new_lights_sch.to_ScheduleRuleset.get\n \n # method to adjust the values in a day schedule by a \n # specified percentage during a range of hours.\n def reduce_schedule(day_sch, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n start_time = OpenStudio::Time.new(0, start_red_hr, start_red_min, 0)\n end_time = OpenStudio::Time.new(0, end_red_hr, end_red_min, 0)\n\n # Get the original values at the desired start and end times\n # and put points into the schedule at those times.\n day_sch.addValue(start_time, day_sch.getValue(start_time))\n day_sch.addValue(end_time, day_sch.getValue(end_time))\n \n # Store the original time/values then clear the schedule\n times = day_sch.times\n values = day_sch.values\n day_sch.clearValues\n\n # Modify the time/values and add back to the schedule\n for i in 0..(values.length - 1)\n if times[i] > start_time and times[i] <= end_time # Inside range\n day_sch.addValue(times[i], values[i] * red_mult)\n else\n day_sch.addValue(times[i], values[i])\n end\n end\n\n end #end reduce schedule\n\n # Reduce default day schedule\n if new_lights_sch.scheduleRules.size == 0\n runner.registerWarning(\"Schedule '#{new_lights_sch.name}' applies to all days. It has been treated as a Weekday schedule.\")\n end\n reduce_schedule(new_lights_sch.defaultDaySchedule, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n \n # Reduce all other schedule rules\n new_lights_sch.scheduleRules.each do |sch_rule|\n reduce_schedule(sch_rule.daySchedule, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n end\n \n end \n end #end of original_lights_schs.uniq.each do\n\n #loop through all lights instances, replacing old lights schedules with the reduced schedules\n model.getLightss.each do |lights|\n if lights.schedule.empty?\n runner.registerWarning(\"There was no schedule assigned for the lights object named '#{lights.name}. No schedule was added.'\")\n else\n old_lights_sch = lights.schedule.get\n lights.setSchedule(original_lights_schs_new_schs[old_lights_sch])\n runner.registerInfo(\"Schedule for the lights object named '#{lights.name}' was reduced to simulate the application of Solar Cogeneration and Daylighting.\")\n end\n end\n\n # NA if the model has no lights\n if model.getLightss.size == 0\n runner.registerNotAsApplicable(\"Not Applicable - There are no lights in the model.\")\n end\n\n # Reporting final condition of model\n runner.registerFinalCondition(\"#{original_lights_schs.uniq.size} schedule(s) were edited to reflect the addition of Solar Cogeneration and Daylighting to the building.\")\n \n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n \n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n\n\t#initialize variables\n\ttz_count = 0\n\tclg_tstat_schedule = []\n\tthermal_zone_array = []\n\t\t\n\t# get the thermal zones and loop through them \n\tmodel.getThermalZones.each do |thermal_zone|\n\t\n\t\tthermal_zone_array << thermal_zone\n\t\t\n\t\t# test to see if thermal zone has a thermostat object assigned or is unconditioned. \n\t\tif thermal_zone.thermostatSetpointDualSetpoint.is_initialized\n\t\t\tzone_thermostat = thermal_zone.thermostatSetpointDualSetpoint.get\n\t\t\ttz_count += 1\n\t\t\t\n\t\t\tif zone_thermostat.coolingSetpointTemperatureSchedule.is_initialized\n\t\t\t\tclg_tstat_schedule = zone_thermostat.coolingSetpointTemperatureSchedule.get\n\t\t\t\t\n\t\t\t\t# clone the existing cooling T-stat schedule in case it is used somewhere else in the model\n\t\t\t\tcloned_clg_tstat_schedule = clg_tstat_schedule.clone\n\t\t\t\t@new_clg_tstat_schedule_name = (\"#{clg_tstat_schedule.name}+1.5F\")\n\t\t\t\n\t\t\t\tif cloned_clg_tstat_schedule.to_ScheduleRuleset.is_initialized\n\t\t\t\t\tschedule = cloned_clg_tstat_schedule.to_ScheduleRuleset.get\n\t\t\t\t\t# gather profiles of cloned schedule\n\t\t\t\t\tprofiles = []\n\t\t\t\t\tcooling_thermostat_array = []\n\t\t\t\t\tdefaultProfile = schedule.to_ScheduleRuleset.get.defaultDaySchedule\n\t\t\t\t\n\t\t\t\t\tprofiles << defaultProfile\n\t\t\t\t\trules = schedule.scheduleRules\n\t\t\t\t\n\t\t\t\t\trules.each do |rule|\n\t\t\t\t\t\tprofiles << rule.daySchedule\n\t\t\t\t\tend # end the do loop through the rulesetsdo\n\n\t\t\t\t\t#adjust profiles of temperature schedule of cloned schedule by + 1.5 deg F delta (0.833 C)\n\t\t\t\t\tprofiles.each do |profile|\n\t\t\t\t\t\ttime = profile.times\n\t\t\t\t\t\ti = 0\n\t\t\t\t\t\t#TODO - name new profile\n\t\t\t\t\t\tprofile.values.each do |value|\n\t\t\t\t\t\t\tdelta = 0.8333\n\t\t\t\t\t\t\tnew_value = value + delta # Note this is where the cooling setpoint is raised\n\t\t\t\t\t\t\tprofile.addValue(time[i], new_value)\n\t\t\t\t\t\t\ti += 1\n\t\t\t\t\t\t\tcloned_clg_tstat_schedule.setName(@new_clg_tstat_schedule_name)\n\t\t\t\t\t\t\tcooling_thermostat_array << cloned_clg_tstat_schedule\n\t\t\t\t\t\tend # end loop through each profile values\n\t\t\t\t\tend # end loop through each profile\n\t\t\t\t\t\n\t\t\t\t\tzone_thermostat.setCoolingSetpointTemperatureSchedule(cloned_clg_tstat_schedule.to_ScheduleRuleset.get)\n\t\t\t\t\trunner.registerInfo(\"The existing cooling thermostat '#{clg_tstat_schedule.name}' has been changed to #{cloned_clg_tstat_schedule.name}. Inspect the new schedule values using the OS App.\")\n\t\t\t\tend # end if statement for cloning and modifying cooling tstat schedule object\n\t\t\telse\n\t\t\t\trunner.registerInfo(\"The dual setpoint thermostat object named #{zone_thermostat.name} serving thermal zone #{thermal_zone.name} did not have a cooling setpoint temperature schedule associated with it. The measure will not alter this thermostat object\")\n\t\t\tend # end if statement for cooling Setpoint Temperature is initialized\n\t\t\t\n\t\t\tif zone_thermostat.heatingSetpointTemperatureSchedule.is_initialized\n\t\t\t\thtg_tstat_schedule = zone_thermostat.heatingSetpointTemperatureSchedule.get\n\t\t\t\t\t\t\n\t\t\t\t# clone the existing heating T-stat schedule in case it is used somewhere else\n\t\t\t\tcloned_htg_tstat_schedule = htg_tstat_schedule.clone\n\t\t\t\t\n\t\t\t\t#name cloned heating t-stat schedule\n\t\t\t\tcloned_htg_tstat_schedule.setName(\"#{htg_tstat_schedule.name}-1.5F\")\n\n\t\t\t\tif cloned_htg_tstat_schedule.to_ScheduleRuleset.is_initialized\n\t\t\t\t\tschedule = cloned_htg_tstat_schedule.to_ScheduleRuleset.get\n\t\t\t\t\n\t\t\t\t\t# gather profiles of cloned schedule\n\t\t\t\t\tprofiles_h = []\n\t\t\t\t\tdefaultProfile = schedule.to_ScheduleRuleset.get.defaultDaySchedule\n\t\t\t\t\t\n\t\t\t\t\tprofiles_h << defaultProfile\n\t\t\t\t\trules_h = schedule.scheduleRules\n\t\t\t\t\trules_h.each do |rule_h|\n\t\t\t\t\t\tprofiles_h << rule_h.daySchedule\n\t\t\t\t\tend # end the rule_h do\n\n\t\t\t\t\t#adjust profiles_h of temperature schedule of cloned schedule by + 1.5 deg F delta (0.833 C)\n\t\t\t\t\tprofiles_h.each do |profile_h|\n\t\t\t\t\t\ttime_h = profile_h.times\n\t\t\t\t\t\ti = 0\n\t\t\t\t\t\t#TODO - name new profile\n\t\t\t\t\t\tprofile_h.values.each do |value_h|\n\t\t\t\t\t\t\tdelta_h = 0.8333\n\t\t\t\t\t\t\tnew_value_h = value_h - delta_h # Note this is where the heating setpoint is lowered \n\t\t\t\t\t\t\tprofile_h.addValue(time_h[i], new_value_h)\n\t\t\t\t\t\t\ti += 1\n\t\t\t\t\t\tend # end loop through each profile values\n\t\t\t\t\tend # end loop through each profile_h\n\t\t\t\t\t\n\t\t\t\t\tzone_thermostat.setHeatingSetpointTemperatureSchedule(cloned_htg_tstat_schedule.to_ScheduleRuleset.get)\n\t\t\t\t\trunner.registerInfo(\"The existing heating thermostat '#{htg_tstat_schedule.name}' has been changed to #{cloned_htg_tstat_schedule.name}. Inspect the new schedule values using the OS App.\")\n\t\t\t\tend # end if statement for cloning and modifying heating tstat schedule object\t\n\t\t\telse\n\t\t\t\trunner.registerInfo(\"The dual setpoint thermostat object named #{zone_thermostat.name} serving thermal zone #{thermal_zone.name} did not have a heating setpoint temperature schedule associated with it. The measure will not alter this thermostat object\")\n\t\t\tend # end if statement for heating Setpoint Temperature is initialized\n\t\tend\t# end if statement for zone_thermstat cooling schedule\n\t\t\n\tend # end loop through thermal zones\t\t\t\n\t\t\t\n\t# Add ASHRAE 55 Comfort Warnings are applied to people objects\n\t# get people objects and people definitions in model\n\tpeople_defs = model.getPeopleDefinitions\n\tpeople_instances = model.getPeoples\n\n\t# loop through people objects\n\tpeople_def_counter = 0\n\tpeople_defs.sort.each do |people_def|\n\t next if not people_def.instances.size > 0\n\t people_def_counter += 1\n\t people_def.setEnableASHRAE55ComfortWarnings(true)\n\tend\n\t\t\t\n\treporting_frequency = \"Timestep\"\n\toutputVariable = OpenStudio::Model::OutputVariable.new(\"Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status []\",model)\n\toutputVariable.setReportingFrequency(reporting_frequency)\n\trunner.registerInfo(\"Adding output variable for 'Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status' reporting '#{reporting_frequency}'\")\n\n\t# write As Not Applicable message\n\tif tz_count == 0\n\t\trunner.registerAsNotApplicable(\"Measure is not applicable. There are no conditioned thermal zones in the model.\")\n\t\treturn true\n\tend\n\n\t# report initial condition of model\n\trunner.registerInitialCondition(\"The initial model contained #{tz_count} thermal zones with #{thermal_zone_array.length} 'Cooling Thermostat Schedule' and #{thermal_zone_array.length} 'Heating Thermostat Schedule' objects for which this measure is applicable.\")\n\n\t# report final condition of model\n\trunner.registerFinalCondition(\"The #{thermal_zone_array.length} Heating and #{thermal_zone_array.length} Cooling Thermostats schedules for #{thermal_zone_array.length} Thermal Zones were altered to reflect a additional deadband width of 3 Deg F . \")\n\treturn true\n\n end",
"def stat(*args)\n @recorder.call(*args) if @recorder\n end",
"def measure (n=1)\n cnt=0\nelapsed_time=Time.now\n\nn.times {\n cnt+=1\n yield} \nelapsed_time=(Time.now-elapsed_time)/cnt\n\nend",
"def running_test_step; end",
"def run() end",
"def stat() end",
"def measure(msg)\n start = Time.now\n yield\n printf \"%<msg>s in %<elapsed>.2f seconds\\n\", msg: msg, elapsed: Time.now - start\nend",
"def measure(msg)\n start = Time.now\n yield\n printf \"%<msg>s in %<elapsed>.2f seconds\\n\", msg: msg, elapsed: Time.now - start\nend",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n #initialize variables\n zone_hvac_count = 0\n pump_count = 0\n air_loop_count = 0\n \n #loop through each air loop in the model\n model.getAirLoopHVACs.sort.each do |air_loop|\n\n # call the method to generate a new occupancy schedule based on a 5% threshold\n occ_sch = air_loop.get_occupancy_schedule(0.15)\n old_sch = air_loop.availabilitySchedule\n next unless compare_eflh(runner, old_sch, occ_sch)\n # set the availability schedule of the airloop to the newly generated schedule\n air_loop.setAvailabilitySchedule(occ_sch)\n runner.registerInfo(\"The availability schedule named #{old_sch.name} for #{air_loop.name} was replaced with a new schedule named #{occ_sch.name} which tracks the occupancy profile of the thermal zones on this airloop.\")\n air_loop_count +=1\n \n end\n\n #loop through each thermal zone\n model.getThermalZones.sort.each do |thermal_zone|\n \n # zone equipments assigned to thermal zones\n thermal_zone_equipment = thermal_zone.equipment \n \n if thermal_zone_equipment.size >= 1\n # run schedule method to create a new schedule ruleset, routines \n occ_sch = thermal_zone.get_occupancy_schedule(0.15)\n \n #loop through Zone HVAC Equipment\n thermal_zone_equipment.each do |equip|\n \n # getting the fan exhaust object & getting relevant information for it. \n if equip.to_FanZoneExhaust.is_initialized\n zone_equip = equip.to_FanZoneExhaust.get\n old_schedule = zone_equip.availabilitySchedule.get\n next unless compare_eflh(runner, old_schedule, occ_sch)\n #assign the 'occ_sch' here as exhaust's availability schedule\n zone_equip.setAvailabilitySchedule(occ_sch)\n runner.registerInfo(\"The availability schedule named #{old_schedule.name} for the OS_Fan_ZoneExhaust named #{zone_equip.name} was replaced with a new schedule named #{occ_sch.name} representing the occupancy profile of the thermal zone named #{thermal_zone.name}.\")\n zone_hvac_count += 1 \t\n elsif equip.to_RefrigerationAirChiller.is_initialized\n zone_equip = equip.to_RefrigerationAirChiller.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_WaterHeaterHeatPump.is_initialized\n zone_equip = equip.to_WaterHeaterHeatPump.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardConvectiveElectric.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardConvectiveElectric.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardConvectiveWater.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardConvectiveWater.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardRadiantConvectiveElectric.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardRadiantConvectiveElectric.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardRadiantConvectiveWater.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardRadiantConvectiveWater.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACDehumidifierDX.is_initialized\n zone_equip = equip.to_ZoneHVACDehumidifierDX.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACEnergyRecoveryVentilator.is_initialized\n zone_equip = equip.to_ZoneHVACEnergyRecoveryVentilator.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\n elsif equip.to_ZoneHVACFourPipeFanCoil.is_initialized\n zone_equip = equip.to_ZoneHVACFourPipeFanCoil.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneHVACHighTemperatureRadiant.is_initialized\n zone_equip = equip.to_ZoneHVACHighTemperatureRadiant.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\n elsif equip.to_ZoneHVACIdealLoadsAirSystem.is_initialized\n zone_equip = equip.to_ZoneHVACIdealLoadsAirSystem.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t \n elsif equip.to_ZoneHVACLowTemperatureRadiantElectric.is_initialized\n zone_equip = equip.to_ZoneHVACLowTemperatureRadiantElectric.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneHVACLowTempRadiantConstFlow.is_initialized\n zone_equip = equip.to_ZoneHVACLowTempRadiantConstFlow.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t \t\n elsif equip.to_ZoneHVACLowTempRadiantVarFlow.is_initialized\n zone_equip = equip.to_ZoneHVACLowTempRadiantVarFlow.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized\n zone_equip = equip.to_ZoneHVACPackagedTerminalAirConditioner.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACPackagedTerminalHeatPump.is_initialized\n zone_equip = equip.to_ZoneHVACPackagedTerminalHeatPump.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.is_initialized\n next unless compare_eflh(runner, old_schedule, occ_sch) \n equip.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.get.setTerminalUnitAvailabilityschedule(occ_sch)\n runner.registerInfo(\"The availability schedule for the Zone HVAC Terminal Unit Variable Refrigerant Flow Object has been replaced with a new schedule named #{occ_sch.name} representing the occupancy profile of the thermal zone named #{thermal_zone.name}.\")\t\t\t\t\t\n zone_hvac_count += 1 \n elsif equip.to_ZoneHVACUnitHeater.is_initialized\n zone_equip = equip.to_ZoneHVACUnitHeater.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\n elsif equip.to_ZoneHVACUnitVentilator.is_initialized\n zone_equip = equip.to_ZoneHVACUnitVentilator.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneVentilationDesignFlowRate.is_initialized\n runner.registerInfo(\"Thermal Zone named #{thermal_zone.name} has a Zone Ventilation Design Flow Rate object attacjhed as a ZoneHVACEquipment object. No modification were made to this object.\")\t\t\n end \t\n \n end # end loop through Zone HVAC Equipment\n \n else\n runner.registerInfo(\"Thermal Zone named #{thermal_zone.name} has no Zone HVAC Equipment objects attached - therefore no schedule objects have been altered.\")\t\n end # end of if statement\n \n end # end loop through thermal zones\n\n # Change pump control status if any airloops or\n # zone equipment were changed.\n if air_loop_count > 0 || zone_hvac_count > 0\n model.getPlantLoops.each do |plantLoop|\n #Loop through each plant loop demand component\n plantLoop.demandComponents.each do |dc|\n if dc.to_PumpConstantSpeed.is_initialized\n cs_pump = dc.to_PumpConstantSpeed.get\n if cs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Demand side Constant Speed Pump object named #{cs_pump.name} on the plant loop named #{dc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Pump Control Type attribute of Demand side Constant Speed Pump object named #{cs_pump.name} on the plant loop named #{dc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end\n end\n \n if dc.to_PumpVariableSpeed.is_initialized\n vs_pump = dc.to_PumpVariableSpeed.get\n if vs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Demand side Variable Speed Pump named #{vs_pump.name} on the plant loop named #{dc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Demand side Pump Control Type attribute of Variable Speed Pump named #{vs_pump.name} on the plant loop named #{dc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end\n end\n end\n \n #Loop through each plant loop supply component\n plantLoop.supplyComponents.each do |sc|\n if sc.to_PumpConstantSpeed.is_initialized\n cs_pump = sc.to_PumpConstantSpeed.get\n if cs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Supply side Constant Speed Pump object named #{cs_pump.name} on the plant loop named #{sc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Supply Side Pump Control Type atteribute of Constant Speed Pump named #{cs_pump.name} on the plant loop named #{sc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end #end if statement\t\n end #end if statement for changing supply component constant speed pump objects\n \n if sc.to_PumpVariableSpeed.is_initialized\n vs_pump = sc.to_PumpVariableSpeed.get\n if vs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Supply side Variable Speed Pump object named #{vs_pump.name} on the plant loop named #{sc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Pump Control Type attribute of Supply Side Variable Speed Pump named #{vs_pump.name} on the plant loop named #{sc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end #end if statement\t\n end #end if statement for changing supply component variable speed pump objects\n \n end # end loop throught plant loop supply side components\n \n end # end loop through plant loops\n end\n \n #Write N/A message\n if air_loop_count == 0 && zone_hvac_count == 0 && pump_count == 0 \n runner.registerAsNotApplicable(\"The model did not contain any Airloops, Thermal Zones having ZoneHVACEquipment objects or associated plant loop pump objects to act upon. The measure is not applicable.\")\n return true\n end\t\n \n #report initial condition of model\n runner.registerInitialCondition(\"The model started with #{air_loop_count} AirLoops, #{zone_hvac_count} Zone HVAC Equipment Object and #{pump_count} pump objects subject to modifications.\")\n \n # report final condition of model\n runner.registerFinalCondition(\"The measure modified the availability schedules of #{air_loop_count} AirLoops and #{zone_hvac_count} Zone HVAC Equipment objects. #{pump_count} pump objects had control settings modified.\")\n \n # Add ASHRAE Standard 55 warnings\n reporting_frequency = \"Timestep\"\n outputVariable = OpenStudio::Model::OutputVariable.new(\"Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status []\",model)\n outputVariable.setReportingFrequency(reporting_frequency)\n runner.registerInfo(\"Adding output variable for 'Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status' reporting at the model timestep.\")\n \n return true\n\t\n end",
"def calc_next_run\n nil\n end",
"def calc_next_run\n nil\n end",
"def estimate\n # (native code) \n end",
"def running_test_case; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def tick; end",
"def tick; end",
"def tick; end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n verbose_info_statements = runner.getBoolArgumentValue(\"verbose_info_statements\",user_arguments)\n fixed_window_subsurface = runner.getOptionalWorkspaceObjectChoiceValue('fixed_window_subsurface', user_arguments, model) # model is passed in because of argument type\n internal_variable_availability_dictionary_reporting = runner.getStringArgumentValue('internal_variable_availability_dictionary_reporting', user_arguments)\n ems_runtime_language_debug_output_level = runner.getStringArgumentValue('ems_runtime_language_debug_output_level', user_arguments) \n actuator_availability_dictionary_reporting = runner.getStringArgumentValue('actuator_availability_dictionary_reporting', user_arguments) \n \n runner.registerInitialCondition(\"Measure began with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n \n # declare arrys for scope\n array_of_21_sets = []\n material_property_glazing_spectral_data_vector = []\n standard_glazing_layer_array = []\n construction_array = []\n ems_window_construction_array = []\n \n # load idf into workspace\n workspace = OpenStudio::Workspace::load(OpenStudio::Path.new(\"#{File.dirname(__FILE__)}/resources/EMSThermochromicWindow.idf\")).get\n \n # get all MaterialPropertyGlazingSpectralData objects from within the idf\n # material_property_glazing_spectral_datas = source_idf.getObjectsByType(\"MaterialProperty:GlazingSpectralData\".to_IddObjectType)\n material_property_glazing_spectral_datas = workspace.getObjectsByType(\"MaterialProperty:GlazingSpectralData\".to_IddObjectType)\n if verbose_info_statements == true\n runner.registerInfo(\"The model has #{material_property_glazing_spectral_datas.size} material_property_glazing_spectral_datas objects.\")\n end\n \n material_property_glazing_spectral_datas.each do |material_property_glazing_spectral_data|\n \n spectral_data = {\"name\" => \"\",\"properties\" => []}\n spectral_data[\"name\"] = material_property_glazing_spectral_data.getString(0).to_s\n \n # Note: EnergyPlus file MaterialProperty:GlazingSpectralData objects have 1764 /4 = 441 sets of 4 values each \n n = material_property_glazing_spectral_data.numFields\n (1..n).each do |i| \n spectral_data[\"properties\"] << material_property_glazing_spectral_data.getString(i).to_s \n end\n array_of_21_sets << spectral_data\n end\n \n array_of_21_sets.each do |set|\n \n props = set[\"properties\"]\n material_property_glazing_spectral_data = OpenStudio::Model::MaterialPropertyGlazingSpectralData.new(model)\n material_property_glazing_spectral_data.setName(\"#{set[\"name\"]}\")\n \n k = (props.length / 4) - 1\n (0..k).each do |i| # note 440 uniques (a, b, c, d) pairs of attributes for each spectral data field object\n material_property_glazing_spectral_data.addSpectralDataField(props[(i*4)+0].to_f, props[(i*4)+1].to_f, props[(i*4)+2].to_f, props[(i*4)+3].to_f)\t\n end\n \n material_property_glazing_spectral_data_vector << material_property_glazing_spectral_data\n end \n \n # create (2) required new air gas materials to used by all EMS window constructions \n air_gas_3mm_material = OpenStudio::Model::Gas.new(model, \"Air\", 0.003) \n air_gas_3mm_material.setName(\"AIR 3MM\")\n \n air_gas_8mm_material = OpenStudio::Model::Gas.new(model, \"Air\", 0.008) \n air_gas_8mm_material.setName(\"AIR 8MM\")\n \n # loop through array of OS MaterialPropertyGlazingSpectralData objects and create 21 new Standard Glazing objects \n material_property_glazing_spectral_data_vector.each do |spec_data_obj|\n spec_data_obj_name = spec_data_obj.name\n layer_name = spec_data_obj_name.to_s.slice(\"sp\")\n if ((spec_data_obj_name == \"WO18RT25SP\") || (spec_data_obj_name == \"Clear3PPGSP\"))\n layer = OpenStudio::Model::StandardGlazing.new(model, 'Spectral', 0.0075)\n else\n layer = OpenStudio::Model::StandardGlazing.new(model, 'Spectral', 0.003276)\n end\n layer.setName(\"#{layer_name}\")\n layer.setWindowGlassSpectralDataSet(spec_data_obj)\n layer.setInfraredTransmittanceatNormalIncidence(0) # same for all 21 constructions\n layer.setFrontSideInfraredHemisphericalEmissivity(0.84) # same for all 21 constructions\n layer.setBackSideInfraredHemisphericalEmissivity(0.84) # same for all 21 constructions\n if ((spec_data_obj_name == \"WO18RT25SP\") || (spec_data_obj_name == \"Clear3PPGSP\"))\n layer.setConductivity(1.0) \n else\n layer.setConductivity(0.6) \n end\n layer.setDirtCorrectionFactorforSolarandVisibleTransmittance(1) # same for all 21 constructions\n layer.setSolarDiffusing(false)\n standard_glazing_layer_array << layer\n end\n\n # Create (2) unique standard glazing layers not used for Thermochromatic performance \n sb60_clear_3_ppg_layer = standard_glazing_layer_array[0]\n clear_3ppg_layer = standard_glazing_layer_array[1]\n remaining_standard_glazing_layer_array = standard_glazing_layer_array.drop(2)\n \n # create (19) new arrays of layered constructions representing thermochromatic layers\n remaining_standard_glazing_layer_array.each do |remaining_standard_glazing_layer|\n construction = [sb60_clear_3_ppg_layer, air_gas_3mm_material, remaining_standard_glazing_layer, air_gas_8mm_material, sb60_clear_3_ppg_layer]\n construction_array << construction\n end\n \n # create 19 new OS:Construction objects representing EMS thermochromatic windows\n name_index_array = [25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 50, 55, 60, 65, 70, 75, 80, 85]\n index = 0\n \n construction_array.each do |const|\n ems_window_construction = OpenStudio::Model::Construction.new(const)\n ems_window_construction.setName(\"TCwindow_#{name_index_array[index]}\")\n if verbose_info_statements == true\n runner.registerInfo(\"Created a new Construction named #{ems_window_construction.name} representing a thermochromatic window construction.\")\n end\n ems_window_construction_array << ems_window_construction\n index +=1\n end\n\n # check the user argument of the fixed window subsurface for reasonableness\n if fixed_window_subsurface.empty?\n handle = runner.getStringArgumentValue('fixed_window_subsurface', user_arguments)\n if handle.empty?\n runner.registerError('No fixed window subsurface was chosen.')\n else\n runner.registerError(\"The selected fixed window subsurface with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !fixed_window_subsurface.get.to_SubSurface.empty?\n fixed_window_subsurface = fixed_window_subsurface.get.to_SubSurface.get\n else\n runner.registerError('Script Error - argument not showing up as construction.')\n return false\n end\n end\n \n # Create a new EnergyManagementSystem:Sensor object representing the Surface Outside Face temp of the EMS thermochromatic window subsurface\n ems_win_Tout_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"Surface Outside Face Temperature\")\n ems_win_Tout_sensor.setName(\"Win1_Tout\")\n ems_win_Tout_sensor.setKeyName(\"#{fixed_window_subsurface.name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Sensor object named '#{ems_win_Tout_sensor.name}' representing the Surface Outside Face temp of the EMS thermochromatic window subsurface was added to the model.\") \n end\n \n # Create a new EMS Actuator Object representing the construction state of the EMS generated thermochromatic window \n ems_win_construct_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(fixed_window_subsurface, \"Surface\", \"Construction State\")\n ems_win_construct_actuator.setName(\"Win1_Construct\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Actuator object named '#{ems_win_construct_actuator.name}' representing construction state of the EMS generated thermochromatic window was added to the model.\") \n end\n \n # Create 19 EnergyManagementSystem:ConstructionIndexVariable objects for each unique thermochromatic construction\n ems_window_construction_array.each do |ems_window_construction|\n ems_constr_index_var = OpenStudio::Model::EnergyManagementSystemConstructionIndexVariable.new(model, ems_window_construction ) \n ems_constr_index_var.setName(\"#{ems_window_construction.name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS SystemConstructionIndexVariable object named '#{ems_constr_index_var.name}' representing the the EMS construction state of the thermochromatic window was added to the model.\") \n end\n end\n \n # Create new EnergyManagementSystem:Program object for assigning different window constructions by dynamically evaluating the exterior surface temp of the fixed window subsurface \n ems_apply_thermochromatic_constructions_prgm = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_apply_thermochromatic_constructions_prgm.setName(\"#{fixed_window_subsurface.name}_Control\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"IF #{ems_win_Tout_sensor.name} <= 26.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_25\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 28.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_27\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 30.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_29\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 32.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_31\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 34.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_33\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 36.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_35\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 38.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_37\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 40.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_39\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 42.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_41\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 44.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_43\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 47.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_45\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 52.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_50\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 57.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_55\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 62.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_60\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 67.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_65\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 72.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_70\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 77.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_75\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 82.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_80\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSE\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_85\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ENDIF\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Program Object named '#{ems_apply_thermochromatic_constructions_prgm.name}' for dynamically assigning different window constructions based on the exterior surface temp was added to the model.\") \n end\n \n # Create a new EnergyManagementSystem:ProgramCallingManager object configured to call the EMS programs\n ems_prgm_calling_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n ems_prgm_calling_mngr.setName(\"My thermochromic window emulator\")\n ems_prgm_calling_mngr.setCallingPoint(\"BeginTimestepBeforePredictor\")\n ems_prgm_calling_mngr.addProgram(ems_apply_thermochromatic_constructions_prgm)\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program Calling Manager object named '#{ems_prgm_calling_mngr.name}' added to call EMS program for dynamically applying a thermochromatic window.\") \n end\n \n # create unique object for OutputEnergyManagementSystems and configure to allow EMS reporting\n outputEMS = model.getOutputEnergyManagementSystem\n outputEMS.setInternalVariableAvailabilityDictionaryReporting(\"internal_variable_availability_dictionary_reporting\")\n outputEMS.setEMSRuntimeLanguageDebugOutputLevel(\"ems_runtime_language_debug_output_level\")\n outputEMS.setActuatorAvailabilityDictionaryReporting(\"actuator_availability_dictionary_reporting\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS OutputEnergyManagementSystem object configured per user arguments.\") \n end\n \n runner.registerFinalCondition(\"Measure finished with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n end",
"def bench(action, msg = nil)\n @t ||= Time.now\n @total ||= 0\n @step ||= 0\n case action\n when :start\n @step = 0\n @total = 0\n @t = Time.now\n when :step\n @step += 1\n int = Time.now - @t\n @total += int\n @t = Time.now\n dbg(\"Benchmark #{msg.nil? ? (\"%02d\" % @step) : msg}: #{\"%8.3fms\" % (int * 1000)} (Total: #{\"%8.3fms\" % (@total * 1000)}).\")\n end\nend",
"def apply_measure_and_run(test_name, measure, argument_map, osm_path, epw_path, run_model: false)\n assert(File.exist?(osm_path))\n assert(File.exist?(epw_path))\n\n # create run directory if it does not exist\n if !File.exist?(run_dir(test_name))\n FileUtils.mkdir_p(run_dir(test_name))\n end\n assert(File.exist?(run_dir(test_name)))\n\n # change into run directory for tests\n start_dir = Dir.pwd\n Dir.chdir run_dir(test_name)\n\n # remove prior runs if they exist\n if File.exist?(model_output_path(test_name))\n FileUtils.rm(model_output_path(test_name))\n end\n if File.exist?(report_path(test_name))\n FileUtils.rm(report_path(test_name))\n end\n\n # copy the osm and epw to the test directory\n new_osm_path = \"#{run_dir(test_name)}/#{File.basename(osm_path)}\"\n FileUtils.cp(osm_path, new_osm_path)\n new_epw_path = \"#{run_dir(test_name)}/#{File.basename(epw_path)}\"\n FileUtils.cp(epw_path, new_epw_path)\n # create an instance of a runner\n runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)\n\n # load the test model\n model = load_model(new_osm_path)\n\n # set model weather file\n epw_file = OpenStudio::EpwFile.new(OpenStudio::Path.new(new_epw_path))\n OpenStudio::Model::WeatherFile.setWeatherFile(model, epw_file)\n assert(model.weatherFile.is_initialized)\n\n # run the measure\n puts \"\\nAPPLYING MEASURE...\"\n measure.run(model, runner, argument_map)\n result = runner.result\n\n # show the output\n show_output(result)\n\n # save model\n model.save(model_output_path(test_name), true)\n\n errs = []\n if run_model && (result.value.valueName == 'Success')\n puts \"\\nRUNNING ANNUAL SIMULATION...\"\n\n std = Standard.build('NREL ZNE Ready 2017')\n std.model_run_simulation_and_log_errors(model, run_dir(test_name))\n\n # check that the model ran successfully and generated a report\n assert(File.exist?(model_output_path(test_name)))\n assert(File.exist?(sql_path(test_name)))\n assert(File.exist?(report_path(test_name)))\n\n # set runner variables\n runner.setLastEpwFilePath(epw_path)\n runner.setLastOpenStudioModelPath(OpenStudio::Path.new(model_output_path(test_name)))\n runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sql_path(test_name)))\n sql = runner.lastEnergyPlusSqlFile.get\n model.setSqlFile(sql)\n\n # test for unmet hours\n unmet_heating_hrs = std.model_annual_occupied_unmet_heating_hours(model)\n unmet_cooling_hrs = std.model_annual_occupied_unmet_cooling_hours(model)\n unmet_hrs = std.model_annual_occupied_unmet_hours(model)\n max_unmet_hrs = 550\n if unmet_hrs\n if unmet_hrs > 550\n errs << \"For #{test_name} there were #{unmet_heating_hrs.round(1)} unmet occupied heating hours and #{unmet_cooling_hrs.round(1)} unmet occupied cooling hours (total: #{unmet_hrs.round(1)}), more than the limit of #{max_unmet_hrs}.\" if unmet_hrs > max_unmet_hrs\n else\n puts \"There were #{unmet_heating_hrs.round(1)} unmet occupied heating hours and #{unmet_cooling_hrs.round(1)} unmet occupied cooling hours (total: #{unmet_hrs.round(1)}).\"\n end\n else\n errs << \"For #{test_name} could not determine unmet hours; simulation may have failed.\"\n end\n end\n\n # change back directory\n Dir.chdir(start_dir)\n\n assert(errs.empty?, errs.join(\"\\n\"))\n\n return result\n end",
"def after_assumption(name); end",
"def call\n result = while_measuring_memory_usage { action.call }\n\n Measurement.from_result(result)\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n retrofit_month = runner.getStringArgumentValue('retrofit_month', user_arguments).to_i\n retrofit_day = runner.getStringArgumentValue('retrofit_day', user_arguments).to_i\n\n # report initial condition of model\n runner.registerInitialCondition(\"Measure started successfully.\")\n\n # TODO: check the month and day for reasonableness\n runner.registerInfo(\"User entered retrofit month: #{retrofit_month}\")\n runner.registerInfo(\"User entered retrofit day: #{retrofit_day}\")\n\n prog_calling_manager = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n prog_calling_manager.setCallingPoint('BeginTimestepBeforePredictor')\n\n # Remove old and add new equip with EMS by spaces\n hash_space_epd = Hash.new\n v_spaces = model.getSpaces\n v_spaces.each do |space|\n current_space_equip = space.electricEquipment[0]\n unless current_space_equip.nil?\n\n # Get equipment power density for each space type\n new_space_epd = runner.getOptionalDoubleArgumentValue(\"new_#{space.name.to_s}_epd\", user_arguments)\n if new_space_epd.is_initialized\n hash_space_epd[\"new_#{space.name.to_s}_epd\"] = new_space_epd\n runner.registerInfo(\"User entered new electric equipment power density for #{space.name.to_s} is #{new_space_epd} W/m2\")\n # Set ems\n current_space_equip_def = current_space_equip.electricEquipmentDefinition\n equip_sch_name = current_space_equip.schedule.get.nameString\n equip_sch_ems_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')\n equip_sch_ems_sensor.setKeyName(equip_sch_name)\n runner.registerInfo(\"Delete old equip object for #{space.name}\")\n current_space_equip.remove\n\n new_equip = add_equip_space(space, current_space_equip_def)\n equip_level_w = new_space_epd.to_f * space.floorArea.to_f\n ems_equip_program = add_equip_ems(model, new_equip, equip_level_w, equip_sch_ems_sensor, retrofit_month, retrofit_day)\n prog_calling_manager.addProgram(ems_equip_program)\n runner.registerInfo(\"Add ems equipment control for #{space.name} succeeded.\")\n else\n # Get equipment power ratio for each space type\n new_space_ratio = runner.getDoubleArgumentValue(\"new_#{space.name.to_s}_ratio\", user_arguments)\n\n old_equip_sch = current_space_equip.schedule.get\n ems_equip_program = add_equip_ems_w_occ_var(model, current_space_equip, old_equip_sch, new_space_ratio, retrofit_month, retrofit_day)\n prog_calling_manager.addProgram(ems_equip_program)\n runner.registerInfo(\"Add ems equipment control for #{space.name} succeeded.\")\n # runner.registerInfo(\"Delete old equip object for #{space.name}\")\n # current_space_equip.remove\n end\n\n end\n end\n\n # Remove old and add new equip with EMS by space types\n hash_space_type_epd = Hash.new\n v_space_types = model.getSpaceTypes\n v_space_types.each do |space_type|\n current_spaces = space_type.spaces\n current_space_type_equip = space_type.electricEquipment[0]\n unless current_space_type_equip.nil?\n # Get equipment power density for each space type\n current_space_type_epd = runner.getStringArgumentValue(\"new_#{space_type.name.to_s}_epd\", user_arguments)\n hash_space_type_epd[\"new_#{space_type.name.to_s}_epd\"] = current_space_type_epd\n runner.registerInfo(\"User entered new electric equipment power density for #{space_type.name.to_s} is #{current_space_type_epd} W/m2\")\n\n # Set ems\n current_space_type_equip_def = current_space_type_equip.electricEquipmentDefinition\n current_space_type_sch_set = space_type.defaultScheduleSet.get\n current_space_type_equip_sch_set = current_space_type_sch_set.electricEquipmentSchedule.get\n\n equip_sch_name = current_space_type_equip_sch_set.nameString\n equip_sch_ems_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')\n equip_sch_ems_sensor.setKeyName(equip_sch_name)\n\n puts \"Delete old equip object for #{space_type.name}\"\n current_space_type_equip.remove\n\n current_spaces.each do |space|\n # Calculate equipemtn electric power for each space\n new_equip = add_equip_space_type(model, space, space_type, current_space_type_equip_def)\n equip_level_w = current_space_type_epd.to_f * space.floorArea.to_f\n ems_equip_program = add_equip_ems(model, new_equip, equip_level_w, equip_sch_ems_sensor, retrofit_month, retrofit_day)\n prog_calling_manager.addProgram(ems_equip_program)\n runner.registerInfo(\"Add ems equipment control for #{space.name} succeeded.\")\n end\n end\n end\n\n # echo the model updates back to the user\n runner.registerInfo(\"The electric equipment retrofit measure is applied.\")\n\n # report final condition of model\n runner.registerFinalCondition(\"Measure ended successfully.\")\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n runner.registerInfo(\"Start to create lighting measure from occupant schedule\")\n\n ### Get user selected lighting space assumptions for each space\n v_space_types = model.getSpaceTypes\n i = 1\n lght_space_type_arg_vals = {}\n # Loop through all space types, group spaces by their types\n v_space_types.each do |space_type|\n # Loop through all spaces of current space type\n v_current_spaces = space_type.spaces\n next if not v_current_spaces.size > 0\n v_current_spaces.each do |current_space|\n lght_space_type_val = runner.getStringArgumentValue(@@v_space_args[current_space.nameString], user_arguments)\n lght_space_type_arg_vals[current_space.nameString] = lght_space_type_val\n i += 1\n end\n end\n\n puts lght_space_type_arg_vals\n\n ### Start creating new lighting schedules based on occupancy schedule\n occ_schedule_dir = runner.getStringArgumentValue('occ_schedule_dir', user_arguments)\n model_temp_run_path = Dir.pwd + '/'\n measure_root_path = File.dirname(__FILE__)\n\n puts '=' * 80\n puts measure_root_path\n\n if File.file?(occ_schedule_dir)\n # Check if user provided a occupancy schedule CSV file\n csv_file = occ_schedule_dir\n puts 'Use user provided occupancy schedule file at: ' + csv_file.to_s\n runner.registerInitialCondition('Location check:' + File.expand_path(\"../..\", measure_root_path))\n # runner.registerInitialCondition('Use user provided occupancy schedule file at: ' + csv_file.to_s)\n else\n # Check if schedule file at several places\n # 1. Default fils path when run with OSW in CLI\n csv_path_lookup_1 = File.expand_path(\"../..\", measure_root_path) + \"/files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"First lookup location: \" + csv_path_lookup_1\n runner.registerInfo(\"First lookup location: \" + csv_path_lookup_1)\n # 2. Default path when run with OpenStudio CLI\n csv_path_lookup_2 = File.expand_path(\"../..\", model_temp_run_path) + \"/files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"Second lookup location: \" + csv_path_lookup_2\n runner.registerInfo(\"Second lookup location: \" + csv_path_lookup_2)\n # 3. Default path when run with OpenStudio GUI\n csv_path_lookup_3 = File.expand_path(\"../../..\", model_temp_run_path) + \"/resources/files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"Third lookup location: \" + csv_path_lookup_3\n runner.registerInfo(\"Third lookup location: \" + csv_path_lookup_3)\n # 4. Generated files folder when run with rspec\n csv_path_lookup_4 = File.expand_path(\"..\", model_temp_run_path) + \"/generated_files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"Forth lookup location: \" + csv_path_lookup_4\n runner.registerInfo(\"Forth lookup location: \" + csv_path_lookup_4)\n # 5. Generated files folder with OpenStudio V2.9.0+\n csv_path_lookup_5 = File.join(File.expand_path(\"../..\", model_temp_run_path), 'generated_files', @@default_occupant_schedule_filename)\n puts '#' * 80\n puts \"Fifth lookup location: \" + csv_path_lookup_5\n runner.registerInfo(\"Fifth lookup location: \" + csv_path_lookup_5)\n\n if File.file?(csv_path_lookup_1)\n csv_file = csv_path_lookup_1\n elsif File.file?(csv_path_lookup_2)\n csv_file = csv_path_lookup_2\n elsif File.file?(csv_path_lookup_3)\n csv_file = csv_path_lookup_3\n elsif File.file?(csv_path_lookup_4)\n csv_file = csv_path_lookup_4 \n elsif File.file?(csv_path_lookup_5)\n csv_file = csv_path_lookup_5\n else\n csv_file = ''\n end\n puts 'Use default occupancy schedule file at: ' + csv_file.to_s\n runner.registerInfo('Use default occupancy schedule file at: ' + csv_file.to_s)\n end\n\n # Get the spaces with occupancy count schedule available\n v_spaces_occ_sch = File.readlines(csv_file)[3].split(',') # Room ID is saved in 4th row of the occ_sch file\n v_headers = Array.new\n v_spaces_occ_sch.each do |space_occ_sch|\n if !['Room ID', 'Outdoor', 'Outside building'].include? space_occ_sch and !space_occ_sch.strip.empty?\n v_headers << space_occ_sch\n end\n end\n v_headers = [\"Time\"] + v_headers\n\n # report initial condition of model\n runner.registerInfo(\"The building has #{v_headers.length - 1} spaces with available occupant schedule file.\")\n\n # Read the occupant count schedule file and clean it\n clean_csv = File.readlines(csv_file).drop(6).join\n csv_table_sch = CSV.parse(clean_csv, headers: true)\n new_csv_table = csv_table_sch.by_col!.delete_if do |column_name, column_values|\n !v_headers.include? column_name\n end\n\n runner.registerInfo(\"Successfully read occupant count schedule from CSV file.\")\n runner.registerInfo(\"Creating new lighting schedules...\")\n\n # Create lighting schedule based on the occupant count schedule\n v_cols = Array.new\n v_ts = new_csv_table.by_col!['Time']\n v_headers.each do |header|\n if header != 'Time'\n space_name = header\n v_occ_n = new_csv_table.by_col![space_name]\n v_light = create_lighting_sch_from_occupancy_count(space_name, v_ts, v_occ_n, @@off_delay)\n v_cols << v_light\n end\n end\n\n runner.registerInfo(\"Writing new lighting schedules to CSV file.\")\n # Write new lighting schedule file to CSV\n file_name_light_sch = \"#{model_temp_run_path}/#{@@lighting_schedule_CSV_name}\"\n vcols_to_csv(v_cols, file_name_light_sch)\n\n # Add new lighting schedule from the CSV file created\n runner.registerInfo(\"Removing old OS:Lights and OS:Lights:Definition for office and conference rooms.\")\n # Remove old lights definition objects for office and conference rooms\n v_space_types.each do |space_type|\n space_type.spaces.each do |space|\n selected_space_type = lght_space_type_arg_vals[space.name.to_s]\n if (@@office_type_names.include? selected_space_type) || (@@conference_room_type_names.include? selected_space_type)\n space_type.lights.each do |lght|\n puts 'Remove old lights definition object: ' + lght.lightsDefinition.name.to_s\n lght.lightsDefinition.remove\n end\n end\n end\n end\n\n # Remove old lights objects for office and conference rooms\n # Caution: the order of deletion matters\n v_space_types.each do |space_type|\n space_type.spaces.each do |space|\n selected_space_type = lght_space_type_arg_vals[space.name.to_s]\n if (@@office_type_names.include? selected_space_type) || (@@conference_room_type_names.include? selected_space_type)\n space_type.lights.each do |lght|\n puts 'Remove old lights object: ' + lght.name.to_s\n lght.remove\n end\n end\n end\n end\n\n puts '---> Create new lighting schedules from CSV.'\n\n runner.registerInfo(\"Adding new OS:Schedule:File objects to the model....\")\n v_spaces = model.getSpaces\n v_spaces.each do |space|\n v_headers.each_with_index do |s_space_name, i|\n if s_space_name == space.name.to_s\n col = i\n temp_file_path = file_name_light_sch\n sch_file_name = space.name.to_s + ' lght sch'\n schedule_file = get_os_schedule_from_csv(model, temp_file_path, sch_file_name, col, skip_row = 1)\n schedule_file.setMinutesperItem(@@minute_per_item.to_s)\n model = add_light(model, space, schedule_file)\n end\n end\n end\n\n # report final condition of model\n runner.registerFinalCondition(\"Finished creating and adding new lighting schedules for #{v_headers.length - 1} spaces.\")\n\n return true\n end",
"def span\n measure\n @span\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n \n #use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # System Type 2: PTHP, Residential\n # This measure creates:\n # a constant volume packaged terminal heat pump unit with DX heating \n # and cooling for each zone in the building\n \n always_on = model.alwaysOnDiscreteSchedule\n\n # Make a PTHP for each zone\n model.getThermalZones.each do |zone|\n \n fan = OpenStudio::Model::FanConstantVolume.new(model,always_on)\n fan.setPressureRise(300)\n\n supplemental_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model,always_on)\n\n clg_cap_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)\n clg_cap_f_of_temp.setCoefficient1Constant(0.942587793)\n clg_cap_f_of_temp.setCoefficient2x(0.009543347)\n clg_cap_f_of_temp.setCoefficient3xPOW2(0.0018423)\n clg_cap_f_of_temp.setCoefficient4y(-0.011042676)\n clg_cap_f_of_temp.setCoefficient5yPOW2(0.000005249)\n clg_cap_f_of_temp.setCoefficient6xTIMESY(-0.000009720)\n clg_cap_f_of_temp.setMinimumValueofx(17.0)\n clg_cap_f_of_temp.setMaximumValueofx(22.0)\n clg_cap_f_of_temp.setMinimumValueofy(13.0)\n clg_cap_f_of_temp.setMaximumValueofy(46.0)\n\n clg_cap_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)\n clg_cap_f_of_flow.setCoefficient1Constant(0.718954)\n clg_cap_f_of_flow.setCoefficient2x(0.435436)\n clg_cap_f_of_flow.setCoefficient3xPOW2(-0.154193)\n clg_cap_f_of_flow.setMinimumValueofx(0.75)\n clg_cap_f_of_flow.setMaximumValueofx(1.25)\n\n clg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)\n clg_energy_input_ratio_f_of_temp.setCoefficient1Constant(0.342414409)\n clg_energy_input_ratio_f_of_temp.setCoefficient2x(0.034885008)\n clg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(-0.000623700)\n clg_energy_input_ratio_f_of_temp.setCoefficient4y(0.004977216)\n clg_energy_input_ratio_f_of_temp.setCoefficient5yPOW2(0.000437951)\n clg_energy_input_ratio_f_of_temp.setCoefficient6xTIMESY(-0.000728028)\n clg_energy_input_ratio_f_of_temp.setMinimumValueofx(17.0)\n clg_energy_input_ratio_f_of_temp.setMaximumValueofx(22.0)\n clg_energy_input_ratio_f_of_temp.setMinimumValueofy(13.0)\n clg_energy_input_ratio_f_of_temp.setMaximumValueofy(46.0)\n\n clg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)\n clg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.1552)\n clg_energy_input_ratio_f_of_flow.setCoefficient2x(-0.1808)\n clg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.0256)\n clg_energy_input_ratio_f_of_flow.setMinimumValueofx(0.5)\n clg_energy_input_ratio_f_of_flow.setMaximumValueofx(1.5)\n\n clg_part_load_fraction = OpenStudio::Model::CurveQuadratic.new(model)\n clg_part_load_fraction.setCoefficient1Constant(0.75)\n clg_part_load_fraction.setCoefficient2x(0.25)\n clg_part_load_fraction.setCoefficient3xPOW2(0.0)\n clg_part_load_fraction.setMinimumValueofx(0.0)\n clg_part_load_fraction.setMaximumValueofx(1.0)\n\n clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,\n always_on,\n clg_cap_f_of_temp,\n clg_cap_f_of_flow,\n clg_energy_input_ratio_f_of_temp,\n clg_energy_input_ratio_f_of_flow,\n clg_part_load_fraction)\n\n htg_cap_f_of_temp = OpenStudio::Model::CurveCubic.new(model)\n htg_cap_f_of_temp.setCoefficient1Constant(0.758746)\n htg_cap_f_of_temp.setCoefficient2x(0.027626)\n htg_cap_f_of_temp.setCoefficient3xPOW2(0.000148716)\n htg_cap_f_of_temp.setCoefficient4xPOW3(0.0000034992)\n htg_cap_f_of_temp.setMinimumValueofx(-20.0)\n htg_cap_f_of_temp.setMaximumValueofx(20.0)\n\n htg_cap_f_of_flow = OpenStudio::Model::CurveCubic.new(model)\n htg_cap_f_of_flow.setCoefficient1Constant(0.84)\n htg_cap_f_of_flow.setCoefficient2x(0.16)\n htg_cap_f_of_flow.setCoefficient3xPOW2(0.0)\n htg_cap_f_of_flow.setCoefficient4xPOW3(0.0)\n htg_cap_f_of_flow.setMinimumValueofx(0.5)\n htg_cap_f_of_flow.setMaximumValueofx(1.5)\n\n htg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveCubic.new(model)\n htg_energy_input_ratio_f_of_temp.setCoefficient1Constant(1.19248)\n htg_energy_input_ratio_f_of_temp.setCoefficient2x(-0.0300438)\n htg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(0.00103745)\n htg_energy_input_ratio_f_of_temp.setCoefficient4xPOW3(-0.000023328)\n htg_energy_input_ratio_f_of_temp.setMinimumValueofx(-20.0)\n htg_energy_input_ratio_f_of_temp.setMaximumValueofx(20.0)\n\n htg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)\n htg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.3824)\n htg_energy_input_ratio_f_of_flow.setCoefficient2x(-0.4336)\n htg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.0512)\n htg_energy_input_ratio_f_of_flow.setMinimumValueofx(0.0)\n htg_energy_input_ratio_f_of_flow.setMaximumValueofx(1.0)\n\n htg_part_load_fraction = OpenStudio::Model::CurveQuadratic.new(model)\n htg_part_load_fraction.setCoefficient1Constant(0.75)\n htg_part_load_fraction.setCoefficient2x(0.25)\n htg_part_load_fraction.setCoefficient3xPOW2(0.0)\n htg_part_load_fraction.setMinimumValueofx(0.0)\n htg_part_load_fraction.setMaximumValueofx(1.0)\n\n htg_coil = OpenStudio::Model::CoilHeatingDXSingleSpeed.new( model,\n always_on,\n htg_cap_f_of_temp,\n htg_cap_f_of_flow,\n htg_energy_input_ratio_f_of_temp,\n htg_energy_input_ratio_f_of_flow,\n htg_part_load_fraction ) \n\n pthp = OpenStudio::Model::ZoneHVACPackagedTerminalHeatPump.new(model,\n always_on, \n fan,\n htg_coil,\n clg_coil,\n supplemental_htg_coil)\n\n pthp.setName(\"#{zone.name} PTHP\")\n pthp.addToThermalZone(zone)\n\n end\n\n \n return true\n \n end"
] | [
"0.7984654",
"0.76391506",
"0.7635997",
"0.71696514",
"0.6692245",
"0.6692245",
"0.6672187",
"0.6630635",
"0.6598557",
"0.6587669",
"0.65313715",
"0.6481984",
"0.6405212",
"0.64018977",
"0.63331616",
"0.6284003",
"0.6284003",
"0.6284003",
"0.6280883",
"0.6269114",
"0.6242129",
"0.6220219",
"0.6196817",
"0.61963415",
"0.61963415",
"0.613111",
"0.61070645",
"0.60716754",
"0.60513824",
"0.60180604",
"0.6008489",
"0.6008489",
"0.5999642",
"0.59752226",
"0.59640926",
"0.5961962",
"0.59586793",
"0.59572476",
"0.59572476",
"0.59458774",
"0.59334147",
"0.5927729",
"0.59212303",
"0.59168243",
"0.5912971",
"0.5912157",
"0.5901739",
"0.5870623",
"0.58662254",
"0.58653766",
"0.5846795",
"0.58387405",
"0.5838315",
"0.57889616",
"0.5773113",
"0.5769482",
"0.57563287",
"0.5744905",
"0.5739598",
"0.5724039",
"0.57182187",
"0.5714246",
"0.5699603",
"0.5698249",
"0.56974393",
"0.568892",
"0.56881225",
"0.5685161",
"0.5673086",
"0.5661831",
"0.5648094",
"0.56476986",
"0.5645455",
"0.56383663",
"0.56383663",
"0.56335735",
"0.56218266",
"0.56218266",
"0.56090885",
"0.5607752",
"0.5596829",
"0.5596829",
"0.5596829",
"0.5596829",
"0.5596829",
"0.5596829",
"0.5596829",
"0.5596829",
"0.5596829",
"0.5595833",
"0.5595833",
"0.5595833",
"0.55890876",
"0.5583086",
"0.55677503",
"0.55674726",
"0.5563867",
"0.5563604",
"0.5559335",
"0.5557927",
"0.55490464"
] | 0.0 | -1 |
=> 5 Phase I First, write a function that compares each element to every other element of the list. Return the element if all other elements in the array are larger. What is the time complexity for this function? Phase II Now rewrite the function to iterate through the list just once while keeping track of the minimum. What is the time complexity? def largest_contiguous_subsum(list)0(n^3) new_arr = [] (0...list.length).each do |i| (i...list.length).each do |j| new_arr << list[i..j].sum end end new_arr.max end | def largest_contiguous_subsum(list)
current_max = list[0]
current_sum = list[0]
(1...list.size).each do |i|
current_sum += list[i]
if current_sum > current_max
current_max = current_sum
end
if current_sum < 0
current_sum = 0
end
end
current_max
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def largest_contiguous_subsum_1(list)\n subs = []\n (0...list.length).each do |idx| #O(n)\n (idx...list.length).each do |idx_2| #O(n)\n subs << list[idx..idx_2] #O(n)\n end\n end\n max = list.first\n subs.each do |subarr|\n if subarr.sum > max\n max = subarr.sum\n end\n end\n max\nend",
"def largest_contiguous_subsum(list) # O(n^2)\n array = []\n list.each_with_index do |ele1, i1| # O(n^2)\n (i1...list.length).each do |i2|\n array << list[i1..i2]\n end\n end\n\n max_sum = array.first.sum\n array[1..-1].each do |subarr| # O(n^2)\n sum = subarr.sum\n if sum > max_sum\n max_sum = sum\n end\n end\n\n max_sum\n\nend",
"def largest_contiguous_subsum1(list)\n greatest_sum = -1.0/0.0\n (0...list.length).each do |i|\n (i...list.length).each do |j|\n greatest_sum = list[i..j].sum if greatest_sum < list[i..j].sum\n end\n end\n greatest_sum\nend",
"def largest_contiguous_subsum1(list)\n arr = []\n (0...list.length).each do |i|\n (i...list.length).each { |j| arr << list[i..j] }\n end\n largest_sum = arr.first.sum\n arr.each do |sub_arr|\n largest_sum = sub_arr.sum if sub_arr.sum > largest_sum\n end\n largest_sum\nend",
"def largest_contiguous_subsum2(array)\n # return [list[0]] if list.count == 1\n #\n # start_num = list.shift\n # large_sum = start_num\n #\n # other_list = list.dup\n #\n # idx = 0\n # while idx < list.count\n # sum = list[0..idx].inject(:+)\n # if large_sum < start_num + sum\n # large_sum = start_num + sum\n # end\n # idx += 1\n # end\n #\n # [large_sum] + largest_contiguous_subsum2(other_list)\n\n largest = nil\n current = 0\n\n array.each do |el|\n current += el\n if largest.nil? || current > largest\n largest = current\n end\n current = 0 if current < 0\n end\n\n largest\n\nend",
"def largest_contiguous_subsum(list)\n new_arr = []\n\n (0...list.length).each do |idx1| #O(n)\n (0...list.length).each do |idx2| #O(n)\n if idx2 >= idx1 #O(1)\n new_arr << list[idx1..idx2].sum #O(1)\n end \n end \n \n end \n \n return new_arr.max #O(n)\nend",
"def largest_contiguous_subsum(list)\n max_sum = list[0]\n\ttemp_sum = list[0]\n\tdebugger\n #0(n) #note: only n^2 if nested\n \n return list.max if list.all? { |ele| ele < 0 } \n #need to add O(1) return case\n # Write a new function using O(n) time with O(1) memory. Keep a running tally of the largest sum.\n\n list_2 = list.drop(1)\n list_2.each do |ele|\n\t\ttemp_sum = [ele, temp_sum + ele].max #O(1) operation, should refactor \n #temp_sum = ele = 4, temp_sum = 1+3, [4, 8].max\n # [3, -7]\n #[3, 5 + 3] = > 3, 8 = > 8 max = 5\n #[-7, 8 - 7] => 1, 1 = > 1 max = 8\n max_sum = temp_sum if temp_sum > max_sum\n\tend\n\t\n\tmax_sum\nend",
"def largest_contiguous_subsum_2(list)\n current_sum = 0\n largest_sum = 0\n (0...list.length).each do |idx|\n current_sum += list[idx]\n largest_sum = current_sum if current_sum > largest_sum\n current_sum = 0 if current_sum < 0\n end\n largest_sum\nend",
"def largest_contiguous_sub_sum1(list)\n max = list[0]\n (0...list.length).each do |i|\n (i...list.length).each do |j| \n sub_sum = list[i..j].sum \n max = sub if sub >= max \n end\n end\n max\nend",
"def largest_contiguous_subsum(list) # O(n^2)\n subs_sums = []\n\n list.each_index do |i|\n list.each_index do |j|\n next if j < i\n subs_sums << list[i..j]\n end\n end\n\n highest_array_sum = nil\n subs_sums.each do |array|\n array_sum = array.reduce(:+)\n if highest_array_sum == nil || array_sum > highest_array_sum\n highest_array_sum = array_sum\n end\n end\n\n highest_array_sum\nend",
"def largest_contiguous_subsum(list)\n # debugger\n results = [] # O(1)\n\n list.each_with_index do |el1, idx1| # O(n)\n list.each_with_index do |el2, idx2| # O(n) => O(n^2)\n next if idx2 < idx1 # O(1)\n results << list[idx1..idx2] # O(1)\n end\n end\n\n results.map! { |subsum| subsum.reduce(:+) } # O(n^2)\n results.max # O(1)\nend",
"def largest_contiguous_subsum_2(list)# [2, 3, -6, 7, -6, 7]\n largest_num = list[0]#2 O(1)\n running_sum = list[0]#2 - 5 after entering loop. O(1)\n\n (1...list.length).each do |i| #O(n) \n running_sum = 0 if running_sum < 0 #O(1)\n running_sum += list[i] #O(1)\n largest_num = running_sum if running_sum > largest_num #O(1)\n end\n return largest_num #O(1)\nend",
"def largest_contiguous_subsum(arr) #BigO of O(n)\n max = 0 \n current_sum = 0\n arr.each_with_index do |el,idx|\n if current_sum + el >= el \n current_sum += el \n else \n current_sum = el \n end \n max = current_sum if current_sum > max \n end \n max\nend",
"def largest_contiguous_subsum_1(list) \n subs = [] #O(1)\n (0...list.length).each do |start_num| #O(n)\n (start_num...list.length).each do |end_num| #O(n)\n subs << list[start_num..end_num] #O(n)\n end\n end\n subs_sum = [] #O(1)\n subs.each do |sub| #O(n**2)\n sub_sum = 0 #O(1)\n sub.each {|s| sub_sum += s} #O(n)\n subs_sum << sub_sum #O(1)\n end\n subs_sum.inject do |acc,el| #O(n)\n if acc > el #O(1)\n acc #O(1)\n else\n el #O(1)\n end\n end\n end",
"def largest_contiguous_subsum1(list)\n p Time.now\n sub_arrays = []\n list.each_index do |i|\n list.each_index do |j|\n next if j < i\n sub_arrays << list[i..j]\n end\n end\n sub_arrays.map{|numbers| numbers.inject(:+)}.max\n p Time.now\nend",
"def largest_contiguous_subsum(list)\r\n sub_arr = []\r\n list.each_with_index do |ele1,idx1|\r\n list.each_with_index do |ele2,idx2|\r\n sub_arr<< list[idx1..idx2] if idx2>=idx1\r\n end\r\n end\r\n p sub_arr.size\r\n sub_arr.map{ |sub| sub.sum}.max\r\n #(O(n^2 + m)\r\nend",
"def largest_contiguous_subsum_2(list)\n largest_sum = 0\n current_sum = 0\n\n list.each do |el|\n largest_sum = current_sum \n current_sum += el \n if current_sum < el \n current_sum = el \n end \n largest_sum = current_sum if largest_sum < current_sum\n end\n\n largest_sum\nend",
"def largest_contiguous_subsum_v2(arr) # O(n)\n\n largest_sum = arr[0]\n current_sum = arr[0]\n \n (1...arr.length).each do |i|\n if current_sum < 0\n if current_sum < arr[i]\n current_sum = arr[i]\n end\n else\n current_sum += arr[i]\n end\n if current_sum > largest_sum\n largest_sum = current_sum\n end\n end\n largest_sum\nend",
"def largest_contiguous_subsum2(list)\n # O(N) ==> Time\n # O(1) ==> Space\n largest = list.first\n curr = list.first\n\n len = list.length\n (1...len).each do |i|\n curr = 0 if curr < 0 \n curr += list[i]\n largest = curr if curr > largest\n end\n largest\nend",
"def largest_contiguous_subsum(list)\n curr_sum = list[0]\n max_sum = list[0]\n (1...list.length).each do |idx|\n # debugger\n curr_sum += list[idx]\n if curr_sum < list[idx] \n curr_sum = list[idx]\n end\n if curr_sum > max_sum\n max_sum = curr_sum\n end\n end\n max_sum\nend",
"def largest_contiguous_subsum_one(list)\n sub_arr = []\n sum = 0\n list.each_with_index do |ele, i|\n (i...list.length).each do |i2|\n sub_arr << list[i..i2]\n end\n end\n sub_arr.each do |arr|\n if arr.sum > sum\n sum = arr.sum\n end\n end\n sum\nend",
"def largest_contiguous_subsum2(list)\n result = list.first\n sum = list.first\n\n list.each_with_index do |n, i|\n next if i == 0\n\n sum = 0 if sum < 0\n\n sum += n\n\n result = sum if sum > result\n end\n\n result\nend",
"def largest_contiguous_subsum(list)\n helper_arr = [list.first]\n (1...list.length).each do |idx|\n if helper_arr[-1] + list[idx] > list[idx]\n helper_arr << helper_arr[-1] + list[idx]\n else\n helper_arr << list[idx]\n end\n end\n helper_arr.max\nend",
"def largest_contiguous_subsum(list)\n # O(N*M) ==> Time\n # O(N*M) ==> Space\n sub_arrs = sub_arrays_of(list) # O(N^3)\n sums = []\n sub_arrs.each do |sub_arr| ## O(N*M)\n sums << sub_arr.sum\n end\n # Get the max of the sums array\n sums.max # O(N)\nend",
"def largest_contiguous_subsum(list)\r\n \r\n largest = -1*Float::INFINITY\r\n current_sum = 0\r\n\r\n list.each do |num|\r\n if (current_sum += num ) < 0\r\n current_sum = 0\r\n if largest < num\r\n largest = num\r\n end\r\n else\r\n largest = current_sum if largest < current_sum\r\n end\r\n end\r\n largest\r\n # last_idx = 0\r\n # list.each_with_index do |e, i|\r\n # if current_sum < 0 || (current_sum += e) > largest\r\n # last_idx = i \r\n # largest = current_sum > 0 ? current_sum : e\r\n # end\r\n # end\r\n # p largest\r\n # p last_idx\r\n # largest = -1*Float::INFINITY\r\n # current_sum = 0\r\n\r\n # last_idx.downto(0).each do |i|\r\n # if current_sum < 0 || (current_sum += list[i]) > largest\r\n # largest = current_sum > 0 ? current_sum : list[i]\r\n # end\r\n # end\r\n\r\n # largest\r\nend",
"def largest_contiguous_subsum(list) \n subs = []\n\n (0...list.length).each do |i|\n (i...list.length).each do |j|\n sub = list[i..j]\n subs << sub\n end\n end\n \n max = nil\n\n subs.each do |sub|\n sum = sub.sum \n if max == nil || sum > max\n max = sum\n end\n end\n max\nend",
"def largest_contiguous_subsum1(array)\n sub_array = []\n\n array.each_index do |i|\n array.each_index do |j|\n next if i > j\n sub_array << array[i..j]\n end\n end\n sum = sub_array.first.inject(:+)\n sub_array.each do |el|\n sum = el.inject(:+) if el.inject(:+) > sum\n end\n sum\nend",
"def largest_contiguous_subsum_fast(list)\n start = Time.now\n max_sum = list[0]\n cur_sum = list[0]\n list[1..-1].each do |el|\n if el >= cur_sum && cur_sum < 0\n cur_sum = el\n else\n cur_sum += el\n end\n max_sum = cur_sum if cur_sum > max_sum\n end\n finish = Time.now\n puts \"Runtime: #{finish - start}\"\n return max_sum\nend",
"def largest_contiguous_subsum(list)\n max_sum = list.first\n current_sum = list.first\n \n (1...list.length).each do |i| \n current_sum = 0 if current_sum < 0 \n current_sum += list[i]\n max_sum = current_sum if current_sum > max_sum\n end\n max_sum\nend",
"def largest_contiguous_subsum2(int_list)\n largest_sum = int_list.first\n curr_sum = int_list.first\n\n (1...int_list.length).each do |idx|\n curr_sum = (int_list[idx] > curr_sum + int_list[idx]) ? int_list[idx] : curr_sum + int_list[idx]\n largest_sum = curr_sum if curr_sum > largest_sum\n end\n\n largest_sum\nend",
"def better_largest_contiguous_subsum(list)\n current_largest_sum = 0\n current_sum = 0\n return list.max if list.all? {|ele| ele < 0}\n\n (0...list.length).each do |i |\n # debugger\n #add current element to current sum\n current_sum += list[i]\n\n #if current sum is less than 0 ignore it and reset to move on to next number\n if ( current_sum < 0 ) \n current_sum = 0\n end \n # if current sum is greater than our current largest sum, we want to keep it\n if current_sum > current_largest_sum\n current_largest_sum = current_sum\n end\n end\n current_largest_sum\nend",
"def largest_contiguous_subsum(list)\n largest_sum = 0\n current_sum = list[0]\n (1...list.length).each do |i|\n current_sum = 0 if current_sum < 0 #we need to reset current sum if we hit a negative number\n current_sum += list[i]\n largest_sum = current_sum if current_sum > largest_sum\n end\n largest_sum\nend",
"def largest_contiguous_subsum1(list)\n sums = []\n\n list.each_with_index do |el1, i1|\n list.each_with_index do |el2, i2|\n if i1 == i2\n sums << el1\n else\n sums << el1 + el2\n end\n end\n end\n\n result = sums.first\n\n sums.each do |sum|\n result = sum if sum > result\n end\n\n result\nend",
"def largest_contiguous_subsum_2(list)\n largest_sum = list.first\n current_sum = 0\n list.each do |ele| \n current_sum += ele\n if current_sum > largest_sum\n largest_sum = current_sum\n end\n current_sum = 0 if current_sum < 0 \n end\n largest_sum\nend",
"def largest_contiguous_sub_sum2(arr)\n #one varable tracks largest sum\n #one variable tracks current sum\n #O(n) + O(1)\n # list = [2, 3, -6, 7, -6, 7]\n\n # largest_sum= arr.first\n\n # i = 0\n # arr_end = true\n\n # while arr_end\n # current_sum = arr[i]\n # if arr[i+1] == nil\n # arr_end = false\n # puts \"This is current sum: #{current_sum}\"\n # else\n # if current_sum > largest_sum\n # current_sum += arr[i+1]\n # largest_sum = current_sum\n # end\n # end\n # if i < arr.length\n # arr_end = true\n # i += 1\n # end\n # end\n # largest_sum\n \n\n\n # arr.each_with_index do |ele, idx|\n # if ele > largest_sum\n # largest_sum = ele\n # end\n\n # i = idx\n # sum = ele\n # while i < arr.length - 1\n # if sum <= sum + arr[i+1]\n # largest_sum = sum + arr[i+1]\n # end\n # sum = sum + arr[i+1]\n # i+=1\n # end\n # end\n # largest_sum\n\nend",
"def better_largest_contiguous_subsum(list)\n total_sum = list.first\n current_sum = list.first\n\n list.each_index do |idx| \n current_sum = [list[idx], current_sum + list[idx]].max\n total_sum = [total_sum, current_sum].max\n end\n\n return total_sum\nend",
"def largest_contiguous_subsum(arr)\n max = 0\n\n (0...arr.count).each do |i|\n sum = arr[i]\n (i + 1...arr.count).each do |j|\n sum += arr[j]\n max = sum if max < sum \n end \n end \n\n max\nend",
"def largest_contiguous_subsum_slow(arr)\n res = arr.first\n (0...arr.length - 1).each do |i|\n (i+1...arr.length).each do |j|\n tmp_sum = arr[i..j].reduce(:+)\n res = tmp_sum if tmp_sum > res\n end\n end\n return res\nend",
"def largest_contiguous_subsum_2(arr)\n sum = 0\n max = 0\n arr.each do |num|\n sum += num\n if sum > 0\n max = sum if sum > max\n else\n sum = 0\n end\n end\n max\nend",
"def largest_contiguous_subsum2(array)\r\n largest = array[0]\r\n current_sum = array[0]\r\n\r\n (1...array.length).each do |i|\r\n current_sum = 0 if current_sum < 0\r\n num = array[i]\r\n current_sum += num\r\n if current_sum > largest\r\n largest = current_sum\r\n end\r\n end\r\n\r\n largest\r\nend",
"def largest_contiguous_subsum(array)\n sums_list = []\n sums = []\n\n idx1 = 0\n\n while idx1 < array.length #O(n)\n idx2 = idx1 #O(1)\n while idx2 < array.length #O(n)\n sums_list << array[idx1..idx2] #O(n)\n idx2 += 1\n end\n idx1 += 1\n end\n\n sums_list.each do |list| #O(n)\n sums << list.reduce {|sum, num| sum + num} #O(n)\n end\n sums.max\nend",
"def largest_contiguous_subsum2(list)\n sum = 0 # keeps track of current sum\n largest_sum = list.first # evaluates to the largest sum\n list.each do |ele|\n sum += ele \n largest_sum = sum if sum > largest_sum\n sum = 0 if sum < 0\n end\n largest_sum\nend",
"def largest_contiguous_subsum(list)\n new_arr = []\n (0...list.length - 1).each do |i|\n (i...list.length).each do |j|\n new_arr << list[i..j]\n end\n end\n new_arr.map { |sub_arr| sub_arr.sum }.max\nend",
"def largest_contiguous_subsum(list)\n max_sum = 0\n i = 0\n while i < list.size\n curr_sum = list[0..i].take(i).sum #take from front\n max_sum = curr_sum if curr_sum > max_sum\n\n curr_sum = list[i..-1].take(i).sum #take from front\n max_sum = curr_sum if curr_sum > max_sum\n\n curr_sum = list[0..i].drop(i).sum #drop from back\n max_sum = curr_sum if curr_sum > max_sum\n\n curr_sum = list[i..-1].drop(i).sum #drop from back\n max_sum = curr_sum if curr_sum > max_sum\n\n curr_sum = list[i..-i].take(i).sum #take from front\n max_sum = curr_sum if curr_sum > max_sum\n\n curr_sum = list[i..-i].drop(i).sum #drop from back\n max_sum = curr_sum if curr_sum > max_sum\n\n i += 1\n end\n max_sum\nend",
"def largest_contiguous_subsum1(list)\n subs = []\n (0...list.length).each do |i|\n (i...list.length).each do |j|\n subs << list[i..j]\n end\n end\n\n subs.map(&:sum).max\nend",
"def largest_contiguous_subsum(array)\r\n max = array.first \r\n current_sum = 0\r\n array.each do |ele|\r\n current_sum += ele\r\n max = current_sum if current_sum > max\r\n current_sum = 0 if current_sum < 0\r\n end\r\n max\r\nend",
"def largest_contiguous_subsum2(list)\n largest_sum = list[0]\n current_sum = 0\n# list = [2, 3, -6, 7, -6, 7]\n list.each do |number|\n current_sum += number\n if current_sum > largest_sum\n largest_sum = current_sum\n elsif current_sum < 0\n current_sum = 0\n end\n end\n largest_sum\nend",
"def largest_contiguous_subsum2(array)\n #all negative numbers\n if array.none? {|el| el > 0 }\n max = array.first\n array.each do |el1|\n next if max == el1\n if el1 > max\n max = el1\n end\n end\n max\n end\n\n current_sum = 0\n max_sum = 0\n\n array.each do |num|\n current_sum += num\n max_sum = current_sum if current_sum > max_sum\n if current_sum < 0\n current_sum = 0\n next\n current_sum += num\n max_sum = current_sum if current_sum > max_sum\n end\n\n end\n max_sum\n\nend",
"def largest_contiguous_subsum_v2(list)\n largest_sum = list.first\n sum = list.first # but the first element can be a negative number\n\n (1...list.length).each do |i|\n # a negative number + a postive number always less than pos number on its own\n sum = 0 if sum < 0 # if we add to a negative sum, then result is less than pos number on its own\n sum += list[i]\n largest_sum = sum if largest_sum < sum\n end\n\n largest_sum\nend",
"def largest_contiguous_subsum(list)\n prev_max = -9999999999999\n new_max = 0\n list.each do |ele|\n new_max += ele\n prev_max = new_max if prev_max <= new_max\n new_max = 0 if new_max < 0 # Reset\n end\n prev_max\nend",
"def largest_cont_subsum_fast(list)\n # for constant size to be true, you cant create any variables\n # whose memory size depends on the size of the input\n curr_sum = list[0]\n largest_sum = list[0]\n\n # we know there are n^2 potential, so if we ever check all of them\n # it must be n^2\n\n # there must be a way to find the max without checking every subarray\n list[1..-1].each do |ele|\n # debugger\n if curr_sum > largest_sum\n largest_sum = curr_sum\n end\n\n if curr_sum < 0\n curr_sum = 0\n end\n\n curr_sum += ele\n\n end\n\n # debugger\n return [largest_sum, curr_sum].max\n\nend",
"def largest_contiguous_subsum(arr)\n i = 0\n subs = []\n while i < arr.length\n j = i\n\n while j < arr.length\n subs << arr[i..j]\n\n j += 1\n end\n\n i += 1\n end\n\n\n return (subs.max {|a, b| a.sum <=> b.sum}).sum\n\nend",
"def largest_contiguous_subsum(list)\n subs = [] \n (0...list.length).each do |i|\n (i...list.length).each do |j|\n subs << list[i..j]\n end\n end\n\n subs.map {|el| el.sum}.max\nend",
"def largest_contiguous_subsum(arr)\n max_sum = arr.first\n\n (0...arr.length).each do |start|\n (start...arr.length).each do |ending|\n sum = arr[start..ending].sum\n max_sum = sum if sum > max_sum\n end\n end\n\n max_sum\nend",
"def largest_contiguous_subsum(list)\r\n max_val = 0 #8\r\n current_sum = 0 #8\r\n list.each do |num|\r\n current_sum = [0, current_sum + num].max\r\n max_val = [max_val, current_sum].max\r\n end\r\n return max_val\r\nend",
"def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend",
"def largest_contiguous_subsum_1(list)\r\n subarrays = [] #1\r\n list.each_with_index do |ele1, i| #n\r\n list[i...list.length].each_with_index do |ele2,i2| #(n-1)\r\n subarrays << list[i..i2+i] #k \r\n end\r\n end # n^2\r\n subarrays.map { |subarray| subarray.sum}.max # n^x\r\nend",
"def largest_contiguous_subsum(array)\n current_sum = array.first\n largest_sum = array.first\n array.each do |num|\n current_sum += num\n if largest_sum < current_sum\n largest_sum = current_sum\n end\n end\n largest_sum\nend",
"def largest_contiguous_subsum(list)\n sub_arr = []\n \n (0...list.length).each do |idx|\n (idx...list.length).each do |jdx|\n sub_arr << list[idx..jdx]\n end\n end\n\n sub_arr.map! {|ele| ele.sum}.max\nend",
"def largest_cont_subsum_slow(list) # n = list.length\n subarrs = find_subarrays(list) # n^2 runtime\n largest = subarrs[0].sum\n \n subarrs.each do |subarr| # n^2 length subarrs\n largest = [largest, subarr.sum].max # constant\n end\n\n return largest\n # n^2 overall\nend",
"def largest_contiguous_subsum(list)\n length = 1\n sub_arrays = []\n until length == list.length\n sub_arrays += list.each_cons(length).to_a\n length += 1\n end\n sub_arrays.map! { |el| el.reduce(:+) }.max\n\n # sub_arrays = []\n #\n # list.each_with_index do |ele, idx1|\n # list.each_with_index do |ele2, idx2|\n # sub_arrays << list[idx1..idx2] unless list[idx1..idx2].length < 1\n # end\n # end\n # sub_arrays.map! { |el| el.reduce(:+) }.max\n\nend",
"def largest_contiguous_subsum(array)\n sub_arrs = []\n array.each_index do |ind1|\n array[ind1..-1].each_index do |ind2|\n sub_arrs.push(array[ind1..ind2+ind1])\n end\n end\n max_sum = sub_arrs.first.sum\n sub_arrs.each {|sub| max_sum = sub.sum if sub.sum >= max_sum }\n return max_sum\nend",
"def largest_contiguous_subsum(nums)\n running_sum = 0\n max = nums.first || 0\n\n nums.each do |n|\n running_sum += n\n max = running_sum if max < running_sum\n running_sum = 0 if running_sum < 0\n end\n max\nend",
"def largest_contiguous_subsum_fast(array)\n curr_sum = array.first\n largest_sum = array.first\n\n return array.max if array.all?{|val| val < 0} # O(n)\n\n array.drop(1).each_with_index do |val, i|\n if val > 0 # add val to curr_sum and largest_sum if it's positive\n curr_sum += val\n largest_sum = curr_sum\n elsif val < 0\n temp_sum = curr_sum + val\n\n if val + curr_sum > 0\n curr_sum += val\n elsif array[i + 1] + temp_sum < array[i + 1]\n curr_sum = 0\n largest_sum = array[i + 1]\n else\n largest_sum = temp_sum + array[i + 1]\n end\n end\n\n end\n largest_sum\nend",
"def largest_contiguous_subsum(arr) # n^2\n subs = []\n (0...arr.length).each do |start_i|\n (start_i...arr.length).each do |end_i|\n subs << arr[start_i..end_i]\n end\n end\n\n subs.map { |sub| sub.inject(:+) }.max\nend",
"def largest_contiguous_subsum(arr)\n subs = []\n l = arr.length\n (0...l).each do |i|\n (0...l).each do |j| \n subs << arr[i..j] if arr[i..j].length > 0 # n*n *( n) == n^3 + n\n end\n end\n subs.map(&:sum).max\nend",
"def largest_contiguous_subsum(list)\n answer=[]\n list.each_with_index do |ele,index|\n list.each_with_index do |ele2,index2|\n if index2 >= index \n answer.push(list[index..index2])\n end\n end\n end\n answer.map {|array| array.sum}.max\nend",
"def largest_contiguous_subsum(arr)\n max = arr.first\n arr.each_index do |idx1|\n (idx1+1..arr.length).each do |idx2|\n sub_arr = arr[idx1...idx2]\n sum = sub_arr.reduce(:+)\n max = sum if max < sum \n end\n\n end\n max\nend",
"def largest_contiguous_subsum(array)\n previous_sum = 0\n current_sum = 0\n array.each_with_index do |el, i|\n\n current_sum = previous_sum + el\n if previous_sum < 0\n if el < previous_sum\n current_sum = previous_sum\n else\n current_sum = el\n end\n end\n\n previous_sum = current_sum\n end\n\n current_sum\nend",
"def largest_contiguous_subsum2(arr)\n max = arr[0]\n current = arr[0]\n arr.drop(1).each do |num|\n current += num\n max = current if current > max\n current = 0 if current < 0\n end\n max\nend",
"def largest_contiguous_subsum_good(arr) \n last_max = arr.first\n current_max = 0\n arr.each do |num|\n temp_sum = current_max + num\n if temp_sum < 0\n last_max = current_max if temp_sum > last_max\n else\n if temp_sum > last_max\n last_max = temp_sum\n end\n end\n if num > temp_sum\n current_max = num\n else\n current_max = temp_sum\n end\n end\n last_max\nend",
"def better_largest_contiguous_subsum(arr)\n largest_sum = 0\n current_sum = 0\n i = 0\n while i < arr.length\n if arr[i] + current_sum >= 0\n current_sum += arr[i]\n else\n current_sum = 0\n end \n largest_sum = current_sum if current_sum > largest_sum \n i += 1\n end\n largest_sum\n end",
"def largest_contiguous_subsum(list)\n all_subarrays = Array.new \n i = 0 \n j = 0\n\n while j < list.length \n while i < list.length \n all_subarrays << list[j..i]\n i += 1 \n end \n j += 1 \n i = j \n end\n\n sums = Array.new\n\n all_subarrays.each do |arr|\n sum = 0\n\n arr.each { |n| sum += n }\n\n sums << sum\n end\n\n sums.max\nend",
"def largest_contiguous_subsum(arr)\r\n all_sub_arrays = [] # space : O(n^2)\r\n\r\n (0...arr.length).each do |i|\r\n (i...arr.length).each do |i2|\r\n all_sub_arrays << arr[i..i2] # slice makes n^3\r\n end\r\n end\r\n\r\n all_sub_arrays.map { |sub_arr| sub_arr.sum }.max # O(n^2)\r\nend",
"def largest_contiguous_subsum(arr)\n\n\nend",
"def largest_contiguous_sub_sum(arr)\n subarrs = [] #O(1)\n\n (0...arr.length).each do |idx| #O(n)\n (idx...arr.length).each do |jdx| #O(n/2)\n subarrs << arr[idx..jdx] #O(n)\n end\n end \n\n subarrs.map! do |array| #O(n)\n array.reduce(:+) #O(n)\n end \n\n subarrs.max #O(n)\nend",
"def largest_contiguous_subsum(arr)\n result = []\n\n arr.each_with_index do |el1, idx1|\n i = idx1\n while i < arr.length\n result << arr[idx1..i]\n i += 1\n end\n end\n\n largest_sum = result.first.inject(:+)\n result.each do |sub_arr|\n curr_sum = sub_arr.inject(:+)\n largest_sum = curr_sum if curr_sum > largest_sum\n end\n largest_sum\nend",
"def largest_contiguous_subsum1(array)\r\n subset = []\r\n array.each_index do |i| # make subets, store into 'subset' array\r\n (i...array.length).each do |j| # o(n^2)\r\n subset << array[i..j] # o(n^3) cause slicing\r\n end\r\n end\r\n\r\n subset_sum = []\r\n subset.each do |ele|\r\n subset_sum << ele.sum\r\n end\r\n subset_sum.max\r\nend",
"def largest_contiguous_subsum_1(arr)\n res = []\n i = 0\n while i < arr.length\n j = i\n while j < arr.length\n res << arr[i..j].reduce(:+)\n j += 1\n end\n i += 1\n end\n res.max\nend",
"def best_largest_contiguous_subsum(arr)\n return arr.max if arr.max < 0\n largest = 0\n current = 0\n\n\n (0..(arr.length-1)).each do |idx1|\n if current + arr[idx1] < 0\n current = arr[idx1]\n else\n current += arr[idx1]\n end\n\n largest = current if current > largest\n end\n largest\nend",
"def largest_contiguous_subsum(arr)\n sum = arr.first\n\n (0...(arr.length - 1)).each do |idx1|\n (idx1..(arr.length - 1)).each do |idx2|\n if idx1 == idx2\n ss = arr[idx1]\n else\n ss = arr[idx1..idx2].reduce(:+)\n end\n sum = ss if ss > sum\n end\n end\n sum\nend",
"def largest_contiguous_subsum_2(arr)\n (1...arr.length).each do |i|\n if arr[i] + arr[i - 1] > 0\n arr[i] = arr[i] + arr[i - 1]\n elsif arr[i] < 0 && arr[i-1] < 0\n arr[i] = [arr[i-1], arr[i]].max\n else\n arr[i] = 0\n end\n end\n\n arr.max\nend",
"def largest_contiguous_subsum_once(arr)\n largest_subsum = 0\n current = 0\n\n arr.each do |elm|\n current += elm\n if largest_subsum < current\n largest_subsum = current\n elsif current < 0\n current = 0 \n end \n end \n\n # (0...arr.count).each do |i|\n # current_subsum = (largest_subsum + arr[i])\n # if current_subsum > largest_subsum \n # largest_subsum = current_subsum \n # elsif current_subsum < 0 \n # largest_subsum = 0 \n # end\n # end \n\n largest_subsum \nend",
"def largest_contiguous_subsum(list)\n subsets = []\n (0...list.length).each do |idx1|\n (idx1...list.length).each do |idx2|\n subsets << list[idx1..idx2]\n end\n end\n\n #orignial [1,2,3]\n\n #[1]\n #[1,2]\n #[1,2,3]\n #[2]\n #[2,3]\n #[3]\n\n\n largest = subsets[0].sum\n subsets.each do |subset|\n largest = subset.sum if subset.sum > largest\n end\n\n largest\nend",
"def largest_contiguous_subsum2(array)\n largest_sum = array.first\n current_sum = array.first\n\n (1..array.length-1).each do |i|\n current_sum = 0 if current_sum < 0\n current_sum += array[i]\n largest_sum = current_sum if current_sum > largest_sum\n end\n largest_sum\n \nend",
"def largest_contiguous_subsum(list)\n subs = []\n list.each_with_index do |ele1, idx1|\n (idx1..list.length-1).each do |idx2|\n subs.push(list[idx1..idx2])\n end\n end\n subs_sum = subs.map{|sub_arr| sub_arr.sum}\n subs_sum.flatten.max\nend",
"def largest_contiguous_subsum(arr)\n max = arr[0]\n current = 0\n (0...arr.length).each do |i|\n current += arr[i]\n max = current if current > max\n current = 0 if current < 0\n end\n max\nend",
"def largest_contiguous_subsum(arr)\n current_sum = arr.first \n max_sum = arr.first \n (0...arr.length-1).each do |i|\n if current_sum < 0 \n current_sum = [current_sum, arr[i+1]].max\n max_sum = current_sum\n else \n current_sum += arr[i+1]\n max_sum = [current_sum, max_sum].max\n end \n end \n max_sum\nend",
"def largest_contiguous_subsum(array)\n arr = []\n (0...array.length).each do |i|\n (i + 1...array.length).each do |j|\n arr << array[i] + array[j] \n end\n end\n arr.max\n \nend",
"def largest_contiguous_subsum(arry)\n sums = 0\n size = arry.length\n\n (0..size - 1).each do | i|\n sub = []\n (i + 1..size).each do |j|\n sub = arry[i..j]\n if sub.sum > sums\n sums = sub.sum \n end\n end\n end\n sums\nend",
"def largest_contiguous_subsum(arr)\n \n curr_sum = arr.first\n largest_sum = arr.first\n (1...arr.length).each do |i| \n if curr_sum < 0\n curr_sum = 0 #reset\n end\n\n curr_sum += arr[i] \n \n if curr_sum > largest_sum \n largest_sum = curr_sum\n end\n end\n largest_sum\nend",
"def largest_contiguous_subsum_fast(arr)\n global_max = arr.first\n prev_max = arr.first\n\n arr.drop(1).each do |el|\n curr_max = (prev_max + el > el) ? (prev_max + el) : el\n prev_max = curr_max\n global_max = curr_max if curr_max > global_max\n end\n global_max\nend",
"def largest_contiguous_subsum(list)\n max = nil\n subarrays = []\n\n list.each_with_index do |el1, idx1|\n (idx1...list.length).each do |idx2|\n subarrays << list[idx1..idx2]\n end\n end\n\n sums = []\n subarrays.each do |array|\n sums << array.inject(:+)\n end\n\n sums.max\nend",
"def largest_con_subsum_2(list)\n largest = list.first\n contiguous_sum = list.first\n\n i = 1\n \n while i < list.length\n current = list[i]\n contiguous_sum += current\n if contiguous_sum > largest\n largest = contiguous_sum \n elsif current > largest\n largest = current\n \n end\n contiguous_sum = 0 if contiguous_sum < 0\n i += 1 \n \n end\n return largest\nend",
"def largest_contiguous_subsum(arr)\n largest = arr.first\n current_sum = arr.first\n i = 1\n while i < arr.length\n if arr[i] < 0\n largest = current_sum if current_sum > largest\n largest = arr[i] if arr[i] > largest\n if current_sum + arr[i] > 0\n current_sum += arr[i]\n else\n current_sum = 0 unless current_sum < 0\n end\n else\n current_sum += arr[i]\n end\n i+=1\n end\n largest = current_sum if current_sum > largest\n largest\nend",
"def largest_contiguous_subsum(arr)\r\n # sub_arr = []\r\n # (0...arr.length).each do |idx|\r\n # (idx...arr.length).each do |idx_2| \r\n # sub_arr << arr[idx..idx_2]\r\n # end\r\n # end\r\n # p sub_arr.length \r\n # sub_arr.map {|sub| sub.sum }.max\r\n max = arr.first #8\r\n curr = arr.first #8\r\n arr.drop(1).each do |ele| \r\n curr = 0 if curr < 0\r\n curr += ele\r\n max = curr if curr > max\r\n end\r\n max\r\nend",
"def largest_contiguous_subsum_two(list)\n largest_sum = list[0]\n current_sum = 0\n # list.inject {|acc, ele| acc + ele}\n list.each do |ele|\n current_sum = [ele, current_sum + ele].max\n largest_sum = [largest_sum, current_sum].max\n end\n largest_sum\nend",
"def largest_contiguous_subsum_1(arr)\n largest = []\n (0...arr.length).each do |i|\n (i...arr.length).each do |j|\n largest << arr[i..j]\n end\n end\n sums = largest.map do |sub_array|\n sub_array.sum\n end\n sums.max\nend",
"def largest_contiguous_subsum(arry)\n bigone = arry.first || 0\n actual_sum = 0\n\n arry.each do |number|\n actual_sum += number\n if actual_sum > bigone\n bigone = actual_sum \n end\n if actual_sum < 0\n actual_sum = 0 \n end\n end\n return bigone\nend",
"def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend"
] | [
"0.9269417",
"0.9231172",
"0.91395384",
"0.91220176",
"0.9090307",
"0.90778863",
"0.90721405",
"0.9059933",
"0.9048553",
"0.9021661",
"0.9000857",
"0.8998376",
"0.8998222",
"0.89965117",
"0.89892554",
"0.89688325",
"0.8960531",
"0.8937953",
"0.8935685",
"0.89301443",
"0.8903166",
"0.89019436",
"0.88899523",
"0.8873129",
"0.8863314",
"0.8860248",
"0.88598275",
"0.8849245",
"0.8837259",
"0.8826369",
"0.8815937",
"0.88152856",
"0.8807759",
"0.88048345",
"0.8800884",
"0.879212",
"0.87910676",
"0.8790899",
"0.8774784",
"0.8772314",
"0.87638324",
"0.8762632",
"0.876103",
"0.8756001",
"0.8746014",
"0.8745271",
"0.8737777",
"0.87370604",
"0.87355024",
"0.873467",
"0.87273544",
"0.8716265",
"0.8704483",
"0.870166",
"0.8698005",
"0.8696191",
"0.86901075",
"0.868783",
"0.8681098",
"0.8680798",
"0.86750686",
"0.86725247",
"0.86691314",
"0.8665344",
"0.86630344",
"0.8644091",
"0.8643532",
"0.86425066",
"0.8633769",
"0.86326647",
"0.86312383",
"0.8628369",
"0.8628133",
"0.8627877",
"0.86273926",
"0.86245924",
"0.86218387",
"0.862178",
"0.86205035",
"0.86163616",
"0.8613502",
"0.86130255",
"0.8612233",
"0.86112946",
"0.86106026",
"0.86092526",
"0.86075664",
"0.86040884",
"0.8601019",
"0.859791",
"0.85961974",
"0.8590144",
"0.8587995",
"0.8581146",
"0.85810864",
"0.857791",
"0.8576955",
"0.85743815",
"0.85638344",
"0.8562828"
] | 0.8877425 | 23 |
function2 ===> test no.2 | def total_cash(petshop)
return petshop[:admin][:total_cash]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_function2()\n 'ouch'\nend",
"def method2() end",
"def stest_method_1(test); end",
"def two\n end",
"def yet_another_func\r\n 18\r\n end",
"def foo2(x)\n bar(x)\n end",
"def xyz2\n\n end",
"def sum2(n1, n2)\n puts n1+n2\nend",
"def second_method(name_1, name_2)\n puts \"#{name_1}'s beauty really can't compare with #{name_2}'s.\"\nend",
"def fun1(a, b)\n a * b\nend",
"def f1(x, x); end",
"def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n void fun1(integer arg) {\r\n i = i++;\r\n }\r\n void fun1(string arg)\r\n {\r\n int i = 0;\r\n if (i == 0) {\r\n printf(\"Hello Zero\");\r\n }\r\n }\r\n EOD\r\n )\r\n function_length = length.counts\r\n assert_equal(7, function_length[\"fun1\"])\r\n end",
"def what_am_i arg arg2\n \nend",
"def _test_2\n dotest(\n TestCase45a2,\n \"\"\"\n.0 - 1\n.1 - 2\ndone.\n \"\"\".strip)\n end",
"def second\n set_function_and_argument(:second, nil)\n end",
"def m2\n puts \"metodo 2\"\n end",
"def foo2(a, ...)\n bar2(a, ...)\nend",
"def func1 val #missing the symbols for arguments\r\n if val = 1 #missing 1 equal symbol.\r\n return true\r\n else\r\n return false\r\n end\r\nend",
"def diff1; end",
"def print_me_2\n \"I'm printing the return value!!!\"\nend",
"def method_2_1(arg1, arg2)\n puts arg1 + ' ' + arg2\n end",
"def getTwo\n\n\t2\nend",
"def CheckNums(num1,num2)\n\n # code goes here\n return num1 \n \nend",
"def add_two(number)\n number + 2 # res of last line will be returned\nend",
"def diff2; end",
"def test; end",
"def print_two_again(arg1, arg2)\r\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\r\nend",
"def print_two_again(arg1, arg2)\r\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\r\nend",
"def f1\n fscore(1)\n end",
"def print_two_again(arg1,arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n\tputs \"arg1 : #{arg1}, arg2 : #{arg2}\"\nend",
"def my_method2(a)\n puts a \nend",
"def do_something\n puts \"second version\"\n end",
"def test_match\n\t\tassert_equal(2,add(1,1))\n\tend",
"def print_two_again(arg1,arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\n end",
"def print_two_again(arg1, arg2) \r\n \tputs \"arg1: #{arg1}, arg2: #{arg2}\"\r\n end",
"def plus_one(num_2)\n return num_2 +1\n\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg2}, arg2:#{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\n end",
"def add_two(x)\n\tx + 5\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\n end",
"def check_nums(num1, num2)\r\n\r\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1,arg2)\n puts \"arg1: #{arg1},arg2: #{arg2}\"\n end",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, args2: #{arg2}\"\nend",
"def puts_two_again(arg1, arg2) # easy way to make a function, unlike puts_two\n\tputs \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1:#{arg1}, arg2: #{arg2}\"\nend",
"def demo2\n end",
"def print_two_again (arg1, arg2)\n puts \"again arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def add_2(x, y)\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1 #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n\tputs \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n\tputs \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n\tputs \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n\tputs \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def ptest_method_1(test); end",
"def addition1(num1, num2)\n\tprint \"addition1 gets call: \"\n\treturn num1 + num2\nend",
"def test; true; end",
"def one_away(str1, str2)\n\nend",
"def sum_two(x, y)\n x + y\nend",
"def print_two_again(arg1, arg2)\n\tputs \"arg1 #{arg1}, arg2: #{arg2}\"\nend",
"def puts_two_again(arg1, arg2)\r\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\r\nend",
"def method1; end",
"def bigger_two(list_1,list_2)\n puts \"running code\"\n sum_one = list_1[0] + list_1[1]\n sum_two = list_2[0] + list_2[1]\n #changed variable name to sum because thats more clear than x and y\n if sum_one > sum_two\n return list_1\n else #used else to condense code\n return list_2\n end\n if sum_two = sum_one\n return list_1\n end\nend",
"def puts_two_again(arg1,arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def func1(val) # adds brackets - good practice\r\n if val == 1 # uses == comparator\r\n return true\r\n else\r\n return false\r\n end\r\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1; #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1; #{arg1}, arg2: #{arg2}\"\nend",
"def first_method(num_1, num_2)\n puts num_1 + num_2\nend",
"def bad_smell_by_nfunctions\n end",
"def fun2(&block)\n block.yield\nend",
"def f() 1 end",
"def fun1\n yield\nend"
] | [
"0.7040361",
"0.6511971",
"0.6446112",
"0.6443784",
"0.61250985",
"0.6123539",
"0.61125404",
"0.6106946",
"0.60680604",
"0.60140276",
"0.6003924",
"0.5933421",
"0.5923851",
"0.5880884",
"0.5880179",
"0.5857769",
"0.58499277",
"0.5846838",
"0.5841441",
"0.58226895",
"0.5822637",
"0.58146495",
"0.576204",
"0.57531536",
"0.5726648",
"0.5726228",
"0.57158715",
"0.57158715",
"0.570232",
"0.5700115",
"0.56995183",
"0.56975687",
"0.5693824",
"0.5690953",
"0.56886005",
"0.568346",
"0.56824934",
"0.5673733",
"0.5669657",
"0.56616783",
"0.5661105",
"0.56583184",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.5658284",
"0.56558585",
"0.56427026",
"0.56414545",
"0.5626588",
"0.5622971",
"0.56224394",
"0.5619582",
"0.5619582",
"0.5619582",
"0.5619582",
"0.56163573",
"0.56148654",
"0.5607186",
"0.5607186",
"0.5607186",
"0.5607186",
"0.56042194",
"0.560042",
"0.5586751",
"0.55845064",
"0.55753744",
"0.5562068",
"0.55616194",
"0.55608237",
"0.5555739",
"0.5548942",
"0.5541741",
"0.5539978",
"0.5539978",
"0.5538653",
"0.55361617",
"0.55306625",
"0.5525958",
"0.55237657"
] | 0.0 | -1 |
function3 ===> tests no.3 & 4. | def add_or_remove_cash(petshop,cash)
petshop[:admin][:total_cash] += cash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def three_and_5(number)\r\n \r\nend",
"def func1 val #missing the symbols for arguments\r\n if val = 1 #missing 1 equal symbol.\r\n return true\r\n else\r\n return false\r\n end\r\nend",
"def min_3(x, y, z)\nend",
"def m3; 3 end",
"def check_funcall (f)\nend",
"def test\n\t\t@a+@b > @c && @a+@c > @b && @b+@c > @a\n\tend",
"def great_of_three(a,b,c)\n if a>b && a>c then\n print \"a is greater\"\n elsif b>a && b>c then \n print \"b is greater\"\n elsif c>a && c>b then\n print \"c is greater\"\n else\n print \"All are equal\"\n end\nend",
"def minofthree(num1, num2, num3)\n if num1 < num2\n if num1 < num3\n return num1\n else\n return num3\n end\n else\n if num2 < num3\n return num2\n else\n return num3\n end\n end\nend",
"def is_bad_version(n)\r\n return true if n > 3\r\n false\r\nend",
"def by_three?(x)\n if x % 3 == 0 \n return true\n else \n return false \n end\nend",
"def bad_smell_by_nfunctions\n end",
"def three_of_a_kind?(roll)\n false\nend",
"def divisible_by_three?(number)\n number % 3 == 0\nend",
"def equal_number(number1,number2,number3)\n\tif number1==number2\n\t\treturn 2\n\telsif number2==number3\n\t\treturn 2\n\telsif number1==number3\n\t\treturn 2\n\telsif number1==number2 and number2==number3\n\t\treturn 3\n\telse \n\t\treturn 0\n\tend\nend",
"def by_three?(number)\n if number%3 == 0\n return true\n else\n return false\n end\nend",
"def got_three?(elements)\n elements.each_cons 3 do |a, b, c|\n if a == b && b == c \t\n \t return true\n end \n end \n \treturn false\nend",
"def divisible_by_three(num)\n num%3 == 0 ? true : false\nend",
"def between_strict(num1,num2,num3)\n if num2 > num3\n if num1>num3 && num1<num2\n return true\n end\n return false\n end\n \n if num1>num2 && num1<num3\n return true\n end\n return false\nend",
"def add_3(x, y, z)\nend",
"def divisible_by_three(number)\n if number % 3 == 0 \n return true\n else \n return false \n end\nend",
"def verify_functions(test_data)\n test_functions = test_data[Org::FUNCTIONS.name]\n errors = []\n test_functions = [{ Org::FUNCTION.name => ''}] unless test_functions\n test_functions.each_with_index do |test_function, index|\n text_values_match?(test_function[Org::FUNCTION.name], element_value(function_input(index)), errors)\n end\n errors\n end",
"def by_three?(number)\n if number % 3 == 0\n return true\n else\n return false\n end\nend",
"def is_divisible_by_three?(number)\n return true if number % 3 == 0\nend",
"def sum3(x, y, z)\n x + y + z\nend",
"def check ; true ; end",
"def add_three(num1, num2, num3)\nreturn num1 + num2 + num3\nend",
"def min_of_three(num1, num2, num3)\n if num1 < num2 and num1 < num3\n return num1\n end\n if num2 < num1 and num2 < num3\n return num2\n end\n return num3\nend",
"def got_three?(array) # def got_three?(elements)\n array.each_cons 3 do |a, b, c| # elements.each_cons 3 do |a, b, c|\n if a == b && b == c # return true if a == b && b == c\n return true # end\n else # false\n false # end\n end\n end\nend",
"def func1(val) # adds brackets - good practice\r\n if val == 1 # uses == comparator\r\n return true\r\n else\r\n return false\r\n end\r\nend",
"def check_third_rule\n total_method_calls = @data[:method_calls].size\n\n proper_method_calls = @data[:method_calls].inject(0) do |sum, method_call|\n sum += 1 unless method_call.number_of_arguments > 4\n sum\n end\n\n @output[:third_rule] ||= {}\n @output[:third_rule][:proper_method_calls] = proper_method_calls\n @output[:third_rule][:total_method_calls] = total_method_calls\n\n log_third_rule if @store_details\n end",
"def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n void fun1(integer arg) {\r\n i = i++;\r\n }\r\n void fun1(string arg)\r\n {\r\n int i = 0;\r\n if (i == 0) {\r\n printf(\"Hello Zero\");\r\n }\r\n }\r\n EOD\r\n )\r\n function_length = length.counts\r\n assert_equal(7, function_length[\"fun1\"])\r\n end",
"def test_6_function_input_3_return_mined\r\n results = create_array()\r\n assert_equal(\"Mined\", results[3-1])\r\n end",
"def test_less_than_3_equal_chars\n\t\tassert_equal(false,compare('1234','1325'))\n\tend",
"def by_three?(n)\n return n % 3 == 0\nend",
"def add_three(number)\n return number + 3\n number + 4\nend",
"def add_three(number)\n return number + 3\n number + 4\nend",
"def add_three(number)\n return number + 3\n number + 4\nend",
"def add_three(number)\n return number + 3\n number + 4\nend",
"def min_of_three(num1, num2, num3)\n if num1 < num2\n if num1 < num3\n return num1\n end\n else\n if num2 < num3\n return num2\n end\n end\n return num3\nend",
"def always_three_method(number)\n\t(((number+5)*2 -4)/2 - number)\nend",
"def func1 val # Val should be inside round brackets ().\r\n if val = 1 # Requires == to check status\r\n return true # Indent both returns as they relate to the if and else.\r\n else\r\n return false\r\n end\r\nend",
"def func_if(args)\n p1 = car(args)\n p2 = car(cdr(args))\n p3 = cdr(cdr(args))\n\n if _eval(p1) != @o_man.nil\n return _eval(p2)\n end\n\n return func_progn(p3)\n end",
"def between_strict(num1, num2, num3)\n if num1 > num2\n if num1 < num3\n return true\n else return false\n end\n else return false\n end\nend",
"def conditionally(*) end",
"def conditionally(*) end",
"def valid?\n n >= 3\n end",
"def min_of_three(num1, num2, num3)\n if num1 < num2 && num1 < num3\n return num1\n elsif num2 < num1 && num2 < num3\n return num2\n else\n return numm3\n end\nend",
"def func4(*args)\n if args.length==0\n puts \"no arguments\\n\"\n elsif args.length==1\n puts (\"one arguemnet = \"+args[0]+\"\\n\")\n elsif args.length>1\n puts (\"more than arguments\")\n puts args\n end\nend",
"def min_of_three(siffra1, siffra2, siffra3)\n output = nil\n if siffra1 < siffra2\n output = siffra1\n else\n output = siffra2\n end\n if siffra3 < output\n output = siffra3\n end\n return output\n\nend",
"def max_of_three(num1,num2,num3)\n return num1 if num1 > num2 && num1 > num3\n return num2 if num2 > num1 && num1 > num3 \n return num3\nend",
"def check_third_rule\n total_method_calls = @data[:method_calls].size\n\n proper_method_calls = @data[:method_calls].inject(0) do |sum, params|\n sum += 1 unless params.first > 4\n sum\n end\n\n @output[:third_rule] ||= {}\n @output[:third_rule][:proper_method_calls] = proper_method_calls\n @output[:third_rule][:total_method_calls] = total_method_calls\n\n log_third_rule if @store_details\n end",
"def meth_three\n\treturn 1, 2, 3\nend",
"def str3; end",
"def str3; end",
"def a3()\n puts('123454')\nend",
"def add_three(number)\n number + 3\n return number + 4\nend",
"def add_three(number)\n number + 3\n number + 4 \nend",
"def is_power_of_three(n)\n return true if n == 1\n return false if 0 != n%3\n return false if n <= 0\n return is_power_of_three(n/3)\nend",
"def add_three num1,num2,num3\n num1+num2+num3\nend",
"def min_four(num1, num2, num3, num4)\n\n if num1 > num2\n output1 = num1\n else\n output1 = num2\n end\n\n if num3 > num4\n output2 = num3\n else\n output2 = num4\n end\n\n if output1 > output2\n return output1\n else\n return output2\n end\nend",
"def between_strict(num1, num2, num3)\n if num1 > num2 and num1 < num3\n return true\n end\n return false\nend",
"def add_three(number)\n return number + 3\nend",
"def add_three(number)\n return number + 3\nend",
"def add_three(number)\n return number + 3\nend",
"def add_three(number)\n return number + 3\nend",
"def min_of_three(min,num2,num3,num4)\n if min > num2\n min = num2\n end\n if min > num3\n min = num3\n end\n if min > num4\n min = num4\n end\n return min\nend",
"def betweenstrict(siffra1, siffra2, siffra3)\n output = false\n if siffra1 > siffra2 && siffra1 < siffra3\n output = true\n end\n return output\nend",
"def func1 val\n if val = 1 #should be ==\n return true #needs an indent\n else\n return false#needs an indent\n end\nend",
"def add_three(number)\n return number + 7\n number + 12\nend",
"def is_function?(data)\n\t/.\\(.*\\)/.match(data)? true :false\nend",
"def plus_three(num)\n num + 3\nend",
"def fun3(&block)\n block.yield unless block.nil?\nend",
"def got_three?(numbers)\n numbers.each_cons(3) do |a, b, c|\n if a == b && b == c\n return true\n end\n return false\n end\nend",
"def has_multiple_of_three?(numbers)\n numbers.any?{ |element| element % 3 == 0 }\nend",
"def between(n1, n2, n3)\n output = true\n if n1 < n2\n output = false\n elsif n1 > n3\n output = false\n end\n return output\nend",
"def condition; end",
"def function3A(n = 0)\n\tfn1 = 0\n\tfn2 = 1\n\n\tsum = 0\n\tif (n == 1)\n\t\treturn 0\n\telsif (n == 2)\n\t\treturn 1\n\telse\n\t\ti = 1\n\t\twhile i < (n) # while i is less than the nth number calculate the sum of Fn-1 and Fn-2, where Fn-2 stores the sum\n\t\t\tsum = fn1 + fn2\n\t\t\tfn1 = fn2\n\t\t\tfn2 = sum\n\t\t\ti += 1\n\t\tend\n\t\treturn sum\n\tend\nend",
"def add_three(num)\n\nend",
"def add_three num1, num2, num3\n\tnum1 + num2 + num3\n\nend",
"def add_three(num1, num2, num3)\n result = num1 + num2 + num3\n return result\nend",
"def if0(e1, e2, e3)\n if eval_ex(e1) == 0\n return eval_ex(e2)\n else\n return eval_ex(e3)\n end\n end",
"def max_of_three(num1,num2,num3)\n if max_of_two(num1,num2) <= num3\n return num3\n end\n return max_of_two(num1,num2)\nend",
"def three_of_a_kind?\n n_of_a_kind? 3\n end",
"def functions\n\n end",
"def min_of_three(n1, n2, n3)\n output =\"\"\n if n1 < n2\n output = n1\n else\n output =n2\n end\n if output < n3\n return output\n else \n return n3\n end\nend",
"def can_be_divided_by_three(number)\n is_divisible_by_3 = number % 3\n is_divisible_by_3 == 0\nend",
"def min_of_three(min,num2,num3)\n if min > num2\n min = num2\n end\n if min > num3\n min = num3\n end\n return min\nend",
"def got_three?(array)\n comp = ''\n num = 0\narray.each do |value|\n if value == comp && num == 1\n return true\n elsif value == comp\n num = 1\n else\n comp = value\n num = 0\n end\nend\n false\nend",
"def got_three?(array)\n\noutcome =false\ni = 0\n\tuntil i == array.length\n\t\toutcome = true if array[i] == array[i + 1] && array[i + 1] == array[i + 2]\n\t\ti += 1\n\tend\n\treturn outcome\nend",
"def between_strict(n1, n2, n3)\n if n1 > n2 && n1 < n3\n return true\n else\n return false\n end\nend",
"def test_function2()\n 'ouch'\nend",
"def add_three(num1, num2, num3)\n\tnum1 + num2 + num3\nend",
"def max_of_three(num1, num2, num3)\n return num1 if num1 > num2 && num1 > num3\n return num2 if num2 > num3 && num2 > num1\n return num3\nend",
"def add_three num1, num2, num3\n num1 + num2 + num3\nend",
"def test; true; end",
"def print_again_third (arg2,arg3)\n puts \"arg2: #{arg2}, arg3:#{arg3}\"\nend",
"def verify_ts3_condition\n Unified835Output::BenignNull.new\n end",
"def ok? \n @funct == nil ? (return false) : (return true)\n end",
"def check5(pmt)\n pmt > 5\nend",
"def got_three?(array)\n\tarray.each_cons 3 do |x, y, z|\n\t\treturn true if x == y && y == z\n\tend\n\treturn false\nend",
"def checks; end"
] | [
"0.63424164",
"0.5920216",
"0.59028673",
"0.588423",
"0.5800671",
"0.5777478",
"0.5733854",
"0.5730103",
"0.57189965",
"0.5676787",
"0.5675387",
"0.5674722",
"0.56545454",
"0.56521684",
"0.5649689",
"0.5616876",
"0.56115955",
"0.56103843",
"0.5606925",
"0.56060153",
"0.5598756",
"0.5596895",
"0.5596099",
"0.55857587",
"0.55683535",
"0.5567075",
"0.5557991",
"0.5552866",
"0.5551205",
"0.55492735",
"0.5532438",
"0.5520326",
"0.55183864",
"0.55173194",
"0.5516908",
"0.5516908",
"0.5516908",
"0.5516908",
"0.5516656",
"0.5505809",
"0.5496947",
"0.5483267",
"0.54784715",
"0.5477545",
"0.5477545",
"0.54740983",
"0.5471435",
"0.5461707",
"0.5452663",
"0.5433818",
"0.54227674",
"0.5421617",
"0.5416222",
"0.5416222",
"0.5409004",
"0.5408657",
"0.5405154",
"0.5394996",
"0.53823376",
"0.5376537",
"0.5361296",
"0.5361051",
"0.5361051",
"0.5361051",
"0.5361051",
"0.53543645",
"0.5353591",
"0.53509974",
"0.53507173",
"0.53483427",
"0.53469914",
"0.53451675",
"0.5343629",
"0.53422356",
"0.53408253",
"0.53319496",
"0.5329871",
"0.53243166",
"0.5324057",
"0.53139454",
"0.5312176",
"0.531206",
"0.53079045",
"0.5305923",
"0.530557",
"0.5304661",
"0.5304437",
"0.52926815",
"0.5291979",
"0.5288771",
"0.52871275",
"0.5283166",
"0.52796423",
"0.52778053",
"0.52695775",
"0.52668583",
"0.52652586",
"0.52630883",
"0.5260327",
"0.5259014",
"0.5245586"
] | 0.0 | -1 |
function5 ===> test no.5 | def pets_sold(petshop)
return petshop[:admin][:pets_sold]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def high_five; end",
"def f5(x, x:); end",
"def addFive(num)\n num + 5\nend",
"def five\n return 5 # Some people choose to use the return statement just to be clear, \n end",
"def by_five?(n)\n return n % 5 == 0\nend",
"def five(number)\n number % 5 == 0 ? true : false\nend",
"def by_five?(num)\n num % 5 == 0\nend",
"def fifth\n at(4)\n end",
"def by_five2?(a)\n a%5 == 0\nend",
"def check5(pmt)\n pmt > 5\nend",
"def add_five num\n num + 5\nend",
"def three_and_5(number)\r\n \r\nend",
"def check5(num)\n puts true if num > 5\n puts false if num <= 5\nend",
"def by_five? num\n #returning is implicit\n num % 5 == 0\nend",
"def mult_five(number)\n if number%5 === 0\n puts \"#{number} is a multiple of 5.\"\n else\n puts \"#{number} is not a multiple of 5.\" # You need the hash stuff here because you can't add an integer to a string, you idiot.\n end\nend",
"def divisible_by_five?(num)\n return num % 5 == 0\nend",
"def mult_five(number)\n if number % 5 == 0\n return true\n else \n return false\n end\nend",
"def five(a, b, c, d, e)\n \"I was passed #{a} #{b} #{c} #{d} #{e}\"\n end",
"def is_div_by_5(number)\n if number % 5 == 0\n return \"true\"\n else\n return \"false\"\n end\nend",
"def check5(num)\n if num <= 5\n 'false'\n elsif num >= 6\n 'true'\n end\nend",
"def five(a,b,c,d,e)\n\t\"I was passed #{a}, #{b}, #{c}, #{d}, #{e}\"\nend",
"def divisible_by_5?(num)\n num % 5 == 0\nend",
"def bad_smell_by_nfunctions\n end",
"def eval_5_cards( c1, c2, c3, c4, c5)\n 1\n end",
"def five(a, b, c, d, e)\n \"I was passed #{a} #{b} #{c} #{d} #{e}\"\nend",
"def fifth_of_array(array)\nend",
"def mambo_no_5; end",
"def test_number_divisible_by_five\n\t\tassert_equal \"buzz\", FizzBuzz.identify(10)\n\tend",
"def can_be_divided_by_five(number)\n is_divisible_by_5 = number % 5\n is_divisible_by_5 == 0\nend",
"def is_div_by_5(number)\n return number % 5 == 0 ? true : false\nend",
"def is_number_five?(number)\n number.eql? 5\nend",
"def test_function2()\n 'ouch'\nend",
"def is_div_by_5(number)\n if number % 5 == 0\n return true\n else\n return false\n end\nend",
"def is_div_by_5(n)\n if n%5 == 0\n return true\n else\n return false\n end\nend",
"def fifth!\n fifth || raise_record_not_found_exception!\n end",
"def by_five? n\n # Returning is implicit in Ruby. The last evaluated expression in a\n # method's body will always be returned unless you tell it otherwise.\n p n % 5 == 0\nend",
"def buzz?(x)\n x % 5 == 0\n end",
"def stest_method_1(test); end",
"def multiply_by_five(n)\n n * 5\nend",
"def multiply_by_five(n)\n n * 5\nend",
"def multiply_by_five(n)\n n * 5\nend",
"def multiply_by_five(n)\n n * 5\nend",
"def multiply_by_five(n)\n n * 5\nend",
"def multiply_by_five(n)\n n * 5\nend",
"def multiply_by_five(n)\n n * 5\nend",
"def multiply_by_five(n)\n n * 5\nend",
"def multiply_by_five(n)\n n * 5\nend",
"def multiply_by_five(n)\n n * 5\nend",
"def over_five?(value)\n puts value > 5 ? 'Over 5' : 'Not over 5'\nend",
"def z_function(number)\n return 0 if number < 5\n number/5 + z_function(number/5)\nend",
"def over_five?(value=nil)\n\treturn \"Exactly 5\" if value.to_i == 5\n\tif value.to_i > 5\n\t\treturn \"Over 5\"\n\telse\n\t\treturn \"Under 5\"\n\tend\nend",
"def rand5()\n rand(1..5)\nend",
"def eval_5_cards(c1, c2, c3, c4, c5)\n begin\n index = PTable[c1]*PTable[c2]*PTable[c3]*PTable[c4]*PTable[c5]\n if FlushTable[FlushTable[FlushTable[FlushTable[FlushTable[0][c1]][c2]][c3]][c4]][c5] == 5\n EqClLookup[index].nonflush\n else\n EqClLookup[index].flush\n end\n rescue\n NULL_EQ_CLASS\n end\n end",
"def silly_check(number)\n\tif number < 5\n\t\treturn \"The number is less than 5\" \n\telse\n\t\treturn \"The number is greater than or equal to 5\"\nend\nend",
"def largest_five(digits)\r\n\r\nend",
"def silly_check(number)\n\tif number < 5\n\t\treturn \"The number is less than 5\"\n\telse\n\t\treturn \"The number is greater than or equal to 5\"\n\tend\nend",
"def buzz(int)\n int % 5 == 0\nend",
"def test_fizzbuzz__5_returns_buzz\n #Arrange\n number = 5\n #Act\n result = fizzbuzz(number)\n #Assert\n assert_equal(\"Buzz\", result)\n end",
"def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n void fun1(integer arg) {\r\n i = i++;\r\n }\r\n void fun1(string arg)\r\n {\r\n int i = 0;\r\n if (i == 0) {\r\n printf(\"Hello Zero\");\r\n }\r\n }\r\n EOD\r\n )\r\n function_length = length.counts\r\n assert_equal(7, function_length[\"fun1\"])\r\n end",
"def multiply_by_five(n)\r\n n * 5\r\n end",
"def over_five?\n\tvalue = 3\n\tputs value > 5 ? \"Over Five\" : \"Not over FIVE\"\nend",
"def rand5\n rand(1..5)\nend",
"def has5?(a)\n return 5<=a.size\nend",
"def p15\n\t\nend",
"def by_five? num \n # Returning is implicit. The last expression\n # in a method's body will always be returned unless\n # you explicitly call return above\n num % 5 == 0\nend",
"def fizz_buzz number\nend",
"def fizz_buzz number\nend",
"def fizz_buzz number \nend",
"def addFive(num=5)\n return 5 + num\nend",
"def sum_of_digits_to_fifth?(num)\n\tnum == num.to_s.split(//).map{|i| (i.to_i)**5}.reduce(:+)\nend",
"def next5\n x = @exact[0,5]\n x + @list[0,5 - x.size]\n end",
"def exercise_119 (number)\n end",
"def test_number_5\n\t\t\tassert_equal(\"Minds\", mineminds_array[4])\n\t\tend",
"def rand5\n rand(0...5)\nend",
"def an_array_with_5_elements\n [1, 2, 3, 4, 5]\nend",
"def sum_of_fifth n\r\n n.to_s.split(\"\").map! {|i| (i.to_i)**5}.inject(:+)\r\nend",
"def silly_check(num)\n\tif num < 5\n\t\tp \"The number is less than 5\"\n\telse\n\t\tp \"The number is greater than or equal to 5\"\n\tend\nend",
"def f() 1 end",
"def fizzbuzz(number)\n #binding.pry\n if (number % 3 == 0 && number % 5 == 0)\n then \"FizzBuzz\"\n elsif number % 3 == 0\n then \"Fizz\"\n elsif number % 5 == 0\n then \"Buzz\"\n else\n nil\n end\nend",
"def divisible_by_3_and_5(number)\n answer = number%15\n answer == 0\nend",
"def yet_another_func\r\n 18\r\n end",
"def test_6_function_input_3_return_mined\r\n results = create_array()\r\n assert_equal(\"Mined\", results[3-1])\r\n end",
"def select_div5(numbers)\n numbers.select { |e| (e % 5).zero? }\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\nend\n\nequal_to_four(5)",
"def silly_check(number)\n return \"The number is less than 5\" if (number < 5)\n \"This number is greater than of equal to 5\"\nend",
"def fizzbuzz_kata(num) \n\t4 \nend",
"def koan_3\nend",
"def is_buzz?(number)\n number % 5 == 0\n end",
"def test; end",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def fifth\n self[4]\n end",
"def koan_4\nend",
"def supports_routines?\n version[0] >= 5\n end",
"def multiple_of_5\n\t\n\tif duration <= 0 || (duration % 5) != 0\n\t\terrors.add(:duration, \"it must be a multiple of 5\")\n\tend\n\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend"
] | [
"0.68881714",
"0.664261",
"0.6531995",
"0.649462",
"0.64598274",
"0.64357376",
"0.6423189",
"0.6418871",
"0.6347563",
"0.63415694",
"0.6324647",
"0.6319709",
"0.629111",
"0.6233271",
"0.6202924",
"0.61625344",
"0.61592185",
"0.6149848",
"0.6146304",
"0.61423147",
"0.61381704",
"0.6116026",
"0.6096765",
"0.6068341",
"0.6054423",
"0.6031118",
"0.60137606",
"0.60046434",
"0.59920734",
"0.59824103",
"0.5970758",
"0.5950265",
"0.59405375",
"0.59248614",
"0.59164095",
"0.5867138",
"0.58599985",
"0.584741",
"0.5842475",
"0.5842475",
"0.5842475",
"0.5842475",
"0.5842475",
"0.5842475",
"0.5842475",
"0.5842475",
"0.5842475",
"0.5842475",
"0.58350635",
"0.5814191",
"0.5813679",
"0.58032507",
"0.57933545",
"0.5781141",
"0.5709635",
"0.5699775",
"0.56751806",
"0.5637221",
"0.5590233",
"0.558901",
"0.5571214",
"0.5566857",
"0.5565149",
"0.5564801",
"0.55645514",
"0.55637616",
"0.55637616",
"0.55497855",
"0.5546121",
"0.55390763",
"0.55373335",
"0.5531577",
"0.5529301",
"0.55117875",
"0.55013037",
"0.5497511",
"0.5489887",
"0.5480555",
"0.54565525",
"0.5455441",
"0.5453422",
"0.5451079",
"0.54501104",
"0.54394674",
"0.54371727",
"0.5436119",
"0.5419465",
"0.5416344",
"0.5416239",
"0.5413903",
"0.54107827",
"0.53836465",
"0.5380729",
"0.5378337",
"0.53738123",
"0.53738123",
"0.53738123",
"0.53738123",
"0.53738123",
"0.53738123",
"0.53738123"
] | 0.0 | -1 |
function6 ===> test no.6 | def increase_pets_sold(petshop,sold)
petshop[:admin][:pets_sold]+=sold
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stest_method_1(test); end",
"def bad_smell_by_nfunctions\n end",
"def six\n square_of_sum(100) - sum_of_squares(100)\nend",
"def v6?\n return v6\n end",
"def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n void fun1(integer arg) {\r\n i = i++;\r\n }\r\n void fun1(string arg)\r\n {\r\n int i = 0;\r\n if (i == 0) {\r\n printf(\"Hello Zero\");\r\n }\r\n }\r\n EOD\r\n )\r\n function_length = length.counts\r\n assert_equal(7, function_length[\"fun1\"])\r\n end",
"def test_function2()\n 'ouch'\nend",
"def heres_six(&block)\n block.call 6\nend",
"def heres_six(&block)\n block.call 6\nend",
"def high_five; end",
"def test; true; end",
"def f5(x, x:); end",
"def test; end",
"def f() 1 end",
"def yet_another_func\r\n 18\r\n end",
"def check_funcall (f)\nend",
"def a3()\n puts('123454')\nend",
"def p15\n\t\nend",
"def test_6_function_input_3_return_mined\r\n results = create_array()\r\n assert_equal(\"Mined\", results[3-1])\r\n end",
"def three_and_5(number)\r\n \r\nend",
"def fizzbuzz_kata(num) \n\t4 \nend",
"def supports_routines?\n version[0] >= 5\n end",
"def koan_3\nend",
"def fifth\n at(4)\n end",
"def by_five2?(a)\n a%5 == 0\nend",
"def test_number_divisible_by_five\n\t\tassert_equal \"buzz\", FizzBuzz.identify(10)\n\tend",
"def addFive(num)\n num + 5\nend",
"def five\n return 5 # Some people choose to use the return statement just to be clear, \n end",
"def fizz_buzz number\nend",
"def fizz_buzz number\nend",
"def mambo_no_5; end",
"def fizz_buzz number \nend",
"def koan_4\nend",
"def version_gte_6?\n version >= v60\n end",
"def fifth_of_array(array)\nend",
"def by_five? num\n #returning is implicit\n num % 5 == 0\nend",
"def multiple_of_7(num)\n num % 7 == 0\nend",
"def functions\n\n end",
"def check5(pmt)\n pmt > 5\nend",
"def test_match\n\t\tassert_equal(2,add(1,1))\n\tend",
"def is_bad_version(n)\r\n return true if n > 3\r\n false\r\nend",
"def h_6!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 10 )\n\n type = H6\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 333:5: 'h6'\n match( \"h6\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 10 )\n\n end",
"def test_fizzbuzz__5_returns_buzz\n #Arrange\n number = 5\n #Act\n result = fizzbuzz(number)\n #Assert\n assert_equal(\"Buzz\", result)\n end",
"def test_count_fish__3_fish()\n actual = @river1.count_fish()\n assert_equal(5, actual)\n end",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def add_five num\n num + 5\nend",
"def fizz(int)\n int % 3 == 0\nend",
"def test_funcall_hash_means_lookup\n assert_evals_to 3, \"((hash (1 1) (2 2) (3 3)) 3)\"\n end",
"def by_five?(n)\n return n % 5 == 0\nend",
"def mult_five(number)\n if number % 5 == 0\n return true\n else \n return false\n end\nend",
"def ptest_method_1(test); end",
"def my955; end",
"def message_for(test); end",
"def message_for(test); end",
"def friday_13th?(num)\n \nend",
"def problem_14\nend",
"def by_five?(num)\n num % 5 == 0\nend",
"def sixth\n at(5)\n end",
"def fizzbuzz(number)\n #binding.pry\n if (number % 3 == 0 && number % 5 == 0)\n then \"FizzBuzz\"\n elsif number % 3 == 0\n then \"Fizz\"\n elsif number % 5 == 0\n then \"Buzz\"\n else\n nil\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end # this end was missing\nend",
"def f6(x, x: nil); end",
"def test_defun_function\n defun(:my_ruby_func) { |a|\n 0\n }\n # redefine\n defun(:my_ruby_func) { |a|\n \"String from my_ruby_func: '#{a}'\"\n }\n assert_equal(\"String from my_ruby_func: 'Hello!'\", my_ruby_func(\"Hello!\"))\n end",
"def is_function?(data)\n\t/.\\(.*\\)/.match(data)? true :false\nend",
"def divby2not6(n)\n 1.upto(n) { |e| puts e if (e % 2 == 0) && !(e % 6 == 0) }\nend",
"def verify_functions(test_data)\n test_functions = test_data[Org::FUNCTIONS.name]\n errors = []\n test_functions = [{ Org::FUNCTION.name => ''}] unless test_functions\n test_functions.each_with_index do |test_function, index|\n text_values_match?(test_function[Org::FUNCTION.name], element_value(function_input(index)), errors)\n end\n errors\n end",
"def check ; true ; end",
"def problem_8\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def SS2_7 args\r\n\r\nend",
"def fizz?(x)\n x % 3 == 0\n end",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end # <-- this end was missing\nend",
"def test_fizzbuzz__4_returns_4_as_string\n #Arrange\n number = 4\n #Act\n result = fizzbuzz(number)\n #Assert\n assert_equal(\"4\", result)\n end",
"def test_contains_four_eachface\n assert true == false\n end",
"def solution4(input)\n end",
"def test_func(dis, dat, func, expected)\n\tactual = send(func,dis, dat)\n\tputs (actual == expected ? \"Pass\" : \"Fail\") + \": \" + func.to_s + \" test\"\nend",
"def mult_five(number)\n if number%5 === 0\n puts \"#{number} is a multiple of 5.\"\n else\n puts \"#{number} is not a multiple of 5.\" # You need the hash stuff here because you can't add an integer to a string, you idiot.\n end\nend",
"def check5(num)\n if num <= 5\n 'false'\n elsif num >= 6\n 'true'\n end\nend",
"def fizzbuzz(fiz_3)\n if fiz_3 % 3 == 0 && fiz_3 % 5 == 0 \n return \"FizzBuzz\"\n end \n \n if fiz_3 % 3 == 0 \n return \"Fizz\"\n end\n \n if fiz_3 % 5 == 0 \n return \"Buzz\"\n end\nend",
"def test \n end",
"def test_twenty_five\n assert_equal(\"Fizz\", fizbuzz(25))\n end",
"def func1 val #missing the symbols for arguments\r\n if val = 1 #missing 1 equal symbol.\r\n return true\r\n else\r\n return false\r\n end\r\nend",
"def test_ipv6_unavailable\n assert true\n end",
"def test_fizzbuzz__15_returns_fizzbuzz\n #Arrange\n number = 15\n #Act\n result = fizzbuzz(number)\n #Assert\n assert_equal(\"FizzBuzz\", result)\n end",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def test_cases; end"
] | [
"0.60805726",
"0.5982458",
"0.597286",
"0.58375",
"0.5827457",
"0.58069617",
"0.57995415",
"0.57995415",
"0.5794804",
"0.5748315",
"0.56986994",
"0.5657895",
"0.5638173",
"0.5520828",
"0.5514025",
"0.5509899",
"0.5503745",
"0.5488426",
"0.5487556",
"0.54803187",
"0.5441254",
"0.5420979",
"0.5418318",
"0.5413102",
"0.54011035",
"0.5391491",
"0.53842026",
"0.5338171",
"0.5338171",
"0.53196675",
"0.5315637",
"0.53142154",
"0.53119874",
"0.53042316",
"0.53014636",
"0.52950954",
"0.5292625",
"0.52898824",
"0.5289574",
"0.52893955",
"0.52874875",
"0.5275058",
"0.5274733",
"0.5271926",
"0.5271926",
"0.5271926",
"0.52543193",
"0.5245396",
"0.52325046",
"0.52320933",
"0.52310544",
"0.5227048",
"0.5226096",
"0.5223073",
"0.5223073",
"0.5220158",
"0.5218038",
"0.5202088",
"0.52008116",
"0.5199592",
"0.51919985",
"0.5188735",
"0.51822484",
"0.5179306",
"0.5177145",
"0.5176799",
"0.5173859",
"0.5165316",
"0.5161805",
"0.5155704",
"0.5152012",
"0.51495147",
"0.5148655",
"0.5146349",
"0.5145695",
"0.514368",
"0.51430136",
"0.5141414",
"0.51372045",
"0.5134344",
"0.5113865",
"0.51129144",
"0.5107967",
"0.5107704",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51059943",
"0.51057094"
] | 0.0 | -1 |
function7 ===> test no.7 | def stock_count(petshop)
return petshop[:pets].size()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiple_of_7(num)\n num % 7 == 0\nend",
"def bad_smell_by_nfunctions\n end",
"def check_funcall (f)\nend",
"def stest_method_1(test); end",
"def high_five; end",
"def test_function2()\n 'ouch'\nend",
"def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n void fun1(integer arg) {\r\n i = i++;\r\n }\r\n void fun1(string arg)\r\n {\r\n int i = 0;\r\n if (i == 0) {\r\n printf(\"Hello Zero\");\r\n }\r\n }\r\n EOD\r\n )\r\n function_length = length.counts\r\n assert_equal(7, function_length[\"fun1\"])\r\n end",
"def problem_8\nend",
"def problem_14\nend",
"def yet_another_func\r\n 18\r\n end",
"def friday_13th?(num)\n \nend",
"def three_and_5(number)\r\n \r\nend",
"def test; true; end",
"def SS2_7 args\r\n\r\nend",
"def test_funcall_hash_means_lookup\n assert_evals_to 3, \"((hash (1 1) (2 2) (3 3)) 3)\"\n end",
"def exercise_119 (number)\n end",
"def divisive_by_7(x)\n x % 7 == 0 ? \"yup!\" : \"nope!\"\nend",
"def is_bad_version(n)\r\n return true if n > 3\r\n false\r\nend",
"def f() 1 end",
"def test; end",
"def fizzbuzz_kata(num) \n\t4 \nend",
"def method_731(base); end",
"def verify_functions(test_data)\n test_functions = test_data[Org::FUNCTIONS.name]\n errors = []\n test_functions = [{ Org::FUNCTION.name => ''}] unless test_functions\n test_functions.each_with_index do |test_function, index|\n text_values_match?(test_function[Org::FUNCTION.name], element_value(function_input(index)), errors)\n end\n errors\n end",
"def p15\n\t\nend",
"def ptest_method_1(test); end",
"def koan_3\nend",
"def test_6_function_input_3_return_mined\r\n results = create_array()\r\n assert_equal(\"Mined\", results[3-1])\r\n end",
"def fizz_buzz number\nend",
"def fizz_buzz number\nend",
"def test_match\n\t\tassert_equal(2,add(1,1))\n\tend",
"def fizz_buzz number \nend",
"def six\n square_of_sum(100) - sum_of_squares(100)\nend",
"def test_number_divisible_by_five\n\t\tassert_equal \"buzz\", FizzBuzz.identify(10)\n\tend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def check5(pmt)\n pmt > 5\nend",
"def test_fizzbuzz__5_returns_buzz\n #Arrange\n number = 5\n #Act\n result = fizzbuzz(number)\n #Assert\n assert_equal(\"Buzz\", result)\n end",
"def test_that_10_works\n assert_equal(true, funk_master(\"123456789X\"))\n assert_equal(true, funk_master(\"1- 23456 7-89x\"))\n assert_equal(false, funk_master(\"2 22222- - 222X\"))\n assert_equal(false, funk_master(\"1- 23B56 7-89x\"))\n end",
"def a3()\n puts('123454')\nend",
"def iseven(siffra)\n output = false\n if siffra % 2 == 0\n output = true\n end\n\n return output\n\nend",
"def test_true\n\t\tassert_equal(true, winning_numbers(4,[1,2,3,4]))\n\tend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def test_contains_four_eachface\n assert true == false\n end",
"def is_function?(data)\n\t/.\\(.*\\)/.match(data)? true :false\nend",
"def long_planeteer_calls(calls)# code an argument here\n # Your code here\n calls.any? {|x| x.chars.length>4}\nend",
"def check(number)\n \n end",
"def version_gte_7?\n version >= v70\n end",
"def fizzbuzz(number)\n #binding.pry\n if (number % 3 == 0 && number % 5 == 0)\n then \"FizzBuzz\"\n elsif number % 3 == 0\n then \"Fizz\"\n elsif number % 5 == 0\n then \"Buzz\"\n else\n nil\n end\nend",
"def test_fizzbuzz__15_returns_fizzbuzz\n #Arrange\n number = 15\n #Act\n result = fizzbuzz(number)\n #Assert\n assert_equal(\"FizzBuzz\", result)\n end",
"def equal_to_four(x)\n if x == 4\n puts 'yes'\n else \n puts 'no'\n end\nend",
"def divisible_by_seven(nums)\n nums.each do |num|\n if num % 7 == 0\n return num\n end\n end\nend",
"def test_number_has_three_in_it\n\t\tassert_equal \"fizz\", FizzBuzz.identify(13)\n\tend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def seventh\n at(6)\n end",
"def supports_routines?\n version[0] >= 5\n end",
"def test_fizzbuzz__4_returns_4_as_string\n #Arrange\n number = 4\n #Act\n result = fizzbuzz(number)\n #Assert\n assert_equal(\"4\", result)\n end",
"def featured(number)\n sum = 7\n loop do \n return \"There is no possible number that fulfills those requirements\" if number >= 9_876_543_210\n if sum <= number\n sum += 7\n elsif sum.even?\n sum += 7\n elsif sum.digits.uniq != sum.digits\n sum += 7\n else\n break\n end\n end\n sum\nend",
"def koan_4\nend",
"def heres_six(&block)\n block.call 6\nend",
"def heres_six(&block)\n block.call 6\nend",
"def fizz(int)\n int % 3 == 0\nend",
"def hook_solution?(a); end",
"def equal_to_four(x)\n if x == 4\n puts 'yup'\n else\n puts 'nope'\n end\nend",
"def test_count_fish__3_fish()\n actual = @river1.count_fish()\n assert_equal(5, actual)\n end",
"def fourth_method(number)\n\tnumber += 7 #number is scoped locally to the method\nend",
"def addFive(num)\n num + 5\nend",
"def equal_to_four (x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end\nend",
"def featured2(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend",
"def functions\n\n end",
"def magic_number?(n)\r\n \r\nend",
"def test_contains_13_eachsuit\n assert true == false\n end",
"def add_three(number)\n return number + 7\n number + 12\nend",
"def check ; true ; end",
"def _test_numbers ; process_test_case(\"numbers\") ; end",
"def fizz?(x)\n x % 3 == 0\n end",
"def eval_7_card_hand( cards )\n 1\n end",
"def fun_name(defn)\n # The ultimate masterpiece of illegible code.\n defn[3][1][1][3][1][1]\n end",
"def test_nothing; end",
"def test_func(dis, dat, func, expected)\n\tactual = send(func,dis, dat)\n\tputs (actual == expected ? \"Pass\" : \"Fail\") + \": \" + func.to_s + \" test\"\nend",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\n end # this end was missing\nend",
"def test_prints_SB_if_div_by_5_and_7\n # sf = SuperFizz.new\n #35\n assert_equal 'SuperBuzz', SuperFizz.machine(35)[0]\n end",
"def equal_to_four(x)\n if x == 4\n puts \"yup\"\n else\n puts \"nope\"\nend\n\nequal_to_four(5)",
"def by_five? num\n #returning is implicit\n num % 5 == 0\nend",
"def f5(x, x:); end",
"def my955; end"
] | [
"0.6374842",
"0.60398775",
"0.5972006",
"0.58968633",
"0.5895581",
"0.5858507",
"0.5851899",
"0.58467114",
"0.5822782",
"0.5784375",
"0.5767312",
"0.5753044",
"0.57227296",
"0.571081",
"0.56736726",
"0.5634649",
"0.5619564",
"0.5570747",
"0.5562352",
"0.5551127",
"0.55335116",
"0.5503039",
"0.5492024",
"0.54621667",
"0.5459597",
"0.5458492",
"0.5446537",
"0.5436226",
"0.5436226",
"0.54216665",
"0.5412093",
"0.54099256",
"0.5404559",
"0.53987",
"0.53987",
"0.53987",
"0.539865",
"0.5396749",
"0.5390101",
"0.5390036",
"0.53890264",
"0.53847957",
"0.5375235",
"0.53745824",
"0.5360669",
"0.53597355",
"0.53538054",
"0.53515065",
"0.53425413",
"0.5339924",
"0.5338977",
"0.5331833",
"0.53246474",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.5323504",
"0.53224945",
"0.53180695",
"0.53143114",
"0.53096193",
"0.5308416",
"0.53001857",
"0.53001857",
"0.5299304",
"0.52920574",
"0.528561",
"0.5282113",
"0.52803856",
"0.52662075",
"0.52582127",
"0.52481234",
"0.5246582",
"0.52284515",
"0.52266204",
"0.52232075",
"0.5219398",
"0.5215526",
"0.52136457",
"0.52067083",
"0.5203697",
"0.52009004",
"0.51961714",
"0.5194239",
"0.5189291",
"0.51876837",
"0.5187657",
"0.5187024",
"0.5186429"
] | 0.0 | -1 |
function8 ===> test no.8 & 9 using ".each" | def pets_by_breed(petshop,breed)
pets=[]
petshop[:pets].each do
|pet|
if pet[:breed] == breed
pets.push(breed)
end
end
return pets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_0010_each\n @@log.debug \"test_0010_each starts\" if @@log.debug?\n count = 0\n @list.each do |elt|\n count += 1\n end\n assert_equal(4, count)\n @@log.debug \"test_0010_each ends\" if @@log.debug?\n end",
"def each(*) end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&a_proc); end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def test_each\n # codecite examples\n evens = Sequence.new(5, 2) {|a| a.last + 2} \n odds = Sequence.new(5, 1) {|a| a.last + 2}\n fibs = Sequence.new(5, 1, 1) {|a| a[-2] + a[-1]}\n # codecite examples\n \n assert_equal [2,4,6,8,10], evens.to_a\n assert_equal [1,3,5,7,9], odds.to_a\n assert_equal [1,1,2,3,5], fibs.to_a\n end",
"def every?(arr, &blck)\n # arr.all? { |el| blck.call(el) }\n arr.each do |el|\n if !blck.call(el)\n return false\n end\n end\n return true\nend",
"def each(&block)\nend",
"def each(node, &block); end",
"def each(&blk); each_value(&blk) ; end",
"def each &block\n end",
"def each(&block)\n\n end",
"def each(&block)\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each(&block)\n tests.each(&block)\n end",
"def my_all?\n\t\t#if any element is false return false\n\t\tmy_each do | element |\n\t\t\tif yield( element )\n\t\t\t\tnext\n\t\t\telse\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\n\t\t# returns true when all iterations pass\n\t\treturn true\n\n\tend",
"def _each(&block)\n _next.each(&block) if _next\n end",
"def test_018_each()\n TestVals.each do |sVal|\n bs = BitString.new(sVal)\n pos = 0\n bs.each do |val|\n assert_equal(val,\n bs[pos],\n \"Test unbounded each block(#{val}) (for #{pos})\")\n pos += 1\n end\n #\n # And again for a bounded value.\n #\n bs = BitString.new(sVal, sVal.length)\n pos = 0\n bs.each do |val|\n assert_equal(val,\n bs[pos],\n \"Test bounded each block(#{val}) (for #{pos})\")\n pos += 1\n end\n end\n end",
"def my_each(&prc)\n end",
"def each\n end",
"def each\n end",
"def my_all?(collection)\n #our counter\n i = 0\n block_return_values = [ ]\n while i < collection.length\n block_return_values << yield(collection[i])\n # yield(collection[i]) go throughe each element in the index.\n i = i + 1\n #i += 1 does the same thing. Use this if it's easier for you.\n\n end\n\n if block_return_values.include?(false)\n false\n else\n true\n end\nend",
"def every?(arr, &prc)\n\n arr.each do |ele|\n return false if !(prc.call(ele))\n end\n\n true\nend",
"def test_each_is_a_method_on_arrays\n assert_equal true, [].methods.include?(as_name(:each))\n end",
"def each(&block) # block into proc\n\nend",
"def my_all? \n\ti = true\n\tself.my_each do |a|\n\t\tunless yield (a)\n\t\t\ti = false\n\t\t\tbreak\n\t\tend\n\tend\n\ti\nend",
"def custom_each(array)\r\n i = 0 \r\n while i < array.length \r\n yield array[i]\r\n i += 1\r\n end\r\nend",
"def my_all?\n my_each do |i|\n if (!yield(i))\n return false\n end\n end\n true\n end",
"def each\n raise 'Not implemented'\n end",
"def every?(arr, &prc)\n count = 0\n arr.each do |ele| \n if prc.call(ele)\n count += 1\n end\n end\n count == arr.length\nend",
"def each(*args,&blk)\n\t\t@rounds.each(*args,&blk) \n\tend",
"def iterator?() end",
"def each(&b) \n @data.each(&b) \n end",
"def my_all?(collection)\n i = 0\n block_return_values = []\n while i < collection.length\n block_return_values.push(yield(collection[i]))\n #Three steps\n #First we add yield keyword to yield each element of the block\n #Second we, save the the return values to an array which we declare\n #before the while loop\n i = i + 1\n end\n #Third, we want the final to be true or false for each element in\n #our block_return_values as that is what all? returns\n if block_return_values.include?(false)\n false\n else\n true\n end\nend",
"def each_pair(*) end",
"def test_0650_each_slice\n @@log.debug \"test_0650_each_slice starts\" if @@log.debug?\n assert_respond_to(@list, :each_slice, \"test_0650_each_slice_respond\")\n # Type check.\n enum = @list.each_slice(2)\n result = enum.is_a? Enumerator\n assert(result,\"test_0650_each_slice_class\") \n # Check each array slice.\n pass = 0\n @list.each_slice(2) {|suba|\n pass += 1\n case pass\n when 1\n assert_equal([@aen, @bsb], suba, \"test_0650_each_slice_p1\")\n when 2\n assert_equal([@cab, @dad], suba, \"test_0650_each_slice_p2\")\n else\n fail(\"test_0650_each_slice_invalid\")\n end\n }\n #\n pass = 0\n @list.each_slice(3) {|suba|\n pass += 1\n case pass\n when 1\n assert_equal([@aen, @bsb, @cab], suba, \"test_0650_each_slice_p1b\")\n when 2\n assert_equal([@dad], suba, \"test_0650_each_slice_p2b\")\n else\n fail(\"test_0650_each_slice_invalid_b\")\n end\n }\n @@log.debug \"test_0650_each_slice ends\" if @@log.debug?\n end",
"def each_identity; end",
"def my_all?(&block)\n counter = 0\n my_each do |elem|\n counter += 1 if block.call(elem) == true\n end\n return true if counter == size\n\n false\n end",
"def each(&block)\n all.each(&block)\n end",
"def basic_8 (array_iterate, eval_int)\n total = 0\n array_iterate.each { |n| total += 1 if n > eval_int}\n return total\nend",
"def each_mid(&block)\n \n end",
"def each\n end",
"def my_all?(collection)\n i = 0 \n block_return_values = []\n while i < collection.length\n \n # declare our array & yield each element in the collection\n \n block_return_values << yield(collection[i])\n i = i + 1 \n end\n \n # add an ' #include? ' method to determine the return value of the my_all? method.\n \n if block_return_values.include?(false)\n false \n else \n true \n end\nend",
"def test_0655_each_with_index\n @@log.debug \"test_0655_each_with_index starts\" if @@log.debug?\n assert_respond_to(@list, :each_with_index, \"test_0655_each_with_index_respond\")\n # Type check\n enum = @list.each_with_index\n result = enum.is_a? Enumerator\n assert(result,\"test_0655_each_with_index_class\") \n # Check each index number\n @list.each_with_index {|item, index|\n case\n when item == @aen\n assert(index == 0, \"test_0655_each_with_index_i0\")\n when item == @bsb\n assert(index == 1, \"test_0655_each_with_index_i1\")\n when item == @cab\n assert(index == 2, \"test_0655_each_with_index_i2\")\n when item == @dad\n assert(index == 3, \"test_0655_each_with_index_i3\")\n else\n flunk(\"test_0655_each_with_index_invalid\")\n end\n }\n#\n# The author's paper copy of the 1.9 Pickaxe implies that each_with_index\n# can be invoked with one or more arguments as shown below.\n#\n# This appears to be incorrect, which can be confirmed by either:\n#\n# * Attempting to run the code shown\n# * Documentation at http://ruby-doc.org/core-1.9/classes/Enumerable.html\n#\n=begin\n # Invoke with argument(s)\n myarg = \"-tag\"\n accum = \"\"\n @list.each_with_index(myarg) {|item, index|\n case\n when item == @aen\n assert(index == 0, \"test_0655_each_with_index_i0a\")\n assert(myarg == \"-tag\", \"test_0655_each_with_index_tag0\")\n when item == @bsb\n assert(index == 1, \"test_0655_each_with_index_i1a\")\n assert(myarg == \"-tag\", \"test_0655_each_with_index_tag1\")\n when item == @cab\n assert(index == 2, \"test_0655_each_with_index_i2a\")\n assert(myarg == \"-tag\", \"test_0655_each_with_index_tag2\")\n when item == @dad\n assert(index == 3, \"test_0655_each_with_index_i3a\")\n assert(myarg == \"-tag\", \"test_0655_each_with_index_tag3\")\n else\n flunk(\"test_0655_each_with_index_invalid\")\n end\n }\n=end\n @@log.debug \"test_0655_each_with_index ends\" if @@log.debug?\n end",
"def each # And define each on top of next\n loop {yield self.next }\n end",
"def each\n for each element\n yield(element)\n end\nend",
"def custom_each(array)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\nend",
"def my_all?\n return unless block_given?\n self.my_each do |ele|\n if not yield ele then return false\n end\n end\n return true\n end",
"def every?(arr, &proc)\r\n count = 0\r\n arr.each { |el| count += 1 if proc.call(el) }\r\n count == arr.length\r\nend",
"def iterating_method?(name); end",
"def my_all?\n self.my_each {|x| return false if yield(x) != true}\n true\n end",
"def test_0920_each_entry\n @@log.debug \"test_0920_each_entry starts\" if @@log.debug?\n assert_respond_to(@list, :each_entry, \"test_0920_each_entry_respond\")\n # Type check\n enum = @list.each_entry\n type_check = enum.is_a? Enumerator\n assert(type_check,\"test_0920_each_entry_class\")\n # :TODO: Realistic example(s).\n @@log.debug \"test_0920_each_entry ends\" if @@log.debug?\n end",
"def my_all?(arr, &prc)\n arr.each do |ele|\n return false if !prc.call(ele)\n end\n true\nend",
"def each(&block)\n raise NotImplementedError\n end",
"def test_0160_each_with_index\n @@log.debug \"test_0160_each_with_index starts\" if @@log.debug?\n assert_respond_to(@list, :each_with_index, \"test_0160_each_with_index_respond\")\n # Basic operation\n ta = []\n @list.each_with_index do |obj, ndx|\n ta << \"#{obj.first}-#{ndx}\"\n end\n assert_equal([\"Alfred-0\", \"Bob-1\", \"Charlie-2\", \"Dilbert-3\"], ta, \"test_0160_each_with_index_basic\")\n # Check Enumerator or Enumerable::Enumerator return, no block given\n new_list = @list.each_with_index\nif RUBY_VERSION >= \"1.9\"\n result = new_list.is_a? Enumerator\n assert(result, \"test_0160_each_with_index_enumcheck\")\nelse\n result = new_list.is_a? Enumerable::Enumerator\n assert(result, \"test_0160_each_with_index_enumenumcheck\")\nend\n @@log.debug \"test_0160_each_with_index ends\" if @@log.debug?\n end",
"def iterArr\r\n arr = [1, 3, 5, 7, 9]\r\n arr.each{|i| puts i}\r\nend",
"def each(&block)\n raise NotImplementedError\n end",
"def each_value(&block); end",
"def each(options={}, &block)\n end",
"def each(&block)\n bits.each(&block)\n end",
"def each\n\t\t\t@elements.each\n\t\tend",
"def each(&block)\n return all.each(&block)\n end",
"def each (arr)\n # arr = [2, 3, 4] #val will be 2 in the first iteration and so on.\n for val in arr \n # we are calling block ({ |x| x * 10 }) with \n result = yield(val)\n puts \"result: #{result}\"\n end\nend",
"def test_break_works_with_each_style_iterations\n array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n sum = 0\n array.each do |item|\n break if item > 3\n sum += item\n end\n assert_equal 6, sum\n end",
"def custom_each(array)\n i = 0\n while i < array.length\n #yield will pass this element to the block\n yield array[i] #each and single element of array iterate\n i += 1 #to stop infinite loop\n end\nend",
"def each\n while true do\n yield\n break if ! advance\n end\n end",
"def fizzbuzz(num)\n collection = (1..num).to_a\n collection.each do |num|\n if (num % 3 == 0) && (num % 5 != 0)\n puts \"Fizz #{num}\"\n elsif (num % 5 == 0) && (num % 3 != 0)\n puts \"Buzz #{num}\"\n elsif (num % 3 == 0) && (num % 5 == 0)\n puts \"FizzBuzz #{num}\"\n end\n end\nend",
"def each &b\n\t\t@array.each(&b)\n\tend",
"def each(&block)\r\n @range.each(&block)\r\n end",
"def my_all?\n status = true\n self.my_each do |item|\n if (yield item) != true\n status = false\n end\n end\n status\n end",
"def iterArr\n arr = [1, 3, 5, 7, 9]\n arr.each{|i| puts i}\nend",
"def test_try_each_instead_of_collect_change_array\n array = [1, 2, 3]\n array = array.each { |item| item + 10 }\n #assert_equal [11, 12, 13], array\n assert_equal [1, 2, 3], array\n end",
"def each\n# And define each on top of next\nloop { yield self.next }\nend",
"def each\n# And define each on top of next\nloop { yield self.next }\nend",
"def test_0640_each_cons\n @@log.debug \"test_0640_each_cons starts\" if @@log.debug?\n assert_respond_to(@list, :each_cons, \"test_0640_each_cons_respond\")\n # Type check\n enum = @list.each_cons(2)\n result = enum.is_a? Enumerator\n assert(result,\"test_0640_each_cons_class\") \n # Ckeck each consecutive array\n pass = 0\n @list.each_cons(2) {|suba|\n pass += 1\n case pass\n when 1\n assert_equal([@aen, @bsb], suba, \"test_0640_each_cons_p1\")\n when 2\n assert_equal([@bsb, @cab], suba, \"test_0640_each_cons_p2\")\n when 3\n assert_equal([@cab, @dad], suba, \"test_0640_each_cons_p3\")\n else\n fail(\"test_0640_each_cons_invalid\")\n end\n }\n @@log.debug \"test_0640_each_cons ends\" if @@log.debug?\n end",
"def my_all?(&prc)\n self.my_each do |el|\n return false if !prc.call(el)\n end\n\n true\n end",
"def each(&block)\n @succ.each(&block)\n end",
"def my_all?(collection)\n i = 0\n block_return_values = []\n while i < collection.length\n block_return_values << yield(collection[i]) #or .push, in this case shove is being used.\n i = i + 1 #i += does the same thing. Use this if it's easier for you.\n end\n\n if block_return_values.include?(false)\n false\n else\n true\n end\nend",
"def my_all?\n return self unless block_given?\n for a in self\n if !yield(a)\n return false\n end\n end\n return true\n end",
"def test_array_each\n alphabet = ('A'..'C').to_a\n i = 0\n alphabet.each do |letter|\n assert alphabet[i] == letter, \"Should be #{alphabet[i]} for i = #{i}\"\n i += 1\n end\n end",
"def my_each(array) \n n = 0\n while n < array.length \n yield(array[n])\n n = n + 1 \n end\n array\nend"
] | [
"0.6608434",
"0.6592421",
"0.65745664",
"0.65745664",
"0.65745664",
"0.65745664",
"0.65745664",
"0.65745664",
"0.6443152",
"0.637548",
"0.637548",
"0.637548",
"0.637548",
"0.637548",
"0.637548",
"0.637548",
"0.637548",
"0.637548",
"0.637548",
"0.637548",
"0.6112291",
"0.6047763",
"0.60337704",
"0.6031179",
"0.6008074",
"0.5978805",
"0.59736055",
"0.5970819",
"0.5967804",
"0.5967804",
"0.5967804",
"0.5967804",
"0.5967804",
"0.5967804",
"0.58734024",
"0.5867139",
"0.58575183",
"0.58476186",
"0.58309215",
"0.580637",
"0.580637",
"0.580083",
"0.5795371",
"0.579525",
"0.5787369",
"0.578694",
"0.5780038",
"0.57694745",
"0.5749912",
"0.57452303",
"0.5740623",
"0.57146186",
"0.56704086",
"0.5664152",
"0.5646732",
"0.5646036",
"0.56216735",
"0.5618541",
"0.56179565",
"0.5611019",
"0.5603305",
"0.55978763",
"0.5597011",
"0.5581743",
"0.55795026",
"0.5576529",
"0.5572314",
"0.55712396",
"0.5556053",
"0.55528384",
"0.55511117",
"0.5543919",
"0.5543543",
"0.5540961",
"0.5534682",
"0.55319595",
"0.5531893",
"0.54972047",
"0.54810214",
"0.5479018",
"0.5467167",
"0.54542357",
"0.5451007",
"0.54477644",
"0.544366",
"0.5438885",
"0.54330635",
"0.5432768",
"0.5431356",
"0.5426792",
"0.54253477",
"0.54127264",
"0.54091626",
"0.54091626",
"0.5406884",
"0.54066944",
"0.54008806",
"0.53989935",
"0.5376097",
"0.5370898",
"0.53667617"
] | 0.0 | -1 |
function9 ===> no.8 & 9 using "for loop" | def pets_by_breed(petshop,breed)
pets=[]
for pet in petshop[:pets] do
if pet[:breed] == breed
pets.push(breed)
end
end
return pets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def looper\n for i in 1..10\n return i\n end\nend",
"def looper \r\n for i in 1..10\r\n puts i\r\n end\r\nend",
"def looper\n for i in 1..10\n puts i\n end\nend",
"def generateLoop2\n for i in 1...10 do #do optional\n puts i\n end\n end",
"def func7\n arr = []\n for i in (0..9) do\n arr.push(func6)\n end\n return arr\nend",
"def number_loop_three(i)\n (0..i).each do |num|\n puts \"The number now is #{num}\" \n end \nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def number_loop_two(x)\n i = [1,2,3,4,5,6]\n\n for x in i\n puts \"number #{x}!\"\n end\nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def for(operation); end",
"def for_iterator\n\tfor item in 1..3 do\n\t puts \"The current item is #{item}.\"\n\tend\nend",
"def looper\n for i in 1..10\n puts i #needs an indent\n end\n # needs to return the final result of the loop to fulfil the test.\nend",
"def method_return_from_loop\n (1..10).each do |n|\n if n == 5\n return 5 * 5\n end\n end\n nil\n end",
"def puts_1_to_10\n (1..10).each { |i| puts i }\nend",
"def puts_1_to_10\n (1..10).each { |i| puts i }\nend",
"def elefantes(num)\n for i in 1..num\n p \"#{i} elefante se columpiaba sobre la tela de una araña, como veía que resistía fueron a llamar a otro elefante.\"\n end\nend",
"def mi_funcion(parametro)\n parametro.times do\n puts \"Ruby es raramente elegante.\"\n end\nend",
"def range_print_10\n array = (0..9).to_a\narray.each do |x|\n print x\nend\n\nend",
"def for_loop\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 21 )\n return_value = ForLoopReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n\n _last = _first_0 = nil\n string_literal77 = nil\n string_literal83 = nil\n __ID85__ = nil\n __FOR_IN88__ = nil\n __ID90__ = nil\n variable_statement78 = nil\n expression79 = nil\n expression80 = nil\n expression81 = nil\n block82 = nil\n variable_statement84 = nil\n expression86 = nil\n block87 = nil\n variable_statement89 = nil\n expression91 = nil\n block92 = nil\n\n tree_for_string_literal77 = nil\n tree_for_string_literal83 = nil\n tree_for_ID85 = nil\n tree_for_FOR_IN88 = nil\n tree_for_ID90 = nil\n\n begin\n # at line 116:3: ( ^( 'for' ( variable_statement | expression ) expression expression block ) | ^( 'each' ( variable_statement | ID ) expression block ) | ^( FOR_IN ( variable_statement | ID ) expression block ) )\n alt_24 = 3\n case look_24 = @input.peek( 1 )\n when FOR then alt_24 = 1\n when EACH then alt_24 = 2\n when FOR_IN then alt_24 = 3\n else\n raise NoViableAlternative( \"\", 24, 0 )\n end\n case alt_24\n when 1\n root_0 = @adaptor.create_flat_list\n\n\n # at line 116:5: ^( 'for' ( variable_statement | expression ) expression expression block )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal77 = match( FOR, TOKENS_FOLLOWING_FOR_IN_for_loop_603 )\n\n tree_for_string_literal77 = @adaptor.copy_node( string_literal77 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal77, root_1 )\n\n\n\n match( DOWN, nil )\n # at line 116:15: ( variable_statement | expression )\n alt_21 = 2\n look_21_0 = @input.peek( 1 )\n\n if ( look_21_0 == VAR )\n alt_21 = 1\n elsif ( look_21_0.between?( AMP, AMP_ASGN ) || look_21_0 == POST_DECR || look_21_0.between?( GEQ, AREF ) || look_21_0.between?( GREATER, HAT ) || look_21_0.between?( ARROW, HAT_ASGN ) || look_21_0 == ASGN || look_21_0 == REGEX || look_21_0 == IN || look_21_0 == INCR || look_21_0.between?( INSTANCEOF, RSHIFT3 ) || look_21_0 == RSHIFT3_ASGN || look_21_0 == RSHIFT_ASGN || look_21_0 == LEQ || look_21_0.between?( LESS, SLASH ) || look_21_0 == SLASH_ASGN || look_21_0.between?( STAR, DECR ) || look_21_0 == STAR_ASGN || look_21_0 == LSHIFT || look_21_0.between?( DELETE, THIS ) || look_21_0.between?( MINUS, TILDE ) || look_21_0.between?( MINUS_ASGN, MOD ) || look_21_0.between?( MOD_ASGN, TYPEOF ) || look_21_0.between?( NEQ, UMINUS ) || look_21_0.between?( NEQQ, UNDEFINED ) || look_21_0 == NEW || look_21_0 == NOT || look_21_0.between?( NULL, UPLUS ) || look_21_0 == OBJECT || look_21_0.between?( EQ, OR_ASGN ) || look_21_0 == FALSE || look_21_0 == PIPE || look_21_0 == PIPE_ASGN || look_21_0 == PLUS || look_21_0.between?( ID, DOC ) )\n alt_21 = 2\n else\n raise NoViableAlternative( \"\", 21, 0 )\n end\n case alt_21\n when 1\n # at line 116:17: variable_statement\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_variable_statement_IN_for_loop_608 )\n variable_statement78 = variable_statement\n @state.following.pop\n\n @adaptor.add_child( root_1, variable_statement78.tree )\n\n\n when 2\n # at line 116:38: expression\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_for_loop_612 )\n expression79 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression79.tree )\n\n\n end\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_for_loop_616 )\n expression80 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression80.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_for_loop_618 )\n expression81 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression81.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_block_IN_for_loop_620 )\n block82 = block\n @state.following.pop\n\n @adaptor.add_child( root_1, block82.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 2\n root_0 = @adaptor.create_flat_list\n\n\n # at line 117:5: ^( 'each' ( variable_statement | ID ) expression block )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal83 = match( EACH, TOKENS_FOLLOWING_EACH_IN_for_loop_630 )\n\n tree_for_string_literal83 = @adaptor.copy_node( string_literal83 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal83, root_1 )\n\n\n\n match( DOWN, nil )\n # at line 117:15: ( variable_statement | ID )\n alt_22 = 2\n look_22_0 = @input.peek( 1 )\n\n if ( look_22_0 == VAR )\n alt_22 = 1\n elsif ( look_22_0 == ID )\n alt_22 = 2\n else\n raise NoViableAlternative( \"\", 22, 0 )\n end\n case alt_22\n when 1\n # at line 117:17: variable_statement\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_variable_statement_IN_for_loop_634 )\n variable_statement84 = variable_statement\n @state.following.pop\n\n @adaptor.add_child( root_1, variable_statement84.tree )\n\n\n when 2\n # at line 117:38: ID\n _last = @input.look\n __ID85__ = match( ID, TOKENS_FOLLOWING_ID_IN_for_loop_638 )\n\n tree_for_ID85 = @adaptor.copy_node( __ID85__ )\n\n @adaptor.add_child( root_1, tree_for_ID85 )\n\n\n\n end\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_for_loop_642 )\n expression86 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression86.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_block_IN_for_loop_644 )\n block87 = block\n @state.following.pop\n\n @adaptor.add_child( root_1, block87.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 3\n root_0 = @adaptor.create_flat_list\n\n\n # at line 118:5: ^( FOR_IN ( variable_statement | ID ) expression block )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __FOR_IN88__ = match( FOR_IN, TOKENS_FOLLOWING_FOR_IN_IN_for_loop_654 )\n\n tree_for_FOR_IN88 = @adaptor.copy_node( __FOR_IN88__ )\n\n root_1 = @adaptor.become_root( tree_for_FOR_IN88, root_1 )\n\n\n\n match( DOWN, nil )\n # at line 118:15: ( variable_statement | ID )\n alt_23 = 2\n look_23_0 = @input.peek( 1 )\n\n if ( look_23_0 == VAR )\n alt_23 = 1\n elsif ( look_23_0 == ID )\n alt_23 = 2\n else\n raise NoViableAlternative( \"\", 23, 0 )\n end\n case alt_23\n when 1\n # at line 118:17: variable_statement\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_variable_statement_IN_for_loop_658 )\n variable_statement89 = variable_statement\n @state.following.pop\n\n @adaptor.add_child( root_1, variable_statement89.tree )\n\n\n when 2\n # at line 118:38: ID\n _last = @input.look\n __ID90__ = match( ID, TOKENS_FOLLOWING_ID_IN_for_loop_662 )\n\n tree_for_ID90 = @adaptor.copy_node( __ID90__ )\n\n @adaptor.add_child( root_1, tree_for_ID90 )\n\n\n\n end\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_for_loop_666 )\n expression91 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression91.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_block_IN_for_loop_668 )\n block92 = block\n @state.following.pop\n\n @adaptor.add_child( root_1, block92.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n end\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 21 )\n\n end\n \n return return_value\n end",
"def looper\r\n for i in 1..10\r\n puts i #wrong method puts.\r\nend #wrong position of end word.\r\nend",
"def fizzbuzz\n (1..100).each do |num|\n puts fizz_buzz(num)\n end\nend",
"def basic_9 (array_iterate)\n square_array = array_iterate.collect { |n| n * n}\n return square_array\nend",
"def basic_4 (array_iterate)\n array_iterate.each { |n| puts \"Item: #{n}\"}\n puts\nend",
"def fizz_buzz_to(limit)\n #from 1 to the limit number, for each number, take the number \n 1.upto(limit).each do |num|\n #print out result of calling fizzbuzz with the number.\n puts fizzbuzz(num)\n #ends the each do \n end\n#ends the function definition. \nend",
"def for_loop_counter\n numbers = (0 .. 6)\n numbers.each do |num|\n puts \"At the top num is #{num}\"\n if num > 0\n puts \"Numbers: now: \", numbers\n end\n end\nend",
"def mtdarry \n 10.times do |num| \n p num\n square = num * num \n p square\n return square\n #return num, square if num > 7\n end \nend",
"def add_up(i)\r\n sum = 0\r\n for a in 1..i do \r\n sum = sum + a\r\n end\r\n\r\n puts sum \r\n\r\nend",
"def range_print_10\n (0..9).step(1) do |n| \n puts n \n end \n \nend",
"def for_mod(number, increment)\n\tnumbers = [] # create an empty array named and assign it to the variable numbers\n\tfor i in (0...number).step(increment) # we use Range.step(n) funtion instead of the increment i\n\t\tputs \"At the top i is #{i}\"\n\t\tnumbers.push(i) #add i to numbers array\n\t\tputs \"Numbers now: #{numbers}\"\n\t\tputs \"At the bottom i is #{i}\"\n\tend\n\treturn numbers #array\nend",
"def integer_print_10\n 10.times do |x|\n puts x \n end \nend",
"def f i\n return i\n end",
"def a_method\n [1, 2, 3].each do |num|\n puts num * 2\n end\nend",
"def times_iterator(number_of_times)\n 7.times do\n puts \"Welcome to Flatiron School's Web Development Course!\"\n end\nend",
"def sum_using_for(min, max)\n # your code here\n total = 0\n for i in min..max\n total += i\n end\n total\nend",
"def basic_8 (array_iterate, eval_int)\n total = 0\n array_iterate.each { |n| total += 1 if n > eval_int}\n return total\nend",
"def fizzbuzz_array(n)\n (1..n).map do |i|\n fizzbuzz(i)\n end\nend",
"def foobar\n (1..10).each do |val|\n return val # returns from method\n end\nend",
"def ex2\n for i in (0..5)\n for j in (1..(4 - (4 - i).abs))\n print '#'\n end\n print \"\\n\"\n end\nend",
"def each_number_to( number )\r\n\r\n index = 0\r\n while index < number\r\n yield(index)\r\n index += 1\r\n end\r\n\r\nend",
"def fizzbuzz (num1, num2)\n new_arr = []\n\n num1.upto(num2) do |num|\n new_arr << fizzbuzz_case(num)\n end\n\nnew_arr \nend",
"def each_cons(n)\n # Your code goes here.\n end",
"def iter\n f1,f2,k = 1,1,2\n f1,f2,k = f2,f1+f2,k+1 while f2.to_s.size < 1000\n puts k\nend",
"def using_times\n 7.times do\n puts \"Wingardium Leviosa\"\n end\nend",
"def using_times \n 7.times do \n puts \"Wingardium Leviosa\"\n end\nend",
"def numbers(n)\n\nend",
"def fizz_buzz_to(limit)\n#starting from the number 1 up to the variable limit, do something to each integer\n 1.upto(limit).each do |num|\n#print the output of the fizzbuzz method \n puts fizzbuzz(num)\n end\nend",
"def kelp(a,b)\n for i in a..b \n puts i\n end\n \"done\"\n end",
"def array_print_10\n array = []\n array = \"0\".upto(\"9\").to_a\n array.each do |x|\n puts x\n end\nend",
"def n_times(n)\r\n#+++solution+++\r\n n.times do yield() end\r\n#---solution---\r\nend",
"def fizzbuzz_to(limit)\n #Create a loop that starts from 1 and ends at the argument given\n 1.upto(limit) do |i|\n #Print the output of every iteration of the method 'fizzbuzz' when called with the argument of the integers 1 through the limit given\n puts(fizzbuzz(i))\n end\nend",
"def iterArr\r\n arr = [1, 3, 5, 7, 9]\r\n arr.each{|i| puts i}\r\nend",
"def fizz_buzz_to(limit)\n#this signifies a loop stating that from 1 up to the inputed limit, the code will continue to execute\n 1.upto(limit).each do |num|\n #prints the results of the previous method each time the loop is executed \n puts fizzbuzz(num)\n #ends the upto loop \n end\n#ends defined method\nend",
"def fizz_buzz(min, max)\n (min..max).each do |number|\n puts fizz_buzz_calculator(number)\n end\nend",
"def using_times\n\t7.times do\n\t puts \"Wingardium Leviosa\"\n\tend\nend",
"def bark_var(i)\n i.times do\n puts \"wow!\"\n end\n end",
"def factorial(n)\n for i in (1...n)\n n = n * i\n # puts n\n end\n puts n\nend",
"def iterate_with_proc_example!(&code)\n\t\tself.each_with_index do |n, i|\n\t\t\tself[i] = code.call(n)\n\t\tend\n\tend",
"def fib_cheat(num)\n results = []\n (1..num).each {|num| results << fib_num(num)}\n results\nend",
"def ex1\n for i in (0..5)\n for j in (1..(6 - i))\n print '#'\n end\n print \"\\n\"\n end\nend",
"def greet(n)\n n.times do |x|\n puts \"Hello: #{x}\"\n end\nend",
"def iter_soln\n\ttotal = 0\n\t(0..999).each do |i|\n\t\ttotal += i if(i%3 == 0 || i%5 == 0)\n\tend\n\n\tputs total\nend",
"def loop; end",
"def looper\n i = 0\n while i < 20\n i += 1\n # break if i == 9\n # next if i.even?\n # return if i == 9\n puts i\n end\n puts \"done with the loop\"\nend",
"def go\n @i += 1\n puts \"====================\"\n puts \"Tour n°#{@i}\"\n puts \"====================\"\n\n#creation d'une boucle pour alterner les joueurs\n loop do @i < 9\n \n if @i.odd?\n turn(@joueur1)\n\n else @i.even?\n turn(@joueur2)\n end\n break if @i == 9\n end\n end",
"def determine_pair(main_code)\n #double for loop?\n test_code = main_code.clone\n\n for i in (0..99) do\n\n test_code[1] = i\n\n for i in (0..99) do\n test_code[2] = i\n computed = test_code.clone\n computer(computed)\n if computed[0]==19690720\n puts \"When origin=19690720, noun= #{test_code[1]}, verb=#{test_code[2]}\"\n\n end\n\n end\n\n end\n\nend",
"def problem18(r) \n h = r.length\n sum = 0\n for i in 0..h-1 \n \n end\nend",
"def another_method\n [1, 2, 3].each do |num|\n puts num * 2\n end\n puts 'hi'\nend",
"def loop_with_return\n numbers = []\n counter = 0\n\n while counter < 20\n counter += 1\n return counter if counter == 5\n numbers << counter\n end\n\n numbers\nend",
"def scope_loop\n\t1.upto(5) do |i|\n\t\tputs \"the variable is #{i}\"\n\tend\n\nend",
"def step_test\n 3.upto(6) do |x|\n puts \" \"\n x.upto(x + 2) do |i|\n print \"#{i}\\t\"\n end\n end\nend",
"def using_times\n $num.times do\n puts \"Wingardium Leviosa\"\n end\nend",
"def foo(endVariable)\n (1..endVariable).each do |i|\n puts \"Valor es: #{i}\"\n end\nend",
"def nextLooping(number)\n for i in 1..10\n if i * number % 5 == 0\n next\n else\n puts i * number\n end\n end\n end",
"def add_up(i)\n sum = 0\n for item in 1..i do\n sum = sum + item\n end\n return sum\n end",
"def each(*) end",
"def methodA(n)\n count = 0\n for i in 1..n\n for j in 1..i\n count += f(j)\n end\n end\n return count\nend",
"def sequence(num)\n\n results = []\n\n 1.upto(num) { |num| results << num }\n\n results\n\nend",
"def iterArr\n arr = [1, 3, 5, 7, 9]\n arr.each{|i| puts i}\nend",
"def times_iterator(number_of_times)\n number_of_times.times do\n puts \"Welcome to Flatiron School's Web Development Course!\"\n end\nend",
"def pow(base_num, pow_num)\n result = 1\n pow_num.times do |index|#loop trough the code ex: if pow_num is = 3, the loop will trough 3 times.\n result = result * base_num\n end\n return result\nend",
"def integer_print_10\n 10.times do |x|\n print x\n end\nend",
"def fizzbuzz_iterator range_from , range_to\n (range_from..range_to).each do |i|\n if divisible_by?(i,3) && divisible_by?(i,5)\n @fizzbuzz_array << \"FizzBuzz\"\n elsif divisible_by?(i,3)\n @fizzbuzz_array << \"Fizz\"\n elsif divisible_by?(i,5)\n @fizzbuzz_array << \"Buzz\"\n else\n @fizzbuzz_array << i\n end\n end\n end",
"def func(list)\n\n puts list[0]\n\n midpoint = list.length / 2\n\n array[0..midpoint-1].each do |element|\n puts element\n end\n\n 10.times do\n puts 'hello world'\n end\nend",
"def i_love_each_of( albums )\n i = 0\n until i == albums.count \n puts \"I <3 #{albums[ i ]}!\" \n i += 1\n end\nend",
"def print_range\n\n\tsum = 0\n\t\n\tfor i in 1...1000 do\n\t\t\t\t\n\t\tif i%3 == 0 or i%5 == 0\n\t\t\t\n\t\t\tsum += i\n\t\t\t\n\t\t\t#just for initial tracing\n\t\t\t#puts i \n\n\t\tend\t\n\n\tend\t \n\t\t\n\tputs sum\n\t\t\nend",
"def factorial(num)\r\n result = 1;\r\n for i in 1..num\r\n result *= i\r\n end\r\n puts result\r\nend",
"def loop_message_n_times(array,n)\n n.times{puts array}\n \n \n\nend",
"def multiples(i)\n ms = []\n (1..10).each do |j|\n ms << i * j\n end\n ms\nend",
"def fizz_buzz_to(limit)\n# This defines the variable \"fizz_buzz-to\" and explains in parenthesis what parameters can be passed into it.\n# In this case, there is only one parameter: limit.\n 1.upto(limit).each do |num|\n#Here we are using a loop to say that from integers 1 up to whatever number is placed in the parameter limit, do the following.\n puts fizzbuzz(num)\n#So for integers from 1 up until the established limit, run that number through the fizzbuzz variable and print the result (which, based on our case options, will be \"FizzBuzz\", \"Fizz\", \"Buzz\" or the number itself.)\n end\n #This ends the steps within the loop.\nend",
"def fizz_buzz_to(limit)\n 1.upto(limit).each do |num|\n puts fizzbuzz(num)\n end\nend",
"def fizzbuzz_to(limit)\n\t# Upto is being called to the 1. You pick a variable and it will print all the number up to that 'limit'. \n 1.upto(limit) do |i|\n \t# This Prints out the code on terminal. \n puts(fizzbuzz(i))\n end\nend",
"def number_counting_seq(n)\r\n\r\nend",
"def loops\n return @loops if @loops\n @loops = (data['loops']||[]).map { |l| function.blocks.by_name(l).loop }\n end",
"def fizz_buzz_to(limit)\n# in increments of 1, \"do\" something each time you see \"num\"\n 1.upto(limit).each do |num|\n# print each incremental number on each loop until (value passed to limit) is reached\n puts fizzbuzz(num)\n# end upto method\n end\n# end fizz_buzz_to\nend",
"def run_block_with_return\n numbers = []\n\n (1..20).each do |number|\n return number if number == 11\n numbers << number\n end\n\n numbers\nend",
"def fizzbuzz(num_1, num_2, range)\n # Invokes the for-loop method \"each\" to the interger range, ending the range\n # at the parameter \"range\" value.\n # Iterates the following if/elsif/else statement over each element in the index\n (1..range).each do |i|\n # Checks if the modulus of varriable \"i\" into the parameter \"num_1\" is the\n # same class as the interger 0\n # Checks if the modulus of varriable \"i\" into the parameter \"num_2\" is the\n # same class as the interger 0\n # The loogical AND operator checks if both === methods returned TRUE\n # If yes, returns TRUE. If no, returns FALSE.\n if i % num_1 === 0 && i % num_2 === 0\n # If the if statement returns TRUE, prints the string 'fizzbizz' to\n # the console\n # if the if statemnt returns FALSE, does nothing.\n puts 'fizzbuzz'\n # Calculates the modulus of the \"i\" variable into the paramater num_1.\n # Evaluates if the return to the above calculation is an interger.\n elsif i % num_1 === 0\n # If the elsif statement above returns TRUE, prints the string 'fizz' to\n # the console.\n # if the elsif statemnt above returns FLASE, does nothing.\n puts 'fizz'\n # Calculates the modulus of the \"i\" variable into the parameter num_2.\n # Evaluates if the return of the above calculation is an interger.\n elsif i % num_2 === 0\n # If the elsif statement above returns TRUE, prints the string 'buzz' to\n # the console.\n # if the eslif statemnt above returns FALSE, does nothing\n puts 'buzz'\n # If no nother if/els if statement has returned TRUE, this line will run\n else\n # Prints the current value of the varribale \"i\" to the console.\n puts i\n # Ends the if/elsif/els statements\n end\n # Ends the \".each\" method invocation\n end\n # Ends the definitions of the \"fizzbuzz\" method.\nend",
"def yo_dawg(num)\n n.times do\n n.times do\n puts \"I put a loop in your loop so you can loop while you loop.\"\n end\n end\nend",
"def iterate_proc!(&cod)\n self.each_with_index { |n, i|\n self[i] = cod.call(n)\n }\n end",
"def SimpleAdding(num)\nsum=0\n 1.upto(num) do |x|\n\tsum+=x\n\tend\n\t\nreturn sum\nend"
] | [
"0.6779122",
"0.67550707",
"0.67104614",
"0.66926473",
"0.6656659",
"0.65270895",
"0.6499904",
"0.6495576",
"0.64103496",
"0.64103496",
"0.64103496",
"0.6312063",
"0.62044024",
"0.6197904",
"0.61917573",
"0.61780125",
"0.61780125",
"0.6070426",
"0.6065542",
"0.60293585",
"0.5962743",
"0.5946392",
"0.5913854",
"0.58770645",
"0.584924",
"0.58296406",
"0.58245486",
"0.5783143",
"0.5781877",
"0.5771005",
"0.57526165",
"0.57390714",
"0.57114273",
"0.57075274",
"0.5703355",
"0.5694994",
"0.5694378",
"0.56786114",
"0.56643003",
"0.56556267",
"0.56439084",
"0.5640959",
"0.562711",
"0.56270033",
"0.56116277",
"0.5609015",
"0.56049615",
"0.55982375",
"0.5588841",
"0.5580892",
"0.55718994",
"0.5568587",
"0.556312",
"0.55575854",
"0.5555796",
"0.55489177",
"0.55483794",
"0.55455637",
"0.5541645",
"0.55412835",
"0.5536925",
"0.55278176",
"0.55274516",
"0.5524664",
"0.55198103",
"0.5508557",
"0.55051345",
"0.55045795",
"0.5494921",
"0.5481181",
"0.5479506",
"0.54794145",
"0.5477781",
"0.54774547",
"0.54703575",
"0.54692996",
"0.54667026",
"0.5459775",
"0.54427224",
"0.5438619",
"0.54385436",
"0.54363525",
"0.5433398",
"0.54293644",
"0.5427436",
"0.54257274",
"0.54252225",
"0.5422202",
"0.5416746",
"0.5405375",
"0.5397512",
"0.53974295",
"0.53920114",
"0.53893304",
"0.53861666",
"0.5372155",
"0.5370994",
"0.53682786",
"0.5365295",
"0.5362282",
"0.53591317"
] | 0.0 | -1 |
function10 ===> test no.10 & 11 using ".each" | def find_pet_by_name(petshop,pet_name)
petshop[:pets].each do
if pet_hash[:name] == pet_name
return pet_hash
end
end
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_0010_each\n @@log.debug \"test_0010_each starts\" if @@log.debug?\n count = 0\n @list.each do |elt|\n count += 1\n end\n assert_equal(4, count)\n @@log.debug \"test_0010_each ends\" if @@log.debug?\n end",
"def each(*) end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&a_proc); end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each(&blk); each_value(&blk) ; end",
"def puts_1_to_10\n (1..10).each { |i| puts i }\nend",
"def puts_1_to_10\n (1..10).each { |i| puts i }\nend",
"def each(node, &block); end",
"def each(&block)\n end",
"def each(&block)\n tests.each(&block)\n end",
"def each(&block)\nend",
"def each &block\n end",
"def each\n end",
"def each\n end",
"def each(&block)\n\n end",
"def each(*args,&blk)\n\t\t@rounds.each(*args,&blk) \n\tend",
"def my_each(&prc)\n end",
"def each (arr)\n # arr = [2, 3, 4] #val will be 2 in the first iteration and so on.\n for val in arr \n # we are calling block ({ |x| x * 10 }) with \n result = yield(val)\n puts \"result: #{result}\"\n end\nend",
"def test_each\n # codecite examples\n evens = Sequence.new(5, 2) {|a| a.last + 2} \n odds = Sequence.new(5, 1) {|a| a.last + 2}\n fibs = Sequence.new(5, 1, 1) {|a| a[-2] + a[-1]}\n # codecite examples\n \n assert_equal [2,4,6,8,10], evens.to_a\n assert_equal [1,3,5,7,9], odds.to_a\n assert_equal [1,1,2,3,5], fibs.to_a\n end",
"def each\n end",
"def custom_each(array)\r\n i = 0 \r\n while i < array.length \r\n yield array[i]\r\n i += 1\r\n end\r\nend",
"def each (arr)\n # arr = [2, 3, 4, 5]\n # val will be 2 in the first iteration and so on...\n for val in arr \n # we are calling block ({ |x| x * 10 }) with val\n result = yield(val)\n puts \"result: #{result}\"\n end\nend",
"def every?(arr, &blck)\n # arr.all? { |el| blck.call(el) }\n arr.each do |el|\n if !blck.call(el)\n return false\n end\n end\n return true\nend",
"def basic_4 (array_iterate)\n array_iterate.each { |n| puts \"Item: #{n}\"}\n puts\nend",
"def fizz_buzz_to(limit)\n #from 1 to the limit number, for each number, take the number \n 1.upto(limit).each do |num|\n #print out result of calling fizzbuzz with the number.\n puts fizzbuzz(num)\n #ends the each do \n end\n#ends the function definition. \nend",
"def iterate(expected, meth=:each, *args)\n\t\tlambda { |obj|\n\t\t\tt = []\n\t\t\tobj.__send__(meth, *args) { |v| t << v }\n\t\t\tt == expected\n\t\t}\n\tend",
"def each(&block)\n all.each(&block)\n end",
"def _each(&block)\n _next.each(&block) if _next\n end",
"def multiples(num)\n# \"each\" loop for each integer\n (1..num).each do |num|\n # numbers that are mulitples of 3 and 5\n if num % 3 == 0 && num % 5 == 0\n puts \"FizzBuzz\"\n # multiples of 5\n elsif num % 5 == 0\n puts \"Buzz\"\n # multiples of 3\n elsif num % 3 == 0\n puts \"Fizz\"\n # if not divisible by 5 or 3, just print number\n else\n puts num\n end\n end\nend",
"def each(&block) # block into proc\n\nend",
"def each\n raise 'Not implemented'\n end",
"def fizzbuzz(num)\n collection = (1..num).to_a\n collection.each do |num|\n if (num % 3 == 0) && (num % 5 != 0)\n puts \"Fizz #{num}\"\n elsif (num % 5 == 0) && (num % 3 != 0)\n puts \"Buzz #{num}\"\n elsif (num % 3 == 0) && (num % 5 == 0)\n puts \"FizzBuzz #{num}\"\n end\n end\nend",
"def fizzbuzz\n (1..100).each do |num|\n puts fizz_buzz(num)\n end\nend",
"def test_try_each_instead_of_collect_change_array\n array = [1, 2, 3]\n array = array.each { |item| item + 10 }\n #assert_equal [11, 12, 13], array\n assert_equal [1, 2, 3], array\n end",
"def each_pair(*) end",
"def custom_each(array)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\nend",
"def isbn10(isbn_array, isbn_number) #defines a function used to check a 10 digit number\n\tcounter= 0 #establishes a counter\n\ttotal10 = 0 #establishes a check number total\n\t10.times do #initiates a loop through the 10 digit number\n\t\tnumber = isbn_array[counter] #pulls number from the isbn array based on its aray location\n\t\ttotal10 = total10 + (number*(counter+1)) #does multiplication and adds product to total10\n\t\tcounter = counter +1 #updates counter\n\tend #ends do loop\n\n\tprint \"The check total is #{total10}. \\n \\n\" #prints total10\n\tif 0 == total10%11 #performs check to see if total10 is evenly divisible by 11 and prints accordingly\n\n\t\tprint \"#{isbn_number} is a valid 10-digit ISBN number. \\n \\n\"\n\telse\n\t\tprint \"#{isbn_number} is NOT a valid 10-digit ISBN number. \\n \\n\"\t\n\tend #ends if statement\nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def each(&b) \n @data.each(&b) \n end",
"def iterArr\r\n arr = [1, 3, 5, 7, 9]\r\n arr.each{|i| puts i}\r\nend",
"def each_identity; end",
"def every?(arr, &prc)\n\n arr.each do |ele|\n return false if !(prc.call(ele))\n end\n\n true\nend",
"def _test_numbers ; process_test_case(\"numbers\") ; end",
"def test_each_is_a_method_on_arrays\n assert_equal true, [].methods.include?(as_name(:each))\n end",
"def custom_each(array)\n i = 0\n while i < array.length\n #yield will pass this element to the block\n yield array[i] #each and single element of array iterate\n i += 1 #to stop infinite loop\n end\nend",
"def my_all?\n\t\t#if any element is false return false\n\t\tmy_each do | element |\n\t\t\tif yield( element )\n\t\t\t\tnext\n\t\t\telse\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\n\t\t# returns true when all iterations pass\n\t\treturn true\n\n\tend",
"def fizzBuzz\n array = [*1..100]\n array.each { |num|\n if ((num % 3) == 0) && ((num % 5) == 0)\n puts \"FizBuzz\"\n elsif num % 5 == 0\n puts \"Buzz\"\n elsif num % 3 == 0\n puts \"Fizz\"\n else \n puts num\n end\n }\nend",
"def each\n\t\t\t@elements.each\n\t\tend",
"def each(options={}, &block)\n end",
"def every?(arr, &prc)\n count = 0\n arr.each do |ele| \n if prc.call(ele)\n count += 1\n end\n end\n count == arr.length\nend",
"def each # And define each on top of next\n loop {yield self.next }\n end",
"def each(&block)\n @all.each(&block)\n end",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def test_0650_each_slice\n @@log.debug \"test_0650_each_slice starts\" if @@log.debug?\n assert_respond_to(@list, :each_slice, \"test_0650_each_slice_respond\")\n # Type check.\n enum = @list.each_slice(2)\n result = enum.is_a? Enumerator\n assert(result,\"test_0650_each_slice_class\") \n # Check each array slice.\n pass = 0\n @list.each_slice(2) {|suba|\n pass += 1\n case pass\n when 1\n assert_equal([@aen, @bsb], suba, \"test_0650_each_slice_p1\")\n when 2\n assert_equal([@cab, @dad], suba, \"test_0650_each_slice_p2\")\n else\n fail(\"test_0650_each_slice_invalid\")\n end\n }\n #\n pass = 0\n @list.each_slice(3) {|suba|\n pass += 1\n case pass\n when 1\n assert_equal([@aen, @bsb, @cab], suba, \"test_0650_each_slice_p1b\")\n when 2\n assert_equal([@dad], suba, \"test_0650_each_slice_p2b\")\n else\n fail(\"test_0650_each_slice_invalid_b\")\n end\n }\n @@log.debug \"test_0650_each_slice ends\" if @@log.debug?\n end",
"def another_method\n [1, 2, 3].each do |num|\n puts num * 2\n end\n puts 'hi'\nend",
"def iterArr\n arr = [1, 3, 5, 7, 9]\n arr.each{|i| puts i}\nend",
"def each\n loop do\n @next += (@next % 10 == 3) ? 4 : 2\n yield @next\n end\n end",
"def each\n for each element\n yield(element)\n end\nend",
"def my_all? \n\ti = true\n\tself.my_each do |a|\n\t\tunless yield (a)\n\t\t\ti = false\n\t\t\tbreak\n\t\tend\n\tend\n\ti\nend",
"def each_mid(&block)\n \n end",
"def range_print_10\n array = (0..9).to_a\narray.each do |x|\n print x\nend\n\nend",
"def test_0655_each_with_index\n @@log.debug \"test_0655_each_with_index starts\" if @@log.debug?\n assert_respond_to(@list, :each_with_index, \"test_0655_each_with_index_respond\")\n # Type check\n enum = @list.each_with_index\n result = enum.is_a? Enumerator\n assert(result,\"test_0655_each_with_index_class\") \n # Check each index number\n @list.each_with_index {|item, index|\n case\n when item == @aen\n assert(index == 0, \"test_0655_each_with_index_i0\")\n when item == @bsb\n assert(index == 1, \"test_0655_each_with_index_i1\")\n when item == @cab\n assert(index == 2, \"test_0655_each_with_index_i2\")\n when item == @dad\n assert(index == 3, \"test_0655_each_with_index_i3\")\n else\n flunk(\"test_0655_each_with_index_invalid\")\n end\n }\n#\n# The author's paper copy of the 1.9 Pickaxe implies that each_with_index\n# can be invoked with one or more arguments as shown below.\n#\n# This appears to be incorrect, which can be confirmed by either:\n#\n# * Attempting to run the code shown\n# * Documentation at http://ruby-doc.org/core-1.9/classes/Enumerable.html\n#\n=begin\n # Invoke with argument(s)\n myarg = \"-tag\"\n accum = \"\"\n @list.each_with_index(myarg) {|item, index|\n case\n when item == @aen\n assert(index == 0, \"test_0655_each_with_index_i0a\")\n assert(myarg == \"-tag\", \"test_0655_each_with_index_tag0\")\n when item == @bsb\n assert(index == 1, \"test_0655_each_with_index_i1a\")\n assert(myarg == \"-tag\", \"test_0655_each_with_index_tag1\")\n when item == @cab\n assert(index == 2, \"test_0655_each_with_index_i2a\")\n assert(myarg == \"-tag\", \"test_0655_each_with_index_tag2\")\n when item == @dad\n assert(index == 3, \"test_0655_each_with_index_i3a\")\n assert(myarg == \"-tag\", \"test_0655_each_with_index_tag3\")\n else\n flunk(\"test_0655_each_with_index_invalid\")\n end\n }\n=end\n @@log.debug \"test_0655_each_with_index ends\" if @@log.debug?\n end",
"def each_number_to( number )\r\n\r\n index = 0\r\n while index < number\r\n yield(index)\r\n index += 1\r\n end\r\n\r\nend",
"def each(&block)\r\n @range.each(&block)\r\n end",
"def test_break_works_with_each_style_iterations\n array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n sum = 0\n array.each do |item|\n break if item > 3\n sum += item\n end\n assert_equal 6, sum\n end",
"def my_each(array) # put argument(s) here\n i = 0\n\n while i < array.length\n yield array[i]\n i += 1\n end\n array\nend",
"def foobar\n (1..10).each do |val|\n return val # returns from method\n end\nend",
"def my_all?\n my_each do |i|\n if (!yield(i))\n return false\n end\n end\n true\n end",
"def every(objTemplate)\n results = Array.new\n foreach(objTemplate) do |item|\n results << item if !block_given?\n results << item if block_given? && (yield item)\n end\n results \nend",
"def print_all( print_result )\n print_result.each do |print_output|\n puts print_output\n end\nend",
"def a_method\n [1, 2, 3].each do |num|\n puts num * 2\n end\nend",
"def iterating_method?(name); end",
"def super_fizzbuzz(array)\n\tarray = [1..100]\n\tarray.each do |num|\n\t\tif num % 3 == 0 \n\t\t\tprint \"Fizz\"\n\t\tend \n\t\tif num % 5 == 0 \n\t\t\tprint \"Buzz\"\n\t\tend \n\t\tif num % 15 == 0 \n\t\t\tprint \"FizzBuzz\"\n\t\tend \n\tend \nend",
"def my_all?(&block)\n counter = 0\n my_each do |elem|\n counter += 1 if block.call(elem) == true\n end\n return true if counter == size\n\n false\n end",
"def run_block_with_return\n numbers = []\n\n (1..20).each do |number|\n return number if number == 11\n numbers << number\n end\n\n numbers\nend",
"def each_cons(n)\n # Your code goes here.\n end",
"def each(&blk)\n data.each(&blk)\n end"
] | [
"0.66305876",
"0.6582482",
"0.6336903",
"0.6336903",
"0.6336903",
"0.6336903",
"0.6336903",
"0.6336903",
"0.6327795",
"0.63255477",
"0.63255477",
"0.63255477",
"0.63255477",
"0.63255477",
"0.63255477",
"0.63255477",
"0.63255477",
"0.63255477",
"0.63255477",
"0.63255477",
"0.5980555",
"0.5980555",
"0.5980555",
"0.5980555",
"0.5980555",
"0.5980555",
"0.59717655",
"0.5955559",
"0.5955559",
"0.5886294",
"0.5856096",
"0.5850825",
"0.58331466",
"0.5825274",
"0.58073837",
"0.58073837",
"0.5802275",
"0.5797311",
"0.57931316",
"0.57729995",
"0.5746982",
"0.57273173",
"0.57107866",
"0.56890124",
"0.5679677",
"0.5672279",
"0.5662172",
"0.56178415",
"0.5603013",
"0.55988425",
"0.55943906",
"0.5571851",
"0.55592835",
"0.5555081",
"0.55433726",
"0.5526942",
"0.55264556",
"0.551934",
"0.5497405",
"0.54940414",
"0.54940414",
"0.54940414",
"0.54870504",
"0.54855347",
"0.5477186",
"0.5468897",
"0.5460904",
"0.5452091",
"0.5446729",
"0.5445291",
"0.5442141",
"0.5435719",
"0.5435176",
"0.54304117",
"0.5420578",
"0.5411493",
"0.5409242",
"0.539839",
"0.53929454",
"0.53909063",
"0.53884315",
"0.5388173",
"0.5385984",
"0.5371622",
"0.53705466",
"0.53650695",
"0.5363021",
"0.5358184",
"0.53462434",
"0.53331214",
"0.5329684",
"0.53282857",
"0.5327842",
"0.5315582",
"0.5308848",
"0.53044623",
"0.53041923",
"0.5298048",
"0.5297557",
"0.52945215",
"0.5290653"
] | 0.0 | -1 |
function11 answering to test no.10 and 11 using ".each" | def find_pet_by_name(petshop,pet_name)
for pet_hash in petshop[:pets] do
if pet_hash[:name] == pet_name
return pet_hash
end
end
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_0010_each\n @@log.debug \"test_0010_each starts\" if @@log.debug?\n count = 0\n @list.each do |elt|\n count += 1\n end\n assert_equal(4, count)\n @@log.debug \"test_0010_each ends\" if @@log.debug?\n end",
"def isbn10(isbn_array, isbn_number) #defines a function used to check a 10 digit number\n\tcounter= 0 #establishes a counter\n\ttotal10 = 0 #establishes a check number total\n\t10.times do #initiates a loop through the 10 digit number\n\t\tnumber = isbn_array[counter] #pulls number from the isbn array based on its aray location\n\t\ttotal10 = total10 + (number*(counter+1)) #does multiplication and adds product to total10\n\t\tcounter = counter +1 #updates counter\n\tend #ends do loop\n\n\tprint \"The check total is #{total10}. \\n \\n\" #prints total10\n\tif 0 == total10%11 #performs check to see if total10 is evenly divisible by 11 and prints accordingly\n\n\t\tprint \"#{isbn_number} is a valid 10-digit ISBN number. \\n \\n\"\n\telse\n\t\tprint \"#{isbn_number} is NOT a valid 10-digit ISBN number. \\n \\n\"\t\n\tend #ends if statement\nend",
"def _test_numbers ; process_test_case(\"numbers\") ; end",
"def multiples(num)\n# \"each\" loop for each integer\n (1..num).each do |num|\n # numbers that are mulitples of 3 and 5\n if num % 3 == 0 && num % 5 == 0\n puts \"FizzBuzz\"\n # multiples of 5\n elsif num % 5 == 0\n puts \"Buzz\"\n # multiples of 3\n elsif num % 3 == 0\n puts \"Fizz\"\n # if not divisible by 5 or 3, just print number\n else\n puts num\n end\n end\nend",
"def fizzBuzz\n array = [*1..100]\n array.each { |num|\n if ((num % 3) == 0) && ((num % 5) == 0)\n puts \"FizBuzz\"\n elsif num % 5 == 0\n puts \"Buzz\"\n elsif num % 3 == 0\n puts \"Fizz\"\n else \n puts num\n end\n }\nend",
"def fizzbuzz(num)\n collection = (1..num).to_a\n collection.each do |num|\n if (num % 3 == 0) && (num % 5 != 0)\n puts \"Fizz #{num}\"\n elsif (num % 5 == 0) && (num % 3 != 0)\n puts \"Buzz #{num}\"\n elsif (num % 3 == 0) && (num % 5 == 0)\n puts \"FizzBuzz #{num}\"\n end\n end\nend",
"def puts_1_to_10\n (1..10).each { |i| puts i }\nend",
"def puts_1_to_10\n (1..10).each { |i| puts i }\nend",
"def each(*) end",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def fizz_buzz_to(limit)\n #from 1 to the limit number, for each number, take the number \n 1.upto(limit).each do |num|\n #print out result of calling fizzbuzz with the number.\n puts fizzbuzz(num)\n #ends the each do \n end\n#ends the function definition. \nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def fizzbuzz(num1,num2)\n num1.upto(num2).each do |n|\n case\n when n % 3 == 0\n 'fizz'\n when n % 5 == 0\n 'buzz'\n when n % 3 == 0 && n % 5 == 0\n 'fizzbuzz'\n else\n p n\n end\n end\nend",
"def ingredients_and_amounts(perfect_10_recipe)\n perfect_10_recipe.each do |ingredients, amounts|\n puts \"You need #{amounts} of #{ingredients}\"\n end \nend",
"def run\n (-100..100).each do |number|\n fizz = @fizz_buzz.fizz?(number)\n buzz = @fizz_buzz.buzz?(number)\n if fizz && buzz then puts \"fizzBuzz (#{number})\"\n elsif fizz then puts \"fizz (#{number})\"\n elsif buzz then puts \"buzz (#{number})\"\n else puts number\n end\n end\n end",
"def test_exercise_119\n verify_method :exercise_119,\n :with => [{param: 1, expect: '1'},\n {param: 2, expect: '10'},\n {param: 3, expect: '11'},\n {param: 8, expect: '1000'},\n {param: 11, expect: '1011'}]\n end",
"def test test_cases, f\n test_cases.each do |s, l, e|\n a = send(f, s, l)\n print \"#{f} #{s}, #{l} = #{a} ... \"\n if a == e\n puts 'PASS'\n else\n puts 'FAIL'\n end\n end\nend",
"def fizzbuzz(num_1, num_2, range)\n# Defines a method that will test pass each of a range of integers to the if-statement.\n (1..range).each do |i|\n # Sets the condition to act on an integer if the it's multiple of num_1 and num_2.\n if i % num_1 === 0 && i % num_2 === 0\n # Prints string if the conditions are met.\n puts 'fizzbuzz'\n # Sets the condition to act on integer if it's a multiple of num_1\n elsif i % num_1 === 0\n # Prints string if the condition is met.\n puts 'fizz'\n # Sets the condition to act on integer if it's a multiple of num_2\n elsif i % num_2 === 0\n # Prints string if the condition is met.\n puts 'buzz'\n # Sets the condition if none of the previous conditions are met.\n else\n # Prints the integer from the range\n puts i\n # Closes if-statment\n end\n # Closes each method\n end\n# Closes method\nend",
"def amounts(perfect_10_recipe)\n perfect_10_recipe.each_value do |x|\n puts \"#{x}\"\n end\nend",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def fizzbuzz(num_1, num_2, range)\n #set range of numbers for fizzbuzz\n (1..range).each do |i|\n #set initial condition\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n #set alternate condition\n elsif i % num_1 === 0\n puts 'fizz'\n #set alternate condition\n elsif i % num_2 === 0\n puts 'buzz'\n #set else condition\n else\n puts i\n #close if-statement\n end\n #close .each method\n end\n#close fizzbuzz\nend",
"def ingredients_and_amounts(perfect_10_recipe)\n perfect_10_recipe.each do |x,y|\n puts \"#{x}\"\n puts \"#{y}\"\n end\n end",
"def fizzbuzz\n (1..100).each do |num|\n puts fizz_buzz(num)\n end\nend",
"def test_each\n # codecite examples\n evens = Sequence.new(5, 2) {|a| a.last + 2} \n odds = Sequence.new(5, 1) {|a| a.last + 2}\n fibs = Sequence.new(5, 1, 1) {|a| a[-2] + a[-1]}\n # codecite examples\n \n assert_equal [2,4,6,8,10], evens.to_a\n assert_equal [1,3,5,7,9], odds.to_a\n assert_equal [1,1,2,3,5], fibs.to_a\n end",
"def test_loop_number_positive\n @numbers.each do |value, expected|\n assert_equal expected, @TS_Loop.format(value)\n end\n end",
"def super_fizz(number)\n(0..1000).each do |number|\ndivisible_by_3 = number % 3\ndivisible_by_5 = number % 5\ndivisible_by_7 = number % 7\nif divisible_by_3 == 0\n if divisible_by_5 == 0\n if divisible_by_7 == 0\n puts \"SuperFizzBuzz\"\n else\n puts \"FizzBuzz\"\n end\n elsif divisible_by_7 == 0\n puts \"SuperFizz\"\n else\n puts \"Fizz\"\n end\nelsif divisible_by_5 == 0\n if divisible_by_7 == 0\n puts \"SuperBuzz\"\n else\n puts \"Buzz\"\n end\nelsif divisible_by_7 == 0\n puts \"Super\"\nelse\n puts number\nend\nend\nend",
"def fizzbuzz(a,b)\n numbers = (a..b).to_a\n\n numbers.each do |number|\n if number % 15 == 0\n puts \"FizzBuzz\"\n elsif number % 3 == 0\n puts \"Fizz\"\n elsif number % 5 == 0\n puts \"Buzz\"\n else\n puts number\n end\n end\nend",
"def fizz_buzz\n (1..100).each do |n|\n if is_div(n, 15)\n puts \"FIZZBUZZ\"\n elsif is_div(n, 3)\n puts \"FIZZ\"\n elsif is_div(n, 5)\n puts \"BUZZ\"\n else\n puts n\n end\n end\nend",
"def cracklePop\n (1..100).to_a.each do |x|\n if x % 3 && x % 5 == 0\n puts \"CracklePop\"\n elsif x % 3 == 0\n puts \"Crackle\"\n elsif x % 5 == 0\n puts \"Pop\"\n else\n puts x\n end\n end\nend",
"def fizzbuzz()\n numbers = Array(1..100)\n numbers.each do |num|\n if num % 15 == 0\n puts \"FizzBuzz\" \n elsif num % 3 == 0\n puts \"Fizz\"\n elsif num % 5 == 0\n puts \"Buzz\"\n else\n puts num\n end\n end\nend",
"def super_fizzbuzz(array)\n\tarray = [1..100]\n\tarray.each do |num|\n\t\tif num % 3 == 0 \n\t\t\tprint \"Fizz\"\n\t\tend \n\t\tif num % 5 == 0 \n\t\t\tprint \"Buzz\"\n\t\tend \n\t\tif num % 15 == 0 \n\t\t\tprint \"FizzBuzz\"\n\t\tend \n\tend \nend",
"def ingredients_and_amounts(perfect_10_recipe)\n perfect_10_recipe.each do |ingredients, amounts|\n puts \"#{ingredients}\"\n end\nend",
"def each(*args,&blk)\n\t\t@rounds.each(*args,&blk) \n\tend",
"def divisible(number)\r\n# There is no need to check all numbers from 1 to 20, since\r\n# if the number can be divided by 12, it can also be divided by 3, 4, and 6\r\n# if it can be divided by 14, it can be divided by 2 and 7, and so on.\r\n# 10 and 20 can be skipped since we iterate with step 20\r\n\r\n 11.upto(19) { |t| if number % t != 0 then return false; end }\r\n return true\r\nend",
"def fizzbuzz(num_1, num_2, range)\n # Invokes the for-loop method \"each\" to the interger range, ending the range\n # at the parameter \"range\" value.\n # Iterates the following if/elsif/else statement over each element in the index\n (1..range).each do |i|\n # Checks if the modulus of varriable \"i\" into the parameter \"num_1\" is the\n # same class as the interger 0\n # Checks if the modulus of varriable \"i\" into the parameter \"num_2\" is the\n # same class as the interger 0\n # The loogical AND operator checks if both === methods returned TRUE\n # If yes, returns TRUE. If no, returns FALSE.\n if i % num_1 === 0 && i % num_2 === 0\n # If the if statement returns TRUE, prints the string 'fizzbizz' to\n # the console\n # if the if statemnt returns FALSE, does nothing.\n puts 'fizzbuzz'\n # Calculates the modulus of the \"i\" variable into the paramater num_1.\n # Evaluates if the return to the above calculation is an interger.\n elsif i % num_1 === 0\n # If the elsif statement above returns TRUE, prints the string 'fizz' to\n # the console.\n # if the elsif statemnt above returns FLASE, does nothing.\n puts 'fizz'\n # Calculates the modulus of the \"i\" variable into the parameter num_2.\n # Evaluates if the return of the above calculation is an interger.\n elsif i % num_2 === 0\n # If the elsif statement above returns TRUE, prints the string 'buzz' to\n # the console.\n # if the eslif statemnt above returns FALSE, does nothing\n puts 'buzz'\n # If no nother if/els if statement has returned TRUE, this line will run\n else\n # Prints the current value of the varribale \"i\" to the console.\n puts i\n # Ends the if/elsif/els statements\n end\n # Ends the \".each\" method invocation\n end\n # Ends the definitions of the \"fizzbuzz\" method.\nend",
"def fizzbuzz(start_number, end_number)\n (start_number..end_number).each do |number|\n if number % 15 == 0 \n puts \"FizzBuzz\"\n elsif number % 5 == 0\n puts \"Buzz\"\n elsif number % 3 == 0\n puts \"Fizz\"\n else\n puts number\n end \n end\nend",
"def amounts(perfect_10_recipe)\n perfect_10_recipe.each do |ingredients, amounts|\n puts \"#{amounts}\"\n end\nend",
"def fizzbuzz(num_1, num_2, range)\n #calls alll numbers in range to each do variable |i|\n (1..range).each do |i|\n # begins if else statement if i can be divided by num_1 and if i divided by num_2\n if i % num_1 === 0 && i % num_2 === 0\n # 'fizzbuzz' is printed to terminal\n puts 'fizzbuzz'\n #if the above is not true i will be checked if divisble by num_1\n elsif i % num_1 === 0\n # if true 'fizz' will be printed to the terminal\n puts 'fizz'\n # checks if i can be divided by num_2\n elsif i % num_2 === 0\n # if true 'buzz' is printed to the terminal\n puts 'buzz'\n #if none of the above is true\n else\n # the variable i is printed to the terminal\n puts i\n #ends if else statement\n end\n #ends range.each do\n end\n #ends method\nend",
"def fizzbuzz(num_1, num_2, range) # Create class method called 'fizzbuzz'\n (1..range).each do |i| # Iterate process for each item in a range\n if i % num_1 === 0 && i % num_2 === 0 # If statement - Modulus: Divides left hand operand by right hand operand and returns remainder. === tests equality\n puts 'fizzbuzz' # Prints fizzbuzz\n elsif i % num_1 === 0 # Elsif statement - Modulus of integer and num_1\n puts 'fizz' # Prints fizzbuzz\n elsif i % num_2 === 0 # Elsif statement - Modulus of integer and num_2\n puts 'buzz' # Prints buzz\n else # For anthing else\n puts i # Print the integer\n end\n end\nend",
"def each(&block)\n tests.each(&block)\n end",
"def ingredients_and_amounts(perfect_10_recipe)\n perfect_10_recipe.each do |x, y|\n puts \"#{x} #{y}\"\n end\nend",
"def display_each(numbers)\n numbers.each do |number|\n output.puts fizz_buzzer.fizz_or_buzz(number)\n end\n end",
"def iter_soln\n\ttotal = 0\n\t(0..999).each do |i|\n\t\ttotal += i if(i%3 == 0 || i%5 == 0)\n\tend\n\n\tputs total\nend",
"def fizzbuzz(num_1, num_2, range)\n # iterates arguments\n (1..range).each do |i\n # states if remainder of i divided by num_1 is equal to 0 AND remainder ofi divided by num_2 is equal to 0\n if i % num_1 === 0 && i % num_2 === 0\n # assigns puts value\n puts 'fizzbuzz'\n # states if remainder of i divided by num_1 is equal to 0\n elsif i % num_1 === 0\n # assigns puts value\n puts 'fizz'\n # states if remainder of i divided by num_2 is equal to 0\n elsif i % num_2 === 0\n # assigns puts value\n puts 'buzz'\n # states what to do if all above tests fail\n else\n # assigns puts to i\n puts i\n # ends if else statement\n end\n # ends iteration\n end\n # ends function\nend",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def fizz(number)\t\t\t\t# creates fizz function had number argument\n\tfor\ti in 1..number\t\t\t# for loop i is the current value runs from 1 to 100 the agrument\n if i % 5 == 0 and i % 3 == 0 # if the current number is both divisible by 3\n puts \"FizzBuzz\"\t\t\t# prints FizzBuzz\n elsif i % 5 == 0\t\t\t# else if the current number is divisible by 5\n puts \"Buzz\"\t\t\t\t# prints Buzz\n elsif i % 3 == 0\t\t\t# esle if the current number is divisible by 3\n puts \"Fizz\"\t\t\t\t# prints Fizz\n else\t\t\t\t\t\t# else if none of the above conditions exist\n puts i\t\t\t\t\t# print the current number\n end\t\t\t\t\t\t# ends if\n end\t\t\t\t\t\t# ends \n end",
"def test_true\n\t\tassert_equal(true, winning_numbers(4,[1,2,3,4]))\n\tend",
"def well(x)\ngood = 0\nbad = 0\n x.each do |i|\n if i == \"good\"\n good+=1\n else\n bad +=1\n end\nend\n\nif good>2\n 'I smell a series!'\nelsif good >=1 && good<=2\n \"Publish!\"\nelse\n \"Fail!\"\nend\nend",
"def fizzbuzz\n\t(1..100).each do |num|\n\t if num % 3 == 0 && num % 5 == 0\n\t\tputs \"Fizzbuzz\"\n\t elsif num % 3 == 0\n\t\tputs \"Fizz\"\n\t elsif num % 5 == 0 \n\t\tputs \"Buzz\"\n\t else\n\t\tputs num\n\t end\n\tend\nend",
"def number_loop_two(x)\n i = [1,2,3,4,5,6]\n\n for x in i\n puts \"number #{x}!\"\n end\nend",
"def check_number_of_results(li_arr)\n puts \"#{@@info_indicate} start checking if displaying correct number of results\"\n if result_more_then_ten\n assert_true(li_arr.size == 10, 'display 10 results')\n else\n #result_more\n assert_true(li_arr.size == get_data_total_results, 'display all results')\n end\n end",
"def number_check\n nums = [0, 1, 2, 3, 4, 5, 6 , 7, 8, 9, 10, 11, 12, 13, 14, 15]\n nums.each do |i|\n if i % 2 == 0\n puts \"#{i} even\"\n else\n puts \"#{i} odd\"\n end\n end\n end",
"def output\n @range.each do |number|\n if even_split?(number, 3)\n puts \"fizz\"\n elsif even_split?(number, 5)\n puts \"buzz\"\n else\n puts number\n end\n end\n end",
"def each\n end",
"def number_loop_three(i)\n (0..i).each do |num|\n puts \"The number now is #{num}\" \n end \nend",
"def fizzbuzz(starting, ending)\n (starting..ending).each do |num|\n if (num % 15).zero?\n p \"FizzBuzz\"\n elsif (num % 3).zero?\n p \"Fizz\"\n elsif (num % 5).zero?\n p \"Buzz\"\n else\n p num\n end\n end\nend",
"def fizzbuzz(num_1, num_2, range)\n #defines new method fizzbuzz with 3 parameters\n (1..range).each do |i|\n #establishes range and loop. |i| iterates through the range.\n if i % num_1 === 0 && i % num_2 === 0\n #starts conditional with mathematical function\n puts 'fizzbuzz'\n #prints out fizzbuzz if the \"if\" conditions are met.\n\n elsif i % num_1 === 0\n #establishes another condition if above condition parameters not met.\n puts 'fizz'\n #prints out fizz if the preceding \"elsif\" condition is met.\n elsif i % num_2 === 0\n #establishes another condition if above condition parameters not met.\n puts 'buzz'\n #prints out buzz if the preceding \"elsif\" condition is met.\n else\n #establishes condition for any other situation that does not fulfill preceding conditional staements.\n puts i\n # prints out value of if the preceding condition is met.\n\n end\n #ends conditional\n end\nend",
"def fizz_buzz_check\n @numbers.collect do |x|\n if multiple_of(15, x)\n 'FizzBuzz'\n elsif multiple_of(3, x)\n 'Fizz'\n elsif multiple_of(5, x)\n 'Buzz'\n else\n x\n end\n end\n end",
"def run_block_with_return\n numbers = []\n\n (1..20).each do |number|\n return number if number == 11\n numbers << number\n end\n\n numbers\nend",
"def fizzbuzz(num_1, num_2, range)\n #loop with .each do instead of for loop\n (1..range).each do |i|\n #Use modulo operator to get the remainder of the division i on num-1\n #if i modulo num_1 triple equals 0 AND i modulo num_2 triple equals 0\n if i % num_1 === 0 && i % num_2 === 0\n #print \"fizzbuzz\"\n puts 'fizzbuzz'\n #else if i modulo num_1 triple equals 0\n elsif i % num_1 === 0\n #print \"fizz\"\n puts 'fizz'\n #else if i modulo num_2 triple equals 0\n elsif i % num_2 === 0\n #print \"buzz\"\n puts 'buzz'\n #otherwise\n else\n #print i\n puts i\n #end\n end\n #end\n end\n #end\nend",
"def fizzbuzz(num_1, num_2, range)\n# Take every integer between 1 and the range argument and do the following:\n (1..range).each do |i|\n # If the integer's modulous with num_1 argument equals zero and the integer's modulous with the num_2 argument equals zero\n if i % num_1 === 0 && i % num_2 === 0\n # print fizzbuzz\n puts 'fizzbuzz'\n # Otherwise if the integer's modulous with num_1 argument equals zero\n elsif i % num_1 === 0\n # print fizz\n puts 'fizz'\n # Otherwise if the integer's modulous with num_2 argument equals zero\n elsif i % num_2 === 0\n # print buzz\n puts 'buzz'\n # None of the above?\n else\n # Then just print the integer\n puts i\n # close if statement\n end\n # close .each method\n end\n# close fizz buzz method\nend",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def fizz_buzz(min, max)\n (min..max).each do |number|\n puts fizz_buzz_calculator(number)\n end\nend",
"def method_return_from_loop\n (1..10).each do |n|\n if n == 5\n return 5 * 5\n end\n end\n nil\n end",
"def fizzbuzz(number)\n (1..number).each do |num|\n if (num % 15).zero?\n puts 'FizzBuzz'\n elsif (num % 3).zero?\n puts 'Fizz'\n elsif (num % 5).zero?\n puts 'Buzz'\n else\n puts num\n end\n end\nend",
"def fizz_buzz_to(limit)\n#starting from the number 1 up to the variable limit, do something to each integer\n 1.upto(limit).each do |num|\n#print the output of the fizzbuzz method \n puts fizzbuzz(num)\n end\nend",
"def range_print_10\n array = (0..9).to_a\narray.each do |x|\n print x\nend\n\nend",
"def fizzbuzz(num_1, num_2, range)\n # starts a counter from 1 to range value\n # for each in that range, print the specified output on\n # these next conditions:\n (1..range).each do |i|\n\n # if the next number in the counter is divisible\n # by both num1 and num2 (with 0 remainder)\n if i % num_1 === 0 && i % num_2 === 0\n # print this specified output\n puts 'fizzbuzz'\n\n # if the next number in the counter is divisible by num1 (with 0 remainder)\n elsif i % num_1 === 0\n # print this specified output\n puts 'fizz'\n\n # if the next number in the counter is divisible by num2 (with 0 remainder)\n elsif i % num_2 === 0\n # print this specified output\n puts 'buzz'\n # if none of these conditions are met,\n else\n # print the next number in the range counter.\n puts i\n # end of conditionals\n end\n # end of each.do loop\n end\n # end of method\nend",
"def isbn13(isbn_array, isbn_number) #defines a function to evaluate a 13 dogot number\n\tcounter= 0 #establishes a counter\n\ttotal13 = 0#establishes a check total\n\tmultiples_array = [1,3,1,3,1,3,1,3,1,3,1,3,1] #creates array of values to multiply by the 13 digits\n\t13.times do #initiates a loop through the 13 digit number\n\t\tnumber = isbn_array[counter] #pulls a number from the isbn array based on its array location\n\t\tmultiplier = multiples_array[counter] #pulls a number from the multiples array \n\t\ttotal13 = total13 + (number * multiplier) #calculates product of digit and multiplier and adds to total13\n\t\tcounter += 1 #updates counter\n\tend #ends loop\n\t\n\tprint \"The check total is #{total13}. \\n \\n\" #prints the total13 value\n\tif 0 == total13%10 #evaluates if total13 is evenly divisible by 10 and prints output acdordingly\n\t\tprint \"#{isbn_number} is a valid 13-digit ISBN number. \\n \\n\"\n\telse\n\t\tprint \"#{isbn_number} is NOT a valid 13-digit ISBN number. \\n \\n\"\t\n\tend #ends if statement\nend",
"def check4aces num\n \tnum.each do |x|\n\t\tif x == 11\n\t\t\t@pScore.delete(11)\n\t\t\t@pScore << 1\n\t\tend\n\tend\n end",
"def print_even\n (1..99).each do |num|\n if num.even?\n puts num\n end\n end\nend",
"def basic_8 (array_iterate, eval_int)\n total = 0\n array_iterate.each { |n| total += 1 if n > eval_int}\n return total\nend",
"def each\n loop do\n @next += (@next % 10 == 3) ? 4 : 2\n yield @next\n end\n end",
"def fizzbuzz(num_1, num_2, range)\n # this declaring the iteration range\n (1..range).each do |i|\n # this is an if statement that if true it will print fizzbuzz. if it is false it will go to the next elsif satement\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n # this is an elsif satement that if the above is found false and this statement is true it will print 'fizz'. If this statement is also false it will move on to the next elsif statement\n elsif i % num_1 === 0\n puts 'fizz'\n # this is an elsif satement that if the above two statements found false and this statement is true it will print 'buzz'. If this statement is also false it will move on to the final else statement\n elsif i % num_2 === 0\n puts 'buzz'\n # this is an else satement that if all of the above are found false it will print 'i'.\n else\n puts i\n end\n end\nend",
"def run_tests()\n check_solution(1, [1, 4, 10, 13, 15], true)\n check_solution(2, [1, 4, 10, 10, 13, 15], true)\n check_solution(3, [1, 2, 5, 3, 4 ], false)\nend",
"def run_tests()\n check_solution(1, [1, 4, 10, 13, 15], true)\n check_solution(2, [1, 4, 10, 10, 13, 15], true)\n check_solution(3, [1, 2, 5, 3, 4 ], false)\nend",
"def _test_pages_available\n #execute this code x number of times\n @custom_number_of_users.times do |i|\n puts 'Running tests for user #'+i.to_s\n # assert_section nil\n end\n end",
"def initial_isbn_valid(isbn_array)\n #method with argument\n isbn_count = isbn_array.count\n #count the isbn number for ten numbers, and prints\n if isbn_count == 10\n \tvalid_10_digit_isbn(isbn_array)\n #count the isbn number for thirteen numbers, and prints \t\n elsif isbn_count == 13\n \tvalid_13_digit_isbn(isbn_array)\n # prints that the number is not valid\n else\n puts \"not an isbn number. it must be 10 or 13 digits\"\n end\nend",
"def run_tests\n check_solution(1, [6, 29, 18, 2, 72, 19, 18, 10, 37], 18, 2)\n check_solution(2, [6, 29, 18, 2, 72, 19, 18, 10, 37], 9, -1)\nend"
] | [
"0.6203731",
"0.61079866",
"0.6024744",
"0.6020365",
"0.58519197",
"0.58336186",
"0.5807084",
"0.5807084",
"0.57963276",
"0.5780439",
"0.5742017",
"0.5737671",
"0.5737671",
"0.5737671",
"0.57339376",
"0.573385",
"0.57212484",
"0.5715685",
"0.5701855",
"0.56791925",
"0.56539387",
"0.56457716",
"0.56457716",
"0.56457716",
"0.56457716",
"0.56457716",
"0.56457716",
"0.56457716",
"0.56457716",
"0.56457716",
"0.56457716",
"0.56457716",
"0.56377727",
"0.5605166",
"0.55818284",
"0.5578887",
"0.5574493",
"0.5572102",
"0.5570159",
"0.55570537",
"0.5546028",
"0.5526736",
"0.5519776",
"0.5514581",
"0.5491053",
"0.5490972",
"0.54888994",
"0.5475724",
"0.5466927",
"0.5466654",
"0.546063",
"0.5455672",
"0.54483306",
"0.5444736",
"0.54428506",
"0.54382944",
"0.5423416",
"0.5423416",
"0.5423416",
"0.5423416",
"0.5423416",
"0.5423416",
"0.54225665",
"0.54165626",
"0.54121995",
"0.5409082",
"0.5387786",
"0.53766847",
"0.537436",
"0.53743535",
"0.53728855",
"0.536289",
"0.53591806",
"0.53570986",
"0.53478914",
"0.5346045",
"0.5340659",
"0.533935",
"0.53290147",
"0.53290147",
"0.53290147",
"0.53290147",
"0.53290147",
"0.53290147",
"0.5327988",
"0.53259724",
"0.5323377",
"0.5322357",
"0.5318856",
"0.53172827",
"0.5312578",
"0.5311582",
"0.529796",
"0.52947587",
"0.5289493",
"0.5286617",
"0.5283989",
"0.5283989",
"0.527966",
"0.5278124",
"0.52732426"
] | 0.0 | -1 |
function13 ===> test no.13 | def add_pet_to_stock(petshop,new_pet)
petshop[:pets].push(new_pet)
return petshop
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yet_another_func\r\n 18\r\n end",
"def bad_smell_by_nfunctions\n end",
"def p15\n\t\nend",
"def a3()\n puts('123454')\nend",
"def problem_14\nend",
"def exercise_119 (number)\n end",
"def method_12475663\n\nend",
"def test_that_10_works\n assert_equal(true, funk_master(\"123456789X\"))\n assert_equal(true, funk_master(\"1- 23456 7-89x\"))\n assert_equal(false, funk_master(\"2 22222- - 222X\"))\n assert_equal(false, funk_master(\"1- 23B56 7-89x\"))\n end",
"def test_function2()\n 'ouch'\nend",
"def mambo_no_5; end",
"def test_cic13_pass_0123456789012_returns_0\r\n\t\tassert_equal(\"0\", calculate_ISBN13_checksum(\"0123456789012\"))\r\n\tend",
"def stest_method_1(test); end",
"def koan_3\nend",
"def is_function?(data)\n\t/.\\(.*\\)/.match(data)? true :false\nend",
"def extraNumber(a, b, c)\n \nend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def number_one_reason_i_lost()\n\nend",
"def example_passed(_)\n end",
"def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n void fun1(integer arg) {\r\n i = i++;\r\n }\r\n void fun1(string arg)\r\n {\r\n int i = 0;\r\n if (i == 0) {\r\n printf(\"Hello Zero\");\r\n }\r\n }\r\n EOD\r\n )\r\n function_length = length.counts\r\n assert_equal(7, function_length[\"fun1\"])\r\n end",
"def extractFunctionMeta(line)\n res = \"\"\n numret = 0\n if line.include? '('\n mindex = line.index('(')\n sindex = line.index(')')\n res = line[3..(mindex - 1)]\n numret = line[(mindex - 1)..(sindex - 1)].length\n else\n spindex = (line.strip[3..line.length]).strip.index(' ')\n if spindex != nil\n res = line[3..spindex]\n numret = 2\n else\n res = line[3..line.length]\n numret = 0\n end\n end\n return res.strip, numret\nend",
"def test; true; end",
"def test_sequence_valid15\n result = engine(\"Trump12%\")\n assert(result, \"'Trump12%' should be valid because it contains caps, lowers, numbers and non-alpha-numerics.\")\n end",
"def my955; end",
"def _test_numbers ; process_test_case(\"numbers\") ; end",
"def f() 1 end",
"def a\n puts \"Function 'a' called\"\n 99\nend",
"def test_func(dis, dat, func, expected)\n\tactual = send(func,dis, dat)\n\tputs (actual == expected ? \"Pass\" : \"Fail\") + \": \" + func.to_s + \" test\"\nend",
"def verify_functions(test_data)\n test_functions = test_data[Org::FUNCTIONS.name]\n errors = []\n test_functions = [{ Org::FUNCTION.name => ''}] unless test_functions\n test_functions.each_with_index do |test_function, index|\n text_values_match?(test_function[Org::FUNCTION.name], element_value(function_input(index)), errors)\n end\n errors\n end",
"def koan_4\nend",
"def functions\n\n end",
"def three_to_twenty\n\nend",
"def test_number_has_three_in_it\n\t\tassert_equal \"fizz\", FizzBuzz.identify(13)\n\tend",
"def function_name\n working code\nend",
"def test_exercise_1124\n verify_method :exercise_1124,\n :with => [{params: [1111111, 1234567], expect: 1},\n {params: [33 * 7, 33 * 23], expect: 33},\n {params: [41 * 13, 41 * 29], expect: 41}]\n\n end",
"def three_and_5(number)\r\n \r\nend",
"def test; end",
"def test_6_function_input_3_return_mined\r\n results = create_array()\r\n assert_equal(\"Mined\", results[3-1])\r\n end",
"def test_pos14\n \t\tassert_equal(\"MinedMinds\", new_kat[14])\n\tend",
"def magic_numbers(count)\nend",
"def function!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 83 )\n\n type = FUNCTION\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 204:12: 'function'\n match( \"function\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 83 )\n\n end",
"def magic_number?(n)\r\n \r\nend",
"def fizz_buzz number \nend",
"def test_get_number_by_idx\n assert_equal(@sequence[0], 5)\n \tassert_equal(@sequence[2], 13)\n assert_equal(@sequence[4], 34)\n assert_equal(@sequence[-33], nil)\n end",
"def fizz_buzz number\nend",
"def fizz_buzz number\nend",
"def test_contains_13_eachsuit\n assert true == false\n end",
"def friday_13th?(num)\n \nend",
"def test_exercise_1120\n verify_method :exercise_1120,\n :with => [{param: 1, expect: Math.log(1).truncate},\n {param: 2, expect: Math.log(2).truncate},\n {param: 4, expect: Math.log(4 * 3 * 2).truncate},\n {param: 3, expect: Math.log(3 * 2).truncate}]\n end",
"def test_exercise_1114\n verify_method :exercise_1114,\n :with => [{param: 2, expect: Math.log2(2).truncate},\n {param: 3, expect: Math.log2(3).truncate},\n {param: 9, expect: Math.log2(9).truncate},\n {param: 90, expect: Math.log2(90).truncate}]\n end",
"def test_number_15\n\t\t\t\t\n\t\t\tassert_equal(\"Mined Minds\",mineminds_array[14])\n\t\t\t\n\t\tend",
"def test_check_for_num_or_x\r\n\t\tisbn_number = '123456789x'\r\n\t\tassert_equal(true, check_for_x(isbn_number))\r\n\tend",
"def test_promedio_edades\n n=5\n print validate(23.2, promedio_edades(n)) \nend",
"def message_for(test); end",
"def message_for(test); end",
"def test_valid_10_digit_isbn767\n assert_equal(true, valid_isbn?(\"0-321 14 6530\")) \n end",
"def is_valid_isbn13?(isbn_)\n isbn = cleanup(isbn_)\n return false if isbn.nil? or isbn.length!=13 or isbn.match(/^97[8|9][0-9]{10}$/).nil?\n sum = 0\n 0.upto(12) { |ndx| sum += isbn[ndx].chr.to_i * (ndx % 2 == 0 ? 1 : 3) }\n sum.remainder(10) == 0\n end",
"def add_three(n)\r\n puts n + 3 \r\nend",
"def number(num)\n\ta = 8\n\tputs \"method #{a}\"\nend",
"def new_function_text(line, matchdata, randomized_name)\n \"#{line}\n record = {}\n method(__method__).parameters.each{|arg| record[arg[1].to_s] = (eval arg[1].to_s)}\n RECORDER.push([\\\"#{matchdata[2]}\\\", record, \\\"called\\\"])\n x = #{randomized_name}(*(record.values))\n RECORDER.push([\\\"#{matchdata[2]}\\\", x, \\\"returned\\\"])\n return x\nend\n\n#{matchdata[1]}#{randomized_name}#{matchdata[3]}\n \"\nend",
"def fun_def fun\n\tDATA.rewind\n\tDATA.readlines.each do |line|\n\t\treturn line if line =~ /#{fun}/\n\tend\nend",
"def fizzbuzz_kata(num) \n\t4 \nend",
"def test_more_than_one_variable\n assert_equal(20,minus(80,40,20))\t\n end",
"def line(number); end",
"def xxxtest_function_prototype_on_more_than_one_line\r\n length = initialize_length(\r\n <<-EOD\r\n func_prototype(\r\n int myCat,\r\n boolean huh\r\n );\r\n EOD\r\n )\r\n assert_equal(nil, length.counts['func_prototype'])\r\n assert_equal(5, length.counts['global'])\r\n end",
"def add_three(num)\n\nend",
"def line(number)\n end",
"def test_exercise_119\n verify_method :exercise_119,\n :with => [{param: 1, expect: '1'},\n {param: 2, expect: '10'},\n {param: 3, expect: '11'},\n {param: 8, expect: '1000'},\n {param: 11, expect: '1011'}]\n end",
"def problem_8\nend",
"def process_defn(exp)\n make_function exp\n end",
"def test_check_if_number_is_not_13_digits_long_false_if_not\n\t\tnum = \"123456789123\"\n\t\tassert_equal(false, validate_length(num))\n\tend",
"def test_match\n\t\tassert_equal(2,add(1,1))\n\tend",
"def add_three(n)\n puts n + 3\nend",
"def test_seqence_valid18\n result = engine(\"Trump1%\")\n refute(result, \"'Trump1%' should not be valid because it is too short in length.\")\n end",
"def t__13!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 6 )\n\n type = T__13\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 22:9: 'a'\n match( 0x61 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 6 )\n\n end",
"def demo3\n end",
"def isbn13(isbn_array, isbn_number) #defines a function to evaluate a 13 dogot number\n\tcounter= 0 #establishes a counter\n\ttotal13 = 0#establishes a check total\n\tmultiples_array = [1,3,1,3,1,3,1,3,1,3,1,3,1] #creates array of values to multiply by the 13 digits\n\t13.times do #initiates a loop through the 13 digit number\n\t\tnumber = isbn_array[counter] #pulls a number from the isbn array based on its array location\n\t\tmultiplier = multiples_array[counter] #pulls a number from the multiples array \n\t\ttotal13 = total13 + (number * multiplier) #calculates product of digit and multiplier and adds to total13\n\t\tcounter += 1 #updates counter\n\tend #ends loop\n\t\n\tprint \"The check total is #{total13}. \\n \\n\" #prints the total13 value\n\tif 0 == total13%10 #evaluates if total13 is evenly divisible by 10 and prints output acdordingly\n\t\tprint \"#{isbn_number} is a valid 13-digit ISBN number. \\n \\n\"\n\telse\n\t\tprint \"#{isbn_number} is NOT a valid 13-digit ISBN number. \\n \\n\"\t\n\tend #ends if statement\nend",
"def check_funcall (f)\nend",
"def test_true\n\t\tassert_equal(true, winning_numbers(4,[1,2,3,4]))\n\tend",
"def verify_not_before=(_arg0); end",
"def verify_not_before=(_arg0); end",
"def test_account_format\n assert_equal false, elfproef(123456)\n assert_equal false, elfproef(1234567890)\n assert_equal false, elfproef('12345678a')\n end",
"def check(number)\n \n end",
"def fun\n puts 3\nend",
"def verdi; end",
"def add_three(number)\n return number + 7\n number + 12\nend",
"def assert_num\n\traise \"Card not 16 digits\" unless true\nend",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def test_on_rice_edu_13\n return unless algo\n dfa = load_adl_automaton(\"rice_edu_13.adl\", __FILE__)\n min = load_adl_automaton(\"rice_edu_13.min.adl\", __FILE__)\n assert_equivalent(algo.execute(dfa), min)\n end",
"def test_cantidad_cuotas\n print validate(36, cantidad_cuotas(16,1900.0))\n print validate(24, cantidad_cuotas(29,2100.0)) \n print validate(12, cantidad_cuotas(19,700.0)) \n print validate(6, cantidad_cuotas(20,1000.0))\n print validate(3, cantidad_cuotas(15,3200.0)) \nend",
"def fn\n Fn\n end",
"def test_seqence_valid20\n result = engine(\"DonTrump%\")\n refute(result, \"'DonTrump%' should not be valid because it is too short in length.\")\n end",
"def hey_hey; end",
"def test_new_1\n\n #\n assert_nothing_raised { TaLib::TAFunc.new( \"MACD\" ) }\n\n #\n assert_nothing_raised { TaLib::TAFunc.new( :MACD ) }\n\n #\n e = assert_raise( RuntimeError ) { TaLib::TAFunc.new( [:MACD] ) }\n assert_equal( 0, e.message =~ /Type error for the function name:/ )\n\n #\n e = assert_raise( RuntimeError ) { taf = TaLib::TAFunc.new( \"\" ) }\n\n #\n e = assert_raise( RuntimeError ) { taf = TaLib::TAFunc.new( \"nonamef\" ) }\n assert_equal( false, e.message.match(/^no such function: nonamef/i).nil? )\n\n\n end"
] | [
"0.62322813",
"0.61237425",
"0.6097154",
"0.5938337",
"0.5909476",
"0.5887184",
"0.587739",
"0.56158996",
"0.56122303",
"0.55790186",
"0.5565156",
"0.5563447",
"0.55595183",
"0.55380505",
"0.5536725",
"0.55009884",
"0.55009884",
"0.55009884",
"0.54868233",
"0.54649353",
"0.5464008",
"0.5456962",
"0.5447226",
"0.5440999",
"0.54300976",
"0.54300547",
"0.5429033",
"0.5422215",
"0.5416672",
"0.5413737",
"0.5403845",
"0.5401621",
"0.5393481",
"0.5384023",
"0.5380569",
"0.5378521",
"0.53678095",
"0.5357759",
"0.53575754",
"0.53459245",
"0.53300697",
"0.53037137",
"0.52916676",
"0.5291048",
"0.52867055",
"0.5284989",
"0.5284989",
"0.5282004",
"0.5262363",
"0.52598566",
"0.5257977",
"0.52495927",
"0.5244397",
"0.5233089",
"0.5220009",
"0.5220009",
"0.5217191",
"0.5205417",
"0.5200085",
"0.51969606",
"0.51909757",
"0.5190036",
"0.51766485",
"0.5173809",
"0.5164296",
"0.51590884",
"0.5155338",
"0.51552516",
"0.5150635",
"0.5149093",
"0.5148391",
"0.5147996",
"0.51450765",
"0.51365626",
"0.51325375",
"0.5125614",
"0.51230085",
"0.51208687",
"0.511862",
"0.5112893",
"0.5108036",
"0.5108036",
"0.5104081",
"0.5102797",
"0.510279",
"0.5102714",
"0.5098584",
"0.509825",
"0.5093024",
"0.5093024",
"0.5093024",
"0.5093024",
"0.5093024",
"0.5093024",
"0.5093024",
"0.50868547",
"0.50860244",
"0.50802547",
"0.5079202",
"0.50759786",
"0.5074106"
] | 0.0 | -1 |
function14 ===> test no.14 | def customer_pet_count(customer)
return customer[:pets].count()
# return customer[:pets].length()
# return customer[:pets].size()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yet_another_func\r\n 18\r\n end",
"def bad_smell_by_nfunctions\n end",
"def problem_14\nend",
"def test_function2()\n 'ouch'\nend",
"def p15\n\t\nend",
"def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n void fun1(integer arg) {\r\n i = i++;\r\n }\r\n void fun1(string arg)\r\n {\r\n int i = 0;\r\n if (i == 0) {\r\n printf(\"Hello Zero\");\r\n }\r\n }\r\n EOD\r\n )\r\n function_length = length.counts\r\n assert_equal(7, function_length[\"fun1\"])\r\n end",
"def stest_method_1(test); end",
"def functions\n\n end",
"def verify_functions(test_data)\n test_functions = test_data[Org::FUNCTIONS.name]\n errors = []\n test_functions = [{ Org::FUNCTION.name => ''}] unless test_functions\n test_functions.each_with_index do |test_function, index|\n text_values_match?(test_function[Org::FUNCTION.name], element_value(function_input(index)), errors)\n end\n errors\n end",
"def test; true; end",
"def test; end",
"def koan_4\nend",
"def method_12475663\n\nend",
"def koan_3\nend",
"def my955; end",
"def a3()\n puts('123454')\nend",
"def is_function?(data)\n\t/.\\(.*\\)/.match(data)? true :false\nend",
"def test_pos14\n \t\tassert_equal(\"MinedMinds\", new_kat[14])\n\tend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def function_name\n working code\nend",
"def f() 1 end",
"def check_funcall (f)\nend",
"def extractFunctionMeta(line)\n res = \"\"\n numret = 0\n if line.include? '('\n mindex = line.index('(')\n sindex = line.index(')')\n res = line[3..(mindex - 1)]\n numret = line[(mindex - 1)..(sindex - 1)].length\n else\n spindex = (line.strip[3..line.length]).strip.index(' ')\n if spindex != nil\n res = line[3..spindex]\n numret = 2\n else\n res = line[3..line.length]\n numret = 0\n end\n end\n return res.strip, numret\nend",
"def example_passed(_)\n end",
"def mambo_no_5; end",
"def high_five; end",
"def test_that_10_works\n assert_equal(true, funk_master(\"123456789X\"))\n assert_equal(true, funk_master(\"1- 23456 7-89x\"))\n assert_equal(false, funk_master(\"2 22222- - 222X\"))\n assert_equal(false, funk_master(\"1- 23B56 7-89x\"))\n end",
"def test_func(dis, dat, func, expected)\n\tactual = send(func,dis, dat)\n\tputs (actual == expected ? \"Pass\" : \"Fail\") + \": \" + func.to_s + \" test\"\nend",
"def verdi; end",
"def extraNumber(a, b, c)\n \nend",
"def three_and_5(number)\r\n \r\nend",
"def test_6_function_input_3_return_mined\r\n results = create_array()\r\n assert_equal(\"Mined\", results[3-1])\r\n end",
"def general_func_call(fn)\n \"#{@scanner.next.value} #{expr_list(fn)} #{@scanner.next.value}#{@scanner.next.value}\\n\"\n\n end",
"def _test_numbers ; process_test_case(\"numbers\") ; end",
"def a\n puts \"Function 'a' called\"\n 99\nend",
"def exercise_119 (number)\n end",
"def magic_numbers(count)\nend",
"def test_contains_13_eachsuit\n assert true == false\n end",
"def test_more_than_one_variable\n assert_equal(20,minus(80,40,20))\t\n end",
"def test_match\n\t\tassert_equal(2,add(1,1))\n\tend",
"def test_cases; end",
"def ptest_method_1(test); end",
"def fn\n Fn\n end",
"def is_bad_version(n)\r\n return true if n > 3\r\n false\r\nend",
"def FunctionCall(rest, parsed); end",
"def test_nothing; end",
"def demo3\n end",
"def message_for(test); end",
"def message_for(test); end",
"def test_rubie_number_valid\r\n random = Minitest::Mock.new(\"test_random\")\r\n def random.rand(num); 2; end\r\n assert_equal 2, @g.rubie_number(3, random)\r\n end",
"def test \n end",
"def check5(pmt)\n pmt > 5\nend",
"def fizz_buzz number\nend",
"def fizz_buzz number\nend",
"def g; end",
"def g; end",
"def number_one_reason_i_lost()\n\nend",
"def five\n return 5 # Some people choose to use the return statement just to be clear, \n end",
"def fizz_buzz number \nend",
"def xxxtest_function_prototype_on_more_than_one_line\r\n length = initialize_length(\r\n <<-EOD\r\n func_prototype(\r\n int myCat,\r\n boolean huh\r\n );\r\n EOD\r\n )\r\n assert_equal(nil, length.counts['func_prototype'])\r\n assert_equal(5, length.counts['global'])\r\n end",
"def method_731(base); end",
"def test_promedio_edades\n n=5\n print validate(23.2, promedio_edades(n)) \nend",
"def long_planeteer_calls(calls)# code an argument here\n # Your code here\n calls.any? {|x| x.chars.length>4}\nend",
"def test_fizzbuzz__4_returns_4_as_string\n #Arrange\n number = 4\n #Act\n result = fizzbuzz(number)\n #Assert\n assert_equal(\"4\", result)\n end",
"def test_valid_10_digit_isbn767\n assert_equal(true, valid_isbn?(\"0-321 14 6530\")) \n end",
"def test_contains_four_eachface\n assert true == false\n end",
"def test_a\n end",
"def test_exercise_1114\n verify_method :exercise_1114,\n :with => [{param: 2, expect: Math.log2(2).truncate},\n {param: 3, expect: Math.log2(3).truncate},\n {param: 9, expect: Math.log2(9).truncate},\n {param: 90, expect: Math.log2(90).truncate}]\n end",
"def print_me_2\n \"I'm printing the return value!!!\"\nend",
"def check ; true ; end",
"def three_to_twenty\n\nend",
"def test_fizzbuzz__15_returns_fizzbuzz\n #Arrange\n number = 15\n #Act\n result = fizzbuzz(number)\n #Assert\n assert_equal(\"FizzBuzz\", result)\n end",
"def test_number_15\n\t\t\t\t\n\t\t\tassert_equal(\"Mined Minds\",mineminds_array[14])\n\t\t\t\n\t\tend",
"def fizzbuzz_kata(num) \n\t4 \nend",
"def k_func!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 66 )\n\n\n\n type = K_FUNC\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 517:3: 'func'\n match( \"func\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 66 )\n\n\n end",
"def addFive(num)\n num + 5\nend",
"def test_true\n\t\tassert_equal(true, winning_numbers(4,[1,2,3,4]))\n\tend",
"def problem_8\nend",
"def test_defun_function\n defun(:my_ruby_func) { |a|\n 0\n }\n # redefine\n defun(:my_ruby_func) { |a|\n \"String from my_ruby_func: '#{a}'\"\n }\n assert_equal(\"String from my_ruby_func: 'Hello!'\", my_ruby_func(\"Hello!\"))\n end",
"def how_it_works\r\n end",
"def test_get_number_by_idx\n assert_equal(@sequence[0], 5)\n \tassert_equal(@sequence[2], 13)\n assert_equal(@sequence[4], 34)\n assert_equal(@sequence[-33], nil)\n end",
"def test\n end",
"def test\n end",
"def test\n end",
"def fun_name(defn)\n # The ultimate masterpiece of illegible code.\n defn[3][1][1][3][1][1]\n end",
"def f; @function.to_s; end",
"def fctReturn5\n return 5\nend",
"def tests=(_arg0); end",
"def tests=(_arg0); end",
"def function!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 83 )\n\n type = FUNCTION\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 204:12: 'function'\n match( \"function\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 83 )\n\n end",
"def fungsiPertama()\n puts \"Ini adalah fungsi pertama\"\nend",
"def test_on_rice_edu_13\n return unless algo\n dfa = load_adl_automaton(\"rice_edu_13.adl\", __FILE__)\n min = load_adl_automaton(\"rice_edu_13.min.adl\", __FILE__)\n assert_equivalent(algo.execute(dfa), min)\n end",
"def x; 1; end",
"def test_1\n\t\tputs check_custom nil\n\t\tputs check_custom \"hi\"\n\t\tputs check_custom 'hi(there)'\n\tend",
"def check_for_adroll_function\n $tracer.trace(\"GameStopAnalyticsFunctions: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n $tracer.trace(\"#{optimizely_adroll_function}\")\n #If product has NO discount the finder used is confirm_subtotal_value else it will use the confirm_prediscount_subtotal finder\n\t\torder_confirm_subtotal = confirm_prediscount_subtotal.exists ? confirm_prediscount_subtotal.innerText.gsub(/[$]/, '') : confirm_subtotal_value.innerText.gsub(/[$]/, '')\n $tracer.trace(\"adroll_conversion_value_in_dollars = '#{order_confirm_subtotal}'\")\n $tracer.trace(\"adroll_custom_data = { \\\"ORDER_ID\\\": \\\"#{order_confirmation_number}\\\"\")\n optimizely_adroll_function.should include \"adroll_conversion_value_in_dollars = '#{order_confirm_subtotal}'\"\n optimizely_adroll_function.should include \"adroll_custom_data = { \\\"ORDER_ID\\\": \\\"#{order_confirmation_number}\\\"\"\n end",
"def hey_hey; end",
"def test_age_of_person()\n\n end",
"def supports_routines?\n version[0] >= 5\n end",
"def test\n\n end"
] | [
"0.6461965",
"0.6421681",
"0.6294361",
"0.6123404",
"0.6119711",
"0.6095419",
"0.6059656",
"0.5884191",
"0.5880202",
"0.587424",
"0.58327544",
"0.58093905",
"0.57898176",
"0.5744506",
"0.5723393",
"0.571815",
"0.5709012",
"0.56760544",
"0.5658918",
"0.5658918",
"0.5658918",
"0.5635962",
"0.56199116",
"0.5598341",
"0.55747396",
"0.55567884",
"0.55444944",
"0.5524827",
"0.55098146",
"0.54951453",
"0.54831374",
"0.5477482",
"0.5477015",
"0.545408",
"0.5446792",
"0.5446574",
"0.5429783",
"0.5419644",
"0.5417898",
"0.54176575",
"0.541708",
"0.53878456",
"0.5371252",
"0.53634685",
"0.5361381",
"0.5359298",
"0.5353169",
"0.5338416",
"0.5323534",
"0.5321879",
"0.5321879",
"0.53185564",
"0.5317656",
"0.53150356",
"0.53148514",
"0.53148514",
"0.5314099",
"0.5314099",
"0.53129345",
"0.53034943",
"0.52997655",
"0.5297484",
"0.52897614",
"0.5286526",
"0.5284336",
"0.5282693",
"0.5281683",
"0.5278468",
"0.52709055",
"0.5267421",
"0.5267049",
"0.5266138",
"0.52621746",
"0.52615994",
"0.52600235",
"0.52586955",
"0.5256395",
"0.5248317",
"0.52398264",
"0.52288264",
"0.52254564",
"0.5221707",
"0.52200913",
"0.52141297",
"0.52141297",
"0.52141297",
"0.5211409",
"0.52072316",
"0.5198155",
"0.51959634",
"0.51959634",
"0.5193816",
"0.5186756",
"0.5181668",
"0.5179421",
"0.51772976",
"0.5175282",
"0.5170547",
"0.51683366",
"0.51678926",
"0.5166458"
] | 0.0 | -1 |
...functions 14 attempts... attempt1 def customer_pet_count(customers) string="" for customer in customers do string+=customers[:pets].to_s end return string.to_i end attempt2 def customer_pet_count(customers) string_value=customers[:pets].to_s return string_value.to_i end attempt3 def customer_pet_count(customers) for customer in customers do return customers[:pets].to_s.to_i end end function15 ===> test no.15 | def add_pet_to_customer(customer,new_pet)
customer[:pets].push(new_pet[:pet_type])
return customer[:pets].count()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customer_pet_count(customer)\n return customer[:pets].count()\n # return customer[:pets].length()\n # return customer[:pets].size()\n end",
"def customer_pet_count(number)\n return number[:pets].count\nend",
"def customer_pet_count(supplied_customer)\n return supplied_customer[:pets].length\nend",
"def customer_pet_count (customer)\n return customer[:pets].count\nend",
"def customer_pet_count(customer)\n return customer[:pets].length\nend",
"def customer_pet_count(customer)\n return customer[:pets].length\nend",
"def customer_pet_count(customer)\n return customer[:pets].count()\nend",
"def customer_pet_count(customer)\n customer[:pets].length()\nend",
"def customer_pet_count(customer)\n return customer[:pets].count\nend",
"def customer_pet_count(customer)\n return customer[:pets].count\nend",
"def customer_pet_count(customers)\n return customers[:pets].count()\nend",
"def customer_pet_count(customer)\n return customer[:pets].count\nend",
"def customer_pet_count(customer)\n customer[:pets].count\nend",
"def customer_pet_count(customer_hash)\n return customer_hash[:pets].count\nend",
"def customer_pet_count(customer_hash)\n return customer_hash[:pets].length\nend",
"def test_customer_pet_count\n count = customer_pet_count(@customers[0])\n assert_equal(0, count)\n end",
"def customer_pet_count(customer_array)\n customer_array[:pets].count\nend",
"def get_product_sales_count(toy_name,sales_sum,purchase_price_sum,product_purchase_cnt)\n\ttoy_name[\"purchases\"].each do |purchase_num|\n sales_sum = sum(sum: purchase_num[\"price\"] , sum1: purchase_num[\"shipping\"] , sum2: sales_sum)\n purchase_price_sum = sum(sum: purchase_num[\"price\"] ,sum1: purchase_price_sum)\n product_purchase_cnt += 1\n end\n return sales_sum,purchase_price_sum,product_purchase_cnt\nend",
"def sell_pet_to_customer(pet_shop, pet, customer)\n customer[:pets].count\n pet_shop[:admin][:pets_sold]\n customer[:cash]\n pet_shop[:admin][:total_cash]\nend",
"def return_total_char_count(catalogue)\n total = 0\n catalogue.each_value { |value| total += value }\n total\nend",
"def stock_count(pet_shop_pet_count)\n return pet_shop_pet_count[:pets].length\nend",
"def cards_total(cards) #private method, so could not be used in test\n total = 0 #unitilized variable\n for card in cards\n total += card.value\n end # return statment was in middle of for loop\n return \"You have a total of\" + total.to_s #no implicit conversion of Integer into String\n\nend",
"def owner_pet_count(owner)\n return owner[:pets].length()\nend",
"def stock_count(pet_shop)\nreturn pet_shop[:pets].length\nend",
"def stock_count(pet_shop)\n return pet_shop[:pets].count()\nend",
"def stock_count(pet_shop)\n return pet_shop[:pets].count()\nend",
"def count_money(people)\n total_money = 0\n for person in people\n total_money += person[:monies]\nend\nreturn total_money\nend",
"def stock_count(count)\n return count[:pets].count\nend",
"def sell_pet_to_customer(hash, pet, customer)\n add_pet_to_customer(customer, pet)\n increase_pets_sold(hash, 1) #interger too specific why not pet.count.to_i?\n remove_customer_cash(customer, 900)\n add_or_remove_cash(hash, 900)\nend",
"def count_eggs(chicken_array)\n total_eggs = 0\n for chicken in chicken_array\n total_eggs += chicken[:eggs]\n end\n return total_eggs\nend",
"def stock_count(pet_shop)\n return pet_shop[:pets].length\nend",
"def money_total(people)\n count = 0\n people.each do |person|\n count += person[:monies] \nend\nreturn count\nend",
"def stock_count(pet_shop)\n return pet_shop[:pets].count\nend",
"def stock_count(pet_shop)\n return pet_shop[:pets].count\nend",
"def stock_count(pet_shop)\n return pet_shop[:pets].count\nend",
"def stock_count(pet_shop)\n pet_shop[:pets].count()\nend",
"def stock_count(stock_number)\n return stock_number [:pets].count\nend",
"def get_brand_revenue_count(brand_key_details,brand_revenue,brand_purchase_cnt)\n\tbrand_key_details[\"purchases\"].each do |purchase_brand|\n brand_purchase_cnt += 1\n brand_revenue = sum(sum: brand_revenue , sum1: purchase_brand[\"price\"] , sum2: purchase_brand[\"shipping\"] )\n end\n return brand_revenue , brand_purchase_cnt\nend",
"def stock_count(shop)\n return shop[:pets].length\nend",
"def stock_count(shop)\n return shop[:pets].length\nend",
"def stock_count(shop)\n return shop[:pets].length\nend",
"def list_pets \n \"I have #{self.dogs.count} dog(s), and #{self.cats.count} cat(s).\"\n end",
"def find_pet_by_name(pet_shop_hash, pet_name)\n name_count = nil\n pet_shop_hash[:pets].each { | pet | name_count = pet if pet[:name] == pet_name}\n return name_count\nend",
"def number_of_house_pets(cats, dogs)\n puts \"I have #{cats} cats!\"\n puts \"I have #{dogs} dogs!\"\n puts \"Wow that's a lot of pets!\"\nend",
"def stock_count(stock)\n return stock[:pets].length\nend",
"def count_pet\n pets.count\n end",
"def stock_count(petshop)\n return petshop[:pets].size()\n end",
"def stock_count(shop)\n shop[:pets].length \nend",
"def total_review_character_count\n review_character_counts.inject(:+)\n end",
"def customers_count()\n return customers().length()\n end",
"def count_customers\n return customers().length\n end",
"def list_pets\n \"I have #{self.dogs.count} dog(s), and #{self.cats.count} cat(s).\"\n end",
"def list_pets\n \"I have #{self.dogs.count} dog(s), and #{self.cats.count} cat(s).\"\n end",
"def sell_pet_to_customer(pet_shop, pet, customer)\n if\n pet_shop[:admin][:total_cash] += pet[:price]\n customer[:cash] -= pet[:price]\n else\n p \"Not enough dough :( \"\n end\n customer[:pets] << pet\n pet_shop[:admin][:pets_sold] += [:pets].count()\nend",
"def list_pets\n \"I have #{pets[:fishes].count} fish, #{pets[:dogs].count} dog(s), and #{pets[:cats].count} cat(s).\"\n end",
"def list_pets\n \"I have #{pets[:fishes].count} fish, #{pets[:dogs].count} dog(s), and #{pets[:cats].count} cat(s).\"\n end",
"def list_pets\n \"I have #{@pets[:fishes].count} fish, #{@pets[:dogs].count} dog(s), and #{@pets[:cats].count} cat(s).\"\n end",
"def pet_count\n pets.count\n end",
"def add_pet_to_customer(customer, new_pet)\n customer[:pets].push(new_pet)\n customer[:pets].count\nend",
"def test_sell_pet_to_customer__pet_found\n customer = @customers[0]\n pet = find_pet_by_name(@pet_shop,\"Arthur\")\n\n sell_pet_to_customer(@pet_shop, pet, customer)\n\n assert_equal(1, customer_pet_count(customer)) #checks the customer pet count so we need to add the pet into the :pets array\n assert_equal(1, pets_sold(@pet_shop)) #checks the pet is sold so we need to add 1 to admin: pets_sold:\n assert_equal(100, customer_cash(customer)) #checks the cash has been deducted from the customers cash e.g. customer cash should = customer cash - cost of the pet\n assert_equal(1900, total_cash(@pet_shop)) #checks the price of the pet is added to the total total cash\n end",
"def test_sell_pet_to_customer__pet_found\n customer = @customers[0]\n pet = find_pet_by_name(@pet_shop,\"Arthur\")# pre-exising function #9\n\n sell_pet_to_customer(@pet_shop, pet, customer)# need to define this function\n\n assert_equal(1, customer_pet_count(customer))#pre-existing\n assert_equal(1, pets_sold(@pet_shop))#pre-existing\n assert_equal(100, customer_cash(customer))#pre-existing\n assert_equal(1900, total_cash(@pet_shop))#pre-existing\n end",
"def list_pets\n return \"I have #{@pets[:fishes].count} fish, #{@pets[:dogs].count} dog(s), and #{@pets[:cats].count} cat(s).\"\n end",
"def amount_of_chocolate_chips(recipe_hash)\n \"#{recipe_hash[:mini_dark_chocolate_chips]} of mini dark chocolate chips\"\nend",
"def count_population(country)\n population = 0\n for country in country\n population += country[:population]\n end\n return population\nend",
"def stock_count(stock_count_array)\n stock_count_array[:pets].count\nend",
"def sell_pet_to_customer(shop,the_pet,the_customer)\n if the_pet != nil\n add_pet_to_customer(the_customer,the_pet)\n shop[:admin][:pets_sold] +=1\n remove_customer_cash(the_customer,the_pet[:price])\n add_or_remove_cash(shop,the_pet[:price])\n # else\n # shop[:admin][:pets_sold] +=1\n end\nend",
"def sell_pet_to_customer(petshop,pet,customer)\n\n if (customer[:cash] >= pet[:price]) #&& (petshop[:pets][:name] == pet[:name])\n customer[:pets].push(pet[:name])\n end\n # return customer[:pets].count()\n end",
"def get_count(input)\n input.count('aeiou')\nend",
"def num_of_customers()\n customers.size\nend",
"def count_vowels(datacontent)\n #initalize vowel_array\n vowel_list ={'a'=>0, 'e'=>0, 'i'=>0, 'o'=> 0, 'u'=>0}\n sum_of_vowels = 0\n datacontent.each_char do |i| \n vowel_list.each_key do |a|\n if i == a\n sum_of_vowels += 1\n vowel_list[i] += 1 \n end\n end\n end\n return vowel_list,sum_of_vowels\nend",
"def sell_pet_to_customer(pet_shop, pet_to_sell, customer)\n for pet_for_sale in pet_shop[:pets]\n if pet_for_sale[:name] == pet_to_sell\n customer[:pets].push(pet_to_sell)\n pet_shop[:admin][:pets_sold] += 1\n customer[:cash] -= pet_to_sell[:price]\n pet_shop[:admin][:total_cash] += pet_to_sell[:price]\n end\n end\nend",
"def list_pets\n # if @pets[:cats].size == 1\n # @catplural = \"\"\n # else\n # @catplural = \"'s\"\n # end\n # if @pets[:dogs].size == 1\n # @dogplural = \"\"\n # else\n # @dogplural = \"'s\"\n # end\n # \"I have #{pets[:fishes].size} fish, #{pets[:dogs].size} dog#{@dogplural}, and #{pets[:cats].size} cat#{@catplural}.\"\n \"I have #{pets[:fishes].size} fish, #{pets[:dogs].size} dog(s), and #{pets[:cats].size} cat(s).\"\n end",
"def total_age\n ages = 0\n vet[:cats].each do |cat|\n ages += cat[:age]\n end\n return ages\nend",
"def count_code(str)\n\n\n\nend",
"def increase_pets_sold(pets_sold_number, amount)\n return pets_sold_number[:admin][:pets_sold] += amount\nend",
"def num_repeats(string)\n tallies = {}\n\n (0..string.length - 1).each do |idx|\n letter = string[idx]\n tallies[letter] ||= 0\n tallies[letter] += 1\n end\n\n count_tallies_greater_than_two(tallies)\nend",
"def how_many(srt)\n arr = srt.split(\" \")\n count = {}\n\n #arr.map{ |s| \"#{s} #{arr.count s}\" }\n\n # arr.each do |s|\n # s.downcase!\n # count[s] = count.key?(s) ? count[s]+1 : 1\n # end\nend",
"def countTheOranges\n\t\treturn @fruit_num\n\tend",
"def joke_count # {{{\n\n @log.message :debug, \"Entering count function\"\n\n jokes = Joke.all\n sources = Hash.new\n\n sources[ \"Total\" ] = jokes.length\n sources[ \"Manually Entered\" ] = 0\n\n jokes.each do |j|\n source = j.source\n\n if( source == nil )\n sources[ \"Manually Entered\" ] += 1\n else\n sources[ source ] = 0 if sources[ source ].nil?\n sources[ source ] += 1\n end\n end\n\n sources\n end",
"def amount_of_chocolate_chips(perfect_10_recipe)\n puts perfect_10_recipe[:mini_dark_chocolate_chips]\nend",
"def customer_count()\n customers().count()\nend",
"def total_pets\n pets.count\n end",
"def get_total_purchases(toy)\n\treturn toy['purchases'].length\nend",
"def bottles_num(counter)\n if counter > 1\n # puts \"Counter > 1\"\n return counter.to_s + \" bottles \"\n elsif counter == 1\n # puts \"Counter == 1\"\n return counter.to_s + \" bottle \"\n else\n # puts \"Counter == 0\"\n return \"No more bottles \"\n end\nend",
"def bakery_num( num_of_people, fav_food ) # defines a method called bakery_num that takes two parameters, num_of_peope, fav_food\n serving_sizes = { \"pie\" => 8, \"cake\" => 6, \"cookie\" => 1 } # Hash of available foods and associated counts\n food_quantities = { \"fav_food\" => 0, \"pie\" => 0, \"cake\" => 0, \"cookie\" => 0 } # Hash of food quantities\n\n # Raise error if serving sizes doesn't contain food\n raise ArgumentError.new(\"You can't make that food\") if !serving_sizes.has_key? (fav_food)\n\n # Returns the necessary number of food items needed to satisfy each serving if the \n # number of people attending is evenly divisible by the quantity of the passed favorite food.\n return \"You need to make #{num_of_people / serving_sizes[fav_food]} #{fav_food}(s).\" if num_of_people % serving_sizes[fav_food] == 0\n\n # Loop through each key in food_quantities to determine how many of each food item is needed.\n food_quantities.each do |key, value|\n if key == \"fav_food\" \n food_quantities[key] = num_of_people / serving_sizes[fav_food] # Setting \"fav_food\" property for future use in food_quantities\n food_quantities[fav_food] = food_quantities[key]\n num_of_people = num_of_people % serving_sizes[fav_food] # Setting remaining amount of people left after fav_food is determined.\n elsif num_of_people / serving_sizes[key] > 0 # key is not fav_food and number of remaining people divided by the next food item serving size is greater than zero\n food_quantities[key] = num_of_people / serving_sizes[key] # Setting count for additional food items needed for remaining people\n num_of_people = num_of_people % serving_sizes[key] # Setting number of remaining people after the additional food item\n end # Ending conditional\n end # Ending .each loop\n\n return \"You need to make #{food_quantities[\"pie\"]} pie(s), #{food_quantities[\"cake\"]} cake(s), and #{food_quantities[\"cookie\"]} cookie(s).\"\nend",
"def number_of_pets\n @pets.keys.count\n end",
"def food_count()\nreturn @stomach.count()\nend",
"def add_item_counts(cart:[])\n cart.each do |item|\n item.map { |food_item, info| info[:count] = count_item(food_item, cart) }\n end\nend",
"def count_population_of_uk(collection_of_countries)\n total_population = 0\n for country in collection_of_countries\n total_population += country[:population]\n end\n return total_population\nend",
"def count_letters (name, counts)\n sum = 0\n $alphabet.each_with_index { |val, index| counts[index] += name.count(val) }\n counts\nend",
"def all_customers_alt() # Read film1.all_customers_alt\n sql = \"SELECT COUNT(id) FROM tickets WHERE film_id = $1\"\n values = [@id]\n result = SqlRunner.run(sql, values)\n count_hash = result[0]\n return count_hash['count']\n end",
"def sell_pet_to_customer(petshop,name,customer)\n for pet in petshop[:pets]\n if pet[:name] == name\n customers[:pets].push(pet)\n petshop[:admin][:pets_sold].push(pet)\n sold[:admin][:total_cash] += amount\n end\n end\n return nil\nend",
"def cat_count\n total_arr = []\n counter = 0\n #cat_array1 = [\"Characters\", \"Films\", \"Planets\", \"Starships\", \"Species\"]\n\n 5.times do\n #x = cat_array1[0]\n url_array = [\"http://www.swapi.co/api/people\", \"http://www.swapi.co/api/films\",\n \"http://www.swapi.co/api/planets\", \"http://www.swapi.co/api/starships\",\n \"http://www.swapi.co/api/species\"]\n response_string = RestClient.get(url_array[counter])\n response_hash = JSON.parse(response_string)\n total = response_hash[\"count\"]\n total_arr << total\n counter = counter + 1\n end\n total_arr\nend",
"def total_visit\n pet_histories.count\n end",
"def getCount(inputStr)\n inputStr.downcase.count('aeiou')\nend",
"def getCount(inputStr)\n inputStr.downcase.count('aeiou')\nend",
"def total_money( people)\n total_money = 0\n\n for person in people\n total_money += person[:monies]\n end\n return total_money\nend",
"def increase_pets_sold(increase, total)\n return increase[:admin][:pets_sold] += total\nend",
"def count_sheep \n 5.times {|sheep| puts sheep}\n 10 \nend",
"def sell_pet_to_customer(shop,pet,customer)\n if pet != nil && customer_can_afford_pet(customer,pet) == true\n for animal in shop[:pets]\n if animal[:name] == pet[:name]\n amount = pet[:price]\n add_pet_to_customer(customer,pet)\n customer_pet_count(customer)\n increase_pets_sold(shop,1)\n remove_customer_cash(customer,amount)\n add_or_remove_cash(shop,amount)\n end\n end\n end\nend"
] | [
"0.7764381",
"0.7669291",
"0.76637095",
"0.7663579",
"0.7645392",
"0.7645392",
"0.7618273",
"0.7611017",
"0.7607454",
"0.7607454",
"0.7606744",
"0.75951016",
"0.74921995",
"0.7414525",
"0.73596346",
"0.728692",
"0.7129551",
"0.6684505",
"0.6606899",
"0.659277",
"0.65199405",
"0.64256364",
"0.64140517",
"0.6395217",
"0.63583076",
"0.63583076",
"0.6358273",
"0.63527524",
"0.63357246",
"0.6327898",
"0.6301294",
"0.62895536",
"0.62527645",
"0.62527645",
"0.6240359",
"0.62144023",
"0.6156652",
"0.615309",
"0.6130944",
"0.6130671",
"0.6130671",
"0.61189586",
"0.6110043",
"0.6098672",
"0.6092911",
"0.6079384",
"0.6070462",
"0.6063774",
"0.6051879",
"0.6014332",
"0.5984767",
"0.59706193",
"0.59706193",
"0.5969889",
"0.59432214",
"0.59432214",
"0.59366035",
"0.59200525",
"0.59078044",
"0.58955187",
"0.58944285",
"0.5883755",
"0.587871",
"0.5872116",
"0.5866923",
"0.5845997",
"0.58420557",
"0.5830649",
"0.5818375",
"0.58167064",
"0.5816493",
"0.5809374",
"0.58046854",
"0.580381",
"0.57941777",
"0.57792467",
"0.57766354",
"0.5766028",
"0.5765597",
"0.57643646",
"0.57514644",
"0.5749293",
"0.5739684",
"0.57396775",
"0.57358724",
"0.5735828",
"0.5735692",
"0.573263",
"0.5731093",
"0.5718554",
"0.5718445",
"0.56995845",
"0.56969243",
"0.56948847",
"0.56934357",
"0.56934357",
"0.56923014",
"0.5690636",
"0.5684723",
"0.56812274"
] | 0.5946747 | 54 |
OPTIONAL function16 ===> test no.16 & 17 | def customer_can_afford_pet(customer,new_pet)
customer[:cash] >= new_pet[:price] ?
true : false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bad_smell_by_nfunctions\n end",
"def conditionally(*) end",
"def conditionally(*) end",
"def p15\n\t\nend",
"def stest_method_1(test); end",
"def check_funcall (f)\nend",
"def yet_another_func\r\n 18\r\n end",
"def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n void fun1(integer arg) {\r\n i = i++;\r\n }\r\n void fun1(string arg)\r\n {\r\n int i = 0;\r\n if (i == 0) {\r\n printf(\"Hello Zero\");\r\n }\r\n }\r\n EOD\r\n )\r\n function_length = length.counts\r\n assert_equal(7, function_length[\"fun1\"])\r\n end",
"def example_passed(_)\n end",
"def func1 val #missing the symbols for arguments\r\n if val = 1 #missing 1 equal symbol.\r\n return true\r\n else\r\n return false\r\n end\r\nend",
"def functions\n\n end",
"def long_planeteer_calls(calls)# code an argument here\n # Your code here\n calls.any? {|x| x.chars.length>4}\nend",
"def verify_mode=(_arg0); end",
"def check_for_adroll_function\n $tracer.trace(\"GameStopAnalyticsFunctions: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n $tracer.trace(\"#{optimizely_adroll_function}\")\n #If product has NO discount the finder used is confirm_subtotal_value else it will use the confirm_prediscount_subtotal finder\n\t\torder_confirm_subtotal = confirm_prediscount_subtotal.exists ? confirm_prediscount_subtotal.innerText.gsub(/[$]/, '') : confirm_subtotal_value.innerText.gsub(/[$]/, '')\n $tracer.trace(\"adroll_conversion_value_in_dollars = '#{order_confirm_subtotal}'\")\n $tracer.trace(\"adroll_custom_data = { \\\"ORDER_ID\\\": \\\"#{order_confirmation_number}\\\"\")\n optimizely_adroll_function.should include \"adroll_conversion_value_in_dollars = '#{order_confirm_subtotal}'\"\n optimizely_adroll_function.should include \"adroll_custom_data = { \\\"ORDER_ID\\\": \\\"#{order_confirmation_number}\\\"\"\n end",
"def func_Handler(funciones)\n\t#Manejo de la estructura.\n\tArgError = 0\n\tif (funciones.list_Arg != nil)\n\t\tArgError = listArg_Handler(funciones.list_Arg)\n\tend\n #si la funcion tiene firma verificamos\n firmError = 0\n firma=false\n\tif (funciones.firma != nil)\n\t\tfirma=true\n\t\tfirmError = firm_Handler(funciones.firma)\n\tend\n\n\tinstrError = linst_Handler(firma,funciones.list_inst,funciones.nombre)\n\treturn ArgError + instrError + firmError\nend",
"def three_and_5(number)\r\n \r\nend",
"def test; true; end",
"def long_planeteer_calls(calls)# code an argument here\n # Your code here\n calls.any? do |call|\n call.length > 4\n end\nend",
"def check ; true ; end",
"def supports_routines?\n version[0] >= 5\n end",
"def ITD07=(arg)",
"def ok? \n @funct == nil ? (return false) : (return true)\n end",
"def high_five; end",
"def verify_functions(test_data)\n test_functions = test_data[Org::FUNCTIONS.name]\n errors = []\n test_functions = [{ Org::FUNCTION.name => ''}] unless test_functions\n test_functions.each_with_index do |test_function, index|\n text_values_match?(test_function[Org::FUNCTION.name], element_value(function_input(index)), errors)\n end\n errors\n end",
"def extraNumber(a, b, c)\n \nend",
"def method8(x: nil, y: nil, z: nil)\r\n p x, y, z\r\nend",
"def despined?(*)\n end",
"def long_planeteer_calls(calls) # code an argument here\n # Your code here\n calls.any? { |call| call.length > 4 }\nend",
"def alternatives; end",
"def verification_flags=(_arg0); end",
"def func_if(args)\n p1 = car(args)\n p2 = car(cdr(args))\n p3 = cdr(cdr(args))\n\n if _eval(p1) != @o_man.nil\n return _eval(p2)\n end\n\n return func_progn(p3)\n end",
"def flag; end",
"def if_proc=(_arg0); end",
"def optional; end",
"def long_planteer_calls(calls)\n calls.any? {|call| call.length > 4} # code from lecture\nend",
"def is_function?(data)\n\t/.\\(.*\\)/.match(data)? true :false\nend",
"def true(_argvs)\n return nil\n end",
"def test_nothing; end",
"def functions\n fncs = [:entry]\n fncs << :return if @probe.return?\n fncs\n end",
"def test_1\n\t\tputs check_custom nil\n\t\tputs check_custom \"hi\"\n\t\tputs check_custom 'hi(there)'\n\tend",
"def SAC15=(arg)",
"def hook_solution?(a); end",
"def f() 1 end",
"def checks=(_arg0); end",
"def test_exercise_115\n verify_method :exercise_115,\n :with => [{param: [0.8, 0.8], expect: true},\n {param: [0.1, 0.1], expect: true},\n {param: [0.9, 0.9], expect: true},\n {param: [1, 1], expect: false},\n {param: [0, 0], expect: false}]\n end",
"def test_function2()\n 'ouch'\nend",
"def problem_14\nend",
"def general_func_call(fn)\n \"#{@scanner.next.value} #{expr_list(fn)} #{@scanner.next.value}#{@scanner.next.value}\\n\"\n\n end",
"def fizzbuzz(number)\n #binding.pry\n if (number % 3 == 0 && number % 5 == 0)\n then \"FizzBuzz\"\n elsif number % 3 == 0\n then \"Fizz\"\n elsif number % 5 == 0\n then \"Buzz\"\n else\n nil\n end\nend",
"def assert_num\n\traise \"Card not 16 digits\" unless true\nend",
"def fizz_buzz(number)\n if can_be_divided_by_three_and_five(number)\n return \"FizzBuzz\" #ends method early to avoid getting the following two responses\n end\n if can_be_divided_by_three(number)\n return \"Fizz\"\n end\n if can_be_divided_by_five(number)\n return \"Buzz\"\n end\nend",
"def long_planeteer_calls(array)\n return array.any?{|item| item.length > 4}\n # code an argument here\n # Your code here\nend",
"def verify_not_before=(_arg0); end",
"def verify_not_before=(_arg0); end",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def call_help\n return (@attributes & 0x04 == 0x04)\n end",
"def my955; end",
"def test_zero_prospectors\n\t\tassert check_args([1, 0])\n\tend",
"def method_731(base); end",
"def ITD04=(arg)",
"def explain_false(task); end",
"def long_planeteer_calls(calls)\n res1 = calls.any? { |num| num.length>4} \n return res1\nend",
"def processing_instruction?; end",
"def processing_instruction?; end",
"def fizz_buzz n\n n%15==0 && \"FizzBuzz\" or n%5==0 && \"Buzz\" or n%3==0 && \"Fizz\" or n\n # (\"FizzBuzz\" if n%15==0) || (\"Buzz\" if n%5==0) || (\"Fizz\" if n%3==0) || n\nend",
"def check_dealer_hand(dealer_hand)\n case count_hand(dealer_hand)\n when 2..16\n return 0\n when 22..100\n return -1\n else\n return 1\n end\nend",
"def offenses_to_check=(_arg0); end",
"def tests=(_arg0); end",
"def tests=(_arg0); end",
"def test_cases; end",
"def explain_true(task); end",
"def check5(pmt)\n pmt > 5\nend",
"def checks; end",
"def test_code2(flight_planner_instance)\n puts flight_planner_instance.can_i_fly?(\"MIA\", \"LAX\") == false\n puts flight_planner_instance.can_i_fly?(\"PHX\", \"LAX\") == true\nend",
"def test_will_return_via_tail_call\n src =<<-EOC\ndefn g() {9}\ndefn f(x) {\n zero?(:x) && return %g\n %g + 9\n}\nEOC\n vi = mkvi src+\"\\nf(0)\\n\";ti = mkti src+\"\\nf(0)\\n\"\n assert (vi.run == 9) && (ti.run == 9), \"Expected both optimized and non_optiized to return9, but one of them did not\"\n end",
"def evaluate_q42_data(data)\n\tcase\n\twhen data <= 2\n\t\t:yes\n\twhen data <= 4\n\t\t:sometimes\n\twhen data == 5\n\t\t:never\n\telse\n\t\t:refuse_to_say\n\tend\nend",
"def result_of_checking; end",
"def evocations?\n\n\t !evocations('n08112402').nil?\n\n\tend",
"def usage; end",
"def usage; end",
"def verify_noop (noop_fc=0)\n \n result = false\n\t \n cmd_valid_cnt = tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_VLD}\")\n cmd_error_cnt = tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_ERR}\")\n seq_cnt = tlm(\"#{@app.target_hk_str} #{Ccsds::PRI_HDR_SEQUENCE}\")\n event_seq_cnt = tlm(\"CFE_EVS EVENT_MSG_PKT CCSDS_SEQUENCE\")\n \n cmd(\"#{@app.target} #{Osk::CMD_STR_NOOP} with #{Ccsds::PRI_HDR_STREAMID} #{@app.cmd_mid}, #{Ccsds::PRI_HDR_SEQUENCE} 0, #{Ccsds::PRI_HDR_LENGTH} 1, #{Ccsds::SEC_HDR_CHECKSUM} 0, #{Ccsds::SEC_HDR_FUNCCODE} #{noop_fc}\")\n wait(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_VLD} == #{cmd_valid_cnt}+1\", 10) # Delay until updated cmd valid count or timeout. \n\t\n #~~puts tlm(\"#{@target_hk_str} CMD_VALID_COUNT\")\n if ( (tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_VLD}\") == (cmd_valid_cnt + 1)) && \n (tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_ERR}\") == cmd_error_cnt))\n \n # TODO - Add utility to queue recent events so they can be queried \n event_seq_cnt_delta = tlm(\"CFE_EVS EVENT_MSG_PKT CCSDS_SEQUENCE\") - event_seq_cnt\n event_app = tlm(\"CFE_EVS EVENT_MSG_PKT APP_NAME\")\n event_type = tlm(\"CFE_EVS EVENT_MSG_PKT EVENT_TYPE\")\n event_msg = tlm(\"CFE_EVS EVENT_MSG_PKT MESSAGE\")\n puts \"event_seq_cnt_delta = #{event_seq_cnt_delta}\\n\"\n if (event_seq_cnt_delta == 1)\n if ((event_app == @app.target) and (event_type == Fsw::Const::CFE_EVS_INFORMATION) and (event_msg.include? @app.version))\n result = true\n end\n else\n puts \"#{@app.target} NOOP test warning: Unable to verify event message. Event message sequence count changed by #{event_seq_cnt_delta}\" \n result = true\n end\n \n else\n if ( tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_VLD}\") == seq_cnt)\n raise \"#{@app.target} NOOP test failed: HK telemetry packet not received\"\n end\n raise \"#{@app.target} NOOP test failed: Command counters\"\n end\n\t\n return result\n \n end",
"def function_match(match_ast, ast_node, match_data = {})\n case fname = match_ast[0].function\n when :'_'\n return (match_ast[0].literal == ast_node.function ? true : false)\n when :'?'\n match_data[match_ast[0].literal] = ast_node.function\n return true\n end\n false\n end",
"def get_function_from_line line, ref_option_hash\n # if it is a funciton define it first\n if line.match(/->/) != nil\n # when string is prefixed with ->, it recommends an action for the button\n # save the value rather than declaring lambda function here\n # due to colliding variable references from lambda function is not a good idea\n # also, storing function's arguments for later call so that less code will be written\n function_list = line[2..].strip.split\n\n # just a debug, telling which info that this function gets\n log_everything(function_list.to_s, true)\n\n # accordingly assign to slot of function name and function arguments in order to call it later\n ref_option_hash[:function_name] = function_list[0]\n ref_option_hash[:function_args] = function_list[1..]\n return true\n end\n \n return false\nend",
"def test_exercise_1124\n verify_method :exercise_1124,\n :with => [{params: [1111111, 1234567], expect: 1},\n {params: [33 * 7, 33 * 23], expect: 33},\n {params: [41 * 13, 41 * 29], expect: 41}]\n\n end",
"def ptest_method_1(test); end",
"def check(number)\n \n end",
"def SS2_7 args\r\n\r\nend",
"def fn\n Fn\n end",
"def ITD06=(arg)",
"def long_planeteer_calls(planateer_calls)# code an argument here\n # Your code here\n planateer_calls.any? { |call| call.length >= 5 }\n \nend",
"def not_used\n [:not_used, nil, Reader::Position.caller(2)]\n end",
"def secret_method_2 # :nodoc:\n end",
"def get_function_from_line line, ref_option_hash\n # if it is a funciton define it first\n if line.match(/->/) != nil\n # when string is prefixed with ->, it recommends an action for the button\n # save the value rather than declaring lambda function here\n # due to colliding variable references that lambda function is not a good idea\n # also, storing function's arguments for later call for less code being written\n function_list = line[2..].strip.split\n\n # just a debug, telling which info that this function gets\n debug(lambda { puts function_list.to_s })\n\n # accordingly assign to slot of function name and function arguments in order to call it later\n ref_option_hash[:function_name] = function_list[0]\n ref_option_hash[:function_args] = function_list[1..]\n return true\n end\n \n return false\nend",
"def check_for_optimizely_function\n $tracer.trace(\"GameStopAnalyticsFunctions: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n optimizely_adroll_function.should include \"window['optimizely'] = window['optimizely'] || [];\"\n optimizely_adroll_function.should include \"window['optimizely'].push([\\\"trackEvent\\\", \\\"purchase\\\", { \\\"revenue\\\": totalSaleInCents }]);\"\n end",
"def validate_tags_from_order_confirmation(params)\n $tracer.trace(\"GameStopAnalyticsFunctions: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n case true\n when params[\"do_optimizely\"]\n check_for_optimizely_function\n when params[\"do_adroll\"]\n check_for_adroll_function\n when params[\"do_ci\"]\n channel_intelligence_script.should_exist\n end\n end",
"def condition; end",
"def test_exercise_113\n verify_method :exercise_113,\n :with => [{param: '1 2 3', expect: false},\n {param: '1 1 1', expect: true}]\n end",
"def test_neg_prospectors\n\t\trefute check_args([1, -1])\n\tend",
"def test_no_argument_case\n result = interpret 'one=->(a) { true };%one(1)'\n assert result\n end"
] | [
"0.62424505",
"0.5744811",
"0.5744811",
"0.57002884",
"0.56974125",
"0.5674824",
"0.56678206",
"0.5629981",
"0.55861497",
"0.54871476",
"0.5477791",
"0.54751116",
"0.5471525",
"0.5470599",
"0.54658854",
"0.5418365",
"0.5362668",
"0.5346376",
"0.53306895",
"0.5303516",
"0.5302262",
"0.5284892",
"0.5278587",
"0.5276441",
"0.5256881",
"0.52426004",
"0.5240534",
"0.5238515",
"0.5234299",
"0.5227669",
"0.52005255",
"0.5183835",
"0.5181804",
"0.51720214",
"0.51660043",
"0.5154638",
"0.515386",
"0.5152902",
"0.51511186",
"0.5149791",
"0.51443624",
"0.5138978",
"0.5131556",
"0.51231766",
"0.51116127",
"0.5106223",
"0.51037186",
"0.5098436",
"0.50947535",
"0.50917053",
"0.5091527",
"0.50891393",
"0.50830877",
"0.50830877",
"0.50816756",
"0.50816756",
"0.50816756",
"0.5079698",
"0.507769",
"0.50776136",
"0.5076243",
"0.5074196",
"0.50731117",
"0.50721836",
"0.50715935",
"0.50715935",
"0.50532115",
"0.50495964",
"0.5047305",
"0.504638",
"0.504638",
"0.504625",
"0.5045866",
"0.5044395",
"0.50433797",
"0.50377023",
"0.5037524",
"0.50343025",
"0.50335515",
"0.50309086",
"0.5017006",
"0.5017006",
"0.50153965",
"0.5012615",
"0.5005963",
"0.5004523",
"0.5003485",
"0.5002691",
"0.5000469",
"0.49940163",
"0.49939823",
"0.49865878",
"0.49847677",
"0.49832764",
"0.49828848",
"0.4980544",
"0.49735674",
"0.4971497",
"0.4969179",
"0.49675086",
"0.49637455"
] | 0.0 | -1 |
function17 ===> test no.16 & 17 | def customer_can_afford_pet(customer,new_pet)
customer_cash=customer[:cash]
@pet_shop[:pets].push(new_pet)
for pet in @pet_shop[:pets] do
if customer_cash >= pet[:price]
return true
else
return false
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bad_smell_by_nfunctions\n end",
"def three_and_5(number)\r\n \r\nend",
"def yet_another_func\r\n 18\r\n end",
"def p15\n\t\nend",
"def functions\n\n end",
"def stest_method_1(test); end",
"def check_funcall (f)\nend",
"def test; true; end",
"def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n void fun1(integer arg) {\r\n i = i++;\r\n }\r\n void fun1(string arg)\r\n {\r\n int i = 0;\r\n if (i == 0) {\r\n printf(\"Hello Zero\");\r\n }\r\n }\r\n EOD\r\n )\r\n function_length = length.counts\r\n assert_equal(7, function_length[\"fun1\"])\r\n end",
"def verify_functions(test_data)\n test_functions = test_data[Org::FUNCTIONS.name]\n errors = []\n test_functions = [{ Org::FUNCTION.name => ''}] unless test_functions\n test_functions.each_with_index do |test_function, index|\n text_values_match?(test_function[Org::FUNCTION.name], element_value(function_input(index)), errors)\n end\n errors\n end",
"def problem_14\nend",
"def test_true\n\t\tassert_equal(true, winning_numbers(4,[1,2,3,4]))\n\tend",
"def test_function2()\n 'ouch'\nend",
"def check ; true ; end",
"def high_five; end",
"def check(number)\n \n end",
"def f() 1 end",
"def long_planeteer_calls(calls)# code an argument here\n # Your code here\n calls.any? {|x| x.chars.length>4}\nend",
"def koan_4\nend",
"def koan_3\nend",
"def test_to_15_advanced\n validate_to_15_map(to_15_advanced_map)\n end",
"def test_func(dis, dat, func, expected)\n\tactual = send(func,dis, dat)\n\tputs (actual == expected ? \"Pass\" : \"Fail\") + \": \" + func.to_s + \" test\"\nend",
"def has_teen( a , b , c )\n a = ( 13 <= a && a <= 19 )\n b = ( 13 <= b && b <= 19 )\n c = ( 13 <= c && c <= 19 )\n return a || b || c\nend",
"def three_to_twenty\n\nend",
"def test_contains_13_eachsuit\n assert true == false\n end",
"def test test_cases, f\n test_cases.each do |s, l, e|\n a = send(f, s, l)\n print \"#{f} #{s}, #{l} = #{a} ... \"\n if a == e\n puts 'PASS'\n else\n puts 'FAIL'\n end\n end\nend",
"def magic_numbers(count)\nend",
"def check5(pmt)\n pmt > 5\nend",
"def method_731(base); end",
"def exercise_119 (number)\n end",
"def test_to_15_basic\n validate_to_15_map(to_15_basic_map)\n end",
"def test_code2(flight_planner_instance)\n puts flight_planner_instance.can_i_fly?(\"MIA\", \"LAX\") == false\n puts flight_planner_instance.can_i_fly?(\"PHX\", \"LAX\") == true\nend",
"def test_contains_four_eachface\n assert true == false\n end",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def is_function?(data)\n\t/.\\(.*\\)/.match(data)? true :false\nend",
"def test_cases; end",
"def test_more_than_one_variable\n assert_equal(20,minus(80,40,20))\t\n end",
"def is_a_teenager? (age)\n #age < 13\t#first failing test\n #age > 11 #second failing test\n #age = 20 #third failing test\n\n age > 12 && age < 20\n\n\nend",
"def check5(num)\n puts true if num > 5\n puts false if num <= 5\nend",
"def flag; end",
"def solution(n)\n n & 15\nend",
"def fizzbuzz_kata(num) \n\t4 \nend",
"def function(action1, action2, action3)\n puts \"To '#{action1}', '#{action2}', or '#{action3}' a function all mean the same thing.\"\nend",
"def check_for_adroll_function\n $tracer.trace(\"GameStopAnalyticsFunctions: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n $tracer.trace(\"#{optimizely_adroll_function}\")\n #If product has NO discount the finder used is confirm_subtotal_value else it will use the confirm_prediscount_subtotal finder\n\t\torder_confirm_subtotal = confirm_prediscount_subtotal.exists ? confirm_prediscount_subtotal.innerText.gsub(/[$]/, '') : confirm_subtotal_value.innerText.gsub(/[$]/, '')\n $tracer.trace(\"adroll_conversion_value_in_dollars = '#{order_confirm_subtotal}'\")\n $tracer.trace(\"adroll_custom_data = { \\\"ORDER_ID\\\": \\\"#{order_confirmation_number}\\\"\")\n optimizely_adroll_function.should include \"adroll_conversion_value_in_dollars = '#{order_confirm_subtotal}'\"\n optimizely_adroll_function.should include \"adroll_custom_data = { \\\"ORDER_ID\\\": \\\"#{order_confirmation_number}\\\"\"\n end",
"def test_that_10_works\n assert_equal(true, funk_master(\"123456789X\"))\n assert_equal(true, funk_master(\"1- 23456 7-89x\"))\n assert_equal(false, funk_master(\"2 22222- - 222X\"))\n assert_equal(false, funk_master(\"1- 23B56 7-89x\"))\n end",
"def func1 val #missing the symbols for arguments\r\n if val = 1 #missing 1 equal symbol.\r\n return true\r\n else\r\n return false\r\n end\r\nend",
"def test_exercise_115\n verify_method :exercise_115,\n :with => [{param: [0.8, 0.8], expect: true},\n {param: [0.1, 0.1], expect: true},\n {param: [0.9, 0.9], expect: true},\n {param: [1, 1], expect: false},\n {param: [0, 0], expect: false}]\n end",
"def test; end",
"def checks; end",
"def _test_numbers ; process_test_case(\"numbers\") ; end",
"def run_tests\n check_solution(1, [6, 29, 18, 2, 72, 19, 18, 10, 37], 18, 2)\n check_solution(2, [6, 29, 18, 2, 72, 19, 18, 10, 37], 9, -1)\nend",
"def check_nums(num1, num2)\r\n\r\nend",
"def functions\n fncs = [:entry]\n fncs << :return if @probe.return?\n fncs\n end",
"def result_of_checking; end",
"def friday_13th?(num)\n \nend",
"def test\n\t\t@a+@b > @c && @a+@c > @b && @b+@c > @a\n\tend",
"def test_has_teen\n\t\tassert_equal true, @m.has_teen(13)\n\t\tassert_equal true, @m.has_teen(19)\n\t\tassert_equal false, @m.has_teen(12)\n\t\tassert_equal false, @m.has_teen(20)\n\tend",
"def cases()\n \n end",
"def goodVsEvil(good, evil)\n # good_power, evil_power = 0, 0\n # good.split.each_with_index do |num, i|\n # if i < 3\n # good_power += num.to_i * (i + 1)\n # elsif i < 5\n # good_power += num.to_i * i\n # elsif i == 5\n # good_power += num.to_i * 2 * i\n # end\n # end\n god = good.split.each_with_index.inject(0) do |sum, (num, i)|\n if i < 3\n sum + num.to_i * (i + 1)\n elsif i < 5\n sum + num.to_i * i\n elsif i == 5\n sum + num.to_i * 2 * i\n end\n end\n \n \n evl = evil.split.each_with_index.inject(0) do |sum, (num, i)|\n case i\n when 0\n sum + num.to_i * (i + 1)\n when 1, 2, 3\n sum + num.to_i * 2\n when 4\n sum + num.to_i * (i - 1)\n when 5\n sum + num.to_i * i\n when 6\n sum + num.to_i * (i + 4) \n end\n end\n \n if evl > god\n str = \"Evil eradicates all trace of Good\"\n elsif evl < god\n str = \"Good triumphs over Evil\"\n else\n str = \"No victor on this battle field\"\n end\n \n \"Battle Result: #{str}\"\nend",
"def example_passed(_)\n end",
"def test_match\n\t\tassert_equal(2,add(1,1))\n\tend",
"def hook_solution?(a); end",
"def test_has_teen\n\t\tassert_equal false, @m.has_teen?(1, 2, 3)\n\t\tassert_equal true, @m.has_teen?(0, 10, 14)\n\t\tassert_equal false, @m.has_teen?(21, 8, 8)\n\tend",
"def \n \n long_planeteer_calls(planeteer_calls)\n \n puts \n p planeteer_calls \n puts\n \n planeteer_calls.any? { |any_string| any_string.length > 4 }\n # !! (<) !!\n # >__<\n \nend",
"def passes; end",
"def passes; end",
"def divisible_by_3_and_5(number)\n answer = number%15\n answer == 0\nend",
"def test_exercise_1124\n verify_method :exercise_1124,\n :with => [{params: [1111111, 1234567], expect: 1},\n {params: [33 * 7, 33 * 23], expect: 33},\n {params: [41 * 13, 41 * 29], expect: 41}]\n\n end",
"def trux\n true\nend",
"def falsx\n false\nend",
"def check_miraban num\nend",
"def assert_num\n\traise \"Card not 16 digits\" unless true\nend",
"def getFunctionsDetails(function)\n\tcase function\n\twhen 'F1'\n\t\tdetails = {\n\t\t\tlb: -100,\n\t\t\tub: 100,\n\t\t\tdim: 30,\n\t\t\tnameFunction: 'F1',\n\t\t\tobj: 0\n\t\t}\n\tend\n\n\treturn details\t\nend",
"def fizzbuzz(number)\n #binding.pry\n if (number % 3 == 0 && number % 5 == 0)\n then \"FizzBuzz\"\n elsif number % 3 == 0\n then \"Fizz\"\n elsif number % 5 == 0\n then \"Buzz\"\n else\n nil\n end\nend",
"def long_planeteer_calls(calls)# code an argument here\n # Your code here\n calls.any? do |call|\n call.length > 4\n end\nend",
"def my955; end",
"def test_exercise_1114\n verify_method :exercise_1114,\n :with => [{param: 2, expect: Math.log2(2).truncate},\n {param: 3, expect: Math.log2(3).truncate},\n {param: 9, expect: Math.log2(9).truncate},\n {param: 90, expect: Math.log2(90).truncate}]\n end",
"def number_one_reason_i_lost()\n\nend",
"def test_cantidad_cuotas\n print validate(36, cantidad_cuotas(16,1900.0))\n print validate(24, cantidad_cuotas(29,2100.0)) \n print validate(12, cantidad_cuotas(19,700.0)) \n print validate(6, cantidad_cuotas(20,1000.0))\n print validate(3, cantidad_cuotas(15,3200.0)) \nend",
"def problem_8\nend",
"def run_tests()\n check_solution(1, [1, 4, 10, 13, 15], true)\n check_solution(2, [1, 4, 10, 10, 13, 15], true)\n check_solution(3, [1, 2, 5, 3, 4 ], false)\nend",
"def run_tests()\n check_solution(1, [1, 4, 10, 13, 15], true)\n check_solution(2, [1, 4, 10, 10, 13, 15], true)\n check_solution(3, [1, 2, 5, 3, 4 ], false)\nend",
"def fizz_buzz number \nend",
"def extraNumber(a, b, c)\n \nend",
"def test_valid_straight\n\t\thand = [\"7d\", \"8d\", \"6d\", \"4d\", \"5d\"] \n\t\tassert_equal(true,straight(hand))\n\tend",
"def method_12475663\n\nend",
"def fn\n Fn\n end",
"def check5(num)\n if num <= 5\n 'false'\n elsif num >= 6\n 'true'\n end\nend",
"def long_planteer_calls(calls)\n calls.any? {|call| call.length > 4} # code from lecture\nend",
"def test_exercise_113\n verify_method :exercise_113,\n :with => [{param: '1 2 3', expect: false},\n {param: '1 1 1', expect: true}]\n end",
"def verdi; end",
"def fizz_buzz number\nend",
"def fizz_buzz number\nend",
"def four_of_kind\n (0..12).each { |i|\n fok = {}\n num = 0\n @hash_7_card.each { |s, _r|\n next unless [14 - i] & @hash_7_card[s] == [14 - i]\n fok[s] = [14 - i]\n num += 1\n return fok if num == 4\n }\n }\n nil\n end",
"def check_dealer_hand(dealer_hand)\n case count_hand(dealer_hand)\n when 2..16\n return 0\n when 22..100\n return -1\n else\n return 1\n end\nend",
"def test_truth\n end",
"def run_tests\n check_solution(1, (100..200).to_a, 135, 35)\n check_solution(2, [13, 19, 24, 29, 32, 37, 43], 35, -1)\nend",
"def function_name\n working code\nend",
"def long_planeteer_calls(calls)\n res1 = calls.any? { |num| num.length>4} \n return res1\nend"
] | [
"0.62383884",
"0.6220641",
"0.6165646",
"0.599516",
"0.59046304",
"0.5853994",
"0.57610255",
"0.5720108",
"0.571919",
"0.5699902",
"0.5638538",
"0.55419165",
"0.5516256",
"0.55126685",
"0.5488994",
"0.54596925",
"0.5451892",
"0.5430361",
"0.54229474",
"0.53785235",
"0.53747463",
"0.5371365",
"0.53650045",
"0.53278303",
"0.5325283",
"0.5323226",
"0.531986",
"0.53191966",
"0.5318713",
"0.531672",
"0.5314662",
"0.53130674",
"0.53087705",
"0.5308027",
"0.5308027",
"0.5308027",
"0.5294025",
"0.52924967",
"0.52806187",
"0.527768",
"0.5273498",
"0.5260768",
"0.5246193",
"0.5237022",
"0.5236858",
"0.5236778",
"0.52293116",
"0.52259445",
"0.52256525",
"0.52237666",
"0.5220158",
"0.52128",
"0.5208808",
"0.52085984",
"0.52075076",
"0.5203427",
"0.51856965",
"0.5167833",
"0.5166063",
"0.5163716",
"0.5146063",
"0.5138167",
"0.51286477",
"0.5127057",
"0.5124833",
"0.5118563",
"0.5117082",
"0.5117082",
"0.51112515",
"0.51049674",
"0.5102409",
"0.50968903",
"0.5096774",
"0.509413",
"0.50921106",
"0.5087707",
"0.5086699",
"0.5076516",
"0.50756365",
"0.5075301",
"0.50705445",
"0.5063731",
"0.5063429",
"0.5063429",
"0.506301",
"0.50581896",
"0.5055132",
"0.50540614",
"0.5045921",
"0.504551",
"0.5045399",
"0.5041776",
"0.50401425",
"0.5034352",
"0.5034352",
"0.50337076",
"0.5033307",
"0.50328314",
"0.50311196",
"0.5030621",
"0.50206643"
] | 0.0 | -1 |
Integration tests function18 for test no.1820 | def sell_pet_to_customer(petshop,pet,customer)
if (customer[:cash] >= pet[:price]) #&& (petshop[:pets][:name] == pet[:name])
customer[:pets].push(pet[:name])
end
# return customer[:pets].count()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def graffiti_test\n end",
"def test_cases; end",
"def test_function2()\n 'ouch'\nend",
"def stest_method_1(test); end",
"def running_test_case; end",
"def tests; end",
"def tests; end",
"def testing\n # ...\n end",
"def my_tests\n end",
"def test_case; end",
"def test_step; end",
"def integration_test()\n return [\"all\"]\n end",
"def test_steps; end",
"def test_steps; end",
"def test_method\n end",
"def test_age_of_person()\n\n end",
"def test\n\n end",
"def test \n end",
"def test_a\n end",
"def test\n end",
"def test\n end",
"def test\n end",
"def verify_functions(test_data)\n test_functions = test_data[Org::FUNCTIONS.name]\n errors = []\n test_functions = [{ Org::FUNCTION.name => ''}] unless test_functions\n test_functions.each_with_index do |test_function, index|\n text_values_match?(test_function[Org::FUNCTION.name], element_value(function_input(index)), errors)\n end\n errors\n end",
"def before_test(test); end",
"def before_test(test); end",
"def test_to_15_basic\n validate_to_15_map(to_15_basic_map)\n end",
"def running_test_step; end",
"def test_a18\n instance_eval { setup_from_file.call('A', '18') }\n @status.validate\n assert_equal(true, @road.comps[0].oneway?)\n assert_equal(true, @road.comps[1].oneway?)\n assert_equal(2, @road.num_comps)\n assert_equal(1, @road.num_logical_comps)\n assert(!@status.has_issue_by_name?('not_navigable'))\n #assert_equal(7, @road.length.to_i)\n end",
"def test_integrate_calculation_methods_2b\n x = [[\"Router\", \"3\", \"Scan\", \"SLA1\", \"3\", \"99.99\"], [\"PC\", \"4\", \"Alert\", \"SLA2\", \"6\", \"199.99\"]]\n assert_equal(1180.77, StubIntegration.new.integrate_calculation_methods_2(x))\n end",
"def _test_numbers ; process_test_case(\"numbers\") ; end",
"def test_create_product_formula\n \n end",
"def test; end",
"def default_test\r\n end",
"def smoke_test()\n return [\"case_aaaa\"]\n end",
"def integration_test()\n int =[\"case_aaaa\",\"case_cccc\"]\n return int\n end",
"def test_0_dummy\n\t\tend",
"def test_to_15_advanced\n validate_to_15_map(to_15_advanced_map)\n end",
"def test_get_loaf_stock\n assert_equal(24, @bakery.get_loaf_stock(\"sourdough\"))\n end",
"def check_for_adroll_function\n $tracer.trace(\"GameStopAnalyticsFunctions: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n $tracer.trace(\"#{optimizely_adroll_function}\")\n #If product has NO discount the finder used is confirm_subtotal_value else it will use the confirm_prediscount_subtotal finder\n\t\torder_confirm_subtotal = confirm_prediscount_subtotal.exists ? confirm_prediscount_subtotal.innerText.gsub(/[$]/, '') : confirm_subtotal_value.innerText.gsub(/[$]/, '')\n $tracer.trace(\"adroll_conversion_value_in_dollars = '#{order_confirm_subtotal}'\")\n $tracer.trace(\"adroll_custom_data = { \\\"ORDER_ID\\\": \\\"#{order_confirmation_number}\\\"\")\n optimizely_adroll_function.should include \"adroll_conversion_value_in_dollars = '#{order_confirm_subtotal}'\"\n optimizely_adroll_function.should include \"adroll_custom_data = { \\\"ORDER_ID\\\": \\\"#{order_confirmation_number}\\\"\"\n end",
"def test_legacy\n # Set up legacy handlers\n setup_legacy_handling\n\n common_tests\n end",
"def run_fe_tests\n end",
"def tests=(_arg0); end",
"def tests=(_arg0); end",
"def default_test; end",
"def generate_alltest\n\n end",
"def __dummy_test__\n end",
"def compare_tests(test_a, test_b); end",
"def compare_tests(test_a, test_b); end",
"def default_test\n end",
"def functions\n\n end",
"def love_test\nend",
"def test_update_loaf_stock\n assert_equal(28, @bakery.update_loaf_stock(4,\"sourdough\"))\n end",
"def example_passed(_)\n end",
"def test_nothing\n end",
"def self_test; end",
"def self_test; end",
"def default_test\n end",
"def test_setup\r\n \r\n end",
"def test_truth\n end",
"def test_exercise_1124\n verify_method :exercise_1124,\n :with => [{params: [1111111, 1234567], expect: 1},\n {params: [33 * 7, 33 * 23], expect: 33},\n {params: [41 * 13, 41 * 29], expect: 41}]\n\n end",
"def bad_smell_by_nfunctions\n end",
"def functionals_changed(test_changed_files, t)\n changed_controllers = []\n changed_functional_tests = []\n changed_view_directories = Set.new\n test_changed_files.each do |file|\n controller_match = file.match(/app\\/controllers\\/(.*).rb/)\n if controller_match\n changed_controllers << controller_match[1]\n end\n\n view_match = file.match(/app\\/views\\/(.*)\\/.+\\.erb/)\n if view_match\n changed_view_directories << view_match[1]\n end\n\n functional_test_match = file.match(/test\\/functional\\/(.*).rb/)\n if functional_test_match\n changed_functional_tests << functional_test_match[1]\n end\n end\n\n test_files = FileList['test/functional/**/*_test.rb'].select{|file| changed_controllers.any?{|controller| file.match(/test\\/functional\\/#{controller}_test.rb/) }} +\n FileList['test/functional/**/*_test.rb'].select{|file| changed_view_directories.any?{|view_directory| file.match(/test\\/functional\\/#{view_directory}_controller_test.rb/) }} +\n FileList['test/functional/**/*_test.rb'].select{|file|\n (changed_functional_tests.any?{|functional_test| file.match(/test\\/functional\\/#{functional_test}.rb/) } ||\n test_changed_files.any?{|changed_file| file==changed_file })\n }\n\n test_files = test_files.uniq\n test_files = test_files.reject{ |f| Smokescreen.critical_tests.include?(f) }\n\n t.libs << \"test\"\n t.verbose = true\n if !test_files.empty?\n t.test_files = test_files\n else\n t.test_files = []\n end\n end",
"def test; true; end",
"def test_exercise_1114\n verify_method :exercise_1114,\n :with => [{param: 2, expect: Math.log2(2).truncate},\n {param: 3, expect: Math.log2(3).truncate},\n {param: 9, expect: Math.log2(9).truncate},\n {param: 90, expect: Math.log2(90).truncate}]\n end",
"def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n void fun1(integer arg) {\r\n i = i++;\r\n }\r\n void fun1(string arg)\r\n {\r\n int i = 0;\r\n if (i == 0) {\r\n printf(\"Hello Zero\");\r\n }\r\n }\r\n EOD\r\n )\r\n function_length = length.counts\r\n assert_equal(7, function_length[\"fun1\"])\r\n end",
"def test_nothing\n end",
"def test_average_flight_length\n lib = CSAirLib.new\n assert_equal(lib.average_flight_length,2300)\n end",
"def scope_test\n end",
"def spec; end",
"def spec; end",
"def test_cayman_islands\n end",
"def test_nothing; end",
"def _test_message ; process_test_case(\"message\") ; end",
"def test_contains_13_eachsuit\n assert true == false\n end",
"def test_order; end",
"def test_acknowledgement \n end",
"def test_acknowledgement\n\n end",
"def test_acknowledgement\n\n end",
"def test_acknowledgement\n\n end",
"def test_acknowledgement\n\n end",
"def test_exercise_1120\n verify_method :exercise_1120,\n :with => [{param: 1, expect: Math.log(1).truncate},\n {param: 2, expect: Math.log(2).truncate},\n {param: 4, expect: Math.log(4 * 3 * 2).truncate},\n {param: 3, expect: Math.log(3 * 2).truncate}]\n end",
"def test_validity\r\n assert @valid_skill.valid?\r\n end",
"def test_function_get_user_info_unsuccessfully\n user_id = \"wrong-id\"\n\n #Call function get_user_info in model V1::User\n user = V1::User.get_user_info(user_id)\n\n #Get value code which is returned when call function get_user_info\n actual = user[:meta][:code]\n\n expected = 2004\n #Show result of this function(true=>pass)\n puts this_method_name + \" - \" +assert_equal(expected, actual).to_s\n end",
"def test_should_eat()\n yay_or_nay = should_eat(\"ice cream\", \"winter\")\n assert_equal(\"False\", should_eat)\n end",
"def test_guest_funds\n assert_equal(200, @guest3.return_guest_funds)\n end",
"def test_hack\n assert(true)\n end",
"def functionals_changed_tests(test_changed_files, t)\n test_changed_files = test_changed_files.split(\"\\n\") if test_changed_files.is_a?(String)\n test_files = FileList['test/functional/**/*_test.rb'].select{|file| test_changed_files.any?{|changed_file| file==changed_file }}\n test_files = test_files.uniq\n test_files = test_files.reject{ |f| Smokescreen.critical_tests.include?(f) }\n\n t.libs << \"test\"\n t.verbose = true\n if !test_files.empty?\n t.test_files = test_files\n else\n t.test_files = []\n end\n end",
"def test_it_raises_year_mismatch_code_error\n skip \"to be implemented\"\n # valid_voting_proxy.vote!\n # html = valid_voting_proxy.page_source\n # assert_match(\n # /too short length/,\n # html\n # )\n end",
"def ptest_method_1(test); end",
"def test_exercise_115\n verify_method :exercise_115,\n :with => [{param: [0.8, 0.8], expect: true},\n {param: [0.1, 0.1], expect: true},\n {param: [0.9, 0.9], expect: true},\n {param: [1, 1], expect: false},\n {param: [0, 0], expect: false}]\n end",
"def yet_another_func\r\n 18\r\n end",
"def _test_2\n dotest(\n TestCase45a2,\n \"\"\"\n.0 - 1\n.1 - 2\ndone.\n \"\"\".strip)\n end",
"def failures; end",
"def failures; end",
"def failures; end",
"def after_test(_test); end",
"def after_test(_test); end",
"def after_test(_test); end",
"def run_app_tests\n end",
"def test_function_get_user_info_successfully\n user_id = 28\n\n #Call function get_user_info in model V1::User\n user = V1::User.get_user_info(user_id)\n\n #Get value code which is returned when call function get_user_info\n actual = user[:meta][:code]\n\n expected = 200\n #Show result of this function(true=>pass)\n puts this_method_name + \" - \" +assert_equal(expected, actual).to_s\n end",
"def test_dk50\n instance_eval { setup_from_file.call('DK', '50') }\n @status.validate\n assert_equal(2, @road.num_comps)\n assert_equal(2, @road.num_logical_comps)\n assert(@status.has_issue_by_name?('road_disconnected'))\n end"
] | [
"0.6423968",
"0.6356973",
"0.6353363",
"0.6257234",
"0.6252131",
"0.62388027",
"0.62388027",
"0.6235027",
"0.62203115",
"0.6206287",
"0.6122316",
"0.611179",
"0.6097247",
"0.6097247",
"0.60902935",
"0.60641396",
"0.6047217",
"0.6033881",
"0.6018191",
"0.6017146",
"0.6017146",
"0.6017146",
"0.6003166",
"0.5938243",
"0.5938243",
"0.5938225",
"0.59284395",
"0.59173644",
"0.5915685",
"0.5910255",
"0.5873436",
"0.58594173",
"0.58500296",
"0.58215326",
"0.58086914",
"0.58027005",
"0.5795318",
"0.57738596",
"0.57615185",
"0.57401705",
"0.57305616",
"0.5702076",
"0.5702076",
"0.5697106",
"0.567832",
"0.56727374",
"0.56587785",
"0.56587785",
"0.56531733",
"0.5633538",
"0.5619913",
"0.56188214",
"0.56130695",
"0.5590531",
"0.5588492",
"0.5588492",
"0.55860955",
"0.5583007",
"0.55819327",
"0.5548782",
"0.55464554",
"0.55438673",
"0.55365163",
"0.55301034",
"0.5528361",
"0.5526124",
"0.55144966",
"0.5513384",
"0.5511751",
"0.5511751",
"0.5487698",
"0.54747945",
"0.54709506",
"0.5468135",
"0.5463521",
"0.5461404",
"0.54613197",
"0.54613197",
"0.54613197",
"0.54613197",
"0.5449964",
"0.544697",
"0.5432607",
"0.54248387",
"0.54231864",
"0.5412155",
"0.54112667",
"0.5399014",
"0.5398443",
"0.53905433",
"0.5390202",
"0.53879905",
"0.5383841",
"0.5383841",
"0.5383841",
"0.53655696",
"0.53655696",
"0.53655696",
"0.53617734",
"0.5361565",
"0.53580433"
] | 0.0 | -1 |
Instructions: Create a function that takes a string and returns a string in which each character is repeated once. | def double_char(str)
characters = []
str.split("").each do |x|
characters << x*2
end
p characters.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repeater(str)\n repeated_str = ''\n\n str.each_char do |char|\n repeated_str << char * 2\n end\n\n repeated_str\nend",
"def repeater(string)\n new_string = ''\n string.chars.each do |char|\n 2.times { new_string << char }\n end\n new_string\nend",
"def repeater(string)\n string.chars.map do |char|\n char + char\n end.join\nend",
"def repeater(string)\n string.chars.map { |char| char + char }.join\nend",
"def repeater(string)\n new_string = ''\n string.chars.each do |char|\n new_string << char << char\n end\n new_string\nend",
"def repeater(string)\n string.chars.map! { |char| char * 2 }.join('')\nend",
"def repeater(string)\n new_str = ''\n\n string.chars.each { |x| new_str << x * 2 }\n new_str\nend",
"def repeater(string)\r\n result = \"\"\r\n string.chars.each do |letter|\r\n result << letter * 2\r\n end\r\n result\r\nend",
"def repeater(string)\n result = ''\n string.each_char do |char|\n result << char << char\n end\n result\nend",
"def repeater(string)\n result = ''\n string.each_char do |char|\n result << char << char\n end\n result\nend",
"def repeater(string)\n string.chars.map{ |char| char * 2 }.join\nend",
"def repeater(string)\n result = ''\n string.each_char { |char| result << char * 2 }\n result\nend",
"def rampant_repeats(string, hash)\n new_str = \"\"\n string.each_char do |char| \n if hash[char]\n hash[char].times { new_str += char }\n else\n new_str += char\n end\n end\n new_str\nend",
"def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend",
"def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend",
"def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend",
"def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend",
"def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend",
"def repeater(string)\r\n new_string = \"\"\r\n string.each_char { |char| new_string << char*2 }\r\n new_string\r\nend",
"def repeater(string)\n doubled_str = \"\"\n string.each_char do |char|\n doubled_str << char << char\n # doubled_str.concat(char*2)\n # doubled_str.concat(char, char)\n end\n \n doubled_str\nend",
"def repeater(str)\n str.chars.map { |chr| chr * 2}.join\nend",
"def repeater(string)\n string.chars.map { |el| el * 2 }.join\nend",
"def repeater(string)\n result = \"\"\n string.each_char { |char| result << char * 2}\n result\nend",
"def repeater(str)\n new_str = ''\n str.chars.each do |char|\n new_str << char * 2\n end\n \n p new_str\nend",
"def repeater(string)\n doubled_string = []\n\n string.chars.each do |char|\n doubled_string << char * 2\n end\n\n doubled_string.join\nend",
"def repeater(str)\n\n str.chars.map {|char| char*2}.join\n\nend",
"def repeat_str (n, s)\n string = ''\n n.times do\n string << s\n end\n return string\nend",
"def rampant_repeats(string, hash)\n new_str = \"\"\n string.each_char do |char|\n if hash.key?(char)\n hash[char].times { new_str += char }\n else\n new_str += char \n end\n end\n new_str\nend",
"def repeat_str (n, s)\r\n return s * n\r\nend",
"def repeater2(string)\n result = '' \n string.each_char do |char|\n result << char << char\n end\n result\nend",
"def repeat_str (n, s)\n s * n\nend",
"def repeat_str (n, s)\n s * n\nend",
"def rampant_repeats(str, hash)\n\n new_str = \"\"\n\n str.each_char { |char| new_str += char * ( hash[char] || 1) }\n\n new_str\n\nend",
"def repeat_str (n, s)\n s*n\nend",
"def repeat_str(n, s)\n return s * n\nend",
"def repeater(str)\n new_str = ''\n return new_str if str.eql?('')\n str.chars.each do|char|\n new_str << char * 2\n end\n new_str\nend",
"def repeater(str)\n temp_arr = []\n str.chars do |letter|\n temp_arr << letter * 2\n end\n \n temp_arr.join('')\nend",
"def rampant_repeats(str, hash)\n new_str = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n hash[char].times { new_str += char }\n else\n new_str += char\n end\n end\n new_str\nend",
"def repeat_str n, s\n s * n\nend",
"def repeater(string)\n doubled = ''\n characters = string.chars\n size = characters.size\n counter = 0\n\n while counter < size\n doubled = doubled + string[counter] + string[counter]\n\n counter += 1\n end\n\n doubled\nend",
"def repeater(str)\n [str.chars, str.chars].transpose.join\nend",
"def rampant_repeats(str, hash)\n new_str = ''\n str.each_char do |char|\n if hash.has_key?(char)\n hash[char].times do\n new_str << char\n end\n else\n new_str << char\n end\n end\n new_str\nend",
"def encode_repeating(my_string)\r\n i = 0\r\n j = 0\r\n letter = my_string[i]\r\n while i < my_string.length\r\n j += 1 while my_string[j + 1] == letter\r\n if j - i >= 2\r\n my_string[(i + 1)..j] = (j - i + 1).to_s\r\n end\r\n additional = 0\r\n additional = 1 if j > i\r\n i += 1 + additional\r\n j = i\r\n letter = my_string[i]\r\n end\r\n return my_string\r\nend",
"def repeater(word)\n word.chars.map { |char| char * 2 }.join\nend",
"def rampant_repeats(string, hash)\n new_str = ''\n\n string.each_char do |char|\n if hash.has_key?(char)\n new_str += (char*hash[char])\n else\n new_str += char\n end\n end\n new_str\nend",
"def repeater(str)\n result = ''\n str.each_char { |char| result << char * 2 } # or result << char << char\n result\nend",
"def encode_repeating(my_string)\n return my_string if !my_string || my_string.length < 2\n current, check_next = 0, 1\n until current == my_string.length\n check_next += 1 while my_string[current] == my_string[check_next]\n repeats = check_next - current\n if repeats > 2\n my_string[current + 1] = repeats.to_s\n check_next -= my_string.slice!((current + repeats.to_s.length + 1)...check_next).length\n end\n current = check_next\n end\n return my_string\nend",
"def repeater(str)\n str.chars.each_with_object('') {|char, str| str << char * 2}\nend",
"def rampant_repeats(str, hash)\n new_str = \"\"\n\n str.each_char do |char|\n if hash.has_key?(char)\n new_str += char * hash[char]\n else\n new_str += char\n end\n end\n new_str\nend",
"def repeater(string)\n array = string.split('')\n array.map! do |char|\n char * 2\n end\n array.join\nend",
"def repeater(string)\n string.chars.zip(string.chars).join\nend",
"def repeater(string)\n string.split('').map { |char| char * 2 }.join\nend",
"def repeater(str)\n str.gsub(/(.)/, '\\1\\1')\nend",
"def repeater(str)\n str.gsub(/(.)/, '\\1\\1')\nend",
"def repeater(text)\n double_string = ''\n text.each_char { |char| double_string << char * 2 }\n double_string\nend",
"def repeater(string)\n doubled_str = ''\n string.size.times do |i|\n doubled_str << string[i] * 2\n end\n doubled_str\nend",
"def repeater(string)\n doubled = \"\"\n single_chars = string.chars\n single_chars.each do |char|\n doubled_char = char * 2\n doubled << doubled_char\n end\n doubled\nend",
"def repeat (string, n=2)\n\tresult = \"\"\n\tn.times{result += string + \" \"}\n\treturn result.chomp(\" \")\nend",
"def rampant_repeats(str, hash)\n n_str = ''\n str.each_char do |char|\n if hash.has_key?(char) \n n_str += char * hash[char]\n else\n n_str += char\n end\n end\n n_str\nend",
"def repeat(string, num)\n new_string = \"\"\n num.times do\n new_string += string\n end\n new_string\nend",
"def encode_repeating(my_string)\n # return if nil or empty\n return if (my_string == nil || my_string.length == 0)\n\n entering_index = 0 # this is where characters will get replaced\n examining_index = 0 # this is where the current character is getting examined and counted\n length = my_string.length\n while examining_index < length # all n characters will be examined\n temp = my_string[examining_index] # current character\n count = 1 # current character count\n while my_string[examining_index+1] == temp && examining_index < length\n examining_index += 1 # increment index\n count += 1 # increment current character count\n end\n # update at entering_index on seeing the subsequent character changing\n if count > 2 # enter the current character followed by it's count\n my_string[entering_index] = my_string[examining_index]\n entering_index += 1\n my_string[entering_index] = count.to_s\n entering_index += 1\n elsif count == 2 # enter the current character twice\n count.times do\n my_string[entering_index] = my_string[examining_index]\n entering_index += 1\n end\n else # count == 1, enter the current character once\n my_string[entering_index] = my_string[examining_index]\n entering_index += 1\n end\n examining_index += 1 # move to next character\n end\n\n # delete trailing characters in the string.\n count = length - entering_index\n count.times do # worst case: delete n-2 number of characters\n my_string.slice! entering_index # trim the string\n end\n return\nend",
"def repeater(str)\n str.chars.zip(str.chars).join\nend",
"def repeat string, number=2\n\trepeated = \"\"\n\tcur_index = 0\n\n\tnumber.times do\n\t\trepeated += string\n\n\t\tif cur_index != number - 1\n\t\t\trepeated += \" \"\n\t\tend\n\n\t\tcur_index += 1\n\tend\n\n\trepeated\nend",
"def crunch(string)\n string.gsub(/([a-z0-9])\\1+/, \"\\\\1\")\nend",
"def repeat (string, number = 2)\n # .cycle calls the array (number) of times\n # .to_a on an array, converts to an array object (words on their own line)\n # .join(' ') puts string together \"word word word\"\n [string].cycle(number).to_a.join(' ')\nend",
"def encode_repeating(my_string)\n puts my_string\n\n if my_string == \"\" || my_string == nil || my_string.length == 0\n return my_string\n end\n\n\n new_arr = []\n hash = {}\n i = 0\n while i < my_string.length\n\n char = my_string[i]\n print char\n\n if hash[char]\n hash[char] += 1\n else\n hash[char] = 1\n end\n\n i += 1\n\n end\n\n puts hash\n\n\n hash.each do |k, v|\n if v <= 2\n v.times do\n new_arr << k\n end\n elsif v > 2\n new_arr << k\n new_arr << v\n end\n end\n\n puts new_arr\n puts new_arr.join\n\n my_string = new_arr.join\n return my_string\n # raise NotImplementedError\nend",
"def repeatedString(s, n)\n s.count('a') * (n / s.size) + s[0, n % s.size].count('a')\nend",
"def rampant_repeats(str, hash)\n str.chars.map { |c| hash.key?(c) ? c * hash[c] : c }.join\nend",
"def repeat(str, n = 2)\n arr = []\n n.times {arr << str}\n arr.join(\" \")\nend",
"def repeat(string, nrepeats = 2)\n output = ((string + \" \")*nrepeats).sub(/ $/, '')\n end",
"def crunch(string)\n string.gsub(/(.)\\1+/, '\\1')\nend",
"def encode_repeating(my_string)\n return nil if my_string.nil?\n return my_string if my_string.length <= 1\n\n i = 0\n j = 0\n k = 0\n while j <= i && i < my_string.length\n k = i\n if my_string[i] != my_string[i + 1]\n my_string[j] = my_string[i]\n\n else\n counter = 1\n while my_string[i] == my_string[i + 1]\n i += 1\n counter += 1\n end\n\n if counter == 2\n my_string[j] = my_string[k]\n my_string[j + 1] = my_string[k]\n else\n my_string[j] = my_string[k]\n my_string[j + 1] = counter.to_s\n end\n j += 1\n end\n j += 1\n i += 1\n end\n\n my_string[j...my_string.length] = \"\"\n return my_string\nend",
"def repeat(text , num=2)\n #text = text.chars\n val = \"\"\n i = 0\n for i in (1..num)\n val = text + \" \"+ val\n end\n return val.rstrip\n \nend",
"def repeatedString(s, n)\n s.count('a') * n.div(s.size) + s.slice(0,n.remainder(s.size)).count('a')\nend",
"def repeater(string)\n string.split(//).map {|char| char * 2 }.join\nend",
"def repeat_copy(str, n = 1)\n return str * n\nend",
"def repeat(string, num = 2)\n\treturn ((string + \" \") * num).strip\nend",
"def generate_chars(num, chars)\n return_chars = ''\n num.times { return_chars += chars.sample.to_s }\n return_chars\nend",
"def rampant_repeats(str, hash)\n (str.split(\"\").map do |char| \n if hash.keys.include?(char)\n char * hash[char] \n else\n char\n end\n end).join(\"\")\nend",
"def repeat (n, s)\n\t\tres = \"\"\n\t\tfor i in 0...n\n\t\t\tres << s\n\t\tend\n\t\treturn res\n\tend",
"def non_repeating_character(str)\n str.each_char do |char|\n return char if str.count(char) == 1\n end\nend",
"def repeatedString(s, n)\n length = s.length\n\n repeat_count = n / length\n\n remainder = n % length\n\n count_a(s) * repeat_count + count_a(s[0...remainder])\nend",
"def repeatedString(s, n)\n count = s.count(\"a\")\n rep = (n / s.length)\n if n % s.length != 0\n short_s = s.slice(0, n % s.length)\n return (count * rep) + short_s.count(\"a\")\n else\n return (count * rep)\n end\n \nend",
"def repeat_string(str, i)\n return \"\" if (i <= 0)\n return str if (i == 1)\n d = repeat_string(str, i >> 1)\n d += d\n d += str if (i & 1)\n return d\n end",
"def repeat(word, x=2)\n return ((+ word + ' ') *x).rstrip\n \nend",
"def rampant_repeats(s, h)\n s.chars.map do |c|\n if h[c]\n c * h[c]\n else\n c\n end\n end.join(\"\")\nend",
"def repeater(string)\n doubled = ''\n count = 0\n\n until count == string.length\n doubled << string[count] * 2\n count += 1\n end\n doubled\nend",
"def repeat(str, num)\n\t a = (str + \" \")* num\n\t return a.chop\nend",
"def rampant_repeats(str, hash)\n (str.split(\"\").map do |char| \n if hash.keys.include?(char)\n # if hash.has_key?(char)\n char * hash[char] \n else\n char\n end\n end).join(\"\")\nend",
"def repeater(string)\n doubled_arr = []\n string.each_char{ |char| doubled_arr << char *= 2} \n p doubled_arr.join\nend",
"def rampant_repeats(str, hash)\n repeated = \"\"\n # iterate through str chars, if chars is in hash.keys, add to output chars * key.value\n str.each_char do |letter|\n if hash.keys.include?(letter)\n repeated += letter * hash[letter]\n else\n repeated += letter\n end\n end\n\n repeated\nend",
"def encode_repeating(my_string)\n\n return nil if my_string.nil?\n\n start = 0\n\n until my_string[start].nil?\n\n count = 1\n\n while my_string[start + count] == my_string[start]\n count += 1\n end\n\n if count < 3\n start += count\n else\n my_string[start + 1] = count.to_s\n my_string.slice!(start + 2, count - 2)\n start += 2\n end\n\n end\n\n return my_string\n\nend",
"def repeat(word, times=2)\n\t((word+\" \")*times).rstrip\nend",
"def repeat(word, times = 2)\r\n ((word + ' ') * times).strip\r\nend",
"def crunch(string)\n array = string.chars\n no_repeats = []\n no_repeats.push(array[0])\n for i in 0..(array.size - 1)\n no_repeats.push(array[i+1]) if array[i] != array[i+1]\n end\n\n no_repeats.join\nend",
"def repeatedString(s, n)\n char_array = s.split('')\n count_of_a_in_string = 0\n char_array.each do |letter|\n if letter == \"a\"\n count_of_a_in_string += 1\n end\n end\n\n factor = n/s.length()\n reminder = n % s.length()\n count_of_a_in_final_string = factor * count_of_a_in_string\n\n reminder.times do |index|\n count_of_a_in_final_string += 1 unless s[index] != \"a\"\n end\n count_of_a_in_final_string\nend",
"def repeater(string)\n string = string.split(\" \")\n\n string.map do |word|\n word = word.split('')\n word.map {|letter| letter * 2}.join('')\n end.join(' ')\nend",
"def repeat(str, n = 2)\n ((str + ' ') * n).strip\nend",
"def repeat(input, iterations = 0)\n if (iterations <= 2)\n \"#{input}\" + \" \" + \"#{input}\"\n else\n \"#{input} \" * (iterations - 1) + \"#{input}\"\n end\nend",
"def repeat(x,reps=2)\n\t# if I exclude .join, the result will be stacked on top of each other\n\t([x] * reps).join(\" \")\nend",
"def repeat(word, num=2)\n word = word + \" \"\n word *= num\n\n # Removes trailing whitespace\n word.rstrip\nend"
] | [
"0.82889843",
"0.8127127",
"0.8047757",
"0.7999656",
"0.7944132",
"0.7913355",
"0.781617",
"0.7799636",
"0.77930003",
"0.77930003",
"0.7761988",
"0.77335757",
"0.7730579",
"0.77258474",
"0.77258474",
"0.77258474",
"0.77258474",
"0.77258474",
"0.77220994",
"0.7715247",
"0.7713259",
"0.7702996",
"0.77011746",
"0.77010185",
"0.7687903",
"0.7674142",
"0.7671994",
"0.7657536",
"0.7646081",
"0.76423717",
"0.764125",
"0.764125",
"0.76292664",
"0.7624176",
"0.76175225",
"0.7609092",
"0.760649",
"0.759576",
"0.7573734",
"0.7567511",
"0.7567022",
"0.7562901",
"0.75285876",
"0.7481417",
"0.74738586",
"0.7473687",
"0.7461704",
"0.7448646",
"0.7446682",
"0.7444709",
"0.74388576",
"0.74341375",
"0.7424767",
"0.7424767",
"0.73670006",
"0.73645055",
"0.7356097",
"0.73349327",
"0.73132974",
"0.73082083",
"0.7307469",
"0.73064864",
"0.73029226",
"0.7293098",
"0.72903335",
"0.72834146",
"0.7279522",
"0.72603106",
"0.72573483",
"0.72549015",
"0.7247337",
"0.724447",
"0.7208502",
"0.71773547",
"0.7168954",
"0.7150465",
"0.714384",
"0.71193314",
"0.71075916",
"0.7087981",
"0.7071795",
"0.7061654",
"0.7060799",
"0.705935",
"0.70312077",
"0.70237184",
"0.7016619",
"0.7016087",
"0.6984505",
"0.697447",
"0.69743323",
"0.6969955",
"0.6967153",
"0.69530505",
"0.6949332",
"0.6933818",
"0.69191635",
"0.6902254",
"0.6889221",
"0.68438685",
"0.68332475"
] | 0.0 | -1 |
GET /favorite_tweets GET /favorite_tweets.json | def index
@favorite_tweets = FavoriteTweet.where(:user => session[:user_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favorite_tweets\n logger.debug { \"#{__method__} is called twitter_user_id=#{id}\" }\n tweets = []\n tweets = InMemory::FavoriteTweet.find_by(uid) if InMemory.enabled? && InMemory.cache_alive?(created_at)\n tweets = Efs::FavoriteTweet.where(uid: uid) if tweets.blank? && Efs::Tweet.cache_alive?(created_at)\n tweets = ::S3::FavoriteTweet.where(uid: uid) if tweets.blank?\n tweets.map { |tweet| ::TwitterDB::Favorite.new(uid: uid, screen_name: screen_name, raw_attrs_text: tweet.raw_attrs_text) }\n end",
"def favorites(options = nil)\n def uri_suffix(opts); opts && opts[:page] ? \"?page=#{opts[:page]}\" : \"\"; end\n uri = '/favorites.json' + uri_suffix(options)\n response = http_connect {|conn|\tcreate_http_get_request(uri) }\n bless_models(Twitter::Status.unmarshal(response.body))\n end",
"def index\n @tweets = @user.tweets.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def tweets\n user = User.find(params[:id])\n render json: user.list_tweets, status: :ok\n end",
"def favorite\n tweet_id=params[:tuit_id]\n client.favorite(tweet_id) unless tweet_id == nil\n respond_to do |format|\n format.html { }\n\t format.json { head :no_content }\n\t format.js\n end\n end",
"def list\r\n #page = params[:page].nil? ? 0 : params[:page]\r\n tweets = Tweet.all\r\n render json: tweets\r\n end",
"def index\n @tweets = Tweet.all\n\n render json: @tweets\n end",
"def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end",
"def index\n @favos = Favo\n .where(user_id: current_user.id)\n @tweets = Tweet.all\n end",
"def index\n\t\tuser = User.find_by(id: params[:user_id])\n\t\tif user.present?\n\t\t\tfollower_ids = user.followers.pluck(:id)\n\t\t\ttweets = Tweet.where(\"user_id IN (?)\", follower_ids).order(\"updated_at DESC\")\n\t\t\trender json: {:status=>\"success\", :code=>200, :message=>\"List of tweets from the users you follow.\", data: tweets}\n\t\telse\n\t\t\trender json: {:status=>\"failure\", :message=>\"User is not present.\", data: tweets}\n\t\tend\n\tend",
"def list_tweets\n tweets\n end",
"def favorite_activities\n get(\"/user/#{@user_id}/activities/favorite.json\")\n end",
"def favorite_activities()\n get(\"/user/#{@user_id}/activities/favorite.json\")\n end",
"def show\n user = user_from_token\n @tweet = user.tweets.where(:id => params[:id])\n render :json => @tweet\n end",
"def favorite_tweet_params\n params[:favorite_tweet]\n end",
"def show_user_tweets\n @user_tweets = TwitterClient.user_timeline(params[:name])\n render json: @user_tweets\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n query = params[:q]\n respond_to do |format|\n format.html { @tweets_url = query ? \"/tweets.json?q=#{query}\" : '/tweets.json' }\n format.json do\n tweets, has_more =\n if query\n search_result =\n Tweet.search(\n query,\n page: params[:page] || 1,\n per_page: 20,\n includes: [\n { user: { avatar_attachment: %i[blob] } },\n :likes,\n { images_attachments: %i[blob] },\n { comments: { user: { avatar_attachment: %i[blob] } } },\n ],\n )\n [search_result.results, search_result.current_page < search_result.total_pages]\n else\n @pagy, tweets =\n pagy Tweet\n .includes(\n { user: { avatar_attachment: %i[blob] } },\n :likes,\n { images_attachments: %i[blob] },\n { comments: { user: { avatar_attachment: %i[blob] } } },\n )\n .order(created_at: :desc)\n [tweets, @pagy.page < @pagy.pages]\n end\n render json: { has_more: has_more, data: TweetBlueprint.render_as_hash(tweets) }\n end\n end\n end",
"def favorites(screen_name)\n url = 'https://api.twitter.com/1.1/favorites/list.json?count=2&screen_name=' + screen_name\n request(@agent, @token, url)\n end",
"def like_hello\n @client.search(\"#{@hashtbonjour}\", result_type: \"recent\").take(25).collect do |tweet|\n @client.favorite(tweet)\n end\n end",
"def favourite_tweets_since id\n twitter_client.favorites since_id: id.to_s\n end",
"def set_favorite_tweet\n @favorite_tweet = FavoriteTweet.find(params[:id])\n end",
"def index\n #Array of all tweets. Used for index html page\n @tweets = Tweet.all\n end",
"def index\n @following_user_ids = @user.following.pluck(:id)\n\n @tweets = Tweet.where(user_id: @following_user_ids).order(created_at: :desc).includes(:user)\n json_response(@tweets)\n end",
"def favorited_tweet?(tweet)\n favorite_tweets.include? tweet\n end",
"def index\n query = params[:q]\n respond_to do |format|\n format.html { \n if query\n @tweets_url = \"/tweets.json?q=#{query}\"\n else\n @tweets_url = \"/tweets.json\" \n end\n }\n format.json { \n tweets, has_more = if query\n search_result = Tweet.search(query, \n page: params[:page] || 1, \n per_page: 20, \n includes: [\n {user: {avatar_attachment: [:blob]}},\n :likes, {images_attachments: [:blob]},\n {comments: {user: {avatar_attachment: [:blob]}}}\n ])\n [search_result.results, search_result.current_page < search_result.total_pages]\n else\n @pagy, tweets = pagy Tweet.includes({user: {avatar_attachment: [:blob]}},\n :likes, \n {images_attachments: [:blob]},\n {comments: {user: {avatar_attachment: [:blob]}}}).order(created_at: :desc)\n [tweets, @pagy.page < @pagy.pages]\n end\n render json: {has_more: has_more, data: TweetBlueprint.render_as_hash(tweets) }\n }\n end\n end",
"def index\n number_tweets = if params[\"count\"] then params[\"count\"].to_i else 10 end\n tweet_ids = []\n if @user.interests\n for i in 1..number_tweets\n interest = @user.interests.sample\n tweet = Rails.application.config.twitter_client.search(\"#{interest[:hashtag]}\", count: 1).take(1)\n tweet_ids.push(tweet.first.id.to_s)\n end\n end\n\n render json: tweet_ids, status: :ok\n end",
"def index\n\t\t@tweets = current_user.tweets\n\tend",
"def getThreeTweets\n\t\trender json: TwitterAPI.get_top_3_tweets(params[:twitter_id])\n\tend",
"def index\n chain = Tweet\n chain = chain.since_id(params[:since_id]) if params[:since_id]\n @tweets = chain.all(:order => 'msg_twid ASC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def index\n # binding.pry\n @tweet = Tweet.new\n if current_user\n friend_ids = Friend.where(user_id: current_user).pluck(:friends_id) \n @tweets = Tweet.where(user_id: friend_ids)\n else\n @tweets = Tweet.includes([:user]).all\n end\n\n @tweets = @tweets.order(updated_at: :desc).page(params[:page]).per(10)\n end",
"def index\n @tweets = Tweetaro.all\n end",
"def show_tweets\n @user = get_user_or_current_user(params[:id])\n @tweets = Tweet.where(:user_id => @user.id).order(created_at: :desc)\n end",
"def index\n if params[:page] && current_user\n render json: current_user, scope: {page: params[:page]}, serializer: UserWithTweetsSerializer, meta: {total_pages: current_user.timeline_tweets.count/25}\n elsif current_user\n render json: current_user, serializer: UserWithTweetsSerializer\n elsif params[:page]\n @tweets = Tweet.all.page(params[:page])\n render json: @tweets\n else\n @tweets = Tweet.all\n render json: @tweets\n end\n end",
"def index\n @tweets = Tweet.all\n end",
"def get_user_favorites username_for\n do_request 'get_user_favorites', username_for: username_for\n end",
"def create\n @favorite_tweet = FavoriteTweet.new(favorite_tweet_params)\n\n respond_to do |format|\n if @favorite_tweet.save\n format.html { redirect_to @favorite_tweet, notice: 'Favorite tweet was successfully created.' }\n format.json { render action: 'show', status: :created, location: @favorite_tweet }\n else\n format.html { render action: 'new' }\n format.json { render json: @favorite_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favorite(client)\n\tensemble = client.search(\"#bonjour_monde\", result_type: \"recent\").take(25)\n#\tensemble.each do |tweet|\n\t\tclient.favorite(ensemble)\n#\tend\nend",
"def show\r\n @tweets = Tweet.all\r\n @tweet = Tweet.find(params[:id])\r\n end",
"def tweets\n @tweets = @user.tweets.order(created_at: :desc).paginate(:page => params[:page], :per_page => 5) # order OWN tweets according to when they were created, with the most recent tweet at the top.\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def index\n if !current_user.favorites.blank?\n return current_user.favorites\n else\n render json: { errors: \"No favorites for current user\" }, status: :not_found\n end\n end",
"def index\n @likes = Like.where(tweet_id: params[:tweet_id])\n @tweets = Tweet.paginate(page: params[:page], per_page: 10)\n end",
"def favorite_tweet(tweet)\n # Ternary to prevent duplicates\n favorited_tweet?(tweet) ? favorite_tweets : favorite_tweets << tweet\n end",
"def favorites\n @favorites ||= Favorite.by_tweet_id.key(id)\n end",
"def index\n @favorites = current_user.favorites\n render json: Api::V1::WatchableSerializer.new(@favorites.map(&:favoritable)).serialized_json\n end",
"def index\n @actor_tweets = ActorTweet.all\n end",
"def show\r\n tweet = Tweet.find(params[:id])\r\n render json: tweet\r\n end",
"def recent_tweets(count)\n start(\"/recent/tweets/#{count}\")\n end",
"def show\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n end\n end",
"def show\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n end\n end",
"def get_favourite_restaurants\n @profile = Profile.find(params[:id])\n @restaurants = @profile.favourites\n\n render status: 200, json: @restaurants\n end",
"def mention_tweets\n logger.debug { \"#{__method__} is called twitter_user_id=#{id}\" }\n tweets = []\n tweets = InMemory::MentionTweet.find_by(uid) if InMemory.enabled? && InMemory.cache_alive?(created_at)\n tweets = Efs::MentionTweet.where(uid: uid) if tweets.blank? && Efs::Tweet.cache_alive?(created_at)\n tweets = ::S3::MentionTweet.where(uid: uid) if tweets.blank?\n tweets.map { |tweet| ::TwitterDB::Mention.new(uid: uid, screen_name: screen_name, raw_attrs_text: tweet.raw_attrs_text) }\n end",
"def index\n timeline = Tweet.where(user_id: User.find(@current_user_id).follows).or(Tweet.where(user_id: @current_user_id))\n render json: {timeline: timeline}\n end",
"def index\n @favorites = Favorite.all\n @user = current_user\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @favorites }\n end\n end",
"def index\n @tweeters = Tweeter.all\n end",
"def favorite\n current_user.favorite_topic(@topic.id)\n render json: {ok: 1}\n end",
"def favorite_hashtags\n favorite_stuffs(:hashtags, :text, 3)\n end",
"def index\n @favorite_templates = FavoriteTemplate.all\n render json: @favorite_templates\n end",
"def show\n render json: @favorite\n end",
"def latest_tweets\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = ENV[\"TWITTER_CONSUMER_KEY\"]\n config.consumer_secret = ENV[\"TWITTER_CONSUMER_SECRET\"]\n end\n\n count = params[:count] || 10\n time_line = client.user_timeline(current_user.twitter_handle, {count: count})\n current_user.update(time_fetched: current_user.time_fetched+1)\n if time_line.class == Twitter::Error::NotFound\n render json: {status: 400, success: false, message: 'Twitter handle or id not valid'}\n else\n render json: {status: 200, success: true, message: 'Success', data: time_line.map{|a| a.text}.as_json}\n end\n\n rescue => e\n Rails.logger.error \"account_controller#latest_tweets - Error: #{e.message}\"\n render json: {status: 500, success: false, message: 'Unexpected error'}\n end",
"def show\n render json: @tweet\n end",
"def favorite(action, value)\n raise ArgumentError, \"Invalid favorite action provided: #{action}\" unless @@FAVORITES_URIS.keys.member?(action)\n value = value.to_i.to_s unless value.is_a?(String)\n uri = \"#{@@FAVORITES_URIS[action]}/#{value}.json\"\n case action\n when :add\n response = http_connect {|conn| create_http_post_request(uri) }\n when :remove\n response = http_connect {|conn| create_http_delete_request(uri) }\n end\n bless_model(Twitter::Status.unmarshal(response.body))\n end",
"def index\n puts(\"Total tweets: #{Tweet.count}\")\n @tweets = Tweet.all\n @tweets.each do |tweet|\n puts( \"#{tweet.zombie}: #{tweet.status}\")\n end\n\n @tweets\n end",
"def favorite(id)\n post(\"/favorites/create/#{id}.json\")\n end",
"def twubbles\n @sad_tweets = WordTweet.recent_sad_tweets\n respond_to do |f|\n f.json { render :json => twubbles_json(@sad_tweets) }\n f.html\n end\n end",
"def all_tweets\n Tweet.all\n end",
"def index\n authorize! :index, Spree::Favorite\n @favorites = spree_current_user.favorites\n respond_to do |format|\n format.html\n format.json { render json: @favorites }\n end\n end",
"def index\n authenticate\n @tweets = Tweet.where(\n user_id: current_user.id,\n stat: nil\n ).order(:id)\n end",
"def favorite_tweets\n puts \"Do you want to favorite all of the tweets from the query? The query '#{@query.strip}' has #{@tweets.size} tweets. Y/N\"\n @decision = gets\n @tweets.each do |tweet|\n begin\n Twitter.favorite(tweet.id)\n rescue Twitter::Error::TooManyRequests => error\n puts \"Oops, we are rate limited. We will try again at: #{Time.now + error.rate_limit.reset_in + 5}\"\n sleep error.rate_limit.reset_in + 5\n retry\n rescue Twitter::Error::ServiceUnavailable => error\n sleep(10)\n retry\n rescue Twitter::Error::Forbidden => error\n puts \"You already favorited tweet from #{tweet.user.screen_name}\"\n next\n rescue Twitter::Error::NotFound => error\n puts \"Sorry something went wrong. #{error}\"\n next\n else\n puts \"Favorited '#{tweet.text}' from #{tweet.user.screen_name}\"\n end\n sleep(1)\n end\nend",
"def index\n @new_tweets = NewTweet.all\n end",
"def get_latest_tweets(num_of_tweets)\n client = configure_authentication\n latest = client.home_timeline({:count => num_of_tweets})\n client.end_session\n info = latest.to_json\n end",
"def by_user\r\n tweets = Tweet.where(user_id: params[:user_id])\r\n render json: tweets\r\n end",
"def tweets\n @_tweets ||= client.filter_tweets(screen_names)\n end",
"def show\n\t\treferenced = @topic.tweets.count(:distinct)\n\t\tusers = @topic.tweets.user.count(:distinct)\n\t\trender json: show_json(@topic, referenced, users)\n\tend",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n end\n end",
"def get_favorites\n authenticate_rem\n follower = @current_user || User.find_by_id(params[:user_id])\n render json: Product.order(created_at: :desc).limit(20).map(&:simple_info.with(follower)),\n status: :ok\n end",
"def user_tweet\n get_tweets params[:Enter_what_you_want_to_search]\n respond_to do |format|\n format.html \n format.json \n end\n \nend",
"def show_favorites\n authenticate_rem\n follower = @current_user || User.find_by_id(params[:user_id])\n render json: follower.favorite_products.map(&:simple_info.with(follower)), status: :ok\n end",
"def index\n\n if params[:q]\n @tweets = Tweet.where('content LIKE ?', \"%#{params[:q]}%\").order(created_at: :desc).page params[:page]\n elsif user_signed_in?\n @tweets = Tweet.tweets_for_me(current_user).or(current_user.tweets).order(created_at: :desc).page params[:page]\n else\n @tweets = Tweet.eager_load(:user, :likes).order(created_at: :desc).page params[:page]\n end\n\n @tweet = Tweet.new\n @user_likes = Like.where(user: current_user).pluck(:tweet_id)\n end",
"def show\n @all_tweets = set_tweet_collection.tweets\n end",
"def index\n @tweets = Tweet.all\n @user = current_user\n @recent_tweets = Tweet.order(created_at: :desc).limit(10)\n @pop_tweets = Tweet.order(likes_count: :desc).limit(10)\n @tweet = Tweet.new\n #@users # 基於測試規格,必須講定變數名稱,請用此變數中存放關注人數 Top 10 的使用者資料\n end",
"def get_favorite\n @json = FavoriteBeer&.all.where(user_id: @current_user.id).as_json\n\n @json.map! { |beer| beer.slice('id', 'name', 'tagline', 'description', 'abv', 'punk_id') }\n @json.each { |beer| beer[:favorite] = true }\n\n render json: {\n favorite_beers: @json\n }\n end",
"def get_tweets(list)\n if list.authorized?(@user)\n list.tweets\n else\n []\n end\nend",
"def show\n @tweets = @usuario.tweets\n end",
"def index\r\n @tweets = Tweet.all\r\n @tweet = Tweet.new\r\n end",
"def get_favorite(key, json)\n data =JSON.parse(json)\n return data['favorites'][key]\nend",
"def index\n respond_with RawTweet.all\n end",
"def search\n @tweets = TwitterClient.search(params[:query], result_type: 'recent').take(20)\n render json: @tweets\n end",
"def index\r\n @users = User.where.not(id: current_user&.id)\r\n @tweet = Tweet.new\r\n @tweets = Tweet.all.page(params[:page])\r\n\r\n \r\n if params[:q]\r\n @tweets = Tweet.where('content LIKE ?', \"%#{params[:q]}%\").page(params[:page])\r\n if @tweets.nil?\r\n @tweets = Tweet.all.page(params[:page])\r\n end\r\n else\r\n @tweets = Tweet.all.page(params[:page])\r\n end\r\n \r\n #SCOPE comentado para evitar conflicto con buscador\r\n if signed_in?\r\n @tweets = Tweet.tweets_for_me(current_user).page(params[:page])\r\n else\r\n @tweets = Tweet.all.order(\"created_at DESC\").page(params[:page])\r\n end\r\n\r\n if params[:tweetsearch].present?\r\n @tweets = Tweet.search_my_tweets(params[:tweetsearch]).page(params[:page]).order(\"created_at DESC\")\r\n elsif params[:hashtag].present?\r\n @tweets = Tweet.search_my_tweets(\"##{params[:hashtag]}\").page(params[:page]).order(\"created_at DESC\")\r\n end\r\n\r\n end",
"def tweets(opts={})\n params = {\n :screen_name => NAME,\n :trim_user => true,\n :include_entities => true\n }.merge(opts)\n get(\"/statuses/user_timeline.json\",params)\n end",
"def index\n @tweet = Tweet.new\n @comment = Comment.new\n @tweets = Tweet.all.order('created_at DESC')\n @friends = current_user.get_friends\n end",
"def favourites\n\t\tfavourites = Partay.get('http://shoponline.tescolotus.com/api/v1/favorites/by-category?page=1&sortby=Relevance&issecure=False', :headers => {'Content-Type' => 'application/json','language' => 'en-GB', 'region' => 'TH', 'userId' => access_token, 'Host' => 'r.tesco.com.my'})\n\t\tfavourites_counter = JSON(favourites)\n\t\tself.favourite_count(JSON(favourites_counter)[\"pageInformation\"][\"totalCount\"])\n\t\tif fav_count >= 1\n\t\t\tputs \"Your favourites count is:#{fav_count}\"\n\t\telse\n\t\t\traise \"There are no products in your favourites list.\"\n\t\tend\n\tend",
"def get_favorite(key, json)\n return JSON.parse(json)[\"favorites\"][key]\nend",
"def index\n @tweets = Tweet.select { |tweet| tweet.user_id == current_user.id }\n end",
"def favorites_timeline(user, count, max_id, since_id, reply_depth)\n\n options = {\n :timeline_kind => :favorites,\n :count => count\n }\n self.append_official_card_parameters(options)\n options[:user_id ] = user if user.is_a?(Integer)\n options[:screen_name] = user if user.is_a?(String)\n options[:max_id ] = max_id if max_id\n options[:since_id ] = since_id if since_id\n\n followers = self.followers()\n timeline = Tw::Timeline.compose(\n @requester,\n followers,\n reply_depth,\n options)\n tweetArray = timeline.perform()\n\n return tweetArray\n end"
] | [
"0.7687445",
"0.7336894",
"0.7269229",
"0.72110707",
"0.7145635",
"0.7080381",
"0.7061777",
"0.699663",
"0.6964348",
"0.69222003",
"0.691475",
"0.6902407",
"0.68968076",
"0.686262",
"0.68007827",
"0.6799856",
"0.6792255",
"0.6792255",
"0.6792255",
"0.6792255",
"0.6792255",
"0.6792255",
"0.67804885",
"0.67537653",
"0.67421216",
"0.6728057",
"0.6727958",
"0.66685957",
"0.6656558",
"0.66517967",
"0.66496044",
"0.66441786",
"0.66211283",
"0.6612348",
"0.6609907",
"0.6604979",
"0.6597537",
"0.6582764",
"0.65809065",
"0.6560542",
"0.6546061",
"0.6538799",
"0.6511766",
"0.64901197",
"0.64857495",
"0.6483814",
"0.6479401",
"0.6477909",
"0.6445116",
"0.6444414",
"0.64277536",
"0.6417873",
"0.6416962",
"0.64112586",
"0.64112586",
"0.6400974",
"0.6394078",
"0.63922197",
"0.63844717",
"0.63785374",
"0.6378153",
"0.6376938",
"0.6362985",
"0.63626385",
"0.6339231",
"0.6331776",
"0.6330154",
"0.63235176",
"0.6320604",
"0.63172144",
"0.63062906",
"0.63059914",
"0.63035524",
"0.6303337",
"0.63023263",
"0.62946576",
"0.62882674",
"0.6283895",
"0.62773937",
"0.6269302",
"0.626895",
"0.626297",
"0.6257423",
"0.62429166",
"0.6236812",
"0.6235736",
"0.62271816",
"0.62247163",
"0.62158185",
"0.6214904",
"0.62018144",
"0.61992776",
"0.61968654",
"0.6186934",
"0.6185991",
"0.6176772",
"0.61756235",
"0.6174649",
"0.6161679",
"0.6159245"
] | 0.7241433 | 3 |
GET /favorite_tweets/1 GET /favorite_tweets/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favorite_tweets\n logger.debug { \"#{__method__} is called twitter_user_id=#{id}\" }\n tweets = []\n tweets = InMemory::FavoriteTweet.find_by(uid) if InMemory.enabled? && InMemory.cache_alive?(created_at)\n tweets = Efs::FavoriteTweet.where(uid: uid) if tweets.blank? && Efs::Tweet.cache_alive?(created_at)\n tweets = ::S3::FavoriteTweet.where(uid: uid) if tweets.blank?\n tweets.map { |tweet| ::TwitterDB::Favorite.new(uid: uid, screen_name: screen_name, raw_attrs_text: tweet.raw_attrs_text) }\n end",
"def index\n @tweets = @user.tweets.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def favorites(options = nil)\n def uri_suffix(opts); opts && opts[:page] ? \"?page=#{opts[:page]}\" : \"\"; end\n uri = '/favorites.json' + uri_suffix(options)\n response = http_connect {|conn|\tcreate_http_get_request(uri) }\n bless_models(Twitter::Status.unmarshal(response.body))\n end",
"def index\n @favorite_tweets = FavoriteTweet.where(:user => session[:user_id])\n end",
"def favorite\n tweet_id=params[:tuit_id]\n client.favorite(tweet_id) unless tweet_id == nil\n respond_to do |format|\n format.html { }\n\t format.json { head :no_content }\n\t format.js\n end\n end",
"def tweets\n user = User.find(params[:id])\n render json: user.list_tweets, status: :ok\n end",
"def index\n @tweets = Tweet.all\n\n render json: @tweets\n end",
"def list\r\n #page = params[:page].nil? ? 0 : params[:page]\r\n tweets = Tweet.all\r\n render json: tweets\r\n end",
"def show\n user = user_from_token\n @tweet = user.tweets.where(:id => params[:id])\n render :json => @tweet\n end",
"def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end",
"def index\n\t\tuser = User.find_by(id: params[:user_id])\n\t\tif user.present?\n\t\t\tfollower_ids = user.followers.pluck(:id)\n\t\t\ttweets = Tweet.where(\"user_id IN (?)\", follower_ids).order(\"updated_at DESC\")\n\t\t\trender json: {:status=>\"success\", :code=>200, :message=>\"List of tweets from the users you follow.\", data: tweets}\n\t\telse\n\t\t\trender json: {:status=>\"failure\", :message=>\"User is not present.\", data: tweets}\n\t\tend\n\tend",
"def index\n @favos = Favo\n .where(user_id: current_user.id)\n @tweets = Tweet.all\n end",
"def favourite_tweets_since id\n twitter_client.favorites since_id: id.to_s\n end",
"def index\n chain = Tweet\n chain = chain.since_id(params[:since_id]) if params[:since_id]\n @tweets = chain.all(:order => 'msg_twid ASC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def show_user_tweets\n @user_tweets = TwitterClient.user_timeline(params[:name])\n render json: @user_tweets\n end",
"def set_favorite_tweet\n @favorite_tweet = FavoriteTweet.find(params[:id])\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def show\r\n tweet = Tweet.find(params[:id])\r\n render json: tweet\r\n end",
"def favorite_activities\n get(\"/user/#{@user_id}/activities/favorite.json\")\n end",
"def favorite_activities()\n get(\"/user/#{@user_id}/activities/favorite.json\")\n end",
"def show\r\n @tweets = Tweet.all\r\n @tweet = Tweet.find(params[:id])\r\n end",
"def index\n number_tweets = if params[\"count\"] then params[\"count\"].to_i else 10 end\n tweet_ids = []\n if @user.interests\n for i in 1..number_tweets\n interest = @user.interests.sample\n tweet = Rails.application.config.twitter_client.search(\"#{interest[:hashtag]}\", count: 1).take(1)\n tweet_ids.push(tweet.first.id.to_s)\n end\n end\n\n render json: tweet_ids, status: :ok\n end",
"def index\n @following_user_ids = @user.following.pluck(:id)\n\n @tweets = Tweet.where(user_id: @following_user_ids).order(created_at: :desc).includes(:user)\n json_response(@tweets)\n end",
"def getThreeTweets\n\t\trender json: TwitterAPI.get_top_3_tweets(params[:twitter_id])\n\tend",
"def show\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n end\n end",
"def show\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n end\n end",
"def like_hello\n @client.search(\"#{@hashtbonjour}\", result_type: \"recent\").take(25).collect do |tweet|\n @client.favorite(tweet)\n end\n end",
"def index\n query = params[:q]\n respond_to do |format|\n format.html { @tweets_url = query ? \"/tweets.json?q=#{query}\" : '/tweets.json' }\n format.json do\n tweets, has_more =\n if query\n search_result =\n Tweet.search(\n query,\n page: params[:page] || 1,\n per_page: 20,\n includes: [\n { user: { avatar_attachment: %i[blob] } },\n :likes,\n { images_attachments: %i[blob] },\n { comments: { user: { avatar_attachment: %i[blob] } } },\n ],\n )\n [search_result.results, search_result.current_page < search_result.total_pages]\n else\n @pagy, tweets =\n pagy Tweet\n .includes(\n { user: { avatar_attachment: %i[blob] } },\n :likes,\n { images_attachments: %i[blob] },\n { comments: { user: { avatar_attachment: %i[blob] } } },\n )\n .order(created_at: :desc)\n [tweets, @pagy.page < @pagy.pages]\n end\n render json: { has_more: has_more, data: TweetBlueprint.render_as_hash(tweets) }\n end\n end\n end",
"def list_tweets\n tweets\n end",
"def index\n # binding.pry\n @tweet = Tweet.new\n if current_user\n friend_ids = Friend.where(user_id: current_user).pluck(:friends_id) \n @tweets = Tweet.where(user_id: friend_ids)\n else\n @tweets = Tweet.includes([:user]).all\n end\n\n @tweets = @tweets.order(updated_at: :desc).page(params[:page]).per(10)\n end",
"def index\n #Array of all tweets. Used for index html page\n @tweets = Tweet.all\n end",
"def favorites(screen_name)\n url = 'https://api.twitter.com/1.1/favorites/list.json?count=2&screen_name=' + screen_name\n request(@agent, @token, url)\n end",
"def index\n query = params[:q]\n respond_to do |format|\n format.html { \n if query\n @tweets_url = \"/tweets.json?q=#{query}\"\n else\n @tweets_url = \"/tweets.json\" \n end\n }\n format.json { \n tweets, has_more = if query\n search_result = Tweet.search(query, \n page: params[:page] || 1, \n per_page: 20, \n includes: [\n {user: {avatar_attachment: [:blob]}},\n :likes, {images_attachments: [:blob]},\n {comments: {user: {avatar_attachment: [:blob]}}}\n ])\n [search_result.results, search_result.current_page < search_result.total_pages]\n else\n @pagy, tweets = pagy Tweet.includes({user: {avatar_attachment: [:blob]}},\n :likes, \n {images_attachments: [:blob]},\n {comments: {user: {avatar_attachment: [:blob]}}}).order(created_at: :desc)\n [tweets, @pagy.page < @pagy.pages]\n end\n render json: {has_more: has_more, data: TweetBlueprint.render_as_hash(tweets) }\n }\n end\n end",
"def recent_tweets(count)\n start(\"/recent/tweets/#{count}\")\n end",
"def index\n if params[:page] && current_user\n render json: current_user, scope: {page: params[:page]}, serializer: UserWithTweetsSerializer, meta: {total_pages: current_user.timeline_tweets.count/25}\n elsif current_user\n render json: current_user, serializer: UserWithTweetsSerializer\n elsif params[:page]\n @tweets = Tweet.all.page(params[:page])\n render json: @tweets\n else\n @tweets = Tweet.all\n render json: @tweets\n end\n end",
"def index\n @tweets = Tweetaro.all\n end",
"def index\n\t\t@tweets = current_user.tweets\n\tend",
"def index\n @tweets = Tweet.all\n end",
"def index\n if !current_user.favorites.blank?\n return current_user.favorites\n else\n render json: { errors: \"No favorites for current user\" }, status: :not_found\n end\n end",
"def show_tweets\n @user = get_user_or_current_user(params[:id])\n @tweets = Tweet.where(:user_id => @user.id).order(created_at: :desc)\n end",
"def create\n @favorite_tweet = FavoriteTweet.new(favorite_tweet_params)\n\n respond_to do |format|\n if @favorite_tweet.save\n format.html { redirect_to @favorite_tweet, notice: 'Favorite tweet was successfully created.' }\n format.json { render action: 'show', status: :created, location: @favorite_tweet }\n else\n format.html { render action: 'new' }\n format.json { render json: @favorite_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @favorites = Favorite.all\n @user = current_user\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @favorites }\n end\n end",
"def index\n timeline = Tweet.where(user_id: User.find(@current_user_id).follows).or(Tweet.where(user_id: @current_user_id))\n render json: {timeline: timeline}\n end",
"def index\n @favorites = current_user.favorites\n render json: Api::V1::WatchableSerializer.new(@favorites.map(&:favoritable)).serialized_json\n end",
"def favorite\n current_user.favorite_topic(@topic.id)\n render json: {ok: 1}\n end",
"def favorite_tweet_params\n params[:favorite_tweet]\n end",
"def latest_tweets\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = ENV[\"TWITTER_CONSUMER_KEY\"]\n config.consumer_secret = ENV[\"TWITTER_CONSUMER_SECRET\"]\n end\n\n count = params[:count] || 10\n time_line = client.user_timeline(current_user.twitter_handle, {count: count})\n current_user.update(time_fetched: current_user.time_fetched+1)\n if time_line.class == Twitter::Error::NotFound\n render json: {status: 400, success: false, message: 'Twitter handle or id not valid'}\n else\n render json: {status: 200, success: true, message: 'Success', data: time_line.map{|a| a.text}.as_json}\n end\n\n rescue => e\n Rails.logger.error \"account_controller#latest_tweets - Error: #{e.message}\"\n render json: {status: 500, success: false, message: 'Unexpected error'}\n end",
"def show\n render json: @favorite\n end",
"def get_user_favorites username_for\n do_request 'get_user_favorites', username_for: username_for\n end",
"def get_favourite_restaurants\n @profile = Profile.find(params[:id])\n @restaurants = @profile.favourites\n\n render status: 200, json: @restaurants\n end",
"def show\n @favorite = Favorite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @favorite }\n end\n end",
"def favorite(client)\n\tensemble = client.search(\"#bonjour_monde\", result_type: \"recent\").take(25)\n#\tensemble.each do |tweet|\n\t\tclient.favorite(ensemble)\n#\tend\nend",
"def index\n @likes = Like.where(tweet_id: params[:tweet_id])\n @tweets = Tweet.paginate(page: params[:page], per_page: 10)\n end",
"def get_latest_tweets(num_of_tweets)\n client = configure_authentication\n latest = client.home_timeline({:count => num_of_tweets})\n client.end_session\n info = latest.to_json\n end",
"def favorites\n @favorites ||= Favorite.by_tweet_id.key(id)\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n end\n end",
"def favorite(id)\n post(\"/favorites/create/#{id}.json\")\n end",
"def show\n @retweet = Retweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retweet }\n end\n end",
"def show\n render json: @tweet\n end",
"def index\n @tweeters = Tweeter.all\n end",
"def show\n @tweet = Tweet.find(params[:id])\n end",
"def show\n @tweet = Tweet.find(params[:id])\n end",
"def get_favorite(key, json)\n data =JSON.parse(json)\n return data['favorites'][key]\nend",
"def show\n @tweeter = Tweeter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweeter }\n end\n end",
"def index\n puts(\"Total tweets: #{Tweet.count}\")\n @tweets = Tweet.all\n @tweets.each do |tweet|\n puts( \"#{tweet.zombie}: #{tweet.status}\")\n end\n\n @tweets\n end",
"def show\n respond_to do |format|\n begin\n @tweet = TweetApp::ClientContext.status(:get, params[:id])\n format.html # show.rhtml\n format.json { render :json => @tweet.to_json }\n format.xml { render :xml => @tweet.to_xml }\n rescue Twitter::RESTError => re\n handle_rest_error(re, format)\n end\n end\n end",
"def index\n @favorite_templates = FavoriteTemplate.all\n render json: @favorite_templates\n end",
"def index\n @actor_tweets = ActorTweet.all\n end",
"def get_favorite(key, json)\n return JSON.parse(json)[\"favorites\"][key]\nend",
"def favorite(action, value)\n raise ArgumentError, \"Invalid favorite action provided: #{action}\" unless @@FAVORITES_URIS.keys.member?(action)\n value = value.to_i.to_s unless value.is_a?(String)\n uri = \"#{@@FAVORITES_URIS[action]}/#{value}.json\"\n case action\n when :add\n response = http_connect {|conn| create_http_post_request(uri) }\n when :remove\n response = http_connect {|conn| create_http_delete_request(uri) }\n end\n bless_model(Twitter::Status.unmarshal(response.body))\n end",
"def by_user\r\n tweets = Tweet.where(user_id: params[:user_id])\r\n render json: tweets\r\n end",
"def favorited_tweet?(tweet)\n favorite_tweets.include? tweet\n end",
"def show\n\t\treferenced = @topic.tweets.count(:distinct)\n\t\tusers = @topic.tweets.user.count(:distinct)\n\t\trender json: show_json(@topic, referenced, users)\n\tend",
"def index\n authenticate\n @tweets = Tweet.where(\n user_id: current_user.id,\n stat: nil\n ).order(:id)\n end",
"def get_favorite(key, json)\n hash = JSON.parse(json)\n return hash[\"favorites\"][key]\n\nend",
"def index\n @new_tweets = NewTweet.all\n end",
"def index\r\n @tweets = Tweet.all\r\n @tweet = Tweet.new\r\n end",
"def tweets\n @tweets = @user.tweets.order(created_at: :desc).paginate(:page => params[:page], :per_page => 5) # order OWN tweets according to when they were created, with the most recent tweet at the top.\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def mention_tweets\n logger.debug { \"#{__method__} is called twitter_user_id=#{id}\" }\n tweets = []\n tweets = InMemory::MentionTweet.find_by(uid) if InMemory.enabled? && InMemory.cache_alive?(created_at)\n tweets = Efs::MentionTweet.where(uid: uid) if tweets.blank? && Efs::Tweet.cache_alive?(created_at)\n tweets = ::S3::MentionTweet.where(uid: uid) if tweets.blank?\n tweets.map { |tweet| ::TwitterDB::Mention.new(uid: uid, screen_name: screen_name, raw_attrs_text: tweet.raw_attrs_text) }\n end",
"def get_favorites\n authenticate_rem\n follower = @current_user || User.find_by_id(params[:user_id])\n render json: Product.order(created_at: :desc).limit(20).map(&:simple_info.with(follower)),\n status: :ok\n end",
"def index\n authorize! :index, Spree::Favorite\n @favorites = spree_current_user.favorites\n respond_to do |format|\n format.html\n format.json { render json: @favorites }\n end\n end",
"def post(number = 1)\n results = twitter_client.search(\"#sad\")\n return unless results.try(:any?)\n results.take(number).each do |tweet|\n twitter_client.favorite(tweet)\n twitter_client.update(\"@#{tweet.user.screen_name} Happiness is the art of never holding in your mind the memory of any unpleasant thing that has passed.\")\n end\n end",
"def favorite_tweets\n puts \"Do you want to favorite all of the tweets from the query? The query '#{@query.strip}' has #{@tweets.size} tweets. Y/N\"\n @decision = gets\n @tweets.each do |tweet|\n begin\n Twitter.favorite(tweet.id)\n rescue Twitter::Error::TooManyRequests => error\n puts \"Oops, we are rate limited. We will try again at: #{Time.now + error.rate_limit.reset_in + 5}\"\n sleep error.rate_limit.reset_in + 5\n retry\n rescue Twitter::Error::ServiceUnavailable => error\n sleep(10)\n retry\n rescue Twitter::Error::Forbidden => error\n puts \"You already favorited tweet from #{tweet.user.screen_name}\"\n next\n rescue Twitter::Error::NotFound => error\n puts \"Sorry something went wrong. #{error}\"\n next\n else\n puts \"Favorited '#{tweet.text}' from #{tweet.user.screen_name}\"\n end\n sleep(1)\n end\nend",
"def favorite_tweet(tweet)\n # Ternary to prevent duplicates\n favorited_tweet?(tweet) ? favorite_tweets : favorite_tweets << tweet\n end",
"def get_tweet(id)\n\n\t\t# tweet = Tweet.where({:tweet_id => id})\n\n\n\tend",
"def show\n @tweetsandwich = Tweetsandwich.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweetsandwich }\n end\n end",
"def index\n @favoritos = Favorito.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @favoritos }\n end\n end",
"def show_favorites\n authenticate_rem\n follower = @current_user || User.find_by_id(params[:user_id])\n render json: follower.favorite_products.map(&:simple_info.with(follower)), status: :ok\n end",
"def show\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n format.xml { render xml: @tweet }\n end\n end",
"def create_favorite(id)\n post \"favorites/create/#{id}\", {}\n end",
"def get_tweets\n # TODO-JW: look into -- respond_to :json\n @card = Card.find(params[:id])\n @api = Twitter.user_timeline(@card.twitter_handle, options={count: 10})\n if @api\n tweets = []\n @api.each_with_index do |tweet,i|\n tweets[i] = {}\n tweets[i][:tweet_id] = String(tweet.id)\n tweets[i][:text] = auto_link(tweet.text)\n tweets[i][:created] = tweet.created_at\n tweets[i][:user_id] = tweet.user.screen_name\n end\n render json: tweets \n else\n [].to_json\n end\n end",
"def index\n respond_with RawTweet.all\n end",
"def show\n @twitter_list = TwitterList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @twitter_list }\n end\n end",
"def twubbles\n @sad_tweets = WordTweet.recent_sad_tweets\n respond_to do |f|\n f.json { render :json => twubbles_json(@sad_tweets) }\n f.html\n end\n end",
"def index\n favoritable_type = params[:type] || params[:favoritable_type]\n\n @favorites = if favoritable_type.present?\n current_user.favoritables\n .where(favoritable_type: favoritable_type)\n else\n current_user.favoritables\n end\n\n @total = @favorites.count\n\n @favorites = @favorites\n .page(params[:page])\n .per(params[:per])\n\n # render json: {favorites: @favorites, total: @total}\n end",
"def get_favorite\n @json = FavoriteBeer&.all.where(user_id: @current_user.id).as_json\n\n @json.map! { |beer| beer.slice('id', 'name', 'tagline', 'description', 'abv', 'punk_id') }\n @json.each { |beer| beer[:favorite] = true }\n\n render json: {\n favorite_beers: @json\n }\n end"
] | [
"0.74497986",
"0.7217033",
"0.7212017",
"0.71911246",
"0.7177048",
"0.70935404",
"0.70396423",
"0.7016141",
"0.70106065",
"0.69962627",
"0.6890951",
"0.6883632",
"0.6850413",
"0.6797372",
"0.67810524",
"0.6780074",
"0.67399305",
"0.67399305",
"0.67399305",
"0.67399305",
"0.67399305",
"0.67399305",
"0.67393416",
"0.67298543",
"0.6719128",
"0.6705967",
"0.67021453",
"0.668562",
"0.66705215",
"0.66625994",
"0.66625994",
"0.6660308",
"0.66574717",
"0.6641768",
"0.6632297",
"0.663007",
"0.66247725",
"0.6565741",
"0.6559304",
"0.6549221",
"0.6527549",
"0.65195936",
"0.6515652",
"0.65154934",
"0.6514214",
"0.6481201",
"0.64660734",
"0.6465792",
"0.6464745",
"0.64589",
"0.64584315",
"0.6444388",
"0.6439294",
"0.6435874",
"0.6422511",
"0.6419688",
"0.6411466",
"0.6409601",
"0.6398751",
"0.6398623",
"0.6393503",
"0.63846534",
"0.6378376",
"0.63767904",
"0.6370608",
"0.63678813",
"0.63678813",
"0.63663036",
"0.6360813",
"0.63569146",
"0.6355359",
"0.63509154",
"0.6346979",
"0.6344382",
"0.6317772",
"0.6315293",
"0.63081837",
"0.629901",
"0.6297188",
"0.62963784",
"0.6296079",
"0.6294143",
"0.6273193",
"0.6269713",
"0.6261516",
"0.6257906",
"0.62481886",
"0.6245579",
"0.624367",
"0.6240666",
"0.6239713",
"0.6237725",
"0.62045646",
"0.6200148",
"0.6172775",
"0.6170215",
"0.61630434",
"0.61617464",
"0.6158985",
"0.61565214",
"0.61502844"
] | 0.0 | -1 |
POST /favorite_tweets POST /favorite_tweets.json | def create
@favorite_tweet = FavoriteTweet.new(favorite_tweet_params)
respond_to do |format|
if @favorite_tweet.save
format.html { redirect_to @favorite_tweet, notice: 'Favorite tweet was successfully created.' }
format.json { render action: 'show', status: :created, location: @favorite_tweet }
else
format.html { render action: 'new' }
format.json { render json: @favorite_tweet.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n user = user_from_token\n @tweet = user.tweets.new()\n @tweet.tweet = params[:tweet]\n if @tweet.save\n render :json => @tweet, :status => :created\n else\n render :json => @tweet.errors, :status => :unprocessable_entity\n end\n end",
"def create_favorite(id)\n post \"favorites/create/#{id}\", {}\n end",
"def favorite_tweets\n logger.debug { \"#{__method__} is called twitter_user_id=#{id}\" }\n tweets = []\n tweets = InMemory::FavoriteTweet.find_by(uid) if InMemory.enabled? && InMemory.cache_alive?(created_at)\n tweets = Efs::FavoriteTweet.where(uid: uid) if tweets.blank? && Efs::Tweet.cache_alive?(created_at)\n tweets = ::S3::FavoriteTweet.where(uid: uid) if tweets.blank?\n tweets.map { |tweet| ::TwitterDB::Favorite.new(uid: uid, screen_name: screen_name, raw_attrs_text: tweet.raw_attrs_text) }\n end",
"def favorite_tweet_params\n params[:favorite_tweet]\n end",
"def create\n @tweet = current_user.tweets.create(params[:tweet])\n respond_with(@tweet, :location => tweet_url(@tweet))\n end",
"def create\n @tweet = Tweet.create(tweet_params)\n\n @tweet = get_tagged(@tweet)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to home_path, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = @user.tweets.build(params[:tweet])\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to user_tweet_path(@user, @tweet), notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: :created, location: user_tweet_path(@user, @tweet) }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_favorite_tweet\n @favorite_tweet = FavoriteTweet.find(params[:id])\n end",
"def create\n @user = User.find(params[:user_id])\n @tweet = @user.tweets.create(tweet_params)\n redirect_to user_tweets_path\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n @tweet.user_vote = 0\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n \n respond_to do |format|\n if @tweet.save\n format.html { redirect_to tweets_path, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.new(params[:tweet])\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: :created, location: @tweet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.new(params[:tweet])\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: :created, location: @tweet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favorite(id)\n post(\"/favorites/create/#{id}.json\")\n end",
"def create\n @tweet = current_user.tweets.build(tweet_params)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_tweet\n # @tweets << tweet: violates SST\n Tweet.new('tweet message', self)\n end",
"def favorite_tweet(tweet)\n # Ternary to prevent duplicates\n favorited_tweet?(tweet) ? favorite_tweets : favorite_tweets << tweet\n end",
"def create\n @tweet = Tweet.new(tweet_params.merge(user: current_user))\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to root_path, notice: \"Tweet was successfully created.\" }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favorite\n tweet_id=params[:tuit_id]\n client.favorite(tweet_id) unless tweet_id == nil\n respond_to do |format|\n format.html { }\n\t format.json { head :no_content }\n\t format.js\n end\n end",
"def post_tweet(user_id, tweet_id)\n @alltweets << [user_id, tweet_id]\n end",
"def create\r\n @tweet = Tweet.new(tweet_params)\r\n @tweet.user = current_user\r\n \r\n respond_to do |format|\r\n if @tweet.save\r\n format.html { redirect_to @tweet, notice: \"Tweet was successfully created.\" }\r\n format.json { render :show, status: :created, location: @tweet }\r\n else\r\n format.html { render :new, status: :unprocessable_entity }\r\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @tweet = current_user.tweets.new tweet_params\n\n if current_user\n @tweet.user_id = current_user.id\n end\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: \"Tweet was successfully created.\" }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tputs params[:post_now]\n\t\tif params[:post_now] == \"1\"\n\t\t\tclient = Twitter::REST::Client.new do |config|\n\t\t\t\tconfig.consumer_key = TWITTER_API_KEY\n\t\t\t\tconfig.consumer_secret = TWITTER_API_SECRECT\n\t\t\t\tconfig.access_token = current_user.access_token\n\t\t\t\tconfig.access_token_secret = current_user.access_token_secret\n\t\t\tend\n\t\t\tcontent = params[:tweet][:content]\n\t\tend\n\t\t@tweet = current_user.tweets.build(tweet_params)\n\t\trespond_to do |format|\n\t\t\tif @tweet.save\n\t\t\t\tif client.update(\"#{content}\")\n\t\t\t\t\tputs @tweet.update(tweeted: true)\n\t\t\t\t\tflash[:notice] = \"Successfully posted \" \n\t\t\t\telse\n\t\t\t\t\tflash[:notice] = \"not updated \" \n\t\t\t\tend\n\t\t\t\tformat.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @tweet }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @tweet.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def post(number = 1)\n results = twitter_client.search(\"#sad\")\n return unless results.try(:any?)\n results.take(number).each do |tweet|\n twitter_client.favorite(tweet)\n twitter_client.update(\"@#{tweet.user.screen_name} Happiness is the art of never holding in your mind the memory of any unpleasant thing that has passed.\")\n end\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n @tweet.user = current_user\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to root_path, notice: \"Tweet creado felizmente.\" }\n format.json { redirect_to root_path, status: :created, location: @tweet }\n else\n format.html { redirect_to root_path, notice: \"No se puede tuitear nada.\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n\n if @tweet.save\n render :show, status: :created, location: { tweet: @tweet }\n else\n render json: @tweet.errors, status: :unprocessable_entity\n end\n end",
"def create\n @tweet = Tweet.create(:user_id => current_user.id, :text => tweet_params[:text])\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n if @tweet.username == nil\n # This is for the current user posting tweets\n @tweet.username = current_user.name\n @tweet.user_id = current_user.id\n # Updates to Twitter\n current_user.twitter.update(@tweet.tweetbody)\n else \n # Incoming tweets from the daemon script\n @tweet.save\n end\n respond_with(@tweet)\n end",
"def create\n @tweet = Tweet.new(params[:tweet])\n @user = User.find(session[:user_id])\n @tweet.user = @user\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: :created, location: @tweet }\n else\n @tweets = Tweet.paginate page: params[:page], order:'created_at desc', per_page: 10\n @user = User.new\n format.html { render action: \"index\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = current_user.tweets.new(tweet_params)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_back fallback_location: root_path, notice: 'ツーイトの投稿が完了しました。' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favorited_tweet?(tweet)\n favorite_tweets.include? tweet\n end",
"def create\n signin_apikey\n \n if session[:user_id] != nil\n @tweet = Tweet.new(tweet_params)\n @tweet.author = User.find(session[:user_id]).email.split('@')[0].strip\n @tweet.user_id = User.find(session[:user_id]).id\n if !@tweet.url.blank?\n if !is_url(@tweet.url)\n respond_to do |format|\n format.json { render json: \"Invalid url!\".to_json, status: 400 }\n end\n return\n end\n @tweet.url = @tweet.url.sub \"https://\", \"\"\n @tweet.url = @tweet.url.sub \"www.\", \"\"\n @urlsplit = @tweet.url.split(\"/\")\n @urlsplit.each do |suburl|\n if suburl.include?(\".\")\n @tweet.shorturl = suburl\n end\n end\n end\n @tweet2 = Tweet.find_by url: @tweet.url\n if (@tweet.content.blank? && !@tweet.url.blank?)\n respond_to do |format|\n if @tweet.title.blank?\n format.html { redirect_to new_tweet_path, alert: 'Please try again.' }\n format.json { render json: \"Title property cannot be blank\".to_json, status: 400 }\n elsif (@tweet2 != nil)\n format.html { redirect_to '/tweets/' + @tweet2.id.to_s }\n msg = \"The URL already exists\"\n format.json { render json: msg.to_json , status: 400, location: @tweet }\n elsif @tweet.save\n format.html { redirect_to '/tweets', notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: 201 }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n elsif (@tweet.url.blank? && !@tweet.content.blank?)\n @tweet.ask = true\n respond_to do |format|\n if @tweet.title.blank?\n format.html { redirect_to new_tweet_path, alert: 'Please try again.' }\n format.json { render json: \"Title property cannot be blank\".to_json, status: 400 }\n elsif @tweet.save\n format.html { redirect_to '/tweets', notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: 201 }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n else\n @comment_text=@tweet.content\n @tweet.content=nil\n @tweet.ask = false\n \n if @tweet.save\n Comment.create(contribution: @tweet.id, text: @comment_text, escomment: true, comment_id: nil, user: @tweet.user_id)\n render :json => @tweet.attributes.merge( )\n end\n end\n else\n respond_to do |format|\n format.json { render json: {message: 'Unauthorized, you don\\'t have a valid api_key' }, status: 401 }\n end\n end\n end",
"def create\n @tweet = current_user.tweets.build(tweet_params)\n\n #respond_to do |format|\n if @tweet.save\n flash[:success] = 'ツイートを投稿しました。'\n redirect_to tweets_path\n #format.html { redirect_to @tweet }\n #format.json { render :show, status: :created, location: @tweet }\n else\n @tweets = current_user.feed_tweets.order(id: :desc).page(params[:page])\n flash.now[:danger] = 'ツイートを投稿できませんでした。'\n render 'tweets/index'\n #format.html { render :new }\n #format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end",
"def create\n @favorite = current_user.favoritables.build(favorite_params)\n\n if @favorite.save\n render json: @favorite, status: :created\n else\n render json: @favorite.errors, status: :unprocessable_entity\n end\n end",
"def post_tweet(message)\n tweet = Tweet.new(self, message)\n self.tweets << tweet\n end",
"def create\n @favoritetweet = Favoritetweet.new(params[:favoritetweet])\n\n respond_to do |format|\n if @favoritetweet.save\n format.html { redirect_to(@favoritetweet, :notice => 'Favoritetweet was successfully created.') }\n format.xml { render :xml => @favoritetweet, :status => :created, :location => @favoritetweet }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @favoritetweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def tweet(tweet_body)\n encoded_url = url_encode \"#{@handle}/#{@password}/#{tweet_body}\"\n HTTParty.post(\"#{@api_path}/tweets/new/#{encoded_url}\")\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n @tweet.user_id = current_user.id\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to root_path, notice: \"Tu Tweet se ha publicado con exito!\" }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet_collection = TweetCollection.new(tweet_collection_params)\n Tweet.tweets.each {|t| @tweet_collection.tweets << t}\n \n respond_to do |format|\n if @tweet_collection.save\n format.html { redirect_to @tweet_collection, notice: 'Tweet collection was successfully created.' }\n format.json { render :show, status: :created, location: @tweet_collection }\n else\n format.html { render :new }\n format.json { render json: @tweet_collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweett = Tweett.new(tweett_params)\n\n respond_to do |format|\n if @tweett.save\n format.html { redirect_to @tweett, notice: 'Tweett was successfully created.' }\n format.json { render :show, status: :created, location: @tweett }\n else\n format.html { render :new }\n format.json { render json: @tweett.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @new_tweet = NewTweet.new(new_tweet_params)\n\n respond_to do |format|\n if @new_tweet.save\n format.html { redirect_to @new_tweet, notice: 'New tweet was successfully created.' }\n format.json { render :show, status: :created, location: @new_tweet }\n else\n format.html { render :new }\n format.json { render json: @new_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweets\n user = User.find(params[:id])\n render json: user.list_tweets, status: :ok\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n @tweet.user_id = current_user.id\n\n \n\n \n \n \n\n \n \n \n\n\n \n\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to root_path, notice: \"Tweet was successfully created.\" }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n begin\n @tweet = TweetApp::ClientContext.status(:post, params[:text])\n flash[:notice] = 'Tweet was successfully created.'\n format.html { redirect_to tweet_url(@tweet) }\n format.json { head :created, :location => tweet_url(@tweet) }\n format.xml { head :created, :location => tweet_url(@tweet) }\n rescue Twitter::RESTError => re\n handle_rest_error(re, format, 'new')\n end\n end\n end",
"def create\n @tweet = FuKing::Twitter.update(params[:tweet][:text])\n\n respond_to do |format|\n if @tweet\n flash[:notice] = 'Tweet was successfully created.'\n format.html { redirect_to(:action => :index) }\n format.mobile { redirect_to(:action => :index) }\n format.xml { render :xml => @tweet, :status => :created, :tweet => @tweet }\n else\n format.html { render :action => \"new\" }\n format.mobile { render :action => \"new\" }\n format.xml { render :xml => @tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = user.favorites.new(favorite_params)\n\n if @favorite.save\n render :show, status: :ok\n else\n render json: @favorite.errors, status: :unprocessable_entity\n end\n end",
"def create\n @tweet = current_user.tweets.build(tweet_params)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to member_url(current_user), notice: '投稿しました' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(favorite_params)\n if @favorite.save\n render json: FavoriteSerializer.new(@favorite), status: :created\n else\n render json: @favorite.errors.full_messages.to_sentence, status: :unprocessable_entity\n end\n end",
"def create\n @tweet = Tweet.new(params[:tweet])\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to(@tweet, :notice => 'Tweet was successfully created.') }\n format.xml { render :xml => @tweet, :status => :created, :location => @tweet }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(params[:favorite])\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render json: @favorite, status: :created, location: @favorite }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @retweet = Retweet.new(params[:retweet])\n\n respond_to do |format|\n if @retweet.save\n format.html { redirect_to @retweet, notice: 'Retweet was successfully created.' }\n format.json { render json: @retweet, status: :created, location: @retweet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Use current_user below, so that new tweets are only created by the logged in user #MDM\n #@tweet = Tweet.new(tweet_params)\n @tweet = current_user.tweets.new(tweet_params)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweet_from_api\n @tweet_api = User.find(2).tweets.create(tweet_params)\n render json: @tweet_api\n end",
"def create\n @watcher = Watcher.new(watcher_params)\n\n respond_to do |format|\n if @watcher.save\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = \"1jFn305ISZq4moZsv6mYyGls4\"\n config.consumer_secret = \"i8JvIWmswNqA7c9HIpTHJ1nIxZAGGcWyLaGBxfteQXMkNK4DqK\"\n config.access_token = \"14191779-n4X4Fs1WDx9IlNqjt5WhDYT0oMttRlmBP3ysoUhII\"\n config.access_token_secret = \"dixLEBjwapLNrmlZEu2amiB8qcZGihvPnLXoN5d15AgsA\"\n end\n # TODO: max_id, since_id\n client.search(@watcher.keywords, :lang => 'en', :count => 100).take(100).collect do |tweet|\n Tweet.create(:watcher_id => @watcher.id, :tweet_id => tweet.id, :fields => tweet.to_h)\n end\n\n format.html { redirect_to @watcher, notice: 'Watcher was successfully created.' }\n format.json { render :show, status: :created, location: @watcher }\n else\n format.html { render :new }\n format.json { render json: @watcher.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n recipe = Recipe.find(params[:id])\n @favorite = current_user.add_to_favorite(recipe.id)\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to :back, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n tweet.user = current_user\n\n respond_to do |format|\n if tweet.save\n format.html { redirect_to tweet, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: tweet }\n else\n format.html { render :new }\n format.json { render json: tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @tweet = Tweet.new(params[:tweet])\n \n # write stats\n @keywords.each do |word|\n \n if @tweet.text.downcase.include? word then\n \n stat = WordStatistic.where(:word => word, :day => DateTime.now.beginning_of_day..DateTime.now).first\n if stat.nil? then\n new_stat = WordStatistic.new(:word => word, :day => DateTime.now, :freq => 1)\n new_stat.save\n else\n \n stat.freq += 1\n stat.save\n end\n end\n end # keywords\n\n respond_to do |format|\n if @tweet.save\n format.json { render :json => @tweet, :notice => 'Tweet was successfully created.' }\n format.xml { render :xml => @tweet, :status => :created, :location => @tweet }\n else\n format.xml { render :xml => @tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(favorite_params)\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(favorite_params)\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @favorite_tweets = FavoriteTweet.where(:user => session[:user_id])\n end",
"def add_word_to_favorites(word, *args)\n http_method = :post\n path = '/word/{word}/favorite'\n path.sub!('{word}', word.to_s)\n\n # Ruby turns all key-value arguments at the end into a single hash\n # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')\n # becomes {:limit => 10, :part_of_speech => 'verb'}\n last_arg = args.pop if args.last.is_a?(Hash)\n last_arg = args.pop if args.last.is_a?(Array)\n last_arg ||= {}\n\n # Look for a kwarg called :request_only, whose presence indicates\n # that we want the request itself back, not the response body\n if last_arg.is_a?(Hash) && last_arg[:request_only].present?\n request_only = true\n last_arg.delete(:request_only)\n end\n\n params = last_arg\n body ||= {}\n request = Wordnik::Request.new(http_method, path, :params => params, :body => body)\n request_only ? request : request.response.body\n end",
"def favo_params\n params.require(:favo).permit(:user_id, :tweet_id)\n end",
"def add_tweet(tweet)\n @tweets << tweet\n end",
"def favorite(action, value)\n raise ArgumentError, \"Invalid favorite action provided: #{action}\" unless @@FAVORITES_URIS.keys.member?(action)\n value = value.to_i.to_s unless value.is_a?(String)\n uri = \"#{@@FAVORITES_URIS[action]}/#{value}.json\"\n case action\n when :add\n response = http_connect {|conn| create_http_post_request(uri) }\n when :remove\n response = http_connect {|conn| create_http_delete_request(uri) }\n end\n bless_model(Twitter::Status.unmarshal(response.body))\n end",
"def create\n @tweet_post = TweetPost.new(tweet_post_params)\n\n respond_to do |format|\n if @tweet_post.save\n format.html { redirect_to @tweet_post, notice: \"Tweet post was successfully created.\" }\n format.json { render :show, status: :created, location: @tweet_post }\n \n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tweet_post.errors, status: :unprocessable_entity }\n \n end\n end\n end",
"def favorite_tweets\n puts \"Do you want to favorite all of the tweets from the query? The query '#{@query.strip}' has #{@tweets.size} tweets. Y/N\"\n @decision = gets\n @tweets.each do |tweet|\n begin\n Twitter.favorite(tweet.id)\n rescue Twitter::Error::TooManyRequests => error\n puts \"Oops, we are rate limited. We will try again at: #{Time.now + error.rate_limit.reset_in + 5}\"\n sleep error.rate_limit.reset_in + 5\n retry\n rescue Twitter::Error::ServiceUnavailable => error\n sleep(10)\n retry\n rescue Twitter::Error::Forbidden => error\n puts \"You already favorited tweet from #{tweet.user.screen_name}\"\n next\n rescue Twitter::Error::NotFound => error\n puts \"Sorry something went wrong. #{error}\"\n next\n else\n puts \"Favorited '#{tweet.text}' from #{tweet.user.screen_name}\"\n end\n sleep(1)\n end\nend",
"def post_tweet(message)\n Tweet.new(message, self)\n end",
"def favorite_params\n params.require(:favorite).permit(:user_id, :post_id)\n end",
"def index\n @tweets = @user.tweets.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def create\n begin \n new_tweet = Tweet.new(tweet_params)\n if new_tweet.save()\n render(status: 201, json: {tweet: new_tweet})\n else # if validation fails\n render(status: 422, json: {error: new_tweet.errors})\n end\n rescue => error\n render(status: 500, json: {error: \"Internal Server Error: #{error.message}\"})\n end\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n\n respond_to do |format|\n if @favourite.save\n sync_update @favourite.fav_post\n format.html { redirect_to :my_favourites, notice: 'Favourite was successfully created.' }\n format.json { render json: @favourite }\n else\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweeter = Tweeter.new(params[:tweeter])\n\n respond_to do |format|\n if @tweeter.save\n format.html { redirect_to @tweeter, notice: 'Tweeter was successfully created.' }\n format.json { render json: @tweeter, status: :created, location: @tweeter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tweeter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favorites(options = nil)\n def uri_suffix(opts); opts && opts[:page] ? \"?page=#{opts[:page]}\" : \"\"; end\n uri = '/favorites.json' + uri_suffix(options)\n response = http_connect {|conn|\tcreate_http_get_request(uri) }\n bless_models(Twitter::Status.unmarshal(response.body))\n end",
"def mention_tweets\n logger.debug { \"#{__method__} is called twitter_user_id=#{id}\" }\n tweets = []\n tweets = InMemory::MentionTweet.find_by(uid) if InMemory.enabled? && InMemory.cache_alive?(created_at)\n tweets = Efs::MentionTweet.where(uid: uid) if tweets.blank? && Efs::Tweet.cache_alive?(created_at)\n tweets = ::S3::MentionTweet.where(uid: uid) if tweets.blank?\n tweets.map { |tweet| ::TwitterDB::Mention.new(uid: uid, screen_name: screen_name, raw_attrs_text: tweet.raw_attrs_text) }\n end",
"def tweet(postids)\n handle_response(get(\"/content/tweet.json\", :query => {:postids => postids}))\n end",
"def create\n @tweeter = Tweeter.new(tweeter_params)\n\n respond_to do |format|\n if @tweeter.save\n format.html { redirect_to @tweeter, notice: 'Tweeter was successfully created.' }\n format.json { render :show, status: :created, location: @tweeter }\n else\n format.html { render :new }\n format.json { render json: @tweeter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_tweet(message)\n Tweet.new(message, self)\n end",
"def index\n number_tweets = if params[\"count\"] then params[\"count\"].to_i else 10 end\n tweet_ids = []\n if @user.interests\n for i in 1..number_tweets\n interest = @user.interests.sample\n tweet = Rails.application.config.twitter_client.search(\"#{interest[:hashtag]}\", count: 1).take(1)\n tweet_ids.push(tweet.first.id.to_s)\n end\n end\n\n render json: tweet_ids, status: :ok\n end",
"def create\n @fr_tweet = FrTweet.new(fr_tweet_params)\n\n respond_to do |format|\n if @fr_tweet.save\n format.html { redirect_to @fr_tweet, notice: 'Fr tweet was successfully created.' }\n format.json { render :show, status: :created, location: @fr_tweet }\n else\n format.html { render :new }\n format.json { render json: @fr_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n if Tweet::Create.(current_user, tweet_params)\n return redirect_to tweets_path, notice: 'Tweet was successfully created.'\n end\n\n end",
"def update\n respond_to do |format|\n if @favorite_tweet.update(favorite_tweet_params)\n format.html { redirect_to @favorite_tweet, notice: 'Favorite tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @favorite_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_twit(twit)\n RestClient.post configuration.base_url + '/twits',\n { twit: twit }.to_json,\n content_type: :json,\n accept: :json\n end",
"def create\n @tweet = Tweetaro.new(tweetaro_params)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweetしました!' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @tweet = Tweet.new(tweet_params)\r\n @tweet.poster_id = current_user.id\r\n @tweet.user = current_user\r\n @tweet.is_retweet = false\r\n\r\n # if @tweet.is_reply\r\n # Tweet.find(@tweet.reply_id).replies << @tweet\r\n # end\r\n\r\n respond_to do |format|\r\n if @tweet.save\r\n format.html { redirect_to root_path}\r\n format.js { render 'create' }\r\n else\r\n @tweet_stream = []\r\n format.html { render action: 'new' }\r\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n\r\n # if @tweet.is_reply\r\n # Conversation.create(@tweet_id)\r\n\r\n # Notification.new(user_id: Tweet.find(reply_id).user_id, img_url: User.find(Tweet.find(reply_id).user_id).img_url, content: @tweet.content, message: \"#{User.find(@tweet.user_id).full_name} retweeted your tweet!\"\r\n # end\r\n\r\n end",
"def add_tweet(tweet)\n\t\ttweets << tweet\n\tend",
"def create\n @tweetsandwich = Tweetsandwich.new(params[:tweetsandwich])\n\n respond_to do |format|\n if @tweetsandwich.save\n format.html { redirect_to @tweetsandwich, notice: 'Tweetsandwich was successfully created.' }\n format.json { render json: @tweetsandwich, status: :created, location: @tweetsandwich }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tweetsandwich.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @qweet = current_user.qweets.build(qweet_params)\n\n respond_to do |format|\n if @qweet.save\n format.html { redirect_to root_path, notice: \"Qweet was successfully created.\" }\n format.json { render :show, status: :created, location: @qweet }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @qweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favorites(screen_name)\n url = 'https://api.twitter.com/1.1/favorites/list.json?count=2&screen_name=' + screen_name\n request(@agent, @token, url)\n end",
"def index\r\n @tweets = Tweet.all\r\n @tweet = Tweet.new\r\n end",
"def create(stanza)\n #<iq type='set'><message ...>...</message>...<message ...></message></iq>\n @tweets = stanza.children.map {|m| Tweet.from_xml(m)}\n\n if @tweets.all? {|t| t.save }\n result :success # TODO: this is hackish\n else\n # some sort of error response\n end\n end",
"def favorite_user_tweets\n puts \"Are you sure you want to favorite the most recent tweet of ALL of the unique users of #{@other_user.strip}? Y/N\"\n @decision = gets\n\n case @decision.strip\n when \"Y\"\n @unique_user_ids.each do |followerId|\n begin\n @favorite_user = Twitter.user(followerId)\n if @favorite_user.status.nil?\n puts \"Blank status for #{@favorite_user.screen_name}\"\n next\n else\n Twitter.favorite(@favorite_user.status.id)\n end\n rescue Twitter::Error::TooManyRequests => error\n puts \"Oops, we are rate limited. We will try again at: #{Time.now + error.rate_limit.reset_in + 5}\"\n sleep error.rate_limit.reset_in + 5\n retry\n rescue Twitter::Error::ServiceUnavailable => error\n sleep(10)\n retry\n rescue Twitter::Error::Forbidden => error\n puts \"You already favorited tweet from #{@favorite_user.screen_name}\"\n next\n rescue Twitter::Error::NotFound => error\n puts \"Sorry something went wrong. #{error}\"\n next\n else\n puts \">>> Favorited last tweet of #{@favorite_user.screen_name}.\"\n end\n sleep(1)\n end\n when \"N\"\n puts \"Ok, well that was a waste of time.\"\n else\n puts \"Something went wrong here. Start over.\"\n end\n\nend",
"def mark_favourite\n @favourite_artist = FavouriteArtist.where(spotify_id: params[:spotify_id]).first_or_create(_params)\n render :json => @favourite_artist.to_json\n end",
"def tweet_new_tweet(tweet)\n #setup twitter client\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = $consumer_key\n config.consumer_secret = $consumer_secret\n config.access_token = $access_token\n config.access_token_secret = $access_token_secret\n end\n\n $log.debug(tweet)\n client.update(tweet)\n $log.info(\"Successfully tweeted!\")\nend",
"def postTweet(status)\n\t\t\t@client.update(status)\n\t\tend",
"def create\n @tweeeet = current_user.tweeeets.build(tweeeet_params)\n\n respond_to do |format|\n if @tweeeet.save\n format.html { redirect_to root_path, notice: 'Tweet creado con éxito!' }\n format.json { render :show, status: :created, location: @tweeeet }\n else\n format.html { render :new }\n format.json { render json: @tweeeet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process_tweet(tweet)\n log_info { \"New Tweet: #{tweet.uri}\" }\n\n if tweet.retweeted_status.present?\n text =\n \"Retweeted from <a href=\\\"https://twitter.com/#{tweet.retweeted_status.user.screen_name}\\\">@#{tweet.retweeted_status.user.screen_name}</a>:\\n\" +\n convert_all_entities(tweet.retweeted_status)\n\n send_media_of tweet.retweeted_status, retweeted: true\n\n elsif tweet.quoted_status?\n text =\n convert_all_entities(tweet) + \"\\n\\n\" +\n \"Retweeted from <a href=\\\"https://twitter.com/#{tweet.quoted_status.user.screen_name}\\\">@#{tweet.quoted_status.user.screen_name}</a>:\\n\" +\n convert_all_entities(tweet.quoted_status)\n\n send_media_of tweet.quoted_status, retweeted: true\n\n else\n text = convert_all_entities(tweet)\n\n send_media_of tweet\n\n end\n\n text = text + \"\\n\\n<a href=\\\"#{tweet.uri}\\\">Reply</a>\"\n\n @bot.telegram.api.send_message(\n chat_id: @config.twitter.target_channel,\n text: text,\n parse_mode: 'HTML',\n disable_web_page_preview: true\n )\n\n end",
"def favourite_params\n params.require(:favourite).permit(:user_id, :fav_post_id)\n end",
"def create\n Favorite.create favorite_params\n show_all\n end",
"def index\n\t\tuser = User.find_by(id: params[:user_id])\n\t\tif user.present?\n\t\t\tfollower_ids = user.followers.pluck(:id)\n\t\t\ttweets = Tweet.where(\"user_id IN (?)\", follower_ids).order(\"updated_at DESC\")\n\t\t\trender json: {:status=>\"success\", :code=>200, :message=>\"List of tweets from the users you follow.\", data: tweets}\n\t\telse\n\t\t\trender json: {:status=>\"failure\", :message=>\"User is not present.\", data: tweets}\n\t\tend\n\tend",
"def perform\n tweets = load_tweets\n tweets.each do |t|\n t.hashtags.each do |h|\n Trend.create(hashtags: h.text, created_at: Time.now)\n end\n end\n end"
] | [
"0.71963686",
"0.69921327",
"0.69658303",
"0.68816566",
"0.68612856",
"0.685439",
"0.68041986",
"0.6791777",
"0.6752056",
"0.6720362",
"0.67200935",
"0.669575",
"0.669575",
"0.6688767",
"0.66724735",
"0.6639043",
"0.65915155",
"0.658637",
"0.65502",
"0.6545046",
"0.6530948",
"0.6509632",
"0.6496084",
"0.6492643",
"0.64911646",
"0.64857227",
"0.647452",
"0.64484185",
"0.6445253",
"0.64360774",
"0.6428174",
"0.6425641",
"0.64215815",
"0.64174473",
"0.6406096",
"0.64027786",
"0.63962835",
"0.63863826",
"0.6384819",
"0.63818204",
"0.6354727",
"0.6344045",
"0.63382506",
"0.63159174",
"0.6310687",
"0.6306639",
"0.629756",
"0.62944126",
"0.62749374",
"0.6266611",
"0.6265745",
"0.62323743",
"0.6222894",
"0.61837536",
"0.61808753",
"0.61800814",
"0.6175482",
"0.61749345",
"0.61749345",
"0.61744773",
"0.61539984",
"0.61434364",
"0.614192",
"0.613185",
"0.61275125",
"0.61262625",
"0.6117335",
"0.6116933",
"0.61103314",
"0.61102664",
"0.61045706",
"0.6082842",
"0.606571",
"0.6062719",
"0.60564333",
"0.6050794",
"0.6050059",
"0.6046121",
"0.60454303",
"0.6041476",
"0.60294926",
"0.6029368",
"0.6025721",
"0.60242677",
"0.6003944",
"0.59837186",
"0.598051",
"0.5971766",
"0.5969355",
"0.5965417",
"0.5959431",
"0.59452087",
"0.5938086",
"0.5934431",
"0.59323466",
"0.59307224",
"0.59290045",
"0.59265524",
"0.59215695",
"0.59188384"
] | 0.7433148 | 0 |
PATCH/PUT /favorite_tweets/1 PATCH/PUT /favorite_tweets/1.json | def update
respond_to do |format|
if @favorite_tweet.update(favorite_tweet_params)
format.html { redirect_to @favorite_tweet, notice: 'Favorite tweet was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @favorite_tweet.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n if @tweet.update_attributes(params[:tweet])\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n if @tweet.update_attributes(params[:tweet])\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n if @tweet.update_attributes(params[:tweet])\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # Add in this #MDM\n @tweet = Tweet.find(params[:id]) \n \n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tweet.update(tweet_params)\n respond_with(@tweet)\n end",
"def update\n respond_to do |format|\n if tweet.save\n format.html { redirect_to tweets_path, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: tweet }\n else\n format.html { render :edit }\n format.json { render json: tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(tweet)\n client.update tweet\n end",
"def update\n respond_to do |format|\n if @tweet.update_attributes(params[:tweet])\n format.html { redirect_to user_tweet_path(@user, @tweet), notice: 'Tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @retweet = Retweet.find(params[:id])\n\n respond_to do |format|\n if @retweet.update_attributes(params[:retweet])\n format.html { redirect_to @retweet, notice: 'Retweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @retweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @tweet.update(tweet_params)\n\t\t\t\tformat.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @tweet }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @tweet.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: \"Tweet was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: \"Tweet was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: \"Tweet was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n @tweet.assign_attributes(tweet_params)\n @tweet.uuid = session[:uid]\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n check_tweet_for_user\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favorite = Favorite.find(params[:id])\n\n respond_to do |format|\n if @favorite.update_attributes(params[:favorite])\n format.html { redirect_to @favorite, notice: 'Favorite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favorite = Favorite.find(params[:id])\n\n respond_to do |format|\n if @favorite.update_attributes(params[:favorite])\n format.html { redirect_to @favorite, notice: 'Favorite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @tweet.update(tweet_params)\r\n format.html { redirect_to @tweet, notice: \"Tweet was successfully updated.\" }\r\n format.json { render :show, status: :ok, location: @tweet }\r\n else\r\n format.html { render :edit, status: :unprocessable_entity }\r\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @new_tweet.update(new_tweet_params)\n format.html { redirect_to @new_tweet, notice: 'New tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @new_tweet }\n else\n format.html { render :edit }\n format.json { render json: @new_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favoritetweet = Favoritetweet.find(params[:id])\n\n respond_to do |format|\n if @favoritetweet.update_attributes(params[:favoritetweet])\n format.html { redirect_to(@favoritetweet, :notice => 'Favoritetweet was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @favoritetweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @tweet.update(tweet_params)\r\n format.html { redirect_to @tweet}\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def set_favorite_tweet\n @favorite_tweet = FavoriteTweet.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @favorite.update(favorite_params)\n format.html { redirect_to @favorite, notice: 'Favorite was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite }\n else\n format.html { render :edit }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite.update(favorite_params)\n format.html { redirect_to @favorite, notice: 'Favorite was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite }\n else\n format.html { render :edit }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite.update(favorite_params)\n format.html { redirect_to @favorite, notice: 'Favorite was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite }\n else\n format.html { render :edit }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @retweet.update(tweet_params)\n format.html { redirect_to retweets_path, notice: 'Retweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @retweet }\n else\n format.html { render :edit }\n format.json { render json: @retweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trash_tweet.update(trash_tweet_params)\n format.html { redirect_to @trash_tweet, notice: 'Trash tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @trash_tweet }\n else\n format.html { render :edit }\n format.json { render json: @trash_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favorite_template.update(favorite_template_params)\n render json: @favorite_template\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweetaro_params)\n format.html { redirect_to @tweet, notice: 'Tweetを更新しました。' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweett.update(tweett_params)\n format.html { redirect_to @tweett, notice: 'Tweett was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweett }\n else\n format.html { render :edit }\n format.json { render json: @tweett.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @tweet.user == current_user\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: \"Tweet was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to root_path, notice: \"You did not tweeted this tweet!\"\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to root_path, notice: 'ツーイトの編集が完了しました。' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tweeter = Tweeter.find(params[:id])\n\n respond_to do |format|\n if @tweeter.update_attributes(params[:tweeter])\n format.html { redirect_to @tweeter, notice: 'Tweeter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweeter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: '編集しました' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite.update_attributes(params[:favorite])\n format.html { redirect_to(favorites_path, :notice => 'Favorite was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n if params.has_key? :like\n @client.put(\"/me/favorites/#{params[:id]}\")\n head :ok and return\n end\n\n if params.has_key? :unlike\n @client.delete(\"/me/favorites/#{params[:id]}\")\n head :ok and return\n end\n\n if params.has_key? :repost\n @client.put(\"/me/track_reposts/#{params[:id]}\")\n head :ok and return\n end\n\n if params.has_key? :unpost\n @client.delete(\"/me/track_reposts/#{params[:id]}\")\n head :ok and return\n end\n\n head :bad_request\n end",
"def update\n @favorite = Favorite.find(params[:id])\n\n respond_to do |format|\n if @favorite.update_attributes(params[:favorite])\n format.html { redirect_to(favorites_url, :notice => 'Favorite was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @favorite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @favorite.update(favorite_params)\n render :show, status: :ok\n else\n render json: @favorite.errors, status: :unprocessable_entity\n end\n end",
"def update\n \t@project = Project.find(params[:project_id])\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n if @tweet.update_attributes(params[:tweet])\n format.html { redirect_to(project_tweet_path(@project,@tweet), :notice => 'Tweet was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n signin_apikey\n if session[:user_id] != nil\n if @tweet.user_id.to_s == session[:user_id].to_s\n respond_to do |format|\n if @tweet.update(tweet_update_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully edited.' }\n format.json { render json: @tweet, status: 200 }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.json { render json: {message: 'Forbidden, you can\\'t edit a tweet that is not yours' }, status: 403 }\n end\n end\n else\n respond_to do |format|\n format.json { render json: {message: 'Unauthorized, you don\\'t have a valid api_key' }, status: 401 }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite_recipe.update(favorite_recipe_params)\n format.html { redirect_to @favorite_recipe, notice: 'Favorite recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite_recipe }\n else\n format.html { render :edit }\n format.json { render json: @favorite_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tweetsandwich = Tweetsandwich.find(params[:id])\n\n respond_to do |format|\n if @tweetsandwich.update_attributes(params[:tweetsandwich])\n format.html { redirect_to @tweetsandwich, notice: 'Tweetsandwich was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweetsandwich.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_with Favor.update(params[:id], params[:favor])\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.js\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_my_favorites\n\t\tif @user.update_attributes(my_favorite: params[:my_favorite])\n\t\t# response to the JSON\n\t\t\trender json: { success: true,message: \"My favorites Successfully Updated.\", response: {my_favorite: @user.my_favorite} },:status=>200\n\t else\n\t render :json=> { success: false, message: @user.errors },:status=> 203\n\t end\t\n\tend",
"def update\n respond_to do |format|\n if @tweeeet.update(tweeeet_params)\n format.html { redirect_to @tweeeet, notice: 'Tweet actualizado con éxito!' }\n format.json { render :show, status: :ok, location: @tweeeet }\n else\n format.html { render :edit }\n format.json { render json: @tweeeet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fr_tweet.update(fr_tweet_params)\n format.html { redirect_to @fr_tweet, notice: 'Fr tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @fr_tweet }\n else\n format.html { render :edit }\n format.json { render json: @fr_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @favourite.update(favourite_params)\n format.html { redirect_to @favourite, notice: 'Favourite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favourite.update(favourite_params)\n format.html { redirect_to @favourite, notice: 'Favourite was successfully updated.' }\n format.json { render :show, status: :ok, location: @favourite }\n else\n format.html { render :edit }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite_web_thing.update(favorite_web_thing_params)\n format.html { redirect_to @favorite_web_thing, notice: 'Favorite web thing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @favorite_web_thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favourite.update(favourite_params)\n format.html { redirect_to @favourite, notice: \"Favourite was successfully updated.\" }\n format.json { render :show, status: :ok, location: @favourite }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favor = Favor.find(params[:id])\n\n respond_to do |format|\n if @favor.update_attributes(params[:favor])\n format.html { redirect_to @favor, notice: 'Favor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tweet(id)\n RawTweet.update(id, is_processed: true)\n end",
"def update\n respond_to do |format|\n if @change_table_tweet_info.update(change_table_tweet_info_params)\n format.html { redirect_to @change_table_tweet_info, notice: 'Change table tweet info was successfully updated.' }\n format.json { render :show, status: :ok, location: @change_table_tweet_info }\n else\n format.html { render :edit }\n format.json { render json: @change_table_tweet_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @avatar_tweet = AvatarTweet.find(params[:id])\n\n respond_to do |format|\n if @avatar_tweet.update_attributes(params[:avatar_tweet])\n format.html { redirect_to(@avatar_tweet, :notice => 'Avatar tweet was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @avatar_tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet_post.update(tweet_post_params)\n format.html { redirect_to @tweet_post, notice: \"Tweet post was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tweet_post }\n \n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tweet_post.errors, status: :unprocessable_entity }\n \n end\n end\n end",
"def update\n @fav = Fav.find(params[:id])\n\n respond_to do |format|\n if @fav.update_attributes(params[:fav])\n format.html { redirect_to @fav, notice: 'Fav was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fav.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweeter.update(tweeter_params)\n format.html { redirect_to @tweeter, notice: 'Tweeter was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweeter }\n else\n format.html { render :edit }\n format.json { render json: @tweeter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @favorite_route.update(favorite_route_params)\n render json: @favorite_route, status: :ok, location: @favorite_route\n else\n render json: @favorite_route.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @list_favorite.update(list_favorite_params)\n format.html { redirect_to @list_favorite, notice: 'Lista favoritos foi atualizada!' }\n format.json { render :show, status: :ok, location: @list_favorite }\n else\n format.html { render :edit }\n format.json { render json: @list_favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favorite_bundle = FavoriteBundle.find(params[:id])\n\n respond_to do |format|\n if @favorite_bundle.update_attributes(params[:favorite_bundle])\n format.html { redirect_to @favorite_bundle, notice: 'Favorite bundle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favorite_bundle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if params == [:tweet_id,:id]\n @tweet = Tweet.find(params[:tweet_id])\n @actor_tweet = ActorTweet.find(params[:id])\n respond_to do |format|\n if @actor_tweet.update(actor_tweet_params)\n format.html { redirect_to @actor_tweets, notice: 'Actor tweet actualizado correctamente.' }\n format.json { render :show, status: :ok, location: @actor_tweet }\n else\n format.html { render :edit }\n format.json { render json: @actor_tweet.errors, status: :unprocessable_entity }\n end\n end\n end\n if params == [:actor_id,:id]\n @actors = Actor.find(params[:actor_id])\n @actor_tweet = ActorTweet.find(params[:id])\n respond_to do |format|\n if @actor_tweet.update(actor_tweet_params)\n format.html { redirect_to @actor_tweets, notice: 'Actor tweet actualizado correctamente.' }\n format.json { render :show, status: :ok, location: @actor_tweet }\n else\n format.html { render :edit }\n format.json { render json: @actor_tweet.errors, status: :unprocessable_entity }\n end\n end\n end\n\n end",
"def update\n respond_to do |format|\n if @favorite_item.update(favorite_item_params)\n format.html { redirect_to @favorite_item, notice: t('.notice') }\n format.json { render :show, status: :ok, location: @favorite_item }\n else\n format.html { render :edit }\n format.json { render json: @favorite_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_api\n \t@task = Task.find(params[:id])\n \tcurrent_user\n \t@favorite = Favorite.find(@task.favorite_id)\n\n respond_to do |format|\n format.js { render 'demo/update_api' }\n end\n end",
"def update\n req = ActiveSupport::JSON.decode(request.body)\n @bookmark = Bookmark.find(req)\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:id])\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render json: @bookmark, status: :created, location: @bookmarks }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t# find our post\n\t\tid = params[:id]\n\t\t@post = Post.find(id)\n\n\t\t# increment the number of votes\n\t\tif params[:tweet] == \"true\"\n\t\t\t@post.votes = @post.votes + 1\n\t\t\t@post.save\n\t\telsif params[:flagged] == \"true\"\n\t\t\t@post.flagged = @post.flagged + 1\n\t\t\t@post.save\n\t\tend\n\t\t\n\t\t# TODO: ask Tom what this does again\n\t\trender :json => @post\n\tend",
"def update\n respond_to do |format|\n if @tweet_collection.update(tweet_collection_params)\n format.html { redirect_to @tweet_collection, notice: 'Tweet collection was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet_collection }\n else\n format.html { render :edit }\n format.json { render json: @tweet_collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if current_user.id==@tweet.user_id\n \n \n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n elsif current_user.id!=@tweet.user_id\n \n\n \n redirect_to tweets_url, {notice: 'You Cannot update the tweet since you are not the author :p .'}\n end\n\n end",
"def update\n @favourites = Favourite.find(params[:id])\n\n respond_to do |format|\n if @favourites.update_attributes(params[:favourites])\n flash[:notice] = 'Favourites was successfully updated.'\n format.html { redirect_to(@favourites) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @favourites.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @auction_favorite.update(auction_favorite_params)\n format.html { redirect_to @auction_favorite, notice: 'Favorite was successfully updated.' }\n format.json { render :show, status: :ok, location: @auction_favorite }\n else\n format.html { render :edit }\n format.json { render json: @auction_favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @twitter_user = TwitterUser.find(params[:id])\n\n respond_to do |format|\n if @twitter_user.update_attributes(params[:twitter_user])\n format.html { redirect_to @twitter_user, notice: 'Twitter user was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @twitter_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @twee.update(twee_params)\n format.html { redirect_to @twee, notice: 'Twee was successfully updated.' }\n format.json { render :show, status: :ok, location: @twee }\n else\n format.html { render :edit }\n format.json { render json: @twee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favourite = Favourite.find(params[:id])\n\n respond_to do |format|\n if @favourite.update_attributes(params[:favourite])\n flash[:notice] = 'Favourite was successfully updated.'\n format.html { redirect_to(@favourite) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @favourite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @twizzle.update(twizzle_params)\n format.html { redirect_to @twizzle, notice: 'Twizzle was successfully updated.' }\n format.json { render :show, status: :ok, location: @twizzle }\n else\n format.html { render :edit }\n format.json { render json: @twizzle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweet_new_tweet(tweet)\n #setup twitter client\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = $consumer_key\n config.consumer_secret = $consumer_secret\n config.access_token = $access_token\n config.access_token_secret = $access_token_secret\n end\n\n $log.debug(tweet)\n client.update(tweet)\n $log.info(\"Successfully tweeted!\")\nend",
"def update\n @twitter_list = TwitterList.find(params[:id])\n\n respond_to do |format|\n if @twitter_list.update_attributes(params[:twitter_list])\n format.html { redirect_to @twitter_list, notice: 'Twitter list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @twitter_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_scheme_favorite.update(user_scheme_favorite_params)\n format.html { redirect_to @user_scheme_favorite, notice: 'User scheme favorite was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_scheme_favorite }\n else\n format.html { render :edit }\n format.json { render json: @user_scheme_favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @search_tweet = SearchTweet.find(params[:id])\n\n respond_to do |format|\n if @search_tweet.update_attributes(params[:search_tweet])\n format.html { redirect_to(@search_tweet, :notice => 'Search tweet was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @search_tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tweets_chosen_thread = TweetsChosenThread.find(params[:id])\n\n respond_to do |format|\n if @tweets_chosen_thread.update_attributes(params[:tweets_chosen_thread])\n format.html { redirect_to(@tweets_chosen_thread, :notice => 'TweetsChosenThread was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tweets_chosen_thread.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tweets_chosen_thread = TweetsChosenThread.find(params[:id])\n\n respond_to do |format|\n if @tweets_chosen_thread.update_attributes(params[:tweets_chosen_thread])\n format.html { redirect_to(@tweets_chosen_thread, :notice => 'TweetsChosenThread was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tweets_chosen_thread.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite_quotes.update(favorite_quote_params)\n format.html { redirect_to @favorite_quote, notice: 'Favorite quote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @favorite_quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_notes(favorite_token)\n return unless notes.any?\n\n notes.each do |note|\n note.update_attribute(:favorite, favorite_token)\n end\n end",
"def update\n @favorite_flyer = FavoriteFlyer.find(params[:id])\n\n respond_to do |format|\n if @favorite_flyer.update_attributes(params[:favorite_flyer])\n format.html { redirect_to @favorite_flyer, notice: 'Favorite flyer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favorite_flyer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favorito = Favorito.find(params[:id])\n\n respond_to do |format|\n if @favorito.update_attributes(params[:favorito])\n format.html { redirect_to @favorito, notice: 'Favorito was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favorito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweet(tweet)\n\t\tclient = Twitter::REST::Client.new do |config|\n\t\tconfig.consumer_key = Rails.application.config.twitter_key\n\t\tconfig.consumer_secret = Rails.application.config.twitter_secret\n\t\tconfig.access_token = oauth_token\n\t\tconfig.access_token_secret = oauth_secret\n\tend\n\tclient.update(tweet)\n\tend",
"def update\n respond_to do |format|\n if @favourites_recipe.update(favourites_recipe_params)\n format.html { redirect_to @favourites_recipe, notice: 'Favourites recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @favourites_recipe }\n else\n format.html { render :edit }\n format.json { render json: @favourites_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @shops_favorite = ShopsFavorite.find(params[:id])\n\n respond_to do |format|\n if @shops_favorite.update_attributes(params[:shops_favorite])\n format.html { redirect_to(@shops_favorite, :notice => 'Shops favorite was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shops_favorite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Like.update(params[\"id\"], params[\"like\"])\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n @tweet.user_vote = 0\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def update\n @micropost = Micropost.find(params[:micropost_id])\n current_user.retweet(@micropost)\n respond_to do |format|\n format.html { redirect_to \"/static_pages/home\"}\n format.js\n end\n end",
"def update\n respond_to do |format|\n if @favoritepizza.update(favoritepizza_params)\n format.html { redirect_to @favoritepizza, notice: 'Favoritepizza was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @favoritepizza.errors, status: :unprocessable_entity }\n end\n end\n end",
"def change_favorite_status\r\n\t\t\tProject.update_favorite_status params[:id], params[:is_favorite]\r\n\r\n\t\t\trender json: { status: 0 }\r\n\t\tend",
"def favorite\n tweet_id=params[:tuit_id]\n client.favorite(tweet_id) unless tweet_id == nil\n respond_to do |format|\n format.html { }\n\t format.json { head :no_content }\n\t format.js\n end\n end"
] | [
"0.6960678",
"0.6960678",
"0.6960678",
"0.69604725",
"0.69222766",
"0.69034183",
"0.6883614",
"0.68249536",
"0.6781655",
"0.6781655",
"0.6781655",
"0.6781655",
"0.6761557",
"0.675751",
"0.67472273",
"0.67472273",
"0.67472273",
"0.6719685",
"0.6706669",
"0.67002296",
"0.66891885",
"0.66891885",
"0.6685029",
"0.6681585",
"0.66506433",
"0.66347116",
"0.6602308",
"0.6597894",
"0.6592498",
"0.6592498",
"0.6592498",
"0.65713954",
"0.65503037",
"0.6542265",
"0.65285796",
"0.65200925",
"0.65103155",
"0.6495321",
"0.6464247",
"0.64564705",
"0.64501876",
"0.64309",
"0.6393346",
"0.63733065",
"0.63501805",
"0.6330941",
"0.632368",
"0.6300768",
"0.62966293",
"0.62902844",
"0.6284753",
"0.6274847",
"0.6220454",
"0.62091565",
"0.62022066",
"0.6196464",
"0.61725163",
"0.6164634",
"0.615187",
"0.61357445",
"0.61211663",
"0.6118975",
"0.611396",
"0.611234",
"0.6107515",
"0.6094453",
"0.60930866",
"0.6080584",
"0.6069635",
"0.60647494",
"0.60590816",
"0.60571814",
"0.60499245",
"0.60428673",
"0.6035283",
"0.60335696",
"0.6029016",
"0.6001438",
"0.59956247",
"0.59784776",
"0.5977903",
"0.5967888",
"0.59646827",
"0.5959502",
"0.59563655",
"0.59563655",
"0.5956065",
"0.594631",
"0.59447825",
"0.5941823",
"0.5938875",
"0.59335816",
"0.5933122",
"0.5930038",
"0.5925339",
"0.592305",
"0.5920236",
"0.5915982",
"0.59079355",
"0.5907137"
] | 0.75267 | 0 |
DELETE /favorite_tweets/1 DELETE /favorite_tweets/1.json | def destroy
TwitterSyncWorker.new.delete(session[:user_id], @favorite_tweet.id)
@favorite_tweet.destroy
respond_to do |format|
format.html { redirect_to request.referer }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n user = user_from_token\n user.tweets.destroy(params[:id])\n head :no_content\n end",
"def destroy\n @interesting_tweet.destroy\n respond_to do |format|\n format.html { redirect_to interesting_tweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favoritetweet = Favoritetweet.find(params[:id])\n @favoritetweet.destroy\n\n respond_to do |format|\n format.html { redirect_to(favoritetweets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tweet = Tweet.find(params[:id])\n @tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to tweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet = Tweet.find(params[:id])\n @tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to tweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to tweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy_favorite(id)\n delete \"favorites/destroy/#{id}\"\n end",
"def destroy\n tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_path, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet = Tweet.find(params[:id])\n @tweet.delete_tweet_keep_sub_tweets\n @tweet.reload\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_back fallback_location: root_path, notice: 'ツーイトの削除が完了しました。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: '削除しました' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite = Favorite.find(params[:id])\n @favorite.destroy\n\n respond_to do |format|\n format.html { redirect_to favorites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet = Tweet.find(params[:id])\n @tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to(tweets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n death = []\r\n death << Retweet.where(tweet_id: @tweet.id)\r\n death.flatten!\r\n death.each do |die|\r\n die.destroy\r\n end\r\n\r\n @tweet.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to tweets_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @retweet = Retweet.find(params[:id])\n @retweet.destroy\n\n respond_to do |format|\n format.html { redirect_to retweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweeeet.destroy\n respond_to do |format|\n format.html { redirect_to tweeeets_url, notice: 'Tweet eliminado con éxito!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: \"Tweet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: \"Tweet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: \"Tweet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: \"Tweet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: \"Tweet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n check_tweet_for_user\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @tweet.destroy\r\n respond_to do |format|\r\n format.html { redirect_to tweets_url, notice: \"Tweet was successfully destroyed.\" }\r\n format.json { head :no_content }\r\n end \r\n end",
"def destroy\n respond_to do |format|\n begin\n @tweet = TweetApp::ClientContext.status(:delete, params[:id])\n flash[:message] = \"Tweet with id #{params[:id]} was deleted from Twitter\"\n format.html { redirect_to tweets_url }\n format.json { head :ok }\n format.xml { head :ok }\n rescue Twitter::RESTError => re\n handle_rest_error(re, format)\n end\n end\n end",
"def destroy\n @trash_tweet.destroy\n respond_to do |format|\n format.html { redirect_to trash_tweets_url, notice: 'Trash tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet = Tweet.find(params[:id])\n\n if @tweet.user_id == session[:user_id]\n @tweet.retweets.destroy_all\n\n @tweet.destroy\n else\n flash[:notice] = \"Tweet can not be deleted\"\n end\n\n respond_to do |format|\n format.html { redirect_to tweets_url }\n format.json { head :no_content }\n end \n end",
"def destroy\n @tweet.destroy\n redirect_to tweets_path\n #respond_to do |format|\n #format.html { redirect_to tweets_url }\n #format.json { head :no_content }\n #end\n end",
"def destroy\n @avatar_tweet = AvatarTweet.find(params[:id])\n @avatar_tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to(avatar_tweets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @favorite.destroy\n respond_to do |format|\n format.html { redirect_to favorites_url, notice: 'Favorite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite.destroy\n respond_to do |format|\n format.html { redirect_to favorites_url, notice: 'Favorite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite.destroy\n respond_to do |format|\n format.html { redirect_to favorites_url, notice: 'Favorite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = @favourite.fav_post\n @favourite.destroy\n sync_update @post\n respond_to do |format|\n format.html { redirect_to :my_favourites, notice: 'Favourite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite.destroy\n\n head :no_content\n end",
"def destroy\n @new_tweet.destroy\n respond_to do |format|\n format.html { redirect_to new_tweets_url, notice: 'New tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweetaros_url, notice: 'Tweetを削除しました。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_with(@tweet)\n end",
"def destroy\n @favorite = Favorite.find(params[:id])\n @favorite.destroy\n\n respond_to do |format|\n format.html { redirect_to(favorites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @actor_tweet.destroy\n respond_to do |format|\n format.html { redirect_to @tweet, notice: 'Actor tweet eliminado correctamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @zweet.destroy\n respond_to do |format|\n format.html { redirect_to zweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite = Favorite.find(params[:id])\n @favorite.destroy\n\n respond_to do |format|\n format.html { redirect_to favorites_url , notice: '削除しました。'}\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite.destroy\n respond_to do |format|\n format.html { redirect_to favorites_url, notice: 'Favorito quitado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweeter = Tweeter.find(params[:id])\n @tweeter.destroy\n\n respond_to do |format|\n format.html { redirect_to tweeters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweetsandwich = Tweetsandwich.find(params[:id])\n @tweetsandwich.destroy\n\n respond_to do |format|\n format.html { redirect_to tweetsandwiches_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twitter_id = TwitterId.find(params[:id])\n @twitter_id.destroy\n\n respond_to do |format|\n format.html { redirect_to twitter_ids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fr_tweet.destroy\n respond_to do |format|\n format.html { redirect_to fr_tweets_url, notice: 'Fr tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @retweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Retweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweett.destroy\n respond_to do |format|\n format.html { redirect_to tweetts_url, notice: 'Tweett was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n run Tweet::Delete\n\n flash[:alert] = \"Tweet deleted\"\n redirect_to tweets_path\n end",
"def destroy\n @favorite_web_thing.destroy\n respond_to do |format|\n format.html { redirect_to favorite_web_things_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@tweet.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n respond_with favorites.first!.destroy\n end",
"def destroy\n #deletes selected tweet\n @tweet.destroy\n\n #After tweet is deleted, redirects back to the main tweet URL\n #Also, adds a notice to let the user know the tweet was deleted\n respond_to do |format |\n format.html {redirect_to tweets_url, notice: \"Post was deleted\" }\n end\n\n end",
"def destroy\n favor = Favor.where(:user_id => params[:user_id], :post_id => params[:post_id])\n favor.destroy\n render :json => {:ok => true}, :head => :no_content\n end",
"def destroy\n @favorite_quotes.destroy\n respond_to do |format|\n format.html { redirect_to favorite_quotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list_favorite.destroy\n respond_to do |format|\n format.html { redirect_to list_favorites_url, notice: 'Lista removida dos favoritos!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favor = Favor.find(params[:id])\n @favor.destroy\n\n respond_to do |format|\n format.html { redirect_to favors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourites = Favourite.find(params[:id])\n @favourites.destroy\n\n respond_to do |format|\n format.html { redirect_to(favourites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @favor.destroy\n\n respond_to do |format|\n format.html { redirect_to favors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourite.destroy\n respond_to do |format|\n format.html { redirect_to favourites_url, notice: \"Favourite was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourite.destroy\n respond_to do |format|\n format.html { redirect_to favourites_url, notice: 'Favourite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite_thesis.destroy\n respond_to do |format|\n format.html { redirect_to favorite_theses_url, notice: 'Favorite these was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def unfavorite_tweet(tweet)\n favorite_tweets.delete(tweet)\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to \"/timeline\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n # Add in this #MDM\n # Use current_user below, so that new tweets are only created by the logged in user #MDM\n # @tweet = Tweet.find(params[:id])\n @tweet = current_user.tweets.find(params[:id])\n \n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def unfavorite(id)\n post(\"/favorites/destroy/#{id}.json\")\n end",
"def destroy\n @favourite.destroy\n respond_to do |format|\n format.html { redirect_to @favourite }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourite = Favourite.find(params[:id])\n @favourite.destroy\n\n respond_to do |format|\n format.html { redirect_to(favourites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tweet_db.destroy\n respond_to do |format|\n format.html { redirect_to tweet_dbs_url, notice: 'Tweet db was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet_post.destroy\n respond_to do |format|\n format.html { redirect_to tweet_posts_url, notice: \"Tweet post was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @qweet.destroy\n respond_to do |format|\n format.html { redirect_to qweets_url, notice: \"Qweet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twitter_list = TwitterList.find(params[:id])\n @twitter_list.destroy\n\n respond_to do |format|\n format.html { redirect_to twitter_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @search_tweet = SearchTweet.find(params[:id])\n @search_tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to(search_tweets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @favorite_recipe.destroy\n respond_to do |format|\n format.html { redirect_to favorite_recipes_url, notice: 'Favorite recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fav = Fav.find(params[:id])\n @fav.destroy\n\n respond_to do |format|\n format.html { redirect_to favs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @favorite_restaurant.destroy\n respond_to do |format|\n format.html { redirect_to favorite_restaurants_url, notice: 'Favorite restaurant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = current_user\n @FavoriteMovie = FavoriteMovie.find(params[:id]).delete\n render json: { msg: \"Delete Successful\" }\n end",
"def destroy\n @favorite_dish.destroy\n respond_to do |format|\n format.html { redirect_to favorite_dishes_url, notice: 'Favorite dish was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twitter_user = TwitterUser.find(params[:id])\n @twitter_user.destroy\n\n respond_to do |format|\n format.html { redirect_to twitter_users_url }\n format.json { head :ok }\n end\n end",
"def delete_from_favorites(word, *args)\n http_method = :delete\n path = '/word/{word}/favorite'\n path.sub!('{word}', word.to_s)\n\n # Ruby turns all key-value arguments at the end into a single hash\n # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')\n # becomes {:limit => 10, :part_of_speech => 'verb'}\n last_arg = args.pop if args.last.is_a?(Hash)\n last_arg = args.pop if args.last.is_a?(Array)\n last_arg ||= {}\n\n # Look for a kwarg called :request_only, whose presence indicates\n # that we want the request itself back, not the response body\n if last_arg.is_a?(Hash) && last_arg[:request_only].present?\n request_only = true\n last_arg.delete(:request_only)\n end\n\n params = last_arg\n body ||= {}\n request = Wordnik::Request.new(http_method, path, :params => params, :body => body)\n request_only ? request : request.response.body\n end",
"def destroy\n @user_follower = UserFollower.find(:first, :conditions => {:user_id => params[:id], :follower_id => params[:user_id]})\n @user_follower.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_tweets_path(current_user)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tweet_store.destroy\n respond_to do |format|\n format.html { redirect_to tweet_stores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite_flyer = FavoriteFlyer.find(params[:id])\n @favorite_flyer.destroy\n\n respond_to do |format|\n format.html { redirect_to favorite_flyers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hearted.destroy\n respond_to do |format|\n format.html { redirect_to hearteds_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Like.delete(params[\"id\"])\n end",
"def destroy\n @favourite_food = FavouriteFood.find(params[:id])\n @favourite_food.destroy\n\n respond_to do |format|\n format.html { redirect_to favourite_foods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @auction_favorite.destroy\n respond_to do |format|\n format.html { redirect_to auction_favorites_url, notice: 'Favorite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twizzle.destroy\n respond_to do |format|\n format.html { redirect_to twizzles_url, notice: 'Twizzle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shops_favorite = ShopsFavorite.find(params[:id])\n @shops_favorite.destroy\n\n respond_to do |format|\n format.html { redirect_to(shops_favorites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shop_favorite.destroy\n respond_to do |format|\n format.html { restore_last_request(notice: 'Shop favorite was successfully deleted.') }\n format.json { head :no_content }\n end\n end",
"def remove_favorite_food(food_id)\n delete(\"/user/#{@user_id}/foods/favorite/#{food_id}.json\")\n end",
"def destroy\n @favorite_image.destroy\n respond_to do |format|\n format.html { redirect_to favorite_images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twenty.destroy\n respond_to do |format|\n format.html { redirect_to twenties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favoritepizza.destroy\n respond_to do |format|\n format.html { redirect_to favoritepizzas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourites_recipe.destroy\n respond_to do |format|\n format.html { redirect_to favourites_recipes_url, notice: 'Favourites recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.73611623",
"0.7237081",
"0.72364336",
"0.72051394",
"0.72051394",
"0.71854454",
"0.71765554",
"0.714541",
"0.7023002",
"0.70183814",
"0.69963676",
"0.6993292",
"0.69846225",
"0.6979157",
"0.69612306",
"0.6947594",
"0.6946989",
"0.6946989",
"0.6946989",
"0.6946989",
"0.6946989",
"0.6946989",
"0.69420224",
"0.69420224",
"0.69420224",
"0.69420224",
"0.69420224",
"0.6928122",
"0.691677",
"0.69133294",
"0.69060254",
"0.6899364",
"0.6885085",
"0.68573016",
"0.68410635",
"0.68410635",
"0.68410635",
"0.68409294",
"0.68384284",
"0.68268675",
"0.68233776",
"0.6801579",
"0.6793632",
"0.67853314",
"0.67822963",
"0.6776026",
"0.67731714",
"0.6770312",
"0.67634",
"0.6758967",
"0.67358756",
"0.6732823",
"0.6727291",
"0.671315",
"0.66852885",
"0.6675343",
"0.66542506",
"0.66540104",
"0.66479313",
"0.6633438",
"0.66322345",
"0.6625864",
"0.6621781",
"0.6621037",
"0.66094935",
"0.6604341",
"0.65921205",
"0.65770555",
"0.6576102",
"0.6567496",
"0.6547708",
"0.6545036",
"0.6544936",
"0.65330905",
"0.65224004",
"0.6521478",
"0.6520642",
"0.65200365",
"0.6516257",
"0.65062535",
"0.6501373",
"0.64997214",
"0.6466997",
"0.6459087",
"0.645775",
"0.64542955",
"0.6452869",
"0.64524734",
"0.64510864",
"0.6449986",
"0.6447145",
"0.64449126",
"0.64307237",
"0.64204586",
"0.6414442",
"0.64005655",
"0.63986933",
"0.63923717",
"0.6392234",
"0.63856703"
] | 0.7240167 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_favorite_tweet
@favorite_tweet = FavoriteTweet.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def set_actions\n actions :all\n end",
"def define_action_helpers?; end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def _handle_action_missing(*args); end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def duas1(action)\n action.call\n action.call\nend"
] | [
"0.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.53312254",
"0.53121567",
"0.52971965",
"0.52964705",
"0.52956307",
"0.52587366",
"0.52450675",
"0.5237777",
"0.5237777",
"0.5237777",
"0.5237777",
"0.5237777",
"0.5233381",
"0.52325714",
"0.52288216",
"0.52229726",
"0.5218362",
"0.52142864",
"0.5207988",
"0.5206337",
"0.51762295",
"0.51745105",
"0.51728606",
"0.516616",
"0.5161016",
"0.5157393",
"0.5152562",
"0.51524293",
"0.5152397",
"0.5144533",
"0.513982",
"0.51342106",
"0.5113793",
"0.5113793",
"0.5113671",
"0.51092553",
"0.51062804",
"0.50921935",
"0.5088855",
"0.5082236",
"0.5079901",
"0.5066569",
"0.5055307",
"0.5053106",
"0.50499666",
"0.50499666",
"0.5035068",
"0.50258636",
"0.50220853",
"0.5015893",
"0.50134486",
"0.5001442",
"0.50005543",
"0.4998581",
"0.49901858",
"0.49901858",
"0.4986648",
"0.49809486",
"0.49792925",
"0.4978855",
"0.49685496",
"0.49656174",
"0.49576473",
"0.49563017",
"0.4955349",
"0.49536878",
"0.4952439",
"0.49460214",
"0.494239",
"0.49334687",
"0.49315962",
"0.49266812",
"0.49261138",
"0.4925925",
"0.4922542",
"0.4920779",
"0.49173284",
"0.49169463",
"0.4916256",
"0.49162322",
"0.49156886"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def favorite_tweet_params
params[:favorite_tweet]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def valid_params_request?; end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def list_params\n params.permit(:name)\n end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def url_whitelist; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end"
] | [
"0.69811666",
"0.6782836",
"0.6747644",
"0.6742015",
"0.6735273",
"0.6593917",
"0.65037674",
"0.6498627",
"0.6482372",
"0.64795715",
"0.64566946",
"0.6439213",
"0.6380714",
"0.6378147",
"0.63657266",
"0.63206697",
"0.6300169",
"0.62992156",
"0.6295538",
"0.62943023",
"0.62915146",
"0.6290595",
"0.62824667",
"0.62420255",
"0.62403506",
"0.6217174",
"0.6213706",
"0.62112075",
"0.6194868",
"0.6178784",
"0.6174678",
"0.6172499",
"0.61630744",
"0.61544263",
"0.615248",
"0.6147727",
"0.61221075",
"0.6119646",
"0.61076134",
"0.6106584",
"0.6094013",
"0.6081423",
"0.6071337",
"0.6063637",
"0.6021453",
"0.6018253",
"0.60161054",
"0.60112554",
"0.60071784",
"0.60071784",
"0.60004836",
"0.6000254",
"0.5999255",
"0.59930664",
"0.59919107",
"0.5991741",
"0.5980763",
"0.59663844",
"0.59605104",
"0.5960486",
"0.5959414",
"0.5957901",
"0.59538954",
"0.5953327",
"0.59450173",
"0.59391475",
"0.59391475",
"0.59386194",
"0.59351885",
"0.593139",
"0.5926316",
"0.5925927",
"0.59176016",
"0.59119296",
"0.5909275",
"0.5908221",
"0.59053046",
"0.58983994",
"0.58980995",
"0.58964473",
"0.5895902",
"0.5893993",
"0.58927304",
"0.5887752",
"0.58841616",
"0.5880381",
"0.58752084",
"0.586956",
"0.5868584",
"0.58679324",
"0.5867004",
"0.58667004",
"0.58642864",
"0.5863347",
"0.58626384",
"0.58615845",
"0.58594906",
"0.5854959",
"0.5854423",
"0.58506453",
"0.5850135"
] | 0.0 | -1 |
jobs Show recent and running jobs. l, limit LIMITJOBS Limit the number of jobs returned (defaults to 10) s, skip SKIPJOBS Skip a certain amount of jobs (defaults to 0) Examples: List the last 20 jobs: $ mortar jobs l 20 | def index
validate_arguments!
options[:limit] ||= '10'
options[:skip] ||= '0'
jobs = api.get_jobs(options[:skip], options[:limit]).body['jobs']
jobs.each do |job|
if job['start_timestamp']
job['start_timestamp'] = Time.parse(job['start_timestamp']).strftime('%A, %B %e, %Y, %l:%M %p')
end
end
headers = [ 'job_id', 'script' , 'status' , 'start_date' , 'elapsed_time' , 'cluster_size' , 'cluster_id']
columns = [ 'job_id', 'display_name', 'status_description', 'start_timestamp', 'duration', 'cluster_size', 'cluster_id']
display_table(jobs, columns, headers)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jobs(opts = {})\n api(\n @client.list_jobs(\n @project_id,\n deep_symbolize_keys(opts)\n )\n )\n end",
"def get_jobs_list(status = :all, page = 1, reload = false)\n Bitmovin::Job.list(status, page, reload)\n end",
"def jobs\n command('.jobs').split(\"\\n\")\n end",
"def jobs(opts = {})\n api(api_method: @bq.jobs.list,\n parameters: opts)\n end",
"def list_jobs(json_payload={})\n conn = @client.get do |req|\n req.url '/api/v2/job/list?'\n req.headers[\"Authorization\"] = @token\n req.params = json_payload\n end\n conn.body\n end",
"def show_recent_jobs\n\n max_jobs = \"\"\n\n # until max_jobs.to_i.between?(1, FreelancerFinder::Job.all.count)\n # puts \"#{FreelancerFinder::Job.all.count} Total Listings to Choose From!\".magenta\n # print \"How many jobs would you like to see?: \".blue\n # max_jobs = gets.chomp.downcase\n # end\n\n puts \"#{FreelancerFinder::Job.all.count} Total Listings to Choose From!\".magenta\n max_jobs = @prompt.slider('How many jobs would you like to see?', max: FreelancerFinder::Job.all.count, step: 10)\n\n max_jobs = max_jobs.to_i - 1\n\n jobs = []\n\n FreelancerFinder::Job.all.each.with_index do |job, index|\n jobs << job\n break if index >= max_jobs\n end\n\n jobs\n end",
"def listjobs(project=self.project)\n get('listjobs.json', project: project).reject{|k,v| k=='status'}\n end",
"def list_jobs(args)\n Morpheus::Cli::BackupJobsCommand.new.list(args)\n end",
"def display_jobs(jobs)\n\n clear_screen\n\n @last_results = jobs\n\n choices = []\n choices << {name: 'Return to Menu'.colorize(:magenta), value: 'menu'}\n choices << {name: 'Exit'.colorize(:red), value: 'exit'}\n\n choices += jobs.map.with_index(1) {|job, idx| {name: \"#{job.job_summary}\".colorize(:light_blue), value: idx} }\n jobSelection = prompt.select(\"Select a job posting (use the left and right arrows to navigate pages)\\n#{'_'*(@screen_size-1)} \".colorize(:white), choices, per_page: 35)\n\n if jobSelection == \"exit\"\n farewell_message\n exit\n elsif jobSelection == \"menu\"\n job = \"menu\"\n else\n job = jobs.find.with_index {|job, idx| jobSelection == idx }\n end\n\n\n return job\n end",
"def jobs\r\n end",
"def find_jobs(params:)\n response = HTTParty.get(\"#{@host}/api/jobs\", query: params)\n\n return response[\"jobs\"] \n end",
"def maxjobs\n runopts(:maxjobs)\n end",
"def jobs(params={})\n @radius = params[:radius] if params[:radius]\n @zipcode = params[:zipcode] if params[:zipcode]\n return @jobs if (@jobs && !params[:force])\n page = params[:page] || 1\n per_page = params[:per_page] || 100\n @jobs = get_jobs(page,per_page)\n end",
"def jobs\n\t\t# ...\n\tend",
"def all_jobs\n\n find_jobs()\n end",
"def index\n @jobs = PeriodicJob.list params[:page], current_user.row_limit\n end",
"def list_jobs all: nil, token: nil, max: nil, filter: nil, min_created_at: nil, max_created_at: nil,\n parent_job_id: nil\n # The list operation is considered idempotent\n min_creation_time = Convert.time_to_millis min_created_at\n max_creation_time = Convert.time_to_millis max_created_at\n execute backoff: true do\n service.list_jobs @project, all_users: all, max_results: max,\n page_token: token, projection: \"full\", state_filter: filter,\n min_creation_time: min_creation_time, max_creation_time: max_creation_time,\n parent_job_id: parent_job_id\n end\n end",
"def index\n @jobs = Job.all\n @paginated_jobs = @jobs.paginate(:page => params[:page], :per_page => Settings.Pagination.NoOfEntriesPerPage)\n end",
"def print_jobs_list(opts = {})\n data, _status_code, _headers = print_jobs_list_with_http_info(opts)\n data\n end",
"def last_20_jobs(project_id)\n api(\"projects/#{project_id}/jobs\").sort_by { |j| -j['id'] }\nend",
"def list_jobs\n jobs = if unsafe_params[:editable]\n Job.editable_by(@context).accessible_by_private\n else\n Job.accessible_by(@context)\n end\n\n if unsafe_params[:scopes].present?\n check_scope!\n jobs = jobs.where(scope: unsafe_params[:scopes])\n end\n\n if unsafe_params[:space_uid].present?\n jobs = jobs.terminal\n end\n\n result = jobs.eager_load(user: :org).order(id: :desc).map do |job|\n describe_for_api(job, unsafe_params[:describe])\n end\n\n render json: result\n end",
"def get_jobs(from, to)\n\n job_info = get_job_info(from)\n total_page = job_info[:x_total_pages].to_i\n new_to = (to == nil || to < total_page) ? to : total_page\n puts \">> total page : \" + total_page.to_s\n\n jobs = []\n (from..new_to).each do |page|\n job_api = \"#{BASE_URL}/v4/projects/#{PROJECT_ID}/jobs?page=#{page}&per_page=#{PER_PAGE}\"\n puts \">>start:page:\" + page.to_s\n\n begin\n response = RestClient::Request.new(\n :method => :get,\n :url => job_api,\n :verify_ssl => false,\n :headers => {\"PRIVATE-TOKEN\" => API_TOKEN}\n ).execute\n\n if response != nil && response.code == 200\n res = JSON.parse(response.to_str)\n jobs += res\n end\n\n rescue RestClient::ExceptionWithResponse => err\n puts \"jobs error: #{err.response}\"\n end\n end\n\n jobs\nend",
"def as_jobs\n @jobs ||= find_latest_completed_jobs\n end",
"def index\n @jobs = Job.all.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 3)\n end",
"def list(status = :all, page = 1, reload = false)\n var_name = :\"@#{status}_list#{ page }\"\n\n val = instance_variable_get var_name\n\n return val if val && !reload\n\n get = Net::HTTP::Get.new \"/api/jobs/#{ page }/#{ status }\", initheaders = headers\n\n response = Bitmovin.http.request get\n\n json = prepare_response_json(response.body)\n \n value_to_set = json[:jobs].map { |p| Bitmovin::Job.new(p) }\n\n instance_variable_set var_name, value_to_set\n end",
"def index\n @jobs = Job.page(params[:page])\n end",
"def jobs\n @jobs || {}\n end",
"def list_jobs(username, password, uuid = nil)\n jobs = get_json('jobs.json', username, password)\n puts \"\"\n jobs[\"jobs\"].each do |job|\n next if uuid && job['uuid'] != uuid\n if job['jobURL']\n job.merge!(get_json(job['jobURL'], username, password, ''))\n end\n puts summarise_job(job, 2)\n puts \"\"\n end\n del = jobs['delivered']\n puts \"#{del['jobCount']} jobs, #{del['activityCount']} activities delivered since #{del['since']}\"\nend",
"def index\n self.limit\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @jobs }\n end\n end",
"def jobs\r\n @parser.jobs\r\n end",
"def getCurrentJobs\n getJobs('0/')\n end",
"def index\n @jobs = Job.all\n end",
"def index\n @jobs = Job.with_hires(nil).all\n end",
"def display_jobs\n jobs = SearchJobs::Jobs.all\n\n jobs.each.with_index(1) do |job, index|\n puts \"#{index}.\".colorize(:red) + \"==========#{job.company.upcase.strip}=========\".colorize(:yellow)\n puts \"#{job.name.upcase}\".colorize(:blue)\n end\n end",
"def list\n puts \"\\n\\n#{Job.count} job postings found\\n\\n\"\n Job.list.map do |job|\n puts \"#{job.id}. #{job.firstline}\"\n end\n puts menu\n end",
"def index\n\t\t@page = 'browse'\n if params[:search].blank?\n\t\t case params[:type]\n\t\t\t\twhen \"featured\"\n\t\t\t\t\t@jobs = Job.featured\n when \"latest\"\n @jobs = Job.recently_submited(9)\n\t\t\t\twhen \"closed\"\n\t\t\t\t\t@jobs = Job.closed\n\t\t\t\telse\n\t\t\t\t\t@jobs = Job.open\n end\n else\n\t\t\t@page = 'search'\n @jobs = Job.active.find(:all, :conditions => ['role LIKE ? OR company LIKE ?', \"%#{params[:search]}%\", \"%#{params[:search]}%\"])\n\t\t\tif @jobs.empty?\n @page_header_line = \"Your search by <strong>#{h(params[:search])}</strong> did not return any job. Try a different search or <a href='#{jobs_url}'>go browse</a>.\"\n else\n @page_header_line = \"Your search by <strong>#{h(params[:search])}</strong> returned the following results: \"\n end\n end\n\n @jobs = @jobs.paginate :per_page => 10, :page => params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @jobs }\n end\n end",
"def jobs\n self.ListJobs.first.map { |j| map_job(j) }\n end",
"def list_jobs\n @glue_client.list_jobs\n rescue Aws::Glue::Errors::GlueException => e\n @logger.error(\"Glue could not list jobs: \\n#{e.message}\")\n raise\n end",
"def public_api_get_jobs(modified, api_key, opts = {})\n data, _status_code, _headers = public_api_get_jobs_with_http_info(modified, api_key, opts)\n return data\n end",
"def job(job_name)\n jobs job_name\n end",
"def possible_jobs\n \n\n job = params[:job].titleize\n location = params[:location].titleize\n\n results = Cb.job.search({ location: location,\n keywords: job })\n jobs = results.model.jobs\n @job_data = {\n job: job,\n location: location,\n job_results: jobs\n }\n end",
"def jobs\n @jobs ||= Beaneater::Jobs.new(self)\n end",
"def print_jobs_list_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PrintJobsApi.print_jobs_list ...'\n end\n # resource path\n local_var_path = '/print-jobs/'\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n query_params[:'created_after'] = opts[:'created_after'] if !opts[:'created_after'].nil?\n query_params[:'created_before'] = opts[:'created_before'] if !opts[:'created_before'].nil?\n query_params[:'modified_after'] = opts[:'modified_after'] if !opts[:'modified_after'].nil?\n query_params[:'modified_before'] = opts[:'modified_before'] if !opts[:'modified_before'].nil?\n query_params[:'id'] = opts[:'id'] if !opts[:'id'].nil?\n query_params[:'order_id'] = opts[:'order_id'] if !opts[:'order_id'].nil?\n query_params[:'exclude_line_items'] = opts[:'exclude_line_items'] if !opts[:'exclude_line_items'].nil?\n query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?\n query_params[:'ordering'] = opts[:'ordering'] if !opts[:'ordering'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Object')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PrintJobsApi#print_jobs_list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def workflow_run_jobs(repo, run_id, options = {})\n paginate \"#{Repository.path repo}/actions/runs/#{run_id}/jobs\", options do |data, last_response|\n data.jobs.concat last_response.data.jobs\n end\n end",
"def jobs\n raise NotImplementedError\n end",
"def index\n # TODO: Using .to_a \"preloads\" the query. Investigate if it's a good practice.\n # @jobs = Job.future.page(params[:page]).per_page(JOBS_PER_PAGE).to_a\n if month_filter = params[:month]\n @jobs = Job.in_this_years_month(month_filter)\n else\n @jobs = Job.future\n end\n @job_type_id = job_type_param\n @jobs = @jobs\n .job_type(@job_type_id)\n .page(page_query_param)\n .per_page(JOBS_PER_PAGE)\n if page_query_param > @jobs.total_pages\n redirect_to jobs_path(page: @jobs.total_pages,\n job_type: params[:job_type],\n month: params[:month])\n end\n end",
"def index\n if params[:my_job] == 'all jobs'\n @jobs = search_by_session(current_login.jobs.search(params[:search])).order(\"created_at desc\").paginate(:per_page => 10, :page => params[:page])\n elsif params[:my_job]== 'unassigned jobs'\n @jobs = search_by_session(current_login.jobs.search(params[:search]).where(:assigned_to => \"NULL\")).paginate(:per_page => 10, :page => params[:page])\n elsif params[:my_job] == 'my jobs'\n @jobs = search_by_session(current_login.jobs.search(params[:search]).where(\"status='open' AND assigned_to != 'NULL'\")).paginate(:per_page => 10, :page => params[:page])\n elsif params[:my_job] == 'closed jobs'\n @jobs = search_by_session(current_login.jobs.search(params[:search]).where(:status => \"closed\")).paginate(:per_page => 10, :page => params[:page])\n else\n @jobs = search_by_session(current_login.jobs.search(params[:search])).order(\"created_at desc\").paginate(:per_page => 10, :page => params[:page])\n end\n\n respond_to do |format|\n format.xml {render :xml => @jobs}\n format.json {render :json => @jobs}\n end\n end",
"def render_jobs_list(jobs)\n workflow_with_jobs = []\n workflow_batch = {}\n\n jobs.each do |job|\n analysis = job&.analysis\n job.current_user = current_user\n workflow = analysis&.workflow\n slot = workflow_with_jobs.last\n\n if slot.nil? || slot[:analysis_dxid] != analysis&.dxid ||\n slot[:workflow]&.dxid != workflow&.dxid\n workflow_with_jobs << { analysis_dxid: analysis&.dxid,\n batch_id: analysis&.batch_id,\n workflow: workflow, jobs: [job] }\n fill_batch_with_workflows(workflow_batch, workflow, analysis)\n else\n slot[:jobs] << job\n end\n end\n\n workflow_with_jobs.map! do |slot|\n if slot[:workflow].nil?\n slot[:jobs].map do |job|\n job_serialized = JobSerializer.new(job)\n job_serialized.launched_on = job.analysis&.created_at || job.created_at\n job_serialized\n end\n else\n slot[:workflow].current_user = current_user\n\n workflow_serialized = WorkflowSerializer.new(slot[:workflow])\n number_workflows_in_batch(workflow_batch[slot[:batch_id]],\n workflow_serialized, slot[:analysis_dxid])\n workflow_serialized.jobs = slot[:jobs].map do |job|\n job_serialized = JobSerializer.new(job)\n\n launched_on = job.analysis&.created_at || job.created_at\n job_serialized.launched_on = launched_on\n if workflow_serialized.launched_on.nil? ||\n launched_on < workflow_serialized.launched_on\n workflow_serialized.launched_on = launched_on\n end\n\n job_serialized\n end\n\n workflow_serialized.launched_on ||= Time.current\n workflow_serialized\n end\n end.flatten!\n\n page_array = paginate_array(sort_array_by_fields(workflow_with_jobs))\n page_meta = pagination_meta(workflow_with_jobs.count)\n page_meta[:count] = page_meta.dig(:pagination, :total_count)\n\n render json: { jobs: page_array, meta: page_meta }, adapter: :json\n end",
"def jobs_grid(jobs)\n initialize_grid(\n jobs,\n name: \"jobs\",\n order: \"jobs.id\",\n order_direction: \"desc\",\n per_page: 100,\n )\n end",
"def index\n if pmg_super? || admin?\n @jobs = Job.paginate :per_page => 15, :include => [:versions, :client],\n :page => params[:page], \n :order => sort_order('created_at')\n\n elsif pmg_user?\n @jobs = Job.paginate :per_page => 15, :page => params[:page],\n :include => [:versions, :client],\n :conditions => ['client_id IN (?)', current_user.clients.map{|x| x.id}],\n :order => sort_order('job_name')\n\n elsif client_su?\n @jobs = Job.paginate :per_page => 15, :page => params[:page],\n :include => [:versions, :client],\n :conditions => ['client_id IN (?)', current_user.employer.subclients.map{|x| x.id}],\n :order => sort_order('job_name')\n\n elsif client?\n @jobs = Job.paginate :per_page => 15, :page => params[:page],\n :include => [:versions, :client],\n :conditions => ['client_id = ?', current_user.client_id],\n :order => sort_order('job_name')\n\n end\n \n # error messages\n if current_user.level == :admin\n @messages = Message.find(:all, :order => \"updated_at desc\")\n end\n \n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @jobs.to_xml }\n end\n end",
"def job_items\n job_arguments(1)\n end",
"def index\n @jobs = Job.all\n end",
"def index\n @jobs = Job.all\n end",
"def index\n @jobs = Job.all\n end",
"def index\n @jobs = Job.all\n end",
"def index\n @jobs = Job.all\n end",
"def index\n @jobs = Job.all\n end",
"def jobs\n return nil unless @rufus\n return @saved_job_list if !running\n\n @rufus.jobs.collect do |job|\n {\n :job => job,\n :job_spec_id => job.handler.job_spec_id,\n :job_spec_name => job.handler.job_spec_name,\n :launched_job => job.handler.launched_job,\n :running => job.running?,\n :last_time => job.last_time,\n :next_time => job.next_time,\n :opts => job.opts,\n :scheduled_at => job.scheduled_at,\n :unscheduled_at => job.unscheduled_at,\n :id => job.id,\n :tags => job.tags,\n :last_work_time => job.last_work_time,\n :mean_work_time => job.mean_work_time\n }\n end\n end",
"def index\n jobs_index(Job.all)\n end",
"def index\n @jobs = Job.paginate :page => params[:page], :order => 'created_at DESC', :per_page =>10\n @job = Job.find(:last)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @jobs }\n format.json { render :json => @jobs }\n end\n end",
"def index\n @jobs = Job.published.desc\n end",
"def refresh\n @jobs = Job.paginate :page => params[:page], :order => 'created_at DESC', :per_page =>10\n end",
"def peek(count = nil)\n jids = JSON.parse(@client.call('peek', @name, (count || 1)))\n jobs = jids.map { |j| Job.new(@client, j) }\n count.nil? ? jobs[0] : jobs\n end",
"def peek(count = nil)\n jids = JSON.parse(@client.call('peek', @name, (count || 1)))\n jobs = jids.map { |j| Job.new(@client, j) }\n # If no count was provided, return a job. Otherwsie, return an array\n count.nil? ? jobs[0] : jobs\n end",
"def index\n \t@jobs = Job.all\n \t# if i wanted to find all of my jobs\n \t# @jobs = current_user.jobs.all\n end",
"def index\n @job_managers = JobManager.where(job_id: @job.id)\n end",
"def jobs\n if params[:start_date] and params[:end_date]\n @jobs = Job.where(\"startdate > :s and enddate < :e and hostname = :h and jobname != :n\", :s=>params[:start_date].to_datetime,:e=>params[:end_date].to_datetime.next,:h=>\"M6650M453\",:n=>'Get Iddrive').order('jobid desc')\n else\n @jobs = latest_jobs\n end\n end",
"def help\n puts \"job 'name' - create job named 'name'\"\n puts \"background 'name' - make 'name' a background job\"\n puts \"forget_background - make there be no background job\"\n puts \"jobs - a list of jobs\"\n puts \"forget_job 'name' - forget a job\"\n puts \"\"\n\n puts \"start 'job' - start named job\"\n puts \"pause - pause current job\"\n puts \"stop 'job' - stop named job\"\n puts \"stop - stop the running job\"\n puts \"active - jobs that have been started and not stopped\"\n puts \"record 'job', 20.minutes, 'jan-23 1:00 pm'\"\n puts \"\"\n\n puts \"start_day - start the day with the background job\"\n puts \"pause_day - pause all jobs\"\n puts \"stop_day - stop all active jobs\"\n \n puts \"\"\n puts \"records - see accumulated records\"\n puts \"this_month - records so far this month\"\n puts \"last_month - last month's records\"\n puts \"recent - yesterday and today's records\"\n puts \"\"\n\n puts \"The following commands refer to the numbers printed by\"\n puts \"'records', 'this_month', and similar commands.\"\n puts \"forget 2, 3 - forget those records\"\n puts \"shorten 1, 20.minutes - remove 20 minutes from record 1\"\n puts \"lengthen 1, 20.minutes - add 20 minutes to record 1\"\n puts \"\"\n\n puts \"The 'at' command allows you to start, pause, start_day (etc.)\"\n puts \"at particular times in the past or future. Examples:\"\n puts \" at '1:00 pm' do start 'job' end\"\n puts \" at '2003/01/23 8:00 a.m.' do start_day end\"\n puts \" at '9:33 PM yesterday' do stop_day end\"\n puts \"\"\n \n\n puts \"undo - undo last command.\"\n print \"exit - leave the program\" # No trailing newline.\n\n end",
"def index\n @push_jobs = apply_pagination(@push_jobs)\n end",
"def job_history\n history = []\n record = nil\n\n command('llist jobs').split(\"\\n\").each do |line|\n next unless line.index ': '\n key, value = line.split(': ', 2)\n key.strip!\n value.chomp!\n\n if key == 'JobId'\n record = { key => value }\n history << record\n elsif record\n record[key] = value\n end\n end\n\n history\n end",
"def index\n @worker_jobs = WorkerJob.all.page(params[:page])\n end",
"def index\n # Fetches space jobs.\n if params[:space_id]\n jobs = []\n if find_user_space\n jobs = @space.jobs.\n eager_load(:app, user: :org, analysis: :workflow).\n includes(:taggings).\n search_by_tags(params.dig(:filters, :tags)).\n order(order_from_params).page(page_from_params).per(PAGE_SIZE)\n jobs.each { |job| job.current_user = @context.user }\n\n jobs = JobService::JobsFilter.call(jobs, params[:filters])\n\n sync_jobs(jobs)\n end\n\n page_dict = pagination_dict(jobs)\n\n render json: jobs, root: \"jobs\", meta: count(page_dict[:total_count]).\n merge({ pagination: page_dict }), adapter: :json\n else\n # Fetches all user 'private' jobs.\n jobs = Job.\n editable_by(@context).\n accessible_by_private.\n eager_load(:app, user: :org, analysis: :workflow).\n includes(:taggings).\n search_by_tags(params.dig(:filters, :tags)).\n order(ORDER_GROUP_FIELDS)\n jobs = JobService::JobsFilter.call(jobs, params[:filters])\n\n render_jobs_list(jobs)\n end\n end",
"def job(id, options = {})\n objectify get(\"/job/#{id}\", options)['joblist']['job']\n end",
"def search(*args)\n\t\t\targs = args[0] if args.is_a?(Array) && args.count == 1\n\n\t \tcb_response = self.api_get(Cb.configuration.uri_job_search, :query => args)\n\t \tjson_hash = JSON.parse(cb_response.response.body)\n\n\t \tpopulate_from json_hash, \"ResponseJobSearch\"\n\n\t \tjobs = []\n\t \tjson_hash[\"ResponseJobSearch\"][\"Results\"][\"JobSearchResult\"].each do |cur_job|\n\t \t\tjobs << CbJob.new(cur_job)\n\t \tend\n\n\t \treturn jobs\n\t\tend",
"def workflow_run_attempt_jobs(repo, run_id, attempt_number, options = {})\n paginate \"#{Repository.path repo}/actions/runs/#{run_id}/attempts/#{attempt_number}/jobs\", options do |data, last_response|\n data.jobs.concat last_response.data.jobs\n end\n end",
"def job_summaries(params = {}) # rubocop:disable Style/OptionHash\n query = {\n \"statusGroups\": \"ALL\", # JOB_STATUS_GROUPS\n \"sortBy\": \"created\", # \"count\", \"title\", \"lead\", \"created\", \"status\"\n \"sortOrder\": \"ASC\" # \"ASC\", \"DESC\"\n }.merge(params)\n\n request(:get, \"applicant_tracking/jobs\", query: query)\n end",
"def index\n $lmc_left_menu = \"lmw_all_jobs\"\n $lmc_subleft_menu = \"lmw_saved_jobs\"\n @user = current_user\n @saved_jobs_ids = current_user.saved_jobs.pluck(:job_id)\n @saved_jobs = Job.where(id: @saved_jobs_ids).text_search(params[:query], params[:town], params[:status])\n end",
"def get_job_info(page)\n job_api = \"#{BASE_URL}/v4/projects/#{PROJECT_ID}/jobs?page=#{page}&per_page=#{PER_PAGE}\"\n begin\n response = RestClient::Request.new(\n :method => :get,\n :url => job_api,\n :verify_ssl => false,\n :headers => {\"PRIVATE-TOKEN\" => API_TOKEN}\n ).execute\n\n response.headers\n\n rescue RestClient::ExceptionWithResponse => err\n puts \"jobs info error: #{err.response}\"\n return nil\n end\nend",
"def user_jobs\r\n @selected_user = User.find(params[:user])\r\n jobs = filter_user_jobs(params[:user], params[:hours])\r\n @job_pages, @jobs = paginate_collection jobs, :per_page => 50, :page => params[:page]\r\n end",
"def last_job_number\n @jobs.length\n end",
"def jobs\n doc = Nokogiri::XML open(@url)\n\n doc.search('//job').map { |node|\n Job.new(attributes_from(node))\n }\n end",
"def load_jobs(jobs)\n j = 1\n jobs.each do |job|\n case j\n when 1\n self.job_cod_1 = job.code\n self.job_title_1 = job.title\n when 2\n self.job_cod_2 = job.code\n self.job_title_2 = job.title\n when 3\n self.job_cod_3 = job.code\n self.job_title_3 = job.title\n when 4\n self.job_cod_4 = job.code\n self.job_title_4 = job.title\n when 5\n self.job_cod_5 = job.code\n self.job_title_5 = job.title\n when 6\n self.job_cod_6 = job.code\n self.job_title_6 = job.title\n else\n #nothing\n end\n j += 1\n end\n end",
"def inspect_jobs(index = nil)\n return empty_msg if empty?\n desc = []\n puts \"\\n\"\n @jobs.each_with_index do |j, i|\n unless index.nil?\n next unless i == index\n end\n desc << '| Job: ' + \"#{i + 1} \".rjust(8) + '|' + 'Pattern:'.rjust(18) + \" #{j.pattern.basename}\".ljust(120) + '|'\n desc << '| |' + 'Compiler ID:'.rjust(18) + \" #{j.id} \".ljust(120) + '|'\n desc << '| |' + 'Pinmap:'.rjust(18) + \" #{j.pinmap_workbook} \".ljust(120) + '|'\n desc << '| |' + '.atp directory:'.rjust(18) + \" #{j.pattern.dirname} \".ljust(120) + '|'\n desc << '| |' + '.pat directory:'.rjust(18) + \" #{j.output_directory} \".ljust(120) + '|'\n desc << '| |' + 'LSF:'.rjust(18) + \" #{j.location == :lsf ? true : false} \".ljust(120) + '|'\n desc << '| |' + 'Delete log files:'.rjust(18) + \" #{j.clean} \".ljust(120) + '|'\n desc << '| |' + 'Verbose:'.rjust(18) + \" #{j.verbose} \".ljust(120) + '|'\n fragment = '| |' + 'Compiler args:'.rjust(18)\n overflow_fragment = '| |' + ' '.rjust(18)\n compiler_args = []\n compiler_fragment = ''\n j.compiler_options.each_key do |k|\n if compiler_fragment.size + \" -#{k}\".size >= 120\n compiler_args << compiler_fragment\n compiler_fragment = nil\n end\n compiler_fragment += \" -#{k}\"\n end\n compiler_args << compiler_fragment unless compiler_fragment.nil?\n compiler_fragment = ''\n j.compiler_options_with_args.each_pair do |k, v|\n if compiler_fragment.size + \" -#{k}:#{v}\".size >= 120\n compiler_args << compiler_fragment\n compiler_fragment = nil\n end\n compiler_fragment += \" -#{k}:#{v}\"\n end\n compiler_args << compiler_fragment unless compiler_fragment.nil?\n if compiler_args.join.length <= 120\n desc << fragment + \"#{compiler_args.join}\".ljust(120) + '|'\n else\n # Need to cycle through compiler args and build a fragment <= 100 characters\n # and print it. Keep going until the remaining args is <= 100 and print again\n char_cnt = 0\n line_cnt = 0\n args = []\n compiler_args = compiler_args.join.strip.split(/\\s+/)\n until compiler_args.empty?\n args = compiler_args.select { |e| (char_cnt += e.length + 1) < 120 }\n # remove the args that fit on the first line\n compiler_args -= args\n if line_cnt == 0\n desc << fragment + \" #{args.join(' ')}\".ljust(120) + '|'\n else\n desc << overflow_fragment + \" #{args.join(' ')}\".ljust(120) + '|'\n end\n args = []\n line_cnt += 1\n char_cnt = 0\n end\n end\n desc << '-' * desc.first.size\n end\n puts desc.flatten.join(\"\\n\")\n end",
"def index\n $lmc_left_menu = \"lmw_all_jobs\"\n $lmc_subleft_menu = \"lmw_job_applications\"\n @user = current_user\n @job_applications_ids = current_user.job_applications.pluck(:job_id)\n @job_applications = Job.where(id: @job_applications_ids).text_search(params[:query], params[:town], params[:status])\n end",
"def get_monitors\n return @jobs\n end",
"def job\n fetch('games.final_fantasy_xiv.jobs')\n end",
"def jobs_without_template\n []\n end",
"def find_unpublished_jobs(params:)\n response = HTTParty.get(\"#{@host}/api/jobs/unpublished_jobs\", query: params)\n \n return response['jobs']\n end",
"def jobs_api_listings(query, location, number, from, additional_options={})\n from ||= \"0\"\n location_query = \"in #{location}\" if (!location.nil? && !location.empty?)\n params = {\n query:\n {\n query: \"#{query} jobs #{location_query}\", size: number, from: from\n }.merge(additional_options.reject{|k,v| !v.present?})\n }\n jobs_api_response = JobsApi.new.search(params)\n if jobs_api_response.code == 200\n JSON.parse(jobs_api_response.body)\n else\n []\n end\n end",
"def completed_jobs\n @completed_jobs = Job.where(status: 'done').order(:deadline).paginate(page: params[:page], per_page: 15)\n end",
"def index\n do_authorize_class(:index, AnalysisJobsItem)\n do_get_opts\n\n do_get_analysis_job\n @analysis_jobs_items, opts = Settings.api_response.response_advanced(\n api_filter_params,\n get_query,\n AnalysisJobsItem,\n AnalysisJobsItem.filter_settings(@is_system_job)\n )\n\n show_items_as_results(request.head?, @analysis_jobs_items, opts)\n end",
"def jobs(&block)\n @jobs_array = (@jobs_array || []) << block\n end",
"def find_jobs (tag=nil)\n\n jobs = @cron_jobs.values + @non_cron_jobs.values\n jobs = jobs.select { |job| job.has_tag?(tag) } if tag\n jobs\n end",
"def index\n @q = Job.ransack(params[:q])\n @jobs = @q.result(distinct: true).page(params[:page])\n if @jobs.length == 1 && !@jobs.first.new_record?\n redirect_to @jobs.first\n end\n end",
"def get_jobs(url)\n result = JSON.parse(get_data(url))\n job_list = []\n result[\"jobs\"].each do |job|\n job = JenkinsJob.new job[\"name\"], job[\"color\"], job[\"url\"]\n job_list << job\n end\n job_list\nend",
"def work_jobs(queue = :job)\n Resque::Worker.new(queue).work(0)\n end",
"def enqueue(jobs, args={}, o={})\n opts = [\n o[:pri] || default_pri,\n o[:delay] || default_delay,\n o[:ttr] || default_ttr\n ]\n\n jobs = [jobs.to_s] unless jobs.is_a?(Array)\n jobs.compact!\n raise ArgumentError, \"you need at least 1 job\" if jobs.empty?\n job = jobs.first\n\n beanstalk.use(job)\n beanstalk.yput({ :args => args, :next_jobs => jobs[1..-1]}, *opts)\n rescue Beanstalk::NotConnected => e\n raise e if defined?(r)\n r = true\n error exception_message(e, \"You have a problem with beanstalkd.\\nIs it running?\")\n @@beanstalk = new_beanstalk\n retry\n end",
"def index\n @jobs = if params[:category].blank?\n Job.order created_at: :desc\n else\n Job.joins( :category ).\n where( categories: { name: params[:category] } ).\n order( created_at: :desc )\n end\n end",
"def available_jobs\n active_jobs + eligible_jobs\n end",
"def jobwaiting(maxjobs, verbose, jtype)\n while (get_job_count(jtype) >= maxjobs)\n ::IO.select(nil, nil, nil, 2.5)\n if verbose\n print_status('waiting for modules to finish')\n end\n end\n end"
] | [
"0.7115468",
"0.7035529",
"0.69772846",
"0.6892695",
"0.6824405",
"0.68047684",
"0.6725643",
"0.6671638",
"0.66124475",
"0.659958",
"0.6595867",
"0.65953207",
"0.6593811",
"0.654509",
"0.65241235",
"0.6510012",
"0.6495486",
"0.6466259",
"0.64655596",
"0.6454251",
"0.64518386",
"0.64000785",
"0.6369458",
"0.63466984",
"0.6316353",
"0.62780535",
"0.62397295",
"0.6200157",
"0.61644113",
"0.61572176",
"0.6153658",
"0.6146966",
"0.61135566",
"0.6112944",
"0.6097986",
"0.6097263",
"0.60807085",
"0.60797954",
"0.6065032",
"0.6057345",
"0.6020316",
"0.60026807",
"0.5992199",
"0.5953266",
"0.5939584",
"0.5939563",
"0.5932661",
"0.5912475",
"0.5887755",
"0.5886782",
"0.5880061",
"0.5873628",
"0.5873628",
"0.5873628",
"0.5873628",
"0.5873628",
"0.5873628",
"0.5859088",
"0.580913",
"0.58073807",
"0.5806719",
"0.58025044",
"0.5778284",
"0.57545125",
"0.5749345",
"0.5746147",
"0.5740835",
"0.57355034",
"0.57352406",
"0.57296056",
"0.5727462",
"0.5686228",
"0.56818366",
"0.56361717",
"0.5622422",
"0.56002456",
"0.5595997",
"0.5592497",
"0.5591352",
"0.5590109",
"0.55882514",
"0.5585052",
"0.5571319",
"0.55663013",
"0.55629516",
"0.55603033",
"0.55352587",
"0.55273175",
"0.55227286",
"0.55191076",
"0.55175996",
"0.5516955",
"0.5516505",
"0.5512261",
"0.550614",
"0.55012494",
"0.55006796",
"0.5496186",
"0.5477258",
"0.547395"
] | 0.6439239 | 21 |
jobs:status JOB_ID Check the status of a job. p, poll Poll the status of a job | def status
job_id = shift_argument
unless job_id
error("Usage: mortar jobs:status JOB_ID\nMust specify JOB_ID.")
end
# Inner function to display the hash table when the job is complte
def display_job_status(job_status)
job_display_entries = {
"status" => job_status["status_description"],
"progress" => "#{job_status["progress"]}%",
"cluster_id" => job_status["cluster_id"],
"job submitted at" => job_status["start_timestamp"],
"job began running at" => job_status["running_timestamp"],
"job finished at" => job_status["stop_timestamp"],
"job running for" => job_status["duration"],
"job run with parameters" => job_status["parameters"],
}
unless job_status["error"].nil? || job_status["error"]["message"].nil?
error_context = get_error_message_context(job_status["error"]["message"])
unless error_context == ""
job_status["error"]["help"] = error_context
end
job_status["error"].each_pair do |key, value|
job_display_entries["error - #{key}"] = value
end
end
if job_status["num_hadoop_jobs"] && job_status["num_hadoop_jobs_succeeded"]
job_display_entries["hadoop jobs complete"] =
'%0.2f / %0.2f' % [job_status["num_hadoop_jobs_succeeded"], job_status["num_hadoop_jobs"]]
end
if job_status["outputs"] && job_status["outputs"].length > 0
job_display_entries["outputs"] = Hash[job_status["outputs"].select{|o| o["alias"]}.collect do |output|
output_hash = {}
output_hash["location"] = output["location"] if output["location"]
output_hash["records"] = output["records"] if output["records"]
[output['alias'], output_hash]
end]
end
styled_header("#{job_status["project_name"]}: #{job_status["pigscript_name"]} (job_id: #{job_status["job_id"]})")
styled_hash(job_display_entries)
end
# If polling the status
if options[:poll]
ticking(polling_interval) do |ticks|
job_status = api.get_job(job_id).body
# If the job is complete exit and display the table normally
if Mortar::API::Jobs::STATUSES_COMPLETE.include?(job_status["status_code"] )
redisplay("")
display_job_status(job_status)
break
end
# If the job is running show the progress bar
if job_status["status_code"] == Mortar::API::Jobs::STATUS_RUNNING
progressbar = "=" + ("=" * (job_status["progress"].to_i / 5)) + ">"
if job_status["num_hadoop_jobs"] && job_status["num_hadoop_jobs_succeeded"]
hadoop_jobs_ratio_complete =
'%0.2f / %0.2f' % [job_status["num_hadoop_jobs_succeeded"], job_status["num_hadoop_jobs"]]
end
printf("\r[#{spinner(ticks)}] Status: [%-22s] %s%% Complete (%s MapReduce jobs finished)", progressbar, job_status["progress"], hadoop_jobs_ratio_complete)
# If the job is not complete, but not in the running state, just display its status
else
redisplay("[#{spinner(ticks)}] Status: #{job_status['status_description']}")
end
end
# If not polling, get the job status and display the results
else
job_status = api.get_job(job_id).body
display_job_status(job_status)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status(*job_id)\n #take default job_id if not specified\n if job_id.empty?\n job_id = @job_id\n else\n job_id = job_id[0]\n end\n\n \n url=\"#{@base_url}/#{@tool}/status/#{URI.encode(job_id)}\"\n uri = URI.parse(url)\n\n resp = Net::HTTP.get_response(uri)\n #puts resp.body\n\n #params = XmlSimple.xml_in(resp.body)\n\n return resp.body\n\n\n end",
"def send_job_status(jobname)\n\t\tputs \"* Checking status of: #{@jenkins_url}\"\n\t\tresponse = http_req(@jenkins_url)\n\t\t\n\t\tjobs = JSON.parse(response.body)[\"jobs\"]\n\t\t\n\t\tjobs.each { |j|\n\t\t\tname = j[\"name\"]\n\n\t\t\tif name.casecmp(jobname) == 0\n\t\t \twrite_serial_status(j)\n \t\t\tend\n\t\t}\n\tend",
"def get_job_status(job_id)\n @dbh[:progress_bars].filter(:id => job_id).first\n end",
"def wait_on_status(jobid)\r\n uri = URI(\"http://api.idolondemand.com/1/job/status/\" + jobid)\r\n uri.query = URI.encode_www_form(:apikey => $api_key)\r\n res = Net::HTTP.get_response(uri, p_addr = $proxy_host, p_port = $proxy_port)\r\n obj = JSON.parse(res.body)\r\n\r\n if obj['status'] == 'queued'\r\n puts \"job [#{jobid}] #{obj['status']}, waiting #{$status_wait} seconds\"\r\n sleep($status_wait)\r\n wait_on_status(jobid)\r\n end\r\nend",
"def get_status(job)\n (job.status == 'done' and !job.successful) ? 'Failed' : job.status.capitalize\n end",
"def do_poll\n\t\tstatus_lamp\n\t\tstatus_input\n\t\tprojector_information\n\t\tstatus_error\n\tend",
"def get_status(do_poll = false)\n if do_poll\n stat = issue_erequest({ :command => 'status' })\n else\n stat = self.persisted_status\n end\n jobid = stat.to_i\n stat = jobid unless jobid == 0\n return stat\n end",
"def get_job_status(job_id)\n raise ArgumentError, \"job_id is required\" unless job_id.present?\n\n request_body = ''\n xml = Builder::XmlMarkup.new(:target => request_body, :indent => 1)\n\n xml.instruct!\n xml.Envelope do\n xml.Body do\n xml.GetJobStatus do\n xml.JOB_ID job_id\n end\n end\n end\n\n doc = send_xml_api_request(request_body)\n status = result_dom(doc)['JOB_STATUS'] rescue nil\n desc = result_dom(doc)['JOB_DESCRIPTION'] rescue nil\n [status, desc]\n end",
"def clientPoll(jobId)\n printDebugMessage('clientPoll', 'Begin', 1)\n status = 'PENDING'\n while(status == 'PENDING' || status == 'RUNNING') do\n status = getStatus(jobId)\n printOutputMessage(status, 1)\n sleep(5) if(status == 'PENDING' || status == 'RUNNING')\n end\n printDebugMessage('clientPoll', 'End', 1)\n end",
"def wait(jobid)\n resp = command %{wait jobid=\"#{jobid}\"}\n expr = /^JobStatus=.*\\((.)\\)$/\n if resp =~ expr\n $1\n else\n raise \"Command error:\" + \\\n \" expected #{expr.inspect},\" + \\\n \" got #{resp.inspect}\"\n end\n end",
"def job_status(organization, jobid)\n uri = server_uri(\"/organizations/#{organization}/jobs/#{jobid}/status\")\n res_data = api_get(uri)\n @logger.debug res_data\n\n return res_data\n end",
"def status(job_id:)\n login_result = login\n return login_result unless login_result.success?\n\n result = SdrClient::BackgroundJobResults.show(url: Settings.sdr_api.url, job_id: job_id)\n if result[:status] != 'complete'\n nil\n elsif result[:output][:errors].present?\n error = result[:output][:errors].first\n error_msg = error[:title]\n error_msg += \": #{error[:message]}\" if error[:message]\n Dry::Monads::Failure(error_msg)\n else\n Dry::Monads::Success(result[:output][:druid])\n end\n end",
"def poll_lc_job(job, options={})\n options = {:timeout => 900}.merge(options)\n max_sleep_secs = 60\n resp = ASM::Util.block_and_retry_until_ready(options[:timeout], RetryException, max_sleep_secs) do\n resp = get_lc_job(job)\n unless resp[:percent_complete] == \"100\" || resp[:job_status] =~ /complete/i\n logger.info(\"%s status on %s: %s\" % [job, host, Parser.response_string(resp)])\n raise(RetryException)\n end\n resp\n end\n raise(ResponseError.new(\"LC job %s failed\" % job, resp)) unless resp[:job_status] =~ /complete/i\n\n resp\n rescue Timeout::Error\n raise(Error, \"Timed out waiting for job %s to complete. Final status: %s\" % [job, Parser.response_string(resp)])\n end",
"def get_job_status id\n response = get \"http://#{@host}/loadbalancers/tenant/#{@tenant}/jobs/#{id}\"\n raise LBModelException.new \"Expected HTTP 200 but got #{response.code} instead\" unless response.code == 200\n\n JSON.parse(response)\n end",
"def status\n job = delayed_job\n return 'queued' if job_queued?(job)\n return 'working' if job_working?(job)\n return 'completed' if job_completed?(job)\n return 'failed' if job_failed?(job)\n return 'unknown'\n end",
"def query_status(job_id)\n job = get_job_status(job_id)\n if job && (job[:job_finish] || job[:last_updated] > @last_queried[job_id])\n @last_queried[job_id] = Time.now\n job\n else\n nil\n end\n end",
"def check_job_status(report)\n job = load_job(report[:job_id])\n if (job && ((job.processed?) && !(job.complete?)))\n job.send_pack_request # Send a job complete message to the workers, and have one of them download and zip up the results files\n end\n end",
"def get_job_status(job)\n status = nil\n if job.present?\n if job.is_a?(Hash)\n job = job.stringify_keys\n actor = @registered_jobs[job['id']]\n status = actor.status\n else\n actor = @registered_jobs[job.to_i]\n status = actor.status\n end\n end\n status\n end",
"def poll\n\t\tactive_node = Node.find_by_mac_address(params[:nodeid]) || create_node\n\n\t\tif params[:jobid]\n\t\t\t# check status of current job\n\t\t\tjob = Job.find(params[:jobid])\n\n\t\t\tif job.status == \"active\"\n\t\t\t\trender :json => '{ \"status\": \"active\"}'\n\t\t\telse\n\t\t\t\trender\t:json => '{ \"status\": \"halt\"}'\n\t\t\tend\n\t\telse\n\t\t\t# check if there are any ongoing jobs\n\t\t\tjobs = Job.active\n\n\t\t\t# If there are any, choose one randomly\n\t\t\tif jobs.count > 0\n\t\t\t\tjob_idx = rand(jobs.count - 1)\n\n\t\t\t\tjob = jobs[job_idx]\n\n\t\t\t\t# If it's a dictionary job let's find the work\n\t\t\t\tif job[:attack_type] == \"dictionary\"\n\t\t\t\t\t# Not elegant, but can't directly assign job[:work] = ...\n\t\t\t\t\tjob.work = dictionary_content_for_job(job.id, active_node.id)\n\n\t\t\t\t\tif job.work == \"\"\n\t\t\t\t\t\tjob.status = \"completed\"\n\t\t\t\t\t\tjob.save\n\t\t\t\t\t\treturn :json => '{ \"status\": \"halt\"}'\n\t\t\t\t\tend\n\t\t\t\telsif job[:attack_type] == \"bruteforce\"\n\t\t\t\t\tjob.next_index = job.next_index.nil? ? 0 : job.next_index\n\n\t\t\t\t\tbruteforce_status = BruteforceStatus.create({\n\t\t\t\t\t\t:node_id => active_node.id,\n\t\t\t\t\t\t:job_id => job.id,\n\t\t\t\t\t\t:index => job.next_index\n\t\t\t\t\t})\n\t\t\t\t\t## Calculate next index. We're just going to increase by 50 for now\n\t\t\t\t\tjob.next_index = job.next_index + 50\n\t\t\t\t\tjob.save\n\n\t\t\t\t\t# TODO: Mark job complete if next_index > length\n\t\t\t\t\tkeyspace_size = Bruteforce::totalSize(job.charset)\n\t\t\t\t\tif job.next_index > keyspace_size\n\t\t\t\t\t\tjob.status = \"completed\"\n\t\t\t\t\t\tjob.save\n\t\t\t\t\tend\n\n\t\t\t\tend\n\n\t\t\t\trender :json => job, methods: [:work, :response_flag_meta]\n\t\t\telse\n\t\t\t\trender :json => '{ \"job\": \"none\"}'\n\t\t\tend\n\t\tend\n\n\t\t# mark the client as active\n\t\tactive_node.mark_active\n\tend",
"def set_job_status\n @job_status = JobStatus.find(params[:id])\n end",
"def set_job_status\n @job_status = JobStatus.find(params[:id])\n end",
"def update_status(job_id, data)\n Global.io.push(\"status\", data.merge(job_id: job_id), to: @websocket_manager.find(job_id))\n end",
"def update_job_status\n if hired_changed? and job\n if hired\n self.job.update_attribute :open, false\n else\n self.job.update_attribute :open, true\n end\n end\n end",
"def status()\n return [true, [], [], []] if not self.jobids.any?\n \n statuses = GridVid.query(@_keys.merge({:jobids => self.jobids}))\n passed = []\n running = [] \n failed = [] \n \n statuses.each_pair {|jobid, val|\n case val['status']\n when \"PASS\"\n passed << val['jobid'] \n when \"FAILED\" \n failed << val['jobid'] \n else\n running << val['jobid'] \n end \n }\n \n return [running.length == 0, passed, failed, running] \n end",
"def check_status\n response = do_request(build_status_xml())\n status_elem = REXML::XPath.first(response,'/webthumb/jobStatus/status')\n @status = (status_elem.text || '').downcase == 'complete' ? STATUS_PICKUP : STATUS_PROCESSING\n \n if pickup?\n \n if status_elem\n @completion_time = status_elem.attributes['completionTime']\n @pickup_url = status_elem.attributes['pickup']\n @browser_width = (status_elem.attributes['browserWidth'] || \"0\").to_i\n @browser_height = (status_elem.attributes['browserHeight'] || \"0\").to_i \n end\n end\n @status\n end",
"def call_status\n job = Job.find(params[:job_id])\n if !job.expert_id.blank? or !job.expert_id.nil?\n render :json=> {:success => false }\n else\n if params[:accept]\n job.update_attributes(:status => \"completed\", :expert_id => params[:expert_id])\n elsif params[:end]\n job.update_attributes(:status => \"active\")\n end\n end\n end",
"def change_job_status_from_details\n @project_job = @current_organization.project_jobs.find(params[:id])\n if params[:status].present?\n if @project_job.status.present? && @project_job.status != params[:status]\n @project_job.update_column(:status, params[:status])\n @project_job.check_or_upgrade_project_stage \n create_comment_activity(\"<b>\"+params[:status]+ \"</b> the Task\")\n create_in_app_notification(\"Update\", \"Job status changed to #{params[:status]}\")\n Activity.create(:organization_id => @project_job.organization_id, :activity_user_id => @current_user.id, :activity_type => @project_job.class.name, :activity_id => @project_job.id, :activity_status => \"StatusChanged\", :activity_desc => \"Job status changed to #{params[:status]}\", :activity_date => @project_job.updated_at, :is_public => true, :source_id => @project_job.project.id,:source_type => @project_job.project.class.name)\n end\n end\n render partial: \"project_job_status_bar\"\n end",
"def job_status(report, message, status)\n job = load_job(report[:job_id])\n if job\n job.status = status\n job.save!\n end\n message.delete\n end",
"def update_status\r\n self.reload\r\n jobs = self.jobs\r\n complete_jobs = get_complete_jobs(jobs, JobStatus::COMPLETED, ProcessorStatus::COMPLETED) \r\n incomplete_jobs = get_complete_jobs(jobs, JobStatus::INCOMPLETED, ProcessorStatus::INCOMPLETED) unless self.facility.client.name == 'UNIVERSITY OF PITTSBURGH MEDICAL CENTER'\r\n incomplete_jobs = get_upmc_incomplete_jobs(jobs, JobStatus::INCOMPLETED) if self.facility.client.name == 'UNIVERSITY OF PITTSBURGH MEDICAL CENTER'\r\n complete_output_ready_jobs = get_output_ready_jobs(jobs, JobStatus::COMPLETED, ProcessorStatus::COMPLETED, QaStatus::COMPLETED) \r\n incomplete_output_ready_jobs = get_output_ready_jobs(jobs, JobStatus::INCOMPLETED, ProcessorStatus::INCOMPLETED, QaStatus::INCOMPLETED)\r\n\r\n excluded_jobs = jobs.select do |job|\r\n job.job_status.upcase == JobStatus::EXCLUDED\r\n end\r\n \r\n new_jobs = jobs.select do |job|\r\n job.job_status == JobStatus::NEW\r\n end\r\n\r\n allocated_jobs = jobs.select do |job|\r\n job.job_status == JobStatus::PROCESSING\r\n end\r\n\r\n excluded_processing_or_new_jobs = jobs.select do |job|\r\n ((job.job_status == JobStatus::NEW || job.job_status == JobStatus::PROCESSING) &&\r\n job.is_excluded == true)\r\n end\r\n\r\n previous_status = self.status\r\n if jobs.size == new_jobs.size or jobs.size == 0\r\n self.status = BatchStatus::NEW\r\n self.completion_time = nil\r\n elsif jobs.size == (complete_output_ready_jobs.size + excluded_jobs.size +\r\n incomplete_output_ready_jobs.size + excluded_processing_or_new_jobs.size)\r\n self.completion_time = Time.now\r\n self.status = BatchStatus::OUTPUT_READY\r\n elsif jobs.size == (complete_jobs.size + excluded_jobs.size +\r\n incomplete_jobs.size + excluded_processing_or_new_jobs.size)\r\n self.completion_time = Time.now\r\n self.status = BatchStatus::COMPLETED\r\n else\r\n self.status = BatchStatus::PROCESSING\r\n self.completion_time = nil\r\n end\r\n if previous_status == BatchStatus::NEW && self.status == BatchStatus::PROCESSING &&\r\n self.processing_start_time.blank?\r\n self.processing_start_time = Time.now\r\n end\r\n if previous_status == BatchStatus::PROCESSING && self.status == BatchStatus::COMPLETED\r\n self.processing_end_time = Time.now\r\n end\r\n set_qa_status\r\n self.save \r\n end",
"def track_status(jlh)\n jmd = jlh[:jmd]\n jle = jlh[:jle]\n result = jle.job_result\n red = $application_properties['red']\n green = $application_properties['green']\n red_expression = Regexp.new(red,Regexp::MULTILINE)\n green_expression = Regexp.new(green,Regexp::MULTILINE)\n run_data_expression = Regexp.new($application_properties['run_data'],Regexp::MULTILINE)\n introscope_data_expression = Regexp.new($application_properties['introscope_data'],Regexp::MULTILINE)\n result_no_carriage = result.gsub(\"\\n\",'')\n result_no_carriage = result.gsub(\"\\r\\n\",'')\n match = green_expression.match(result)\n run_data_match = run_data_expression.match(result_no_carriage)\n if (run_data_match)\n state = run_data_match[1]\n jle.run_data = state\n $logger.debug(\"The current run of #{jmd.job_code} is storing the following run data state: #{state}\")\n end\n introscope_data_match = introscope_data_expression.match(result_no_carriage)\n if (introscope_data_match)\n state = introscope_data_match[1]\n jle.introscope_data = state\n $logger.debug(\"The current run of #{jmd.job_code} is storing the following introscope state: #{state}\")\n end\n\n if match\n cur_status = \"GREEN\"\n else\n match = red_expression.match(result)\n\n if match\n cur_status = \"RED\"\n else\n cur_status = \"UNKNOWN\"\n $logger.debug(\"The output for job_code #{jmd.job_code} does not have valid status output!\")\n end\n end\n\n #look up the last successfully completed job log entry to see what the previous status was\n #last_log = JobLogEntry.job_log_by_jc_desc(jmd.job_code).finished(true).status_completed(true).limit(1)\n last_log = JobLogEntry.get_last_tracked_status(jmd.job_code,true)\n #if we have a last log entry to compare against then increment the status_cnt if it is the same\n #as the current run. Otherwise, the count will default to 1 as the status just changed\n #if we kill the job engine during a save or the job was never run assume green.\n last_status = last_log.nil? ? \"GREEN\" : last_log.status\n\n status_cnt = 1\n unless last_log.nil?\n if (cur_status.eql?(last_status))\n #if the last job was abandoned (reboot mongrel during execution) we might still have a null\n if (last_log.status_cnt.nil?)\n last_log.status_cnt = 0\n end\n status_cnt = last_log.status_cnt + 1\n end\n end\n #return the current status and the last log status\n {:current_status => cur_status, :last_status => last_status, :status_cnt => status_cnt}\n end",
"def listjobs(project=self.project)\n get('listjobs.json', project: project).reject{|k,v| k=='status'}\n end",
"def get_status_job(gear, component)\n args = build_base_gear_args(gear)\n job = RemoteJob.new(component.cartridge_name, 'status', args)\n job\n end",
"def checkJobStatus (msg)\n\n @sqs = Aws::Sqs.new(AMAZON_ACCESS_KEY_ID, AMAZON_SECRET_ACCESS_KEY)\n\n @queue_name = PRESCHEDULING_QUEUE\n\n @queue = @sqs.queue(@queue_name, false)\n @msg = msg\n\n puts 'I just received the message:'\n puts @msg\n\n @parts = @msg.to_s.split(';')\n # toca también por punto y coma porque las urls van separadas por :\n @parts2 = @msg.to_s.split(';')\n\n if(@parts[0] == INSTALLING_APP_MSG)\n\n # ahora encuentro el job que me dicen que esta en estado instalando\n @job = Job.find(@parts[1])\n @job.status = JOBS_STATUS[:INSTALLING]\n @job.save\n @msg.delete\n\n @event = Event.new(:code => 4, :description => @msg, :event_date => DateTime.now )\n @event.execution = @job.execution\n @event.save\n\n end\n\n if(@parts[0] == RUNNING_APP_MSG)\n\n # ahora encuentro el job que me dicen que esta en estado instalando\n @job = Job.find(@parts[1])\n @job.status = JOBS_STATUS[:RUNNING]\n @job.save\n\n @hostname = @parts[2]\n @execution = @job.execution\n @execution.running_jobs = @execution.running_jobs+1\n @execution.save\n @virtual_machines = @execution.cluster.virtual_machines\n puts @hostname\n puts 'is busy'\n\n @busy_vm\n\n @virtual_machines.each do |vm|\n\n if(vm.hostname.split('.').first == @hostname)\n @busy_vm = vm\n end\n\n end\n\n if(@busy_vm != nil)\n @busy_vm.is_busy = true\n @busy_vm.save\n end\n puts 'vm saved'\n\n @msg.delete\n\n @event = Event.new(:code => 5, :description => @msg, :event_date => DateTime.now)\n @event.execution = @execution\n @event.save\n end\n\n if(@parts[0] == UPLOADING_OUTPUTS_MSG)\n\n # ahora encuentro el job que me dicen que esta en estado instalando\n @job = Job.find(@parts[1])\n @job.status = JOBS_STATUS[:UPLOADING_OUTPUTS]\n @job.save\n @msg.delete\n\n @event = Event.new(:code => 6, :description => UPLOADING_OUTPUTS+@job.id.to_s, :event_date => DateTime.now)\n @event.execution = @job.execution\n @event.save\n end\n\n if(@parts2[0] == REGISTER_FILE_MSG)\n\n puts 'registering file'\n\n # ahora encuentro el job que me dicen que toca registrarle el output\n @job = Job.find(@parts2[1])\n # creo un nuevo cloud file para representar el archivo\n @cloud_file = CloudFile.new\n @file_url =@parts2[2]\n puts @file_url\n\n @directories = Directory.where('name=?',@job.id.to_s)\n\n # es que ya existe\n if(@directories.size == 1)\n @directory = @directories[0]\n else\n @parent_directory = @job.directory\n #primero creo un directorio donde guardar la salida, el id es el nombre del job\n @directory = Directory.new\n @directory.user = @job.user\n @directory.name = @job.id.to_s\n @directory.parent_id = @parent_directory.id\n @directory.save\n end\n\n\n\n\n\n @file_url_parts = @file_url.split('/')\n @file_name = @file_url_parts.last\n\n @cloud_file.name = @file_name\n @cloud_file.directory = @directory\n @cloud_file.user = @job.user\n\n @url = @file_url_parts[4] + '/'+ @file_url_parts[5]+ '/' + @file_url_parts[6]\n @cloud_file.url = @url\n @cloud_file.avatar = @file_name\n\n #TODO Esto se debe cambiar OJO.\n @cloud_file.size = get_object_size_s3 (@file_url_parts[3]+\"/\"+@cloud_file.url)\n @cloud_file.save\n\n @msg.delete\n\n @event = Event.new(:code => 7, :description => REGISTER_FILE+@cloud_file.name, :event_date => DateTime.now)\n @event.execution = @job.execution\n @event.save\n end\n\n if ( @parts[0]== FINISHED_JOB_MSG)\n\n # ahora encuentro el job que me dicen que esta en estado Finalizado\n @job = Job.find(@parts[1])\n @job.status = JOBS_STATUS[:FINISHED]\n @job.save\n\n puts @job.to_s\n\n @hostname = @parts[2]\n @execution = @job.execution\n @execution.running_jobs = @execution.running_jobs-1\n @execution.finished_jobs = @execution.finished_jobs+1\n # si el número de jobs es 0 quiere decir que no hay jobs corriendo en este momento\n # esto quiere decir que la ejecución se ha terminado\n if @execution.running_jobs == 0\n @execution.ended = true\n puts \"Finished\" + @job.to_s\n end\n\n @execution.save\n @virtual_machines = @execution.cluster.virtual_machines\n puts @hostname\n puts 'is busy'\n\n @busy_vm\n\n @virtual_machines.each do |vm|\n\n if(vm.hostname.split('.').first == @hostname)\n @busy_vm = vm\n end\n\n end\n\n if(@busy_vm != nil)\n @busy_vm.is_busy = false\n @busy_vm.save\n end\n puts 'vm saved'\n\n @msg.delete\n\n #si la ejecución terminó\n if @execution.ended?\n\n @execution_total_cost = 0\n\n #si la ejecución terminó, apago todas las máquinas virtuales\n @virtual_machines.each do |vm|\n\n stop_one_vm(vm, @execution.cluster.user)\n\n #@execution_total_cost += vm.execution_hours* VM_PRICING[vm.execution.vm_type]\n @execution_total_cost += (vm.execution_hours * VM_PRICING[@execution.vm_type])\n\n end\n\n #le pongo que la fecha de finalización es ahora\n @end_date = DateTime.now\n @execution.end_date = @end_date\n\n #OJO!!!! TODO\n @execution.total_cost = @execution_total_cost\n @execution.save\n\n\n @event = Event.new(:code => 10, :description => EXECUTION_FINISHED+@execution.id.to_s, :event_date => @end_date)\n @event.execution = @execution\n @event.save\n\n end\n\n\n end\n\n if ( @parts[0]== SWITCHED_TO_QUEUE)\n\n @event = Event.new(:code => 3, :description => @msg, :event_date => DateTime.now )\n @queue = @parts[1].to_s.split('-')\n @exec = Execution.find(@queue[1])\n @event.execution = @exec\n @event.save\n\n end\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nend",
"def job?(cmd)\n @job = api.query_job(cmd)\n job.wait_until_done!\n fld = job.failed?\n puts(job.error['message']) if fld\n fld\n end",
"def status\n if @pbsid.nil?\n OSC::Machete::Status.not_submitted\n else\n @torque.qstat @pbsid, host: @host\n end\n end",
"def status\n check_exists\n SideJob.redis.get \"#{redis_key}:status\"\n end",
"def search_find_job_and_get_status(job)\n\t click_on('Filter Jobs')\n\t wait_for_ajax\n\t fill_in('users-id-search', :with => \"\") #clear Recruiter field\n\t fill_in('requisition.title_id', :with => \"#{job}\")\n\t click_on('search-btn-id')\n\t wait_for_ajax\n\t search_job_get_status(job)\n\tend",
"def check_status\n return status if pid.nil?\n\n pre_status = `#{check_status_command}`\n unless pre_status.nil? || pre_status.empty?\n state = check_process_status(pre_status)\n completed?(state) ? check_completed_status : state\n else\n failed? ? status : check_completed_status\n end\n end",
"def update_job_status(status)\n @csv_report_job.status = status\n @csv_report_job.save!\n end",
"def batch_job_status_reason\n return if job_description.blank?\n\n job_hash = JSON.parse(job_description)\n if job_hash\n job_hash['statusReason']\n end\n end",
"def pending_status\n 'pending' if archive_retrieval_job_id\n end",
"def poll_jenkins_job(job_url)\n job_hash = get_jenkins_info(job_url)\n\n ##\n # Sometimes we get a nil because we get here too soon after the jenkins\n # job's build was triggered. This is kind of an ugly workaround but\n # whatever.\n #\n while job_hash['lastBuild'].nil?\n job_hash = get_jenkins_info(job_url)\n sleep 1\n end\n\n wait_for_build job_hash['lastBuild']['url']\n end",
"def check_for_job_completion\n self.job.check_for_completion if complete?\n end",
"def wait_for_job\n\t\tloop {\n\t\t\tputs \":: #{self.feedback['job_desc']}: #{self.job_state}\" if ENV['LKP_VERBOSE']\n\n\t\t\tbreak if self.job_successfull_finished? or\n\t\t\t\t self.job_failed? or\n\t\t\t\t self.job_cancelled?\n\n\t\t\t# otherwise, the job is still in the queue or running; let's wait\n\t\t\tsleep 60\n\t\t}\n\n\t\treturn self.feedback['scheduled_time'] || self.feedback[\"#{self.job_state}_time\"]\n\tend",
"def status\n return @task_status if job_ended?\n\n current_task_status = puppet_to_task_status(puppet_status)\n\n self.task_status = case current_task_status\n when 'successful'\n processing_succeed_task\n when 'running'\n processing_running_task\n when 'failed'\n processing_error_task\n when 'undefined'\n processing_undefined_task\n end\n\n time_is_up! if should_stop?\n @task_status\n end",
"def get_joblist_status\n\t\t\tsc = {}\n\t\t\tmethod = \"r\"\n\t\t\tmethod = \"w\" if !::File.exist?(JOBLIST_LOCK)\n\n\t\t\tFile::open(JOBLIST_LOCK, method){ |ld|\n\t\t\t\t# lock!\n\t\t\t\tbreak if ld.flock(File::LOCK_SH) != 0\n\t\t\t\t\n\t\t\t\t# get clobal option.\n\t\t\t\tFile::open(JOBLIST, \"r\") { |fp|\n\t\t\t\t\tbreak if !(line = fp.gets)\n\t\t\t\t\tbuf = (line.chomp!).split(\",\")\n\t\t\t\t\tif buf[0] == '0' or buf[0] == '1'\n\t\t\t\t\t\tsc['flg'] = buf[0]\n\t\t\t\t\t\tif buf[0] == '0' # no move\n\t\t\t\t\t\t\tsc['option'] = -1 \n\t\t\t\t\t\t\tsc['time'] = -1\n\t\t\t\t\t\telse # move\n\t\t\t\t\t\t\tsc['option'] = buf[1].to_i\n\t\t\t\t\t\t\tsc['time'] = buf[2]\n\t\t\t\t\t\t\tsc['pid'] = buf[3].to_i\n\t\t\t\t\t\tend\n\t\t\t\t\t\t@flg = buf[0]\n\t\t\t\t\tend\n\n\t\t\t\t} # joblist close\n\t\t\t} # joblist unlock!\n\n\t\t\treturn sc\n\t\tend",
"def test_save_after_update_when_status_returns_symbol\n OSC::Machete::Job.any_instance.stubs(:status).returns(OSC::Machete::Status.running)\n assert OSC::Machete::Status.running, @job.job.status\n\n @job.expects(:\"save\").never\n @job.status = \"R\"\n @job.update_status!\n\n @job.expects(:\"save\").at_least_once\n @job.status = \"Q\"\n @job.update_status!\n end",
"def get_jobs_list(status = :all, page = 1, reload = false)\n Bitmovin::Job.list(status, page, reload)\n end",
"def status (job)\n content_tag :span, :class => (case job.status when 1 then 'label label-important' when 2 then 'label label-success' when 3 then 'label' end) do\n case job.status\n when 1 \n 'No Publicado'\n when 2\n 'Publicado'\n when 3\n 'Finalizado'\n end\n end\n end",
"def work_status(job_handle, numerator, denominator)\n worker_queue.set_status(numerator, denominator)\n end",
"def get_log_job_status(xml_data:)\n raise \"xml_data must be a valid Nokogiri::XML::Document type\" unless xml_data.is_a?(Nokogiri::XML::Document)\n xml_data.xpath('//response/result/job/status')[0].content.to_s\n end",
"def wait_for_job(job_id, timeout_seconds)\n states = ['FINISHED', 'CANCELED', 'FAILED']\n wait_interval = 2 # seconds\n total_taken = 0\n while total_taken < timeout_seconds\n sleep wait_interval\n total_taken += wait_interval\n status = @cp.get_job(job_id)\n if states.include? status['state']\n return\n end\n end\n end",
"def update #:nodoc:\n job = Job.find(params[:id])\n job.enter(params[:status], params, request.headers)\n respond_with job, location: api_job_url(job)\n end",
"def search_job_get_status(searchString)\n search_and_get_value_table('requisition-view-table-body',4, searchString, 10)\n end",
"def write_serial_status(job)\n \tproject = job[\"name\"]\n \t\n \tcase job[\"color\"]\n\t\t\t\n\t\t\t# TODO: Handle anime colors as well\n\t\t\t\t\t\t \t\n \t when \"red\"\n \t puts \"Writing status for: #{project} [Failed]\"\n \t @sp.write(\"3\")\n \t \n \t when \"yellow\"\n\t\t \t\tputs \"Writing status for: #{project} [Unstable]\"\n\t\t \t\t@sp.write(\"1\")\n\t\t \t\t\n \t when \"blue\"\n \t puts \"Writing status for: #{project} [Success]\"\n \t @sp.write(\"4\")\n \t else \n \t\t\t\tputs \"Unknown color: #{job[\"color\"]}\" \t \n \tend\n\tend",
"def monitor_jobs\n @job_pids.each do |job_id, pid|\n # Check if alive\n line = `ps -www -o rss,state -p #{pid}`.split(\"\\n\")[1]\n rss = state = nil\n running = true\n if line\n rss, state = line.split ' '\n log.debug \"Process #{pid} for job #{job_id} in state #{state}, uses #{rss}k mem\"\n else\n # Missing process, which means something went very wrong.\n # TODO: report it!\n log.debug \"Process #{pid} for job #{job_id} is missing!\"\n running = false\n end\n \n # Now check if finished, which means it will be in Z (zombie) status\n # TODO: should we use EventMachine#watch_process ?\n # UPDATE: we are not collecting process status, so we should never see zombie processes.\n if state =~ /Z/\n # Process completed, collect information\n pid, status = Process.wait2 pid\n log.debug \"Process #{pid} for job #{job_id} exited with status #{status.exitstatus}\"\n running = false\n end\n \n job = MongoJob.find_job job_id\n \n if running\n # Still running, so ping database\n # One more thing to check - if the job does not exist, we are killing the process.\n if job\n job.ping\n else\n log.info \"Job #{job_id} for process #{pid} is missing, killing\"\n Process.kill 'KILL', pid\n end\n else\n # Process not running\n # Check the status of the job - if it is still marked as \"working\", we should set its\n # status to \"failed\"\n if job\n if job.status == 'working'\n job.fail \"Process died.\"\n else\n log.info \"Process #{pid} for job #{job_id} ended.\"\n end\n end\n # For sure we are not working on it anymore, so remove from the stack\n finish_job job_id\n end\n \n end\n end",
"def update\n @job = Job.find(params[:id])\n case params[:status]\n when \"requested\"\n @job.status :requested\n when \"printed\"\n @job.status :printed\n when \"paid\"\n @job.status :paid\n end\n \n @job.save\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n flash[:notice] = 'Job was successfully updated.'\n format.html { redirect_to(@job) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def do_ping\n\t\t\tstatus=`initctl status #{@job_name}`\n\t\t\tstatus.include?(\"running\") ? :up : :down\n\t end",
"def getStatus id\n\t\tstatus = @tickets.read ['status'], ['id', id]\n\t\tstatus = status[0]['status']\n\tend",
"def watch_apply_ok_for_job\n j = (Job.find(params[:job_id].present? ? params[:job_id] : params[:id]) rescue nil)\n if j == nil || @current_user == j.user\n flash[:error] = 'You can\\'t watch or apply to your own listing.'\n redirect_to job_path(j)\n end\n end",
"def status\n (@remote_job || fetch_job).merge(attributes)\n end",
"def set_initial_status\n if LaunchedJob.where(job_spec: self.job_spec, status: LaunchedJob::RUNNING).size > 0\n self.update(status: ERROR, start_time: Time.now)\n raise \"JobSpec already running\" \n else\n self.update(status: RUNNING, start_time: Time.now)\n end\n end",
"def tag_with_job_status(job)\n # Find all run actions associated to this run\n all_job_actions_sorted_by_id = job.actions.order('id ASC')\n\n # Browse actions and sort by status\n # FIXME: the latest action on a specific step overrides the data for the same previous instance of this step\n all_job_actions_sorted_by_id.each do |action|\n if action.errno.to_i >0\n border_color = COLOR_FAILED\n elsif action.completed_at.nil?\n border_color = COLOR_RUNNING\n else\n border_color = COLOR_COMPLETED\n end\n\n # Set attributes for thiss step\n self.step_attributes(action.step_id, {\n :border_color => border_color,\n :errno => action.errno,\n })\n end\n end",
"def poll_deployment_job(job, options={})\n options = {:timeout => 600}.merge(options)\n max_sleep_secs = 60\n resp = ASM::Util.block_and_retry_until_ready(options[:timeout], RetryException, max_sleep_secs) do\n resp = get_deployment_job(job)\n unless %w[Success Failed].include?(resp[:job_status])\n logger.info(\"%s status on %s: %s\" % [job, host, Parser.response_string(resp)])\n raise(RetryException)\n end\n resp\n end\n raise(ResponseError.new(\"Deployment job %s failed\" % job, resp)) unless resp[:job_status] == \"Success\"\n\n resp\n rescue Timeout::Error\n raise(Error, \"Timed out waiting for job %s to complete. Final status: %s\" % [job, Parser.response_string(resp)])\n end",
"def status()\n JobRunStatus.label_from_id(self.job_run_status_id)\n end",
"def get_status\n fetch_status unless status == :completed\n status\n end",
"def get_status\n fetch_status unless status == :completed\n status\n end",
"def print_jobs_status_read(id, opts = {})\n data, _status_code, _headers = print_jobs_status_read_with_http_info(id, opts)\n data\n end",
"def set_jobstatus(option, jobno, code, date, bnum, anum)\n\t\t\tline = \"\"\n\t\t\tmethod = \"r\"\n\t\t\tret = false\n\t\t\tmethod = \"w\" if !::File.exist?(JOBLIST_LOCK)\n\t\t\tFile::open(JOBLIST_LOCK, method){ |ld|\n\t\t\t\t# lock!\n\t\t\t\tbreak if ld.flock(File::LOCK_EX) != 0\n\t\t\t\t# joblist none...\n\t\t\t\tbreak if !::File.exist?(JOBLIST)\n\n\t\t\t\tFile::open(JOBLIST, \"r\"){ |fp|\n\t\t\t\t\tFile::open(JOBLISTTMP, \"w\"){ |wp|\n\t\t\t\t\t\tline = fp.gets\n\t\t\t\t\t\twp.write(line) # line 1(global option)\n\t\t\t\t\t\twhile line = fp.gets\n\t\t\t\t\t\t\tbuf = line.split(\",\")\n\t\t\t\t\t\t\tif buf.size == 6\n\t\t\t\t\t\t\t\tif buf[1].size == 36 and jobno == buf[1]\n\t\t\t\t\t\t\t\t\tline = \"%d,%s,\" % [option, jobno]\n\t\t\t\t\t\t\t\t\tline += \"%x,%d,\" % [code, date]\n\t\t\t\t\t\t\t\t\tline += \"%d,%d\\n\" % [bnum, anum]\n\t\t\t\t\t\t\t\t\tret = true\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\twp.write(line)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# ?? Error?(No jobno hit.)\n\t\t\t\t\t\tif !ret\n\t\t\t\t\t\t\tline = \"%d,%s,\" % [option, jobno]\n\t\t\t\t\t\t\tline += \"%x,%d,\" % [code, date]\n\t\t\t\t\t\t\tline += \"%d,%d\\n\" % [bnum, anum]\n\t\t\t\t\t\t\twp.write(line)\n\t\t\t\t\t\t\tret = true\n\t\t\t\t\t\tend\n\n\t\t\t\t\t}# joblist(tmp) close\n\t\t\t\t} # joblist close\n\n\t\t\t\t# file rename(\"JOBLISTTMP\"(renew joblist) -> \"JOBLIST\")\n\t\t\t\tFileUtils.mv(JOBLISTTMP, JOBLIST)\n\t\t\t} # joblist unlock!\n\n\t\t\treturn ret\n\t\tend",
"def update_status status\n @job.set({\n custom_status: status,\n pinged_at: Time.now\n })\n end",
"def set_db_job_status\n @db_job_status = DbJobStatus.find(params[:id])\n end",
"def incomplete?\r\n job_status != JobStatus::COMPLETED\r\n end",
"def status\n id ? Resque::Plugins::Status::Hash.get(id) : nil\n end",
"def log_job_complete?(job_id:)\n status = false\n xml_data = get_log_xml(job_id: job_id)\n response_code = get_log_xml_response_code(xml_data: xml_data)\n\n if response_code == \"success\"\n job_status = get_log_job_status(xml_data: xml_data)\n status = true if job_status == \"FIN\"\n else\n raise \"Error in response XML: #{data.inspect}\"\n end\n\n status\n end",
"def wait_until_complete\n tries = 0\n status = nil\n sleep 1\n while tries < 100\n status = self.status\n puts \"Waiting... status=\" + status[\"status\"]\n if status[\"status\"] != \"queued\" && status[\"status\"] != \"running\"\n break\n end\n sleep 2\n end\n status\n end",
"def change_status\n if wait? and challenged_performance and challenger_performance\n self.approval_waiting!\n notify_judges\n end\n end",
"def fax_job_id_status_get(api_key, job_id, opts = {})\n fax_job_id_status_get_with_http_info(api_key, job_id, opts)\n return nil\n end",
"def find_pending(job, batch)\n sql = \"Select * from #{@schema_name}.job_runs where job_id = '#{job.id}' and batch = '#{batch.to_json}' and (status = 'queued' or status = 'running' );\"\n job_run_query(sql)\n end",
"def wait_for_status(primitive, node = nil)\n msg = \"Wait for known status of '#{primitive}'\"\n msg += \" on node '#{node}'\" if node\n Puppet.debug msg\n retry_block_until_true do\n cib_reset\n primitive_status(primitive) != nil\n end\n msg = \"Primitive '#{primitive}' has status '#{primitive_status primitive}'\"\n msg += \" on node '#{node}'\" if node\n Puppet.debug msg\n end",
"def get_job(jobid, cluster)\n begin\n data = cluster.job_adapter.info(jobid)\n\n raise OodCore::JobAdapterError if data.native.nil?\n ActiveJobs::Jobstatusdata.new(data, cluster, true)\n\n rescue OodCore::JobAdapterError\n OpenStruct.new(name: jobid, error: \"No job details because job has already left the queue.\" , status: status_label(\"completed\") )\n rescue => e\n Rails.logger.info(\"#{e}:#{e.message}\")\n Rails.logger.info(e.backtrace.join(\"\\n\"))\n OpenStruct.new(name: jobid, error: \"No job details available.\\n\" + e.backtrace.to_s, status: status_label(\"\") )\n end\n end",
"def enqueue_verify_reg_status_job\n\n BgJob.enqueue(\n ::RegisterBrandedToken::GetProposeStatusJob,\n {critical_log_id: @critical_chain_interaction_log_id},\n {wait: 30.seconds}\n )\n\n success\n\n end",
"def job_report(job)\n state = job['state']\n owner = job['user']\n uid = job['uid']\n if ((state.to_s==\"running\") || (state.to_s==\"waiting\"))\n @logger.info \"monitor{#@id} - #{owner} job #{uid} #{state}\"\n else \n @logger.warn \"monitor{#@id} - #{owner} job #{uid} #{state}\"\n end\n end",
"def job_exists? name\n\t\t\tjob = get_job name\n\t\t\treturn job[:success]\n\t\tend",
"def complete?\n case @status\n when 'new', 'voting', 'running'\n false\n when 'complete'\n true\n else\n fail Exceptions::PushJobError, @job\n end\n end",
"def processing\n result = RegisterCheckerApi.job_status(job_name, job_correlation_id)\n return if result == 'RUNNING'\n\n if result == 'SUCCESS'\n session[:job] = nil\n flash[:success] = I18n.t('database_updated')\n redirect_to authenticated_root_path\n else\n redirect_to authenticated_root_path, alert: 'Uploaded file is not valid'\n end\n end",
"def test_status_sym\n @job.status = nil\n assert ! @job.submitted?\n assert @job.not_submitted?\n\n @job.status = :Q\n\n assert @job.submitted?\n assert ! @job.completed?\n assert @job.active?\n assert_equal \"Queued\", @job.status.to_s\n\n @job.status = :R\n assert @job.active?\n assert_equal \"Running\", @job.status.to_s\n\n @job.status = :C\n assert @job.completed?, \"completed? should return true when status is C\"\n assert ! @job.failed?, \"failed? should return false when status is not F\"\n\n @job.status = :F\n assert @job.completed?, \"completed? should return true when status is F\"\n assert ! @job.passed?, \"passed? should return false when status is F\"\n assert @job.failed?, \"failed? should return true when status is F\"\n end",
"def update_status\n\n command = params[:status].to_sym\n case command\n when :setup, :start, :abort, :terminate\n @project.send(\"#{command}_done!\")\n when :stop\n @project.stop_done!\n # save return result data\n raw_data = params[:data]\n results = JSON.parse(raw_data)\n results.each {|result| LoadTest.create!(result.merge(project_id: @project.id))}\n\n when :download, :export\n result_download_parms = {}\n result_download_parms[:status] = 1\n ProjectResultDownload.update(params[:request_id], result_download_parms)\n\n when :status\n status_data = params[:status_data]\n unless status_data.blank?\n if JSON.parse(status_data).empty?\n if @project.may_stop?\n submit_process(:stop)\n @project.stop! # TODO refactor as a :before callback to events\n end\n end\n end\n else\n raise \"Unknown command for status update: #{command}\"\n end\n\n flash[:success] = \"#{command} completed successfully!\"\n render nothing: true\n end",
"def status\n if not(exist?)\n return :init\n end\n\n if @ppg_filename.nil?\n return :unset\n end\n\n if Global.job_queue.active?(@id)\n return :processing\n end\n\n return :processable\n end",
"def status!(id, retries = nil, duration = nil)\n retries ||= self.retries\n duration ||= self.duration\n ret = nil\n retries.times do\n begin\n ret = status id\n if ret &&\n ret[:status] &&\n ret[:status] =~ /[a-z]/i &&\n ret[:status] !~ /sent to judge|(?:pend|queu|compil|link|runn|judg)ing/i\n return ret\n end\n rescue\n end\n sleep duration\n end\n return ret if ret\n raise OperationFailureError, \"Fail to get status\"\n end",
"def update_status\n begin\n if self.service_test.status_changed?\n results = self.service_test.test_results.last(2)\n unless results.empty?\n case results.length\n when 1\n previous = TestResult.new_with_unknown_status\n when 2\n previous = results[0] \n end\n \n if USE_EVENT_LOG\n \n service = self.service_test.service\n \n ActivityLog.create(:action => \"status_change\",\n :data =>{:current_result_id => self.id, :previous_result_id =>previous.id },\n :activity_loggable => self.service_test,\n :referenced => service)\n \n current_status = ServiceCatalographer::Monitoring::TestResultStatus.new(self)\n previous_status = ServiceCatalographer::Monitoring::TestResultStatus.new(previous)\n \n \n if ENABLE_TWITTER\n ServiceCatalographer::Util.say \"Called TestResult#update_status. A status change has occurred so submitting a job to tweet about...\"\n msg = \"Service '#{ServiceCatalographer::Util.display_name(service)}' has a test change status from #{previous_status.label} to #{current_status.label} (#{self.created_at.strftime(\"%Y-%m-%d %H:%M %Z\")})\"\n Delayed::Job.enqueue(ServiceCatalographer::Jobs::PostTweet.new(msg), :priority => 0, :run_at => 5.seconds.from_now)\n end\n \n unless MONITORING_STATUS_CHANGE_RECIPIENTS.empty?\n status_recipients_emails = MONITORING_STATUS_CHANGE_RECIPIENTS.dup\n \n if NOTIFY_SERVICE_RESPONSIBLE\n status_recipients_emails = status_recipients_emails + self.responsible_emails\n end\n ServiceCatalographer::Util.say \"Called TestResult#update_status. A status change has occurred so emailing the special set of recipients about it...\"\n subject = \"[#{SITE_NAME}] Service '#{ServiceCatalographer::Util.display_name(service)}' has a test change status from #{previous_status.label} to #{current_status.label}\"\n text = \"A monitoring test status change has occurred! Service '#{ServiceCatalographer::Util.display_name(service)}' has a test (#{self.service_test.test_type}, ID: #{self.service_test.test_id}) change status from #{previous_status.label} to #{current_status.label}. Last test result message: #{current_status.message}. Go to Service: #{ServiceCatalographer::Api.uri_for_object(service)}\"\n Delayed::Job.enqueue(ServiceCatalographer::Jobs::StatusChangeEmails.new(subject, text, status_recipients_emails), :priority => 0, :run_at => 5.seconds.from_now)\n end\n \n end\n end\n end\n rescue Exception => ex\n logger.error(\"There was problems updating the status for service test : #{self.service_test.id}\")\n logger.error(ex)\n end\n end",
"def content\n @client.status(self.job_id)\n end",
"def perform\n self.status = STATUS_DONE\n self.save\n job.update_status\n end",
"def batch_job_status_url\n return if job_description.blank?\n\n job_hash = JSON.parse(job_description)\n if job_hash && job_hash['jobId']\n AwsUtil.get_batch_job_url(job_hash['jobQueue'], job_hash['jobId'])\n end\n end",
"def status\n MsgQ.status(@qid)\n end",
"def has_pending?(job, batch)\n sql = \"Select count(*) from #{@schema_name}.job_runs where job_id = '#{job.id}' and batch = '#{batch.to_json}' and ( status = 'queued' or status = 'running' );\"\n r = exec_sql(sql)\n count = r.first[\"count\"].to_i\n count > 0\n end",
"def update_sauce_job_status(json_data = {})\n host = \"http://#{settings.sl_user}:#{settings.sl_api_key}@saucelabs.com\"\n path = \"/rest/v1/#{settings.sl_user}/jobs/#{session_id}\"\n url = \"#{host}#{path}\"\n ::RestClient.put url, json_data.to_json, content_type: :json, accept: :json\n end",
"def job_completed(job)\n report_success(job) if job['on_success']\n if job['period'] && job['period'].to_i > 0\n job['status'] = 'queued'\n job['make_after'] = job['period']\n job['args'].delete(:job_itself)\n storage.save(job) { |job| schedule(job) }\n else\n if JR.config[:remove_done_jobs]\n storage.destroy(job)\n else\n job['status'] = 'complete'\n storage.save(job)\n end\n end\n end",
"def monitor_job(job_id, start: true)\n job_state, placeholder_task, job_task = client.find_job_info_by_id(job_id)\n job = JobMonitor.new(self, job_id, state: job_state, placeholder_task: placeholder_task, task: job_task)\n if start\n job.start\n end\n job\n end",
"def find_job(job_id)\n response = HTTParty.get(\"#{@host}/api/jobs/#{job_id}\")\n\n return response['job']\n end",
"def job_status_processed?\n if self.has_interpreter_assigned? && self.invoice_submitted? && self.completed?\n return true\n else\n return false\n end\n end"
] | [
"0.7153619",
"0.7117048",
"0.71071595",
"0.7082527",
"0.69060886",
"0.6898863",
"0.6862939",
"0.6821774",
"0.6779827",
"0.67699057",
"0.67117155",
"0.6661498",
"0.6643092",
"0.6625317",
"0.6611041",
"0.65927327",
"0.6582257",
"0.64325106",
"0.64257914",
"0.6416165",
"0.6416165",
"0.6332064",
"0.6312008",
"0.6289233",
"0.62831616",
"0.6272821",
"0.6243265",
"0.6234497",
"0.6205511",
"0.6181264",
"0.6144157",
"0.60815746",
"0.60719466",
"0.60658294",
"0.6059139",
"0.6036845",
"0.6036366",
"0.60028917",
"0.598525",
"0.5927634",
"0.5916691",
"0.59143054",
"0.5910581",
"0.5906281",
"0.588423",
"0.5882027",
"0.58737314",
"0.5870447",
"0.5865135",
"0.584226",
"0.58291656",
"0.5822683",
"0.58210725",
"0.5809838",
"0.58033717",
"0.5775956",
"0.5769213",
"0.57613075",
"0.5746947",
"0.5735336",
"0.57342917",
"0.57229483",
"0.57132",
"0.57100827",
"0.57091373",
"0.5706469",
"0.5706469",
"0.569467",
"0.569287",
"0.5687482",
"0.5678559",
"0.5671798",
"0.5658943",
"0.5652274",
"0.56516147",
"0.56472707",
"0.5637921",
"0.56376225",
"0.56286204",
"0.5626977",
"0.56153494",
"0.5612982",
"0.5610616",
"0.5607876",
"0.56064934",
"0.5594565",
"0.55911577",
"0.55803025",
"0.5574151",
"0.5571006",
"0.5560463",
"0.55599064",
"0.55522954",
"0.554634",
"0.5531138",
"0.5529909",
"0.5526947",
"0.55236965",
"0.55170375",
"0.55093515"
] | 0.60737044 | 32 |
Inner function to display the hash table when the job is complte | def display_job_status(job_status)
job_display_entries = {
"status" => job_status["status_description"],
"progress" => "#{job_status["progress"]}%",
"cluster_id" => job_status["cluster_id"],
"job submitted at" => job_status["start_timestamp"],
"job began running at" => job_status["running_timestamp"],
"job finished at" => job_status["stop_timestamp"],
"job running for" => job_status["duration"],
"job run with parameters" => job_status["parameters"],
}
unless job_status["error"].nil? || job_status["error"]["message"].nil?
error_context = get_error_message_context(job_status["error"]["message"])
unless error_context == ""
job_status["error"]["help"] = error_context
end
job_status["error"].each_pair do |key, value|
job_display_entries["error - #{key}"] = value
end
end
if job_status["num_hadoop_jobs"] && job_status["num_hadoop_jobs_succeeded"]
job_display_entries["hadoop jobs complete"] =
'%0.2f / %0.2f' % [job_status["num_hadoop_jobs_succeeded"], job_status["num_hadoop_jobs"]]
end
if job_status["outputs"] && job_status["outputs"].length > 0
job_display_entries["outputs"] = Hash[job_status["outputs"].select{|o| o["alias"]}.collect do |output|
output_hash = {}
output_hash["location"] = output["location"] if output["location"]
output_hash["records"] = output["records"] if output["records"]
[output['alias'], output_hash]
end]
end
styled_header("#{job_status["project_name"]}: #{job_status["pigscript_name"]} (job_id: #{job_status["job_id"]})")
styled_hash(job_display_entries)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def info_hash\n puts \"monitor{#@id} - jobs statuses: \"\n @j_hash.each do |key, value|\n puts \"#{key} : #{value}\"\n end\n puts \"-------------------------------\"\n end",
"def output_hash; end",
"def status\n job_id = shift_argument\n unless job_id\n error(\"Usage: mortar jobs:status JOB_ID\\nMust specify JOB_ID.\")\n end\n \n # Inner function to display the hash table when the job is complte\n def display_job_status(job_status)\n job_display_entries = {\n \"status\" => job_status[\"status_description\"],\n \"progress\" => \"#{job_status[\"progress\"]}%\",\n \"cluster_id\" => job_status[\"cluster_id\"],\n \"job submitted at\" => job_status[\"start_timestamp\"],\n \"job began running at\" => job_status[\"running_timestamp\"],\n \"job finished at\" => job_status[\"stop_timestamp\"],\n \"job running for\" => job_status[\"duration\"],\n \"job run with parameters\" => job_status[\"parameters\"],\n }\n\n \n unless job_status[\"error\"].nil? || job_status[\"error\"][\"message\"].nil?\n error_context = get_error_message_context(job_status[\"error\"][\"message\"])\n unless error_context == \"\"\n job_status[\"error\"][\"help\"] = error_context\n end\n job_status[\"error\"].each_pair do |key, value|\n job_display_entries[\"error - #{key}\"] = value\n end\n end\n \n if job_status[\"num_hadoop_jobs\"] && job_status[\"num_hadoop_jobs_succeeded\"]\n job_display_entries[\"hadoop jobs complete\"] = \n '%0.2f / %0.2f' % [job_status[\"num_hadoop_jobs_succeeded\"], job_status[\"num_hadoop_jobs\"]]\n end\n \n if job_status[\"outputs\"] && job_status[\"outputs\"].length > 0\n job_display_entries[\"outputs\"] = Hash[job_status[\"outputs\"].select{|o| o[\"alias\"]}.collect do |output|\n output_hash = {}\n output_hash[\"location\"] = output[\"location\"] if output[\"location\"]\n output_hash[\"records\"] = output[\"records\"] if output[\"records\"]\n [output['alias'], output_hash]\n end]\n end\n \n styled_header(\"#{job_status[\"project_name\"]}: #{job_status[\"pigscript_name\"]} (job_id: #{job_status[\"job_id\"]})\")\n styled_hash(job_display_entries)\n end\n \n # If polling the status\n if options[:poll]\n ticking(polling_interval) do |ticks|\n job_status = api.get_job(job_id).body\n # If the job is complete exit and display the table normally \n if Mortar::API::Jobs::STATUSES_COMPLETE.include?(job_status[\"status_code\"] )\n redisplay(\"\")\n display_job_status(job_status)\n break\n end\n\n # If the job is running show the progress bar\n if job_status[\"status_code\"] == Mortar::API::Jobs::STATUS_RUNNING\n progressbar = \"=\" + (\"=\" * (job_status[\"progress\"].to_i / 5)) + \">\"\n\n if job_status[\"num_hadoop_jobs\"] && job_status[\"num_hadoop_jobs_succeeded\"]\n hadoop_jobs_ratio_complete = \n '%0.2f / %0.2f' % [job_status[\"num_hadoop_jobs_succeeded\"], job_status[\"num_hadoop_jobs\"]]\n end\n\n printf(\"\\r[#{spinner(ticks)}] Status: [%-22s] %s%% Complete (%s MapReduce jobs finished)\", progressbar, job_status[\"progress\"], hadoop_jobs_ratio_complete)\n\n # If the job is not complete, but not in the running state, just display its status\n else\n redisplay(\"[#{spinner(ticks)}] Status: #{job_status['status_description']}\")\n end\n end\n # If not polling, get the job status and display the results\n else\n job_status = api.get_job(job_id).body\n display_job_status(job_status)\n end\n end",
"def display_job(job, timing)\n bench_pad = padding(benchmark_names, 3)\n\n puts job.header % [\n job.name.ljust(bench_pad),\n timing.rounded(:iterations_per_second),\n timing.iterations,\n timing.rounded(:duration)\n ]\n end",
"def all_results(job)\n # if need smaller windows use this print statement\n printf(\"%-40<title>s%-40<salary_range>s%-16<app_deadline>s\\n\",\n title: job.title.to_s, salary_range: job.salary_range.to_s, app_deadline: job.app_deadline.to_s)\n # printf(\"%-40<title>s%-35<department>s%-40<salary_range>s%-20<app_deadline>s\\n\",\n # title: job.title.to_s, department: job.department.to_s,\n # salary_range: job.salary_range.to_s, app_deadline: job.app_deadline.to_s)\n end",
"def hash\n swap\n scatter\n completed_string\n end",
"def show boook\n\t\t\tputs @hash\n\t\t\t\n\t\tend",
"def billing_history_hashes\n expand(billing_information_icon)\n show_billing_history_link.click\n wait_until { !billing_history_table.hashes.first.values.first.nil? }\n billing_history_table.hashes\n end",
"def print_prime_table\n out = ''\n prime_array = print_prime\n top_line = \"\\t#{prime_array.join(\"\\t\")}\"\n out += top_line + \"\\n\"\n for prime_row in prime_array\n line = \"\"\n line += \"#{prime_row}\\t\"\n for prime_col in prime_array\n line += \"#{prime_row * prime_col}\\t\"\n end\n out += line + \"\\n\"\n end\n out\n end",
"def display_jobs\n jobs = SearchJobs::Jobs.all\n\n jobs.each.with_index(1) do |job, index|\n puts \"#{index}.\".colorize(:red) + \"==========#{job.company.upcase.strip}=========\".colorize(:yellow)\n puts \"#{job.name.upcase}\".colorize(:blue)\n end\n end",
"def display_branch_list\n table = build_table_view\n\n puts \"\\n\\n\"\n puts table\n end",
"def jobs_and_temp_reg(job)\n printf(\"%-50<title>s%-24<tempreg>s\\n\", title: job.title.to_s, tempreg: job.temp_reg.to_s)\n end",
"def printHashTable\n puts \"Hash: \"\n @letterHash.each_pair{ |k,v| puts \"#{k}: #{v}\"}\n end",
"def show_job_details(job)\n @scraper.scrape_details(job)\n job.print_info\n job\n end",
"def hash_printer(hash)\n puts \"Grocery List\"\n hash.each do |key, value|\n puts \"You need #{value} #{key}(s).\"\n end\nend",
"def hashes(to = $stdout)\n hashes = {}\n \n ObjectSpace.each_object(Hash) do |hash|\n begin\n keys_orig = hash.keys.sort\n rescue ArgumentError\n #When unable to sort regexps...\n next\n end\n \n keys = []\n keys_orig.each do |key|\n keys << key.to_s\n end\n \n if keys.empty?\n keystr = :empty\n else\n keystr = keys.join(\":\")\n end\n \n if !hashes.key?(keystr)\n hashes[keystr] = 1\n else\n hashes[keystr] += 1\n end\n end\n \n hashes.delete_if do |key, val|\n val < 100\n end\n \n hashes = Knj::ArrayExt.hash_sort(hashes) do |h1, h2|\n h2[1] <=> h1[1]\n end\n \n to.print \"<h1>Hashes</h1>\\n\"\n to.write \"<table class=\\\"hashes list\\\">\\n\"\n to.write \"\\t<thead>\\n\"\n to.write \"\\t\\t<tr>\\n\"\n to.write \"\\t\\t\\t<th>Hash keys</th>\\n\"\n to.write \"\\t\\t\\t<th>Instances</th>\\n\"\n to.write \"\\t\\t</tr>\\n\"\n to.write \"\\t</thead>\\n\"\n to.write\"\\t<tbody>\\n\"\n \n hashes.each do |key, val|\n to.write \"\\t\\t<tr>\\n\"\n to.write \"\\t\\t\\t<td>#{Knj::Web.html(key)}</td>\\n\"\n to.write \"\\t\\t\\t<td>#{Knj::Locales.number_out(val, 0)}</td>\\n\"\n to.write \"\\t\\t</tr>\\n\"\n end\n \n to.write \"\\t</tbody>\\n\"\n to.write \"</table>\\n\"\n end",
"def print_hash(list)\nputs \"Current grocery list:\"\nputs \"---------------------\"\nlist.each do |item_name, item_quant|\n puts \" #{item_name}: #{item_quant}\"\nend\nend",
"def display(hashName)\n system \"clear\" \n puts \"Aluno: Notas [ N1, N2, N3, Media ] cadastradas:\"\n puts \"----------------------------------\"\n hashName.each do |a, b|\n puts \"#{a}: \\t #{b}\"\n end\n puts \"----------------------------------\"\n countKeys = hashName.keys.count\n puts \"[ #{countKeys} ] aluno(s) cadastrado(s)\"\n voltar\nend",
"def show_table(game_status)\n prompt \"================================\"\n prompt \"================================\"\n prompt \"#{game_status[:current_game_status]}\"\n prompt \"================================\"\n prompt \"================================\"\nend",
"def show_table(game_status)\n prompt \"================================\"\n prompt \"================================\"\n prompt \"#{game_status[:current_game_status]}\"\n prompt \"================================\"\n prompt \"================================\"\nend",
"def bin_status\n rows = []\n\n # loop through to find all available bin space\n self.bins.each do |bin|\n rows << [bin.type, \"#{bin.bin_level}%\"]\n end\n # Drawing and styling the table\n table = Terminal::Table.new :rows => rows\n table = Terminal::Table.new :title => ' Your available bin space '.light_white.on_light_red, :headings => ['Bin type'.light_white, 'How much used'.light_white], :rows => rows, :style => {:width => 100, :padding_left => 1, :border_x => \"=\"}\n\n puts table\n end",
"def hash\n [ auto_compress_pictures , auto_recover , build_version , calc_mode , calc_stack_size , calculation_id , check_comptiliblity , check_excel_restriction , crash_save , create_calc_chain , data_extract_load , date1904 , display_drawing_objects , enable_macros , first_visible_tab , hide_pivot_field_list , is_default_encrypted , is_hidden , is_h_scroll_bar_visible , is_minimized , is_v_scroll_bar_visible , iteration , language_code , max_change , max_iteration , memory_setting , number_decimal_separator , number_group_separator , parsing_formula_on_open , precision_as_displayed , recalculate_before_save , re_calculate_on_open , recommend_read_only , region , remove_personal_information , repair_load , shared , sheet_tab_bar_width , show_tabs , update_adjacent_cells_border , update_links_type , window_height , window_left , window_top , window_width ].hash\n end",
"def available_bin_space(current_house)\n rows = [] \n # loop through the houses array, displaying available space in both kinds of bins\n self.houses.each do |house|\n if house.contact_name != current_house.contact_name\n rows << [house.house_number, house.street.name, house.contact_name, house.general_bin_space, house.recycle_bin_space, house.green_bin_space] \n end\n end \n \n # Drawing and styling the table\n table = Terminal::Table.new :rows => rows\n table = Terminal::Table.new :title => ' Your neighbours available bin space '.light_white.on_light_red, :alignment => :center, \n :headings => ['House number'.light_white, 'Street name'.light_white, 'Contact name'.light_white, 'General'.red, 'Recycle'.light_yellow, 'Green'.green], :rows => rows, :style => {:width => 100, :padding_left => 1, :border_x => \"=\"}\n puts table\n end",
"def spending_table(hash, total)\n puts \"\".center(80, \"_\")\n hash.each{ |item, value| puts tabled_format(item, value) }\n puts \"\".center(80, \"_\")\n total = hash.values.inject(:+)\n puts tabled_format(\"Total\", total)\n end",
"def print_job\n @scanjob = Scanjob.find(params[:id])\n update_scanjob_state(@scanjob)\n\n render :template => 'admin/scanjobs/print_job', :layout => 'print'\n end",
"def table_summary(summary_hash)\n header = [\n 'label', 'tps', 'error_percent', 'mean', 'median', '75th', '95th', '99th'\n ]\n data_rows = []\n labels = summary_hash.keys\n labels.delete('ALL')\n labels << 'ALL'\n labels.each do |label|\n row = []\n header.each do |key|\n if key == 'error_percent'\n error_perc = summary_hash[label][key]\n error_perc = error_perc.to_s.red if error_perc > 0\n row << error_perc\n elsif key == 'label'\n final_label = label\n final_label = label.green if label == 'ALL'\n row << final_label\n else\n row << summary_hash[label][key]\n end\n end\n data_rows << row\n end\n puts Terminal::Table.new headings: header, rows: data_rows\n return data_rows\nend",
"def print_table\n\t\t@start_map.each {|k,v|\n\t\t\tr = @end_map[k]\n\t\t\tdiff = r-v\n\t\t\tputs \"#{k} => #{v} | #{r} diff #{diff}\"\n\t\t}\n end",
"def recent_records_table\n rows = @recent_records.reverse.collect { | rec |\n stringifier = RecordStringifier.new(rec)\n state = if rec.running?\n b(\"running\")\n elsif rec.paused?\n \"paused\"\n else\n ''\n end\n tr({:bgcolor => BodyBlueFill},\n td(stringifier.full_job_name),\n td(stringifier.start_date_time),\n td(stringifier.cumulative_hours),\n td(state)) }\n \n table({:align => 'center', :width => '66%', :border => \"1\",\n :cellspacing => \"0\", :cellpadding => \"3\"},\n tr({:bgcolor => HeaderBlueFill},\n td({:align => \"center\", :colspan => \"4\" },\n 'Recent Records')),\n *rows)\n end",
"def prepare_fasta_hhviz_histograms_etc\n # Reformat query into fasta format ('full' alignment, i.e. 100 maximally diverse sequences, to limit amount of data to transfer)\n @commands << \"#{HH}/hhfilter -i #{@basename}.a3m -o #{@local_dir}/#{job.jobid}.reduced.a3m -diff 100\"\n @commands << \"#{HH}/reformat.pl a3m fas #{@local_dir}/#{job.jobid}.reduced.a3m #{@basename}.fas -d 160\" # max. 160 chars in description \n \n # Reformat query into fasta format (reduced alignment) (Careful: would need 32-bit version to execute on web server!!)\n @commands << \"#{HH}/hhfilter -i #{@basename}.a3m -o #{@local_dir}/#{job.jobid}.reduced.a3m -diff 50\"\n @commands << \"#{HH}/reformat.pl -r a3m fas #{@local_dir}/#{job.jobid}.reduced.a3m #{@basename}.reduced.fas\"\n @commands << \"rm #{@local_dir}/#{job.jobid}.reduced.a3m\"\n \n # Generate graphical display of hits\n @commands << \"#{HH}/hhviz.pl #{job.jobid} #{job.job_dir} #{job.url_for_job_dir} &> /dev/null\"\n \n # Generate profile histograms\n @commands << \"#{HH}/profile_logos.pl #{job.jobid} #{job.job_dir} #{job.url_for_job_dir} 1>> #{job.statuslog_path} 2>> #{job.statuslog_path}\"\n end",
"def inspect_jobs(index = nil)\n return empty_msg if empty?\n desc = []\n puts \"\\n\"\n @jobs.each_with_index do |j, i|\n unless index.nil?\n next unless i == index\n end\n desc << '| Job: ' + \" #{i + 1} \".rjust(8) + '|' + 'Pattern/AIV:'.rjust(18) + \" #{j.pattern.basename}\".ljust(125) + '|'\n desc << '| |' + 'Compiler ID:'.rjust(18) + \" #{j.id} \".ljust(125) + '|'\n desc << '| |' + 'AVC Files:'.rjust(18) + \" #{j.count} \".ljust(125) + '|'\n desc << '| |' + 'Output Directory:'.rjust(18) + \" #{j.output_directory} \".ljust(125) + '|'\n desc << '| |' + '.avc directory:'.rjust(18) + \" #{j.avc_dir} \".ljust(125) + '|'\n desc << '| |' + '.binl directory:'.rjust(18) + \" #{j.binl_dir} \".ljust(125) + '|'\n desc << '| |' + 'LSF:'.rjust(18) + \" #{j.location == :lsf ? true : false} \".ljust(125) + '|'\n desc << '| |' + 'Delete log files:'.rjust(18) + \" #{j.clean} \".ljust(125) + '|'\n desc << '| |' + 'Verbose:'.rjust(18) + \" #{j.verbose} \".ljust(125) + '|'\n if j.aiv2b_opts && j.aiv2b_opts.is_a?(String)\n aiv2b_opts = j.aiv2b_opts.gsub('AI_V2B_OPTIONS ', '')\n else\n aiv2b_opts = render_aiv2b_options_line.gsub('AI_V2B_OPTIONS', '')\n end\n desc << '| |' + 'AI_V2B Options:'.rjust(18) + \" #{aiv2b_opts} \".ljust(125) + '|'\n desc << '-' * desc.first.size\n end\n puts desc.flatten.join(\"\\n\")\n end",
"def hash_print (hash)\n\thash.each do |k,v|\n\t\tputs \"#{k} #{v} students\"\n\tend\nend",
"def autogrow_hashes\n wait_until_bus_section_load\n tables.last.hashes\n end",
"def display_table(orders)\n table_hash = Hash.new([])\n tables = []\n items = []\n orders.each do |order|\n items << order[2]\n if !table_hash.has_key?(order[1])\n table_hash[order[1]] = []\n end\n table_hash[order[1]] << order[2]\n end\n\n header = items.uniq.sort.unshift(\"Table\")\n tables << header\n table_hash.keys.map {|key| key.to_i}.sort.each do |table|\n table = table.to_s\n hash = Hash.new(0)\n table_order = table_hash[table]\n table_order.each do |item|\n if !hash.has_key?(item)\n hash[item] = 0\n end\n hash[item] += 1\n end\n new_row = [table]\n items.uniq.sort.each do |item|\n if !hash.has_key?(item)\n hash[item] = 0\n end\n new_row << hash[item].to_s\n end\n tables << new_row\n end\n\n return tables\nend",
"def display_table\n loc = 1\n for card in @cards_showing\n print (\"\\e[0m#{loc}\".ljust(8, \" \") + \"#{card.display_card}\" + \" \".ljust(20, \" \"))\n loc += 1\n puts \"\" if (loc % 2 != 0) || (loc == (@table_size + 1) && @table_size != @table_max)\n end\n\n print \"\\e[0m\"\n end",
"def print_prime_table(n_primes)\n out = ''\n prime_array = is_prime_new(n_primes)\n top_line = \"\\t#{prime_array.join(\"\\t\")}\"\n out += top_line + \"\\n\"\n for prime_row in prime_array\n line = \"\"\n line += \"#{prime_row}\\t\"\n for prime_col in prime_array\n line += \"#{prime_row * prime_col}\\t\"\n end\n out += line + \"\\n\"\n end\n out\nend",
"def jobs_history_key\n \"stats:jobs:#{self.name}:history\"\n end",
"def hash\n [name, displayname, schedule, timezone, owner, owner_email, success_count, error_count, last_success, last_error, disabled, tags, metadata, retries, parent_job, dependent_jobs, processors, concurrency, executor, executor_config, status].hash\n end",
"def prettyfie_list(hash)\r\n puts \"This is your current grocery list:\"\r\n puts \"\\n\"\r\n hash.each {|key, value| puts \"#{key} quantity = #{value}\" }\r\n puts \"\\n\"\r\nend",
"def status\n if @item_count === 0.0\n puts \"There are no entries in this hash.\"\n puts \"Load Factor for hash is 0.\"\n else\n @items.each do |pair|\n unless pair.nil?\n index = self.index(pair.key, @items.length)\n puts \"Entry #{pair} is located at Index #{index} and has a value of \" + \"\\\"\" + \"#{pair.value}\" + \"\\\"\" + \".\"\n end\n end\n puts \"Load Factor for hash is #{@item_count / @items.length}.\"\n end\n end",
"def task_report\n print \"task #{@name} is #{@state}\"\n case @state\n when 'waiting' ; puts \"\"\n when 'running'\n puts \" and \"+VT100.RED(\"has not completed\")+\" because\"\n @emits.each { |event_name|\n event = @joblist.find(event_name)\n event.report_consumers(@joblist)\n }\n end\n end",
"def echo_hash(name,hash,headers=[])\n content = \"<h3>#{name}</h3><table class=\\\"pure-table\\\">\"\n if !headers.empty?\n content += \"<thead><tr>\"\n headers.each do |title|\n content += \"<th>#{title}</th>\"\n end\n content += \"</tr></thead>\"\n end\n content += \"<tbody>\"\n alt = true\n hash.each do |key,value|\n if alt\n content += \"<tr class=\\\"pure-table-odd\\\"><td>#{key}</td>\"\n else\n content += \"<tr><td>#{key}</td>\"\n end\n alt = !alt\n if value.is_a?(Hash)\n value.each do |sk,sv|\n content += \"<td>#{sv}</td>\"\n end\n content += \"</tr>\"\n else\n content += \"<td>#{value}</td></tr>\"\n end\n end\n content += '</tbody></table>'\n @body += content\n self\n end",
"def display_jobs(jobs)\n\n clear_screen\n\n @last_results = jobs\n\n choices = []\n choices << {name: 'Return to Menu'.colorize(:magenta), value: 'menu'}\n choices << {name: 'Exit'.colorize(:red), value: 'exit'}\n\n choices += jobs.map.with_index(1) {|job, idx| {name: \"#{job.job_summary}\".colorize(:light_blue), value: idx} }\n jobSelection = prompt.select(\"Select a job posting (use the left and right arrows to navigate pages)\\n#{'_'*(@screen_size-1)} \".colorize(:white), choices, per_page: 35)\n\n if jobSelection == \"exit\"\n farewell_message\n exit\n elsif jobSelection == \"menu\"\n job = \"menu\"\n else\n job = jobs.find.with_index {|job, idx| jobSelection == idx }\n end\n\n\n return job\n end",
"def inspect_jobs(index = nil)\n return empty_msg if empty?\n desc = []\n puts \"\\n\"\n @jobs.each_with_index do |j, i|\n unless index.nil?\n next unless i == index\n end\n desc << '| Job: ' + \"#{i + 1} \".rjust(8) + '|' + 'Pattern:'.rjust(18) + \" #{j.pattern.basename}\".ljust(120) + '|'\n desc << '| |' + 'Compiler ID:'.rjust(18) + \" #{j.id} \".ljust(120) + '|'\n desc << '| |' + 'Pinmap:'.rjust(18) + \" #{j.pinmap_workbook} \".ljust(120) + '|'\n desc << '| |' + '.atp directory:'.rjust(18) + \" #{j.pattern.dirname} \".ljust(120) + '|'\n desc << '| |' + '.pat directory:'.rjust(18) + \" #{j.output_directory} \".ljust(120) + '|'\n desc << '| |' + 'LSF:'.rjust(18) + \" #{j.location == :lsf ? true : false} \".ljust(120) + '|'\n desc << '| |' + 'Delete log files:'.rjust(18) + \" #{j.clean} \".ljust(120) + '|'\n desc << '| |' + 'Verbose:'.rjust(18) + \" #{j.verbose} \".ljust(120) + '|'\n fragment = '| |' + 'Compiler args:'.rjust(18)\n overflow_fragment = '| |' + ' '.rjust(18)\n compiler_args = []\n compiler_fragment = ''\n j.compiler_options.each_key do |k|\n if compiler_fragment.size + \" -#{k}\".size >= 120\n compiler_args << compiler_fragment\n compiler_fragment = nil\n end\n compiler_fragment += \" -#{k}\"\n end\n compiler_args << compiler_fragment unless compiler_fragment.nil?\n compiler_fragment = ''\n j.compiler_options_with_args.each_pair do |k, v|\n if compiler_fragment.size + \" -#{k}:#{v}\".size >= 120\n compiler_args << compiler_fragment\n compiler_fragment = nil\n end\n compiler_fragment += \" -#{k}:#{v}\"\n end\n compiler_args << compiler_fragment unless compiler_fragment.nil?\n if compiler_args.join.length <= 120\n desc << fragment + \"#{compiler_args.join}\".ljust(120) + '|'\n else\n # Need to cycle through compiler args and build a fragment <= 100 characters\n # and print it. Keep going until the remaining args is <= 100 and print again\n char_cnt = 0\n line_cnt = 0\n args = []\n compiler_args = compiler_args.join.strip.split(/\\s+/)\n until compiler_args.empty?\n args = compiler_args.select { |e| (char_cnt += e.length + 1) < 120 }\n # remove the args that fit on the first line\n compiler_args -= args\n if line_cnt == 0\n desc << fragment + \" #{args.join(' ')}\".ljust(120) + '|'\n else\n desc << overflow_fragment + \" #{args.join(' ')}\".ljust(120) + '|'\n end\n args = []\n line_cnt += 1\n char_cnt = 0\n end\n end\n desc << '-' * desc.first.size\n end\n puts desc.flatten.join(\"\\n\")\n end",
"def hash\n @table.hash\n end",
"def job_buttons_xhtml\n names = @jobs.values.collect { | job | job.full_name }.sort\n names.collect { | name |\n body_row(submit('name', name))\n }\n end",
"def product_component_print(product)\n sgc= \"<table>\"\n if(product.components.empty?)\n sgc+= \"<tr><td>No Components Available </td></tr>\"\n else\n for comp in product.components.sort {|x,y| x.name <=> y.name }\n sgc+= \"<tr><td>#{link_to comp.name, comp}</td></tr>\"\n end\n\n end\n sgc+= \"</table>\"\n return sgc\n end",
"def print_details(job)\n printf \"-----------------------------------------------------------------------------------\\n\"\n printf(\"\\nTitle: %<title>s\\n\", title: job.title.to_s)\n printf(\"Department: %<department>s\\n\", department: job.department.to_s)\n printf(\"Application Deadline: %<deadline>s\\n\", deadline: job.app_deadline.to_s)\n printf(\"Salary Range: %<salary>s\\n\", salary: job.salary_range.to_s)\n printf(\"Positions Available: %<avail>s\\n\", avail: job.pos_available.to_s)\n printf(\"Job Category: %<cat>s\\n\", cat: job.category.to_s)\n printf(\"Job Appointment (FTE): %<fte>s\\n\", fte: job.fte.to_s)\n printf(\"Full/Part Time: %<fullpart>s\\n\", fullpart: job.full_part.to_s)\n printf(\"Temporary or Regular: %<tempreg>s\\n\", tempreg: job.temp_reg.to_s)\n printf(\"Posting Start Date: %<date>s\\n\", date: job.start_date.to_s)\n printf(\"Positing End Date: %<date>s\\n\", date: job.end_date.to_s)\n printf(\"Department Contact Name: %<name>s\\n\", name: job.contact_name.to_s)\n printf(\"Department Contact Phone: %<phone>s\\n\", phone: job.contact_phone.to_s)\n printf(\"\\nSummary:\\n %<duties>s\\n\", duties: job.duties_summary.to_s)\n printf(\"\\nRequired Qualifications:\\n %<qual>s\\n\", qual: job.req_qualifications.to_s)\n printf(\"\\nDesired Qualifications:\\n %<qual>s\\n\", qual: job.des_qualifications.to_s)\n end",
"def print_all_cells\n # for each active cell\n \t@cell_list.each{|cell|\n \t\t\tcelltype = cell.get_celltype\n \t\t\tcall_funcs = {}\n \t\tif celltype.is_active? then\n \t\t\tif ! celltype.kind_of? CompositeCelltype then\n\t\t \t\tprint \"[active cell] #{cell.get_namespace_path}\"\n print_locale cell.get_locale\n print \"\\n\"\n\t\t \t\tcell.get_join_list.get_items.each{ |j|\n\t\t \t\t\tif j.get_definition.kind_of? Port then\n\t\t \t\t\t\tport = j.get_definition\n\t\t\t \t\t\tport.get_signature.get_function_head_array.each{ |f|\n\t\t\t \t\t\t func_name = \"->#{port.get_name}.#{f.get_name}__T\".to_sym\n\t\t\t \t\t\t call_funcs[ func_name ] = false\n\t\t \t\t\t\t}\n\t\t \t\t\tend\n\t\t \t\t}\n # isn't the call port function called from entry port function ?\n # if called, it's not actually active (task main, handler main is not called from entry function)\n \t\t\t\tcelltype.get_port_list.each{ |ep|\n \t\t\t\t\tif ep.get_port_type == :ENTRY then\n \t\t\t\t\t\tep.get_signature.get_function_head_array.each{ |f|\n \t\t\t\t\t\t\tep_func = \"#{celltype.get_global_name}_#{ep.get_name}_#{f.get_name}\".to_sym\n\t \t\t\t\t\t\tif $tcflow_funclist[ ep_func ] then\n\t \t\t\t\t\t\t\t$tcflow_funclist[ ep_func ].get_call_funcs.each{ |cf, cff|\n if call_funcs[cf] == false then\n # printf \"#{ep_func} calls #{cf}\\n\"\n call_funcs[cf] = true\n end\n\t \t\t\t\t\t\t\t}\n\t \t\t\t\t\t\telse\n\t \t\t\t\t\t\t\tprint \"ep_func #{ep_func} not found. why not defined ?\\n\"\n\t \t\t\t\t\t\tend\n \t\t\t\t\t\t}\n \t\t\t\t\tend\n \t\t\t\t}\n call_funcs.each{ |call_func_name, v|\n if v == false then # not called from entry port func\n # print \" #{f} \\n\"\n # decompose\n indent_level = 1\n no_caller_cell = true\n cell.print_call_func_flow no_caller_cell, call_func_name, indent_level\n end\n }\n\t\t \tend\n\t \tend\n \t}\n \t@namespace_list.each{|ns|\n \t\tns.print_all_cells\n \t}\n \tif false then\n \t\t$tcflow_funclist.each{|name, func|\n \t\t\tprint name, \"\\n\"\n \t\t\tif func.kind_of? TCFlow::Function then\n\t \t\t\tfunc.get_call_funcs.each{ |cname,cfunc|\n \t\t\t\t\tprint \" -> \", cname, \"\\n\"\n \t\t\t\t}\n \t\t\tend\n \t\t}\n \tend\n end",
"def display_progress\n\t\t@progress_key.join(\" \")\n\tend",
"def printable\n asPrintable = \"\"\n doCount = 0 # way to keep track of the entries loop so a new line can be added to the end of the concat string\n @entries.sort.each do |keyWord, value|\n asPrintable += \"[#{keyWord}] \\\"#{value}\\\"\"\n if doCount < @entries.length - 1 # in order for test to pass, it cant have a extra line at the end\n asPrintable += \"\\n\" # only add one if not the last element of the hash\n end\n doCount += 1 # each loop adds one\n end\n asPrintable # return concat string\n end",
"def available_recycle_space\n rows = []\n \n # puts \"Current: #{house.contact_name}\"\n current_house = house.contact_name\n # loop through to find all available recycling bin space\n self.houses.each do |house|\n if house.contact_name != current_house.contact_name\n rows << [house.house_number, house.street, house.contact_name, house.recycle_bin_space]\n end\n end\n # Drawing and styling the table\n table = Terminal::Table.new :rows => rows\n table = Terminal::Table.new :title => 'Available Recycling Bin Space'.magenta, :alignment => :center, \n :headings => ['House number'.green, 'Street name'.green, 'Contact'.green, 'Recycle'.green], :rows => rows\n\n puts table\n end",
"def print_list(hash)\n puts \"Grocery List\"\n hash.each do |item|\n puts item\nend\nend",
"def hash\n [paginate_sheets, count_rows_per_page, count_columns_per_page, render_grid_lines, render_empty_rows, render_empty_columns, render_hidden_rows, render_hidden_columns, render_headings, render_print_area_only, text_overflow_mode].hash\n end",
"def list\n puts \"\\n\\n#{Job.count} job postings found\\n\\n\"\n Job.list.map do |job|\n puts \"#{job.id}. #{job.firstline}\"\n end\n puts menu\n end",
"def print_info\n\n puts \"\\e[H\\e[2J\" # clear terminal screen\n\n # print the listing title\n print \"#{@@white}Job Title: #{@@green}#{self.title}\\n\"\n\n\n # print the time left to bid\n print \"\\t#{@@white}Time Left: #{@@green}#{self.time_left}\\n\"\n\n # print the budget for the job if valid\n if self.budget\n print \"\\t#{@@white}Budget: #{@@green}#{self.budget}\\n\"\n end\n\n # print the tags associated with the listing\n print \"\\t#{@@white}Tags: #{@@green}#{self.tags.join(',')}\\n\"\n\n # print the number of bids if valid\n if self.bids\n print \"\\n\\t#{@@white}Bids: #{@@green}#{self.bids}\\n\"\n end\n\n # print the average bid if valid\n if self.avg_bid\n print \"\\t#{@@white}Average Bid: #{@@green}#{self.avg_bid}\\n\"\n end\n\n # display the summary of bids at the momment\n print \"\\t#{@@white}Bid Summary: #{@@green}#{self.bid_summary}\\n\" if self.bid_summary\n\n # if we don't have the main description then print the short_description otherwise print the main description\n print \"\\t#{@@white}Description: \\n#{@@green}\"\n if self.description == nil\n # print \"#{self.short_description}\\n\\n\".green # put a .each_line block here and add \\t\\t to space it out properly\n desc = self.short_description\n else\n # print \"#{self.description}\\n\\n\".green\n desc = self.description\n end\n\n # fix the formating issues by indenting each line with tabs twice\n desc.each_line {|line| print \"\\t\\t#{@@green}#{line}\\n\"}\n\n print \"#{@@reset}\"\n end",
"def printhash(hash)\n puts \"-----------------------\"\n hash.each { |item, qty| \n puts \"#{item},\\n qty: #{qty}\"\n puts \"\"\n }\n puts \"-----------------------\"\nend",
"def hash\n [sequence_number, corporate_number, process, correct, update_date, change_date, name, name_image_id, kind, prefecture_name, city_name, street_number, address_image_id, prefecture_code, city_code, post_code, address_outside, address_outside_image_id, close_date, close_cause, successor_corporate_number, change_cause, assignment_date, latest, en_name, en_prefecture_name, en_city_name, en_address_outside, furigana, hihyoji].hash\n end",
"def render_hash(hsh)\n str = \"\"\n indiff_hsh = hsh.with_indifferent_access\n indiff_hsh.keys.sort.each do |key|\n str << \"#{key}: \"\n value = indiff_hsh[key]\n PP::pp(value, str)\n end\n str\n end",
"def print\n puts \"Multiplication Table of Prime Numbers\"\n table = Terminal::Table.new :title => \"#{(grid.length - 1).to_s} prime numbers\" do |t|\n \n # For each prime number, create a row\n for x in 0..(grid.length - 1) do\n\n # Start each row with the prime number\n row = [nil]\n \n for y in 0..(grid.length - 1) do\n row << grid[x][y]\n end\n \n # Add the row as well as a seperator for every row, except the last\n t << row\n t << :separator unless x == (grid.length)\n end\n \n end\n puts table\n end",
"def report_table(output, sort, options = {}, &block)\n output.puts\n\n top_categories = output.slice_results(sorted_by(sort))\n output.with_style(:top_line => true) do \n output.table(*statistics_header(:title => options[:title],:highlight => sort)) do |rows|\n top_categories.each { |(cat, info)| rows.push(statistics_row(cat)) }\n end\n end\n output.puts\n end",
"def supp_plan_hashes(index = 2)\n wait_until_bus_section_load\n tables[index].hashes\n end",
"def inspect\t\t\n\t\tmsg = '{'\n\t\t@hash.each_with_index do |info, index|\n\t\t\tmsg += info.to_s\n\t\t\tmsg += \", \" if @hash.size > 1 and index + 1 < @hash.size \n\t\tend\n\t\tmsg += '}'\n\t\tmsg\n\tend",
"def print_list(hash)\n\tputs \"\" \n hash.each do |item, qty|\n puts \"#{item}: #{qty}\\n\"\n end\nend",
"def show_primer_table primer_tab, primers_over_60, primers_over_90\n data = show do\n title \"Create an IDT DNA oligos order\"\n \n warning \"Oligo concentration for primer(s) #{primers_over_60} will have to be set to \\\"100 nmole DNA oligo.\\\"\" if primers_over_60 != \"\"\n warning \"Oligo concentration for primer(s) #{primers_over_90} will have to be set to \\\"250 nmole DNA oligo.\\\"\" if primers_over_90 != \"\"\n \n #check \"Click Custom DNA Oligos, click Bulk Input. Copy paste the following table and then click the Update button.\"\n \n check \"Under \\\"Custom DNA Oligos\\\", click \\\"DNA Oligos\\\", then under \\\"Single-stranded DNA\\\" click \\\"Order now\\\", and click \\\"Bulk input\\\". Copy and paste the following table there.\"\n table primer_tab\n \n check \"Click Add to Order, review the shopping cart to double check that you entered correctly. There should be #{operations.length} primers in the cart.\"\n check \"Click Checkout, then click Continue.\"\n check \"Enter the payment information, click the oligo card tab, select the Card1 in Choose Payment and then click Submit Order.\"\n check \"Go back to the main page, let it sit for 5-10 minutes, return and refresh, and find the order number for the order you just placed.\"\n \n get \"text\", var: \"order_number\", label: \"Enter the IDT order number below\", default: 100\n end\n\n operations.each { |op| op.set_output_data(\"Primer\", :order_number, data[:order_number]) }\n end",
"def show_table\n build_html do\n if paths.keys.length == 0\n div.which_filesets do\n span \"Did not find any shipped files matching #{path}\"\n end\n else\n table.which_filesets do\n thead do\n tr do\n th '#'\n th 'Path'\n th 'Lpp'\n end\n end\n tbody do\n index = 0\n paths.each_pair do |path, lpps|\n lpps.each do |lpp|\n tr do\n td index += 1\n td path\n td link_to(lpp, swinfo_get_path(lpp))\n end\n end\n end\n end\n end\n end\n end\n end",
"def display_current(game_hash)\n\treset_screen\n\tputs pretty_board(hash_to_array(game_hash))\n\tsleep(0.001)\nend",
"def show_hash(students)\nstudents.each {|key, value| puts \"#{key}: #{value} students\" }\nend",
"def hash\n [activity_id, blueprint_id, blueprint_location_id, blueprint_type_id, completed_character_id, completed_date, cost, duration, end_date, facility_id, installer_id, job_id, licensed_runs, output_location_id, pause_date, probability, product_type_id, runs, start_date, station_id, status, successful_runs].hash\n end",
"def comparing(job_one, job_two)\n printf \"-----------------------------------------------------------------------------------\\n\"\n print \"\\nTitle:\".ljust(35) + job_one.title.to_s.ljust(35) + job_two.title.to_s.ljust(35)\n print \"\\nDepartment:\".ljust(35) + job_one.department.to_s.ljust(35) + job_two.department.to_s.ljust(35)\n print \"\\nApplication Deadline:\".ljust(35) + job_one.app_deadline.to_s.ljust(35)\n print job_two.app_deadline.to_s.ljust(35)\n print \"\\nSalary Range:\".ljust(35) + job_one.salary_range.to_s.ljust(35) + job_two.salary_range.to_s.ljust(35)\n print \"\\nPositions Available:\".ljust(35) + job_one.pos_available.to_s.ljust(35)\n print job_two.pos_available.to_s.ljust(35)\n print \"\\nJob Catergory:\".ljust(35) + job_one.category.to_s.ljust(35) + job_two.category.to_s.ljust(35)\n print \"\\nJob Appointment (FTE):\".ljust(35) + job_one.fte.to_s.ljust(35) + job_two.fte.to_s.ljust(35)\n print \"\\nFull/Part Time:\".ljust(35) + job_one.full_part.to_s.ljust(35) + job_two.full_part.to_s.ljust(35)\n print \"\\nTemporary or Regular:\".ljust(35) + job_one.temp_reg.to_s.ljust(35) + job_two.temp_reg.to_s.ljust(35)\n print \"\\nPosting Start Date:\".ljust(35) + job_one.start_date.to_s.ljust(35) + job_two.start_date.to_s.ljust(35)\n print \"\\nPosting End Date:\".ljust(35) + job_one.end_date.to_s.ljust(35) + job_two.end_date.to_s.ljust(35)\n print \"\\nDepartment Contact Name:\".ljust(35) + job_one.contact_name.to_s.ljust(35)\n print job_two.contact_name.to_s.ljust(35)\n print \"\\nDepartment Contact Phone:\".ljust(35) + job_one.contact_phone.to_s.ljust(35)\n print job_two.contact_phone.to_s.ljust(35) + \"\\n\"\n end",
"def tasks_info\n all_tasks = Set.new\n all_job_info = {}\n history.each_key do |cycle_index|\n tasks, job_info = tasks_info_of_snapshot(cycle_index)\n all_tasks.merge(tasks)\n all_job_info.merge!(job_info)\n end\n [all_tasks, all_job_info]\n end",
"def pretty_list(hash)\r\n puts \"Grocery List:\"\r\n puts \" \"\r\n hash.each do |item_name, quantity|\r\n puts \"#{item_name}: #{quantity}\"\r\n end\r\nend",
"def create_job_hash\n input_feed = Feedjira::Feed.fetch_and_parse('https://www.jobsatosu.com/all_jobs.atom ')\n feed_entries = input_feed.entries\n @jobs = Hash.new\n feed_entries.each do |fe|\n discription = ActionView::Base.full_sanitizer.sanitize(fe.content)\n if discription.length > 500\n short_discription = discription[0..500]+\"...\"\n else\n short_discription = discription\n end\n link = fe.links[0]\n @jobs[fe.entry_id] = \n {published: fe.published,\n updated: fe.updated,\n url: fe.url,\n links: link,\n title: fe.title,\n content: short_discription,\n full_content: discription,\n department: fe.author} \n end\n @jobs\n end",
"def job_properties(job)\n job.properties.each do |k, v|\n puts \"#{k} : #{v}\"\n end\n puts \"\"\n end",
"def job_summary\n summary = \"#{self.title} - \"\n\n if self.avg_bid\n summary += \"#{self.avg_bid}\"\n elsif self.budget\n summary += \"#{self.budget}\"\n elsif self.budget_range\n summary += \"#{self.budget_range.join(\" - \")}\"\n end\n summary\n end",
"def print_all_tasks\n tasks = retrieve_tasks\n @values[:result] = Array.new()\n tasks.each_key { |key|\n print_tasks_to_key(tasks[key]) if (tasks[key].size > 0)\n }\n end",
"def print_list(hash)\r\n grocery_list=hash\r\n grocery_list.each do |item, quantity|\r\n puts \"You need to get #{quantity} of #{item}\"\r\n end\r\nend",
"def print_student_job_listings jobs\n puts \"Available student jobs: #{jobs.count}\"\n jobs.each_with_index do |info, i|\n puts \"Job listing #{i + 1}\"\n puts 'Title: ' + info[:title]\n puts 'Employer: ' + info[:employer]\n puts 'Pay: ' + info[:pay]\n puts 'Job Duration: ' + info[:duration]\n puts 'Hours: ' + info[:hours]\n puts 'Description: ' + info[:desc]\n puts 'Additional information: ' + info[:link] + \"\\n\\n\"\n end\nend",
"def write_comparison_table(app, cm)\n \n row_num = 0 # TODO use same numbering for all rows\n \n [['context_1', 'context_2'], ['context_1', 'context_3']].each{|ctx_set|\n \n cm.add_row(\n {:text=>(cm.html?)?'<strong>Scenarios:</strong>':'Scenarios:', :colspan=>2},\n {:text=>ctx_set.inspect.to_s, :colspan=>20}\n )\n \n cm.add_row({:text=>'', :colspan=>4}, {:text=>'IIS', :colspan=>6}, {:text=>'Apache', :colspan=>9})\n cm.add_row({:text=>'', :colspan=>4}, {:text=>'Load Agents', :colspan=>2}, {:text=>'No WinCache', :colspan=>3}, {:text=>'WinCache', :colspan=>3}, {:text=>'No APC', :colspan=>3}, {:text=>'APC', :colspan=>3}, {:text=>'APC w/ IGBinary', :colspan=>3})\n cm.add_row('', 'OS', 'Physical', 'Virtual', 'Base', 'Test', 'Gain', 'Base', 'Test', 'Gain', 'Base', 'Test', 'Gain', 'Base', 'Test', 'Gain')\n \n cm.add_row('1', 'Win 2003 x86 SP2', '2', '8', '50', '100', '50%', '100', '50', '50%', '50', '100', '50%', '100', '50', '50%')\n \n cm.add_row(\n {:text=>(cm.html?)?'<strong>Windows INI:</strong>':'INI:', :colspan=>2},\n # TODO show INI\n {:text=>ctx_set.inspect.to_s, :colspan=>20}\n )\n cm.add_row(\n {:text=>(cm.html?)?'<strong>Linux INI:</strong>':'INI:', :colspan=>2},\n # TODO show INI\n {:text=>ctx_set.inspect.to_s, :colspan=>20}\n )\n \n \n \n }\n \n return cm\n end",
"def display_menu\n print \"---------------------------------------------------------------------------------\\n\"\n print \"\\nChoose an option below by entering its corresponding number or type the name\"\n print \" of a job to get more details about it: \\n\"\n print \"1. Sort the jobs by minimum salary\\n\"\n print \"2. Sort the jobs by maximum salary\\n\"\n print \"3. Sort the jobs by upcoming application deadline\\n\"\n print \"4. Sort the jobs by posting start date\\n\"\n print \"5. Sort the jobs by posting end date\\n\"\n print \"6. Sort the jobs by positions available\\n\"\n print \"7. Print the job full time/ part time information\\n\"\n print \"8. Print the job temporary/regular information\\n\"\n print \"9. Compare two jobs by typing the first job, and then second job\\n\"\n print \"10. To enter a new keyword to search for a new list of jobs\\n\"\n print \"Type 'quit' to end the program.\\n\"\n end",
"def print\n @table.each do |e|\n if e\n puts \"#{e.key}: #{e.value}\"\n else\n puts \"empty\"\n end\n end\nend",
"def hash\n [task_id, title, category_id, due_date, completed_date_utc, publicly_visible, completed, project_id, opportunity_id, milestone_id, pipeline_id, stage_id, details, status, priority, percent_complete, start_date, assigned_by_user_id, parent_task_id, owner_visible, responsible_user_id, assigned_team_id, assigned_date_utc, owner_user_id, date_created_utc, date_updated_utc, reminder_date_utc, reminder_sent, tasklinks].hash\n end",
"def display_cache\n puts \"Slot | Valid | Tag | Data \"\n @slots.each do |slot|\n puts \" #{slot.num} | #{slot.is_valid} | #{slot.tag} | #{slot.saved_blocks.join(\" \")}\"\n end\n end",
"def job_fair\n event_display(\"Flatiron holds a JOB FAIR. Everyone busts out their business cards.\")\n group_event_hash_creator({soft_skills: 3})\n end",
"def print_table(formulae)\n services = formulae.map do |formula|\n status = get_status_string(formula[:status])\n status += formula[:exit_code].to_s if formula[:status] == :error\n file = formula[:file].to_s.gsub(Dir.home, \"~\").presence if formula[:loaded]\n\n { name: formula[:name], status: status, user: formula[:user], file: file }\n end\n\n longest_name = [*services.map { |service| service[:name].length }, 4].max\n longest_status = [*services.map { |service| service[:status].length }, 15].max\n longest_user = [*services.map { |service| service[:user]&.length }, 4].compact.max\n\n # `longest_status` includes 9 color characters from `Tty.color` and `Tty.reset`.\n # We don't have these in the header row, so we don't need to add the extra padding.\n headers = \"#{Tty.bold}%-#{longest_name}.#{longest_name}<name>s \" \\\n \"%-#{longest_status - 9}.#{longest_status - 9}<status>s \" \\\n \"%-#{longest_user}.#{longest_user}<user>s %<file>s#{Tty.reset}\"\n row = \"%-#{longest_name}.#{longest_name}<name>s \" \\\n \"%-#{longest_status}.#{longest_status}<status>s \" \\\n \"%-#{longest_user}.#{longest_user}<user>s %<file>s\"\n\n puts format(headers, name: \"Name\", status: \"Status\", user: \"User\", file: \"File\")\n services.each do |service|\n puts format(row, **service)\n end\n end",
"def show_section_name_idx\n\t\t\t puts \" Section header string table index: #{@elf_section_name_idx}\"\n\t\tend",
"def display_name(hash)\n\thash.each do |cohort,num|\n \t\tputs \"#{cohort}: #{num} students\"\n\tend \nend",
"def display_results_html\n\t\t output =\"<!DOCTYPE html><html xmlns=\\\"http://www.w3.org/1999/xhtml\\\"><head><title></title></head><body>\"\n\t\t output.concat(\"<table><thead><tr><td>FileName</td></tr><tr><td>#{@folder1}</td></tr><tr><td>#{@folder2}</td></tr><tr><td>Equal</td></tr></thead>\")\n @filehash.each{ |key, value| output.concat(\"<tbody><tr><td>#{value.file_name}</td></tr><tr><td>#{value.file_hash1}</td></tr><tr><td>#{value.file_hash2}</td></tr><tr><td>#{value.file_hash1==value.file_hash2}</td></tr>\")}\n output.concat(\"</tbody></table></body></html>\")\n puts output\n end",
"def print_list(hash)\n puts \"Grocery list:\"\n hash.each {|item, quantity| puts \"#{item} - #{quantity}\"}\nend",
"def to_table\n result = Mortadella::Horizontal.new headers: @commit_attributes, dry: %w[BRANCH LOCATION]\n main_commits = @commits.delete 'main'\n main_commits.try(:keys).try(:each) do |sha|\n main_commits[sha]['LOCATION'] = main_commits[sha]['LOCATION'].to_sentence\n result << main_commits[sha].values\n end\n @commits.values.each do |branch_commits|\n branch_commits.values.each do |commit|\n commit['LOCATION'] = commit['LOCATION'].to_sentence\n result << commit.values\n end\n end\n result.table\n end",
"def pretty_print_job\n raise NotImplementedError\n end",
"def show_table\n build_html do\n if upd_apar_defs.length == 0\n div.upd_apar_defs do\n span \"Did not find any items matching request\"\n end\n else\n table.upd_apar_defs do\n thead do\n tr do\n th '#'\n [ \"Defect\", \"Apar\", \"PTF\", \"Abstract\",\n \"LPP\", \"VRMF\", \"Version\", \"Service Pack\" ].each do |header_label|\n th class: \"upd_apar_def-#{header_label.gsub(\" \", \"_\").downcase}\" do\n span class: \"upd_apar_defs_header_span\" do\n text header_label\n span class: \"sort sortable\" do\n end\n end\n end\n end\n end\n end\n tbody do\n # upd_apar_defs.each_with_index { |o, i| show_upd_apar_def(o,i) }\n end\n end\n end\n end\n end",
"def hash\n if @_hash.nil?\n @_hash = {}\n run\n end\n @_hash\n end",
"def print_tables\n puts(\"\")\n if self.certs.count > 0\n rows = self.certs.collect do |cert|\n cert_expiration = cert.expiration_date.nil? ? \"Unknown\" : Time.parse(cert.expiration_date).strftime(\"%Y-%m-%d\")\n [cert.name, cert.id, cert.class.to_s.split(\"::\").last, cert_expiration]\n end\n puts(Terminal::Table.new({\n title: \"Certificates that are going to be revoked\".green,\n headings: [\"Name\", \"ID\", \"Type\", \"Expires\"],\n rows: FastlaneCore::PrintTable.transform_output(rows)\n }))\n puts(\"\")\n end\n\n if self.profiles.count > 0\n rows = self.profiles.collect do |p|\n status = p.valid? ? p.profile_state.green : p.profile_state.red\n\n # Expires is sometimes nil\n expires = p.expiration_date ? Time.parse(p.expiration_date).strftime(\"%Y-%m-%d\") : nil\n [p.name, p.id, status, p.profile_type, expires]\n end\n puts(Terminal::Table.new({\n title: \"Provisioning Profiles that are going to be revoked\".green,\n headings: [\"Name\", \"ID\", \"Status\", \"Type\", \"Expires\"],\n rows: FastlaneCore::PrintTable.transform_output(rows)\n }))\n puts(\"\")\n end\n\n if self.files.count > 0\n rows = self.files.collect do |f|\n components = f.split(File::SEPARATOR)[-3..-1]\n\n # from \"...1o7xtmh/certs/distribution/8K38XUY3AY.cer\" to \"distribution cert\"\n file_type = components[0..1].reverse.join(\" \")[0..-2]\n\n [file_type, components[2]]\n end\n\n puts(Terminal::Table.new({\n title: \"Files that are going to be deleted\".green + \"\\n\" + self.storage.human_readable_description,\n headings: [\"Type\", \"File Name\"],\n rows: rows\n }))\n puts(\"\")\n end\n end",
"def block_hash\n\t\tdigest = Digest::SHA2.new\n\n\t\tdigest << '%d' % [ self.index ]\n\t\tdigest << self.timestamp.strftime( '%s%N' )\n\t\tdigest << self.payload\n\t\tdigest << self.payload_hash\n\t\tdigest << self.proof.to_s\n\t\tdigest << self.previous_hash\n\t\t\n\t\treturn digest.hexdigest\n\tend",
"def available_green_space\n rows = []\n # loop through to find all available green bin space\n self.houses.each do |house|\n rows << [house.house_number, house.street, house.contact_name, house.green_bin_space]\n end\n # Drawing and styling the table\n table = Terminal::Table.new :rows => rows\n table = Terminal::Table.new :title => 'Available Green Bin Space'.magenta, :alignment => :center, \n :headings => ['#'.green, 'Street Name'.green, 'Contact'.green, 'Green'.green], :rows => rows\n puts table\n end",
"def display\n puts \"Random Call: #{@call_column}, #{@call_number}\"\n puts \"\\n\"\n p \"B I N G O\"\n puts self.check.map { |block| puts block.inspect }\n end",
"def output_results_table(results={})\n puts\n puts \"----------------------------------------\"\n puts \"| Type | Mean | Median |\"\n puts \"----------------------------------------\"\n results.each do |label, hash|\n print \"| \" + label.ljust(10) + \" | \"\n print sprintf(\"%.6f\", hash[:mean]).rjust(10) + \" | \"\n puts sprintf(\"%.6f\", hash[:median]).rjust(10) + \" | \"\n end\n puts \"----------------------------------------\"\n puts\nend",
"def print_table(n)\n prime_number = PrimeNumber.new(@path)\n prime_and_flag = prime_number.get_prime_numbers(n)\n table = Table.new(prime_and_flag[0])\n puts table.make_products_table\n if prime_and_flag[1]\n diff = prime_and_flag[2]\n File.open(File.expand_path(@path), \"a\") do |f|\n f.puts(prime_and_flag[0][diff..-1])\n end\n end\n end",
"def print_sorted_changes(input = nil)\n sort_by_change(input).each do |coin|\n table = terminal_table do |t|\n t.add_row [coin.name, \"#{coin.percent_change_24h}%\"]\n t.style = { all_separators: true, width: 60 }\n end\n puts table\n end\n end",
"def displays_students(hash_to_display)\n hash_to_display.each do |key, value|\n puts \"#{key}: #{value} students\"\n end\nend"
] | [
"0.6631238",
"0.6258912",
"0.6101561",
"0.5896043",
"0.58573925",
"0.58538145",
"0.58102214",
"0.5682262",
"0.5674862",
"0.56625235",
"0.56623787",
"0.56602186",
"0.5655557",
"0.5626425",
"0.56256115",
"0.5615027",
"0.56135696",
"0.56107056",
"0.5602099",
"0.5602099",
"0.5594997",
"0.55821437",
"0.5579769",
"0.5571418",
"0.55461645",
"0.54982805",
"0.5495911",
"0.5489449",
"0.54843974",
"0.54777485",
"0.5468883",
"0.54682106",
"0.5443165",
"0.54405403",
"0.54280925",
"0.54205346",
"0.5412231",
"0.54030925",
"0.5394013",
"0.5392155",
"0.5380071",
"0.5379746",
"0.53761464",
"0.5374993",
"0.5369612",
"0.53523177",
"0.53482175",
"0.53401166",
"0.5339105",
"0.5333552",
"0.53302044",
"0.53221023",
"0.5320909",
"0.53147525",
"0.5312234",
"0.5311928",
"0.53055716",
"0.53032625",
"0.5287631",
"0.52874035",
"0.5283463",
"0.52804846",
"0.52789015",
"0.5273244",
"0.5269753",
"0.52679646",
"0.52648944",
"0.52648324",
"0.5261433",
"0.5255193",
"0.5254231",
"0.52536047",
"0.5253456",
"0.52504003",
"0.5247528",
"0.52365637",
"0.5235831",
"0.52357715",
"0.523446",
"0.52246386",
"0.5218344",
"0.52183026",
"0.5216873",
"0.52145123",
"0.5208291",
"0.52062577",
"0.5205268",
"0.52049077",
"0.5196022",
"0.5195778",
"0.5189129",
"0.51863205",
"0.5185525",
"0.51844853",
"0.51843107",
"0.51806754",
"0.5180388",
"0.51792336",
"0.5179071",
"0.5178427"
] | 0.5888107 | 4 |
jobs:stop JOB_ID Stop a running job. | def stop
job_id = shift_argument
unless job_id
error("Usage: mortar jobs:stop JOB_ID\nMust specify JOB_ID.")
end
response = api.stop_job(job_id).body
#TODO: jkarn - Once all servers have the additional message field we can remove this check.
if response['message'].nil?
display("Stopping job #{job_id}.")
else
display(response['message'])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(options = {})\n # set :stopping\n info \"stopping job\"\n unsubscribe\n kill if options[:force]\n end",
"def kill_job(job_id)\n __push([], :kill_job, job_id)\n end",
"def job_stopped? job=@current_job\n return false unless job and job.respond_to? :run_proc\n job_id = job.id\n st = Job::STOP_TEMPLATE.dup\n st['id'] = job_id\n stop = read st\n if stop\n puts \"#{name}: Asked to stop #{@current_job.id}\"\n @current_job = nil\n end\n !stop.nil?\n end",
"def stop\n # TODO: can this be elsewhere?\n puts \"Stopping job #{@sandbox.job.id}\"\n\n @thread.kill\n ActiveRecord::Base.clear_active_connections!\n @mutex.synchronize { @thread_status.running = false }\n end",
"def stop\n interface.remove_new_job_listener(self)\n end",
"def stop\n interface.remove_new_job_listener(self)\n end",
"def finish_job job\n job_id = job.respond_to?(:id) ? job.id : job\n @current_jobs.delete job_id\n @job_pids.delete(job_id)\n end",
"def kill_job\n raise UnableToKillJobNotRunningError unless self.status == RUNNING\n begin\n JobScheduler.find.try(:kill_job, self)\n raise KilledJobError.new 'Job Killed'\n rescue => err\n job_error_handler(err)\n ensure\n close_job \n end\n end",
"def terminate\n find_job\n if @job.nil?\n type = :error\n text = \"Sorry, this job does not exist or is not accessible by you\"\n path = api_jobs_path\n\n render json: { path: path, message: { type: type, text: text } }, adapter: :json\n return\n end\n if !@job.terminal?\n DNAnexusAPI.new(@context.token).call(@job.dxid, \"terminate\")\n type = :success\n text = \"Job was successfully terminated\"\n else\n type = :warning\n text = \"Job is in terminal state and can not be terminated\"\n end\n path = api_job_path(@job)\n\n render json: { path: path, message: { type: type, text: text } }, adapter: :json\n end",
"def test_stop_stopped_job\n job 'job'\n assert_message(\"Timeclock tried to stop job 'job'.\n But 'job' is already stopped.\",\n stop('job'))\n end",
"def stop (bundleId)\n execute(:stop, bundleId)\n end",
"def cancel_job job_id, location: nil\n # The BigQuery team has told us cancelling is considered idempotent\n execute backoff: true do\n service.cancel_job @project, job_id, location: location\n end\n end",
"def kill\n if TerminateJobObject(@job_handle, Process.pid) == 0\n raise Error, get_last_error\n end\n end",
"def terminate(job = ALL_JOBS)\n DRMAA.control(job, DRMAA::ACTION_TERMINATE)\n end",
"def cancel_job(message, job_id = nil, step_id = nil, proc_id = nil)\n job_id = get_job_id(error = false) unless job_id\n if job_id and not step_id\n step_id = get_step_id(get_job_directory(job_id), error = false)\n end\n scancel(job_id, step_id) if job_id\n message = if proc_id\n \"Record Job Energy error in process #{proc_id} - #{message}\"\n else\n \"Record Job Energy error - #{message}\"\n end\n raise EnergyRecordError, message\nend",
"def remove_job(job_id)\n # Remove the task from the scheduler\n if !@tasks_by_job_ids[job_id].nil?\n # Unschedule the job\n @scheduler.unschedule(job_id)\n # Fetch the used task\n task = @tasks_by_job_ids[job_id]\n # Remove the reference\n @tasks_by_job_ids.delete(job_id)\n # Find the reference in the task list\n if !@job_ids_by_task[task].nil?\n @job_ids_by_task[task].delete(job_id)\n end\n end\n end",
"def cancel_job(job, error = false)\n report_success(job) if !error && job['on_success']\n report_error(job) if error && job['on_error']\n if JR.config[:remove_cancelled_jobs]\n storage.destroy(job)\n else\n job['status'] = 'cancelled'\n storage.save(job)\n end\n end",
"def unlock(job_id)\n locked.del(job_id)\n end",
"def stop\n Cocaine::CommandLine.new(\n @opt.fetch(:command, 'bin/delayed_job'),\n 'stop'\n ).run\n end",
"def terminate(job = ALL_JOBS)\n DRMAA.control(job, DRMAA::ACTION_TERMINATE)\n end",
"def destroy\n Job.destroy(params[:id])\n end",
"def stop(pid)\n access_processes do |processes|\n processes[pid] && processes[pid].stop\n end\n end",
"def unschedule_cron_job (job_id)\n\n unschedule(job_id)\n end",
"def cancel\n @job = Job.find(params[:id])\n logger.debug( 'initiating background cluster termination...' ) \n @job.cancel!\n # Delayed::Job.enqueue ClusterTerminateJob.new(@job)\n flash[:notice] = 'Cancellation request submitted...'\n logger.debug( 'Cancellation request recieved for Job!...' ) \n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { render :xml => @job }\n format.json { render :json => @job }\n end\n end",
"def destroy\n\t\tproject = Project.editable(current_user).find_by_name(params[:project_id])\n\t\traise \"There is no such project.\" unless project.present?\n\n\t\tjob = Job.find(params[:id])\n\t\traise \"The project does not have the job.\" unless job.project == project\n\n\t\tjob.destroy_if_not_running\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to project_jobs_path(project.name) }\n\t\tend\n\tend",
"def quitWorkingJob\n\t\t@db.hdel('sgt-unit:'+@id, 'job')\n\tend",
"def update\n\t\tproject = Project.editable(current_user).find_by_name(params[:project_id])\n\t\traise \"There is no such project.\" unless project.present?\n\n\t\tjob = Job.find(params[:id])\n\t\traise \"The project does not have the job.\" unless job.project == project\n\n\t\tjob.stop_if_running\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to :back }\n\t\tend\n\tend",
"def destroy\n @job = Job.find(params[:id])\n @job.deactivate!\n flash[:notice] = \"Job successfully deactivated.\"\n respond_to do |format|\n format.html { redirect_to(edit_admin_job_url(@job)) }\n format.xml { head :ok }\n end\n end",
"def stop(manifest)\n raise ArgumentError unless manifest.kind_of? Launch::Manifest\n @logger.info \"stopping the job for #{manifest.label}\"\n end",
"def destroy\n @job = Job.destroy(params[:id])\n redirect_to jobs_path\n end",
"def stop!\n worker.stop! if worker\n end",
"def delete_job job_id\n @schedule_list.delete_if {|x| x.id == job_id }\n end",
"def destroy\n record_activity :destroy, @job # Must come before the destroy action.\n if @job.destroy\n logger.info \"#{@job} destroyed successfully\"\n flash_t :success, t(\".job_destroyed_successfully\")\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n else\n record_activity :destroy_failed, @job\n if !@job.canceled?\n logger.warn \"#{@job} not destroyed because not canceled\"\n flash_t :danger, t(\".job_not_destroyed_because_not_canceled\")\n else\n logger.error \"Unable to destroy: #{@job}\"\n flash_t :danger, t(\".unable_to_destroy_job\")\n end\n respond_to do |format|\n format.html { redirect_to @job }\n format.json { head :no_content }\n end\n end\n end",
"def delete_job job_id, location: nil\n execute do\n service.delete_job @project, job_id, location: location\n end\n end",
"def cancelJob( job )\n\t\t\t\tcancelled = false\n\t\t\t\t\n\t\t\t\tThread.exclusive {\n\t\t\t\t\tcancelled = ( @jobs.delete( job ) != nil )\n\t\t\t\t}\t\t\t\t\t\n\t\t\t\t\n\t\t\t\treturn cancelled\n\t\t\tend",
"def stop\n return if @status == :stopped\n begin\n Process::kill('-TERM', @pid)\n rescue Exception => e\n # nothing here\n ensure\n @status = :stopped\n end\n end",
"def destroy\n job = Job.find(params[:id])\n job.destroy\n respond_with job do |format|\n format.html { redirect_to jobs_path }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: \"Job was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n if UbiquoJobs.manager.delete(params[:id])\n flash[:notice] = t(\"ubiquo.jobs.job_removed\")\n else\n flash[:error] = t(\"ubiquo.jobs.cant_remove\")\n end\n\n respond_to do |format|\n format.html { redirect_to(ubiquo.jobs_path) }\n format.xml { head :ok }\n end\n end",
"def stop\n info \"STOP!\"\n @worker.shutdown! if @worker\n end",
"def delete_job(sid)\n\t\t\tresponse = connection.delete(\"search/jobs/#{sid}\")\n\t\t\treturn_error_or_body(response, response.body)\n\t\tend",
"def destroy\n @job.destroy\n redirect_to jobs_path, notice:'Job deleted.'\n end",
"def cancel(id)\n response = client.cancel_job(id: id)\n build_encode(get_job_details(id)) if response.successful?\n end",
"def destroy\n Sidekiq.redis do |conn|\n # delete from set\n conn.srem self.class.jobs_key, redis_key\n\n # delete runned timestamps\n # conn.del job_enqueued_key\n\n # delete jid_history\n conn.del jid_history_key\n\n # delete main job\n conn.del redis_key\n end\n\n logger.info { \"CRON JOB: deleted job with name: #{@name}\" }\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n redirect_to jobs_path\n end",
"def do_unschedule (job_id)\n\n job = get_job job_id\n\n return (@cron_jobs.delete(job_id) != nil) if job.is_a?(CronJob)\n\n return false unless job # not found\n\n if job.is_a?(AtJob) # catches AtJob and EveryJob instances\n @non_cron_jobs.delete(job_id)\n job.params[:dont_reschedule] = true # for AtJob as well, no worries\n end\n\n for i in 0...@pending_jobs.length\n if @pending_jobs[i].job_id == job_id\n @pending_jobs.delete_at i\n return true # asap\n end\n end\n\n true\n end",
"def endJob\n\t\tunits.each do |unit|\n\t\t\tunemployUnit unit\n\t\tend\n\t\t\n\t\t# TODO: Remove job from it's queue\n\t\t\n\t\t@db.del('sgt-job:' + @id + ':units')\n\t\t@db.del('sgt-job:'+@id)\n\tend",
"def stop!\n logger.info \"stopping worker #{pid}\"\n process.stop(20) # Give worker some time to stop.\n # TODO: Move stop timeout to the config?\n end",
"def destroy\n @job = current_member.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :ok }\n end\n end",
"def kill\n @job = Job.find params[:id]\n @job.kill!\n\n respond_to do |format|\n format.html { redirect_to job_path(@job) }\n format.json {\n render :json => @job,\n :methods => [:status_name, :percentage, :total, :completed, :error, :ended?]\n }\n end\n end",
"def unschedule (job_id)\n\n @unschedule_queue << job_id\n end",
"def job(id, options = {})\n objectify get(\"/job/#{id}\", options)['joblist']['job']\n end",
"def attempt_to_stop\n recipe.schedule.clean_up_task_jobs\n self.stop_time = Time.now.to_datetime\n rhizomes.each do |r|\n r.batch = nil\n r.save!\n end\n stop!\n [:success, \"Stopped <strong>#{name.html_safe}</strong>!\"]\n end",
"def delete\n job_resource.delete\n end",
"def stop\n\n @threadPool.each do |t|\n\n t.terminate\n\n end\n\n @threadPool = []\n\n @running = false\n\n @jobs.each do |j|\n j.signalCancel \n end\n\n @jobs = []\n @timeoutList = []\n @preJobs = {}\n @messageIndex = {}\n\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.hidden = true\n\t\t@job.save\n\n\t\tif @job.save\n\t\t flash[:notice] = 'Job successfully removed.'\n\t\tend\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.xml { head :ok }\n end\n end",
"def destroy \n @job = Mugen::Job.delete(params[:id])\n \n respond_to do |format|\n format.html { redirect_to(mygengo_jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = @user.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def kill\n unless pid.nil?\n WITH_PBS ? `qdel #{pid}` : Process.kill(\"TERM\", -pid.to_i)\n set_status! :m\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n if @job.destroy\n response_message = {:message => \"Job deleted successfully.\", :job => @job}\n else\n response_message = {:message => \"Job deletion failed. Please try again!\"}\n end\n\n respond_to do |format|\n format.xml { render :xml => response_message }\n format.json { render :json => response_message }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\n connection.delete do |req|\n req.url \"job/#{id}\"\n end\n end",
"def stop\n if @pid\n Process.kill('KILL', @pid)\n Process.wait @pid\n end\n @pid = nil\n if @pgid\n Process.kill('KILL', -(@pgid))\n end\n @pgid = nil\n end",
"def clear_job_id(job_id)\n @processed_job_ids.delete(job_id)\n end",
"def cmd_stop argv\n setup argv\n uuid = @hash['uuid']\n response = @api.stop(uuid)\n msg response\n return response\n end",
"def cancel\n @job = Job.find(params[:id])\n\n respond_to do |format|\n if @job.cancel \n flash[:notice] = 'Job was successfully cancelled.'\n format.html { redirect_to(@job) }\n format.xml { head :ok }\n else\n format.html { render :action => \"show\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def stop!(kill=true)\n if exists?(pid)\n _pid = File.read(pid).to_i\n puts \"=> Found pid #{_pid}...\"\n FileUtils.rm_f(pid)\n begin\n puts \"=> Killing process #{_pid}...\"\n Process.kill(:KILL, _pid)\n rescue Errno::ESRCH => e\n puts \"=> #{e.message}\"\n end\n else\n puts \"=> Pid not found, process seems don't exist!\"\n end\n end",
"def stop!(kill=true)\n if exists?(pid)\n _pid = File.read(pid).to_i\n puts \"=> Found pid #{_pid}...\"\n FileUtils.rm_f(pid)\n begin\n puts \"=> Killing process #{_pid}...\"\n Process.kill(:KILL, _pid)\n rescue Errno::ESRCH => e\n puts \"=> #{e.message}\"\n end\n else\n puts \"=> Pid not found, process seems don't exist!\"\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n if current_user.is_an_admin? or @job.status != \"paid\"\n @job.destroy\n else\n flash[:error] = \"Paid jobs can only be modified by an administrator.\"\n end\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job.destroy\n flash[:success] = 'Job was successfully destroyed.' \n redirect_to jobs_url \n end",
"def stop\n return unless @state == :started\n enqueue { @stop_requested = true }\n unless @thread.join(5)\n # TODO: use Platform to test for this\n unless defined?(JRuby)\n Thread.new { @thread.kill; @thread.join(0) }\n end\n end\n\n @thread = nil\n @state = :stopped\n end",
"def stop!(sqajob)\n\t\t#Open3.popen3('#{Rails.root}/public/stop_test_script.sh')\n\t\t#@sqajob = sqajob\n #Open3.popen3(\"ps -ef | grep /nfs/sjorhqa128-1.data/qa/WEB_BIN/SQA/bin/build_CMD | awk \\'{print $2}\\' | xargs kill -9 \")\n #sleep 5\n #Open3.popen3(\"ps -ef | grep /nfs/sjorhqa128-1.data/qa/WEB_BIN/SQA/JOBS/#{@sqajob.jobname} | awk \\'{print $2}\\' | xargs kill -9 \")\n\tend",
"def remove_by_id(id)\n @jobs.delete { |job| job.id == id }\n end",
"def stop\n return if worker.nil?\n @worker.stop\n @worker = nil\n end",
"def cancel_associated_job!\n return unless respond_to?(:background_job_ref) && background_job_ref.present?\n\n ref_parts = background_job_ref.split('%')\n valid_ref_cns = ['delayed__backend__active_record__job'].freeze\n valid_ref_cn = valid_ref_cns.select { |s| s == ref_parts.first }.first\n return unless valid_ref_cn\n\n job = valid_ref_cn.ns_camelize.constantize.find(ref_parts.last.to_i)\n job&.delete\n end",
"def destroy\n @job = @user.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to :dashboard, notice: 'Job was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = @user.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to :dashboard, notice: \"Job was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def stop!\n @thread.kill if @running\n @running = false\n end",
"def stop!\n if exists?(pid)\n _pid = File.read(pid).to_i\n print \"=> Found pid #{_pid}...\\n\"\n FileUtils.rm_f(pid)\n begin\n print \"=> Killing process #{_pid}...\\n\"\n on_exit.call if on_exit\n Process.kill(:KILL, _pid)\n rescue Errno::ESRCH => e\n puts \"=> #{e.message}\"\n end\n else\n print \"=> Pid not found, process seems don't exist!\\n\"\n end\n end",
"def stop\n if @pid\n kind_kill -@pid\n @pid = nil\n end\n end",
"def destroy\n @job.destroy\n redirect_to root_url\n end",
"def stop(kill: false, pid: self.pid)\n alive = status(pid: pid, print: false)\n if alive == :running || (kill && alive == :draining)\n puts \"Stopping pool #{pid}...\"\n signal = kill ? \"TERM\" : \"QUIT\"\n begin\n Process.kill(signal, pid)\n rescue Errno::ESRCH\n # ignore if the pid no longer exists\n end\n wait(kill)\n else\n status\n end\n end",
"def stop\n put :stop\n end",
"def cancel_scheduled_job(job_id, opts = {})\n data, _status_code, _headers = cancel_scheduled_job_with_http_info(job_id, opts)\n data\n end",
"def cancel(job, project=self.project)\n post('cancel.json', project: project, job: job)['prevstate']\n end",
"def stop\n action('stop')\n end",
"def stop()\n @running = false # to avoid error message from termination\n # the \"minus\" terminates all processes with the group ID @pid\n # this ensures the child and all of its grandchildren are terminated\n # PROBLEM: the children are not terminated when the parent exits\n Process.kill(\"-TERM\", @pid)\n Timer.cancel(@name)\n @@inst[self.class].delete(@name)\n end",
"def stop\n @mutex_after_fork.synchronize { stop_worker }\n end",
"def stop(reason)\n if @pid\n begin\n Process.kill('KILL', @pid)\n Process.waitpid(@pid)\n rescue Errno::ESRCH, Errno::ECHILD\n end\n end\n @log.info \"[#{Time.now.iso8601}] Killing pid: #{@pid.to_s}. Reason: #{reason}\"\n @pid = nil\n end"
] | [
"0.73273987",
"0.7175865",
"0.71753585",
"0.71748996",
"0.6982509",
"0.6982509",
"0.6942156",
"0.67249715",
"0.6706788",
"0.6540835",
"0.65160674",
"0.6445151",
"0.643705",
"0.64167774",
"0.63927066",
"0.6387198",
"0.63614136",
"0.635167",
"0.6337637",
"0.633173",
"0.6301892",
"0.6299258",
"0.6267778",
"0.6264662",
"0.62628514",
"0.62465715",
"0.62316823",
"0.6199712",
"0.6193689",
"0.6186302",
"0.6171242",
"0.6151107",
"0.6131931",
"0.6130897",
"0.6085593",
"0.60768855",
"0.60580367",
"0.6046599",
"0.60458523",
"0.60443336",
"0.6015148",
"0.60112095",
"0.6000469",
"0.5988873",
"0.5987883",
"0.5986785",
"0.5972598",
"0.59681493",
"0.59620756",
"0.595323",
"0.59531003",
"0.594935",
"0.59417635",
"0.59357554",
"0.5933585",
"0.59268475",
"0.59150994",
"0.59045947",
"0.59043616",
"0.5893098",
"0.58929306",
"0.58887005",
"0.5876208",
"0.58636934",
"0.5860285",
"0.5860285",
"0.5860285",
"0.5860285",
"0.5860285",
"0.5860285",
"0.5860285",
"0.5860285",
"0.58509076",
"0.58113885",
"0.580354",
"0.5786369",
"0.5772859",
"0.5769737",
"0.5769737",
"0.57541806",
"0.57438874",
"0.5733421",
"0.57292974",
"0.57241815",
"0.5720847",
"0.57177174",
"0.571386",
"0.5704799",
"0.570315",
"0.56978846",
"0.5695236",
"0.5692027",
"0.5686471",
"0.5681519",
"0.56779796",
"0.56531996",
"0.5646025",
"0.56371593",
"0.56262416",
"0.561977"
] | 0.8248524 | 0 |
GET /favourite_foods/1 GET /favourite_foods/1.json | def show
@favourite_food = FavouriteFood.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @favourite_food }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end",
"def show\n @favourite_listing = get_favourite_listing(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favourite_listing }\n end\n end",
"def get_favourite_restaurants\n @profile = Profile.find(params[:id])\n @restaurants = @profile.favourites\n\n render status: 200, json: @restaurants\n end",
"def show\n @fav = Fav.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fav }\n end\n end",
"def food_info(food_id)\n get(\"/foods/#{food_id}.json\")\n end",
"def show\n render json: @favorite\n end",
"def show\n json_response(@fav)\n end",
"def frequent_foods\n get(\"/user/#{@user_id}/foods/log/frequent.json\")\n end",
"def show\n @favorite = Favorite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @favorite }\n end\n end",
"def favorite_activities\n get(\"/user/#{@user_id}/activities/favorite.json\")\n end",
"def favorite_activities()\n get(\"/user/#{@user_id}/activities/favorite.json\")\n end",
"def show\n\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\n end\n end",
"def index\n json_response(current_restaurant.restaurant_food_items)\n end",
"def show\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\n end\n end",
"def show\n @favorite_flyer = FavoriteFlyer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favorite_flyer }\n end\n end",
"def index\n @favoritos = Favorito.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @favoritos }\n end\n end",
"def new\n @favourite_food = FavouriteFood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @favourite_food }\n end\n end",
"def show\n render json: @favorite_route\n end",
"def show\n @favor = Favor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favor }\n end\n end",
"def show\n @favor = Favor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favor }\n end\n end",
"def show\n respond_with favorites.first!\n end",
"def show\n json_response(@food_item)\n end",
"def show\n @favorito = Favorito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favorito }\n end\n end",
"def index\n @favorites = Favorite.all\n @user = current_user\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @favorites }\n end\n end",
"def show\n @favorite = Favorite.find(params[:id])\n respond_with(@favorite)\n end",
"def recent_foods\n get(\"/user/#{@user_id}/foods/log/recent.json\")\n end",
"def favourite_artists\n @favourite_artists = FavouriteArtist.all\n render :json => @favourite_artists.to_json\n end",
"def index\n @faves_arr = []\n @favourites = current_user.favourites.map do |fave|\n @faves_arr << Location.find_by_id(fave.location_id)\n end\n\n render json: @faves_arr.map(&:transform_json), status: 201\n end",
"def index\n @favorites = current_user.favorites\n render json: Api::V1::WatchableSerializer.new(@favorites.map(&:favoritable)).serialized_json\n end",
"def index\n if !current_user.favorites.blank?\n return current_user.favorites\n else\n render json: { errors: \"No favorites for current user\" }, status: :not_found\n end\n end",
"def index\n @favories = Favory.all\n end",
"def show\n @favor = Favor.find(params[:id])\n render json: @favor, meta: { status: :ok }, meta_key: 'result'\n end",
"def add_favorite_food(food_id)\n post(\"/user/#{@user_id}/foods/log/favorite/#{food_id}.json\")\n end",
"def get_favorites\n authenticate_rem\n follower = @current_user || User.find_by_id(params[:user_id])\n render json: Product.order(created_at: :desc).limit(20).map(&:simple_info.with(follower)),\n status: :ok\n end",
"def show\n @fooditem = Fooditem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @fooditem }\n end\n end",
"def favorite(action, value)\n raise ArgumentError, \"Invalid favorite action provided: #{action}\" unless @@FAVORITES_URIS.keys.member?(action)\n value = value.to_i.to_s unless value.is_a?(String)\n uri = \"#{@@FAVORITES_URIS[action]}/#{value}.json\"\n case action\n when :add\n response = http_connect {|conn| create_http_post_request(uri) }\n when :remove\n response = http_connect {|conn| create_http_delete_request(uri) }\n end\n bless_model(Twitter::Status.unmarshal(response.body))\n end",
"def favorites(options = nil)\n def uri_suffix(opts); opts && opts[:page] ? \"?page=#{opts[:page]}\" : \"\"; end\n uri = '/favorites.json' + uri_suffix(options)\n response = http_connect {|conn|\tcreate_http_get_request(uri) }\n bless_models(Twitter::Status.unmarshal(response.body))\n end",
"def favorite\n @venue = Venue.find(params[:id])\n current_user.favorite!(@venue)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json=> { \n :venue=>@venue.as_json(:only => [:id, :fs_venue_id, :name], \n :include => { \n :tenders => { :only => [:id, :name, :tender], :methods => [:photo_url],\n :include => { \n :workvenues => { :only => [:id, :fs_venue_id, :name] },\n :shifts => { }\n } },\n :favorites => { :only => [:id, :user_id, :venue_id] },\n :workfavorites => { :only => [:id, :user_id, :venue_id] }\n }\n ) \n } }\n end\n end",
"def index\n respond_with @favorites\n end",
"def index\n @favorite_routes = FavoriteRoute.all\n render json: @favorite_routes\n end",
"def mark_favourite\n @favourite_artist = FavouriteArtist.where(spotify_id: params[:spotify_id]).first_or_create(_params)\n render :json => @favourite_artist.to_json\n end",
"def show_favorites\n authenticate_rem\n follower = @current_user || User.find_by_id(params[:user_id])\n render json: follower.favorite_products.map(&:simple_info.with(follower)), status: :ok\n end",
"def index\n @foods = Food.all\n end",
"def index\n @favourites = Favourite.all\n end",
"def index\n @favourites = Favourite.all\n end",
"def index\n @favourites = Favourite.all\n end",
"def index\n @favourites = Favourite.all\n end",
"def favorite(id)\n post(\"/favorites/create/#{id}.json\")\n end",
"def get_favorite\n @json = FavoriteBeer&.all.where(user_id: @current_user.id).as_json\n\n @json.map! { |beer| beer.slice('id', 'name', 'tagline', 'description', 'abv', 'punk_id') }\n @json.each { |beer| beer[:favorite] = true }\n\n render json: {\n favorite_beers: @json\n }\n end",
"def index\n favoritable_type = params[:type] || params[:favoritable_type]\n\n @favorites = if favoritable_type.present?\n current_user.favoritables\n .where(favoritable_type: favoritable_type)\n else\n current_user.favoritables\n end\n\n @total = @favorites.count\n\n @favorites = @favorites\n .page(params[:page])\n .per(params[:per])\n\n # render json: {favorites: @favorites, total: @total}\n end",
"def index\n @fast_foods = FastFood.all\n end",
"def index\n @favors = Favor.order(@order)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @favors }\n end\n end",
"def index\n @favours = Favour.all\n end",
"def show\n @favourites = Favourite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @favourites }\n end\n end",
"def index\n @favorites = current_user.favorites\n respond_with(@favorites)\n end",
"def get_favorite(key, json)\n return JSON.parse(json)[\"favorites\"][key]\nend",
"def find_food(query)\n get(\"/foods/search.json?query=#{URI.escape(query)}\")\n end",
"def destroy\n @favourite_food = FavouriteFood.find(params[:id])\n @favourite_food.destroy\n\n respond_to do |format|\n format.html { redirect_to favourite_foods_url }\n format.json { head :no_content }\n end\n end",
"def new\n @fav = Fav.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fav }\n end\n end",
"def index\n @favourites = Favourite.all\n end",
"def index\n type = params[:type]\n fg = params[:fg]\n @page = Page.find(2)\n @foodTypes = FoodType.all\n @type_id = type\n\n @foods = Food.find_by_sql([\"SELECT * FROM FOODS WHERE food_type_id = ?\", type])\n\n \n @foods = Food.find_by_sql(\"SELECT * FROM FOODS WHERE important = 't'\") if !params.has_key?(:type)\n \n \n if !fg.nil?\n @front_food = Food.find(fg) \n end if\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foods }\n end\n end",
"def get_favorite(key, json)\n data =JSON.parse(json)\n return data['favorites'][key]\nend",
"def getFavorites(userID, ofWhat)\n request('getFavorites', {'userID' => userID, 'ofWhat' => ofWhat})\nend",
"def show\n @love = Love.find(params[:id])\n render json: @love\n end",
"def get_favorite(key, json)\n hash = JSON.parse(json)\n return hash[\"favorites\"][key]\n\nend",
"def index\n @favorites = Favorite.all\n end",
"def index\n @favorites = Favorite.all\n end",
"def index\n @favorites = Favorite.all\n end",
"def show\n @food_recipe = FoodRecipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food_recipe }\n end\n end",
"def index\n @favourites_recipes = FavouritesRecipe.all\n end",
"def show\n @favourite = Favourite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @favourite }\n end\n end",
"def favourite_for(user)\n favourites.find_by_user_id user\n end",
"def show\n @favorites = Favorite.all\n end",
"def index\n @favorite_recipes = FavoriteRecipe.all\n end",
"def index\n @user_foods = UserFood.all\n end",
"def favourites\n\t\t\t\t@user = User.find_by(:facebook_id => params[:id_facebook])\n\t\t\t\t@favourites = Favourite.where(\"user_id = #{@user.id}\")\n\t\t\tend",
"def remove_favorite_food(food_id)\n delete(\"/user/#{@user_id}/foods/favorite/#{food_id}.json\")\n end",
"def index\n @foodhampers = Foodhamper.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foodhampers }\n end\n end",
"def index\n @favoritos = perfil.favoritos\n end",
"def all_favoring_posts\n render :json => User.find(params[:user_id]).favoring_posts\n end",
"def index\n @fridge_foods = FridgeFood.find_all_by_user_id(session[:user_id])\n\n logger.debug @fridge_food\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml # { render :xml => @fridge_foods }\n end\n end",
"def favorite_for(user)\n favs.find_by(user_id: user)\n end",
"def show\n @favorite_bundle = FavoriteBundle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favorite_bundle }\n end\n end",
"def _my_favorite_list\r\n\t\t\t# Author\r\n\t\t\tauthorize! :view_my, Project\r\n\r\n\t\t\tper = Rails.application.config.item_per_page\r\n\r\n\t\t\tparams[:page] ||= 1\r\n\t\t\tparams[:page] = params[:page].to_i\r\n\r\n\t\t\tprojects = Project.my_favorite_search_with_params params\r\n\r\n\t\t\tcount = projects.count\r\n\r\n\t\t\treturn render json: { status: 1 } if count === 0\r\n\r\n\t\t\trender json: {\r\n\t\t\t\tstatus: 0,\r\n\t\t\t\tresult: {\r\n\t\t\t\t\tlist: render_to_string(partial: 'projects/my_favorite_list', locals: { projects: projects.page(params[:page], per) }),\r\n\t\t\t\t\tpagination: render_to_string(partial: 'shared/pagination', locals: { total: count, per: per, page: params[:page] })\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\tend",
"def favorite(path)\n response = @api.request(:proppatch, \"#{@path}/#{path}\", nil, MAKE_FAVORITE)\n parse_dav_response(response)\n end",
"def set_api_v1_favorite\n @api_v1_favorite = Api::V1::Favorite.find(params[:id])\n end",
"def show\n @food = Food.find(params[:id])\n respond_with(@food)\n end",
"def show\n @foodhamper = Foodhamper.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @foodhamper }\n end\n end",
"def favorite\n if current_user\n info = params[:recipe_id]\n @found = Favorite.find_by(recipe_id: info, user_id: current_user.id)\n if !@found\n @favorite = Favorite.new\n @favorite.recipe_id = info\n @favorite.user_id = current_user.id\n @favorite.save!\n head :ok\n end\n else\n redirect_to '/'\n end\n end",
"def show\n @kf_course_user_fav = Kf::CourseUserFav.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_course_user_fav }\n end\n end",
"def new\n @favorite = Favorite.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @favorite }\n end\n end",
"def show\n render json: @favorite_template\n end",
"def show\n @favorite = current_user.favorites.find_by(recipe_id: @recipe.id)\n end",
"def index\n @favorite_templates = FavoriteTemplate.all\n render json: @favorite_templates\n end",
"def index\n @favorite_items = FavoriteItem.all\n end",
"def new\n @favourite_listing = FavouriteListing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @favourite_listing }\n end\n end",
"def index\n @favoritepizzas = Favoritepizza.all\n end",
"def show\n @foil = Foil.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @foil }\n end\n end",
"def show\n render json: @pizza\n end",
"def favorite\n tweet_id=params[:tuit_id]\n client.favorite(tweet_id) unless tweet_id == nil\n respond_to do |format|\n format.html { }\n\t format.json { head :no_content }\n\t format.js\n end\n end"
] | [
"0.84989434",
"0.7063839",
"0.7056084",
"0.7033001",
"0.70282334",
"0.69767",
"0.697556",
"0.6894857",
"0.6857454",
"0.68488467",
"0.67617226",
"0.66966665",
"0.66960293",
"0.66952133",
"0.6692517",
"0.6680044",
"0.66745186",
"0.66721827",
"0.66412985",
"0.66412985",
"0.6639293",
"0.6629722",
"0.6620577",
"0.66151863",
"0.66039276",
"0.6595564",
"0.65860116",
"0.65452135",
"0.6518032",
"0.649201",
"0.6487542",
"0.6471966",
"0.64606786",
"0.6450684",
"0.6445673",
"0.6443291",
"0.6432186",
"0.6425173",
"0.64243037",
"0.64209855",
"0.64179265",
"0.6402127",
"0.6373592",
"0.6365946",
"0.6365946",
"0.6365946",
"0.6365946",
"0.6361936",
"0.63594985",
"0.6352013",
"0.6329477",
"0.63228124",
"0.6318729",
"0.6315475",
"0.63113314",
"0.6309169",
"0.6305995",
"0.6293759",
"0.6278256",
"0.62777907",
"0.627293",
"0.62655896",
"0.6253586",
"0.6237477",
"0.62332374",
"0.6233214",
"0.6233214",
"0.6233214",
"0.6223876",
"0.62203336",
"0.62166536",
"0.62141234",
"0.62116367",
"0.6209669",
"0.6204196",
"0.6199312",
"0.6189502",
"0.61835104",
"0.61800253",
"0.6176179",
"0.6168764",
"0.616647",
"0.6162507",
"0.6161389",
"0.6161001",
"0.6160746",
"0.6159258",
"0.61337674",
"0.61314476",
"0.6122016",
"0.61201876",
"0.61194324",
"0.61186814",
"0.611567",
"0.6111833",
"0.6105267",
"0.6099765",
"0.6093491",
"0.6091684",
"0.60909647"
] | 0.7635762 | 1 |
GET /favourite_foods/new GET /favourite_foods/new.json | def new
@favourite_food = FavouriteFood.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @favourite_food }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @fav = Fav.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fav }\n end\n end",
"def new\n @favorite = Favorite.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @favorite }\n end\n end",
"def create\n @favourite_food = FavouriteFood.new(params[:favourite_food])\n\n respond_to do |format|\n if @favourite_food.save\n format.html { redirect_to @favourite_food, notice: 'Favourite food was successfully created.' }\n format.json { render json: @favourite_food, status: :created, location: @favourite_food }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favourite_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @favourite_listing = FavouriteListing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @favourite_listing }\n end\n end",
"def new\n @food = Food.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @food }\n end\n end",
"def new\n @favor = Favor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @favor }\n end\n end",
"def new\n @favor = Favor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @favor }\n end\n end",
"def new\n @food = Food.new\n @food.user = current_user\n @series = get_series('foods')\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @food }\n end\n end",
"def new\n @favorite_flyer = FavoriteFlyer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @favorite_flyer }\n end\n end",
"def new\n @favorito = Favorito.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @favorito }\n end\n end",
"def create\n @fav = Fav.new(params[:fav])\n\n respond_to do |format|\n if @fav.save\n format.html { redirect_to @fav, notice: 'Fav was successfully created.' }\n format.json { render json: @fav, status: :created, location: @fav }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fav.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @fooditem = Fooditem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @fooditem }\n end\n end",
"def new\n @favorite = Favorite.new\n\n respond_with(@favorite)\n end",
"def new\n @foam = Foam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @foam }\n end\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n\n respond_to do |format|\n if @favourite.save\n format.html { redirect_to @favourite, notice: \"Favourite was successfully created.\" }\n format.json { render :show, status: :created, location: @favourite }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @foil = Foil.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @foil }\n end\n end",
"def new\n @food_recipe = FoodRecipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @food_recipe }\n end\n end",
"def create\n json_response(current_restaurant.restaurant_food_items.create!(food_item_params), :created)\n end",
"def new\n @foodhamper = Foodhamper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @foodhamper }\n end\n end",
"def create\n @favorite = Favorite.new(params[:favorite])\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render json: @favorite, status: :created, location: @favorite }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n\n respond_to do |format|\n if @favourite.save\n format.html { redirect_back notice: 'Favourite was successfully created.', fallback_location: root_path }\n format.json { render :show, status: :created, location: @favourite }\n else\n format.html { render :new }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @foiltype = Foiltype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @foiltype }\n end\n end",
"def new\n @fish_type = FishType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fish_type }\n end\n end",
"def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end",
"def new\n @favourite = Favourite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @favourite }\n end\n end",
"def create\n @favorite_recipe = FavoriteRecipe.new(favorite_recipe_params)\n\n respond_to do |format|\n if @favorite_recipe.save\n format.html { redirect_to @favorite_recipe, notice: 'Favorite recipe was successfully created.' }\n format.json { render :show, status: :created, location: @favorite_recipe }\n else\n format.html { render :new }\n format.json { render json: @favorite_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(favorite_params)\n if @favorite.save\n render json: FavoriteSerializer.new(@favorite), status: :created\n else\n render json: @favorite.errors.full_messages.to_sentence, status: :unprocessable_entity\n end\n end",
"def create\n @favo = Favo.new(favo_params)\n\n respond_to do |format|\n if @favo.save\n format.html { redirect_to @favo, notice: 'Favo was successfully created.' }\n format.json { render :show, status: :created, location: @favo }\n else\n format.html { render :new }\n format.json { render json: @favo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_favorite(id)\n post \"favorites/create/#{id}\", {}\n end",
"def create\n @food = @fridge.foods.create(food_params)\n respond_with @food, location: -> { kitchen_board_path }\n end",
"def new\n @favorite = Favorite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @favorite }\n end\n end",
"def create\n @favour = Favour.new(favour_params)\n\n respond_to do |format|\n if @favour.save\n format.html { redirect_to @favour, notice: 'Favour was successfully created.' }\n format.json { render :show, status: :created, location: @favour }\n else\n format.html { render :new }\n format.json { render json: @favour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @favourites = Favourites.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @favourites }\n end\n end",
"def new\n @fishing_method = FishingMethod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fishing_method }\n end\n end",
"def create\n @food = Food.new(params[:food])\n\n respond_to do |format|\n if @food.save\n format.html { redirect_to @food, notice: \"Piatto creato correttamente.\" }\n format.json { render json: @food, status: :created, location: @food }\n else\n format.html { render action: \"new\" }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @todo = @list.todos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @todo }\n end\n end",
"def create\n @food = Food.new(food_params)\n respond_to do |format|\n if @food.save\n format.html { redirect_to @food, notice: 'Food was successfully created.' }\n format.json { render :show, status: :created, location: @food }\n else\n format.html { render :new }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @restaurant = Restaurant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restaurant }\n end\n end",
"def new\n @restaurant = Restaurant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restaurant }\n end\n end",
"def new\n @restaurant = Restaurant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restaurant }\n end\n end",
"def new\n @restaurant = Restaurant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restaurant }\n end\n end",
"def new\n @restaurant = Restaurant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restaurant }\n end\n end",
"def create\n @favorite = Favorite.new(favorite_params)\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(favorite_params)\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @father = Father.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @father }\n end\n end",
"def create\n @fooditem = Fooditem.new(params[:fooditem])\n\n respond_to do |format|\n if @fooditem.save\n format.html { redirect_to @fooditem, :notice => 'Fooditem was successfully created.' }\n format.json { render :json => @fooditem, :status => :created, :location => @fooditem }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @fooditem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @family = Family.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @family }\n end\n end",
"def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monkey }\n end\n end",
"def create\n session[:return_to] ||= request.referer\n @favourites = Favourite.new(favourite_params)\n\n\n respond_to do |format|\n if @favourites.save\n format.html { redirect_to session.delete(:return_to), notice: 'Favourite was successfully created.' }\n format.json { render action: 'show', status: :created, location: data_show_path }\n else\n format.html { render action: 'new' }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @favorite_bundle = FavoriteBundle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @favorite_bundle }\n end\n end",
"def new\n @Love = Love.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @Love }\n end\n end",
"def new\n #@food_item params set via ability.rb\n\n respond_to do |format|\n format.html { render 'new', layout: !(request.xhr?) }\n format.json { render json: @food_item }\n end\n end",
"def new\n @faction = Faction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @faction }\n end\n end",
"def new\n @food_form = FoodForm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @food_form }\n end\n end",
"def new\n @star_fact = Star::Fact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @star_fact }\n end\n end",
"def new\n @restaurant = Restaurant.find(params[:restaurant_id])\n @food = Food.new\n end",
"def new\n @foodlog = Foodlog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @foodlog }\n end\n end",
"def mark_favourite\n @favourite_artist = FavouriteArtist.where(spotify_id: params[:spotify_id]).first_or_create(_params)\n render :json => @favourite_artist.to_json\n end",
"def new\n @flavor = Flavor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @flavor }\n end\n end",
"def new\n authorize! :manage_account, current_account\n @food = current_account.foods.new\n respond_with @food\n end",
"def new\r\n @restaurant = Restaurant.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @restaurant }\r\n end\r\n end",
"def new\n @food = Food.new(:nutritional_information => NutritionalInformation.new)\n respond_with(@food)\n end",
"def create\n @fast_food = FastFood.new(fast_food_params)\n\n respond_to do |format|\n if @fast_food.save\n format.html { redirect_to @fast_food, notice: 'Fast food was successfully created.' }\n format.json { render :show, status: :created, location: @fast_food }\n else\n format.html { render :new }\n format.json { render json: @fast_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new #GIRO: POST /foals(.:format) foals#create\n@foal = Foal.new #GIRO: http://localhost:3000/foals/new\nend",
"def new\n @restaurant_dish = Restaurant::Dish.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restaurant_dish }\n end\n end",
"def create\n favourite=current_user.add_favourite(params[:key])\n if favourite\n respond_to do |format|\n format.json { render :json => jsonp(favourites_to_json([favourite])) }\n format.xml { render :xml => favourites_to_xml([favourite]) }\n format.text { render :text => text_not_supported }\n end\n else\n render_error('Favourite not found', 404)\n end\n end",
"def create\n @favorecido = Favorecido.new(favorecido_params)\n @favorecido = @favorecido\n respond_to do |format|\n if @favorecido.save\n format.html { redirect_to favorecidos_url, notice: 'Favorecido criado com sucesso.' }\n format.json { render :show, status: :created, location: @favorecido }\n else\n format.html { render :new }\n format.json { render json: @favorecido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @flower = Flower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @flower }\n end\n end",
"def new\n @family_crest = FamilyCrest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @family_crest }\n end\n end",
"def new\n @fiction = Fiction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fiction }\n end\n end",
"def favorite(id)\n post(\"/favorites/create/#{id}.json\")\n end",
"def create\n @favourites = Favourite.new()\n @favourites.user_id = current_user.id;\n @favourites.army_list_id = params[:favourite][:army_list_id]\n \n respond_to do |format|\n if @favourites.save\n flash[:notice] = 'Favourites was successfully created.'\n format.html { redirect_back_or_default(user_favourites_url(current_user)) }\n format.xml { render :xml => @favourites, :status => :created, :location => @favourites }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @favourites.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @favourites_recipe = FavouritesRecipe.new\n @favourites_recipe.user_id = current_user.id\n @favourites_recipe.recipe_id = params[:recipe_id]\n respond_to do |format|\n if @favourites_recipe.save\n format.html { redirect_to @favourites_recipe, notice: 'Favourites recipe was successfully created.' }\n format.json { render :show, status: :created, location: @favourites_recipe }\n else\n format.html { render :new }\n format.json { render json: @favourites_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n\n respond_to do |format|\n if @favourite.save\n sync_update @favourite.fav_post\n format.html { redirect_to :my_favourites, notice: 'Favourite was successfully created.' }\n format.json { render json: @favourite }\n else\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @todo = Todo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @todo }\n end\n end",
"def new\n @todo = Todo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @todo }\n end\n end",
"def new\n @todo = Todo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @todo }\n end\n end",
"def new\n @todo = Todo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @todo }\n end\n end",
"def new\n @todo = Todo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @todo }\n end\n end",
"def new\n @ftype = Ftype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ftype }\n end\n end",
"def new\n @bowl = Bowl.new\n @dry_fruits = DryFruit.all\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bowl }\n end\n end",
"def new\n \t@restaurant = Restaurant.new\n\n \trespond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restaurant }\n end\nend",
"def add_favorite_food(food_id)\n post(\"/user/#{@user_id}/foods/log/favorite/#{food_id}.json\")\n end",
"def new\n @fact = fact_type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fact }\n end\n end",
"def new\n @moose = Moose.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @moose }\n end\n end",
"def new\n @flaw = Flaw.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @flaw }\n end\n end",
"def create\n recipe = Recipe.find(params[:id])\n @favorite = current_user.add_to_favorite(recipe.id)\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to :back, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @wish = Wish.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wish }\n end\n end",
"def create\n @recipes_food = RecipesFood.new(recipes_food_params)\n\n respond_to do |format|\n if @recipes_food.save\n format.html { redirect_to @recipes_food, notice: 'Recipes food was successfully created.' }\n format.json { render :show, status: :created, location: @recipes_food }\n else\n format.html { render :new }\n format.json { render json: @recipes_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favourite_category = FavouriteCategory.new(favourite_category_params)\n\n respond_to do |format|\n if @favourite_category.save\n format.html { redirect_to @favourite_category, notice: 'Favourite category was successfully created.' }\n format.json { render :show, status: :created, location: @favourite_category }\n else\n format.html { render :new }\n format.json { render json: @favourite_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @goat = Goat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goat }\n end\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n if @favourite.save\n render text: 'ok'\n else\n render text: 'fail'\n end\n end",
"def new\n @todo_list = TodoList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @todo_list }\n end\n end",
"def new\n @friendslist = Friendslist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @friendslist }\n end\n end",
"def new\n @finder = Finder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finder }\n end\n end",
"def new\n @foto = Foto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @foto }\n end\n end",
"def new\n @belief = Belief.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @belief }\n end\n end",
"def new\n render :json => @fiestas.push(params[:fiesta])\n end",
"def new\n @saved_food = SavedFood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @saved_food }\n end\n end",
"def new\n @beverage = Beverage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beverage }\n end\n end"
] | [
"0.7602866",
"0.74826956",
"0.74777085",
"0.7373788",
"0.73180306",
"0.72258997",
"0.72258997",
"0.71241575",
"0.7093327",
"0.70832",
"0.70824677",
"0.7039349",
"0.69641525",
"0.69337416",
"0.6918807",
"0.69062984",
"0.6884498",
"0.6866088",
"0.68614453",
"0.6861139",
"0.68589246",
"0.68449295",
"0.6824842",
"0.6805309",
"0.67794913",
"0.6762702",
"0.67477304",
"0.67329913",
"0.67279696",
"0.6723228",
"0.67187667",
"0.6703404",
"0.6683697",
"0.66760886",
"0.6675303",
"0.66618824",
"0.665572",
"0.66517675",
"0.66517675",
"0.66517675",
"0.66517675",
"0.66517675",
"0.66499716",
"0.66499716",
"0.6639809",
"0.6636681",
"0.6626122",
"0.66147673",
"0.6606167",
"0.6602073",
"0.6597603",
"0.65950745",
"0.6587769",
"0.65824944",
"0.6577071",
"0.65763605",
"0.6574971",
"0.6571975",
"0.65571076",
"0.65503526",
"0.6545948",
"0.6542769",
"0.65394026",
"0.6533796",
"0.6529259",
"0.6528586",
"0.6528396",
"0.6527139",
"0.65234846",
"0.6517796",
"0.65089023",
"0.65045804",
"0.6502322",
"0.6492111",
"0.64908755",
"0.64908755",
"0.64908755",
"0.64908755",
"0.64908755",
"0.6483139",
"0.6477304",
"0.6456698",
"0.64556295",
"0.64550215",
"0.6447211",
"0.6444378",
"0.64412904",
"0.6438612",
"0.642649",
"0.64253896",
"0.64226055",
"0.6420769",
"0.6420179",
"0.641645",
"0.64112765",
"0.6409785",
"0.6396349",
"0.6395471",
"0.6392714",
"0.63833904"
] | 0.78515697 | 0 |
POST /favourite_foods POST /favourite_foods.json | def create
@favourite_food = FavouriteFood.new(params[:favourite_food])
respond_to do |format|
if @favourite_food.save
format.html { redirect_to @favourite_food, notice: 'Favourite food was successfully created.' }
format.json { render json: @favourite_food, status: :created, location: @favourite_food }
else
format.html { render action: "new" }
format.json { render json: @favourite_food.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end",
"def add_favorite_food(food_id)\n post(\"/user/#{@user_id}/foods/log/favorite/#{food_id}.json\")\n end",
"def mark_favourite\n @favourite_artist = FavouriteArtist.where(spotify_id: params[:spotify_id]).first_or_create(_params)\n render :json => @favourite_artist.to_json\n end",
"def create\n json_response(current_restaurant.restaurant_food_items.create!(food_item_params), :created)\n end",
"def create_favorite(id)\n post \"favorites/create/#{id}\", {}\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n\n respond_to do |format|\n if @favourite.save\n format.html { redirect_to @favourite, notice: \"Favourite was successfully created.\" }\n format.json { render :show, status: :created, location: @favourite }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(favorite_params)\n if @favorite.save\n render json: FavoriteSerializer.new(@favorite), status: :created\n else\n render json: @favorite.errors.full_messages.to_sentence, status: :unprocessable_entity\n end\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n\n respond_to do |format|\n if @favourite.save\n sync_update @favourite.fav_post\n format.html { redirect_to :my_favourites, notice: 'Favourite was successfully created.' }\n format.json { render json: @favourite }\n else\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = current_user.favoritables.build(favorite_params)\n\n if @favorite.save\n render json: @favorite, status: :created\n else\n render json: @favorite.errors, status: :unprocessable_entity\n end\n end",
"def favorite(id)\n post(\"/favorites/create/#{id}.json\")\n end",
"def create\n @food = @fridge.foods.create(food_params)\n respond_with @food, location: -> { kitchen_board_path }\n end",
"def create\n @favo = Favo.new(favo_params)\n\n respond_to do |format|\n if @favo.save\n format.html { redirect_to @favo, notice: 'Favo was successfully created.' }\n format.json { render :show, status: :created, location: @favo }\n else\n format.html { render :new }\n format.json { render json: @favo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fav = Fav.new(params[:fav])\n\n respond_to do |format|\n if @fav.save\n format.html { redirect_to @fav, notice: 'Fav was successfully created.' }\n format.json { render json: @fav, status: :created, location: @fav }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fav.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n favourite=current_user.add_favourite(params[:key])\n if favourite\n respond_to do |format|\n format.json { render :json => jsonp(favourites_to_json([favourite])) }\n format.xml { render :xml => favourites_to_xml([favourite]) }\n format.text { render :text => text_not_supported }\n end\n else\n render_error('Favourite not found', 404)\n end\n end",
"def create\n @favorite_recipe = FavoriteRecipe.new(favorite_recipe_params)\n\n respond_to do |format|\n if @favorite_recipe.save\n format.html { redirect_to @favorite_recipe, notice: 'Favorite recipe was successfully created.' }\n format.json { render :show, status: :created, location: @favorite_recipe }\n else\n format.html { render :new }\n format.json { render json: @favorite_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favour = Favour.new(favour_params)\n\n respond_to do |format|\n if @favour.save\n format.html { redirect_to @favour, notice: 'Favour was successfully created.' }\n format.json { render :show, status: :created, location: @favour }\n else\n format.html { render :new }\n format.json { render json: @favour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n\n respond_to do |format|\n if @favourite.save\n format.html { redirect_back notice: 'Favourite was successfully created.', fallback_location: root_path }\n format.json { render :show, status: :created, location: @favourite }\n else\n format.html { render :new }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(params[:favorite])\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render json: @favorite, status: :created, location: @favorite }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @done_food = DoneFood.new(done_food_params)\n\n respond_to do |format|\n if @done_food.save\n format.html { redirect_to @done_food, notice: 'Done food was successfully created.' }\n format.json { render :show, status: :created, location: @done_food }\n else\n format.html { render :new }\n format.json { render json: @done_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n recipe = Recipe.find(params[:id])\n @favorite = current_user.add_to_favorite(recipe.id)\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to :back, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(favorite_params)\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(favorite_params)\n\n respond_to do |format|\n if @favorite.save\n format.html { redirect_to @favorite, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @favorite }\n else\n format.html { render :new }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorecido = Favorecido.new(favorecido_params)\n @favorecido = @favorecido\n respond_to do |format|\n if @favorecido.save\n format.html { redirect_to favorecidos_url, notice: 'Favorecido criado com sucesso.' }\n format.json { render :show, status: :created, location: @favorecido }\n else\n format.html { render :new }\n format.json { render json: @favorecido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fast_food = FastFood.new(fast_food_params)\n\n respond_to do |format|\n if @fast_food.save\n format.html { redirect_to @fast_food, notice: 'Fast food was successfully created.' }\n format.json { render :show, status: :created, location: @fast_food }\n else\n format.html { render :new }\n format.json { render json: @fast_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @faves_arr = []\n @favourites = current_user.favourites.map do |fave|\n @faves_arr << Location.find_by_id(fave.location_id)\n end\n\n render json: @faves_arr.map(&:transform_json), status: 201\n end",
"def create\n @food = Food.new(food_params)\n respond_to do |format|\n if @food.save\n format.html { redirect_to @food, notice: 'Food was successfully created.' }\n format.json { render :show, status: :created, location: @food }\n else\n format.html { render :new }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n Favorite.create favorite_params\n show_all\n end",
"def new\n @favourite_food = FavouriteFood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @favourite_food }\n end\n end",
"def create\n @user = current_user\n @favorite_movie = @user.favorite_movies.build(favorite_movie_params)\n if @user.save\n render json: @favorite_movie\n end\n end",
"def create\n @favorite = user.favorites.new(favorite_params)\n\n if @favorite.save\n render :show, status: :ok\n else\n render json: @favorite.errors, status: :unprocessable_entity\n end\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n if @favourite.save\n render text: 'ok'\n else\n render text: 'fail'\n end\n end",
"def create\n @favourites = Favourite.new()\n @favourites.user_id = current_user.id;\n @favourites.army_list_id = params[:favourite][:army_list_id]\n \n respond_to do |format|\n if @favourites.save\n flash[:notice] = 'Favourites was successfully created.'\n format.html { redirect_back_or_default(user_favourites_url(current_user)) }\n format.xml { render :xml => @favourites, :status => :created, :location => @favourites }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @favourites.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite_dish = FavoriteDish.new(favorite_dish_params)\n\n respond_to do |format|\n if @favorite_dish.save\n format.html { redirect_to @favorite_dish, notice: 'Favorite dish was successfully created.' }\n format.json { render :show, status: :created, location: @favorite_dish }\n else\n format.html { render :new }\n format.json { render json: @favorite_dish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite_restaurant = FavoriteRestaurant.new(favorite_restaurant_params)\n\n respond_to do |format|\n if @favorite_restaurant.save\n format.html { redirect_to @favorite_restaurant, notice: 'Favorite restaurant was successfully created.' }\n format.json { render :show, status: :created, location: @favorite_restaurant }\n else\n format.html { render :new }\n format.json { render json: @favorite_restaurant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @animal_food = AnimalFood.new(animal_food_params)\n\n respond_to do |format|\n if @animal_food.save\n format.html { redirect_to @animal_food, notice: \"Animal food was successfully created.\" }\n format.json { render :show, status: :created, location: @animal_food }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @animal_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favorite(action, value)\n raise ArgumentError, \"Invalid favorite action provided: #{action}\" unless @@FAVORITES_URIS.keys.member?(action)\n value = value.to_i.to_s unless value.is_a?(String)\n uri = \"#{@@FAVORITES_URIS[action]}/#{value}.json\"\n case action\n when :add\n response = http_connect {|conn| create_http_post_request(uri) }\n when :remove\n response = http_connect {|conn| create_http_delete_request(uri) }\n end\n bless_model(Twitter::Status.unmarshal(response.body))\n end",
"def create\n @favourites_recipe = FavouritesRecipe.new\n @favourites_recipe.user_id = current_user.id\n @favourites_recipe.recipe_id = params[:recipe_id]\n respond_to do |format|\n if @favourites_recipe.save\n format.html { redirect_to @favourites_recipe, notice: 'Favourites recipe was successfully created.' }\n format.json { render :show, status: :created, location: @favourites_recipe }\n else\n format.html { render :new }\n format.json { render json: @favourites_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_food = UserFood.new(user_food_params)\n\n respond_to do |format|\n if @user_food.save\n format.html { redirect_to @user_food, notice: 'User food was successfully created.' }\n format.json { render :show, status: :created, location: @user_food }\n else\n format.html { render :new }\n format.json { render json: @user_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = current_user.favorites.create(favorited_id:params[:favorited_id], favorited_type: params[:favorited_type])\n logger.debug \"FAV \" + @favorite.to_s\n respond_to do |format|\n format.js\n end\n end",
"def favourite_params\n params.require(:favourite).permit(:user_id, :fav_post_id)\n end",
"def create\n @food = Food.new(food_params)\n @food.user_id = current_user.id \n @food.restaurant_id = @restaurant.id\n\n respond_to do |format|\n if @food.save\n format.html { redirect_to @restaurant }\n format.json { render :show, status: :created, location: @food }\n else\n format.html { render :new }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favorite_params\n params.require(:favorite).permit(:name, :location_id, :user_id)\n end",
"def create\n @favor = Favor.new(params[:favor])\n\n respond_to do |format|\n if @favor.save\n format.html { redirect_to @favor, notice: 'Favor was successfully created.' }\n format.json { render json: @favor, status: :created, location: @favor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fooditem = Fooditem.new(params[:fooditem])\n\n respond_to do |format|\n if @fooditem.save\n format.html { redirect_to @fooditem, :notice => 'Fooditem was successfully created.' }\n format.json { render :json => @fooditem, :status => :created, :location => @fooditem }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @fooditem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @favourite_station = FavouriteStation.new(favourite_station_params)\n respond_to do |format|\n if current_user.favourites.include? @favourite_station.observation_station\n redirect_to @favourite_station.observation_station,\n notice:\"#{@favourite_station.observation_station.name} is already your favourite!\"\n elsif @favourite_station.save\n current_user.favourite_stations << @favourite_station\n format.html { redirect_to @favourite_station.observation_station,\n notice: \"#{@favourite_station.observation_station.name} has been added to the favourites.\" }\n format.json { render :show, status: :created, location: @favourite_station }\n else\n redirect_to root_path, notice:\"That's not allowed!\"\n end\n end\n end",
"def create\n session[:return_to] ||= request.referer\n @favourites = Favourite.new(favourite_params)\n\n\n respond_to do |format|\n if @favourites.save\n format.html { redirect_to session.delete(:return_to), notice: 'Favourite was successfully created.' }\n format.json { render action: 'show', status: :created, location: data_show_path }\n else\n format.html { render action: 'new' }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @favourite_food = FavouriteFood.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favourite_food }\n end\n end",
"def create\n @food = Food.new(params[:food])\n\n respond_to do |format|\n if @food.save\n format.html { redirect_to @food, notice: \"Piatto creato correttamente.\" }\n format.json { render json: @food, status: :created, location: @food }\n else\n format.html { render action: \"new\" }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @favourite_details = Hash.new\n\n @favourite_details[:user_id] = params[:user_id]\n @favourite_details[:job_posting_id] = params[:job_posting_id]\n @favourite_details[:status_flag] = params[:status_flag]\n @favourite = Favourite.new(@favourite_details)\n\n respond_to do |format|\n if @favourite.save\n flash[:notice] = 'Favourite was successfully created.'\n format.html { redirect_to(@favourite) }\n format.xml { render :xml => @favourite, :status => :created, :location => @favourite }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @favourite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_to_favourites\n \n #pull out whichever recipe you are clicking on\n yummly_id = params[:yummly_id]\n recipe = Yummly.find(yummly_id)\n\n # make new instance of that recipe\n r = Recipe.find_or_create_by(name: recipe.name, thumbnail: recipe.thumbnail)\n\n UserFavouriteRecipe.create(recipe_id: r.id, user_id: current_user.id, yummly_id: yummly_id)\n\n redirect_to recipes_url, notice: \"Added recipe from your list of favourite recipes\"\n\n end",
"def create\n @favourite_drink = FavouriteDrink.new(favourite_drink_params)\n\n respond_to do |format|\n if @favourite_drink.save\n format.html { redirect_to @favourite_drink, notice: 'Favourite drink was successfully created.' }\n format.json { render :show, status: :created, location: @favourite_drink }\n else\n format.html { render :new }\n format.json { render json: @favourite_drink.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorito = Favorito.new(params[:favorito])\n\n respond_to do |format|\n if @favorito.save\n format.html { redirect_to @favorito, notice: 'Favorito was successfully created.' }\n format.json { render json: @favorito, status: :created, location: @favorito }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favorito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipes_food = RecipesFood.new(recipes_food_params)\n\n respond_to do |format|\n if @recipes_food.save\n format.html { redirect_to @recipes_food, notice: 'Recipes food was successfully created.' }\n format.json { render :show, status: :created, location: @recipes_food }\n else\n format.html { render :new }\n format.json { render json: @recipes_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n favory = current_user.favories.create(product_id: params[:id], user_id: current_user.id)\n redirect_to products_path()\n end",
"def create\n @favorite = current_user.favorites.build(params[:favorite])\n if @favorite.save\n flash[:notice] = \"Favorite saved!\"\n end\n # redirect_to root_path\n respond_with(@favorite)\n end",
"def create\n @food = Food.create(params[:food])\n redirect_to foods_url\n end",
"def create\n\t\t food_params = params.require(:food).permit(:name, :exercise, :calories, :time)\n\t\t food = Food.create(food_params)\n\t\t current_user.foods << food\n\t\t if food.save\n\t\t \tredirect_to \"/users/#{current_user.id}\"\n\t\t end\n\tend",
"def create\n @favorite_flyer = FavoriteFlyer.new(params[:favorite_flyer])\n\n respond_to do |format|\n if @favorite_flyer.save\n format.html { redirect_to @favorite_flyer, notice: 'Favorite flyer was successfully created.' }\n format.json { render json: @favorite_flyer, status: :created, location: @favorite_flyer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favorite_flyer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n fav = params[:favorite]\n fav[:user_id] = current_user.id\n fav[:name] = fav[:note]\n @favorite = Favorite.new(fav)\n @favorite.save\n render 'toggle'\n end",
"def create\n favorite_image = current_user.favorite_images.new(create_params)\n if favorite_image.save\n render json: { id: favorite_image.id }, status: :ok\n else\n render json: { error: favorite_image.errors.full_messages.to_sentence }, status: :bad_request\n end\n end",
"def create\n @favourite_category = FavouriteCategory.new(favourite_category_params)\n\n respond_to do |format|\n if @favourite_category.save\n format.html { redirect_to @favourite_category, notice: 'Favourite category was successfully created.' }\n format.json { render :show, status: :created, location: @favourite_category }\n else\n format.html { render :new }\n format.json { render json: @favourite_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favo_params\n params.require(:favo).permit(:user_id, :tweet_id)\n end",
"def set_favorite\n @json = Punk::API.one_beer!(params[:id])\n @json = @json&.first\n if FavoriteBeer.where(punk_id: @json[:punk_id], user_id: @current_user.id).empty?\n @fav_beer = FavoriteBeer.new(@json)\n @fav_beer.user_id = @current_user.id.to_i\n @fav_beer.save!\n end\n\n @json[:favorite] = true\n render json: {\n favorite_beer_set: @json\n }\n end",
"def create\n build_resource\n if resource.valid?\n if resource.favorited_user.present? && is_valid_favorite(resource.favorited_user)\n resource.save\n render json: resource, serializer: Api::V1::FavoriteSerializer\n else\n render json: [{'error':'Unable to favorite this user'}], status: :unprocessable_entity\n end\n else\n render json: resource.errors, status: :unprocessable_entity\n end\n end",
"def food_params\n params.require(:food).permit(:name, :date, :food, :place, :picture, :user_id, :count, :counttype)\n end",
"def favourite_artists\n @favourite_artists = FavouriteArtist.all\n render :json => @favourite_artists.to_json\n end",
"def favorite_params\n params.require(:favorite).permit(\n :list_id, :location_id\n )\n end",
"def create\n @favorite_item = current_user.favorite_items.new(favorite_item_params)\n\n respond_to do |format|\n if @favorite_item.save\n format.html { redirect_to @favorite_item, notice: t('.notice') }\n format.js\n format.json { render :show, status: :created, location: @favorite_item }\n else\n format.html { render :new }\n format.json { render json: @favorite_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def food_params\n params.require(:food).permit(:name, :description, :image_url, :price,\n :category_id, :restaurant_id,\n tag_ids: [])\n end",
"def create\n @favoritepizza = Favoritepizza.new(favoritepizza_params)\n\n @favoritepizza = Favoritepizza.new params.require(:favoritepizza).permit(:pizza_id)\n if @favoritepizza.save\n current_user.favoritepizzas << @favoritepizza\n redirect_to user_path current_user\n else\n render :back\n end\n end",
"def create\n @type_food = TypeFood.new(type_food_params)\n\n respond_to do |format|\n if @type_food.save\n format.html { redirect_to @type_food, notice: 'Type food was successfully created.' }\n format.json { render :show, status: :created, location: @type_food }\n else\n format.html { render :new }\n format.json { render json: @type_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @favourite_food = FavouriteFood.find(params[:id])\n @favourite_food.destroy\n\n respond_to do |format|\n format.html { redirect_to favourite_foods_url }\n format.json { head :no_content }\n end\n end",
"def create\n @auction_favorite = Auction::Favorite.new(auction_favorite_params)\n\n respond_to do |format|\n if @auction_favorite.save\n format.html { redirect_to @auction_favorite, notice: 'Favorite was successfully created.' }\n format.json { render :show, status: :created, location: @auction_favorite }\n else\n format.html { render :new }\n format.json { render json: @auction_favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favourite_params\n params.require(:favourite).permit(:user_id, :book_id, :deleted_at, :deleted)\n end",
"def favourite_params\n params.require(:favourite).permit(:user_id, :product_id)\n end",
"def create_favorite\r\n favorite = RequestFavorite.find(params[:request_id]).request\r\n request = Request.new(user_id: favorite.user_id, service_id: favorite.service_id, description: favorite.description, service_type: favorite.service_type, payment_method: favorite.payment_method, vehicle_type: favorite.vehicle_type, latitud: favorite.latitud, longitud: favorite.longitud, status: '')\r\n if request.save\r\n render json: request\r\n else\r\n render json: {errors: request.errors.full_messages}, status: 422\r\n end\r\n end",
"def create\n @fooddiary = @food.fooddiaries.new(fooddiary_params)\n @fooddiary.user_id = current_user.id\n @fooddiary.name = @food.name\n @fooddiary.eiweiß = @food.eiweiß\n @fooddiary.fett = @food.fett\n @fooddiary.kohlenhydrate = @food.kohlenhydrate\n @fooddiary.kalorien = @food.kalorien\n respond_to do |format|\n if @fooddiary.save\n format.html { redirect_to foods_path }\n format.json { render :show, status: :created, location: @fooddiary }\n else\n format.html { render :new }\n format.json { render json: @fooddiary.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @list_favorite = ListFavorite.new(list_favorite_params)\n\n respond_to do |format|\n if @list_favorite.save\n format.html { redirect_to @list_favorite, notice: 'Lista foi adicionada aos favoritos!' }\n format.json { render :show, status: :created, location: @list_favorite }\n else\n format.html { render :new }\n format.json { render json: @list_favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favorite_restaurant_params\n params.require(:favorite_restaurant).permit(:user_id, :restaurant_id)\n end",
"def favoritepizza_params\n params.require(:favoritepizza).permit(:user_id, :pizza_id)\n end",
"def create\n @favoriten = Favoriten.new(favoriten_params)\n\n respond_to do |format|\n if @favoriten.save\n format.html { redirect_to @favoriten, notice: 'Favoriten was successfully created.' }\n format.json { render :show, status: :created, location: @favoriten }\n else\n format.html { render :new }\n format.json { render json: @favoriten.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite = Favorite.new(params[:favorite])\n @favorite.user = current_user\n \n respond_to do |format|\n if @favorite.save\n format.html { redirect_to(favorites_url, :notice => 'Favorite was successfully created.') }\n format.xml { render :xml => @favorite, :status => :created, :location => @favorite }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @favorite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @fridge_food = FridgeFood.new(params[:fridge_food])\n\n respond_to do |format|\n if @fridge_food.save\n format.html { redirect_to(@fridge_food, :notice => 'Fridge food was successfully created.') }\n format.xml { render :xml => @fridge_food, :status => :created, :location => @fridge_food }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @fridge_food.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n # Rails.logger.warn \"====================\"\n # Rails.logger.warn foaf_params[:interests_attributes]\n # Rails.logger.warn \"====================\"\n\n \n @foaf = Foaf.new(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n end\n end\n\n respond_to do |format|\n if @foaf.save \n format.html { redirect_to @foaf, notice: 'FOAF was successfully created.' }\n format.json { render action: 'show', status: :created, location: @foaf }\n else\n format.html { render action: 'new' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_favorites(brewery_id)\n Favorite.create(user_id: current_user.id,brewery_id:brewery_id)\n end",
"def create_favorites(brewery_id)\n Favorite.create(user_id: current_user.id,brewery_id:brewery_id)\n end",
"def frequent_foods\n get(\"/user/#{@user_id}/foods/log/frequent.json\")\n end",
"def create\n @meal_food = MealFood.new(meal_food_params)\n\n respond_to do |format|\n if @meal_food.save\n format.html { redirect_to @meal_food, notice: 'Meal food was successfully created.' }\n format.json { render :show, status: :created, location: @meal_food }\n else\n format.html { render :new }\n format.json { render json: @meal_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_favourite_restaurants\n @profile = Profile.find(params[:id])\n @restaurants = @profile.favourites\n\n render status: 200, json: @restaurants\n end",
"def done_food_params\n params.require(:done_food).permit(:Client_id, :Food_id, :count)\n end",
"def create\n @saved_food = SavedFood.new(params[:saved_food])\n\n respond_to do |format|\n if @saved_food.save\n format.html { redirect_to(@saved_food, :notice => 'Saved food was successfully created.') }\n format.xml { render :xml => @saved_food, :status => :created, :location => @saved_food }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @saved_food.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @fav_pokemon = FavPokemon.new(fav_pokemon_params)\n\n respond_to do |format|\n if @fav_pokemon.save\n format.html { redirect_to @fav_pokemon, notice: 'Fav pokemon was successfully created.' }\n format.json { render :show, status: :created, location: @fav_pokemon }\n else\n format.html { render :new }\n format.json { render json: @fav_pokemon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n # Rails.logger.warn \"====================\"\n # Rails.logger.warn foaf_params[:interests_attributes]\n # Rails.logger.warn \"====================\"\n\n \n @foaf = Foaf.new(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n end\n end\n\n respond_to do |format|\n if @foaf.save \n format.html { redirect_to @foaf, notice: 'Foaf was successfully created.' }\n format.json { render action: 'show', status: :created, location: @foaf }\n else\n format.html { render action: 'new' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def remove_favorite_food(food_id)\n delete(\"/user/#{@user_id}/foods/favorite/#{food_id}.json\")\n end",
"def animal_food_params\n params.require(:animal_food).permit(:animal_id, :food_id)\n end",
"def favoriteanimal_params\n params.require(:favorite_animal).permit(:user_id, :animal_id)\n end",
"def create\n @favorite_route = FavoriteRoute.new(favorite_route_params)\n if @favorite_route.save\n render json: @favorite_route, status: :created, location: @favorite_route\n else\n render json: @favorite_route.errors, status: :unprocessable_entity\n end \n end",
"def create\n @food_event = FoodEvent.new(food_event_params)\n\n respond_to do |format|\n if @food_event.save\n format.html { redirect_to @food_event, notice: 'Food event was successfully created.' }\n format.json { render :show, status: :created, location: @food_event }\n else\n format.html { render :new }\n format.json { render json: @food_event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favory.update(favory_params)\n format.html { redirect_to @favory, notice: \"Favory was successfully updated.\" }\n format.json { render :show, status: :ok, location: @favory }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @favory.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favorite_params\n params.require(:favorite).permit(:user_id, :post_id)\n end"
] | [
"0.7474016",
"0.72381335",
"0.68717104",
"0.67320657",
"0.67147535",
"0.6686058",
"0.6683381",
"0.66759866",
"0.66702694",
"0.66301703",
"0.6624711",
"0.6616305",
"0.6553704",
"0.64493114",
"0.64317966",
"0.6424552",
"0.6421776",
"0.64178",
"0.63654524",
"0.6352685",
"0.63417727",
"0.63417727",
"0.6336499",
"0.6310442",
"0.62940294",
"0.6274822",
"0.6266885",
"0.6265646",
"0.62521803",
"0.62505865",
"0.6241531",
"0.62319684",
"0.6225987",
"0.6222222",
"0.6219537",
"0.62185454",
"0.62097216",
"0.6191773",
"0.619002",
"0.6186309",
"0.61788887",
"0.6177519",
"0.6166384",
"0.6142088",
"0.6138276",
"0.61201406",
"0.61084133",
"0.6107264",
"0.6098964",
"0.6094695",
"0.6091971",
"0.60875785",
"0.6072125",
"0.6060844",
"0.6056658",
"0.6052988",
"0.6042112",
"0.60369736",
"0.6029265",
"0.6025302",
"0.60212773",
"0.6014776",
"0.6011798",
"0.6002265",
"0.59926265",
"0.59901357",
"0.5983937",
"0.5981096",
"0.5973375",
"0.5957821",
"0.59500986",
"0.5949191",
"0.59410954",
"0.59348077",
"0.59249514",
"0.59210753",
"0.59093744",
"0.590875",
"0.58990717",
"0.58989275",
"0.5888789",
"0.5862467",
"0.5842628",
"0.5835319",
"0.5812761",
"0.5812761",
"0.5811205",
"0.5809764",
"0.5808557",
"0.58083755",
"0.5801985",
"0.57999426",
"0.579975",
"0.57985413",
"0.5796631",
"0.5792614",
"0.57922244",
"0.57921314",
"0.57819754",
"0.5780327"
] | 0.7219231 | 2 |
PUT /favourite_foods/1 PUT /favourite_foods/1.json | def update
@favourite_food = FavouriteFood.find(params[:id])
respond_to do |format|
if @favourite_food.update_attributes(params[:favourite_food])
format.html { redirect_to @favourite_food, notice: 'Favourite food was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @favourite_food.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end",
"def update\n json_response(@food_item.update!(food_item_params))\n end",
"def update\n respond_to do |format|\n if @favory.update(favory_params)\n format.html { redirect_to @favory, notice: \"Favory was successfully updated.\" }\n format.json { render :show, status: :ok, location: @favory }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @favory.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favo.update(favo_params)\n format.html { redirect_to @favo, notice: 'Favo was successfully updated.' }\n format.json { render :show, status: :ok, location: @favo }\n else\n format.html { render :edit }\n format.json { render json: @favo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favourite.update(favourite_params)\n format.html { redirect_to @favourite, notice: \"Favourite was successfully updated.\" }\n format.json { render :show, status: :ok, location: @favourite }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favourite.update(favourite_params)\n format.html { redirect_to @favourite, notice: 'Favourite was successfully updated.' }\n format.json { render :show, status: :ok, location: @favourite }\n else\n format.html { render :edit }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mark_favourite\n @favourite_artist = FavouriteArtist.where(spotify_id: params[:spotify_id]).first_or_create(_params)\n render :json => @favourite_artist.to_json\n end",
"def update\n @fav = Fav.find(params[:id])\n\n respond_to do |format|\n if @fav.update_attributes(params[:fav])\n format.html { redirect_to @fav, notice: 'Fav was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fav.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @favourite.update(favourite_params)\n format.html { redirect_to @favourite, notice: 'Favourite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_favorite_food(food_id)\n post(\"/user/#{@user_id}/foods/log/favorite/#{food_id}.json\")\n end",
"def update\n respond_with Favor.update(params[:id], params[:favor])\n end",
"def update\n respond_to do |format|\n if @favour.update(favour_params)\n format.html { redirect_to @favour, notice: 'Favour was successfully updated.' }\n format.json { render :show, status: :ok, location: @favour }\n else\n format.html { render :edit }\n format.json { render json: @favour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favorite = Favorite.find(params[:id])\n\n respond_to do |format|\n if @favorite.update_attributes(params[:favorite])\n format.html { redirect_to @favorite, notice: 'Favorite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favorite = Favorite.find(params[:id])\n\n respond_to do |format|\n if @favorite.update_attributes(params[:favorite])\n format.html { redirect_to @favorite, notice: 'Favorite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite.update(favorite_params)\n format.html { redirect_to @favorite, notice: 'Favorite was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite }\n else\n format.html { render :edit }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite.update(favorite_params)\n format.html { redirect_to @favorite, notice: 'Favorite was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite }\n else\n format.html { render :edit }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite.update(favorite_params)\n format.html { redirect_to @favorite, notice: 'Favorite was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite }\n else\n format.html { render :edit }\n format.json { render json: @favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favourite = Favourite.new(favourite_params)\n\n respond_to do |format|\n if @favourite.save\n sync_update @favourite.fav_post\n format.html { redirect_to :my_favourites, notice: 'Favourite was successfully created.' }\n format.json { render json: @favourite }\n else\n format.json { render json: @favourite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @food.update(food_params)\n respond_with @food, location: -> { kitchen_board_path }\n end",
"def update\n if @favorite.update(favorite_params)\n render :show, status: :ok\n else\n render json: @favorite.errors, status: :unprocessable_entity\n end\n end",
"def update\n @favourite = Favourite.find(params[:id])\n\n respond_to do |format|\n if @favourite.update_attributes(params[:favourite])\n flash[:notice] = 'Favourite was successfully updated.'\n format.html { redirect_to(@favourite) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @favourite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @favourites = Favourite.find(params[:id])\n\n respond_to do |format|\n if @favourites.update_attributes(params[:favourites])\n flash[:notice] = 'Favourites was successfully updated.'\n format.html { redirect_to(@favourites) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @favourites.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_food\n @food = @fridge.foods.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @favorecido.update(favorecido_params)\n format.html { redirect_to favorecidos_url, notice: 'Favorecido atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @favorecido }\n else\n format.html { render :edit }\n format.json { render json: @favorecido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def favorite(action, value)\n raise ArgumentError, \"Invalid favorite action provided: #{action}\" unless @@FAVORITES_URIS.keys.member?(action)\n value = value.to_i.to_s unless value.is_a?(String)\n uri = \"#{@@FAVORITES_URIS[action]}/#{value}.json\"\n case action\n when :add\n response = http_connect {|conn| create_http_post_request(uri) }\n when :remove\n response = http_connect {|conn| create_http_delete_request(uri) }\n end\n bless_model(Twitter::Status.unmarshal(response.body))\n end",
"def update\n respond_to do |format|\n if @favorite_recipe.update(favorite_recipe_params)\n format.html { redirect_to @favorite_recipe, notice: 'Favorite recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite_recipe }\n else\n format.html { render :edit }\n format.json { render json: @favorite_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favourites_recipe.update(favourites_recipe_params)\n format.html { redirect_to @favourites_recipe, notice: 'Favourites recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @favourites_recipe }\n else\n format.html { render :edit }\n format.json { render json: @favourites_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @favourite.update(favourite_params)\n redirect_to @favourite, notice: 'Favourite was successfully updated.'\n else\n render action: :edit\n end\n end",
"def update\n @favor = Favor.find(params[:id])\n\n respond_to do |format|\n if @favor.update_attributes(params[:favor])\n format.html { redirect_to @favor, notice: 'Favor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite_item.update(favorite_item_params)\n format.html { redirect_to @favorite_item, notice: t('.notice') }\n format.json { render :show, status: :ok, location: @favorite_item }\n else\n format.html { render :edit }\n format.json { render json: @favorite_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favoritepizza.update(favoritepizza_params)\n format.html { redirect_to @favoritepizza, notice: 'Favoritepizza was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @favoritepizza.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fast_food.update(fast_food_params)\n format.html { redirect_to @fast_food, notice: 'Fast food was successfully updated.' }\n format.json { render :show, status: :ok, location: @fast_food }\n else\n format.html { render :edit }\n format.json { render json: @fast_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @food.update(food_params)\n format.html { redirect_to @food, notice: 'Food was successfully updated.' }\n format.json { render :show, status: :ok, location: @food }\n else\n format.html { render :edit }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_favourite\n @favourite = Favourite.find(params[:id])\n end",
"def update\n @favorite = Favorite.find(params[:id])\n\n respond_to do |format|\n if @favorite.update_attributes(params[:favorite])\n format.html { redirect_to(favorites_url, :notice => 'Favorite was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @favorite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @food = Food.find(params[:id])\n\n respond_to do |format|\n if @food.update_attributes(params[:food])\n format.html { redirect_to foods_path(), notice: 'Food was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favourite_listing = get_favourite_listing(params[:id])\n\n respond_to do |format|\n if @favourite_listing.update_attributes(params[:favourite_listing])\n format.html { redirect_to @favourite_listing, notice: 'Favourite listing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favourite_listing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_favourite\n @favourite = Favourite.find(params[:id])\n end",
"def set_favourite\n @favourite = Favourite.find(params[:id])\n end",
"def set_favourite\n @favourite = Favourite.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @favorite_dish.update(favorite_dish_params)\n format.html { redirect_to @favorite_dish, notice: 'Favorite dish was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite_dish }\n else\n format.html { render :edit }\n format.json { render json: @favorite_dish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite.update_attributes(params[:favorite])\n format.html { redirect_to(favorites_path, :notice => 'Favorite was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n respond_to do |format|\n if @done_food.update(done_food_params)\n format.html { redirect_to @done_food, notice: 'Done food was successfully updated.' }\n format.json { render :show, status: :ok, location: @done_food }\n else\n format.html { render :edit }\n format.json { render json: @done_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_my_favorites\n\t\tif @user.update_attributes(my_favorite: params[:my_favorite])\n\t\t# response to the JSON\n\t\t\trender json: { success: true,message: \"My favorites Successfully Updated.\", response: {my_favorite: @user.my_favorite} },:status=>200\n\t else\n\t render :json=> { success: false, message: @user.errors },:status=> 203\n\t end\t\n\tend",
"def update\n if @favorite_route.update(favorite_route_params)\n render json: @favorite_route, status: :ok, location: @favorite_route\n else\n render json: @favorite_route.errors, status: :unprocessable_entity\n end\n end",
"def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'FOAF was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favourite_food = FavouriteFood.new(params[:favourite_food])\n\n respond_to do |format|\n if @favourite_food.save\n format.html { redirect_to @favourite_food, notice: 'Favourite food was successfully created.' }\n format.json { render json: @favourite_food, status: :created, location: @favourite_food }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favourite_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @favourite_food = FavouriteFood.find(params[:id])\n @favourite_food.destroy\n\n respond_to do |format|\n format.html { redirect_to favourite_foods_url }\n format.json { head :no_content }\n end\n end",
"def set_favory\n @favory = Favory.find(params[:id])\n end",
"def favorite(id)\n post(\"/favorites/create/#{id}.json\")\n end",
"def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'Foaf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_food.update(user_food_params)\n format.html { redirect_to @user_food, notice: 'User food was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_food }\n else\n format.html { render :edit }\n format.json { render json: @user_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite_restaurant.update(favorite_restaurant_params)\n format.html { redirect_to @favorite_restaurant, notice: 'Favorite restaurant was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite_restaurant }\n else\n format.html { render :edit }\n format.json { render json: @favorite_restaurant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favorito = Favorito.find(params[:id])\n\n respond_to do |format|\n if @favorito.update_attributes(params[:favorito])\n format.html { redirect_to @favorito, notice: 'Favorito was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favorito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @animal_food.update(animal_food_params)\n format.html { redirect_to @animal_food, notice: \"Animal food was successfully updated.\" }\n format.json { render :show, status: :ok, location: @animal_food }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @animal_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_favo\n @favo = Favo.find(params[:id])\n end",
"def set_favorite\n @json = Punk::API.one_beer!(params[:id])\n @json = @json&.first\n if FavoriteBeer.where(punk_id: @json[:punk_id], user_id: @current_user.id).empty?\n @fav_beer = FavoriteBeer.new(@json)\n @fav_beer.user_id = @current_user.id.to_i\n @fav_beer.save!\n end\n\n @json[:favorite] = true\n render json: {\n favorite_beer_set: @json\n }\n end",
"def update\n @favorite_flyer = FavoriteFlyer.find(params[:id])\n\n respond_to do |format|\n if @favorite_flyer.update_attributes(params[:favorite_flyer])\n format.html { redirect_to @favorite_flyer, notice: 'Favorite flyer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favorite_flyer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_favourites_recipe\n @favourites_recipe = FavouritesRecipe.find(params[:id])\n end",
"def update\n @food = Food.find(params[:id])\n\n respond_to do |format|\n if @food.update_attributes(params[:food])\n format.html { redirect_to @food, notice: \"Piatto aggiornato correttamente.\" }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = @current_user\n @excuse = Excuse.find(params[:id])\n # @excuse.location = @user.location\n # favorites = @excuse.favorites.build\n\n respond_to do |format|\n if @excuse.update_attributes(params[:excuse])\n format.html { redirect_to @excuse, notice: 'Excuse was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @excuse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @favourite_food = FavouriteFood.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favourite_food }\n end\n end",
"def set_favorecido\n @favorecido = Favorecido.find(params[:id])\n end",
"def set_food\n @food = @recipe.foods.find(params[:id])\n end",
"def create_favorite(id)\n post \"favorites/create/#{id}\", {}\n end",
"def update\n if @diet.nil?\n send_error_json(nil, \"Param 'diet' missing\", 400)\n return\n end\n\n if !check_owner()\n send_error_json(@diet.id, 'Unauthorized', 403)\n return\n end\n\n fav = true\n if params['diet'].nil? || params['diet']['favourite'].nil? || params['diet']['favourite']=='false'\n fav = false\n end\n update_hash = {:favourite => fav}\n if params['diet'] && params['diet']['amount']\n update_hash[:amount] = params['diet']['amount'].to_f\n end\n if params['diet'] && params['diet']['food_type_name']\n ft = FoodType.where(name: params['diet']['food_type_name']).first\n if !ft.nil?\n amount = @diet.amount\n if !update_hash[:amount].nil?\n amount = update_hash[:amount].to_f\n end\n update_hash[:food_type_id] = ft.id\n update_hash[:name] = ft.name\n # update_hash[:calories] = amount*ft.kcal\n # update_hash[:carbs] = amount*ft.carb\n # update_hash[:fat] = amount*ft.fat\n # update_hash[:prot] = amount*ft.prot\n else\n send_error_json(@diet.id, \"Invalid food type\", 400)\n return\n end\n\n end\n\n if @diet.update_attributes(update_hash)\n send_success_json(@diet.id, { diet_name: @diet.diet_name})\n else\n send_error_json(@diet.id, @diet.errors.full_messages.to_sentence, 400)\n end\n\n end",
"def update\n @shops_favorite = ShopsFavorite.find(params[:id])\n\n respond_to do |format|\n if @shops_favorite.update_attributes(params[:shops_favorite])\n format.html { redirect_to(@shops_favorite, :notice => 'Shops favorite was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shops_favorite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_favour\n @favour = Favour.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @food_item_add_on.update(food_item_add_on_params)\n format.html { redirect_to @food_item_add_on, notice: 'Food item add on was successfully updated.' }\n format.json { render :show, status: :ok, location: @food_item_add_on }\n else\n format.html { render :edit }\n format.json { render json: @food_item_add_on.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list_favorite.update(list_favorite_params)\n format.html { redirect_to @list_favorite, notice: 'Lista favoritos foi atualizada!' }\n format.json { render :show, status: :ok, location: @list_favorite }\n else\n format.html { render :edit }\n format.json { render json: @list_favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_api_v1_favorite\n @api_v1_favorite = Api::V1::Favorite.find(params[:id])\n end",
"def remove_favorite_food(food_id)\n delete(\"/user/#{@user_id}/foods/favorite/#{food_id}.json\")\n end",
"def update\n if params.has_key? :like\n @client.put(\"/me/favorites/#{params[:id]}\")\n head :ok and return\n end\n\n if params.has_key? :unlike\n @client.delete(\"/me/favorites/#{params[:id]}\")\n head :ok and return\n end\n\n if params.has_key? :repost\n @client.put(\"/me/track_reposts/#{params[:id]}\")\n head :ok and return\n end\n\n if params.has_key? :unpost\n @client.delete(\"/me/track_reposts/#{params[:id]}\")\n head :ok and return\n end\n\n head :bad_request\n end",
"def update\n respond_to do |format|\n if @auction_favorite.update(auction_favorite_params)\n format.html { redirect_to @auction_favorite, notice: 'Favorite was successfully updated.' }\n format.json { render :show, status: :ok, location: @auction_favorite }\n else\n format.html { render :edit }\n format.json { render json: @auction_favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipes_food.update(recipes_food_params)\n format.html { redirect_to @recipes_food, notice: 'Recipes food was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipes_food }\n else\n format.html { render :edit }\n format.json { render json: @recipes_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @shop_favorite.update(shop_favorite_params)\n format.html { redirect_to(@shop_favorite, notice: 'Shop favorite was successfully updated.') }\n format.json { render :show, status: :ok, location: @shop_favorite }\n else\n format.html { render :edit }\n format.json { render json: @shop_favorite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fooditem = Fooditem.find(params[:id])\n\n respond_to do |format|\n if @fooditem.update_attributes(params[:fooditem])\n format.html { redirect_to @fooditem, :notice => 'Fooditem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @fooditem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @food_event.update(food_event_params)\n format.html { redirect_to @food_event, notice: 'Food event was successfully updated.' }\n format.json { render :show, status: :ok, location: @food_event }\n else\n format.html { render :edit }\n format.json { render json: @food_event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def update\n respond_to do |format|\n if @favorite_album.update(favorite_album_params)\n format.html { redirect_to @favorite_album, notice: 'Favorite album was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite_album }\n else\n format.html { render :edit }\n format.json { render json: @favorite_album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @type_food.update(type_food_params)\n format.html { redirect_to @type_food, notice: 'Type food was successfully updated.' }\n format.json { render :show, status: :ok, location: @type_food }\n else\n format.html { render :edit }\n format.json { render json: @type_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_favorite_recipe\n @favorite_recipe = FavoriteRecipe.find(params[:id])\n end",
"def update\n @favorite_template.update(favorite_template_params)\n render json: @favorite_template\n end",
"def update\n respond_to do |format|\n if @favourite_category.update(favourite_category_params)\n format.html { redirect_to @favourite_category, notice: 'Favourite category was successfully updated.' }\n format.json { render :show, status: :ok, location: @favourite_category }\n else\n format.html { render :edit }\n format.json { render json: @favourite_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def set_favorite_item\n @favorite_item = FavoriteItem.find(params[:id])\n end",
"def favorite\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if favorited = @product.favorite_toggle(params[:udid])\n format.html { redirect_to @product, notice: 'Favorite was successfully updated.' }\n format.json { render json: {favorite_count: @product.favorite_count, favorited: favorited == 1 ? true : false }, status: :ok }\n else\n format.html { render action: \"show\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_food\n @food = Food.find(params[:id])\n end",
"def set_food\n @food = Food.find(params[:id])\n end",
"def set_food\n @food = Food.find(params[:id])\n end",
"def set_food\n @food = Food.find(params[:id])\n end",
"def set_food\n @food = Food.find(params[:id])\n end",
"def set_food\n @food = Food.find(params[:id])\n end",
"def set_food\n @food = Food.find(params[:id])\n end",
"def set_food\n @food = Food.find(params[:id])\n end",
"def set_food\n @food = Food.find(params[:id])\n end",
"def set_food\n @food = Food.find(params[:id])\n end",
"def set_food\n @food = Food.find(params[:id])\n end",
"def set_api_favorite\n @api_favorite = Api::Favorite.find(params[:id])\n end"
] | [
"0.7014924",
"0.67057246",
"0.6702148",
"0.66944414",
"0.66811377",
"0.667469",
"0.666159",
"0.6640309",
"0.6587724",
"0.6557583",
"0.65235865",
"0.64982474",
"0.64741874",
"0.64741874",
"0.64584434",
"0.64584434",
"0.64584434",
"0.63933563",
"0.6358495",
"0.6343483",
"0.6337244",
"0.63319594",
"0.63093966",
"0.62877244",
"0.62829524",
"0.62553835",
"0.62474126",
"0.6223653",
"0.6206584",
"0.6203819",
"0.61998266",
"0.61967784",
"0.6171125",
"0.6165531",
"0.61546314",
"0.6153351",
"0.6151966",
"0.61451936",
"0.61451936",
"0.61451936",
"0.61449957",
"0.6137589",
"0.6133178",
"0.6121845",
"0.6119065",
"0.60951114",
"0.6093537",
"0.6092711",
"0.60793495",
"0.60619134",
"0.60585487",
"0.60551643",
"0.60484433",
"0.6047741",
"0.6034788",
"0.6032498",
"0.6026878",
"0.6025376",
"0.60164756",
"0.6002505",
"0.6001094",
"0.59888744",
"0.59773666",
"0.5973891",
"0.59727067",
"0.5964049",
"0.5963406",
"0.59632856",
"0.5960328",
"0.5953776",
"0.59440935",
"0.5943495",
"0.59430647",
"0.5940397",
"0.5911223",
"0.59045124",
"0.58987916",
"0.58950025",
"0.58938074",
"0.5889612",
"0.5874998",
"0.58653855",
"0.5858177",
"0.5856338",
"0.5853857",
"0.5853857",
"0.5839905",
"0.58356506",
"0.5834055",
"0.5832886",
"0.5832886",
"0.5832886",
"0.5832886",
"0.5832886",
"0.5832886",
"0.5832886",
"0.5832886",
"0.5832886",
"0.5832886",
"0.58312356"
] | 0.6960666 | 1 |
DELETE /favourite_foods/1 DELETE /favourite_foods/1.json | def destroy
@favourite_food = FavouriteFood.find(params[:id])
@favourite_food.destroy
respond_to do |format|
format.html { redirect_to favourite_foods_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_favorite_food(food_id)\n delete(\"/user/#{@user_id}/foods/favorite/#{food_id}.json\")\n end",
"def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @fooditem = Fooditem.find(params[:id])\n @fooditem.destroy\n\n respond_to do |format|\n format.html { redirect_to fooditems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @saved_food = SavedFood.find(params[:id])\n @saved_food.destroy\n\n respond_to do |format|\n format.html { redirect_to(saved_foods_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @fast_food.destroy\n respond_to do |format|\n format.html { redirect_to fast_foods_url, notice: 'Fast food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fridge_food = FridgeFood.find(params[:id])\n @fridge_food.destroy\n\n respond_to do |format|\n format.html { redirect_to(fridge_foods_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @fav = Fav.find(params[:id])\n @fav.destroy\n\n respond_to do |format|\n format.html { redirect_to favs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to(foods_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @favorite = Favorite.find(params[:id])\n @favorite.destroy\n\n respond_to do |format|\n format.html { redirect_to favorites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite_dish.destroy\n respond_to do |format|\n format.html { redirect_to favorite_dishes_url, notice: 'Favorite dish was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favoritepizza.destroy\n respond_to do |format|\n format.html { redirect_to favoritepizzas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @animal_food.destroy\n respond_to do |format|\n format.html { redirect_to animal_foods_url, notice: \"Animal food was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fooddiary.destroy\n respond_to do |format|\n format.html { redirect_to food_fooddiaries_url(@food.id) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourite.destroy\n respond_to do |format|\n format.html { redirect_to favourites_url, notice: \"Favourite was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourite.destroy\n respond_to do |format|\n format.html { redirect_to favourites_url, notice: 'Favourite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourites_recipe.destroy\n respond_to do |format|\n format.html { redirect_to favourites_recipes_url, notice: 'Favourites recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite_flyer = FavoriteFlyer.find(params[:id])\n @favorite_flyer.destroy\n\n respond_to do |format|\n format.html { redirect_to favorite_flyers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_with favorites.first!.destroy\n end",
"def destroy\n @food.destroy\n respond_to do |format|\n format.html { redirect_to foods_url, notice: 'Food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food.destroy\n respond_to do |format|\n format.html { redirect_to foods_url, notice: 'Food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food.destroy\n respond_to do |format|\n format.html { redirect_to foods_url, notice: 'Food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food_recipe = FoodRecipe.find(params[:id])\n @food_recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to food_recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy_favorite(id)\n delete \"favorites/destroy/#{id}\"\n end",
"def destroy\n\t\tif food = FoodItem.find(params[:id])\n\t\t\tfood.destroy\n\t\t\thead :no_content\n\t\tend\n\tend",
"def destroy\n @favourite.destroy\n respond_to do |format|\n format.html { redirect_to @favourite }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foaf.destroy\n\n respond_to do |format|\n format.html { redirect_to foafs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foaf.destroy\n\n respond_to do |format|\n format.html { redirect_to foafs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite_recipe.destroy\n respond_to do |format|\n format.html { redirect_to favorite_recipes_url, notice: 'Favorite recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @raw_food.destroy\n respond_to do |format|\n format.html { redirect_to raw_foods_url, notice: 'Raw food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipes_food.destroy\n respond_to do |format|\n format.html { redirect_to recipes_foods_url, notice: 'Recipes food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foam = Foam.find(params[:id])\n @foam.destroy\n\n respond_to do |format|\n format.html { redirect_to foams_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @food.destroy\n respond_to do |format|\n format.html { redirect_to @restaurant, notice: 'Food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_food.destroy\n respond_to do |format|\n format.html { redirect_to user_foods_url, notice: 'User food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite_restaurant.destroy\n respond_to do |format|\n format.html { redirect_to favorite_restaurants_url, notice: 'Favorite restaurant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @done_food.destroy\n respond_to do |format|\n format.html { redirect_to done_foods_url, notice: 'Done food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @campus_food = CampusFood.find(params[:id])\n @campus_food.destroy\n\n respond_to do |format|\n format.html { redirect_to campus_foods_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @favour.destroy\n respond_to do |format|\n format.html { redirect_to favours_url, notice: 'Favour was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food_item.destroy\n respond_to do |format|\n format.html { redirect_to food_items_url, notice: \"Food item was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type_food.destroy\n respond_to do |format|\n format.html { redirect_to type_foods_url, notice: 'Type food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meal_food.destroy\n respond_to do |format|\n format.html { redirect_to meal_foods_url, notice: 'Meal food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food_item_add_on.destroy\n respond_to do |format|\n format.html { redirect_to food_item_add_ons_url, notice: 'Food item add on was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foodlog = Foodlog.find(params[:id])\n @foodlog.destroy\n\n respond_to do |format|\n format.html { redirect_to foodlogs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @favo.destroy\n respond_to do |format|\n format.html { redirect_to favos_url, notice: 'Favo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food_item.destroy!\n head :no_content\n end",
"def destroy\n @post = @favourite.fav_post\n @favourite.destroy\n sync_update @post\n respond_to do |format|\n format.html { redirect_to :my_favourites, notice: 'Favourite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourite_drink.destroy\n respond_to do |format|\n format.html { redirect_to favourite_drinks_url, notice: 'Favourite drink was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favor = Favor.find(params[:id])\n @favor.destroy\n\n respond_to do |format|\n format.html { redirect_to favors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourite_listing = get_favourite_listing(params[:id])\n @favourite_listing.destroy\n\n respond_to do |format|\n format.html { redirect_to favourite_listings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourites = Favourite.find(params[:id])\n @favourites.destroy\n\n respond_to do |format|\n format.html { redirect_to(favourites_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @favorite.destroy\n respond_to do |format|\n format.html { redirect_to favorites_url, notice: 'Favorite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite.destroy\n respond_to do |format|\n format.html { redirect_to favorites_url, notice: 'Favorite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite.destroy\n respond_to do |format|\n format.html { redirect_to favorites_url, notice: 'Favorite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foodhamper = Foodhamper.find(params[:id])\n @foodhamper.destroy\n\n respond_to do |format|\n format.html { redirect_to foodhampers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourite = Favourite.find(params[:id])\n @favourite.destroy\n\n respond_to do |format|\n format.html { redirect_to(favourites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @restaurant_dish = Restaurant::Dish.find(params[:id])\n @restaurant_dish.destroy\n\n respond_to do |format|\n format.html { redirect_to restaurant_dishes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @restaurant = Restaurant.find(params[:restaurant_id])\n @food = @restaurant.foods.find(params[:id])\n @food.destroy\n # Food.find(params[:id]).destroy\n redirect_to restaurant_path(@restaurant)\n end",
"def destroy\n @food.destroy\n @food.image.destroy\n @j = Joint.where(food_id: @food.id)\n if @j == true\n @j.destroy_all\n end\n respond_to do |format|\n format.html { redirect_to foods_url, notice: 'Food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :manage_account, current_account\n @food = current_account.foods.find(params[:id])\n @food.destroy\n respond_with @food, :location => foods_url\n end",
"def destroy\n @favorite_web_thing.destroy\n respond_to do |format|\n format.html { redirect_to favorite_web_things_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite.destroy\n respond_to do |format|\n format.html { redirect_to favorites_url, notice: 'Favorito quitado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite.destroy\n\n head :no_content\n end",
"def destroy\n @favorecido.destroy\n respond_to do |format|\n format.html { redirect_to favorecidos_url, notice: 'Favorecido eliminado com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foil = Foil.find(params[:id])\n @foil.destroy\n\n respond_to do |format|\n format.html { redirect_to foils_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @favourite.destroy\n respond_to do |format|\n format.html { redirect_back notice: 'Favourite was successfully destroyed.', fallback_location: root_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favor.destroy\n\n respond_to do |format|\n format.html { redirect_to favors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food.destroy\n respond_with @food, location: -> { kitchen_board_path }\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def destroy\n @favorite = Favorite.find(params[:id])\n @favorite.destroy\n\n respond_to do |format|\n format.html { redirect_to favorites_url , notice: '削除しました。'}\n format.json { head :no_content }\n end\n end",
"def destroy\n @dish_mood.destroy\n respond_to do |format|\n format.html { redirect_to dish_moods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foodhistory.destroy\n respond_to do |format|\n format.html { redirect_to foodhistories_url, notice: 'Foodhistory was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite_image.destroy\n respond_to do |format|\n format.html { redirect_to favorite_images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite = Favorite.find(params[:id])\n @favorite.destroy\n\n respond_to do |format|\n format.html { redirect_to(favorites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @foiltype = Foiltype.find(params[:id])\n @foiltype.destroy\n\n respond_to do |format|\n format.html { redirect_to foiltypes_url }\n format.json { head :ok }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @fascicle.destroy\n respond_to do |format|\n format.html { redirect_to fascicles_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @coffeeshoplist.destroy\n respond_to do |format|\n format.html { redirect_to coffeeshoplists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foodery = Foodery.find(params[:id])\n @foodery.destroy\n\n respond_to do |format|\n format.html { redirect_to(fooderies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @diet_dish.destroy\n respond_to do |format|\n format.html { redirect_to diet_dishes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourite.destroy\n redirect_to favourites_url\n end",
"def destroy\n @fish.destroy\n respond_to do |format|\n format.html { redirect_to fish_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = current_user\n @FavoriteMovie = FavoriteMovie.find(params[:id]).delete\n render json: { msg: \"Delete Successful\" }\n end",
"def destroy\n @favorite_album.destroy\n respond_to do |format|\n format.html { redirect_to favorite_albums_url, notice: 'Favorite album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaurant = Restaurant.find(params[:id])\n @restaurant.destroy\n\n respond_to do |format|\n format.html { redirect_to restaurants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaurant = Restaurant.find(params[:id])\n @restaurant.destroy\n\n respond_to do |format|\n format.html { redirect_to restaurants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaurant = Restaurant.find(params[:id])\n @restaurant.destroy\n\n respond_to do |format|\n format.html { redirect_to restaurants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaurant = Restaurant.find(params[:id])\n @restaurant.destroy\n\n respond_to do |format|\n format.html { redirect_to restaurants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaurant = Restaurant.find(params[:id])\n @restaurant.destroy\n\n respond_to do |format|\n format.html { redirect_to restaurants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaurant = Restaurant.find(params[:id])\n @restaurant.destroy\n\n respond_to do |format|\n format.html { redirect_to restaurants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaurant = Restaurant.find(params[:id])\n @restaurant.destroy\n\n respond_to do |format|\n format.html { redirect_to restaurants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaurant = Restaurant.find(params[:id])\n @restaurant.destroy\n\n respond_to do |format|\n format.html { redirect_to restaurants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food_truck.destroy\n respond_to do |format|\n format.html { redirect_to food_trucks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @store_detail = StoreDetail.find(params[:store_detail_id])\n @food = Food.find(params[:id])\n @food.destroy\n respond_to do |format|\n format.html { redirect_to store_detail_foods_path(@store_detail), notice: 'Food detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourite_category.destroy\n respond_to do |format|\n format.html { redirect_to favourite_categories_url, notice: 'Favourite category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list_favorite.destroy\n respond_to do |format|\n format.html { redirect_to list_favorites_url, notice: 'Lista removida dos favoritos!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food = Food.find(params[:id])\n name = @food.name.nil? ? 'Item' : @food.name\n @food.destroy\n respond_to do |format|\n flash[:notice] = \"#{name} was successfully deleted.\"\n format.html { redirect_to foods_url }\n format.xml { head :ok }\n end\n end",
"def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end",
"def destroy\n Fish.find(params[:id]).destroy\n render nothing: true\n end"
] | [
"0.7427092",
"0.7296844",
"0.7296844",
"0.70963365",
"0.7025781",
"0.70044833",
"0.69768685",
"0.6970896",
"0.6966709",
"0.6951589",
"0.69415987",
"0.6933586",
"0.6929641",
"0.6925296",
"0.69223464",
"0.692048",
"0.6912096",
"0.69096017",
"0.6908586",
"0.68933874",
"0.68933874",
"0.68933874",
"0.68855435",
"0.6877791",
"0.68771577",
"0.6869587",
"0.6866338",
"0.6866338",
"0.6864568",
"0.68471295",
"0.68443894",
"0.6842553",
"0.68403184",
"0.6837704",
"0.6835466",
"0.68235964",
"0.6822982",
"0.681866",
"0.6817037",
"0.6781456",
"0.6779971",
"0.67779076",
"0.6777246",
"0.67718357",
"0.6764097",
"0.6763109",
"0.67619735",
"0.67547715",
"0.67447263",
"0.6744635",
"0.6739939",
"0.67368615",
"0.67368615",
"0.67368615",
"0.67272276",
"0.6724951",
"0.67172945",
"0.67096627",
"0.6706501",
"0.66909933",
"0.66749537",
"0.6662717",
"0.6649935",
"0.6641257",
"0.6637497",
"0.66341907",
"0.6624294",
"0.6622376",
"0.66172105",
"0.6617193",
"0.66162413",
"0.6615601",
"0.66137016",
"0.6611432",
"0.6599758",
"0.65977436",
"0.6589177",
"0.6588264",
"0.6585837",
"0.6568447",
"0.65645057",
"0.6563837",
"0.65618104",
"0.65602696",
"0.6557578",
"0.65490645",
"0.65490645",
"0.65490645",
"0.65490645",
"0.65490645",
"0.65490645",
"0.65490645",
"0.65490645",
"0.65476596",
"0.65347743",
"0.6534677",
"0.6523652",
"0.6522926",
"0.6519041",
"0.65149915"
] | 0.7730022 | 0 |
use before filter to validate authenticity | def create
sent_email = SentEmail.find_by_slug(params[:s])
Event.create_from_api!(:category => "email", :type => params[:event].try(:titleize), :prospect_id => sent_email.prospect_id, :sent_email_id => sent_email.id)
head :created
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def any_authenticity_token_valid?; end",
"def verify_authenticity_token; end",
"def verify_authenticity_token\n if auth_token_param.present?\n verify_valid_auth_token!\n else\n super\n end\n end",
"def form_authenticity_param; end",
"def verify_authenticity_token\n verified_request? || raise(ActionController::InvalidAuthenticityToken)\n end",
"def before_rodauth\n rails_verify_authenticity_token\n super\n end",
"def valid_for_params_auth?; end",
"def authenticate_scope!\n \n \n do_before_request \n\n end",
"def valid_for_authentication?; end",
"def valid_for_authentication?; end",
"def rails_verify_authenticity_token\n controller = rails_controller.new\n controller.set_request! ActionDispatch::Request.new(scope.env)\n controller.send(:verify_authenticity_token)\n end",
"def handle_unverified_request\n raise ActionController::InvalidAuthenticityToken\n end",
"def handle_unverified_request\n raise ActionController::InvalidAuthenticityToken\n end",
"def authenticity_token\n @authenticity_token || helper.form_authenticity_token\n end",
"def authenticity_token\n @authenticity_token || helper.form_authenticity_token\n end",
"def before_filter; end",
"def filter_request(request)\n @token.authenticate(request)\n end",
"def protect_against_forgery?; end",
"def rails_check_csrf!\n rails_controller_instance.send(:verify_authenticity_token)\n end",
"def authenticate_user!\n token, options = ActionController::HttpAuthentication::Token.token_and_options(request)\n\n super unless token == 'rbMmEeoH8RxRDyN24PQv'\n end",
"def valid_for_http_auth?; end",
"def protected\n auth = request.headers['HTTP_AUTHORIZATION']\n\n if auth =~ /sekret/\n render json: {success: \"You're in!\"}\n else\n render json: {error: 'Unauthorized'}, status: 401\n end\n end",
"def request_authenticity_tokens; end",
"def rails_check_csrf!\n rails_controller_instance.send(:verify_authenticity_token)\n end",
"def verify_authenticity_token\n super unless request_comes_from_facebook?\n end",
"def _before_validation\n end",
"def verified_request?\r\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\r\n end",
"def allow_params_authentication!; end",
"def authenticity_token\n @context.registers[:authenticity_token]\n end",
"def protect_against_forgery?\n\n end",
"def verified_request?\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n end",
"def verified_request?\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n end",
"def verified_request?\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n end",
"def verified_request?\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n end",
"def check_json_authenticity\n\t\treturn unless request.format.js? or request.format.json?\n\t\treturn unless protect_against_forgery?\n\t\tauth_token = params[request_forgery_protection_token]\n\t\tunless (auth_token and form_authenticity_token == URI.unescape(auth_token))\n\t\t\traise(ActionController::InvalidAuthenticityToken)\n\t\tend\n\tend",
"def check_json_authenticity\n return unless request.format.js? or request.format.json?\n return unless protect_against_forgery?\n return unless params[request_forgery_protection_token]\n auth_token = params[request_forgery_protection_token]\n unless (auth_token and form_authenticity_token == URI.unescape(auth_token))\n raise(ActionController::InvalidAuthenticityToken)\n end\n end",
"def protect_against_forgery?\n end",
"def validation_login\n validate_token User, params[:token]\n end",
"def verified_request?\n\t\tsuper || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n\tend",
"def authenticate_user\n render_403 'Invalid user.' if @user.blank? || !@user.active?\n end",
"def check_json_authenticity\n return unless request.format.js? or request.format.json?\n return unless protect_against_forgery?\n auth_token = params[request_forgery_protection_token]\n unless (auth_token and form_authenticity_token == URI.unescape(auth_token))\n raise(ActionController::InvalidAuthenticityToken)\n end\n end",
"def check_json_authenticity\n return unless request.format.js? or request.format.json?\n return unless protect_against_forgery?\n auth_token = params[request_forgery_protection_token]\n unless (auth_token and form_authenticity_token == URI.unescape(auth_token))\n raise(ActionController::InvalidAuthenticityToken)\n end\n end",
"def before_each(req)\n if dealership(req).nil? then not_found\n elsif !authenticated?(req) then unauthenticated\n elsif !authorized?(role(req), session_user(req)) then unauthorized\n else super\n end\n end",
"def validate_api_filter\n if params[:token].nil?\n token = params[params.keys.reject { |k| [:action, :controller].include?(k) }.first][:token]\n unless token.nil?\n params[:token] = token\n params[params.keys.reject { |k| [:action, :controller].include?(k) }.first].delete(:token)\n end\n end\n @user = User.api_key_authentication(params[:token]) if params[:token]\n unless @user\n render :xml => \"<xml><error><response>Invalid API Key</response></error></xml>\", :status => :forbidden\n false\n end\n end",
"def valid_before; end",
"def verified_request?\n\t\tsuper || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n\tend",
"def proof_of_authenticity\n valid_asset_definition? ? @asset_definition.proof_of_authenticity : false\n end",
"def authenticity_token\n render json: { token: form_authenticity_token }\n end",
"def validate_filter\n ensure_filter_only_attributes\n ensure_no_unsupported_filters\n end",
"def before_request\n self.login if require_login? && !@authenticating\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def authenticate(request)\n\n end",
"def check_authentication\n case self.controller_name\n when /^clients/i, /^ingredients/i, /^orders/i, /^pages/i, /^productpresentations/i, /^products/i, /^companies/i\n authenticate\n end\n end",
"def handle_unverified_request\n \n # By default this method raises ActionController::InvalidAuthenticityToken\n #redirect_to root_url\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def protect_against_forgery?\n controller.send(:protect_against_forgery?)\n end",
"def validate_authentication_token\n \n @user = User.find_by_services_authentification_token(params[:auth_token])\n bad_request if @user.nil?\n end",
"def oAuthValidate\r\n logger.info(\"UserController::oAuthValidate::Params:----#{params}\")\r\n \r\n end",
"def pre_validation\n\n\n end",
"def http_authenticatable?; end",
"def pre_validation\n\n end",
"def before_request\n end",
"def validate_and_sanitize\n r = validate\n return invalid_credentials_response('a_ar_b_vas_1') unless r.success?\n\n @parsed_request_time = Time.at(@request_timestamp.to_i)\n\n return invalid_credentials_response(\"um_vac_1\") unless @parsed_request_time && (@parsed_request_time.between?(Time.now - expiry_window, Time.now + expiry_window))\n\n @request_parameters.permit!\n\n [\"signature\"].each do |k|\n @request_parameters.delete(k)\n end\n\n success\n end",
"def validate\n raise \"Can only validate request messages\" unless type == :request\n\n raise(NotTargettedAtUs, \"Received message is not targetted to us\") unless PluginManager[\"security_plugin\"].validate_filter?(payload[:filter])\n end",
"def pre_authorize_cb; end",
"def accept_authenticity\n authenticate_with_http_basic do |email, password|\n user = User.find_by(email: email, provider: 'pagehub')\n\n if user && user.valid_password?(password)\n @current_user = user\n end\n end\n\n warden.custom_failure! if performed?\n\n halt! 401 unless current_user.present?\n verify_authenticity_token unless otr_api_call?\n end",
"def authenticate_scope!\n super\n end",
"def authorize\n end",
"def authorize\n end",
"def authentication\n login_required and \n (params[\"commit\"] == \"Login\" or verify_authenticity_token) \n end",
"def validate\n hash={:valid => valid?}\n\n # make sure no authentication information is left by\n # this validation \n reset_session\n cookies[:auth_token]\n\n respond_to do |format|\n format.json { render :json => jsonp(hash) }\n format.xml { render :xml => hash.to_xml(:skip_types => true, :root => 'authentication') }\n format.text { render :text => text_not_supported }\n end\n end",
"def authenticate\n# byebug\n return true if public_action?\n if request.format.json?\n authenticate_token || render_json_unauthorized\n else\n authenticate_user!\n end\n end",
"def before_validation_callback\n end",
"def login_filter\n\t\tif not protect?( action_name )\n\t\t\treturn true \n\t\tend\n\n\t\tif not session[:user_id]\n\t\t\t# user isn't logged in\n\t\t\tstore_location\n\t\t\tredirect_to :controller=>\"account\", :action=>\"login\"\n\t\t\treturn false\n\t\tend\n\n\t\t# initialize the @user variable\n\t\t@user = User.find( session[:user_id] )\n\t\t\n\t\tif not @user.validated?\n\t\t\t# user is logged in, but they haven't been validated\n\t\t\tredirect_to :controller=>\"account\", :action=>\"not_activated\"\n\t\t\treturn false\n\t\telsif not authorized?( @user, action_name )\n\t\t\t# user is logged in and validated, but not authorized\n\t\t\tredirect_to :controller=>\"account\", :action =>\"denied\"\n\t\t\treturn false\n\t\telse\n\t\t\t# user is logged in AND validated AND authorized! let 'em in!\n\t\t\treturn true\t\n\t\tend\n\n\t\t# we shouldn't get here\n\t\traise \"Serious malfunction in 'login_filter' -- please contact manufacturer (cgahan@ideeinc.com)...\"\n\tend",
"def protect_against_forgery?\n false\n end",
"def check_csrf\n rails_check_csrf!\n end",
"def check_auth\n authorize @equipment_listing\n end",
"def authenticate_request\n fail 'Sub-class to implement.'\n end",
"def verify_authenticity_token(*args) \n if params[:api_key] && params[:format] == 'xml' \n key = params[:api_key]\n conditions = ['api_key = ? AND (api_key_expires_at < ? OR api_key_expires_at IS NULL)', key, Time.now]\n gateway = Gateway.first(:conditions => conditions) \n raise(ActionController::InvalidAuthenticityToken) unless gateway\n else\n original_verify_authenticity_token(*args) \n end \n end",
"def auth_controller?\n false\n end",
"def valid_authenticity_token?(session, encoded_masked_token); end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN']) || api_operator.present?\n end",
"def authenticate\n self.get && true\n end",
"def authenticate_requester!(request)\n end",
"def before\n\t\t\ttrue\n\t\tend",
"def authenticate_user!\n puts \"request type is #{request.content_type}\"\n unless request.content_type == 'application/json' \n unless current_user\n flash[:alert] = \"Please login to continue.\"\n redirect_to new_user_session_path\n end\n end\n end",
"def authenticated?; super; end"
] | [
"0.696648",
"0.69142133",
"0.6748593",
"0.6724684",
"0.6712404",
"0.66588014",
"0.6544405",
"0.64587235",
"0.6415576",
"0.6415576",
"0.6372786",
"0.6349039",
"0.6349039",
"0.6327784",
"0.6327461",
"0.6254966",
"0.6254722",
"0.62340516",
"0.6218359",
"0.619184",
"0.6170809",
"0.6162959",
"0.6153819",
"0.60942084",
"0.60919803",
"0.6052783",
"0.60118896",
"0.59934515",
"0.5991751",
"0.598026",
"0.5966887",
"0.5966887",
"0.5966887",
"0.5966887",
"0.59598327",
"0.5947168",
"0.59396785",
"0.59333634",
"0.5924825",
"0.5916061",
"0.59153813",
"0.59153813",
"0.58893365",
"0.5882975",
"0.587845",
"0.5854869",
"0.58547014",
"0.5853549",
"0.584693",
"0.5842261",
"0.58314884",
"0.58314884",
"0.58314884",
"0.58314884",
"0.58314884",
"0.58314884",
"0.58314884",
"0.58314884",
"0.58314884",
"0.58314884",
"0.58314884",
"0.58314884",
"0.58314884",
"0.5794916",
"0.57946855",
"0.5794642",
"0.57875985",
"0.57875985",
"0.57875985",
"0.575369",
"0.57532007",
"0.5727802",
"0.5706045",
"0.5698677",
"0.5696918",
"0.5686537",
"0.56686723",
"0.56594723",
"0.5657505",
"0.5646332",
"0.5638644",
"0.563132",
"0.563132",
"0.5628889",
"0.56229544",
"0.56223136",
"0.55957675",
"0.55956805",
"0.5586201",
"0.55776787",
"0.5577183",
"0.55573577",
"0.55433506",
"0.55339855",
"0.55241895",
"0.55220276",
"0.5520173",
"0.5512319",
"0.5502361",
"0.549272",
"0.5492447"
] | 0.0 | -1 |
GET /shops/1 GET /shops/1.xml | def show
@user = User.find(params[:user_id])
@shop = Shop.find(params[:id])
redirect_to user_shop_products_path(:user_id => @user, :shop_id => @shop)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @hops_addition = HopsAddition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hops_addition }\n end\n end",
"def show\n @shops_favorite = ShopsFavorite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shops_favorite }\n end\n end",
"def show\n @shop_item = ShopItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shop_item }\n end\n end",
"def index\n @shops = @shops.all\n end",
"def index\n @sprints = @product.sprints\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sprints }\n end\n end",
"def show\n @title = \"Show Operations\"\n @operation = Operation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operation }\n end\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end",
"def index\n @shops = Shop.all\n end",
"def index\n @shops = Shop.all\n end",
"def index\n @shops = Shop.all\n end",
"def index\n @shops = Shop.all\n end",
"def index\n @shops = Shop.all\n end",
"def workload\n @sprint = Sprint.find(params[:id])\n\n respond_to do |format|\n format.html # workload.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def show\n @repairshop = Repairshop.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @repairshop }\n end\n end",
"def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end",
"def index\n\n @soaps = Soap.find(:all)\n @user = User.find(:first)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @purchase }\n end\n end",
"def show\n @sprint = Sprint.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @sprint.to_xml }\n end\n end",
"def show\n @shelf = Shelf.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shelf.to_xml(:include => :books) }\n end\n end",
"def index\n @shops = @business_type.shops.all\n end",
"def index\n @sitelinks = Sitelink.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sitelinks }\n end\n end",
"def show\n @sprint = Sprint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def show\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end",
"def index\n @lookup_scantasks = LookupScantask.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_scantasks }\n end\n end",
"def show\n @operation = Operation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operation }\n end\n end",
"def index\n @sprints = Sprint.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @sprints.to_xml }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service }\n end\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sale }\n end\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sale }\n end\n end",
"def show\n @service = Service.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service }\n end\n end",
"def show\n @statusproject = Statusproject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @statusproject }\n end\n end",
"def index\n @q = params[:q]\n @q ||= \"\"\n @shops = Shop.search(@q).records\n\n\n respond_to do |format|\n format.html { render action: 'index' }\n format.json { render json: @shops, each_serializer: ShopListSerializer }\n end\n end",
"def show\n @sitio = Sitio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sitio }\n end\n end",
"def show\n @shops = Barbershop.find(params[:id])\n\n end",
"def index\n @shopping_lists = ShoppingList.find_all_by_user_id(session[:user_id])\n\n respond_to do |format|\n format.html \n format.xml { render :xml => @shopping_lists }\n end\n end",
"def show\n @workshops_course = WorkshopsCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @workshops_course }\n end\n end",
"def show\n @shopping = Shopping.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shopping }\n\t #format.json { render :json => @shopping}\n end\n end",
"def show\n @service_checker = ServiceChecker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service_checker }\n end\n end",
"def show\n\t@storecunsumption = Storecunsumption.find(params[:id])\n\t\trespond_to do |format|\t\t\n\t\tformat.html \n\t\tformat.xml { render :xml => @storecunsumptions }\t\t#Render to XML File\n\t\tend\n\tend",
"def show\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tso.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end",
"def show\n @scraper = Scraper.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @scraper }\n end\n end",
"def index\n @workshops = Workshop.past\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workshops }\n end\n end",
"def show\n @spouse = Spouse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spouse }\n end\n end",
"def show\n @recycling_site = RecyclingSite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @recycling_site }\n end\n end",
"def index\n @components_saddles = Components::Saddle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @components_saddles }\n end\n end",
"def show\n\n @sales_type = SalesType.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sales_type }\n end\n \n end",
"def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def show\n @shop_category = ShopCategory.find(params[:id])\n attr_hash = { :only => [:id, :created_at, :updated_at, :description, :tags, :title] }\n respond_to do |format|\n format.html {}\n format.xml { render :xml => @shop_category.to_xml(attr_hash) }\n format.json { render :json => @shop_category.to_json(attr_hash) }\n end\n end",
"def show\n @spit = Spit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spit }\n end\n end",
"def index\n @ships = Ship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ships }\n end\n end",
"def show\n @shop = Wmall::Shop.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop }\n end\n end",
"def show\n @lookup_scantask = LookupScantask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_scantask }\n end\n end",
"def show\n @sitelink = Sitelink.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sitelink }\n end\n end",
"def show\n @store = Store.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @store }\n end\n end",
"def show\n @page_id = \"services\"\n @service = Service.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service }\n end\n end",
"def show\n @shout = Shout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shout }\n end\n end",
"def show\n @shout = Shout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shout }\n end\n end",
"def show\n @service_check_detail = ServiceCheckDetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service_check_detail }\n end\n end",
"def show\n @service_subscription = ServiceSubscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service_subscription }\n end\n end",
"def index\n @shops = Shop.all\n @search = Shop.search(params[:q])\n @shops = @search.result.page(params[:page]).per(30)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shops }\n end\n\n end",
"def show\n @shop_ose = ShopOse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_ose }\n end\n end",
"def show\n @slittingproduction = Slittingproduction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @slittingproduction }\n end\n end",
"def show\n @silo = Silo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @silo }\n end\n end",
"def show\n @scout_master = ScoutMaster.find(params[:id])\n @scouts = Scouter.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @scout_master }\n end\n end",
"def shops\n @shops ||= (@doc/\"SpcShop\").collect { |it| Element.new(it) }\n end",
"def rest_get(uri)\n \n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n return doc\n \n end\n \nend",
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def index\n @standards = Standard.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @standards }\n end\n end",
"def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end",
"def show\n @service_log = ServiceLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service_log }\n end\n end",
"def show\n @store = Store.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @store }\n end\n end",
"def show\n @sale_order = SaleOrder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sale_order }\n end\n end",
"def show\n @home_categories_products_indices_shop = Home::Categories::Products::Indices::Shop.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @home_categories_products_indices_shop }\n end\n end",
"def index\n @service_versions = ServiceVersion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @service_versions }\n end\n end",
"def index\n @staff_shifts = StaffShift.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @staff_shifts }\n end\n end",
"def index\n return redirect_to shops_path\n end",
"def show\n @cso = Cso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cso }\n end\n end",
"def show\n @site = Site.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def show\n @site = Site.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def get_shop\n @shop = Shop.find(params[:shop_id])\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def index\n @workshops = Workshop.all\n end",
"def show\n @savings = Savings.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @savings }\n end\n end",
"def show\n @service_version = ServiceVersion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service_version }\n end\n end",
"def show\n @stockist = Stockist.find(params[:id])\n\n respond_to do |format|\n format.html # show.haml\n format.xml { render :xml => @stockist }\n end\n end",
"def show\n @staff_shift = StaffShift.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @staff_shift }\n end\n end",
"def show\n @slitting = Slitting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @slitting }\n end\n end",
"def new\n @shop = Shop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shop }\n end\n end",
"def show_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @scholarship }\n end\n end",
"def index\n @shots = Shot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @shots }\n end\n end",
"def show\n respond_to do |format|\n format.html { render action: 'show' }\n format.json { render json: @shop }\n end\n end",
"def index\n endpoint(get(services_url).body)\n end",
"def show\n @store = Store.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @store }\n end\n end",
"def show\n @store = Store.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @store }\n end\n end",
"def show\n @strelki = Strelki.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @strelki }\n end\n end",
"def show\n @msshiplot = Msshiplot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @msshiplot }\n end\n end"
] | [
"0.6238221",
"0.61808896",
"0.61581135",
"0.614906",
"0.60675645",
"0.6041577",
"0.60405374",
"0.6007169",
"0.6007169",
"0.6007169",
"0.6007169",
"0.6007169",
"0.5956732",
"0.59397095",
"0.5939524",
"0.59149855",
"0.58711517",
"0.58564293",
"0.5843357",
"0.5841318",
"0.5838049",
"0.5835565",
"0.58129424",
"0.58061254",
"0.58057743",
"0.58019656",
"0.578375",
"0.578375",
"0.576401",
"0.5723669",
"0.57165307",
"0.5712637",
"0.569285",
"0.5681934",
"0.5680068",
"0.56782615",
"0.5673581",
"0.5670902",
"0.56706214",
"0.5670085",
"0.56633204",
"0.56567234",
"0.56527215",
"0.56521106",
"0.5644723",
"0.5632798",
"0.563104",
"0.563104",
"0.563104",
"0.563104",
"0.563104",
"0.56191987",
"0.5618358",
"0.5610207",
"0.5602204",
"0.5601313",
"0.55978364",
"0.559177",
"0.5591128",
"0.55823076",
"0.55823076",
"0.557597",
"0.5573719",
"0.55719024",
"0.5561263",
"0.55504644",
"0.5546111",
"0.5545376",
"0.55420715",
"0.55381316",
"0.5537711",
"0.553676",
"0.5536024",
"0.5534914",
"0.5532829",
"0.553039",
"0.55254877",
"0.5522636",
"0.55213535",
"0.5517677",
"0.55172026",
"0.5510711",
"0.5510711",
"0.5509879",
"0.5508024",
"0.5505418",
"0.550478",
"0.5503222",
"0.5497675",
"0.54972523",
"0.54962707",
"0.5494997",
"0.549233",
"0.5489196",
"0.54870844",
"0.548701",
"0.5486633",
"0.5481262",
"0.5481262",
"0.54762733",
"0.5471634"
] | 0.0 | -1 |
GET /shops/new GET /shops/new.xml | def new
@shop = Shop.new
@user = User.find(params[:user_id])
# @categories =Category.find(:all, :conditions => { :parent_id => nil})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @shop = Shop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shop }\n end\n end",
"def new\n @hops_addition = HopsAddition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hops_addition }\n end\n end",
"def new\n @shops_favorite = ShopsFavorite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shops_favorite }\n end\n end",
"def new\n @title = \"New Operations\"\n @operation = Operation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operation }\n end\n end",
"def new\n @shopping = Shopping.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shopping }\n end\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @sprint = Sprint.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @shop_item = ShopItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shop_item }\n end\n end",
"def new\n @shelf = Shelf.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shelf }\n end\n end",
"def new\n @repairshop = Repairshop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @repairshop }\n end\n end",
"def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def new\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml\n end\n end",
"def new\n @operation = Operation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operation }\n end\n end",
"def new\n @shift = Shift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shift }\n end\n end",
"def new\n @shift = Shift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shift }\n end\n end",
"def new\n @shift = Shift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shift }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @shopping_list = ShoppingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shopping_list }\n end\n end",
"def new\n @rssnew = Rssnews.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rssnew }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @staff_shift = StaffShift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @staff_shift }\n end\n end",
"def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end",
"def new\n @shop = Shop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop }\n end\n end",
"def new\n @shop = Shop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop }\n end\n end",
"def new\n @shop = Shop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop }\n end\n end",
"def new\n @page_id = \"services\"\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service }\n end\n end",
"def new\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service }\n end\n end",
"def new\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def new\n @scraper = Scraper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scraper }\n end\n end",
"def new\n @nossos_servico = NossosServico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end",
"def new\n @repo = Repo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @repo }\n end\n end",
"def new\n @ss_type = SsType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ss_type }\n end\n end",
"def new\n @screw = Screw.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @screw }\n end\n end",
"def new\n @spit = Spit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spit }\n end\n end",
"def new\n @store = Store.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @store }\n end\n end",
"def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end",
"def new\n @workshops_course = WorkshopsCourse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @workshops_course }\n end\n end",
"def new\n @pushed = Pushed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pushed }\n end\n end",
"def new\n @store = Store.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @store }\n end\n end",
"def new\n @store = Store.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @store }\n end\n end",
"def new\n @store = Store.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @store }\n end\n end",
"def new\n @savings = Savings.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @savings }\n end\n end",
"def new\n @novel = Novel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @novel }\n end\n end",
"def new\n @station = Station.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @station }\n end\n end",
"def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end",
"def new\n @sti = Sti.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sti }\n end\n end",
"def new\n @lookup_scantask = LookupScantask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_scantask }\n end\n end",
"def new\n @sifter = Sifter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sifter }\n end\n end",
"def new\n # Set variables\n @snop = Snop.new\n @default_uri = params[:uri]\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n @scrape_order = ScrapeOrder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scrape_order }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def new\n @title = \"New Company\"\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def new\n @addition = Addition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @addition }\n end\n end",
"def new\n @item = Item.new\n @shop = Shop.find(params[:shop_id])\n @item.shop = @shop\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @production = Production.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @production }\n end\n end",
"def new\n @newspage = Newspage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newspage }\n end\n end",
"def new\n @recycling_site = RecyclingSite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recycling_site }\n end\n end",
"def new\n @collection = Collection.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @collection }\n end\n end",
"def new\n @statusproject = Statusproject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @statusproject }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @site }\n format.xml { render :xml => @site }\n end\n end",
"def new\n @service_version = ServiceVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service_version }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @software }\n end\n end",
"def new\n @slittingproduction = Slittingproduction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slittingproduction }\n end\n end",
"def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @sm = Sm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sm }\n end\n end",
"def new\n @suite = Suite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @suite }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end",
"def new\n @populate_feed_info = PopulateFeedInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @populate_feed_info }\n end\n end",
"def create\n @shop = @shops.new(shop_params)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: \"Shop was successfully created.\" }\n format.json { render :show, status: :created, location: @shop }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html { render :template => \"admin_sites/new\" }\n format.xml { render :xml => @site }\n end\n end",
"def new\n @story = Story.new\n @sprints = Sprint.new\n @products = Product.find(:all, :select => \"id, name\")\n @sprints = Sprint.find(:all, :select => 'id, title')\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @story }\n end\n end",
"def new\n @produto = ProdutoSimples.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @produto }\n end\n end",
"def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end",
"def new\n @strelki = Strelki.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @strelki }\n end\n end",
"def new\n @final_service = FinalService.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @final_service }\n end\n end",
"def new\n #1st you retrieve the customer thanks to params[:customer_id]\n customer = Customer.find(params[:customer_id])\n #2nd you build a new one\n @site = customer.sites.create\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @shop_ose = ShopOse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop_ose }\n end\n end",
"def new\n @salesplan = Salesplan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @salesplan }\n end\n end",
"def new\n @task = Task.new\n @sprint = Sprint.find(params[:id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end",
"def new\n @reqinfo = Reqinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reqinfo }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def new\n @news = News.new\n @title = \"New news\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end",
"def new\n @selector_site = SelectorSite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @selector_site }\n end\n end",
"def new\n @pool = Pool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pool }\n end\n end",
"def new\n @silo = Silo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @silo }\n end\n end",
"def new\n @copy = Copy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @copy }\n end\n end",
"def new\n @spiel = Spiel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spiel }\n end\n end",
"def new\n print params\n @product_sold = ProductSold.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_sold }\n end\n end",
"def new\n @git_repo = GitRepo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @git_repo }\n end\n end",
"def new\n @shot = Shot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shot }\n end\n end",
"def new\n @catalog = Catalog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalog }\n end\n end"
] | [
"0.70002466",
"0.68457824",
"0.6811468",
"0.6742787",
"0.6641042",
"0.66259116",
"0.66259116",
"0.6603827",
"0.6557197",
"0.6501302",
"0.64788455",
"0.6448646",
"0.6429665",
"0.6394656",
"0.63940257",
"0.63940257",
"0.63940257",
"0.6389104",
"0.6389104",
"0.6389104",
"0.6389104",
"0.6389104",
"0.6389104",
"0.6389104",
"0.6389104",
"0.63872105",
"0.6385303",
"0.6351797",
"0.6334829",
"0.6334788",
"0.6331601",
"0.6331601",
"0.6331601",
"0.63305277",
"0.63298696",
"0.63298696",
"0.632642",
"0.63175726",
"0.63140476",
"0.6304363",
"0.6290066",
"0.6276789",
"0.6274349",
"0.6258933",
"0.62528896",
"0.62408495",
"0.6236329",
"0.62291384",
"0.62291384",
"0.62291384",
"0.6207098",
"0.61994416",
"0.61950576",
"0.61929655",
"0.6180315",
"0.61802036",
"0.6180165",
"0.6178544",
"0.6168148",
"0.61633986",
"0.6163244",
"0.6161818",
"0.61611",
"0.6157456",
"0.6157114",
"0.6155521",
"0.61550117",
"0.6154558",
"0.6149113",
"0.61363375",
"0.61356044",
"0.6135408",
"0.61335415",
"0.6132963",
"0.61296827",
"0.6126679",
"0.61262804",
"0.6114485",
"0.61140525",
"0.6106793",
"0.6105821",
"0.6094909",
"0.609279",
"0.6092203",
"0.60858864",
"0.6082594",
"0.6081416",
"0.60806507",
"0.60768783",
"0.60765576",
"0.60765576",
"0.60753554",
"0.607271",
"0.60724473",
"0.60680366",
"0.6064813",
"0.60605586",
"0.6058907",
"0.60463256",
"0.6046225",
"0.6045511"
] | 0.0 | -1 |
POST /shops POST /shops.xml | def create
@user = User.find(params[:user_id])
@shop = Shop.new(params[:shop])
@shop.user = @user
@shop.status = 1
respond_to do |format|
if @shop.save
flash[:notice] = "您的店铺己激活#{params[:category_id]}=shop#{params[:shop][:category_id]}。"
format.html { redirect_to control_path(:user_id => @shop.user) }
else
format.html { render :action => "new" }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @shop = @shops.new(shop_params)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: \"Shop was successfully created.\" }\n format.json { render :show, status: :created, location: @shop }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def create\n @shop = Shop.new(shop_params)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to shops_url, notice: 'Shop #{@shop.name} was successfully created.' }\n format.json { render :show, status: :created, location: shops_url }\n else\n format.html { render :new }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_xml(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_XML)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|\n https.request(request)\n end\n return response.body if check_response(response, 201)\n end",
"def create\n @hops_addition = HopsAddition.new(params[:hops_addition])\n\n respond_to do |format|\n if @hops_addition.save\n flash[:notice] = 'HopsAddition was successfully created.'\n format.html { redirect_to(@hops_addition) }\n format.xml { render :xml => @hops_addition, :status => :created, :location => @hops_addition }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @hops_addition.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @shop = Shop.new(shop_params)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to shops_path, success: 'Shop was successfully created.' }\n else\n format.html { render action: 'new' }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # state 0 means shop is invaliable\n @shop = current_user.shops.new(shop_params.merge state: 0)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to uppics_shop_url(@shop), notice: 'Shop was successfully created.' }\n format.json { render :show, status: :created, location: @shop }\n else\n format.html { render :new }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sys_op = SysOp.new(params[:sys_op])\n\n respond_to do |format|\n if @sys_op.save\n format.html { redirect_to @sys_op, notice: 'Sys op was successfully created.' }\n format.json { render json: @sys_op, status: :created, location: @sys_op }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sys_op.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @repairshop = Repairshop.new(params[:repairshop])\n\n respond_to do |format|\n if @repairshop.save\n format.html { redirect_to(@repairshop, :notice => 'Repairshop was successfully created.') }\n format.xml { render :xml => @repairshop, :status => :created, :location => @repairshop }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @repairshop.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n @shop = Shop.find(params[:shop_id])\n @item.shop = @shop\n respond_to do |format|\n if @item.save\n format.html { redirect_to(@shop, :notice => 'Item was successfully created.') }\n format.xml { render :xml => @shop_for_item, :status => :created, :location => @shop_for_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @shop_for_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @director = Director.find(params[:director_id])\n @soaps = @director.soaps.create(soap_params)\n redirect_to director_path(@director)\n\n\n end",
"def create\n @shop = Shop.new(params[:shop])\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: 'Shop was successfully created.' }\n format.json { render json: @shop, status: :created, location: @shop }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shop = Shop.new(params[:shop])\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: 'Shop was successfully created.' }\n format.json { render json: @shop, status: :created, location: @shop }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shop = Shop.new(shop_params)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: 'Shop was successfully created.' }\n format.json { render :show, status: :created, location: @shop }\n else\n format.html { render :new }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shop = Shop.new(shop_params)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: 'Shop was successfully created.' }\n format.json { render :show, status: :created, location: @shop }\n else\n format.html { render :new }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @apply_shop = ApplyShop.new(apply_shop_params)\n\n respond_to do |format|\n if @apply_shop.save\n format.html { redirect_to @apply_shop, notice: 'Apply shop was successfully created.' }\n format.json { render action: 'show', status: :created, location: @apply_shop }\n else\n format.html { render action: 'new' }\n format.json { render json: @apply_shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@admin_shop = Admin::Shop.new(admin_shop_params)\n\n\t\trespond_to do |format|\n\t\t\tif @admin_shop.save\n\t\t\t\tformat.html { redirect_to @admin_shop, notice: 'Shop was successfully created.' }\n\t\t\t\tformat.json { render json: @admin_shop, status: :created, location: @admin_shop }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @admin_shop.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def postSales_logSyndication( action_type, syndication_type, publisher_id, expiry_date, entity_id, group_id, seed_masheryid, supplier_masheryid, country, reseller_masheryid)\n params = Hash.new\n params['action_type'] = action_type\n params['syndication_type'] = syndication_type\n params['publisher_id'] = publisher_id\n params['expiry_date'] = expiry_date\n params['entity_id'] = entity_id\n params['group_id'] = group_id\n params['seed_masheryid'] = seed_masheryid\n params['supplier_masheryid'] = supplier_masheryid\n params['country'] = country\n params['reseller_masheryid'] = reseller_masheryid\n return doCurl(\"post\",\"/sales_log/syndication\",params)\n end",
"def create\n @shop_ose = ShopOse.new(params[:shop_ose])\n\n respond_to do |format|\n if @shop_ose.save\n format.html { redirect_to @shop_ose, notice: 'Shop ose was successfully created.' }\n format.json { render json: @shop_ose, status: :created, location: @shop_ose }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shop_ose.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(name=\"Default name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Post.new(@url)\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n response.body\n end",
"def create\n @shop = Shop.new(shop_params)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: 'Shop was successfully created.' }\n format.json { render action: 'show', status: :created, location: @shop }\n else\n format.html { render action: 'new' }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shop = Shop.new(shop_params)\n\n if @shop.save\n render :show, status: :created, location: @shop\n else\n render json: @shop.errors, status: :unprocessable_entity\n end\n end",
"def create\n @home_categories_products_indices_shop = Home::Categories::Products::Indices::Shop.new(params[:home_categories_products_indices_shop])\n\n respond_to do |format|\n if @home_categories_products_indices_shop.save\n format.html { redirect_to @home_categories_products_indices_shop, notice: 'Shop was successfully created.' }\n format.json { render json: @home_categories_products_indices_shop, status: :created, location: @home_categories_products_indices_shop }\n else\n format.html { render action: \"new\" }\n format.json { render json: @home_categories_products_indices_shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def shops\n @shops ||= (@doc/\"SpcShop\").collect { |it| Element.new(it) }\n end",
"def create\n @shops_favorite = ShopsFavorite.new(params[:shops_favorite])\n\n respond_to do |format|\n if @shops_favorite.save\n format.html { redirect_to(@shops_favorite, :notice => 'Shops favorite was successfully created.') }\n format.xml { render :xml => @shops_favorite, :status => :created, :location => @shops_favorite }\n format.json { render :json => @shops_favorite, :status => :created, :location => @shops_favorite }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @shops_favorite.errors, :status => :unprocessable_entity }\n format.json { render :json => @shops_favorite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def create\n @shopping = Shopping.new(params[:shopping])\n\n respond_to do |format|\n if @shopping.save\n format.html { redirect_to(@shopping, :notice => 'Shopping was successfully created.') }\n format.xml { render :xml => @shopping, :status => :created, :location => @shopping }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @shopping.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @shop_item = @flat.shop_items.build(params[:shop_item])\n @shop_item.send_out(current_user)\n\n respond_to do |format|\n if @shop_item.save\n format.html { redirect_to [@flat, @shop_item], notice: 'Shop item was successfully created.' }\n format.json { render json: @shop_item, status: :created, location: [@flat, @shop_item] }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shop_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shop = Shop.new(shop_params)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, shop: @shop }\n else\n format.html { render :new }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #returning connection.post(collection_path, to_xml, self.class.headers) do |response|\n returning connection.post(collection_path, to_ssj, self.class.headers) do |response|\n self.id = id_from_response(response)\n load_attributes_from_response(response)\n end\n end",
"def post(resource, params)\n case resource\n when \"pedidos\", \"place_order\", \"new_order\" then url = \"/pedidos\"\n when \"envios\", \"shipping\" then url = \"/envios\"\n else url = \"/#{resource}\"\n end\n\n post_request(url, params)\n end",
"def create\n @shop = Shop.new(shop_params)\n @shopkeeper = current_user.shopkeeper\n @shop.shopkeeper_id = @shopkeeper.id\n\n if @shop.save\n render json: @shop, status: :created, location: @shop\n else\n render json: @shop.errors, status: :unprocessable_entity\n end\n end",
"def create\n @sale = Sale.new(params[:sale])\n\n respond_to do |format|\n if @sale.save\n flash[:notice] = 'Sale was successfully created.'\n format.html { redirect_to(sales_url) }\n format.xml { render :xml => @sale, :status => :created, :location => @sale }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sale.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sprint = Sprint.new(params[:sprint])\n\n respond_to do |format|\n if @sprint.save\n flash[:notice] = 'Sprint was successfully created.'\n format.html { redirect_to product_sprint_path(@product, @sprint) }\n format.xml { render :xml => @sprint, :status => :created, :location => @sprint }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sprint.errors, :status => :unprocessable_entity }\n end\n end\n\n end",
"def create\n @shopdetail = Shopdetail.new(shopdetail_params)\n\n respond_to do |format|\n if @shopdetail.save\n format.html { redirect_to @shopdetail, notice: 'Shopdetail was successfully created.' }\n format.json { render :show, status: :created, location: @shopdetail }\n else\n format.html { render :new }\n format.json { render json: @shopdetail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @scoop = Scoop.new(scoop_params)\n @scoop.kid = current_kid\n respond_to do |format|\n if @scoop.save\n format.html { redirect_to scoops_path, notice: 'Scoop was successfully created!' }\n format.json { render :show, status: :created, location: @scoop }\n else\n format.html { render :new }\n format.json { render json: @scoop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sprint = Sprint.new(params[:sprint])\n\n respond_to do |format|\n if @sprint.save\n flash[:notice] = 'Sprint was successfully created.'\n format.html { redirect_to(@sprint) }\n format.xml { render :xml => @sprint, :status => :created, :location => @sprint }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sprint.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @scrape_order = ScrapeOrder.new(params[:scrape_order])\n\n respond_to do |format|\n if @scrape_order.save\n format.html { redirect_to(scrape_orders_path, :notice => 'Scrape order was successfully created.') }\n format.xml { render :xml => @scrape_order, :status => :created, :location => @scrape_order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @scrape_order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sprint.save\n\n respond_with(@sprint)\n end",
"def create\n authorize! :create, @shop\n @shop = Shop.new(shop_params)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: 'Shop was successfully created.' }\n format.json { render :show, status: :created, location: @shop }\n else\n format.html { render :new }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shop_tag = ShopTag.new(shop_tag_params)\n\n respond_to do |format|\n if @shop_tag.save\n format.html { redirect_to @shop_tag, notice: 'Shop tag was successfully created.' }\n format.json { render :show, status: :created, location: @shop_tag }\n else\n format.html { render :new }\n format.json { render json: @shop_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_call(action, xml_data)\n require 'net/http'\n require 'uri'\n current_url = URL;\n if action != 'get-queue'\n get_server(@@_target_type_options[@@_target_type]);\n end\n uri = URI.parse(current_url+\"/\"+action)\n http = Net::HTTP.new(uri.host,uri.port)\n request=Net::HTTP::Post.new(uri.request_uri);\n request.set_form_data({ \"queue\"=> array_to_xml(xml_data,\"\")})\n return http.request(request).body\n end",
"def create\n @staff_shift = StaffShift.new(params[:staff_shift])\n\n respond_to do |format|\n if @staff_shift.save\n format.html { redirect_to(staff_shifts_url, :notice => t('staffshift.title2')+\" \"+t('created')) }\n format.xml { render :xml => @staff_shift, :status => :created, :location => @staff_shift }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @staff_shift.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def send_post(data_xml,url)\r\n result = @client.post(self.target_uri(url), :body => data_xml , :head => {'Content-Type' => 'application/xml'} ) \r\n raise \"Invalid status #{result.http_status} from server #{@host}:#{@port}\" if(result.http_status != '200') \r\n #reply = Reply.from_xml(result.http_body)\r\n if block_given?\r\n yield(result.http_body)\r\n else\r\n result.http_body\r\n end\r\n end",
"def post_config(url_prefix, xml)\n url_prefix = URI.escape(\"#{@jenkins_path}#{url_prefix}\")\n http = Net::HTTP.start(@server_ip, @server_port)\n request = Net::HTTP::Post.new(\"#{url_prefix}\")\n puts \"[INFO] PUT #{url_prefix}\" if @debug\n request.basic_auth @username, @password\n request.body = xml\n request.content_type = 'application/xml'\n response = http.request(request)\n response.code\n end",
"def create\n # Shopify passes the shop domain (aka uid) as an environment variable,\n # not as part of the request body.\n shop_uid = request.env['HTTP_X_SHOPIFY_SHOP_DOMAIN']\n\n Rails.logger.info(\"Shopify webook received for shop '#{shop_uid}'\")\n\n shop = Shop.find_by(shopify_uid: shop_uid)\n\n if shop\n SynchronizeTeamJob.new.async.perform(shop.team.id)\n else\n Rails.logger.info(\"Shop not found '#{shop_uid}'\")\n end\n\n rescue StandardError => e\n # Rescue any error so that we always respond with 200, otherwise Shopify will disable the webhook.\n # Still log and report an error to newrelic, though, so that we know about it.\n ReportError.call(\"Error processing shopify webhook: #{e.message}\")\n ensure\n head :ok\n end",
"def create\n @spit = Spit.new(params[:spit])\n\n respond_to do |format|\n if @spit.save\n format.html { redirect_to(@spit, :notice => 'Spit was successfully created.') }\n format.xml { render :xml => @spit, :status => :created, :location => @spit }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @spit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @shop_admin = ShopAdmin.new(shop_admin_params)\n\n respond_to do |format|\n if @shop_admin.save\n format.html { redirect_to @shop_admin, notice: 'Shop admin was successfully created.' }\n format.json { render :show, status: :created, location: @shop_admin }\n else\n format.html { render :new }\n format.json { render json: @shop_admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end",
"def post_query( xml )\n url = URI.parse( self.url )\n response = self.http.post_form( url, { \"query\" => xml } )\n return response.body\n end",
"def create\n @shopping = Shopping.new(params[:shopping])\n\n respond_to do |format|\n if @shopping.save\n format.html { redirect_to admins_shoppings_url, :notice => 'O Shopping foi criado com sucesso.' }\n format.json { render :json => @shopping, :status => :created, :location => @shopping }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @shopping.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_config(url_prefix, xml)\n post_data(url_prefix, xml, 'application/xml;charset=UTF-8')\n end",
"def new\n @hops_addition = HopsAddition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hops_addition }\n end\n end",
"def post operation, data={}\n body = case data\n when String\n body = data\n else\n Yajl::Encoder.encode(data)\n end\n\n request = new_request operation, body\n request.sign sts\n hydra.queue request\n hydra.run\n response = request.response\n puts response.inspect if @debug\n\n if response.code == 200\n Yajl::Parser.parse response.body\n else\n raise_error response\n end\n end",
"def create\n @shopcode = Shopcode.new(shopcode_params)\n\n respond_to do |format|\n if @shopcode.save\n format.html { redirect_to @shopcode, notice: 'Shopcode was successfully created.' }\n format.json { render :show, status: :created, location: @shopcode }\n else\n format.html { render :new }\n format.json { render json: @shopcode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @men_shop_collection = MenShopCollection.new(men_shop_collection_params)\n\n respond_to do |format|\n if @men_shop_collection.save\n format.html { redirect_to @men_shop_collection, notice: 'Men shop collection was successfully created.' }\n format.json { render :show, status: :created, location: @men_shop_collection }\n else\n format.html { render :new }\n format.json { render json: @men_shop_collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @shops = @shops.all\n end",
"def create\n params[:shop][:starts_at] = Chronic.parse params[:shop][:starts_at]\n params[:shop][:ends_at] = Chronic.parse params[:shop][:ends_at]\n\n @shop = Shop.new(params[:shop])\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: 'Shop was successfully created.' }\n format.json { render json: @shop, status: :created, location: @shop }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_post(action, data)\n api_request(action, data, 'POST')\n end",
"def create\n @shop = Shop.new(shop_params)\n @shop.enable_new_version = false\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to backend_shop_shop_steps_path(@shop) + \"/sms_message\" }\n format.json { render action: 'show', status: :created, location: @shop }\n else\n format.html { render action: 'new' }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @service = Service.new(service_params)\r\n respond_to do |format|\r\n if @service.save #/enter/companies/:company_id/services/:id/add_stack\r\n format.html { redirect_to \"/enter/companies/#{@service.company_id}/services/#{@service.id}/add_stack\", notice: 'Service was successfully created.' }\r\n format.json { render :add_stack, status: :created, location: @service }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @service.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @task = Task.new(params[:task])\n @sprint = Sprint.find(@task.sprint_id)\n\n respond_to do |format|\n if @task.save\n flash[:notice] = 'Task was successfully created.'\n format.html { redirect_to(@task) }\n format.xml { render :xml => @task, :status => :created, :location => @task }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @shop = Barbershop.new(shop_params)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to '/', notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @shop }\n else\n format.html { render :new }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nossos_servico = NossosServico.new(params[:nossos_servico])\n\n respond_to do |format|\n if @nossos_servico.save\n format.html { redirect_to(@nossos_servico, :notice => 'Nossos servico was successfully created.') }\n format.xml { render :xml => @nossos_servico, :status => :created, :location => @nossos_servico }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @nossos_servico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/investmentaccount/v1\")\n end",
"def create\n @training_workshop = TrainingWorkshop.new(training_workshop_params)\n\n respond_to do |format|\n if @training_workshop.save\n format.html { redirect_to @training_workshop, notice: 'Training workshop was successfully created.' }\n format.json { render :show, status: :created, location: @training_workshop }\n else\n format.html { render :new }\n format.json { render json: @training_workshop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shop = Shop.new(shop_params)\n @shop.user_id = current_user.id\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: '美食餐廳已新增。' }\n format.json { render :show, status: :created, location: @shop }\n else\n format.html { render :new }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shoe = Shoe.new(params[:shoe])\n\n respond_to do |format|\n if @shoe.save\n format.html { redirect_to @shoe, notice: 'Shoe was successfully created.' }\n format.json { render json: @shoe, status: :created, location: @shoe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shoe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_create_link_via_API_XML\r\n get \"/logout\"\r\n post \"/links.xml\", :api_key=>'testapikey',\r\n :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response :created\r\n end",
"def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end",
"def create\n @operation = Operation.new(params[:operation])\n\n respond_to do |format|\n if @operation.save\n flash[:notice] = 'Operation was successfully created.'\n format.html { redirect_to(@operation) }\n format.xml { render :xml => @operation, :status => :created, :location => @operation }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @operation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/loan/v1\")\n end",
"def reply(shops)\n generic_elements = shops.map do |shop|\n\n # First, we want the generate the URL that leads to the webview displaying the shop data\n url = shop_url(id: shop.dig('id'))\n\n # Then we generate we web url button object\n button = Templates::WebUrlButton.new(\n url: url,\n title: 'Show'\n )\n\n # We build a Generic Element by passing all the data, including the button from above as an array\n Templates::GenericTemplateElement.new(\n title: shop.dig('name'),\n image_url: shop.dig('logo_url', 'url'),\n subtitle: shop.dig('discount_en'),\n buttons: [button]\n )\n end\n\n # We putting the generic elements from above inside a generic template\n payload = Templates::GenericTemplate.new(elements: generic_elements)\n\n # The generic template needs to be put inside an attachment of type template\n attachment = Templates::Attachment.new(type: 'template', payload: payload)\n\n # Using our Facebook Messages API Wrapper, we send the message including the attachment to the set psid\n Apis::Facebook::Messages.send(psid, message: {attachment: attachment})\n end",
"def create\n @shout = Shout.new(params[:shout])\n\n sendPush (@shout.name + ' just shouted ' + @shout.shout_message)\n \n respond_to do |format|\n if @shout.save\n format.html { redirect_to(@shout, :notice => 'Shout was successfully created.') }\n format.xml { render :xml => @shout, :status => :created, :location => @shout }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @shout.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post\n resource.post(request, response)\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def create\n @sitio = Sitio.new(params[:sitio])\n\n respond_to do |format|\n if @sitio.save\n format.html { redirect_to(@sitio, :notice => 'Sitio was successfully created.') }\n format.xml { render :xml => @sitio, :status => :created, :location => @sitio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sitio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_report dep_name, user, vars, log\n require 'net/http'\n require 'uri'\n\n returning(Net::HTTP.post_form(\n URI.parse('http://gist.github.com/api/v1/xml/new'),\n {\n \"files[from]\" => user,\n \"files[vars.yml]\" => vars,\n \"files[#{dep_name}.log]\" => log.decolorize\n }\n )) do |response|\n report_report_result dep_name, response\n end.is_a? Net::HTTPSuccess\n end",
"def create\n @sorder = Sorder.new(params[:sorder])\n\n respond_to do |format|\n if @sorder.save\n format.html { redirect_to sites_path, notice: '您的预约申请已提交,请耐心等待回复!' }\n format.json { render json: @sorder, status: :created, location: @sorder }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sorder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = request_post(\"/api/order\", data)\n\tputs response.body\nend",
"def submit_order(printer_order)\n return_data = {}\n printer = printer_order.printer\n order = printer_order.order_line_items[0].order\n login_data = login(printer)\n session_id = login_data[:session_id]\n\n Rails.logger.debug \"---------- *session id for login to spreadshirt* -----------\"\n Rails.logger.debug \"value: #{session_id}\"\n Rails.logger.debug \"---------- ***** -----------\"\n\n #formatted_no_decl = Nokogiri::XML::Node::SaveOptions::FORMAT + Nokogiri::XML::Node::SaveOptions::NO_DECLARATION\n\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.order(:\"xmlns:xlink\" => \"http://www.w3.org/1999/xlink\", :xmlns => \"http://api.spreadshirt.com\") {\n xml.shop(:id => printer.external_shop_id)\n xml.orderItems {\n\n # loop through each of our line items\n printer_order.order_line_items.each do |order_line_item|\n product_attachment_name = \"reference-product-#{order_line_item.id}\"\n image_attachment_name = \"reference-image-#{order_line_item.id}\"\n product = order_line_item.listing.product\n xml.orderItem {\n xml.quantity order_line_item.quantity\n xml.element(:type => \"sprd:product\", :\"xlink:href\" => \"http://api.spreadshirt.com/api/v1/shops/#{printer.external_shop_id}/products/#{product_attachment_name}\") {\n xml.properties{\n xml.property(order_line_item.master_product_color.external_id, :key => \"appearance\")\n xml.property(order_line_item.master_product_size.external_id, :key => \"size\") # size now comes from shopify\n }\n }\n xml.correlation {\n xml.partner {\n xml.orderItemId order_line_item.id\n }\n }\n xml.attachments {\n xml.attachment(:type => \"sprd:product\", :id => product_attachment_name) {\n xml.product(:\"xmlns:xlink\" => \"http://www.w3.org/1999/xlink\", :xmlns => \"http://api.spreadshirt.com\") {\n xml.productType(:id => product.master_product.external_id)\n xml.appearance(:id => order_line_item.master_product_color.external_id)\n xml.restrictions {\n xml.freeColorSelection false\n xml.example false\n }\n xml.configurations {\n xml.configuration(:type => \"design\") {\n xml.printArea(:id => product.master_product_print_area.external_id)\n xml.printType(:id => \"17\")\n xml.offset(:unit => \"mm\") {\n xml.x product.print_image_x_offset\n xml.y product.print_image_y_offset\n }\n ##========== *calculating DPI* ===========##\n # DPI = Pixel x 25.4 / X(mm)\n # \n order_dpi = (4000 * 25.4 / product.master_product_print_area.view_size_width).round(0)\n\n ##========== ***** ==========##\n \n xml.content(:dpi => order_dpi, :unit => \"mm\") {\n xml.svg {\n xml.image(:width => (product.master_product_print_area.print_area_width/10).floor * 10, :height => (product.master_product_print_area.print_area_height/10).floor * 10,\n :designId => image_attachment_name, :printColorIds => \"\")\n }\n }\n xml.restrictions {\n xml.changeable false\n }\n }\n }\n }\n }\n xml.attachment(:type => \"sprd:design\", :id => image_attachment_name) {\n xml.reference(:\"xlink:href\" => product.print_image.url)\n }\n }\n }\n end\n }\n\n xml.correlation {\n xml.partner {\n xml.id printer.account\n xml.orderId printer_order.id\n }\n }\n\n xml.payment {\n xml.type \"EXTERNAL_FULFILLMENT\"\n }\n\n xml.shipping {\n xml.shippingType(:id => \"14\")\n xml.address {\n xml.person {\n xml.salutation(:id => \"99\")\n xml.firstName \"-\"\n xml.lastName order.shipping_name\n }\n xml.street order.shipping_address\n xml.streetAnnex order.shipping_address2\n xml.city order.shipping_city\n # xml.state(order_line_item.order.shipping_state, :code => order_line_item.order.shipping_state)\n # xml.country(order_line_item.order.shipping_country, :code => order_line_item.order.shipping_country)\n xml.state(order.shipping_state, :code => order.shipping_state_code)\n xml.country(order.shipping_country, :code => order.shipping_country_code)\n xml.zipCode order.shipping_postal_code\n xml.email \"test@example.net\"\n }\n }\n\n xml.billing {}\n }\n end\n # data = builder.to_xml( save_with:formatted_no_decl )\n data = builder.to_xml\n\n Rails.logger.debug \"---------- *request body for submitting order to spreadshirt* -----------\"\n Rails.logger.debug \"value: #{data}\"\n Rails.logger.debug \"---------- ***** -----------\"\n\n begin\n response = SpreadshirtClient.post \"/orders\", data, authorization: true, session: session_id\n rescue Exception => e\n\n Rails.logger.debug \"---------- *exception when submiting order to spreadshirt * -----------\"\n Rails.logger.debug \"value: #{e.message}\"\n Rails.logger.debug \"---------- ***** -----------\"\n\n end\n Rails.logger.debug \"---------- *response data when is submitted some orders to spreadshirt* -----------\"\n Rails.logger.debug \"value: #{response}\"\n Rails.logger.debug \"---------- ***** -----------\"\n\n doc = Nokogiri::XML(response)\n order_id = doc.children.first[:id]\n return_data[:status] = \"Submitted\"\n return_data[:external_id] = order_id\n\n return return_data\n end",
"def create\n @shopping_list = ShoppingList.new(params[:shopping_list])\n\n respond_to do |format|\n if @shopping_list.save\n format.html { redirect_to(@shopping_list, :notice => 'Shopping list was successfully created.') }\n format.xml { render :xml => @shopping_list, :status => :created, :location => @shopping_list }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @shopping_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sprint = Sprint.new(params[:sprint])\n\n respond_to do |format|\n if @sprint.save\n format.html { redirect_to [:admin, @sprint], notice: 'Sprint was successfully created.' }\n format.json { render json: @sprint, status: :created, location: @sprint }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sprint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def POST; end",
"def create\n @shop = Shop.new(params[:shop])\n #return render :text => \"The Create action... is #{@shop.isActive}\"\n respond_to do |format|\n if @shop.save\n format.html { redirect_to(@shop, :notice => 'Shop was successfully created.') }\n format.xml { render :xml => @shop, :status => :created, :location => @shop }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @shop.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n seth_server_rest.post_rest(\"data\", self)\n self\n end",
"def create\n @sales_type = SalesType.new(params[:sales_type])\n\n respond_to do |format|\n if @sales_type.save\n format.html { redirect_to(sales_types_path, :notice => 'Sales type was successfully created.') }\n format.xml { render :xml => @sales_type, :status => :created, :location => @sales_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sales_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @swot = Swot.new(swot_params)\n\n respond_to do |format|\n if @swot.save\n format.html { redirect_to @swot, notice: 'Swot was successfully created.' }\n format.json { render :show, status: :created, location: @swot }\n else\n format.html { render :new }\n format.json { render json: @swot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookshop = Bookshop.new(bookshop_params)\n\n respond_to do |format|\n if @bookshop.save\n format.html { redirect_to @bookshop, notice: \"Bookshop was successfully created.\" }\n format.json { render :show, status: :created, location: @bookshop }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bookshop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post\n Rentlinx.client.post(self)\n end",
"def insert_into_shop(name, id) # need to insert the actual stores and ids now into the shop\n shop = \"INSERT INTO shops (name, id) VALUES ($1, $2)\"\n\n result = shop.exec_params(shop, [name, id])\n result.entries\nend",
"def create\n @shelf = Shelf.new(:shop_id => @shop.id)\n\n if @shelf.save\n flash[:message] = \"New shelf created!\"\n redirect_to(shop_path(:id => @shop.id))\n else\n # Flash hash with message: \"Save failed\" or whatever\n redirect_to(shop_path(:id => @shop.id))\n end\n end",
"def create \n @shift = @user.shifts.build(params[:shift])\n \n respond_to do |format|\n if @shift.save\n flash[:notice] = t('shift.created')\n format.html { redirect_to(user_shift_path(@user, @shift)) }\n format.xml { render :xml => @shift, :status => :created, :location => @shift }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @shift.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @suite = Suite.new(params[:suite])\n @resorts = Resort.all\n\n respond_to do |format|\n if @suite.save\n flash[:notice] = 'Suite was successfully created.'\n format.html { redirect_to(@suite) }\n format.xml { render :xml => @suite, :status => :created, :location => @suite }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @suite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @bookshop = Bookshop.new(bookshop_params)\n\n respond_to do |format|\n if @bookshop.save\n format.html { redirect_to @bookshop, notice: 'Bookshop was successfully created.' }\n format.json { render :show, status: :created, location: @bookshop }\n else\n format.html { render :new }\n format.json { render json: @bookshop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @workshops_course = WorkshopsCourse.new(params[:workshops_course])\n\n respond_to do |format|\n if @workshops_course.save\n format.html { redirect_to(@workshops_course, :notice => 'WorkshopsCourse was successfully created.') }\n format.xml { render :xml => @workshops_course, :status => :created, :location => @workshops_course }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @workshops_course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @promos = Promos.new(params[:promos])\n\n respond_to do |format|\n if @promos.save\n flash[:notice] = 'Promos was successfully created.'\n format.html { redirect_to(@promos) }\n format.xml { render :xml => @promos, :status => :created, :location => @promos }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @promos.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n @pet_shop = current_user.pet_shops.build(pet_shop_params)\n\n respond_to do |format|\n if @pet_shop.save\n format.html { redirect_to @pet_shop, notice: I18n.t('.shop-created') || 'Pet shop was successfully created.' }\n format.json { render :show, status: :created, location: @pet_shop }\n else\n format.html { render :new }\n format.json { render json: @pet_shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sales_item = SalesItem.new(sales_item_params)\n\n respond_to do |format|\n if @sales_item.save\n format.html { redirect_to @sales_item, notice: 'Sales item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sales_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @sales_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_jenkins_job(name, xml_file)\n create_url = \"http://#{Pkg::Config.jenkins_build_host}/createItem?name=#{name}\"\n form_args = [\"-H\", '\"Content-Type: application/xml\"', \"--data-binary\", \"@#{xml_file}\"]\n curl_form_data(create_url, form_args)\n \"http://#{Pkg::Config.jenkins_build_host}/job/#{name}\"\nend",
"def create\n @coffee_shop = CoffeeShop.new(coffee_shop_params)\n\n respond_to do |format|\n if @coffee_shop.save\n format.html { redirect_to @coffee_shop, notice: 'Coffee shop was successfully created.' }\n format.json { render :show, status: :created, location: @coffee_shop }\n else\n format.html { render :new }\n format.json { render json: @coffee_shop.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6073832",
"0.57361233",
"0.5615422",
"0.5612782",
"0.5589205",
"0.5582772",
"0.5566365",
"0.55600804",
"0.55398667",
"0.5537808",
"0.55039555",
"0.5498018",
"0.5498018",
"0.54216623",
"0.54216623",
"0.5421615",
"0.5402898",
"0.53979045",
"0.5373297",
"0.5363733",
"0.53515804",
"0.5323983",
"0.53137594",
"0.5283416",
"0.52810115",
"0.5272408",
"0.52452713",
"0.5238911",
"0.52378964",
"0.52191186",
"0.5189731",
"0.5172202",
"0.5130591",
"0.5130461",
"0.51102",
"0.5095271",
"0.50766796",
"0.5076021",
"0.50672317",
"0.50540674",
"0.5053176",
"0.5047409",
"0.50391346",
"0.5037524",
"0.50361556",
"0.50325906",
"0.50218683",
"0.5001269",
"0.50001687",
"0.49993575",
"0.4997174",
"0.499582",
"0.4990861",
"0.4986475",
"0.4980228",
"0.4974951",
"0.49688032",
"0.4965419",
"0.4961742",
"0.49592403",
"0.4952183",
"0.49458912",
"0.4940825",
"0.4940825",
"0.4938844",
"0.4933743",
"0.49311256",
"0.49286145",
"0.49201864",
"0.4917796",
"0.4916226",
"0.49094525",
"0.49012566",
"0.49004325",
"0.48973876",
"0.4896831",
"0.4892669",
"0.48915583",
"0.48877552",
"0.48825136",
"0.4870661",
"0.4864254",
"0.4860525",
"0.4859549",
"0.48560837",
"0.4846346",
"0.48419166",
"0.48398137",
"0.48359233",
"0.4833056",
"0.483275",
"0.48287535",
"0.48247594",
"0.48224092",
"0.4821517",
"0.48210472",
"0.48200965",
"0.48174423",
"0.48170626",
"0.4816339",
"0.48155883"
] | 0.0 | -1 |
PUT /shops/1 PUT /shops/1.xml | def update
@shop = Shop.find(params[:id])
@user = @shop.user
respond_to do |format|
if @shop.update_attributes(params[:shop])
flash[:notice] = 'Shop was successfully updated.'
format.html { redirect_to userhome_path(:user_id => @user) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @shop.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def update\n @shop = Shop.find(params[:id])\n\n respond_to do |format|\n if @shop.update_attributes(params[:shop])\n format.html { redirect_to(@shop, :notice => 'Shop was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shop.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end",
"def update\n @shop = Shop.find(params[:id])\n\n if @shop.update(shop_params)\n head :no_content\n else\n render json: @shop.errors, status: :unprocessable_entity\n end\n end",
"def put(path, doc = nil, options = {})\n execute('PUT', path, options, doc)\n end",
"def put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \n end",
"def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def put(*args)\n request(:put, *args)\n end",
"def put!\n request! :put\n end",
"def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"def update\n @shop_ose = ShopOse.find(params[:id])\n\n respond_to do |format|\n if @shop_ose.update_attributes(params[:shop_ose])\n format.html { redirect_to @shop_ose, notice: 'Shop ose was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shop_ose.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @shop = Shop.find(params[:id])\n\n respond_to do |format|\n if @shop.update_attributes(params[:shop])\n format.html { redirect_to @shop, notice: 'Shop was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @scoop.update(scoop_params)\n format.html { redirect_to scoops_path, notice: 'Scoop was successfully updated!' }\n format.json { render :show, status: :ok, location: @scoop }\n else\n format.html { render :edit }\n format.json { render json: @scoop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_update_project_via_API_XML\r\n get \"/logout\"\r\n put \"/projects/1.xml\", :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response 401\r\n end",
"def update\n @shops_favorite = ShopsFavorite.find(params[:id])\n\n respond_to do |format|\n if @shops_favorite.update_attributes(params[:shops_favorite])\n format.html { redirect_to(@shops_favorite, :notice => 'Shops favorite was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shops_favorite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @sys_op = SysOp.find(params[:id])\n\n respond_to do |format|\n if @sys_op.update_attributes(params[:sys_op])\n format.html { redirect_to @sys_op, notice: 'Sys op was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sys_op.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @title = \"Update Operations\"\n @operation = Operation.find(params[:id])\n\n respond_to do |format|\n if @operation.update_attributes(params[:operation])\n flash[:notice] = 'Operation was successfully updated.'\n format.html { redirect_to(@operation) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @operation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @home_categories_products_indices_shop = Home::Categories::Products::Indices::Shop.find(params[:id])\n\n respond_to do |format|\n if @home_categories_products_indices_shop.update_attributes(params[:home_categories_products_indices_shop])\n format.html { redirect_to @home_categories_products_indices_shop, notice: 'Shop was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @home_categories_products_indices_shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n @shop_item = ShopItem.find(params[:id])\n\n respond_to do |format|\n if @shop_item.update_attributes(params[:shop_item])\n format.html { redirect_to(@shop_item, :notice => 'Shop item was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shop_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @shop = Shop.find(params[:id])\n\n respond_to do |format|\n if @shop.update_attributes(params[:shop])\n format.html { redirect_to @shop, notice: 'Shop was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @shop = Shop.find(params[:id])\n\n respond_to do |format|\n if @shop.update_attributes(params[:shop])\n format.html { redirect_to @shop, notice: 'Shop was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put( doc, opts = {} )\n response = http_action :put, doc, opts.merge( :doc => doc )\n doc['_id'], doc['_rev'] = response['id'], response['rev'] if doc.kind_of? Hash\n response\n end",
"def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end",
"def update\n @shelf = Shelf.find(params[:id])\n\n respond_to do |format|\n if @shelf.update_attributes(params[:shelf])\n flash[:notice] = 'Shelf was successfully updated.'\n format.html { redirect_to(@shelf) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shelf.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_eshop\n @eshop = Eshop.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @shop.update(shop_params)\n format.html { redirect_to shops_url, notice: 'Shop #{@shop.name} was successfully updated.' }\n format.json { render :show, status: :ok, location: shops_url }\n else\n format.html { render :edit }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, options={})\n request :put, path, options\n end",
"def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end",
"def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end",
"def update\n @hops_addition = HopsAddition.find(params[:id])\n\n respond_to do |format|\n if @hops_addition.update_attributes(params[:hops_addition])\n flash[:notice] = 'HopsAddition was successfully updated.'\n format.html { redirect_to(@hops_addition) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @hops_addition.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @shop.update(shop_params)\n render :show, status: :ok, location: @shop\n else\n render json: @shop.errors, status: :unprocessable_entity\n end\n end",
"def update\n # returning connection.put(element_path(prefix_options), to_xml, self.class.headers) do |response|\n returning connection.put(element_path(prefix_options), to_ssj, self.class.headers) do |response|\n load_attributes_from_response(response)\n end\n end",
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def put(path, opts = {})\n request(:put, path, opts).body\n end",
"def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end",
"def update\n respond_to do |format|\n if @shop.update_attributes(shop_params)\n format.html { redirect_to @shop, notice: 'Shop was successfully updated.' }\n format.json { render :show, status: :ok, location: @shop }\n else\n format.html { render :edit }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @spouse = Spouse.find(params[:id])\n\n respond_to do |format|\n if @spouse.update_attributes(params[:spouse])\n flash[:notice] = 'Spouse was successfully updated.'\n format.html { redirect_to(@spouse) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @spouse.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, data=nil)\n request(:put, path, data)\n end",
"def update\n @shop_item = @flat.shop_items.find(params[:id])\n\n respond_to do |format|\n if @shop_item.update_attributes(params[:shop_item])\n format.html { redirect_to [@flat, @shop_item], notice: 'Shop item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shop_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end",
"def update\n respond_to do |format|\n if @shop.update(shop_params)\n format.html { redirect_to shops_path, success: 'Shop was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path = '/files/', params = {})\n request :put, path, params\n end",
"def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(request)\n error = validate(request)\n return error if error\n\n code =\n if data_store.exists?(request.rest_path)\n set_data(request, request.rest_path, request.body, :data_store_exceptions)\n 200\n else\n name = request.rest_path[4]\n data_store.create(request.rest_path[0..3], name, request.body, :create_dir)\n 201\n end\n already_json_response(code, request.body)\n end",
"def put(id:, url_variables:, body:)\n ensure_service_document\n end",
"def put(path, payload)\n req = Net::HTTP::Put.new(path)\n action(req, payload)\n end",
"def put(path, data={})\n request(:put, path, data)\n end",
"def put url, object = nil\n request url, HTTP::Put, object\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def set_workshop\n @workshop = Workshop.find(params[:id])\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(path, options={})\n send_request 'put', path, options\n end",
"def update\n respond_to do |format|\n if @shop.update(shop_params)\n format.html { redirect_to @shop, notice: 'Shop was successfully updated.' }\n format.json { render :show, status: :ok, location: @shop }\n else\n format.html { render :edit }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @shop.update(shop_params)\n format.html { redirect_to @shop, notice: 'Shop was successfully updated.' }\n format.json { render :show, status: :ok, location: @shop }\n else\n format.html { render :edit }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_shelf(shelf_id, shelf_name, exclusive_flag = \"false\", sortable_flag = \"false\", featured = \"false\")\n\t\toptions = {\"user_shelf[name]\" => shelf_name, \"user_shelf[exclusive_flag]\" => exclusive_flag, \"user_shelf[sortable_flag]\" => sortable_flag, \"user_shelf[featured]\" => featured}\n\t\tdata = oauth_request(\"/user_shelves/#{shelf_id}.xml\", options, \"put\")\n\tend",
"def update\n @shop = Shop.find(params[:id])\n\n respond_to do |format|\n if @shop.update_attributes(params[:shop])\n format.html { redirect_to edit_shop_path(@shop), notice: 'Preferences have been updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, params={})\n RestClient.put request_base+path, params\n end",
"def update\n respond_to do |format|\n if @shop.update(shop_params)\n format.html { redirect_to @shop, notice: \"Shop was successfully updated.\" }\n format.json { render :show, status: :ok, location: @shop }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sitio = Sitio.find(params[:id])\n\n respond_to do |format|\n if @sitio.update_attributes(params[:sitio])\n format.html { redirect_to(@sitio, :notice => 'Sitio was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sitio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put endpoint, data\n do_request :put, endpoint, data\n end",
"def put(action, params={}, options={})\n request(:put, action, params, options)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end",
"def put(splat)\n bad_request if splat.empty?\n _put resolve_uri(splat[0]), request.body.read\n end",
"def put_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Put.new(uri)\n req.body = document.to_json\n run(uri, req)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def update\n @repairshop = Repairshop.find(params[:id])\n\n respond_to do |format|\n if @repairshop.update_attributes(params[:repairshop])\n format.html { redirect_to(@repairshop, :notice => 'Repairshop was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @repairshop.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_workshop\n @workshop = Workshop.find(params[:id])\n end",
"def set_workshop\n @workshop = Workshop.find(params[:id])\n end",
"def set_workshop\n @workshop = Workshop.find(params[:id])\n end",
"def set_workshop\n @workshop = Workshop.find(params[:id])\n end",
"def set_workshop\n @workshop = Workshop.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @shop.update(shop_params)\n format.html { redirect_to @shop, notice: 'Shop was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @shop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, params={}, options={})\n request(:put, api_path(path), params, options)\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def put\n if(resource.collection?)\n Forbidden\n elsif(!resource.parent_exists? || !resource.parent_collection?)\n Conflict\n else\n resource.lock_check if resource.supports_locking?\n status = resource.put(request, response)\n response['Location'] = \"#{scheme}://#{host}:#{port}#{url_format(resource)}\" if status == Created\n response.body = response['Location']\n status\n end\n end",
"def put(path, params)\n request(:put, path, params)\n end"
] | [
"0.6442686",
"0.6177593",
"0.57824564",
"0.5660673",
"0.56010354",
"0.5593099",
"0.5546171",
"0.5471413",
"0.545599",
"0.54085034",
"0.54083234",
"0.539672",
"0.53673124",
"0.535751",
"0.53493255",
"0.5347734",
"0.53435487",
"0.53432304",
"0.5343018",
"0.53414613",
"0.5339738",
"0.5328666",
"0.53270876",
"0.53219116",
"0.5320594",
"0.53202",
"0.53109205",
"0.53109205",
"0.5309725",
"0.5269358",
"0.5258825",
"0.5236009",
"0.52229965",
"0.52130026",
"0.5205579",
"0.5205201",
"0.5198959",
"0.51906496",
"0.51745725",
"0.5164469",
"0.51570857",
"0.51567703",
"0.51475585",
"0.51341563",
"0.5126276",
"0.51185715",
"0.5114234",
"0.5103759",
"0.50993645",
"0.50991917",
"0.5098541",
"0.50985044",
"0.50985044",
"0.50985044",
"0.50914204",
"0.5085131",
"0.50783235",
"0.5076728",
"0.50761205",
"0.5075083",
"0.5075083",
"0.5075083",
"0.5075083",
"0.5075083",
"0.5075083",
"0.5075083",
"0.5075083",
"0.5073287",
"0.5062843",
"0.5062843",
"0.50583285",
"0.5053508",
"0.5053508",
"0.505217",
"0.50492203",
"0.50363755",
"0.5034878",
"0.5034448",
"0.5033785",
"0.5028245",
"0.50263447",
"0.50263447",
"0.5025342",
"0.5021613",
"0.50199574",
"0.5019179",
"0.5014938",
"0.5014938",
"0.50146854",
"0.5004539",
"0.5001219",
"0.5001219",
"0.5001219",
"0.5001219",
"0.5001219",
"0.4998829",
"0.49946296",
"0.49943614",
"0.49868035",
"0.49836645"
] | 0.5278759 | 29 |
DELETE /shops/1 DELETE /shops/1.xml | def destroy
@shop = Shop.find(params[:id])
@shop.destroy
respond_to do |format|
format.html { redirect_to(admin_shops_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @repairshop = Repairshop.find(params[:id])\n @repairshop.destroy\n\n respond_to do |format|\n format.html { redirect_to(repairshops_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @hops_addition = HopsAddition.find(params[:id])\n @hops_addition.destroy\n\n respond_to do |format|\n format.html { redirect_to(hops_additions_url) }\n format.xml { head :ok }\n end\n end",
"def demolish\n @shop = Shop.find(params[:id])\n @shop.destroy\n\n respond_to do |format|\n format.html { redirect_to(shops_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @title = \"Destroy Operations\"\n @operation = Operation.find(params[:id])\n @operation.destroy\n\n respond_to do |format|\n format.html { redirect_to(operations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shelf = Shelf.find(params[:id])\n @shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to(shelves_url) }\n format.xml { head :ok }\n end\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def destroy\n @shops_favorite = ShopsFavorite.find(params[:id])\n @shops_favorite.destroy\n\n respond_to do |format|\n format.html { redirect_to(shops_favorites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shop.destroy\n\n head :no_content\n end",
"def destroy\n @shop = Shop.find(params[:id])\n @shop.destroy\n\n\n respond_to do |format|\n flash[:success] = \"Deleted successfully \"\n format.html { redirect_to shops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sys_op = SysOp.find(params[:id])\n @sys_op.destroy\n\n respond_to do |format|\n format.html { redirect_to sys_ops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop = Shop.find(params[:id])\n @shop.destroy\n\n respond_to do |format|\n format.html { redirect_to shops_url }\n format.json { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @shop = Shop.find(params[:id])\n @shop.destroy\n\n respond_to do |format|\n format.html { redirect_to shops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop = Shop.find(params[:id])\n @shop.destroy\n\n respond_to do |format|\n format.html { redirect_to shops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @store = Store.find(params[:id])\n @store.destroy\n\n respond_to do |format|\n format.html { redirect_to(stores_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @operation = Operation.find(params[:id])\n @operation.destroy\n\n respond_to do |format|\n format.html { redirect_to(operations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @store = Store.find(params[:id])\n @store.destroy\n\n respond_to do |format|\n format.html { redirect_to(stores_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shop.destroy\n respond_to do |format|\n format.html { redirect_to shops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop.destroy\n respond_to do |format|\n format.html { redirect_to shops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop.destroy\n respond_to do |format|\n format.html { redirect_to shops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop = Wmall::Shop.find(params[:id])\n @shop.destroy\n\n respond_to do |format|\n format.html { redirect_to pro_wmall_shops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop_item = @flat.shop_items.find(params[:id])\n @shop_item.destroy\n\n respond_to do |format|\n format.html { redirect_to shop_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @shop_for_item = @item.shop\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(@shop_for_item) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin_store = Store.find(params[:id])\n @admin_store.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_stores_url) }\n format.xml { head :ok }\n end\n end",
"def delete(connection)\n r = connection.execute(%(<SiteDeleteRequest session-id=\"#{connection.session_id}\" site-id=\"#{@id}\"/>))\n r.success\n end",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def destroy\n @home_categories_products_indices_shop = Home::Categories::Products::Indices::Shop.find(params[:id])\n @home_categories_products_indices_shop.destroy\n\n respond_to do |format|\n format.html { redirect_to home_categories_products_indices_shops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apply_shop.destroy\n respond_to do |format|\n format.html { redirect_to apply_shops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @snap = Snap.find(params[:id])\n @snap.destroy\n\n respond_to do |format|\n format.html { redirect_to(snaps_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shop.destroy\n end",
"def delete(splat)\n bad_request if splat.empty?\n _delete resolve_uri(splat[0])\n end",
"def destroy\n\t\t@admin_shop = Admin::Shop.find(params[:id])\n\t\t@admin_shop.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to admin_shops_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def deleteSite _args\n \"deleteSite _args;\" \n end",
"def destroy\n @recycling_site = RecyclingSite.find(params[:id])\n @recycling_site.destroy\n\n respond_to do |format|\n format.html { redirect_to(recycling_sites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @service = Service.find(params[:id])\n @service.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_services_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @service_check_detail = ServiceCheckDetail.find(params[:id])\n @service_check_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to(service_check_details_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shopping = Shopping.find(params[:id])\n @shopping.destroy\n\n respond_to do |format|\n format.html { redirect_to(shoppings_url) }\n format.xml { head :ok }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @shop_ose = ShopOse.find(params[:id])\n @shop_ose.destroy\n\n respond_to do |format|\n format.html { redirect_to shop_oses_url }\n format.json { head :ok }\n end\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def destroy\n @cso = Cso.find(params[:id])\n @cso.destroy\n\n respond_to do |format|\n format.html { redirect_to(csos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @colonoscopytest = Colonoscopytest.find(params[:id])\n @colonoscopytest.destroy\n\n respond_to do |format|\n format.html { redirect_to(colonoscopytests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sitemenu.destroy\n respond_to do |format|\n format.html { redirect_to sitemenus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop.destroy\n respond_to do |format|\n format.html { redirect_to shops_url, notice: '店舗の削除をしました' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @site.destroy\n\n respond_to do |format|\n format.html { redirect_to(sites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @site = Site.find(params[:id])\n @site.destroy\n\n respond_to do |format|\n format.html { redirect_to(sites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @site = Site.find(params[:id])\n @site.destroy\n\n respond_to do |format|\n format.html { redirect_to(sites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @site = Site.find(params[:id])\n @site.destroy\n\n respond_to do |format|\n format.html { redirect_to(sites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @site = Site.find(params[:id])\n @site.destroy\n\n respond_to do |format|\n format.html { redirect_to(sites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @site = Site.find(params[:id])\n @site.destroy\n\n respond_to do |format|\n format.html { redirect_to(sites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @site = Site.find(params[:id])\n @site.destroy\n\n respond_to do |format|\n format.html { redirect_to(sites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @site = Site.find(params[:id])\n @site.destroy\n\n respond_to do |format|\n format.html { redirect_to(sites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @site = Site.find(params[:id])\n @site.destroy\n\n respond_to do |format|\n format.html { redirect_to(sites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n sf = @site.site_files.find params[:id]\n sf.destroy\n\n flash[:notice] = \"#{sf.path} has been deleted.\"\n respond_to do |format|\n format.html { redirect_to(site_site_files_path(@site)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sa = Sa.find(params[:id])\n @sa.destroy\n\n respond_to do |format|\n format.html { redirect_to(sas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n @senhas = Senha.find(params[:id])\n @senhas.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shayari = Shayari.find(params[:id])\n @shayari.destroy\n\n respond_to do |format|\n format.html { redirect_to(shayaris_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shop.destroy\n respond_to do |format|\n format.html { redirect_to backend_shops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @alfresco = Alfresco.find(params[:id])\n @alfresco.destroy\n\n respond_to do |format|\n format.html { redirect_to(alfrescos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @scoop.destroy\n respond_to do |format|\n format.html { redirect_to scoops_path, notice: 'Scoop was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nossos_servico = NossosServico.find(params[:id])\n @nossos_servico.destroy\n\n respond_to do |format|\n format.html { redirect_to(nossos_servicos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sti = Sti.find(params[:id])\n @sti.destroy\n\n respond_to do |format|\n format.html { redirect_to(stis_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @service = Service.find(params[:id])\n @service.destroy\n\n respond_to do |format|\n format.html { redirect_to(services_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @service = Service.find(params[:id])\n @service.destroy\n\n respond_to do |format|\n format.html { redirect_to(services_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @service = Service.find(params[:id])\n @service.destroy\n\n respond_to do |format|\n format.html { redirect_to(services_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sofa = Sofa.find(params[:id])\n @sofa.destroy\n\n respond_to do |format|\n format.html { redirect_to(sofas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sim_staff = SimStaff.find(params[:id])\n @sim_staff.destroy\n\n respond_to do |format|\n format.html { redirect_to(sim_staffs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sitelink = Sitelink.find(params[:id])\n @sitelink.destroy\n\n respond_to do |format|\n format.html { redirect_to(sitelinks_url) }\n format.xml { head :ok }\n end\n end",
"def delete(*rest) end",
"def destroy\n @selector_site = SelectorSite.find(params[:id])\n @selector_site.destroy\n\n respond_to do |format|\n format.html { redirect_to(selector_sites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy \n Link.connection.execute(\"delete from links where id in (#{params[:id].join(',')})\") unless params[:id].blank?\n respond_to do |format|\n format.html { redirect_to(links_url) }\n format.xml { head :ok }\n end\n end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"def destroy\n @sitio = Sitio.find(params[:id])\n @sitio.destroy\n\n respond_to do |format|\n format.html { redirect_to(sitios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to shelves_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale_on_sale_import = SaleOnSaleImport.find(params[:id])\n @sale_on_sale_import.destroy\n\n respond_to do |format|\n format.html { redirect_to(sale_on_sale_imports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n # retrieve the site thanks to params[:id]\n @site = Site.find(params[:id])\n @site.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end",
"def destroy\n @operations_check = OperationsCheck.find(params[:id])\n @operations_check.destroy\n\n respond_to do |format|\n format.html { redirect_to operations_checks_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n make_call(mk_conn(path), :delete)\n end",
"def destroy\n @sale.destroy\n\n head :no_content\n end",
"def delete(action, **args); end",
"def destroy\n @shop.destroy\n respond_to do |format|\n format.html { redirect_to shops_url, notice: 'Shop was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop.destroy\n respond_to do |format|\n format.html { redirect_to shops_url, notice: 'Shop was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop.destroy\n respond_to do |format|\n format.html { redirect_to shops_url, notice: 'Shop was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop.destroy\n respond_to do |format|\n format.html { redirect_to shops_url, notice: 'Shop was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop.destroy\n respond_to do |format|\n format.html { redirect_to shops_url, notice: 'Shop was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shelf.destroy\n respond_to do |format|\n format.html { redirect_to shelves_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @atest = Atest.find(params[:id])\n @atest.destroy\n\n respond_to do |format|\n format.html { redirect_to(atests_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\n request = Net::HTTP::Delete.new(\"#{@url}/#{id}.xml\")\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def destroy\n @sales_type = SalesType.find(params[:id])\n @sales_type.destroy\n\n respond_to do |format|\n format.html { redirect_to({:controller=>\"sales_types\", :action=>\"index\"}) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @addeshop.destroy\n respond_to do |format|\n format.html { redirect_to addeshops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @strip = Strip.find(params[:id])\n @strip.destroy\n respond_to do |format|\n format.html { redirect_to strips_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sprint = Sprint.find(params[:id])\n @sprint.destroy\n\n respond_to do |format|\n format.html { redirect_to product_path(@product) }\n format.xml { head :ok }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete\n delete_from_server single_url\n end"
] | [
"0.65141165",
"0.6476739",
"0.6475688",
"0.6457269",
"0.6414871",
"0.6388637",
"0.6360673",
"0.6348651",
"0.6323372",
"0.6276365",
"0.6236237",
"0.6235271",
"0.623514",
"0.6194304",
"0.6172855",
"0.6166707",
"0.6166707",
"0.61563534",
"0.6146716",
"0.612103",
"0.6108715",
"0.6108715",
"0.6108715",
"0.61072576",
"0.60931516",
"0.6090157",
"0.6083175",
"0.6075522",
"0.60575736",
"0.6049974",
"0.6038548",
"0.6030381",
"0.6022538",
"0.6021929",
"0.6020536",
"0.6010884",
"0.6006584",
"0.59921044",
"0.59911627",
"0.59873044",
"0.59771085",
"0.59729874",
"0.5963551",
"0.5963525",
"0.5961649",
"0.59613824",
"0.5960821",
"0.5960333",
"0.5957839",
"0.5957839",
"0.5957839",
"0.5957839",
"0.5957839",
"0.5957839",
"0.5957839",
"0.5957839",
"0.5957435",
"0.5944162",
"0.59372586",
"0.5934639",
"0.5933097",
"0.5930412",
"0.59291625",
"0.59233725",
"0.59194875",
"0.5913462",
"0.59109485",
"0.5910465",
"0.5910465",
"0.5910465",
"0.5902159",
"0.58910334",
"0.58895093",
"0.5885139",
"0.58843964",
"0.5882551",
"0.5874945",
"0.5874945",
"0.58691996",
"0.5868513",
"0.58666843",
"0.5861366",
"0.58575666",
"0.58543116",
"0.5854286",
"0.58469653",
"0.5846831",
"0.5846831",
"0.5846831",
"0.5846831",
"0.5846831",
"0.5839319",
"0.5835659",
"0.58356297",
"0.5831229",
"0.5827457",
"0.5826246",
"0.5820248",
"0.5819688",
"0.58189017"
] | 0.6776488 | 0 |
Note When giving a block to this helper, use <%. Otherwise, use <%= | def flash_display(flash_type, &block)
message = flash_message_for(flash_type)
return '' if message.nil?
marked_up_message = build_flash_display(message)
(block_given?) ? wrap_flash(marked_up_message, flash_type, &block) : %Q[<div id="flash_#{flash_type}">#{marked_up_message}</div>]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html\n #this is a way to create longer strings in place easily.\n x = <<DELIM\n<html>\n<body>\n#{yield}\n</body>\n</html>\nDELIM\nend",
"def render(context)\n # Sanitize the code inside the block\n resolve_code = super.to_s.gsub(/\\A(\\n|\\r)+|(\\n|\\r)+\\z/, \"\")\n \n # Invoke Rouge to format our code\n formatted_code = rouge_resolve(resolve_code)\n \n # Output the formatted code with the proper HTML tags\n to_html_code(formatted_code)\n end",
"def content_for(*args,&block)\n if block\n helpers.content_for(*args,&block)\n else\n rawtext(helpers.content_for(*args))\n ''\n end\n end",
"def yield_tag(text); end",
"def quote_tag\n :div\n end",
"def tag(tag)\n print \"<#{tag}>\"\n print yield\n print \"</#{tag}>\"\nend",
"def format_as_block_html(name, attr, body, indent); end",
"def render(*args, &block); end",
"def erb(template) render template end",
"def render_block(block)\n block.map do |prop, value|\n render_property prop, value\n end.join('')\n end",
"def format\n unless block\n fields.inject(\"\".html_safe) do |html, field|\n html << view(field)\n end\n end\n end",
"def handle_raw_html_tag(name); end",
"def render()\n @@CLUSTER_TEMPLATE ||= %q{\nIronfan.cluster <%= @cluster.provider.inspect %>, <%= @cluster.name.to_s.inspect %> do\n\n hadoop_distro <%= @cluster.hadoop_distro.inspect %>\n\n cloud <%= @cloud.name.inspect %> do\n image_name <%= @cloud.image_name.inspect %>\n flavor <%= @cloud.flavor.inspect %>\n end\n\n <% @facets.each do |name, facet| %>\n facet <%= facet.name.inspect %> do\n instances <%= facet.instances.inspect %>\n <% facet.run_list.each { |item| %>\n <%= item.sub('[', ' \"').sub(']', '\"') %><% } %>\n end\n <% end %>\n\n cluster_role.override_attributes({\n :hadoop => {\n :distro_name => <%= @cluster.hadoop_distro.inspect %>\n }\n })\nend\n}\n require 'erb'\n ERB.new(@@CLUSTER_TEMPLATE).result(binding)\n end",
"def tag(tagname, text)\n html = \"<#{tagname}>#{text}</#{tagname}>\"\n yield html\nend",
"def by_using_call(string1, string2, &block)\r\n result = ''\r\n result += wrap_in_tag('h1', string1)\r\n result += wrap_in_tag('ul', block.call(4))\r\n result += wrap_in_tag('h2', string2)\r\nend",
"def _(data=\"\"); self.__ self.escape_html(data.to_s); end",
"def inline_tags; end",
"def block_html(raw)\n raw = unindent(raw)\n\n if md = raw.match(/\\<(.+?)\\>(.*)\\<(\\/.+?)\\>/m)\n open_tag, content, close_tag = md.captures\n \"<#{open_tag}>\\n#{recursive_render(unindent(content))}<#{close_tag}>\"\n else\n raw\n end\n end",
"def yieldreturn_tag(text); end",
"def yieldparam_tag(text); end",
"def display_as_html(content, &block)\n content = content.presence || \"\"\n if content !~ /<\\w+[^>]>/\n content = content.gsub(\"\\n\", \"<br />\")\n end\n content_tag :div, :class => \"rtf\" do\n if block_given?\n concat(capture(&block))\n end\n concat(content.html_safe)\n end\n end",
"def display_as_html(content, &block)\n content = content.presence || \"\"\n if content !~ /<\\w+[^>]>/\n content = content.gsub(\"\\n\", \"<br />\")\n end\n content_tag :div, :class => \"rtf\" do\n if block_given?\n concat(capture(&block))\n end\n concat(content.html_safe)\n end\n end",
"def to_s\n label = @field.label\n val = @template.send(:h, formatted_value)\n if @block\n @template.concat(@template.capture(label, val, &@block), @block.binding)\n else\n <<-EOF\n<div class=\"form_submission_field_display\">\n <strong class=\"label\">#{label}</strong>\n <span class=\"response\">#{val}</span>\n</div>\nEOF\n end\n end",
"def wrap_block_in_syntax_tags(block)\n \"<div class=\\\"syntax\\\">\" + block + '</div>'\n end",
"def content_tag(tag_name)\n result = \"<#{tag_name}>\"\n result << yield\n result << \"</#{tag_name}>\"\n result\nend",
"def yield_for(symbol)\n haml_concat(content_blocks[symbol].join)\n end",
"def render_block(name, context, blocks = {}, use_blocks = true)\n # ob_start();\n display_block(name, context, blocks, use_blocks)\n # return ob_get_clean();\n end",
"def to_html(*args); end",
"def to_html(*args); end",
"def to_html(*args); end",
"def to_html(*args); end",
"def to_html; end",
"def renderHelper(el)\n\t\tif el === nil\n\t\t\treturn ' '\n\t\telse\n\t\t\treturn el\n\t\tend\n\tend",
"def h1\n puts \"<h1>\" + yield + \"</h1>\"\nend",
"def render\n if @block\n instance_eval(&@block)\n end\n end",
"def h2\n puts \"<h2>\" + yield + \"</h2>\"\nend",
"def showInHtml(data)\n \"<div>#{data}</div>\"\n end",
"def html(x)\n \"<html>\" + x + \"</html>\"\nend",
"def reyield\n '<%=yield %>'\n end",
"def render; ''; end",
"def render_to_string(*args, &block); end",
"def echo_with_yield(str)\n yield\n str\nend",
"def render_div(line)\n render_tag('%div' + line)\n end",
"def render_div(line)\n render_tag('%div' + line)\n end",
"def render_erb\n end",
"def with_raw_haml_concat\n yield\n end",
"def to_inline_html\n to_html true\n end",
"def rendered=(_arg0); end",
"def html_block_show(block)\n title, content = send(block.class.to_s.underscore, block)\n html_blocklike_show(title, content)\n end",
"def erb( content )\n puts \" Running embedded Ruby (erb) code/helpers...\"\n \n content = ERB.new( content ).result( binding() )\n content\n end",
"def html?; end",
"def html?; end",
"def html?; end",
"def item_tag_for( model_name, column_name, value=nil)\n return '' if value.nil?\n return content_tag(:p, :id => model_name + '-' + column_name) do\n raw(\n content_tag(:span, column_name.humanize.capitalize, :class => 'attr-title') +\n content_tag(:span, value, :class => \"attr-value\" )\n )\n end\n end",
"def inner_html(*args); end",
"def inner_html(*args); end",
"def html_blocklike_show(title, content)\n render('layouts/block', :title => title, :content => content) unless content.blank?\n end",
"def capture(*args)\n super.html_safe\n end",
"def text(node)\r\n RenderErb.(erb: TEMPLATE, object: node)\r\n end",
"def render( template, scope )\n\t\treturn ''\n\tend",
"def render_views_in_this(block)\n html = ''\n block.views.each do |view|\n models_view = view.models_view(block)\n \n if view.model_name =~ /(tag)|(image)/ && !view.scope.blank?\n scope_model = view.owner_id.blank? ? eval(\"@#{view.scope}\") : model_class(view.scope).find(view.owner_id)\n data = eval(\"scope_model.#{view.model_name.pluralize}\")\n \n elsif view.model_name == 'post' && view.scope == 'tag'\n tag = view.owner_id.blank? ? eval(\"@tag\") : Tag.find(view.owner_id)\n data = Post.find(:all, :conditions => models_view.conditions).select { |p| p.tags.map(&:name).include? tag.name }\n data = data.paginate(:per_page => 15, :page => params[:page]) if models_view.paginate\n \n else\n data = view.model.all(view_find_options(view, models_view))\n end\n \n html << render(:partial => \"#{view_types_dir}#{models_view.view_type}\", :locals => { :data => data })\n end\n html\n #rescue\n # resource = block.class.to_controller_str\n # block_str = current_user && current_user.has_permission?(resource, 'edit', params) ? \"<a href='/#{resource}/#{block.id}/edit'>#{block.title}</a>\" : block.title\n # \"<div class='flash error'>And error occured loading view in block: #{block_str}</div>\"\n end",
"def render_views_in_this(block)\n html = ''\n block.views.each do |view|\n models_view = view.models_view(block)\n \n if view.model_name =~ /(tag)|(image)/ && !view.scope.blank?\n scope_model = view.owner_id.blank? ? eval(\"@#{view.scope}\") : model_class(view.scope).find(view.owner_id)\n data = eval(\"scope_model.#{view.model_name.pluralize}\")\n \n elsif view.model_name == 'post' && view.scope == 'tag'\n tag = view.owner_id.blank? ? eval(\"@tag\") : Tag.find(view.owner_id)\n data = Post.find(:all, :conditions => models_view.conditions).select { |p| p.tags.map(&:name).include? tag.name }\n data = data.paginate(:per_page => 15, :page => params[:page]) if models_view.paginate\n \n else\n data = view.model.all(view_find_options(view, models_view))\n end\n \n html << render(:partial => \"#{view_types_dir}#{models_view.view_type}\", :locals => { :data => data })\n end\n html\n #rescue\n # resource = block.class.to_controller_str\n # block_str = current_user && current_user.has_permission?(resource, 'edit', params) ? \"<a href='/#{resource}/#{block.id}/edit'>#{block.title}</a>\" : block.title\n # \"<div class='flash error'>And error occured loading view in block: #{block_str}</div>\"\n end",
"def ie_html(attrs={}, &block)\n ie_tag(:html, attrs, &block)\n end",
"def codespan(code)\n \"{{#{code}}}\"\n end",
"def liquid_block(block)\n Liquid::Template.parse(block).render(@context)\n end",
"def render_field_with_block(label, &block)\n content = with_output_buffer(&block)\n render_field_content(label, content)\n end",
"def the_widget(attrs = {}, &block)\n attrs = {qty_truncate: 100, block_right: '', class: ''}.merge(attrs)\n \"<div class='media #{attrs[:class]}'>\n <div class='media-left text-center'>\n <div class='text-red'>#{object.day}</div>\n <div class='num'>#{object.hour}</div>\n </div>\n <div class='media-body'>\n <div class='media-heading text-gray'>\n #{object.title}\n </div>\n #{block ? h.capture(&block) : ''}\n </div>\n #{\"<div class='media-right'>#{attrs[:media_right]}</div>\" if attrs[:media_right]}\n </div>\".html_safe\n end",
"def render\n inspect\n end",
"def erb(content)\n ERB.new(content).result(binding)\nend",
"def snippet_tag\n :div\n end",
"def codeblock\n H[:pre, attr, H[:code, value]]\n end",
"def cms_snippet_render(identifier, cms_site = @cms_site, &block)\n return '' unless cms_site\n content = cms_snippet_content(identifier, cms_site, &block)\n render :inline => ComfortableMexicanSofa::Tag.process_content(\n cms_site.pages.build, ComfortableMexicanSofa::Tag.sanitize_irb(content)\n )\n end",
"def render(source)\n ERB.new(source, nil, '-').result(binding)\n end",
"def tag(tagname, attributes={})\n # Output the tag name\n @out << \"<#{tagname}\"\n\n # Output the attributes\n attributes.each {|attr,value| @out << \" #{attr}='#{value}'\" }\n \n if block_given?\n # This block has content\n @out << '>' # End the opening tag\n content = yield # Invoke the block to output or return content\n if content # If any content returned\n @out << content.to_s # Output it as a string\n end\n @out << \"</#{tagname}>\" # Close the tag\n else \n # Otherwise, this is an empty tag, so just close it.\n @out << '/>'\n end\n nil # Tags output themselves, so they don't return any content\n end",
"def format_as_span_html(name, attr, body); end",
"def cms_snippet_render(identifier, cms_site = @cms_site, &block)\n return '' unless cms_site\n content = cms_snippet_content(identifier, cms_site, &block)\n render :inline => ComfortableMexicanSofa::Tag.process_content(\n cms_site.pages.build, ComfortableMexicanSofa::Tag.sanitize_irb(content)\n )\n end",
"def render(options = T.unsafe(nil), locals = T.unsafe(nil), &block); end",
"def render_tag(tag_name, html_options = {}, &block)\n options = ['']\n options << %{id=\"#{html_options[:id]}\"} if html_options[:id].present?\n options << %{class=\"#{html_options[:css]}\"} if html_options[:css].present?\n\n %{<#{tag_name}#{options.join(' ')}>#{yield}</#{tag_name}>}\n end",
"def render(scope = T.unsafe(nil), locals = T.unsafe(nil), &block); end",
"def op_helper_simple(tagname, tagclass, to_add)\n @content << %(<#{tagname} class=\"#{tagclass}\">) << to_add << %(</#{tagname}>)\n end",
"def wrap_block(method, options = {}, &block)\n # content = capture(&block)\n concat(tag('div', {:class => 'irow', :id => \"irow_#{@object_name}_#{method}\"}), block.binding)\n concat(label_for_field(method, options), block.binding)\n concat(tag('div', {:class => 'input'}), block.binding)\n yield self\n concat(cr, block.binding)\n concat('</div>', block.binding)\n concat('</div>', block.binding)\n end",
"def h obj; obj.to_s.html_escape end",
"def liquid_renderer; end",
"def echo_with_yield(str)\n yield if block_given?\n str\nend",
"def login_block\n\n content_tag :div, :id => 'login-block' do\n\n if logged_in?\n # Block with username and logout\n [\n content_tag(:p, current_user.auth_name, :class => 'username'),\n content_tag(:p, :class => 'login-link logout') do\n link_to('Sign out', logout_path)\n end\n ].reduce :+\n\n else\n # Block with login\n content_tag :p, :class => 'login-link login' do\n link_to('Sign in', login_path)\n end # p\n end\n\n end # div\n end",
"def render\n render_to_string(:inline => '<%= render_grid(grid) %>', :locals => {:grid => self})\n end",
"def to_html \n generator.generate\n end",
"def html_safe\n self\n end",
"def __in_erb_template;\n end",
"def __in_erb_template;\n end",
"def cms_block_render(identifier, blockable = @cms_page)\n tag = blockable && (block = blockable.blocks.find_by_identifier(identifier)) && block.tag\n return '' unless tag\n render :inline => ComfortableMexicanSofa::Tag.process_content(blockable, tag.render)\n end",
"def attr_with_erb_to_html(invitation, attribute)\n process_template(invitation.send(attribute.to_sym,:source))\n rescue Exception => e\n \"#{e.class} in ERB for #{attribute.to_s}: #{e.message}\"\n logger.error \"#{e.class} in ERB for #{attribute.to_s}: #{e.message}: BT: #{e.backtrace.inspect}\"\n end",
"def show_header_tag(obj)\n return \"no display_name method\" if !obj.respond_to?('display_name')\n content_tag('div', :style => 'display:inline;') do\n obj.display_name + \" \" + content_tag('span', \"(id: #{obj.id})\", :class => 'small_grey')\n end\n end",
"def admin_area(&block)\n # check for condition; eg, if admin?\n if true\n # # using only concat\n # concat('<div class=\"admin\">'.html_safe)\n # yield\n # concat('</div>'.html_safe)\n # using concat and capture, no need for yield\n concat content_tag :div, capture(&block), class: \"admin\"\n end\n end",
"def text_block(text)\n h(text).gsub(/\\n/, '<br/>').html_safe\n end",
"def render_with_liquid?; end",
"def render_with_liquid?; end",
"def format_email_itinerary_item(&block)\n\n # Check to see if there is any content in the block\n content = capture(&block)\n if content.nil?\n content = \" \"\n end\n html << content\n return html.html_safe\n end",
"def rendered; end",
"def inline_code; end",
"def render(props)\n # HTML.\n end"
] | [
"0.6574328",
"0.6565752",
"0.65264815",
"0.64930767",
"0.6360935",
"0.6347731",
"0.62378734",
"0.62313664",
"0.62101454",
"0.61420566",
"0.61019504",
"0.6092712",
"0.6082125",
"0.6030616",
"0.6028208",
"0.6025939",
"0.6020808",
"0.5966871",
"0.5965985",
"0.59492224",
"0.5947978",
"0.5947978",
"0.592846",
"0.5922695",
"0.5916382",
"0.5879349",
"0.5868009",
"0.58674675",
"0.58674675",
"0.58674675",
"0.58674675",
"0.5855102",
"0.58516234",
"0.58401024",
"0.5832782",
"0.5827094",
"0.58212507",
"0.58211184",
"0.5812904",
"0.5809652",
"0.58079785",
"0.58045775",
"0.5800058",
"0.5800058",
"0.57965475",
"0.5796522",
"0.57829463",
"0.5769555",
"0.5761852",
"0.576098",
"0.575497",
"0.575497",
"0.575497",
"0.57541317",
"0.5743547",
"0.5743547",
"0.5734183",
"0.573228",
"0.5710501",
"0.5702697",
"0.5699521",
"0.5699521",
"0.56801534",
"0.56636745",
"0.56620437",
"0.56574494",
"0.5633209",
"0.5631963",
"0.56295013",
"0.56289417",
"0.56223613",
"0.56171316",
"0.5609152",
"0.5603393",
"0.55957645",
"0.55904984",
"0.5589552",
"0.55858123",
"0.55824167",
"0.55565256",
"0.5554522",
"0.55436784",
"0.5541845",
"0.55359966",
"0.55323446",
"0.5530591",
"0.55291295",
"0.5528982",
"0.55260676",
"0.55260676",
"0.5518667",
"0.55185914",
"0.5517647",
"0.551434",
"0.55092907",
"0.55051255",
"0.55051255",
"0.55036545",
"0.5494759",
"0.5494515",
"0.5492727"
] | 0.0 | -1 |
Returns the metaclass or eigenclass so that i can dynamically add class methods to active record models | def metaclass
class << self;
self
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metaclass\n class << self; self; end;\n end",
"def metaclass\n class << self; self end\n end",
"def meta_eval\n metaclass.instance_eval\n end",
"def metametaclass; self.metaclass.metaclass; end",
"def metaclass\n class << self\n self\n end\n end",
"def metaclass\n class << self\n self\n end\n end",
"def metaclass\n class << self\n self\n end \n end",
"def metaclass\n if !self.metaclass?\n raise NoMetaClass, self\n else\n class << self; self; end; \n end\n end",
"def meta_eval &blk; metaclass.instance_eval &blk; end",
"def meta_eval &blk; metaclass.instance_eval &blk; end",
"def model_class\n @model_class ||= derived_model_class_name.constantize\n end",
"def model_class\n @class_name.constantize\n end",
"def meta_eval(&block)\n metaclass.instance_eval(&block)\n end",
"def model\n @type.constantize\n end",
"def model\n @type.constantize\n end",
"def model_class\n class_name.constantize\n end",
"def model_class\n self.class_name.constantize\n end",
"def true_class\n return ModelProxy\n end",
"def eigenclass\n class << self\n return self\n end\n end",
"def model\n if object[inheritance_column]\n object[inheritance_column].constantize\n else\n original_class\n end\n end",
"def model_class; end",
"def concrete_model\n self.class\n end",
"def model_class\n return @model_class || self.class.model_class\n end",
"def model_class\n self.class.models[implementation_model_name]\n end",
"def model_class\n @model_class ||= mapping.to\n end",
"def dynamic_model_class_name\n dynamic_model.implementation_class.name\n end",
"def eigenclass\n class << self; self; end\n end",
"def class\n @model.class\n end",
"def model_class\n @model_class ||= model_name.camelize.constantize\n end",
"def type_klass; end",
"def eigenclass\n class << self\n self\n end\n end",
"def klass\n reflection.klass\n end",
"def klass\n reflection.klass\n end",
"def class_with_model_name # :nodoc:\n self.class_without_model_name.tap do |c|\n c.instance_variable_set('@_model_name', @model_name)\n (class << c; self; end).send(:define_method,:model_name) do\n model_namer = Struct.new(:name).new(self.instance_variable_get('@_model_name'))\n ActiveModel::Name.new(model_namer)\n end\n end\n end",
"def model_class\n self.class.const_get('MODEL')\n end",
"def couchrest_model\n ## TODO - deprecate this method\n return if self.term.nil? || instance_database.nil? || self.vocabulary.nil?\n \n write_attribute(:instance_class_name, self.term.singularize.camelize)\n\n if Object.const_defined?(self.instance_class_name.intern)\n klass = Object.const_get(self.instance_class_name.intern)\n else\n db = instance_database\n prop_list = self.vocabulary.properties.inject([]) {|plist, p| plist << p}\n type_list = self.vocabulary.types.inject([]) {|tlist, t| tlist << t} \n \n klass = Object.const_set(self.instance_class_name.intern, \n Class.new(CouchRest::Model::Base) do\n use_database db\n prop_list.each {|p| property p.term.to_sym}\n property :serial_number\n property :data_source_id\n timestamps!\n\n # type_list.each |t| do\n # property t.to_sym do\n # t.properties.each {|tp| property tp.term.to_sym}\n # end\n # end\n # \n design do\n view :by_serial_number\n view :by_data_source_id\n end\n \n end\n )\n end\n klass\n end",
"def get_class()\n l = get_type()\n #puts \"Type #{l.class} in #{self.class} , #{self}\"\n l.object_class()\n end",
"def get_class()\n l = get_type()\n #puts \"Type #{l.class} in #{self.class} , #{self}\"\n l.object_class()\n end",
"def hook_model_klass\n fail 'child class to return a model klass here'\n end",
"def get_class type\n case type\n when Class\n type\n when BaseModel\n type.my_class\n when String, Symbol\n return get_class send(\"#{type}_model\") if [:subject, :object, :join].include?(type.to_sym)\n type.to_s.constantize\n else\n raise \"Can't determine a class from: #{type}\"\n end \n end",
"def meta_eval string = nil, &block\n return metaclass.class_eval(string) if string\n metaclass.class_eval &block\n end",
"def model_type\n self.class.model_type\n end",
"def get_model\n return model_classes[item_type].new()\n end",
"def cv_klass\n object.model.class.properties[attribute_name.to_s].class_name\n end",
"def target_class\n if reflection.polymorphic?\n base_model.send(reflection.foreign_type).constantize\n else\n reflection.klass\n end\n end",
"def base_class\n S::Model\n end",
"def model\n self.class.const_get(:MODEL)\n end",
"def klass\n object_name.classify.constantize\n end",
"def class_eval(*args, &block)\r\n metaclass.class_eval(*args, &block)\r\n end",
"def to_model_class\n to_model_name.classify.constantize\n end",
"def object_class\n self.class.object_class\n end",
"def class_eval(*args, &block)\n metaclass.class_eval(*args, &block)\n end",
"def model_class=(_arg0); end",
"def class_obj\n self.class\n end",
"def meta_module\n return @_meta_module if defined?(@_meta_module)\n if self.name\n @_meta_module = ::Gorillib::Model::NamedSchema.get_nested_module(\"Meta::#{self.name}Type\")\n else\n @_meta_module = Module.new\n end\n self.class_eval{ include(@_meta_module) }\n @_meta_module\n end",
"def _class\n special_attribute('@class'.freeze) || self.class.name.demodulize\n end",
"def associated_class\n self[:class] ||= self[:class_name].constantize\n end",
"def model_class\n @model_class ||= controller_path.classify.constantize\n end",
"def associated_class\n self[:class] ||= self[:class_name].constantize\n end",
"def can_get_class?(klass); true; end",
"def repeatable_thing_class\n base_type = attr_json_registration.type.base_type\n if base_type.is_a?(AttrJson::Model)\n base_type\n else\n # Will return a symbol name, confusingly\n base_type.type\n end\n end",
"def record_class\n @record_class ||= record_class_for(self)\n end",
"def get_mobj(mname=nil) @model_class.instance; end",
"def get_model_class(file); end",
"def base_class; end",
"def class\n object.class\n end",
"def to_class(model_name)\r\n Kernel.const_get(model_name.to_s.camelize)\r\n end",
"def object_class object_type\n object_type.classify.constantize\n end",
"def getRubyClass\n @ruby_class\n end",
"def class\n __getobj__.class\n end",
"def model_class\n self.name.gsub(/Test$/, '').constantize\n end",
"def klass\n @klass ||= association ? association.klass : model\n end",
"def class_for assoc_name\n raise NotImplementedError\n end",
"def class_for assoc_name\n raise NotImplementedError\n end",
"def klass\n type.to_s.classify.constantize\n end",
"def klass\n self.class\n end",
"def to_class\n\t\t@model.classes.map { |kname, klass| klass.to_class( @model ) } +\n\t\t\t@model.find_through.map { |t| t.to_class }\n\tend",
"def klass\n class_name = self[\"_type\"]\n class_name ? class_name.constantize : nil\n end",
"def child_class\n Objekt\n end",
"def meta_classes\n META_CLASSES\n end",
"def class\n @object.class\n end",
"def class_for assoc_name\n @model_class.reflect_on_association(assoc_name.to_sym).klass\n end",
"def extensions\n\t\teigenclass = ( class << self; self; end )\n\t\treturn eigenclass.included_modules.find_all do |mod|\n\t\t\t(class << mod; self; end).include?(Treequel::Model::ObjectClass)\n\t\tend\n\tend",
"def target_class(database_record)\n target_reflection(database_record).klass\n end",
"def model_from_options #nodoc\n @options[:class_name].nil? ? nil : @options[:class_name].constantize\n end",
"def add_class_method(c,m,&b)\r\n eigenclass = class << c; self; end\r\n eigenclass.class_eval {\r\n define_method(m, &b)\r\n }\r\nend",
"def instance_type; end",
"def __create_meta_schema_class klass\n binder = self.name\n self.const_set(klass,\n Class.new(ActiveRecord::Base) do # class MetaSchema < ActiveRecord::Base\n singleton_class.send(:define_method, :table_name_prefix) do # def self.table_name_prefix\n \"#{binder.underscore}_\" # \"foo_binder\" # If we have a class FooBinder < Binder::AR\n end # end\n end) # end\n end",
"def klass\n described_class\n end",
"def klass\n described_class\n end",
"def base\n @parent ? @parent.model_instance.send(@name.to_s.pluralize) : model_class\n end",
"def model_type\n @model_type ||= :ActiveRecord\n end",
"def klass; end",
"def klass; end",
"def klass; end",
"def klass; end",
"def klass; end",
"def klass; end",
"def klass; end"
] | [
"0.7443653",
"0.736564",
"0.73096275",
"0.7266055",
"0.7168175",
"0.7168175",
"0.7155354",
"0.7136638",
"0.71214074",
"0.71214074",
"0.6859118",
"0.68331546",
"0.6738636",
"0.6725199",
"0.6725199",
"0.6720037",
"0.662257",
"0.6601476",
"0.65788364",
"0.6539718",
"0.65267575",
"0.6523054",
"0.65112025",
"0.6510714",
"0.6485248",
"0.6462397",
"0.64180404",
"0.64079416",
"0.63937366",
"0.6381843",
"0.6348681",
"0.6268991",
"0.6268991",
"0.62640065",
"0.6262213",
"0.6223172",
"0.62122774",
"0.62122774",
"0.6200913",
"0.6165234",
"0.6144926",
"0.61290944",
"0.60800374",
"0.6067199",
"0.60666484",
"0.605376",
"0.6037723",
"0.6036033",
"0.60269177",
"0.601651",
"0.60157645",
"0.60116214",
"0.6008669",
"0.6003619",
"0.60016274",
"0.5973195",
"0.5969154",
"0.5969068",
"0.5965426",
"0.5941766",
"0.59355307",
"0.5930312",
"0.5917143",
"0.5914071",
"0.5894381",
"0.58836836",
"0.588212",
"0.586918",
"0.5868832",
"0.5859194",
"0.5855741",
"0.58339614",
"0.58202815",
"0.58202815",
"0.5816774",
"0.581198",
"0.5809762",
"0.5800708",
"0.57963896",
"0.5790473",
"0.5789671",
"0.5789648",
"0.57790667",
"0.57707953",
"0.5770682",
"0.57651514",
"0.57608384",
"0.5741708",
"0.5722175",
"0.5722175",
"0.57190686",
"0.56943405",
"0.56861514",
"0.56861514",
"0.56861514",
"0.56861514",
"0.56861514",
"0.56861514",
"0.5685369"
] | 0.70322067 | 11 |
the most important part | def re_define_class_method(name, &block)
#klass = self.to_s
metaclass.instance_eval do
undef_method(name) if method_defined?(name)
define_method(name, &block)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def offences_by; end",
"def first; end",
"def first; end",
"def probers; end",
"def first?; end",
"def schubert; end",
"def suivre; end",
"def first() end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def offences_by=(_arg0); end",
"def who_we_are\r\n end",
"def private; end",
"def anchored; end",
"def order; end",
"def order; end",
"def first\n end",
"def berlioz; end",
"def extra; end",
"def stderrs; end",
"def caar; first.first end",
"def used?; end",
"def terpene; end",
"def normal\n first\n end",
"def celebration; end",
"def ignores; end",
"def priority() nil end",
"def remaining; end",
"def priority=(*) end",
"def schumann; end",
"def caveats; nil end",
"def caveats; nil end",
"def feruchemist; end",
"def formation; end",
"def verdi; end",
"def strain; end",
"def extra_state; end",
"def isolated; end",
"def isolated; end",
"def malts; end",
"def blg; end",
"def gounod; end",
"def least\n nil\n end",
"def strategy; end",
"def placebo?; false end",
"def scientist; end",
"def weber; end",
"def most_interesting_man_in_the_world; end",
"def by_priority; end",
"def internship_passed; end",
"def informational?; end",
"def flag; end",
"def entry_order; end",
"def probers=(_arg0); end",
"def sitemaps; end",
"def trd; end",
"def celebrity; end",
"def celebrity; end",
"def bizet; end",
"def final; end",
"def extra; @extra; end",
"def minor; end",
"def minor; end",
"def minor; end",
"def starship; end",
"def anatomy; end",
"def intensifier; end",
"def required_positionals; end",
"def entry_order=(_arg0); end",
"def processor; end",
"def operations; end",
"def operations; end",
"def most_specific_subdivision; end",
"def parts; end",
"def parts; end",
"def parts; end",
"def silly_adjective; end",
"def buzzword; end",
"def buzzword; end",
"def jack_handey; end",
"def incomplete\r\n\r\n end",
"def rest_positionals; end",
"def optional; end",
"def weaker\n descendants\n end",
"def villian; end",
"def high_five; end",
"def summary; end",
"def summary; end",
"def summary; end",
"def summary; end",
"def unusual_sport; end",
"def deco_pos; end",
"def nature; end",
"def manufacture; end",
"def skips; end",
"def priority(*) end",
"def romeo_and_juliet; end",
"def weight; end",
"def top;end"
] | [
"0.67971194",
"0.677613",
"0.677613",
"0.6759582",
"0.6559737",
"0.6454681",
"0.6317848",
"0.62660635",
"0.62423116",
"0.62423116",
"0.62423116",
"0.62423116",
"0.62187135",
"0.62176746",
"0.6162741",
"0.6160375",
"0.6093518",
"0.6093518",
"0.5998459",
"0.5995323",
"0.5980306",
"0.59657294",
"0.5950919",
"0.59338146",
"0.5909903",
"0.5890009",
"0.5876292",
"0.5857062",
"0.5836662",
"0.5801575",
"0.5794734",
"0.57759047",
"0.5751205",
"0.5751205",
"0.57239205",
"0.56849265",
"0.56835526",
"0.5683379",
"0.5676742",
"0.5649828",
"0.5649828",
"0.5641683",
"0.5628781",
"0.5624233",
"0.56038105",
"0.55876684",
"0.5575105",
"0.5565923",
"0.5556117",
"0.5554716",
"0.55533695",
"0.55515784",
"0.55512196",
"0.5532365",
"0.5528483",
"0.55206734",
"0.55131155",
"0.55070394",
"0.55059445",
"0.55059445",
"0.5501646",
"0.5497022",
"0.54951733",
"0.5494028",
"0.5494028",
"0.5494028",
"0.548697",
"0.5485247",
"0.5478803",
"0.54705006",
"0.5470379",
"0.5467613",
"0.54559463",
"0.54559463",
"0.54405093",
"0.54342955",
"0.54342955",
"0.54342955",
"0.54328334",
"0.5432776",
"0.5432776",
"0.54313356",
"0.5430135",
"0.5422327",
"0.54048634",
"0.54006815",
"0.5397049",
"0.5396849",
"0.5396745",
"0.5396745",
"0.5396745",
"0.5396745",
"0.5395433",
"0.5390851",
"0.538405",
"0.53826547",
"0.536612",
"0.5360366",
"0.5352027",
"0.5351642",
"0.53479254"
] | 0.0 | -1 |
the most important part | def alias_class_method(new_name, old_name)
#klass = self.to_s
metaclass.instance_eval do
alias_method new_name, old_name
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def offences_by; end",
"def first; end",
"def first; end",
"def probers; end",
"def first?; end",
"def schubert; end",
"def suivre; end",
"def first() end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def offences_by=(_arg0); end",
"def who_we_are\r\n end",
"def private; end",
"def anchored; end",
"def order; end",
"def order; end",
"def first\n end",
"def berlioz; end",
"def extra; end",
"def stderrs; end",
"def caar; first.first end",
"def used?; end",
"def terpene; end",
"def normal\n first\n end",
"def celebration; end",
"def ignores; end",
"def priority() nil end",
"def remaining; end",
"def priority=(*) end",
"def schumann; end",
"def caveats; nil end",
"def caveats; nil end",
"def feruchemist; end",
"def formation; end",
"def verdi; end",
"def strain; end",
"def extra_state; end",
"def isolated; end",
"def isolated; end",
"def malts; end",
"def blg; end",
"def gounod; end",
"def least\n nil\n end",
"def strategy; end",
"def placebo?; false end",
"def scientist; end",
"def weber; end",
"def most_interesting_man_in_the_world; end",
"def by_priority; end",
"def internship_passed; end",
"def informational?; end",
"def flag; end",
"def entry_order; end",
"def probers=(_arg0); end",
"def sitemaps; end",
"def trd; end",
"def celebrity; end",
"def celebrity; end",
"def bizet; end",
"def final; end",
"def extra; @extra; end",
"def minor; end",
"def minor; end",
"def minor; end",
"def starship; end",
"def anatomy; end",
"def intensifier; end",
"def required_positionals; end",
"def entry_order=(_arg0); end",
"def processor; end",
"def operations; end",
"def operations; end",
"def most_specific_subdivision; end",
"def parts; end",
"def parts; end",
"def parts; end",
"def silly_adjective; end",
"def buzzword; end",
"def buzzword; end",
"def jack_handey; end",
"def incomplete\r\n\r\n end",
"def rest_positionals; end",
"def optional; end",
"def weaker\n descendants\n end",
"def villian; end",
"def high_five; end",
"def summary; end",
"def summary; end",
"def summary; end",
"def summary; end",
"def unusual_sport; end",
"def deco_pos; end",
"def nature; end",
"def manufacture; end",
"def skips; end",
"def priority(*) end",
"def romeo_and_juliet; end",
"def weight; end",
"def top;end"
] | [
"0.67971194",
"0.677613",
"0.677613",
"0.6759582",
"0.6559737",
"0.6454681",
"0.6317848",
"0.62660635",
"0.62423116",
"0.62423116",
"0.62423116",
"0.62423116",
"0.62187135",
"0.62176746",
"0.6162741",
"0.6160375",
"0.6093518",
"0.6093518",
"0.5998459",
"0.5995323",
"0.5980306",
"0.59657294",
"0.5950919",
"0.59338146",
"0.5909903",
"0.5890009",
"0.5876292",
"0.5857062",
"0.5836662",
"0.5801575",
"0.5794734",
"0.57759047",
"0.5751205",
"0.5751205",
"0.57239205",
"0.56849265",
"0.56835526",
"0.5683379",
"0.5676742",
"0.5649828",
"0.5649828",
"0.5641683",
"0.5628781",
"0.5624233",
"0.56038105",
"0.55876684",
"0.5575105",
"0.5565923",
"0.5556117",
"0.5554716",
"0.55533695",
"0.55515784",
"0.55512196",
"0.5532365",
"0.5528483",
"0.55206734",
"0.55131155",
"0.55070394",
"0.55059445",
"0.55059445",
"0.5501646",
"0.5497022",
"0.54951733",
"0.5494028",
"0.5494028",
"0.5494028",
"0.548697",
"0.5485247",
"0.5478803",
"0.54705006",
"0.5470379",
"0.5467613",
"0.54559463",
"0.54559463",
"0.54405093",
"0.54342955",
"0.54342955",
"0.54342955",
"0.54328334",
"0.5432776",
"0.5432776",
"0.54313356",
"0.5430135",
"0.5422327",
"0.54048634",
"0.54006815",
"0.5397049",
"0.5396849",
"0.5396745",
"0.5396745",
"0.5396745",
"0.5396745",
"0.5395433",
"0.5390851",
"0.538405",
"0.53826547",
"0.536612",
"0.5360366",
"0.5352027",
"0.5351642",
"0.53479254"
] | 0.0 | -1 |
++ Call all necessary methods to convert a string of HTML into Textile markup. | def to_textile
headings(@workingcopy)
structure(@workingcopy)
text_formatting(@workingcopy)
entities(@workingcopy)
tables(@workingcopy)
@workingcopy = CGI::unescapeHTML(@workingcopy)
@workingcopy
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html_markup_textile(text); end",
"def convert_html(text)\n auto_html text do\n html_escape :map => {\n '&' => '&',\n '>' => '>',\n '<' => '<',\n '\"' => '\"'\n }\n image\n youtube :width => 510, :height => 332\n vimeo :width => 510, :height => 332\n link :target => :_blank\n redcarpet :target => :_blank\n end\n end",
"def convert_html(html)\n # Sanitize the html and surround in a <span> tag to make it work with htmltolatex better\n html = \"<span>\" + sanitize(html, :tags => %w(em i sup sub)) + \"</span>\"\n\n # Create the temp files and output the html source to the first one\n raw = Tempfile.new('htmltolatex_html')\n output = Tempfile.new('htmltolatex_tex')\n raw << html; raw.flush\n \n # Run htmltolatex on the source\n path = File.join(RAILS_ROOT, \"lib\", \"htmltolatex\")\n `cd #{path} && #{File.join(path, \"htmltolatex\")} -input #{raw.path} -output #{output.path}`\n\n # Read in the results\n converted = File.open(output.path, \"rb\") { |f| f.read }\n \n # Close and unlink the files\n raw.close!\n output.close!\n \n # Return the results\n converted\n end",
"def html_markup_html(text); end",
"def textile_to_html(str)\n RedCloth.new(str).to_html\n end",
"def html_markup_text(text); end",
"def text_to_html( content )\r\n content = case @markup_type\r\n when :markdown\r\n markdown_to_html( content )\r\n when :textile\r\n textile_to_html( content )\r\n when :rest\r\n rest_to_html( content )\r\n end\r\n content\r\n end",
"def html_markup_textile_strict(text); end",
"def htmlify(text, markup = T.unsafe(nil)); end",
"def html_markup_markdown(text); end",
"def text_to_html( content )\n content = case @markup_type\n when :markdown\n markdown_to_html( content )\n when :textile\n textile_to_html( content )\n when :mediawiki\n mediawiki_to_html( content )\n when :rest\n rest_to_html( content )\n end\n content\n end",
"def to_html(text, format = nil)\n format ||= :textile\n if format == :textile\n RedCloth.new(text).to_html\n else\n text\n end\n end",
"def to_html text\n html = (''.encode text.encoding).dup\n\n encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding]\n\n s = StringScanner.new text\n insquotes = false\n indquotes = false\n after_word = nil\n\n until s.eos? do\n case\n when s.scan(/<(tt|code)>.*?<\\/\\1>/) then # skip contents of tt\n html << s.matched.gsub('\\\\\\\\', '\\\\')\n when s.scan(/<(tt|code)>.*?/) then\n warn \"mismatched <#{s[1]}> tag\" # TODO signal file/line\n html << s.matched\n when s.scan(/<[^>]+\\/?s*>/) then # skip HTML tags\n html << s.matched\n when s.scan(/\\\\(\\S)/) then # unhandled suppressed crossref\n html << s[1]\n after_word = nil\n when s.scan(/\\.\\.\\.(\\.?)/) then\n html << s[1] << encoded[:ellipsis]\n after_word = nil\n when s.scan(/\\(c\\)/i) then\n html << encoded[:copyright]\n after_word = nil\n when s.scan(/\\(r\\)/i) then\n html << encoded[:trademark]\n after_word = nil\n when s.scan(/---/) then\n html << encoded[:em_dash]\n after_word = nil\n when s.scan(/--/) then\n html << encoded[:en_dash]\n after_word = nil\n when s.scan(/"|\"/) then\n html << encoded[indquotes ? :close_dquote : :open_dquote]\n indquotes = !indquotes\n after_word = nil\n when s.scan(/``/) then # backtick double quote\n html << encoded[:open_dquote]\n after_word = nil\n when s.scan(/(?:'|'){2}/) then # tick double quote\n html << encoded[:close_dquote]\n after_word = nil\n when s.scan(/`/) then # backtick\n if insquotes or after_word\n html << '`'\n after_word = false\n else\n html << encoded[:open_squote]\n insquotes = true\n end\n when s.scan(/'|'/) then # single quote\n if insquotes\n html << encoded[:close_squote]\n insquotes = false\n elsif after_word\n # Mary's dog, my parents' house: do not start paired quotes\n html << encoded[:close_squote]\n else\n html << encoded[:open_squote]\n insquotes = true\n end\n\n after_word = nil\n else # advance to the next potentially significant character\n match = s.scan(/.+?(?=[<\\\\.(\"'`&-])/) #\"\n\n if match then\n html << match\n after_word = match =~ /\\w$/\n else\n html << s.rest\n break\n end\n end\n end\n\n html\n end",
"def preprocessMarkdownForHTML(markdown)\n output = \"\"\n inInstructions = false\n \n markdown.split(\"\\n\").each do |line|\n # parse an instructions list\n # use a dummy HTML tag so our final regex doesn't get stuck in an infinite loop replacing itself\n instructionsMatch = line.match(/^>>\\s*(.*?)$/)\n if instructionsMatch\n if not inInstructions\n output += \"<instructions>\\n\"\n end\n output += instructionsMatch[1] + \"\\n\"\n inInstructions = true\n next # don't try to parse anything else\n elsif inInstructions\n output += \"</instructions>\\n\"\n inInstructions = false\n end\n\n # parse headers and page IDs\n headerMatch = line.match(/^(#+)\\s+(.*?)\\s+@@(.*?)$/)\n if headerMatch\n headerLevel = headerMatch[1].length.to_s\n headerTitle = headerMatch[2]\n headerID = headerMatch[3]\n node = nodeWithID(headerID, $doc.toc.rootNode)\n if not node\n puts \"ERROR: Couldn't find node with ID #{headerID}\"\n exit 1\n end\n output += \"<h#{headerLevel}><a name=\\\"#{headerID}\\\">#{node.levelPrefix} #{headerTitle}</a></h#{headerLevel}>\\n\"\n next\n end\n \n # parse links to page IDs and replace with links to the real .htm file\n while 1\n linkMatch = line.match(/\\[.*?\\]\\((@@(.*?))\\)/)\n if linkMatch\n linkID = linkMatch[2]\n linkValue = linkToPageIDFrom(linkID, \"_PAGE_\") # use dummy value\n if not linkValue\n puts \"ERROR: Invalid link ID \\\"#{linkID}\\\"\"\n exit 1\n end\n line[linkMatch[1]] = linkValue\n else\n break\n end\n end\n \n # parse image and label combo\n imgLabelMatch = line.match(/!!\\[(.*?)\\]\\((.*?)\\)/)\n if imgLabelMatch\n label = imgLabelMatch[1]\n imgPath = imgLabelMatch[2]\n \n # read the image and width height to force the size on images for better loading\n # when viewing the files in the boot DVD. there are some issues where anchor jump\n # links don't always jump to the right place on the boot DVD and apparently forcing\n # the image sizes allows the pages to jump properly.\n \t\timgWidth = 0\n \t\timgHeight = 1\n \t\tbegin\n \t\t data = nil\n \t\t if (imgPath =~ /.png$/)\n \t\t data = IO.read($pagesDir + \"/\" + imgPath, 8, 16).unpack('NN')\n\t\t else\n\t\t puts \"ERROR: Unsupported image type: #{imgPath}\"\n\t\t exit 1\n\t end\n \t\t if (data)\n \t\t imgWidth = data[0]\n \t\t imgHeight = data[1]\n\t\t end\n\t\t rescue\n\t end\n imgWidthHeightAttrs = \"\"\n if imgWidth != 0 and imgHeight != 0\n imgWidthHeightAttrs = \" width=\\\"#{imgWidth}\\\" height=\\\"#{imgHeight}\\\"\"\n end\n\n output += \"<p class=\\\"imageAndLabel\\\"><img src=\\\"#{imgPath}\\\" alt=\\\"\" + CGI::escapeHTML(label) + \"\\\"#{imgWidthHeightAttrs}/><br/><em>\" + CGI::escapeHTML(label) + \"</em></p>\\n\"\n next\n end\n \n # parse warning paragraphs\n warningMatch = line.match(/^!!\\s+(.*?)$/)\n if warningMatch\n output += \"<warning>\\n\" + warningMatch[1] + \"\\n<\\/warning>\\n\"\n next\n end\n \n output += line + \"\\n\"\n end\n \n # close off an open instructions div\n if inInstructions\n output += \"</instructions>\\n\"\n end\n \n # Markdown doesn't allow processing of markup within block-level tags such as <div>, so we have to manually process the markup.\n # We call preprocessMarkdownForHTML() to properly process our custom markup within these custom block elements.\n # An extra newline is added to force a paragraph\n while 1\n instructionsMatch = output.match(/(<instructions>)(.*?)(<\\/instructions>)/m)\n if instructionsMatch\n output[instructionsMatch[1]] = \"<div class=\\\"instructions\\\">\"\n output[instructionsMatch[2]] = markdownToHTML(preprocessMarkdownForHTML(\"\\n\"+instructionsMatch[2]))\n output[instructionsMatch[3]] = \"</div>\"\n else\n break\n end\n end\n \n while 1\n warningMatch = output.match(/(<warning>)\\s*(.*?)(<\\/warning>)/m)\n if warningMatch\n output[warningMatch[1]] = \"<div class=\\\"warning\\\"><div class=\\\"warningBody\\\"><div class=\\\"warningImg\\\"></div><div class=\\\"warningContent\\\">\"\n output[warningMatch[2]] = markdownToHTML(preprocessMarkdownForHTML(\"\\n\"+warningMatch[2]))\n output[warningMatch[3]] = \"</div></div></div>\"\n else\n break\n end\n end\n \n return output\nend",
"def to_html\n case @markup\n when 'markdown'\n @data_for_output.collect! {|line| BlueCloth.new(line).to_html}\n when 'textile'\n @data_for_output.collect! {|line| RedCloth.new(line).to_html}\n when 'bbcode'\n @data_for_output.collect! {|line| line.bbcode_to_html}\n end\n end",
"def textile content\n require 'RedCloth'\n @textile = RedCloth.new(content).to_html\n end",
"def TeX2htm(text,state=:normal,fname=\"\",sec=\"\")\n sp=proc{|s| $trads[$key.succ!]=s; \"\\\\#{$key} \"}\n mathdisplay=proc{|s|\n sp[TeX2htm(s,:math).h(\"I\").h(\"td\").h(\"tr\").h(\"table\").h(\"center\")]}\n text=text.gsub(/([^\\\\]|^)%.*/){m=$~;m[1]} # suppress tex comments\n unless state==:math\n text.gsub!(/\\\\$/,\"\\\\ \")\n vb=/\\|'\\\\\\|'\\|/ # a | in verbatim\n vb2=/\\|\\s*\\{\\s*\\\\tt\\s*\\\\\\|\\s*\\}\\s*\\|/ # another way for | in verbatim\n vbb=/(?:#{vb2}|#{vb})/o\n text.gsub!(/([^\\\\]|^|\\\\\\\\)\\|((?:[^|]|#{vbb})*)\\|/om){ m=$~\n if m[2]=~/\\n/\n m[1]+sp[m[2].gsub(vbb,\"|\").lines.map{|l| v=l.split(\"#\");\n\tv[0].gsub!(/&/,\"#\");v[0].gsub!(/</,\"<\");\n\tif v[1] then v[1]=TeX2htm(v[1]); v.join(\"#\")\n\telse v[0]\n\tend}.join.h(\"pre\")]\n else m[1]+sp[m[2].gsub(vbb,\"|\").gsub(/&/,\"#\").gsub(/</,\"<\").clean.h(\"code\")]\n end\n }\n text.gsub!(/\\$\\$(.*?)\\$\\$/m){m=$~; mathdisplay[m[1]]}\n text.gsub!(/\\\\\\[(.*?)\\\\\\]/m){m=$~; mathdisplay[m[1]]}\n text.gsub!(/([^\\\\]|^)\\$(.*?)\\$/m){m=$~\n m[1]+sp[TeX2htm(m[2],:math).h(\"I\")]}\n text.gsub!(/([^\\\\]|^)\\*([^*]*)([^\\\\])\\*/){m=$~;\n m[1]+sp[(m[2]+m[3]).h(\"strong\")]}\n end\n text.gsub!(/\\\\\\\\/){\"\\\\cr\"}\n text.gsub!(/([^\\\\])<([^>]*)>/m){m=$~;m[1]+sp[TeX2htm(m[2]).h(\"var\")]}\n text.gsub!(/([^\\\\]|^)'((?:[^']|\\\\')*)([^\\\\])'/m){m=$~;\n m[1]+sp[(m[2]+m[3]).clean.h(\"code\")]}\n text.gsub!(/([^\\\\]|^)\\\\([*{}|': <>;,#~-])/){m=$~;m[1]+sp[OneChar[m[2]]]}\n text.gsub!(/([^\\\\]|^)\\\\([*{}|': <>;,#~-])/){m=$~;m[1]+sp[OneChar[m[2]]]}\n unless state==:math\n text.gsub!(/^\\s*$/,\"\\\\par\")\n text.gsub!(/^\\s*\\\\vspace\\{[^}]*\\}\\s*$/,\"\\\\par\")\n text.gsub!(/^([^:\\n]*)([^\\\\]):(.*?)(?=\\\\par)/m){m=$~\n sp[\"<DL><DT>#{TeX2htm(m[1]+m[2])}:<DD>\"]+\"#{m[3]}\"+sp[\"</DL>\"]}\n text.gsub!(/\\\\cr/){sp[\"<BR>\"]}\n # characters that can appear in a cross reference\n text.gsub!(/([^\\\\]|^)\"([\\w\\s.$-]*)\"/m){m=$~;\n m[1]+sp[\"<a href=\\\"#{name2fn m[2]}\\\">#{m[2]}</a>\"]}\n text.gsub!(/\\\\\"/){sp['\"']}\n text.gsub!(/\\\\cite(?:\\[([^\\]\\[]*)\\])?\\s*\\{\\s*((?:\\w|,)+)\\s*\\}/m) { m=$~\n r=\"<A href=\\\"biblio.htm##{m[2].split(\",\")[0]}\\\">#{m[2].h(\"cite\")}</a>\"\n r<< \", \"+m[1] if m[1]\n sp[r] }\n text.gsub!(/\\\\accent\\s*([0-9]*)\\s*([a-zA-Z])/m){m=$~\n a=Accents[m[1]+m[2]]\n if a then a\n else $err.print \"** unhandled accent #{fname}:#{sec} #{m[0]}\\n\"\n end}\n text.gsub!(/\\\\psubsection\\s*\\{(.*?)\\}/m){m=$~; m[1].h(\"h3\")}\n text.gsub!(/\\\\psection\\s*\\{(.*?)\\}/m){m=$~;m[1].h(\"h1\").style(\"color:#ff0000\")}\n text.gsub!(/\\\\index\\s*\\{(.*?)\\}/m){m=$~\n $indexcount+=1 # emit an anchor and remember the index keys for later\n r=m[1].gsub(/\\\\([a-zA-Z]+) /){m=$~; $trads[m[1]] || \"\\\\#{m[1]} \"}\n $index[r]=$index[r].push([\"#{fname}#I#{$indexcount}\",\"#{sec.chapnum}.#{sec.secnum}\"])\n \"<A name = \\\"I#{$indexcount}\\\"></a>\\n\"\n }\n text.gsub!(/\\\\begin\\{([^}]*)\\}(.*?)\\\\end\\{\\1\\}/m){m=$~\n case m[1]\n when \"displaymath\",\"equation\" then mathdisplay[m[2]]\n when \"center\" then m[2].h(\"center\")\n when \"itemize\",\"enumerate\" then m[2]\n else \"{beg-\"+m[1]+\"}\".h(\"s\")+m[2]+\"{end-\"+m[1]+\"}\".h(\"s\")\n end}\n text.gsub!(/~/,\" \")\n end\n# nestedbraces=// # can define but not recognized inside another regexp\n# text.gsub!(/\\\\(\\s)/){m=$~;m[1]}\n text.gsub!(/\\{\\s*\\\\(?:sl|it)([^}]*)\\}/m){m=$~;\n sp[TeX2htm(m[1],state).h(\"I\")]}\n text.gsub!(/\\{\\s*\\\\cal([^}]*\\{[^}]*\\}[^}]*)\\}/m){sp[$~[1].style(\"font-family: cursive\")]}\n text.gsub!(/\\{\\s*\\\\cal([^}]*)\\}/m){sp[$~[1].style(\"font-family: cursive\")]}\n text.gsub!(/\\{\\s*\\\\tt([^}]*\\{[^}]*\\}[^}]*)\\}/m){m=$~;sp[m[1].h(\"code\")]}\n text.gsub!(/\\{\\s*\\\\tt([^}]*)\\}/m){m=$~;sp[m[1].h(\"code\")]}\n text.gsub!(/\\{\\s*\\\\bf([^}]*\\{[^}]*\\}[^}]*)\\}/m){m=$~;sp[m[1].h(\"strong\")]}\n text.gsub!(/\\{\\s*\\\\bf([^}]*)\\}/m){m=$~;sp[m[1].h(\"strong\")]}\n text.gsub!(/\\{\\s*\\\\em([^}]*\\{[^}]*\\}[^}]*)\\}/m){m=$~;sp[m[1].h(\"em\")]}\n text.gsub!(/\\{\\s*\\\\em([^}]*)\\}/m){m=$~;sp[m[1].h(\"em\")]}\n if state==:math\n text.gsub!(/</){sp[\"<\"]}\n text.gsub!(/>/){sp[\">\"]}\n texarg=/([^{\\\\]|\\{(?:(?:[^{}]|\\{[^{}]*\\})*)\\}|\\\\[a-zA-Z]+)/\n text.gsub!(/\\^\\\\prime/om){sp[\"'\"]}\n text.gsub!(/\\^\\{\\\\prime\\\\prime\\}/om){sp[\"''\"]}\n text.gsub!(/\\\\not\\s*\\\\equiv/om){sp[\"≢\"]}\n text.gsub!(/\\\\(?:text|mbox|hbox)\\{([^{}]*)\\}/){m=$~;\n sp[TeX2htm(m[1]).h(\"/i\")]}\n text.gsub!(/\\^\\s*#{texarg}/om){m=$~;sp[TeX2htm(m[1],:math).h(\"sup\")]}\n text.gsub!(/_\\s*#{texarg}/om){m=$~;sp[TeX2htm(m[1],:math).h(\"sub\")]}\n text.gsub!(/\\\\underline\\s*#{texarg}/om){m=$~;sp[TeX2htm(m[1],:math).h(\"u\")]}\n text.gsub!(/\\\\overline\\s*#{texarg}/om){m=$~;\n sp['<span style=\"text-decoration: overline\">'+\n TeX2htm(m[1],:math)+\"<\\/span>\"]}\n text.gsub!(/\\{\\s*\\\\rm([^}]*)\\}/m){m=$~;sp[m[1].h(\"I\")]}\n text.gsub!(/\\{\\s*\\\\mathcal([^}]*)\\}/m){m=$~;sp[m[1].h(\"u\")]}\n text.gsub!(/\\\\frac#{texarg}#{texarg}/om){m=$~;\n n=TeX2htm(m[1],'math'); d=TeX2htm(m[2],'math')\n n=\"(#{n})\" if n.length>1\n d=\"(#{d})\" if n.length>1\n \"#{n}/#{d}\"}\n text.gsub!(/\\\\not\\s*\\\\in/){sp[\"∉\"]}\n text.gsub!(/\\\\not\\s*=/){sp[\"≠\"]}\n text.gsub!(/\\\\([a-zA-Z]+)/){m=$~;\n if MathMacs[m[1]] then sp[MathMacs[m[1]]] else m[0] end}\n text.gsub!(/\\\\pmod\\s*#{texarg}/){m=$~;sp[\"(</i>mod<i> #{TeX2htm(m[1],:math)})\"]}\n text.gsub!(/\\\\begin\\{([^}]*)\\}(.*?)\\\\end\\{\\1\\}/m){m=$~\n case m[1]\n when \"array\",\"pmatrix\" then \n if m[1]==\"array\" then r=m[2].sub(/\\{[cl]*\\}/,\"\") else r=m[2] end\n r=r.split(\"\\\\cr\").map{|l| l.split(\"&\").map{|i| \n i.h(\"I\").h(\"td\")}.join(\"\").h(\"tr\")}.join.h('table style=\"display:inline-table;\"').h(\"td\").h(\"/td\")\n if m[1]==\"pmatrix\" then \"(\"+r+\")\" else r end\n else \"{beg-\"+m[1]+\"}\".h(\"s\")+m[2]+\"{end-\"+m[1]+\"}\".h(\"s\")\n end\n }\n end\n text.gsub!(/\\\\(?:text|mbox|hbox)\\{([^{}]*)\\}/){m=$~;\n sp[TeX2htm(m[1]).h(\"/i\")]}\n text.gsub!(/\\\\([a-zA-Z]+)/){m=$~;AlwaysMacs[m[1]] || m[0]}\n text.gsub!(/\\{([^{}]*)\\}/){m=$~; m[1]}\n text.gsub!(/\\\\([a-zA-Z]+) /){m=$~; $trads[m[1]] || \"\\\\#{m[1]} \"}\n text.gsub!(/\\\\([a-zA-Z]+) /){m=$~; $trads[m[1]] || \"\\\\#{m[1]} \"}\n text.gsub!(/\\\\([a-zA-Z]+)/){m=$~; $trads[m[1]] || \"\\\\#{m[1]}\"}\n text.scan(/\\\\([a-zA-Z]+)/){|m| $err.print \"!!!!! #{m.inspect} state=#{state}\\n\"}\n text\nend",
"def to_html( *rules )\n rules = DEFAULT_RULES if rules.empty?\n # make our working copy\n text = self.dup\n \n @urlrefs = {}\n @shelf = []\n textile_rules = [:block_textile_table, :block_textile_lists,\n :block_textile_prefix, :inline_textile_image, :inline_textile_link,\n :inline_textile_code, :inline_textile_span, :glyphs_textile]\n markdown_rules = [:refs_markdown, :block_markdown_setext, :block_markdown_atx, :block_markdown_rule,\n :block_markdown_bq, :block_markdown_lists, \n :inline_markdown_reflink, :inline_markdown_link]\n @rules = rules.collect do |rule|\n case rule\n when :markdown\n markdown_rules\n when :textile\n textile_rules\n else\n rule\n end\n end.flatten\n\n # standard clean up\n incoming_entities text \n clean_white_space text \n\n # start processor\n @pre_list = []\n rip_offtags text\n no_textile text\n escape_html_tags text\n hard_break text \n unless @lite_mode\n refs text\n # need to do this before text is split by #blocks\n block_textile_quotes text\n blocks text\n end\n inline text\n smooth_offtags text\n\n retrieve text\n\n text.gsub!( /<\\/?notextile>/, '' )\n text.gsub!( /x%x%/, '&' )\n clean_html text if filter_html\n text.strip!\n text\n\n end",
"def fix_html(ary)\n text = \"\"\n\n ary.each do |s|\n temp = s.gsub('<', '<').gsub('>', '>')\n temp = temp.gsub('&b', '<b>').gsub('&/b', '</b>')\n temp = temp.gsub('&i', '<i>').gsub('&/i', '</i>')\n\n text += \" #{temp}<br />\\n\"\n end\n\n return text\nend",
"def process_markdown\n self.data = self.class.convert_markdown(self.data)\n sanitize_html\n end",
"def html_markup_org(text); end",
"def html_markup_asciidoc(text); end",
"def text_to_html (text, args = {})\n args = { emotes: false, map_headings: 1 }.merge args\n \n html = Moredown.text_to_html(text, args)\n html.gsub!('src=\"media/', 'src=\"/media/')\n html.gsub!(/<pre><code>#! (.*?)\\n([^<]*?)<\\/code><\\/pre>/) { |match| \"<pre><code class=\\\"#{$1.downcase.strip}\\\">#{$2.strip}</code></pre>\" }\n \n html\n end",
"def conv_html(txt)\n case txt\n when Array\n txt.join.\n gsub(/>/, '>').\n gsub(/</, '<').\n gsub(/"/, '\"').\n gsub(/&/, '&')\n else # it's a String\n txt.\n gsub(/>/, '>').\n gsub(/</, '<').\n gsub(/"/, '\"').\n gsub(/&/, '&')\n end\n end",
"def setup\n @html = <<-TEXTILE\n<h1>Give RedCloth a try!</h1>\n<p>A <strong>simple</strong> paragraph with<br />\na line break, some <em>emphasis</em> and a <a href=\"http://redcloth.org\">link</a></p>\n<ul>\n\t<li>an item</li>\n\t<li>and another</li>\n</ul>\n<ol>\n\t<li>one</li>\n\t<li>two</li>\n</ol>\nTEXTILE\n \n end",
"def html_to_bbcode(string); end",
"def markup text\n document = parse text\n\n document.accept formatter\n end",
"def bbcode_to_html(string); end",
"def parse_html(string)\n t = Tag.new\n tag = string.match(TAG_R).captures.to_s #returns an array\n t.type = tag[0]\n str_class = string.match(CLASS_R).captures #already an array\n t.classes = str_class.join.split(\" \")\n t.id = string.match(ID_R).captures[0]\n t.name = string.match(NAME_R).captures[0]\n t\n end",
"def wrap(html); end",
"def wrap(html); end",
"def html(s)\n convert(s, mime: 'text/html')\n end",
"def html(text)\n scan(text, HTML, :html)\n end",
"def gfm(text, html_options = {})\n return text if text.nil?\n\n # Duplicate the string so we don't alter the original, then call to_str\n # to cast it back to a String instead of a SafeBuffer. This is required\n # for gsub calls to work as we need them to.\n text = text.dup.to_str\n\n @html_options = html_options\n\n # Extract pre blocks so they are not altered\n # from http://github.github.com/github-flavored-markdown/\n text.gsub!(%r{<pre>.*?</pre>|<code>.*?</code>}m) { |match| extract_piece(match) }\n # Extract links with probably parsable hrefs\n text.gsub!(%r{<a.*?>.*?</a>}m) { |match| extract_piece(match) }\n # Extract images with probably parsable src\n text.gsub!(%r{<img.*?>}m) { |match| extract_piece(match) }\n\n # TODO: add popups with additional information\n\n text = parse(text)\n\n # Insert pre block extractions\n text.gsub!(/\\{gfm-extraction-(\\h{32})\\}/) do\n insert_piece($1)\n end\n\n sanitize text.html_safe, attributes: ActionView::Base.sanitized_allowed_attributes + %w(id class), tags: ActionView::Base.sanitized_allowed_tags + %w(table tr td th)\n end",
"def html2text(html)\n html ||= \"\" # ensure string is non-nil\n text = html.\n gsub(/( |\\n|\\s)+/im, ' ').squeeze(' ').strip.\n gsub(/<([^\\s]+)[^>]*(src|href)=\\s*(.?)([^>\\s]*)\\3[^>]*>\\4<\\/\\1>/i, '\\4')\n\n linkregex = /<[^>]*(src|href)=\\s*(.?)([^>\\s]*)\\2[^>]*>\\s*/i\n while linkregex.match(text)\n text.sub!(linkregex, \"\")\n end\n \n text = CGI.unescapeHTML(\n text.\n gsub(/<(script|style)[^>]*>.*<\\/\\1>/im, '').\n gsub(/<!--.*-->/m, '').\n gsub(/<hr(| [^>]*)>/i, \"___\\n\").\n gsub(/<li(| [^>]*)>/i, \"\\n* \").\n gsub(/<blockquote(| [^>]*)>/i, '> ').\n gsub(/<(br)(| [^>]*)>/i, \"\\n\").\n gsub(/<(\\/h[\\d]+|p)(| [^>]*)>/i, \"\\n\\n\").\n gsub(/<[^>]*>/, '')\n ).lstrip.gsub(/\\n[ ]+/, \"\\n\") + \"\\n\"\n\n converted = []\n text.split(//).collect { |c| converted << ( c[0] > 127 ? \"&##{c[0]};\" : c ) }\n converted.join('')\n end",
"def conv_html(txt)\n txt.\n gsub(/>/, '>').\n gsub(/</, '<').\n gsub(/"/, '\"').\n gsub(/&/, '&')\n \n end",
"def description_html\n convert_html description\n end",
"def convert_html(str, attrs, exclusive = false)\n tags = @html_tags.select { |start, bitmap|\n exclusive == exclusive?(bitmap)\n }.keys.join '|'\n\n 1 while str.gsub!(/<(#{tags})>(.*?)<\\/\\1>/i) { |orig|\n attr = @html_tags[$1.downcase]\n html_length = $1.length + 2\n seq = NULL * html_length\n attrs.set_attrs($`.length + html_length, $2.length, attr)\n seq + $2 + seq + NULL\n }\n end",
"def html2text(html)\n\n result = ''\n begin\n web_doc = Hpricot(html)\n web_doc.search(\"//comment()\").remove\n web_doc.search(\"script\").remove\n web_doc.search(\"style\").remove\n web_doc.search(\"noscript\").remove\n web_doc.search(\"object\").remove\n web_doc.search(\"embed\").remove\n web_doc.search(\"head\").remove\n\n web_doc.traverse_text do |e| \n\n begin\n if e.content\n result += e.content+\"\\n\"\n end\n rescue\n # ignore errors\n end\n end\n rescue Exception => e\n # ignore errors\n warn \"html2text() - Exception '#{e.message}' trying to parse '#{html}'\"\n end\n\n if result == ''\n # Use a simple regular-expression approach to remove all tags\n result = html.gsub(/<[^>]*>/, '')\n end\n\n coder = HTMLEntities.new\n result = coder.decode(result)\n\n result.gsub!(/\\n[\\r\\n \\t]*/, \"\\n\")\n\n result\nend",
"def textile( content )\n return if content.nil? or content.empty?\n #( ::RedCloth::TEXTILE_TAGS << [ 96.chr, '&8216;'] ).each do |pat,ent|\n # content.gsub!( pat, ent.gsub('&','&#') )\n #end\n self << ::RedCloth.new( content ).to_html\n end",
"def process_markup()\n [title,content].each do |text|\n next if !text\n clear_webpage(text).scan(PTN_MARKUP).map{|e|e[0].split(PTN_ELEMENT_SEP)}.flatten.each do |element|\n #debug \"[process_markup] element: \"+element.inspect\n next if !element\n ptn = element.scan(PTN_METADATA)\n #debug \"[process_markup] ptn: \"+ptn.inspect\n if ptn.size > 0\n m[ptn[0][0].to_sym] = parse_value(ptn[0][1])\n else\n create_and_link(element, 'tag' , \"t\")\n #add_tags(element, \"m\")\n end\n end#scan\n end#each\n end",
"def textilize(do_object_links=false)\n\n # This converts the \"_object blah_\" constructs into \"x{OBJECT id label}x\".\n # (The \"x\"s prevent Textile from interpreting the curlies as style info.)\n if do_object_links\n check_name_links!\n check_other_links!\n check_our_images!\n end\n\n # Let Textile munge the thing up now.\n replace(RedCloth.new(self).to_html)\n\n # Remove pre-existing links first, replacing with \"<XXXnn>\".\n hrefs = []\n gsub!(/(<a[^>]*>.*?<\\/a>|<img[^>]*>)/) do |href|\n if do_object_links\n href = href.gsub(/\n x\\{([A-Z]+) \\s+ ([^\\{\\}]+?) \\s+\\}\\{\\s+ ([^\\{\\}]+?) \\s+\\}x\n /x, '\\\\2')\n end\n hrefs.push(href)\n \"<XXX#{hrefs.length - 1}>\"\n end\n\n # Now turn bare urls into links.\n gsub!(/([a-z]+:\\/\\/([^\\s<>]|<span class=\"caps\">[A-Z]+<\\/span>)+)/) do |url|\n url1 = url.gsub(/<span class=\"caps\">([A-Z]+)<\\/span>/, '\\\\1')\n extra = url1.sub!(/([^\\w\\/]+$)/, '') ? $1 : ''\n url2 = ''\n if url1.length > URL_TRUNCATION_LENGTH and not url1.starts_with?(HTTP_DOMAIN)\n if url1.match(/^(\\w+:\\/\\/[^\\/]+)(.*?)$/)\n url2 = $1 + '/...'\n else\n url2 = url1[0..URL_TRUNCATION_LENGTH] + '...'\n end\n else\n url2 = url1\n end\n url1.gsub!(/([ \"%<>\\\\])/) {URI_ESCAPE[$1]}\n \"<a href=\\\"#{url1}\\\">#{url2}</a>\" + extra\n end\n\n # Convert _object_ tags into proper links.\n if do_object_links\n gsub!(/\n x\\{([A-Z]+) \\s+ ([^\\{\\}]+?) \\s+\\}\\{\\s+ ([^\\{\\}]+?) \\s+\\}x\n /x) do |orig|\n type, label, id = $1, $2, $3\n id.gsub!(/([ \"%?=&<>\\\\])/) {URI_ESCAPE[$1]}\n url = \"#{HTTP_DOMAIN}/observer/lookup_#{type.downcase}/#{id}\"\n \"<a href=\\\"#{url}\\\">#{label}</a>\"\n end\n end\n\n # Make sure all links are fully-qualified.\n gsub!(/href=\"\\//, \"href=\\\"#{HTTP_DOMAIN}/\")\n\n # Put pre-existing links back in (removing the _object_ tag wrappers).\n gsub!(/<XXX(\\d+)>/) do\n hrefs[$1.to_i].to_s.gsub(/ x\\{ ([^\\{\\}]*) \\}x /x, '\\\\1')\n end\n\n return self\n end",
"def html_parser; end",
"def to_markdown(html, _options = {})\n cleaned = html.scrub\n cleaned = pre_sanitize(cleaned)\n cleaned = Sanitize.fragment(cleaned, HTML_SANITIZATION_CONFIG)\n Kramdown::Document.new(cleaned, input: :html).to_kramdown.strip\n rescue\n 'The description could not be imported, the most likely cause of this is that it contained illegal HTML markup'\n end",
"def to_textile\n headings(@workingcopy)\n structure(@workingcopy)\n text_formatting(@workingcopy)\n entities(@workingcopy)\n tables(@workingcopy)\n @workingcopy = lists(@workingcopy)\n image_links(@workingcopy)\n links(@workingcopy)\n @workingcopy = CGI::unescapeHTML(@workingcopy)\n @workingcopy\n end",
"def inline_html(text)\n # process simple inlines\n for inline in INLINES_HTML\n text.gsub!(/#{inline[0]}/m, inline[1]) if text.match(/#{inline[0]}/m)\n end\n # process link inlines\n if text.match(LINKS_REGEXP)\n text.gsub!(LINKS_REGEXP) do |string|\n match = string.match(LINKS_REGEXP)\n before = match[1]\n body = match[2]\n after = match[3]\n parts = body.split(' ')\n if parts.length > 1\n url = parts.first\n link = parts[1..-1].join(' ')\n else\n url = body\n link = body\n end\n \"#{before}<a href='#{url}'>#{link}</a>#{after}\"\n end\n end\n # process note inlines\n if text.match(NOTES_REGEXP)\n text.gsub!(NOTES_REGEXP) do |string|\n match = string.match(NOTES_REGEXP)\n before = match[1]\n body = match[2]\n after = match[3]\n @document.notes << body\n index = @document.notes.length\n \"#{before}<a href='#note#{index}' name='source#{index}'>\"+\n \"[#{index}]</a>#{after}\"\n end\n end\n # process escapes (that is \\x is replaced with x)\n text.gsub!(/\\\\(.)/, \"\\\\1\") if text.match(/\\\\(.)/)\n text\n end",
"def tp(sanitize = true)\n Textile.textile_div_safe do\n Textile.textilize(self, do_object_links: false, sanitize: sanitize)\n end\n end",
"def process_html(html)\r\n html = email_process(html)\r\n process_menu(html)\r\n end",
"def deco_textilizable(*args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n case args.size\n when 1\n obj = options[:object]\n text = args.shift\n when 2\n obj = args.shift\n attr = args.shift\n text = obj.send(attr).to_s\n else\n raise ArgumentError, 'invalid arguments to textilizable'\n end\n return '' if text.blank?\n project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)\n only_path = options.delete(:only_path) == false ? false : true\n\n text = text.dup\n\n ####add custom\n tmp_text = deco_block_textile_quotes(text)\n if(tmp_text) then\n text = tmp_text\n else\n text = text.dup\n end\n ####\n\n macros = catch_macros(text)\n text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr)\n\n @parsed_headings = []\n @heading_anchors = {}\n @current_section = 0 if options[:edit_section_links]\n\n parse_sections(text, project, obj, attr, only_path, options)\n text = parse_non_pre_blocks(text, obj, macros) do |text|\n [:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name|\n send method_name, text, project, obj, attr, only_path, options\n end\n end\n parse_headings(text, project, obj, attr, only_path, options)\n\n if @parsed_headings.any?\n replace_toc(text, @parsed_headings)\n end\n\n text.html_safe\n end",
"def ae_some_html(s)\n return '' if s.nil? \n \n # converting newlines\n s.gsub!(/\\r\\n?/, \"\\n\")\n \n # escaping HTML to entities\n s = s.to_s.gsub('&', '&').gsub('<', '<').gsub('>', '>')\n \n # blockquote tag support\n s.gsub!(/\\n?<blockquote>\\n*(.+?)\\n*<\\/blockquote>/im, \"<blockquote>\\\\1</blockquote>\")\n \n # other tags: b, i, em, strong, u\n %w(b i em strong u).each { |x|\n s.gsub!(Regexp.new('<(' + x + ')>(.+?)</('+x+')>',\n Regexp::MULTILINE|Regexp::IGNORECASE), \n \"<\\\\1>\\\\2</\\\\1>\")\n }\n \n # A tag support\n # href=\"\" attribute auto-adds http://\n s = s.gsub(/<a.+?href\\s*=\\s*['\"](.+?)[\"'].*?>(.+?)<\\/a>/im) { |x|\n '<a href=\"' + ($1.index('://') ? $1 : 'http://'+$1) + \"\\\">\" + $2 + \"</a>\"\n }\n \n # replacing newlines to <br> ans <p> tags\n # wrapping text into paragraph\n s = \"<p>\" + s.gsub(/\\n\\n+/, \"</p>\\n\\n<p>\").\n gsub(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') + \"</p>\"\n \n s \n end",
"def ae_some_html(s)\n return '' if s.nil? \n \n # converting newlines\n s.gsub!(/\\r\\n?/, \"\\n\")\n \n # escaping HTML to entities\n s = s.to_s.gsub('&', '&').gsub('<', '<').gsub('>', '>')\n \n # blockquote tag support\n s.gsub!(/\\n?<blockquote>\\n*(.+?)\\n*<\\/blockquote>/im, \"<blockquote>\\\\1</blockquote>\")\n \n # other tags: b, i, em, strong, u\n %w(b i em strong u).each { |x|\n s.gsub!(Regexp.new('<(' + x + ')>(.+?)</('+x+')>',\n Regexp::MULTILINE|Regexp::IGNORECASE), \n \"<\\\\1>\\\\2</\\\\1>\")\n }\n \n # A tag support\n # href=\"\" attribute auto-adds http://\n s = s.gsub(/<a.+?href\\s*=\\s*['\"](.+?)[\"'].*?>(.+?)<\\/a>/im) { |x|\n '<a href=\"' + ($1.index('://') ? $1 : 'http://'+$1) + \"\\\">\" + $2 + \"</a>\"\n }\n \n # replacing newlines to <br> ans <p> tags\n # wrapping text into paragraph\n s = \"<p>\" + s.gsub(/\\n\\n+/, \"</p>\\n\\n<p>\").\n gsub(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') + \"</p>\"\n \n s \n end",
"def as_html_deprecated #use TextEncoder.convert_to_html instead.\n return self if self.blank?\n mytext = self\n #mytext = CGI.escapeHTML(mytext)\n mytext.gsub!(NpbConstants::URL_DETECTION){|web_link| %{ <a href=\"#{web_link.strip}\">#{web_link.strip}</a> }}\n #mytext.gsub!(NpbConstants::EMAIL_DETECTION){|email| %{\\1<a href=\"mailto:#{email.strip}\">#{email.strip}</a>}}\n mytext.gsub!(NpbConstants::EMAIL_DETECTION){|email| %{#{$1}<a href=\"mailto:#{email.strip}\">#{email.strip}</a>}}\n mytext.gsub!(/\\A +/) {|l_spaces| (\" \"*l_spaces.size)} \n mytext.gsub!(/\\n +/) {|l_spaces| (\"\\n\" + (\" \"*(l_spaces.size-1)))}\n mytext.gsub!(/\\n{2,}/,'</p><p>')\n mytext.gsub!(/(\\n)([^\\n])/, '<br/>\\2')\n mytext\n end",
"def convert_markdown\n self.html_content = Raptor::Markdown.render(self.content)\n end",
"def html_to_text html, charset\n ## ignore charset. html2text produces output in the system charset.\n #puts \"; forced to decode html. running #{HTML_CONVERSION_CMD} on #{html.size}b mime part...\"\n content = begin\n Timeout.timeout(HTML_CONVERSION_TIMEOUT) do\n Heliotrope.popen3(HTML_CONVERSION_CMD) do |inn, out, err|\n inn.print html\n inn.close\n out.read\n end\n end\n rescue Timeout::Error\n $stderr.puts \"; warning: timeout when converting message from html to text\"\n \"[html conversion failed on this command (htmlconversionfailure)]\"\n end\n [content, SYSTEM_CHARSET]\n end",
"def html_to_text html, charset\n ## ignore charset. html2text produces output in the system charset.\n #puts \"; forced to decode html. running #{HTML_CONVERSION_CMD} on #{html.size}b mime part...\"\n content = begin\n Timeout.timeout(HTML_CONVERSION_TIMEOUT) do\n Heliotrope.popen3(HTML_CONVERSION_CMD) do |inn, out, err|\n inn.print html\n inn.close\n out.read\n end\n end\n rescue Timeout::Error\n $stderr.puts \"; warning: timeout when converting message from html to text\"\n \"[html conversion failed on this command (htmlconversionfailure)]\"\n end\n [content, SYSTEM_CHARSET]\n end",
"def mark_text(str)\n\t str = clean_html(str)\n\t \n\t return str\n end",
"def html_convert(str)\r\n\t\t#リンク処理\r\n\t\tstr = str.to_s.gsub(/(http[s]?\\:\\/\\/[\\w\\.\\~\\-\\/\\?\\&\\+\\=\\:\\@\\%\\;\\#\\%]+)/) do\r\n\t\t\t\"<a href=\\\"#{$1}\\\" target=\\\"_blank\\\">#{$1}</a>\"\r\n\t\tend\r\n\t\t#@ハンドル名リンク\r\n\t\tstr = str.to_s.gsub(/(\\@)([a-zA-Z0-9_]+)/) do\r\n\t\t\t\"<a href=\\\"http://twitter.com/#{$2}\\\" target=\\\"_blank\\\">#{$1}#{$2}</a>\"\r\n\t\tend\r\n\t\t# #タグリンク\r\n\t\tstr = str.to_s.gsub(/(#)([a-zA-Z0-9]+)/) do\r\n\t\t\t\"<a href=\\\"http://twitter.com/#search?q=%23#{$2}\\\" target=\\\"_blank\\\">#{$1}#{$2}</a>\"\r\n\t\tend\r\n\t\treturn str\r\n\tend",
"def textile_code( tag, atts, cite, content )\n %(<pre><code>#{content}</pre></code>)\n end",
"def plain_html\n self.class.to_html.to_html(text.dup)\n end",
"def htmlClean(html)\n html\nend",
"def scan(string, options = {})\n return string if !options[:converters] or options[:converters].empty?\n\n doc = Nokogiri::HTML.fragment(string)\n\n doc.search('.//text()').each do |el|\n t = el.text\n if t.strip.size > 0\n t = convert(t, options) if convertable?(el)\n end\n el.replace(t)\n end\n\n doc.to_html\n end",
"def convert\n Converters::HtmlConverter.new(input: to_html)\n end",
"def html_markup_pre(text); end",
"def call\n # mode = (context[:gfm] != false) ? :gfm : :markdown\n # html = GitHub::Markdown.to_html(@text, mode)\n # html.rstrip!\n # html\n\n options = context[:redcarpet_options] || {}\n renderer = HtmlWithRouge.new(\n filter_html: options.fetch(:filter_html, false),\n hard_wrap: options.fetch(:hard_wrap, true)\n )\n options.reject! { |k, v| [:filter_html, :hard_wrap].include?(k) }\n markdown = Redcarpet::Markdown.new(renderer, options)\n html = markdown.render(@text)\n html.rstrip!\n html\n end",
"def markdown(text)\n BlueCloth::new(text).to_html\nend",
"def convert_markdown\n # self.content_html = Kramdown::Document.new(content).to_html\n self.content_html = markdown(content)\n end",
"def convert_html(html)\n converter = AhaServices::JiraWikiConverter.new\n converter.convert_html_from_aha(html)\n end",
"def conv_markup(txt)\n txt.\n gsub(%r{<tt>(.*?)</tt>}) { \"+#$1+\" } .\n gsub(%r{<code>(.*?)</code>}) { \"+#$1+\" } .\n gsub(%r{<b>(.*?)</b>}) { \"*#$1*\" } .\n gsub(%r{<em>(.*?)</em>}) { \"_#$1_\" }\n end",
"def textilize_me\n text = self.blurb || ''\n if text && text.respond_to?(:to_s)\n doc = RedCloth.new( text.to_s )\n doc.to_html\n self.converted_to_html = RedCloth.new(doc).to_html\n end\n end",
"def tpl(sanitize = true)\n Textile.textile_div_safe do\n Textile.textilize(self, do_object_links: true, sanitize: sanitize)\n end\n end",
"def html\n return if self.text.blank?\n\n html = self.text\n \n # s = StringScanner.new(self.text)\n # html = ''\n # while markup = s.scan_until(/\\[code/) do\n # html += RedCloth.new(markup[0..-6]).to_html\n # s.pos= s.pos-5\n # code = s.scan_until(/\\[\\/code\\]/)\n # if code\n # code.gsub!(/\\[code\\]/, '[code lang=\"ruby\"]')\n # html += '<div class=\"syntax\">' + Syntaxi.new(code).process + '</div>' \n # else\n # break\n # end\n # end\n # html += RedCloth.new(s.rest).to_html\n \n html\n end",
"def textilize(do_object_links=false, sanitize=true)\n\n # This converts the \"_object blah_\" constructs into \"x{OBJECT id label}x\".\n # (The \"x\"s prevent Textile from interpreting the curlies as style info.)\n if do_object_links\n check_name_links!\n check_other_links!\n check_our_images!\n end\n\n # Let Textile munge the thing up now.\n red = RedCloth.new(self)\n red.sanitize_html = sanitize\n replace(red.to_html)\n\n # Remove pre-existing links first, replacing with \"<XXXnn>\".\n hrefs = []\n gsub!(/(<a[^>]*>.*?<\\/a>|<img[^>]*>)/) do |href|\n if do_object_links\n href = href.gsub(/\n x\\{([A-Z]+) \\s+ ([^\\{\\}]+?) \\s+\\}\\{\\s+ ([^\\{\\}]+?) \\s+\\}x\n /x, '\\\\2')\n end\n hrefs.push(href)\n \"<XXX#{hrefs.length - 1}>\"\n end\n\n # Now turn bare urls into links.\n gsub!(/([a-z]+:\\/\\/([^\\s<>]|<span class=\"caps\">[A-Z]+<\\/span>)+)/) do |url|\n url1 = url.gsub(/<span class=\"caps\">([A-Z]+)<\\/span>/, '\\\\1')\n extra = url1.sub!(/([^\\w\\/]+$)/, '') ? $1 : ''\n url2 = ''\n if url1.length > URL_TRUNCATION_LENGTH and not url1.starts_with?(HTTP_DOMAIN)\n if url1.match(/^(\\w+:\\/\\/[^\\/]+)(.*?)$/)\n url2 = $1 + '/...'\n else\n url2 = url1[0..URL_TRUNCATION_LENGTH] + '...'\n end\n else\n url2 = url1\n end\n # Leave as much untouched as possible, but some characters will cause the HTML\n # to be badly formed, so we need to at least protect those.\n url1.gsub!(/([<>\"\\\\]+)/) { CGI.escape($1) }\n \"<a href=\\\"#{url1}\\\">#{url2}</a>\" + extra\n end\n\n # Convert _object_ tags into proper links.\n if do_object_links\n gsub!(/\n x\\{([A-Z]+) \\s+ ([^\\{\\}]+?) \\s+\\}\\{\\s+ ([^\\{\\}]+?) \\s+\\}x\n /x) do |orig|\n type, label, id = $1, $2, $3\n id.gsub!(/̶[01];/, '\"')\n id = CGI.unescapeHTML(id)\n id = CGI.escape(id)\n url = \"#{HTTP_DOMAIN}/observer/lookup_#{type.downcase}/#{id}\"\n \"<a href=\\\"#{url}\\\">#{label}</a>\"\n end\n end\n\n # Make sure all links are fully-qualified.\n gsub!(/href=\"\\//, \"href=\\\"#{HTTP_DOMAIN}/\")\n\n # Put pre-existing links back in (removing the _object_ tag wrappers).\n gsub!(/<XXX(\\d+)>/) do\n hrefs[$1.to_i].to_s.gsub(/ x\\{ ([^\\{\\}]*) \\}x /x, '\\\\1')\n end\n\n return self\n end",
"def display(text, html_options = nil)\n if html_options\n html_options = html_options.stringify_keys\n tag_options = tag_options(html_options)\n else\n tag_options = nil\n end\n #sanitize(text).to_html.gsub(\"<p>\", \"<p#{tag_options}>\")\n markdown(sanitize(text.gsub(\"\\n\",\"<br/>\"))).gsub(\"<p>\", \"<p#{tag_options}>\")\n end",
"def conv_markup(txt, prefix, linelen)\n\n # this code assumes that tags are not used inside tags\n pos = 0\n old_pos = 0\n style = STYLE_NORMAL\n current_indent = prefix.size\n while pos = txt.index(%r{(<tt>|<code>|<b>|<em>|</tt>|</code>|</b>|</em>)}, old_pos)\n new_part = txt[old_pos...pos]\n @proc.call(new_part, style)\n\n # get tag name\n old_pos = txt.index(\">\", pos) + 1\n style = case txt[(pos+1)...(old_pos-1)]\n when \"tt\"\n STYLE_TELETYPE\n when \"code\"\n STYLE_CODE\n when \"b\"\n STYLE_BOLD\n when \"em\"\n STYLE_EMPHASIS\n else\n # closing or unknown tags\n STYLE_NORMAL\n end\n end\n @proc.call(txt[old_pos...txt.size], style)\n @proc.call(\"\\n\")\n end",
"def substitute_markdown_inside_raw_html\n each_element(:raw_html) do |e|\n html = e.parsed_html\n next unless html\n\n html.process_markdown_inside_elements(self)\n end\n end",
"def textile_attribute(*attribute_names, **options)\n markup_attribute(*attribute_names, **options.merge(markup: :textile))\n end",
"def plain_text(html)\n HtmlToPlainText.plain_text(html)\n end",
"def block_textile_table( text ) \n text.gsub!( TABLE_RE ) do |matches|\n\n caption, id, tatts, fullrow = $~[1..4]\n tatts = pba( tatts, 'table' )\n tatts = shelve( tatts ) if tatts\n rows = []\n\n fullrow.\n split( /\\|$/m ).\n delete_if {|row|row.empty?}.\n each do |row|\n\n ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\\. )(.*)/m\n row << \" \"\n \n cells = []\n row.split( '|' ).each_with_index do |cell, i|\n next if i == 0\n \n ctyp = 'd'\n ctyp = 'h' if cell =~ /^_/\n\n catts = ''\n catts, cell = pba( $1, 'td' ), $2 if cell =~ /^(_?#{S}#{A}#{C}\\. ?)(.*)/\n\n catts = shelve( catts ) if catts\n cells << \"\\t\\t\\t<t#{ ctyp }#{ catts }>#{ cell.strip.empty? ? \" \" : row.split( '|' ).size-1 != i ? cell : cell[0...cell.length-1] }</t#{ ctyp }>\"\n end\n ratts = shelve( ratts ) if ratts\n rows << \"\\t\\t<tr#{ ratts }>\\n#{ cells.join( \"\\n\" ) }\\n\\t\\t</tr>\"\n end\n caption = \"\\t<p class=\\\"caption\\\">#{caption}</p>\\n\" if caption\n \"#{caption}\\t<table#{ tatts }>\\n#{ rows.join( \"\\n\" ) }\\n\\t</table>\\n\\n\"\n end\n end",
"def convert_html_to_text html\n # lynx's -dump option requires a *.html file\n require 'tempfile'\n tmp_file = Tempfile.new('inochi').path + '.html'\n\n begin\n File.write tmp_file, html.to_s.\n #\n # add space between list items to improve readability\n #\n gsub(/(?=<li>)/, '<p> </p>')\n\n `lynx -dump #{tmp_file} -width 70`\n ensure\n File.delete tmp_file\n end\nend",
"def to_md\n # Usually ruby is extremely readable, but I think \"-1\" means \"give me all the \n # trailing blank lines\" is surprisingly opaque. That's what the -1 does...\n lines = @text.split(\"\\n\", -1)\n lines.collect do |line|\n result = line\n \n # Leave lines that start with 4 spaces alone. These are code blocks and\n # should pass through unchanged.\n unless result =~ /^\\s{4,}/\n \n # Convert headers\n result.sub!(/^(=){1,6}/) { |s| \"#\" * s.length} unless result =~ /^={7,}/\n \n # Convert strong to have two stars\n # The matching pair of stars should start with a single star that is either at\n # the beginning of the line or not following a backslash, have at least one\n # non-star and non-backslash in between, then end in one star\n result.gsub!(/(\\A|[^\\\\\\*])\\*([^\\*]*[^\\*\\\\])\\*/, '\\1**\\2**')\n\n # Convert inline code spans to use backticks\n result.gsub!(/(\\A|[^\\\\])\\+([^\\+]+)\\+/, '\\1`\\2`')\n\n # Convert bare http:, mailto: and ftp: links\n result.gsub!(/(\\A|\\s)(http:|https:|mailto:|ftp:)(\\S*)/, '\\1[\\2\\3](\\2\\3)')\n\n # Convert bare www to an http: link\n result.gsub!(/(\\A|\\s)www\\.(\\S*)/, '\\1[www.\\2](http://www.\\2)')\n\n # Convert link: links to refer to local files\n result.gsub!(/(\\A|\\s)link:(\\S*)/, '\\1[\\2](\\2)')\n\n # Convert multi word labels surrounded by {} with a url\n result.gsub!(/\\{([^\\}]*)\\}\\[(\\S*)\\]/, '[\\1](\\2)')\n\n # Convert one word labels with a url\n result.gsub!(/(\\A|\\s)([^\\{\\s]\\S*)\\[(\\S*)\\]/, '\\1[\\2](\\3)')\n\n end\n \n result\n end.join(\"\\n\")\n end",
"def textilizable(text, options = {})\r\n return \"\" if text.blank?\r\n\r\n # different methods for formatting wiki links\r\n case options[:wiki_links]\r\n when :local\r\n # used for local links to html files\r\n format_wiki_link = Proc.new {|title| \"#{title}.html\" }\r\n when :anchor\r\n # used for single-file wiki export\r\n format_wiki_link = Proc.new {|title| \"##{title}\" }\r\n else\r\n if @project\r\n format_wiki_link = Proc.new {|title| url_for :controller => 'wiki', :action => 'index', :id => @project, :page => title }\r\n else\r\n format_wiki_link = Proc.new {|title| title }\r\n end\r\n end\r\n\r\n # turn wiki links into textile links:\r\n # example:\r\n # [[link]] -> \"link\":link\r\n # [[link|title]] -> \"title\":link\r\n text = text.gsub(/\\[\\[([^\\]\\|]+)(\\|([^\\]\\|]+))?\\]\\]/) {|m| \"\\\"#{$3 || $1}\\\":\" + format_wiki_link.call(Wiki.titleize($1)) }\r\n\r\n # turn issue ids into links\r\n # example:\r\n # #52 -> <a href=\"/issues/show/52\">#52</a>\r\n text = text.gsub(/#(\\d+)(?=\\b)/) {|m| link_to \"##{$1}\", :controller => 'issues', :action => 'show', :id => $1}\r\n\r\n # turn revision ids into links (@project needed)\r\n # example:\r\n # r52 -> <a href=\"/repositories/revision/6?rev=52\">r52</a> (@project.id is 6)\r\n text = text.gsub(/(?=\\b)r(\\d+)(?=\\b)/) {|m| link_to \"r#{$1}\", :controller => 'repositories', :action => 'revision', :id => @project.id, :rev => $1} if @project\r\n\r\n # when using an image link, try to use an attachment, if possible\r\n attachments = options[:attachments]\r\n if attachments\r\n text = text.gsub(/!([<>=]*)(\\S+\\.(gif|jpg|jpeg|png))!/) do |m|\r\n align = $1\r\n filename = $2\r\n rf = Regexp.new(filename, Regexp::IGNORECASE)\r\n # search for the picture in attachments\r\n if found = attachments.detect { |att| att.filename =~ rf }\r\n image_url = url_for :controller => 'attachments', :action => 'show', :id => found.id\r\n \"!#{align}#{image_url}!\"\r\n else\r\n \"!#{align}#{filename}!\"\r\n end\r\n end\r\n end\r\n\r\n # finally textilize text\r\n @do_textilize ||= (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? \"textilize\")\r\n text = @do_textilize ? auto_link(RedCloth.new(text, [:hard_breaks]).to_html) : simple_format(auto_link(h(text)))\r\n end",
"def escape_html(str, type = T.unsafe(nil)); end",
"def to_textile\n __textile__.to_s\n end",
"def to_html\n @markdown_class.new(@markdown).to_html\n end",
"def do_adhoc(str)\n str.gsub!(/^\\\\cleardoublepage$/, \"\")\n str.gsub!(/^\\\\plainifnotempty$/, \"\")\n str.gsub!(/^\\\\small$/, \"\")\n str.gsub!(/^\\\\normalsize$/, \"\")\n str.gsub!(/^\\\\centering$/, \"\")\n\n # URL\n str.gsub!(/\\\\verb\\|(.+?)\\|/) do |m|\n s = $1\n if s =~ URI.regexp\n s\n else\n m\n end\n end\n\n text_pairs = {\n %! \\\\vspace*{-0.1\\\\Cvs}! => \"\",\n %!$10^{12} = 1 \\\\mathrm{TB}$! => %!@<raw>#{LBRACE}|html|10<sup>12</sup>#{RBRACE}=1TB!,\n %!$\\\\exists, \\\\forall$! => %!@<raw>#{LBRACE}|html|∃, ∀#{RBRACE}!,\n %!$\\\\lnot,\\\\land,\\\\lor$! => %!@<raw>#{LBRACE}|html|¬,∧,∨#{RBRACE}!,\n %!$>$! => %!@<raw>#{LBRACE}|html|>#{RBRACE}!,\n %!$<$! => %!@<raw>#{LBRACE}|html|<#{RBRACE}!,\n %!B$^+$! => %!@<raw>#{LBRACE}|html|B<sup>+</sup>#{RBRACE}!,\n %!\\\\paragraph{Step 4.} \\\\ ! => %!\\\\paragraph{Step 4.}!,\n %!\\\\verb|http://s2k-ftp.cs.berkeley.edu/ingres/|! => %!http://s2k-ftp.cs.berkeley.edu/ingres/!,\n %!\\\\verb|pc<code.size()|! => %!@<tt>#{LBRACE}pc<code.size()#{RBRACE}!,\n %!\\\\verb|c|! => %!@<tt>#{LBRACE}c#{RBRACE}!,\n %!\\\\verb|m|! => %!@<tt>#{LBRACE}m#{RBRACE}!,\n %!\\\\verb|z|! => %!@<tt>#{LBRACE}z#{RBRACE}!,\n %!$n$! => %!n!,\n %!$\\\\mathrm{O}(1)$! => %!O(1)!,\n %!$\\\\mathrm{O}(n)$! => %!O(n)!,\n %!$\\\\beta$! => %!@<raw>#{LBRACE}|html|β#{RBRACE}!,\n %!$t$! => %!t!,\n %![$^{11}$C]! => %!@<raw>#{LBRACE}|html|[<sup>11</sup>C]#{RBRACE}!,\n }\n\n text_pairs.each do |k,v|\n regex = Regexp.compile(Regexp.quote(k))\n str.gsub!(regex, v)\n end\n\n str.gsub!(/^\\s*\\\\begin\\{lstlisting\\}\\n((?:.|\\n)*?)\\n\\s*\\\\end\\{lstlisting\\}\\n/) do |m|\n \"//emlist{\\n\" + $1 + \"\\n//}\\n\"\n end\n\n str.gsub!(/^\\s*\\\\begin\\{quote\\}\\n((?:.|\\n)*?)\\n\\s*\\\\end\\{quote\\}\\n/) do |m|\n \"//quote{\\n\" + $1 + \"\\n//}\\n\"\n end\n\n str.gsub!(/^\\s*\\\\(begin|end)\\{(minipage|center|figure)\\}.*$/, \"\")\n\n img_refs = Hash.new\n str.gsub!(/^\\s*\\\\includegraphics(?:\\[.*?\\])?\\{(.+?)\\}[\\s\\n]*\\\\caption\\{(.+?)\\}[\\s\\n]*\\\\label\\{(.+?)\\}/) do |m|\n imgfile = $1.strip\n caps = $2.strip\n label = $3.strip\n if imgfile =~ /\\.eps\\Z/\n imgfile = File.basename(imgfile, \".eps\")\n img_refs[label.strip] = imgfile\n \"\\n//image[#{imgfile}][#{caps}]{\\n//}\\n\"\n elsif imgfile =~ /\\.pdf\\Z/\n imgfile = File.basename(imgfile, \".pdf\")\n img_refs[label.strip] = imgfile\n \"\\n//image[#{imgfile}][#{caps}]{\\n//}\\n\"\n else\n m\n end\n end\n\n str.gsub!(/^\\s*\\\\includegraphics(?:\\[.*?\\])?\\{(.+?)\\}[\\s\\n]*\\\\caption\\{(.+?)\\}/) do |m|\n imgfile = File.basename($1.strip)\n caps = $2.strip\n imgfile.gsub!(/\\.\\w+\\Z/, \"\")\n \"\\n//image[#{imgfile}][#{caps}]{\\n//}\\n\"\n end\n\n str.gsub!(/図\\s*\\\\ref\\{([^\\}]*)\\}/) do |m|\n \"@<img>#{LBRACE}#{img_refs[$1.strip] || $1.strip}#{RBRACE}\"\n end\n\n str.gsub!(/^\\s*\\\\begin\\{enumerate\\}((?:.|\\n)*)\\s*\\\\end\\{enumerate\\}/) do |m|\n block = $1\n idx = 0\n if block =~ /\\\\begin/\n block\n else\n items = block.strip.split(/\\\\item\\s*/).select{|s| s.size > 0}\n items_str = \"\\n\"\n items.each do |item|\n items_str += \" \" + (idx += 1).to_s + \". \" + item.gsub(/\\n\\s*/,\"\").strip + \"\\n\"\n end\n items_str\n end\n end\n\n str.gsub!(/^\\s*\\\\begin\\{itemize\\}((?:.|\\n)*)\\s*\\\\end\\{itemize\\}/) do |m|\n block = $1\n if block =~ /\\\\begin/\n block\n else\n items = block.strip.split(/\\\\item\\s*/).select{|s| s.size > 0}\n items_str = \"\\n\"\n items.each do |item|\n items_str += \" * \" + item.gsub(/\\n\\s*/,\"\").strip + \"\\n\"\n end\n items_str\n end\n end\n\n # brainfuck\n str.gsub!(/\\\\verb\\|([-+><,\\.\\[\\] ]+)\\|/) do |m|\n %!@<tt>#{LBRACE}#{$1}#{RBRACE}!\n end\n\n # file url in hoge.tex\n str.gsub!(/\\{\\\\scriptsize((?:.|\\n)+?)\\}/) do |m|\n s = $~[1].strip\n if s.strip =~ URI.regexp && s == $~[0]\n s\n else\n m\n end\n end\n\n str\nend",
"def parse(html, options = {})\n # clean html\n clean_html = cleaner.clean(html, options)\n\n # fix html\n pdf_model = fixer.fix(clean_html, options)\n end",
"def strip_tags(html); end",
"def strip_tags(html); end",
"def strip_tags(html); end",
"def preprocess!\n input_html\n nil\n end",
"def initialize_html_tags; end",
"def to_textile\n output = \"\"\n output_buffer = TextileOutputBuffer.new(output)\n\n translate(@header_lines, output_buffer)\n @headlines.each do |headline|\n translate(headline.body_lines, output_buffer)\n end\n output\n end",
"def textile_ruby( tag, atts, cite, content )\n %(<pre><code class=\"ruby\">#{content}</pre></code>)\n end",
"def to_html(string, _options = {})\n # Escape any \" that are not already escaped\n string.gsub!(/([^\\\\])\"/, '\\1\\\"')\n # Escape any ' that are not already escaped\n string.gsub!(/([^\\\\])'/, %q(\\1\\\\\\'))\n html = Kramdown::Document.new(string, input: :kramdown).to_html\n end",
"def stextilize(text)\n if text.blank?\n \"\"\n else\n if ENV['RAILS_ENV'] == 'test'\n # For some reason, the call to :sanitize_html causes problems in tests. Weird.\n textilized = RedCloth.new(text, [ :hard_breaks, :filter_styles ])\n else\n textilized = RedCloth.new(text, [ :hard_breaks, :sanitize_html, :filter_styles ])\n end\n textilized.to_html\n end\n end",
"def setup_markup_transform(&block)\n self.send :define_method, :markup, block\n end",
"def render_markdown(text)\n html_renderer.render(text).html_safe if text.present?\n end",
"def parse\n #use regex to split\n arr = @html_string.scan(TAGS_AND_TEXT).flatten\n\n #remove nil values and return\n arr.compact!\n\n #remove white spaces\n arr.map! { |s| s.strip}\n end",
"def markdown(text)\n sanitize BlueCloth::new(text).to_html\n end",
"def apply_span_transforms( str, rs )\n\t\t\t@log.debug \"Applying span transforms to:\\n %p\" % str\n\n\t\t\tstr = transform_code_spans( str, rs )\n\t\t\tstr = transform_auto_links( str, rs )\n\t\t\tstr = encode_html( str )\n\t\t\tstr = transform_images( str, rs )\n\t\t\tstr = transform_anchors( str, rs )\n\t\t\tstr = transform_italic_and_bold( str, rs )\n\n\t\t\t# Hard breaks\n\t\t\tstr.gsub!( / {2,}\\n/, \"<br#{EmptyElementSuffix}\\n\" )\n\n\t\t\t@log.debug \"Done with span transforms:\\n %p\" % str\n\t\t\treturn str\n\t\tend"
] | [
"0.7921789",
"0.71427923",
"0.7081709",
"0.6979907",
"0.69110125",
"0.6898772",
"0.67728746",
"0.6702057",
"0.66206914",
"0.65856284",
"0.65273196",
"0.6499709",
"0.6467193",
"0.64440393",
"0.63703775",
"0.6330149",
"0.6281741",
"0.6262261",
"0.6204559",
"0.6200194",
"0.61998546",
"0.61918116",
"0.6187894",
"0.61662054",
"0.6150583",
"0.6131063",
"0.61210144",
"0.6113127",
"0.6106728",
"0.60987556",
"0.60987556",
"0.6088921",
"0.60781413",
"0.6034566",
"0.6027558",
"0.6002882",
"0.59876263",
"0.5972988",
"0.5968902",
"0.5941058",
"0.5915219",
"0.58952624",
"0.5886848",
"0.5884478",
"0.5879197",
"0.58790576",
"0.58588666",
"0.58543813",
"0.5847437",
"0.5844697",
"0.5844697",
"0.583549",
"0.5826358",
"0.5824117",
"0.5824117",
"0.58223253",
"0.58192205",
"0.5815371",
"0.5812664",
"0.5802183",
"0.5795235",
"0.5756122",
"0.57482576",
"0.5740278",
"0.5739586",
"0.57158446",
"0.57140875",
"0.57131207",
"0.5711517",
"0.5697358",
"0.56955546",
"0.56847805",
"0.5682214",
"0.56673074",
"0.566476",
"0.5663653",
"0.56625634",
"0.56602514",
"0.5655409",
"0.5643543",
"0.5627621",
"0.5616374",
"0.56124026",
"0.5608876",
"0.5596099",
"0.55881375",
"0.55720025",
"0.55720025",
"0.55720025",
"0.55705917",
"0.5565252",
"0.5564337",
"0.556203",
"0.5555634",
"0.5536441",
"0.5533142",
"0.55298346",
"0.5522681",
"0.5520428",
"0.5517571"
] | 0.60097146 | 35 |
def create_self(keys) if keys and keys != None | def __tkvariable_optkeys
super() << 'listvariable'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new(keys)\n to_ary == keys ? self : self.class.new(keys)\n end",
"def initialize(left_keys, right_keys)\n @left_keys = left_keys\n @right_keys = right_keys\n\n @map = join_key_map\n end",
"def create_key(arg = nil)\n set_or_return(\n :create_key,\n arg,\n kind_of: [ TrueClass, FalseClass ]\n )\n end",
"def make_keys!\n root_dir = SAFE_KEYS_DIR\n object_id = self.id\n pass = self.password \n raise Safe::KeygenError if object_id.nil? || pass.nil?\n dir_class = root_dir + \"/#{self.class.to_s.tableize}/\"\n dir = dir_class + \"#{object_id}/\"\n if File.exists?(root_dir) && File.directory?(root_dir)\n Dir.mkdir(dir_class) unless File.exists?(dir_class)\n Dir.mkdir(dir) unless File.exists?(dir)\n gen_keypair(dir, pass)\n else\n Dir.mkdir(root_dir)\n Dir.mkdir(dir_class)\n Dir.mkdir(dir)\n gen_keypair(dir, pass)\n end \n end",
"def create\n copy self.class.create(to_hash_without_nils)\n true\n end",
"def create\n copy self.class.create(to_hash_without_nils)\n true\n end",
"def from_keys\n end",
"def perform(keys)\n raise NotImplementedError\n end",
"def perform(keys)\n raise NotImplementedError\n end",
"def initialize(keys, data)\n @keys = {}\n keys.each_with_index { |x, i| @keys[x.to_sym] = i }\n @data = data\n end",
"def initialize(keys)\n if keys.empty?\n raise Error, \"Cannot initialize encryptor without encryption key\"\n end\n\n # First key is used for encryption\n @key_id, @key, @auth_data, @padding = keys[0]\n\n # All keys are candidates for decryption\n @key_map = {}\n keys.each do |key_id, key, auth_data, padding|\n @key_map[key_id] = [key, auth_data, padding].freeze\n end\n\n freeze\n end",
"def initialize(key_vals)\n fields = self.class.fields_list\n if not fields.nil? then # record paramétré\n if fields == key_vals.keys then # tout va bien\n @allowed_keys = fields\n @key_vals = key_vals\n rebuild_array\n else raise \"#{self.class.to_s} wrong initialization, expected #{fields}\" end\n else # record anonyme\n @allowed_keys = key_vals.keys\n @key_vals = key_vals\n key_vals.each do |k,v|\n getter = k.to_sym\n setter = format(\"%s=\", k.to_s).to_sym\n define_singleton_method(getter){ @key_vals[k] }\n define_singleton_method(setter){|nv| @key_vals[k] = nv; rebuild_array}\n self.push(v)\n end\n end\n end",
"def add_keys(*keys)\n @rye_opts[:keys] ||= []\n @rye_opts[:keys] += keys.flatten.compact\n @rye_opts[:keys].uniq!\n self # MUST RETURN self\n end",
"def create(*args)\n returning super(*args) do |response|\n @key = response['Key'] if response['Key']\n end\n end",
"def get_nillable_from_hash_iterative(hash, keys)\n data = hash\n keys.each do |key|\n return nil if data[key].nil?\n data = data[key]\n end\n end",
"def initialize(values = {})\n @root = nil\n\n values.each { |key, value| put(key, value) }\n end",
"def missing_keys; end",
"def key_coercions=(_arg0); end",
"def initialize_tuple_keys\n @tuple_keys = mapping.keys.flatten + non_primitives.flat_map(&:tuple_keys)\n end",
"def with_keys\n keys.each_with_object self.class.new do |hash_key, hsh|\n hsh[ yield hash_key ] = self[ hash_key ]\n end\n end",
"def post_process_defaults(keys)\n keys.each do |name|\n key = key_objects[name]\n @attribute_objects[name] = key.create_attribute(key.default.call(self))\n end\n end",
"def decide_for_keys(keys, options = nil)\n @optimizely_client&.decide_for_keys(clone, keys, options)\n end",
"def decide_for_keys(keys, options = nil)\n @optimizely_client&.decide_for_keys(clone, keys, options)\n end",
"def initialize_pop_keys\n @pop_keys = mapping.values + non_primitives.flat_map(&:tuple_keys)\n end",
"def xkeys_new (*args); @template.factory :array; end",
"def test_initialize_of_class_key\n name = 'name'\n column_names = %w(colA colB colC)\n is_unique = true\n\n key = Key.new(name, column_names, is_unique)\n assert_equal(name , key.name , \"names\")\n assert_equal(column_names, key.column_names, \"column_names\")\n assert_equal(is_unique , key.unique? , \"is_unique\")\n end",
"def key=(_arg0); end",
"def key=(_arg0); end",
"def key=(_arg0); end",
"def initialize(key)\n @key = key\n @left = nil\n @right = nil\n end",
"def initialize_subhashes(hash, keys)\n key = keys.shift\n subhash = hash[key] || (hash[key] = {})\n if keys.size > 0\n initialize_subhashes(subhash, keys)\n else\n subhash\n end\n end",
"def check_or_create_for!(hash, key)\n hash[key] = \"\" unless hash.include?(key)\n end",
"def child_keys() []; end",
"def esponi(*keys)\n return self if keys.none?\n self.select { |key, value| key.in? keys }\n end",
"def initialize(*args)\n # Don't allow an object to be created unless key values are provided and a list of keys has been defined at the class level\n raise ArgumentError unless args[0].has_keys?(self.class.keys) and !(self.class.keys.empty?)\n args.each do |arg|\n raise ArgumentError, 'Creating a Record expects a hash as an argument' unless arg.is_a?(Hash)\n arg.each do |k, v|\n self.send(\"#{k.to_s}=\".to_sym, v)\n end\n end\n # create the primary key for this record then\n # store the pk and the record in the records class instance variable\n # Use a non-printable character as the delimiter \\x01 to avoid code/data conflicts\n self.class.records[self.class.build_key(self)] = self\n end",
"def MyStruct(*keys)\r\n\t Class.new do \r\n\t\t attr_accessor *keys\r\n\t\t def initialize(hash)\r\n\t\t\t hash.each do |key,value|\r\n\t\t\t\t instance_variable_set(\"@#{key}\", value)\r\nend\r\n\t\t end\r\n\t end\r\n end",
"def anythingize_lonely_keys(*args)\n hash = args.last.class == Hash ? args.delete_at(-1) : {}\n args.each { | arg | hash[arg] = WebMock::Matchers::AnyArgMatcher.new(nil) }\n hash\n end",
"def initialize(client_keys={})\n # error if no hash,\n return unless client_keys.is_a? Hash\n # error if hash keys named incorrectly\n return unless valid_key_names? client_keys.keys\n\n client_keys.each do |key, value|\n self.send(\"#{key}=\", value)\n end\n end",
"def create\n\n keys = [params[:n], params[:e], params[:d]]\n # keys = [:n, :e, :d]\n if (params.keys && keys).any?\n my_rsa = RsaFull.new(n: params[:n], e: params[:e], d: params[:d])\n else\n keys = RsaFull.new_key\n my_rsa = RsaFull.new(n: keys[0], e: keys[1], d: keys[2])\n end\n respond_to do |format|\n if my_rsa.save\n format.json {render json: {'id' => my_rsa.id}}###\n end\n end\n end",
"def create_if_exists(hash, *args, name:)\n exists = false\n args.each do |key|\n exists = false\n break unless hash.is_a?(Hash)\n\n exists = hash.key?(key)\n break unless exists\n\n hash = hash[key]\n end\n return unless exists\n return if respond_to?(name) && !send(name).nil?\n\n self.class.send(:attr_accessor, name)\n send(\"#{name}=\", hash)\n end",
"def initialize(keys)\n @header = []\n @keys = keys\n end",
"def prepare_data(keys: nil, concurrency: false, verbose: false)\n fetch_key = ->(key) { (keys.nil? || key.in?(keys)) && __send__(key) }\n if concurrency\n each_concurrently(RUBY_GEM_KEYS + GITHUB_KEYS, &fetch_key)\n else\n (RUBY_GEM_KEYS + GITHUB_KEYS).each(&fetch_key)\n end\n puts(name) if verbose\n end",
"def new_record?\n key_value.nil?\nend",
"def initialize(key=nil)\n super\n end",
"def initialize(elements = nil)\n super()\n (elements || {}).each_pair{ |key, value| self[key] = value }\n end",
"def generate_new_keys(\n name:,\n email: \"\",\n comment: \"\",\n creation_date: Time.now,\n key_validity_seconds: 1.year\n )\n\n generated =\n Rnp.new.generate_key(\n default_key_params(\n name: name,\n email: email,\n comment: comment,\n creation_date: creation_date,\n key_validity_seconds: key_validity_seconds,\n ),\n )\n\n %i[primary sub].map do |key_type|\n raw = generated[key_type]\n creation_hash = creation_params(\n raw: raw, activation_date: creation_date, metadata: raw.json,\n )\n\n RK::Key::PGP.create(creation_hash)\n end\n end",
"def fill_with(default=nil, keys=nil)\n a = self.clone\n a.fill_with!(default, keys)\n a\n end",
"def new_without_self(klass, key1, key2)\n ivar = :\"@#{key1}\"\n return instance_variable_get(ivar) if instance_variable_defined?(ivar)\n object = if @attrs[key1]\n attrs = @attrs.dup\n value = attrs.delete(key1)\n klass.new(value.update(key2 => attrs))\n else\n Twitter::NullObject.new\n end\n instance_variable_set(ivar, object)\n end",
"def missing_for_create\n # If we haven't set a value, and there is no default, we can't\n # create the stack.\n @hash.values.select { |v| !v.set? && !v.default? }\n end",
"def set_keys\n self.auth = gen_key('auth') if auth.blank?\n self.mkey = gen_key('mkey') if mkey.blank?\n end",
"def default_keys; end",
"def rk(*elements)\n $_rk = Rk.new unless $_rk\n\n # Differ between calling \"rk\" without/with params\n if elements.empty?\n # Return instance of Rk for calling methods like \"rk.separator\"\n $_rk\n else\n # Return key build by Rk.rk\n $_rk.rk(elements)\n end\n end",
"def only(*keys)\n h = {}\n keys.each{|key|h[key] = self[key]}\n h\n end",
"def new_collection(key, no_nil: false)\n initialize_value(\n mapping[key] || matching_mapping(key) || default_without_mapping(no_nil: no_nil)\n )\n end",
"def new_by_key(key)\n args = RedisModelExtension::Database.redis {|r| r.hgetall(key) }\n return nil unless args && args.any?\n args.symbolize_keys!\n\n new_instance = new(args)\n new_instance.store_keys\n\n return new_instance\n end",
"def initialize(default_key=nil)\n @items = HashWithIndifferentAccess.new { |hash, key| hash[key] = [] }\n @keys = [default_key.to_s].compact\n @items[default_key.to_s] = [] unless default_key.nil?\n end",
"def MyStruct(*keys)\n Class.new do\n attr_accessor *keys\n def initialize(hash)\n hash.each do |key, value|\n instance_variable_set(\"@#{key}\", value)\n end\n end\n end\nend",
"def initialize(initial_hash = nil)\n super\n @optional_method_names = %i[recursive ignoreIfNotExists]\n end",
"def keys(*_arg0, &_arg1); end",
"def assign_key(attrs)\n case attrs.class.name\n when 'Fixnum'\n new_var 'key', attrs\n @item ||= Item.find_by_id(attrs)\n when 'Item'\n @item ||= attrs\n new_var 'key', @item.id\n when 'List'\n @list ||= attrs\n @item ||= @list.items.new\n when 'String'\n if /^[-+]?[0-9]+$/ === attrs\n @item ||= Item.find_by_id(attrs.to_i)\n new_var 'key', attrs.to_i\n else\n @list = List.find_by_name(attrs)\n @item = @list.items.new\n end\n end\n if @item.nil?\n return { :success => false, :errors => ['could not find key']}\n end\n @list ||= @item.list\n new_var 'list', @list.name\n new_var 'created_at', @item.created_at\n new_var 'updated_at', @item.updated_at\n end",
"def key_types=(_arg0); end",
"def solution(keys, default_value)\n hash = Hash.new\n keys.each do |x|\n hash[x] = default_value\n end\n hash\nend",
"def initialize_keys\n @key0 = 0x12345678\n @key1 = 0x23456789\n @key2 = 0x34567890\n @password.each_byte { |byte| update_keys(byte.chr) }\n nil\n end",
"def exists(*keys); end",
"def initialize(attrs = {})\n @attributes = {}.with_indifferent_access\n process(defaults.merge(attrs))\n @new_record = true if id.nil?\n generate_key\n end",
"def key=(_); end",
"def key=(_); end",
"def sub(keys)\n h1 = {}\n h2 = {}\n h3 = {}\n\n keys.each do |k|\n dna = self.dna_hash[k]\n next unless dna\n h1[k] = dna\n aa = self.aa_hash[k]\n h2[k] = aa\n qc = self.qc_hash[k]\n h3[k] = qc\n end\n title = self.title\n file = self.file\n ViralSeq::SeqHash.new(h1,h2,h3,title,file)\n end",
"def initialize(key, log: Loog::NULL)\n raise 'Key can\\'t be nil' if key.nil?\n @key = key\n raise 'Log can\\'t be nil' if log.nil?\n @log = log\n end",
"def missing_keys_from(required_keys)\n required_keys.select{ |k| self.get(k).to_s.empty? }\n end",
"def [](*key_list)\n fetch_or_init_keys(Array(key_list).flatten) { |key| new_collection(key) }\n end",
"def key_id=(_arg0); end",
"def convert!(keys=nil, opts=OPTS)\n if keys.is_a?(Hash)\n opts = keys\n keys = nil\n end\n\n _capture!(:nested_params, opts) do\n if sub = subkey(Array(keys).dup, opts.fetch(:raise, true))\n yield sub\n end\n end\n end",
"def initialize\n @hash = lens_keys.map { |k| [k, nil] }.to_h.with_indifferent_access\n end",
"def generate_key; end",
"def create_hash(&block); end",
"def create_hash(&block); end",
"def keys(*) end",
"def initialize(path_or_key)\n if path_or_key.respond_to?(:head) && path_or_key.respond_to?(:tail)\n @head = path_or_key.head\n @tail = path_or_key.tail\n else\n path = path_or_key.to_s\n segments = path.nil? ? [] : path.split(SEPARATOR)\n\n unless segments.empty?\n @head = segments.shift\n @tail = segments.empty? ? nil : Key.new(segments.join(SEPARATOR))\n end\n end\n end",
"def create_a_collection_of_keys(keys_details)\n today_epoch = Date.today.to_time.to_i\n keys = []\n found_key = false\n key = nil\n key_type = choose_key_type\n CSV.parse(keys_details, col_sep: ':') do |row|\n current_key_type = row[0]\n if current_key_type == key_type\n key = Key.new(row[4], row[6])\n populate_key_num_of_days_left_and_level(key, today_epoch)\n found_key = true\n elsif found_key && current_key_type == 'uid'\n key.description = row[9]\n keys.push key\n found_key = false\n end\n end\n keys\n end",
"def exchange_keys; end",
"def exchange_keys; end",
"def exists?(*keys); end",
"def deep_transform_keys(&block)\n new_instance_with_inherited_permitted_status(\n @parameters.deep_transform_keys(&block)\n )\n end",
"def empty?\n @keys.empty?\n end",
"def reserve_key(key); end",
"def initialize(options = {})\n if (options.keys & [:parent_field, :parent_fields, :child_field, :child_fields]).empty? &&\n (kf = options.fetch(:key_field, options[:key_fields]))\n @key_fields = [kf].flatten\n @parent_fields = []\n @child_fields = @key_fields\n else\n @parent_fields = [options.fetch(:parent_field, options[:parent_fields]) || []].flatten\n @child_fields = [options.fetch(:child_field, options[:child_fields]) || [0]].flatten\n @key_fields = @parent_fields + @child_fields\n end\n @field_names.map!(&:to_s) if @field_names = options[:field_names]\n @case_sensitive = options.fetch(:case_sensitive, true)\n @trim_whitespace = options.fetch(:trim_whitespace, false)\n @ignore_header = options[:ignore_header]\n @include = options[:include]\n @exclude = options[:exclude]\n @path = options.fetch(:path, 'NA') unless @path\n @warnings = []\n end",
"def keypair(*args)\n if args && !args.empty?\n args.each {|arg| _keypairs.unshift Key.new(arg) unless arg.nil? || arg.empty? }\n else\n @keypair ||= _keypairs.select {|key| key.exists? }.first\n end\n end",
"def nil_values(the_input, nil_keys_array = Array.new)\n the_input.select { |_, v| v.blank? }.each_key do |key|\n nil_keys_array << key.to_s\n end\n raise K2EmptyParams.new(nil_keys_array) unless nil_keys_array.blank?\n end",
"def init_on_create(*args) # :nodoc:\n self[:_classname] = self.class.to_s\n if args[0].respond_to?(:each_pair)\n args[0].each_pair { |k, v| respond_to?(\"#{k}=\") ? self.send(\"#{k}=\", v) : @_java_node[k] = v }\n end\n end",
"def initialize(attrs)\n @attrs = attrs.symbolize_keys\n if @attrs[:title].nil? and @attrs[:desc].nil? and @attrs[:image_url].nil?\n raise 'title, desc, and image_url cannot be nil at the same time'\n end\n end",
"def create(hash)\n NotImplementedError\n end",
"def update!(**args)\n @keys = args[:keys] unless args[:keys].nil?\n end",
"def custom_from_hashes\n self.create_hash.each_pair do |key,value|\n method_name = \"#{key}_from_hash\".to_sym\n if self.respond_to?(method_name)\n self.send(method_name,value)\n end\n end\n end",
"def create_key\n self.key = loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless Api.exists?(key: random_token)\n end\n end",
"def initialize(cellar, bottle)\n @cellar = cellar\n @bottle = bottle\n self.add_to_cellar_key(cellar)\n self.add_to_bottle_key(bottle)\n @@all << self\nend",
"def create_default_key_reader\n @key_reader = DefaultKeyReader.new self\n end",
"def initialize(id, key='')\n @_id = id\n @_key = key\n end",
"def transform_keys(&block)\n return to_enum(:transform_keys) unless block_given?\n new_instance_with_inherited_permitted_status(\n @parameters.transform_keys(&block)\n )\n end",
"def initialize(*keys, **attrs)\n @etcd_node = nil\n self.class.etcd_schema.each_key_value(*keys) do |sym, value|\n self.instance_variable_set(\"@#{sym}\", value)\n end\n initialize_json(**attrs)\n end",
"def subkey(keys, do_raise)\n unless key = keys.shift\n return self\n end\n\n reason = :invalid_type\n\n case key\n when String\n unless @obj.is_a?(Hash)\n raise Error, \"parameter #{param_name(nil)} is not a hash\" if do_raise\n return\n end\n present = !@obj[key].nil?\n when Integer\n unless @obj.is_a?(Array)\n raise Error, \"parameter #{param_name(nil)} is not an array\" if do_raise\n return\n end\n present = key < @obj.length\n else\n raise ProgrammerError, \"invalid argument used to traverse parameters: #{key.inspect}\"\n end\n\n unless present\n reason = :missing\n raise Error, \"parameter #{param_name(key)} is not present\" if do_raise\n return\n end\n\n self[key].subkey(keys, do_raise)\n rescue => e\n handle_error(key, reason, e)\n end"
] | [
"0.62678665",
"0.60088927",
"0.58794594",
"0.58340746",
"0.57857406",
"0.57857406",
"0.57188386",
"0.57139456",
"0.57139456",
"0.5679811",
"0.5597602",
"0.557066",
"0.55679655",
"0.55502874",
"0.5540782",
"0.55354774",
"0.55298954",
"0.550549",
"0.54759586",
"0.54719937",
"0.5466897",
"0.5466809",
"0.5466809",
"0.54349935",
"0.5434455",
"0.5432703",
"0.5393339",
"0.5393339",
"0.5393339",
"0.53819877",
"0.5329486",
"0.5329112",
"0.52881074",
"0.52838874",
"0.527765",
"0.52727616",
"0.5271306",
"0.52632916",
"0.5257465",
"0.52557766",
"0.5254435",
"0.5248555",
"0.5219635",
"0.521183",
"0.52048284",
"0.5201371",
"0.51929814",
"0.5189626",
"0.5169959",
"0.51691544",
"0.51537645",
"0.5148519",
"0.5141478",
"0.5140273",
"0.5133811",
"0.513222",
"0.51142967",
"0.51093775",
"0.5107573",
"0.5103016",
"0.5101964",
"0.5098976",
"0.5096101",
"0.50940603",
"0.5084721",
"0.5081796",
"0.5081796",
"0.50712115",
"0.5066676",
"0.5058672",
"0.5057813",
"0.50540864",
"0.50527817",
"0.504312",
"0.50406057",
"0.5038192",
"0.5038192",
"0.5035276",
"0.50312024",
"0.5025418",
"0.50203156",
"0.50203156",
"0.5019584",
"0.5010949",
"0.4993463",
"0.49868143",
"0.49852824",
"0.49796325",
"0.49789894",
"0.4974006",
"0.49720976",
"0.49692294",
"0.49668717",
"0.49668193",
"0.49586448",
"0.4957287",
"0.49570462",
"0.4955097",
"0.4954283",
"0.49508262",
"0.49502385"
] | 0.0 | -1 |
Emit our attribute values as a line of CSVs | def to_csv
nombre_completo << " - " << debe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_csv\n attributes = %w{id email name course_ids major_title created_at}\n \n CSV.generate(headers: true) do |csv|\n csv << attributes\n csv << attributes.map{ |attr| self.send(attr) }\n end\n end",
"def to_csv\n self.all.to_promise.then do |all|\n io = StringIO.new\n io << (attrs.join(',') + \"\\n\")\n all.each do |model|\n line = model.to_csv(attrs: attrs, tab_sub: CSV_TAB_SUB, cr_sub: CSV_CR_SUB, nl_sub: CSV_NL_SUB, comma_sub: CSV_COMMA_SUB) # send(attr).to_s.gsub(',', COMMA_SUB)\n io << (line + \"\\n\")\n end\n io.string.to_promise\n end\n end",
"def to_csv\n csvString = LineCounter.columnNames.join(',') + \"\\n\"\n self.each { |result| csvString += result.to_a.join(',') + \"\\n\"}\n csvString\n end",
"def csv\n @name + \",r,\" + @foods.join(\",\")\n end",
"def to_csv\n \"#{@key},#{@expected},#{@type}\"\n end",
"def csv\n @name + \",b,\" + @calories.to_s\n end",
"def gen_raw_line\n return nil unless self.valid?\n line = ''\n data = []\n SUB_STR_ATTRIBUTES.each do |field,field_regex|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n line = \"#{data.join ' ,'}\"\n end\n\n data = []\n BOOL_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n if line == ''\n line += \"#{data.join ','} \"\n else\n line += \",#{data.join ','} \"\n end\n end\n\n data = []\n ARR_STR_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n if line == ''\n line += \"#{data.join ','} \"\n else\n line += \", #{data.join ','} \"\n end\n end\n\n data = []\n STR_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n line += data.join ' '\n return line\n end",
"def to_csv_row\n [@id, @name, @address]\n end",
"def csv_attributes\n [\n \"Nimi\" => \"name\",\n \"Järjestys\" => \"numbering_order\",\n \"Lyhenne\" => \"shorten\",\n \"Ehdokkaita\" => :candidate_count,\n \"Vaalirengas\" => :coalition_name\n ]\n end",
"def export_csv\n export_string = \"#{@id},#{type_string},#{@name.gsub(/[\\,,\\s]/,\"\")},\"\n @details.each{|k,v| export_string << \"#{k}=#{v};\".gsub(/[\\,,\\s]/,\"\") }\n export_string\n end",
"def export_csv\n export_string = \"#{@id},#{type_string},#{@name.gsub(/[\\,,\\s]/,\"\")},\"\n @details.each{|k,v| export_string << \"#{k}=#{v};\".gsub(/[\\,,\\s]/,\"\") }\n export_string\n end",
"def csv_row\n [\n hub_id,\n tag_id,\n \"%2.2f\" % temperature,\n ACCELERATION_FORMAT % x_acceleration,\n ACCELERATION_FORMAT % y_acceleration,\n ACCELERATION_FORMAT % z_acceleration,\n rssi,\n timestamp.to_i\n ].join(\",\")\n end",
"def to_csv\n value.to_csv\n end",
"def to_csv_data( options={} )\n fields = self.class.to_csv_fields( options ).fields\n data, model_data = [], fields.inject( [] ) { |arr,field| arr << attributes[field].to_s }\n if options[:include]\n to_csv_data_for_included_associations( options[:include ] ).map do |assoc_csv_data|\n data << model_data + assoc_csv_data\n end\n else\n data << model_data\n end\n data\n end",
"def to_csv\n # id.to_s << \",\" << last_name << \",\" << first_name << \",\" << email << \",\" << birthdate.to_s\n end",
"def to_csv\n [@name, @description, @prep_time, @done]\n end",
"def to_csv\n return '' if empty?\n\n klass = first.class\n columns = klass.columns.map(&:name).reject { |column| column =~ /password|token/ }\n columns << 'tags'\n CSV.generate do |csv|\n csv << columns.map { |column| klass.human_attribute_name(column) }\n each do |item|\n csv << columns.map do |column|\n if column == 'tags'\n item.tag_list.join(' ')\n else\n item.send(column)\n end\n end\n end\n end\n end",
"def csv(rows)\n rows.map { |r| r.join(';') }.join(\"\\n\")\n end",
"def as_csv(*)\n populate_carriers!\n\n CSV.generate do |csv|\n csv << [\n 'key', 'primary_co2_emission',\n *primary_carriers.map { |c| \"primary_demand_of_#{c} (MJ)\" },\n *final_carriers.map { |c| \"final_demand_of_#{c} (MJ)\" }\n ]\n\n @graph.group_nodes(:application_group).each do |node|\n csv << node_row(node)\n end\n end\n end",
"def to_csv(a_separateur = ';')\n @nom + a_separateur + @devises_conversion.map(&:to_csv).join(a_separateur)\n end",
"def csv\n\t\tc = \"#{entrytime},#@entrytype,#@extcmd,#@host,#@service,\"\n\t\tc += \"#@attempt,#@rc,#@state,#@hardsoft,\\\"#@msg\\\",\"\n\t\tc += \"#@contact,#@command,#@ack_author,#@ack_data,\"\n\t\tc\n\tend",
"def csv_string\n CSV.generate do |csv|\n header.write_header csv\n records.each {|r| r.write_record csv}\n end\n end",
"def attr_csv(*attributes)\n define_attribute_methods rescue nil\n super\n attributes.reject { | attr | attr.is_a?(Hash) }.each { | attr | alias_method \"#{attr}_before_type_cast\", attr }\n\n # Register before_validate to update the csv fields\n before_validation :update_csved_attributes\n end",
"def line_for(column_values)\n column_values.map {|value| value_for(value) }.join('\",\"')\n end",
"def to_csv(headers=nil)\n headers = Item.csv_headers if headers.nil?\n values = []\n headers.each do |h|\n values << '\"' + self.send(h).to_s + '\"'\n end\n return values.join(\"\\t\")\n end",
"def build_csv()\n\t\tconcat_path = \"#{@location}/#{@name}.csv\"\n\n\t\tCSV.open(concat_path, 'wb') do |csv_line|\n\t\t\t\t\t\n\t\t\theaders = ['movie_date', 'title', 'lifetime_gross_sales']\n\t\t\tcsv_line << headers\n\n\t\t\t@cage.each do |cage|\n\t\t\t\tcsv_line << [cage[:movie_date], cage[:title], cage[:life_time_gross]]\n\t\t\tend\n\t\tend\n\tend",
"def csvString\n resultColumns = self.generateResultColumns\n headers = resultColumns[:columns].keys\n # Start off instantiating the csv string with the header values\n csvString = headers.map{|s| self.filterValue(s)}.join(@options[:delimiter])\n\n # Now iterate over each row, sticking its value under each header\n (0..resultColumns[:maxRowIndex]).each do |rowIndex|\n csvString << \"\\r\\n\"\n csvString << headers.map{ |header|\n self.filterValue(resultColumns[:columns][header][rowIndex])\n }.join(@options[:delimiter])\n end\n return csvString\n end",
"def ext_attributes(values)\n ext_attrib_list = []\n values.each do |key, value|\n ext_attrib_list << \"#{key.to_s} : #{value}\"\n end\n\n result = ext_attrib_list.join(\",\\n\") \n return result\n end",
"def generate(opts={})\n nd = normalized_data\n ::CSV.generate(opts) do |csv|\n # set header row\n csv << nd[:headers]\n nd[:values].each do |row|\n csv << row\n end\n end\n end",
"def to_csv\n @csv ||= format_csv\n end",
"def csv_attributes\n @csv_attributes ||= Hash[header.column_names.zip(row_array)]\n end",
"def csv(meth)\n @output_type = 'csv'\n @output_filename = \"#{model.link.downcase}_#{normalized_type}.csv\"\n columns = model.columns_for(type, request)\n headers = columns.map{|column| column_label_for(type, request, model, column)}\n EnumCSV.csv(model.send(meth, normalized_type, request, :all_results=>true), :headers=>headers) do |obj|\n columns.map{|column| model.column_value(type, request, obj, column)}\n end\n end",
"def to_csv(options={})\n CSV.generate(options) do |csv|\n csv << self.values.map{|v| v.to_csv}\n end\n end",
"def to_csv\n fields = []\n\n fields << '\"' + key.to_s + '\"'\n fields << '\"' + scientific_name + '\"'\n fields << '\"' + (locality || '') + '\"'\n fields << '\"' + (resource ? resource.name : '') + '\"'\n fields << '\"' + (georef? ? 'TRUE':'FALSE') +'\"'\n fields << '\"' + (date_collected ? date_collected.to_s : '') + '\"'\n fields << '\"' + (latitude ? latitude.to_s : '') + '\"'\n fields << '\"' + (longitude ? longitude.to_s : '') + '\"'\n fields << '\"' + (colcode ? colcode.name : '') + '\"'\n fields << '\"' + (instcode ? instcode.name : '') + '\"'\n fields << '\"' + (catalogue_no ? catalogue_no.to_s : '') + '\"'\n\n fields.join(CSV_SEPARATOR)\n end",
"def generate_csv\n csv_string = CSV.generate do |csv|\n csv << [\"Sl no.\",\"Scheme\",\"IP no.\", \"Patient name\", \"UHID no.\", \"Reg no.\", \"DOA\", \"DOS\", \"DOD\", \"Plan of treatment\", \"Approved Amount\",\"Claim Amount\", \"TDS\",\"Net Amount\",\"Hospital charges\",\"Medicine charges\",\"Implant charges\"]\n sl_no = 1\n @claims.each do |claim|\n csv <<[sl_no,\"#{claim.scheme rescue \"\"}\",\"#{claim.ip_no rescue \"\"}\",\"#{claim.patient_name rescue \"\"}\",\"#{claim.uhid_no rescue \"\"}\",\"#{claim.reg_no rescue \"\"}\",\"#{claim.date_of_admission}\",\"#{claim.date_of_surgery}\",\"#{claim.date_of_discharge}\",\"#{claim.plan_of_treatment rescue \"\"}\",(claim.approved_amount rescue 0.0),(claim.claim_amount rescue 0.0),(claim.tds_amount rescue 0.0),(claim.net_amount rescue 0.0),(claim.hospital_charge rescue 0.0),(claim.medicine_charge rescue 0.0),(claim.implant_charge rescue 0.0)]\n sl_no +=1\n end\n end\n csv_string\n end",
"def export_to_csv(users)\n CSV.open(\"./user.csv\", \"wb\") do |csv|\n csv << Universe.attribute_names\n users.each do |user|\n csv << user.attributes.values\n end\n end\n end",
"def student_to_csv(student)\n\t\tstudent.values\nend",
"def output\n CSV.open(\"test.csv\", \"wb\") do |csv|\n csv << [\"name\",\"type\",\"value\",\"date\"]\n @array_csv.each do |element|\n csv << element\n puts element.inspect\n end\n end\n end",
"def to_csv()\n all = general_info_csv() + \"\\r\\n\" +\n teacher_for_csv() + \"\\r\\n\" +\n contributor_to_csv() + \"\\r\\n\" +\n published_in_csv() + \"\\r\\n\" +\n text_fields_csv()\n all\n end",
"def to_csv\n [@primary_key, \n @name, \n @user_record_name,\n @identifier,\n @cloudkit_last_modified_device,\n @notes.length,\n get_crypto_salt_hex,\n @crypto_iterations,\n get_crypto_key_hex]\n end",
"def to_csv\n CSV.generate { |csv| to_a.each { |r| csv << r } }\n end",
"def to_csv(params, cookies, options = {})\n @cookies = cookies\n @id = \"#{params[:controller]}_#{params[:action]}_#{model_class.name}\" if @id.blank?\n \n before_csv_render\n \n return CSV.generate do |csv|\n tmp = []\n get_visible_columns.each do |col|\n tmp << col.name\n end\n csv << tmp\n @model.each do |mdl|\n tmp = []\n get_visible_columns.each do |col|\n tmp << Misc::nested_send(mdl, col.id)\n end\n csv << tmp\n end\n end\n end",
"def convert_to_csv(records_array)\n CSV.generate(headers: true) do |csv|\n csv << ATTRIBUTES_TO_SELECT\n\n records_array.each do |info|\n csv << info.attributes\n .slice(*ATTRIBUTES_TO_SELECT)\n .values\n end\n end\n end",
"def to_csv\n str = ''\n str << ( columns.join(\",\") + \"\\n\" )\n rows.each { |row|\n next if is_hr(row) || !row_visible(row)\n str << ( row.map{|x|\n x = x.to_s\n x.gsub(/[\\r\\n]/, ' ').gsub(/\\s+/, ' ').gsub('\"', '\"\"')\n }.map{|x| \"\\\"#{x}\\\"\" }.join(\",\") + \"\\n\" )\n }\n str\n end",
"def to_csv(created_at, updated_at)\n csv = Array.new\n csv.push id.to_s\n csv.push last_name.gsub(/\\\\/, \"\")\n csv.push first_name ? first_name.gsub(/\\\\/, \"\") : NULL\n csv.push fed\n csv.push title || NULL\n csv.push gender\n csv.push born ? born.to_s : NULL\n csv.push rating ? rating.to_s : NULL\n csv.push NULL # ICU ID\n csv.push created_at\n csv.push updated_at\n csv.join(\",\")\n end",
"def get_csv\n CSV.generate do |csv|\n csv << ['Name','Student ID','User ID','Role','Email Address','Sections']\n get_feed[:students].each do |student|\n name = student[:last_name] + ', ' + student[:first_name]\n user_id = student[:login_id]\n student_id = student[:student_id]\n email_address = student[:email]\n role = ENROLL_STATUS_TO_CSV_ROLE[student[:enroll_status]]\n sections = sections_to_name_string(student[:sections])\n csv << [name, student_id, user_id, role, email_address, sections]\n end\n end\n end",
"def to_csv\n to_return =[[@primary_key, \n @note.note_id,\n @uuid, \n @type,\n @alt_text,\n @token_identifier]]\n\n return to_return\n end",
"def to_csv\n self.find.map {|row| row.join(',')}.join(\"\\n\")\n end",
"def to_csv\n [@record_id, @email, @phone, @name_prefix, @first_name, @middle_name, @last_name, @name_suffix, @name_phonetic]\n end",
"def to_csv(items)\n\t\trequire \"csv\"\n\t\tlines = []\n\t\titems.each do |item|\n\t\t\tlines << CSV.generate_line(item.values_at(:codec,\n\t\t\t\t:album_artist, :album_title, :year, :publisher, :genre,\n\t\t\t\t:style, :comment, :cover, :disc_number, :disc_title,\n\t\t\t\t:track_number,:track_artist, :track_title, :composer))\n\t\tend\n\t\tlines\n\tend",
"def record_to_csv(record, options = {})\n csv_data = record.serializable_hash.values.collect { |value| escape_for_csv(value) }\n\n [*options[:methods]].each { |x| csv_data << escape_for_csv(record.send(x)) if record.respond_to?(x) } if options[:methods]\n\n csv_data.join( csv_delimiter )\n end",
"def to_csv(options = {})\n CSV.generate(options) do |csv|\n csv << nombres_columnas\n datos # Completa los datos de los taxones por medio del ID\n\n taxones.each do |taxon|\n datos_taxon = []\n\n columnas.split(',').each do |col|\n datos_taxon << eval(\"taxon.#{col}\")\n end\n csv << datos_taxon\n end\n end\n end",
"def write(data_row)\n @csv << data_row.values_at(*@output_fields)\n end",
"def entry_to_csv index\n\t\tcsv_string = \"\\\"\" + @year + \"\\\",\\\"\" + @edition + \"\\\",\" + contents[index].to_csv\n\t\treturn csv_string\n\tend",
"def to_csv_row\n CSV::Row.new(HEADERS, [firstname, lastname, suburb, age, gender])\nend",
"def to_csv\n initialize_generator\n csv_report_generator.records = pull_join\n csv_report_generator.generate_report\n end",
"def generateCSV()\n findCommits\n findLinesOfCode\n\n CSV.open(\"data.csv\", \"wb\") {|csv| @students.to_a.each {|elem| csv << elem} }\nend",
"def print_attribute(name, value, threshold)\n out = ''\n if value.is_a?(Yarpler::Models::Relation)\n out << threshold + ',\"' + name + '\": \"' + print_datastructure(value, threshold + ' ') + '\"' + \"\\n\"\n else\n out << threshold + ',\"' + name + '\": \"' + value.to_s + '\"' + \"\\n\"\n end\n end",
"def to_csv\r\n name\r\n end",
"def getCsvText\r\n sep = \"|\"\r\n t = \"\"\r\n \r\n t << \"Question Number\" + sep \r\n questions.size.times do |i| \r\n t << (i + 1).to_s + sep \r\n end\r\n t << \"Points\"\r\n t << \"\\n\"\r\n \r\n t << \"Correct Answer\" + sep\r\n for question in questions \r\n t << correctAnswerText(question).to_s + sep \r\n end \r\n t << \"\\n\"\r\n \r\n for user in users \r\n t << user.getName + sep\r\n for question in questions \r\n t << answerText(user, question) + sep\r\n end \r\n t << getPoints(user).to_s\r\n t << \"\\n\" \r\n end\r\n return t \r\nend",
"def csv_write (filename = \"students.csv\")\n CSV.open(filename, \"w\") do |row|\n @students.each do |student|\n row << [student[:name], student[:cohort], student[:food]]\n end\n end\nend",
"def save_wizards\n #open the file for writing\n file = File.open(\"wizards.csv\", \"w\")\n # iterate over the array of save_wizards\n @wizards.each do |wizard|\n wizard_data = [wizard[:name], wizard[:house]]\n csv_line = wizard_data.join(\",\")\n file.puts csv_line\n end\n file.close\nend",
"def to_csv\n Formatter::CSV.render(self)\n end",
"def to_csv( separateur = ':' )\n DBC.require( separateur.size == 1, \"#{self}.to_csv: separateur invalide: #{separateur}\" )\n [numero.to_s,\n vie,\n attaque,\n defense,\n tete,\n tetedefense,\n torse,\n torsedefense,\n mains,\n mainsdefense,\n pantalons,\n pantalonsdefense,\n bottes,\n bottesdefense,\n arme,\n armeattaque,\n type.to_s,\n nom,\n puissance\n ].join(separateur)\n end",
"def create_assignment_csv(args)\n [:path, :urls].each{|arg| args[arg] or raise Error::Argument, \"Missing arg '#{arg}'\" }\n headers = ['audio_url',\n 'project_id',\n 'unusual',\n 'chunk',\n 'chunk_hours',\n 'chunk_minutes',\n 'chunk_seconds',\n 'voices_count',\n (1 .. args[:voices].count).map{|n| [\"voice#{n}\", \"voice#{n}title\"]}\n ].flatten\n csv = args[:urls].map do |url|\n [url, \n local.id,\n args[:unusual].join(', '),\n interval_as_time_string,\n interval_as_hours_minutes_seconds.map{|n| (n == 0) ? nil : n },\n args[:voices].count,\n args[:voices].map{|v| [v[:name], v[:description]]}\n ].flatten\n end\n local.file(*args[:path]).as(:csv).write_arrays(csv, headers)\n local.file_path(*args[:path])\n end",
"def create_csv()\n hashes = Transaction.all_as_hashes\n CSV.generate do |csv|\n # Adds the keys as headings on the first line\n csv << hashes.first.keys\n # Iterates through the transactions and populates CSV\n hashes.each do |hash|\n csv << hash.values\n end\n end\n end",
"def process\n @properties.map { |k, v| transform_attr(k, v) }.join\n end",
"def process\n @properties.map { |k, v| transform_attr(k, v) }.join\n end",
"def to_csv\n [\n c1,\n c2,\n c1_card,\n c2_card,\n pair_card,\n c1_mode,\n c2_mode,\n c1_null_count,\n c2_null_count,\n c1_is_sparser?,\n strength\n ]\n end",
"def to_csv_data( options={} )\n inject( [] ) do |arr,model_instance|\n arr.push( *model_instance.to_csv_data( options ) )\n end\n end",
"def addElectroporationData(csv, hydra_list)\n columns = ['last_electroporated', 'gap_size', 'pulse_length', 'field_strength', 'voltage', 'mass_dna']\n hydra_list.each do |hydra|\n csv << hydra.id.to_s\n csv << \", \"\n columns.each{|key| csv << hydra.get(key.to_sym).to_s << \", \"}\n csv = csv[0,csv.length-2]\n csv << \"\\n\"\n end\n return csv\n end",
"def write_to_csv(type)\n fields = return_fields(type)\n records = get_records(type)\n file_name = generate_name(type)\n\n CSV.open(file_name, \"wb:UTF-8\") do |file|\n @logger.info \"Opened #{file_name} for export\"\n file << fields\n records.each do |record|\n arr = []\n fields.each do |field|\n arr << record.send(field)\n arr.map!(&method(:remove_quotes))\n end\n file << arr\n end\n end\n end",
"def csv=(klass); end",
"def csv_print_to_file\n CSV.open(\"metadata_output.csv\", \"w\") do |csv|\n metadata.each do |key, value|\n if value.class == Hash\n csv << [key]\n print_hash_to_csv(value, csv)\n else\n csv << [key, value]\n end\n end\n end\n end",
"def to_csv\n self.data.to_csv\n end",
"def csv(opts = {})\n Squib.csv(opts)\n end",
"def write_record csv = nil\n csv ||= self.csv\n raise 'Record#add_record_to_csv: no associated CSV object.' unless csv\n\n csv << values\n end",
"def as_csv\n CSV.generate do |csv|\n csv << BUSINESS_LINE_OPTIONS\n tasks.each do |task|\n csv << [\n business_line.name,\n task.appeal_id,\n task.appeal_type,\n task.appeal.claimant&.name,\n task.appeal.request_issues.size,\n task.appeal.decision_issues.size,\n task.appeal.veteran_file_number,\n task.appeal.intake&.user&.css_id,\n task.type,\n task.id,\n \"https://appeals.cf.ds.va.gov#{business_line.tasks_url}/tasks/#{task.id}\",\n task.assigned_to.try(:name) || task.assigned_to.try(:css_id),\n task.created_at.strftime(\"%Y-%m-%d\"),\n task.closed_at.strftime(\"%Y-%m-%d\")\n ].flatten\n end\n end\n end",
"def csv_write filename , *field\n CSV.open(filename, \"a\") do |csv|\n csv << field\n end\nend",
"def row_for(record, attributes = @attributes)\n attributes.map { |attr| record.send(attr).to_s }\n end",
"def data_input\n @students.each do |obj|\n File.open(\"students_directory.csv\", \"a\") { |file| file.puts \"#{obj[:name]}, #{obj[:age]}, #{obj[:gender]}\" }\n end\nend",
"def csv\n data = digital_object_imports.map(&:import_data)\n Bulwark::StructuredCSV.generate(data)\n end",
"def save_students\n#CSV writing notation\nCSV.open(\"students.csv\", \"w\") do |student|\n @students.each do |student|\n student_data = [student[:name], student[:cohort], student[:height], student[:eyecolour]]\n csv_line = student_data.join(\",\")\n file.puts(csv_line)\n end\n option_selected\nend\nend",
"def row(part, fields)\n \n data = \"\"\n \n # TODO: Add in notes, grain direction.\n fields.each { |f|\n \n # val = eval f[1] # Eval can be dangerous if passing something wrong into it...\n val = part[f[1]]\n \n # Check if the val is a float, so we can perform fraction conversion.\n if val.class == Float\n val = val.to_fraction(@round_dimensions)\n end\n \n data += \"#{val.to_s}\"\n data += f == fields.last ? \"\\n\" : \",\"\n\n puts \"[CSVRenderer.row] row values: #{f[0]}, #{val}\\n\\n\" if $cutlister_debug\n \n }\n \n data\n \n end",
"def save_students\n file = File.open(\"students.csv\", \"w\")\n @students.each do |student|\n student_data = [student[:name], student[:cohort], student[:hobby], student[:country]]\n csv_line = student_data.join(\",\")\n file.puts csv_line\n end\n file.close\nend",
"def to_s; map { |name, val| \"#{val['name']}=#{val}\" }.join(','); end",
"def write\n row.set_attribute(attr_name, contents)\n end",
"def attribute_string\n s = []\n s << \"PROGRAM-ID=#{ (program_id || 1).to_i }\"\n s << \"BANDWIDTH=#{ bandwidth.to_i }\"\n s << \"CODECS=\\\"#{ codecs }\\\"\" if codecs\n s << \"RESOLUTION=#{ resolution }\" if resolution\n s.join(',')\n end",
"def attribute_values \n @attribute_values = Hash.new\n @attribute_values[:influencers] = \"Influencers: \" + self.influencers.to_s\n @attribute_values[:specialties] = \"Specialities: \" + self.specialties.to_s\n @attribute_values[:compensation] = \"Compensation: \" + self.compensation.to_s\n @attribute_values[:experience] = \"Experience: \" + self.experience.to_s\n \n @attribute_values[:genre] = \"Genre(s): \"\n if self.genre != nil\n self.genre.split(\",\").each do |genre|\n @attribute_values[:genre] += genre + \", \"\n end\n @attribute_values[:genre] = @attribute_values[:genre][0, @attribute_values[:genre].length-2]\n end\n \n @attribute_values\n end",
"def attribute_values \n @attribute_values = Hash.new\n @attribute_values[:influencers] = \"Influencers: \" + self.influencers.to_s\n @attribute_values[:specialties] = \"Specialities: \" + self.specialties.to_s\n @attribute_values[:compensation] = \"Compensation: \" + self.compensation.to_s\n @attribute_values[:experience] = \"Experience: \" + self.experience.to_s\n \n @attribute_values[:genre] = \"Genre(s): \"\n if self.genre != nil\n self.genre.split(\",\").each do |genre|\n @attribute_values[:genre] += genre + \", \"\n end\n @attribute_values[:genre] = @attribute_values[:genre][0, @attribute_values[:genre].length-2]\n end\n \n @attribute_values\n end",
"def attribute_values \n @attribute_values = Hash.new\n @attribute_values[:influencers] = \"Influencers: \" + self.influencers.to_s\n @attribute_values[:specialties] = \"Specialities: \" + self.specialties.to_s\n @attribute_values[:compensation] = \"Compensation: \" + self.compensation.to_s\n @attribute_values[:experience] = \"Experience: \" + self.experience.to_s\n \n @attribute_values[:genre] = \"Genre(s): \"\n if self.genre != nil\n self.genre.split(\",\").each do |genre|\n @attribute_values[:genre] += genre + \", \"\n end\n @attribute_values[:genre] = @attribute_values[:genre][0, @attribute_values[:genre].length-2]\n end\n \n @attribute_values\n end",
"def to_cookiestxt_line(linefeed = \"\\n\")\n [\n @domain,\n @for_domain ? True : False,\n @path,\n @secure ? True : False,\n @expires.to_i.to_s,\n @name,\n @value\n ].join(\"\\t\") << linefeed\n end",
"def to_csv_array\n base_url = \"http://www.lincomp.ch\"\n c = Cart.new\n c.add_product(self)\n shipped_price = (taxed_price.rounded + c.shipping_cost.rounded)\n availability = \"48h\"\n if stock < 1\n availability = \"ask\"\n end\n unless product_pictures.main.empty?\n image_link = base_url + product_pictures.main.first.file.url unless product_pictures.main.first.file.blank?\n end\n unless attachments.empty?\n factsheet_link = base_url + attachments.first.file.url unless attachments.first.file.blank?\n end\n unless categories.empty?\n categories_arr = [] \n categories.each do |c|\n categories_arr << c.fully_qualified_name\n end\n categories_string = categories_arr.join(\"|\")\n end\n\n # We use string interpolation notation (#{foo}) so that nil errors are already\n # handled gracefully without any extra work.\n [\"#{id}\", \"#{manufacturer}\" ,\"#{manufacturer_product_code}\", \"#{name}\",\\\n \"#{description}\", \"#{price.rounded}\", \"#{taxed_price.rounded}\", \"#{shipped_price}\",\\\n \"#{taxes}\", \"#{c.shipping_cost.rounded}\", \"#{stock}\", \"#{availability}\", \"#{weight}\",\\\n \"#{base_url}/products/#{self.id}\",\"#{image_link}\",\"#{factsheet_link}\",\"#{ean_code}\",\\\n \"#{categories_string}\",\"#{c.total_taxed_shipping_price.rounded}\"]\n end",
"def to_csv\n map {|row|\n row.map {|f|\n f =~ /[[:punct:]]/ ? '\"' + f.gsub(/\"/, '\"\"') + '\"' : f }.\n join(\",\")}.\n join(\"\\n\")\n end",
"def orders_to_csv\n orders.map { |order| order.id}.join(\", \")\n end",
"def save_students\n file = File.open(\"students.csv\",\"w\")\n @students.each do |student|\n student_data = [student[:name], student[:cohort]]\n csv_line = student_data.join(\",\")\n file.puts csv_line\n end\n file.close\nend",
"def genCsvSpeed()\n csv = [] ;\n to_a.each{|analyzer|\n csv.push(analyzer.genCsvRowSpeed()) ;\n }\n return csv ;\n end",
"def to_attr_list\n heading.to_attr_list\n end",
"def generate_csv\n @project = Project.find(params[:id])\n \n content_type = if request.user_agent =~ /windows/i\n ' application/vnd.ms-excel '\n else\n ' text/csv '\n end\n \n project_net = @project.find_all_connections(friend = true, follower = false) \n \n CSV::Writer.generate(output = \"\") do |csv|\n csv << [\"DL n=\" + @project.persons.count.to_s ]\n csv << [\"format = edgelist1\"]\n csv << [\"labels embedded:\"]\n csv << [\"data:\"]\n project_net.each do |entry|\n csv << [entry[0], entry[1], \"1\"]\n end\n @project.persons.each do |person|\n csv << [person.username]\n end\n end\n send_data(output,\n :type => content_type,\n :filename => @project.name.to_s + \"_FF_SNA.csv\")\n end",
"def generate_itemdef_line(type,name,isData,isDrill)\n itemdef=File.new('itemdef.csv','a')\n itemdef << name.underscore.humanize << \",\" << name << \",\" << type << \",\" << isData << \",\" << isDrill << \"\\n\"\n itemdef.close;\n end"
] | [
"0.71113497",
"0.7096309",
"0.661558",
"0.65616846",
"0.6488295",
"0.64558345",
"0.63784313",
"0.6370484",
"0.6339045",
"0.6316517",
"0.6316517",
"0.62874985",
"0.62566775",
"0.6248133",
"0.6228902",
"0.6189181",
"0.6157887",
"0.6132368",
"0.61217993",
"0.6103656",
"0.6100651",
"0.6096515",
"0.6072202",
"0.6059695",
"0.6057",
"0.60382026",
"0.60361254",
"0.6016092",
"0.5989338",
"0.5986753",
"0.5979494",
"0.5963484",
"0.59513015",
"0.5935953",
"0.5926043",
"0.59189665",
"0.59047496",
"0.5892814",
"0.5891261",
"0.5888189",
"0.5869416",
"0.5853944",
"0.5811384",
"0.5808273",
"0.58028615",
"0.57900596",
"0.5781382",
"0.5754387",
"0.5750917",
"0.5744706",
"0.57241595",
"0.57214046",
"0.57199854",
"0.57181925",
"0.57179135",
"0.57156736",
"0.57128304",
"0.57030225",
"0.56931907",
"0.56895816",
"0.56882143",
"0.5661483",
"0.56584895",
"0.5656476",
"0.56547695",
"0.5634798",
"0.56234455",
"0.56234455",
"0.56166595",
"0.5593037",
"0.55878645",
"0.55762297",
"0.55714697",
"0.5567771",
"0.55633634",
"0.55595464",
"0.55352896",
"0.55347556",
"0.5524445",
"0.5519243",
"0.5508424",
"0.55033946",
"0.54996717",
"0.54995376",
"0.54955405",
"0.5495181",
"0.5484459",
"0.5476377",
"0.5474346",
"0.5474346",
"0.5474346",
"0.5468588",
"0.546576",
"0.54651016",
"0.5463888",
"0.5463578",
"0.54568636",
"0.5449349",
"0.5447763",
"0.54369396"
] | 0.56636155 | 61 |
Constructs an instance of Padrino::PathRouter::Compiler | def initialize(routes)
@routes = routes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile\n if routes.any?\n eval(compiled_statement, binding, \"Generated Code for Router\", 1)\n else\n reset!\n end\n end",
"def compile\n Tipsy::Runners::Compiler.new(@args, @site)\n end",
"def mkcompiler source=''\n VishCompiler.new source\nend",
"def compiler\n @compiler ||= Compiler.new(self)\n end",
"def compiler\n @compiler ||= Compiler.new(self)\n end",
"def compile\n if routes.any?\n eval(compiled_statement, binding, \"Generated Code for Merb::Router#match(#{__FILE__}:#{__LINE__})\", 1)\n else\n reset!\n end\n end",
"def make_compiler(trim_mode)\n ERB::Compiler.new(trim_mode)\n end",
"def compile\n @clazz = eval(@controller) if not @controller.blank?\n create_segments()\n route_str = \"\"\n i = 0\n @segments.each { |seg|\n case seg\n when ControllerSegment\n @controller = seg\n route_str << \"([^/]+)\"\n seg.pos = (i += 1)\n when ActionSegment\n @action = seg\n route_str << \"([^/]+)?\"\n seg.pos = (i += 1)\n when ParamSegment\n #@action = seg\n route_str << \"([^/]+)\"\n seg.pos = (i += 1)\n else\n route_str << seg.path\n end \n }\n puts route_str\n @regex = Regexp.new(route_str)\n end",
"def create_compiler()\n if current_state == :initial\n AsapInitialCompiler.new(self)\n elsif current_state == :coverage\n AsapProfilingCompiler.new(self)\n elsif current_state == :optimize\n AsapOptimizingCompiler.new(self)\n else\n raise \"Unknown ASAP state: #{current_state}\"\n end\n end",
"def compile!\n return if compiled?\n @regexps = @routes.map.with_index do |route, index|\n route.index = index\n /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @regexps = recursive_compile(@regexps)\n @compiled = true\n end",
"def initialize\n @router = Router.new(ROUTES)\n end",
"def compile\n end",
"def initialize\n compiler = Treetop::Compiler::GrammarCompiler.new\n @where = File.expand_path(File.dirname(__FILE__))\n grammar = File.join(@where, 'seqpar.treetop')\n output = File.join(@where, 'seqpar.rb')\n compiler.compile(grammar, output)\n load output\n File.delete(output)\n @parser = SeqParParser.new\n end",
"def program\n @compile\n end",
"def compile!\n return if compiled?\n @routes.each_with_index do |route, index|\n route.index = index\n route.regexp = /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @compiled = true\n end",
"def build_compiler\n node_name = nodename(:function)\n fact_values = facts_hash(node_name)\n\n # if we specify a pre_condition, we should ensure that we compile that\n # code into a catalog that is accessible from the scope where the\n # function is called\n Puppet[:code] = pre_cond\n\n node_options = {\n :parameters => fact_values,\n }\n\n stub_facts! fact_values\n\n node = build_node(node_name, node_options)\n\n compiler = Puppet::Parser::Compiler.new(node)\n compiler.compile\n compiler\n end",
"def initialize()\n #@source = aSourceTemplate\n #@representation = compile(aSourceTemplate)\n end",
"def define_compiler(base_class, args, &block)\n\t\t\tcompiler_class = Class.new(base_class)\n\t\t\tcompiler_class.class_eval(&block)\n\t\t\tcompiler = compiler_class.new(args)\n\t\t\toutput_dir = ''\n\t\t\toutput_tags = []\n\t\t\tif args[:output_dir]\n\t\t\t\toutput_dir = args[:output_dir]\n\t\t\telsif args[:output_name]\n\t\t\t\toutput_dir, args[:output_name] = File.split(args[:output_name])\n\t\t\t\toutput_tags << $1 if args[:output_name] =~ /(\\.[^\\.]+)$/\n\t\t\tend\n\t\t\toutput_tags << args[:output_tag] if args[:output_tag]\n\t\t\toutput_tags.concat(args[:output_tags]) if args[:output_tags]\n\t\t\t\n\t\t\traise LaceError.new(\"Compiler definition is missing an :input_pattern\") unless args[:input_pattern]\n\t\n\t\t\tadd_compiler(output_dir, compiler, args[:input_pattern], args[:dependency_pattern], output_tags)\n\t\t\treturn compiler_class\n\t\tend",
"def build_parser\n code = ''\n\n %w[opal/ruby/nodes opal/ruby/parser opal/ruby/ruby_parser].each do |src|\n full = File.join OPAL_PATH, 'opal_lib', src + '.rb'\n compiled = compile_source full\n code += \"opal.register('#{src}.rb', #{compiled});\"\n end\n\n code += build_stdlib 'racc/parser.rb', 'strscan.rb', 'dev.rb'\n code += \"opal.require('dev');\"\n\n code\n end",
"def initialize\n @router = Router.new\n add_head_not_allowed_methods_and_options_methods\n self.class.endpoints.each do |endpoint|\n endpoint.mount_in(@router)\n end\n\n @router.compile!\n @router.freeze\n end",
"def compile\n @instance ||= new\n end",
"def compile_to_ruby_source_as parser_class_name\r\n result = \"class #{parser_class_name} < Dhaka::CompiledParser\\n\\n\"\r\n result << \" self.grammar = #{grammar.name}\\n\\n\"\r\n result << \" start_with #{start_state.id}\\n\\n\"\r\n states.each do |state|\r\n result << \"#{state.compile_to_ruby_source}\\n\\n\"\r\n end\r\n result << \"end\"\r\n result\r\n end",
"def compiler=(name) #:nodoc:\n cls = Compiler.select(name) or raise ArgumentError, \"No #{name} compiler available. Did you install it?\"\n return self if cls === @compiler\n @compiler = cls.new(project, options)\n from Array(cls.sources).map { |path| project.path_to(:source, usage, path) }.\n select { |path| File.exist?(path) } if sources.empty?\n into project.path_to(:target, usage, cls.target) unless target\n with Array(@compiler.dependencies)\n self\n end",
"def create\n @compiler = Compiler.new(params[:compiler])\n\n respond_to do |format|\n if @compiler.save\n format.html { redirect_to @compiler, notice: 'Compiler was successfully created.' }\n format.json { render json: @compiler, status: :created, location: @compiler }\n else\n format.html { render action: \"new\" }\n format.json { render json: @compiler.errors, status: :unprocessable_entity }\n end\n end\n end",
"def dsl\n Nanoc::CompilerDSL.new(self, @compiler.site.config)\n end",
"def compile_plan()\n return Plan::ParserPlan.build( self )\n end",
"def compile\n if @pattern.kind_of? String then\n @pattern = Regexp.new(@pattern)\n end\n @clazz = eval(@controller)\n end",
"def compiled_path=(path); end",
"def compile(source)\n ast = transformer.apply(parser.parse(source))\n ast.compile\n end",
"def initialize(compiler, for_source)\n raise \"no compiler\" unless compiler\n raise \"no source\" unless for_source\n @compiler = compiler\n @source = for_source\n @source_used = false\n @names = {}\n end",
"def initialize(router)\n @router = router\n end",
"def compilelet\n\n end",
"def basic_compiler\n @basic_compiler ||= indirection.terminus(config['basic_compiler'])\n end",
"def compile\n raise NotImplementedError\n end",
"def initialize(router)\n @router = router\n end",
"def compile_parser_plan( name )\n case name\n when Model::Markers::Reference, Plan::Symbol\n name = name.name\n end\n\n assert( @production_sets.member?(name), \"not a valid start rule name\" )\n state_table = StateTable.build( self, name )\n\n return ParserPlan.new( self, name.grammar, state_table )\n end",
"def initialize(name:, app: nil, path:, constraints: {}, required_defaults: [], defaults: {}, request_method_match: nil, precedence: 0, scope_options: {}, internal: false, source_location: nil)\n @name = name\n @app = app\n @path = path\n\n @request_method_match = request_method_match\n @constraints = constraints\n @defaults = defaults\n @required_defaults = nil\n @_required_defaults = required_defaults\n @required_parts = nil\n @parts = nil\n @precedence = precedence\n @path_formatter = @path.build_formatter\n @scope_options = scope_options\n @internal = internal\n @source_location = source_location\n\n @ast = @path.ast.root\n @path.ast.route = self\n end",
"def set_up\n @compiler = VishCompiler.new('')\n @compiler.default_optimizers[:constant_folder] = true\n end",
"def initialize(context, owner, file)\n# puts \"calling Compiler on #{file}\"\n @context = context\n @owner = owner\n @file = file\n utterance = ''\n File.open(file) do |f|\n f.each_line { |l| utterance << l }\n end\n # Since this is a new compiler, we need to wipe out any old compiler catalog stuff\n # Compiler.init_catalog(context)\n planner = OverlogPlanner.new(@context, utterance)\n planner.plan\n @the_program = planner.program\t\t\n\n # typeChecker = TypeChecker.new(@runtime, @the_program)\n # This is an XTC-ism\n # args = [\"-no-exit\", \"-silent\", file]\n # run(args)\n\n # if (runtime.errorCount > 0) then\n # @the_program.definitions.each { |table| Table.drop(table.name) }\n # end\n end",
"def compile\n self.class.compile(id)\n end",
"def compile(*args)\n\t filtered_args, vm = prepare_call(args)\n\t CompiledCall.new(self, filtered_args, vm)\n\tend",
"def create_method_from_source(compiler)\n sol_method = @receiver.ct_type.object_class.resolve_method!(@name)\n return nil unless sol_method\n #puts \"#{sol_method.name} , adding to #{@receiver.ct_type.object_class.name}\"\n @receiver.ct_type.object_class.add_instance_method(sol_method)\n sol_method.create_callable_method_for(@receiver.ct_type)\n new_compiler = sol_method.compiler_for(@receiver.ct_type)\n compiler.add_method_compiler(new_compiler)\n new_compiler.callable\n end",
"def compile_parser(base, grammar_or_parser, opts={})\r\n compile(Class.new(base), grammar_or_parser, opts)\r\n end",
"def compile( compiler )\n parfait_block = self.parfait_block(compiler)\n block_compiler = SlotMachine::BlockCompiler.new( parfait_block , compiler.get_method )\n head = body.to_slot( block_compiler )\n block_compiler.add_code(head)\n compiler.add_method_compiler(block_compiler)\n end",
"def build_compiler(node_name, fact_values)\n node_options = {\n :parameters => fact_values,\n }\n\n stub_facts! fact_values\n\n node = build_node(node_name, node_options)\n\n compiler = Puppet::Parser::Compiler.new(node)\n compiler.compile\n compiler\n end",
"def compile\n lexer = Bolverk::ASM::Lexer.new(@stream)\n tokens = lexer.scan\n\n parser = Bolverk::ASM::Parser.new(tokens)\n parse_tree = parser.parse\n\n generator = Bolverk::ASM::Generator.new(parse_tree)\n source = generator.generate\n\n return source\n end",
"def compile(source)\n regexp = Regexp.compile(source)\n expression = parse(regexp)\n Regexp.compile(expression.to_s(true), expression.flags)\n end",
"def compile(str)\n @compiled[str]\n end",
"def source_compiler\n @source_compiler ||= Sprockets::Environment.new.tap do |env|\n env.append_path File.expand_path(\"./js\", File.dirname(__FILE__))\n end\n end",
"def compile(name)\n Rule::Compile.build(file(name))\n end",
"def compile\n @re = build_re(@__opts__)\n\n # Define dynamic patterns\n tlds = @__tlds__.dup\n\n onCompile\n\n tlds.push(TLDS_2CH_SRC_RE) if (!@__tlds_replaced__)\n tlds.push(@re[:src_xn])\n\n @re[:src_tlds] = tlds.join('|')\n @re[:email_fuzzy] = Regexp.new(@re[:tpl_email_fuzzy].gsub('%TLDS%', @re[:src_tlds]), true)\n @re[:link_fuzzy] = Regexp.new(@re[:tpl_link_fuzzy].gsub('%TLDS%', @re[:src_tlds]), true)\n @re[:link_no_ip_fuzzy] = Regexp.new(@re[:tpl_link_no_ip_fuzzy].gsub('%TLDS%', @re[:src_tlds]), true)\n @re[:host_fuzzy_test] = Regexp.new(@re[:tpl_host_fuzzy_test].gsub('%TLDS%', @re[:src_tlds]), true)\n\n #\n # Compile each schema\n #\n\n aliases = []\n\n @__compiled__ = {} # Reset compiled data\n\n schemaError = lambda do |name, val|\n raise Error, ('(LinkifyIt) Invalid schema \"' + name + '\": ' + val)\n end\n\n @__schemas__.each do |name, val|\n\n # skip disabled methods\n next if (val == nil)\n\n compiled = { validate: nil, link: nil }\n\n @__compiled__[name] = compiled\n\n if (val.is_a? Hash)\n if (val[:validate].is_a? Regexp)\n compiled[:validate] = createValidator(val[:validate])\n elsif (val[:validate].is_a? Proc)\n compiled[:validate] = val[:validate]\n else\n schemaError(name, val)\n end\n\n if (val[:normalize].is_a? Proc)\n compiled[:normalize] = val[:normalize]\n elsif (!val[:normalize])\n compiled[:normalize] = createNormalizer()\n else\n schemaError(name, val)\n end\n next\n end\n\n if (val.is_a? String)\n aliases.push(name)\n next\n end\n\n schemaError(name, val)\n end\n\n #\n # Compile postponed aliases\n #\n\n aliases.each do |an_alias|\n if (!@__compiled__[@__schemas__[an_alias]])\n # Silently fail on missed schemas to avoid errons on disable.\n # schemaError(an_alias, self.__schemas__[an_alias]);\n else\n @__compiled__[an_alias][:validate] = @__compiled__[@__schemas__[an_alias]][:validate]\n @__compiled__[an_alias][:normalize] = @__compiled__[@__schemas__[an_alias]][:normalize]\n end\n end\n\n #\n # Fake record for guessed links\n #\n @__compiled__[''] = { validate: nil, normalize: createNormalizer }\n\n #\n # Build schema condition, and filter disabled & fake schemas\n #\n slist = @__compiled__.select {|name, val| name.length > 0 && !val.nil? }.keys.map {|str| escapeRE(str)}.join('|')\n\n # (?!_) cause 1.5x slowdown\n @re[:schema_test] = Regexp.new('(^|(?!_)(?:[><\\uff5c]|' + @re[:src_XPCc] + '))(' + slist + ')', 'i')\n @re[:schema_search] = Regexp.new('(^|(?!_)(?:[><\\uff5c]|' + @re[:src_XPCc] + '))(' + slist + ')', 'i')\n @re[:schema_at_start] = Regexp.new('^' + @re[:schema_search].source, 'i')\n\n @re[:pretest] = Regexp.new(\n '(' + @re[:schema_test].source + ')|(' + @re[:host_fuzzy_test].source + ')|@',\n 'i'\n )\n\n #\n # Cleanup\n #\n\n resetScanCache\n end",
"def compile!\n @directives.freeze unless @directives.frozen?\n\n @result ||= compile.freeze\n end",
"def compile_program(program)\n @compile_counter = 0\n program.each_line do |line| \n self.compile_line(line) \n end\n end",
"def compile\n compile_body\n compile_head\n \n builder = ScriptBuilder.new @template\n builder.build_for_page @filename\n end",
"def compile template\n @program = Program.new(\n @options[:result_variable] || :_erbout,\n @options[:continue_result]\n )\n\n # convert \"% at beginning of line\" usage into <% normal %> usage\n if @options[:shorthand]\n i = 0\n contents, directives =\n template.split(/(#{DIRECTIVE_HEAD}#{DIRECTIVE_BODY}#{DIRECTIVE_TAIL})/mo).\n partition { (i += 1) & 1 == 1 } # even/odd partition\n\n # only process the content; do not touch the directives\n # because they may contain code lines beginning with \"%\"\n contents.each do |content|\n # process unescaped directives\n content.gsub! %r/^(#{SPACING})(#{SHORTHAND_HEAD}#{SHORTHAND_BODY})#{SHORTHAND_TAIL}/o, '\\1<\\2%>'\n\n # unescape escaped directives\n content.gsub! %r/^(#{SPACING})(#{SHORTHAND_HEAD})#{SHORTHAND_HEAD}/o, '\\1\\2'\n end\n\n template = contents.zip(directives).join\n end\n\n # convert single-line comment directives into nothing\n template.gsub!(/^#{SPACING}#{DIRECTIVE_HEAD}##{DIRECTIVE_BODY}#{DIRECTIVE_TAIL}#{SPACING}$/, '')\n\n # translate template into Ruby code\n @margins = []\n @crowns = []\n\n directive_matches = template.scan(/#{\n '((%s)%s(%s)%s(%s)(%s?))' % [\n SPACING,\n DIRECTIVE_HEAD,\n DIRECTIVE_BODY,\n DIRECTIVE_TAIL,\n SPACING,\n NEWLINE,\n ]\n }/mo)\n\n directive_matches.each do |match|\n # iteratively whittle the template\n before_content, after_content = template.split(match[0], 2)\n template = after_content\n\n # process the raw content before the directive\n process_content before_content\n\n # process the directive itself\n args = match + [after_content]\n process_directive(*args)\n end\n\n # process remaining raw content *after* last directive\n process_content template\n\n # handle missing ends\n if @options[:infer_end]\n @margins.each { emit_end }\n else\n warn \"There are at least #{@margins.length} missing '<% end %>' statements in the eRuby template.\" unless @margins.empty?\n end\n\n @program.compile\n end",
"def to_risc(compiler)\n build_with(compiler.builder(self))\n end",
"def initialize(output, results, message_compiler, path)\n @output = output\n @results = results\n @message_compiler = message_compiler\n @path = path\n end",
"def compiled_path; end",
"def compile(rule, rs, is_reset=false)\n evaluated = evaluate(rule,rs,is_reset)\n return Compiled.new(\n rule,\n evaluated,\n codes(evaluated)\n ).freeze\n end",
"def initialize(compiler, sequence:, var:)\n @seq = sequence # The node to be compiled\n @seq_var = var # Holds the name of the variable holding the AST::Node we are matching\n super(compiler)\n end",
"def compile!\n raise NotImplementedError\n end",
"def compile(spec)\n handle_exceptions {\n @oneline = spec.index(\"\\n\").nil?\n @spec = spec.sub(/^\\s*\\n/, \"\")\n @file = find_caller_file\n @tokens = Lexer.lex(name, @spec, @oneline)\n ast = Parser.parse(tokens)\n\n help_spec = (@help == true ? \"-h,help\" : @help)\n version_spec = (@version == true ? \"--version\" : @version)\n quiet_spec = (@quiet == true ? \"-q,quiet\" : @quiet)\n verbose_spec = (@verbose == true ? \"+v,verbose\" : @verbose)\n debug_spec = (@debug == true ? \"--debug\" : @debug)\n\n @quiet_option = \n ast.inject_option(quiet_spec, \"Quiet\", \"Do not write anything to standard output\") if @quiet\n @verbose_option = \n ast.inject_option(verbose_spec, \"Increase verbosity\", \"Write verbose output\") if @verbose\n @debug_option = \n ast.inject_option(debug_spec, \"Write debug information\") if @debug\n @help_option = \n ast.inject_option(help_spec, \"Write short or long help\") { |option|\n short_option = option.short_names.first \n long_option = option.long_names.first\n [\n short_option && \"#{short_option} prints a brief help text\",\n long_option && \"#{long_option} prints a longer man-style description of the command\"\n ].compact.join(\", \")\n } if @help\n @version_option = \n ast.inject_option(version_spec, \"Write version number and exit\") if @version\n\n @grammar = Analyzer.analyze(ast)\n }\n self\n end",
"def initialize(options = {}, &block)\n self.path = options[:path]\n self.rules = options[:rules]\n self.prefix = options[:prefix] || ''\n end",
"def prepare!\n @prepared = true\n @routes.sort_by!(&:order)\n self.class.setup_compiler! && compile! if Pendragon.configuration.enable_compiler?\n end",
"def compile_string(string, outFile)\n @in, @out = StringScanner.new(string), outFile\n compile_program # call the main compile method to start compiling\n end",
"def compile\n robot.handlers.each do |handler|\n next unless handler.respond_to?(:http_routes)\n\n handler.http_routes.each { |route| router.add_route(route) }\n end\n end",
"def compiled_source\n set_strict_locals = strict_locals!\n source = encode!\n code = @handler.call(self, source)\n\n method_arguments =\n if set_strict_locals\n \"output_buffer, #{set_strict_locals}\"\n else\n \"local_assigns, output_buffer\"\n end\n\n # Make sure that the resulting String to be eval'd is in the\n # encoding of the code\n source = +<<-end_src\n def #{method_name}(#{method_arguments})\n @virtual_path = #{@virtual_path.inspect};#{locals_code};#{code}\n end\n end_src\n\n # Make sure the source is in the encoding of the returned code\n source.force_encoding(code.encoding)\n\n # In case we get back a String from a handler that is not in\n # BINARY or the default_internal, encode it to the default_internal\n source.encode!\n\n # Now, validate that the source we got back from the template\n # handler is valid in the default_internal. This is for handlers\n # that handle encoding but screw up\n unless source.valid_encoding?\n raise WrongEncodingError.new(source, Encoding.default_internal)\n end\n\n if Template.frozen_string_literal\n \"# frozen_string_literal: true\\n#{source}\"\n else\n source\n end\n end",
"def compile\n read_yml if File.exists?(@project)\n\n default_options = {}\n other_options = {}\n\n @compile_options.each do |k,v| \n if /default/.match(k)\n default_options[k] = v\n else\n other_options[k] = v\n end\n end\n\n command = \"#{@flex_sdk_bin}#{@compiler}\"\n other_options.each { |k,v| command += \" -#{k}=\\\"#{[v].flatten.join ','}\\\"\" }\n default_options.each { |k,v| command += \" -#{k}=\\\"#{[v].flatten.join ','}\\\"\" }\n command += \" #{@document_class}.as\"\n\n# puts command\n# TextMate.exit_show_html\n\n @command = command\n#TextMate.exit_show_html\n if process_output command\n# load_debugger\n display_web_player #unless ARGV[0] = \"--display\"\n# display_player\n end\nend",
"def compile!(view); end",
"def compile(src, options = '')\n return self if src == @source\n\n @mutex.lock\n begin\n @program = @context.create_program src\n # Compilte the program on all available devices in the context.\n @program.build @context.devices, options, nil\n @source = src.freeze\n rescue CLError => e\n if e.program_build_failed?\n raise ProgramBuildError, @program.build_info(@context.default_device, CL_PROGRAM_BUILD_LOG)\n else\n raise e\n end\n ensure\n @mutex.unlock\n end\n self\n end",
"def compiledo\n\n end",
"def to_proc\n lambda { |path| new(path) }\n end",
"def gen_router\n filename = 'config/router.rb'\n bakname = 'config/router.rb~'\n File.delete(bakname) if File.exist?(bakname)\n File.rename(filename, bakname) if File.exist?(filename)\n File.open(filename, \"w\") do |file|\n file.puts(router_content)\n end\n end",
"def compile(source, mapper)\n raise NotImplementedError\n end",
"def cifrom(compiler)\n CodeInterpreter.new(compiler.bc, compiler.ctx)\nend",
"def compile(mod, grammar_or_parser, opts={})\r\n model = parser_model(grammar_or_parser)\r\n mod.module_eval ParserGenerator.code_for(model, opts)\r\n mod\r\n end",
"def build_circuit(name, path = '')\n @definitions[name].each_pair do |input, outputs|\n ns_input = Pin.new(path + input)\n outputs = *outputs\n\n outputs.each do |output|\n @circuit.add_wire(ns_input, Pin.new(path + output) )\n build_subcircuit(ns_input) if input.include?('#')\n end\n end\n end",
"def compile_exec()\n compile\n exec\n end",
"def compile_template_path\n \"#{__class__.to_s.snake_case.gsub('::','/')}/#{@__type}\"\n end",
"def initialize_compiler\n self.compile_tasks = [:multi, :test, :check_manifest]\n end",
"def compile\n prep\n client.setup_run_context\n end",
"def initialize(path)\n self.class.script = self\n @path = path\n @rules = []\n @default_action = lambda {}\n end",
"def initialize(executable_path,rule_directory)\n\t\t@executable_path = executable_path\n\t\t@rule_directory = rule_directory\n\tend",
"def initialize(resource_creator = method(:create_resource))\n @routes = []\n @resource_creator = resource_creator\n end",
"def initialize(pattern, *options)\n case pattern\n when ::Regexp, PCRE2::Regexp\n @source = pattern.source\n else\n @source = pattern\n end\n\n @pattern_ptr = Lib.compile_pattern(source, options)\n end",
"def initialize(compilers = [])\n @method_compilers = nil\n compilers.each{|c| add_compiler(c)}\n end",
"def initialize(path = nil, options = nil)\n self.path = path\n self.options = options\n self.source = options[:source] if options\n self.source = LaravelRepo if not @source\n end",
"def compile(path)\n content = File.read(path)\n %{\n var template = Hogan.compile(#{content.to_json});\n module.exports = (function(data){ return template.render(data); });\n }\n end",
"def compile()\n self._compiled = <<\"JAVASCRIPT\"\n(function(repl) {\n try {\n var rc;\n #{code.join(' ')}\n repl.rc_ok(rc);\n } catch(e) {\n repl.rc_fail(e.name, e.message ? e.message : e);\n };\n})(#{replid});\nJAVASCRIPT\n self._code = []\n end",
"def initialize(env) #:nodoc:\n @env = env.dup\n # a parent router may be assuming a successful match\n # but this subrouter may not, so we explicitly set it to not matched\n # on creation\n not_matched\n @rules = []\n # Actually create the rules so that the procs we create are in the\n # context of an instance of this object. This is most important when the\n # rule is based on a symbol. We need that symbol to resolve to an\n # instance method; however, instance methods are not available until\n # after an instance is created.\n self.class.rules.each {|rule| match *rule }\n\n @prerequisites = []\n self.class.prerequisites.each do |prerequisite|\n @prerequisites << normalize_match_params(prerequisite)\n end\n end",
"def make_path_with_params(args, params)\n names, params_array = args.partition{ |arg| arg.is_a?(Symbol) }\n name = names[0, 2].join(\" \").to_sym\n compiled_router.path(name, *(params_array << params))\n rescue PathRouter::InvalidRouteException\n raise Padrino::Routing::UnrecognizedException, \"Route mapping for url(#{name.inspect}) could not be found\"\n end",
"def compiled_statement\n @compiler_mutex.synchronize do\n condition_keys, if_statements = Set.new, \"\"\n\n routes.each_with_index do |route, i|\n route.freeze\n route.conditions.keys.each { |key| condition_keys << key }\n if_statements << route.compiled_statement(i == 0)\n end\n\n statement = \"def match(request)\\n\"\n statement << condition_keys.inject(\"\") do |cached, key|\n cached << \" cached_#{key} = request.#{key}.to_s\\n\"\n end\n statement << if_statements\n statement << \" else\\n\"\n statement << \" [nil, {}]\\n\"\n statement << \" end\\n\"\n statement << \"end\"\n end\n end",
"def to_parser\n parser = Racc::GrammarFileParser.new\n result = parser.parse to_yacc\n nfa = Racc::States.new(result.grammar).nfa\n parsegen = Racc::ParserFileGenerator.new nfa.dfa, result.params\n parser_src = parsegen.generate_parser\n\n if $DEBUG\n puts \"############# PARSED GRAMMAR\"\n puts parser_src\n puts \"############# END PARSED GRAMMAR\"\n end\n\n Module.new { class_eval parser_src }.const_get('GeneratedGrammar')\n end",
"def initialize(path,logger=nil)\r\n @pathname = Pathname.new(path)\r\n @logger = logger\r\n scan_templates\r\n end",
"def initialize(str, debug=false)\n setup_parser(str, debug)\n @g = KPeg::Grammar.new\n end",
"def compiled_statement\n @compiler_mutex.synchronize do\n condition_keys, if_statements = Set.new, \"\"\n \n routes.each_with_index do |route, i|\n route.freeze\n route.conditions.keys.each { |key| condition_keys << key }\n if_statements << route.compiled_statement(i == 0)\n end\n \n statement = \"def match(request)\\n\"\n statement << condition_keys.inject(\"\") do |cached, key|\n cached << \" cached_#{key} = request.#{key}.to_s\\n\"\n end\n statement << if_statements\n statement << \" else\\n\"\n statement << \" [nil, {}]\\n\"\n statement << \" end\\n\"\n statement << \"end\"\n end\n end",
"def initialize(schemas = {}, options = {})\n schemas = {} unless schemas\n\n # not needed\n # if (!(this instanceof LinkifyIt)) {\n # return new LinkifyIt(schemas, options);\n # }\n\n # not needed, if you want to pass options, then must also pass schemas\n # if options.empty?\n # if (isOptionsObj(schemas)) {\n # options = schemas;\n # schemas = {};\n # }\n # }\n\n @__opts__ = DEFAULT_OPTIONS.merge(options)\n\n # Cache last tested result. Used to skip repeating steps on next `match` call.\n @__index__ = -1\n @__last_index__ = -1 # Next scan position\n @__schema__ = ''\n @__text_cache__ = ''\n\n @__schemas__ = {}.merge!(DEFAULT_SCHEMAS).merge!(schemas)\n @__compiled__ = {}\n\n @__tlds__ = TLDS_DEFAULT\n @__tlds_replaced__ = false\n\n @re = {}\n\n @bypass_normalizer = false # only used in testing scenarios\n\n compile\n end",
"def router\n @router ||= PathRouter.new\n block_given? ? yield(@router) : @router\n end",
"def new\n @compiler = Compiler.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @compiler }\n end\n end",
"def initialize(runtime=nil)\n runtime ||= ExecJS.runtime\n @context = runtime.compile(self.class.source)\n end",
"def dsl\n @dsl ||= Nanoc3::CompilerDSL.new(self)\n end"
] | [
"0.6617182",
"0.63980216",
"0.62864166",
"0.6168754",
"0.6168754",
"0.61174935",
"0.6088863",
"0.5981532",
"0.597832",
"0.5890744",
"0.5830917",
"0.5811533",
"0.5811146",
"0.57788706",
"0.5757336",
"0.5754809",
"0.5747623",
"0.5712318",
"0.563797",
"0.5606646",
"0.5567982",
"0.556079",
"0.5549106",
"0.55459833",
"0.5506955",
"0.54898953",
"0.5403396",
"0.5398465",
"0.5378902",
"0.53671455",
"0.53667593",
"0.5340835",
"0.5340668",
"0.5296456",
"0.5294267",
"0.5283608",
"0.5273545",
"0.52218276",
"0.5219294",
"0.5216826",
"0.52145785",
"0.52105516",
"0.5206034",
"0.5194972",
"0.5194341",
"0.5170257",
"0.5158362",
"0.5143212",
"0.51392907",
"0.51342916",
"0.5129583",
"0.51229924",
"0.5121348",
"0.51060855",
"0.5088809",
"0.5078734",
"0.50672746",
"0.5057394",
"0.5034309",
"0.5027187",
"0.5026217",
"0.5025686",
"0.50250804",
"0.50200945",
"0.50102305",
"0.50089884",
"0.49983597",
"0.49982116",
"0.49933243",
"0.49808475",
"0.497837",
"0.49744597",
"0.496626",
"0.49556473",
"0.4937731",
"0.4911865",
"0.49055922",
"0.49050835",
"0.4902724",
"0.48967716",
"0.4894385",
"0.48923755",
"0.4885104",
"0.48753586",
"0.4874796",
"0.48721203",
"0.48594266",
"0.4851547",
"0.48467374",
"0.48451632",
"0.48435342",
"0.48409104",
"0.48381856",
"0.48360485",
"0.48310858",
"0.4819444",
"0.48111328",
"0.48107776",
"0.4809086",
"0.47935647",
"0.4787844"
] | 0.0 | -1 |
Compiles all routes into regexps. | def compile!
return if compiled?
@routes.each_with_index do |route, index|
route.index = index
route.regexp = /(?<_#{index}>#{route.matcher.to_regexp})/
end
@compiled = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile!\n return if compiled?\n @regexps = @routes.map.with_index do |route, index|\n route.index = index\n /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @regexps = recursive_compile(@regexps)\n @compiled = true\n end",
"def compile\n @clazz = eval(@controller) if not @controller.blank?\n create_segments()\n route_str = \"\"\n i = 0\n @segments.each { |seg|\n case seg\n when ControllerSegment\n @controller = seg\n route_str << \"([^/]+)\"\n seg.pos = (i += 1)\n when ActionSegment\n @action = seg\n route_str << \"([^/]+)?\"\n seg.pos = (i += 1)\n when ParamSegment\n #@action = seg\n route_str << \"([^/]+)\"\n seg.pos = (i += 1)\n else\n route_str << seg.path\n end \n }\n puts route_str\n @regex = Regexp.new(route_str)\n end",
"def compile\n robot.handlers.each do |handler|\n next unless handler.respond_to?(:http_routes)\n\n handler.http_routes.each { |route| router.add_route(route) }\n end\n end",
"def compile\n if routes.any?\n eval(compiled_statement, binding, \"Generated Code for Router\", 1)\n else\n reset!\n end\n end",
"def compile\n if routes.any?\n eval(compiled_statement, binding, \"Generated Code for Merb::Router#match(#{__FILE__}:#{__LINE__})\", 1)\n else\n reset!\n end\n end",
"def generate_routes m\n # routes\n unless command_has_resources\n # add routes like unnested scaffold \n # eg. map.resources books\n m.route_resources controller_file_name\n else\n resource_list = controller_file_name.map { |r| r.to_sym.inspect }.join(', ')\n parent_resource = parent_resource_name\n \n path = destination_path('config/routes.rb')\n content = File.read(path)\n \n logger.route \"resources #{resource_list}\"\n \n # map.resources :parents do |parent|\n # parent.resources :parents do |parent|\n sentinel = \"\\.resources(.*)?:#{parent_resource.pluralize}(.*)do(.*)\\\\|#{parent_resource}\\\\|\"\n \n if content =~ /#{sentinel}/\n gsub_file 'config/routes.rb', sentinel do |match|\n \"#{match}\\n #{parent_resource}.resources :#{table_name}\"\n end\n else\n # without do block\n # map.resources :parents \n # parent.resources :parents\n sentinel = \"\\.resources(.*):#{parent_resource.pluralize}\"\n if content =~ /#{sentinel}/\n gsub_file 'config/routes.rb', sentinel do |match|\n \"#{match} do |#{parent_resource}|\\n #{parent_resource}.resources :#{table_name}\\n end\"\n end\n end\n end\n end\n end",
"def load_routes\n\n # get our routes\n routes = Rails.application.routes.routes.to_a\n\n # filter out internal routes, those outside our base context, and those with no name\n routes.reject!{ |r| r.internal or !r.defaults.key?( :controller ) or r.name.nil? }\n\n # finally, map everything to a simpler version\n self.routes = routes.map do |r|\n {\n controller: r.defaults[:controller],\n action: r.defaults[:action].to_sym,\n name: r.name,\n params: r.parts.reject{ |p| p == :format }\n }\n end\n\n end",
"def initialize(routes)\n @routes = routes.map { |r| '/' + r }\n @captures = Match.new []\n end",
"def all_routes\n matching_routes\n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def generate_routes!\n Router.new(self).generate(@app)\n end",
"def parse_routes!\n allowed_routes.each do |route|\n if (endpoint = endpoints.find_from_route(route))\n endpoint.merge_http_methods!(route[:http_methods])\n else\n controller = controllers.find_or_create_from_route(route)\n endpoint = endpoints.create_from_route(route, controller)\n\n controller.add_endpoint(endpoint)\n end\n end\n end",
"def recursive_compile(regexps, paths = [])\n return paths if regexps.length.zero?\n paths << Regexp.union(regexps)\n regexps.shift\n recursive_compile(regexps, paths)\n end",
"def alter_regex_for_custom_routes(node); end",
"def reset!\n class << self\n alias_method :match, :match_before_compilation\n end\n self.routes, self.named_routes = [], {}\n end",
"def rewrite_routes_trailing_slash\n trailing_slash = Regexp.new(/.*\\/\\?\\\\z/)\n no_trailing_slash = Regexp.new(/(.*)\\\\z\\//)\n Sinatra::Application.routes.each do |method, routes|\n routes.each do |r|\n route_regexp_str = r[0].inspect\n if trailing_slash.match(route_regexp_str)\n next\n else\n new_route = route_regexp_str.gsub(no_trailing_slash, \"\\\\1\\\\/?\\\\z/\")\n r[0] = eval(new_route)\n end\n end\n end\nend",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def reset!\n class << self\n alias_method :match, :match_before_compilation\n end\n self.routes, self.named_routes, self.resource_routes = [], {}, {}\n end",
"def _routes; end",
"def routes(&block); end",
"def routes(&block); end",
"def routes(filter = nil)\n Rails.application.reload_routes!\n formatted = formatted_routes\n if filter\n formatted.select!{ |r| r.match(filter) }\n end\n puts formatted\n end",
"def inject_routes\n gsub_file 'config/routes.rb', /root (:to =>|to:) \"catalog#index\"/, ''\n gsub_file 'config/routes.rb', /'welcome#index'/, \"'sufia/homepage#index'\" # Replace the root path injected by CurationConcerns\n\n routing_code = \"\\n Hydra::BatchEdit.add_routes(self)\\n\" \\\n \" # This must be the very last route in the file because it has a catch-all route for 404 errors.\\n\" \\\n \" # This behavior seems to show up only in production mode.\\n\" \\\n \" mount Sufia::Engine => '/'\\n\"\n\n sentinel = /devise_for :users/\n inject_into_file 'config/routes.rb', routing_code, after: sentinel, verbose: false\n end",
"def all\n routes = {}\n routable.each do |r|\n routes.merge!(@ruhoh.collection(r).routes)\n end\n routes\n end",
"def add_routes(&block)\n @router ||= Routes.new\n @router.define(&block)\n url.router = @router\n end",
"def process_routes src\n RoutesProcessor.new(@tracker).process_routes src\n end",
"def anchored_routes; end",
"def routes_map; end",
"def remap(map)\n @tree.free if @tree\n @tree = R3::Tree.new(map.size)\n\n map.each do |method_and_route, app|\n method, route, data = method_and_route\n\n raise ArgumentError, 'path need to start with /' unless route[0] == '/'\n\n @tree.add(route, method, [app, data])\n end\n\n @tree.compile\n end",
"def routes\n @routes ||= load_routes\n end",
"def routes\n routes = {}\n self.class.each_route do |route|\n #routes[:name] = route.app.name # \"SomeSinatraApp\"\n info = {}\n routes[route.path.to_s.to_sym] = info # that's the path given as argument to get and akin\n info[:verb] = route.verb # get / head / post / put / delete\n info[:file] = route.file # \"some_sinatra_app.rb\" or something\n info[:line] = route.line # the line number of the get/post/... statement\n info[:pattern] = route.pattern # that's the pattern internally used by sinatra\n info[:keys] = route.keys # keys given when route was defined\n info[:conditions] = route.conditions # conditions given when route was defined\n info[:block] = route.block # the route's closure\n end\n routes\n end",
"def routes\n @routes ||= []\n end",
"def routes\n @routes ||= []\n end",
"def add_compressed_routes!\n assets.packages.each do |name, package|\n get package.route_regex do\n if defined?(settings.assets.app.clear_tilt_cache) && settings.assets.app.clear_tilt_cache\n AssetPack.clear_tilt_cache!(@template_cache, settings.assets.app)\n end\n\n mtime, contents = @template_cache.fetch(package.path) {\n [ package.mtime, package.minify ]\n }\n\n content_type package.type\n last_modified mtime\n assets_expires\n contents\n end\n end\n end",
"def add_rexval_routes\n # rexval_route = \"rex_route :#{plural_name}\"\n # route rexval_route\n end",
"def add_routes(routes)\n \n return if skip_method(__method__)\n \n write_artifact(\"config/routes.rb\") do |file|\n file.puts(\"Rails.application.routes.draw do\")\n file.puts(\"\n concern :common_routes do\n get :range, on: :collection\n # handles requests where relation is a query param (RestAngularBuilder)\n # e.g. users/1/related.json?relation=department\n get :related \n post :search\n end\")\n \n if namespace\n file.puts(\" namespace :#{namespace} do\")\n end\n routes.each do |route|\n namespace.nil? ? file.puts(route) : file.puts(indent(route))\n end\n if namespace\n file.puts(\" end\")\n end\n file.puts(\"end\")\n end\n\n end",
"def routes\n @routes ||= []\n end",
"def call(request)\n compile! unless compiled?\n pattern, verb, params = *parse_request(request)\n pattern = pattern.encode(Encoding.default_external)\n candidacies = match_with(pattern)\n raise_exception(404) if candidacies.empty?\n candidacies, allows = *candidacies.partition{ |route| route.verb == verb }\n raise_exception(405, :verbs => allows.map(&:verb)) if candidacies.empty?\n candidacies.map{ |route| [route, route.params_for(pattern, params)] }\n end",
"def routes\n routes_method.call\n end",
"def each\n @routes.each do |rt|\n yield rt\n end\n self\n end",
"def api \n api = { }\n \n param_regex = Regexp.new '\\(\\[\\^\\\\\\\\\\/\\?\\#\\]\\+\\)'\n Nagira.routes.keys.each do |method|\n api[method] ||= []\n Nagira.routes[method].each do |r|\n path = r[0].inspect[3..-3]\n r[1].each do |parm|\n path.sub!(param_regex,\":#{parm}\")\n end\n path.gsub!('\\\\','')\n api[method] << path unless path.empty? \n end\n end\n api\n end",
"def routes\n { :static => @route_ids, :dynamic => @dynamic }\n end",
"def routes\n cached_routes\n end",
"def prepare(first = [], last = [], &block)\n @routes = []\n root_behavior._with_proxy(&block)\n @routes = first + @routes + last\n compile\n self\n end",
"def init_routes\n puts \"Adding the caboose store routes...\"\n \n filename = File.join(@app_path,'config','routes.rb')\n return if !File.exists?(filename)\n return if !@force\n \n str = \"\" \n str << \"\\t# Catch everything with caboose\\n\" \n str << \"\\tmount CabooseStore::Engine => '/'\\n\"\n \n file = File.open(filename, 'rb')\n contents = file.read\n file.close \n if (contents.index(str).nil?)\n arr = contents.split('end', -1)\n str2 = arr[0] + \"\\n\" + str + \"\\nend\" + arr[1]\n File.open(filename, 'w') {|file| file.write(str2) }\n end \n end",
"def add_to_routes m\n file_to_update = 'config/routes.rb'\n line_to_add = \"map.resources :casein_#{controller_file_name}\"\n insert_sentinel = 'CaseinAddRoutes::mapper map'\n gsub_add_once m, file_to_update, \" \" + line_to_add, insert_sentinel\n logger.route line_to_add\n end",
"def compile\n @re = build_re(@__opts__)\n\n # Define dynamic patterns\n tlds = @__tlds__.dup\n\n onCompile\n\n tlds.push(TLDS_2CH_SRC_RE) if (!@__tlds_replaced__)\n tlds.push(@re[:src_xn])\n\n @re[:src_tlds] = tlds.join('|')\n @re[:email_fuzzy] = Regexp.new(@re[:tpl_email_fuzzy].gsub('%TLDS%', @re[:src_tlds]), true)\n @re[:link_fuzzy] = Regexp.new(@re[:tpl_link_fuzzy].gsub('%TLDS%', @re[:src_tlds]), true)\n @re[:link_no_ip_fuzzy] = Regexp.new(@re[:tpl_link_no_ip_fuzzy].gsub('%TLDS%', @re[:src_tlds]), true)\n @re[:host_fuzzy_test] = Regexp.new(@re[:tpl_host_fuzzy_test].gsub('%TLDS%', @re[:src_tlds]), true)\n\n #\n # Compile each schema\n #\n\n aliases = []\n\n @__compiled__ = {} # Reset compiled data\n\n schemaError = lambda do |name, val|\n raise Error, ('(LinkifyIt) Invalid schema \"' + name + '\": ' + val)\n end\n\n @__schemas__.each do |name, val|\n\n # skip disabled methods\n next if (val == nil)\n\n compiled = { validate: nil, link: nil }\n\n @__compiled__[name] = compiled\n\n if (val.is_a? Hash)\n if (val[:validate].is_a? Regexp)\n compiled[:validate] = createValidator(val[:validate])\n elsif (val[:validate].is_a? Proc)\n compiled[:validate] = val[:validate]\n else\n schemaError(name, val)\n end\n\n if (val[:normalize].is_a? Proc)\n compiled[:normalize] = val[:normalize]\n elsif (!val[:normalize])\n compiled[:normalize] = createNormalizer()\n else\n schemaError(name, val)\n end\n next\n end\n\n if (val.is_a? String)\n aliases.push(name)\n next\n end\n\n schemaError(name, val)\n end\n\n #\n # Compile postponed aliases\n #\n\n aliases.each do |an_alias|\n if (!@__compiled__[@__schemas__[an_alias]])\n # Silently fail on missed schemas to avoid errons on disable.\n # schemaError(an_alias, self.__schemas__[an_alias]);\n else\n @__compiled__[an_alias][:validate] = @__compiled__[@__schemas__[an_alias]][:validate]\n @__compiled__[an_alias][:normalize] = @__compiled__[@__schemas__[an_alias]][:normalize]\n end\n end\n\n #\n # Fake record for guessed links\n #\n @__compiled__[''] = { validate: nil, normalize: createNormalizer }\n\n #\n # Build schema condition, and filter disabled & fake schemas\n #\n slist = @__compiled__.select {|name, val| name.length > 0 && !val.nil? }.keys.map {|str| escapeRE(str)}.join('|')\n\n # (?!_) cause 1.5x slowdown\n @re[:schema_test] = Regexp.new('(^|(?!_)(?:[><\\uff5c]|' + @re[:src_XPCc] + '))(' + slist + ')', 'i')\n @re[:schema_search] = Regexp.new('(^|(?!_)(?:[><\\uff5c]|' + @re[:src_XPCc] + '))(' + slist + ')', 'i')\n @re[:schema_at_start] = Regexp.new('^' + @re[:schema_search].source, 'i')\n\n @re[:pretest] = Regexp.new(\n '(' + @re[:schema_test].source + ')|(' + @re[:host_fuzzy_test].source + ')|@',\n 'i'\n )\n\n #\n # Cleanup\n #\n\n resetScanCache\n end",
"def prepare(first = [], last = [], &block)\n @routes = []\n root_behavior.with_proxy(&block)\n @routes = first + @routes + last\n compile\n self\n end",
"def inject_routes\n routing_code = \"Hydra::BatchEdit.add_routes(self)\"\n sentinel = /HydraHead.add_routes\\(self\\)/\n inject_into_file 'config/routes.rb', \"\\n #{routing_code}\\n\", { :after => sentinel, :verbose => false }\n\n routing_code = \"\\n # This must be the very last route in the file because it has a catch all route for 404 errors.\n # This behavior seems to show up only in production mode.\n mount Sufia::Engine => '/'\\n\"\n sentinel = /devise_for :users/\n inject_into_file 'config/routes.rb', routing_code, { :after => sentinel, :verbose => false }\n \n end",
"def route2map(routes)\n # Map\n # pathname => [controler, action, GET|POST, path]\n map = {}\n ac = [[\"\", \"\"]]\n routes.each do |r|\n if r[:name].nil?\n # TODO: no name\n elsif r[:name] == \"root\"\n # verb is nil\n a = r[:reqs].scan(/:action=>\"(\\w+)\"/)\n c = r[:reqs].scan(/:controller=>\"(\\w+)\"/)\n map[r[:name]] = [c[0][0], a[0][0], 'ROOT', r[:path]]\n elsif r[:verb].nil?\n $log.debug(\"route #{r} - SKIP\")\n elsif r[:verb] == \"\"\n # SKIP\n $log.error(\"route #{r} - SKIP\")\n # 2013-04-11 Nancy => netzke /netzke/:action(.:format) {:controller=>\"netzke\"}\n else\n a = r[:reqs].scan(/:action=>\"([a-z_]+)\"/)\n c = r[:reqs].scan(/:controller=>\"([a-z_\\/]+)\"/) # hoge/hoge\n map[r[:name]] = [c[0][0], a[0][0], r[:verb], r[:path]]\n end\n end\n map\n end",
"def generate\n gen_app\n handle_public_index\n gen_file(\"config/routes.rb\", \"routes\")\n @app.goals.values.each_with_index { |goal, i| gen_goal(goal, i) }\n gen_misc\n self\n end",
"def routes\n desc 'shows all routes'\n task routes: :environment do\n print_routes api_routes\n end\n end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def build_route \n # #puts \"build Rails route for #{@model_name} in config/routes.rb\"\n \n template = File.read(template(\"rails/route.erb\"))\n text = Erubis::Eruby.new(template).evaluate( self )\n\n @@rails_routes << text\n end",
"def load_all_routes(roda_app)\n roda_app.request.public\n\n if Bridgetown.env.development? &&\n !Bridgetown::Current.preloaded_configuration.skip_live_reload\n setup_live_reload roda_app\n end\n\n Bridgetown::Rack::Routes.sorted_subclasses&.each do |klass|\n klass.merge roda_app\n end\n end",
"def regexps; end",
"def setup_routes\n if prefix\n pre = prefix.to_s[1..-1] + '/'\n end\n model_regexp = Regexp.union(models.keys.map{|m| Regexp.escape(m)})\n controller = @controller.name.sub(/Controller\\z/, '').underscore\n ::Rails.application.routes.prepend do\n match \"#{pre}:autoforme_model/:autoforme_action(/:id)\" , :controller=>controller, :action=>'autoforme', :via=>[:get, :post],\n :constraints=>{:autoforme_model=>model_regexp, :autoforme_action=>ALL_SUPPORTED_ACTIONS_REGEXP}\n end\n ::Rails.application.reload_routes!\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/cms',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/cms/,\n :title => 'Gestor contenidos',\n :description => 'Gestiona los contenidos',\n :fit => 2,\n :module => :cms},\n {:path => '/admin/cms/content-types',\n :parent_path => '/admin/cms',\n \t :regular_expression => /^\\/admin\\/cms\\/content-types/, \n :title => 'Tipos de contenido' , \n :description => 'Manages the content types: creation and update of content types.',\n :fit => 3,\n :module => :cms},\n {:path => '/mctype/:type/:aspect',\n :parent_path => \"/mctypes\",\n :regular_expression => /^\\/mctype\\/.+\\/.+/, \n :title => 'Content type aspect configuration', \n :description => 'Edit the content type/aspect configuration',\n :fit => 1,\n :module => :cms}, \n {:path => '/admin/cms/contents',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/content/, \n :title => 'Contenidos', \n :description => 'Manages the contents',\n :fit => 2,\n :module => :cms},\n {:path => '/admin/cms/content/new/',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/content\\/new/, \n :title => 'Crear contenido', \n :description => 'Create a new content: Choose the content type.',\n :fit => 2,\n :module => :cms},\n {:path => '/admin/cms/content/new/:content_type',\n :parent_path => \"/admin/cms/content/new/\",\n :regular_expression => /^\\/admin\\/cms\\/content\\/new\\/.+/, \n :title => 'Nuevo', \n :description => 'Create a new content: Complete data.',\n :fit => 3,\n :module => :cms}, \n {:path => '/admin/cms/content/edit/:content_id',\n :parent_path => '/admin/cms/contents',\n :regular_expression => /^\\/admin\\/cms\\/content\\/edit\\/.+/, \n :title => 'Editar contenido', \n :description => 'Editar contenido',\n :fit => 1,\n :module => :cms}, \n {:path => '/admin/cms/taxonomy',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/taxonomy/, \n :title => 'Taxonomías', \n :description => 'Manages the taxonomies: creation and update of taxonomies',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/terms/:taxonomy_id',\n :parent_path => \"/admin/cms/taxonomy\",\n :regular_expression => /^\\/admin\\/cms\\/terms\\/.+/, \n :title => 'Term',\n :description => 'Manage the terms of a taxonomy.',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/templates',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/templates/, \n :title => 'Plantillas', \n :description => 'Manages templates: creation and update of templates',\n :fit => 1,\n :module => :cms }, \n {:path => '/admin/cms/comments',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/comments/, \n :title => 'Comentarios', \n :description => 'Manages comments: creation and update of templates',\n :fit => 1,\n :module => :cms }, \n {:path => '/admin/cms/blocks',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/blocks/, \n :title => 'Bloques', \n :description => 'Manage the blocks. It allows to discover and configure modules blocks',\n :fit => 1,\n :module => :cms},\n {:path => '/admin/cms/views',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/views/, \n :title => 'Vistas', \n :fit => 1,\n :description => 'Manage the views: creation and update of views',\n :module => :cms},\n {:path => '/content/:page',\n :regular_expression => /^\\/content\\/.+/,\n :title => 'Content',\n :description => 'Shows a content',\n :fit => 1,\n :module => :cms},\n {:path => '/contents/category/:term_id',\n :regular_expression => /^\\/contents\\/category\\/.+/,\n :title => 'Contents by category',\n :description => 'Shows all the contents tagged with the category',\n :fit => 1,\n :module => :cms},\n {:path => '/admin/cms/menu-management',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/menu-management/, \n :title => 'Menu', \n :description => 'Manages the menus: creation and update of menus',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/menu-item-management/:menu_name',\n :parent_path => '/admin/cms/menu-management',\n :regular_expression => /^\\/admin\\/cms\\/menu-item-management\\/.+/, \n :title => 'Elemento de menú',\n :description => 'Manage the items of a menu.',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/translate/content/:content_id',\n :parent_path => '/admin/cms/contents',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/content\\/.+/, \n :title => 'Traducir contenido', \n :description => 'Translate a content',\n :fit => 1,\n :module => :translation },\n {:path => '/admin/cms/translate/menuitem/:menuitem_id',\n :parent_path => '/admin/cms/menu-management',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/menuitem\\/.+/, \n :title => 'Traducir elemento de menu', \n :description => 'Translate a menu item',\n :fit => 1,\n :module => :translation }, \n {:path => '/admin/cms/translate/term/:term_id',\n :parent_path => '/admin/cms/taxonomy',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/term\\/.+/, \n :title => 'Traducir término',\n :description => 'Translate a term.',\n :fit => 1,\n :module => :translation },\n {:path => '/admin/cms/translate/template/:template_id',\n :parent_path => '/admin/cms/templates',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/template\\/.+/, \n :title => 'Traducir plantilla',\n :description => 'Translate a term.',\n :fit => 1,\n :module => :translation } \n ]\n \n end",
"def routes(context={})\n \n routes = [{:path => '/admin/aspects',\n \t :regular_expression => /^\\/admin\\/config\\/aspects/, \n :title => 'Aspects' , \n :description => 'Configure the aspects.',\n :fit => 1,\n :module => :aspects},\n {:path => '/admin/aspect/:model_name/:aspect',\n :parent_path => \"/model-aspects\",\n :regular_expression => /^\\/admin\\/config\\/aspect\\/.+\\/.+/, \n :title => 'Model aspect configuration', \n :description => 'Edit the model/aspect configuration',\n :fit => 1,\n :module => :aspects\n }]\n \n end",
"def finalize_artifacts\n \n return if skip_method(__method__)\n \n puts \"finalize Rails routes in config/routes.rb\"\n \n add_routes(@@rails_routes)\n \n # create the navigation menu\n finalize_menu\n \n end",
"def print_routes \n \n # Create a new hash\n h = Hash.new()\n\n # Use Sinatra advanced routes\n # to build out a hash based on the routes\n Sinatra::Application.each_route do |route|\n unless route.path.eql? \"/\" or route.path.eql? \"/*\"\n h[route.path.split(\"/\")[1]] = request.base_url + route.path \n end\n end\n\n # Return that badboy\n return h\n\nend",
"def custom_routes; end",
"def all_re(pattern, &hndlr)\n @j_del.allWithRegEx(pattern) { |j_req| hndlr.call(HttpServerRequest.new(j_req)) }\n end",
"def add_gateway_routes\n # The routes required a Gateway Resource to contain them.\n # TODO: Support more routes. Right now outputing all routes in 1 template will hit the 60 routes limit.\n # Will have to either output them as a joined string or break this up to multiple templates.\n # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html\n # Outputs: Maximum number of outputs that you can declare in your AWS CloudFormation template. 60 outputs\n # Output name: Maximum size of an output name. 255 characters.\n #\n # Note we must use .all_paths, not .routes here because we need to\n # build the parent ApiGateway::Resource nodes also\n Jets::Router.all_paths.each do |path|\n homepage = path == ''\n next if homepage # handled by RootResourceId output already\n\n resource = Jets::Resource::ApiGateway::Resource.new(path, internal: true)\n add_resource(resource)\n add_outputs(resource.outputs)\n end\n end",
"def routes\n request :get, '/routes'\n end",
"def prepare!\n @prepared = true\n @routes.sort_by!(&:order)\n self.class.setup_compiler! && compile! if Pendragon.configuration.enable_compiler?\n end",
"def processed_route\n return @original_route unless any_wildcard?\n as_regex\n end",
"def add_individual_routes!\n assets.served.each do |path, from|\n get %r{#{\"^/#{path}/\".squeeze('/')}(.*)$} do |file|\n fmt = File.extname(file)[1..-1]\n\n if file =~ /(.*)\\.([a-f0-9]{32})\\.(.*)/\n clean_file = \"#{$1}.#{$3}\"\n requested_hash = $2\n else\n clean_file = file\n end\n\n # Sanity checks\n pass unless AssetPack.supported_formats.include?(fmt)\n\n fn = asset_path_for(clean_file, from) or pass\n\n pass if settings.assets.ignored?(\"#{path}/#{clean_file}\")\n\n # Send headers\n content_type fmt.to_sym\n last_modified File.mtime(fn)\n assets_expires\n\n format = File.extname(fn)[1..-1]\n\n if defined?(settings.assets.app.clear_tilt_cache) && settings.assets.app.clear_tilt_cache\n AssetPack.clear_tilt_cache!(@template_cache, settings.assets.app)\n end\n\n if AssetPack.supported_formats.include?(format)\n # Static file\n if fmt == 'css'\n # Matching static file format\n pass unless fmt == File.extname(fn)[1..-1]\n @template_cache.fetch(fn) { asset_filter_css File.read(fn) }\n else\n # It's a raw file, just send it\n send_file fn\n end\n else\n # Dynamic file\n not_found unless AssetPack.tilt_formats[format] == fmt\n\n @template_cache.fetch(fn) {\n settings.assets.fetch_dynamic_asset(fn) {\n out = render format.to_sym, File.read(fn), :filename => fn\n out = asset_filter_css(out) if fmt == 'css'\n out\n }\n }\n end\n end\n end\n end",
"def map(&block)\n @routes.map(&block)\n end",
"def action_routes action\n request_methods, route = REQUEST_METHODS, action.to_s\n REQUEST_METHODS.each do |m|\n regex = /\\A#{m}_/i\n if route =~ regex\n request_methods = [m]\n route = route.sub regex, ''\n break\n end\n end\n\n route.size == 0 && raise('wrong action name \"%s\"' % action)\n\n path_rules.keys.sort.reverse.each do |key|\n route = route.gsub(key.is_a?(Regexp) ? key : /#{key}/, path_rules[key])\n end\n\n pages, dirs = [], []\n path = rootify_url(base_url, route)\n pages << {nil => [path, nil]}\n dirs << {nil => [rootify_url(base_url), path]} if route == APPETITE__INDEX_ACTION\n\n ((@action_aliases||{})[action]||[]).each do |url|\n pages << {nil => [rootify_url(base_url, url), nil]}\n end\n\n canonicals.each do |c|\n canonical_path = rootify_url(c, route)\n pages << {nil => [canonical_path, path]}\n dirs << {nil => [rootify_url(c), path]} if route == APPETITE__INDEX_ACTION\n end\n pages.each do |page|\n format?(action).each { |format| page[format] = page[nil].first + format }\n end\n [request_methods, pages + dirs].freeze\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/system',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/system/, \n :title => 'Sistema', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/admin/logger',\n :parent_path => '/admin/system',\n :regular_expression => /^\\/admin\\/logger/, \n :title => 'Trazas', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/logger-config',\n :regular_expression => /^\\/admin\\/logger-config/, \n :title => 'Logger configuration', \n :description => 'Configure the logger',\n :fit => 1,\n :module => :system }, \n {:path => '/business-events',\n :regular_expression => /^\\/admin\\/business-events/, \n :title => 'Business events',\n :description => 'Manage the business events.',\n :fit => 1,\n :module => :system }]\n \n end",
"def routes_normal\n return Array.new\n end",
"def routes(set_name = :main, &block)\n self.class.routes(set_name, &block)\n load_routes\n end",
"def handle_routes\n instance_exec(@_roda_app.request, &self.class.router_block)\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/media',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/media/,\n :title => 'Medios',\n :description => 'Gestión de medios',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/config',\n :parent_path => '/admin/media',\n :regular_expression => /^\\/admin\\/media\\/config/,\n :title => 'Configuración',\n :description => 'Configuración medios',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/album',\n :parent_path => '/admin/media',\n :regular_expression => /^\\/admin\\/media\\/album/,\n :title => 'Albums',\n :description => 'The albums admin tools to create and modify media albums',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/photo/:album_name',\n :parent_path => '/admin/media/album',\n :regular_expression => /^\\/admin\\/media\\/photo\\/.+/,\n :title => 'Photos',\n :description => 'It manages the album\\'s photos. Used to upload and edit the album\\'s photos.',\n :fit => 1,\n :module => :media_gallery},\n {:path => '/gallery/:album_name',\n :regular_expression => /^\\/photo_gallery\\/.+/,\n :title => 'Photos',\n :description => 'It shows the album\\'s photos.',\n :fit => 1,\n :module => :media_gallery}]\n \n end",
"def route6\n name = params[:name]\n regex = Regexp.new(Regexp.escape(name))\n end",
"def routes\n return @routes unless @routes.nil?\n r = Parse::API::Hooks::TRIGGER_NAMES_LOCAL + [:function]\n @routes = OpenStruct.new(r.reduce({}) { |h, t| h[t] = {}; h })\n end",
"def my_routes\n my_routes = []\n exceptions = %w(Login Signin)\n self.class.routes['GET'].each do |r|\n route = r.first.to_s.gsub(/\\W+|mix/,'').capitalize\n my_routes << route unless exceptions.include?(route)\n end\n return my_routes\n end",
"def routes(routes_def)\n RouterDefinition.new(routes_def)\n end",
"def patterns\n @patterns ||=\n [\n {\n :type => :erb,\n :rx => /\\.erb\\Z/,\n :rep => '',\n },\n {\n :type => :none,\n :rx => /\\Z/,\n :rep => '',\n },\n ]\n end",
"def routes(&block)\n routes = Routes.new\n routes.instance_eval(&block) if block_given?\n @route_definition = routes\n end",
"def as_rack_app\n #routes = Rack::Mount::RouteSet.new_without_optimizations do |set|\n routes = Rack::Mount::RouteSet.new do |set|\n @set = set\n self.add_routes\n add_route %r{^.*$}, :action => \"render_static\"\n end\n return routes\n end",
"def reload_routes!; end",
"def reload_routes!; end",
"def compiled_statement\n @compiler_mutex.synchronize do\n condition_keys, if_statements = Set.new, \"\"\n\n routes.each_with_index do |route, i|\n route.freeze\n route.conditions.keys.each { |key| condition_keys << key }\n if_statements << route.compiled_statement(i == 0)\n end\n\n statement = \"def match(request)\\n\"\n statement << condition_keys.inject(\"\") do |cached, key|\n cached << \" cached_#{key} = request.#{key}.to_s\\n\"\n end\n statement << if_statements\n statement << \" else\\n\"\n statement << \" [nil, {}]\\n\"\n statement << \" end\\n\"\n statement << \"end\"\n end\n end",
"def routes\n @route_map.dup\n end",
"def routes(path = nil, &blk)\n if path or block_given?\n @routes = Config::Routes.new(root, path, &blk)\n else\n @routes\n end\n end"
] | [
"0.8115772",
"0.7071185",
"0.7014843",
"0.6735203",
"0.6690873",
"0.64595294",
"0.62049437",
"0.6125483",
"0.61136585",
"0.61121184",
"0.61121184",
"0.6107773",
"0.60939205",
"0.6033074",
"0.59805006",
"0.5959296",
"0.59400547",
"0.59196824",
"0.59196824",
"0.59196824",
"0.59196824",
"0.59196824",
"0.59196824",
"0.59196824",
"0.59196824",
"0.59196824",
"0.59196824",
"0.59196824",
"0.59031945",
"0.58428884",
"0.58387345",
"0.58387345",
"0.57970846",
"0.5781612",
"0.57427573",
"0.5709251",
"0.5695934",
"0.5667076",
"0.5661915",
"0.5657929",
"0.5644415",
"0.56325424",
"0.56183034",
"0.56183034",
"0.56103814",
"0.5594187",
"0.55843735",
"0.5572863",
"0.55670696",
"0.55514365",
"0.5543955",
"0.55432814",
"0.5533397",
"0.5524562",
"0.55214685",
"0.5516975",
"0.5515851",
"0.5515297",
"0.55040795",
"0.5503219",
"0.55015516",
"0.5494808",
"0.54939634",
"0.5487096",
"0.5487096",
"0.5487096",
"0.54748607",
"0.546639",
"0.543399",
"0.54163027",
"0.541429",
"0.5386936",
"0.53819776",
"0.5374894",
"0.5373626",
"0.53633666",
"0.53545606",
"0.5342638",
"0.53421956",
"0.53419924",
"0.53375626",
"0.5319748",
"0.53155893",
"0.53131163",
"0.5303244",
"0.53023016",
"0.52768666",
"0.5273749",
"0.52693766",
"0.52656543",
"0.52592474",
"0.5252992",
"0.52435225",
"0.5242157",
"0.524213",
"0.5240222",
"0.5240222",
"0.522058",
"0.5219652",
"0.5216513"
] | 0.7659134 | 1 |
Returns true if all routes has been compiled. | def compiled?
!!@compiled
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty?\n @routes.empty?\n end",
"def any_empty_routing?\n self.empty?(self, \"routings\", false)\n end",
"def built?\n Namespace.root.executed_blueprints.include?(self)\n end",
"def routing_params?\n routing_params.any?\n end",
"def routing_params?\n routing_params.any?\n end",
"def needs_compilation?(path, locals)\n return true if Merb::Config[:reload_templates] || !METHOD_LIST[path]\n \n current_locals = SUPPORTED_LOCALS_LIST[path]\n current_locals != locals &&\n !(locals - current_locals).empty?\n end",
"def compile!\n return if compiled?\n @routes.each_with_index do |route, index|\n route.index = index\n route.regexp = /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @compiled = true\n end",
"def routes_are_correct?\n @solution.each do |route|\n return false if route.demand > @vehicle_capacity\n end\n return true\n end",
"def recompile?\n true\n end",
"def recompile?\n true\n end",
"def compiled?\n !!@log\n end",
"def compile!\n return if compiled?\n @regexps = @routes.map.with_index do |route, index|\n route.index = index\n /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @regexps = recursive_compile(@regexps)\n @compiled = true\n end",
"def compiled?\n !@result.nil?\n end",
"def compiling?\n !@converging\n end",
"def match_before_compilation(request) #:nodoc:\n raise NotCompiledError, \"The routes have not been compiled yet\"\n end",
"def working_on?(project_route)\n \tself.routes.include?(project_route)\n end",
"def use_static_routes?\n sorting.use_static_routes?\n end",
"def all_routes\n matching_routes\n end",
"def all_nodes_are_finished?\n all? do |node|\n node.finished?\n end\n end",
"def all_nodes_are_finished?\n all? do |node|\n node.finished?\n end\n end",
"def built?\n !@view.nil?\n end",
"def route_check_true\n if @route.nil?\n puts 'Маршрут не установлен!!!'\n else\n true\n end\n end",
"def has_included_resources?\n @has_included_resources ||= included_resources.any?\n end",
"def complete?\n keys.all?(&:complete?)\n end",
"def building?\n !build_stack.empty?\n end",
"def route? method\n if @tracker.routes[:allow_all_actions] or @tracker.options[:assume_all_routes]\n true\n else\n routes = @tracker.routes[@current_class]\n routes and (routes.include? :allow_all_actions or routes.include? method)\n end\n end",
"def show_all_routes\n if @routes.empty?\n routes_void\n else\n routes_list\n end\n end",
"def has_resources?\n return resources.count > 0\n end",
"def built?\n @built = false if @built.nil?\n @built\n end",
"def has_included_resources?\n !self.included_resources.empty?\n end",
"def has_constants?\n @context.constants.length > 0\n end",
"def processings?\n @processings.any?\n end",
"def should_cache?\n ctrait = controller.trait\n\n [ Global.cache_all,\n ctrait[:cache_all],\n actions_cached.map{|k,v| k.to_s}.include?(method),\n ].any?\n end",
"def compile\n if routes.any?\n eval(compiled_statement, binding, \"Generated Code for Merb::Router#match(#{__FILE__}:#{__LINE__})\", 1)\n else\n reset!\n end\n end",
"def empty?\n @directions.empty?\n end",
"def completed_path?\n path.size == nodes.size - 1\n end",
"def valid?\n return false unless @paths.count > 1\n @paths.each do |p|\n return false unless p.valid?\n end\n true\n end",
"def finished?\r\n return passengers.all? {|x| x.plan.empty? }\r\n end",
"def has_views?\n !@views.empty?\n end",
"def has_views?\n !@views.empty?\n end",
"def done?\n @possibles.all? do |ops_modifiers, count|\n count.zero? || !all_ops_modifiers_qualify?(ops_modifiers, count)\n end\n end",
"def calls?\n ! callsites.empty?\n end",
"def has_includes?\n @context.includes.length > 0\n end",
"def dependencies_are_ready?\n return @dependencies_are_ready unless @dependencies_are_ready.nil?\n return false if @dependencies_have_failed\n ready = all? do |task|\n task.successful? or task.skipped?\n end\n debug 'All dependencies are ready' if ready\n @dependencies_are_ready = ready\n end",
"def requests?\n return requests.any?\n end",
"def any?\n @calls.any?\n end",
"def defined_any?\n cassette_records.size > 0\n end",
"def all_bundled?\n remaining_flowers.zero?\n end",
"def active?\n\t\t\t\t!@resources.empty?\n\t\t\tend",
"def routable?(path)\n !!Rails.application.routes.recognize_path(path, method: :get)\n rescue ActionController::RoutingError\n false\n end",
"def tasks_are_finished?\n return true if @tasks_are_finished\n finished = all? do |task|\n task.finished?\n end\n if finished\n debug 'All tasks are finished'\n @tasks_are_finished = true\n end\n finished\n end",
"def paths?\n !paths.empty?\n end",
"def finished?\n @left_generator.finished? && @right_generator.finished?\n end",
"def finished?\n @left_generator.finished? && @right_generator.finished?\n end",
"def loaded?\n !@all.nil?\n end",
"def empty?\n @dispatchers.empty?\n end",
"def whitelisted_routes\n grack_route? || internal_route? || lfs_route? || sidekiq_route?\n end",
"def handlers?\n registered_handlers.length > 0\n end",
"def finished? nodes\n nodes.each { |k,v| return false if !v.done && v.distance != -1 }\n return true \n end",
"def route_assets?\n request.path_info.match %r{^/assets/}\n end",
"def all?\n @options[:all].present?\n end",
"def sections_classes_all_there?\n sections_classes_to_check.flatten.all?(&:all_there?)\n end",
"def cache_filled?\n !!@cache[:header] && !!@cache[:footer]\n end",
"def compile\n if routes.any?\n eval(compiled_statement, binding, \"Generated Code for Router\", 1)\n else\n reset!\n end\n end",
"def section_classes_all_there?\n section_classes_to_check.all?(&:all_there?)\n end",
"def all?(*paths)\n !catch(:done){ traverse(*paths){|f| throw(:done, true) unless yield f }}\n end",
"def binder_routing_ok?(binder, action)\n\n\t\treturn request.path[0..named_binder_route(binder, action).size - 1] == named_binder_route(binder, action)\n\n\tend",
"def should_compile_assets?\n diff.has_asset_changes? || !File.exist?('public/assets')\n end",
"def dependency_forward_any?\n forward_dependencies.any?\n end",
"def complete?\n requirements.each do |r|\n next if self[r].present?\n\n return false\n end\n end",
"def run_check\n check_for_default_routes\n check_for_action_globs\n check_for_cve_2014_0130\n end",
"def finished?\n @main_generator.finished?\n end",
"def dependencies_resolved?\n !@resolved_dependencies.nil?\n end",
"def acyclic?\n topsort.size == size\n end",
"def bindings?\n !bindings.empty?\n end",
"def route?(*subdir_patterns)\n regexp = generate_regex(subdir_patterns)\n Munge::Util::BooleanRegex.match?(regexp, @route)\n end",
"def loading?\n !load_stack.empty?\n end",
"def full?\r\n\t\tif nodes?\r\n\t\t\tnodes.each { |node|\r\n\t\t\t\tif node == nil\r\n\t\t\t\t\treturn false\r\n\t\t\t\tend\r\n\t\t\t}\r\n\t\tend\r\n\t\t\r\n\t\treturn true\r\n\tend",
"def compiled_statement\n @compiler_mutex.synchronize do\n condition_keys, if_statements = Set.new, \"\"\n\n routes.each_with_index do |route, i|\n route.freeze\n route.conditions.keys.each { |key| condition_keys << key }\n if_statements << route.compiled_statement(i == 0)\n end\n\n statement = \"def match(request)\\n\"\n statement << condition_keys.inject(\"\") do |cached, key|\n cached << \" cached_#{key} = request.#{key}.to_s\\n\"\n end\n statement << if_statements\n statement << \" else\\n\"\n statement << \" [nil, {}]\\n\"\n statement << \" end\\n\"\n statement << \"end\"\n end\n end",
"def check_availability_of_cargo_wagons\n @trains.each do |train|\n train.each do |element|\n if element.class != Symbol\n return false if element.wagons.any? && element.type == 'cargo'\n end\n end\n end\n end",
"def calls?\n ! callees.empty?\n end",
"def compiled_statement\n @compiler_mutex.synchronize do\n condition_keys, if_statements = Set.new, \"\"\n \n routes.each_with_index do |route, i|\n route.freeze\n route.conditions.keys.each { |key| condition_keys << key }\n if_statements << route.compiled_statement(i == 0)\n end\n \n statement = \"def match(request)\\n\"\n statement << condition_keys.inject(\"\") do |cached, key|\n cached << \" cached_#{key} = request.#{key}.to_s\\n\"\n end\n statement << if_statements\n statement << \" else\\n\"\n statement << \" [nil, {}]\\n\"\n statement << \" end\\n\"\n statement << \"end\"\n end\n end",
"def references?\n !@references.empty?\n end",
"def allowed_routes\n introspector.routes.keep_if(&method(:allow_route?))\n end",
"def success?\n\t\t\t@ports.select{|p| not p.success}.size + @urls.select{|u| not u.success}.size < 1\n\t\tend",
"def all_nodes_are_successful?\n all? do |node|\n node.successful?\n end\n end",
"def all_nodes_are_successful?\n all? do |node|\n node.successful?\n end\n end",
"def valid?\n valid_controllers? && valid_presenters? && valid_routes?\n end",
"def has_class_methods?\n m = all_methods().find{|m| m.singleton && (@options.show_all || m.visibility == :public || m.visibility == :protected)}\n m ? true : false\n end",
"def complete?\n last_layer = true # If the previous layer had an empty branch\n\n each_depth do |layer, depth|\n return false if !last_layer\n nil_exists = false # If an empty branch exists at the current layer\n\n layer.each do |n|\n if n.nil?\n nil_exists = true\n elsif nil_exists\n return false\n end\n end\n\n last_layer = false if nil_exists\n end\n\n true\n end",
"def context_free?\n all? { |r| r.context_free? }\n end",
"def busy?\n\t\t\t\t@resources.collect do |_,usage|\n\t\t\t\t\treturn true if usage > 0\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn false\n\t\t\tend",
"def busy?\n\t\t\t\t@resources.collect do |_, usage|\n\t\t\t\t\treturn true if usage > 0\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn false\n\t\t\tend",
"def has_children?\n bag.has_children?(path)\n end",
"def unresolved_call?\n callees.include?(\"__any__\")\n end",
"def endpoints?\n endpoints.any?\n end",
"def exists?\n @@instance_routes_count += 1\n @config_file = \"#{@@config_dir}route-#{@resource[:name]}\"\n\n # do not check file contents if the purpose is to ensure the file isn't there\n return File.exists?(@config_file) if @resource[:ensure] == :absent\n\n # load puppet configuration (`should`)\n @memory_values = []\n\n for route in @resource[:routes]\n @memory_values.push(route.strip)\n end\n\n # handle the special hack with :exclusive\n @@exclusive_routes = @resource.to_hash[:exclusive] if @@exclusive_routes.nil?\n\n # load on-disk configuration (`is`)\n @disk_values = load_disk_config()\n\n # if this is the last file to be checked, trigger exclusivity enforcement\n enforce_exclusivity if (@@instance_routes_count == @@total_resource_routes_count)\n\n return @disk_values == @memory_values\n end",
"def valid?\n arcs.each do |arc|\n source_transition = find_transition(arc.source_id)\n source_place = find_place(arc.source_id)\n target_transition = find_transition(arc.target_id)\n target_place = find_place(arc.target_id)\n\n # arc from transition to place\n cond1 = not(source_transition.nil?) && not(target_place.nil?)\n\n # arc from place to transition\n cond2 = not(source_place.nil?) && not(target_transition.nil?)\n\n unless cond1 or cond2\n return false\n end\n end\n\n return true\n end",
"def prepare!\n @engine = Compiler.new(@routes)\n @prepared = true\n return if @current_order.zero?\n @routes.sort_by!(&:order)\n end"
] | [
"0.671087",
"0.65421283",
"0.63469076",
"0.60441524",
"0.60304177",
"0.5986562",
"0.5969123",
"0.5889682",
"0.58432394",
"0.58432394",
"0.5822604",
"0.58051395",
"0.5800606",
"0.57533544",
"0.5716744",
"0.5689925",
"0.56418836",
"0.5616786",
"0.5600265",
"0.5600265",
"0.55954146",
"0.5594896",
"0.55903035",
"0.5569573",
"0.5553813",
"0.5540828",
"0.55329263",
"0.5527568",
"0.5526118",
"0.55012566",
"0.5491155",
"0.54900414",
"0.54697704",
"0.54655284",
"0.5450181",
"0.5443898",
"0.54242027",
"0.540136",
"0.53867143",
"0.53867143",
"0.5385433",
"0.53775305",
"0.53747344",
"0.537404",
"0.5373391",
"0.53709954",
"0.5369555",
"0.5365544",
"0.5362536",
"0.53505725",
"0.53256667",
"0.5314189",
"0.5312419",
"0.5312419",
"0.5312157",
"0.53054076",
"0.53023326",
"0.529529",
"0.5293879",
"0.5293557",
"0.5286837",
"0.52810603",
"0.52762914",
"0.5275049",
"0.52741027",
"0.5262997",
"0.5261439",
"0.5260807",
"0.5258001",
"0.52551556",
"0.5251244",
"0.5249634",
"0.5246459",
"0.523793",
"0.52349246",
"0.52342755",
"0.52290785",
"0.52240556",
"0.5215433",
"0.52140325",
"0.5211715",
"0.5205737",
"0.51963145",
"0.51936096",
"0.519026",
"0.5189921",
"0.5189921",
"0.51877385",
"0.518752",
"0.5175176",
"0.5175172",
"0.51728076",
"0.5170688",
"0.5169677",
"0.5163517",
"0.51630646",
"0.5151994",
"0.5148833",
"0.51448786"
] | 0.62956077 | 4 |
Finds routes by using request or env. | def find_by(request_or_env)
request = request_or_env.is_a?(Hash) ? Sinatra::Request.new(request_or_env) : request_or_env
pattern = decode_pattern(request.path_info)
verb = request.request_method
rotation { |offset| match?(offset, pattern) }.select { |route| route.verb == verb }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route(env)\n routes.each do |route|\n return route if route.match(env)\n end\n\n nil\n end",
"def find_route(request)\n @routes.find {|r| r.match?(request) }\n end",
"def find_route(routes, request)\n transport = request.websocket? ? 'WS' : 'HTTP'\n routes.match(request.request_method, transport, request.path)\n end",
"def route_for(request)\n index, params = if @around_match\n send(@around_match, request) { match(request) }\n else\n match(request)\n end\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def recognized_routes_for(env)\n Array(router.recognize(env).first)\n end",
"def route_for(request) #:nodoc:\n index, params = match(request)\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def match(req)\n request = req\n @routes.each do |route|\n return route if route.matches?(request)\n end\n end",
"def get_route( request )\n return nil unless defined?( RAILS_ENV ) \n ::ActionController::Routing::Routes.recognize_path( request.path, {:method => request.request_method.downcase.to_sym } )\n end",
"def match(req)\n routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n @routes.find { |route| route.matches?(req)}\n end",
"def match(req)\n @routes.find { |route| route.matches?(req) }\n end",
"def match(request)\n path = String.normalize_path(request.path)\n method = request.method\n\n match, data = nil\n @sets.each { |set|\n match, data = set[1].match(path, method)\n break if match\n }\n\n fns = []\n if match\n fns = match[3]\n\n # handle route params\n #TODO where to do this?\n request.params.merge!(Hash.strhash(self.data_from_path(path, data, match[1])))\n\n #TODO where to do this?\n request.route_path = match[4]\n end\n\n fns\n end",
"def get_requested_route(env)\n request = Rack::Request.new(env)\n \n http_method = request.request_method.downcase\n path = request.path_info\n\n [http_method, path]\n end",
"def find_match(env)\n path = env['REQ_PATH']\n @serve.each do |pattern, block|\n case pattern\n when FalseClass\n when TrueClass\n return Match.new(self, path, block)\n when String\n if pattern=='*'\n return Match.new(self, path, block)\n elsif /^\\*?\\.[a-z]+$/ =~ pattern\n return Match.new(self, path, block) if File.extname(realpath(path))==pattern\n else\n return Match.new(self, path, block) if File.basename(realpath(path))==pattern\n end\n when Regexp\n if matchdata = pattern.match(path)\n return Match.new(self, path, block, *matchdata.to_a)\n end\n when Waw::Validation::Validator\n if pattern.validate(matching_file(path))\n return Match.new(self, path, block) \n end\n when StaticController::AbstractMatcher\n if pattern.matches?(env)\n return Match.new(self, path, block)\n end\n else\n raise WawError, \"Unrecognized wawaccess pattern #{pattern}\"\n end\n end\n nil\n end",
"def match(req)\n # @routes.each do |route|\n # return route if route.matches?(req)\n # end\n #\n # nil\n @routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n @routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n @routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n @routes.select{|rt| rt.matches?(req) }.first\n end",
"def match(req)\n @routes.each do |route|\n if route.matches?(req)\n return route\n end\n end\n\n nil\n end",
"def match(req)\n @routes.each do |route|\n if route.matches?(req)\n return route\n end\n end\n return nil\n end",
"def call(env)\n rr = Rack::Request.new(env)\n l = env['rack.logger']\n db = l ? l.method(:debug) : DEBUG_NULL\n db.call(DEBUG_NAME) do\n \"[ ? ] url: #{rr.url.inspect}, path: #{rr.fullpath.inspect}\"\n end\n matches = routes_for(rr.fullpath, rr.url)\n result = nil\n matches.each do |addressive|\n env[ADDRESSIVE_ENV_KEY] = addressive\n begin\n result = (addressive.spec.callback || addressive.spec.app).call(env)\n db.call(DEBUG_NAME) do\n \"[#{result[0]}] #{addressive.spec.template.pattern} with #{addressive.variables.inspect} on #{addressive.spec.app} ( route #{addressive.data[:'routes.scanned']} / #{addressive.data[:'routes.total']} ) after #{'%.6f' % addressive.data[:duration]}\"\n end\n rescue\n db.call(DEBUG_NAME) do\n \"[!!!] #{addressive.spec.template.pattern} with #{addressive.variables.inspect} on #{addressive.spec.app} ( route #{addressive.data[:'routes.scanned']} / #{addressive.data[:'routes.total']} ) after #{'%.6f' % addressive.data[:duration]}\"\n end\n raise\n end\n if result[0] != 404\n break\n end\n end\n if result.nil?\n db.call(DEBUG_NAME) do\n \"[404] Nothing found\"\n end\n return not_found(env)\n end\n return result\n end",
"def find_by_path(request_path)\n routes = Disraptor::RouteStore.get_routes()\n\n return routes.values.detect do |route|\n route['sourcePath'] == request_path\n end\n end",
"def routes\n request :get, '/routes'\n end",
"def route\n @route ||= Role.available_routes.find {|r| r.conditions[:path_info].to_s == path_info && r.conditions[:request_method].to_s == request_method}\n end",
"def call(env)\n route = @routes.map do |exp, meta|\n next unless matches = env[\"PATH_INFO\"].match(exp)\n meta.merge(captures: matches)\n end.compact.first\n\n return Yokunai::ErrorsController.new(env).not_found unless route\n\n request_method = env[\"REQUEST_METHOD\"]\n if route[:methods].include?(request_method)\n Object.const_get(route[:class])\n .new(env, route[:captures])\n .public_send(request_method.downcase)\n else\n Yokunai::ErrorsController.new(env).unsupported_method\n end\n end",
"def match(req)\n @routes.detect { |route| route.matches?(req) }\n end",
"def call(env)\n route = self.route(env)\n if route\n env['params'] = route.match(env) || {}\n route.call(env)\n else\n env['params'] = {}\n not_found.call(env)\n end\n end",
"def route_for(**url_details)\n @routes.select { |rt| url_details <= rt.url_details }.first\n end",
"def route! env\n http_route = \"#{env[REQ_METHOD]} #{env[PATH_INFO]}\"\n return true if env[GIN_ROUTE] == http_route\n\n env[GIN_TARGET], env[GIN_PATH_PARAMS] =\n router.resources_for env[REQ_METHOD], env[PATH_INFO]\n\n env[GIN_ROUTE] = http_route\n\n !!env[GIN_TARGET]\n end",
"def route!(request)\n @@request = request\n @@routes.each do |route|\n if route.first == request.path\n return route.last.call\n break\n end\n end\n end",
"def call(env)\n # Rack::Request provides convenient methods\n # for the incoming request\n request = Rack::Request.new(env)\n\n # return a 200 status for all matching routes\n @routes.each do |route|\n content = route.match(request)\n # [][-1] is an enumerable of stringable objects\n # => sometimes you want to return responses lazily (through an enumerable)\n # .to_s because you don't want this to blow up when\n # a route handler returns an array or other format\n return [200, { 'Content-Type' => 'text/plain' }, [content.to_s]] if content\n end\n\n # otherwise, return 404\n [404, {}, ['Not Found']]\n end",
"def match(env)\n @resources.each do |resource|\n matcher_name = resource.match(env)\n return matcher_name if matcher_name\n end\n\n nil\n end",
"def matching_resources(env)\n @resources.find_all { |resource| resource.match!(env) }\n end",
"def handle(request, env)\n params = @params.dup\n path_info, script_name = env[\"PATH_INFO\"], env[\"SCRIPT_NAME\"]\n \n return unless request_conditions.all? do |method_name, condition|\n # TODO: Refactor this... it lacks awesome\n next true unless request.respond_to?(method_name)\n matched, captures = condition.match(request)\n if matched\n params.merge!(captures)\n if method_name == :path_info\n new_path_info = @path_info.dup if @path_info\n new_path_info ||= env[\"PATH_INFO\"].sub(/^#{Regexp.escape(matched)}/, '')\n new_path_info.gsub!(SEGMENT_REGEXP) { |s| params[$2.to_sym] }\n env[\"SCRIPT_NAME\"] = Utils.normalize(request.env[\"SCRIPT_NAME\"] + matched)\n env[\"PATH_INFO\"] = Utils.normalize(new_path_info)\n end\n true\n end\n end\n \n env[\"rack_router.route\"] = self\n env[\"rack_router.params\"].merge! params\n \n @app.call(env)\n ensure\n env[\"PATH_INFO\"], env[\"SCRIPT_NAME\"] = path_info, script_name\n end",
"def routes\n routes = {}\n self.class.each_route do |route|\n #routes[:name] = route.app.name # \"SomeSinatraApp\"\n info = {}\n routes[route.path.to_s.to_sym] = info # that's the path given as argument to get and akin\n info[:verb] = route.verb # get / head / post / put / delete\n info[:file] = route.file # \"some_sinatra_app.rb\" or something\n info[:line] = route.line # the line number of the get/post/... statement\n info[:pattern] = route.pattern # that's the pattern internally used by sinatra\n info[:keys] = route.keys # keys given when route was defined\n info[:conditions] = route.conditions # conditions given when route was defined\n info[:block] = route.block # the route's closure\n end\n routes\n end",
"def get_rack_app(env)\n raise 'No Routes!' unless @route_obj\n\n @route_obj.check_url(\n request_url(env['PATH_INFO']),\n env['REQUEST_METHOD'],\n request_query_params(env['QUERY_STRING'])\n )\n end",
"def get_rack_app(env)\n raise 'No routes!' unless @route_obj\n @route_obj.check_url env['PATH_INFO']\n end",
"def call(request)\n compile! unless compiled?\n pattern, verb, params = *parse_request(request)\n pattern = pattern.encode(Encoding.default_external)\n candidacies = match_with(pattern)\n raise_exception(404) if candidacies.empty?\n candidacies, allows = *candidacies.partition{ |route| route.verb == verb }\n raise_exception(405, :verbs => allows.map(&:verb)) if candidacies.empty?\n candidacies.map{ |route| [route, route.params_for(pattern, params)] }\n end",
"def get_route_environments(rlm_base_url, rlm_username, rlm_password, route, request_environment)\n get_environments_by(route, rlm_base_url, rlm_username, rlm_password, 'route environment list', request_environment)\n # route_type = get_route_type(rlm_base_url, rlm_username, rlm_password, \"route type\", route)\n # unless route_type == \"Strict\"\n # get_environments_by(route, rlm_base_url, rlm_username, rlm_password, \"route environment list\")\n # else\n # []\n # end\n end",
"def find_my_routes(*args)\n bounds = args[0][:bounds].nil? ? default_coordinates : args[0][:bounds].dup\n routes = case args[0][:filter]\n when \"recommended\"\n Route.where(:\"overview_points.latlng\".within(:box) => bounds).where(visibility: 'recommended')\n when \"liked\"\n # TODO need to build this\n else # 'my' or blank\n Route.where(:\"overview_points.latlng\".within(:box) => bounds).where(owner_id: id)\n end\n end",
"def call(env)\n @request = Dolphy::Request.new(env)\n @response = Dolphy::Response.new\n\n router.find_route_for(request).each do |matcher, block|\n if match = router.find_match_data_for(request, with: matcher)\n response.body = [block.call(*match.captures)]\n end\n end\n\n response.status = 404 if response.body.empty?\n response.body << \"Page not found.\" if response.body.empty?\n response.finish\n end",
"def all_routes\n matching_routes\n end",
"def routable_request?(env)\n return true unless defined?(Rails) # If not running on a Rails app, we can't verify if it is invalid\n Rails.application.routes.recognize_path(env['PATH_INFO'])\n true\n rescue ActionController::RoutingError\n false\n end",
"def match_for(path)\n @routes.select { |rt| rt.match?(path) }.first\n end",
"def routes(routes, destination)\n routes.keys.each { |route| return route if routes[route] == destination }\n nil\nend",
"def handle_routes\n instance_exec(@_roda_app.request, &self.class.router_block)\n end",
"def check_request_for_route(request)\n match = ::Merb::Router.match(request)\n if match[0].nil? && match[1].empty?\n raise ::Merb::ControllerExceptions::BadRequest, \"No routes match the request. Request uri: #{request.uri}\"\n else\n match[1]\n end\n end",
"def route() request.route end",
"def recognized_route\n unless @recognized_route\n path = params[:resource_path] || params[:erp] || request.path\n environment = ::ActionController::Routing::Routes.extract_request_environment(request)\n environment.merge!(:method => params[:resource_method]) if params[:resource_method]\n @recognized_route ||= ::ActionController::Routing::Routes.routes_for_controller_and_action(controller_path, action_name).find do |route|\n route.recognize(path, environment)\n end or ResourcesController.raise_no_recognized_route(self)\n end\n @recognized_route\n end",
"def call(env)\n # Grab the verb and requested path from the env parameter\n @request = Rack::Request.new(env)\n verb = @request.request_method\n requested_path = @request.path_info\n\n # Grab the handler block from @routes if it exists\n handler = @routes.fetch(verb, {}).fetch(requested_path, nil)\n\n if handler\n # Evaluate our route handler block in the context of that instance,\n # to give it access to all of the methods (Compare: handler.call)\n result = instance_eval(&handler)\n\n if result.class == String\n # For convenience, if a handler returns a string,\n # assume that it is a successful response.\n [200, {}, [result]]\n else\n # Otherwise, return the result of the block as-is.\n result\n end\n else\n # Return a 404 with a custom error message\n # instead of the default Internal Server Error\n [404, {}, [\"Oops! No routes for #{verb} #{requested_path}\"]]\n end\n end",
"def my_routes\n my_routes = []\n exceptions = %w(Login Signin)\n self.class.routes['GET'].each do |r|\n route = r.first.to_s.gsub(/\\W+|mix/,'').capitalize\n my_routes << route unless exceptions.include?(route)\n end\n return my_routes\n end",
"def recognized_request_for(path, request_method = nil)\n path = \"/#{path}\" unless path.first == '/'\n\n # Assume given controller\n request = ActionController::TestRequest.new({}, {}, nil)\n request.env[\"REQUEST_METHOD\"] = request_method.to_s.upcase if request_method\n request.path = path\n\n ActionController::Routing::Routes.recognize(request)\n request\n end",
"def routes\n routes_method.call\n end",
"def find(verb, url)\n http_verb = verb.to_s.upcase\n route = \"#{http_verb} #{url}\"\n @list[route]\n end",
"def call env\r\n raw = nil\r\n self.class.env = env\r\n #\r\n # match route\r\n # support : String, Regexp\r\n # rel - nil| body| [status,{header},[bodys]]\r\n #\r\n req = Rack::Request.new env\r\n self.class.params = req.params\r\n method = env[\"REQUEST_METHOD\"].downcase\r\n settings[:route][method.to_sym].each do |p|\r\n case p[:path]\r\n when String\r\n if env[\"REQUEST_PATH\"] == p[:path]\r\n raw = p[:proc].call\r\n end\r\n when Regexp\r\n if env[\"REQUEST_PATH\"] =~ p[:path]\r\n if !p[:extend_key].nil? # analize extend_params like /hehe/:id\r\n req.params[p[:extend_key].to_sym] = $1\r\n end\r\n raw = p[:proc].call\r\n end\r\n else\r\n throw :illegal_route\r\n end\r\n end\r\n #\r\n # anaylize raw\r\n # nil - return not_found\r\n # Array - return raw if match [fixnum, hash, array]\r\n # other - return [200, {}, [other.to_s]]\r\n #\r\n status = 200\r\n header = {}\r\n bodys = \"\"\r\n if raw.nil?\r\n not_found\r\n else\r\n bodys = raw\r\n if Array === raw\r\n status = raw[0]\r\n header = raw[1]\r\n bodys = raw[2]\r\n end\r\n if settings[:json] == true\r\n bodys = bodys.to_json\r\n end\r\n if Array === bodys\r\n bodys = bodys.map{|e| e.to_s}\r\n [status, header, bodys]\r\n else\r\n [status, header, [bodys.to_s]]\r\n end\r\n end\r\n end",
"def recognize_path(path_info)\n route, params = recognize(Rack::MockRequest.env_for(path_info)).first\n [route.name, params]\n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def routes\n context[:routes]\n end",
"def gather_endpoints_to_check\n Rails.application.routes.routes.map do |route|\n verb = route.verb.downcase.to_sym\n example_path = route.path.spec\n .to_s.gsub('(.:format)', '')\n .gsub(/:([^\\/]+)/,'SOME_PLACEHOLDER_PARAM')\n .gsub('*path', 'SOME_PLACEHOLDER_PATH')\n .gsub('*filename','SOME_PLACEHOLDER_FILENAME')\n next unless verb.present?\n [verb, example_path]\n end.compact\n end",
"def routes(set_name = :main, &block)\n if set_name && block\n @@routes[set_name] = block\n else\n @@routes\n end\n end",
"def find_route(url)\n @routes.each do |route|\n if route.match(url)\n return route\n end\n end\n nil\n end",
"def get_routes\n raise \"Method not implemented\"\n end",
"def routes\n cached_routes\n end",
"def recognize(request)\n prepare! unless prepared?\n pattern, verb, params = parse_request(request)\n fetch(pattern, verb){|route| [route, params_for(route, pattern, params)] }\n end",
"def find(name) \n print(\"finding route for #{name}\\n\")\n res={}\n resList=[]\n @route.each_pair do |p,d|\n match=if p.class==String\n name==p\n elsif p.class==Regexp\n name=~p\n else\n print \"Routes::find: got #{p.class}\\n\"\n false\n end\n if match\n prio=d.options[:prio]\n if res.include?(d.dest)\n if res[d.dest][:prio]>prio\n res[d.dest]=d.options\n end\n else\n res[d.dest]=d.options\n end\n end\n end\n resList=res.to_a.map {|r| RouteEntry.new(r[0], r[1])} # as array of RouteEntry\n resList.sort! {|a,b| a.options[:prio] <=> b.options[:prio]} # sort by prio\n end",
"def each_route &block\n @routes_lookup.each do |key,route|\n next unless Array === key\n block.call route, key[0], key[1]\n end\n end",
"def route_for_path(path, method=nil)\n env = Rack::MockRequest.env_for(path || \"\", {:method => method})\n req = ActionDispatch::Request.new(env)\n route, matches, params = Rails.application.routes.set.recognize(req)\n return route\n end",
"def find_resource(request, response)\n if route = find_route(request)\n prepare_resource(route, request, response)\n end\n end",
"def route_sets; end",
"def call_by_request(request)\n rotation do |offset|\n pattern = decode_pattern(request.path_info)\n if route = match?(offset, pattern)\n params = route.params_for(pattern, request.params)\n yield(route, params) if route.verb == request.request_method\n route\n end\n end\n end",
"def find_all(req)\n prefetch nil\n\n specs.values.select do |spec|\n req.match? spec\n end\n end",
"def _find_context_by_params(path, verb, params)\n (stub[path][verb].find { |_, spec| spec['request'] == params } || []\n ).first\n end",
"def recognize(env)\n env[\"lita.robot\"] = robot\n recognized_routes_for(env).map { |match| match.route.name }\n end",
"def routes\n @routes ||= load_routes\n end",
"def request_type_find_all?\n request.env[\"PATH_INFO\"][-8..-1] == \"find_all\"\n end",
"def routes\n app_obj.routes\n end",
"def routes\n @routes ||= []\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/system',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/system/, \n :title => 'Sistema', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/admin/logger',\n :parent_path => '/admin/system',\n :regular_expression => /^\\/admin\\/logger/, \n :title => 'Trazas', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/logger-config',\n :regular_expression => /^\\/admin\\/logger-config/, \n :title => 'Logger configuration', \n :description => 'Configure the logger',\n :fit => 1,\n :module => :system }, \n {:path => '/business-events',\n :regular_expression => /^\\/admin\\/business-events/, \n :title => 'Business events',\n :description => 'Manage the business events.',\n :fit => 1,\n :module => :system }]\n \n end",
"def request_matching specs\n specs = specs_matching specs\n req = specs && pack_path(specs)\n req\n end",
"def routes\n raise NotImplementedError\n end",
"def recognize_with_filtering(request, &block)\n path, route, matches, params = request.env['PATH_INFO'], nil, nil, nil\n original_path = path.dup\n\n filters.run(:around_recognize, path, request.env) do\n route, matches, params = recognize_without_filtering(request)\n params || {}\n end\n\n request.env['PATH_INFO'] = original_path # hmm ...\n return nil unless route\n\n if block_given?\n return block.call(route, matches, params)\n else\n return route, matches, params\n end\n end",
"def match(env)\n return nil unless match!(env)\n\n name, = @matchers.find { |_name, matcher| matcher.match(env) }\n name\n end",
"def routes(set_name = :main, &block)\n self.class.routes(set_name, &block)\n load_routes\n end",
"def routes\n @routes ||= []\n end",
"def routes\n @routes ||= []\n end",
"def request_to(path, method = :get, env = {})\n env[:request_method] ||= method.to_s.upcase\n env[:request_uri] = path\n \n check_request_for_route(build_request({}, env))\n end",
"def match(request, service_request, routes) \n routes.each do |method, options|\n unless method.match(':action')\n return options[:action] if service_request.methodname == method\n else \n matcher = Regexp.escape(method).sub(':action', '([A-Za-z0-9_]*)')\n matcher = \"^#{matcher}$\"\n if match = service_request.methodname.match(matcher)\n return match[1]\n end\n end\n end\n raise \"no service route matches #{service_request.methodname}\"\n end",
"def env_for(env, params = {}, options = {})\n require \"rack/mock\"\n\n case env\n when ::String\n ::Rack::MockRequest.env_for(env, options)\n when ::Symbol\n begin\n url = path(env, params)\n return env_for(url, params, options) # rubocop:disable Style/RedundantReturn\n rescue Hanami::Router::MissingRouteError\n {} # Empty Rack env\n end\n else\n env\n end\n end",
"def request_to(path, method = :get, env = {})\n env[:request_method] ||= method.to_s.upcase\n env[:request_uri] = path\n \n check_request_for_route(fake_request(env))\n end",
"def resolve(env)\n @request = Rack::Request.new(env)\n method = env['REQUEST_METHOD']\n path = env['PATH_INFO']\n key = \"#{method} #{path}\"\n do_action(key)\n rescue StandardError => e\n puts e.message\n puts e.backtrace\n Controller.new.internal_error\n end",
"def run(req, res)\n parse_http_methods!(req)\n matching_route = match(req)\n if matching_route\n matching_route.run(req, res)\n else\n res.status = 404\n res.write \"404 route not found\"\n end\n end",
"def route(index_or_name)\n case index_or_name\n when Integer\n Rails.application.routes.routes[index_or_name]\n when Symbol # named route\n Rails.application.routes.named_routes.get index_or_name\n end\nend",
"def find_all(req)\n res = []\n\n return res unless @remote\n\n name = req.dependency.name\n\n @all[name].each do |uri, n|\n if req.match? n, @prerelease\n res << Gem::Resolver::IndexSpecification.new(\n self, n.name, n.version, uri, n.platform)\n end\n end\n\n res\n end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end"
] | [
"0.7627223",
"0.74200827",
"0.7418732",
"0.721284",
"0.7113679",
"0.70978194",
"0.6911638",
"0.67903876",
"0.6689333",
"0.6689333",
"0.66392386",
"0.6619604",
"0.6610928",
"0.65896064",
"0.6587124",
"0.65777093",
"0.6553928",
"0.6553928",
"0.65202415",
"0.647904",
"0.6425076",
"0.6399662",
"0.639286",
"0.636293",
"0.631036",
"0.6291428",
"0.62726736",
"0.6032687",
"0.6029553",
"0.60185385",
"0.6006777",
"0.6002547",
"0.59973764",
"0.5982797",
"0.5899639",
"0.5896632",
"0.5885077",
"0.5874464",
"0.5861144",
"0.58548015",
"0.5845141",
"0.5823153",
"0.582097",
"0.58160496",
"0.5787212",
"0.57534367",
"0.5739225",
"0.5727681",
"0.57203174",
"0.5710457",
"0.5705983",
"0.57056415",
"0.5695106",
"0.56701726",
"0.5669241",
"0.56444484",
"0.5634048",
"0.56205046",
"0.56205046",
"0.5606702",
"0.55831456",
"0.5582829",
"0.5582464",
"0.55759543",
"0.55583423",
"0.5547089",
"0.5547007",
"0.5536075",
"0.5521671",
"0.5518809",
"0.55135876",
"0.55081844",
"0.5495557",
"0.54752946",
"0.54728293",
"0.5472731",
"0.54712373",
"0.5470057",
"0.5442243",
"0.54379183",
"0.54351026",
"0.54340726",
"0.54291356",
"0.5419659",
"0.5418699",
"0.54174656",
"0.54174656",
"0.54100084",
"0.54069036",
"0.53786504",
"0.5378407",
"0.5363057",
"0.53551733",
"0.53511846",
"0.53501546",
"0.5346331",
"0.5346331",
"0.5346331",
"0.5346331",
"0.5346331"
] | 0.77067447 | 0 |
Calls routes by using request. | def call_by_request(request)
rotation do |offset|
pattern = decode_pattern(request.path_info)
if route = match?(offset, pattern)
params = route.params_for(pattern, request.params)
yield(route, params) if route.verb == request.request_method
route
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route() request.route end",
"def routes\n request :get, '/routes'\n end",
"def route!(request)\n @@request = request\n @@routes.each do |route|\n if route.first == request.path\n return route.last.call\n break\n end\n end\n end",
"def run(req, res)\n # The #run method will figure out what URL was requested, match it to\n # the path regex of one Route object, and finally ask the Route to\n # instantiate the appropriate controller, and call the appropriate method.\n end",
"def handle_routes\n instance_exec(@_roda_app.request, &self.class.router_block)\n end",
"def run(request, response)\n\n match_data = @pattern.match(request.path)\n\n route_params = Hash[match_data.names.zip(match_data.captures)]\n\n @controller_class\n .new(request, response, route_params)\n .invoke_action(action_name)\n end",
"def call(request)\n compile! unless compiled?\n pattern, verb, params = *parse_request(request)\n pattern = pattern.encode(Encoding.default_external)\n candidacies = match_with(pattern)\n raise_exception(404) if candidacies.empty?\n candidacies, allows = *candidacies.partition{ |route| route.verb == verb }\n raise_exception(405, :verbs => allows.map(&:verb)) if candidacies.empty?\n candidacies.map{ |route| [route, route.params_for(pattern, params)] }\n end",
"def dispatch_action(request)\n method = request_method(request)\n path = request.path.sub(/\\.\\w+$/, '')\n route = @routing.detect { |r| r[0] == method && r[1] == path }\n route[2] if route\n end",
"def call(env)\n request = Rack::Request.new(env)\n raise_exception(400) unless valid_verb?(request.request_method)\n recognize(request).each do |route, params|\n catch(:pass){ return invoke(route, params) }\n end\n rescue BadRequest, NotFound, MethodNotAllowed\n $!.call\n end",
"def routes\n routes_method.call\n end",
"def routes(&block); end",
"def routes(&block); end",
"def match(request)\n path = String.normalize_path(request.path)\n method = request.method\n\n match, data = nil\n @sets.each { |set|\n match, data = set[1].match(path, method)\n break if match\n }\n\n fns = []\n if match\n fns = match[3]\n\n # handle route params\n #TODO where to do this?\n request.params.merge!(Hash.strhash(self.data_from_path(path, data, match[1])))\n\n #TODO where to do this?\n request.route_path = match[4]\n end\n\n fns\n end",
"def route_for(request)\n index, params = if @around_match\n send(@around_match, request) { match(request) }\n else\n match(request)\n end\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def call(env)\n route = self.route(env)\n if route\n env['params'] = route.match(env) || {}\n route.call(env)\n else\n env['params'] = {}\n not_found.call(env)\n end\n end",
"def call(request); end",
"def run(req, res)\n match_data = @pattern.match(req.path)\n\n route_params = {}\n match_data.names.each do |name|\n route_params[name] = match_data[name]\n end\n\n @controller_class.new(req, res, route_params).invoke_action(action_name)\n end",
"def run(req, res)\n #@action = :index\n #@method = :get\n #@pattern = /^\\/users$/\n #@class = DummyController\n \n @params = req.path\n #route_params = @params\n ControllerBase.new(req, res, @params).invoke_action(@method, @pattern, @class, @action)\n end",
"def handle(request, env)\n params = @params.dup\n path_info, script_name = env[\"PATH_INFO\"], env[\"SCRIPT_NAME\"]\n \n return unless request_conditions.all? do |method_name, condition|\n # TODO: Refactor this... it lacks awesome\n next true unless request.respond_to?(method_name)\n matched, captures = condition.match(request)\n if matched\n params.merge!(captures)\n if method_name == :path_info\n new_path_info = @path_info.dup if @path_info\n new_path_info ||= env[\"PATH_INFO\"].sub(/^#{Regexp.escape(matched)}/, '')\n new_path_info.gsub!(SEGMENT_REGEXP) { |s| params[$2.to_sym] }\n env[\"SCRIPT_NAME\"] = Utils.normalize(request.env[\"SCRIPT_NAME\"] + matched)\n env[\"PATH_INFO\"] = Utils.normalize(new_path_info)\n end\n true\n end\n end\n \n env[\"rack_router.route\"] = self\n env[\"rack_router.params\"].merge! params\n \n @app.call(env)\n ensure\n env[\"PATH_INFO\"], env[\"SCRIPT_NAME\"] = path_info, script_name\n end",
"def call(env)\n @request = Rack::Request.new(env)\n verb = @request.request_method\n requested_path = @request.path_info\n handler = @routes.fetch(verb, {}).fetch(requested_path, nil)\n\n if handler\n # give handler access to all of the methods, on the instance of Nancy::Base\n result = instance_eval(&handler)\n # If a handler returns a string, assume that it is a successful response, and so we construct a successful Rack response\n # otherwise, we return the result of the block as-is\n # [status, header, body]\n if result.class == String\n [200, {}, [result]]\n else\n result\n end\n else\n [404, {}, [\"Oops! No route for #{verb} #{requested_path}\"]]\n end\n end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def call(env)\n route = @routes.map do |exp, meta|\n next unless matches = env[\"PATH_INFO\"].match(exp)\n meta.merge(captures: matches)\n end.compact.first\n\n return Yokunai::ErrorsController.new(env).not_found unless route\n\n request_method = env[\"REQUEST_METHOD\"]\n if route[:methods].include?(request_method)\n Object.const_get(route[:class])\n .new(env, route[:captures])\n .public_send(request_method.downcase)\n else\n Yokunai::ErrorsController.new(env).unsupported_method\n end\n end",
"def process_http_request\n route_http_request\n end",
"def make_request(request)\n puts \"\\n\\n\"\n puts \"==> Request, action='#{request.path}', params = #{request.query}...\"\n\n action = request.path.to_s.split(\"/\")[-1]\n\n if action && @app.valid?(action) then\n response = @app.send(action.to_sym, request.query)\n\n return response\n end\n\n return \"Error: Unrecognised action: #{action}\"\n rescue Exception => e\n $stderr.puts \"*** [E]: #{e}\\n#{e.backtrace.join(\"\\n\")}\"\n return \"Error: #{e}\"\n end",
"def run(req, res)\n route_params = {}\n\n match_data = @pattern.match(req.path)\n match_data.names.each do |key|\n route_params[key] = match_data[key]\n end\n\n controller = @controller_class.new(req, res, route_params)\n controller.invoke_action(@action_name)\n end",
"def run(req, res)\n @route_params = {}\n\n # I need to build route_params from the URL params\n # @pattern is the regexp\n match_data = @pattern.match(req.path)\n # * @pattern is the regexp given in the router.draw block in\n # p06_router_server.rb\n # * req.path is the url we are matching against\n # match_data gives us the MatchData object\n match_data.names.each do |name|\n @route_params[name] = match_data[name]\n end\n #this loop creates the params!\n\n controller_instance = @controller_class.new(req, res, @route_params)\n controller_instance.invoke_action(@action_name)\n end",
"def call(env)\n # Grab the verb and requested path from the env parameter\n @request = Rack::Request.new(env)\n verb = @request.request_method\n requested_path = @request.path_info\n\n # Grab the handler block from @routes if it exists\n handler = @routes.fetch(verb, {}).fetch(requested_path, nil)\n\n if handler\n # Evaluate our route handler block in the context of that instance,\n # to give it access to all of the methods (Compare: handler.call)\n result = instance_eval(&handler)\n\n if result.class == String\n # For convenience, if a handler returns a string,\n # assume that it is a successful response.\n [200, {}, [result]]\n else\n # Otherwise, return the result of the block as-is.\n result\n end\n else\n # Return a 404 with a custom error message\n # instead of the default Internal Server Error\n [404, {}, [\"Oops! No routes for #{verb} #{requested_path}\"]]\n end\n end",
"def route\n #TODO\n end",
"def run(req, res)\n if req.body\n check_method_param(req)\n end\n route = match(req)\n if route.nil?\n res.status = 404\n res.body = \"Cannot find route for #{req.request_method} #{req.path}\"\n else\n route.run(req, res)\n end\n end",
"def route_request\n env.logger.debug \"#{self.class} ROUTING - #{env[Goliath::Request::PATH_INFO]}\"\n if has_path = ( env[Goliath::Request::PATH_INFO] =~ /^\\/(\\w+)(\\/\\w+)*/ )\n env.logger.debug \"#{self.class} route_request:\\t pathinfo = #{$1} extended = #{$2}\"\n path_info = $1\n extended_path_info = $2\n has_path = true #it will be a number or nil - let's just make it a bool\n elsif params[:id]\n has_path = true\n end\n \n method = env[Goliath::Request::REQUEST_METHOD]\n action = case method\n when 'GET'\n has_path ? 'show' : 'index'\n when 'POST'\n has_path ? ( raise BadRequestError, \"can't post to this resource\" ) : 'create'\n when 'PUT'\n !has_path ? ( raise BadRequestError, \"no resource to PUT to\" ) : 'update'\n when 'DELETE'\n !has_path ? ( raise BadRequestError, \"no resource to DELETE\" ) : 'delete'\n else\n raise MethodNotAllowedError, \"unknown request method\"\n end\n env.logger.info \"#{self.class} route_request:\\t attempting to call #{action} action\"\n if self.respond_to?(action, true) #second param includes private methods\n env['params']['id'] = params[:id] || (path_info if has_path)\n self.send(action)\n else\n error_on MethodNotAllowedError, \"#{action} not supported for this resource\"\n end\n end",
"def run(req, res)\n if matches?(req)\n controller_instance = controller_class.new(req, res, route_params(req))\n controller_instance.invoke_action(action_name)\n else\n # extra precaution! won't be hit if `Router#run` is used\n res.status = 404\n res.write(\"No route matches for #{http_method} on #{controller_class}\")\n end\n end",
"def run(req, res)\n route_params = self.make_match_hash(req)\n controller = @controller_class.new(req, res, route_params)\n controller.invoke_action(@action_name)\n end",
"def run(req, res)\n regex = Regexp.new(@pattern.to_s)\n match_data = regex.match(req.path)\n route_params = {}\n match_data.names.each do |key|\n route_params[key] = match_data[key]\n end\n control = @controller_class.new(req, res, route_params)\n control.invoke_action(@action_name)\n end",
"def run(req, res)\n match_data = @pattern.match(req.path)\n route_params = (match_data) ?\n match_data.names.zip(match_data.captures).to_h\n : {}\n\n controller_instance = @controller_class.new(req, res, route_params)\n\n controller_instance.invoke_action(@action_name)\n end",
"def process(request_hash)\n request = Request.new(request_hash)\n case request.path\n when '/'\n index_route(request)\n when %r{^/sleep/\\d+$}\n sleep_route(request)\n else\n Response.new(\n \"No route found for #{request.path}. Try '/' or '/sleep/3'.\",\n status: 404\n )\n end\n end",
"def dispatch env\n raise Gin::NotFound,\n \"No route exists for: #{env[REQ_METHOD]} #{env[PATH_INFO]}\" unless\n env[GIN_TARGET]\n\n env[GIN_APP] = self\n env[GIN_TARGET][0].call(env)\n\n rescue ::Exception => err\n handle_error(err, env)\n end",
"def run(request, response)\n matching_route = match(request)\n\n if matching_route.nil?\n response.status = 404\n\n response.write(\"Sorry! The requested URL #{request.path} was not not found!\")\n else\n matching_route.run(request, response)\n end\n end",
"def route_for(request) #:nodoc:\n index, params = match(request)\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def call_routes\n return @call_routes\n end",
"def call(request)\r\n self\r\n end",
"def run(req, res)\n match_data = pattern.match(req.path)\n # hash = {}\n # match_data.names.each do |name|\n # hash[name] = match_data[name]\n # end\n hash = match_data.names.each_with_object({}) do |name, h|\n h[name] = match_data[name]\n end\n controller_class.new(req, res, hash).invoke_action(action_name)\n end",
"def route_for(name, *args); end",
"def run(req, res)\n first_matched_route = match(req)\n\n if first_matched_route\n first_matched_route.run(req, res)\n else\n res.status = 404\n res.write(\"No route matches for #{req.request_method} for #{req.path}\")\n end\n end",
"def run(req, res)\n parse_http_methods!(req)\n matching_route = match(req)\n if matching_route\n matching_route.run(req, res)\n else\n res.status = 404\n res.write \"404 route not found\"\n end\n end",
"def run\n make_request(@path)\n end",
"def call(request)\n handler.call(request)\n end",
"def run(req, res)\n controller = controller_class.new(req, res, route_params(req))\n controller.invoke_action(action_name)\n end",
"def do_dispatch(env)\n path = env['PATH_INFO']\n\n # Try to serve a public file\n ret = dispatch_public(env, path)\n return ret if not ret.nil?\n\n log.debug \"Checking for routes that match: #{path}\"\n route = router.match(env)\n\n if route.has_key? :ok\n dispatch_controller(route, env)\n else\n [404, {\"Content-Type\" => \"text/plain\"}, [\"404 Not Found: #{path}\"]]\n end\n end",
"def _routes; end",
"def request(method, path, params)\n self.class.send(method, path, params)\n end",
"def call(env)\n @request = Dolphy::Request.new(env)\n @response = Dolphy::Response.new\n\n router.find_route_for(request).each do |matcher, block|\n if match = router.find_match_data_for(request, with: matcher)\n response.body = [block.call(*match.captures)]\n end\n end\n\n response.status = 404 if response.body.empty?\n response.body << \"Page not found.\" if response.body.empty?\n response.finish\n end",
"def run(req, res)\n matched_route = match(req)\n if matched_route\n matched_route.run(req, res)\n else\n res.status = 404\n res.write(\"No route matches #{req.fullpath}\")\n end\n end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def request(*args); end",
"def call(env)\n @request = Rack::Request.new(env)\n @params = @path_params.merge(@request.params.symbolize_keys)\n process_response(instance_exec(self, params, request, &@block))\n end",
"def request(*args)\n end",
"def call env\r\n raw = nil\r\n self.class.env = env\r\n #\r\n # match route\r\n # support : String, Regexp\r\n # rel - nil| body| [status,{header},[bodys]]\r\n #\r\n req = Rack::Request.new env\r\n self.class.params = req.params\r\n method = env[\"REQUEST_METHOD\"].downcase\r\n settings[:route][method.to_sym].each do |p|\r\n case p[:path]\r\n when String\r\n if env[\"REQUEST_PATH\"] == p[:path]\r\n raw = p[:proc].call\r\n end\r\n when Regexp\r\n if env[\"REQUEST_PATH\"] =~ p[:path]\r\n if !p[:extend_key].nil? # analize extend_params like /hehe/:id\r\n req.params[p[:extend_key].to_sym] = $1\r\n end\r\n raw = p[:proc].call\r\n end\r\n else\r\n throw :illegal_route\r\n end\r\n end\r\n #\r\n # anaylize raw\r\n # nil - return not_found\r\n # Array - return raw if match [fixnum, hash, array]\r\n # other - return [200, {}, [other.to_s]]\r\n #\r\n status = 200\r\n header = {}\r\n bodys = \"\"\r\n if raw.nil?\r\n not_found\r\n else\r\n bodys = raw\r\n if Array === raw\r\n status = raw[0]\r\n header = raw[1]\r\n bodys = raw[2]\r\n end\r\n if settings[:json] == true\r\n bodys = bodys.to_json\r\n end\r\n if Array === bodys\r\n bodys = bodys.map{|e| e.to_s}\r\n [status, header, bodys]\r\n else\r\n [status, header, [bodys.to_s]]\r\n end\r\n end\r\n end",
"def run url\n # We need to tell Micon about the `:request` scope, so the `:request` component will be\n # destroyed automatically.\n micon.activate :request, {} do\n self.request = Request.new url\n\n # Using router to get controller class and method from the url.\n # Note that You using the `:router` component as if it's just an attribute.\n controller_class, method = router.decode url\n\n # Creating controller and calling it to generate output.\n controller = controller_class.new\n\n # Note we don't need to explicitly pass the `request` to controller, it will be automatically injected.\n controller.send method\n end\n end",
"def get_route( request )\n return nil unless defined?( RAILS_ENV ) \n ::ActionController::Routing::Routes.recognize_path( request.path, {:method => request.request_method.downcase.to_sym } )\n end",
"def route(*args)\n @app.log << \"route #{args.inspect[1..-2]}\"\n @app.route(*args)\nend",
"def call(env)\n rr = Rack::Request.new(env)\n l = env['rack.logger']\n db = l ? l.method(:debug) : DEBUG_NULL\n db.call(DEBUG_NAME) do\n \"[ ? ] url: #{rr.url.inspect}, path: #{rr.fullpath.inspect}\"\n end\n matches = routes_for(rr.fullpath, rr.url)\n result = nil\n matches.each do |addressive|\n env[ADDRESSIVE_ENV_KEY] = addressive\n begin\n result = (addressive.spec.callback || addressive.spec.app).call(env)\n db.call(DEBUG_NAME) do\n \"[#{result[0]}] #{addressive.spec.template.pattern} with #{addressive.variables.inspect} on #{addressive.spec.app} ( route #{addressive.data[:'routes.scanned']} / #{addressive.data[:'routes.total']} ) after #{'%.6f' % addressive.data[:duration]}\"\n end\n rescue\n db.call(DEBUG_NAME) do\n \"[!!!] #{addressive.spec.template.pattern} with #{addressive.variables.inspect} on #{addressive.spec.app} ( route #{addressive.data[:'routes.scanned']} / #{addressive.data[:'routes.total']} ) after #{'%.6f' % addressive.data[:duration]}\"\n end\n raise\n end\n if result[0] != 404\n break\n end\n end\n if result.nil?\n db.call(DEBUG_NAME) do\n \"[404] Nothing found\"\n end\n return not_found(env)\n end\n return result\n end",
"def request(*args, &block); end",
"def recognize(request)\n prepare! unless prepared?\n pattern, verb, params = parse_request(request)\n fetch(pattern, verb){|route| [route, params_for(route, pattern, params)] }\n end",
"def dispatch(name, req, res); end",
"def request(name, method, path, &blk)\n req = LieDetector::Request.new self\n req.method method\n req.path path\n req.instance_exec &blk\n register(req, name)\n end",
"def request(method, *args)\n public_send(method, *args)\n end",
"def primary(request, element)\n # TODO: see if it's faster to compare either\n # by `:java_class`, `:instance_of?` or `:code`\n case\n when request.instance_of?(Cf::GETRequest)\n @route.call(:get, request, element)\n when request.instance_of?(Cf::PUTRequest)\n @route.call(:put, request, element)\n when request.instance_of?(Cf::POSTRequest)\n @route.call(:post, request, element)\n when request.instance_of?(Cf::DELETERequest)\n @route.call(:delete, request, element)\n else\n request.respond(CR[:bad_request])\n end\n end",
"def do_request(request, response)\n if request.request_method != 'GET'\n response.status = 405\n LOG.error \"Unsupported request method #{request.request_method}\"\n return\n end\n\n do_get(request, response)\n end",
"def dispatch_action(req)\n controller = ROUTE_TO_CONTROLLER[req.path_info]\n raise Heartcheck::Errors::RoutingError if controller.nil?\n\n Logger.info \"Start [#{controller}] from #{req.ip} at #{Time.now}\"\n\n controller.new.index.tap do |_|\n Logger.info \"End [#{controller}]\\n\"\n end\n end",
"def process(request); end",
"def run(req, res)\n @params = req.params\n controller_class.send(action_name)\n end",
"def each(*args)\n routes.each(*args)\n end",
"def route_index; end",
"def call(request)\n test request\n end",
"def request_to(path, method = :get, env = {})\n env[:request_method] ||= method.to_s.upcase\n env[:request_uri] = path\n \n check_request_for_route(fake_request(env))\n end",
"def resolve(env)\n @request = Rack::Request.new(env)\n method = env['REQUEST_METHOD']\n path = env['PATH_INFO']\n key = \"#{method} #{path}\"\n do_action(key)\n rescue StandardError => e\n puts e.message\n puts e.backtrace\n Controller.new.internal_error\n end",
"def any(path, &block)\n route 'GET', path, &block\n route 'POST', path, &block\n end",
"def call(env)\n env['rack.logger'] = logger\n Routes.call(env)\n end",
"def call(env)\n env['rack.logger'] = logger\n Routes.call(env)\n end",
"def call(env)\n request = Rack::Request.new(env)\n if redirect_trailing_slash? && (request.head? || request.get?) && request.path_info[-1] == ?/\n response = Rack::Response.new\n response.redirect(request.path_info[0, request.path_info.size - 1], 302)\n response.finish\n else\n response = recognize(request)\n env['router'] = self\n if response.is_a?(RoutingResponse)\n [response.status, response.headers, []]\n elsif response && response.route.dest && response.route.dest.respond_to?(:call)\n process_params(env, response)\n consume_path!(request, response) if response.partial_match?\n response.route.dest.call(env)\n else\n @default_app.call(env)\n end\n end\n end",
"def handle(http_request, response)\n start = Time.now\n request = Merb::Request.new(http_request)\n Merb.logger.info(\"Params: #{request.params.inspect}\")\n Merb.logger.info(\"Cookies: #{request.cookies.inspect}\")\n # user friendly error messages\n if request.route_params.empty?\n raise ControllerExceptions::BadRequest, \"No routes match the request\"\n elsif request.controller_name.nil?\n raise ControllerExceptions::BadRequest, \"Route matched, but route did not specify a controller\" \n end\n Merb.logger.debug(\"Routed to: #{request.route_params.inspect}\")\n # set controller class and the action to call\n klass = request.controller_class\n dispatch_action(klass, request.action, request, response)\n rescue => exception\n Merb.logger.error(Merb.exception(exception))\n exception = controller_exception(exception)\n dispatch_exception(request, response, exception)\n end",
"def match(request, service_request, routes) \n routes.each do |method, options|\n unless method.match(':action')\n return options[:action] if service_request.methodname == method\n else \n matcher = Regexp.escape(method).sub(':action', '([A-Za-z0-9_]*)')\n matcher = \"^#{matcher}$\"\n if match = service_request.methodname.match(matcher)\n return match[1]\n end\n end\n end\n raise \"no service route matches #{service_request.methodname}\"\n end",
"def service(request, response)\n params = @router.resolve_uri(request.request_uri)\n controller = Acoustic::Controller.from_symbol(params[:controller])\n action = params[:action]\n controller.process(action, params, request, response)\n rescue Acoustic::UnresolvableUri, Acoustic::ControllerNameError\n raise Acoustic::NotFound.new(request.request_uri)\n end",
"def call(env)\n path = env[PATH_INFO]\n method = R3.method_code(env[REQUEST_METHOD])\n return method_not_allowed unless method\n\n params, (app, data) = @tree.match(path, method)\n\n return method_not_allowed if !params && @tree.match?(path)\n return path_not_found unless params\n\n store_query_hash_into_env(params, env)\n env[SHELF_R3_DATA] = data if data\n\n app.call(env)\n end",
"def find_route(routes, request)\n transport = request.websocket? ? 'WS' : 'HTTP'\n routes.match(request.request_method, transport, request.path)\n end",
"def route\n @base_controller.route if @base_controller\n end",
"def call(env)\n # Rack::Request provides convenient methods\n # for the incoming request\n request = Rack::Request.new(env)\n\n # return a 200 status for all matching routes\n @routes.each do |route|\n content = route.match(request)\n # [][-1] is an enumerable of stringable objects\n # => sometimes you want to return responses lazily (through an enumerable)\n # .to_s because you don't want this to blow up when\n # a route handler returns an array or other format\n return [200, { 'Content-Type' => 'text/plain' }, [content.to_s]] if content\n end\n\n # otherwise, return 404\n [404, {}, ['Not Found']]\n end",
"def dispatch_request(env)\n @params = Hash.recursively_symbolize_graph!(Rack::Utils::parse_query(env['QUERY_STRING']))\n @json_data = @internal_proxy ? (EventMachineRPC.parse_json_from_file(@params[:json_path]) rescue {}) : {}\n method = strip_base(env)\n self.send(method.to_sym, env)\n end"
] | [
"0.7804204",
"0.7695202",
"0.7332975",
"0.7323927",
"0.72675323",
"0.7197363",
"0.70404977",
"0.69913316",
"0.6950314",
"0.6933684",
"0.68899107",
"0.68899107",
"0.68702203",
"0.6848445",
"0.6842834",
"0.6825233",
"0.6780787",
"0.67286074",
"0.67237717",
"0.66959727",
"0.66917217",
"0.66917217",
"0.66917217",
"0.66917217",
"0.66917217",
"0.66917217",
"0.66917217",
"0.66917217",
"0.66917217",
"0.66917217",
"0.66917217",
"0.6618144",
"0.6595249",
"0.6591689",
"0.6591085",
"0.65776366",
"0.6560654",
"0.65386295",
"0.6523374",
"0.65217036",
"0.64567024",
"0.6450442",
"0.6445353",
"0.6441447",
"0.64320713",
"0.64289117",
"0.64165866",
"0.64072645",
"0.6406968",
"0.6401836",
"0.6387421",
"0.6383382",
"0.637535",
"0.63575107",
"0.63215595",
"0.6306932",
"0.6304066",
"0.62973225",
"0.62801844",
"0.6272638",
"0.62569255",
"0.6207975",
"0.6207076",
"0.6207076",
"0.6207076",
"0.61949724",
"0.61865705",
"0.61814475",
"0.6176078",
"0.61635995",
"0.61609966",
"0.61575377",
"0.6156661",
"0.6132263",
"0.61050767",
"0.6076627",
"0.6057586",
"0.6054987",
"0.60495013",
"0.6048301",
"0.6038866",
"0.60275435",
"0.6025754",
"0.60204417",
"0.602007",
"0.60121566",
"0.60107046",
"0.60052615",
"0.60049087",
"0.60037875",
"0.60037875",
"0.59917307",
"0.59710944",
"0.59637237",
"0.59409386",
"0.59398836",
"0.5932048",
"0.5930305",
"0.5925333",
"0.5903139"
] | 0.73251754 | 3 |
Finds routes by using PATH_INFO. | def find_by_pattern(pattern)
pattern = decode_pattern(pattern)
rotation { |offset| match?(offset, pattern) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recognize_path(path_info)\n prepare! unless prepared?\n route = @engine.find_by_pattern(path_info).first\n [route.name, route.params_for(path_info, {})]\n end",
"def recognize_path(path_info)\n route, params = recognize(Rack::MockRequest.env_for(path_info)).first\n [route.name, params]\n end",
"def recognized_routes_for(env)\n Array(router.recognize(env).first)\n end",
"def gather_endpoints_to_check\n Rails.application.routes.routes.map do |route|\n verb = route.verb.downcase.to_sym\n example_path = route.path.spec\n .to_s.gsub('(.:format)', '')\n .gsub(/:([^\\/]+)/,'SOME_PLACEHOLDER_PARAM')\n .gsub('*path', 'SOME_PLACEHOLDER_PATH')\n .gsub('*filename','SOME_PLACEHOLDER_FILENAME')\n next unless verb.present?\n [verb, example_path]\n end.compact\n end",
"def route_for(request) #:nodoc:\n index, params = match(request)\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def route_for(request)\n index, params = if @around_match\n send(@around_match, request) { match(request) }\n else\n match(request)\n end\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def find_route_info(packet, path)\n parts = path.split('/')\n pad = parts.shift\n matched = home(packet, :subsite => true)\n extras = ''\n while (!parts.empty?)\n next_part = parts.shift\n matches = matched.children.first(:slug => next_part)\n if(matches) \n matched = matches\n else\n extras = parts.unshift(next_part).unshift(pad).join('/')\n parts = []\n end\n end\n [extras, matched]\n end",
"def route_for(**url_details)\n @routes.select { |rt| url_details <= rt.url_details }.first\n end",
"def match_for(path)\n @routes.select { |rt| rt.match?(path) }.first\n end",
"def find_route(routes, request)\n transport = request.websocket? ? 'WS' : 'HTTP'\n routes.match(request.request_method, transport, request.path)\n end",
"def params_from(path)\r\n ensure_that_routes_are_loaded\r\n ActionController::Routing::Routes.recognize_path(path)\r\nend",
"def get_route( request )\n return nil unless defined?( RAILS_ENV ) \n ::ActionController::Routing::Routes.recognize_path( request.path, {:method => request.request_method.downcase.to_sym } )\n end",
"def routes\n routes = {}\n self.class.each_route do |route|\n #routes[:name] = route.app.name # \"SomeSinatraApp\"\n info = {}\n routes[route.path.to_s.to_sym] = info # that's the path given as argument to get and akin\n info[:verb] = route.verb # get / head / post / put / delete\n info[:file] = route.file # \"some_sinatra_app.rb\" or something\n info[:line] = route.line # the line number of the get/post/... statement\n info[:pattern] = route.pattern # that's the pattern internally used by sinatra\n info[:keys] = route.keys # keys given when route was defined\n info[:conditions] = route.conditions # conditions given when route was defined\n info[:block] = route.block # the route's closure\n end\n routes\n end",
"def resources_for http_verb, path\n param_vals = []\n curr_node = @routes_tree[http_verb.to_s.downcase]\n return unless curr_node\n\n path.scan(%r{/([^/]+|$)}) do |(key)|\n next if key.empty?\n\n if curr_node[key]\n curr_node = curr_node[key]\n\n elsif curr_node[\"%s\"]\n param_vals << key\n curr_node = curr_node[\"%s\"]\n\n else\n return\n end\n end\n\n return unless curr_node.value\n rsc = curr_node.value.dup\n\n rsc[-1] = param_vals.empty? ?\n Hash.new :\n rsc[-1].inject({}){|h, name| h[name] = param_vals.shift; h}\n\n rsc\n end",
"def route\n @route ||= Role.available_routes.find {|r| r.conditions[:path_info].to_s == path_info && r.conditions[:request_method].to_s == request_method}\n end",
"def find_by(request_or_env)\n request = request_or_env.is_a?(Hash) ? Sinatra::Request.new(request_or_env) : request_or_env\n pattern = decode_pattern(request.path_info)\n verb = request.request_method\n rotation { |offset| match?(offset, pattern) }.select { |route| route.verb == verb }\n end",
"def get_requested_route(env)\n request = Rack::Request.new(env)\n \n http_method = request.request_method.downcase\n path = request.path_info\n\n [http_method, path]\n end",
"def find_route(request)\n @routes.find {|r| r.match?(request) }\n end",
"def path(name, *args)\n params = args.last.is_a?(Hash) ? args.pop : {}\n candidates = @routes.select { |route| route.name == name }\n fail InvalidRouteException if candidates.empty?\n i = 0\n route = candidates.sort_by! { |candidate|\n # Tries to find the route that matches more, but with fewer names, in stable order\n [(params.keys.map(&:to_s) - candidate.matcher.names).length, candidate.matcher.names.size, i += 1] }.shift\n matcher = route.matcher\n params_for_expand = params.dup\n if !args.empty? && matcher.mustermann?\n matcher.names.each_with_index do |matcher_name, index|\n params_for_expand[matcher_name.to_sym] ||= args[index]\n end\n end\n matcher.mustermann? ? matcher.expand(params_for_expand) : route.path_for_generation\n end",
"def recognized_route\n unless @recognized_route\n path = params[:resource_path] || params[:erp] || request.path\n environment = ::ActionController::Routing::Routes.extract_request_environment(request)\n environment.merge!(:method => params[:resource_method]) if params[:resource_method]\n @recognized_route ||= ::ActionController::Routing::Routes.routes_for_controller_and_action(controller_path, action_name).find do |route|\n route.recognize(path, environment)\n end or ResourcesController.raise_no_recognized_route(self)\n end\n @recognized_route\n end",
"def route(index_or_name)\n case index_or_name\n when Integer\n Rails.application.routes.routes[index_or_name]\n when Symbol # named route\n Rails.application.routes.named_routes.get index_or_name\n end\nend",
"def routes\n request :get, '/routes'\n end",
"def params_from(method, path)\n ensure_that_routes_are_loaded\n ActionController::Routing::Routes.recognize_path(path, :method => method)\n end",
"def match(path, method)\n path = StringUtils.normalize_path(path)\n\n @routes[method.to_sym].each{|r| \n case r[0]\n when Regexp\n if data = r[0].match(path)\n return r, data\n end\n when String\n if r[0] == path\n return r, nil\n end\n end\n }\n\n nil\n end",
"def all_routes\n matching_routes\n end",
"def map_dynamic_segments(route)\n segments = route.to_s.split('/')\n segments.map! do |segment|\n if segment =~ /:/\n '.*'\n else\n segment\n end\n end\n\n segments.join('/')\n end",
"def extract_route\n Xhive::Router::Route.find(request.path)\n end",
"def find(verb, url)\n http_verb = verb.to_s.upcase\n route = \"#{http_verb} #{url}\"\n @list[route]\n end",
"def params_for_path(path)\n routes.each do |route|\n # TODO: Finish nested routes\n if false && route[0].class == Proc\n # puts route[0].call(params).inspect\n\n return false\n elsif route[0] == path\n # Found the matching route\n return route[1]\n end\n end\n\n return {}\n end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def match base, target\n base = base.split('/').slice(1, 100)\n\n base.each_with_index do |el, i|\n if el[0,1] == ':'\n params[el.sub(':','').to_sym] = nav.path[i]\n else\n return unless el == nav.path[i]\n end\n end\n\n call target\n end",
"def match(request)\n path = String.normalize_path(request.path)\n method = request.method\n\n match, data = nil\n @sets.each { |set|\n match, data = set[1].match(path, method)\n break if match\n }\n\n fns = []\n if match\n fns = match[3]\n\n # handle route params\n #TODO where to do this?\n request.params.merge!(Hash.strhash(self.data_from_path(path, data, match[1])))\n\n #TODO where to do this?\n request.route_path = match[4]\n end\n\n fns\n end",
"def route(env)\n routes.each do |route|\n return route if route.match(env)\n end\n\n nil\n end",
"def route_for_path(path, method=nil)\n env = Rack::MockRequest.env_for(path || \"\", {:method => method})\n req = ActionDispatch::Request.new(env)\n route, matches, params = Rails.application.routes.set.recognize(req)\n return route\n end",
"def my_routes\n my_routes = []\n exceptions = %w(Login Signin)\n self.class.routes['GET'].each do |r|\n route = r.first.to_s.gsub(/\\W+|mix/,'').capitalize\n my_routes << route unless exceptions.include?(route)\n end\n return my_routes\n end",
"def routes(filter = nil)\n Rails.application.reload_routes!\n formatted = formatted_routes\n if filter\n formatted.select!{ |r| r.match(filter) }\n end\n puts formatted\n end",
"def routes\n raise NotImplementedError\n end",
"def find_route(indent, name, routes, depth_limit, footprints=[])\n buf = []\n unless footprints.include?(name)\n footprints << name\n # debugger if name == 'Delta'\n if routes[name].blank?\n buf << (' ' * (2 * indent)) + \"resources :#{name.snake_case.singularize.pluralize}\"\n else\n value_buf = []\n unless indent >= depth_limit\n routes[name].each do |subname|\n value_buf += find_route(indent + 1, subname, routes, depth_limit, footprints)\n end\n end\n if value_buf.empty?\n buf << (' ' * (2 * indent)) + \"resources :#{name.snake_case.singularize.pluralize}\"\n else\n buf << (' ' * (2 * indent)) + \"resources :#{name.snake_case.singularize.pluralize} do\"\n buf += value_buf\n buf << (' ' * (2 * indent)) + \"end\"\n end\n end\n footprints.delete(name)\n end\n buf\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/system',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/system/, \n :title => 'Sistema', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/admin/logger',\n :parent_path => '/admin/system',\n :regular_expression => /^\\/admin\\/logger/, \n :title => 'Trazas', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/logger-config',\n :regular_expression => /^\\/admin\\/logger-config/, \n :title => 'Logger configuration', \n :description => 'Configure the logger',\n :fit => 1,\n :module => :system }, \n {:path => '/business-events',\n :regular_expression => /^\\/admin\\/business-events/, \n :title => 'Business events',\n :description => 'Manage the business events.',\n :fit => 1,\n :module => :system }]\n \n end",
"def show_routes\n seen = []\n unless Merb::Router.named_routes.empty?\n puts \"==== Named routes\"\n Merb::Router.named_routes.each do |name,route|\n # something weird happens when you combine sprintf and irb\n puts \"Helper : #{name}\"\n meth = $1.upcase if route.conditions[:method].to_s =~ /(get|post|put|delete)/\n puts \"HTTP method: #{meth || 'GET'}\"\n puts \"Route : #{route}\"\n puts \"Params : #{route.params.inspect}\"\n puts\n seen << route\n end\n end\n puts \"==== Anonymous routes\"\n (Merb::Router.routes - seen).each do |route|\n meth = $1.upcase if route.conditions[:method].to_s =~ /(get|post|put|delete)/\n puts \"HTTP method: #{meth || 'GET'}\"\n puts \"Route : #{route}\"\n puts \"Params : #{route.params.inspect}\"\n puts\n end\n nil\n end",
"def path(name, data = nil)\n RouteLookup.new.path(name, data)\n end",
"def test_routes\n assert_routing(\n { :path => \"/api/capabilities\", :method => :get },\n { :controller => \"api\", :action => \"capabilities\" }\n )\n assert_recognizes(\n { :controller => \"api\", :action => \"capabilities\" },\n { :path => \"/api/0.6/capabilities\", :method => :get }\n )\n assert_routing(\n { :path => \"/api/0.6/permissions\", :method => :get },\n { :controller => \"api\", :action => \"permissions\" }\n )\n assert_routing(\n { :path => \"/api/0.6/map\", :method => :get },\n { :controller => \"api\", :action => \"map\" }\n )\n assert_routing(\n { :path => \"/api/0.6/trackpoints\", :method => :get },\n { :controller => \"api\", :action => \"trackpoints\" }\n )\n assert_routing(\n { :path => \"/api/0.6/changes\", :method => :get },\n { :controller => \"api\", :action => \"changes\" }\n )\n end",
"def recognize_path(path, options)\n recognized_paths = []\n recognized_paths << Rails.application.routes.recognize_path(path, options)\n rescue ActionController::RoutingError => exception\n # The main app didn't recognize the path, try the engines...\n Rails::Engine.subclasses.each do |engine|\n engine_instance = engine.instance\n engine_class = engine_instance.class\n begin\n recognized_path = engine_instance.routes.recognize_path(path, options)\n recognized_path[:engine] = engine_class\n recognized_paths << recognized_path\n rescue ActionController::RoutingError\n Tuttle::Engine.logger.info(\"Routing error recognizing path for #{path}\")\n end\n end\n\n recognized_paths.empty? ? [{ error: exception.message }] : recognized_paths\n end",
"def api \n api = { }\n \n param_regex = Regexp.new '\\(\\[\\^\\\\\\\\\\/\\?\\#\\]\\+\\)'\n Nagira.routes.keys.each do |method|\n api[method] ||= []\n Nagira.routes[method].each do |r|\n path = r[0].inspect[3..-3]\n r[1].each do |parm|\n path.sub!(param_regex,\":#{parm}\")\n end\n path.gsub!('\\\\','')\n api[method] << path unless path.empty? \n end\n end\n api\n end",
"def match(req)\n @routes.select{|rt| rt.matches?(req) }.first\n end",
"def optional_params(route)\n if Rails.version >= \"3.2.0\"\n return route.optional_parts.map(&:to_s)\n end\n path_info = route.conditions[:path_info]\n path_info_source = path_info.source\n if RUBY_VERSION >= '1.9.2'\n optional_named_captures_regexp = /\\?\\:.+?\\(\\?\\<(.+?)\\>/\n path_info_source.scan(optional_named_captures_regexp).flatten\n else\n re = Regexp.escape(\"([^/.?]+)\")\n optional_named_captures_regexp = /#{re}|\\(\\?\\:.+?\\)\\?/\n captures = path_info_source.scan(optional_named_captures_regexp).flatten\n named_captures = path_info.named_captures.to_a.sort_by {|cap|cap.last.first} \n captures.zip(named_captures).map do |type, (name, pos)|\n name unless type == '([^/.?]+)'\n end.compact\n end\n end",
"def print_routes \n \n # Create a new hash\n h = Hash.new()\n\n # Use Sinatra advanced routes\n # to build out a hash based on the routes\n Sinatra::Application.each_route do |route|\n unless route.path.eql? \"/\" or route.path.eql? \"/*\"\n h[route.path.split(\"/\")[1]] = request.base_url + route.path \n end\n end\n\n # Return that badboy\n return h\n\nend",
"def named_routes\n return [] unless app_obj.respond_to?(:routes)\n\n app_obj.routes.map { |route|\n request_method = route.request_methods.first\n next if !route.name || request_method == 'HEAD'\n route_name = route.name.to_s\n route_name =\n if route.controller\n route_name.split(\" \", 2).map{|name| \":#{name}\" }.join(\", \")\n else\n \":#{route_name}\"\n end\n name_array = \"(#{route_name})\"\n original_path = route.original_path.is_a?(Regexp) ? route.original_path.inspect : route.original_path\n full_path = File.join(uri_root, original_path)\n OpenStruct.new(:verb => request_method, :identifier => route.name, :name => name_array, :path => full_path)\n }.compact\n end",
"def recognize_with_filtering(request, &block)\n path, route, matches, params = request.env['PATH_INFO'], nil, nil, nil\n original_path = path.dup\n\n filters.run(:around_recognize, path, request.env) do\n route, matches, params = recognize_without_filtering(request)\n params || {}\n end\n\n request.env['PATH_INFO'] = original_path # hmm ...\n return nil unless route\n\n if block_given?\n return block.call(route, matches, params)\n else\n return route, matches, params\n end\n end",
"def match(req)\n request = req\n @routes.each do |route|\n return route if route.matches?(request)\n end\n end",
"def action_routes action\n request_methods, route = REQUEST_METHODS, action.to_s\n REQUEST_METHODS.each do |m|\n regex = /\\A#{m}_/i\n if route =~ regex\n request_methods = [m]\n route = route.sub regex, ''\n break\n end\n end\n\n route.size == 0 && raise('wrong action name \"%s\"' % action)\n\n path_rules.keys.sort.reverse.each do |key|\n route = route.gsub(key.is_a?(Regexp) ? key : /#{key}/, path_rules[key])\n end\n\n pages, dirs = [], []\n path = rootify_url(base_url, route)\n pages << {nil => [path, nil]}\n dirs << {nil => [rootify_url(base_url), path]} if route == APPETITE__INDEX_ACTION\n\n ((@action_aliases||{})[action]||[]).each do |url|\n pages << {nil => [rootify_url(base_url, url), nil]}\n end\n\n canonicals.each do |c|\n canonical_path = rootify_url(c, route)\n pages << {nil => [canonical_path, path]}\n dirs << {nil => [rootify_url(c), path]} if route == APPETITE__INDEX_ACTION\n end\n pages.each do |page|\n format?(action).each { |format| page[format] = page[nil].first + format }\n end\n [request_methods, pages + dirs].freeze\n end",
"def recognized_request_for(path, request_method = nil)\n path = \"/#{path}\" unless path.first == '/'\n\n # Assume given controller\n request = ActionController::TestRequest.new({}, {}, nil)\n request.env[\"REQUEST_METHOD\"] = request_method.to_s.upcase if request_method\n request.path = path\n\n ActionController::Routing::Routes.recognize(request)\n request\n end",
"def get_routes\n raise \"Method not implemented\"\n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def route(stock_url)\n url=stock_url.split(/\\/+/).join(\"/\")\n @routes.keys.each do |x|\n #@logger.msginfo(\"Main:route:Looking at '#{url}' (#{url[0,@routes[x]['path_length']]}) for '#{x}'\")\n if (x == url[0,@routes[x][\"path_length\"]])\n #@logger.msginfo(\"Main:route: #{@routes[x][\"handler\"].class.to_s} will do '#{url}'\")\n return @routes[x][\"handler\"]\n end\n end\n return nil #Bad, nothing matched\n end",
"def parse_route(path, options, verb)\n path = path.dup if path.kind_of?(String)\n route_options = {}\n\n if options[:params] == true\n options.delete(:params)\n elsif options.include?(:params)\n options[:params] ||= []\n options[:params] |= Array(options[:with]) if options[:with]\n end\n\n # We need check if path is a symbol, if that it's a named route.\n map = options.delete(:map)\n\n # path i.e :index or :show\n if path.kind_of?(Symbol)\n name = path\n path = map ? map.dup : (path == :index ? '/' : path.to_s)\n end\n\n # Build our controller\n controller = Array(@_controller).map(&:to_s)\n\n case path\n when String # path i.e \"/index\" or \"/show\"\n # Now we need to parse our 'with' params\n if with_params = options.delete(:with)\n path = process_path_for_with_params(path, with_params)\n end\n\n # Now we need to parse our provides\n options.delete(:provides) if options[:provides].nil?\n \n options.delete(:accepts) if options[:accepts].nil?\n\n if @_use_format || options[:provides]\n process_path_for_provides(path)\n # options[:add_match_with] ||= {}\n # options[:add_match_with][:format] = /[^\\.]+/\n end\n\n absolute_map = map && map[0] == ?/\n\n unless controller.empty?\n # Now we need to add our controller path only if not mapped directly\n if !map && !absolute_map\n controller_path = controller.join(\"/\")\n path.gsub!(%r{^\\(/\\)|/\\?}, \"\")\n path = File.join(controller_path, path) unless @_map\n end\n end\n\n # Now we need to parse our 'parent' params and parent scope.\n if !absolute_map and parent_params = options.delete(:parent) || @_parent\n parent_params = (Array(@_parent) + Array(parent_params)).uniq\n path = process_path_for_parent_params(path, parent_params)\n end\n\n # Add any controller level map to the front of the path.\n path = \"#{@_map}/#{path}\".squeeze('/') unless absolute_map || !@_map\n\n # Small reformats\n path.gsub!(%r{/\\?$}, '(/)') # Remove index path\n path.gsub!(%r{//$}, '/') # Remove index path\n path[0,0] = \"/\" if path !~ %r{^\\(?/} # Paths must start with a /\n path.sub!(%r{/(\\))?$}, '\\\\1') if path != \"/\" # Remove latest trailing delimiter\n path.gsub!(/\\/(\\(\\.|$)/, '\\\\1') # Remove trailing slashes\n path.squeeze!('/')\n when Regexp\n route_options[:path_for_generation] = options.delete(:generate_with) if options.key?(:generate_with)\n end\n\n name = options.delete(:route_name) if name.nil? && options.key?(:route_name)\n name = options.delete(:name) if name.nil? && options.key?(:name)\n if name\n controller_name = controller.join(\"_\")\n name = \"#{controller_name} #{name}\".to_sym unless controller_name.empty?\n end\n\n options[:default_values] = @_defaults unless options.has_key?(:default_values)\n\n [path, name, parent_params, options, route_options]\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/media',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/media/,\n :title => 'Medios',\n :description => 'Gestión de medios',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/config',\n :parent_path => '/admin/media',\n :regular_expression => /^\\/admin\\/media\\/config/,\n :title => 'Configuración',\n :description => 'Configuración medios',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/album',\n :parent_path => '/admin/media',\n :regular_expression => /^\\/admin\\/media\\/album/,\n :title => 'Albums',\n :description => 'The albums admin tools to create and modify media albums',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/photo/:album_name',\n :parent_path => '/admin/media/album',\n :regular_expression => /^\\/admin\\/media\\/photo\\/.+/,\n :title => 'Photos',\n :description => 'It manages the album\\'s photos. Used to upload and edit the album\\'s photos.',\n :fit => 1,\n :module => :media_gallery},\n {:path => '/gallery/:album_name',\n :regular_expression => /^\\/photo_gallery\\/.+/,\n :title => 'Photos',\n :description => 'It shows the album\\'s photos.',\n :fit => 1,\n :module => :media_gallery}]\n \n end",
"def match(req)\n routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n routes.find { |route| route.matches?(req) }\n end",
"def routes\n routes_method.call\n end",
"def get(route)\n pattern = route.gsub(/:(\\w+)/, '(?<\\1>[^\\\\/]+)')\n puts pattern # => /hello/(?<name>[^\\/]+)\n end",
"def routes_map; end",
"def route_for(name, *args); end",
"def _routes; end",
"def routes\n { :static => @route_ids, :dynamic => @dynamic }\n end",
"def recognize_path(path, options = {})\n Rails.application.routes.recognize_path(path, options)\n rescue ActionController::RoutingError\n Rails::Engine.subclasses.detect do |engine|\n engine_path = engine.routes._generate_prefix({}) if engine.routes.respond_to?(:_generate_prefix)\n engine_path ||= engine.routes.find_script_name({}) if engine.routes.respond_to?(:find_script_name)\n next unless engine_path\n\n path_for_engine = path.gsub(%r(^#{engine_path}), '')\n recognized_path = engine.routes.recognize_path(path_for_engine, options) rescue nil\n break recognized_path if recognized_path\n end\n end",
"def match(path, *rest, &block); end",
"def route(path = request.path_info)\n path = path.gsub(%r{//+}, '/').gsub(%r{^/|/$}, '')\n return route_index if path.empty? || path == docs_prefix\n case path\n when %r{^(#{docs_prefix}|#{list_prefix}|#{search_prefix}|#{static_prefix})(/.*|$)}\n prefix = $1\n paths = $2.gsub(%r{^/|/$}, '').split('/')\n library, paths = *parse_library_from_path(paths)\n return unless library\n return case prefix\n when docs_prefix; route_docs(library, paths)\n when list_prefix; route_list(library, paths)\n when search_prefix; route_search(library, paths)\n when static_prefix; route_static(library, paths)\n end\n end\n nil\n end",
"def routes\n [@name.downcase]\n end",
"def common_routes\n [\n [ search_path, 'Search Talks', 'talks' ],\n [ helps_path, 'Help' , 'helps' ], # TBD: replace with help search\n [ credits_path, 'Credits' , 'credits' ],\n [ static_pages_about_path, 'About' , 'static_pages' ],\n [ static_pages_contact_path, 'Contact' , 'static_pages' ],\n [ static_pages_privacy_path, 'Privacy' , 'static_pages' ],\n [ static_pages_sitemap_path, 'Site Map', 'static_pages' ]\n ]\n end",
"def match(req)\n @routes.find { |route| route.matches?(req)}\n end",
"def path_info\n @headers[\"PATH_INFO\"]\n end",
"def find_my_routes(*args)\n bounds = args[0][:bounds].nil? ? default_coordinates : args[0][:bounds].dup\n routes = case args[0][:filter]\n when \"recommended\"\n Route.where(:\"overview_points.latlng\".within(:box) => bounds).where(visibility: 'recommended')\n when \"liked\"\n # TODO need to build this\n else # 'my' or blank\n Route.where(:\"overview_points.latlng\".within(:box) => bounds).where(owner_id: id)\n end\n end",
"def match(req)\n @routes.find { |route| route.matches?(req) }\n end",
"def lookup_path_direct(namespace, path, type); end",
"def url_for_params(params)\n routes.each do |route|\n if params_match_options?(params, route[1])\n return path_and_params(params, route[0], route[1])\n end\n end\n\n return '/', params\n end",
"def match(req)\n # @routes.each do |route|\n # return route if route.matches?(req)\n # end\n #\n # nil\n @routes.find { |route| route.matches?(req) }\n end",
"def find(name) \n print(\"finding route for #{name}\\n\")\n res={}\n resList=[]\n @route.each_pair do |p,d|\n match=if p.class==String\n name==p\n elsif p.class==Regexp\n name=~p\n else\n print \"Routes::find: got #{p.class}\\n\"\n false\n end\n if match\n prio=d.options[:prio]\n if res.include?(d.dest)\n if res[d.dest][:prio]>prio\n res[d.dest]=d.options\n end\n else\n res[d.dest]=d.options\n end\n end\n end\n resList=res.to_a.map {|r| RouteEntry.new(r[0], r[1])} # as array of RouteEntry\n resList.sort! {|a,b| a.options[:prio] <=> b.options[:prio]} # sort by prio\n end",
"def get_controller_info\n controller_info = {}\n routes = Dir.chdir(::Rails.root.to_s) { `rake routes` }\n routes.split(\"\\n\").each do |entry|\n begin\n method, url, controller_action = entry.split.slice(-3, 3)\n if METHODS.include? method.upcase\n controller, action = controller_action.split('#')\n controller_info[controller] ||= []\n controller_info[controller] << [action, method, url]\n end\n rescue\n end\n end\n controller_info\n end",
"def get_routes\n @agency = params[:name]\n request_url = \"http://services.my511.org/Transit2.0/GetRoutesForAgency.aspx?token=#{@@token}&agencyName=#{@agency}\"\n request_url = request_url.gsub(/ /,\"%20\")\n @routes = search_for_key(parse_request(request_url), \"Route\")\n @routes = [@routes] unless @routes.kind_of?(Array)\n respond_to do |format|\n format.js {}\n end\n end",
"def named_routes; end",
"def routes(context={})\n \n routes = [{:path => '/admin/worker-jobs',\n :regular_expression => /^\\/admin\\/worker-jobs/, \n :title => 'Delayed jobs', \n :description => 'Query delayed jobs',\n :fit => 1,\n :module => :system }]\n \n end",
"def routes\n ['Agriculture, environmental and animal care', 'Business administration', 'Catering and hospitality' \\\n 'Construction',\n 'Creative and design', 'Digital', 'Engineering and manufacturing', 'Hair and beauty', 'Health and science',\n 'Legal, finance and accounting', 'Protective services', 'Sales, marketing and procurement', 'Transport']\n end",
"def match(path)\n if match = @regexp.match(path)\n params = {}\n @named.each_with_index { |name, i| params[name] = match[i + 1] } if @type == :handlers\n {\n path: path,\n title: self.flags.fetch(:title){nil},\n params: params,\n route: self\n }\n else\n false\n end\n end",
"def find_path\n\n end",
"def around_recognition(route, path, env, &block)\r\n unless path =~ %r(^/admin) # TODO ... should be defined through the dsl in routes.rb\r\n if match = path.match(@@pattern)\r\n section = Site.find_by_host(env[:host_with_port]).sections.root\r\n path.sub! /^#{match[0]}/, \"#{match[1]}/#{section.type.pluralize.downcase}/#{section.id}#{match[2]}\"\r\n end\r\n end\r\n yield path, env\r\n end",
"def handle_routes\n instance_exec(@_roda_app.request, &self.class.router_block)\n end",
"def read_request_path(my_lines)\n if /^[A-Z]+\\s+\\/(\\S++)/ =~ my_lines[0] # We check the first line of the request to see\n request_path = $1 # if it matches the \"METHOD /path HTTP/1.1\" format\n#else \n # request_path = \"index.html\"\n end\nend",
"def anchored_routes; end",
"def _roda_before_30__static_routing\n r = @_request\n r.hash_paths(r.request_method)\n r.hash_paths(:static_routing)\n end"
] | [
"0.7454343",
"0.72434527",
"0.6600313",
"0.65620273",
"0.65375525",
"0.65008414",
"0.6498602",
"0.6491022",
"0.6232778",
"0.6200488",
"0.61655927",
"0.6153882",
"0.6104795",
"0.60673475",
"0.60335666",
"0.5991156",
"0.5972602",
"0.5970464",
"0.5961672",
"0.5954706",
"0.5937204",
"0.59265894",
"0.5921956",
"0.5917026",
"0.5912865",
"0.5887124",
"0.5868757",
"0.58264625",
"0.5809384",
"0.5803752",
"0.5803752",
"0.5803752",
"0.5803752",
"0.5803752",
"0.5803752",
"0.5803752",
"0.5803752",
"0.5803752",
"0.5803752",
"0.5803752",
"0.57901657",
"0.577891",
"0.57647336",
"0.5763682",
"0.57589656",
"0.5745747",
"0.57355624",
"0.5730459",
"0.5728436",
"0.5724836",
"0.5721113",
"0.571986",
"0.57142526",
"0.5686781",
"0.56852955",
"0.56769025",
"0.56712645",
"0.56497735",
"0.56354666",
"0.5628823",
"0.5616456",
"0.56125844",
"0.5595845",
"0.55920666",
"0.55920666",
"0.5580154",
"0.55691683",
"0.5568837",
"0.5557664",
"0.5557664",
"0.5556133",
"0.55551225",
"0.5550278",
"0.55477786",
"0.55453557",
"0.55338144",
"0.550383",
"0.5490137",
"0.54884785",
"0.5484276",
"0.54755545",
"0.5471491",
"0.54657245",
"0.5455907",
"0.544815",
"0.54470503",
"0.54422796",
"0.54370433",
"0.5427016",
"0.5415417",
"0.541458",
"0.54133314",
"0.5401857",
"0.5396747",
"0.5391984",
"0.53869534",
"0.5383187",
"0.53774023",
"0.53711694",
"0.5371112",
"0.5369566"
] | 0.0 | -1 |
Returns a instance of PathRouter::Route if path is matched with current regexp | def match?(offset, path)
@routes[offset..-1].find do |route|
route.regexp === path || (path.end_with?("/") && route.regexp === path[0..-2])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_for(path)\n @routes.select { |rt| rt.match?(path) }.first\n end",
"def match(path, method)\n path = StringUtils.normalize_path(path)\n\n @routes[method.to_sym].each{|r| \n case r[0]\n when Regexp\n if data = r[0].match(path)\n return r, data\n end\n when String\n if r[0] == path\n return r, nil\n end\n end\n }\n\n nil\n end",
"def match(req)\n @routes.select{|rt| rt.matches?(req) }.first\n end",
"def match(req)\n @routes.each do |route|\n if route.matches?(req)\n return route\n end\n end\n\n nil\n end",
"def match(req)\n request = req\n @routes.each do |route|\n return route if route.matches?(request)\n end\n end",
"def match(path)\n if match = @regexp.match(path)\n params = {}\n @named.each_with_index { |name, i| params[name] = match[i + 1] } if @type == :handlers\n {\n path: path,\n title: self.flags.fetch(:title){nil},\n params: params,\n route: self\n }\n else\n false\n end\n end",
"def match(path, *rest, &block)\n if rest.empty? && Hash === path\n options = path\n path, to = options.find { |name, _value| name.is_a?(String) }\n\n raise ArgumentError, \"Route path not specified\" if path.nil?\n\n case to\n when Symbol\n options[:action] = to\n when String\n if to.include?(\"#\")\n options[:to] = to\n else\n options[:controller] = to\n end\n else\n options[:to] = to\n end\n\n options.delete(path)\n paths = [path]\n else\n options = rest.pop || {}\n paths = [path] + rest\n end\n\n if options.key?(:defaults)\n defaults(options.delete(:defaults)) { map_match(paths, options, &block) }\n else\n map_match(paths, options, &block)\n end\n end",
"def match(req)\n @routes.each do |route|\n if route.matches?(req)\n return route\n end\n end\n return nil\n end",
"def match(req)\n # @routes.each do |route|\n # return route if route.matches?(req)\n # end\n #\n # nil\n @routes.find { |route| route.matches?(req) }\n end",
"def route_for_path(path, method=nil)\n env = Rack::MockRequest.env_for(path || \"\", {:method => method})\n req = ActionDispatch::Request.new(env)\n route, matches, params = Rails.application.routes.set.recognize(req)\n return route\n end",
"def match(req)\n @routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n @routes.find { |route| route.matches?(req)}\n end",
"def match(req)\n routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n routes.find { |route| route.matches?(req) }\n end",
"def route?(path)\n path = Path.new(path)\n endpoint = endpoints[path]\n route = nil\n\n unless endpoint\n route = route_for(path)\n endpoint = endpoints[route]\n end\n\n endpoint\n end",
"def path_regex\n Regexp.new path_pattern, 'i'\n end",
"def route(env)\n routes.each do |route|\n return route if route.match(env)\n end\n\n nil\n end",
"def route\n @route ||= Role.available_routes.find {|r| r.conditions[:path_info].to_s == path_info && r.conditions[:request_method].to_s == request_method}\n end",
"def match(req)\n @routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n @routes.find { |route| route.matches?(req) }\n end",
"def matches_path?(pattern, path); end",
"def match(*options)\n @matches << Route.new(options)\n end",
"def path_match(request_path)\n request_path.start_with?(path)\n end",
"def build_path_matcher(path, options)\n sections = path.split(/(\\{[^\\}]+\\})/)\n sections = sections.reject {|v| v == '' }\n\n sections.each do |section|\n if section[0] == '{' && section[-1] == '}'\n options[section[1..-2]] = nil\n end\n end\n\n add_path_matcher(sections) if Volt.server?\n\n # Create a path that takes in the params and returns the main\n # part of the url with the params filled in.\n path = Proc.new do |params|\n sections.map do |section|\n if section[0] == '{' && section[-1] == '}'\n params[section[1..-2]]\n else\n section\n end\n end.join('')\n end\n\n return path\n end",
"def recognize_path(path_info)\n prepare! unless prepared?\n route = @engine.find_by_pattern(path_info).first\n [route.name, route.params_for(path_info, {})]\n end",
"def route_for(request)\n index, params = if @around_match\n send(@around_match, request) { match(request) }\n else\n match(request)\n end\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def match_path(*expected)\n MatchPath.new(*expected)\nend",
"def match(matcher, handler)\n routes << Route.new(matcher, handler)\n end",
"def matches?(path)\n return false if path.nil?\n\n send match_method, Pathname.new(path)\n end",
"def match?( path )\n path_matcher =~ path\n end",
"def match(req)\n @routes.detect { |route| route.matches?(req) }\n end",
"def match(path, *rest, &block); end",
"def find_match(env)\n path = env['REQ_PATH']\n @serve.each do |pattern, block|\n case pattern\n when FalseClass\n when TrueClass\n return Match.new(self, path, block)\n when String\n if pattern=='*'\n return Match.new(self, path, block)\n elsif /^\\*?\\.[a-z]+$/ =~ pattern\n return Match.new(self, path, block) if File.extname(realpath(path))==pattern\n else\n return Match.new(self, path, block) if File.basename(realpath(path))==pattern\n end\n when Regexp\n if matchdata = pattern.match(path)\n return Match.new(self, path, block, *matchdata.to_a)\n end\n when Waw::Validation::Validator\n if pattern.validate(matching_file(path))\n return Match.new(self, path, block) \n end\n when StaticController::AbstractMatcher\n if pattern.matches?(env)\n return Match.new(self, path, block)\n end\n else\n raise WawError, \"Unrecognized wawaccess pattern #{pattern}\"\n end\n end\n nil\n end",
"def match_with(pattern)\n offset = 0\n conditions = [pattern]\n conditions << pattern[0..-2] if pattern != \"/\" && pattern.end_with?(\"/\")\n loop.with_object([]) do |_, candidacies|\n return candidacies unless conditions.any?{ |x| @regexps[offset] === x }\n route = @routes[offset..-1].detect{ |route| Regexp.last_match[\"_#{route.index}\"] }\n candidacies << route\n offset = route.index + 1\n end\n end",
"def route4\n name = params[:name]\n regex = Regexp.new(\"@\" + name) if name == \"foo\"\n end",
"def get_route(path, options = nil)\n conditions = options && options.delete(:conditions) || nil\n requirements = options && options.delete(:requirements) || nil\n default_values = options && options.delete(:default_values) || nil\n generate_with = options && options.delete(:generate_with) || nil\n priority = options && options.delete(:priority) || nil\n if options\n options.delete_if do |k, v|\n if v.is_a?(Regexp) || v.is_a?(Proc)\n (requirements ||= {})[k] = v\n true\n end\n end\n end\n\n if conditions && !conditions.empty?\n conditions.keys.all?{|k| request_methods.include?(k)} or raise(\"You are trying to use request methods that don't exist in the request_methods supplied #{conditions.keys.join(', ')} -> #{(conditions.keys - request_methods).join(\", \")}\")\n end\n\n if priority\n enable_priority_lookups!\n end\n\n route = parser.generate_route(path, conditions, requirements, default_values, generate_with, priority)\n raise(MultipleParameterException.new) if !allow_identical_variable_names? and route.paths.first.dynamic? and route.paths.first.dynamic_keys.uniq.size != route.paths.first.dynamic_keys.size\n route.to(options) if options && !options.empty?\n route\n end",
"def processed_route\n return @original_route unless any_wildcard?\n as_regex\n end",
"def matches?(req)\n\n @method == req.request_method.downcase.to_sym && @pattern.match(req.path)\n end",
"def route(path = request.path_info)\n path = path.gsub(%r{//+}, '/').gsub(%r{^/|/$}, '')\n return route_index if path.empty? || path == docs_prefix\n case path\n when %r{^(#{docs_prefix}|#{list_prefix}|#{search_prefix}|#{static_prefix})(/.*|$)}\n prefix = $1\n paths = $2.gsub(%r{^/|/$}, '').split('/')\n library, paths = *parse_library_from_path(paths)\n return unless library\n return case prefix\n when docs_prefix; route_docs(library, paths)\n when list_prefix; route_list(library, paths)\n when search_prefix; route_search(library, paths)\n when static_prefix; route_static(library, paths)\n end\n end\n nil\n end",
"def match?(path)\n path =~ to_regexp\n end",
"def match?(path)\n @regex.match?(path)\n end",
"def path_matches?(path)\n case path\n when String\n # Convert string to regex.\n pattern = path.gsub(/\\*(\\*)?/) do |match|\n if match[1]\n '.*'\n else\n '[^\\/]*'\n end\n end\n\n if Regexp.new(\"^#{pattern}$\").match request.path\n true\n else\n false\n end\n when Regexp\n if path.match request.path\n true\n else\n false\n end\n end\n end",
"def match(path, *rest)\n\n if rest.empty? && Hash === path\n options = path\n path, to = options.find { |name, _value| name.is_a?(String) }\n options[:to] = to\n options.delete(path)\n paths = [path]\n else\n options = rest.pop || {}\n paths = [path] + rest\n end\n\n options[:anchor] = true unless options.key?(:anchor)\n\n if options[:on] && !VALID_ON_OPTIONS.include?(options[:on])\n raise ArgumentError, \"Unknown scope #{on.inspect} given to :on\"\n end\n\n if @scope[:controller] && @scope[:action]\n options[:to] ||= \"#{@scope[:controller]}##{@scope[:action]}\"\n end\n\n paths.each do |_path|\n menu_options = options.dup\n menu_options[:path] ||= _path if _path.is_a?(String)\n\n path_without_format = _path.to_s.sub(/\\(\\.:format\\)$/, '')\n if using_match_shorthand?(path_without_format, menu_options)\n menu_options[:to] ||= path_without_format.gsub(%r{^/}, \"\").sub(%r{/([^/]*)$}, '#\\1')\n end\n\n decomposed_match(_path, menu_options)\n end\n self\n end",
"def route7\n name = params[:name]\n regex = Regexp.new(Regexp.quote(name))\n end",
"def recognize_path(path, options = {})\n Rails.application.routes.recognize_path(path, options)\n rescue ActionController::RoutingError\n Rails::Engine.subclasses.detect do |engine|\n engine_path = engine.routes._generate_prefix({}) if engine.routes.respond_to?(:_generate_prefix)\n engine_path ||= engine.routes.find_script_name({}) if engine.routes.respond_to?(:find_script_name)\n next unless engine_path\n\n path_for_engine = path.gsub(%r(^#{engine_path}), '')\n recognized_path = engine.routes.recognize_path(path_for_engine, options) rescue nil\n break recognized_path if recognized_path\n end\n end",
"def get_route( request )\n return nil unless defined?( RAILS_ENV ) \n ::ActionController::Routing::Routes.recognize_path( request.path, {:method => request.request_method.downcase.to_sym } )\n end",
"def recognized_route\n unless @recognized_route\n path = params[:resource_path] || params[:erp] || request.path\n environment = ::ActionController::Routing::Routes.extract_request_environment(request)\n environment.merge!(:method => params[:resource_method]) if params[:resource_method]\n @recognized_route ||= ::ActionController::Routing::Routes.routes_for_controller_and_action(controller_path, action_name).find do |route|\n route.recognize(path, environment)\n end or ResourcesController.raise_no_recognized_route(self)\n end\n @recognized_route\n end",
"def router\n @router ||= PathRouter.new\n block_given? ? yield(@router) : @router\n end",
"def matcher_for_path(path)\n\n path = path.to_s\n\n if path.include?('*')\n quoted_path = path.gsub('.', '\\.')\n quoted_path = quoted_path.gsub('*', '.+?')\n Regexp.new(\"^#{quoted_path}$\")\n else\n path\n end\n\n end",
"def path(name, *args)\n params = args.last.is_a?(Hash) ? args.pop : {}\n candidates = @routes.select { |route| route.name == name }\n fail InvalidRouteException if candidates.empty?\n i = 0\n route = candidates.sort_by! { |candidate|\n # Tries to find the route that matches more, but with fewer names, in stable order\n [(params.keys.map(&:to_s) - candidate.matcher.names).length, candidate.matcher.names.size, i += 1] }.shift\n matcher = route.matcher\n params_for_expand = params.dup\n if !args.empty? && matcher.mustermann?\n matcher.names.each_with_index do |matcher_name, index|\n params_for_expand[matcher_name.to_sym] ||= args[index]\n end\n end\n matcher.mustermann? ? matcher.expand(params_for_expand) : route.path_for_generation\n end",
"def extract_route\n Xhive::Router::Route.find(request.path)\n end",
"def match?(path)\n has_real_path? path\n end",
"def match(path = '', conditions = {}, &block)\n if path.is_a? Hash\n conditions = path\n else\n conditions[:path] = path\n end\n match_without_path(conditions, &block)\n end",
"def have_current_path(path, **options, &optional_filter_block)\n Matchers::HaveCurrentPath.new(path, **options, &optional_filter_block)\n end",
"def resolve_path(path, *args)\n # logger.debug \"resolve_path: #{path}, args = #{args}\"\n m = /^(([^_]+)_)?((\\w+?)?)$/.match(path)\n if m\n action_with_underscore = m[1]\n action = m[2]\n resource = m[3]\n\n # logger.debug \"resolve_path: matched pattern: #{m}, action = #{action.inspect}, resource = #{resource}\"\n\n return self.class.routes.match_path(resource, action, *args)\n else\n raise \"unable to match path: #{path}_path\"\n end\n end",
"def matches?(req)\n match_method = req.request_method.downcase.to_sym == @http_method\n # match_pattern = req.path.match(Regexp.new(@pattern))\n match_pattern = req.path =~ @pattern\n match_method && match_pattern\n end",
"def recognized_request_for(path, request_method = nil)\n path = \"/#{path}\" unless path.first == '/'\n\n # Assume given controller\n request = ActionController::TestRequest.new({}, {}, nil)\n request.env[\"REQUEST_METHOD\"] = request_method.to_s.upcase if request_method\n request.path = path\n\n ActionController::Routing::Routes.recognize(request)\n request\n end",
"def route6\n name = params[:name]\n regex = Regexp.new(Regexp.escape(name))\n end",
"def route?(path)\n path = Path.new(path)\n interface = interfaces[path]\n route = nil\n\n unless interface\n route = route_for(path)\n interface = interfaces[route]\n end\n\n interface\n end",
"def route_to(path)\n path = \"http://#{BACKEND_SUBDOMAIN}.example.com#{normalize_path(path)}\";\n router.recognize_path(path)\n end",
"def find_route(request)\n @routes.find {|r| r.match?(request) }\n end",
"def matches?(req)\n req.path =~ pattern && http_method == req.request_method.downcase.to_sym\n end",
"def route_for(**url_details)\n @routes.select { |rt| url_details <= rt.url_details }.first\n end",
"def recognize_path(path_info)\n route, params = recognize(Rack::MockRequest.env_for(path_info)).first\n [route.name, params]\n end",
"def matches?(req)\n regex = Regexp.new(@pattern.to_s)\n match_data = regex.match(req.path)\n if match_data.nil?\n return false\n else\n req.request_method.downcase.to_sym == @http_method\n end\n end",
"def match base, target\n base = base.split('/').slice(1, 100)\n\n base.each_with_index do |el, i|\n if el[0,1] == ':'\n params[el.sub(':','').to_sym] = nav.path[i]\n else\n return unless el == nav.path[i]\n end\n end\n\n call target\n end",
"def match(path, search)\n matches = get_matches(path)\n\n if matches.length > 0\n match = matches.sort { |m| m[1] }.first\n\n @params = match[2]\n add_search_to_params(search)\n\n match[0]\n else\n nil\n end\n end",
"def match_rule?(options)\n rules = [options].flatten\n rules.any? do |pattern|\n if pattern.is_a?(Regexp)\n @req.path =~ pattern\n else\n @req.path[0, pattern.length] == pattern\n end\n end\n end",
"def check candidate_path\n # Convert dynamic segments into regexp captures\n matchable_path = candidate_path.gsub(/:\\w+/, '([^/]+)')\n\n # Don't match a partial segment. For example,\n # don't match /widget for /widgets.\n path.match(Regexp.new(\"^/?#{matchable_path}(?:/|$)\"))\n end",
"def find_route(url)\n @routes.each do |route|\n if route.match(url)\n return route\n end\n end\n nil\n end",
"def find_by(request_or_env)\n request = request_or_env.is_a?(Hash) ? Sinatra::Request.new(request_or_env) : request_or_env\n pattern = decode_pattern(request.path_info)\n verb = request.request_method\n rotation { |offset| match?(offset, pattern) }.select { |route| route.verb == verb }\n end",
"def match(str)\n @captures[:captures] = [str]\n @captures if @routes.any? { |r| str.starts_with? r }\n end",
"def route_to(path, args = {}, protocol = \"http://\")\n request = Request.new({:protocol => protocol, :path => path}.merge(args))\n # Merb::Router.match(request)\n Merb::Router.route_for(request)\n end",
"def matches_path? path\n if path_string_or_regexp.is_a?(Regexp)\n !(path_string_or_regexp =~ path).nil?\n else\n path_string_or_regexp == path\n end\n end",
"def find_route(routes, request)\n transport = request.websocket? ? 'WS' : 'HTTP'\n routes.match(request.request_method, transport, request.path)\n end",
"def matches?(req)\n pattern.match(req.path) && req.request_method.downcase == http_method.to_s\n end",
"def matches?(req)\n @pattern.match?(req.path) && @http_method.to_s.downcase == req.request_method.downcase\n end",
"def matches?(req)\n @pattern.to_s.match(req.path) && @http_method.to_s.match(req.request_method.downcase)\n end",
"def path_match(matcher, path)\n case\n when matcher.is_a?(String)\n if matcher.include? '*'\n File.fnmatch(matcher, path)\n else\n path == matcher\n end\n when matcher.respond_to?(:match)\n !matcher.match(path).nil?\n when matcher.respond_to?(:call)\n matcher.call(path)\n else\n File.fnmatch(matcher.to_s, path)\n end\n end",
"def path=( value )\n self.path_matcher = self.class.compile_matcher value\n super( value )\n end",
"def parse_route(path, options, verb)\n path = path.dup if path.kind_of?(String)\n route_options = {}\n\n if options[:params] == true\n options.delete(:params)\n elsif options.include?(:params)\n options[:params] ||= []\n options[:params] |= Array(options[:with]) if options[:with]\n end\n\n # We need check if path is a symbol, if that it's a named route.\n map = options.delete(:map)\n\n # path i.e :index or :show\n if path.kind_of?(Symbol)\n name = path\n path = map ? map.dup : (path == :index ? '/' : path.to_s)\n end\n\n # Build our controller\n controller = Array(@_controller).map(&:to_s)\n\n case path\n when String # path i.e \"/index\" or \"/show\"\n # Now we need to parse our 'with' params\n if with_params = options.delete(:with)\n path = process_path_for_with_params(path, with_params)\n end\n\n # Now we need to parse our provides\n options.delete(:provides) if options[:provides].nil?\n \n options.delete(:accepts) if options[:accepts].nil?\n\n if @_use_format || options[:provides]\n process_path_for_provides(path)\n # options[:add_match_with] ||= {}\n # options[:add_match_with][:format] = /[^\\.]+/\n end\n\n absolute_map = map && map[0] == ?/\n\n unless controller.empty?\n # Now we need to add our controller path only if not mapped directly\n if !map && !absolute_map\n controller_path = controller.join(\"/\")\n path.gsub!(%r{^\\(/\\)|/\\?}, \"\")\n path = File.join(controller_path, path) unless @_map\n end\n end\n\n # Now we need to parse our 'parent' params and parent scope.\n if !absolute_map and parent_params = options.delete(:parent) || @_parent\n parent_params = (Array(@_parent) + Array(parent_params)).uniq\n path = process_path_for_parent_params(path, parent_params)\n end\n\n # Add any controller level map to the front of the path.\n path = \"#{@_map}/#{path}\".squeeze('/') unless absolute_map || !@_map\n\n # Small reformats\n path.gsub!(%r{/\\?$}, '(/)') # Remove index path\n path.gsub!(%r{//$}, '/') # Remove index path\n path[0,0] = \"/\" if path !~ %r{^\\(?/} # Paths must start with a /\n path.sub!(%r{/(\\))?$}, '\\\\1') if path != \"/\" # Remove latest trailing delimiter\n path.gsub!(/\\/(\\(\\.|$)/, '\\\\1') # Remove trailing slashes\n path.squeeze!('/')\n when Regexp\n route_options[:path_for_generation] = options.delete(:generate_with) if options.key?(:generate_with)\n end\n\n name = options.delete(:route_name) if name.nil? && options.key?(:route_name)\n name = options.delete(:name) if name.nil? && options.key?(:name)\n if name\n controller_name = controller.join(\"_\")\n name = \"#{controller_name} #{name}\".to_sym unless controller_name.empty?\n end\n\n options[:default_values] = @_defaults unless options.has_key?(:default_values)\n\n [path, name, parent_params, options, route_options]\n end",
"def route_for(request) #:nodoc:\n index, params = match(request)\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def find_by_path(request_path)\n routes = Disraptor::RouteStore.get_routes()\n\n return routes.values.detect do |route|\n route['sourcePath'] == request_path\n end\n end",
"def route_to(klass_or_name, action)\n RouteToMatcher.new(klass_or_name, action)\n end",
"def with_url_path\n @url_match = UrlMatchBuilder.new(self, true)\n end",
"def add_route(string_or_regex, opts = {})\n raise \"You have to provide an :action method to call\" unless opts[:action]\n method = (opts.delete(:method) || 'GET').to_s.upcase\n # If a string, convert it to a rack-mount compatable regex, eg\n # /some/:var/in/path => /some/(?<var>.*)/in/path\n if string_or_regex.is_a?(String)\n regex_string = \"^\" + string_or_regex.gsub(/:(([^\\/]+))/){|s| \"(?<#{$1}>.*)\" } + \"$\"\n regex = %r{#{regex_string}}\n #puts regex_string # dbg\n else\n regex = string_or_regex\n end\n\n # Add the route to rack-mount\n @set.add_route(self,\n {:path_info => regex, :request_method => method.upcase},\n opts)\n end",
"def route(stock_url)\n url=stock_url.split(/\\/+/).join(\"/\")\n @routes.keys.each do |x|\n #@logger.msginfo(\"Main:route:Looking at '#{url}' (#{url[0,@routes[x]['path_length']]}) for '#{x}'\")\n if (x == url[0,@routes[x][\"path_length\"]])\n #@logger.msginfo(\"Main:route: #{@routes[x][\"handler\"].class.to_s} will do '#{url}'\")\n return @routes[x][\"handler\"]\n end\n end\n return nil #Bad, nothing matched\n end",
"def params_from(path)\r\n ensure_that_routes_are_loaded\r\n ActionController::Routing::Routes.recognize_path(path)\r\nend",
"def around_recognition(route, path, env, &block)\r\n unless path =~ %r(^/admin) # TODO ... should be defined through the dsl in routes.rb\r\n if match = path.match(@@pattern)\r\n section = Site.find_by_host(env[:host_with_port]).sections.root\r\n path.sub! /^#{match[0]}/, \"#{match[1]}/#{section.type.pluralize.downcase}/#{section.id}#{match[2]}\"\r\n end\r\n end\r\n yield path, env\r\n end",
"def route *args\n mounted? || raise(\"`route' works only on mounted controllers. Please consider to use `base_url' instead.\")\n return base_url if args.size == 0\n (route = self[args.first]) && args.shift\n build_path(route || base_url, *args)\n end",
"def matches?(req)\n req.path =~ pattern && req.request_method.to_s.upcase == http_method\n end",
"def route_path(path)\n AutoRouter::Router.map_controller(self, path: path)\n end",
"def route(pattern, options={})\n options[:builder] ||= GentleREST::RouteBuilder\n builder_class = options[:builder]\n begin\n builder = builder_class.new(pattern, options)\n rescue ArgumentError\n raise ArgumentError,\n \"A RouteBuilder class must take a pattern and an \" +\n \"options Hash as parameters in its initialize method.\" \n end\n if builder.respond_to?(:generate)\n new_routes = builder.generate\n new_routes.each do |route|\n if !route.kind_of?(GentleREST::Route)\n raise TypeError,\n \"Expected GentleREST::Route, got #{route.class.name}.\"\n end\n self.routes << route\n end\n new_routes\n else\n raise TypeError,\n \"An instantiated builder class must respond to the \" +\n \":generate message.\"\n end\n end",
"def route?(*subdir_patterns)\n regexp = generate_regex(subdir_patterns)\n Munge::Util::BooleanRegex.match?(regexp, @route)\n end",
"def matches?(req)\n !(req.path =~ @pattern).nil? && \n req.request_method.downcase.to_sym == @http_method\n end",
"def alter_regex_for_custom_routes(node); end",
"def applies_to?(request)\n return false unless pattern\n request.path =~ Mustermann.new(pattern)\n end",
"def matches?(req)\n !(@pattern =~ req.path).nil? && req.request_method.downcase == @http_method.to_s.downcase\n end",
"def path\n @path ||= if Symbol === _path\n find_route_for(_path, *options)\n elsif _path\n _path\n else\n '#'\n end\n end",
"def path_string\n pattern\n end"
] | [
"0.7349533",
"0.67221475",
"0.667222",
"0.6633995",
"0.66129345",
"0.66046774",
"0.6552336",
"0.6493807",
"0.6399288",
"0.63146263",
"0.62720984",
"0.62518644",
"0.6239918",
"0.6239918",
"0.6216776",
"0.6210377",
"0.62056637",
"0.6177853",
"0.61745334",
"0.61745334",
"0.6173611",
"0.61693555",
"0.6146056",
"0.6136601",
"0.613592",
"0.6135277",
"0.6134257",
"0.61252636",
"0.6120959",
"0.6099395",
"0.6064464",
"0.60616845",
"0.606051",
"0.60524434",
"0.6045837",
"0.6019674",
"0.59998643",
"0.5973776",
"0.59632593",
"0.5911459",
"0.5908293",
"0.589812",
"0.58691776",
"0.5850626",
"0.5833796",
"0.5808914",
"0.58009535",
"0.5796596",
"0.5724881",
"0.5721709",
"0.5720373",
"0.57190484",
"0.5704015",
"0.570055",
"0.568882",
"0.56876916",
"0.56662774",
"0.5648169",
"0.5644143",
"0.5638084",
"0.5627494",
"0.5618268",
"0.56018",
"0.5599121",
"0.5597539",
"0.55843675",
"0.55818164",
"0.5581392",
"0.55667317",
"0.5561727",
"0.55491734",
"0.5541722",
"0.5539759",
"0.5504282",
"0.5483376",
"0.5478837",
"0.54781854",
"0.547551",
"0.54721135",
"0.5468152",
"0.54666793",
"0.5444861",
"0.54384905",
"0.5423736",
"0.5405355",
"0.5396857",
"0.53838366",
"0.53787345",
"0.53723574",
"0.5367518",
"0.5341706",
"0.53251386",
"0.5322201",
"0.5318892",
"0.53182906",
"0.531289",
"0.5312854",
"0.5305683",
"0.53046614",
"0.5301818"
] | 0.63866186 | 9 |
Runs through all regexps to find routes. | def rotation(offset = 0)
compile! unless compiled?
loop.with_object([]) do |_, candidacies|
return candidacies unless route = yield(offset)
candidacies << route
offset = route.index.next
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_routes\n matching_routes\n end",
"def each(*args)\n routes.each(*args)\n end",
"def routes\n routes_method.call\n end",
"def each\n @routes.each do |rt|\n yield rt\n end\n self\n end",
"def routes(&block); end",
"def routes(&block); end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def recognized_routes_for(env)\n Array(router.recognize(env).first)\n end",
"def loop_routes\n while(!@shutdown) do\n ensure_activerecord_connection\n \n routes.each do |route|\n break if @shutdown\n yield route\n end\n \n sleep self.sleep_time\n end\n end",
"def each_route(&block)\n\t\tget_routes().each(&block)\n\tend",
"def each(&block)\n _init\n\n routes.each(&block)\n end",
"def routes\n routes = {}\n self.class.each_route do |route|\n #routes[:name] = route.app.name # \"SomeSinatraApp\"\n info = {}\n routes[route.path.to_s.to_sym] = info # that's the path given as argument to get and akin\n info[:verb] = route.verb # get / head / post / put / delete\n info[:file] = route.file # \"some_sinatra_app.rb\" or something\n info[:line] = route.line # the line number of the get/post/... statement\n info[:pattern] = route.pattern # that's the pattern internally used by sinatra\n info[:keys] = route.keys # keys given when route was defined\n info[:conditions] = route.conditions # conditions given when route was defined\n info[:block] = route.block # the route's closure\n end\n routes\n end",
"def _routes; end",
"def handle_routes\n instance_exec(@_roda_app.request, &self.class.router_block)\n end",
"def routes\n @routes ||= []\n end",
"def routes\n @routes ||= []\n end",
"def routes\n @routes ||= []\n end",
"def compile!\n return if compiled?\n @regexps = @routes.map.with_index do |route, index|\n route.index = index\n /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @regexps = recursive_compile(@regexps)\n @compiled = true\n end",
"def routes(filter = nil)\n Rails.application.reload_routes!\n formatted = formatted_routes\n if filter\n formatted.select!{ |r| r.match(filter) }\n end\n puts formatted\n end",
"def routes\n desc 'shows all routes'\n task routes: :environment do\n print_routes api_routes\n end\n end",
"def each_route &block\n @routes_lookup.each do |key,route|\n next unless Array === key\n block.call route, key[0], key[1]\n end\n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def routes_map; end",
"def routes\n raise NotImplementedError\n end",
"def routes\n @routes ||= load_routes\n end",
"def routes(set_name = :main, &block)\n self.class.routes(set_name, &block)\n load_routes\n end",
"def anchored_routes; end",
"def process_routes src\n RoutesProcessor.new(@tracker).process_routes src\n end",
"def my_routes\n my_routes = []\n exceptions = %w(Login Signin)\n self.class.routes['GET'].each do |r|\n route = r.first.to_s.gsub(/\\W+|mix/,'').capitalize\n my_routes << route unless exceptions.include?(route)\n end\n return my_routes\n end",
"def routes\n cached_routes\n end",
"def route_for(request)\n index, params = if @around_match\n send(@around_match, request) { match(request) }\n else\n match(request)\n end\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def load_all_routes(roda_app)\n roda_app.request.public\n\n if Bridgetown.env.development? &&\n !Bridgetown::Current.preloaded_configuration.skip_live_reload\n setup_live_reload roda_app\n end\n\n Bridgetown::Rack::Routes.sorted_subclasses&.each do |klass|\n klass.merge roda_app\n end\n end",
"def fetch\n @routes = []\n source_extractors.keys.each do |source|\n extract_routes(source, data_for_source(source))\n end\n end",
"def all\n routes = {}\n routable.each do |r|\n routes.merge!(@ruhoh.collection(r).routes)\n end\n routes\n end",
"def initialize(routes)\n @routes = routes.map { |r| '/' + r }\n @captures = Match.new []\n end",
"def show_all_routes\n if @routes.empty?\n routes_void\n else\n routes_list\n end\n end",
"def parse_routes!\n allowed_routes.each do |route|\n if (endpoint = endpoints.find_from_route(route))\n endpoint.merge_http_methods!(route[:http_methods])\n else\n controller = controllers.find_or_create_from_route(route)\n endpoint = endpoints.create_from_route(route, controller)\n\n controller.add_endpoint(endpoint)\n end\n end\n end",
"def route_reps\n reps = @items.map { |i| i.reps }.flatten\n reps.each do |rep|\n # Find matching rule\n rule = self.compiler.routing_rule_for(rep)\n raise Nanoc3::Errors::NoMatchingRoutingRuleFound.new(rep) if rule.nil?\n\n # Get basic path by applying matching rule\n basic_path = rule.apply_to(rep)\n next if basic_path.nil?\n\n # Get raw path by prepending output directory\n rep.raw_path = self.config[:output_dir] + basic_path\n\n # Get normal path by stripping index filename\n rep.path = basic_path\n self.config[:index_filenames].each do |index_filename|\n if rep.path[-index_filename.length..-1] == index_filename\n # Strip and stop\n rep.path = rep.path[0..-index_filename.length-1]\n break\n end\n end\n end\n end",
"def load_routes\n\n # get our routes\n routes = Rails.application.routes.routes.to_a\n\n # filter out internal routes, those outside our base context, and those with no name\n routes.reject!{ |r| r.internal or !r.defaults.key?( :controller ) or r.name.nil? }\n\n # finally, map everything to a simpler version\n self.routes = routes.map do |r|\n {\n controller: r.defaults[:controller],\n action: r.defaults[:action].to_sym,\n name: r.name,\n params: r.parts.reject{ |p| p == :format }\n }\n end\n\n end",
"def call_routes\n return @call_routes\n end",
"def route_sets; end",
"def compile!\n return if compiled?\n @routes.each_with_index do |route, index|\n route.index = index\n route.regexp = /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @compiled = true\n end",
"def index\n @routes = Route.hottest\n end",
"def print_routes \n \n # Create a new hash\n h = Hash.new()\n\n # Use Sinatra advanced routes\n # to build out a hash based on the routes\n Sinatra::Application.each_route do |route|\n unless route.path.eql? \"/\" or route.path.eql? \"/*\"\n h[route.path.split(\"/\")[1]] = request.base_url + route.path \n end\n end\n\n # Return that badboy\n return h\n\nend",
"def routes\n app_obj.routes\n end",
"def gather_endpoints_to_check\n Rails.application.routes.routes.map do |route|\n verb = route.verb.downcase.to_sym\n example_path = route.path.spec\n .to_s.gsub('(.:format)', '')\n .gsub(/:([^\\/]+)/,'SOME_PLACEHOLDER_PARAM')\n .gsub('*path', 'SOME_PLACEHOLDER_PATH')\n .gsub('*filename','SOME_PLACEHOLDER_FILENAME')\n next unless verb.present?\n [verb, example_path]\n end.compact\n end",
"def get_routes\n raise \"Method not implemented\"\n end",
"def match_with(pattern)\n offset = 0\n conditions = [pattern]\n conditions << pattern[0..-2] if pattern != \"/\" && pattern.end_with?(\"/\")\n loop.with_object([]) do |_, candidacies|\n return candidacies unless conditions.any?{ |x| @regexps[offset] === x }\n route = @routes[offset..-1].detect{ |route| Regexp.last_match[\"_#{route.index}\"] }\n candidacies << route\n offset = route.index + 1\n end\n end",
"def routes_list\n response = RestClient.get(\n BASE_URL,\n params: {command: 'routeList', a: AGENCY}\n )\n\n parse_routes_response(response.body)\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/system',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/system/, \n :title => 'Sistema', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/admin/logger',\n :parent_path => '/admin/system',\n :regular_expression => /^\\/admin\\/logger/, \n :title => 'Trazas', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/logger-config',\n :regular_expression => /^\\/admin\\/logger-config/, \n :title => 'Logger configuration', \n :description => 'Configure the logger',\n :fit => 1,\n :module => :system }, \n {:path => '/business-events',\n :regular_expression => /^\\/admin\\/business-events/, \n :title => 'Business events',\n :description => 'Manage the business events.',\n :fit => 1,\n :module => :system }]\n \n end",
"def show_routes\n seen = []\n unless Merb::Router.named_routes.empty?\n puts \"==== Named routes\"\n Merb::Router.named_routes.each do |name,route|\n # something weird happens when you combine sprintf and irb\n puts \"Helper : #{name}\"\n meth = $1.upcase if route.conditions[:method].to_s =~ /(get|post|put|delete)/\n puts \"HTTP method: #{meth || 'GET'}\"\n puts \"Route : #{route}\"\n puts \"Params : #{route.params.inspect}\"\n puts\n seen << route\n end\n end\n puts \"==== Anonymous routes\"\n (Merb::Router.routes - seen).each do |route|\n meth = $1.upcase if route.conditions[:method].to_s =~ /(get|post|put|delete)/\n puts \"HTTP method: #{meth || 'GET'}\"\n puts \"Route : #{route}\"\n puts \"Params : #{route.params.inspect}\"\n puts\n end\n nil\n end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def index\n\t\t# default search terms will throw off the search, so remove them\n\t\tsearch_params = remove_default_search_terms(params[:search])\n\t\tlogger.debug(\"routes search params: #{search_params.inspect}\")\n\t\t@routes = Route.search(search_params).all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @routes }\n\t\tend\n\tend",
"def map(&block)\n @routes.map(&block)\n end",
"def generate_routes!\n Router.new(self).generate(@app)\n end",
"def routes\n request :get, '/routes'\n end",
"def routes\n @route_map.dup\n end",
"def get_matches(path)\n matches = []\n\n @routes.each_with_index do |route, i|\n score, pars = score_route(route[:parts], path)\n matches << [i, score, pars] if score > 0\n end\n\n matches\n end",
"def call(env)\n rr = Rack::Request.new(env)\n l = env['rack.logger']\n db = l ? l.method(:debug) : DEBUG_NULL\n db.call(DEBUG_NAME) do\n \"[ ? ] url: #{rr.url.inspect}, path: #{rr.fullpath.inspect}\"\n end\n matches = routes_for(rr.fullpath, rr.url)\n result = nil\n matches.each do |addressive|\n env[ADDRESSIVE_ENV_KEY] = addressive\n begin\n result = (addressive.spec.callback || addressive.spec.app).call(env)\n db.call(DEBUG_NAME) do\n \"[#{result[0]}] #{addressive.spec.template.pattern} with #{addressive.variables.inspect} on #{addressive.spec.app} ( route #{addressive.data[:'routes.scanned']} / #{addressive.data[:'routes.total']} ) after #{'%.6f' % addressive.data[:duration]}\"\n end\n rescue\n db.call(DEBUG_NAME) do\n \"[!!!] #{addressive.spec.template.pattern} with #{addressive.variables.inspect} on #{addressive.spec.app} ( route #{addressive.data[:'routes.scanned']} / #{addressive.data[:'routes.total']} ) after #{'%.6f' % addressive.data[:duration]}\"\n end\n raise\n end\n if result[0] != 404\n break\n end\n end\n if result.nil?\n db.call(DEBUG_NAME) do\n \"[404] Nothing found\"\n end\n return not_found(env)\n end\n return result\n end",
"def routers\n @cons.map{|c| c[:router]}.uniq.map{|m| try_resolve m}\n end",
"def route_reps\n reps = @items.map { |i| i.reps }.flatten\n reps.each do |rep|\n # Find matching rule\n rule = self.compiler.routing_rule_for(rep)\n raise Nanoc3::Errors::NoMatchingRoutingRuleFound.new(rep) if rule.nil?\n\n # Get basic path by applying matching rule\n basic_path = rule.apply_to(rep)\n next if basic_path.nil?\n if basic_path !~ %r{^/}\n raise RuntimeError, \"The path returned for the #{rep.inspect} item representation, “#{basic_path}”, does not start with a slash. Please ensure that all routing rules return a path that starts with a slash.\".make_compatible_with_env\n end\n\n # Get raw path by prepending output directory\n rep.raw_path = self.config[:output_dir] + basic_path\n\n # Get normal path by stripping index filename\n rep.path = basic_path\n self.config[:index_filenames].each do |index_filename|\n if rep.path[-index_filename.length..-1] == index_filename\n # Strip and stop\n rep.path = rep.path[0..-index_filename.length-1]\n break\n end\n end\n end\n end",
"def routes\n @logger.info \"#{__method__}\"\n fill_in \"JourneyPlanner$txtNumberOfPassengers\", with: \"1\"\n country_routes = list_countries.inject([]) do |country_result, country|\n @logger.info \"routes for #{country}\"\n select(country, :from => \"JourneyPlanner_ddlLeavingFromState\")\n sleep 3\n to_from = list_leaving_from.inject([]) do |from_result, from|\n @logger.info \"routes from #{from}\"\n sleep 2\n select(from, :from => \"JourneyPlanner$ddlLeavingFrom\")\n from_result << {from => list_travelling_to}\n from_result\n end\n country_result << {country => to_from}\n country_result\n end\n end",
"def custom_routes; end",
"def test_routes(routes, check_for = value)\n routes.should_not be_empty\n routes.each do |route|\n send(route[:method], route[:route]).body.should == check_for\n $after_filter.should == check_for\n $after_filter = \"\"\n end\n end",
"def show_routes\n seen = []\n unless Merb::Router.named_routes.empty?\n puts \"Named Routes\"\n Merb::Router.named_routes.each do |name,route|\n puts \" #{name}: #{route}\"\n seen << route\n end\n end\n puts \"Anonymous Routes\"\n (Merb::Router.routes - seen).each do |route|\n puts \" #{route}\"\n end\n nil\n end",
"def routes(set_name = :main, &block)\n if set_name && block\n @@routes[set_name] = block\n else\n @@routes\n end\n end",
"def compile\n robot.handlers.each do |handler|\n next unless handler.respond_to?(:http_routes)\n\n handler.http_routes.each { |route| router.add_route(route) }\n end\n end",
"def find_matching_blocks( key )\n\t\treturn self.class.routes.inject([]) do |accum, (re, re_blocks)|\n\t\t\taccum += re_blocks if re.match( key )\n\t\t\taccum\n\t\tend\n\tend",
"def routes\n context[:routes]\n end",
"def routes_normal\n return Array.new\n end",
"def routes\n @active_routes ||= Workling::Discovery.discovered.map { |clazz| @routing.queue_names_routing_class(clazz) }.flatten\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/media',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/media/,\n :title => 'Medios',\n :description => 'Gestión de medios',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/config',\n :parent_path => '/admin/media',\n :regular_expression => /^\\/admin\\/media\\/config/,\n :title => 'Configuración',\n :description => 'Configuración medios',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/album',\n :parent_path => '/admin/media',\n :regular_expression => /^\\/admin\\/media\\/album/,\n :title => 'Albums',\n :description => 'The albums admin tools to create and modify media albums',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/photo/:album_name',\n :parent_path => '/admin/media/album',\n :regular_expression => /^\\/admin\\/media\\/photo\\/.+/,\n :title => 'Photos',\n :description => 'It manages the album\\'s photos. Used to upload and edit the album\\'s photos.',\n :fit => 1,\n :module => :media_gallery},\n {:path => '/gallery/:album_name',\n :regular_expression => /^\\/photo_gallery\\/.+/,\n :title => 'Photos',\n :description => 'It shows the album\\'s photos.',\n :fit => 1,\n :module => :media_gallery}]\n \n end",
"def generate_routes m\n # routes\n unless command_has_resources\n # add routes like unnested scaffold \n # eg. map.resources books\n m.route_resources controller_file_name\n else\n resource_list = controller_file_name.map { |r| r.to_sym.inspect }.join(', ')\n parent_resource = parent_resource_name\n \n path = destination_path('config/routes.rb')\n content = File.read(path)\n \n logger.route \"resources #{resource_list}\"\n \n # map.resources :parents do |parent|\n # parent.resources :parents do |parent|\n sentinel = \"\\.resources(.*)?:#{parent_resource.pluralize}(.*)do(.*)\\\\|#{parent_resource}\\\\|\"\n \n if content =~ /#{sentinel}/\n gsub_file 'config/routes.rb', sentinel do |match|\n \"#{match}\\n #{parent_resource}.resources :#{table_name}\"\n end\n else\n # without do block\n # map.resources :parents \n # parent.resources :parents\n sentinel = \"\\.resources(.*):#{parent_resource.pluralize}\"\n if content =~ /#{sentinel}/\n gsub_file 'config/routes.rb', sentinel do |match|\n \"#{match} do |#{parent_resource}|\\n #{parent_resource}.resources :#{table_name}\\n end\"\n end\n end\n end\n end\n end",
"def all_selectable_routes\n (page_routes + rails_routes).uniq.sort\n end",
"def processed_route\n return @original_route unless any_wildcard?\n as_regex\n end",
"def index\n @rec_run_routes = RecRunRoute.all\n end",
"def routes\n return @routes unless @routes.nil?\n r = Parse::API::Hooks::TRIGGER_NAMES_LOCAL + [:function]\n @routes = OpenStruct.new(r.reduce({}) { |h, t| h[t] = {}; h })\n end",
"def reload_routes!(_show_routes = false)\n Rails.application.reload_routes!\n return unless _show_routes\n\n Rails.application.routes.routes.each do |route|\n puts route.path.spec\n end\n end",
"def routes\n @routes || self.class.routes\n end",
"def available_routes\n routes = {}\n @components.each_value do |c|\n c.proxy.routes.each do |r|\n if routes[r] == nil\n routes[r] = c.proxy.uri\n else\n raise \"Route '#{r}' already handled by component \" +\n routes[r].name\n end\n end if c.registered?\n end\n routes\n end",
"def match(*options)\n @matches << Route.new(options)\n end",
"def prepare_routes\n return if Rails.configuration.eager_load || Rails.env == \"test\" \n begin\n Rails.application.routes_reloader.reload! \n rescue SystemStackError\n # NOP -- Supressing Stack Level Too deep error\n # caused by models being loaded lazily during development mode.\n end\n end",
"def common_routes\n [\n [ search_path, 'Search Talks', 'talks' ],\n [ helps_path, 'Help' , 'helps' ], # TBD: replace with help search\n [ credits_path, 'Credits' , 'credits' ],\n [ static_pages_about_path, 'About' , 'static_pages' ],\n [ static_pages_contact_path, 'Contact' , 'static_pages' ],\n [ static_pages_privacy_path, 'Privacy' , 'static_pages' ],\n [ static_pages_sitemap_path, 'Site Map', 'static_pages' ]\n ]\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/worker-jobs',\n :regular_expression => /^\\/admin\\/worker-jobs/, \n :title => 'Delayed jobs', \n :description => 'Query delayed jobs',\n :fit => 1,\n :module => :system }]\n \n end",
"def reset!\n class << self\n alias_method :match, :match_before_compilation\n end\n self.routes, self.named_routes = [], {}\n end",
"def finalize_artifacts\n \n return if skip_method(__method__)\n \n puts \"finalize Rails routes in config/routes.rb\"\n \n add_routes(@@rails_routes)\n \n # create the navigation menu\n finalize_menu\n \n end",
"def initialize\n @routes = {}\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/cms',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/cms/,\n :title => 'Gestor contenidos',\n :description => 'Gestiona los contenidos',\n :fit => 2,\n :module => :cms},\n {:path => '/admin/cms/content-types',\n :parent_path => '/admin/cms',\n \t :regular_expression => /^\\/admin\\/cms\\/content-types/, \n :title => 'Tipos de contenido' , \n :description => 'Manages the content types: creation and update of content types.',\n :fit => 3,\n :module => :cms},\n {:path => '/mctype/:type/:aspect',\n :parent_path => \"/mctypes\",\n :regular_expression => /^\\/mctype\\/.+\\/.+/, \n :title => 'Content type aspect configuration', \n :description => 'Edit the content type/aspect configuration',\n :fit => 1,\n :module => :cms}, \n {:path => '/admin/cms/contents',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/content/, \n :title => 'Contenidos', \n :description => 'Manages the contents',\n :fit => 2,\n :module => :cms},\n {:path => '/admin/cms/content/new/',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/content\\/new/, \n :title => 'Crear contenido', \n :description => 'Create a new content: Choose the content type.',\n :fit => 2,\n :module => :cms},\n {:path => '/admin/cms/content/new/:content_type',\n :parent_path => \"/admin/cms/content/new/\",\n :regular_expression => /^\\/admin\\/cms\\/content\\/new\\/.+/, \n :title => 'Nuevo', \n :description => 'Create a new content: Complete data.',\n :fit => 3,\n :module => :cms}, \n {:path => '/admin/cms/content/edit/:content_id',\n :parent_path => '/admin/cms/contents',\n :regular_expression => /^\\/admin\\/cms\\/content\\/edit\\/.+/, \n :title => 'Editar contenido', \n :description => 'Editar contenido',\n :fit => 1,\n :module => :cms}, \n {:path => '/admin/cms/taxonomy',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/taxonomy/, \n :title => 'Taxonomías', \n :description => 'Manages the taxonomies: creation and update of taxonomies',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/terms/:taxonomy_id',\n :parent_path => \"/admin/cms/taxonomy\",\n :regular_expression => /^\\/admin\\/cms\\/terms\\/.+/, \n :title => 'Term',\n :description => 'Manage the terms of a taxonomy.',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/templates',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/templates/, \n :title => 'Plantillas', \n :description => 'Manages templates: creation and update of templates',\n :fit => 1,\n :module => :cms }, \n {:path => '/admin/cms/comments',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/comments/, \n :title => 'Comentarios', \n :description => 'Manages comments: creation and update of templates',\n :fit => 1,\n :module => :cms }, \n {:path => '/admin/cms/blocks',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/blocks/, \n :title => 'Bloques', \n :description => 'Manage the blocks. It allows to discover and configure modules blocks',\n :fit => 1,\n :module => :cms},\n {:path => '/admin/cms/views',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/views/, \n :title => 'Vistas', \n :fit => 1,\n :description => 'Manage the views: creation and update of views',\n :module => :cms},\n {:path => '/content/:page',\n :regular_expression => /^\\/content\\/.+/,\n :title => 'Content',\n :description => 'Shows a content',\n :fit => 1,\n :module => :cms},\n {:path => '/contents/category/:term_id',\n :regular_expression => /^\\/contents\\/category\\/.+/,\n :title => 'Contents by category',\n :description => 'Shows all the contents tagged with the category',\n :fit => 1,\n :module => :cms},\n {:path => '/admin/cms/menu-management',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/menu-management/, \n :title => 'Menu', \n :description => 'Manages the menus: creation and update of menus',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/menu-item-management/:menu_name',\n :parent_path => '/admin/cms/menu-management',\n :regular_expression => /^\\/admin\\/cms\\/menu-item-management\\/.+/, \n :title => 'Elemento de menú',\n :description => 'Manage the items of a menu.',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/translate/content/:content_id',\n :parent_path => '/admin/cms/contents',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/content\\/.+/, \n :title => 'Traducir contenido', \n :description => 'Translate a content',\n :fit => 1,\n :module => :translation },\n {:path => '/admin/cms/translate/menuitem/:menuitem_id',\n :parent_path => '/admin/cms/menu-management',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/menuitem\\/.+/, \n :title => 'Traducir elemento de menu', \n :description => 'Translate a menu item',\n :fit => 1,\n :module => :translation }, \n {:path => '/admin/cms/translate/term/:term_id',\n :parent_path => '/admin/cms/taxonomy',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/term\\/.+/, \n :title => 'Traducir término',\n :description => 'Translate a term.',\n :fit => 1,\n :module => :translation },\n {:path => '/admin/cms/translate/template/:template_id',\n :parent_path => '/admin/cms/templates',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/template\\/.+/, \n :title => 'Traducir plantilla',\n :description => 'Translate a term.',\n :fit => 1,\n :module => :translation } \n ]\n \n end"
] | [
"0.731993",
"0.67177325",
"0.65614885",
"0.65394974",
"0.6522915",
"0.6522915",
"0.63694364",
"0.63694364",
"0.63694364",
"0.63694364",
"0.63694364",
"0.63694364",
"0.63694364",
"0.63694364",
"0.63694364",
"0.63694364",
"0.63694364",
"0.63645214",
"0.6329907",
"0.63205886",
"0.6305104",
"0.6301866",
"0.6282284",
"0.6280953",
"0.6271015",
"0.6271015",
"0.61982334",
"0.617802",
"0.6128892",
"0.611931",
"0.6113607",
"0.60937744",
"0.60937744",
"0.60681",
"0.60497075",
"0.6037213",
"0.6025888",
"0.6008344",
"0.59989",
"0.59885937",
"0.5972705",
"0.5965495",
"0.59524167",
"0.5914622",
"0.59044605",
"0.5902898",
"0.5898364",
"0.58911085",
"0.5870302",
"0.5863517",
"0.5819932",
"0.5814856",
"0.5797625",
"0.5786288",
"0.57749426",
"0.577455",
"0.5772458",
"0.5766957",
"0.57555044",
"0.5749864",
"0.5729719",
"0.5704242",
"0.5704086",
"0.5704086",
"0.5704086",
"0.5694097",
"0.568376",
"0.5672398",
"0.56607664",
"0.56604177",
"0.56582844",
"0.5654533",
"0.56415063",
"0.56314605",
"0.5629406",
"0.5625363",
"0.56199557",
"0.56188333",
"0.56104785",
"0.5606337",
"0.55978614",
"0.558103",
"0.55762017",
"0.5571051",
"0.5569384",
"0.55682373",
"0.55557495",
"0.5549762",
"0.5533173",
"0.5527618",
"0.55216116",
"0.55093527",
"0.5507768",
"0.5502694",
"0.5498772",
"0.549635",
"0.5470544",
"0.54642457",
"0.5456436",
"0.54508805",
"0.5450868"
] | 0.0 | -1 |
Encode string with Encoding.default_external | def encode_default_external(string)
string.encode(Encoding.default_external)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def external_encoding\n Encoding.default_external\n end",
"def string_encoder\n return string if string.valid_encoding?\n str = string\n Encoding.list.each do |e|\n begin\n str.force_encoding(e.name)\n tmp_string = str.encode('UTF-8')\n return tmp_string if tmp_string.valid_encoding?\n rescue\n Rails.logger.debug { \"Rescue -> #{e.name}\" } if defined?(::Rails)\n end\n end\n\n impossible_encoding\n\n string\n end",
"def encode(string); end",
"def encode_string; end",
"def encode_string_ex; end",
"def force_encoding(enc)\n @enml.to_s.encode(enc)\n end",
"def _encode_string(string)\n return string unless string.kind_of? String\n string.encode(\"UTF-8\", :undef => :replace, :invalid => :replace, :replace => \"?\")\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encoding::UTF_8) : string\n end",
"def encode_string(string)\n string.encode('UTF-8', {\n :invalid => :replace,\n :undef => :replace,\n :replace => '?'\n })\n rescue Exception\n nil\n end",
"def encode(string)\n Base32.encode(string).downcase.sub(/=+$/, '')\n end",
"def encode(input)\n return '' if input.nil?\n input.to_s.encode(Encoding::UTF_8)\n rescue Encoding::UndefinedConversionError\n input.dup.force_encoding(Encoding::UTF_8)\n end",
"def encode(s)\n return s if s.nil?\n return s if s.valid_encoding?\n if s.force_encoding(\"iso-8859-1\").valid_encoding?\n return s.encode('utf-8', 'iso-8859-1')\n end\n s\n end",
"def encode_string(string)\n string.encode('UTF-8', {\n :invalid => :replace,\n :undef => :replace,\n :replace => '?'\n })\n rescue Exception\n nil\n end",
"def force_encoding(string)\n string.force_encoding(encoding)\n end",
"def fix_encoding(str)\n str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding)\n str\nend",
"def encode!\n source = self.source\n\n return source unless source.encoding == Encoding::BINARY\n\n # Look for # encoding: *. If we find one, we'll encode the\n # String in that encoding, otherwise, we'll use the\n # default external encoding.\n if source.sub!(LEADING_ENCODING_REGEXP, \"\")\n encoding = magic_encoding = $1\n else\n encoding = Encoding.default_external\n end\n\n # Tag the source with the default external encoding\n # or the encoding specified in the file\n source.force_encoding(encoding)\n\n # If the user didn't specify an encoding, and the handler\n # handles encodings, we simply pass the String as is to\n # the handler (with the default_external tag)\n if !magic_encoding && @handler.respond_to?(:handles_encoding?) && @handler.handles_encoding?\n source\n # Otherwise, if the String is valid in the encoding,\n # encode immediately to default_internal. This means\n # that if a handler doesn't handle encodings, it will\n # always get Strings in the default_internal\n elsif source.valid_encoding?\n source.encode!\n # Otherwise, since the String is invalid in the encoding\n # specified, raise an exception\n else\n raise WrongEncodingError.new(source, encoding)\n end\n end",
"def encoding\n @external_encoding\n end",
"def external_encoding; @_external_encoding || _external_encoding; end",
"def to_encoded_str\n string_io = StringIO.new\n self.encode string_io\n string_io.string\n end",
"def encode(string)\n URI.escape(string)\n end",
"def encode(str)\n if @using_old_ruby\n # Because ruby 1.8.7 doesn't have String#encode.\n require 'iconv'\n Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-2]\n else\n str.encode('utf-8', 'binary', :invalid => :replace, :undef => :replace)\n end\n end",
"def encode(text); end",
"def encode(text); end",
"def reencode_string(input); end",
"def set_external_encoding(encoding = Encoding::UTF_8)\n\t\t\t# TODO: Deprecate and remove this setup - it should be the responsibility of the server to set this correctly.\n\t\t\tif Encoding.default_external != encoding\n\t\t\t\twarn \"Updating Encoding.default_external from #{Encoding.default_external} to #{encoding}\" if $VERBOSE\n\t\t\t\tEncoding.default_external = encoding\n\t\t\tend\n\t\tend",
"def test_default_internal_is_honored\n before_enc = Encoding.default_internal\n\n str = \"壁に耳あり、障子に目あり\"\n bson = BSON::BSON_CODER.serialize(\"x\" => str)\n\n silently { Encoding.default_internal = 'EUC-JP' }\n out = BSON::BSON_CODER.deserialize(bson)[\"x\"]\n\n assert_equal Encoding.default_internal, out.encoding\n assert_equal str.encode('EUC-JP'), out\n assert_equal str, out.encode(str.encoding)\n ensure\n silently { Encoding.default_internal = before_enc }\n end",
"def utf8_encode(string, binary: false, placeholder: STRING_PLACEHOLDER)\n string = string.to_s\n\n if binary\n # This option is useful for \"gracefully\" displaying binary data that\n # often contains text such as marshalled objects\n string.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n elsif string.encoding == ::Encoding::UTF_8\n string\n else\n string.encode(::Encoding::UTF_8)\n end\n rescue StandardError => e\n OpenTelemetry.logger.debug(\"Error encoding string in UTF-8: #{e}\")\n\n placeholder\n end",
"def force_default_encoding; end",
"def encoded_string(obj)\n obj.to_s.encode('utf-8', invalid: :replace, undef: :replace)\n end",
"def encode(string)\n Base64.encode64(string).gsub(/\\n/, \"\")\n end",
"def with_external_encoding(encoding)\n old_encoding = Encoding.default_external\n silence_warnings {Encoding.default_external = \"iso-8859-1\"}\n ensure\n silence_warnings {Encoding.default_external = old_encoding if old_encoding}\n end",
"def encode(immune, input)\n return nil if input.nil?\n encoded_string = ''\n encoded_string.encode!(Encoding::UTF_8)\n input.encode(Encoding::UTF_8).chars do |c|\n encoded_string << encode_char(immune,c)\n end\n encoded_string\n end",
"def safe_encode_utf8(text)\n text.force_encoding('ASCII-8BIT').encode(\"UTF-8\", :invalid => :replace, :undef => :replace, :universal_newline => true)\nend",
"def set_encoding\n Encoding.default_external = Encoding::UTF_8\n Encoding.default_internal = Encoding::UTF_8\n nil\n end",
"def force_encoding(enc)\n end",
"def external_encoding()\n #This is a stub, used for indexing\n end",
"def encode\n ::Base64.encode64(@string)\n end",
"def utf8_safe\n encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def protect_encoding(x)\n x.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n end",
"def ident_encode(string)\n string.force_encoding('ISO-8859-1').encode('UTF-8')\n end",
"def set_encoding(text)\n unless text.encoding.name == \"UTF-8\"\n text = text.encode(\"UTF-8\", \n invalid: :replace, \n undef: :replace, \n replace: \"\"\n )\n end\n end",
"def encode_for_excel(s)\n s.encode(default_encoding, invalid: :replace, undef: :replace)\n end",
"def force_encoding(s, encoding)\n if s.respond_to?(:force_encoding)\n s.force_encoding(encoding)\n else\n s\n end\n end",
"def transcode(string)\n return string.encode(\"iso-8859-1\").force_encoding(\"utf-8\")\nend",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def encode(encoding)\n to_s.encode(encoding)\n end",
"def force_encoding(*); self; end",
"def url_encode(string) \r\n encoded_string = ''\r\n string.each_char do |char|\r\n char = (\"%%%02X\" % char.ord) if char.match(/[A-Za-z0-9]/) == nil\r\n encoded_string << char\r\n end\r\n return encoded_string\r\n end",
"def url_encode(string) \r\n encoded_string = ''\r\n string.each_char do |char|\r\n char = (\"%%%02X\" % char.ord) if char.match(/[A-Za-z0-9]/) == nil\r\n encoded_string << char\r\n end\r\n return encoded_string\r\n end",
"def encode(str,encoding)\n\n\tstr.each_char do |num|\n\t\tif (encoding.has_key? (num))\n\t\t\t\" \".push(encoding[num])\n\t\tend\n\tend\n\treturn empty_string\nend",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def setup_encoding\n\t\t\t# TODO: Deprecate and remove this setup - it should be the responsibility of the server to set this correctly.\n\t\t\tif @external_encoding and Encoding.default_external != @external_encoding\n\t\t\t\twarn \"Updating Encoding.default_external from #{Encoding.default_external} to #{@external_encoding}\" if $VERBOSE\n\t\t\t\tEncoding.default_external = @external_encoding\n\t\t\tend\n\t\tend",
"def encode_base64(text)\n Base64.strict_encode64(text).strip\n end",
"def encode_str(str)\n require \"base64\"\n encoded_str=Base64.encode64(str)\n return encoded_str\nend",
"def default_encoding; end",
"def default_encoding; end",
"def unicode_filter_encode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_encode(str) : str\n end",
"def encode(str)\n @base64 = Base64.encode64(str)\n end",
"def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end",
"def base64_encode(string)\n SSL.base64_encode(string)\n end",
"def base64_encode(string)\n SSL.base64_encode(string)\n end",
"def ensure_encoding!(encoding: DEFAULT_ENCODING, try_encodings: PRIORITY_ENCODINGS)\n fix_encoding!(try_encodings: try_encodings)\n encode! encoding\n self\n end",
"def base64_encode value\n encoded_str = Base64.urlsafe_encode64 value, padding: false\nend",
"def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend",
"def to_utf8(s)\n return force_encoding(s.gsub(/&(.*?)-/n) {\n if $1.empty?\n \"&\"\n else\n base64 = $1.tr(\",\", \"/\")\n x = base64.length % 4\n if x > 0\n base64.concat(\"=\" * (4 - x))\n end\n base64.unpack(\"m\")[0].unpack(\"n*\").pack(\"U*\")\n end\n }, \"UTF-8\")\n end",
"def utf8\n self.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')\n end",
"def encode_string(str)\n str = str.to_s.encode('UTF-8')\n\n # Force to binary, when assembling the packet\n str.force_encoding('ASCII-8BIT')\n encode_short(str.bytesize) + str\n end",
"def raw_encoding(default = Encoding::ASCII_8BIT)\n if @io.respond_to? :internal_encoding\n @io.internal_encoding || @io.external_encoding\n elsif @io.is_a? StringIO\n @io.string.encoding\n elsif @io.respond_to? :encoding\n @io.encoding\n else\n default\n end\n end",
"def encode!; end",
"def encode\n transform :encode \n end",
"def string\n str = basic_string\n if str.respond_to? :force_encoding\n str.force_encoding InternalEncoding\n end\n\n convert(str, @encoding)\n end",
"def b64_encode(string)\n Base64.encode64(string).tr(\"\\n=\",'')\n end",
"def encode(value)\n Base64.encode64 value\n end",
"def additional_encoding(s)\n encoding_hash = {\":\" => \"%3A\", \"+\" => \"%2B\"}\n encoding_hash.each_pair do |k, v|\n s.gsub!(k, v)\n end\n s\n end",
"def make_readable(string)\n # See String#encode\n encoding_options = {\n :invalid => :replace, # Replace invalid byte sequences\n :undef => :replace, # Replace anything not defined in ASCII\n :replace => '', # Use a blank for those replacements\n :universal_newline => true # Always break lines with \\n\n }\n return string.encode(Encoding.find('ASCII'), encoding_options)\n end",
"def force_encoding(enc)\n self\n end",
"def encoding\n @io.external_encoding\n end",
"def encoding\n @io.external_encoding\n end",
"def force_encoding(*args) settings.force_encoding(*args) end",
"def iconv(charset)\n encode(charset, fallback: ->(c) { UTF8_TO_ASCII[c] || \"?\" })\n end",
"def force_default_encoding=(_arg0); end",
"def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end",
"def encoding=(enc); end",
"def encoding(value = nil)\n value ? @encoding = value : @encoding\n end",
"def encode(bytes)\n ::Base32.encode(bytes.to_s).downcase\n end",
"def encode to_encode\n CGI.escape(to_encode)\n end",
"def encode(encoder, options = T.unsafe(nil)); end",
"def encode(encoder, options = T.unsafe(nil)); end",
"def encode(string)\n [string]\n end",
"def url_encode(string)\n string = CGI.escape string\n end",
"def force_to_ascii s\n out = \"\"\n s.each_byte do |b|\n if (b & 128) != 0\n out << \"\\\\x#{b.to_s 16}\"\n else\n out << b.chr\n end\n end\n #out.force_encoding Encoding::UTF_8 if in_ruby19_hell? # not necessary?\n out\n end",
"def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend",
"def do_encoding(string)\n ## removing newline (needed for pty/expect newlines)\n string[0, 2] = '' if string.start_with? \"\\r\\n\"\n string[0, 3] = '' if string.start_with? \"\\r\\r\\n\"\n string.gsub!(\"\\r\\n\", \"\\n\")\n # string.chomp!\n string\n end",
"def to_utf8!; replace(to_utf8); end",
"def encode(value)\n value.to_s(BASE)\n end",
"def encoding\n # noop?\n end",
"def encode(string)\n string.unpack('B*')[0].tr('01', \" \\n\")\n end",
"def default_encoding\n Encoding::UTF_8\n end",
"def ensure_correct_encoding!(val)\n if @eval_string.empty? &&\n val.respond_to?(:encoding) &&\n val.encoding != @eval_string.encoding\n @eval_string.force_encoding(val.encoding)\n end\n end"
] | [
"0.75890625",
"0.7542044",
"0.7473844",
"0.7416969",
"0.73306304",
"0.7306955",
"0.7156714",
"0.70741445",
"0.70741445",
"0.7058213",
"0.70472217",
"0.70415145",
"0.7039941",
"0.7026714",
"0.69621706",
"0.6928945",
"0.6855664",
"0.68282866",
"0.6804509",
"0.6754842",
"0.67507124",
"0.6746271",
"0.67002416",
"0.67002416",
"0.6684494",
"0.6659615",
"0.6635863",
"0.6633766",
"0.6622277",
"0.6596814",
"0.65805656",
"0.65724623",
"0.6569338",
"0.6548421",
"0.6546423",
"0.6534991",
"0.6525273",
"0.6521172",
"0.64885587",
"0.64882195",
"0.6475406",
"0.6474057",
"0.6458117",
"0.6456833",
"0.64500797",
"0.64454204",
"0.6370822",
"0.6369103",
"0.6360417",
"0.6360417",
"0.63560206",
"0.6351507",
"0.63453233",
"0.63343126",
"0.6309512",
"0.6288333",
"0.6288333",
"0.628068",
"0.6278639",
"0.6278049",
"0.6260959",
"0.6260959",
"0.6244011",
"0.62435037",
"0.62309235",
"0.6221741",
"0.6217456",
"0.6206278",
"0.6192121",
"0.6190732",
"0.61770666",
"0.6172103",
"0.6169307",
"0.61560136",
"0.61508626",
"0.61449575",
"0.6136962",
"0.6130202",
"0.6130202",
"0.6127224",
"0.6120984",
"0.61141443",
"0.61063147",
"0.6097852",
"0.6096165",
"0.6094899",
"0.6093439",
"0.60824656",
"0.60824656",
"0.6082149",
"0.6070768",
"0.6067145",
"0.60581464",
"0.60452354",
"0.6033945",
"0.602234",
"0.60088444",
"0.60042524",
"0.6003872",
"0.59814984"
] | 0.8961825 | 0 |
Decode uri escape sequences | def decode_uri(string)
string.split(/%2F|%2f/, -1).map { |part| Rack::Utils.unescape(part) }.join('%2F')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unescape_uri(uri); end",
"def decode_uri(uri)\n return uri unless uri\n CGI::unescape(uri)\n end",
"def process_uri(uri)\n URI.parse(URI.escape(URI.unescape(uri)))\n end",
"def process_uri(uri)\n URI.parse(URI.escape(URI.unescape(uri)))\n end",
"def uri_unescape\n tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){[$1.delete('%')].pack('H*')}\n end",
"def url_decode\n Rack::Utils.unescape self\n end",
"def urldecode\n _rfc2396_parser.unescape(self)\n end",
"def url_unescape(s)\n #Added this to make cadaver work\n s = s.gsub(\"%28\", \"(\").gsub(\"%29\", \")\")\n URI.unescape(s)\n end",
"def decode(value)\n `decodeURI(#{value})`\n end",
"def uri_escape(input); end",
"def uri_escape(str)\n str.split(//).map {|c| c.match(URI::UNSAFE) ? sprintf('%%%02x',c.ord).upcase : c }.join\nend",
"def uri_escape(str)\n str.split(//).map {|c| c.match(URI::UNSAFE) ? sprintf('%%%02x',c.ord).upcase : c }.join\nend",
"def parse_escaped_chars; end",
"def urlescape\n @@uri_parser ||= URI::RFC2396_Parser.new\n @@uri_parser.escape(self)\n end",
"def safe_escape(uri); end",
"def unescape(str)\n str.to_s.gsub(/%(..)/) { Regexp.last_match(1).hex.chr }\n end",
"def unescape_raw_response\n Addressable::URI.form_unencode(@raw_response)\n end",
"def unescape(str)\n # Escape all the things\n str.gsub(/\\\\(?:([#{UNESCAPES.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\' then '\\\\' else UNESCAPES[$1] end\n elsif $2 # escape \\u0000 unicode\n [\"#$2\".hex].pack('U*')\n elsif $3 # escape \\0xff or \\xff\n [$3].pack('H2')\n end\n }\n end",
"def url_utf8(raw_url)\n URI::escape(raw_url)\n end",
"def unescape(s); s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){[$1.delete('%')].pack('H*')} end",
"def unescape(str)\n # URI.unescape is obsolete\n DEFAULT_PARSER.unescape(str)\n end",
"def unescape_url(url)\n Addressable::URI.unescape(url)\n end",
"def unescape(value)\n return nil if value.nil?\n regex = /\\\\(?:([nevfbart\\\\])|0?x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/\n value.gsub(regex) do\n if Regexp.last_match(3)\n [Regexp.last_match(3).to_s.hex].pack('U*')\n elsif Regexp.last_match(2)\n [Regexp.last_match(2)].pack('H2')\n else\n UNESCAPES[Regexp.last_match(1)]\n end\n end\n end",
"def unescape_path(path); end",
"def unescape(s)\n s.gsub(/((?:%[0-9a-fA-F]{2})+)/n) {[$1.delete('%')].pack('H*')}\n end",
"def unescape_url(url)\n Addressable::URI.unescape(url)\n end",
"def unescape(*arg)\n warn \"#{caller(1)[0]}: warning: URI.unescape is obsolete\" if $VERBOSE\n DEFAULT_PARSER.unescape(*arg)\n end",
"def uri_escape\n str = xml_escape.gsub(/\\+/, '+')\n str = str.gsub(/\\s/, '+')\n end",
"def decode(text); end",
"def he_decode(text); self.class.he_decode text; end",
"def unescape_path(path)\n URI.unescape(path.to_s)\n end",
"def process_uri(uri)\n URI.parse(uri)\n rescue URI::InvalidURIError\n uri_parts = uri.split('?')\n # regexp from Ruby's URI::Parser#regexp[:UNSAFE], with [] specifically removed\n encoded_uri = URI.encode(uri_parts.shift, /[^\\-_.!~*'()a-zA-Z\\d;\\/?:@&=+$,]/)\n encoded_uri << '?' << URI.encode(uri_parts.join('?')) if uri_parts.any?\n URI.parse(encoded_uri) rescue raise CarrierWave::DownloadError, \"couldn't parse URL\"\n end",
"def decode_escape(input)\n c = input.look_ahead(1)\n case c\n when \"a\" : result = \"\\a\"\n when \"b\" : result = \"\\b\"\n when \"f\" : result = \"\\f\"\n when \"n\" : result = \"\\n\"\n when \"r\" : result = \"\\r\"\n when \"t\" : result = \"\\t\"\n when \"v\" : result = \"\\v\"\n when \"\\\\\" : result = \"\\\\\"\n when /[01234567]/ : raise \"Escaped octal Unicode not supported\"\n when \"x\" : raise \"Escaped hex Unicode not supported\"\n when \"u\" : raise \"Escaped Unicode not supported\"\n else\n result = c\n end\n input.consume 2\n return result\n end",
"def uri_escape(uri)\n URI::DEFAULT_PARSER.escape(uri).gsub('[', '%5B').gsub(']', '%5D')\n end",
"def unescape(s)\n s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n) {\n [$1.delete('%')].pack('H*')\n }\n end",
"def unescape_stringify(str)\n chars = {\n 'a' => \"\\x07\", 'b' => \"\\x08\", 't' => \"\\x09\", 'n' => \"\\x0a\", 'v' => \"\\x0b\", 'f' => \"\\x0c\",\n 'r' => \"\\x0d\", 'e' => \"\\x1b\", \"\\\\\\\\\" => \"\\x5c\", \"\\\"\" => \"\\x22\", \"'\" => \"\\x27\"\n }\n # Escape all the things\n str.gsub(/\\\\(?:([#{chars.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\'\n then '\\\\'\n else\n chars[$1]\n end\n elsif $2\n [\"#$2\".hex].pack('U*')\n elsif $3\n [$3].pack('H2')\n end\n }\n end",
"def unescape(str, escaped = @regexp[:ESCAPED])\n str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(str.encoding)\n end",
"def unescape( value )\n return value unless @escape\n\n value = value.to_s\n value.gsub!(%r/\\\\[0nrt\\\\]/) { |char|\n case char\n when '\\0'; \"\\0\"\n when '\\n'; \"\\n\"\n when '\\r'; \"\\r\"\n when '\\t'; \"\\t\"\n when '\\\\\\\\'; \"\\\\\"\n end\n }\n value\n end",
"def encodeURI s\n URI.escape s, /[^A-Za-z0-9;,\\/?:@&=+$\\-_.!~*'()#]/\nend",
"def escapeRFC3986(str)\r\n return URI.escape(str, /[^A-Za-z0-9\\-_.~]/)\r\nend",
"def escapeRFC3986(str)\n return URI.escape(str,/[^A-Za-z0-9\\-_.~]/)\nend",
"def unescape\n bytes = escaped_path_to_bytes(path)\n str = bytes.pack('C*')\n str.force_encoding(Encoding::UTF_8)\n end",
"def escape_uri(s); Rack::Utils.escape(s); end",
"def prepare(spec)\n URI.decode(spec)\n end",
"def decode_slash(string)\n string.gsub('_slash_', '/')\n end",
"def decode_slash(string)\n string.gsub('_slash_', '/')\n end",
"def decode_as_raw_url\n self.url = URI.decode_www_form_component(url)\n end",
"def unescape( src )\n String.class_eval(%Q(\"#{src}\"))\nend",
"def unescape(str, escaped = @regexp[:ESCAPED])\n enc = str.encoding\n enc = Encoding::UTF_8 if enc == Encoding::US_ASCII\n str.gsub(escaped) { [$&[1, 2]].pack('H2').force_encoding(enc) }\n end",
"def unescape(string,encoding=@@accept_charset)\n str=string.tr('+', ' ').b.gsub(/((?:%[0-9a-fA-F]{2})+)/) do |m|\n [m.delete('%')].pack('H*')\n end.force_encoding(encoding)\n str.valid_encoding? ? str : str.force_encoding(string.encoding)\n end",
"def escapeRFC3986(str)\n return URI.escape(str,/[^A-Za-z0-9\\-_.~]/)\n end",
"def escapeRFC3986(str)\n return URI.escape(str,/[^A-Za-z0-9\\-_.~]/)\n end",
"def unescape(string)\n string.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n) do\n [$1.delete('%')].pack('H*')\n end\n\tend",
"def uri_encode(text)\n URI.escape(text, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))\n end",
"def escape(str)\n URI.escape str, /[:?\\/']/\nend",
"def unescape(s)\n s.to_s.gsub(/%2[Bb]/, \"+\")\n end",
"def unescape_special_chars( str )\n\t\t\tEscapeTable.each {|char, hash|\n\t\t\t\t@log.debug \"Unescaping escaped %p with %p\" % [ char, hash[:md5re] ]\n\t\t\t\tstr.gsub!( hash[:md5re], hash[:unescape] )\n\t\t\t}\n\n\t\t\treturn str\n\t\tend",
"def unescape(val)\n\tval.gsub!(/(\\\\x[\\da-f]{2}|\\\\u[\\da-f]{4})/) { [$1[2..-1].hex].pack('U') }\n\tval\nend",
"def decode_string(str)\n\nend",
"def unescape_component(x)\n # temporarily escape \\\\ as \\007f, which is disallowed in any text\n x.gsub(/\\\\\\\\/, \"\\u007f\").gsub(/\\\\;/, \";\").gsub(/\\\\,/, \",\").\n gsub(/\\\\[Nn]/, \"\\n\").tr(\"\\u007f\", \"\\\\\")\n end",
"def strip_and_unescape(value)\n value.strip\n .gsub(/^\\^\"(.*)\\^\"$/, '\\1')\n .gsub(/^\"(.*)\"$/, '\\1')\n .gsub(/\\^([\\\\\"&%^<>|])/, '\\1')\n .gsub(/\\\\\\\\/, '\\\\')\n end",
"def decode(str)\n str.gsub(/\\\\\\(/, '(').gsub(/\\\\\\)/, ')')\n end",
"def urlencode\n #URI.escape(self)\n _rfc2396_parser.escape(self)\n end",
"def base64_url_decode(str)\n \"#{str}==\".tr(\"-_\", \"+/\").unpack(\"m\")[0]\n end",
"def base64_url_decode(str)\n str += '=' * (4 - str.length.modulo(4))\n Base64.decode64(str.tr('-_', '+/'))\n end",
"def decode(raw, table={})\n\t n = -1\n\t while n and (m = n + 1) < raw.length\n\t n = raw.index('&', m)\n\t next if m == n\n\t n ||= raw.length\n\t q = raw.index('=', m)\n\t next if !q or q > n\n\t \n\t a = raw.index('[', m)\n\t idx = CGI::unescape(raw[m, (a && a<n ? a : q)-m])\n\t into = table\n\t while into and a and a < q and (b = raw.index(']', a)) and b < q\n\t path = idx\n\t idx = CGI::unescape(raw[a+1, b-a-1])\n\t into = (into[path] ||= (idx.size.zero? ? [] : {}))\n\t into = nil unless (idx.size.zero? ? Array : Hash) === into\n\t a = raw.index('[', b + 1)\n\t end\n\t \n\t v = CGI::unescape(raw[q+1, n-q-1])\n\t case into\n when Hash\n into[idx] = v\n when Array\n\t into << v\n\t end\n\t end\n\t into\n\tend",
"def uri_segment(str)\n # pchar - pct-encoded = unreserved / sub-delims / \":\" / \"@\"\n # unreserved = ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\"\n # sub-delims = \"!\" / \"$\" / \"&\" / \"'\" / \"(\" / \")\" / \"*\" / \"+\" / \",\" / \";\" / \"=\"\n str.gsub(%r{[^A-Za-z0-9\\-._~!$&'()*+,;=:@]}n) {\n '%' + $&.unpack(\"H2\")[0].upcase\n }\n end",
"def unescape(x)\n # temporarily escape \\\\ as \\007f, which is disallowed in any text\n x.gsub(/\\\\\\\\/, \"\\u007f\").gsub(/\\\\,/, \",\").gsub(/\\\\[Nn]/, \"\\n\").\n tr(\"\\u007f\", \"\\\\\")\n end",
"def decode_json_scrp\n self\n .gsub('\\u0022', '\"')\n .gsub('\\u00E0', \"à\")\n .gsub('\\u00E2', \"â\")\n .gsub('\\u00E8', \"è\")\n .gsub('\\u00E9', \"é\")\n .gsub('\\u00E7', \"ç\")\n .gsub('\\u00F9', \"ù\")\n .gsub('\\u0026', \"&\")\n .gsub('\\u20AC', \"€\")\n .gsub('\\u0027', \"'\")\n .gsub('\\u00A0', \"\")\n .gsub('\\u00C8', \"È\")\n .gsub('\\u00B2', \"²\")\n .gsub('\\u00C9', \"É\")\n .gsub('\\\\\"', '\"')\n end",
"def url_encode(s)\n s.to_s.b.gsub(/[^a-zA-Z0-9_\\-.]/n) { |m|\n sprintf(\"%%%02X\", m.unpack(\"C\")[0])\n }\n end",
"def consume_escaped; end",
"def uri_escape(string)\n if string.nil?\n nil\n else\n CGI.escape(string.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~')\n end\n end",
"def url_(str)\n encoding = str.encoding\n str.b.gsub(/([^ a-zA-Z0-9_.-]+)/) do |m|\n '%' + m.unpack('H2' * m.bytesize).join('%').upcase\n end.tr(' ', '+').force_encoding(encoding)\n end",
"def encode_uri(uri)\n uri = uri.join(\"/\") if uri.class == Array\n additional_encoding(URI.parse(URI.encode(uri)).to_s)\n end",
"def url_encode(s)\n s.to_s.b.gsub(/[^a-zA-Z0-9_\\-.~]/n) { |m|\n sprintf(\"%%%02X\", m.unpack1(\"C\"))\n }\n end",
"def uri_normalizer; end",
"def unescaped_path\n path_info.split(/(%25|%2F)/i).each_slice(2).map { |v, m| CGI.unescape(v) << (m || '') }.join('')\n end",
"def to_uri_fragment\n # remove HTML tags from the input\n buf = gsub(/<.*?>/, '')\n\n # The first or only character must be a letter.\n buf.insert(0, 'a') unless buf[0,1] =~ /[[:alpha:]]/\n\n # The remaining characters must be letters, digits, hyphens (-),\n # underscores (_), colons (:), or periods (.) or Unicode characters\n buf.unpack('U*').map! do |code|\n if code > 0xFF or code.chr =~ /[[:alnum:]\\-_:\\.]/\n code\n else\n 32 # ASCII character code for a single space\n end\n end.pack('U*').strip.gsub(/[[:space:]-]+/, '-')\n end",
"def decode\n transform :decode\n end",
"def unescape_value(value)\n value = value.to_s\n value.gsub!(%r{\\\\[0nrt\\\\]}) do |char|\n case char\n when '\\0' then \"\\0\"\n when '\\n' then \"\\n\"\n when '\\r' then \"\\r\"\n when '\\t' then \"\\t\"\n when '\\\\\\\\' then '\\\\'\n end\n end\n value\n end",
"def post_process_uri( val )\n\t\t\treturn URI.parse( val.to_s )\n\t\trescue URI::InvalidURIError => err\n\t\t\tself.log.error \"Error trying to parse URI %p: %s\" % [ val, err.message ]\n\t\t\treturn nil\n\t\trescue NoMethodError\n\t\t\tself.log.debug \"Ignoring bug in URI#parse\"\n\t\t\treturn nil\n\t\tend",
"def url_encode(string) \r\n encoded_string = ''\r\n string.each_char do |char|\r\n char = (\"%%%02X\" % char.ord) if char.match(/[A-Za-z0-9]/) == nil\r\n encoded_string << char\r\n end\r\n return encoded_string\r\n end",
"def url_encode(string) \r\n encoded_string = ''\r\n string.each_char do |char|\r\n char = (\"%%%02X\" % char.ord) if char.match(/[A-Za-z0-9]/) == nil\r\n encoded_string << char\r\n end\r\n return encoded_string\r\n end",
"def unicode_filter_decode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_decode(str) : str\n end",
"def convert_encoding(content); end",
"def decode_git_path(path)\n if path[0] == ?\" && path[-1] == ?\"\n path = path[1...-1]\n path.gsub!(/\\\\\\d{3}/) { |m| m[1..-1].to_i(8).chr }\n end\n path.gsub!(/\\\\[rn\"\\\\]/) { |m| eval(%(\"#{m.to_s}\")) }\n path\n end",
"def uri_encode(identifier)\n URI.escape(identifier)\n end",
"def unescape(string)\n string.gsub(/#[[:xdigit:]]{2}/) do |match|\n match[1..-1].to_i(16).chr\n end\n end",
"def unescape(string)\n string.gsub(/#[[:xdigit:]]{2}/) do |match|\n match[1..-1].to_i(16).chr\n end\n end",
"def unescape_link\n self.link = CGI.unescape(link) if self.link.present?\n end",
"def encoded_url\n CGI.escape(url)\n end",
"def decode; end",
"def decode; end",
"def decode_entities(data)\n data = data.dup\n\n data.gsub!(/(&)#(\\d+);?/){ decode_dec_entity($1, $2) }\n data.gsub!(/(&)#x([0-9a-f]+);?/i){ decode_hex_entity($1, $2) }\n data.gsub!(/(%)([0-9a-f]{2});?/i){ decode_hex_entity($1, $2) }\n\n data = validate_entities(data)\n\n return data\n end",
"def parse_uri(input)\n lines = parse_input input\n extract_uri lines\n end",
"def url_encode\n Rack::Utils.escape self\n end",
"def get_url_encoded_file(file)\n begin\n file.gsub!('https','http')\n uri = URI.parse(URI.escape(URI.unescape(file)))\n return uri\n end\n end",
"def iconv() end",
"def unicode_esc!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 9 )\n\n \n # - - - - main rule block - - - -\n # at line 309:9: '\\\\\\\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT\n match( 0x5c )\n match( 0x75 )\n hex_digit!\n hex_digit!\n hex_digit!\n hex_digit!\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 9 )\n\n end",
"def decode_b(str)\n str.gsub!(/=\\?ISO-2022-JP\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/=\\?SHIFT_JIS\\?B\\?([!->@-~]+)\\?=/i) {\n decode64($1)\n }\n str = Kconv::toeuc(str)\n str.gsub!(/\\n/, ' ') \n str.gsub!(/\\0/, '')\n str\n end"
] | [
"0.7888991",
"0.76751953",
"0.7377986",
"0.7377986",
"0.7302313",
"0.7176729",
"0.7032956",
"0.6931313",
"0.6842274",
"0.66753316",
"0.66569096",
"0.66569096",
"0.65852684",
"0.6547811",
"0.6443195",
"0.64291817",
"0.63833445",
"0.6372182",
"0.6342235",
"0.6263125",
"0.6251134",
"0.6249525",
"0.62454516",
"0.6233288",
"0.62169236",
"0.61970896",
"0.6195073",
"0.6174912",
"0.6160693",
"0.61564404",
"0.6146186",
"0.6092605",
"0.6061153",
"0.606062",
"0.6035481",
"0.60198724",
"0.6016353",
"0.6008491",
"0.60058695",
"0.60053277",
"0.5979334",
"0.5976707",
"0.5970676",
"0.5951285",
"0.5943991",
"0.5943991",
"0.5942208",
"0.5915658",
"0.59043264",
"0.58991724",
"0.58851504",
"0.58851504",
"0.5884876",
"0.58688986",
"0.5825411",
"0.5817065",
"0.5814022",
"0.5764498",
"0.5758028",
"0.5745773",
"0.5723601",
"0.57073253",
"0.5694888",
"0.5693478",
"0.5686751",
"0.567776",
"0.5672227",
"0.56718516",
"0.56669134",
"0.56614065",
"0.5643402",
"0.5608866",
"0.5600556",
"0.55920935",
"0.55838096",
"0.55833364",
"0.5568067",
"0.5551554",
"0.5549895",
"0.55390364",
"0.5520044",
"0.55137616",
"0.55137616",
"0.5508358",
"0.55080634",
"0.55021733",
"0.5467241",
"0.5461072",
"0.5461072",
"0.5450181",
"0.5432027",
"0.54261684",
"0.54261684",
"0.54056954",
"0.53925425",
"0.53907126",
"0.5386919",
"0.5382239",
"0.5377389",
"0.5354878"
] | 0.7497991 | 2 |
uisti sa, ze sa na tento produkt neodkazuju ziadne polozky | def ensure_not_referenced_by_any_line_item
if line_items.empty?
return true
else
errors.add(:base, 'Existuju polozky')
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suivre; end",
"def zuruecksetzen()\n end",
"def mi_carrera\n\n\tend",
"def nacti_data(data, pomer)\n poc_nactenych_klauzuli = 0 \n pole_radku = data.split(\"\\n\")\n \n pole_radku.each do |radek|\n if(radek[0]!=\"c\")then #preskakuji komentar\n pole_hodnot = radek.split(' ') # ulozim si hodnoty do pole\n \n case radek[0]\n \n when \"p\"\n #nacteni zakladniho nastaveni instance\n @pocet_promennych = pole_hodnot[2].to_i\n @pocet_klauzuli = pole_hodnot[3].to_i\n # pokud je nastaven pomer (tj. obtiznost instance)\n if((pomer!=-1)&&(@pocet_klauzuli>=@pocet_promennych.to_f*pomer))then\n @pocet_klauzuli = @pocet_promennych.to_f*pomer\n end\n \n when \"w\"\n #nacitani vahoveho vektoru\n citac = 1\n while(citac < pole_hodnot.length)do\n @pole_vah[citac-1] = pole_hodnot[citac].to_i\n citac +=1\n end\n\n # when \"%\" # pouze pro kontrolu\n #ukoncovaci znak\n # puts \"%\" \n \n else\n #nacitani klauzuli\n if(poc_nactenych_klauzuli<@pocet_klauzuli)then\n citac = 0\n while(citac < pole_hodnot.length-1)do\n if(@klauzule[poc_nactenych_klauzuli]==nil)then\n nove_pole = []\n @klauzule[poc_nactenych_klauzuli]= nove_pole\n end\n @klauzule[poc_nactenych_klauzuli][@klauzule[poc_nactenych_klauzuli].length] = pole_hodnot[citac].to_i\n citac +=1\n end\n poc_nactenych_klauzuli+=1\n end \n end\n end\n end \n end",
"def ToCoStoiPrzyA()\n return @RownanieWielomianu.first.WspolczynnikPomocniczy\n end",
"def moverPrimasADespacho(cantidad_lotes)\n\t\n\nend",
"def ognia(a,b)\n\t\tsystem \"clear\"\n\t\tif @pelna.litera[a][b] == \" X\"\n\t\t\t@pusta.litera[a][b] = \" X\"\n\t\t\tprint \"Trafiony \"\n\t\t\tszukany = (Statek.lista_statkow.select {|x| x if x.sam_statek[0] == [a,b] || x.sam_statek[1] == [a,b] ||\n\t\t\t x.sam_statek[2] == [a,b] || x.sam_statek[3] == [a,b]})[0]\n\t\t\tszukany.sam_statek.delete([a,b])\n\t\t\t\n\t\t\tif szukany.sam_statek.length == 0\n\t\t\t\tputs \"Zatopiony !!!\"\n\t\t\t\tszukany.otoczka.each {|x| pusta.litera[x[0]][x[1]]=\" .\" if x[0] >=0 && x[1] >=0 && x[0] < 10 && x[1] < 10}\n\t\t\t\tStatek.lista_statkow.delete(szukany)\n\t\t\t\tprint \"Zostało Ci jeszcze #{Statek.lista_statkow.count} statków do zatopienia\"\n\t\t\tend\n\t\t\tputs\n\t\t\t\n\t\t\telse \n\t\t\tputs \"Pudło !\"\n\t\t\t@pusta.litera[a][b] = \" .\"\n\t\t\t\n\t\tend\n\t\tif Statek.lista_statkow.count > 0\n\t\t\t@pusta.rysuj \n\t\telse\n\t\t\tsystem \"clear\"\n\t\t\t@pusta.rysuj \n\t\t\tputs \"Koniec GRY !!!\" \n\t\tend\n\tend",
"def devolver_azucar \n\t\treturn @azucares\n\tend",
"def povuci_mrezu\n return @mreza\n end",
"def verdi; end",
"def plany_zajec\n PlanZajec.where(\"ogloszenie_id = ?\", self.id)\n end",
"def precio\n\t\t@precio\n\tend",
"def preco\n @preco\n end",
"def probers; end",
"def get_usoterreno\n aux = 0.0\n @contenido.each do |alimento|\n aux += alimento.ground\n end\n @usoterreno = aux\n end",
"def solicitudes_atrasadas\n end",
"def vrat_modif_instanci\n vystup=\"\"\n @pole_dat.each do |radek| \n if(radek[0]==\"p\")then \n vystup +=radek\n vystup += \"w #{generuj_vahy(radek).join(' ')}\\n\" #pridani radku s vahami\n else\n vystup +=radek\n end \n end\n # puts vystup\n return vystup\n end",
"def PodstawAn(ans) \n @RownanieWielomianu.each{ |wezel| \n if(ans.key?(wezel.Wspolczynnik))\n wezel.Wspolczynnik = ans[wezel.Wspolczynnik]\n end\n }\n end",
"def schubert; end",
"def zapis_vysledek(reseni, je_splnitelna) \n @reseni = reseni\n @vysledny_soucet_vah = vrat_soucet_vah(reseni)\n @je_splnitelna = je_splnitelna\n end",
"def asignaturas_peda_por(profe)\n # per = Horario.where('professor_id = ?', profe.id).joins(:asignatura).where('lectiva=true')\n per = Horario.where('professor_id = ?', profe.id).joins(:asignatura)\n .where('asignaturas.lectiva=TRUE').order('asignaturas.orden')\n a = per.map do |h|\n [\"#{h.asignatura.name} #{h.curso.name} \", \"#{h.horas}\"]\n end\n\n end",
"def porcentajegrasa\n\t\t1.2 * imc + 0.23 * @edad - 10.8 * @sexo - 5.4\n\tend",
"def terpene; end",
"def konversiMenit(menit) \n # =================================\n # Area Kode Kode di sini\n \n \n \n # =================================\n end",
"def wydajPrzesylkeKierowcy(kierowca)\n # wybor przesylki\n # przesylka = ...wybieramy jakas\n # usuniecie tej przesylki z @przesylki\n kierowca.push(przesylka) \n end",
"def comisiones_asignadas\n asunto.comisiones if asunto\n end",
"def preenche_parcelas_recorrencia\n return unless recorrencia\n \n if recorrencia.tipo == 'por'\n recorrencia.data_inicial = data\n recorrencia.parcelas = recorrencia.descobre_parcelas\n else\n recorrencia.parcelas = nil\n end\n end",
"def test_cruzado_datos\n Metodos.refresh()\n #point\n w_=Metodos.nuevo(0,\"point\")\n h_=Metodos.nuevo(0,\"point\")\n wP_=Metodos.nuevo(0,\"point\")\n hP_=Metodos.nuevo(216,\"mm\")\n nX=Metodos.nuevo(2,nil)\n nY=Metodos.nuevo(1,nil)\n nPaginas=\"\"\n nPliegos=\"\"\n cuadernillos=false\n #\n esperados=[]\n esperados.push(Clases::Mensaje.new(1))#h real\n esperados.push(Clases::Mensaje.new(2))#wP calculado\n esperados.push(Clases::Mensaje.new(11))#h calculado\n esperados.push(Clases::Mensaje.new(5))#todas pdf\n esperados.push(Clases::Mensaje.new(7))#no impares\n esperados.push(Clases::Mensaje.new(6))#pliegos\n esperados.push(Clases::Mensaje.new(8))#MensajeVars\n esperados.push(Clases::Mensaje.new(9))#tiempo cut&Stack\n #\n respuestas=[]\n respuestas.push([Clases::PreguntaEscalado.new(\"verticalmente\"),true])#id:2\n #\n resultado=nUp(w_,h_,wP_,hP_,nX,nY,nPaginas,nPliegos,cuadernillos,esperados,nil,respuestas)\n assert(resultado.yn,resultado.msg)\n ensure\n #limpio todo, aunque se caiga\n if File.dirname($temp)!=nil then\n `rm -r #{File.dirname($temp)}`\n end\n end",
"def excede_control_de_pago_x_ticket_x_parlay(last_tickect_current_user, entrada) # define el monto maximo a sacar por parlay, ej. pago max para tripletas, cuartetas etc.. no por ticket sino por tipo de ticket parlay ok\n @sumatoria_posible_pago_todos_tickets_de_hoy_ese_parlay = 0 # inicializacion de variable de sumatoria en cero ok.\n #verificar tipo de parlay de ese ticket:\n parlay_count = Jugadalot.where(:ticket_id => last_tickect_current_user).count\n #parlay_count\n\n #switch case para asignar tipo de jugada segun tipo de parlay para buscar en control de pago:\n tipo_jugada = \"default\" # valor vacio para posible uso fuera de contexto de septimetas en adelante, hacer que retorne false la funcion ok. (no encontrado)\n \n #el switch case lo haremos de modo simple con el if statement por ahora ok:\n if parlay_count.to_i == 1\n tipo_jugada = \"directo\" \n end\n\n if parlay_count.to_i == 2\n tipo_jugada = \"pale\" \n end\n\n if parlay_count.to_i == 3\n tipo_jugada = \"tripleta\" \n end\n\n if parlay_count.to_i == 4\n tipo_jugada = \"cuarteta\" \n end\n\n if parlay_count.to_i == 5\n tipo_jugada = \"quinteta\" \n end\n\n if parlay_count.to_i == 6\n tipo_jugada = \"sexteta\" \n end\n\n if parlay_count.to_i == 7\n tipo_jugada = \"septimeta\" \n end\n\n if parlay_count.to_i == 8\n tipo_jugada = \"octaveta\" \n end\n\n control_monto_max_pago = Controldepagogt.where(:tipojugada => tipo_jugada ).first.limiteglobal.to_i\n\n #acabo de conseguir el limite global de ese parlay en curso, ahora buscar la sumatoria de todos las jugadalots.posiblepago de los ticket activo de hoy y ver si no sbobrepara ese limiet ok\n t_ids = Ticket.today.where(:activo => \"si\", :parlay => tipo_jugada.to_s ).ids # todos los ticket actio de hoy con ese parlay ok\n \n @listado_jugadas_a_sumar = Jugadalot.where(:ticket_id => t_ids)# POstgres casting sum string error ok..sum(:posiblepago).to_i\n \n if not @listado_jugadas_a_sumar.nil?\n @listado_jugadas_a_sumar.each do |jugada|\n @sumatoria_posible_pago_todos_tickets_de_hoy_ese_parlay += jugada.posiblepago.to_i\n end\n end\n\n \n\n #Sumar posible pago de esas jugadas de cada ticket parlay ok.\n #@sumatoria_posible_pago_todos_tickets_de_hoy_ese_parlay = 0\n #t.each do |ticket|\n # @sumatoria_posible_pago_todos_tickets_de_hoy_ese_parlay += Jugadalot.where(:ticket_id => ticket.id).last.posiblepago.to_i\n #end\n\n if @sumatoria_posible_pago_todos_tickets_de_hoy_ese_parlay.to_i <= control_monto_max_pago.to_i\n # si es menor todo ok\n false # no excede\n else\n true #si excede \n end\n\n\n end",
"def comer\r\n # @image = Image[\"pez2.png\"]\r\n # Al comer, un pez tendrá x segundos mas de vida, y queda libre para buscar mas comida\r\n @vida_inicio += 2\r\n @libre = true\r\n end",
"def nova_jogada(jogada)\n rodada = @partida_atual.rodada_atual\n# debugger unless rodada_nova? || jogada.jogador.cartas_do_naipe(rodada.naipe).empty? || jogada.carta.naipe == rodada.naipe\n if rodada_nova? || jogada.jogador.cartas_do_naipe(rodada.naipe).empty? || jogada.carta.naipe == rodada.naipe\n rodada.nova_jogada(jogada)\n jogada.carta.jogar!\n if rodada.completa?\n if @partida_atual.completa?\n nova_partida\n end\n @jogador_atual = rodada.vencedor\n @partida_atual.nova_rodada\n end\n# true\n end\n proximo_jogador\n end",
"def status_da_divulgacao(topico)\n end",
"def desplegarProceso\n\t\tputs \"id=#{@id} cantBytes=#{@cantBytes} cantPaginas=#{@cantPaginas}\"\n\t\tputs \"marcosRealAsig=#{@marcosRealAsig} marcosSwapAsig=#{@marcosSwapAsig}\"\n\tend",
"def calcula_tramos(proyecto_id)\n proyecto = Proyecto.find(params[:proyecto_id].to_i) \n dretmax = proyecto.dretmax\n vanomax = proyecto.vanomax\n pant = nil\n tant = nil\n \n Tramo.where(:proyecto_id => proyecto_id).each {|t|\n t.reltramovanos.destroy_all\n if (t.dimgeom!=nil )\n t.dimgeom.destroy\n end \n t.destroy\n } \n Vano.where(:proyecto_id => proyecto_id).destroy_all\n \n \n puntos = Punto.where(:proyecto_id => proyecto_id).order(:secuencia)\n n = 0\n m = puntos.count-1\n \n puntos.each {|p|\n if (n==0)\n tramo = Tramo.new\n tramo.ttramo_id = 1 #arranque\n tramo.cantidad = 1\n tramo.angulo = 0\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Arranque en \" + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n tant = tramo\n \n elsif (n<m) #desvios intermedios\n vano = Vano.new\n vano.nombre = \"Vanos entre \" + pant.punto + ' y ' + p.punto\n if (p.distancia < vanomax)\n vano.vano = p.distancia\n else\n vano.vano = p.distancia / (( p.distancia/vanomax).to_i + 1 )\n end \n vano.proyecto_id = proyecto_id\n vano.cond_e_id = proyecto.cond_e_id\n vano.cond_g_id = proyecto.cond_g_id\n vano.save\n vano.calcvano\n vant = vano\n \n if (p.distancia > dretmax)\n tramo = Tramo.new\n tramo.ttramo_id = 4 #retension\n tramo.cantidad = (p.distancia/dretmax).to_i\n tramo.angulo = 0\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Retensiones entre \" + pant.punto + ' y ' + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tramo.id\n rel.angulo = 0\n rel.save\n end\n if (p.distancia > vanomax)\n tramo = Tramo.new\n tramo.ttramo_id = 5 #alineacion\n tramo.cantidad =(p.distancia/vanomax).to_i - (p.distancia/dretmax).to_i\n tramo.angulo = 0\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Alineaciones entre \" + pant.punto + ' y ' + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tramo.id\n rel.angulo = 0\n rel.save\n end\n tramo = Tramo.new\n tramo.ttramo_id = 2 #desvio\n tramo.cantidad = 1\n tramo.angulo = p.angulo\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Desvio de \" + p.angulo.to_i.to_s + \"° en \" + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tramo.id\n rel.angulo = 0\n rel.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tant.id\n rel.angulo = pant.angulo\n rel.save\n tant = tramo\n \n else #terminal\n vano = Vano.new\n vano.nombre = \"Vanos entre \" + pant.punto + ' y ' + p.punto \n if (p.distancia < vanomax)\n vano.vano = p.distancia\n else\n vano.vano = p.distancia / (( p.distancia/vanomax).to_i + 1 )\n end \n vano.proyecto_id = proyecto_id\n vano.cond_e_id = proyecto.cond_e_id\n vano.cond_g_id = proyecto.cond_g_id\n vano.save\n vano.calcvano\n\n if (p.distancia > dretmax)\n tramo = Tramo.new\n tramo.ttramo_id = 4 #retension\n tramo.cantidad = (p.distancia/dretmax).to_i\n tramo.angulo = 0\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Retensiones entre \" + pant.punto + ' y ' + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tramo.id\n rel.angulo = 0\n rel.save\n end\n if (p.distancia > vanomax)\n tramo = Tramo.new\n tramo.ttramo_id = 5 #alineacion\n tramo.cantidad =(p.distancia/vanomax).to_i - (p.distancia/dretmax).to_i\n tramo.angulo = 0\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Alineaciones entre \" + pant.punto + ' y ' + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tramo.id\n rel.angulo = 0\n rel.save\n end\n tramo = Tramo.new\n tramo.ttramo_id = 3 #terminal\n tramo.cantidad = 1\n tramo.angulo = 0\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Terminal en \" + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tramo.id\n rel.angulo = p.angulo\n rel.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tant.id\n rel.angulo = pant.angulo\n rel.save\n \n end\n \n n+=1\n pant = p\n }\n \n Tramo.where(:proyecto_id=>proyecto_id).each { |t|\n t.calcabezal\n }\n end",
"def set_rodzaj_pracownika\n @rodzaj_pracownika = RodzajPracownika.find(params[:id])\n end",
"def vel\n @velocidad\n end",
"def despachar\n self.estado_id = 2 # en ruta\n self.buzon_id = self.destinatario_id\n self.add_traza(current_user.id ,1, current_user.puesto.buzon_id)\n self.recepcion = Time.now\n self.save!\n end",
"def posti_disponibili\n self.vehicle.posti - self.n_passeggeri\n end",
"def test_04_dada_una_caja_de_ahorros_cuyo_saldo_es_200_pesos_si_extraigo_300_pesos_su_saldo_no_debe_variar\n @una_caja_de_ahorros_nueva.depositar 200.pesos\n @una_caja_de_ahorros_nueva.extraer 300.pesos\n assert_equal 200.pesos, @una_caja_de_ahorros_nueva.saldo\n end",
"def informa(pippo)\n # 1. Calcolo i valori di c14_idaliquotaiva e la loro frequenza in lbooks\n ivaInLbooks = Lbook.gruppiIVA\n risultL = \"1. Segue hash ivaInLbooks: #{ivaInLbooks.inspect}\"\n pippo.scriviRiga(risultL)\n\n # 2. Calcolo i valori di idaliquotaiva e la loro frequenza in books\n ivaInBbooks = Book.gruppiIVA\n risultB = \"2. Segue hash ivaInBbooks: #{ivaInBbooks.inspect}\"\n pippo.scriviRiga(risultB) \nend",
"def letzte_komponente\n \n end",
"def calculo \n self.minutos_reales = 5 * 480 #cantidad de OPERARIOS * Jornada de Trabajo(Turnos)\n self.costo_minuto = 89 #Costo Real por minuto\n self.otros_costos = 540 * 89 #Tiempo Total(Minutos) * Costo Real por Minutos\n self.costo_mano_obra = 420 * 5 * 89 # Jornada Minutos * Cantidad Operarios * Costo Real por minutos \n self.manoObraPlaneada = 650.000 * 5 # Salario Total * Cantidad de operarios \n end",
"def grilleSuivante()\n @grilleRaz = nil\n return nil\n end",
"def moverA_Despacho oc\n #sku = Integer(params[:sku])\n #cantidad = Integer(params[:cantidad])\n #oc = params[:oc]\n idDespacho = (Almacen.find_by depacho:true).almacenId\n @id = idDespacho\n sku = (((Orden.find_by idOrden: oc).sku).strip).to_i\n cantidad = (((Orden.find_by idOrden: oc).cantidad).strip).to_i\n puts cantidad\n cliente = (Orden.find_by idOrden: oc).cliente\n cantidadBodega = ((Inventario.find_by sku: sku).cantidadBodega).to_i\n cantidadBodega = cantidadBodega - cantidad\n (Inventario.find_by sku: sku).update(cantidadBodega: cantidadBodega)\n cantidadVendida = ((Inventario.find_by sku: sku).cantidadVendida).to_i\n cantidadVendida = cantidadVendida - cantidad\n (Inventario.find_by sku: sku).update(cantidadVendida: cantidadVendida)\n # producto = ((Inventario.find_by sku: sku).cantidadBodega).to_i - ((Inventario.find_by sku: sku).cantidadVendida).to_i\n # if sku == 19\n # StockItem.find(1).update(count_on_hand:producto)\n # elsif sku == 27\n # StockItem.find(2).update(count_on_hand:producto)\n # elsif sku == 40\n # StockItem.find(3).update(count_on_hand:producto)\n # elsif sku == 45\n # StockItem.find(4).update(count_on_hand:producto)\n # elsif sku == 47\n # StockItem.find(5).update(count_on_hand:producto)\n # end\n if cliente == 'internacional'\n #Vemos si tenemos lo suficiente en el almacén de despacho\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'GET' + idDespacho\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n temp = RestClient.get 'http://integracion-2016-prod.herokuapp.com/bodega/skusWithStock', {:Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json', :params => {:almacenId => idDespacho}}\n contenido = JSON.parse temp\n i=0\n necesario = cantidad\n restante = cantidad\n while contenido[i].nil? == false do\n sku_ = Integer(contenido[i][\"_id\"])\n total = Integer(contenido[i][\"total\"])\n if sku_ == sku\n puts 'ehtra aca'\n if total >= cantidad\n necesario = 0\n restante = 0\n while cantidad > 0\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'GET' + idDespacho + sku.to_s\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n stock = RestClient.get 'http://integracion-2016-prod.herokuapp.com/bodega/stock', {:Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json', :params => {:almacenId => idDespacho, :sku => sku, :limit => cantidad}}\n stockParseado = JSON.parse stock\n puts stockParseado.length\n k = 0\n puts cantidad\n while k < stockParseado.length\n idProducto = stockParseado[k][\"_id\"]\n direccion = 'internacional'\n orden = RestClient.get 'http://moto.ing.puc.cl/oc/obtener/' + oc\n ordenParseada = JSON.parse orden\n precio = ordenParseada[0][\"precioUnitario\"]\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'DELETE' + idProducto + direccion + precio.to_s + oc\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n RestClient::Request.execute(method: :delete, url: 'http://integracion-2016-prod.herokuapp.com/bodega/stock', payload: {:productoId => idProducto, :direccion => direccion, :precio => precio, :oc => oc}, headers: {Authorization: 'INTEGRACION grupo1:'+clave})\n k += 1\n end\n cantidad -= k\n end\n else\n necesario = cantidad - total\n restante = cantidad - total\n while total > 0\n #Despachamos lo que teniamos en despacho\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'GET' + idDespacho + sku.to_s\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n stock = RestClient.get 'http://integracion-2016-prod.herokuapp.com/bodega/stock', {:Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json', :params => {:almacenId => idDespacho, :sku => sku, :limit => total}}\n stockParseado = JSON.parse stock\n puts stockParseado.length\n k = 0\n while k < stockParseado.length\n idProducto = stockParseado[k][\"_id\"]\n direccion = 'internacional'\n orden = RestClient.get 'http://moto.ing.puc.cl/oc/obtener/' + oc\n ordenParseada = JSON.parse orden\n precio = ordenParseada[0][\"precioUnitario\"]\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'DELETE' + idProducto + direccion + precio.to_s + oc\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n RestClient::Request.execute(method: :delete, url: 'http://integracion-2016-prod.herokuapp.com/bodega/stock', payload: {:productoId => idProducto, :direccion => direccion, :precio => precio, :oc => oc}, headers: {Authorization: 'INTEGRACION grupo1:'+clave})\n k += 1\n end\n total -= k\n end\n #@necesario = necesario\n end\n else\n #necesario = cantidad\n #restante = cantidad\n end\n i += 1\n end\n while necesario > 0 do\n i = Almacen.first.id\n #recorremos los almacenes buscando el producto\n nAlmacenes = Almacen.last.id\n while i <= nAlmacenes \n id = Almacen.find(i).almacenId\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'GET' + id\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n temp = RestClient.get 'http://integracion-2016-prod.herokuapp.com/bodega/skusWithStock', {:Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json', :params => {:almacenId => id}}\n contenido = JSON.parse temp\n j=0\n while contenido[j].nil? == false do\n sku_ = Integer(contenido[j][\"_id\"])\n total = Integer(contenido[j][\"total\"])\n if sku_ == sku && id != idDespacho\n #Encontramos el producto\n signature = 'GET' + id.to_s + sku_.to_s\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n if necesario != 0\n puts necesario\n temp = RestClient.get 'http://integracion-2016-prod.herokuapp.com/bodega/stock', {:Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json', :params => {:almacenId => id, :sku => sku_, :limit => necesario}}\n productos = JSON.parse temp\n @productos = productos\n puts productos\n k = 0\n while k < productos.length\n idProducto = productos[k][\"_id\"]\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'POST' + idProducto + idDespacho\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n RestClient.post 'http://integracion-2016-prod.herokuapp.com/bodega/moveStock', {:productoId => idProducto, :almacenId => idDespacho}.to_json, :Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json'\n k += 1\n end\n necesario -= k\n end \n end\n j += 1\n end\n i += 1\n end \n end\n #Enviamos lo restante\n while restante > 0\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'GET' + idDespacho + sku.to_s\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n stock = RestClient.get 'http://integracion-2016-prod.herokuapp.com/bodega/stock', {:Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json', :params => {:almacenId => idDespacho, :sku => sku, :limit => restante}}\n stockParseado = JSON.parse stock\n puts stockParseado.length\n k = 0\n while k < stockParseado.length\n idProducto = stockParseado[k][\"_id\"]\n direccion = 'internacional'\n orden = RestClient.get 'http://moto.ing.puc.cl/oc/obtener/' + oc\n ordenParseada = JSON.parse orden\n precio = ordenParseada[0][\"precioUnitario\"]\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'DELETE' + idProducto + direccion + precio.to_s + oc\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n RestClient::Request.execute(method: :delete, url: 'http://integracion-2016-prod.herokuapp.com/bodega/stock', payload: {:productoId => idProducto, :direccion => direccion, :precio => precio, :oc => oc}, headers: {Authorization: 'INTEGRACION grupo1:'+clave})\n k += 1\n end\n restante -= k\n end\n\n #(Orden.find_by idOrden: oc).update(estado: \"despachada\")\n #Aquí termina el if internacional \n else\n almacenRecepcion = (IdGrupoProduccion.find_by idGrupo: cliente).idBodegaRecepcion\n #Vemos si hay lo suficiente en el almacén de despacho\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'GET' + idDespacho\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n temp = RestClient.get 'http://integracion-2016-prod.herokuapp.com/bodega/skusWithStock', {:Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json', :params => {:almacenId => idDespacho}}\n contenido = JSON.parse temp\n i=0\n necesario = cantidad\n restante = cantidad\n while contenido[i].nil? == false do\n sku_ = Integer(contenido[i][\"_id\"])\n total = Integer(contenido[i][\"total\"])\n if sku_ == sku\n if total >= cantidad\n necesario = 0\n restante = 0\n while cantidad > 0\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'GET' + idDespacho + sku.to_s\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n stock = RestClient.get 'http://integracion-2016-prod.herokuapp.com/bodega/stock', {:Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json', :params => {:almacenId => idDespacho, :sku => sku, :limit => cantidad}}\n stockParseado = JSON.parse stock\n puts stockParseado.length\n k = 0\n puts cantidad\n while k < stockParseado.length\n idProducto = stockParseado[k][\"_id\"]\n orden = RestClient.get 'http://moto.ing.puc.cl/oc/obtener/' + oc\n ordenParseada = JSON.parse orden\n precio = ordenParseada[0][\"precioUnitario\"]\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'POST' + idProducto + almacenRecepcion\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n RestClient.post 'http://integracion-2016-prod.herokuapp.com/bodega/moveStockBodega', {:productoId => idProducto, :almacenId => almacenRecepcion, oc => oc, precio => precio}.to_json, :Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json'\n k += 1\n end\n cantidad -= k\n end\n else\n necesario = cantidad - total\n restante = cantidad - total\n while total > 0\n #Despachamos lo que teniamos en despacho\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'GET' + idDespacho + sku.to_s\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n stock = RestClient.get 'http://integracion-2016-prod.herokuapp.com/bodega/stock', {:Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json', :params => {:almacenId => idDespacho, :sku => sku, :limit => total}}\n stockParseado = JSON.parse stock\n puts stockParseado.length\n k = 0\n while k < stockParseado.length\n idProducto = stockParseado[k][\"_id\"]\n orden = RestClient.get 'http://moto.ing.puc.cl/oc/obtener/' + oc\n ordenParseada = JSON.parse orden\n precio = ordenParseada[0][\"precioUnitario\"]\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'POST' + idProducto + almacenRecepcion\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n RestClient.post 'http://integracion-2016-prod.herokuapp.com/bodega/moveStockBodega', {:productoId => idProducto, :almacenId => almacenRecepcion, oc => oc, precio => precio}.to_json, :Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json'\n k += 1\n end\n total -= k\n end\n #@necesario = necesario\n end\n else\n necesario = cantidad\n restante = cantidad\n end\n i += 1\n end\n while necesario > 0 do\n i = Almacen.first.id\n #recorremos los almacenes buscando el producto\n nAlmacenes = Almacen.last.id\n while i <= nAlmacenes \n id = Almacen.find(i).almacenId\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'GET' + id\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n temp = RestClient.get 'http://integracion-2016-prod.herokuapp.com/bodega/skusWithStock', {:Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json', :params => {:almacenId => id}}\n contenido = JSON.parse temp\n j=0\n while contenido[j].nil? == false do\n sku_ = Integer(contenido[j][\"_id\"])\n total = Integer(contenido[j][\"total\"])\n if sku_ == sku && id != idDespacho\n #Encontramos el producto\n signature = 'GET' + id.to_s + sku_.to_s\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n if necesario != 0\n temp = RestClient.get 'http://integracion-2016-prod.herokuapp.com/bodega/stock', {:Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json', :params => {:almacenId => id, :sku => sku_, :limit => necesario}}\n productos = JSON.parse temp\n @productos = productos\n puts productos\n k = 0\n while k < productos.length\n idProducto = productos[k][\"_id\"]\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'POST' + idProducto + idDespacho\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n RestClient.post 'http://integracion-2016-prod.herokuapp.com/bodega/moveStock', {:productoId => idProducto, :almacenId => idDespacho}.to_json, :Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json'\n k += 1\n end\n necesario -= k\n end \n end\n j += 1\n end\n i += 1\n end \n end\n #Enviamos lo restante\n while restante > 0\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'GET' + idDespacho + sku.to_s\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n stock = RestClient.get 'http://integracion-2016-prod.herokuapp.com/bodega/stock', {:Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json', :params => {:almacenId => idDespacho, :sku => sku, :limit => restante}}\n stockParseado = JSON.parse stock\n puts stockParseado.length\n k = 0\n while k < stockParseado.length\n idProducto = stockParseado[k][\"_id\"]\n orden = RestClient.get 'http://moto.ing.puc.cl/oc/obtener/' + oc\n ordenParseada = JSON.parse orden\n precio = ordenParseada[0][\"precioUnitario\"]\n key = '.k3GBP9YYZmzWCr'\n hmac = HMAC::SHA1.new(key)\n signature = 'POST' + idProducto + almacenRecepcion\n hmac.update(signature)\n clave = Base64.encode64(\"#{hmac.digest}\")\n RestClient.post 'http://integracion-2016-prod.herokuapp.com/bodega/moveStockBodega', {:productoId => idProducto, :almacenId => almacenRecepcion, oc => oc, precio => precio}.to_json, :Authorization => 'INTEGRACION grupo1:' + clave, :content_type => 'application/json'\n k += 1\n end\n restante -= k\n end\n #(Orden.find_by idOrden: oc).update(estado: \"despachada\")\n end\n\n end",
"def grasa(sexo,peso,talla)\n\t\t@grasa = 1.2*imc(peso,talla)+0.23*@edad-10.8*sexo-5.4\n\tend",
"def asignar_titulo_propiedad()\n \n end",
"def grasa\n\t\t1.2 * imc + 0.23 * @edad - 10.8 * ( sexo ? 1 : 0) - 5.4\n\tend",
"def przydzial\n @zgloszenie = Zgloszenie.find(@zgloszeny.id)\n users_list = User.where(ispracownik:true).pluck(:id)\n l = users_list.size\n i = 0\n @x = 0\n\n Zgloszenie.order(\"created_at desc\").each do |zgloszeny|\n for i in users_list\n if i == zgloszeny.pracownikid\n @x += 1\n User.update(i, :praca => @x)\n end\n end\n end\n\n @worker = User.where(admin:false).order(:praca).pluck(:id).first\n Zgloszenie.update(@zgloszenie, :pracownikid => @worker)\n\n end",
"def An()\n return @RownanieWielomianu.first.Wspolczynnik\n end",
"def rescatar\n self.estado_id = 1 #salida si lo creo, entrada/foliado si lo redirijo\n self.estado_id = 3 if self.trazas.count(:conditions => 'movimiento_id in (2,7,8)') > 0\n if self.origen.externo\n RAILS_DEFAULT_LOGGER.info \"devolviendo de origen externo #{self.origen.to_label} a #{self.documento.buzon}\"\n self.buzon_id = self.documento.buzon_id\n else\n self.buzon_id = self.origen_id\n end\n self.add_traza(current_user.id, 14, current_user.puesto.buzon_id)\n self.save!\n end",
"def porc_grasa\n\t\t(1.2 * self.indice_masa_corporal + 0.23 * edad - 10.8 * sexo - 5.4).round(1)\n\tend",
"def private; end",
"def partido\n localidad.partido\n end",
"def procesar_posible_pago(jugadalot, entrada)\n entrada = entrada[1..(entrada.size-1)] # \".250 => 250\" ok sacar monto apostado ok.\n apostado = entrada.to_f\n \n jugadas = Jugadalot.where(:ticket_id => jugadalot) || []\n \n if (jugadas == []) # esto es posible en rails probado ok. Si no hay jugadas returnal nil para que envie mensaje de realizar jugadas primero ok ted. Ver la logica del progrma que invoca esta funcion ok.\n return nil \n\n else\n #Hay jugadas para procesar la formula del parlay de posible pago ok:\\\n #ganancia = apostado * [coeficiente_jugada_parley_1] * [coeficiente_jugada_parley_2] * [coeficiente_jugada_parley_n] - apostado\n coeficiente_jugada_parley = []\n \n jugadas.each do |jugada|\n b = jugada.ml.to_s\n if( b[0] == \"-\" )# < 0 # -125 mando gavela macho, -110, -170\n coeficiente = (1.to_f + (100.to_f / b.to_f.abs)).to_f.round(4) # trabajar a 4 cifras decimales.\n else\n coeficiente = (1.to_f + ((b.to_f.abs) / 100.to_f)).to_f.round(4) # trabajar a 4 cifras decimales.\n end\n #puts coeficiente\n #debugger\n coeficiente_jugada_parley << coeficiente.to_f.round(4)\n end\n\n #multiplicar los elementos del array para obtener el coeficiente resultante\n #setear algunos casting primero, de string a int para multiplicar con inject\n #coeficiente_jugada_parley.map!(&:to_f) #inject(:*).round(4)\n # coeficiente_resultante = coeficiente_jugada_parley.inject(:*).round(4) # multiplica todos los elementos del array #sacado link:https://stackoverflow.com/questions/7050869/ruby-multiply-all-elements-of-an-array \n \n \n resultante_multiplicar = 1.to_f # 1 es el elemento neutro de la multiplicacion ok ted.\n \n coeficiente_jugada_parley.each do |coeficiente|\n resultante_multiplicar = (resultante_multiplicar.to_f * coeficiente.to_f.round(4)).round(4)\n end\n \n coeficiente_resultante = resultante_multiplicar.to_f.round(4)\n\n ganacia = ( (apostado.to_f * coeficiente_resultante.to_f) - apostado.to_f).to_i\n #ganacia = 18\n acobrar = (apostado + ganacia).to_i\n #lo de abajo comentado es para debug only ok. ted.\n #return apostado, \"#{ganacia}, ticketid:#{jugadalot}, ticketlines: #{jugadas.all.count}, apostado:#{apostado}, coeficiente:#{coeficiente_resultante}, aray:#{coeficiente_jugada_parley.join(\"|\")}, jugadas: #{jugadas.all.count}\", acobrar\n return apostado.to_i, ganacia, acobrar\n\n end # fin del if else end block ok\n \n\n end",
"def setear_fijos_arbol\n # @incisos = Inciso.all\n # @partidas_principales = PartidaPrincipal.all\n # @partidas_parciales = PartidaParcial.all \n @clases = Clase.where(\"fecha_de_baja IS NULL\")\n @bienes_de_consumo = BienDeConsumo.where(\"fecha_de_baja IS NULL\")\n end",
"def casePasACoteArbre\n\n newStatutVide = StatutVide.new(VIDE)\n newStatutArbre = StatutArbre.new(ARBRE)\n grille=@grille.grille\n\n for i in 0..grille.length-1\n for j in 0..grille.length-1\n ok = true\n if (grille[i][j].statutVisible == newStatutVide)\n\n if (i-1 >= 0 && grille[i-1][j].statut == newStatutArbre) || (j-1 >= 0 && grille[i][j-1].statut == newStatutArbre) || (i+1 <= grille.length-1 && grille[i+1][j].statut == newStatutArbre) || (j+1 <= grille.length-1 && grille[i][j+1].statut == newStatutArbre)\n ok = false\n end\n\n return grille[i][j] if ok\n\n end\n end\n end\n\n return 0\n end",
"def set_poznamka\n @poznamka = Poznamka.find(params[:id])\n end",
"def adjourn_points_giocataend\r\n # at the end of the game remain to calculate the primiera\r\n player1 = @players[0]\r\n player2 = @players[1]\r\n hand1 = @carte_prese[player1.name]\r\n hand2 = @carte_prese[player2.name]\r\n prim_res_arr = calculate_primiera(hand1, hand2)\r\n @log.debug(\"Primiera of #{player1.name}:#{prim_res_arr[0]}, #{player2.name}: #{prim_res_arr[1]}\")\r\n # update points on all players\r\n ix = 0\r\n [player1, player2].each do |pl|\r\n points_info = @points_curr_segno[pl.name]\r\n points_info[:primiera] = prim_res_arr[ix]\r\n #calculate total\r\n tot = 0\r\n points_info.each do |k,v|\r\n next if k == :tot\r\n tot += v\r\n end\r\n points_info[:tot] = tot\r\n ix += 1\r\n end\r\n end",
"def llenar_productos\n self.productos = self.clase.descripcion unless self.clase.nil?\n end",
"def ingresar_detalle_en_venta(detalle_venta,venta)\n if venta[:esta_vacio]\n venta[:tope] = detalle_venta\n venta[:final] = detalle_venta\n venta[:esta_vacio] = false\n venta[:size] +=1\n venta[:max]-=1\n else\n final = venta[:final]\n final[:siguiente] = detalle_venta\n venta[:final] = detalle_venta\n venta[:size]+=1\n venta[:max]-=1\n end\nend",
"def dodaj_do_wyslania_po_akceptacji(jid,wiadomosc,typ)\n\twiad={:do => jid, :wiadomosc => wiadomosc, :typ => typ}\n\t@wiadomosci_do_wyslania << wiad\n end",
"def secuenciasugerida \n #recupera los hijos del padre de la cuenta a crear \n\t\thijos = Catalogo.where(\"padre_id = ? AND activo = ?\", idcuenta, true)\n\n #configuracion del nivel a crear\n\t\tidnivel = Catalogo.find_by(id: idcuenta).nivel_id\n\t\tnivelh = Nivel.find_by(id: idnivel).numnivel + 1\n\n nivel = Nivel.find_by(numnivel: nivelh)\n nrodigitos = nivel.nrodigitos\n nrodigitostotal = nivel.nrodigitostotal\n digito = 0\n aux = 0\n\n hijos.each do |e|\n \taux = e.codigo.last(nrodigitos).to_i\n \t\tif digito < aux\n\t\t\t\tdigito = aux\n \t\tend\n \tend\n \tdigito = digito + 1\n \tc =\"\"\n \tnrodigitos.times { c = c + \"0\" }\n \tc = c.to_s + digito.to_s \t\n \t\t\n #codigo sugerido\n \treturn c.last(nrodigitos).to_s\n\tend",
"def excede_control_de_pago_global()\n @sumatoria_posible_pago_todos_tickets_de_hoy_todos_parlay_global = 0 # inicializacionn de variable sumatoria en cero ok\n #La idea aqui es verificar si la sumatoria de posible pago de todas las jugadas de todos los tipos de tickets activos de hoy no excede el limite globar de riesgo del sistema ok\n \n #limite GLOBAL = 1 ADMINISTRATIVO OK Y TIPOJUGADA TAMBIEN MANUAL = GLOBAL OK TED. POPULATE IT IN DATABASE PRODUCTION OK:\n control_monto_max_pago_global = Controldepagogt.where(:tipojugada => \"global\" ).first.limiteglobal.to_i || 1 # setear un valor default ok \n\n t_ids = Ticket.today.where(:activo => \"si\").ids # todos los ticket actio de hoy con ese parlay ok\n \n @listado_sumatoria_posible_pago = Jugadalot.where(:ticket_id => t_ids)# postrges casting erro string ok .sum(:posiblepago).to_i\n \n if not @listado_sumatoria_posible_pago.nil?\n @listado_sumatoria_posible_pago.each do |jugada|\n @sumatoria_posible_pago_todos_tickets_de_hoy_todos_parlay_global += jugada.posiblepago.to_i\n end\n \n end\n \n \n #Sumar posible pago de esas jugadas de cada ticket parlay ok.\n# @sumatoria_posible_pago_todos_tickets_de_hoy_todos_parlay_global = 0\n# t.each do |ticket|\n# @sumatoria_posible_pago_todos_tickets_de_hoy_todos_parlay_global += Jugadalot.where(:ticket_id => ticket.id).last.posiblepago.to_i\n# end\n\n if @sumatoria_posible_pago_todos_tickets_de_hoy_todos_parlay_global.to_i <= control_monto_max_pago_global.to_i\n # si es menor todo ok\n false # no excede\n else\n true #si excede \n end\n\n\n end",
"def saveObject(params)\r\n \r\n @solicitudlabexa.usuario_id = params[:usuario][:identificador].to_i\r\n if params[:asignatura].nil?\r\n @solicitudlabexa.asignatura=Asignatura.new\r\n @solicitudlabexa.asignatura.titulacion_id=params[:titulacion][:titulacion_id] unless params[:titulacion].nil? \r\n @solicitudlabexa.asignatura.curso=params[:nivel]\r\n @solicitudlabexa.asignatura.id=0\r\n else\r\n @solicitudlabexa.asignatura_id = params[:asignatura][:id].to_i\r\n end\r\n @solicitudlabexa.fechasol=Date.today\r\n @solicitudlabexa.npuestos=params[:npuestos]\r\n @solicitudlabexa.curso=params[:nivel].to_s == '0' ? 'optativa' : params[:nivel].to_s\r\n @solicitudlabexa.comentarios=Iconv.conv('ascii//translit//ignore', 'utf-8', params[:comentarios].to_s)\r\n @solicitudlabexa.horaini=params[:horaini][:comienzo]\r\n @solicitudlabexa.horafin=params[:horafin][:fin]\r\n @solicitudlabexa.asignado=\"N\"\r\n \r\n pref=\"\"\r\n @especiales=Laboratorio.where('especial=?',\"t\").to_a \r\n for especial in @especiales do\r\n nombre=especial.ssoo.to_s\r\n if params[:\"#{nombre}\"] and params[:\"#{nombre}\"].to_s!='in'\r\n pref+=especial.nombre_lab.to_s+'-'+nombre+'-'+params[:\"#{nombre}\"]+\";\"\r\n end\r\n end\r\n @solicitudlabexa.preferencias=pref\r\n\r\n if params[:fecha]=~ /[0-3]?[0-9]\\-[0-1]?[0-9]\\-[0-9]{4}/\r\n @solicitudlabexa.fecha=formato_europeo(params[:fecha])\r\n else\r\n @solicitudlabexa.fecha=nil\r\n end\r\n end",
"def getArbol\r\n return @pila_a.last #puedes hacer getArbol sucesivos sin modificar nada en lo absoluto.\r\n end",
"def sigla; @nome; end",
"def obchoduj\r\n @weapon.length.times do |i|\r\n puts \"#{i + 1}) Jmeno:#{@weapon[i].jmeno},Sila #{@weapon[i].sila}, cena:#{@weapon[i].cena}\"\r\n end\r\n puts \"Vyber si zbran k nakupu. Mas momentalne #{@valecnik.gold} zlatych. Pro ukonceni stiskni enter\"\r\n volba = gets.to_i\r\n while volba != 0\r\n if @valecnik.gold < @weapon[volba - 1].cena\r\n puts \"Na nakup #{@weapon[volba - 1].jmeno} nemas dostatek penez. Vyber si jinou zbran. Pro ukonceni obchodovani stiskni enter\"\r\n volba = gets.to_i\r\n else\r\n @valecnik.zbran = @weapon[volba - 1]\r\n @valecnik.gold -= @weapon[volba - 1].cena\r\n puts \"Koupil jsi #{@valecnik.zbran.jmeno}.\"\r\n break\r\n end\r\n end\r\n end",
"def modelo_carne_build_data_right(doc, boleto, colunas, linhas)\n # LOGOTIPO do BANCO\n doc.image boleto.logotipo, x: (colunas[2] - 0.11), y: linhas[0]\n\n # Numero do banco\n doc.moveto x: colunas[4], y: linhas[0]\n doc.show \"#{boleto.banco}-#{boleto.banco_dv}\", tag: :grande\n\n # linha digitavel\n doc.moveto x: colunas[6], y: linhas[0]\n doc.show boleto.codigo_barras.linha_digitavel, tag: :media\n\n # local de pagamento\n doc.moveto x: colunas[2], y: linhas[1]\n doc.show boleto.local_pagamento\n\n # vencimento\n doc.moveto x: colunas[11], y: linhas[1]\n doc.show boleto.data_vencimento.to_s_br\n\n # cedente\n doc.moveto x: colunas[2], y: linhas[2]\n doc.show boleto.cedente\n\n # agencia/codigo cedente\n doc.moveto x: colunas[11], y: linhas[2]\n doc.show boleto.agencia_conta_boleto\n\n # data do documento\n doc.moveto x: colunas[2], y: linhas[3]\n doc.show boleto.data_documento.to_s_br if boleto.data_documento\n\n # numero documento\n doc.moveto x: colunas[3], y: linhas[3]\n doc.show boleto.documento_numero\n\n # especie doc.\n doc.moveto x: colunas[8], y: linhas[3]\n doc.show boleto.especie_documento\n\n # aceite\n doc.moveto x: colunas[9], y: linhas[3]\n doc.show boleto.aceite\n\n # dt processamento\n doc.moveto x: colunas[10], y: linhas[3]\n doc.show boleto.data_processamento.to_s_br if boleto.data_processamento\n\n # nosso numero\n doc.moveto x: colunas[11], y: linhas[3]\n doc.show boleto.nosso_numero_boleto\n\n # uso do banco\n ## nada...\n\n # carteira\n doc.moveto x: colunas[3], y: linhas[4]\n doc.show boleto.carteira\n\n # especie\n doc.moveto x: colunas[5], y: linhas[4]\n doc.show boleto.especie\n\n # quantidade\n doc.moveto x: colunas[7], y: linhas[4]\n doc.show boleto.quantidade\n\n # valor documento\n doc.moveto x: colunas[8], y: linhas[4]\n doc.show boleto.valor_documento.to_currency\n\n # valor do documento\n doc.moveto x: colunas[11], y: linhas[4]\n doc.show boleto.valor_documento.to_currency\n\n # Instruções\n doc.moveto x: colunas[2], y: linhas[5]\n doc.show boleto.instrucao1\n doc.moveto x: colunas[2], y: linhas[6]\n doc.show boleto.instrucao2\n doc.moveto x: colunas[2], y: linhas[7]\n doc.show boleto.instrucao3\n doc.moveto x: colunas[2], y: linhas[8]\n doc.show boleto.instrucao4\n doc.moveto x: colunas[2], y: linhas[9]\n doc.show boleto.instrucao5\n doc.moveto x: colunas[2], y: linhas[10]\n doc.show boleto.instrucao6\n\n # Sacado\n doc.moveto x: colunas[2], y: linhas[11]\n if boleto.sacado && boleto.sacado_documento\n doc.show \"#{boleto.sacado} - #{boleto.sacado_documento.formata_documento}\"\n end\n\n # Sacado endereço\n doc.moveto x: colunas[2], y: linhas[12]\n doc.show boleto.sacado_endereco.to_s\n\n # codigo de barras\n # Gerando codigo de barra com rghost_barcode\n if boleto.codigo_barras\n doc.barcode_interleaved2of5(boleto.codigo_barras, width: '10.3 cm', height: '1.2 cm', x: colunas[2],\n y: linhas[14])\n end\n end",
"def IniciaArea\n\t\t@Lojaq = Admloja.all\n\t\tif @Lojaq.size != 1\t# Se não houver exatamente um registro\n\t\t\t@loja = Admloja.all\n\t\t\t# @loja.delete.all\n\t\t\t# Admloja.delete\n\t\t\t@Novo = Admloja.new\n\t\telse\n\t\t\treturn\n\t\tend\n\n\t\t@Novo.nome = \"MINI LOJA VIRTUAL\"\n\t\t@Novo.cnpj = \"33014556000196\"\n\t\t@Novo.endereco = \"Rua José Dias, 1024\"\n\t\t@Novo.cidade = \"São José dos Campos\"\n\t\t@Novo.bairro = \"Jd. Aquarius\"\n\t\t@Novo.estado = \"SP\"\n\t\t@Novo.tel = \"1212341234\"\n\t\t@Novo.fax = \"1243214321\"\n\t\t@Novo.cel = \"1212345678\"\n\t\t@Novo.email = \"lojavirtual@modelo.com\"\n\t\t@Novo.password = \"175a6350f1f49ed49ab438ab6b2e0e45f6d3b8f9\"\t# senha\n\t\t@Novo.pagadm = 6\n\t\t@Novo.pagloja = 12\n\t\t@Novo.mcab = 1\n\t\t@Novo.maxsec = 0\n\t\t@Novo.maxdep = 0\n\t\t@Novo.upreco = 1\n\t\t@Novo.udesconto = 0\n\t\t@Novo.ufrete = 1\n\t\t@Novo.freefrete = 150\n\t\t@Novo.rodape = \"<strong> ESTE É O RODAPÉ DA LOJA VIRTUAL </STRONG>\"\n\t\t@Novo.cabecalho = '<div class=\"destaque\"><center>Aproveite as promoções da Loja Virtual! <br>Todos os produtos foram cuidadosamente selecionados pra você!<br>Conforto, Segurança e Tecnologia, <br>agora você encontra aqui!!!<br></div>'\n\t\t@Novo.cep = \"12345691\"\n\t\t@Novo.complemento = \"\"\n\t\t@Novo.cpostal = \"\"\t\t\n\t\t@Novo.save\n\t\treturn\n\tend",
"def test_01_dada_una_caja_de_ahorros_nueva_su_saldo_inicial_debe_ser_0_pesos\n assert_equal 0.pesos, @una_caja_de_ahorros_nueva.saldo\n end",
"def vrat_celkovy_soucet_vah\n soucet = 0\n @pole_vah.each do |prvek| \n soucet += prvek.to_i\n end\n return soucet\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def set_profilopazienti\n @profilopazienti = Profilopazienti.find(params[:id])\n end",
"def descuento_sueldo(sueldo, tipo_obrero)\n\tif tipo_obrero == 'o'\n\t\tsueldo - (sueldo * 0.12) #OCURRE A\n\telse\n\t\tsueldo - (sueldo * 0.15) #OCURRE B\n\tend\nend",
"def traktiNodon(nod, stato)\n\n objekto = {\"tipo\" => nod.name, \"filoj\" => [], \"tradukoj\" => {}, \"filNombro\" => 0}\n stato[\"super\"] << nod.name\n\n miaMarko = false\n\n if nod[\"mrk\"] != nil\n objekto[\"mrk\"] = nod[\"mrk\"]\n stato[\"marko\"] << nod[\"mrk\"]\n miaMarko = true\n end\n\n teksto = \"\"\n \n nod.children().each do |fil|\n\n if fil.name == \"kap\"\n novaKapo = traktiKapon(fil, stato)\n objekto[\"nomo\"] = novaKapo[\"nomo\"]\n objekto[\"tildo\"] = novaKapo[\"tildo\"]\n objekto[\"kapo\"] = novaKapo\n if nod.name == \"drv\"\n # Registri tradukojn en esperanton\n\t for nom in objekto[\"nomo\"].split(\", \")\n\t @esperantaj << fariSerchTradukon(nom, nom, stato[\"nomo\"], stato[\"artikolo\"][\"indekso\"], stato[\"marko\"].last, 0)\n\t end\n end\n elsif fil.name == \"uzo\"\n novaUzo = traktiUzon(fil, stato)\n \t if objekto[\"uzoj\"] == nil\n\t objekto[\"uzoj\"] = []\n\t end\n\t objekto[\"uzoj\"] << novaUzo\n elsif fil.name == \"gra\"\n fil.children().each do |fil2|\n if fil2.name == \"vspec\"\n objekto[\"vspec\"] = fil2.text\n end\n end\n elsif fil.name == \"subart\"\n objekto[\"filNombro\"] += 1\n objekto[\"filoj\"] << traktiNodon(fil, stato)\n elsif fil.name == \"drv\"\n objekto[\"filNombro\"] += 1\n objekto[\"filoj\"] << traktiNodon(fil, stato)\n elsif fil.name == \"subdrv\"\n objekto[\"filNombro\"] += 1\n objekto[\"filoj\"] << traktiNodon(fil, stato)\n elsif fil.name == \"snc\"\n objekto[\"filNombro\"] += 1\n stato[\"senco\"] = objekto[\"filNombro\"]\n novaSenco = traktiNodon(fil, stato)\n objekto[\"filoj\"] << novaSenco\n if novaSenco[\"mrk\"] != nil\n @indikiloDeMarko[novaSenco[\"mrk\"]] = objekto[\"filNombro\"].to_s\n end\n stato[\"senco\"] = 0\n elsif fil.name == \"subsnc\"\n objekto[\"filNombro\"] += 1\n novaSubSenco = traktiNodon(fil, stato)\n objekto[\"filoj\"] << novaSubSenco\n if novaSubSenco[\"mrk\"] != nil\n litero = (\"a\"..\"z\").to_a[objekto[\"filNombro\"]-1]\n numero = stato[\"senco\"].to_s + litero\n @indikiloDeMarko[novaSubSenco[\"mrk\"]] = numero\n end\n elsif fil.name == \"dif\"\n novaDifino = traktiDifinon(fil, stato)\n objekto[\"filoj\"] << novaDifino\n elsif fil.name == \"rim\"\n novaRimarko = traktiRimarkon(fil, stato)\n objekto[\"filoj\"] << novaRimarko\n elsif fil.name == \"ref\"\n stato[\"refspac\"] = objekto[\"filoj\"].count > 0\n novaRefo = traktiRefon(fil, stato)\n objekto[\"filoj\"] << novaRefo\n elsif fil.name == \"refgrp\"\n stato[\"refspac\"] = objekto[\"filoj\"].count > 0\n novaRefgrupo = traktiRefgrupon(fil, stato)\n objekto[\"filoj\"] << novaRefgrupo\n elsif fil.name == \"ekz\"\n novaEkzemplo = traktiEkzemplon(fil, stato)\n #teksto += novaEkzemplo[\"teksto\"]\n\t objekto[\"filoj\"] << novaEkzemplo\n elsif fil.name == \"trd\"\n traktiTradukon(fil, stato)\n elsif fil.name == \"trdgrp\"\n traktiTradukGrupon(fil, stato)\n elsif fil.name == \"text\"\n #puts \"teksto: \" + fil.text + \"|\"\n #objekto[\"filoj\"] << {\"tipo\" => \"teksto\", \"teksto\" => fil.text}\n elsif fil.name == \"frm\"\n novaFormulo = traktiFormulon(fil, stato)\n\t teksto += novaFormulo[\"teksto\"]\n else\n objekto[\"filoj\"] << traktiNodon(fil, stato)\n end\n end\n\n for fil in objekto[\"filoj\"]\n if fil[\"teksto\"] != nil\n if fil[\"tipo\"] == \"refo\" or fil[\"tipo\"] == \"refgrupo\"\n\t teksto += \" \"\n\t end\n teksto += fil[\"teksto\"]\n end\n end\n\n # atendu ghis la fino de drv antau enmeti tradukojn el ekzemploj -\n # tiuj ghenerale rilatas al dirajhoj, ke ne estas baza vortoj por serchi\n if stato[\"super\"].count == 1 and stato[\"ekzTradukoj\"] != []\n for lng, tradoj in stato[\"ekzTradukoj\"]\n for trad in tradoj\n\t stato[\"artikolo\"][\"tradukoj\"][lng] << trad\n\t end\n end\n\n stato[\"ekzTradukoj\"] = {}\n end\t \t \n\n if miaMarko then stato[\"marko\"].pop end\n\n #objekto[\"teksto\"] = teksto\n stato[\"super\"].pop\n return objekto\nend",
"def set_precio_boleto\n\t@precio_boleto = PrecioBoleto.find(params[:id])\n\tend",
"def topsman_periphacitis_urosteon()\n end",
"def mostra_tudo\n apius.mostra_resumo\n apide.mostra_resumo\n apifr.mostra_resumo\n apimt.mostra_resumo\n apies.mostra_resumo\n apigm.mostra_resumo\n apibc.mostra_resumo\n end",
"def set_pozi\n @pozi = Pozi.find(params[:id])\n end",
"def deco_pos; end",
"def show\n #訪問\n @houmons = @kofu.houmons.all\n @houmon = @kofu.houmons.build\n \n #訪問回数の自動セット\n @houmon.houmon_su = @houmons.length + 1\n @houmon.build_tenko\n @houmon.build_zaitakufuzai\n \n #点検結果\n @tenkenkekka = @houmon.tenkenkekka\n if @tenkenkekka.nil?\n @tenkenkekka = @houmon.build_tenkenkekka\n end\n \n #問診\n @monshin = @tenkenkekka.monshin\n if @monshin.nil?\n @monshin = @tenkenkekka.build_monshin\n #契約種別が011ならば問診未実施理由自動登録\n if @kofu.keiyaku.keiyakushubetsu_code == \"011\"\n @monshin.jisshi_umu = 2 \n @monshin.mijisshi_riyu = \"街路灯\"\n end\n end\n \n #屋内\n @okunai = @tenkenkekka.okunai\n if @okunai.nil?\n @okunai = @tenkenkekka.build_okunai\n #契約種別が011ならば屋内未実施理由自動登録\n if @kofu.keiyaku.keiyakushubetsu_code == \"011\" \n @okunai.jisshi_umu = 2\n @okunai.mijisshi_riyu = \"街路灯\"\n end\n end\n #屋外\n @okugai = @tenkenkekka.okugai\n if @okugai.nil?\n @okugai = @tenkenkekka.build_okugai\n end\n #測定値\n @sokutei = @tenkenkekka.sokutei\n if @sokutei.nil?\n @sokutei = @tenkenkekka.build_sokutei\n end\n \n \n end",
"def valor_energetico\n (@proteinas * 4) + (@glucidos * 4) + (@grasas * 9)\n end",
"def set_poliza\n @poliza = Poliza.find(params[:id])\n end",
"def set_poliza\n @poliza = Poliza.find(params[:id])\n end",
"def comprar_titulo_propiedad\n comprado = false\n \n coste_compra = @casilla_actual.coste\n \n if coste_compra < @saldo\n \n @casilla_actual.titulo.propietario = self\n \n comprado = true\n @propiedades << @casilla_actual.titulo\n \n modificar_saldo (-coste_compra)\n \n end\n \n return comprado\n end",
"def tas_poser_1_carte joueur\n # Examine tous les tas déjà posés un par un\n self.ta12s.each do |tas|\n # Abandonne l'examen des différents tas quand plus qu'une carte\n break if joueur.cartes.size == 1\n # Evite de compléter la tierce franche lors de la 1° pose\n unless joueur.a_atteint_51?\n next if tas.nom_joueur == joueur.nom + \"_tf\"\n end\n # Regarde si on peut ajouter une carte au tas\n joueur.cartes.each do |carte|\n # Regarde si la carte peut aller sur le tas\n if tas.complete_le_tas? carte\n type = tas.combinaison.type\n # Pose la carte\n self.traces << \" tas <= #{tas.to_s} + [ #{carte.to_s} ]\"\n poser_sur_tas joueur, tas, carte\n # On ne peut plus compléter le tas si c'est une série de plus de 3 cartes\n break if tas.cartes.size > 3\n # on ne peut plus compléter le tas si ce n'est pas une série\n break if type != :serie\n end\n end\n end\n end",
"def celebration; end",
"def initialize(cliente_ruc_o_cedula, tarifa_servicio)\n\n super()\n unless cliente_ruc_o_cedula.blank?\n if cliente_ruc_o_cedula.include?\"RUC\"\n @t_cliente = TEmpresa.find_by_rif(cliente_ruc_o_cedula).t_cliente\n else\n @t_cliente = TPersona.find_by_cedula(cliente_ruc_o_cedula).t_cliente\n end\n end\n @tarifa_servicio = TTarifaServicio.find_by_codigo(tarifa_servicio) unless tarifa_servicio.blank?\n @cliente_ruc_o_cedula = cliente_ruc_o_cedula\n @tarifa_servicio = tarifa_servicio\n @i = 1\n # @t_recibo = t_recibo\n # @t_factura = t_factura\n # @t_resolucion = @t_factura.t_resolucion\n # @t_cliente = t_cliente\n # @t_empresa = @t_cliente.persona.try(:rif) ? @t_cliente.persona : nil\n # @t_persona = @t_cliente.persona.try(:cedula) ? @t_cliente.persona : nil\n # @t_otro = @t_cliente.persona.try(:identificacion) ? @t_cliente.persona : nil\n @meses = [1 => \"Enero\", 2 => \"Febrero\", 3 => \"Marzo\", 4 => \"Abril\", 5 => \"Mayo\", 6 => \"Junio\", 7 => \"Julio\", 8 => \"Agosto\", 9 => \"Septiembre\", 10 => \"Octubre\", 11 => \"Noviembre\", 12 => \"Diciembre\"]\n font_size 10\n document_content\n end",
"def ligar #Metodo/função da classe Carro\n puts 'O carro está pronto para iniciar o trajeto.'\n end",
"def verifcar_alguna_pelea_abierta_antes_pago_any_ticket (ticket)\n #todas peleas cerrada implica cero peleas abiertas ok.\n\n @jugadalots = Jugadalot.where(:ticket_id => ticket.id) # todas las jugadas de ese ticket\n @alguna_pelea_abierta = false\n @peleas_abierta = [] # listado de peleas cerradas array\n\n @jugadalots.each do |jugada|\n \n #verifcar que todas las jugadas de ese ticket esten cerrada (peleas cerradas de ese ticket de esa fecha de esa lina de ese dia ok)\n linea_pelea = Lineat.by_day(jugada.created_at.to_date).where(:pelea => jugada.pelea.to_i).first || [] # \n if linea_pelea.status == \"abierta\"\n @peleas_abierta << linea_pelea.pelea # 3, 4 etc cerradas\n end\n \n end\n\n if @peleas_abierta.empty? # si esta vacio no hay niguna pelea cerrada\n return false \n else\n return @peleas_abierta # retorna las peleas abiertas\n end \n\n\n end",
"def pontosanunciante\n\n\t\tUsuario.find(self.id_usuario).meuspontos\n\n\tend",
"def save_atributos\n\n unless @pre.nil?\n @pre[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@pre[:valor][key],campo:'precio')\n end\n end\n\n unless @compraAtributo.nil?\n @compraAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@compraAtributo[:valor][key],campo:'compra')\n end\n end\n\n unless @polizaAtributo.nil?\n @polizaAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@polizaAtributo[:valor][key],campo:'poliza')\n end\n end\n\n unless @tipovehiculoAtributo.nil?\n @tipovehiculoAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@tipovehiculoAtributo[:valor][key],campo:'tipovehiculo')\n end\n end\n\n unless @tipoproductoAtributo.nil?\n @tipoproductoAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@tipoproductoAtributo[:valor][key],campo:'tipoproducto')\n end \n end\n \n unless @aseguradoraAtributo.nil?\n @aseguradoraAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@aseguradoraAtributo[:valor][key],campo:'aseguradora')\n end\n end\n \n unless @destacadoAtributo.nil?\n @destacadoAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@destacadoAtributo[:valor][key],campo:'destacado')\n end\n end\n\n unless @vigenciaAtributo.nil?\n @vigenciaAtributo[:llave].each do |key,value|\n Atributo.create(producto_id:self.id,llave:value,valor:@vigenciaAtributo[:valor][key],campo:'vigencia')\n end\n end\n\n end",
"def obtener\narray = Tarea.all\n \n @@tareas = Array.new\n array.each{|x| @@tareas.push(x) if /#{@@usuario}/.match(x[\"title\"])}\n\n @@tareas.each do |x|\nstring = x[\"title\"].split\n string.pop\nx[\"title\"] = string.join(\" \")\n\n\n end\n #esto es para que no quede una tarea vacia al principio, la cual es la correspondiente login\n@@tareas.shift\n @@tareas\n\nend",
"def prox()\n\n # Aumenta la frecuencia de acuerdo a la jugada actual del oponente\n if @oponente.getActual().is_a?(Piedra)\n @contadores[:Piedra] = @contadores[:Piedra] + 1\n elsif @oponente.getActual().is_a?(Papel)\n @contadores[:Papel] = @contadores[:Papel] + 1\n elsif @oponente.getActual().is_a?(Tijera)\n @contadores[:Tijera] = @contadores[:Tijera] + 1\n elsif @oponente.getActual().is_a?(Lagarto)\n @contadores[:Lagarto] = @contadores[:Lagarto] + 1\n elsif @oponente.getActual().is_a?(Spock)\n @contadores[:Spock] = @contadores[:Spock] + 1\n end\n\n # Crea una lista con las frecuencias acumuladas\n suma = 0\n acumulado = []\n @contadores.each do |jugada, repeticion|\n suma = suma + repeticion\n acumulado.push(suma)\n end\n\n # Elige un numero al azar entre 0 y la frecuencia total menos uno\n index = $random.rand(0..suma)\n \n # De acuerdo al numero elegido al azar selecciona una jugada\n if index.between?(0, acumulado[0])\n @proxima = Piedra.new()\n elsif index.between?(acumulado[0], acumulado[1])\n @proxima = Papel.new()\n elsif index.between?(acumulado[1], acumulado[2])\n @proxima = Tijera.new()\n elsif index.between?(acumulado[2], acumulado[3])\n @proxima = Lagarto.new()\n elsif index.between?(acumulado[3], acumulado[4])\n @proxima = Spock.new()\n end\n\n return @proxima\n end",
"def stahnoutpdfko \n @pdfko = Vlozitpdf.find(:first, :conditions =>[\"hashString = ?\",params[:hashString]])\n @hostname = self.request.host\n\n if @pdfko.tisk && @pdfko.kopirovat\n @opravneni = 11\n elsif !@pdfko.tisk && @pdfko.kopirovat\n @opravneni = 10\n elsif @pdfko.tisk && !@pdfko.kopirovat\n @opravneni = 01\n else\n @opravneni = 00\n end \n\n @velikostPapiru = \"A4\"\n @soubor = @pdfko.soubor_file_name\n @footerText = @pdfko.paticka\n @username = fel_id[:user_id] \n\n if params[:is_free].present? \n if params[:is_free] == \"free\" \n if @pdfko.distribuce == \"Zdarma pro všechny\"\n if fel_id[:user_id].nil?\n @username = \"anonym\"\n end\n else\n logger.info \"Nepovoleno\"\n session[:hash_string] = @pdfko.hashString\n # přistupuje přes free adresu na dokument, který není určen pro stažení zdarma\n redirect_to :action => :nepovoleno\n return\n end\n else\n raise ActionController::RoutingError.new(\"Not Found\")\n end\n end\n\n if @pdfko.distribuce == \"Placeně\"\n logger.info \"placená distribuce\"\n paid = false\n if fel_id[:user_id].nil?\n session[:hash_string] = @pdfko.hashString\n # přistupuje přes free adresu na dokument, který není určen pro stažení zdarma\n redirect_to :action => :nepovoleno \n return\n else\n user = User.find_by_username(fel_id[:user_id])\n if user\n purchases = Purchase.where(\"user_id = ?\", user.id)\n end\n if !purchases.nil?\n logger.info \"uvnitř purchases\" \n purchases.each do |purchase| \n if purchase.pdf_id == @pdfko.id && !purchase.purchased_at.nil?\n logger.info \"paid true for #{@pdfko.id} and #{purchase.id}\"\n paid = true\n end\n end\n end\n end\n\n if paid == false\n session[:hash_string] = @pdfko.hashString\n session[:pdf_id] = @pdfko.id\n # přistupuje přes free adresu na dokument, který není určen pro stažení zdarma\n redirect_to :action => :nezaplaceno\n return\n end \n end\n\n pdf = Prawn::Document.generate(\"#{Rails.root}/tmp/pdf/tmp_#{@username}_#{@soubor}\", :page_size => @velikostPapiru, :page_layout => :portrait, :left_margin => 0, :right_margin => 0, :top_margin => 0, :bottom_margin => 0) do |pdf|\n pdf.font @@FONT\n \n #------------------------------------------------------------------------------------------------\n # VYPOCET A UMISTENI SIKMEHO VODOTISKU NA STRED STRANKY\n #------------------------------------------------------------------------------------------------\n _delkaTextu = pdf.width_of(@username, :size => @@VELIKOSTPISMAU)\n _vyskaTextu = @@VELIKOSTPISMAU\n page_width = pdf.bounds.bottom_right[0]\n page_height = pdf.bounds.top_left[1]\n \n _textXpozice = (page_width/2) - (_delkaTextu/2)\n _textYpozice = (page_height/2) - (_vyskaTextu/2)\n \n #---posun stredu po rotaci\n _uhloprickaPul = Math.sqrt(_delkaTextu * _delkaTextu + _vyskaTextu * _vyskaTextu) / 2\n\n _vertikalniPosun = Math.sin(@@UHEL) * _uhloprickaPul - (_vyskaTextu / 2)\n _finalYpozice = _textYpozice - _vertikalniPosun\n\n _horizontalniPosun = (_delkaTextu / 2) - Math.cos(@@UHEL) * _uhloprickaPul\n _finalXpozice = _textXpozice + _horizontalniPosun\n\n pdf.fill_color @@BARVAPISMA\n pdf.draw_text(@username, :at => [_finalXpozice, _finalYpozice], :size => @@VELIKOSTPISMAU, :rotate => @@UHEL)\n \n #------------------------------------------------------------------------------------------------\n # UMISTENI VODOTISKU DO HLAVICKY A PATICKY STRANKY\n #------------------------------------------------------------------------------------------------ \n datum = Time.new\n datumFormatted = datum.strftime(\"%d.%m.%Y %H:%M:%S\")\n\n headerText = \"Staženo uživatelem #{@username} z #{@hostname}, \" + datumFormatted\n if @footerText == 0\n @footerText = headerText\n end\n\n pdf.text_box(@footerText, :size => 11, :at => [0,20], :align => :center)\n pdf.text_box(headerText, :size => 11, :at => [0, page_height - 15], :width => page_width, :align => :center)\n pdf.fill_color \"ffffff\"\n pdf.text_box(headerText, :size => 1, :at => [0, page_height - 30], :width => page_width, :align => :center)\n\n for i in (1..4)\n @soubor.chop!\n end\n \n end #konec generovani PDF\n \n #--generator nahodneho hesla owner_pw\n @pdfHeslo = generujHeslo\n \n #--nastaveni opravneni pdf\n case @opravneni\n when 00 #vse zakazano\n @setPerm = \"\"\n when 01 #pouze tisk\n @setPerm = \"allow printing\"\n when 10 #pouze kopirovani\n @setPerm = \"allow copycontents\"\n when 11 #tisk a kopirovani\n @setPerm = \"allow printing copycontents\"\n end\n \n # Vložení vodoznaku do pozadí dokumentu\n # system(\"pdftk #{Rails.root}/public/pdf/#{@soubor}.pdf background #{Rails.root}/tmp/pdf/tmp_#{@username}_#{@soubor}.pdf output #{Rails.root}/tmp/pdf/#{@soubor}_#{@username}.pdf owner_pw #{@pdfHeslo} #{@setPerm}\")\n # Vložení vodoznaku do popředí dokumentu\n system(\"pdftk #{Rails.root}/public/pdf/#{@soubor}.pdf stamp #{Rails.root}/tmp/pdf/tmp_#{@username}_#{@soubor}.pdf output #{Rails.root}/tmp/pdf/#{@soubor}_#{@username}.pdf owner_pw #{@pdfHeslo} #{@setPerm}\")\n\n system(\"rm -rf #{Rails.root}/tmp/pdf/tmp_#{@username}_#{@soubor}.pdf\")\n \n send_file \"#{Rails.root}/tmp/pdf/#{@soubor}_#{@username}.pdf\", :type => \"application/pdf\"\n\n end",
"def set_prace_polozka\n @prace_polozka = PracePolozka.find(params[:id])\n end",
"def set_zgloszeny\n @zgloszeny = Zgloszenie.find(params[:id])\n end",
"def changerEnVide\n\t\t@couleur=-1\n\tend"
] | [
"0.6882641",
"0.6487756",
"0.62509865",
"0.62468296",
"0.6132075",
"0.6107403",
"0.60560375",
"0.5961454",
"0.5881994",
"0.58724505",
"0.58693266",
"0.5839062",
"0.5838738",
"0.58377206",
"0.58095086",
"0.57931495",
"0.578898",
"0.5776171",
"0.57430786",
"0.57404333",
"0.56999946",
"0.5691722",
"0.5652148",
"0.56514347",
"0.56492484",
"0.56361544",
"0.56336606",
"0.563095",
"0.56292987",
"0.56262314",
"0.56207764",
"0.55780214",
"0.55719537",
"0.5571177",
"0.55703384",
"0.55656964",
"0.55650246",
"0.5538748",
"0.5526532",
"0.55230194",
"0.55204844",
"0.5517646",
"0.5513581",
"0.5510345",
"0.5509254",
"0.550817",
"0.5504924",
"0.5497546",
"0.5494009",
"0.54937565",
"0.5493234",
"0.54863966",
"0.5481803",
"0.5481559",
"0.5480115",
"0.54781395",
"0.54674506",
"0.5459819",
"0.54594827",
"0.5455238",
"0.54520905",
"0.5450142",
"0.5447858",
"0.5443915",
"0.5442817",
"0.5440709",
"0.54314715",
"0.5428654",
"0.5428611",
"0.54258335",
"0.5424747",
"0.5420907",
"0.5420907",
"0.5420907",
"0.5420907",
"0.54024583",
"0.5400322",
"0.5397469",
"0.5390811",
"0.53754014",
"0.53717697",
"0.53701466",
"0.5355503",
"0.53425986",
"0.5339601",
"0.53323245",
"0.53323245",
"0.53304034",
"0.53290397",
"0.53240544",
"0.53199726",
"0.53127277",
"0.5311131",
"0.53110975",
"0.5310852",
"0.5310746",
"0.5306175",
"0.5302681",
"0.53025806",
"0.5299866",
"0.52940804"
] | 0.0 | -1 |
after entering login credentials, see if we can't authenticate the user. if not, present them a message and redirect back to the login page. On success, remember them in the session. | def login
user = User.find_by_userid(params[:session][:userid])
if user && user.authenticate(params[:session][:password])
session[:remember_token] = user.id
session[:last_seen] = Time.now
if user.authorizationlevel == 1
redirect_to '/documents'
elsif user.authorizationlevel == 2
redirect_to '/documents'
elsif user.authorizationlevel > 2
redirect_to '/documents'
else
redirect_to '/'
end
else
flash[:error] = 'Invalid Login'
redirect_to '/sessions'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate_user\n unless logged_in?\n store_location\n redirect_to new_session_url\n flash[:info] = \"You must be authenticated to perform this action.\"\n end\n end",
"def authenticate_login\n if session[:user].nil? #There's definitely no user logged in\n flash[:notice] = \"<div class=\\\"flash_failure\\\"> You are not logged in!</div>\"\n redirect_to :action => \"login\", :controller => \"../browse\"\n else #there's a user logged in, but what type is he?\n @user = User.find(session[:user][:id]) # make sure user is in db, make sure they're not spoofing a session id\n if @user.nil?\n flash[:notice] = \"<div class=\\\"flash_failure\\\"> You are not logged in!</div>\"\n redirect_to :action => \"login\", :controller => \"../browse\"\n else\n #session passed too!\n end\n end\n end",
"def authenticate_user\n if session[:user]\n return true\n else\n session[:return_to] = request.fullpath\n redirect_to(:controller => 'users', :action => 'login')\n flash[:notice] = \"You need to login to view the requested page! \"\n flash[:color]= \"invalid\"\n return false\n end\n end",
"def authenticate\n # if login failed, show error message\n if session[:login]\n # redirect_to '/index'\n else\n # continue showing the view\n end\n end",
"def authenticate_user\n if !user_logged_in?\n # Store current url path for future reference\n store_location\n # Redirect to home page with error flash\n flash[:error] = \"Please Signin to access this page\"\n redirect_to root_path\n end\n end",
"def authenticate\n unless session[:user_id]\n session['return_url'] = request.url\n logger.debug request.url\n # Recreate user abilities on each login\n @current_ability = nil\n redirect_to polymorphic_url(:new_user_session)\n end\n end",
"def login\n return unless request.post?\n ::ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_expires => 4.weeks.from_now) if params[:remember_me]\n self.current_user = User.authenticate(params[:login], params[:password])\n if current_user\n redirect_back_or_default(:controller => '/')\n flash[:notice] = \"Logged in successfully\"\n else\n flash[:notice] = \"Please try again\"\n end\n end",
"def authenticate\n redirect_to login_url, danger: \"Please Login\" unless current_user\n end",
"def authenticate\n user = nil\n user = User.find_by_id(session[:user_id]) if session[:user_id].present?\n if !user.present?\n session[:user_id] = nil\n flash[:alert] = \"You must be logged in to access this page\"\n redirect_to login_path(:return_to => request.fullpath)\n end\n end",
"def login_attempt\n authorized_user = User.authenticate(params[:username], params[:login_password])\n if authorized_user\n session[:user_id] = authorized_user.id\n uname = authorized_user.username\n flash[:notice] = \"Welcome, #{authorized_user.username}!\"\n redirect_to(:action => 'home')\n else\n flash[:notice] = \"Invalid username!\"\n flash[:color] = \"invalid\"\n render \"login\"\n end\n end",
"def autenticathe_login!\n unless someone_is_logged_in?\n store_location\n flash[:danger] = \"Por favor, Inicie sesion.\"\n redirect_to welcome_path\n end\n end",
"def authenticate\n if session[:account].blank?\n @is_login = false\n reset_session\n render \"login/error\"\n else\n @is_login = true\n @user = User.where( \"account = ?\", session[:account] )[0]\n end\n end",
"def authenticate\n redirect_to(root_path) unless session[:username]\n end",
"def authenticate_user\n \tif !logged_in?\n \tredirect_to login_url\n \tend\n end",
"def logged_in_user\n store_location unless logged_in?\n flash[:info] = 'Please log in.' unless logged_in?\n redirect_to login_url unless logged_in?\n end",
"def authenticate_user!\n unless logged_in?\n store_location\n redirect_to log_in_path\n end\n end",
"def authenticate\n redirect_to login_url, alert: 'Please log in first' if current_user.nil?\n end",
"def authenticate\n if sesssion[:user_id].nil?\n redirect_to login_path, notice: \"You must log in first.\"\n end\n end",
"def logged_in_user\n return if logged_in?\n\n store_location\n flash[:danger] = 'Please log in first'\n render 'sessions/new', status: :unauthorized\n true # return true to indicate that this triggered things\n end",
"def login_required\n if session[:user]\n begin\n load_session_user\n rescue\n logout_and_redirect_to_login\n else\n return session[:user]\n end\n else\n self.store_location\n redirect_to users_login_url, :alert => \"You don't have access to that, please login.\"\n end\n end",
"def authenticate\n unless authenticated?\n reset_session\n session[:return_to] = request.request_uri\n redirect_to :controller => 'members', :action => 'login'\n return false\n end\n end",
"def authenticate\n begin\n if !session[:user_guid]\n redirect_to(root_path)\n elsif session[:user_guid] != User.find_by(id: session[:user_id].to_i).guid\n redirect_to(logout_user_path)\n end\n rescue\n redirect_to(logout_user_path)\n end\n end",
"def auth\n #redirect to login page unless already logged in\n redirect_to new_user_session_path, alert: \"You must login to access that page\" unless logged_in?\n end",
"def authenticate_user_if_logged_in\n if session[:user_id] && User.exists?(session[:user_id])\n @current_user = User.find session[:user_id]\n elsif session[:user_id]\n # If the session user id exists, but the user doesn't,\n # remove the session variable and show an error.\n session[:user_id] = nil\n session[:search_url] = nil\n flash[:notice] = \"Unable to find the logged in user!\"\n flash[:color] = \"invalid\"\n end\n end",
"def authenticate_user\n unless session[:user_id] && User.exists?(session[:user_id])\n # If the session user id exists, but the user doesn't,\n # remove the session variable and show an error.\n if session[:user_id]\n session[:user_id] = nil\n session[:search_url] = nil\n flash[:notice] = \"Unable to find the logged in user!\"\n flash[:color] = \"invalid\"\n end\n redirect_to(:controller => 'sessions', :action => 'login')\n return false\n else\n @current_user = User.find session[:user_id]\n return true\n end\n end",
"def authenticate\n unless session[:loggedin]\n redirect_to :action => 'login'\n return false\n end\n return true\n end",
"def login\n \t# Find a user with params\n \tuser = User.authenticate(@credentials[:password], @credentials[:username])\n \tif user\n\t \t# Save them in the session\n\t \tlog_in user\n\t \t# Redirect to articles page\n\t \tredirect_to articles_path\n\telse\n\t\tredirect_to :back, status: :created\n\tend\n end",
"def process_login\r\n # Somebody is probably playing\r\n return dc_render_404 unless ( params.dig(:record, :username) && params.dig(:record, :password) )\r\n\r\n return_to = request.env['HTTP_REFERER'] || '/'\r\n if params[:record][:password].present? #password must not be empty\r\n user = DcUser.find_by(username: params[:record][:username], active: true)\r\n if user && user.authenticate(params[:record][:password])\r\n fill_login_data(user, params[:record][:remember_me].to_i == 1)\r\n return redirect_to(params[:return_to] || return_to, allow_other_host: true)\r\n else\r\n clear_login_data # on the safe side\r\n end\r\n end\r\n flash[:error] = t('drgcms.invalid_username')\r\n redirect_to return_to\r\nend",
"def authenticate_user\n redirect_to \"/login\" unless logged_in?\n end",
"def authenticate\n if respond_to? :required_user_role and not user_in_role(required_user_role)\n session['user_attributes'] = nil\n session[:redirect_to] = request.env['PATH_INFO']\n flash[:notice] = \"Login as a #{required_user_role}\"\n redirect_to(login_url)\n end\n end",
"def authenticate\n unless User.find_by_id(session[:current_user_id]) ||\n (Auditor.find_by_id(session[:current_auditor_id]))\n redirect_to ({:controller => :login, :action => :session_timeout})\n end\n end",
"def login\n # redirect to main page if user is already logged in.\n if logged_in? && !request.post?\n if @real_user.admin_user?\n redirect_to(admin_path)\n elsif allowed_to?(:role_is_switched?)\n redirect_to course_assignments_path(session[:role_switch_course_id])\n else\n redirect_to(courses_path)\n end\n return\n end\n unless Settings.remote_auth_login_url || Settings.validate_file\n flash_now(:error, t('main.sign_in_not_supported'))\n end\n if remote_auth? && remote_user_name\n flash_message(:error,\n I18n.t('main.external_authentication_user_not_found',\n name: Settings.remote_auth_login_name ||\n I18n.t('main.external_authentication_default_name')))\n end\n return unless request.post?\n\n # Get information of the user that is trying to login if his or her\n # authentication is valid\n unless validate_login(params[:user_login], params[:user_password])\n render :login, locals: { user_login: params[:user_login] }\n return\n end\n\n session[:auth_type] = 'local'\n\n found_user = User.find_by(user_name: params[:user_login])\n if found_user.nil? || !(found_user.admin_user? || found_user.end_user?)\n flash_now(:error, Settings.validate_user_not_allowed_message || I18n.t('main.login_failed'))\n render :login, locals: { user_login: params[:user_login] }\n return\n end\n\n self.real_user = found_user\n\n uri = session[:redirect_uri]\n session[:redirect_uri] = nil\n refresh_timeout\n # redirect to last visited page or to main page\n if cookies.encrypted[:lti_data].present?\n lti_data = JSON.parse(cookies.encrypted[:lti_data]).symbolize_keys\n redirect_url = lti_data.key?(:lti_redirect) ? lti_data[:lti_redirect] : root_url\n redirect_to redirect_url\n elsif uri.present?\n redirect_to(uri)\n elsif found_user.admin_user?\n redirect_to(admin_path)\n else\n redirect_to(courses_path)\n end\n end",
"def login\n @user = User.authenticate(params[:username], params[:user_password])\n if @user\n session[:user] = @user\n flash['notice'] = \"Login successful\"\n redirect_back_or_default :controller => 'schedule', :action => \"index\"\n else\n if !params[:username].blank? or !params[:user_password].blank? \n flash.now['notice'] = \"Login unsuccessful\"\n end\n @login = params[:username]\n end\n end",
"def user_login\n unless logged_in?\n navigated_location #stores the location that was navigated before login\n flash[:alert]= \"You Must Be Log In Order To Access that Portion of the Site\" \n redirect_to login_path\n end\n end",
"def login\n get_session_variables_from_authenticated_system\n\n return unless request.post?\n attempt_to_login_user\n\n if logged_in? && authorized?(current_user)\n create_secret_image_code\n set_session_variables_for_authenticated_system\n log_the_login\n redirect_with_proper_protocol_and_query_string\n elsif account_subdomain\n flash.now[:notice] = \"Bad username or password for identity url: #{account_subdomain}.#{AppConfig.host}\"\n else\n flash.now[:notice] = \"Bad username or password.\"\n end\n end",
"def authenticate_user\n redirect_to login_path unless logged_in_user?\n end",
"def verify_credentials\n\t\tif (has_valid_credentials) then\n\t\t logger.error(\"VC: Logged in\")\n\t\telse\n\t\t # username is nil, just clobber login_time\n\t\t logger.error(\"VC: Not logged in, redirecting to login\")\n\t\t clear_session()\n\t\t redirect_to :controller => 'application', :action => 'index'\n\t\tend\n\tend",
"def create\n flash[:error] = \"Invalid Login Credentials!\"\n if authenticate!\n flash[:notice] = \"Login successful!\"\n flash[:error] = \"\"\n #redirect_back_or_default root_url\n else\n #render :action => :new\n flash[:error] = \"Invalid Login Credentials!\"\n end\n redirect_to(:back)\n end",
"def login_post\n @user = User.find_by_username(params[:user][:username])\n \n if @user == nil or not @user.password_valid?(params[:user][:password]) then\n respond_to do |format|\n format.html { redirect_to login_users_path, notice: \"Either the username or password is invalid. Please try again.\"}\n format.json { head :no_content }\n end\n return\n else\n session[:user] = @user\n\n if session[:previous_page] then\n respond_to do |format| \n session[:no_back] = true\n format.html { redirect_to session[:previous_page] }\n format.json { head :no_content }\n end\n\n session[:previous_page] = nil\n return\n end\n \n logged_in_home_page = users_path + '/' + session[:user][:id].to_s\n respond_to do |format|\n format.html { redirect_to gardens_path}\n format.json { head :no_content }\n end\n return\n end\n end",
"def authenticate!\n redirect_to login_path unless session[:username]\n end",
"def log_in_user\n unless log_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_path\n end\n end",
"def create\n # refactor this\n user = User.find_by(username: params[:session][:username_or_email].downcase) ||\n User.find_by(email: params[:session][:username_or_email].downcase)\n if authenticated_successfully?(user)\n login(user)\n redirect_to(session[:intended_url] || root_path)\n else\n flash.now[:danger] = \"Hmm... #{$SITE_TITLE} couldn't authenicate your account with those credentials.\"\n render 'new'\n end\n end",
"def login_attempt\n @user = User.where(email: params[:email]).first\n if @user && @user.password == params[:password]\n session[:user_id] = @user.id\n\n redirect_to root_path\n else\n flash[:notice] = \"Invalid Username or Password\"\n\n render \"login\"\n end\n end",
"def authenticate\n if session[:login] == true\n true\n else\n flash[:warning] = 'Please Log In !'\n redirect_to action: 'index'\n end\n end",
"def authenticate\n redirect_to login_path if !logged_in\n end",
"def login\n #Variable setting\n email = params[:user][:email]\n pw = params[:user][:password]\n flash[:login_error]= \"penis\"\n #user instance we are trying to validate\n @user = User.find_by_email(email)\n\n #Does the current user exist?\n if @user\n @current_user = @user.authenticate(pw)\n\n #Is the current user authenticated?\n if @current_user\n session[:user_id] = @user.id\n redirect_to :controller => :users, :action => :home\n else\n flash[:login_error] = \"The password you specified was incorrect\"\n render :index\n end\n\n else\n flash[:login_error] = \"The username you specified does not exist\"\n @user = User.new\n render :index\n end\n end",
"def logged_in_user\n return if logged_in?\n store_location\n redirect_to sessions_new_path, alert: 'Please log in.'\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in first!\"\n redirect_to login_path\n end\n end",
"def try_login\n if user = http_auth_login || validation_login || remember_me_login\n session[:uid] = user.id\n end\n end",
"def authenticate_and_load_user\n \t@logged_in_user = User.where(id:session[:user_id]).first\n\n \tif @logged_in_user.nil?\n \t\tflash[:error] = 'You must be authenticated to visit this page'\n \t\t# Save the user's intended destination in the session, so we can\n \t\t# take them there once they've logged in.\n \t\tsession[:requested_fullpath] = request.fullpath\n \t\tredirect_to controller:'public', action:'login'\n \t\tfalse # return false to prevent execution of controller methods\n \telse\n \t\ttrue\n \tend\n end",
"def logged_in_user\n unless logged_in?\n store_location # This line uses a method in sessions_helper to store request location so that it may redirect them to that location upon login.\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def post_login\n \t\tif logged_in?\n \t\t\tflash[:error] = \"You are already logged in as #{current_user_full_name}\"\n \t\t\tredirect_to(:controller => :photos, :action => :index, :id => session[:current_user_id])\n \t\telse\n\t \t\tcurrent_user = User.find_by_login(params[:login])\n\t\t\t\tif(current_user == nil) then\n\t\t\t\t\t# If no user exists with the given login, redisplay login form with error message.\n\t \t\t\t\tflash[:error] = \"Invalid username\"\n\t \t\t\t\tredirect_to(:action => :login)\n\t\t\t\telsif(!current_user.password_valid?(params[:password])) then\n\t\t\t\t\t# If incorrect password, display error message\n\t\t\t\t\tflash[:error] = \"Invalid password\"\n\t \t\t\t\tredirect_to(:action => :login)\n\t\t\t\telse\n\t\t\t \t\t# Upon successful login, stores user id in session where it can be checked by other code and\n\t\t\t \t\t# redirects to the page displaying the user's photos.\n\t\t \t\t\tsession[:current_user_id] = current_user.id\n\t\t \t\t\tflash[:success] = \"Welcome, #{current_user_first_name}!\"\n\t\t \t\t\tredirect_to(:controller => :photos, :action => :index, :id => session[:current_user_id])\n\t \t\t\tend\n\t \tend\n \tend",
"def authenticate_user!\n\t if !current_user\n\t flash[:danger] = \"You must be logged in to do that!\"\n\t redirect_to \"/login\"\n \t\tend\n\tend",
"def attempt_login\n if params[:email].present? && params[:password].present?\n found_user = User.where(email: params[:email]).first\n authorized_user = found_user.authenticate(params[:password]) if found_user\n end\n\n if authorized_user\n authenticate_user(found_user.id)\n flash[:notice] = 'You are now logged in.'\n redirect_to(challenge_index_path)\n else\n flash.now[:notice] = 'Invalid email/password combination.'\n render('login')\n end\n end",
"def check_auth\n if !session[:logged_in]\n flash[:notice] = \"Please log in again. Session expired\"\n redirect_to :action => :login\n end\nend",
"def authenticate\n self.logged_in_user = User.authenticate(params[:user][:email], params[:user][:password])\n if is_logged_in?\n #redirect_to index_url\n redirect_to :controller => 'pages', :action => 'admin'\n else\n flash[:error] = \"I'm sorry, either your email or password are incorrect\"\n redirect_to :controller => 'account', :action => 'login'\n end\n end",
"def authenticate_user!\n if current_user.id != @user.id\n redirect_back(fallback_location: root_path)\n end\n end",
"def authentication\n if UserSession.find.nil?\n respond_to do |format|\n format.html { redirect_to(\"/login\", :notice => 'You must be logged in') }\n end\n end\n end",
"def logged_in_user\n\tunless logged_in?\n\t store_location\n\t flash[:danger] = \"Please log in.\"\n\t redirect_to login_url\n\tend\n end",
"def authenticate_user\n if session[:user]\n return true\n else\n redirect_to :controller => 'app', :action => 'messageUserLogin', :token => \"login\"\n return\n end\n end",
"def create\n\n logger.debug \"### Processing new login details\"\n user = User.authenticate(params[:email], params[:password])\n\n if user\n\n logger.debug \"### Login details matched - creating login session\"\n session[:user_id] = user.id\n flash[:notice] = \"Logged in!\"\n redirect_to(session[:return_to] || home_index_path) \n session.delete(:return_to)\n else\n logger.debug \"### User details didn't match - login denied\"\n flash[:error] = \"Invalid email or password\"\n render \"new\"\n end\n\n end",
"def authenticate\n if !logged_in? || current_user.nil?\n redirect '/login'\n end\n end",
"def authenticate\n unless current_user\n redirect_to login_path, alert: 'You are not authenticated to view this page. Please log in or sign up at first.'\n end\n end",
"def authenticate\n unless logged_in?\n redirect_to login_url\n end\n end",
"def create_session\n self.current_user = authenticate_user(params[:user][:login], params[:user][:password], :trace => true)\n \n # store remember me in token\n if logged_in?\n if params[:user][:remember_me] == \"1\"\n current_user.remember_me unless current_user.remember_token?\n cookies[cookie_auth_token] = {\n :value => self.current_user.remember_token, :expires => self.current_user.remember_token_expires_at\n }\n end\n \n # callback :after_authentication_success\n self.send(:after_authentication_success, self.current_user) if self.respond_to?(:after_authentication_success)\n \n if !performed? && request.xhr?\n render :update do |page|\n # JS code to close modal\n # update page header to show user information\n end\n elsif !performed?\n flash[:notice] = MESSAGE_LOGIN_SUCCESS\n redirect_back_or_default(authentication_success_url || '/')\n end\n else\n # callback :after_authentication_error\n self.send(:after_authentication_error, self.current_user) if self.respond_to?(:after_authentication_error)\n if !performed? && request.xhr?\n render :update do |page|\n # JS code to re-display login dialog\n end\n elsif !performed?\n flash[:error] = user_class.is_suspended?(params[:user][:login], params[:user][:password]) ? \n \"Login nicht möglich, da Benutzer gesperrt wurde.\" : \n MESSAGE_LOGIN_ERROR\n render :action => 'new'\n end\n end\n end",
"def authenticate\n redirect_to login_path, alert: \"You must be authenticated\" if !current_account\n end",
"def login\n if params['username'] and params['password']\n user = User.where(name:params['username'], password: params['password']).first \n if user\n session['user_attributes'] = user.attributes\n session['user_attributes']['id'] = user.id\n else\n flash[:error] = \"Login failed\"\n end\n end \n \n if session['user_attributes']\n unless params['redirect_to'].nil?\n redirect_to(\"#{params['redirect_to']}\")\n else\n redirect_to(root_url)\n end\n else\n flash[:redirect_to] = params['redirect_to'] unless flash[:redirect_to]\n end\n end",
"def failure\n redirect_to login_path,\n alert: \"Authentication failed, please try again.\"\n end",
"def authenticateUser\n valmsg = User.validateUser(params[:login_username],params[:login_password])\n if (valmsg == 'validuser')\n session[:user] = params[:login_username]\n redirect_to :controller => \"gapp\", :action => \"home\"\n else\n redirect_to :root\n flash[:notice] = \"Username & password mismatch ! Please try again !!\"\n flash[:color]= \"invalid\"\n end\n end",
"def login\n # delete the session from their last login attempt if still there\n session.delete(:auth) unless session[:auth].nil?\n @login_form = LoginForm.new\n end",
"def logged_in_user\n\t\tunless logged_in?\n\t\tstore_location\n\t\tflash[ :danger] = \"Please log in\"\n\t\tredirect_to login_url\n\tend\n\tend",
"def authenticate(exception)\n session[:return_to] = request.fullpath if request.get?\n redirect_to login_url\n end",
"def login\n if params[:username].nil? || params[:username].empty?\n flash[:error] = \"You must enter a username\"\n # If ldap is not setup, there will be no password\n elsif LdapInfo.setup?\n if LdapInfo.login params[:username], params[:password]\n set_current_user params[:username]\n else\n flash[:error] = \"Username and password not accepted\"\n end\n else\n set_current_user params[:username]\n end\n if !request.referer.nil? # Try to redirect to the same page they logged in from\n redirect_to request.referer\n else\n redirect_to tips_path\n end\n end",
"def authenticate_user\n unless signed_in?\n redirect_to login_url, notice: \"Please log in first\"\n end\n end",
"def logged_in_user\n\t \t\tunless logged_in?\n\t \t\t\tstore_location\n\t \t\t\tflash[:danger] = t(:please_login)\n\t \t\t\tredirect_to login_url\n\t \t\tend\n\t \tend",
"def authenticate\n unless signed_in?\n flash[:warn] = {general: ['Please sign in']}\n redirect '/user/sign_in'\n end\n true\n end",
"def logged_in_user\n\tunless logged_in?\n\tstore_location\n\tflash[:danger] = \"Please log in.\"\n\tredirect_to login_url\n\tend\n\tend",
"def logged_in_user\n return if logged_in?\n store_location\n flash[:danger] = t \"flash.login_required\"\n redirect_to login_url\n end",
"def login\n return redirect_to '/' if current_account && current_account.refresh_credentials(cookies) && !current_account.reviewer? && current_account.active?\n\n return render layout: 'new' unless request.post?\n next_url = (params[:next] && CGI.unescape(params[:next])) || '/'\n account = Account.log_in(params[:email], params[:password], session, cookies)\n return redirect_to(next_url) if account && account.active?\n if account && !account.active?\n flash[:error] = \"Your account has been disabled. Contact support@documentcloud.org.\"\n else\n flash[:error] = \"Invalid email or password.\"\n end\n begin\n if referrer = request.env[\"HTTP_REFERER\"]\n redirect_to referrer.sub(/^http:/, 'https:')\n end\n rescue RedirectBackError => e\n return render layout: 'new'\n end\n end",
"def authenticate!\n redirect '/sessions/new' unless logged_in?\nend",
"def process_login\r\n# Somebody is probably playing\r\n return dc_render_404 unless ( params[:record] and params[:record][:username] and params[:record][:password] )\r\n\r\n unless params[:record][:password].blank? #password must not be empty\r\n user = DcUser.find_by(username: params[:record][:username])\r\n if user and user.authenticate(params[:record][:password])\r\n fill_login_data(user, params[:record][:remember_me].to_i == 1)\r\n return redirect_to params[:return_to] || '/'\r\n end\r\n end\r\n flash[:error] = t('drgcms.invalid_username')\r\n redirect_to params[:return_to_error] || '/'\r\nend",
"def authenticate\n if logged_in_user\n redirect_to root_url unless current_user?(find_user)\n end\n end",
"def logged_in_user\n if !logged_in?\n flash[:failure] = \"You must sign in first.\"\n redirect_to(login_url)\n end\n end",
"def logged_in_user\n if !logged_in?\n flash[:failure] = \"You must sign in first.\"\n redirect_to(login_url)\n end\n end",
"def authenticate_user\n# save current page for redirection after login\n redirect_to controller: :user, action: :login unless logged_in? \n current_user\n end",
"def logged_in_user\n return if logged_in?\n\n store_location\n flash[:danger] = 'please log in.'\n redirect_to login_url\n end",
"def login\n return redirect_to '/' if current_account && current_account.refresh_credentials(cookies) && !current_account.reviewer? && current_account.active?\n return render unless request.post?\n next_url = (params[:next] && CGI.unescape(params[:next])) || '/'\n account = Account.log_in(params[:email], params[:password], session, cookies)\n return redirect_to(next_url) if account && account.active?\n if account && !account.active?\n flash[:error] = \"Your account has been disabled. Contact support@documentcloud.org.\"\n else\n flash[:error] = \"Invalid email or password.\"\n end\n begin\n if referrer = request.env[\"HTTP_REFERER\"]\n redirect_to referrer.sub(/^http:/, 'https:')\n end\n rescue RedirectBackError => e\n # Render...\n end\n end",
"def logged_in_user\n return if logged_in?\n store_location\n flash[:danger] = t \"danger.login\"\n redirect_to login_url\n end",
"def do_login\n login_error = false # for error checking\n @author = Author.new(params[:author])\n if @author.email != '' && @author.password != ''\n # the author entered the required data, let's check it\n @logged_in_author = Author.find(:all, :conditions => ['email = ? and hashed_pass = ? and is_active = ?', @author.email, Author.do_password_hash(@author.password), true])\n if @logged_in_author.length > 0\n # we found a author, let's set cookies and send them on their way\n cookies[SL_CONFIG[:USER_EMAIL_COOKIE]] = { :value => @logged_in_author[0].email, :expires => Time.now + 31536000 }\n cookies[SL_CONFIG[:USER_HASH_COOKIE]] = { :value => @logged_in_author[0].hashed_pass, :expires => Time.now + 31536000 }\n if session[:came_from]\n # they came from somewhere, let's send them back there\n temp = session[:came_from]\n session[:came_from] = nil\n redirect_to temp\n else\n # not sure where they came from, just send them to /admin\n redirect_to Site.full_url + '/admin'\n end\n else\n # no good\n flash[:notice] = 'Sorry, but that email/password combination is invalid.'\n login_error = true\n end\n else\n # didn't enter required data\n flash[:notice] = 'You must enter an email and a password.'\n login_error = true\n end\n if login_error\n # there was an error--delete the cookies and send them back to the login page\n cookies.delete SL_CONFIG[:USER_EMAIL_COOKIE]\n cookies.delete SL_CONFIG[:USER_HASH_COOKIE]\n redirect_to Site.full_url + '/login'\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def login_required\n if session[:user_id]\n @user = current_user if @user.nil?\n return true if @user\n end\n flash[:warning]='Please login to continue'\n session[:return_to]=request.fullpath\n redirect_to :controller => \"user\", :action => \"login\"\n return false \n end",
"def validate\n @user = User.authenticate(params[:user], params[:pass])\n if @user != nil\n session[:user] = @user.id\n session[:username] = @user.username\n redirect_to :controller => 'profile'\n else\n flash[:error] = \"Invalid user name or password.\"\n redirect_to :action => 'index'\n end\n end",
"def authenticate\n # Note: testing depends on the fact that 'authenticated' means having the\n # session['uid'] and session['timeout'] set appropriately. Make sure to\n # change AuthenticatedControllerTest if this is changed.\n if !session_expired? && logged_in?\n refresh_timeout # renew timeout for this session\n @current_user = current_user\n else\n # cleanup expired session stuff\n clear_session\n cookies.delete :auth_token\n reset_session\n\n session[:redirect_uri] = request.fullpath # save current uri\n\n # figure out how we want to explain this to users\n if session_expired?\n flash[:login_notice] = I18n.t('main.session_expired')\n else\n flash[:login_notice] = I18n.t('main.please_log_in')\n end\n\n if request.xhr? # is this an XMLHttpRequest?\n # Redirect users back to referer, or else\n # they might be redirected to an rjs page.\n session[:redirect_uri] = request.referer\n head :forbidden # 403\n else\n redirect_to controller: 'main', action: 'login'\n end\n end\n end",
"def authenticate\n if logged_in? && !session_expired?\n refresh_timeout\n else\n remote_login_error = remote_auth? && remote_user_name\n clear_session\n if remote_login_error\n flash_message(:error,\n I18n.t('main.external_authentication_user_not_found',\n name: Settings.remote_auth_login_name ||\n I18n.t('main.external_authentication_default_name')))\n end\n if request.xhr? # is this an XMLHttpRequest?\n # Redirect users back to referer, or else\n # they might be redirected to an rjs page.\n session[:redirect_uri] = request.referer\n head :forbidden # 403\n else\n session[:redirect_uri] = request.fullpath\n redirect_to root_path\n end\n end\n end",
"def client_login\n user = User.authenticate(params[:email], params[:password])\n if user\n session[:user_id] = user.id\n params.delete(:locale)\n set_locale\n redirect_to :controller=>'home', :action=>'index'\n else # Si hay error:\n #Verifico que el usuario este registrado en el sistema\n if User.find_by_email(params[:email]).nil?\n flash[:error] = I18n.t('session.login_email_error', :user=> params[:email].to_s)\n redirect_to sessions_url\n else\n #Si email es valido entonces el error es el password\n flash[:error] = I18n.t('session.login_password_error')\n render \"index\", :layout => \"login\"\n end\n end\n end",
"def logged_in_user\n return if logged_in?\n\n store_location\n flash[:danger] = 'Please log in.'\n redirect_to login_url\n end",
"def authenticate_user!\n if !current_user\n redirect_to login_path, :alert => 'You Must Be Logged In'\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def authenticate_user!\n if !signed_in?\n session[:user_return_to] = request.path if request.path\n redirect_to \"/auth/githubteammember\"\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = 'Unauthorized'\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless current_user\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end"
] | [
"0.77564836",
"0.77532744",
"0.7543252",
"0.7472004",
"0.7447287",
"0.7388099",
"0.73638034",
"0.7356388",
"0.7333298",
"0.73331183",
"0.73003006",
"0.72960305",
"0.7268579",
"0.7268159",
"0.7256869",
"0.7255079",
"0.72422075",
"0.7228445",
"0.7227032",
"0.72177845",
"0.7210048",
"0.7205515",
"0.7188026",
"0.71706104",
"0.7169218",
"0.71496737",
"0.71451575",
"0.7140097",
"0.71361744",
"0.7120343",
"0.71111137",
"0.70986676",
"0.7097266",
"0.7092767",
"0.70880944",
"0.70860064",
"0.70822597",
"0.7081377",
"0.70799243",
"0.7077483",
"0.7077073",
"0.70707136",
"0.7069955",
"0.70654684",
"0.7053906",
"0.7052826",
"0.7045352",
"0.70423895",
"0.70389867",
"0.7037608",
"0.7026119",
"0.70249146",
"0.7014023",
"0.7011971",
"0.7011652",
"0.7010423",
"0.7009545",
"0.7008575",
"0.7007754",
"0.70062023",
"0.7003985",
"0.69932646",
"0.6991815",
"0.69829655",
"0.6981669",
"0.69810766",
"0.6971902",
"0.69715714",
"0.6970727",
"0.6970389",
"0.69689906",
"0.6968188",
"0.69621116",
"0.6955089",
"0.6950421",
"0.6948434",
"0.6948106",
"0.6944826",
"0.69430983",
"0.69371367",
"0.69359803",
"0.69355756",
"0.6932344",
"0.6932344",
"0.6930185",
"0.6924372",
"0.6922558",
"0.6922198",
"0.6920007",
"0.6916719",
"0.69122785",
"0.6907559",
"0.6903911",
"0.69034237",
"0.69011635",
"0.6899374",
"0.6890496",
"0.68881446",
"0.6885518",
"0.68855137",
"0.68849427"
] | 0.0 | -1 |
Remove the user from the session and send them to the home page. | def logout
session[:remember_token] = nil
session[:last_seen] = nil
redirect_to '/'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n # Remove the user id from the session\n @_current_user = session[:current_user_id] = nil\n # @_current_user = session[:email] = nil\n redirect_to root_url\n end",
"def destroy\n # when session is destroyed, it is empty\n \tsession[:user_id] = nil \n # redirect to root_path which is the homepage\n \tredirect_to root_path, notice:\n \t\"You have successfully logged out!\"\n end",
"def destroy\n session.delete :user_id\n redirect_to '/'\n end",
"def destroy\n session.delete(:current_user_key)\n redirect_to welcome_index_path, alert: \"Logged out.\"\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_url, :notice => \"Logged out!\"\n end",
"def destroy\n session[:user_id] = nil\n redirect_to welcome_path\n end",
"def destroy\n # Remove the user id from the session\n session.clear\n redirect_to root_url\n end",
"def destroy\n\t\tsession[:user_id] = nil\n\t\tflash[:notice] = \"Logged Out\"\n\t\treturn redirect_to home_path\n\tend",
"def destroy\n session[:user_id] = nil\n redirect_to root_url, :notice => \"Logged out\"\n end",
"def destroy\n # Remove the user id from the session\n @_current_user = session[:current_user_id] = nil\n redirect_to root_url\n end",
"def logout\n \t\tsession[:user]=nil\n \t\tredirect_to users_url\n \tend",
"def destroy\n if current_user\n session.delete :user_id\n redirect_to root_url\n end\n end",
"def destroy\n session[:user_id] = nil\n redirect_to :back\n end",
"def destroy\n\t\tsession[:user_id] = nil\n\t\tredirect_to '/'\n\tend",
"def destroy\n \t#end session and send to login page\n\n \t\tsession[:user_id] = nil\n \t\tredirect_to root_path\n\n end",
"def destroy\n current_user_session.destroy if current_user_session \n redirect_back_or_home\n end",
"def destroy\n\t\tsession.delete(:user_id)\n\t\tredirect_to root_url, notice: 'Logged out!'\n\tend",
"def destroy\n session.delete :user_id\n redirect_to root_path\n end",
"def destroy\n if current_user\n session.delete :user_id\n redirect_to root_path\n\n end\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_url, :notice => \"Logged out\"\n end",
"def destroy\n session[:user_id] = nil\n redirect_to new_session_path, notice: 'You have been logged out of Unify.'\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_url, :notice => \"logged out!\"\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_path, notice: I18n.t(:session_logged_out)\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_url, :notice => \"Logged out!\"\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_url, :notice => \"Logged out!\"\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_url, :notice => \"You have been logged out\"\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_path\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_path\n end",
"def destroy\n session[:user_id] = nil\n @curr_user = nil\n redirect_to :log_in, :notice => \"Logged out\"\n end",
"def destroy\n @current_user = nil\n session[:user_id] = nil\n \n respond_to do |format|\n format.html { redirect_to(home_path) }\n end\n end",
"def logout\n #render :nothing => true\n \n # Check if exists user data in session\n if session[:logged_user].present?\n # Delete user data from session\n session.delete(:logged_user)\n end\n \n # Set flash message\n flash[:notice] = 'Sessao encerrada com sucesso'\n # Redirect to home \n redirect_to '/home'\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_url, :notice => \"You have been successfully logged out.\"\n end",
"def destroy \n\t\tsession[:user_id] = nil\n\t\tredirect_to root_path\n\tend",
"def destroy\n session[:user_id] = nil\n redirect_to \"/\"\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_url\n end",
"def destroy\n session[:user_id] = nil\n redirect_to(root_path)\n end",
"def logout\n if @signed_in_user\n session.delete(:signed_in_user_id)\n end\n redirect_to users_home_path\n end",
"def destroy\n session[:user_id] = nil\n\n redirect_to \"#{SSOClient.provider_url}/users/sign_out?back=#{URI::encode(main_app.root_url)}\",\n notice: t(\"sso_client.messages.logged_out\")\n end",
"def destroy\n\t\tsession[:user_id]=nil\n\t\tredirect_to root_path\n\tend",
"def logout\n session[:user] = nil\n redirect_to :controller => :home\n end",
"def destroy\n \tsession[:user_id] = nil\n session[:user_name] = nil\n \tredirect_to '/login'\n end",
"def destroy\n session[:user_id] = nil\n redirect_to '/'\n end",
"def destroy \n session.delete :user_id \n head :no_content \n end",
"def logout\n session[:user] = nil\n redirect_to '/'\n end",
"def logout\n session[:user] = nil\n redirect_to '/'\n end",
"def destroy\n\t\tsession[:user_id] = nil\n\t\tflash[:notice] = \"You have logged out.\"\n\t\tredirect_to '/'\n\tend",
"def destroy\n\n # deletes user session\n session[:user_id] = nil\n redirect_to root_path, notice: 'Logged out.'\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_url, notice: 'Logged out!'\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_path()\n end",
"def destroy\n\t\tsession[:user_id] = nil\n \tredirect_to root_url\n\tend",
"def destroy\n\t\tsession.delete(:user_id)\n\t\tredirect_to login_path\n\tend",
"def destroy\n \tsession[:user_id] = nil\n @current_user = nil\n \tredirect_to root_url, notice: \"You are now logged out.\"\n end",
"def destroy\n\n session.delete(:user_id)\n redirect_to root_path, notice: \"logged out successfully \"\n\n end",
"def destroy\n session[:user_id] = nil\n redirect_to pages_logout_path\n end",
"def destroy\n\t\tsession[:user_id] = nil\n\t\tflash[:notice] = \"You have been logged out. Bon Voyage!\"\n\t\tredirect_to root_path\n\tend",
"def destroy\n session[:user_id] = nil\n flash[:info] = \"Logged Out\"\n redirect_to root_path\n end",
"def sign_out\n if @current_user\n session.delete(:user_id)\n redirect_to action: \"index\"\n end\n end",
"def destroy\n\t\tuser = current_user\n\n\t\tsession.delete(:user_id)\n\t\tdelete_current_user()\n\t\t\n\t\tuser.destroy\n\t\tredirect_to home_path\n\tend",
"def logout_user\n cookies.delete(:caboose_user_id)\n session[\"app_user\"] = nil\n reset_session\n end",
"def destroy\n session.delete(:user_id)\n session.delete(:auth)\n flash[:notice] = 'Logged out successfully.'\n redirect_to \"/home\"\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_path\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_path\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_path\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_path\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_path\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_path\n end",
"def logout\n # Remove the user id from the session\n @_current_user = session[:current_user_id] = nil\n redirect_to :root\n end",
"def destroy\r\n\t\t# setting the session to nil\r\n\t\tsession[:user_id] = nil\r\n\t\tflash[:success] = \"You have logged out\"\r\n\t\tredirect_to root_path\r\n\tend",
"def destroy\n session[:user_id] = nil\n # flash[:notice] = \"Successfully logged out.\"\n redirect_to root_url, notice: \"Successfully logged out.\"\n end",
"def destroy\n session[:user_id] = nil\n redirect_to '/login'\n end",
"def destroy\n session[:user_id] = nil\n redirect_to '/login'\n end",
"def destroy\n session[:user_id] = nil\n redirect_to '/login'\n end",
"def destroy\n # assign value of nil which remove key user_id from the session\n session[:user_id] = nil\n redirect_to root_url, notice: \"You're now signed out!\"\n end",
"def destroy\n \tsession[:user_id]= nil\n \tredirect_to root_path\n end",
"def destroy\n\t\t# the act of logging out is performed by simply setting the key (:user_id) \n\t\t# in the session hash to a value of nil (nothing)\n\t\tsession[:user_id] = nil\n\t\t# redirect to root_path (products/index.html.erb') \n\t\tredirect_to root_path \n\tend",
"def clear_session_user\n return if current_user && current_user.email == saml_user\n request.env['warden'].logout\n redirect_to(root_path)\n end",
"def destroy\n current_user_session.destroy\n redirect_to root_url\n end",
"def logout\n \tsession[:user_id] = nil\n \tsession[:home_url] = nil\n \tflash[:notice] = \"You have successfully logged out.\"\n \tredirect_to :action => 'index'\n end",
"def logout\n session[:email] = nil\n session[:firstname] = nil\n session[:lastname] = nil \n render :adduser \n end",
"def log_out_behavior\n session[:user_id] = nil\n redirect_to \"/\"\n end",
"def destroy\n session[:user_id] = nil\n redirect_to sessions_path, flash: { info: 'Logged Out' }\n end",
"def destroy\n if current_user\n session.delete(:user_id)\n flash[:success] = 'See ya!'\n end\n redirect_to signup_path\n end",
"def destroy\n\t\tsession[:current_user_id] = nil\n \t\tredirect_to '/login'\n\tend",
"def destroy\n session[:user_id] = nil\n append_flash :notice, \"You have successfully logged out.\", true\n redirect_to :root\n end",
"def logout\n session[:user] = nil\n end",
"def destroy\n session[:user_id] = nil\n # alerts the user that the signout has been successful\n flash[:success] = \"You have successfully logged out!\"\n # redirects user to homepage\n redirect_to root_path\n end",
"def destroy\n session[:user] = @current_user = nil\n redirect_to :controller => :sessions, :action => :new\n end",
"def destroy\n\t\tsession[:user_id] = nil\n\t\tflash[:success] = \"You have successfully logged out!\"\n\t\tredirect_to root_path\n\tend",
"def destroy\n session[:user_id] = nil\n session[:type] = nil\n redirect_to root, alert: \"You have been logged out.\"\n end",
"def destroy\n session.delete(:user_id) if session[:user_id]\n redirect_to new_session_path\n end",
"def logout\n session[:user_id] = nil\n @user = User.new\n render :index\n end",
"def signoff\n delete_user\n redirect_to home_url\n end",
"def call(params)\n session[:user] = nil #\n redirect_to '/'\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_path\n \n end",
"def destroy\n #logs out user\n log_out\n #takes us back to the home page\n redirect_to root_url\n end",
"def destroy\n session[:user_id] = nil\n session[:roles_permissions_data] = nil\n session[:current_user_school_id] = nil\n #render 'index'\n redirect_to root_url, :notice => \"Logged out!\"\n end",
"def destroy\n session[:user_id] = nil\n flash[:success] = \"You have logged out\"\n redirect_to root_path\n end",
"def destroy\n session[:user_id] = nil\n flash[:success] = \"You have logged out\"\n redirect_to root_path\n end",
"def destroy\n user_session.log_out\n redirect_to root_url\n end",
"def log_me_out\n session['user'] = nil\n end",
"def destroy\n session[:user_id] = nil\n redirect_to root_url, :notice => \"تسجيل الخروج!\"\n end"
] | [
"0.7877501",
"0.78695405",
"0.7802991",
"0.7750761",
"0.77169764",
"0.7704763",
"0.77002597",
"0.7698789",
"0.76759464",
"0.76523733",
"0.76475424",
"0.7632359",
"0.76097924",
"0.760768",
"0.75990623",
"0.7571205",
"0.755414",
"0.7550515",
"0.7543335",
"0.7540896",
"0.7525574",
"0.752432",
"0.75228167",
"0.75158715",
"0.75158715",
"0.75021946",
"0.75019497",
"0.75019497",
"0.7500363",
"0.7481041",
"0.74796206",
"0.74772906",
"0.7475077",
"0.74742997",
"0.7473808",
"0.74648654",
"0.74633193",
"0.7461652",
"0.7458758",
"0.74573433",
"0.74567705",
"0.745596",
"0.74505883",
"0.7441286",
"0.7441286",
"0.74362195",
"0.7430688",
"0.74287105",
"0.74258906",
"0.7420329",
"0.7416838",
"0.74158275",
"0.7414067",
"0.7410844",
"0.74104327",
"0.7406961",
"0.74022996",
"0.7401801",
"0.7391039",
"0.73887175",
"0.7385956",
"0.7385956",
"0.7385956",
"0.7385956",
"0.7385956",
"0.7385956",
"0.7379864",
"0.73783237",
"0.73773164",
"0.736575",
"0.736575",
"0.736575",
"0.7363192",
"0.7361747",
"0.73524076",
"0.73491883",
"0.7348743",
"0.7342696",
"0.73357856",
"0.73295856",
"0.7323365",
"0.73213196",
"0.73178965",
"0.7316027",
"0.73086065",
"0.73079383",
"0.7289587",
"0.7287023",
"0.7274786",
"0.7274626",
"0.7274468",
"0.72698826",
"0.72631395",
"0.72576106",
"0.72566897",
"0.72450227",
"0.72414523",
"0.72414523",
"0.7233943",
"0.7232876",
"0.7222324"
] | 0.0 | -1 |
The list of users the bot shares a server with. | def users
gateway_check
unavailable_servers_check
@users
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shares\n @users.map { |u| u.share }.uniq\n end",
"def all_users\n\t\tshared_users.map(&:id).join(\", \")\n\tend",
"def clients\n clis = []\n url = prefix + \"listc\"\n users = response(url)\n if users.class == Array #success\n users.each do |u|\n clis << ShareUser.new(u[\"id\"], @authid, @subdomain, u)\n end\n return clis\n else #failed\n return users\n end\n end",
"def associated_users(permission: nil)\n owner = self.user\n shares = permission.present? ? self.study_shares.where(permission: permission) : self.study_shares\n share_users = shares.map { |share| User.find_by(email: /#{share.email}/i) }.compact\n [owner] + share_users\n end",
"def users\n @users_by_href.values\n end",
"def list\n get('users')['users']\n end",
"def servers(token)\n request(\n __method__,\n :get,\n \"#{api_base}/users/@me/guilds\",\n Authorization: token\n )\n end",
"def send_user_list(path)\n path = path[1..-1]\n path = path[0..-2] if path.ends_with?(\"/\")\n results = []\n I3.directory.find_people(:groups, path).each do |uuid|\n p = I3.directory.read_person(uuid)\n result = I3::SharedObject.new\n result.account_name = p.account_name.to_s.downcase\n result.first_name = p.first_name.to_s\n result.last_name = p.last_name.to_s\n result.description = p.description.to_s\n results << result\n end #each\n I3.server.send_object(results)\n end",
"def users\n gateway_check\n @users\n end",
"def following_usernames\n url = [PUBLIC_BASE_URL, 'user/show', self.login, 'following'].join('/')\n JSON.parse(open(url).read)['users']\n end",
"def users\n self.class.get(\"/user\", @options).parsed_response[\"items\"]\n end",
"def users\n watches_unique_by_user.map(&:user)\n end",
"def list_users\n http_get(:uri=>\"/users\", :fields=>x_cookie)\n end",
"def list_users\n BrickFTP::API::User.all\n end",
"def list_users\n BrickFTP::API::User.all\n end",
"def users\n User.where(network_id: context[:current_network]&.id)\n end",
"def users\n users = Set.new\n\n @channels.each do |channel|\n users.merge(channel.users)\n end\n\n users\n end",
"def index\n if current_user.try(:admin)\n @shared_with_me = Share.all\n else\n @shared_with_me = current_user.shares\n end\n @shared_by_me = Share.shared_by(current_user)\n end",
"def other_household_members\n return [] if period.nil?\n ids = chooser.household.users.pluck(:id) - [chooser.id]\n period.shares.nonzero.where(user_id: ids).includes(:user).map(&:user)\n end",
"def users(target = nil)\n raw \"USERS #{target}\".strip << \"\\r\\n\"\n end",
"def users\n return [member_1, member_2];\n end",
"def index\n @share_users = ShareUser.all\n end",
"def user_list\n\t\tget_call = Curl::Easy.http_get(\"#{@ip_address}:#{@port_2}/v2.0/users/\"\n\t\t) do |curl| curl.headers['x-auth-token'] = @token end\n\t\t\n\t\tputs \"Here is a list of users...\"\n\t\tparsed_json = JSON.parse(get_call.body_str)\n\t\t\n\t\tputs parsed_json\n\t\treturn parsed_json\n\tend",
"def users\n # TODO use SQL\n results = self.approvers + self.observers + [self.requester]\n results.compact\n end",
"def curator_list\n users.map(&:email)\n end",
"def list_users\n tp @users, :real_name, :slack_id, :user_name => {:display_method => :name}\n end",
"def reply_users_names\n reply_users&.split(/[, ]+/)&.map do |reply_user_id|\n User.find(reply_user_id).real_name\n end&.join(', ')\n end",
"def list_of_users\n\tusers=[]\n\tfor username in Dir.entries(\"/Users\")\n\t\tif !username.start_with?(\".\")\n\t\t\tusers.push(username)\n\t\tend\n\tend\n\treturn users\nend",
"def list_friend\n ActionCable.server.broadcast(\n \"conversations-#{connect_user.id}\",\n message: 'list_user',\n data: User.where.not(id: connect_user).select('id, email')\n )\n end",
"def users\n users = Backlogjp.base._command \"getUsers\", self.id\n users.map {|hash| User.new(hash)}\n end",
"def users\n res = []\n\n tmp = GoodData.get @json['project']['links']['users']\n tmp['users'].map do |user|\n res << GoodData::Membership.new(user)\n end\n\n res\n end",
"def users()\n\t\t\tusers = {}\n\t\t\t@table.items.where(:type => 'USER').each do |user_row|\n\t\t\t\tusers[user_row.attributes[:user_name]] = ServerUser.new(user_row.attributes[:user_name], @dynamo_table, user_row, @metadata, self)\n\t\t\tend\n\t\t\treturn users\n\t\tend",
"def users(*params)\n puts \"Users:\"\n @users.each do |user|\n muted = @muted_users.include?(user)\n puts \"#{user}#{muted ? \" (muted)\" : \"\"}\"\n end\n end",
"def connected_users\n @response[\"connected_users\"] rescue []\n end",
"def followers_usernames\n url = [PUBLIC_BASE_URL, 'user/show', self.login, 'followers'].join('/')\n JSON.parse(open(url).read)['users']\n end",
"def lists\n\t\tRails.cache.fetch(\"#{owner_screen_name}.lists\", :expires_in => 12.hours) do\n\t\t\tbegin\n\t\t\t\tlist = Twitter.lists(owner_screen_name)\n\t\t\trescue Twitter::Error::TooManyRequests\n\n\t\t\trescue Twitter::Error::NotFound\n\t\t\t\t[]\n\t\t\tend\n\t\t\tif list\n\t\t\t\tlist.collect do |item|\n\t\t\t\t\t[item.name, item.slug]\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t[]\n\t\t\tend\n\t\tend\n\tend",
"def users\n result_hash['usr']\n end",
"def users(*params)\n puts \"Users:\"\n\n @users.each do |user|\n muted = @muted_users.include?(user)\n puts \"#{user}#{muted ? ' (muted)' : ''}\"\n end\n end",
"def users\n @users ||= begin\n users = client.team_members ENV[\"GITHUB_TEAM_ID\"], :per_page => 100\n while client.last_response.rels[:next] && client.rate_limit.remaining > 0\n users.concat client.get client.last_response.rels[:next].href\n end\n users.map { |u| User.new u[:login] }\n end\n end",
"def users(target = nil)\n send_data(\"USERS #{target}\".strip)\n end",
"def users_list\n\t\t\tpost= { \"token\" => @token }\n\t\t\tdocxml = nil\n\t\t\tdocxml=nessus_request('users/list', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\tusers=Array.new\n\t\t\tdocxml.root.elements['contents'].elements['users'].each_element('//user') { |user|\n\t\t\t\tentry=Hash.new\n\t\t\t\tentry['name']=user.elements['name'].text\n\t\t\t\tentry['admin']=user.elements['admin'].text\n\t\t\t\tentry['lastlogin']=user.elements['lastlogin'].text\n\t\t\t\tusers.push(entry)\n\t\t\t}\n\t\t\treturn users\n\t\tend",
"def list_users\n response = @connection.dbreq(\"GET\", @lbmgmthost, \"#{@lbmgmtpath}/instances/#{CloudDB.escape(@id.to_s)}/users\",@lbmgmtport,@lbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n CloudDB.symbolize_keys(JSON.parse(response.body)[\"users\"])\n end",
"def public_users\n raw_users = GitHub::API.json(\"/organizations/#{self.login}/public_members\")['users']\n users = []\n\n raw_users.each do |user|\n users << GitHub::User.new(user)\n end\n\n return users\n end",
"def list\n response = @client.get(\"/users\")\n response[\"users\"].map {|u| User.new(@client, u) }\n end",
"def get_users\n users = call(CMD_GET_USERS)[:users]\n users.map {|account| User.new(account) }\n end",
"def users\n @users\n end",
"def users\n []\n end",
"def all_users\n `dscl . list /Users`.split(\"\\n\").delete_if { |e| e =~ /^_/ }\n end",
"def user_list\n execute('dscacheutil -q user') do |result|\n users = []\n result.stdout.each_line do |line|\n users << line.split(': ')[1].strip if /^name:/.match?(line)\n end\n\n yield result if block_given?\n\n users\n end\n end",
"def servers\n Server.left_outer_joins(:server_memberships)\n .where(\n 'member_id = :user_id OR owner_id = :user_id', \n user_id: self.id\n )\n .distinct\n end",
"def apps_permissions_users_list\n return {} unless !skip_info? && is_app_token? && is_not_excluded?\n semaphore.synchronize {\n @apps_permissions_users_list_raw ||= access_token.get('/api/apps.permissions.users.list')\n @apps_permissions_users_list ||= @apps_permissions_users_list_raw.parsed['resources'].inject({}){|h,i| h[i['id']] = i; h}\n }\n end",
"def users\n unless @users\n userListService = $viewContext.getViewService(OTUserListService.java_class)\n @users = userListService.getUserList().sort_by { |user| #sort users by name\n (user.name && !user.name.empty?) ? user.name.downcase.split.values_at(-1, 0) : [''] \n }\n end\n @users\n end",
"def users\n unless @users\n userListService = $viewContext.getViewService(OTUserListService.java_class)\n @users = userListService.getUserList().sort_by { |user| #sort users by name\n (user.name && !user.name.empty?) ? user.name.downcase.split.values_at(-1, 0) : [''] \n }\n end\n @users\n end",
"def users\n if design.only_unblinded\n project.unblinded_members_for_site(subject.site)\n else\n project.members_for_site(subject.site)\n end\n end",
"def all_users\n return [] if @json_data['users'].nil?\n @json_data['users'].collect { |user| [user['first'], user['last']].join(' ') }\n end",
"def index\n # specific_assigned_version_process(__callee__, params)\n @twitter_users = current_user.twitter_users.all\n end",
"def recieved_requests_users\n recieved_requests.map(&:user)\n end",
"def list_current_users *args\r\n puts \"not implemented yet\"\r\n end",
"def users\n return @canonical_user_pool if @canonical_user_pool\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Retrieving all users\"\n check_retval @user_pool.info!\n\n @canonical_user_pool = []\n @user_pool.each { |user| @canonical_user_pool << canonical_user(user) }\n @canonical_user_pool\n end",
"def users\n runner_users + corporation_users\n end",
"def users(channel)\n channel = normalized_channel_name(channel)\n @chan_mutex.synchronize { @channel_members[channel] && @channel_members[channel].keys }\n end",
"def users\n\t\t\telems = []\n\t\t\tget_resource_link(:users, \"users\", \"user\").each do |data|\n\t\t\t\telems << data\n\t\t\t\t# elems << User.new(data)\n\t\t\tend\n\t\t\telems\n\t\tend",
"def list_all_members\n @users.each { |x| puts \"-#{x.first}\"}\n end",
"def list\n log \"retrieving users list from #{users_path}\"\n response = identity_client.get(users_path)\n records = JSON.load(response.body)[\"users\"]\n records.map { |record|\n record[\"username\"]\n }.map { |username|\n Raca::User.new(@account, username)\n }\n end",
"def senders()\n _params = {}\n return @master.call 'users/senders', _params\n end",
"def list_all_users\n\n end",
"def get_repo_users\n repo_users = Array.new\n github = Github.new :oauth_token => github_token\n\n github.repos.list.body.each do |repo|\n repo_users << repo[\"owner\"][\"login\"]\n end\n\n repo_users\n end",
"def fetch_watchers\n watcher_users.to_a\n end",
"def index\n @users = current_user.sent_messages.distinct.map(&:receiver)\n @users += current_user.received_messages.distinct.map(&:sender)\n @users = @users.uniq\n end",
"def users\n res = []\n url = data['links']['roleUsers']\n tmp = GoodData.get url\n tmp['associatedUsers']['users'].each do |user_url|\n user = GoodData.get user_url\n res << GoodData::Profile.new(user)\n end\n res\n end",
"def get_my_friends(token)\n @graph = Koala::Facebook::API.new(token)\n @friends = @graph.get_connections('me', 'friends')\n @ids = []\n @friends.each {|f| @ids << f['id']}\n @users = []\n User.all.each {|u| @users << u if @ids.include?(u.uid) }\n return @users\n end",
"def unique_users\n result = {}\n\n each_value {|channel|\n channel.users.each {|nick, user|\n result[nick] = user.client\n }\n }\n\n return result\n end",
"def all(instance)\n data = service.list_users(instance).to_h[:items] || []\n load(data)\n end",
"def users(list_id)\n Iterable.request(conf, '/lists/getUsers', listId: list_id).get\n end",
"def winner_usernames\n return winners.map {|p| p.username}\n end",
"def returning_users\n []\n end",
"def employees\n emps = []\n url = prefix + \"liste\"\n users = response(url)\n if users.class == Array #success\n users.each do |u|\n emps << ShareUser.new(u[\"id\"], @authid, @subdomain)\n end\n return emps\n else #failed\n return users\n end\n end",
"def members(show_staged=false)\n invites = show_staged ? self.org_invites.active_or_staged : self.org_invites.active\n [self.users, invites.to_a].flatten\n end",
"def users\n if text?\n server.online_members(include_idle: true).select { |u| u.can_read_messages? self }\n elsif voice?\n server.voice_states.map { |id, voice_state| server.member(id) if !voice_state.voice_channel.nil? && voice_state.voice_channel.id == @id }.compact\n end\n end",
"def users\n user_arr = []\n subscriptions.each do |s|\n user_arr << User.find(s.user.id)\n end\n user_arr\n end",
"def all_users\n result = []\n api.search(accounts_dn, ::LDAP::LDAP_SCOPE_SUBTREE, accounts_filter) do |user|\n result << user.to_hash\n end\n result\n end",
"def list_users\n self.class.get('/users')\n end",
"def getUserList\n @userList\n end",
"def users\n return @users\n end",
"def all_people_scheduled\n Entry.users_for_client(self.id)\n end",
"def all\n xml_doc.xpath('/MediaContainer/User').map {|n| [n['email'],n['username']] }\n end",
"def get_random_user_list \n @users = user_list.sample(5).insert(rand(5), {name: \"ME\", bot: false})\n end",
"def get_user_info(list)\n\trequire 'net/http'\n\tNet::HTTP.get(ENV[\"VERITAS-USER-SERVER\"] + \"/users?user_ids=#{list}\")\nend",
"def users\n get('get_users')\n end",
"def users\n GroupMembers.new(:id => id).get.items\n end",
"def clients\n clis = []\n url = prefix + \"listc\"\n users = response(url)\n if users.class == Array #success\n users.each do |u|\n clis << User.new(u[\"id\"], @authid, @subdomain, u)\n end\n return clis\n else #failed\n return users\n end\n end",
"def contributor_usernames\n @contributor_usernames ||= contributors.map(&:username)\n end",
"def list_users\n @users = User.find(:all)\n end",
"def wholist( user )\n\t\trval = \"[Connected Users]\\n\" <<\n\t\t\t\" *#{user}*\\n\"\n\t\t@users.each {|u|\n\t\t\tnext if u == user\n\t\t\trval << \" #{u}\\n\"\n\t\t}\n\n\t\treturn rval\n\tend",
"def get_user_list\n return User.find(:all, :order => 'last_name ASC').collect {|user| [user.full_name, user.id]}\n end",
"def wholist( user )\n\t\trval = \"[Connected Users]\\n\" <<\n\t\t \" *#{user}*\\n\"\n\n\t\t@users.each do |u|\n\t\t\tnext if u == user\n\t\t\trval << \" #{u}\\n\"\n\t\tend\n\n\t\treturn rval\n\tend",
"def list\n\t\t# retrieve all users\n @users = User.find(:all)\n end",
"def fetch_users\n fetch_assignee + fetch_watchers\n end",
"def stakeholders\n self.stakeholder_ids.collect{|user_id| User.find(user_id)}\n end",
"def names\n @users.values.map(&:name)\n end"
] | [
"0.7453593",
"0.7089753",
"0.68664044",
"0.6681071",
"0.66530734",
"0.65349287",
"0.65217024",
"0.6470246",
"0.6450175",
"0.6442677",
"0.6370006",
"0.63691556",
"0.6362759",
"0.633017",
"0.633017",
"0.6301922",
"0.6262014",
"0.6259862",
"0.6259451",
"0.6254173",
"0.62533486",
"0.6243795",
"0.62335116",
"0.62293965",
"0.620869",
"0.61918485",
"0.6187336",
"0.61781216",
"0.61689025",
"0.6150379",
"0.6141423",
"0.61395603",
"0.6106551",
"0.61052895",
"0.61026925",
"0.6099322",
"0.60631084",
"0.6060676",
"0.60597795",
"0.60595834",
"0.605473",
"0.60496086",
"0.60471576",
"0.6019898",
"0.60146",
"0.60129356",
"0.6009272",
"0.60067105",
"0.60055596",
"0.60021204",
"0.59885734",
"0.59763545",
"0.59763545",
"0.59707075",
"0.59495467",
"0.5944965",
"0.5944543",
"0.5940688",
"0.59393",
"0.59362847",
"0.59212756",
"0.5916665",
"0.591066",
"0.591006",
"0.58996516",
"0.5879201",
"0.58789784",
"0.5875258",
"0.5871848",
"0.58693296",
"0.58575535",
"0.5857337",
"0.58529615",
"0.5846826",
"0.5835524",
"0.58329874",
"0.58144206",
"0.578884",
"0.57885575",
"0.57817876",
"0.57740384",
"0.5772056",
"0.5766311",
"0.5756632",
"0.5749022",
"0.57440406",
"0.5741992",
"0.57410127",
"0.5740216",
"0.5739234",
"0.5738479",
"0.57371825",
"0.5735115",
"0.5730082",
"0.57204974",
"0.5718617",
"0.57177293",
"0.5716907",
"0.5713693",
"0.5702665"
] | 0.6338713 | 13 |
The list of servers the bot is currently in. | def servers
gateway_check
unavailable_servers_check
@servers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def servers\n servers_for\n end",
"def servers\n @servers.keys\n end",
"def servers\n servers_by_name.values\n end",
"def list_known_servers\n connect.servers.all\n end",
"def servers\r\n @servers.values\r\n end",
"def servers\n @servers ||= execute_remote!(command(:servers)).each_line.map { |line| JSON.parse line }\n end",
"def servers\n configuration.servers\n end",
"def servers\n @_servers ||= []\n end",
"def servers\n @_servers ||= []\n end",
"def all_servers\n Infrataster::Server.defined_servers.map { |i| server(i.name) }\nend",
"def servers\n @servers.select { |server| server.operable? }\n end",
"def servers\n list = []\n Penctl.execute(@pen, \"servers\", 5).each do |l| \n server = Penctl.parse_server_line(l)\n list[server[:slot]] = server\n end\n list.compact\n end",
"def servers\n server_structs.map do |server|\n inspect_server(server)\n end\n end",
"def servers\n @config['servers'].map { |server| server.split(/:/) }\n end",
"def all_server_hosts\n [server_host]\n end",
"def servers\n response = get \"server\"\n data = JSON.parse response.body\n data[\"servers\"][\"server\"]\n end",
"def servers\n response = get \"server\"\n data = JSON.parse response.body\n data[\"servers\"][\"server\"]\n end",
"def servers\n gateway_check\n @servers\n end",
"def servers # Only in Ruby API (1.3 compatible)\n\t\t@settings.servers\n\tend",
"def get_servers\n\t\t\tbegin\n\t\t\t\tresp = @rs_conn.get('/servers')\n\n\t\t\t\t# 200 Success :: anything else is failure\n\t\t\t\tunless resp.code == \"200\"\n\t\t\t\t\traise \"Error requesting server list. Error code #{resp.code}\"\n\t\t\t\tend\n\t\t\t\t# Convert the output to json\n\t\t\t\tserver_list = JSON.parse(resp.body)\n\t\t\t\treturn server_list\n\t\t\trescue Exception => e\n\t\t\t\traise e\n\t\t\tend\n\t\tend",
"def servers\n endpoint.config.nodes.map(&:to_s)\n end",
"def index\n @servers = @site.servers\n end",
"def available_servers\n authenticate_user!\n @rackspace_servers = Server.rackspace_servers\n end",
"def getServers(admin)\n serverInfos = admin.getClusterStatus().getServerInfo()\n servers = []\n for server in serverInfos\n servers << server.getServerName()\n end\n return servers\nend",
"def servers(token)\n request(\n __method__,\n :get,\n \"#{api_base}/users/@me/guilds\",\n Authorization: token\n )\n end",
"def all_servers\n if is_zz?\n return app_config[:all_servers]\n end\n\n return @all_servers if @all_servers != nil\n\n instances = ey['environment']['instances']\n\n # collect all the app server hosts\n @all_servers = []\n instances.each do |instance|\n @all_servers << instance['private_hostname']\n end\n # add ourselves if we have no info, running on dev box\n @all_servers << this_host_name if @all_servers.empty?\n\n @all_servers\n end",
"def servers\n response = self.class.get(\"/#{self.class.account}/clients.xml\")\n response['clients'].map { |client| ScoutScout::Server.new(client) }\n end",
"def servers\n sync{@servers.keys}\n end",
"def servers\n endpoint = 'https://pcs.baidu.com/rest/2.0/pcs/manage?method=listhost'\n @res = @api.request_json( endpoint )\n end",
"def all_servers\n if @all_servers_cache.nil?\n @all_servers_cache=[]\n CLOUD_NAME.keys.each do |name|\n read(\"servers/#{name.to_s.upcase}\")[:data].each do |i|\n @all_servers_cache.push(i)\n end\n end\n end\n return @all_servers_cache\n end",
"def servers\n return self.bare_metal_servers + self.virtual_servers\n end",
"def name_servers\n Array(@gapi.name_servers)\n end",
"def servers(backend = nil)\n my_servers = []\n if backend.nil?\n # return all servers\n backend_instances.each_value do | backend|\n my_servers << backend.server_names\n end\n else\n begin\n my_servers = backend_instances[backend].server_names\n rescue KeyError => e\n \"The backend #{backend} is not a valid argument\"\n end\n end\n # return a list of serv\n my_servers.flatten.uniq\n end",
"def getRegionServers\n @admin.getClusterMetrics.getLiveServerMetrics.keySet.map { |server_name| server_name }\n end",
"def servers\n server_structs.each do |server|\n def server.alive?\n next_retry <= Time.now\n end\n end\n end",
"def getYPServers()\n ypserverplugin = \"org.cougaar.yp.YPServer\"\n servers = []\n @run.society.each_agent do |agent|\n puts agent.name\n agent.each_component do |component|\n if (component.classname == ypserverplugin) then\n servers.push(agent.name)\n end \n end\n end\n servers\n end",
"def get_servers\n\n if @settings.auto_server_ranking\n\n @self_auto_ranking = 'y'\n\n # if possible fetch server ranked list from cache\n path = get_cache_base_path() + File::SEPARATOR + 'servers'\n\n if File.readable?(path) &&\n (@settings.auto_server_ranking_lifetime == 0 ||\n File.mtime(path) > (Time.now() -\n (60 + [-5,5].sample)*@settings.auto_server_ranking_lifetime))\n\n servers = JSON.parse(File.read(path), :symbolize_names => true)\n\n if !servers.nil?\n @ranking_status = 'A'\n return servers\n end\n\n end\n\n # no or expired server ranked list - rank servers\n servers = rank_servers()\n\n if !servers.nil?\n return servers\n end\n\n end\n\n # check if manual list is cached or not\n # manual list is cached and used for some time when top server fails\n path = get_cache_base_path() + File::SEPARATOR + 'servers-manual'\n if File.readable?(path) &&\n @settings.server_phaseout_lifetime > 0 &&\n File.mtime(path) >\n (Time.now() - (60 + [-5,5].sample)*@settings.server_phaseout_lifetime)\n\n servers = JSON.parse(File.read(path), :symbolize_names => true)\n\n if !servers.nil?\n @ranking_status = 'M'\n return servers\n end\n\n end\n\n # default list\n @ranking_status = 'D'\n return @settings.servers\n\n end",
"def servers(servers)\n servers.select{ |server| server.mongos? }\n end",
"def list_unknownservers\n @admin.listUnknownServers.to_a\n end",
"def name_servers\n response = @client.rest_get(@data['uri'] + '/nameServers')\n response.body\n end",
"def getAllServers(targethost = Model::TARGETHOST)\n if @@serverList.nil?\n @@serverList = ZMProv.new('-l', 'gas', targethost).run[1].split(/\\n/)\n end\n \n @@serverList\n end",
"def servers_selected\n @_servers_selected ||=[]\n end",
"def index\r\n @servers = Server.all\r\n end",
"def index\n @servers = Server.all\n end",
"def index\n @servers = Server.all\n end",
"def index\n @servers = Server.all\n end",
"def index\n @servers = Server.all\n end",
"def index\n @servers = Server.all\n end",
"def all_app_servers\n if is_zz?\n return app_config[:app_servers]\n end\n\n return @all_app_servers if @all_app_servers != nil\n @app_server_types ||= Set.new [ 'solo', 'app', 'app_master' ].freeze\n\n instances = ey['environment']['instances']\n\n # collect all the app server hosts\n @all_app_servers = []\n instances.each do |instance|\n if @app_server_types.include?(instance['role'])\n @all_app_servers << instance['private_hostname']\n end\n end\n # add ourselves if we have no info, running on dev box\n @all_app_servers << this_host_name if @all_app_servers.empty?\n\n @all_app_servers\n end",
"def configured_servers\n\t\thosts = self.configured_hosts\n\t\treturn Mongrel2::Config::Server.where( id: hosts.select(:server_id) )\n\tend",
"def discovered_servers\n server_pool.select {|s| s[:discovered] }\n end",
"def list_liveservers\n @admin.getClusterMetrics.getLiveServerMetrics.keySet.to_a\n end",
"def servers\n result = Gorillib::ModelCollection.new(item_type: Ironfan::Dsl::Server, key_method: :full_name)\n facets.each{ |f| f.servers.each{ |s| result << s } }\n result\n end",
"def guilds\n @obj['guilds']\n end",
"def server\n arrayCommand( \"show server\", DictArray, RESPONSE_SERVER_INFO_FOLLOWS )\n end",
"def server\n arrayCommand( \"show server\", DictArray, RESPONSE_SERVER_INFO_FOLLOWS )\n end",
"def listNodes\n nodes = []\n me = MU::Cloud::AWS::ServerPool.find(cloud_id: cloud_id).values.first\n if me and me.instances\n me.instances.each { |instance|\n found = MU::MommaCat.findStray(\"AWS\", \"server\", cloud_id: instance.instance_id, region: @region, dummy_ok: true)\n nodes.concat(found)\n }\n end\n nodes\n end",
"def domains_slaves_list\n Hash[\n call('domains.slaves.list')[:domains].map do |item|\n [item[:domain], item[:masterip]]\n end\n ]\n end",
"def proxmox_servers\n @proxmox_servers\n end",
"def cluster_servers\n endpoint.config.nodes.map { |h| \"#{h[:host]}:#{h[:port]}\" }\n end",
"def vservers\n @vservers=get_endpoint('vservers').keys\n end",
"def services\n services = RingyDingy::RingServer.list_services\n return [] if services.empty?\n\n services = RingyDingy::RingServer.list_services.values.first.uniq\n\n rrc_servers = services.select do |_, klass,|\n klass == RailsRemoteControl::Server::RINGY_DINGY_SERVICE\n end\n\n rrc_servers.map do |_, _, server, name|\n host, pid, = name.split '_', 3\n Server.new host, pid.to_i, server\n end\n end",
"def clients\n command('.clients').split(\"\\n\")\n end",
"def enterprise_proxy_servers\n return @enterprise_proxy_servers\n end",
"def servers_detailed()\n return get_request(address(\"/servers/detail\"), @token)\n end",
"def server_structs\n array = []\n if @struct.hosts\n @struct.hosts.count.times do |i|\n array << Lib.memcached_select_server_at(@struct, i)\n end\n end\n array\n end",
"def storage_servers\n self.client.get('gh.storage.servers').split(',')\n end",
"def select_server\n compute.servers.map { |s| [s.name, s.id] }\n end",
"def server_commands\n @server_commands ||= []\n end",
"def enterprise_internal_proxy_servers\n return @enterprise_internal_proxy_servers\n end",
"def guilds\n @data['guilds']\n end",
"def inners\n @inners\n end",
"def available_connections(server=:default)\n @available_connections[server]\n end",
"def list_deadservers\n @admin.listDeadServers.to_a\n end",
"def builds\n servers.flat_map { |server| server.builds }\n end",
"def memcached_servers\n %w(127.0.0.1:11211)\n end",
"def index\n @app_servers = AppServer.all\n end",
"def getServerNames(servers, should_return_all_if_servers_empty)\n regionservers = getRegionServers\n servernames = []\n\n if servers.empty?\n # if no servers were specified as arguments, get a list of all servers\n if should_return_all_if_servers_empty\n servernames = regionservers\n end\n else\n # Strings replace with ServerName objects in servers array\n i = 0\n while i < servers.length\n server = servers[i]\n\n if ServerName.isFullServerName(server)\n servernames.push(ServerName.valueOf(server))\n else\n name_list = server.split(',')\n j = 0\n while j < regionservers.length\n sn = regionservers[j]\n if name_list[0] == sn.hostname && (name_list[1].nil? ? true : (name_list[1] == sn.port.to_s))\n servernames.push(sn)\n end\n j += 1\n end\n end\n i += 1\n end\n end\n\n servernames\n end",
"def servers\n Vultr::Resource::Server.new(@faraday)\n end",
"def listen_servers\n\t\tunless @master && !@sync\n\t\t\tputs \"Sincronizando lista de servidores\"\n\t\t\tbegin\n\t\t\t\tminiSocket = TCPSocket.new(Connections::SERVER_IP[0], @port+1)\n\t\t\trescue Errno::ETIMEDOUT => e\n\t\t\t\tputs \"No se pudo relizar la Sincronizacion\"\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\t# Resivimos la lista de Servidores\n\t\t\tres = IO.select([miniSocket], [miniSocket], nil, 10)\n\t\t\tif res != nil\n\t\t\t\t@arry_ips = miniSocket.gets.chomp.split(\" \")\n\t\t\tend\n\t\t\tputs \"Sincronizacion terminada\"\n\t\tend\n\tend",
"def other_server_hosts\n @other_server_hosts ||= all_server_hosts.reject {|x| x == server_host}\n end",
"def candidate_servers\n @candidate_servers.select { |s| !['Unknown', 'PossiblePrimary'].include?(s['type']) }\n end",
"def hosts\n @hosts.values\n end",
"def connected_servers\n related_servers.reject(&:missing_network_topology?)\n end",
"def slaves\n (self[\"slaves\"] || []).map do |options|\n Mongo::Connection.from_uri(uri(options), optional(true).symbolize_keys).tap do |conn|\n conn.apply_saved_authentication\n end\n end\n end",
"def active_remotes\n @remote_forwarded_ports.keys\n end",
"def http_servers\r\n HTTPServersController.instance\r\n end",
"def non_ha_server_identities\n group_instance.server_identities.uniq\n end",
"def joined_guilds\r\n @cache.get(:guilds, lifetime: DList::CACHE_LIFETIME) do\r\n DList._get('/users/me/guilds', @token)\r\n end\r\n end",
"def servers\n Server.left_outer_joins(:server_memberships)\n .where(\n 'member_id = :user_id OR owner_id = :user_id', \n user_id: self.id\n )\n .distinct\n end",
"def server\n servers[0]\n end",
"def hosts(args = nil)\n if args and args[:server]\n args[:server].split(';').collect { |server| $hosts[server] ||\n Config.warn_fail(\"#{server} is not a known host\") }\n else\n $hosts.values\n end\nend",
"def slaves\n connection_without_read_from_slave.instance_variable_get(:@config)[:slaves] || {}\n end",
"def domains_slave_names\n domains_names = []\n self.domains.slave.each do |domain|\n domains_names.push domain.name\n end\n domains_names\n end",
"def details\n data = servers_client.get(server_path, json_headers).body\n JSON.parse(data)['server']\n end",
"def servers(service_id)\n request :get, \"/services/#{service_id}/servers\"\n end",
"def hosts\n @hosts ||= []\n end",
"def servers=(servers)\r\n @servers = {}\r\n servers.each{|s| @servers[s.host] = s}\r\n end",
"def sessions\n threads = servers.map { |server| Thread.new { server.session(true) } if server.session.nil? }\n threads.each { |thread| thread.join if thread }\n servers.map { |server| server.session }.compact\n end",
"def servers(servers)\n servers.select do |server|\n (replica_set_name.nil? || server.replica_set_name == replica_set_name) &&\n server.primary? || server.secondary?\n end\n end"
] | [
"0.8201467",
"0.8065964",
"0.80123717",
"0.79888934",
"0.7987453",
"0.79544026",
"0.7818131",
"0.78065455",
"0.78065455",
"0.78004616",
"0.77382463",
"0.7703609",
"0.761837",
"0.75812453",
"0.7504051",
"0.7484996",
"0.7484996",
"0.74728686",
"0.74665624",
"0.7406516",
"0.73290586",
"0.72876436",
"0.71913713",
"0.7185445",
"0.7167654",
"0.7106991",
"0.71024823",
"0.7093656",
"0.7089082",
"0.7080975",
"0.7050055",
"0.6994787",
"0.6987711",
"0.6969922",
"0.6952013",
"0.6912595",
"0.69049245",
"0.6864787",
"0.6860871",
"0.6840257",
"0.68245447",
"0.6820557",
"0.67982733",
"0.6791465",
"0.6791465",
"0.6791465",
"0.6791465",
"0.6791465",
"0.67536974",
"0.67213607",
"0.672126",
"0.66890067",
"0.6661038",
"0.6599639",
"0.6596285",
"0.6596285",
"0.6583942",
"0.6574386",
"0.6544467",
"0.6542219",
"0.6533115",
"0.651622",
"0.6512222",
"0.65074253",
"0.6490571",
"0.6488227",
"0.642071",
"0.63461775",
"0.63418883",
"0.6337137",
"0.6309604",
"0.63057333",
"0.62891054",
"0.626862",
"0.62588614",
"0.6243566",
"0.6239334",
"0.62335646",
"0.62301284",
"0.6192477",
"0.6178588",
"0.61677897",
"0.6153412",
"0.6151214",
"0.6150059",
"0.6147948",
"0.61288744",
"0.61265653",
"0.6113262",
"0.6104788",
"0.61008453",
"0.6100743",
"0.6100591",
"0.6093182",
"0.60691464",
"0.60646045",
"0.60629845",
"0.6060334",
"0.60560036",
"0.605483"
] | 0.7339068 | 20 |
Finds an emoji by its name. | def find_emoji(name)
LOGGER.out("Resolving emoji #{name}")
emoji.find { |element| element.name == name }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_emoji?(emoji)\n Emoji.find_by_name emoji\n end",
"def find_emoji(key, server = nil)\n server = server || $bot.servers[SERVER_ID] || $bot.servers.first\n return if server.nil?\n if key.is_a?(Integer)\n server.emojis[key]\n elsif key.is_a?(String)\n server.emojis.find{ |id, e| e.name.downcase.include?(key.downcase) }[1]\n else\n nil\n end\nrescue\n nil\nend",
"def emoji\n if failure?\n FAILURE_EMOJI\n else\n ERROR_EMOJI\n end\n end",
"def find_by_name( name )\n\t\t\tnamed_message = nil\n\t\t\t@messages.values.each do |message|\n\t\t\t\tif message.descriptor.name == name\n\t\t\t\t\tnamed_message = message\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn named_message\n\t\tend",
"def find_by_name(name)\n return nil unless name.present?\n names.select {|e| e == name}\n end",
"def find(name)\n m = match(name)\n m.count == 1 ? m[0] : nil\n end",
"def replace_emoji(text)\n emojis = Mumuki::Emojis::EMOJIS\n text.gsub(/:([^\\s:])+:/) do |short_name|\n short_code = short_name.gsub(':', '')\n emoji = emojis[short_code]\n if emoji\n %{<i class=\"mu-emoji #{emoji['ca']} _#{emoji['co']}\" title=\"#{short_name}\"></i>}\n else\n short_name\n end\n end\n end",
"def find_by_name(name)\n find_by('name', name)\n end",
"def emoji_for_species(string)\n case string.downcase.strip\n when 'wolf', /\\swolf/\n '🐺'\n when 'gorilla', /\\sgorilla/\n '🦍'\n when 'rhino', 'rhinoceros', /\\srhino/, /\\srhinoceros/\n '🦏'\n when 'owl', /\\sowl/\n '🦉'\n when 'lion', /\\slion/\n '🦁'\n when 'tiger', /\\stiger/\n '🐯'\n when 'octopus', /\\soctopus/\n '🐙'\n when 'chicken', /\\schicken/\n '🐓'\n when 'dog', /\\sdog/\n '🐶'\n when 'human', /\\shuman/\n '👮'\n when 'eagle', /\\seagle/\n '🦅'\n when 'fish', /\\sfish/\n '🐟'\n when 'unicorn', /\\sunicorn/\n '🦄'\n else\n '❓'\n end\nend",
"def get_japanese_emoticon(emoji_file,emoticon)\n # code goes here\n \n emoji_hash = load_library(emoji_file)\n emoji_hash.each do |key, value|\n #binding.pry\n if value[:english] == emoticon\n return value[:japanese]\n end\n end\n return \"Sorry, that emoticon was not found\"\nend",
"def find_by_name(name)\n end",
"def admin_emoji_remove(options = {})\n raise ArgumentError, 'Required arguments :name missing' if options[:name].nil?\n post('admin.emoji.remove', options)\n end",
"def find(name); end",
"def find_stemcell_by_name(name)\n stemcell = list_stemcells.find do |image_name|\n image_name == name\n end\n\n raise Bosh::Clouds::CloudError, \"Given image name '#{name}' does not exist!\" if stemcell.nil?\n stemcell\n end",
"def include_emoji?(text)\n text && text[/:\\S+:/]\n end",
"def fetch_character_by_name(name)\n uri = URI(BASE_URI + \"?name=#{name}\")\n characters = make_request(uri)\n if characters[0]\n Character.new(characters[0])\n else\n \"Couldn't find a character with that name...\"\n end\n end",
"def find(typed_name)\n nil\n end",
"def get_japanese_emoticon(file_path, emoticon)\n emoji_library = load_library(file_path)\n emoji_equivalent = emoji_library[\"get_emoticon\"][emoticon]\n return \"Sorry, that emoticon was not found\" if emoji_equivalent.nil?\n emoji_equivalent\nend",
"def find(name)\n request = Message::Find.new(Thread.mailbox, name)\n methods = send_request request\n return nil if methods.is_a? NilClass\n rsocket # open relay pipe to avoid race conditions\n actor = DCell::ActorProxy.create.new self, name, methods\n add_actor actor\n end",
"def emojis\n @emojis ||= EmojiData.find_by_str(self.text).uniq { |e| e.unified }\n end",
"def find_badge(name)\n badge_name = name.delete(\" \").downcase #delete whitespace\n return name unless badges.has_key?(badge_name)\n badges[badge_name] \n end",
"def find_by_name(name)\n # this works because of `def item.=='\n item = @set.find { |c| c == name }\n item\n end",
"def emoji; end",
"def find_by_name(name)\n raise TypeError, 'name must respond to #to_sym' unless name.respond_to?(:to_sym)\n name = name.to_sym\n \n all.find { |event_class| event_class.name == name }\n end",
"def get_japanese_emoticon(file, emoticon_input)\n \n emoticons = load_library(file)\n emoticons.each do |key, value|\n if emoticon_input == emoticons[key][:english]\n #binding.pry\n return emoticons[key][:japanese]\n end\n end\n return \"Sorry, that emoticon was not found\"\n \nend",
"def find_player(name)\n all_players.find {|player| name == player.fetch(:player_name)}\nend",
"def find_by_name(name)\n find do |event|\n event.job_class_name == name.to_s\n end\n end",
"def search_for_character(channel, person)\n if @rooms[channel]['characters'].include? person\n return person\n else\n re = /\\A#{Regexp.escape(person)}\\z/i\n @rooms[channel]['characters'].each { |char|\n if char =~ re\n return char\n end\n }\n end\n return nil\n end",
"def find_name name\n find_element :name, name\n end",
"def find_by_name(name)\n #@@artist.detect{|a| a.name == name}\n all.detect{|a| a.name == name}\n end",
"def slack_emoji\n @slack_emoji ||= EmojiDiffer::SlackApi.new(@slack_token).emoji\n end",
"def find_action_by_name(name)\n actions.find { |act| act.name == name }\n end",
"def find_player_by_name!(name)\n find_player_by_name(name) || raise(MissingTarget, name)\n end",
"def get_japanese_emoticon(file_name, emote)\n emoticons = load_library(file_name)\n if emoticons[\"get_emoticon\"][emote]\n return emoticons[\"get_emoticon\"][emote]\n else\n return \"Sorry, that emoticon was not found\"\n end\nend",
"def find_player(name)\n for footballer in @players\n return footballer if @players.include?(name)\n end\n end",
"def find_by_name(name)\n all.find { |device| name == device.name }\n end",
"def find_command( name )\n commands.each { |cmd| return cmd if cmd.name == name }\n nil\n end",
"def find_event(event_name)\n @events.find { |event| event.name.to_s == event_name.to_s }\n # TODO: use a data structure that prevents duplicates\n end",
"def find_by_name(name)\n matching = country_codes.select do |k, v|\n [*v].include? name\n end || {}\n\n # ruby 1.8\n returner = ItuCodes::Helpers.keys_from_hash(matching)\n\n if returner.size <= 1\n returner.first\n else\n returner\n end\n end",
"def find_idex_of_font(searched_font)\n @fonts.find_index { |font| font == searched_font }\nend",
"def find_item(name)\n items.find do |item|\n item.name == name ||\n item.short_name.gsub('…','') == name.gsub('…','')\n end\n end",
"def match(name)\n query(FindByString: name)\n end",
"def find_by_name(name)\n for item in self.collection\n return item if item.name == name\n end\n\n # didn't find item in collection, return nil\n return nil\n end",
"def find_name(arr, name)\n arr.each { |p| return p if (p.to_s == name) }\n puts \"Error: find_name cannot find #{name}\"\n $stdout.flush\nend",
"def find name\n object = objects.find { |o| o.name == name.to_s }\n end",
"def find(name)\n @users.fetch(name)\n end",
"def find_char_data(character_name, response_hash)\n titleized_character_name = character_name.split.map { |word| word.capitalize }.join(' ')\n response_hash[\"results\"].find {|char_data| char_data[\"name\"] == titleized_character_name}\nend",
"def find_by_name(name)\n types[name]\n end",
"def find(name)\n instances.find { |instance| instance.name == (name) }\n end",
"def find( name )\n @commands.find { |klass| klass.command_name == name }\n end",
"def lookup_message(name)\n\t\tend",
"def find(name)\n @boxes.each do |box|\n return box if box.name == name\n end\n\n nil\n end",
"def find(name)\n @boxes.each do |box|\n return box if box.name == name\n end\n\n nil\n end",
"def emoji_image_from_unicode(unicode)\n emoji = Emoji.find_by_unicode(unicode)\n\n if emoji && !EMOJI_IGNORE.include?(emoji.name)\n name = \":#{emoji.name}:\"\n path = File.join(@options[:emoji_asset_path], emoji.image_filename)\n\n %(<img alt=\"#{name}\" title=\"#{name}\" src=\"#{path}\" class=\"emoji\" width=\"20\" height=\"20\" />)\n else\n unicode\n end\n end",
"def emoji_image_filter(text)\n text.gsub(emoji_pattern) do |match|\n name = $1\n \"<span class='emoji'>#{emoji_unicode_replacement(name)}</span>\"\n end\n end",
"def emoji(year)\n int_year = validate_year(year)\n HASH[name(int_year)]\n end",
"def symbol_by_name(name)\n each_symbols.find { |symbol| symbol.name == name }\n end",
"def find_room_by_name(name)\n rooms.detect {|room| room.name == name }\n end",
"def diff\n cache_names = cache_emoji.map { |emoji| emoji.name }\n slack_emoji.map { |emoji| cache_names.include?(emoji.name) }\n end",
"def player_by_name name\n @players.select {|p| p.name == name}.first\n end",
"def get_japanese_emoticon(yml_path, emoticon)\n library = load_library(yml_path)\n emoticon = library.keys.find do |key|\n library[key][:english] == emoticon\n end\n emoticon ? library[emoticon][:japanese] : \"Sorry, that emoticon was not found\"\nend",
"def find_by_name(name)\n service = DNSSD::Service.browse(self::MDNS_TYPE)\n service.each(self::MDNS_TIMEOUT).each do |browse_reply|\n resolve_reply = resolve(browse_reply)\n\n if resolve_reply.text_record[\"name\"] == name\n return Printer.new(get_address(resolve_reply), resolve_reply.text_record)\n end\n end\n\n nil\n ensure\n service.stop if service\n end",
"def find_token_by_name(name)\n self.tokens.where(name: name.to_s).first\n end",
"def screen_name(name)\n find :screen_name => name\n end",
"def get_japanese_emoticon(file_path, emoticon)\n load_library(file_path).each do |emotion, char_hash|\n # binding.pry\n # returns the Japanese equivalent of an English grinning\n # i am given \":)\" in emoticon argument, which is found in get_emoticon\n char_hash.each do |original, translation|\n if original == emoticon\n return translation\n end\n end\n # binding.pry\n end\n\n if load_library(file_path).include?(emoticon) == false\n \"Sorry, that emoticon was not found\"\n end\nend",
"def get_english_meaning(file, emoticon_input)\n emoticons = load_library(file)\n emoticons.each do |key, value|\n if emoticon_input == emoticons[key][:japanese]\n #binding.pry\n return key\n end\n end\n return\"Sorry, that emoticon was not found\"\nend",
"def find_by_french_name(name)\n ISO_639_2.detect do |entry|\n entry if entry.french_name == name\n end\n end",
"def find_by_french_name(name)\n ISO_639_2.detect do |entry|\n entry if entry.french_name == name\n end\n end",
"def get_english_meaning(path, symbol)\n each_emoticon = load_library(path)\n \n each_emoticon.each do |name, value|\n \n if each_emoticon[name][:japanese] == symbol\n return name\n end \n \n end\n \n \"Sorry, that emoticon was not found\"\nend",
"def find_matching(collection, name)\n collection.each do |single|\n return single if single.id == name\n return single if single.name == name\n return single if name.is_a?(Regexp) && name =~ single.name\n end\n @logger.error \"Flavor '#{name}' not found\"\n nil\n end",
"def find_by_name(name)\n binding.pry\n self.name\n end",
"def findname(name)\n found = @names.find { |_ky, vl| vl == name }\n return nil unless found\n\n { id: (id = found[0]), name: name, pw: @passwords[id], email: @emails[id] }\\\n end",
"def find(name)\n all.find { |pattern| pattern.name.to_s.downcase == name.to_s.downcase }\n end",
"def find_player(players, name)\n players.find do |player|\n player[:player_name] == name\n end\nend",
"def get_japanese_emoticon(file_path,emoticon)\n library = load_library(file_path)\n library.each do |key, value|\n if value[:english] == emoticon\n return value[:japanese]\n end\n end\n return \"Sorry, that emoticon was not found\"\nend",
"def find(name)\n list[name]\n end",
"def find_by_spanish_name(name)\n ISO_639_2.detect do |entry|\n entry if entry.spanish_name == name\n end\n end",
"def find_subcommand(name)\n subcommands_for_command_lookup.find { |sc| sc.command == name }\n end",
"def find_channel(name)\n if name.include? '/'\n sid, cid = name.split('/')\n\n server = discord.servers[sid.to_i]\n server ||= (discord.servers.find { |_i, s| s.name.downcase.tr(' ', '~') == sid.downcase } || [])[1]\n return unless server\n\n chan = server.channels.find { |c| [c.id.to_s, c.name].include? cid }\n return unless chan\n\n DiscordChannelShim.new chan\n else\n chans = channel_list.select { |c| c.name == name }\n if chans.count == 1\n chans.first\n elsif chans.count > 1\n chans\n end\n end\n end",
"def find_channel(name)\n if name.include? '/'\n sid, cid = name.split('/')\n\n server = discord.servers[sid.to_i]\n server ||= (discord.servers.find { |_i, s| s.name.downcase.tr(' ', '~') == sid.downcase } || [])[1]\n return unless server\n\n chan = server.channels.find { |c| [c.id.to_s, c.name].include? cid }\n return unless chan\n\n DiscordChannelShim.new chan\n else\n chans = channel_list.select { |c| c.name == name }\n if chans.count == 1\n chans.first\n elsif chans.count > 1\n chans\n end\n end\n end",
"def get_japanese_emoticon(path, emoticon)\n # load the data into a hash\n data = load_library(path)\n # Loop through all the data\n data.each do |key, value|\n #if there is a match for the english emoticon then return the japanese variant\n if value[:english] == emoticon\n return value[:japanese]\n end\n end\n # if the emoticon is not found a sorry message is returned\n return \"Sorry, that emoticon was not found\"\nend",
"def find_matching(collection, name)\n item = collection.find do |single|\n single.id == name ||\n single.name == name ||\n (name.is_a?(Regexp) && name =~ single.name)\n end\n\n # If it is not present in collection, it might be a non-standard image/flavor\n if item.nil? && !name.is_a?(Regexp)\n item = collection.get escape_name_if_necessary(name)\n end\n\n item\n end",
"def find_key(name)\n logger.debug \"Finding key #{name}\" if @mydebug\n user.keys.each { |key| return key if key.name == name }\n\n raise RHC::KeyNotFoundException.new(\"Key #{name} does not exist\")\n end",
"def find_name(data, name)\n found = false\n data.each do |champ|\n if champ[1].downcase == name\n puts \">>> \" + champ[1] + \", \" + champ[2]\n found = true\n return champ[0].to_i\n end\n end\n if not found\n puts name + \" was not found. Please try again!\"\n end\n return -1 \nend",
"def find_by_english_name(name)\n ISO_639_2.detect do |entry|\n entry if entry.english_name == name\n end\n end",
"def find_by_english_name(name)\n ISO_639_2.detect do |entry|\n entry if entry.english_name == name\n end\n end",
"def SmileyExist(smiley)\n uri = URI('http://www.emoji-cheat-sheet.com/graphics/emojis/'+smiley+'.png')\n res = Net::HTTP.get_response(uri)\n\n if res.code == '200'\n return true\n else\n return false\n end\n end",
"def element_named(name)\n @elements.find{|e| e.name.to_s == name.to_s}\n end",
"def get_english_meaning(file_path, emoticon_symbol)\n library = load_library(file_path)\n \n result = library.keys.find do |expression|\n library[expression][:japanese] == emoticon_symbol\n end \n \n if result != nil\n result\n else \n \"Sorry, that emoticon was not found\"\n # binding.pry\n end\nend",
"def find_place_by_name(name)\n _places = find_all_places_by_name(name)\n\n # the result shouldn't be ambiguous\n if _places.size > 1\n raise AmbiguousNetQueryResult.new(__method__, name, _places)\n end\n\n return _places.first\n end",
"def find_entry(entry_name); end",
"def find_column(name)\n columns.detect { |column| column.name.to_sym == name.to_sym }\n end",
"def аватар text\n Data.emoji(text, exact: false, number: 0, lang: :ru)\n end",
"def find_by_name(name = nil, &block)\n all.find { |p| p.name == name.to_s }\n end",
"def cache_emoji\n @cache_emoji ||= cache.load\n end",
"def get_player_by_name n\n @players.each{|p| return p if p.try(:name).try(:downcase) == n.try(:downcase) }\n end",
"def find_by_name(device_name)\n find_by_block { |device| device if device.name == device_name }\n end",
"def find_by_name(name)\n Discovery.find_by_name(name)\n end",
"def find_member_by_username(username)\n @board.members.find { |m| m.username == username }\n end",
"def family_by_name(name)\n Family.find_by_name(name)\n end"
] | [
"0.66077566",
"0.6356576",
"0.6225231",
"0.6219515",
"0.61103976",
"0.6058261",
"0.60096383",
"0.59947395",
"0.5861071",
"0.58036435",
"0.57789695",
"0.57694024",
"0.56958956",
"0.5695522",
"0.567858",
"0.5659555",
"0.56351364",
"0.55797064",
"0.5572729",
"0.55421966",
"0.5525934",
"0.5458421",
"0.54553926",
"0.5421989",
"0.5416606",
"0.5343324",
"0.5291118",
"0.52878624",
"0.5283209",
"0.5271658",
"0.52655816",
"0.52651507",
"0.52639383",
"0.5260302",
"0.525481",
"0.5237064",
"0.52339184",
"0.5223131",
"0.5198519",
"0.51983666",
"0.5197701",
"0.519181",
"0.5186866",
"0.5185687",
"0.51779395",
"0.5176087",
"0.5173472",
"0.5171204",
"0.5168402",
"0.5148307",
"0.5146341",
"0.51440775",
"0.51440775",
"0.5141206",
"0.51347494",
"0.5131859",
"0.5129973",
"0.51277834",
"0.51220363",
"0.51140356",
"0.51105434",
"0.5110489",
"0.51095325",
"0.51006556",
"0.50927645",
"0.50860107",
"0.5082946",
"0.5082946",
"0.508205",
"0.5072043",
"0.5063489",
"0.50614125",
"0.5051102",
"0.5021716",
"0.5012106",
"0.50063366",
"0.49925336",
"0.4991972",
"0.4968952",
"0.4968952",
"0.49682933",
"0.49603516",
"0.49544278",
"0.49539715",
"0.49532667",
"0.49532667",
"0.49510086",
"0.49436414",
"0.49430197",
"0.49411064",
"0.49344265",
"0.49267343",
"0.4921295",
"0.4919833",
"0.49141324",
"0.4912559",
"0.49096167",
"0.49064118",
"0.49058333",
"0.49004075"
] | 0.9117262 | 0 |
The bot's OAuth application. | def bot_application
return unless @type == :bot
response = API.oauth_application(token)
Application.new(JSON.parse(response), self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def oauth_application(token)\n request(\n __method__,\n :get,\n \"#{api_base}/oauth2/applications/@me\",\n Authorization: token\n )\n end",
"def connection_for_application\n oauth_client.client_credentials.get_token\n end",
"def oauth\n ::OAuth::Consumer.new(Config.consumer_key, Config.consumer_secret, :site => \"https://api.twitter.com\")\n end",
"def oauth_client\n @oauth_client ||= OAuth2::Client.new @app_key, @app_secret, site: @workxp_site do |stack|\n stack.request :multipart\n stack.request :url_encoded\n stack.adapter :net_http\n end\n end",
"def set_oauth_application\n @oauth_application = Doorkeeper::Application.find(params[:oauth_application_id])\n end",
"def new_client_application\n OAuth2::Client.new(caller_service.client_id, caller_service.client_secret, :site => authorizator_service.site, :raise_errors => false)\n end",
"def oauth_authentication; end",
"def auth\n require 'oauth'\n say \"This will reset your current access tokens.\", :red if already_authed?\n\n # get the request token URL\n callback = OAuth::OUT_OF_BAND\n consumer = OAuth::Consumer.new $bot[:config][:consumer_key],\n $bot[:config][:consumer_secret],\n site: Twitter::REST::Client::BASE_URL,\n scheme: :header\n request_token = consumer.get_request_token(oauth_callback: callback)\n url = request_token.authorize_url(oauth_callback: callback)\n\n puts \"Open this URL in a browser: #{url}\"\n pin = ''\n until pin =~ /^\\d+$/\n print \"Enter PIN =>\"\n pin = $stdin.gets.strip\n end\n\n access_token = request_token.get_access_token(oauth_verifier: pin)\n $bot[:config][:access_token] = access_token.token\n $bot[:config][:access_token_secret] = access_token.secret\n\n # get the bot's user name (screen_name) and print it to the console\n $bot[:config][:screen_name] = get_screen_name access_token\n puts \"Hello, #{$bot[:config][:screen_name]}!\"\n end",
"def app\n BatchConnect::App.from_token(self.token)\n end",
"def oauth\n request_token = @oauth_consumer.get_request_token\n authorize_url = request_token.authorize_url(:oauth_consumer_key => \n Netflix::Client.consumer_key)\n Launchy.open(authorize_url)\n puts \"Go to browser, a page has been opened to establish oauth\"\n printf \"Pin from Netflix:\"\n pin = gets.chomp\n access_token = request_token.get_access_token(:oauth_verifier => pin)\n end",
"def oauth_consumer\n @oauth_consumer\n end",
"def add_client_app\n @client = Strava::OAuth::Client.new(\n client_id: ENV['STRAVA_CLIENT_ID'],\n client_secret: ENV['STRAVA_CLIENT_SECRET']\n )\n end",
"def facebook\n handle_oauth\n end",
"def auth\r\n OAuth2\r\n end",
"def oauth_instance name = nil\n oauth = Rack::OAuth.get(oauth_request_env, nil)\n raise \"Couldn't find Rack::OAuth instance with name #{ name }\" unless oauth\n oauth\n end",
"def oauth_instance name = nil\n oauth = Rack::OAuth.get(oauth_request_env, nil)\n raise \"Couldn't find Rack::OAuth instance with name #{ name }\" unless oauth\n oauth\n end",
"def get_web_auth()\n\treturn DropboxOAuth2Flow.new(APP_KEY, APP_SECRET, url('/OAuth-finish'),\n\t\t\t\t\t\t\t\t session, :dropbox_auth_csrf_token)\nend",
"def consumer\n OAuth::Consumer.new(consumer_key, consumer_secret, :site => endpoint)\n end",
"def config\n Simple::OAuth2.config\n end",
"def oauth_app_access_token(client_id, client_secret)\n self.oauth_access_token(client_id, client_secret, :type => 'client_cred')\n end",
"def client\n ::DelegatedAuthentication.new(options[:app_id], options[:app_secret], nil, nil, options[:privacy_url], callback_url)\n end",
"def o_auth_authorization\r\n OAuthAuthorizationController.instance\r\n end",
"def authorize_application\n # init auth state and oauth url..enter wormhole\n oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, GIFT_AUTH_CALLBACK)\n encoded_auth_state = create_auth_state\n oauth_url = create_oauth_url(oauth.oauth_callback_url, encoded_auth_state)\n redirect_to(:action => \"exit_portal\", :url => oauth_url) and return\n end",
"def get_consumer\n OAuth::Consumer.new(ENV[\"EVERNOTE_CONSUMER_KEY\"], ENV[\"EVERNOTE_SECRET\"], {\n :site => ENV[\"EVERNOTE_URL\"],\n :request_token_path => \"/oauth\",\n :access_token_path => \"/oauth\",\n :authorize_path => \"/OAuth.action\"\n })\n end",
"def consumer\n @consumer ||= begin\n options = {\n :site => \"https://www.google.com\",\n :request_token_path => \"/accounts/OAuthGetRequestToken\",\n :access_token_path => \"/accounts/OAuthGetAccessToken\",\n :authorize_path=> \"/accounts/OAuthAuthorizeToken\"\n }\n \n OAuth::Consumer.new('lfmp.heroku.com', 'EqH7lROs9KwfSU3QnFpkd8tX', options)\n end\n end",
"def client\n if current_account && current_account.fb_token\n FBGraph::Client.new(:client_id => $api_key,:secret_id =>$secret_key,:token=>current_account.fb_token) \n else\n FBGraph::Client.new(:client_id => $api_key,:secret_id =>$secret_key) \n end\n\n # OAuth2::Client.new($api_key, $secret_key, :site => 'https://graph.facebook.com')\n end",
"def oauth\n {\n consumer_key: @consumer_key,\n consumer_secret: @consumer_secret,\n token: @token,\n token_secret: @token_secret\n }\n end",
"def oauth_client\n if @oauth_client\n @oauth_client\n else\n conn ||= Faraday::Connection.new \\\n :url => \"https://api.gowalla.com\",\n :headers => default_headers\n\n oauth= OAuth2::Client.new(api_key, api_secret, oauth_options = {\n :site => 'https://api.gowalla.com',\n :authorize_url => 'https://gowalla.com/api/oauth/new',\n :access_token_url => 'https://gowalla.com/api/oauth/token'\n })\n oauth.connection = conn\n oauth\n end\n end",
"def oauth\n teapot_q\n end",
"def client\n OAuth2::Client.new(\n API_KEY,\n API_SECRET,\n :authorize_url => \"/uas/oauth2/authorization?response_type=code\", #LinkedIn's authorization path\n :token_url => \"/uas/oauth2/accessToken\", #LinkedIn's access token path\n :site => \"https://www.linkedin.com\"\n )\n end",
"def oauth_url\n url = <<-URL\n https://www.facebook.com/dialog/oauth/\n ?client_id=#{Network::Facebook.app_id}\n &redirect_uri=#{URI.escape(\"#{root_url}auth/facebook/?r=#{redirect_for(request.referer)}\")}\n &scope=#{Network::Facebook.scope}\n URL\n url.gsub(/\\s+/, '')\n end",
"def request_access_token\n # An `OAuth::Consumer` object can make requests to the service on\n # behalf of the client application.\n\n # Ask service for a URL to send the user to so that they may authorize\n # us.\n request_token = CONSUMER.get_request_token\n authorize_url = request_token.authorize_url\n\n # Launchy is a gem that opens a browser tab for us\n Launchy.open(authorize_url)\n\n # Because we don't use a redirect URL; user will receive a short PIN\n # (called a **verifier**) that they can input into the client\n # application. The client asks the service to give them a permanent\n # access token to use.\n puts \"Login, and type your verification code in\"\n oauth_verifier = gets.chomp\n access_token = request_token.get_access_token(\n :oauth_verifier => oauth_verifier\n )\nend",
"def client\n OAuth2::Client.new(\n API_KEY, \n API_SECRET, \n :authorize_url => \"/uas/oauth2/authorization?response_type=code\", #LinkedIn's authorization path\n :token_url => \"/uas/oauth2/accessToken\", #LinkedIn's access token path\n :site => \"https://www.linkedin.com\"\n )\n end",
"def client\n OAuth2::Client.new(\n API_KEY, \n API_SECRET, \n :authorize_url => \"/uas/oauth2/authorization?response_type=code\", #LinkedIn's authorization path\n :token_url => \"/uas/oauth2/accessToken\", #LinkedIn's access token path\n :site => \"https://www.linkedin.com\"\n )\n end",
"def client\n ::OAuth2::Client.new(\n options.client_id,\n options.client_secret,\n deep_symbolize(options.client_options).merge(site: site)\n )\n end",
"def use_oauth\n\t\t\t\n\t\tend",
"def oauth\n Auth.new(params[:uid], params[:oauth_token], action_name)\n end",
"def config\n Grape::OAuth2.config\n end",
"def consumer\n @consumer = OAuth::Consumer.new session[:consumer_key], session[:consumer_secret], :site => MISO_SITE\nend",
"def url\n File.join(DigitalRiver.config.oauth_url)\n end",
"def oauth(options = {})\n @oauth ||= ApiFactory.new 'Authorizations', options\n end",
"def get_api_key\n \n green \"****************************************\"\n green \"****************************************\"\n green \"**** API SETUP TIME! ****\"\n green \"****************************************\"\n green \"****************************************\" \n\n\n puts \"\\n\\nWelcome to Chatterbot. Let's walk through the steps to get a bot running.\\n\\n\"\n\n\n #\n # At this point, we don't have any API credentials at all for\n # this bot, but it's possible the user has already setup an app.\n # Let's ask!\n #\n \n puts \"Hey, looks like you need to get an API key from Twitter before you can get started.\\n\\n\"\n \n app_already_exists = ask_yes_no(\"Have you already set up an app with Twitter?\")\n\n if app_already_exists\n puts \"Terrific! Let's get your bot running!\\n\\n\"\n else\n puts \"OK, I can help with that!\\n\\n\"\n send_to_app_creation\n end\n\n \n print \"\\n\\nPaste the 'Consumer Key' here: \"\n STDOUT.flush\n config[:consumer_key] = STDIN.readline.chomp.strip\n\n print \"Paste the 'Consumer Secret' here: \"\n STDOUT.flush\n config[:consumer_secret] = STDIN.readline.chomp.strip\n\n\n puts \"\\n\\nNow it's time to authorize your bot!\\n\\n\"\n \n if ! app_already_exists && ask_yes_no(\"Do you want to authorize a bot using the account that created the app?\")\n puts \"OK, on the app page, you can click the 'Create my access token' button to proceed.\\n\\n\"\n\n print \"Paste the 'Access Token' here: \"\n STDOUT.flush\n config[:access_token] = STDIN.readline.chomp.strip\n\n\n print \"\\n\\nPaste the 'Access Token Secret' here: \"\n STDOUT.flush\n config[:access_token_secret] = STDIN.readline.chomp.strip\n\n \n # reset the client so we can re-init with new OAuth credentials\n reset_client\n\n # at this point we should have a fully validated client, so grab\n # the screen name\n @screen_name = client.user.screen_name rescue nil\n else\n reset_client\n end\n \n \n #\n # capture ctrl-c and exit without a stack trace\n #\n rescue Interrupt => e\n exit\n end",
"def rack_oauth!(name)\n oauth_instance(name).get_access_token!(oauth_request_env)\n end",
"def client\n @client ||= OAuth2::Client.new(@apikey, @apisecret, :site => @graph_api_url)\n end",
"def create_oauth_application(name, redirect_uris)\n response = JSON.parse(API.create_oauth_application(@token, name, redirect_uris))\n [response['id'], response['secret']]\n end",
"def create_oauth_application(name, redirect_uris)\n response = JSON.parse(API.create_oauth_application(@token, name, redirect_uris))\n [response['id'], response['secret']]\n end",
"def oauth\n redirect_to \"#{root_path}auth/#{Setting['omniauth']['provider']}\"\n end",
"def client\n # Merge in authorize url if supplied\n options.authorize_params[:clientId] = options.client_id\n options.authorize_params[:redirect] = callback_url\n options.client_options[:authorize_url] = options.authorize_url if options.authorize_url.present?\n options.client_options[:site] = options.site if options.site.present?\n\n ::OAuth2::Client.new(\n options.client_id,\n options.client_secret,\n deep_symbolize(options.client_options)\n )\n end",
"def client\n @client ||= OAuth2::Client.new(\n client_id,\n client_secret,\n :site => site,\n :authorize_url => authorize_url,\n :token_url => token_url\n )\n end",
"def bootstrap\n STDERR.puts \"My oauth authorization URL is: #{@bot.invite_url}\"\n load_plugins\n end",
"def app_access_token\n @app_access_token ||= oauth_client.get_app_access_token\n end",
"def url\n File.join(DigitalRiver.config.oauth_url)\n end",
"def oauth #:nodoc:\n @oauth ||= Bountybase.config.twitter[Bountybase.instance] ||\n begin\n E \"Cannot find twitter configuration for\", Bountybase.instance\n raise \"Cannot find twitter configuration\"\n end\n end",
"def dialogue_url\n return \"https://www.facebook.com/dialog/oauth?client_id=\"+@app_id+\"&redirect_uri=\"+@canvas_url+\"&scope=\"+@permission\n end",
"def get_web_auth\n return DropboxOAuth2Flow.new(DROPBOX_APP_KEY, DROPBOX_APP_SECRET, dropbox_callback_url, session, :dropbox_auth_csrf_token)\n end",
"def oauth_url\n @oauth_url || File.join(host, \"oauth20/token\")\n end",
"def auth_url\n MiniFB.oauth_url(@app_id, @redirect_to,\n :scope => 'user_about_me') # See MiniFB.scopes\n end",
"def client\n @client ||= EvernoteOAuth::Client.new token: auth_token\n end",
"def consumer\n @consumer ||= OAuth::Consumer.new(\n config[:consumer_key],\n config[:consumer_secret],\n :site => base_url\n )\n end",
"def create_client_from_outhAccount(scope, oob_uri, user_id, oauth_cred_file)\n #oob_uri = 'urn:ietf:wg:oauth:2.0:oob'\n #user_id = 'eyemole@gmail.com'\n client_id = Google::Auth::ClientId.from_file(oauth_cred_file)\n token_store = Google::Auth::Stores::FileTokenStore.new(:file => 'tokens.yaml')\n authorizer = Google::Auth::UserAuthorizer.new(client_id, scope, token_store)\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: oob_uri )\n #Launchy.open(url)\n puts \"Open this URL in Browser and enter the code you got from browser below\"\n puts \"URL: #{url}\"\n print \"enter the code you got from browser here and press Enter: \"\n # code = gets\n code = STDIN.gets.chomp\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: oob_uri)\n end\n blogger = Google::Apis::BloggerV3::BloggerService.new\n blogger.authorization = credentials\n return blogger\nend",
"def consumer\n @consumer ||= OAuth::Consumer.new(\n @consumer_key,\n @consumer_secret,\n { :site=> self.class.site }\n )\n end",
"def authorized_twitter\n oauth = Twitter::OAuth.new($configure[:twitter][:ctoken], $configure[:twitter][:csecret])\n # Request OAuth authentication if there are no access token yet\n unless($configure[:twitter][:atoken] && $configure[:twitter][:asecret])\n rtoken = oauth.request_token\n puts \"Open next url, authorize this application: #{rtoken.authorize_url}\"\n puts \"Then, enter PIN code:\"\n pin = STDIN.gets.chomp\n # Authrize request token using PIN code (this is required for an application which type is \"Client\")\n atoken = OAuth::RequestToken.new(oauth.consumer, rtoken.token, rtoken.secret).get_access_token(:oauth_verifier => pin)\n # Save access token\n $configure[:twitter][:atoken] = atoken.token\n $configure[:twitter][:asecret] = atoken.secret\n end\n oauth.authorize_from_access($configure[:twitter][:atoken], $configure[:twitter][:asecret])\n # Create Twitter client instance with OAuth\n Twitter::Base.new(oauth)\nend",
"def facebook_oauth\n # Insert your own Facebook client ID and secret here\n # auth = Koala::Facebook::OAuth.new(ENV[\"FACEBOOK_KEY\"], ENV[\"FACEBOOK_SECRET\"])\n\n @facebook_oauth = Koala::Facebook::OAuth.new(ENV[\"FACEBOOK_KEY\"], ENV[\"FACEBOOK_SECRET\"])\n\n\n\n end",
"def oauth_instance(name)\n instance = Rack::OAuth.get(oauth_request_env, name)\n if instance.nil?\n raise Rack::OAuthError, \"Couldn't find Rack::OAuth instance with name #{name}\"\n end\n instance\n end",
"def set_bot\n @bot = Bot.find(params[:bot_id])\n authorize @bot\n end",
"def set_bot\n @bot = Bot.find(params[:id])\n authorize @bot\n end",
"def callback\n self.oaw_callback(params[:oauth_verifier], params[:oauth_token])\n end",
"def set_application\n @application = current_user.oauth_applications.find(params[:id])\n end",
"def get_access_token_as_app(app_id, app_token)\n response = @oauth_connection.post do |req|\n req.url '/oauth/token', :grant_type => 'app', :client_id => api_key, :client_secret => api_secret, :app_id => app_id, :app_token => app_token\n end\n\n @oauth_token = OAuthToken.new(response.body)\n configure_oauth\n @oauth_token\n end",
"def twitter\n handle_oauth\n end",
"def oauth_callback_url\n end",
"def application\n # If we have a doorkeeper_token, derive the Application from it.\n # If not, we're in case #1 above and the Application should be nil.\n @application ||= @doorkeeper_token.try(:application)\n end",
"def signin\n oauth_authorize\n end",
"def oauth_url\n 'https://geoloqi.com/oauth/authorize'\n end",
"def oauth_client(options = {})\n @@linkedin_config ||= LinkedinBackup.load_config\n \n @key = @@linkedin_config['consumer_key']\n @secret = @@linkedin_config['consumer_secret']\n \n @client = Linkedin2::Consumer.new(@key, @secret,options )\n end",
"def get_current_application_information\n response = request(\n :oauth2_applications_me, nil,\n :get,\n \"oauth2/applications/@me\"\n )\n Rapture::OauthApplication.from_json(response.body)\n end",
"def get_consumer\n ::OAuth::Consumer.new(@key, @secret, @configuration)\n end",
"def application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)\n # attempt to extract a token from the url\n FBSession.activeSession.handleOpenURL(url)\n end",
"def client\n @client ||= ::OAuth2::Client.new(\n @consumer_token,\n @consumer_secret,\n :site => 'https://api-ssl.bitly.com',\n :token_url => '/oauth/access_token'\n )\n end",
"def oauth_url_authorize\n return \"#{$SETTINGS[:oauth_server_url_authorize]}?response_type=code&client_id=#{$SETTINGS[:oauth_client_id]}&scope=ALL&redirect_uri=#{oauth_redirect_uri}\" \n end",
"def index\n\t\tredirect_to oauth_applications_path\n\tend",
"def oauth_callback\n at = Marshal.load(session[:qb_request_token]).get_access_token(:oauth_verifier => params[:oauth_verifier])\n \n #There can only be one...\n Qbo.destroy_all\n\n # Save the authentication information \n qbo = Qbo.new\n qbo.qb_token = at.token\n qbo.qb_secret = at.secret\n qbo.token_expires_at = 6.months.from_now.utc\n qbo.reconnect_token_at = 5.months.from_now.utc\n qbo.company_id = params['realmId']\n if qbo.save!\n redirect_to qbo_sync_path, :flash => { :notice => \"Successfully connected to Quickbooks\" }\n else\n redirect_to plugin_settings_path(:redmine_qbo), :flash => { :error => \"Error\" }\n end\n end",
"def oauth_authorize\n redirect_to facebook_client.authorize(oauth_callback_url)\n end",
"def app_secret\n Facebook::Messenger.config.app_secret\n end",
"def fb_client\n self.fb_auth\n return unless !@auth.nil?\n Fb.set_current_user(@auth.token).client\n end",
"def oauth\n login_at(auth_params[:provider])\n end",
"def oauth\n login_at(auth_params[:provider])\n end",
"def initialize(app_id, secret)\n options = {\n site: Parameter::SITE,\n authorize_url: AUTHORIZE_URL,\n token_url: TOKEN_URL\n }\n\n raise 'アプリケーションIDが入力されていません' if app_id.empty?\n raise 'Secretが入力されていません' if secret.empty?\n @client = OAuth2::Client.new(app_id, secret, options)\n end",
"def app_access_token\n # If a token isn't provided but we need it, fetch it\n @app_access_token ||= Koala::Facebook::OAuth.new(@app_id, @secret).get_app_access_token\n end",
"def create_oauth_application(token, name, redirect_uris)\n request(\n __method__,\n :post,\n \"#{api_base}/oauth2/applications\",\n { name: name, redirect_uris: redirect_uris }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def create_oauth_application(token, name, redirect_uris)\n request(\n __method__,\n :post,\n \"#{api_base}/oauth2/applications\",\n { name: name, redirect_uris: redirect_uris }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def set_oauth_client(id, secret, env)\n @oauth_client = OAuth2::Client.new(\n id,\n secret,\n site: Volabit.site_for(env),\n raise_errors: false\n )\n end",
"def oauth_options\n {\n consumer_key: client_id,\n consumer_secret: client_secret,\n token: access_token,\n token_secret: access_token_secret\n }\n end",
"def oauth_hash\n {\n :consumer_key => consumer_key || Bountybase.config.twitter_app[\"consumer_key\"],\n :consumer_secret => consumer_secret || Bountybase.config.twitter_app[\"consumer_secret\"],\n :oauth_token => oauth_token,\n :oauth_token_secret => oauth_secret\n }\n end",
"def client\n Twitter::Client.new(\n oauth_token: token,\n oauth_token_secret: token_secret\n )\n end",
"def client\n @client ||= OAuth2::Client.new( get_config('SMARTCAR_CLIENT_ID'),\n get_config('SMARTCAR_SECRET'),\n :site => OAUTH_PATH\n )\n end",
"def access_token\n OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret)\n end",
"def consumer\n @consumer ||= OAuth::ConsumerWithHyvesExtension.new(key, secret, oauth_options)\n end",
"def client\n @client ||= OAuth2::Client.new(caller_service.client_id,\n caller_service.client_secret,\n :site => called_service.site,\n :raise_errors => false)\n end",
"def init\n init_oauth_access_token\n end"
] | [
"0.73693085",
"0.68700224",
"0.6803141",
"0.67447376",
"0.6739837",
"0.6615489",
"0.65903246",
"0.653939",
"0.6537453",
"0.65316194",
"0.6479371",
"0.6466731",
"0.644376",
"0.6442134",
"0.6422361",
"0.64063597",
"0.6399454",
"0.6356976",
"0.6350804",
"0.6334928",
"0.6330561",
"0.6297239",
"0.62966776",
"0.62965757",
"0.62744033",
"0.6251522",
"0.62476283",
"0.62376446",
"0.6233084",
"0.622213",
"0.6203488",
"0.619266",
"0.6191018",
"0.6191018",
"0.6188372",
"0.6175493",
"0.61577725",
"0.6157345",
"0.61455655",
"0.6141961",
"0.61331564",
"0.6132026",
"0.6120807",
"0.6110648",
"0.61086625",
"0.61086625",
"0.6092448",
"0.60760254",
"0.60704464",
"0.60494393",
"0.6042152",
"0.6035322",
"0.60345405",
"0.60296303",
"0.602688",
"0.6025375",
"0.60240066",
"0.6022477",
"0.60215676",
"0.60115194",
"0.60090554",
"0.6007939",
"0.59988016",
"0.5993074",
"0.59912986",
"0.598548",
"0.59813976",
"0.59569037",
"0.59519756",
"0.59509563",
"0.5938406",
"0.5936887",
"0.5928287",
"0.592757",
"0.59167427",
"0.5916623",
"0.59117675",
"0.59087217",
"0.5908225",
"0.59077984",
"0.58982223",
"0.58950436",
"0.5877951",
"0.5875274",
"0.58750623",
"0.58639205",
"0.58639205",
"0.5863227",
"0.5856184",
"0.5852508",
"0.5852508",
"0.58472836",
"0.58397746",
"0.58372283",
"0.5836402",
"0.58349377",
"0.5833645",
"0.5821001",
"0.58131754",
"0.57973605"
] | 0.80125487 | 0 |
Joins the bot's connection thread with the current thread. This blocks execution until the websocket stops, which should only happen manually triggered. or due to an error. This is necessary to have a continuously running bot. | def join
@gateway.sync
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_async\n # Handle heartbeats\n @heartbeat_interval = 1\n @heartbeat_active = false\n @heartbeat_thread = Thread.new do\n Thread.current[:discordrb_name] = 'heartbeat'\n loop do\n if @heartbeat_active\n send_heartbeat\n sleep @heartbeat_interval\n else\n sleep 1\n end\n end\n end\n\n @ws_thread = Thread.new do\n Thread.current[:discordrb_name] = 'websocket'\n\n # Initialize falloff so we wait for more time before reconnecting each time\n @falloff = 1.0\n\n loop do\n @should_reconnect = true\n websocket_connect\n\n break unless @should_reconnect\n\n if @reconnect_url\n # We got an op 7! Don't wait before reconnecting\n LOGGER.info('Got an op 7, reconnecting right away')\n else\n wait_for_reconnect\n end\n\n # Restart the loop, i. e. reconnect\n end\n\n LOGGER.warn('The WS loop exited! Not sure if this is a good thing')\n end\n\n debug('WS thread created! Now waiting for confirmation that everything worked')\n sleep(0.5) until @ws_success\n debug('Confirmation received! Exiting run.')\n end",
"def connect_loop\n loop do\n @websocket.connect\n @websocket.thread.join\n break unless @should_reconnect.shift\n end\n end",
"def run_async\n @ws_thread = Thread.new do\n Thread.current[:discordrb_name] = 'websocket'\n connect_loop\n LOGGER.warn('The WS loop exited! Not sure if this is a good thing')\n end\n\n LOGGER.debug('WS thread created! Now waiting for confirmation that everything worked')\n loop do\n sleep(0.5)\n\n if @ws_success\n LOGGER.debug('Confirmation received! Exiting run.')\n break\n end\n\n if @should_reconnect == false\n LOGGER.debug('Reconnection flag was unset. Exiting run.')\n break\n end\n end\n end",
"def join_on_connect(bot)\n @config[:channels].each{|chan|\n join_channel( bot, chan )\n }\n \n # If we are not required to do anything else, unhook\n if @config[:connect_only] then\n unregister_all(0.5) # Give my hooks half a second to disconnect\n # or unregister_hooks(0.5, :chanman_connect)\n end\n end",
"def start\n @thread = Thread.new do\n EM::WebSocket.start(ws_options) do |ws|\n ws.onopen do |handshake|\n log \"onopen: #{handshake.headers}\"\n @clients << ws\n end\n\n ws.onclose do |event|\n log \"closed: #{event}\"\n @clients.delete ws\n end\n\n ws.onmessage do |msg|\n log \"received: #{msg}\"\n end\n end\n end\n end",
"def run\n websocket.run\n end",
"def connect\n EM.run do\n client = Faye::WebSocket::Client.new(@url)\n reconnect_url = nil\n\n client.on :message do |msg|\n message_received(client, msg)\n end\n\n client.on :open do |e|\n OutputLogger.logger.info 'Connection Opened!'\n end\n\n client.on :close do |e|\n OutputLogger.logger.info 'Connection closed, trying to reconnect.'\n\n reconnect\n end\n\n client.on :error do |e|\n OutputLogger.logger.error e.inspect\n end\n\n client.on 'transport:down' do |e|\n OutputLogger.logger.info 'Connection down.'\n end\n\n client.on 'transport:up' do |e|\n OutputLogger.logger.info 'Connection back up, trying to reconnect.'\n\n reconnect\n end\n end\n end",
"def em_connect()\n @mutex.synchronize do\n @wscon = WebSocket::EventMachine::Client.connect(:uri => @wsuri)\n end\n @wscon.comm_inactivity_timeout = 60\n\n @wscon.onopen do\n @status = :open\n end\n\n @wscon.onmessage do |data|\n EM.defer do\n packet = JSON.load(data)\n if @status == :open\n if packet.has_key? \"error\"\n LogService.warn \"packet error: #{packet[\"type\"]}, #{packet[\"error\"]}\"\n end\n \n if @callbacks.has_key? packet[\"type\"]\n @callbacks[packet[\"type\"]].each do |c|\n c.call(packet[\"data\"])\n end\n end\n end\n end\n end\n\n @wscon.onclose do |code, reason|\n if @status == :closing\n @status = :closed\n elsif @status == :open || @status == :opening\n @status = :opening\n EM.add_timer(10) do\n em_connect()\n end\n end\n end\n end",
"def start\n connect\n @last_alive = Time.now\n @listener = Thread.new do\n while true\n begin\n @last_alive = Time.now if @hub.fetch_command\n\n if Time.now > @last_alive + @keepalive_timeout\n @logger.error \"connection lost\" if @logger\n @last_alive = Time.now\n reconnect\n end\n\n rescue Exception => e\n exit if e.class == Interrupt\n puts e.message\n puts e.backtrace.join(\"\\n\")\n break\n end\n end\n end\n end",
"def start\n @client = ::Slack::RealTime::Client.new(token: @token)\n @running = true\n\n client.on :open do |event|\n @connected = true\n log \"connected to '#{team_name}'\"\n run_callbacks(:start)\n end\n\n client.on :message do |data|\n begin\n debug message: data\n @last_received_user_message = data\n handle_message(data)\n rescue => e\n log_error e, \"Error handling message #{data.inspect}\"\n end\n end\n\n client.on :close do |event|\n log \"disconnected\"\n @connected = false\n run_callbacks(:finish)\n end\n\n register_low_level_callbacks\n\n client.start_async\n rescue Slack::Web::Api::Error => e\n log \"Connection error for bot #{key}\"\n raise ConnectionError.new(e.message, e.response)\n end",
"def listen\n @@em.schedule do\n EventMachine::WebSocket.run(:host => @host, :port => @port) do |ws|\n ws.onopen { }\n ws.onclose { @connection_event_handlers[:closed].each { |h| h.call self } }\n ws.onerror { |e| @connection_event_handlers[:error].each { |h| h.call self } }\n ws.onmessage { |msg| handle_message(msg, ws) }\n end\n end\n self\n end",
"def sync\n @ws_thread.join\n end",
"def sync\n @ws_thread.join\n end",
"def join\n @listen_thread.join if @listen_thread\n sleep 0.5\n raise @thread_error if @thread_error\n end",
"def connect\n if @connected\n block_given? and yield Exception.new 'mailbox has already connected'\n return\n end\n\n begin\n @ws = WebSocket::EventMachine::Client.connect :uri => 'ws://' + @host + ':' + @port.to_s\n @ws.onopen {\n return if @connected\n @connected = true\n @timer = EM.add_periodic_timer(@interval) { flush } if @buffer_msg\n block_given? and yield\n }\n\n @ws.onmessage { |msg, type|\n process_msg msg, type\n }\n\n @ws.onerror { |err| }\n @ws.onclose { |code, reason|\n emit :close, @id\n }\n rescue => err\n block_given? and yield err\n end\n end",
"def join\n @server_thread.join if @server_thread\n end",
"def join\n @server_thread.join if @server_thread\n end",
"def run\n # Include all handlers now.\n Dir['./handlers/*.rb'].sort.each do |file|\n require file\n end\n\n @config.bots.each do |bot_id, bot_data|\n conn = DiscordConnection.new(bot_data)\n\n conn.connection_id = bot_id\n\n conn.message do |msg|\n next unless @config.discord.allowed_channel_types.include?(msg.channel.channel_type)\n\n if (prefix = check_prefix(msg.text))\n CommandDispatcher.handle prefix, msg\n else\n @handlers.each do |handler|\n break if handler.call(msg) == true\n end\n end\n end\n\n conn.mention do |msg|\n next unless @config.discord.allowed_channel_types.include?(msg.channel.channel_type)\n next if msg.content.match? /^(\\.|\\!)(a|d|add_|del_|delete_|remove_|count_)?q(uote|s|uotes|uote_count)?\\b/\n next unless msg.content.present?\n next if bot_data.client_type == :user\n\n msg.send_message \"#{msg.message.author.mention}, please type `.help` if you would like to learn more about my functions!\"\n end\n\n @connections.push conn\n conn.connect\n end\n\n SweetieBot.log \"Made #{@connections.length} connection#{@connections.length > 1 ? 's' : ''}.\"\n SweetieBot.log 'Ready!'\n\n # keep the main thread alive\n loop do\n if @should_stop\n stop!\n exit\n end\n\n sleep 1\n end\n end",
"def run_socket_thread\n @thread ||= Thread.new { run_socket_loop }\n end",
"def spawn_connection\n connect\n end",
"def disconnect(msg = nil)\n @bot.quit(msg)\n @connection_thread.join\n end",
"def run_bot\n $bot.run(true)\n trap(\"INT\") { shutdown }\n leave_unknown_servers\n log(\"Bot connected to servers: #{$bot.servers.map{ |id, s| s.name }.join(', ')}.\")\nrescue => e\n fatal(\"Failed to execute bot: #{e}\")\n exit\nend",
"def connection_action\n @sslsocket.connect_nonblock\n end",
"def heartbeat_loop\n loop do\n send_heartbeat\n sleep @heartbeat_interval\n next if @heartbeat_acked\n\n LOGGER.error { 'Heartbeat was not acked, reconnecting.' }\n @websocket.close\n break\n end\n end",
"def reconnect\n EM.stop\n\n connect\n end",
"def run\n Thread.start do\n begin\n while true\n main_loop\n end\n ensure\n @protocol.close if @protocol\n end\n end\n end",
"def join_thread\n @thread&.join\n end",
"def start\n @redis = Redis.new(:host => \"#{Settings.redis.host}\", :port => Settings.redis.port)\n\n \n Thread.new do\n EventMachine.run do\n \tputs '='*80, \"Starting websockets server at ws://#{Settings.websocket.host}:#{Settings.websocket.port}\", '='*80\n \n EventMachine::WebSocket.start(:host => \"#{Settings.websocket.host}\", :port => Settings.websocket.port) do |ws|\n ws.onopen do\n \n puts \"#{Time.now.strftime('%H:%M:%S')} : Client connected\", '-'*80\n SOCKETS << ws\n end\n\n ws.onclose do\n \n puts \"#{Time.now.strftime('%H:%M:%S')} : Client disconnected\", '-'*80\n SOCKETS.delete ws\n end\n end\n end\n end\n\n \n Thread.new do\n @redis.subscribe('ws') do |on|\n \n on.message do |chan, msg|\n \n puts \"#{msg}\"\n SOCKETS.each {|s| s.send msg} \n \n end\n end\n end\n\n sleep\n \n end",
"def open\n @thread = Thread.new{ @wamp_client.open }\n end",
"def join\n @server.stop! if @server and @server.running?\n super\n end",
"def join\n return if not running?\n @thread.join\n end",
"def start\n Thread.new do\n loop do\n @connection.wait_for_notify do |channel|\n @actions[channel].call\n end\n end\n end\n end",
"def shutdown\n log(\"Shutting down...\")\n # We need to perform the shutdown in a new thread, because this method\n # gets called from within a trap context\n Thread.new {\n Sock.off\n stop_bot\n disconnect_db\n unblock_threads\n exit\n }\nrescue => e\n fatal(\"Failed to shut down bot: #{e}\")\n exit\nend",
"def connect\r\n if @opts[:threadsafe]\r\n @conns = Knj::Threadhandler.new\r\n \r\n @conns.on_spawn_new do\r\n self.spawn\r\n end\r\n \r\n @conns.on_inactive do |data|\r\n data[:obj].close\r\n end\r\n \r\n @conns.on_activate do |data|\r\n data[:obj].reconnect\r\n end\r\n else\r\n @conn = self.spawn\r\n end\r\n end",
"def disconnect\n @thread.exit\n @client.disconnect\n @channels.clear\n end",
"def new_bot email, password, room\n counter = Thread.new do\n TT.run do\n client = TT::Client.new(email, password, room: room)\n my_bot = Bot.new(client)\n client.on :user_spoke do |message|\n puts \"**** in :user_spoke message: #{message.content}\"\n my_bot.tell(message.content, message.sender) if message.content.split[0] == client.user.name\n end\n client.on :user_entered do |user|\n my_bot.say_hello user\n end\n client.on :song_started do |song|\n my_bot.bop song\n end\n end\n end\nend",
"def connect\n EM.epoll\n\n EM.run do\n trap('TERM') do\n @enable_reconnection = false\n disconnect\n end\n\n trap('INT') do\n @enable_reconnection = false\n disconnect\n end\n\n @ws = WebSocket::EventMachine::Client.connect(uri: @url)\n\n @ws.onopen do\n reset_value\n @ws.send(get_handshake_object(increment_cnt).to_json)\n @on_connected.call if @on_connected\n end\n\n @ws.onmessage do |message, _type|\n @logger.info(\"Message received : #{message}\") if @logger\n if message == ''\n @logger.info(\"Ping received, sending PONG back\")\n @ws.send('')\n else\n main_object = JSON.parse(message)\n data_object = main_object['data']\n rid = main_object['rid']\n cid = main_object['cid']\n event = main_object['event']\n result = Parser.parse(event, rid)\n if result == Parser::CHECK_AUTHENTICATION\n if @on_authentication\n @id = data_object['id']\n @on_authentication.call(self, data_object['isAuthenticated'])\n end\n subscribe_channels\n elsif result == Parser::PUBLISH\n execute(data_object['channel'], data_object['data'])\n elsif result == Parser::REMOVE_AUTHENTICATION\n @auth_token = nil\n elsif result == Parser::SET_AUTHENTICATION\n if @on_set_authentication\n @on_set_authentication.call(self, data_object['token'])\n end\n elsif result == Parser::EVENT\n if haseventack(event)\n executeack(event, data_object, ack_block(cid))\n else\n execute(event, data_object)\n end\n else # Parser::ACKNOWLEDGEMENT\n tuple = @acks[rid] if @acks.include?(rid)\n if tuple\n ack = tuple[1]\n ack.call(tuple[0], String(main_object['error']), String(main_object['data']))\n end\n end\n end\n end\n\n @ws.onerror do |error|\n @on_connect_error.call(error) if @on_connect_error\n end\n\n @ws.onclose do\n if should_reconnect\n @reconnect_interval = @max_reconnect_interval if @reconnect_interval > @max_reconnect_interval\n sleep(@reconnect_interval / 1000)\n @attempts_made += 1\n @logger.info(\"Attempting to reconnect : #{@attempts_made}\") if @logger\n connect\n else\n stop\n end\n end\n\n def stop\n EventMachine.stop\n end\n end\n end",
"def on_message\n websocket_client.on(:message) do |event|\n websocket_response = websocket_response_data_class.new(\n data: event.data,\n bot_params_class: bot_params_class\n )\n\n bot.handle_data(websocket_response.bot_params) do |message|\n websocket_request = websocket_request_data_class.new(message: message, data: websocket_response.bot_params)\n websocket_client.send(websocket_request.data_to_send)\n end\n end\n end",
"def broadcast_worker_loop\n Thread.new do\n begin\n while @running\n broadcast\n sleep(@broadcast_worker_delay)\n end\n rescue => e\n logger.error \"Broadcast worker error:\"\n logger.error e\n retry\n end\n end\n end",
"def start\n # Eventmachine run\n EM.run do\n # set what to do on message from websocket\n on_message\n\n # set what to do on close of websocket connection\n on_close\n end\n end",
"def run\r\n Settings::DEFAULT_TRIGGERS.each_key{|k| load_trigger(k, true)}\r\n Settings::TRIGGERS.each_key{|k| load_trigger(k)}\r\n @socket = TCPSocket.open(self.server, self.port)\r\n\r\n $log.info(\"Initiating handshake with server...\")\r\n say \"USER #{nick} 0 * #{nick}\"\r\n say \"NICK #{nick}\"\r\n\r\n until @socket.eof? do\r\n msg = @socket.gets\r\n msg = (msg.split(\" \")[1] == \"PRIVMSG\" ? PrivateMessage.new(msg) : Message.new(msg))\r\n\r\n if msg.type == \"PRIVMSG\"\r\n cache_message(msg)\r\n fire_triggers(msg)\r\n end\r\n\r\n #keep alive\r\n if msg.parts[0] == \"PING\"\r\n say \"PONG :pingis\"\r\n else\r\n case msg.parts[1]\r\n when \"001\"\r\n $log.info(\"Processing connection to server...\")\r\n when \"376\"\r\n $log.info(\"Connected to server, joining channel...\")\r\n join_chan(self.chan)\r\n when \"366\"\r\n @in_chan = true\r\n $log.info(\"Successfully joined ##{self.chan}\")\r\n else\r\n end\r\n end\r\n #output to terminal window whatever the server is giving our socket\r\n $log.info(\"#{msg.stringify}\")\r\n end\r\n end",
"def run\n until @socket.eof? do\n line = @socket.gets\n\n # Makes sure your bot doesn't timeout!\n if line.match(PING_MSG)\n say \"PONG #{ $~[1]}\"\n else\n bot_main(line)\n end\n end\n end",
"def start_monitoring_connection\n @connection_monitor_thread ||= Thread.new{monitor_connection}\n @connection_monitor_thread.abort_on_exception = true\n end",
"def lights_start_loop_subscribe!\n Helpers.thread { lights_start_loop_subscribe }\n rescue => e\n Helpers.before_retry(e)\n retry\n end",
"def loop_forever\n running = true\n\n while wait_for_connection\n @logger.info(\"New client connected\")\n command, *arguments = next_message.split\n @logger.debug \"#{command} received\"\n response = case command\n when /^track$/i then track(arguments.first)\n when /^list$/i then list\n when /^release$/i then release(arguments.first)\n end\n\n write(response) unless response.nil?\n end\n rescue => e\n @logger.error(\"An error occurred when waiting for new connections!\\n\\t#{e.inspect}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\")\n end",
"def start\n _connect\n sleep 1\n end",
"def wait_end()\n begin\n loop do\n sleep(TICK/1000.0) while (self.connected?() rescue nil)\n break\n end\n rescue Exception => e\n end\n end",
"def wake_up(bot)\r\n bot.servers.each do |key, server|\r\n server.channels.each do |channel|\r\n if channel.name == @botChannelName and @awakenStrings.size > 0\r\n bot.send_message(channel, @awakenStrings.sample)\r\n end\r\n end\r\n end\r\n end",
"def join(channel)\n @bot.join(channel)\n end",
"def run\n connect = false\n until connect do\n begin\n call { |server| @server = server ; start }\n rescue\n Waves::Logger.error e.to_s\n sleep 1\n end\n connect = true\n end\n end",
"def run(threaded=true, verify=true)\n $log.info \"Starting IRC Bot...\"\n\n if threaded then\n # Run the bot.\n @thread = Thread.new do\n $log.info \"Bot thread started.\"\n @bot.start\n end\n \n # Wait for it to connect\n if verify then\n delay = 0\n while(not @bot.connected? and delay < @config[:connect_timeout]) do\n sleep(0.5)\n delay += 0.5\n end\n\n raise \"Bot timed out during first connect.\" if(delay >= @config[:connect_timeout])\n end\n else\n @bot.start\n end\n end",
"def join\n start if !@listener.running?\n @listener.join\n end",
"def join\n raise \"No http-server or http-server not running.\" if !@httpserv or !@httpserv.thread_accept\n \n begin\n @httpserv.thread_accept.join\n @httpserv.thread_restart.join if @httpserv and @httpserv.thread_restart\n rescue Interrupt => e\n self.stop\n end\n \n if @should_restart\n loop do\n if @should_restart_done\n STDOUT.print \"Ending join because the restart is done.\\n\"\n break\n end\n \n sleep 1\n end\n end\n end",
"def hook_bot(bot)\r\n @thread.exit if @thread&.alive?\r\n @thread = Thread.new do\r\n update_stats(bot.users.size, bot.servers.size)\r\n sleep 10 * 60\r\n end\r\n @thread\r\n end",
"def loop( &block )\n sanity_check\n @connection.loop(&block)\n end",
"def join\n require \"thwait\"\n ThreadsWait.new(@event_loop).join\n end",
"def irc_loop\n while true\n until @irc.dead_socket\n sleep 15\n @irc.handle(:irc_loop)\n Thread.pass\n end\n\n # Disconnected? Wait a little while and start up again.\n @nextserver = (@nextserver+1) % @servers.length\n sleep 30\n @irc.stop_listening\n self.connect_socket\n start_listening\n end\n end",
"def test1 #fails\n\n EventMachine::WebSocket.start(:host => \"0.0.0.0\", :port => 8567) do |ws|\n ws.onopen do\n puts \"WebSocket opened\"\n conn = Bunny.new\n conn.start\n#ch = conn.default_channel\n q = $ch.queue(\"tweets\")\n q.subscribe(:block => true) do |delivery_info, properties, body|\n puts \"Received tweet\\n\"\n ws.send \"test\"\n end\n end\n ws.onclose do\n ws.close(code = nil, body = nil)\n puts \"WebSocket closed\"\n# exit\n end\n end\nend",
"def run\n Telebot::Bot.new(@token).run do |chat, message|\n if block_given?\n yield(chat, message)\n elsif !chat.nil?\n id = message.chat.id\n if id.positive?\n post(\n message.chat.id,\n \"This is your chat ID: `#{message.chat.id}`.\"\n )\n end\n end\n end\n rescue Net::OpenTimeout\n retry\n end",
"def join\n @thread.join\n end",
"def run\n begin\n @socket = TCPSocket.open(server, port)\n rescue => e\n puts \"An error occurred: #{e.message}\"\n exit 1\n end\n\n send 'USER ruben 0 * :Ruben'\n send \"NICK #{@nick}\"\n send \"JOIN ##{@channel}\"\n\n listen until @socket.eof?\n end",
"def reconnect!\n if active?\n disconnect\n end\n connect\n end",
"def stop!\n @connections.each do |connection|\n puts \" -> stopping '#{connection.connection_id}'\"\n connection.disconnect\n end\n\n SweetieBot.log 'Stopped.'\n end",
"def reconnect!\n @socket.close\n connect\n end",
"def connect\n say \"NICK #{@botname}\"\n say \"USER #{@botname} 0 * #{@botname}\"\n say \"JOIN #{@channel}\"\n end",
"def run\n # Start the message handler\n @message_handler.start\n\n @worker_list.each { |t| t.join }\n end",
"def enqueue_from_server\n @writter = Thread.new do \n while @online\n begin\n if @socket.eof?\n @socket.close\n puts \"Server is down, please press quit\"\n break\n end\n msg = @socket.gets.chop\n if msg =~ /Advice from channel/ \n @advices << msg\n else\n msg = \"=> #{msg}\"\n @response << msg\n end\n rescue => e\n puts \"Error writter Thread #{e}\"\n end\n end\n end\n end",
"def run\n EventMachine::run do\n @tcp = EventMachine::connect(config.server.host, config.server.port, TCPConnection)\n @tcp.client = self\n spectator_join\n end\n end",
"def start_keepalive_thread\n @keepalive.kill if @keepalive.is_a?(Thread)\n @keepalive = Thread.new do\n loop do\n sleep 10\n @ssh.send_global_request('keepalive@openssh.com')\n end\n end\n end",
"def join\n @worker.join(SHUTDOWN_TIMEOUT)\n end",
"def pong_everyone\n #log \"trying to pong\"\n if @sockets.length > 0 && !self.stopped?\n #log \"ponging\"\n broadcast_message(nil, \"PONG\", [build_handle_list])\n #sleep 5\n clean_handles\n end\n end",
"def start_pong_loop\n Thread.new do\n loop do\n sleep 5\n # log \"pong all\"\n pong_everyone\n # log \"pong logsave\"\n save_chat_log\n end\n end\n end",
"def run\n loop {\n # Thread.start -> takes arguments that it yields to block for creating thread\n # # server#accept -> returns a new Socket object and Addrinfo object\n Thread.start(@server.accept) do |client| # each client thread\n nick_name = client.gets.chomp.to_sym\n # check if client connectiont already exists\n @connections[:clients].each do |other_name, other_client|\n if nick_name == other_name || client == other_client\n puts \"This username already exists\"\n Thread.kill self\n end\n end\n puts \"#{nick_name} #{client}\"\n @connections[:clients][nick_name] = client\n client.puts \"Connection established, Thank you for joining! Happy Chatting\"\n # listen for client messages\n listen_for_user_messages(nick_name, client)\n end\n }\n end",
"def start\n @client.on :hello do\n puts \"Successfully connected, welcome '#{@client.self.name}' to the '#{@client.team.name}' team at https://#{@client.team.domain}.slack.com.\"\n end\n @client.on :close do |_data|\n puts \"Client is about to disconnect\"\n end\n @client.on :closed do |_data|\n puts \"Client has disconnected successfully!\"\n end\n\n @client.on :message do |data|\n message = data.text\n bot_id = @client.self.id\n if self.needs_help?(message, bot_id)\n @client.message channel: data.channel, text: self.respond_help\n else\n symbol_doc = self.read(message, bot_id)\n if self.must_respond?(symbol_doc)\n if symbol_doc.success\n @client.message channel: data.channel, text: self.respond_ok(symbol_doc)\n else\n if message.split.count > 1\n @client.message channel: data.channel, text: self.respond_error(symbol_doc)\n end\n end\n end\n end\n end\n\n @client.start!\n end",
"def run!\n client.on(:hello, &responder.hello)\n client.on(:message, &responder.message)\n client.start!\n end",
"def join\n @thread.join\n end",
"def activate_ssh_loop symbol\n @connections[symbol][:thread] = Thread.new(@connections[symbol]) {|c| c.loop {true}}\n end",
"def run_bot\n return if !ENV['LOOMIO_USER']\n\n # initialize the handler here so that the authentication doesn't have to be repeated\n loomio = LoomioHandler.new()\n\n # start a new thread and run an infinite loop inside it\n #Thread.new do\n loop do\n LogEntry\n .where(loomio_consumed: [false, nil]) # extract all log_entries that haven't been processed yet\n .each { |log_entry|\n process(log_entry, loomio)\n }\n sleep 5 # check for new events every 5 seconds\n end\n #end\nend",
"def websocket; end",
"def websocket; end",
"def poll_for_messages\n $log.debug \"[twitter] Connecting to twitter...\"\n\n\n # Read state at the current point\n most_recent_tweet = @client.home_timeline[0]\n\n while(@continue_polling) do\n $log.debug \"[twitter] Sleeping #{@config[:poll_rate]}s...\"\n sleep(@config[:poll_rate].to_i)\n\n # Read new tweets\n new_tweets = []\n begin\n if most_recent_tweet\n # TODO: handle backoff a la twitter API\n new_tweets = @client.home_timeline(:since_id => most_recent_tweet.id)\n else\n new_tweets = @client.home_timeline()\n end\n rescue Twitter::Error => te\n $log.error \"Twitter error: #{te}\"\n $log.debug te.backtrace.join(\"\\n\")\n end\n\n $log.debug \"[twitter] Got #{new_tweets.length} new tweets.\"\n\n # Update most recent list\n most_recent_tweet = new_tweets[0] if new_tweets[0]\n\n # Delete tweets from ourself.\n unless @config[:say_own_tweets]\n new_tweets.delete_if{|t| t.user? && t.user.screen_name == @config[:twitter_account_username] }\n end\n\n # Output to bots\n new_tweets[0..(@config[:max_tweets_per_poll].to_i - 1)].each do |tweet|\n str = compose_message(tweet)\n\n @channel_mutex.synchronize{\n @channels.each{|channel, bot|\n bot.say str\n }\n }\n\n end\n\n end\n\n end",
"def listen\n connect do\n routes.each do |queue|\n @client.subscribe(queue) do |args|\n run(queue, args)\n end\n end\n end\n while (!Thread.current[:shutdown]) do\n sleep(self.class.sleep_time)\n end\n end",
"def connection_action\n @sslsocket.accept_nonblock\n end",
"def run\n Lita.logger.debug 'Slack::run started'\n sleep\n rescue Interrupt\n Lita.logger.info 'Slack::shutting down'\n end",
"def send_message\n self.get_message\n self.conn.get.status\n end",
"def start\n EM.run do\n @__conn = EventMachine::WebSocketClient.connect(@__socket_url)\n\n @__callbacks[:connection_established] &&\n @__conn.callback do\n instance_exec(&@__callbacks[:connection_established])\n end\n\n @__callbacks[:error] &&\n @__conn.errback do |e|\n instance_exec(e, &@__callbacks[:error])\n end\n\n @__conn.stream do |msg|\n @__conn.close_connection if msg.data == \"done\"\n\n event = JSON.parse(msg.data)[1]\n case event['type']\n when 'paired'\n @__event_pool[:paired] = event\n\n when 'connected'\n break unless @__callbacks[:connected]\n instance_exec(&@__callbacks[:connected])\n @__event_pool[:connected] = event\n\n when 'arm_synced'\n @__event_pool[:arm_synced] = event\n\n when 'unlocked'\n puts(\"unlocked!\")\n @__event_pool[:unlocked] ||= false\n @__event_pool[:unlocked] = true\n\n when 'pose'\n\n break unless @__callbacks[:pose]\n pose = event['pose']\n puts \"this is pose: \" + pose\n #instance_exec(@__event_pool[:pose][:pose], :off, &@__callbacks[:pose]) if @__event_pool[:pose][:pose]\n instance_exec(pose, :on, &@__callbacks[:pose])\n @__event_pool[:pose] = event\n\n when 'orientation'\n break unless @__callbacks[:periodic]\n e = OpenStruct.new({\n :accel => OpenStruct.new({\n :x => event['accelerometer'][0],\n :y => event['accelerometer'][1],\n :z => event['accelerometer'][2]\n }),\n :gyro => OpenStruct.new({\n :x => event['gyroscope'][0],\n :y => event['gyroscope'][1],\n :z => event['gyroscope'][2]\n }),\n :orientation => OpenStruct.new(event['orientation'])\n })\n @__event_pool[:orientation] = e\n instance_exec(e, &@__callbacks[:periodic])\n\n end\n end\n\n @__conn.disconnect do\n EM::stop_event_loop\n end\n end\n end",
"def run\n capture_signals\n load_config\n\n EM.synchrony do\n connect\n start_throttle\n end\n end",
"def start\n @client.ping\n @state.set :run\n @thread ||= Thread.new{ work_loop }\n end",
"def stop!\n return unless running?\n @logger.info 'Stopping WebSocket server'\n @client_mutex.synchronize do\n @clients.each do |socket, client|\n client.stop!\n end\n end\n @server_thread.kill if @server_thread\n @server.close\n end",
"def join\n if request_valid?\n request_user.online!\n \n msg = message(\"joined\")\n msg = javascript_chat_message(msg)\n \n # Inform all joined channels that the user has joined\n Juggernaut.send_to_channels(msg, params[:channels])\n \n render :nothing => true\n else\n # Prevent the user from joining the channel if the request is not\n # from a valid session/user combination\n render :text => \"403\", :status => 403\n end\n end",
"def run!\n start_server!\n @server_thread = Thread.new do\n loop do\n Thread.start(@server.accept) do |socket|\n begin\n handle_request(socket)\n rescue => e\n @logger.error \"#{e.class}: #{e.message}\"\n @logger.debug e.backtrace\n ensure\n closing_client = @client_mutex.synchronize do\n @clients.delete(socket)\n end\n # invoke callbacks for disconnect if there is a client to\n # disconnect\n emit(:client_disconnect, closing_client) if closing_client\n socket.close\n end\n end\n end\n end\n end",
"def attempt_connection\n @connection_future = Concurrent::Future.new do\n connection_method.call\n end\n connection_future.execute\n end",
"def start\n\n logger.info('Starting the WebSocket Client...')\n\n EventMachine.run do\n\n puts '='*80, \"Connecting to websockets server at ws://#{Settings.websocket.host}:#{Settings.websocket.port}\", '='*80\n\n http = EventMachine::HttpRequest.new(\"ws://#{Settings.websocket.host}:#{Settings.websocket.port}/websocket\").get :timeout => 0\n\n http.errback do\n logger.error \"something was wrong in the websocket_client\"\n end\n\n http.callback do\n puts \"#{Time.now.strftime('%H:%M:%S')} : Connected to server\"\n end\n\n http.stream do |msg|\n puts msg\n end\n\n end\n \n end",
"def start\n puts 'Booting BubBot'\n Thread.new do\n loop do\n #puts \"Checking for servers to shutdown\"\n # TODO: actually do that ^\n sleep 10# * 60\n end\n end\n\n app = Rack::Builder.new do\n # if development (TODO)\n use Rack::Reloader\n # end\n run BubBot\n end.to_app\n\n Rack::Handler::Thin.run(app, BubBot.configuration.rack_options_hash)\n end",
"def start_websocket_client\n # make sure log level is still set correctly here\n Bixby::Log.setup_logger(:level => Logging.appenders[\"file\"].level)\n logger.info \"Started Bixby Agent #{Bixby::Agent::VERSION}\"\n @client = Bixby::WebSocket::Client.new(Bixby.agent.manager_ws_uri, AgentHandler)\n trap_signals()\n @client.start\n end",
"def run\n while true; async.handle_message @socket.read; end\n end",
"def connect\n connection.tap do |c|\n c.start\n end\n end",
"def receive(websocket_message) # :nodoc:\n send_async :dispatch_websocket_message, websocket_message\n end",
"def connect!\n EventMachine.run do\n EventMachine::MQTT::ClientConnection.connect(@server) do |c|\n c.subscribe(@topic)\n c.receive_callback do |message|\n handle_incoming_message(message)\n end\n end\n end\n end",
"def establish_connection_with_client\n\t\t# Update help message\n\t\t@help_window.set_text(\"Waiting for client to connect...\", 1)\n\t\tConsole.log \"creating server\"\n\t\t# Create Server\n\t\t$game_server = GameServer.new\n\t\t@connection_thread = Thread.new do\n\t\t\tConsole.log \"waiting for client...\"\n\t\t\tsleep(1)\n\t\t\t$game_server.accept\n\t\t\t# @connection_thread = nil\n\t\t\t$scene = Scene_Pong_Server.new\n\t\tend\n\t\t#Thread.current.priority = 10\n\t\tConsole.log \"Thread is running, returning to normal update cycle\"\n\tend"
] | [
"0.6952133",
"0.69457245",
"0.66505915",
"0.60932404",
"0.6073879",
"0.59758526",
"0.5974482",
"0.58934724",
"0.5839568",
"0.5815858",
"0.5810771",
"0.5776136",
"0.5776136",
"0.5699954",
"0.56866944",
"0.5628136",
"0.56168985",
"0.5523956",
"0.54936826",
"0.54846007",
"0.5476371",
"0.5470699",
"0.54532444",
"0.54387116",
"0.5430202",
"0.5420765",
"0.5410102",
"0.53965646",
"0.53901076",
"0.53799415",
"0.5377086",
"0.5375096",
"0.53737545",
"0.537315",
"0.53617275",
"0.5350742",
"0.53355646",
"0.5331743",
"0.5321584",
"0.5307902",
"0.5304491",
"0.5304099",
"0.5296125",
"0.5295794",
"0.5295329",
"0.5290708",
"0.52764094",
"0.5272423",
"0.52723813",
"0.527102",
"0.5266145",
"0.52571845",
"0.52544725",
"0.52539706",
"0.52153295",
"0.5214751",
"0.52033114",
"0.5199653",
"0.51995534",
"0.5192097",
"0.51879853",
"0.5187413",
"0.518645",
"0.51862234",
"0.5185917",
"0.5174647",
"0.51694876",
"0.51571023",
"0.51550156",
"0.5154333",
"0.51434594",
"0.51387113",
"0.51366764",
"0.51306546",
"0.5115388",
"0.511502",
"0.5108736",
"0.5106107",
"0.5103488",
"0.5103488",
"0.50902534",
"0.5086377",
"0.50823975",
"0.5078327",
"0.5069905",
"0.5066424",
"0.5062198",
"0.5057648",
"0.50554746",
"0.5052551",
"0.50518316",
"0.5050144",
"0.504905",
"0.50414807",
"0.5040106",
"0.5037724",
"0.5036068",
"0.5034008",
"0.5033668",
"0.50302017"
] | 0.50323856 | 99 |
Stops the bot gracefully, disconnecting the websocket without immediately killing the thread. This means that Discord is immediately aware of the closed connection and makes the bot appear offline instantly. | def stop(_no_sync = nil)
@gateway.stop
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop!\n @connections.each do |connection|\n puts \" -> stopping '#{connection.connection_id}'\"\n connection.disconnect\n end\n\n SweetieBot.log 'Stopped.'\n end",
"def stop!\n return unless running?\n @logger.info 'Stopping WebSocket server'\n @client_mutex.synchronize do\n @clients.each do |socket, client|\n client.stop!\n end\n end\n @server_thread.kill if @server_thread\n @server.close\n end",
"def shutdown\n log(\"Shutting down...\")\n # We need to perform the shutdown in a new thread, because this method\n # gets called from within a trap context\n Thread.new {\n Sock.off\n stop_bot\n disconnect_db\n unblock_threads\n exit\n }\nrescue => e\n fatal(\"Failed to shut down bot: #{e}\")\n exit\nend",
"def stop\n log \"closing connection\"\n @running = false\n client.stop!\n log \"closed\"\n end",
"def stop_bot\n $bot.stop\n log(\"Stopped bot\")\nrescue => e\n fatal(\"Failed to stop the bot: #{e}\")\n exit\nend",
"def disconnect()\n @connection.stop()\n @timer.stop()\n @broadcast.stop()\n end",
"def disconnect(msg = nil)\n @bot.quit(msg)\n @connection_thread.join\n end",
"def disconnect\n @thread.exit\n @client.disconnect\n @channels.clear\n end",
"def stop\n connection.write(\"stop\")\n end",
"def stop\n connection.write(\"stop\")\n end",
"def stop\n connection.write(\"stop\")\n end",
"def stop(&blk)\n client.close if (client and (client.connected? || client.reconnecting?))\n blk.call if blk\n @err_cb = nil\n @close_cb = nil\n @reconnect_cb = nil\n @disconnect_cb = nil\n end",
"def stop\n server = Communist.servers.delete(app.object_id) { |s| NullServer.new }\n if Communist.server.respond_to?(:shutdown)\n server.shutdown\n elsif Communist.server.respond_to?(:stop!)\n server.stop!\n else\n server.stop\n end\n @server_thread.join\n end",
"def stop\n Net::HTTP.get('localhost', '/selenium-server/driver/?cmd=shutDown', @port_number)\n end",
"def stop\n if (self.relay_thread)\n self.relay_thread.kill\n self.relay_thread = nil\n end\n\n self.relay_mutex.synchronize {\n self.relays.delete_if { |k, v|\n v.shutdown\n v.close\n true\n }\n }\n\n # make sure we kill off active sockets when we shut down\n while self.rfds.length > 0\n close_relay_conn(self.rfds.shift) rescue nil\n end\n\n # we can safely clear the channels array because all of the\n # reverse relays were closed down\n self.rev_chans.clear\n self.relays.clear\n end",
"def disconnect\n @on_disconnected.call if @on_disconnected\n @enable_reconnection = false\n @ws.close\n end",
"def stop\n @logger.info(\"Stopping #{self.class}...\")\n @connection.stop if @connection\n @logger.info(\"#{self.class} stopped.\")\n end",
"def disconnect quit_message = \"Terminus-Bot: Terminating\"\n send_command 'QUIT', [], quit_message\n\n @disconnecting = true\n end",
"def stop\n if @running\n @running = false\n @connections.each { |conn| conn.stop(@stop_bytes) }\n end\n end",
"def stop\n data = { :bot => Encryptor.encrypt({:id => id}.to_json, :key => $secret_key) }\n RestClient.post \"#{$service_url}/api/bot/stop\", data, { :content_type => :json, :accept => :json }\n rescue => error\n { :status => :error, :message => error.to_s }\n end",
"def shutdown\n @socket = nil\n @thr.join if @thr\n @thr = nil\n end",
"def disconnect!\n @connection.logoff rescue nil\n end",
"def disconnect\n @thread.kill\n @socket.close\n end",
"def stop\n RuoteStomp.stop!\n end",
"def disconnect!\n context.with_connection do |connection|\n connection.disconnect!\n end\n @monitor.stop! and true\n end",
"def halt\n\t\tself.shutting_down = true\n\t\tself.consumer.channel.close\n\tend",
"def stop\n ws.stop\n end",
"def shut_down\n trigger(:shut_down_started)\n @server.stop(true) if @server\n @server_thread.join if @server_thread\n adapter.shut_down\n trigger(:shut_down_complete)\n end",
"def stop\n EM.cancel_timer @notify_timer\n notify :byebye\n stop_ssdp_server\n\n sleep 2\n stop_http_server\n end",
"def stop\n @socket.close\n ensure\n cleanup\n end",
"def stop\n @pull.close if !@pull.nil?\n @push.close if !@push.nil?\n Communicator::get_logger.info \"Forcing app to shut down\"\n exit 0\n end",
"def disconnect(message = nil)\n @voice.destroy\n delete_dir\n respond(message) if message\n @voice = nil\n @channel = nil\n rescue => e\n LOGGER.error 'An error occured while trying to leave a server.'\n LOGGER.log_exception e\n end",
"def stop\n @server.close\n end",
"def quit(msg = false)\n thread[:socket].close\n thread[:socket] = nil\n debug \"[DEBUG] User #{thread[:user]} disconnected.\"\n \"221 Laterz\"\n end",
"def close_socket\n @stop = true\n end",
"def stop\n @server.stop if @server.running?\n end",
"def stop\n @builder.terminate\n @server.terminate\n end",
"def local_disconnect(body)\n @connection.disconnect\n _network_init\n _notice \"disconnected\", :global\nend",
"def stop(*args)\n unless stopped?\n get '/invoke/wm.server.admin/shutdown?bounce=no&timeout=0&option=force'\n wait_until(\"Stopping\") do\n stopped?\n end\n end\n end",
"def stop\n logger.debug \"stopping server\"\n @status = :stopping\n EM.stop_server @sig\n done if @connections.empty?\n sleep 0.1 while @status != :stopped unless EM.reactor_thread?\n end",
"def stop\n info \"STOP!\"\n @worker.shutdown! if @worker\n end",
"def stop\n @server.shutdown if @server\n end",
"def close &on_disconnect\n @heartbeat_timer.cancel if @heartbeat_timer\n @heartbeat_timer = nil\n if on_disconnect\n @closing = true\n @on_disconnect = proc{\n on_disconnect.call\n @closing = false\n }\n end\n\n callback{ |c|\n if c.channels.any?\n c.channels.each do |ch, mq|\n mq.close\n end\n else\n send Protocol::Connection::Close.new(:reply_code => 200,\n :reply_text => 'Goodbye',\n :class_id => 0,\n :method_id => 0)\n end\n }\n end",
"def stop\n @appserver.stop\n \n if @thread\n sleep 0.1 while @thread[:running]\n @thread.kill\n @thread = nil\n end\n end",
"def stop\n @client.stop unless @client == MqClient.instance\n end",
"def disconnect(reason = nil, timeout = 5)\n # Quit and wait for replies from server\n @bot.quit(reason)\n sleep(timeout)\n end",
"def unbind\n puts \"client a connection has terminated\"\n EventMachine::stop_event_loop() \n end",
"def disconnect\n EM.stop if EM::reactor_running?\n self.connection = nil\n end",
"def stop! #:nodoc:\n if @amqp_connections.empty?\n EM.stop_event_loop\n else\n server, connection = @amqp_connections.shift\n connection.close { stop! }\n end\n end",
"def client_disconnected\n puts \"client #{current_user.email} disconnected\"\n current_player = current_user.player\n broadcast_message :player_exit, {\n id: current_player.id\n }\n current_player.is_online = false\n current_player.save\n end",
"def stop\n unless @thread.nil?\n t, @thread = @thread, nil\n t[:stop] = true\n t.wakeup.join if t.status\n end\n\n kill if alive?\n @io.close unless @io.nil? || @io.closed?\n @io = nil\n self\n end",
"def shutdown!\n return unless active?\n\n @session_mutex.synchronize do\n # cancel all active forward channels\n @session.forward.active_locals.each do |lport, host, port|\n @session.forward.cancel_local(lport)\n end\n end\n\n @active = false\n\n @thread.join\n @session.close\n end",
"def disconnect\n @server = nil\n @status = :disconnected\n end",
"def stop\n return if not running?\n @running = false\n @server.shutdown\n end",
"def stop_server\n if ! @wbthread.nil? && @wbthread.alive?\n # signal server thread to quit\n Process.kill('USR1', Process.pid)\n # wait for it to actually quit\n # note: Sometimes it appears to hang here at this join, when there's something wrong with the server or client\n # when that happens just comment out to see more debug info what's wrong\n # you'll also get some spurious concurrency errors of course, but at least the problem will show up too\n @wbthread.join\n end\n end",
"def stop\n EM.add_timer(0) do\n logger.info('Stopping server...')\n EM.stop\n end\n end",
"def stop!\n self.class.cleanup!(:pid => @sudo_pid, :socket => @socket)\n @proxy = nil\n end",
"def stop\n\t\tsuper\n\n\t\tself.socket.shutdown( :WR )\n\tend",
"def stop\n\t\tsuper\n\n\t\tself.socket.shutdown( :WR )\n\tend",
"def close_websocket\n if @handler\n @handler.close_websocket\n else\n # The handshake hasn't completed - should be safe to terminate\n close_connection\n end\n end",
"def unbind()\n Babylon.logger.debug(\"DISCONNECTED\") # Very low level Logging\n EventMachine::stop_event_loop\n end",
"def stop\n @pid ? Process.kill('TERM', @pid) : close_connection\n end",
"def stop\n log.info 'Bot stopping sync'\n @client.stop_syncing\n end",
"def disconnect\n if threaded[:connection]\n threaded[:connection].disconnect\n threaded[:connection] = nil\n end\n end",
"def disconnect\n info 'closing connection to host'\n @connected = false\n end",
"def stop\n self.listener.stop\n self.listener.close\n end",
"def close\n @status = DISCONNECTED\n send(Jabber::Presence.new.set_type(:unavailable))\n end",
"def stop\n @thread.kill\n self.send(:post_stop) if self.respond_to?(:post_stop, true)\n end",
"def kill\n @ws_thread.kill\n end",
"def kill\n @ws_thread.kill\n end",
"def close(handler)\n puts '! Connection closed' if handler.bot.debug\n exit false\n end",
"def drb_stop!\n Vedeu.bind(:_drb_stop_) { Vedeu::Distributed::Server.stop }\n end",
"def stop\n @shutdown = true\n end",
"def shutdown\n client.close\n end",
"def disconnect!\n @client&.close\n rescue StandardError\n nil\n end",
"def stop\n @mutex.synchronize do\n if( not @closed )\n\n begin\n @lsock.close if @lsock\n rescue\n end\n\n begin\n @rsock.close if @rsock\n rescue\n end\n\n @client_thread.kill if( @client_thread and @client_thread.alive? )\n\n @server.remove_client( self )\n\n @closed = true\n end\n end\n end",
"def close\n @channels.each{|channel,omegle|\n omegle.send(\"You have been connected to a message bridge, which is now shutting down. Goodbye.\")\n omegle.disconnect\n }\n end",
"def stop\n @listening = false\n @thread.join if @thread\n end",
"def stop\n Agent.stop\n end",
"def shutdown\n connection.write(\"shutdown\")\n end",
"def stop\n jetty.stop\n end",
"def disconnect\n @hazel.shutdown\n end",
"def turn_off\n self.class._end_session\n end",
"def disconnect!\n disconnect\n end",
"def stop\n Agent.stop\n end",
"def stop\n @listen_thread.kill if listening?\n end",
"def stop\n if @http_server\n # shuts down the server\n @http_server.shutdown\n \n # print goodbye message\n puts\n print_info 'BeEF server stopped'\n end\n end",
"def disconnect\n @socket.close\n end",
"def stop!\n # Permissions are handled by the script, use: :sudo => false\n run_script! :stop, :sudo => false\n end",
"def stop\n return unless running\n\n $logger.trace(\"Appium:#{@pid}\") { 'Stopping appium server' }\n Process.kill('INT', @pid)\n @pid = nil\n @appium_thread.join\n @appium_thread = nil\n end",
"def disconnect\n Log.debug(\"Disconnecting from Stomp\")\n @connection.disconnect\n end",
"def shutdown\n client.deregister_inbound_handler(Rex::Post::Meterpreter::Extensions::Stdapi::Net::SocketSubsystem::TcpServerChannel)\n end",
"def quit!\n command \"quit\" if alive?\n ensure\n @alive = false\n @socket = nil\n File.delete(@socket_path) if File.exist?(@socket_path)\n end",
"def stop!\n @thread.kill && @thread.stop?\n end",
"def stop\n puts \"== The Middleman is shutting down\"\n if !@options[:\"disable-watcher\"]\n Process.kill(::Middleman::WINDOWS ? :KILL : :TERM, @server_job)\n Process.wait @server_job\n @server_job = nil\n end\n end",
"def stop\n return if @closed\n error = check_result ::Libuv::Ext.idle_stop(handle)\n reject(error) if error\n end",
"def stop\n Thread.current[:shutdown] = true\n end",
"def close &on_disconnect\n @on_disconnect = on_disconnect if on_disconnect\n\n callback{ |c|\n if c.channels.any?\n c.channels.each do |ch, mq|\n mq.close\n end\n else\n send Protocol::Connection::Close.new(:reply_code => 200,\n :reply_text => 'Goodbye',\n :class_id => 0,\n :method_id => 0)\n end\n }\n end",
"def disconnect\n if @socket\n @socket.close\n @socket = nil\n @authed = false\n end\n end",
"def disconnect\n if @socket\n @socket.close\n @socket = nil\n @authed = false\n end\n end",
"def async_stop\n maybe_log(\"Stopping #{name}\")\n @ractor.send(Message.new(:stop))\n self\n rescue ::Ractor::ClosedError\n # Ignore to allow stops to be idempotent.\n self\n end"
] | [
"0.7357848",
"0.7296975",
"0.72584254",
"0.7149089",
"0.700618",
"0.68498033",
"0.67867374",
"0.665966",
"0.6564098",
"0.6564098",
"0.6564098",
"0.6457363",
"0.6405716",
"0.64038056",
"0.6369088",
"0.6361477",
"0.6351509",
"0.6326374",
"0.6321919",
"0.63198364",
"0.6319712",
"0.6315687",
"0.62881047",
"0.62862015",
"0.6266833",
"0.6263551",
"0.62548053",
"0.6244703",
"0.62388366",
"0.61922586",
"0.61797273",
"0.61760217",
"0.61316466",
"0.612651",
"0.61261636",
"0.61257964",
"0.6112737",
"0.6110489",
"0.60972846",
"0.60953116",
"0.6081903",
"0.6081243",
"0.6080458",
"0.6072087",
"0.60645074",
"0.60566473",
"0.6047771",
"0.6047541",
"0.60474354",
"0.6047339",
"0.6045338",
"0.6045086",
"0.6041184",
"0.6034084",
"0.60338277",
"0.6032237",
"0.6024645",
"0.6022693",
"0.6022693",
"0.60161585",
"0.6013793",
"0.59933454",
"0.599163",
"0.5986766",
"0.59844244",
"0.59690225",
"0.59608984",
"0.59585077",
"0.5957987",
"0.5957987",
"0.5944431",
"0.59313214",
"0.59275776",
"0.5927313",
"0.591588",
"0.5915731",
"0.5914671",
"0.59055346",
"0.59043026",
"0.5896969",
"0.589542",
"0.5870314",
"0.58600974",
"0.5856247",
"0.5851607",
"0.5842273",
"0.5833975",
"0.5833023",
"0.5830311",
"0.5827202",
"0.58248925",
"0.582402",
"0.5823583",
"0.58080715",
"0.58033997",
"0.57987744",
"0.57776797",
"0.5776325",
"0.5771247",
"0.5771247",
"0.5768911"
] | 0.0 | -1 |
Creates an OAuth invite URL that can be used to invite this bot to a particular server. | def invite_url(server: nil, permission_bits: nil)
@client_id ||= bot_application.id
server_id_str = server ? "&guild_id=#{server.id}" : ''
permission_bits_str = permission_bits ? "&permissions=#{permission_bits}" : ''
"https://discord.com/oauth2/authorize?&client_id=#{@client_id}#{server_id_str}#{permission_bits_str}&scope=bot"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invite_url(server = nil)\n raise 'No application ID has been set during initialization! Add one as the `application_id` named parameter while creating your bot.' unless @application_id\n\n guild_id_str = server ? \"&guild_id=#{server.id}\" : ''\n \"https://discordapp.com/oauth2/authorize?&client_id=#{@application_id}#{guild_id_str}&scope=bot\"\n end",
"def invite_url(html_url)\n # https://github.com/mike-north/micro-observable\n\n # https://github.com/mike-north/micro-observable/invitations\n invite_url = html_url + \"/invitations\"\n invite_url\n end",
"def bookkeeper_invitation_url(access)\n \"#{::AppConfig.mail.host}/access/#{access}\"\n end",
"def join_server(token, invite_code)\n request(\n __method__,\n :post,\n \"#{api_base}/invite/#{invite_code}\",\n nil,\n Authorization: token\n )\n end",
"def guest_url\n if guest_access_enabled?\n \"http://#{@campfire.subdomain}.campfirenow.com/#{guest_invite_code}\"\n else\n nil\n end\n end",
"def get_invitation_link\n\t\tscope = self.scope\n\t\trace_id = self.race_id\n\t\t\n\t\tbase_url = InvitationEmailTarget.get_base_url(race_id, scope)\n\t\t\n\t\tbase_url += case self.scope\n\t\twhen (COMPETITION_SCOPE[:SITE])\n\t\t\t'competitions/' + self.id.to_s + '?code=' + self.invitation_code\n\t\twhen (COMPETITION_SCOPE[:CYCLINGTIPS])\n\t\t\t'?competition_id=' + self.id.to_s + '&code=' + self.invitation_code\n\t\tend\n\t\t\n\t\treturn base_url\n\tend",
"def join_url(username, role, key=nil, options={})\n server = BigbluebuttonRails.configuration.select_server.call(self, :join_meeting_url)\n\n pass = case role\n when :moderator\n self.moderator_api_password\n when :attendee\n self.attendee_api_password\n when :guest\n if BigbluebuttonRails.configuration.guest_support\n options = { guest: true }.merge(options)\n end\n self.attendee_api_password\n else\n map_key_to_internal_password(key)\n end\n\n r = server.api.join_meeting_url(self.meetingid, username, pass, options)\n r.strip! unless r.nil?\n r\n end",
"def send_invite(invite, password=nil)\n @invite = invite\n @event = @invite.event\n @password = password\n @email = @invite.invited_email\n @photographer = @event.photographer\n @subject = @invite.invite_subject\n link_slug = Link.create(event_id: @event.id)\n unique_key = Shortener::ShortenedUrl.generate(event_path(link_slug, invited: 'true')).unique_key\n @link = (ENV['END_CLIENT_URL'] || Rails.application.secrets[:env]['END_CLIENT_URL']) + '/' + unique_key\n mail(to: @email, subject: @subject )\n end",
"def create_url(client)\n Bitlyr::Url.new(client, 'user_clicks' => clicks, 'user_hash' => user_hash)\n end",
"def create_url\n uri = Addressable::URI.new\n uri.query_values = properties\n \"#{ BASE_URI }#{ Hubspotter.configuration.portal_id }#{ create_endpoint }#{ uri.query }\"\n end",
"def oauth_url\n @oauth_url || File.join(host, \"oauth20/token\")\n end",
"def url\n File.join(DigitalRiver.config.oauth_url)\n end",
"def url_after_invite(invite)\n invite.invitable\n end",
"def invite_bot\n SlackUtils::SingletonClient.instance.invite_channel(@bot.channel_id, Bot.slack_bot_id, session[:token])\n end",
"def url\n File.join(DigitalRiver.config.oauth_url)\n end",
"def invitation_url(type, employee)\n if type == :invite\n new_account_organization_invitation_path(current_account, current_organization, invitation: { employee_id: employee.id })\n else\n edit_account_organization_invitation_path(current_account, current_organization, employee.invitation)\n end\n end",
"def oauth_url\n url = <<-URL\n https://www.facebook.com/dialog/oauth/\n ?client_id=#{Network::Facebook.app_id}\n &redirect_uri=#{URI.escape(\"#{root_url}auth/facebook/?r=#{redirect_for(request.referer)}\")}\n &scope=#{Network::Facebook.scope}\n URL\n url.gsub(/\\s+/, '')\n end",
"def get_authentication_url\n @wll.getConsentUrl(\"Contacts.Invite\")\n end",
"def url_after_invite(invite)\n invite.invitable\n end",
"def server_url\n return @custom_url if @custom_url\n if !@sauce_username.nil? && !@sauce_access_key.nil?\n \"http://#{@sauce_username}:#{@sauce_access_key}@ondemand.saucelabs.com:80/wd/hub\"\n else\n \"http://127.0.0.1:#{@port}/wd/hub\"\n end\n end",
"def oauth_uri(provider=\"FACEBOOK\")\n dest= session[\"return_to\"] || request.env[\"REQUEST_URI\"] || \"/\"\n \"#{oauth_uri_left_part}/account/oauth_start?provider=#{CGI.escape(provider)}&dest_left=#{CGI.escape(request_uri_left_part)}&dest_path=#{CGI.escape(dest)}\"\n end",
"def auth_url\n client.authorization.authorization_uri(state: '', approval_prompt: :force, access_type: :offline, user_id: client_email).to_s\n end",
"def vend_url\n URI(\"https://#{config.vend_id}.vendhq.com/\")\n end",
"def endpoint_url\n protocol = @secure ? 'https' : 'http'\n endpoint_host = SmsNotify::Api.endpoint_host\n \"#{protocol}://#{endpoint_host}/\"\n end",
"def oauth_url_authorize\n return \"#{$SETTINGS[:oauth_server_url_authorize]}?response_type=code&client_id=#{$SETTINGS[:oauth_client_id]}&scope=ALL&redirect_uri=#{oauth_redirect_uri}\" \n end",
"def uri\n sprintf(\"%s/%s?token=%s\", API_ENDPOINT, COMMAND, config.slack_bot_token)\n end",
"def server_url\n \"http://#{server_host}:#{server_port}\"\n end",
"def build_url(options)\n protocol = options.include?(:certificate) ? 'drbssl' : 'druby'\n \"#{protocol}://#{options[:host]}:#{options[:port]}\"\n end",
"def generate_authorize_url(request_token)\n request = consumer.create_signed_request(:get,\n consumer.authorize_path, request_token,\n {:oauth_callback => 'oob'})\n\n params = request['Authorization'].sub(/^OAuth\\s+/, '').split(/,\\s+/).map do |param|\n key, value = param.split('=')\n value =~ /\"(.*?)\"/\n \"#{key}=#{CGI::escape($1)}\"\n end.join('&')\n\n \"#{base_url}#{request.path}?#{params}\"\n end",
"def get_meeting_url(id, password)\n prepare\n @api.join_meeting_url(id, 'Guest', password)\n end",
"def endPoint(path='')\n parts = ['https:/', $cfg['net.host'], 'api:1'] + @uriparts\n s = parts.map{|v| v.to_s}.join('/')\n URI(s + path.to_s)\n end",
"def sso_integration_callback_url\n # Usually http://example.com/auth/:system_name/callback\n url = callback_url(query: {})\n\n case kind\n when 'auth0'\n # e.g. http://example.com/auth/invitations/auth0/auth0_123abc/callback\n invitation_signup = client.callback_url(\"#{base_url}/invitations\")\n\n [url, invitation_signup].join(', ')\n else\n url\n end\n end",
"def fire_eagle_auth_url\n client = if fire_eagle_requested?\n requested_client\n else\n fire_eagle_request!\n end\n client.authorization_url \n end",
"def guest_link\n return guest_hearing_link if guest_hearing_link.present?\n\n \"#{VirtualHearing.base_url}?join=1&media=&escalate=1&\" \\\n \"conference=#{formatted_alias_or_alias_with_host}&\" \\\n \"pin=#{guest_pin}&role=guest\"\n end",
"def makeURL(path)\n \"#{self.api_endpt + path}?token=#{self.token}\"\n end",
"def host(inv, options = {}) \n link_to(inv.inviter.user_name, member_profile_url(:id => inv.inviter.user_name), :target => options[:target]) if inv.inviter\n end",
"def endpoint\n @endpoint ||= \"https://#{@subdomain}.desk.com\"\n end",
"def get_request_access_token_url\n URI.encode('https://'\"#{@subdomain}\"'.zendesk.com/oauth/tokens?grant_type=authorization_code&code='+ @code + '&client_id='+ @unique +'&client_secret='+ @secret +'&redirect_uri='\"#{@redirect_uri}\"'/&scope=read%20write')\n end",
"def get_access_url\n @request_token = @client.request_token\n token = @request_token.token\n secret = @request_token.secret\n\n \"http://www.fitbit.com/oauth/authorize?oauth_token=#{token}\"\n end",
"def publish_url(channel)\n (ssl ? \"https\" : \"http\") << \"://#{origin}/publish/#{publish_key}/#{subscribe_key}/#{secret_key || 0}/#{channel}/0\"\n end",
"def set_omniauth_zendesk_urls\n # Pull the account from the session.\n # We cached it here at the begining of the \n # authentication flow.\n account = session['omniauth.zendesk.account']\n\n # Update the client options with the dynamic endppints\n # based on the account subdomain given to us.\n options[:client_options] = {\n :site => \"https://#{account}.zendesk.com\",\n # TODO: Do we need to set these as absolute paths?\n :authorize_url => \"https://#{account}.zendesk.com/oauth/authorizations/new\",\n :token_url => \"https://#{account}.zendesk.com/oauth/tokens\"\n }\n end",
"def oauth_url\n 'https://geoloqi.com/oauth/authorize'\n end",
"def server_url\n @uri\n end",
"def auth_url\n MiniFB.oauth_url(@app_id, @redirect_to,\n :scope => 'user_about_me') # See MiniFB.scopes\n end",
"def screen_uri(params = {}, sn = screen_name)\n uri = URI(\"https://\" + app.captureui_addr)\n uri.path = \"/oauth/#{sn}\"\n uri.query = URI.encode_www_form(params)\n uri.to_s\n end",
"def server\n uri = \"#{options[:use_ssl] ? \"https\" : \"http\"}://#{Blupee.config.api_server}\"\n end",
"def generateConsentFlowUrl(opts={})\n scope = Array(opts[:scope] || @scope).join(\",\")\n suburl = (opts[:suburl] || @auth_url)\n redirect = (opts[:redirect] || @redirect)\n \"#{@fqdn}#{suburl}?client_id=#{CGI.escape(@client_id)}&scope=#{CGI.escape(scope)}&redirect_uri=#{CGI.escape(redirect)}\"\n end",
"def minecraft_link_host\n \"#{verification_token}.verify.minefold.com\"\n end",
"def server_url\n url\n end",
"def authorize_endpoint_url\n uri = URI(openid_config['authorization_endpoint'])\n uri.query = URI.encode_www_form(client_id: client_id,\n redirect_uri: callback_url,\n response_mode: response_mode,\n response_type: response_type,\n nonce: new_nonce)\n uri.to_s\n end",
"def token_endpoint\n URI::HTTPS.build(host: @host, path: '/' + @tenant + TOKEN_PATH)\n end",
"def inquests_url(options)\n url_for({:controller => :inquests, :action => :create}.merge(options))\n end",
"def connectURL\n\t\t\"http://beta.stoffiplayer.com/auth/#{provider}\"\n\tend",
"def create_oauth_url(cb_url, encoded_auth_state)\n oauth_url = \"https://www.facebook.com/dialog/oauth/?client_id=\" +\n \"#{APP_ID}&redirect_uri=#{cb_url}&state=#{encoded_auth_state}\"\n end",
"def oauth_callback_url\n end",
"def new_workplace_invite(sender, invite, recipient_email, recipient_name, workplace, token, workplace_id)\n @sender = sender\n @invite = invite\n @recipient_email = recipient_email\n @recipient_name = recipient_name\n @workplace = workplace \n @token = token\n @workplace_id = workplace_id\n mail(to: \"#{@recipient_email}\", subject: \"#{@sender.name} invited you to join Ossemble\")\n end",
"def generateConsentFlowUrl(endpoint=\"/oauth/authorize\")\n \"#{@fqdn}#{endpoint}?client_id=#{@client_id}&scope=#{@scope}&redirect_uri=#{@redirect_uri}\"\n end",
"def api_url\n authentication_credentials_provided? ? \"https://api.gowalla.com\" : \"http://api.gowalla.com\"\n end",
"def send_self_invite_link\n r = TestEconomyManagement::Invite.new({\n client_id: @client_id,\n client: @client,\n manager: @manager,\n email_addresses: @manager[:email]\n }).perform\n @failed_logs[:send_invite_link] = r.to_hash unless r.success?\n end",
"def pubsubhubbub_callback_url\n ENV['PUBSUBHUBBUB_CALLBACK_URL'].presence || Rails.application.routes.url_helpers\n .url_for(controller: 'curry/pull_request_updates', action: 'create',\n host: ENV['FQDN'], protocol: ENV['PROTOCOL'], port: ENV['PORT'])\n end",
"def base_url\n URI::HTTPS.build(host: @server, port: @port, path: @api)\n end",
"def get_base_uri(server = Server::DEFAULT)\r\n parameters = {\r\n 'base_url' => { 'value' => base_url, 'encode' => false }\r\n }\r\n APIHelper.append_url_with_template_parameters(\r\n ENVIRONMENTS[environment][server], parameters\r\n )\r\n end",
"def invitation(email, service, url)\n @url = url\n @service = service\n @email = email\n mail to: email, subject:\"Suncorp Survey\"\n end",
"def url() \n\t #'http://' << ENV['DOMAIN'] << \n\t '/' << self.author.username.to_s << '/' << self.name.to_s\n end",
"def _url\n URI.join(domain, path_gen.for_uri)\n end",
"def set_endpoint\n if ambiente == :producao\n return GetnetApi::Configure::URL[:producao]\n elsif ambiente == :homologacao\n return GetnetApi::Configure::URL[:homologacao]\n else\n return GetnetApi::Configure::URL[:sandbox]\n end\n end",
"def url\n @url = \"#{@http_mode}://#{self.config.servers[0]}\"\n @url << \"/#{self.config.context}\" if(!self.config.context.empty?)\n #self.config.log.debug_msg(\"Request base URL: #{@url}\")\n @url\n end",
"def site(*args)\n if !@subdomain.to_s.empty?\n site_uri = URI.parse(super)\n site_uri.host = \"#{@subdomain}.#{site_uri.host}\"\n logger.debug \"(slack) Oauth site uri with custom team_domain #{site_uri}\"\n site_uri.to_s\n else\n super\n end\n end",
"def send\n generate_url\n end",
"def send\n generate_url\n end",
"def make_url(dav_uri, mailbox)\n \"#{dav_uri}/#{mailbox}/\"\n end",
"def invitee_string\n\t\n\tend",
"def to_endpoint\n endpoint = @uri.path\n endpoint = '/' + endpoint unless endpoint.start_with?('/')\n Wgit::Url.new(endpoint)\n end",
"def to_endpoint\n endpoint = @uri.path\n endpoint = '/' + endpoint unless endpoint.start_with?('/')\n Wgit::Url.new(endpoint)\n end",
"def create_uri\n end",
"def authorize_url\n polymorphic_url([ @workspace, :twitter_account ], :action => 'authorize')\n end",
"def authenticate_url\n \"https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/urlshortener&response_type=code&client_id=#{ENV['GOOGL_CLIENT_ID']}&redirect_uri=#{ENV['GOOGL_REDIRECT_URI']}&access_type=offline&include_granted_scopes=true&approval_prompt=force\"\n end",
"def invite(invitation, www_host)\n @invitation = invitation\n @www_host = www_host\n \n mail :to => invitation.email_address\n end",
"def server_url\n \"#{ROCCI_SERVER_CONFIG.common.protocol || 'http'}://\" \\\n \"#{ROCCI_SERVER_CONFIG.common.hostname || 'localhost'}:\" \\\n \"#{ROCCI_SERVER_CONFIG.common.port.to_s || '3000'}\"\n end",
"def url\n @client.url + self.class.path + @username\n end",
"def meet_invitation(root_url, url, user, invitee, message, meet)\n @root_url, @url = root_url, url\n @user, @invitee, @message, @meet = user, invitee, message, meet\n mail(#:cc => user.email, \n :to => invitee.email,\n :subject => \"You've been added to a Kaya Meet\")\n end",
"def mailer_url_params(opts)\n return opts unless multisite_install?\n\n opts.merge(subdomain: @team.subdomain)\n end",
"def build_url(url)\n return url unless http_auth\n\n protocol, uri = detect_protocol(url)\n username, password = [:username, :password].map { |part| CGI.escape http_auth[part] }\n \"#{protocol}#{username}:#{password}@#{uri}\"\n end",
"def canvas(suffix)\n \"http://apps.facebook.com/\" + ENV['FACEBOOKER_RELATIVE_URL_ROOT'] + suffix\n end",
"def email_verification_from(token, server_hostname, protocol)\n %Q|\"#{server_hostname} staff\" <admin@#{server_hostname}>|\n end",
"def getServerUrl\n puts \"******* getServerUrl \" + \"*\" * 21\n reqUrl = request.original_url\n puts \" ** reqUrl \" + reqUrl\n gon.currentServerUrl = reqUrl\n end",
"def twitter_url; \"https://twitter.com/#{twitter}\" end",
"def request_token_url\n @options[:request_token_url] || site + request_token_path\n end",
"def plan_url(request)\n build_url(request[:from], request[:to], request[:trip_time], request[:arrive_by], request[:options] || {})\n end",
"def oauth_url(response_type = 'code')\n # The Redirect URI must be the same as registered with Put.io\n PUTIO_BASE_URL + \"/oauth2/authenticate?client_id=%i&response_type=%s&redirect_uri=%s\" % [@client_id, response_type, @redirect_uri]\n end",
"def request_url(requirelogin=false, requireuserinfo=false, expirationdays=30, notifyonupload=false)\n end",
"def authorize_url(params=nil)\n connection.build_url(options[:authorize_url], params).to_s\n end",
"def build_sso_url(link_authn_context, authn_con_compare = AuthnContext::EXACT)\n @query_params[:RelayState] = relay_state_params\n new_url_settings = url_settings\n new_url_settings.authn_context = link_authn_context\n new_url_settings.authn_context_comparison = authn_con_compare\n saml_auth_request = OneLogin::RubySaml::Authrequest.new\n save_saml_request_tracker(saml_auth_request.uuid, link_authn_context)\n saml_auth_request.create(new_url_settings, query_params)\n end",
"def request_url(requirelogin=false, requireuserinfo=false, expirationdays=30, notifyonupload=false)\n end",
"def authorize_url(ticket = nil)\n ticket = self.ticket unless ticket\n \"#{ api.base_url }/auth/#{ ticket }\"\n end",
"def create_uri url\n uri = URI.parse url\n uri.user = @login\n uri.password = @password\n uri\n end",
"def access_token_url\n Settings.lighthouse_health_immunization.access_token_url\n end",
"def signed_open_id_connect_initiation_url(login_hint:)\n URI(open_id_connect_initiation_url).tap do |uri|\n uri.query = {\n iss: Rails.application.secrets.issuer,\n login_hint: login_hint,\n target_link_uri: target_link_uri\n # lti_message_hint: 'xxx'\n }.to_query\n end\n end",
"def two_factor_otp_url\n \"otpauth://totp/%{app_id}?secret=%{secret}&issuer=%{app}\" % {\n :secret => current_user.unconfirmed_otp_secret,\n :app => \"Hammad\",\n :app_id => \"Ham\"\n }\n end",
"def gardener_url\n (ENV['SUT_SCHEME'] || 'https') + \"://\" + gardener_fqhn()\n end"
] | [
"0.79358506",
"0.61601734",
"0.6140274",
"0.61311567",
"0.58596253",
"0.57606685",
"0.5688839",
"0.5661156",
"0.56575847",
"0.56151354",
"0.5590863",
"0.5566705",
"0.5547112",
"0.5542738",
"0.5537466",
"0.5521269",
"0.55186635",
"0.54998434",
"0.5499122",
"0.5492385",
"0.54560745",
"0.5413703",
"0.54054743",
"0.5394571",
"0.5380455",
"0.53747416",
"0.53701425",
"0.5353185",
"0.5349933",
"0.5346711",
"0.5328896",
"0.53201747",
"0.5319699",
"0.5306607",
"0.5287799",
"0.52231336",
"0.52224594",
"0.52148193",
"0.521374",
"0.52036494",
"0.520015",
"0.5188118",
"0.5185471",
"0.5176428",
"0.51697934",
"0.516461",
"0.5160387",
"0.51579964",
"0.5150232",
"0.51500285",
"0.5146803",
"0.51371986",
"0.5120633",
"0.509809",
"0.50887996",
"0.5088506",
"0.5087991",
"0.50850236",
"0.5073184",
"0.5059541",
"0.5057974",
"0.5057096",
"0.5054794",
"0.5043142",
"0.5043023",
"0.5039998",
"0.5038214",
"0.5037896",
"0.50310624",
"0.50310624",
"0.502939",
"0.50260264",
"0.5023769",
"0.5023769",
"0.50221753",
"0.50173247",
"0.50159615",
"0.5003058",
"0.4996013",
"0.49921772",
"0.4988322",
"0.49851888",
"0.49821776",
"0.49811438",
"0.49793616",
"0.49760082",
"0.49758258",
"0.49755123",
"0.4966815",
"0.496584",
"0.49655077",
"0.49648964",
"0.49604258",
"0.49601302",
"0.49570075",
"0.4954879",
"0.49546298",
"0.49436477",
"0.4938778",
"0.49213943"
] | 0.7333291 | 1 |
Sends a text message to a channel given its ID and the message's content. | def send_message(channel, content, tts = false, embed = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil)
channel = channel.resolve_id
debug("Sending message to #{channel} with content '#{content}'")
allowed_mentions = { parse: [] } if allowed_mentions == false
message_reference = { message_id: message_reference.id } if message_reference.respond_to?(:id)
response = API::Channel.create_message(token, channel, content, tts, embed&.to_hash, nil, attachments, allowed_mentions&.to_hash, message_reference, components)
Message.new(JSON.parse(response), self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_text(text)\n client.api.send_message(id, text)\n end",
"def send_message(channel_id, content, tts = false, server_id = nil)\n channel_id = channel_id.resolve_id\n debug(\"Sending message to #{channel_id} with content '#{content}'\")\n\n response = API.send_message(token, channel_id, content, [], tts, server_id)\n Message.new(JSON.parse(response), self)\n end",
"def send_message(channel, content, opts = {})\n raise \"Unknown unit id, try providing :ret => 'id' when fetching units from the API.\" unless id && id > 0\n _cloud_connect.send_message(id, channel, content, opts)\n end",
"def send_message(message_text)\n @selected.send_message(message_text)\n end",
"def send_message_to_channel(client, channel_id, title, message)\n client.chat_postMessage(\n channel: channel_id, \n as_user: true,\n text: \"*\" + title + \"*\",\n attachments: [\n text: message,\n color: \"warning\"\n ]\n )\nend",
"def send_message(channel_id, params)\n cleaned = params.permit(:author_id,\n :sender_name,\n :subject,\n :body,\n :text,\n :attachments,\n { options: [:tags, :archive] },\n :to,\n :cc,\n :bcc)\n create(\"channels/#{channel_id}/messages\", cleaned)\n end",
"def send_message(text, channel)\n uri = URI('https://slack.com/api/chat.postMessage')\n params = {\n token: ENV['BOT_OAUTH_TOKEN'],\n text: text,\n channel: channel\n }\n uri.query = URI.encode_www_form(params)\n\n Net::HTTP.get_response(uri)\n end",
"def send_message\n message = render_to_string(:partial => 'messages/message', :object => @message)\n Juggernaut.send_to_channel(javascript_chat_message(message), @message.channel_id)\n end",
"def send_message(*args, **kwargs)\n bot = kwargs.fetch(:bot) { args.fetch(0) }\n args[0] = id\n kwargs[:chat_id] = id\n bot.send_message(*args, **kwargs)\n end",
"def send_message(text)\n end",
"def send_channel(message)\n @handler.send_channel message\n end",
"def send_message(jid,text)\n m = Jabber::Message.new(jid, text)\n m.set_type :chat\n @client.send m\n end",
"def send_message(chat_id, message)\n ActionCable.server.broadcast \"Chat:#{chat_id}\", response: chat_message(message), type: 'message'\n end",
"def send_text_message(subscriber, message)\n handle_manychat_response(send_content(subscriber, [create_message_text_hash(message)]))\n end",
"def send_message(payload)\n message = Message.new(author: current_user, text: payload[\"message\"])\n\n ActionCable.server.broadcast \"chat\", message: render(message) if message.save\n end",
"def say(text)\n @bot.api.sendMessage(chat_id: @message.chat.id, text: text)\n end",
"def send(to, text)\n begin\n @log.info \"Sending message to '#{to}'\"\n @client.send Message::new(to, text).set_type(:chat).set_id('1').set_subject('Boti')\n return true\n rescue\n @log.error \"Error sending message to '#{to}'\"\n return false\n end\n end",
"def send_message(payload)\n message = Message.new(user: current_user, chat_id: payload[\"id\"], body: payload[\"message\"])\n\n ActionCable.server.broadcast \"chat_#{payload['id']}\", message: render(message) if message.save\n end",
"def send(message, options = { channelID: 1 })\n params = { message: message, channelID: options[:channelID] }\n rest.post chat_path, params: params\n end",
"def run(text,\n channel: DEFAULT_CHANNEL,\n username: DEFAULT_USERNAME,\n icon_url: DEFAULT_ICON_URL,\n icon_emoji: DEFAULT_ICON_EMOJI)\n\n payload = build_payload(text, channel, username, icon_url, icon_emoji)\n\n send_payload(payload)\n end",
"def update text\n payload = { \"text\" => message }.to_json\n data = client.post \"#{api_prefix}/rooms/#{room_id}/chatMessages/#{id}\", payload\n\n new client, room_id, data\n end",
"def send_reply(text)\n @bot.api.send_message(chat_id: @last_message.chat.id, text: text)\n end",
"def send_irc(channel, message)\n real_channel = @zbot.get_channel(channel)\n if real_channel\n real_channel.send(message)\n else\n puts \"############## CHANNEL #{channel} NOT FOUND !\"\n end\n end",
"def send_channel(message)\n @bot.message_queue.push(\"PRIVMSG ##{bot.channel.name} :#{message}\")\n end",
"def send( text )\n checkConnection()\n @conn.write( text + EOL )\n end",
"def send( text )\n checkConnection()\n @conn.write( text + EOL )\n end",
"def send_text\n Rails.logger.info \"Sending \\\"#{text}\\\" to #{number}...\"\n Twilio::Sms.message(TWILIO_CONFIG['caller_id'], number, text)\n end",
"def say(msg)\n self.signed_request '/api/v1/chat.postMessage', 'POST', {roomId: @channel_id, text: '>' + msg}\n end",
"def send_message(content, tts = false, embed = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil)\n @bot.send_message(@id, content, tts, embed, attachments, allowed_mentions, message_reference, components)\n end",
"def send_message(token, channel_id, message, mentions = [], tts = false, guild_id = nil)\n request(\n \"message-#{guild_id}\".to_sym,\n :post,\n \"#{api_base}/channels/#{channel_id}/messages\",\n { content: message, mentions: mentions, tts: tts }.to_json,\n Authorization: token,\n content_type: :json\n )\n rescue RestClient::InternalServerError\n raise Discordrb::Errors::MessageTooLong, \"Message over the character limit (#{message.length} > 2000)\"\n end",
"def send(api_key, channel, message, items, code)\n client(api_key).chat_postMessage(\n channel: \"#\" + channel,\n as_user: true,\n attachments: [\n {\n fallback: \"#{message}\\n\\n\",\n pretext: \"#{message}\\n\\n\",\n title: items.select{|i| i[:title]}.try(:first)[:title],\n title_link: items.select{|i| i[:title_link]}.try(:first)[:title_link],\n color: Speko::Slack.enabled_configs[:codes][code],\n fields: generate_message(items),\n footer: items.select{|i| i[:user]}.try(:first)[:user] || 'unknown user?',\n ts: DateTime.now.to_i\n }\n ]\n )\n rescue\n Rails.logger.debug \"Could not post to Slack Channel: #{channel}\"\n false\n end",
"def handle(channel_id, msg_id, data)\n channel_config, message_config, text =\n prepare_message(channel_id, msg_id, data)\n chats = channel_config.chat_ids\n connector = channel_config.connector\n\n if message_allowed?(message_config, data)\n chats.map { |chat| connector.send_message(chat, text, message_config) }\n else\n logger.warn \"#{channel_id}/#{msg_id}: \" \\\n \"Skip sending message. Because it's not allowed\"\n []\n end\n end",
"def send_message(_target, text) # rubocop:disable Metrics/AbcSize\n url = \"https://api.gitter.im/v1/rooms/#{config.room_id}/chatMessages\"\n uri = URI.parse(url)\n\n Net::HTTP.start(\n uri.host,\n uri.port,\n use_ssl: true,\n verify_mode: OpenSSL::SSL::VERIFY_NONE,\n ) do |http|\n request = Net::HTTP::Post.new(uri.path)\n request.add_field('Content-Type', 'application/json')\n request.add_field('Accept', 'application/json')\n request.add_field('Authorization', \"Bearer #{config.token}\")\n request.body = { 'text' => text }.to_json\n response = http.request(request)\n\n @user_id = MultiJson.load(response.body)['fromUser']['id']\n end\n end",
"def sendChatMessage(a_to, a_text)\n\t\tp 'JabberClient.sendChatMessage'\n\tend",
"def send_message message\n payload = { \"text\" => message }.to_json\n data = client.post \"#{api_prefix}/rooms/#{id}/chatMessages\", payload\n\n Message.new client, id, data\n end",
"def send_message(mes,token,user_id)\n #Open a direct message\n options = {\n token: token,\n user: user_id\n }\n channel_id = post('https://slack.com/api/im.open', options).channel.id\n\n #Send the message\n options = {\n token: token,\n channel: channel_id,\n text: mes\n }\n post('https://slack.com/api/chat.postMessage', options)\nend",
"def perform(data)\n user = User.find(data[\"user_id\"])\n ActionCable.server.broadcast 'chat_channel', content: data[\"content\"], username: user.email, id: user.id\n end",
"def send_message(msg)\n send_data({:type => :message, :body => msg})\n end",
"def ctcp_reply(text)\n recipient = data[:channel] || data[:nick]\n @irc.notice(recipient, \"\\001#{@data[:ctcp_action]} #{text}\\001\")\n end",
"def send_text(text)\n response = AGIResponse.new\n command_str = \"SEND TEXT '#{text}'\"\n begin\n response.native = execute(command_str)\n rescue AGITimeoutError, AGICommandError, AGIHangupError\n raise\n end\n if response.native == -1 then\n raise AGIChannelError.new(@last_response, \"Channel Failure in (#{command_str})\")\n elsif response.native == 0\n response.success = true\n end\n return response\n end",
"def send_text_message(text_message)\n number_to_send_to = text_message.receiver\n message = text_message.content\n twilio_sid = \"AC50070372767bdf26a090b08007bba07f\"\n twilio_token = \"8ae1cdbb08d55b99cab34174c3cd8bbb\"\n twilio_phone_number = \"2245209581\"\n @twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token\n @twilio_client.account.sms.messages.create(\n :from => \"+1#{twilio_phone_number}\",\n :to => number_to_send_to,\n :body => message\n )\n \n end",
"def chat_meMessage(options = {})\n raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?\n raise ArgumentError, 'Required arguments :text missing' if options[:text].nil?\n post('chat.meMessage', options)\n end",
"def send_message_to_channel(channel_name, message)\n logger.debug \"Sending in application to channel #{channel_name}\"\n channel = @channels[channel_name]\n if channel.nil?\n logger.debug \"Trying to send a message to a void channel #{channel_name} en #{self}\"\n return\n end\n channel.publish message\n stat_message_sended channel_name\n # TODO: Message received should count messages received in other parrot servers\n # Should be moved to channel\n stat_message_received channel_name, channel.listeners_count\n logger.debug \"Sended to channel #{channel_name}\"\n end",
"def send_message(message)\n self.broadcast({\n type: \"chat_message\",\n message: message\n })\n end",
"def send_message(message)\n response = HTTParty.post(\n CHAT_URL,\n body: {\n token: ENV[\"SLACK_API_TOKEN\"],\n text: message,\n channel: @slack_id # need slack_id, per Slack documentation for send_message \n },\n )\n \n return response.code == 200 && response.parsed_response[\"ok\"]\n end",
"def send_message(*args, **kwargs)\n chat_id = kwargs.fetch(:chat_id) { args.fetch(0) }\n text = kwargs.fetch(:text) { args.fetch(1) }\n parse_mode = kwargs.fetch(:parse_mode) { args[2] }\n disable_web_page_preview = kwargs.fetch(:disable_web_page_preview) { args[3] }\n\n logger.info \"sending message: #{text.inspect}\"\n data = {text: text, chat_id: chat_id}\n data[:parse_mode] = parse_mode unless parse_mode.nil?\n data[:disable_web_page_preview] = disable_web_page_preview unless disable_web_page_preview.nil?\n\n args.shift(4)\n args.unshift(\"#{@base_path}/sendMessage\", data)\n Message.new(post_message(*args, **kwargs))\n end",
"def send_message(data)\n current_user.messages.create!(body: data[\"message\"], chat_room_id: data[\"chat_room_id\"])\n # the next line broadcasts the message without a job. BUT: that is only the message.\n # We want do more :)\n # ActionCable.server.broadcast(\"chat_rooms_channel\", message: data[\"message\"])\n end",
"def send_text_message(body)\n app = current_application\n if app.present?\n app.send_text_message body\n end\n end",
"def reply(params = {})\n fail InitWithoutBot unless @bot\n\n params[:chat] = self[:chat]['id']\n\n params[:as_plain_message] = true unless params.key? :as_plain_message\n params[:reply_to] = self[:id] unless params[:as_plain_message]\n param.delete :as_plain_message\n\n @bot.send_text params\n end",
"def send_message(recipient, message_text, opts={})\n valid_options = opts.only(:from)\n valid_options.merge!(:req_feat => '48') if valid_options[:from]\n response = execute_command('sendmsg',\n {:to => recipient, :text => message_text}.merge(valid_options)\n ) \n parse_response(response)['ID']\n end",
"def send_temporary_message(channel_id, content, timeout, tts = false, server_id = nil)\n Thread.new do\n message = send_message(channel_id, content, tts, server_id)\n\n sleep(timeout)\n\n message.delete\n end\n\n nil\n end",
"def say(recipient_id, text, quick_replies = nil)\n message_options = {\n recipient: { id: recipient_id },\n message: { text: text }\n }\n\n Bot.deliver(message_options, access_token: ENV['ACCESS_TOKEN'])\nend",
"def message_params\n params.require(:channel_message).permit(:channel_id, :text)\n end",
"def reply(text)\n recipient = data[:channel] || data[:nick]\n @irc.privmsg(recipient, text)\n end",
"def send(target, message)\n @irc.send_msg(target, message)\n end",
"def perform(message)\n\t\t# Broadcast the rendered message to the channel\n\t\tActionCable.server.broadcast 'chatroom_channel', message: render_message(message)\n\tend",
"def send(message)\n @chats.each do |chat|\n begin\n chat.send(message)\n rescue\n @chats.delete(chat)\n end\n end\n end",
"def send_text(id, text, options={:wait_for_keyboard => true})\n\n\t\tif ENV['PLATFORM'] =='android'\n\t\t\tquery(\"* marked:'#{id}'\", :setText => \"#{text}\")\n\t\telse\n\t\t\tif ENV['PLATFORM'] == 'ios'\n\t\t\t\ttouch(id)\n\t\t\t\twait_for_keyboard unless options[:wait_for_keyboard] == false\n\t\t\t\tkeyboard_enter_text(text)\n\n\t\t\tend\n\n\t\tend\n\tend",
"def send_message(message)\n check_parenthesis(message)\n puts \"Send: #{message}\" if @debug\n connection{|c| c.write(message)}\n end",
"def send_message_local(channel, user, message)\n logger.debug \"Sending message: #{message} to user: #{user} on channel: #{channel}. Message\"\n if @@connections[channel].nil?\n logger.error \"channel not configured: #{channel}\"\n return nil\n end\n\n write message, @@connections[channel][user]\n end",
"def respond(message)\n @channel.send_message(message) if @channel\n end",
"def answer(text)\n return unless data[:channel]\n @irc.privmsg(data[:channel], \"#{data[:nick]}: #{text}\")\n end",
"def send_notice(text)\n client.api.send_notice(id, text)\n end",
"def message(to, text, opts = {})\n Entity::Message.new(self, to, text, opts).deliver\n end",
"def send_message(message); end",
"def send_message(message); end",
"def send_message(email, text)\n @notification_server.send_message email, text\n end",
"def send_reply(conversation_id, params)\n cleaned = params.permit(:author_id,\n :sender_name,\n :subject,\n :body,\n :text,\n :attachments,\n { options: [:tags, :archive] },\n :channel_id,\n :to,\n :cc,\n :bcc)\n create_without_response(\"conversations/#{conversation_id}/messages\", cleaned)\n end",
"def process_outgoing_message(id, text) \n return if self.process_command(id, text.split.first, text.split[1..-1]) or not self.online? # try to execute commands\n @logger.warn 'Sending message to chat %s' % id\n reply = text.lines[0].scan(/\\d+/).first.to_i if text.lines[0] =~ /^> ?[0-9]{10}/ \n text = TD::Types::FormattedText.new(text: !reply ? text : text.lines[1..-1].join, entities: [])\n message = TD::Types::InputMessageContent::Text.new(text: text, disable_web_page_preview: false, clear_draft: false)\n return (id) ? @telegram.send_message(id, reply.to_i, nil, nil, message).rescue{|e| @xmpp.send_message(@jid, id, \"Not sent: %s\" % e)} : message\n end",
"def send(message)\n message\n end",
"def send_text(command)\n @session.connection.puts(command)\n end",
"def message(text)\n @text_queue.push text\n end",
"def send_message(subject:, text:, from: nil)\n super(to: get_attribute(:name), subject: subject, text: text, from: from)\n end",
"def send_message(subject:, text:, from: nil)\n super(to: get_attribute(:name), subject: subject, text: text, from: from)\n end",
"def send(id:, subject:, from:, html:, text:)\n request do\n response =\n connection.post(\"#{id}/send\",\n 'from' => from,\n 'subject' => subject,\n 'html' => html,\n 'text' => text)\n\n parse(response.body)\n end\n end",
"def say(recipient_id, text, quick_replies = nil)\n message_options = {\n recipient: { id: recipient_id },\n message: { text: text }\n }\n if quick_replies\n message_options[:message][:quick_replies] = quick_replies\n end\n Bot.deliver(message_options, access_token: ENV['ACCESS_TOKEN'])\nend",
"def link_to_channel(text, channel_name, *args)\n link_to_function text, \"CCPEVE.joinChannel(#{channel_name.inspect})\", *args\n end",
"def send_message (*params)\n send_line Message.new(*params)\n end",
"def send_message(user_id, message)\n @user = User.find(user_id)\n @message = message\n mail(to: @user.email, subject: 'You have a message from')\n end",
"def send_file(token, channel_id, file, caption: nil, tts: false)\n request(\n __method__,\n :post,\n \"#{api_base}/channels/#{channel_id}/messages\",\n { file: file, content: caption, tts: tts },\n Authorization: token\n )\n end",
"def say(message, channel = @config[:channel])\n @t.puts \"PRIVMSG #{channel} :#{message}\"\n log_it([@config[:nick],\"\",\"\",\"\",message]) if channel == @config[:channel]\n end",
"def set_text_message\n @text_message = TextMessage.find(params[:id])\n end",
"def react(channel, msg_id, emoji)\n channel = find_channel(name: channel) rescue nil\n raise OutteError.new 'Channel not found' if channel.nil?\n msg = channel.message(msg_id.to_i) rescue nil\n raise OutteError.new 'Message not found' if msg.nil?\n emoji = find_emoji(emoji, channel.server) if emoji.ascii_only? rescue nil\n raise OutteError.new 'Emoji not found' if emoji.nil?\n msg.react(emoji)\nend",
"def post_message(message)\n # https://api.slack.com/methods/chat.postMessage\n # scopes: chat:write\n slack_client.chat_postMessage(\n channel: channel_id,\n thread_ts: slack_ts,\n text: message\n )\n end",
"def send(message, options={})\n content_window.send(message, options)\n end",
"def speak(msg, channel=@channel)\n if @s and not @stfu\n @s.puts \"PRIVMSG #{channel} :\"+2.chr+\"#{msg}\" # 2.chr = bold char in irc\n end\n end",
"def send_message(subject:, text:, from: nil)\n super(to: read_attribute(:name), subject: subject, text: text, from: from)\n end",
"def send_message_to(_user, _message, extra_data = {})\n return if _user.id == id # skip send message to self\n Conversation.get_single_conversation(id, _user.id).send_message(id, _message, extra_data)\n end",
"def publish( channel, message )\n # Check we are not publishing to a wildcard channel\n STDERR.puts 'Can\\'t publish to a wildcard channel!' if is_channel_wildcard?(channel)\n @client.publish(channel, message)\n end",
"def send_msg(conn,args)\n p = @app.get_client(conn) #pega objeto Player da lista de clientes\n unless p.nil?\n @app.broadcast(Message.new('chat','txt',\n {'author' => CGI::escapeHTML(p.to_s), 'msg' => CGI::escapeHTML(args['msg'])}\n )) #envia a mensagem para todos os clientes\n end\n end",
"def write text=\"\"\n\t\t@message.text = @msg = text.to_s\n\tend",
"def broadcast_message(text)\n @users.each {|u| u.enqueue_message(text) }\n end",
"def update\n\t\t# channel_sid = params[:channel_sid]\n\t\t# message_sid = params[:id]\n\t\t# @client = Twilio::REST::Client.new(ENV['account_sid'], ENV['auth_token'])\n\n\t\t# # Update the message\n\t\t# service = @client.chat.v2.services(ENV['service_sid'])\n\t\t# channel = service.channels(channel_sid).fetch\n\t\t# message = channel.messages(message_sid).fetch\n\t\t# message_updated = message.update(body: params[:body])\n\t\t# puts \"#{message_updated.sid} #{message_updated.body}\"\n\t\t# new_message = \"Message was changed\"\n\t\t# json_response(new_message)\n\tend",
"def raw_send(message)\n TalkerBase.instance.output << \"#{id} send #{message}\"\n end",
"def send_message(_user_id, message, extra_data = {})\n messages.create!({sender_id: _user_id, body: message}.merge(extra_data))\n end",
"def send_message(message)\n @networking.send_message(message)\n end",
"def send_message(user_id, message_content)\n\t\tfull_route = self.endpoint_route.gsub(USER_ID_KEY, user_id)\n\n\t\tdata = message_content.clone\n\t\tdata[\"token\"] = self.webhook_token\n\t\tquery = self.get_query(data)\n\n\t\turl = \"#{ full_route }?#{ query }\"\n\n\t\tresponse = HTTParty.get(url, body: data.to_json, headers: JSON_HEADERS)\n\t\tif response.code < 200 || response.code >= 300\n\t\t\traise \"Error\\nWebook HTTP Status: #{ response['code'] }. #{ response['message'] }\"\n\t\tend\n\tend",
"def deliver(message) \n @channel.send(:add_message, message)\n end",
"def publish_to(channel, data)\n publish_message(message(channel, data))\n end",
"def write (text)\n @client.puts(text)\n end"
] | [
"0.76900965",
"0.7490646",
"0.7319742",
"0.70011264",
"0.69512475",
"0.69056547",
"0.69046086",
"0.6835208",
"0.68224615",
"0.67920786",
"0.67674214",
"0.66974646",
"0.65345925",
"0.6489949",
"0.6481413",
"0.6451904",
"0.64484125",
"0.64401484",
"0.64359456",
"0.6412115",
"0.6392081",
"0.6357351",
"0.6332675",
"0.63295585",
"0.6219385",
"0.6219385",
"0.618576",
"0.6183502",
"0.6177226",
"0.6164299",
"0.6163105",
"0.61616784",
"0.6135281",
"0.6126972",
"0.6121149",
"0.6114274",
"0.6100758",
"0.6087941",
"0.6084816",
"0.6078774",
"0.6076395",
"0.6069456",
"0.60532767",
"0.6026744",
"0.60029936",
"0.5985759",
"0.595059",
"0.5944466",
"0.59430295",
"0.59378374",
"0.5937174",
"0.59175795",
"0.5910158",
"0.5909944",
"0.5903941",
"0.5893261",
"0.5885717",
"0.58787054",
"0.5849886",
"0.5847111",
"0.58379906",
"0.5837156",
"0.5825136",
"0.58222276",
"0.5812116",
"0.5812116",
"0.5805963",
"0.5795714",
"0.5774103",
"0.577142",
"0.5764205",
"0.5758235",
"0.5751363",
"0.5751363",
"0.57494104",
"0.57461846",
"0.57425094",
"0.5736264",
"0.57319224",
"0.5729986",
"0.57296306",
"0.5725258",
"0.5715882",
"0.5714189",
"0.57123977",
"0.57122165",
"0.5707674",
"0.5701364",
"0.56926775",
"0.5679411",
"0.56709635",
"0.56662023",
"0.5658108",
"0.5656978",
"0.5655942",
"0.565564",
"0.56526273",
"0.5642617",
"0.564224",
"0.5633896"
] | 0.6538457 | 12 |
Sends a text message to a channel given its ID and the message's content, then deletes it after the specified timeout in seconds. | def send_temporary_message(channel, content, timeout, tts = false, embed = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil)
Thread.new do
Thread.current[:discordrb_name] = "#{@current_thread}-temp-msg"
message = send_message(channel, content, tts, embed, attachments, allowed_mentions, message_reference, components)
sleep(timeout)
message.delete
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_temporary_message(channel_id, content, timeout, tts = false, server_id = nil)\n Thread.new do\n message = send_message(channel_id, content, tts, server_id)\n\n sleep(timeout)\n\n message.delete\n end\n\n nil\n end",
"def send_message(channel, content, opts = {})\n raise \"Unknown unit id, try providing :ret => 'id' when fetching units from the API.\" unless id && id > 0\n _cloud_connect.send_message(id, channel, content, opts)\n end",
"def send_temporary_message(content, timeout, tts = false, embed = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil)\n @bot.send_temporary_message(@id, content, timeout, tts, embed, attachments, allowed_mentions, message_reference, components)\n end",
"def edit_osd_message(id, text, timeout: nil)\n @osd_messages[id] = Ass::Text.new(text)\n delete_osd_message(id, delay: timeout) if timeout.to_f.positive?\n render_osd_messages\n end",
"def send_text(text)\n client.api.send_message(id, text)\n end",
"def send_message(channel_id, content, tts = false, server_id = nil)\n channel_id = channel_id.resolve_id\n debug(\"Sending message to #{channel_id} with content '#{content}'\")\n\n response = API.send_message(token, channel_id, content, [], tts, server_id)\n Message.new(JSON.parse(response), self)\n end",
"def chat_deleteScheduledMessage(options = {})\n raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?\n raise ArgumentError, 'Required arguments :scheduled_message_id missing' if options[:scheduled_message_id].nil?\n options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]\n post('chat.deleteScheduledMessage', options)\n end",
"def send_message(channel_id, params)\n cleaned = params.permit(:author_id,\n :sender_name,\n :subject,\n :body,\n :text,\n :attachments,\n { options: [:tags, :archive] },\n :to,\n :cc,\n :bcc)\n create(\"channels/#{channel_id}/messages\", cleaned)\n end",
"def delete(channel_id)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'channelId', channel_id)\n\t\t\tclient.queue_service_action_call('channel', 'delete', 'bool', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend",
"def delete_message(display_id, message_id)\n delete \"commandcenter/displays/#{display_id}/messages/#{message_id}\"\n end",
"def delete(reason = nil)\n API::Channel.delete(@bot.token, @id, reason)\n end",
"def send_message(channel, content, tts = false, embed = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil)\n channel = channel.resolve_id\n debug(\"Sending message to #{channel} with content '#{content}'\")\n allowed_mentions = { parse: [] } if allowed_mentions == false\n message_reference = { message_id: message_reference.id } if message_reference.respond_to?(:id)\n\n response = API::Channel.create_message(token, channel, content, tts, embed&.to_hash, nil, attachments, allowed_mentions&.to_hash, message_reference, components)\n Message.new(JSON.parse(response), self)\n end",
"def delete(id)\n\t\t\tkparams = {}\n\t\t\t# Live channel id to delete\n\t\t\tclient.add_param(kparams, 'id', id);\n\t\t\tclient.queue_service_action_call('livechannel', 'delete', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def send_message(token, channel_id, message, mentions = [], tts = false, guild_id = nil)\n request(\n \"message-#{guild_id}\".to_sym,\n :post,\n \"#{api_base}/channels/#{channel_id}/messages\",\n { content: message, mentions: mentions, tts: tts }.to_json,\n Authorization: token,\n content_type: :json\n )\n rescue RestClient::InternalServerError\n raise Discordrb::Errors::MessageTooLong, \"Message over the character limit (#{message.length} > 2000)\"\n end",
"def send(message, timeout = 30)\n client do |sock|\n sock.write \"#{message}\\r\\n\"\n ready = IO.select([sock], nil, nil, timeout)\n raise ServiceError, \"timed out waiting for server response\" unless ready\n sock.recv(256)\n end\n rescue Errno::ECONNREFUSED, Errno::ENOENT\n raise ServiceError, \"#{name} process not running\" unless daemon_running?\n raise ServiceError, \"unable to establish connection\"\n end",
"def delete_message(id)\n record \"/msg/delete/#{id}\"\n end",
"def test_timeout\n @client.queue_name = \"test_timeout\"\n clear_queue\n\n res = @client.messages.post(\"hello world timeout!\")\n p res\n\n msg = @client.messages.get()\n p msg\n assert msg\n\n msg4 = @client.messages.get()\n p msg4\n assert msg4.nil?\n\n puts 'sleeping 45 seconds...'\n sleep 45\n\n msg3 = @client.messages.get()\n p msg3\n assert msg3.nil?\n\n puts 'sleeping another 45 seconds...'\n sleep 45\n\n msg2 = @client.messages.get()\n assert msg2\n assert msg.id == msg2.id\n\n msg2.delete\n\n # now try explicit timeout\n res = @client.messages.post(\"hello world timeout2!\", :timeout=>10)\n p res\n msg = @client.messages.get()\n p msg\n assert msg\n msg4 = @client.messages.get()\n p msg4\n assert msg4.nil?\n puts 'sleeping 15 seconds...'\n sleep 15\n msg2 = @client.messages.get()\n assert msg2\n assert msg.id == msg2.id\n\n end",
"def test_timeout\n @client.queue_name = \"test_timeout_6\"\n clear_queue\n\n res = @client.messages.post(\"hello world timeout!\")\n p res\n\n msg = @client.messages.get()\n p msg\n assert msg\n\n msg4 = @client.messages.get()\n p msg4\n assert_nil msg4\n\n puts 'sleeping 45 seconds...'\n sleep 45\n\n msg3 = @client.messages.get()\n p msg3\n assert_nil msg3\n\n puts 'sleeping another 45 seconds...'\n sleep 45\n\n msg2 = @client.messages.get()\n assert msg2\n assert_equal msg2.id, msg.id\n\n msg2.delete\n\n # now try explicit timeout\n res = @client.messages.post(\"hello world timeout2!\", :timeout => 10)\n p res\n msg = @client.messages.get()\n p msg\n assert msg\n msg4 = @client.messages.get()\n p msg4\n assert_nil msg4\n puts 'sleeping 15 seconds...'\n sleep 15\n msg2 = @client.messages.get()\n assert msg2\n assert_equal msg2.id, msg.id\n\n end",
"def message_delete(id)\n request(:delete, \"messages/#{id.to_s}\")\n end",
"def delete_osd_message(id, delay: nil)\n if delay.nil?\n @osd_messages.delete(id)\n render_osd_messages\n else\n Concurrent::ScheduledTask.execute(delay) do\n @osd_messages.delete(id)\n render_osd_messages\n end\n end\n end",
"def send_message(message_text)\n @selected.send_message(message_text)\n end",
"def delete_conversation(id)\n @client.raw('delete', \"/content/conversations/#{id}\")\n end",
"def send_message(text)\n end",
"def send_message(text, channel)\n uri = URI('https://slack.com/api/chat.postMessage')\n params = {\n token: ENV['BOT_OAUTH_TOKEN'],\n text: text,\n channel: channel\n }\n uri.query = URI.encode_www_form(params)\n\n Net::HTTP.get_response(uri)\n end",
"def send_message_to_channel(client, channel_id, title, message)\n client.chat_postMessage(\n channel: channel_id, \n as_user: true,\n text: \"*\" + title + \"*\",\n attachments: [\n text: message,\n color: \"warning\"\n ]\n )\nend",
"def delete\n @client.post('/api/del_msg', id: get_attribute(:name))\n end",
"def delete_message(message)\n API::Channel.delete_message(@bot.token, @id, message.resolve_id)\n end",
"def message_destroy(id)\n post(\"/direct_messages/destroy/#{id}.json\")\n end",
"def message_destroy(id)\n post(\"/direct_messages/destroy/#{id}.json\")\n end",
"def expire_message(id)\n with_queue_control do |control|\n control.expire_message(id)\n end\n end",
"def delete_msg()\n MsgUtil.delete_msg(params[:ch])\n end",
"def disconnect(reason = nil, timeout = 5)\n # Quit and wait for replies from server\n @bot.quit(reason)\n sleep(timeout)\n end",
"def delete(message_text)\n self.span(:class=>\"discussion_post_message\", :text=>message_text).parent.parent.button(:text=>\"Delete\").click\n end",
"def send_reply(text)\n @bot.api.send_message(chat_id: @last_message.chat.id, text: text)\n end",
"def create_osd_message(text, timeout: nil)\n overlay = Ass::Text.new(text)\n\n id = next_id\n @osd_messages[id] = overlay\n\n delete_osd_message(id, delay: timeout) if timeout.to_f.positive?\n render_osd_messages\n\n id\n end",
"def remove_message(id)\n with_queue_control do |control|\n control.remove_message(id)\n end\n end",
"def send_channel(message)\n @handler.send_channel message\n end",
"def send_channel(message)\n @bot.message_queue.push(\"PRIVMSG ##{bot.channel.name} :#{message}\")\n end",
"def delete_message(data); end",
"def delete_message(data); end",
"def send_reply(conversation_id, params)\n cleaned = params.permit(:author_id,\n :sender_name,\n :subject,\n :body,\n :text,\n :attachments,\n { options: [:tags, :archive] },\n :channel_id,\n :to,\n :cc,\n :bcc)\n create_without_response(\"conversations/#{conversation_id}/messages\", cleaned)\n end",
"def send_text(text)\n response = AGIResponse.new\n command_str = \"SEND TEXT '#{text}'\"\n begin\n response.native = execute(command_str)\n rescue AGITimeoutError, AGICommandError, AGIHangupError\n raise\n end\n if response.native == -1 then\n raise AGIChannelError.new(@last_response, \"Channel Failure in (#{command_str})\")\n elsif response.native == 0\n response.success = true\n end\n return response\n end",
"def delete(id)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'id', id);\n\t\t\tclient.queue_service_action_call('caption_captionparams', 'delete', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def delete_scheduled_message_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TextMagicApi.delete_scheduled_message ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling TextMagicApi.delete_scheduled_message\"\n end\n # resource path\n local_var_path = '/api/v2/schedules/{id}'.sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TextMagicApi#delete_scheduled_message\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def delete_message(token, id, user = nil)\n request_url = user_context(user) << \"/Messages/\" << id\n\n delete_response = make_api_call \"DELETE\", request_url, token\n\n return nil if delete_response.nil? || delete_response.empty?\n\n parse_response(delete_response)\n end",
"def ctcp_reply(text)\n recipient = data[:channel] || data[:nick]\n @irc.notice(recipient, \"\\001#{@data[:ctcp_action]} #{text}\\001\")\n end",
"def post_message(params = {}, opts = {})\n retries = 1\n begin\n log.info { \"out_slack: post_message #{params.dup.tap {|p| p[:token] = '[FILTERED]' if p[:token] }}\" }\n post(post_message_endpoint, params)\n rescue ChannelNotFoundError => e\n if opts[:auto_channels_create]\n log.warn \"out_slack: channel \\\"#{params[:channel]}\\\" is not found. try to create the channel, and then retry to post the message.\"\n channels_create({name: params[:channel], token: params[:token]})\n retry if (retries -= 1) >= 0 # one time retry\n else\n raise e\n end\n end\n end",
"def destroy\n\t\tchannel_sid = params[:channel_sid]\n\t\tmessage_sid = params[:id]\n\t\tputs message_sid\n\t\t@client = Twilio::REST::Client.new(ENV['account_sid'], ENV['auth_token'])\n\t\t# Remove the member\n\t\tservice = @client.chat.v2.services(ENV['service_sid'])\n\t\tchannel = service.channels(channel_sid)\n\t\tresponse = channel.messages(message_sid).delete\n\t\tputs response\n\t\tmessages_response= \"{\\n\\\"message\\\": \\\"Message was deleted\\\"\\n}\"\n\t\tjson_response(messages_response)\n\tend",
"def delete_conversation(id)\n delete(\"conversations/#{id}\")\n end",
"def send_file(token, channel_id, file, caption: nil, tts: false)\n request(\n __method__,\n :post,\n \"#{api_base}/channels/#{channel_id}/messages\",\n { file: file, content: caption, tts: tts },\n Authorization: token\n )\n end",
"def delete_channel!(channel)\n sns.delete_topic(topic_arn: channel.arn)\n end",
"def destroy\n @text_message = TextMessage.find(params[:id])\n @text_message.destroy\n\n respond_to do |format|\n format.html { redirect_to text_messages_url }\n format.json { head :no_content }\n end\n end",
"def send_message(content, tts = false, embed = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil)\n @bot.send_message(@id, content, tts, embed, attachments, allowed_mentions, message_reference, components)\n end",
"def send_message(bot, server, channel, user, message)\n lang = @config[:lang]\n name = Digest::SHA256.hexdigest (message.to_s + lang)\n message.gsub!(/^\\s+/, \"\")\n if !Dir.exists?(@config[:cache_directory])\n system(\"mkdir -p \\\"#{@config[:cache_directory]}\\\"\")\n end\n\n file = File.join(@config[:cache_directory], \"#{name}\")\n\n # popen3\n if !File.exists?(\"#{file}.mp3\")\n File.write \"#{file}.txt\", message\n\n Open3.popen3(\"perl\", \"simple-google-tts/speak.pl\", lang, \"#{file}.txt\", \"#{file}.mp3\") do |stdin, stdout, stderr, thread|\n error = stderr.read\n message = stdout.read\n if thread.value != 0\n # TODO: Billbot tries to log own DMs and enters a loop\n # user.pm \"Error writing a message for you. Please report this to an admin.\"\n # user.pm \"STDOUT\\n```#{message}```\"\n # user.pm \"STDERR\\n```#{error}```\"\n puts \"Error writing message\"\n puts \"STDOUT\\n#{message}\\n\\nSTDERR\\n#{error}\\n\\n\"\n\n system(\"rm -f \\\"#{file}.txt\\\"\")\n return\n end\n end\n\n system(\"rm \\\"#{file}.txt\\\"\")\n end\n\n if !@voice_queue.has_key?(server)\n @voice_queue[server] = []\n end\n\n if @voice_queue[server].select { |v| v.owner == user }.size >= @QUEUE_SIZE\n puts \"Limit reached for \\\"#{user.username}\\\" on \\\"#{channel}\\\"\"\n return\n end\n\n message = VoiceMessage.new(user, channel, \"#{file}.mp3\")\n message.volume = 1.0\n @voice_queue[server] << message\n end",
"def send_text(id, text, options={:wait_for_keyboard => true})\n\n\t\tif ENV['PLATFORM'] =='android'\n\t\t\tquery(\"* marked:'#{id}'\", :setText => \"#{text}\")\n\t\telse\n\t\t\tif ENV['PLATFORM'] == 'ios'\n\t\t\t\ttouch(id)\n\t\t\t\twait_for_keyboard unless options[:wait_for_keyboard] == false\n\t\t\t\tkeyboard_enter_text(text)\n\n\t\t\tend\n\n\t\tend\n\tend",
"def send_irc(channel, message)\n real_channel = @zbot.get_channel(channel)\n if real_channel\n real_channel.send(message)\n else\n puts \"############## CHANNEL #{channel} NOT FOUND !\"\n end\n end",
"def send(message)\n @chats.each do |chat|\n begin\n chat.send(message)\n rescue\n @chats.delete(chat)\n end\n end\n end",
"def chat_scheduleMessage(options = {})\n raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?\n raise ArgumentError, 'Required arguments :post_at missing' if options[:post_at].nil?\n raise ArgumentError, 'Required arguments :text missing' if options[:text].nil?\n options = encode_options_as_json(options, %i[attachments blocks metadata])\n post('chat.scheduleMessage', options)\n end",
"def destroy\r\n push_notification :remove\r\n @message.destroy\r\n respond_to do |format|\r\n format.html { redirect_to channel_messages_url(@channel) }\r\n format.json { head :no_content }\r\n end\r\n end",
"def delete_message(message_id)\n RestClient.delete(\"#{@url}/messages/#{message_id}\")\n end",
"def send(message, options = { channelID: 1 })\n params = { message: message, channelID: options[:channelID] }\n rest.post chat_path, params: params\n end",
"def run(text,\n channel: DEFAULT_CHANNEL,\n username: DEFAULT_USERNAME,\n icon_url: DEFAULT_ICON_URL,\n icon_emoji: DEFAULT_ICON_EMOJI)\n\n payload = build_payload(text, channel, username, icon_url, icon_emoji)\n\n send_payload(payload)\n end",
"def send(s, timeout: 30)\n\n t = Time.now + timeout\n \n super(s)\n\n sleep 0.1 until @received.any? or Time.now > t\n raise UniversalDomRemoteException, 'recv::timeout' if Time.now > t\n\n r = @received.last\n @received = []\n\n return r\n end",
"def delete_channel_with_http_info(channel_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ChatChannelsApi.delete_channel ...'\n end\n # verify the required parameter 'channel_id' is set\n if @api_client.config.client_side_validation && channel_id.nil?\n fail ArgumentError, \"Missing the required parameter 'channel_id' when calling ChatChannelsApi.delete_channel\"\n end\n # resource path\n local_var_path = '/chat/channels/{channelId}'.sub('{' + 'channelId' + '}', channel_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'multipart/form-data'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['OAuth']\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Object')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ChatChannelsApi#delete_channel\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def send( text )\n checkConnection()\n @conn.write( text + EOL )\n end",
"def send( text )\n checkConnection()\n @conn.write( text + EOL )\n end",
"def delete_scheduled_message(id, opts = {})\n delete_scheduled_message_with_http_info(id, opts)\n nil\n end",
"def bulk_delete(token, channel_id, messages = [])\n request(\n __method__,\n :post,\n \"#{api_base}/channels/#{channel_id}/messages/bulk_delete\",\n { messages: messages }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def delete_round(server)\n # Creates a hash channel_id => Array of message IDs in that channel.\n del = @messages[server.id].group_by { |h| h[:channel] }.each_value { |e| e.map! { |h| h[:id] } }\n @messages[server.id] = []\n sleep 2\n del.each_pair do |channel, msgs|\n if msgs.size == 1\n SHRK.channel(channel)&.delete_message(msgs.first)\n else\n SHRK.channel(channel)&.delete_messages(msgs)\n end\n end\n end",
"def destroy\n # delete a specific message\n end",
"def requeue(message_id, timeout=0)\n message_id = message_id.message_id if message_id.respond_to?(:message_id)\n distribution.in_flight_lookup(message_id) do |connection|\n distribution.unregister_message(message_id)\n connection.transmit(\n Command::Req.new(\n :message_id => message_id,\n :timeout => timeout\n )\n )\n distribution.failure(connection.identifier)\n update_ready!(connection)\n end\n true\n end",
"def requeue(message_id, timeout=0)\n message_id = message_id.message_id if message_id.respond_to?(:message_id)\n distribution.in_flight_lookup(message_id) do |connection|\n distribution.unregister_message(message_id)\n connection.transmit(\n Command::Req.new(\n :message_id => message_id,\n :timeout => timeout\n )\n )\n distribution.failure(connection.identifier)\n update_ready!(connection)\n end\n true\n end",
"def sends_close\n script.sends_channel_close(self)\n end",
"def send_message\n message = render_to_string(:partial => 'messages/message', :object => @message)\n Juggernaut.send_to_channel(javascript_chat_message(message), @message.channel_id)\n end",
"def create_timed_delete(timeout, port_entry)\n mtimer = EM.add_timer(timeout.to_i) do\n time_left = port_entry.lifetime_left\n if time_left > 0\n #puts \"object has #{time_left} seconds left, #{Time.now}\"\n create_timed_delete(time_left, port_entry)\n else\n #puts \"timed delete writer #{Time.now}\"\n @portentries.delete(@portentries.key(port_entry))\n end\n end\n port_entry.timer = mtimer\n end",
"def send_message(payload, acknowledge: true, at_time: nil)\n context.send_message(target: Target.new(device_id: id), payload: payload, acknowledge: acknowledge, at_time: at_time)\n end",
"def subscribe_with_timeout(timeout, *channels, &block); end",
"def send(message, callback = nil)\n message.message_id = Random.srand\n\n if callback\n message.reply_to = @reply_topic\n @waiting_reply[message.message_id] = callback\n end\n\n publish_message(message)\n rescue Mosquitto::Error\n @outbox << message\n end",
"def deleteEntityFeatured_message( entity_id)\n params = Hash.new\n params['entity_id'] = entity_id\n return doCurl(\"delete\",\"/entity/featured_message\",params)\n end",
"def delete\n @service.delete_message(self)\n end",
"def delete_message(queue_name, message_id, pop_receipt, options = {})\n query = { \"popreceipt\" => pop_receipt }\n query[\"timeout\"] = options[:timeout].to_s if options[:timeout]\n\n uri = message_uri(queue_name, message_id, query)\n\n call(:delete, uri, nil, {}, options)\n nil\n end",
"def psubscribe_with_timeout(timeout, *channels, &block); end",
"def destroy\n get_message().delete\n end",
"def send(to, text)\n begin\n @log.info \"Sending message to '#{to}'\"\n @client.send Message::new(to, text).set_type(:chat).set_id('1').set_subject('Boti')\n return true\n rescue\n @log.error \"Error sending message to '#{to}'\"\n return false\n end\n end",
"def destroy\n @chatty_crow_channel.destroy\n flash[:notice] = l(:notice_successful_delete)\n redirect_to_plugin_settings\n end",
"def send_message(payload)\n message = Message.new(user: current_user, chat_id: payload[\"id\"], body: payload[\"message\"])\n\n ActionCable.server.broadcast \"chat_#{payload['id']}\", message: render(message) if message.save\n end",
"def sendMessage(args, client = @send_client)\n jabmsg = Jabber::Message::new(args[:receiver], args[:message]).set_type(:chat).set_id('1')\n \n begin \n Timeout::timeout(10) do\n client.send(jabmsg)\n puts \"XMPP TO: \" + args[:receiver].to_s\n puts \"XMPP MESSAGE: \" + args[:message].to_s\n end\n\n rescue => e\n puts \"XMPP Exception in sending: \" + e + \"\\n\"\n puts \"XMPP Reconnecting to server and trying again\"\n puts \" (-- line #{e.backtrace[0].to_s} )\"\n if client == @receive_client\n puts \"re-connecting to RECEIVE_client\"\n connect(@receive_client)\n else\n puts \"re-connecting to SEND_client\"\n connect(@@send_client_info)\n end\n retry\n end\n end",
"def message(text)\n @text_queue.push text\n end",
"def delete_outbound_message_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TextMagicApi.delete_outbound_message ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling TextMagicApi.delete_outbound_message\"\n end\n # resource path\n local_var_path = '/api/v2/messages/{id}'.sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TextMagicApi#delete_outbound_message\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def receive_char(timeout=0)\n response = AGIResponse.new\n command_str = \"RECEIVE CHAR #{(timeout.to_i * 1000)}\"\n begin\n response.native = execute(command_str)\n rescue AGITimeoutError, AGICommandError, AGIHangupError\n raise\n end\n if response.native == -1 then\n raise AGIChannelError.new(@last_response, \"Channel Failure in (#{command_str})\")\n elsif response.native == 0\n raise AGICommandError.new(@last_response, \"Channel doesn't support TEXT in (#{command_str})\")\n else\n response.success = true\n response.data = response.native.chr\n end\n return response\n end",
"def delete_message_template(id)\n @client.raw('delete', \"/content/message-templates/#{id}\")\n end",
"def delete\n @channel_control.delete\n end",
"def listen_for_answer(id, timeout)\n \n if ENV['TIMEOUT_MULTIPLIER']\n timeout = ENV['TIMEOUT_MULTIPLIER'].to_i * timeout\n end\n\n answer = non_blocking_pop(timeout)\n if !answer\n raise Talkshow::Timeout.new\n end\n \n mismatch_retry = 3\n if answer[:id].to_i != id.to_i && mismatch_retry >= 0\n puts \"Talkshow warning: message mismatch (#{answer[:id]} vs #{id})\" unless answer[:id].to_i == 0\n answer = non_blocking_pop(timeout)\n mismatch_retry -= 1\n end\n\n if !answer\n raise Talkshow::Timeout.new\n end\n \n chunks = answer[:chunks]\n if chunks\n answers = [answer]\n\n i = 1\n nil_count = 0\n while ( i < chunks.to_i && nil_count < 3 ) do\n candidate = non_blocking_pop(1)\n if !candidate\n nil_count += 1\n next\n end\n if candidate[:id].to_i != id.to_i\n puts \"Talkshow warning: message mismatch (#{candidate[:id]} vs #{id.to_i})\"\n next\n end\n \n nil_count = 0\n i += 1\n answers << candidate\n end\n \n if answers.count < chunks.to_i\n raise \"Couldn't reconstitute whole message\"\n end\n \n sorted_answers = answers.sort_by{ |a| a[:payload].to_i }\n data = sorted_answers.collect { |a| a[:data] }.join\n answer[:data] = data\n answer[:payload] = nil\n end\n \n answer\n end",
"def send_message(mes,token,user_id)\n #Open a direct message\n options = {\n token: token,\n user: user_id\n }\n channel_id = post('https://slack.com/api/im.open', options).channel.id\n\n #Send the message\n options = {\n token: token,\n channel: channel_id,\n text: mes\n }\n post('https://slack.com/api/chat.postMessage', options)\nend",
"def send_message(payload)\n message = Message.new(author: current_user, text: payload[\"message\"])\n\n ActionCable.server.broadcast \"chat\", message: render(message) if message.save\n end",
"def destroy\n # delete a specific message\n end",
"def delete_communication_channel_id(user_id,id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"user_id is required\" if user_id.nil?\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :user_id => user_id,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/users/{user_id}/communication_channels/{id}\",\n :user_id => user_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n CommunicationChannel.new(response)\n end",
"def message(message, seconds = MAX_TIMEOUT)\n received = false\n Timeout.timeout(seconds) do\n while !received do\n output = TomQueue.test_logger.readline\n received = !!(output =~ /#{Regexp.escape(message)}/)\n end\n end\n true\nrescue Timeout::Error\n false\nend",
"def send_command(msg, request_id = nil, &cb)\n if @timeout && @timeout > 0 \n @requests[request_id] = [msg, cb] if cb\n set_timeout\n else\n error = Monga::Exceptions::Disconnected.new \"Can't find appropriate server (all disconnected)\"\n cb.call(error) if cb\n end\n end",
"def send_text_message(subscriber, message)\n handle_manychat_response(send_content(subscriber, [create_message_text_hash(message)]))\n end"
] | [
"0.7993938",
"0.6187552",
"0.60455555",
"0.60313004",
"0.5957131",
"0.589204",
"0.5685615",
"0.56358874",
"0.56257606",
"0.56028855",
"0.5564914",
"0.55448204",
"0.5540462",
"0.552262",
"0.5519717",
"0.5516406",
"0.5515432",
"0.5468322",
"0.54659766",
"0.541653",
"0.5413082",
"0.5409885",
"0.5394852",
"0.5387878",
"0.53761464",
"0.5373275",
"0.53699607",
"0.5336801",
"0.5336801",
"0.53211087",
"0.53037584",
"0.52663267",
"0.5265194",
"0.5263305",
"0.5263004",
"0.5246678",
"0.5243672",
"0.5232792",
"0.51951474",
"0.51951474",
"0.51949674",
"0.51944023",
"0.51702917",
"0.51669097",
"0.5139314",
"0.51322544",
"0.51172197",
"0.50940657",
"0.5079575",
"0.50728667",
"0.50665325",
"0.5056784",
"0.50561434",
"0.5055195",
"0.50550187",
"0.50469667",
"0.5030408",
"0.5011084",
"0.49997628",
"0.49944907",
"0.49934644",
"0.49918193",
"0.49863675",
"0.49834937",
"0.49803695",
"0.49803695",
"0.49510252",
"0.49478394",
"0.49059427",
"0.4904686",
"0.48985344",
"0.48985344",
"0.48949116",
"0.48938987",
"0.48896372",
"0.48895168",
"0.48886093",
"0.4885063",
"0.48841366",
"0.48832464",
"0.48562413",
"0.4855376",
"0.48504224",
"0.48447874",
"0.4841913",
"0.48412874",
"0.48328868",
"0.48228657",
"0.48221427",
"0.48116308",
"0.48083133",
"0.48042613",
"0.47892213",
"0.4785871",
"0.47800273",
"0.47647393",
"0.4761449",
"0.47606018",
"0.47578174",
"0.47536835"
] | 0.71656483 | 1 |
Sends a file to a channel. If it is an image, it will automatically be embedded. | def send_file(channel, file, caption: nil, tts: false, filename: nil, spoiler: nil)
if file.respond_to?(:read)
if spoiler
filename ||= File.basename(file.path)
filename = "SPOILER_#{filename}" unless filename.start_with? 'SPOILER_'
end
# https://github.com/rest-client/rest-client/blob/v2.0.2/lib/restclient/payload.rb#L160
file.define_singleton_method(:original_filename) { filename } if filename
file.define_singleton_method(:path) { filename } if filename
end
channel = channel.resolve_id
response = API::Channel.upload_file(token, channel, file, caption: caption, tts: tts)
Message.new(JSON.parse(response), self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_file(path); end",
"def send_file(token, channel_id, file, caption: nil, tts: false)\n request(\n __method__,\n :post,\n \"#{api_base}/channels/#{channel_id}/messages\",\n { file: file, content: caption, tts: tts },\n Authorization: token\n )\n end",
"def send_file(channel_id, file, caption: nil, tts: false)\n response = API.send_file(token, channel_id, file, caption: caption, tts: tts)\n Message.new(JSON.parse(response), self)\n end",
"def send_file(path, options = T.unsafe(nil)); end",
"def send_file(file, caption = nil, filename: nil, spoiler: nil)\n pm.send_file(file, caption: caption, filename: filename, spoiler: spoiler)\n end",
"def send_file(path)\n\n @buffer = File.read(path)\n send\n end",
"def send_file(file, caption: nil, tts: false, filename: nil, spoiler: nil)\n @bot.send_file(@id, file, caption: caption, tts: tts, filename: filename, spoiler: spoiler)\n end",
"def send_file(url, name, file_info = {})\n client.api.send_content(id, url, name, 'm.file', extra_information: file_info)\n end",
"def ssh_send_file_ruby(host, username, command, filename)\n filename = File.expand_path(filename)\n ssh_ruby(host, username, command) do |channel|\n File.open(filename, 'rb') do |file|\n file.chunk(1024) do |chunk|\n channel.send_data chunk\n end\n end\n end\n end",
"def send_file(message, file)\n response = self.class.post(@api.send_file_config[:url],\n :query => { :auth_token => @token },\n :body => file_body({ :message => message }.send(@api.send_config[:body_format]), file),\n :headers => file_body_headers(@api.headers)\n )\n\n ErrorHandler.response_code_to_exception_for :user, user_id, response\n true\n end",
"def upload_file_to_slack(channels: ,file: ,options: {})\n upload_file = nil\n ActiveSupport::Notifications.instrument('upload_file_to_slack.action_messenger', channels: channels) do\n upload_file = slack_client.upload_file(channels, file, options)\n end\n upload_file\n ensure\n self.deliveries << DeliveryLog.new(__method__, channels, upload_file)\n end",
"def send_file(path, response)\n input = java.io.FileInputStream.new(path.to_s)\n channel = input.getChannel\n begin\n transfer_channel channel, response.getOutputStream\n ensure\n channel.close\n input.close rescue nil\n end\n end",
"def send_file(file_path, receiver_uuid, file_uuid)\n Pantry.logger.debug(\"[FileService] Sending file #{file_path} to #{receiver_uuid}\")\n @sender.send_file(file_path, receiver_uuid, file_uuid)\n end",
"def send_file_with_mime_type file_path\n # more MIME types: http://de.selfhtml.org/diverses/mimetypen.htm\n kind_of_plain_text = %w{ txt php js css rb yml log }\n kind_of_html = %w{ htm html shtml }\n\n case split_to_filename_and_extension(file_path).last.downcase\n when /jp(e*)g/ then type = 'image/jpeg'\n when 'gif' then type = 'image/gif'\n when 'png' then type = 'image/png'\n when 'bmp' then type = 'image/bmp'\n when 'xml' then type = 'text/xml'\n when 'pdf' then type = 'application/pdf'\n when *kind_of_plain_text then type = 'text/plain'\n when *kind_of_html then type = 'text/html'\n else type = 'application/octet-stream'\n end\n\n if Settings.x_accel_redirect\n send_file_via_nginx_x_accel_redirect file_path, type\n else\n send_file File.expand_path(file_path), :disposition => 'inline', :type => type, :x_sendfile => Settings.x_sendfile\n end\n end",
"def send_file(path, options = {}) #:doc:\n raise MissingFile, \"Cannot read file #{path}\" unless File.file?(path) and File.readable?(path)\n\n options[:length] ||= File.size(path)\n options[:filename] ||= File.basename(path)\n options[:type] ||= Rack::File::MIME_TYPES[File.extname(options[:filename])[1..-1]] || 'text/plain'\n options[:last_modified] ||= File.mtime(path).httpdate\n options[:stream] = true unless options.key?(:stream)\n options[:buffer_size] ||= DEFAULT_SEND_FILE_OPTIONS[:buffer_size]\n send_file_headers! options\n\n if options[:stream]\n throw :halt, [options[:status] || 200, FileStreamer.new(path, options)]\n else\n File.open(path, 'rb') { |file| throw :halt, [options[:status] || 200, [file.read]] }\n end\n end",
"def send_bytes(file)\n until file.eof?\n buffer = file.read(1024)\n @socket.write(buffer)\n end\n end",
"def send_file(file, opts={})\n opts.update(Merb::Const::DEFAULT_SEND_FILE_OPTIONS.merge(opts))\n disposition = opts[:disposition].dup || 'attachment'\n disposition << %(; filename=\"#{opts[:filename] ? opts[:filename] : File.basename(file)}\")\n headers.update(\n 'Content-Type' => opts[:type].strip, # fixes a problem with extra '\\r' with some browsers\n 'Content-Disposition' => disposition,\n 'Content-Transfer-Encoding' => 'binary',\n 'X-SENDFILE' => file\n )\n return\n end",
"def send_file(path, options = {}) #:doc:\n raise MissingFile, \"Cannot read file #{path}\" unless File.file?(path) and File.readable?(path)\n\n options[:length] ||= File.size(path)\n options[:filename] ||= File.basename(path) unless options[:url_based_filename]\n send_file_headers! options\n\n @performed_render = false\n\n if options[:x_sendfile]\n logger.info \"Sending #{X_SENDFILE_HEADER} header #{path}\" if logger\n head options[:status], X_SENDFILE_HEADER => path\n else\n if options[:stream]\n render :status => options[:status], :text => Proc.new { |response, output|\n logger.info \"Streaming file #{path}\" unless logger.nil?\n len = options[:buffer_size] || 4096\n File.open(path, 'rb') do |file|\n while buf = file.read(len)\n output.write(buf)\n end\n end\n }\n else\n logger.info \"Sending file #{path}\" unless logger.nil?\n File.open(path, 'rb') { |file| render :status => options[:status], :text => file.read }\n end\n end\n end",
"def upload_file(channels, file, options)\n options = {channels: channels, file: file}.merge(upload_file_option_to_api_hash(options))\n client.files_upload(options)\n end",
"def transfer file\n stop_timeout\n\n @number += 1\n\n @type = :sending\n @file = file\n\n\t @file.seek 0, IO::SEEK_END\n @filesize = file.tell\n\t @file.seek 0, IO::SEEK_SET\n @total_frames = (@filesize.to_f / @options[:frame_size].to_f).ceil\n\n puts \"Sending file (#{@filesize} bytes)\"\n\n # Set up how much do we currently have (outside of the window)\n @delivered = 0\n\n # window number\n @window = 0\n @current_frame = 0\n @next_frame = 0\n @sum_buffer_len = 0\n @max_buffer_len = 0\n @buffer_len = 0\n\n @buffer = Array.new(@options[:window_size] * 2) { nil }\n @sent = Array.new(@options[:window_size] * 2) { 0 }\n\n start_timeout\n\n send_window\n end",
"def send_channel(message)\n @handler.send_channel message\n end",
"def send_file_data filename\n\t\tEventMachine::send_file_data @signature, filename\n\tend",
"def send_file(file, remotefile = File.basename(file))\n begin\n @ftp.putbinaryfile(file, remotefile)\n return true\n rescue Exception => e\n error_message(e)\n return false\n end\n end",
"def render_file file, content_type=nil\n socket.print \"HTTP/1.1 200 OK\\r\\n\" +\n \"Content-Type: #{content_type || content_type(file)}\\r\\n\" +\n \"Content-Length: #{file.size}\\r\\n\" +\n \"Connection: close\\r\\n\"\n\n socket.print \"\\r\\n\"\n\n # write the contents of the file to the socket\n IO.copy_stream(file, socket)\n end",
"def send_file_contents\n self.status = 200\n prepare_file_headers\n send_data(file.content)\n end",
"def download\n send_file @cfile.path.to_s\n end",
"def on_file(&block)\n on(:message) do |data|\n debug on_file: data, bot_message: bot_message?(data), is_im_channel: is_im_channel?(data.channel)\n if !bot_message?(data) && is_im_channel?(data.channel) && file_message?(data)\n @last_received_user_message.merge!(message: data.text)\n instance_exec(@last_received_user_message, &block)\n end\n end\n end",
"def send_file(client, current_path, input, client_port)\n\n\tif(File.exist?(\"#{current_path}/files/#{input}\"))\n\t\t\tclient.puts \"\\nFile already exists on server\"\n\telse\n\t\tclient.puts \"receiving\"\n\n\t\tclient_serv = TCPSocket.new(\"#{client.peeraddr[3]}\", client_port)\n\t\tclient_serv.puts \"#{input}\"\n\n\t\tfile_bool = client_serv.gets.chomp\n\t\tif(file_bool == \"false\")\n\n\t\telse\n\t\t\treceived_file = File.open(\"#{current_path}/files/#{input}\", \"wb\")\n\n\t\t\tfilecontent = client_serv.read \n\t\t\treceived_file.print filecontent\t \t\t\t\n\t\t\treceived_file.close\n\t\t\tclient_serv.close\n\n\t\t\tputs \"File #{input} Received\"\n\t\tend\n\tend\nend",
"def send(file_or_data, type = nil, send_as = nil)\n if file_or_data.class == File\n data = file_or_data.read\n\n # auto set type based on file type\n type = Rack::Mime.mime_type(\".\" + String.split_at_last_dot(file_or_data.path)[1])\n else\n data = file_or_data\n end\n\n headers = {}\n headers[\"Content-Type\"] = type if type\n headers[\"Content-disposition\"] = \"attachment; filename=#{send_as}\" if send_as\n\n self.context = AppContext.new(request, Response.new(data, response.status, response.header.merge(headers)))\n halt\n end",
"def create\n @channel = Channel.find_by_name(params[:channel_id])\n @attachment = Attachment.new(params[:attachment])\n\n # {\"file\"=>#<ActionDispatch::Http::UploadedFile:0x00000005bc3158 @original_filename=\"investor_faq.org\", @content_type=\"application/octet-stream\",\n # @headers=\"Content-Disposition: form-data; name=\\\"file\\\"; filename=\\\"investor_faq.org\\\"\\r\\nContent-Type: application/octet-stream\\r\\n\", @tempfile=#<File:/tmp/RackMultipart20111212-24212-4znzta>>\n # \"commit\"=>\"Upload\",\n # \"utf8\"=>\"✓\",\n # \"authenticity_token\"=>\"SrS7bnPQ76RQJLWOx58bm1uyDsQq5f4FObPLl9Zh+Ao=\",\n # \"remotipart_submitted\"=>\"true\",\n # \"X-Requested-With\"=>\"IFrame\",\n # \"X-Http-Accept\"=>\"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01\",\n # \"channel_id\"=>\"Shiro\"\n # }\n\n @attachment.user = current_user\n @attachment.channel = Channel.find_by_name(params[:channel_id])\n @attachment.file = params[:file]\n\n respond_to do |format|\n if @attachment.save\n format.html { }\n format.js\n format.json { render json: @attachment, status: :created }\n else\n format.html { render action: \"new\" }\n format.js\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_image(user, iter, max_iter, file)\n attachments['out.png'] = file\n mail(to: user.email, subject: \"Ваше изображение обработано\")\n end",
"def send_file(path, status=200, message='OK')\n header = [\n \"HTTP/1.1 #{status} #{message}\",\n \"Content-Type: #{content_type(path)}\",\n \"Content-Length: #{File.size(path)}\",\n \"Last-Modified: #{mtime(path)}\"\n ].join(\"\\r\\n\")\n @stream.stream_write(\"#{header}\\r\\n\\r\\n\")\n\n File.open(path) do |file|\n while (buf = file.read(BUF_SIZE)) != nil\n @stream.stream_write(buf)\n end\n end\n end",
"def test_send_file()\n # Parameters for the API call\n file = TestHelper.get_file('https://dl.dropboxusercontent.com/u/31838656/binary.png')\n\n # Perform the API call through the SDK function\n result = self.class.controller.send_file(file)\n\n # Test response code\n assert_equal(@response_catcher.response.status_code, 200)\n\n # Test whether the captured response is as we expected\n assert_not_nil(result)\n expected_body = JSON.parse('{\"passed\":true}')\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def send_file(path, opts={})\n opts[:disposition] = 'attachment' if !opts.key?(:disposition)\n attachment opts[:filename] || path if opts[:filename] || opts[:disposition]\n response['Content-Transfer-Encoding'] = 'binary' if opts[:disposition]\n super(path, opts)\n end",
"def send(file_or_data, type: nil, name: nil)\n if file_or_data.is_a?(IO) || file_or_data.is_a?(StringIO)\n data = file_or_data\n\n if file_or_data.is_a?(File)\n type ||= Rack::Mime.mime_type(File.extname(file_or_data.path))\n end\n\n @connection.set_response_header(Rack::CONTENT_TYPE, type || DEFAULT_SEND_TYPE)\n elsif file_or_data.is_a?(String)\n @connection.set_response_header(Rack::CONTENT_TYPE, type) if type\n data = StringIO.new(file_or_data)\n else\n raise ArgumentError, \"Expected an IO or String object\"\n end\n\n @connection.set_response_header(CONTENT_DISPOSITION, name ? \"attachment; filename=#{name}\" : \"inline\")\n halt(data)\n end",
"def show\n send_data(@attachment.file_contents,\n type: @attachment.content_type,\n filename: @attachment.filename)\n end",
"def send_file_method\n :default\n end",
"def send_file_full(req_path, request, response,mime_type=\"image/png\", header_only=false )\n\t return send_file_xsendfile(request, response,req_path, mime_type)\n\tend",
"def send_file(file_path, &block)\n if block.given?\n @j_del.sendFile(file_path, ARWrappedHandler.new(block))\n else\n @j_del.sendFile(file_path)\n end\n self\n end",
"def send_data( data )\n raise \"channel not open\" unless @state == :open\n @channel.send_data data\n end",
"def files_remote_share(options = {})\n raise ArgumentError, 'Required arguments :channels missing' if options[:channels].nil?\n post('files.remote.share', options)\n end",
"def transfer( payload )\n @chronicle.file += payload\n @chronicle.save!\n\n notify( :transfer_success, payload.length )\n rescue => e\n notify( :transfer_failure, e.message )\n end",
"def send_file_to_server(file)\n opener = FileManager.new(file)\n flag, content = opener.open_file\n if flag\n answer = execute_rpc_call(content)\n return parse_answer(answer, file)\n else\n return \"Can't open file #{file}\"\n end\n end",
"def send_disposable_file(path, opts = {})\n if opts[:type] || !response['Content-Type']\n content_type opts[:type] || File.extname(path), :default => 'application/octet-stream'\n end\n\n disposition = opts[:disposition]\n filename = opts[:filename]\n disposition = 'attachment' if disposition.nil? && filename\n filename = path if filename.nil?\n attachment(filename, disposition) if disposition\n\n last_modified opts[:last_modified] if opts[:last_modified]\n\n file = DisposableFile.new nil\n file.path = path\n result = file.serving env\n result[1].each { |k,v| headers[k] ||= v }\n headers['Content-Length'] = result[1]['Content-Length']\n halt opts[:status] || result[0], result[2]\n rescue Errno::ENOENT\n not_found\n end",
"def sendThread (cmdSock, sock, fName)\n\tpath = File.expand_path(\"..\", Dir.pwd) + \"/testFiles/\" + fName\n\tbegin\n\t\tFile.open(fName, \"rb\") do |file|\n\t\t\tcmdSock.puts(file.size)\n\t\t\twhile data = file.gets do\n\t\t\t\tsock.puts(data)\n\t\t\tend\n\t\tend\n\t\tputs \"Done sending file!\"\n\trescue SystemCallError\n\t\traise StandardError\n\t\tputs \"Unable to open file\"\n\t\t#notify client of invalid file name\n\t\tsock.puts(\"0\")\n\t\tsock.puts(\"Error opening file, make sure the\"\\\n\t\t\t\" file you're trying to open exists (LIST command)\")\n\tend\nend",
"def file!\n file or fail Error, \"no file is attached\"\n end",
"def attachment path, opts = {}\n halt send_file path, opts.merge(:attachment => true)\n end",
"def get_file\n \n @file = Datafile.find params[:file]\n send_file @file.full_filename,:type => @file.content_type,:disposition => 'inline'\n\n end",
"def sendThread(cmdSock, sock, fName)\n\tsize = 1024\n\tputs \"Sending a file\"\n\tpath = File.expand_path(\"..\", Dir.pwd) + \"/testFiles/\" + fName\n\tfExists = File.exists?(path)\n\t#if the file exists attempt to open it and send to client\n\tif fExists == true\n\t\tbegin\n\t\t\t#notify client of valid file name\n\t\t\tcmdSock.puts(\"1\")\n\t\t\tFile.open(path, \"rb\") do |file|\n\t\t\t\tcmdSock.puts(file.size)\n\t\t\t\twhile data = file.gets do\n\t\t\t\t\tsock.puts(data)\n\t\t\t\tend\n\t\t\tend\n\t\t\tputs \"done sending file\"\n\t\trescue SystemCallError\n\t\t\traise StandardError\n\t\t\tputs \"Unable to open file\"\n\t\t\t#notify client of invalid file name\n\t\t\tcmdSock.puts(\"0\")\n\t\t\tcmdSock.puts(\"Error opening file, make sure the\"\\\n\t\t\t\t\" file you're trying to open exists (LIST command)\")\n\t\tend\n\telse\n\t\tputs \"file doesn't exist\"\n\t\t#notify client of invalid file name\n\t\tcmdSock.puts(\"0\")\n\t\tcmdSock.puts(\"Requested file does not exist, check the available\"\\\n\t\t\t\" files (LIST command)\")\n\tend\nend",
"def deliver_to_file\n @deliver_to_file\n end",
"def send(obj)\n Rubinius.primitive :channel_send\n raise PrimitiveFailure, \"Channel#send primitive failed\"\n end",
"def send_message_to_channel(client, channel_id, title, message)\n client.chat_postMessage(\n channel: channel_id, \n as_user: true,\n text: \"*\" + title + \"*\",\n attachments: [\n text: message,\n color: \"warning\"\n ]\n )\nend",
"def send_image(image)\n response = AGIResponse.new\n command_str = \"SEND IMAGE #{image}\"\n begin\n response.native = execute(command_str)\n rescue AGITimeoutError, AGICommandError, AGIHangupError\n raise\n end\n if response.native == -1 then\n raise AGIChannelError.new(@last_response, \"Channel Failure in (#{command_str})\")\n elsif response.native == 0\n response.success = true\n end\n return response\n end",
"def recieve_and_read_file\n read_file(@message)\n end",
"def upload(file, someone)\n end",
"def figure_1 \n #file_path = File.join(Rails.root, \"public/images\", \"\")\n send_file(File.join(FILE_PATH, \"LgrNucDist.jpg\"), :type => 'image/png', :disposition => 'inline')\n end",
"def attach_file(input, file)\n path = File.expand_path(File.join(SUPPORT_DIR,\"attachments/#{file}\"))\n\n raise RuntimeError, \"file '#{path}' does not exists\" unless File.exists?(path)\n\n input.set(path)\n end",
"def serve\n @photo = User.find(params[:user_id])\n send_data(@photo.data, :type => @photo.mime_type, \n :filename => \"#{@photo.filename}.jpg\",\n :disposition => \"inline\")\n\n\n # send_file(\"./public/uploads/#{@user.filename}\",\n # type: @user.mime_type,\n # disposition: 'inline' )\n end",
"def send_file path, opts={}\n if opts[:type] || !@response[CNT_TYPE]\n content_type opts[:type] || File.extname(path),\n :default => 'application/octet-stream'\n end\n\n disposition = opts[:disposition]\n filename = opts[:filename]\n disposition = 'attachment' if disposition.nil? && filename\n filename = File.basename(path) if filename.nil?\n\n if disposition\n @response[CNT_DISPOSITION] =\n \"%s; filename=\\\"%s\\\"\" % [disposition, filename]\n end\n\n last_modified opts[:last_modified] || File.mtime(path).httpdate\n halt 200 if @request.head?\n\n @response[CNT_LENGTH] = File.size?(path).to_s\n halt 200, File.open(path, \"rb\")\n\n rescue Errno::ENOENT\n halt 404\n end",
"def deliver\n File.open(file_path, 'w') { |file| file.write(rendered_content) }\n Launchy.open(\"file:///#{URI.parse(file_path)}\")\n end",
"def upload_media_file( wikipath, filename, raw )\n p filename\n headers = {\n 'Content-Type' => 'application/octet-stream',\n 'X-File-Name' => filename\n }\n url = upload_url( wikipath, filename )\n p url\n wait_second\n pp @agent.post( url, raw, headers )\n save_uploaded( filename )\n end",
"def show\n\n\n extension = @notice.Select_File.split('.')\n send_file Rails.root.join('public','uploads',@notice.Select_File),\n :type => \"application/#{extension[1]}\", :x_sendfile =>true\n \n @file=\"http://localhost:3000/notices/\".concat(@notice.Select_File)\n\n\n\n \n\n end",
"def sends_data(data)\n script.sends_channel_data(self, data)\n end",
"def send_file path, opts = {}\n\n file = ::Rack::File.new nil\n file.path = path\n (cache_control = opts[:cache_control]) && (file.cache_control = cache_control)\n response = file.serving env\n\n response[1]['Content-Disposition'] = opts[:attachment] ?\n 'attachment; filename=\"%s\"' % (opts[:filename] || ::File.basename(path)) :\n 'inline'\n\n (content_type = opts[:content_type]) &&\n (response[1]['Content-Type'] = content_type)\n\n (last_modified = opts[:last_modified]) &&\n (response[1]['Last-Modified'] = last_modified)\n\n halt response\n end",
"def file\n\n content_upload_id = params[:id]\n\n raise \"content upload without id\" if content_upload_id.blank?\n\n # if the id is not numeric, assume it's a link name\n if content_upload_id.to_i == 0\n content_upload = ContentUpload.find_by_link_name(content_upload_id)\n else # assume the id passed is numeric and find it by ID\n content_upload = ContentUpload.find_by_id(content_upload_id)\n end\n\n raise \"content upload not found\" if content_upload.blank?\n\n # send them to the file on the content server\n redirect_to(content_upload.content_server_url, status: :moved_permanently)\n\n end",
"def x_sendfile(path, options = {})\n if behind_apache? or behind_nginx? or params['x_sendfile']\n headers['X-Sendfile'] = File.expand_path(path)\n end\n send_file(path, options)\n end",
"def x_sendfile(path, options = {})\n if behind_apache? or behind_nginx? or params['x_sendfile']\n headers['X-Sendfile'] = File.expand_path(path)\n end\n send_file(path, options)\n end",
"def file(options={}, &block)\n ssh.file(options, &block)\n end",
"def send_csv_file\n if @csv_file.present?\n data = CsvStorage.find_by(csv_file_type: @csv_file.type).try(:data_store)\n send_data(data, filename: @csv_file.name) if data.present?\n end\n end",
"def send_irc(channel, message)\n real_channel = @zbot.get_channel(channel)\n if real_channel\n real_channel.send(message)\n else\n puts \"############## CHANNEL #{channel} NOT FOUND !\"\n end\n end",
"def send_file(path, opts = OPTS)\n res = response\n headers = res.headers\n if opts[:type] || !headers[RodaResponseHeaders::CONTENT_TYPE]\n res.content_type(opts[:type] || ::File.extname(path), :default => 'application/octet-stream')\n end\n\n disposition = opts[:disposition]\n filename = opts[:filename]\n if disposition || filename\n disposition ||= 'attachment'\n filename = path if filename.nil?\n res.attachment(filename, disposition)\n end\n\n if lm = opts[:last_modified]\n last_modified(lm)\n end\n\n file = RACK_FILES.new nil\n s, h, b = if Rack.release > '2'\n file.serving(self, path)\n else\n file.path = path\n file.serving(@env)\n end\n\n res.status = opts[:status] || s\n headers.delete(RodaResponseHeaders::CONTENT_LENGTH)\n headers.replace(h.merge!(headers))\n res.body = b\n\n halt\n rescue Errno::ENOENT\n not_found\n end",
"def send_data(data, options = {}) #:doc:\n logger.info \"Sending data #{options[:filename]}\" if logger\n send_file_headers! options.merge(:length => data.size)\n @performed_render = false\n render :status => options[:status], :text => data\n end",
"def send_email_by_passing_file(sendto, attachmnent_filename, path='./public')\n Pony.mail({\n :to => sendto,\n :from => 'Magic Team',\n :subject => 'Your web scrapper successfully finished',\n :body => 'Thanks for using web scrapper service offered by MAGiC',\n :attachments => {attachmnent_filename => File.read(File.join(path, attachmnent_filename))},\n :via => :smtp,\n :via_options => {\n :address => 'smtp.gmail.com',\n :port => '587',\n :enable_starttls_auto => true,\n :user_name => 'osu.magic.team@gmail.com',\n :password => 'OSUCSE3901',\n :authentication => :plain, # :plain, :login, :cram_md5, no auth by default\n :domain => \"localhost.localdomain\" # the HELO domain provided by the client to the server\n },\n })\n end",
"def upload(filename)\r\n select(nil, nil, nil, 1)\r\n\r\n peer = \"#{rhost}:#{rport}\"\r\n print_status(\"#{peer} - Trying to upload #{::File.basename(filename)}\")\r\n conn = connect(false, datastore['VERBOSE'])\r\n if not conn\r\n fail_with(Exploit::Failure::Unreachable, \"#{@peer} - Connection failed\")\r\n end\r\n\r\n # Switch to binary mode\r\n print_status(\"#{peer} - Set binary mode\")\r\n send_cmd(['TYPE', 'I'], true, conn)\r\n\r\n # Prepare active mode: Get attacker's IP and source port\r\n src_ip = datastore['SRVHOST'] == '0.0.0.0' ? Rex::Socket.source_address : datastore['SRVHOST']\r\n src_port = datastore['SRVPORT'].to_i\r\n\r\n # Prepare active mode: Convert the IP and port for active mode\r\n src_ip = src_ip.gsub(/\\./, ',')\r\n src_port = \"#{src_port/256},#{src_port.remainder(256)}\"\r\n\r\n # Set to active mode\r\n print_status(\"#{peer} - Set active mode \\\"#{src_ip},#{src_port}\\\"\")\r\n send_cmd(['PORT', \"#{src_ip},#{src_port}\"], true, conn)\r\n\r\n # Tell the FTP server to download our file\r\n send_cmd(['STOR', filename], false, conn)\r\n\r\n print_good(\"#{peer} - Upload successful\")\r\n disconnect(conn)\r\n end",
"def file\n\n content_upload_id = params[:id]\n\n raise \"content upload without id\" if content_upload_id.blank?\n\n # if the id is not numeric, assume it's a link name\n if content_upload_id.to_i == 0\n content_upload = ContentUpload.find_by_link_name(content_upload_id)\n else # assume the id passed is numeric and find it by ID\n content_upload = ContentUpload.find_by_id(content_upload_id)\n end\n\n raise \"content upload not found\" if content_upload.blank?\n\n # send them to the file on the content server\n redirect_to(content_upload.content_server_url)\n\n end",
"def publish(channel, data)\n send_action('publish', channel, data)\n end",
"def send_blobs(ssh,srcpath,despath)\n if File.exist?srcpath\n #puts srcpath.split('/').inspect+\" srcfile\"\n #puts srcpath.split('/')[-1] + \" src file\"\n #puts ssh.exec!(\"ls\").inspect\n if ssh.exec!(\"ls\").inspect.include? srcpath.split('/')[-1]\n\n#return\n end\n ssh.scp.upload!( srcpath , despath , :recursive => true )do|ch, name, sent, total|\n percent = (sent.to_f*100 / total.to_f).to_i\n print \"\\r#{@host}: #{name}: #{percent}%\"\n end\n print \"\\n\"\n puts \"#{srcpath} upload Done.\"\n else\n abort(\"ERROR: Don't have such File: #{srcpath}\")\n end\n end",
"def push_file(path, filedata)\n @bridge.push_file(path, filedata)\n end",
"def push_file(path, filedata)\n @bridge.push_file(path, filedata)\n end",
"def send_image(url, name, image_info = {})\n client.api.send_content(id, url, name, 'm.image', extra_information: image_info)\n end",
"def send_files(type, server)\n raise \"No server given\" if !server\n FileUtils.mkdir_p \"./uploads/#{type}\"\n system \"rsync --progress -rue 'ssh -p #{ssh_port(server)}' uploads/#{type} #{server.user}@#{server.hostname}:#{shared_path}/uploads/\"\n end",
"def stream_file(file, digits='', offset=nil)\n digits.gsub!(/['\"]/, '')\n response = AGIResponse.new\n if offset.nil? then\n command_str = \"STREAM FILE #{file} '#{digits}'\"\n else\n command_Str = \"STREAM FILE #{file} ''#{digits}' #{offset}\"\n end\n begin\n response.native = execute(command_str)\n rescue AGITimeoutError, AGICommandError, AGIHangupError\n raise\n end\n if response.native == -1 then\n raise AGIChannelError.new(@last_response, \"Channel Failure in (#{command_str})\")\n elsif response.native == 0\n response.success = true\n else\n response.success = true\n response.data = response.native.chr\n end\n return response\n end",
"def show_file\n options = { type: @static_page.custom_file.file.content_type,\n disposition: 'inline' }\n send_file @static_page.custom_file.path, options\n end",
"def test_send_file()\n # Parameters for the API call\n file = File::open(TestHelper.get_file('http://localhost:3000/response/image'))\n\n # Perform the API call through the SDK function\n result = @controller.send_file(file)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def put_file(to, content = nil, path = nil)\n raise ArgumentError, \"Need to provide either content or path\" if content.nil? && path.nil?\n run_session do |ssh|\n content ||= IO.binread(path)\n $log&.debug(\"#{self.class}##{__method__} - Copying file to #{@host}:#{to}.\")\n ssh.sftp.file.open(to, 'wb') { |f| f.write(content) }\n $log&.debug(\"#{self.class}##{__method__} - Copying of file to #{@host}:#{to}, complete.\")\n end\n end",
"def write(filename, message, client)\n afile = File.new(filename, \"r+\")\n if afile\n afile.syswrite(message)\n client.puts(\"Changes made to \"+ filename)\n else\n client.puts \"Unable to write to file!\"\n end\nend",
"def send_file stream_id, file\n res_headers = { \"status\" => \"200 OK\", \"version\" => \"HTTP/1.1\" }\n res_headers[\"Content-Type\"] = Rack::Mime.mime_type File.extname(file)\n\n # File contents\n data = if File.exists? file\n File.binread(file)\n elsif File.exists? \"#{file}.erb\"\n Tilt.new(\"#{file}.erb\").render\n else\n res_headers[\"Content-Type\"] = \"text/plain\"\n res_headers[\"status\"] = \"404 Not Found\"\n\n \"404 Not Found\"\n end\n\n res_headers[\"Content-Length\"] = data.size.to_s\n\n # Create response stream.\n # See hello_world.rb for detailed SPDY protocol instructions.\n syn_reply = SPDY::Protocol::Control::SynReply.new zlib_session: @parser.zlib_session\n\n # Send headers.\n send_data syn_reply.create(stream_id: stream_id, headers: res_headers).to_binary_s\n\n # Send contents.\n send_data SPDY::Protocol::Data::Frame.new.create(stream_id: stream_id, data: data).to_binary_s\n\n # Finalize response.\n fin = SPDY::Protocol::Data::Frame.new\n send_data fin.create(stream_id: stream_id, flags: 1).to_binary_s\n end",
"def file\n version = params[:version].nil? ? :original : params[:version].to_sym\n file = @user_application.files.find(params[:id]).file.versions[version]\n file_path = File.join(RAILS_ROOT, 'files', file.public_path)\n type = file.content_type\n filename = file.public_filename\n disposition = params[:disposition] == 'inline' ? 'inline' : 'attachment'\n send_file file_path, :disposition => disposition, :type => (type || \"text\"), :filename => filename unless file_path.nil?\n end",
"def file_send(file_local, file_target, compressed=false)\n\t\traise \"Target machine is not accessible\" if (!@config[\"ssh\"] or !@ip)\n\t\traise \"Local file (#{source}) is not accessible\" if (!(file_local[-1].eql? \"/\") && !(file_local[-2,2].eql? \"/*\") && !File.exist?(File.expand_path(file_local)))\n\n\t\t# Prepare\n\t\tfile_local = File.expand_path(file_local.gsub(/\\/\\*$/, ''))\n\t\tfile_target = file_target.gsub(/\\/$/, '')\n\n\t\t# Send\n\t\tif (compressed && !(['.tar.gz','.gz','.zip'].include? File.extname(file_local)))\n\t\t\t# Compress, send, uncompress\n\t\t\tcase compressed\n\t\t\t\twhen \"tar\"\n\t\t\t\t\t# TAR\n\t\t\t\t\t_tarname = Time.now.to_i\n\t\t\t\t\tputs \"[INFO] Sending #{file_local} using TAR archive\" if $debug\n\t\t\t\t\t`rm -f /tmp/captain/transfers/#{_tarname}.tar.gz && cd $(dirname \"#{file_local}\") && tar -czf /tmp/captain/transfers/#{_tarname}.tar.gz $(basename \"#{file_local}\") && scp -rq -oStrictHostKeyChecking=no -oConnectTimeout=8 -i \"#{@config[\"ssh\"][\"key\"]}\" /tmp/captain/transfers/#{_tarname}.tar.gz #{@config[\"ssh\"][\"username\"]}@#{@ip}:/tmp/captain/transfers/#{_tarname}.tar.gz 2>/dev/null && rm -f /tmp/captain/transfers/#{_tarname}.tar.gz`\n\t\t\t\t\t_scp = command_send(\"tar -xzf /tmp/captain/transfers/#{_tarname}.tar.gz -C $(dirname '#{file_target}') && mv \\\"$(dirname '#{file_target}')/$(basename '#{file_local}')\\\" \\\"#{file_target}\\\" && rm -f /tmp/captain/transfers/#{_tarname}.tar.gz\")\n\t\t\t\twhen \"zip\"\n\t\t\t\t\t# ZIP\n\t\t\t\t\t_zipname = Time.now.to_i\n\t\t\t\t\tputs \"[INFO] Sending #{file_local} using ZIP archive\" if $debug\n\t\t\t\t\t`rm -f /tmp/captain/transfers/#{_zipname}.zip && cd $(dirname \"#{file_local}\") && zip -rq /tmp/captain/transfers/#{_zipname}.zip $(basename \"#{file_local}\") && scp -rq -oStrictHostKeyChecking=no -oConnectTimeout=8 -i \"#{@config[\"ssh\"][\"key\"]}\" /tmp/captain/transfers/#{_zipname}.zip #{@config[\"ssh\"][\"username\"]}@#{@ip}:/tmp/captain/transfers/#{_zipname}.zip 2>/dev/null && rm -f /tmp/captain/transfers/#{_zipname}.zip`\n\t\t\t\t\t_scp = command_send(\"unzip /tmp/captain/transfers/#{_zipname}.zip -d $(dirname '#{file_target}') && mv \\\"$(dirname '#{file_target}')/$(basename '#{file_local}')\\\" \\\"#{file_target}\\\" && rm -f /tmp/captain/transfers/#{_zipname}.zip\")\n\t\t\t\telse\n\t\t\t\t\traise \"Unsupported archiving type \"+compressed\n\t\t\tend\n\t\telse\n\t\t\t# Send uncompressed\n\t\t\tputs \"[INFO] Sending #{file_local}\" if $debug\n\t\t\t_scp = `scp -rq -oStrictHostKeyChecking=no -oConnectTimeout=8 -i \"#{@config[\"ssh\"][\"key\"]}\" \"#{file_local}\" #{@config[\"ssh\"][\"username\"]}@#{@ip}:\"#{file_target}\" 2>/dev/null`\n\t\tend\n\t\treturn _scp\n\tend",
"def upload_file\n #TODO\n end",
"def send_file(path, not_found_file = nil, &block)\n if not_found_file.nil?\n if block_given?\n @j_del.sendFile(path, ARWrappedHandler.new(block))\n else\n @j_del.sendFile(path)\n end\n else\n if block_given?\n @j_del.sendFile(path, not_found_file, ARWrappendHandler.new(block))\n else\n @j_del.sendFile(path, not_found_file)\n end\n end\n self\n end",
"def command_put filename, filesize\n filename = Server.absolute_path(@directory.path, filename)\n puts \"Receiving #{filename}\"\n\n @client.puts \"OK\"\n\n @data_connection.receive filename, filesize.to_i\n end",
"def file= file\n unless file.size == 0\n picture = Attachment.new :content => file.read\n picture.save\n write_attribute 'picture_id', picture.id\n end\n end",
"def upload(type, path)\n File.open(path, 'r') do |file|\n make_request(\n :post, '/upload',\n headers: {\n 'Content-Type' => type, 'Content-Length' => file.size.to_s,\n 'Transfer-Encoding' => 'chunked'\n },\n content: file, base: @media_uri\n )['content_uri']\n end\n end",
"def serve_file!\n ::File.open(file, \"r\") do | stream |\n serve_stream! stream, nil\n end\n end",
"def send_packet(type, *args)\n data = Net::SSH::Buffer.from(*args)\n msg = Net::SSH::Buffer.from(:long, data.length+1, :byte, type, :raw, data)\n channel.send_data(msg.to_s)\n end",
"def send_file(reqfile, content_type)\n reqfile = File.join(@repo_dir, reqfile)\n return render_not_found if !File.exists?(reqfile)\n\n @res = Rack::Response.new\n @res.status = 200\n @res[\"Content-Type\"] = content_type\n @res[\"Last-Modified\"] = File.mtime(reqfile).httpdate\n\n yield\n\n if size = File.size?(reqfile)\n @res[\"Content-Length\"] = size.to_s\n @res.finish do\n File.open(reqfile, \"rb\") do |file|\n while part = file.read(8192)\n @res.write part\n end\n end\n end\n else\n body = [File.read(reqfile)]\n size = Rack::Utils.bytesize(body.first)\n @res[\"Content-Length\"] = size\n @res.write body\n @res.finish\n end\n end",
"def upload_file(file)\n file_path = file.path\n\n @size = File.size(file_path)\n @filename = File.basename(file_path)\n @io = File.open(file_path)\n io.binmode\n Rails.logger.debug \"filename of file to upload: #{filename} filepath: #{file_path}\"\n upload_io(io, size, filename).tap do\n io.close\n end\n end",
"def print_upload(id, file_name, file)\r\n dir = \"prints/#{id}\"\r\n file.original_filename = file_name + (File.extname file.original_filename)\r\n return write(dir, file)\r\n end",
"def execute(file)\n check_args!(file)\n\n resolve_uploader.upload(file)\n end"
] | [
"0.72900164",
"0.72698545",
"0.7137879",
"0.69675636",
"0.68549645",
"0.66866946",
"0.65693897",
"0.649217",
"0.64434123",
"0.63217616",
"0.6277791",
"0.6217847",
"0.62096065",
"0.61116534",
"0.6031926",
"0.60135734",
"0.5973319",
"0.5952479",
"0.5935816",
"0.5908261",
"0.58866596",
"0.5854879",
"0.5847467",
"0.5845273",
"0.58384407",
"0.5822313",
"0.56784606",
"0.56418365",
"0.5634973",
"0.5582598",
"0.5568802",
"0.5549038",
"0.55354327",
"0.55265576",
"0.5515178",
"0.55057067",
"0.55027133",
"0.550183",
"0.5498756",
"0.54868233",
"0.5473956",
"0.5471443",
"0.5466906",
"0.5463028",
"0.5462801",
"0.54594475",
"0.5435925",
"0.54340035",
"0.5431577",
"0.5420829",
"0.5419788",
"0.53472483",
"0.53197986",
"0.5319185",
"0.5313923",
"0.5292803",
"0.52864015",
"0.5250683",
"0.5245765",
"0.5228467",
"0.52202994",
"0.5217056",
"0.52079636",
"0.5205578",
"0.5204097",
"0.5195437",
"0.5195437",
"0.51948225",
"0.5189693",
"0.5189432",
"0.51700205",
"0.51697665",
"0.5145502",
"0.5143238",
"0.51211363",
"0.51008755",
"0.5066604",
"0.5062174",
"0.5062174",
"0.5061519",
"0.50591385",
"0.50589395",
"0.50586146",
"0.5056124",
"0.504241",
"0.5031014",
"0.5024757",
"0.5024492",
"0.5020555",
"0.5017536",
"0.5017505",
"0.50021994",
"0.5000691",
"0.50005955",
"0.49985662",
"0.49954268",
"0.4991701",
"0.49904197",
"0.49863192",
"0.49791008"
] | 0.73033434 | 0 |
Creates a server on Discord with a specified name and a region. | def create_server(name, region = :'eu-central')
response = API::Server.create(token, name, region)
id = JSON.parse(response)['id'].to_i
sleep 0.1 until (server = @servers[id])
debug "Successfully created server #{server.id} with name #{server.name}"
server
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_server(name, region = :london)\n response = API.create_server(token, name, region)\n id = JSON.parse(response)['id'].to_i\n sleep 0.1 until @servers[id]\n server = @servers[id]\n debug \"Successfully created server #{server.id} with name #{server.name}\"\n server\n end",
"def create_guild(name:, region: nil, icon: nil, verification_level: nil, default_message_notifications: nil,\n explicit_content_filter: nil, roles: nil, channels: nil)\n response = request(\n :guilds, nil,\n :post,\n \"guilds\",\n name: name, region: region, icon: icon, verification_level: verification_level,\n default_message_notifications: default_message_notifications, explicit_content_filter: explicit_content_filter,\n roles: roles, channels: channels,\n )\n\n Rapture::Guild.from_json(response.body)\n end",
"def create_server(params)\n body = connection.post(\"/v2/servers/#{account}\", params).body\n async_response(body)\n end",
"def create_server(connection, name, options={})\n raise \"Need to extend create_server method!\"\n end",
"def create_server(options = {})\n begin\n server = connection.servers.create(options[:server_def])\n rescue Excon::Errors::BadRequest => e\n response = Chef::JSONCompat.from_json(e.response.body)\n if response['badRequest']['code'] == 400\n message = \"Bad request (400): #{response['badRequest']['message']}\"\n ui.fatal(message)\n else\n message = \"Unknown server error (#{response['badRequest']['code']}): #{response['badRequest']['message']}\"\n ui.fatal(message)\n end\n raise CloudExceptions::ServerCreateError, message\n end\n\n msg_pair(\"Instance Name\", server.name)\n msg_pair(\"Instance ID\", server.id)\n\n print \"\\n#{ui.color(\"Waiting for server [wait time = #{options[:server_create_timeout]}]\", :magenta)}\"\n\n # wait for it to be ready to do stuff\n server.wait_for(Integer(options[:server_create_timeout])) { print \".\"; ready? }\n\n puts(\"\\n\")\n server\n end",
"def create_guild(data)\n ensure_server(data)\n end",
"def create_guild(data)\n ensure_server(data, true)\n end",
"def create_server opts\n Server.create opts.merge :account => self\n end",
"def create_server\n\n end",
"def create_server(options = {})\n begin\n add_custom_attributes(options[:server_def])\n server = connection.servers.create(options[:server_def])\n rescue Excon::Error::BadRequest => e\n response = Chef::JSONCompat.from_json(e.response.body)\n if response[\"badRequest\"][\"code\"] == 400\n message = \"Bad request (400): #{response[\"badRequest\"][\"message\"]}\"\n ui.fatal(message)\n else\n message = \"Unknown server error (#{response[\"badRequest\"][\"code\"]}): #{response[\"badRequest\"][\"message\"]}\"\n ui.fatal(message)\n end\n raise CloudExceptions::ServerCreateError, message\n rescue Fog::Errors::Error => e\n raise CloudExceptions::ServerCreateError, e.message\n end\n\n print \"\\n#{ui.color(\"Waiting for server [wait time = #{options[:server_create_timeout]}]\", :magenta)}\"\n\n # wait for it to be ready to do stuff\n server.wait_for(Integer(options[:server_create_timeout])) { print \".\"; ready? }\n\n puts(\"\\n\")\n server\n end",
"def create_server(name, image, flavor, networks = nil, keypair = nil, security_group = nil, metadata = nil)\n data = { \n \"server\" => { \n \"name\" => name,\n \"imageRef\" => image,\n \"flavorRef\" => flavor,\n } \n }\n unless networks.nil?\n data[\"server\"][\"networks\"] = networks \n end\n unless keypair.nil?\n data[\"server\"][\"key_name\"] = keypair\n end\n unless security_group.nil?\n data[\"server\"][\"security_group\"] = security_group \n end\n return post_request(address(\"/servers\"), data, @token)\n end",
"def create(name, type)\n configure [\"aaa group server #{type} #{name}\", 'exit']\n end",
"def create_domain\n debug(\"Creating domain #{domain_name}\")\n debug(\"Using options: #{domain_options}\")\n domain = client.servers.create(domain_options)\n prepare_domain(domain)\n domain\n end",
"def create_server(server_name, environment_name, login, remote_addr, remote_path, shell_code = \"\")\n server = get_server(server_name, environment_name)\n if server['environment'].nil?\n server['environment'] = create_server_environment(environment_name)\n end\n if server['server'].nil?\n new_env = RestClient.post(\n \"#{@project_url}release_servers.json?environment_id=#{server['environment']['id']}\",\n {\n \"release_server\" => {\n \"name\" => server_name,\n \"remote_path\" => remote_path,\n \"authenticate_by_key\" => true,\n \"login\" => login,\n \"port\" => 22,\n \"protocol\" => \"sftp\",\n \"local_path\" => \"/\",\n \"remote_addr\" => remote_addr,\n \"shell_code\" => shell_code\n },\n },\n {\n 'Content-Type' => 'application/json'\n }\n )\n new_env = JSON.parse(new_env)\n return {'status' => 'created', 'release_server' => new_env['release_server']}\n\n else\n return {'status' => 'exists', 'release_server' => server['server']}\n end\n end",
"def do_create_server(connection, options)\n server = connection.servers.create(options)\n yield(server) if block_given?\n server\n end",
"def create_server\n return nil if created? # only create a server if it does not already exist\n\n fog_description = fog_description_for_launch\n Chef::Log.debug(JSON.generate(fog_description)) # .dup.tap{|hsh| hsh[:user_data] = \"...\" }\n @fog_server = ClusterChef.connection.servers.create(fog_description)\n end",
"def server(name, options = {}, &block)\n server = Server.new(options.merge(:name => name, :servers => self.__servers))\n self.__servers << server\n end",
"def create(options = {})\n raise ArgumentError.new(\"You must provide :cores and :ram\") if options[:ram].nil? or options[:cores].nil?\n raise ArgumentError.new(\":ram has to be at least 256MiB and a multiple of it\") if options[:ram].to_i < 256 or (options[:ram].to_i % 256) > 0\n raise ArgumentError.new(\":availability_zone has to be either 'AUTO', 'ZONE_1', or 'ZONE_2'\") if options[:availability_zone] and !['AUTO', 'ZONE_1', 'ZONE_2'].include? options[:availability_zone]\n raise ArgumentError.new(\":os_type has to be either 'WINDOWS' or 'OTHER'\") if options[:os_type] and !['WINDOWS', 'OTHER'].include? options[:os_type]\n options[:server_name] = options.delete :name if options[:name]\n response = Profitbricks.request :create_server, options\n self.find(:id => response[:server_id])\n end",
"def server(name, options = {}, &blk)\n add_child(:servers, Hubcap::Server.new(self, name, options, &blk))\n end",
"def register_server(name)\n do_send(Erlang::Tuple.new([\n Erlang::Atom.new('register_with_group'),\n Erlang::Atom.new(name)]))\n end",
"def create(name)\n @name=name\n @vserver_hash=Map.new.set(:properties, :basic, :pool)\n end",
"def create_server(options = {})\n begin\n add_custom_attributes(options[:server_def])\n server = connection.servers.create(options[:server_def])\n\n print \"\\nWaiting For Server\"\n server.wait_for(Integer(options[:server_create_timeout])) do\n print '.'\n !locked?\n end\n\n # attach/or create any volumes.\n options[:server_volumes].each do |voldef|\n Chef::Log.debug(\"Volume definition: #{voldef}\")\n if voldef.key?(:size) || voldef.key?(:size_gb)\n # create a new volume\n result = connection.add_volume(server.id, voldef)\n name = (result / 'disk/name').first.text\n elsif voldef.key? :id\n server.attach_volume(voldef)\n name = voldef[:id]\n else\n raise CloudExceptions::ServerCreateError, \"cannot handle volume definition #{voldef}\"\n end\n\n print \"\\nAttached #{name} volume\"\n end\n\n print \"\\nWaiting For Volumes\"\n server.wait_for(Integer(options[:server_create_timeout])) do\n print '.'\n !locked?\n end\n Chef::Log.debug(\"options: #{options}\")\n server.start_with_cloudinit(user_data: options[:cloud_init])\n rescue Excon::Error::BadRequest => e\n response = Chef::JSONCompat.from_json(e.response.body)\n message = if response['badRequest']['code'] == 400\n \"Bad request (400): #{response['badRequest']['message']}\"\n else\n \"Unknown server error (#{response['badRequest']['code']}): #{response['badRequest']['message']}\"\n end\n ui.fatal(message)\n raise CloudExceptions::ServerCreateError, message\n rescue Fog::Errors::Error => e\n raise CloudExceptions::ServerCreateError, e.message\n end\n\n print \"\\n#{ui.color(\"Waiting for server [wait time = #{options[:server_create_timeout]}]\", :magenta)}\"\n\n # wait for it to be ready to do stuff\n server.wait_for(Integer(options[:server_create_timeout])) do\n print '.'\n ready?\n end\n\n puts(\"\\n\")\n server\n end",
"def one(server, name = nil)\n @name = name || @name\n send_to_one(server, :create, name: @name)\n end",
"def create_server(zone: \"fi-hel1\", title:, hostname:, core_number: 1,\n memory_amount: 1024, storage_devices:, ip_addresses: :all)\n data = {\n \"server\" => {\n \"zone\" => zone,\n \"title\" => title,\n \"hostname\" => hostname,\n \"core_number\" => core_number,\n \"memory_amount\" => memory_amount,\n \"storage_devices\" => { \"storage_device\" => storage_devices }\n }\n }\n\n if ip_addresses != :all\n ips = []\n ips << { \"access\" => \"public\", \"family\" => \"IPv4\" } if ip_addresses.include? :public\n ips << { \"access\" => \"private\", \"family\" => \"IPv4\" } if ip_addresses.include? :private\n ips << { \"access\" => \"public\", \"family\" => \"IPv6\" } if ip_addresses.include? :ipv6\n\n data[\"server\"][\"ip_addresses\"] = {}\n data[\"server\"][\"ip_addresses\"][\"ip_address\"] = ips\n end\n\n json = JSON.generate data\n response = post \"server\", json\n response\n end",
"def create_server\n raise NotImplementedError, \"Implement #{__callee__} in #{self.class.to_s}\"\n end",
"def create_server_on_master(s)\n image_id = server_image_id(s) #s.respond_to?('image_id') ? s.image_id : 'no_image'\n flavor_id = server_flavor_id(s) #s.respond_to?('flavor_id') ? s.flavor_id : nil\n create_record_with_fields(\"machine\",\n [\"name\", \"type\", \"instance_id\", \"public_ipv4\", \"image_id\", \"flavor_id\"],\n [server_name(s), provider, s.identity, s.public_ip_address, image_id , flavor_id])\n end",
"def server_create(server_name, template)\n # calculate instance id\n Puppet.debug \"template keys => \" + JSON.pretty_generate(template)\n\n server_id, server_host = ::Pinas::Common.extract_instance_id_from(server_name)\n\n # 1. setup the default options\n options = {\n :name => server_name,\n :flavor_ref => get_flavor(template[:flavor_name]), # For Openstack provider\n :image_ref => get_image(template[:image_name]), # For Openstack provider\n :flavor_id => get_flavor(template[:flavor_name]), # For HPCloud provider\n :image_id => get_image(template[:image_name]), # For HPCloud provider\n :key_name => template[:key_name],\n :security_groups => template[:security_groups],\n }\n Puppet.debug \"setup default options = >\" + JSON.pretty_generate(options)\n # 2. setup the meta data/user data for the server, for boot hooks\n begin\n options[:metadata] = meta_to_hash(ERB.new(template[:meta_data]).result(binding)) if template.has_key?(:meta_data)\n rescue Exception => e\n Puppet.crit \"servers.create in running erb for :metadata, Error: #{e}\"\n raise Puppet::Error, \"Error : #{e}\"\n end\n begin\n options[:user_data] = ERB.new(File.read(template[:user_data])).result(binding) if template.has_key?(:user_data)\n rescue Exception => e\n Puppet.crit \"servers.create in running erb for :user_data, Error: #{e}\"\n raise Puppet::Error, \"Error : #{e}\"\n end\n Puppet.debug \"added metadata and user_data\"\n Puppet.debug \"has network_name key ? #{template.has_key?(:network_name)}\"\n Puppet.debug \"network class => #{network.class}\"\n Puppet.debug \"template[:network_name] => #{template[:network_name]}\"\n Puppet.debug \"template[:network_name] => #{template['network_name']}\"\n # 3. get the network uuid and name\n if @network != nil and template.has_key?(:network_name) and template[:network_name] != ''\n Puppet.debug \"adding network #{template[:network_name]}\"\n networks = Array.new\n nics = Array.new\n nics << get_networkid(template[:network_name])\n # nics << template[:network_name]\n Puppet.debug \"working on nics => #{nics}.\"\n begin\n nics.each do |net|\n Puppet.debug \"working on net => #{net}\"\n network = find_match(@network.networks, net)\n networks.push('net_id' => network.id) if network\n end\n options[:nics] = networks\n rescue Exception => e\n raise Puppet::Error, \"Problem assigning nics, #{e}\"\n end\n Puppet.debug \"after options, got = >\" + JSON.pretty_generate(options)\n end\n # 4. create new server and wait for it to be ready.\n # TODO: implement retryable and wait for code. need to confirm we have a timeout in fog.\n # server = @compute.servers.create(options)\n # retryable(on: Timeout::Error, tries: 200) do\n # begin\n # server.wait_for(30) { ready? }\n # rescue RuntimeError, Fog::Errors::TimeoutError => e\n # end\n # end\n Puppet.debug \"attempting to create server #{server_name}\"\n new_server = nil\n begin\n new_server = @compute.servers.create(options)\n new_server.wait_for { ready?}\n new_server.wait_for { !addresses.nil? }\n rescue Exception => e\n Puppet.crit \"servers.create Error: #{e}\"\n raise Puppet::Error, \"Error : #{e}\"\n end\n\n Puppet.notice \"server created #{server_name} on net #{template[:network_name]} \"\n begin\n newserver_ip_assign(new_server)\n rescue Exception => e\n Puppet.crit \"server_ip_assign Error: #{e}\"\n raise Puppet::Error, \"Error : #{e}\"\n end\n\n end",
"def real_server_create (network-id, name, serverId, inService)\n org_endpoint \"/network/#{network_id}/realServer\"\n xml_params(name: name, serverId: serverId, inService: inService)\n post\n end",
"def create\n name = shift_argument\n url = shift_argument\n\n unless name && url\n raise(Heroku::Command::CommandFailed, \"Usage: clients:register [NAME] [CALLBACK_URL]\")\n end\n\n validate!(url)\n client = request do\n api.request(\n :body => encode_json(\n { :name => name, :redirect_uri => url }),\n :expects => 201,\n :headers => headers,\n :method => :post,\n :path => \"/oauth/clients\"\n ).body\n end\n\n if options[:shell]\n puts \"HEROKU_OAUTH_ID=#{client[\"id\"]}\"\n puts \"HEROKU_OAUTH_SECRET=#{client[\"secret\"]}\"\n else\n styled_header(%{Registered client \"#{name}\".})\n styled_hash(client)\n end\n end",
"def create_esb_server (config, hostname, ip1, ip2)\n config.vm.define hostname do |esb|\n esb.vm.provider \"virtualbox\" do |provider|\n provider.customize [\"modifyvm\", :id, \"--memory\", 2048]\n end\n\n esb.vm.network \"private_network\", ip: ip1\n esb.vm.host_name = hostname\n\n esb.vm.network \"private_network\", ip: ip2\n end\nend",
"def create_server\n\t\treturn Hglib::Server.new( self.path.to_s )\n\tend",
"def create params\n raise_start_server unless Server::node\n new params\n end",
"def create_server(vdu, image_name, flavour_name, ports)\n\t\t@hot.resources_list << Server.new(\n\t\t\tvdu['id'],\n\t\t\t{get_resource: flavour_name},\n\t\t\t{get_resource: image_name},\n\t\t\tports,\n\t\t\tadd_wait_condition(vdu))\n\t\t@hot.outputs_list << Output.new(\"#{vdu['id']}#id\", \"#{vdu['id']} ID\", {get_resource: vdu['id']})\n\tend",
"def create(state)\n info(\"Creating instance #{instance.name}\")\n return if state[:server_id]\n\n domain = create_domain\n state[:server_id] = domain.id\n state[:hostname] = domain.public_ip_address\n\n instance.transport.connection(state).wait_until_ready\n\n info(\"Libvirt instance #{domain.name} created.\")\n end",
"def create_instance(credentials, image_id, opts)\n racks = new_client( credentials )\n hwp_id = opts[:hwp_id] || 1\n name = Time.now.to_s\n if (opts[:name]) then name = opts[:name] end\n safely do\n return convert_srv_to_instance(racks.start_server(image_id, hwp_id, name))\n end\n end",
"def create(client, scope, redirect_uri, response_type, state, instance_name = 'default-client', instance_description = 'default client')\n scope = Utils.normalize_scope(scope) & client.scope # Only allowed scope\n fields = { :client_id=>client.id, :scope=>scope, :redirect_uri=>client.redirect_uri || redirect_uri,\n :response_type=>response_type, :state=>state,\n :grant_code=>nil, :authorized_at=>nil,\n :created_at=>Time.now.to_i, :revoked=>nil,\n :instance_name => instance_name, :instance_description => instance_description }\n fields[:_id] = collection.insert(fields)\n Server.new_instance self, fields\n end",
"def add_name_server(server)\n configure \"ip name-server #{server}\"\n end",
"def create(name)\n url = prefix + \"create\" + \"&name=#{name}\"\n return response(url)\n end",
"def create(name)\n set_shutdown(name, enable: false)\n end",
"def create(identity, client, scope, redirect_uri = nil, expires = nil, instance_name = \"default-client\", instance_description = \"default client\" )\n raise ArgumentError, \"Identity must be String or Integer\" unless String === identity || Integer === identity\n scope = Utils.normalize_scope(scope) & client.scope # Only allowed scope\n expires_at = Time.now.to_i + (expires || 300)\n fields = { :_id=>Server.secure_random, :identity=>identity, :scope=>scope,\n :client_id=>client.id, :redirect_uri=>client.redirect_uri || redirect_uri,\n :created_at=>Time.now.to_i, :expires_at=>expires_at, :granted_at=>nil,\n :access_token=>nil, :revoked=>nil ,\n :instance_name => instance_name, :instance_description => instance_description }\n collection.insert fields\n Server.new_instance self, fields\n end",
"def create_host(host, args = {})\n raise ArgumentError, \"Must specify ip and port\" unless \\\n args.include? :ip and args.include? :port\n\n modify_host(host, args, 'create')\n end",
"def create(opts)\n opts = check_params(opts,[:servers])\n super(opts)\n end",
"def _register_client(credentials)\n DoubleDutch::SpaceCadet::Config.register(\n \"#{credentials[:region]}-#{credentials[:env]}\".downcase,\n credentials[:username].downcase,\n credentials[:key],\n credentials[:region].upcase\n )\n end",
"def create(options = {})\n options[:name] ||= SecureRandom.hex\n\n create_options = { p: port }\n create_options[:c] = options[:name] if options[:name]\n create_options[:d] = options[:dir] if options[:dir]\n exec(\"create\", create_options)\n\n options[:name]\n end",
"def createPrivateNetworks(name='')\n opt = @options.merge!({ :body => { :name => name } })\n\n self.class.post(\"/privateNetworks\", opt)\n end",
"def create(name)\n url = prefix + \"create\" + \"&name=#{name}\"\n return response(url)\n end",
"def create_server!(conn, name, key_name, type, image, sec_groups)\n unless @mock\n unless conn.images.find { |i| i.id == image }\n @log.error \"Cannot find image with id #{image}, available images: \"\n conn.images.table([:id, :name])\n abort\n end\n unless conn.flavors.find { |f| f.id == type.to_s }\n @log.error \"Cannot find flavor with id #{type}, available flavors: \"\n conn.flavors.table([:id, :name])\n abort\n end\n end\n server = conn.servers.create(\n :name => name,\n :flavor_ref => type,\n :image_ref => image,\n :key_name => key_name,\n :security_groups => sec_groups\n )\n # TODO -- mocking is not working, reload is not assigning ip addresses. Custom assigning is not\n # TODO -- getting persisted to the server object hence getting the public ip address is working\n # TODO -- and getting the internal ip address is not working. FIX THIS for mocking to work!!!\n if @mock\n server.reload\n server.addresses= {\n 'public'=>[\n {\n 'OS-EXT-IPS-MAC:mac_addr' => (1..6).map{'%0.2X'%rand(256)}.join(':'),\n 'version' => 4,\n 'addr' => 4.times.map{ Fog::Mock.random_numbers(3) }.join('.'),\n 'OS-EXT-IPS:type' => 'fixed'\n },\n {\n 'OS-EXT-IPS-MAC:mac_addr' => (1..6).map{'%0.2X'%rand(256)}.join(':'),\n 'version' => 4,\n 'addr' => 4.times.map{ Fog::Mock.random_numbers(3) }.join('.'),\n 'OS-EXT-IPS:type' => 'floating'\n }\n ]\n }\n end\n server\n end",
"def server(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"server \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def add_radius_server(name, server, opts = {})\n # order of command options matter here!\n server = \"server #{server} \"\n server << \"auth-port #{opts[:auth_port]} \" if opts[:auth_port]\n server << \"acct-port #{opts[:acct_port]} \" if opts[:acct_port]\n server << \"vrf #{opts[:vrf]}\" if opts[:vrf]\n configure [\"aaa group server radius #{name}\", server, 'exit']\n end",
"def create(server)\n run_barman_command(\"backup #{server}\")\n end",
"def newWorld(db, name)\n\tif db.hexists('sgt-worlds', name)\n\t\treturn World.new(db, db.hget('sgt-worlds', name))\n\tend\n\tnewId = newUUID(db)\n\t\n\t# Associate this name to the world id\n\tdb.hset('sgt-worlds', name, newId)\n\t\t\n\t# The 'name' property of the object\n\tdb.hset('sgt-world:'+newId, 'name', name)\n\t\n\tworld = World.new(db, newId)\n\tworld\nend",
"def create\n database.command({ :create => name }.merge(options))\n end",
"def create_guild_role(data)\n role_data = data['role']\n server_id = data['guild_id'].to_i\n server = @servers[server_id]\n new_role = Role.new(role_data, self, server)\n server.add_role(new_role)\n end",
"def create_cluster(name, options = {})\n cluster = Cluster.receive(cluster_name: name, href: File.join('clusters', name))\n cluster.create options\n end",
"def clc_test_server\n puts \"clc_test_server\"\n server = clc_service.servers.find { |s| s.Name == clc_server_name }\n unless server\n server = clc_service.servers.create({\n :Name => clc_server_name\n }.merge(clc_set_test_server_attributes))\n server.wait_for { ready? }\n end\n server\nend",
"def setup_server(s)\n # noop\n end",
"def server(name, host, user, options={})\n servers.push(DO::Server.new(name, host, user, options))\n local(name) { servers_selected.replace(servers.select { |s| s.name == name }) }\n end",
"def register_slave\n uri = \"druby://#{@options[:server_host]}:#{@options[:server_port]}\"\n slave = { :id => @options[:id], :host => `hostname`.strip, :port => @options[:port] }\n ok = false\n loop do\n begin\n server = DRbObject.new_with_uri(uri)\n server.register_slave(slave)\n if not ok\n @logger.info(\"successfully registered\")\n ok = true\n end\n rescue Exception => e\n if ok\n @logger.warn(\"can't update server\")\n ok = false\n end\n end\n sleep @options[:register_timeout]\n end\n end",
"def add_server(string)\n\n end",
"def initialize(name, server)\n @name = name\n @server = server\n @uri = \"/#{name.gsub('/','%2F')}\"\n create_database_unless_exists\n end",
"def server_exists_at(address)\n DNSSD.register!(address.name, TYPE, nil, address.port)\n end",
"def new_address\n @client.new_address(name)\n end",
"def create_server(mechanism_name, realm = \"gsasl\", &block)\n peer = Peer.new(@context, mechanism_name, :server)\n @peers[peer.session.address] = peer\n peer.realm = realm\n peer.authentication_callback = block if block_given?\n peer\n end",
"def create(client, scope, redirect_uri, response_type, state)\n scope = Utils.normalize_scope(scope) & client.scope # Only allowed scope\n fields = { :client_id=>client.id, :scope=>scope, :redirect_uri=>client.redirect_uri || redirect_uri,\n :response_type=>response_type, :state=>state,\n :grant_code=>nil, :authorized_at=>nil,\n :created_at=>Time.now.to_i, :revoked=>nil }\n fields[:_id] = collection.insert(fields)\n Server.new_instance self, fields\n end",
"def create_public_hosted_zone(app_name, stack_name, name, comment, tags: [])\n properties = {\n Name: name\n }\n\n properties[:HostedZoneConfig] = {\n Comment: comment\n } unless comment.blank?\n\n properties[:HostedZoneTags] = [\n {\n Key: 'Application',\n Value: app_name\n },\n {\n Key: 'Stack',\n Value: stack_name\n }\n ]\n properties[:HostedZoneTags].concat(tags) unless tags.blank?\n\n resource_name = \"#{app_name}HostedZone\"\n resource resource_name,\n Type: 'AWS::Route53::HostedZone',\n Properties: properties\n resource_name\n end",
"def gateway(name, options = {}, &block)\n server = Server.new(options.merge(:name => name, :is_gateway => true, :servers => self.__servers))\n self.__servers << server\n end",
"def create_dhcp_server(network, options)\n end",
"def create_user(name)\n\t\t@mutex.synchronize do\n\t\t\t@name = name\n\t\t\t@reg_response = new_sub(@discovery['registration_response']['url'],\n\t\t\t\t@discovery['registration_response']['capability'])\n\t\t\t@command_id = rand(99999999)\n\t\t\t@reg_response.last = (Time.now.to_i * 1000) - 5\n\t\t\t@reg_response.add_listener('reg_response') {|m| user_created(m)}\n\t\t\t@reg_response.start_listening\n\t\t\t@create_player_channel = new_channel(@discovery['registration']['url'],\n\t\t\t\t@discovery['registration']['capability'])\n\t\t\thsh = {'name' => name, 'id' => @command_id}\n\t\t\tif USE_ENCRYPTION\n\t\t\t\t@encryption_keys = OpenSSL::PKey::RSA.generate(1024)\n\t\t\t\thsh['public_key'] = @encryption_keys.public_key\n\t\t\tend\n\t\t\t@create_player_channel.publish(hsh.to_json)\n\t\tend\n\t\twait_for_player_to_be_created\n\tend",
"def run\n sanity_check\n\n ui.info(\"Creating new client for #{node_name}\")\n\n @client = create_client!\n\n ui.info(\"Creating new node for #{node_name}\")\n\n create_node!\n end",
"def exec_city!(*args)\n raise t(:you_are_not_an_admin) unless admin?\n\n res = City.find_or_create_by!(name: args[0], province: args[1])\n respond_with :message, text: res.inspect\n end",
"def create_volume(options)\n # Creating the volume is part of the server creation\n end",
"def create_volume(options)\n # Creating the volume is part of the server creation\n end",
"def register(client); end",
"def create_namespace project:, location:, namespace:\n # [START servicedirectory_create_namespace]\n # project = \"Your Google Cloud project ID\"\n # location = \"The Google Cloud region containing the new namespace\"\n # namespace = \"The name of the namespace you are creating\"\n\n require \"google/cloud/service_directory\"\n\n # Initialize the client\n registration_service = Google::Cloud::ServiceDirectory.registration_service\n\n # The parent path of the namespace\n parent = registration_service.location_path(\n project: project, location: location\n )\n\n # Use the Service Directory API to create the namespace\n response = registration_service.create_namespace(\n parent: parent, namespace_id: namespace\n )\n puts \"Created namespace: #{response.name}\"\n # [END servicedirectory_create_namespace]\nend",
"def create_db name\n \n req = Net::HTTP::Put.new \"/#{name}\"\n ret = @http.request req\n \n puts \"Creating Database #{name} => #{ret.msg} (#{ret.code})\\n\"\n \n end",
"def create(options = {})\n response = request(:post, \"/network_zones.json\", :query => {:pack => options})\n end",
"def create_bot\n $bot = Discordrb::Bot.new(\n token: $config['discord_secret'],\n client_id: $config['discord_client'],\n log_mode: :quiet,\n intents: [\n :servers,\n :server_members,\n :server_bans,\n :server_emojis,\n :server_integrations,\n :server_webhooks,\n :server_invites,\n :server_voice_states,\n #:server_presences,\n :server_messages,\n :server_message_reactions,\n :server_message_typing,\n :direct_messages,\n :direct_message_reactions,\n :direct_message_typing\n ]\n )\n log(\"Created bot\")\nrescue => e\n fatal(\"Failed to create bot: #{e}\")\n exit\nend",
"def create\n @server = @site.servers.new(server_params.merge({used_at: (Time.now - 1.day)}))\n\n respond_to do |format|\n if @server.save\n format.html { redirect_to [:admin, @site], notice: 'Server was successfully created.' }\n format.json { render action: 'show', status: :created, location: [:admin, @site] }\n else\n format.html { render action: 'new' }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_guild_role(data)\n role_data = data['role']\n server_id = data['guild_id'].to_i\n server = @servers[server_id]\n new_role = Role.new(role_data, self, server)\n existing_role = server.role(new_role.id)\n if existing_role\n existing_role.update_from(new_role)\n else\n server.add_role(new_role)\n end\n end",
"def create(state)\n # we are checking the config here instead of when the class is loaded because\n # test-kitchen doesn't have the platform object instantiated until we call create\n raise Kitchen::UserError, /Error. Only windows is supported./ unless windows_os?\n newhost = poolsclosed_machine\n raise Kitchen::InstanceFailure, /Error, no available instances in poolsclosed/ if newhost.nil?\n state[:hostname] = newhost\n end",
"def create_hosts( count, profile, name, sync_file )\n require_configured!\n profile = get_profile( profile ) if profile.is_a?( Symbol )\n profile = profile.dup\n\n # FIXME: Support profile overrides? Also add some targeted CLI\n # overrides (like for :availability_zone)?\n\n if profile[ :user_data ] == :ec2_user_sudo\n profile[ :user_data ] = no_tty_sudoer( 'ec2-user' )\n end\n\n dname = profile.delete( :default_name )\n name ||= dname\n\n count.times do\n hname = if count == 1\n raise \"Host #{name} already exists!\" if space.get_host( name )\n name\n else\n find_name( name )\n end\n props = aws_create_instance( hname, profile )\n host = space.host( props )\n yield( host ) if block_given?\n append_host_definitions( [ host ], nil, sync_file )\n host[ :just_created ] = true\n # Need to use a host prop for this since context(s) do not\n # exist yet. Note it is set after append_host_definitions, to\n # avoid permanently writing this property to the sync_file.\n end\n end",
"def create(name=nil, options={})\n deprecate # 07/26/2012\n name = create_request(name, options)\n loop do\n break if create_complete?(name)\n sleep 1\n end\n name\n end",
"def server(name, opts)\r\n srv = EventMachine::connect(opts[:host], opts[:port], EventMachine::ProxyServer::Backend) do |c|\r\n c.name = name\r\n c.plexer = self\r\n end\r\n\r\n @servers[name] = srv\r\n end",
"def create_role(token, server_id)\n request(\n __method__,\n :post,\n \"#{api_base}/guilds/#{server_id}/roles\",\n nil,\n Authorization: token\n )\n end",
"def create\n\t\t#sanity checks\n\t\tif params[:'licserver-tags'].empty? || params[:'licserver-location'].empty? then\n\t\t\trender :nothing => true, :status => :bad_request\n\t\t\treturn\n\t\tend\n\n\t\tmatch_data = /(?<port_id>\\d*)@(?<server_id>[\\w.-]+)/.match( params[:'licserver-location'])\n\n\t\t#start creating\n\t\tlicserver = Licserver.new( :port => match_data[:port_id], :server => match_data[:server_id])\n\n\t\tif licserver.save! then\n\t\t\t#update licserver features\n\t\t\tlicserver.update_features\n\n\t\t\t#add the proper tags\n\t\t\tparams[:'licserver-tags'].split.each{ |x| Tag.new(:title => x.downcase, :licserver_id => licserver.id ).save! }\n\t\t\trender :nothing => true, :status => :ok\n\t\t\treturn\n\t\telse\n\t\t\trender :nothing => true, :status => :bad_request\n\t\t\treturn\n\t\tend\n\tend",
"def create_remote(entity)\n log_event(\"[I] Creating remote user #{entity.id} (#{entity.uuid})\")\n @entity = entity\n rest(:post, PATH, data_for_remote)\n end",
"def create\n\t\t@guild = Guild.new(guild_params)\n\t\t@guild.points = 0\n\t\t@guild.owner = current_user\n\n\t\trespond_to do |format|\n\t\t\tif @guild.save\n\t\t\t\tformat.html { redirect_to @guild, notice: 'Guild was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @guild }\n\t\t\telse\n\t\t\t\tformat.html { broadcast_errors @guild, guild_params }\n\t\t\t\tformat.json { render json: @guild.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def server(name, host, user, options={})\n servers.push(DO::Server.new(name, host, user, options))\n task name do |opts, b|\n allowed = opts.map { |k,v| k if remote.include?(k) && v }.compact\n denied = opts.map { |k,v| k if remote.include?(k) && v == false }.compact\n if (allowed.empty? && denied.empty?) ||\n (!allowed.empty? && allowed.include?(name)) ||\n (!denied.empty? && !denied.include?(name))\n @_current_server = servers.find { |s| s.name == name }\n begin\n b.arity == 1 ? b.call(opts) : b.call\n ensure\n @_current_server = nil\n end\n end\n end\n end",
"def create_image(options)\n data = JSON.generate(:createImage => options)\n response = @compute.connection.csreq(\"POST\",@svrmgmthost,\"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/action\",@svrmgmtport,@svrmgmtscheme,{'content-type' => 'application/json'},data)\n OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)\n image_id = response[\"Location\"].split(\"/images/\").last\n OpenStack::Compute::Image.new(@compute, image_id)\n end",
"def create\n remote = extract_option('--remote', 'heroku')\n stack = extract_option('--stack', 'aspen-mri-1.8.6')\n timeout = extract_option('--timeout', 30).to_i\n name = args.shift.downcase.strip rescue nil\n name = heroku.create_request(name, {:stack => stack})\n display(\"Creating #{name}...\", false)\n info = heroku.info(name)\n begin\n Timeout::timeout(timeout) do\n loop do\n break if heroku.create_complete?(name)\n display(\".\", false)\n sleep 1\n end\n end\n display \" done, stack is #{info[:stack]}\"\n\n (options[:addons] || \"\").split(\",\").each do |addon|\n addon.strip!\n display \"Adding #{addon} to #{name}... \", false\n heroku.install_addon(name, addon)\n display \"done\"\n end\n\n if buildpack = options[:buildpack]\n heroku.add_config_vars(name, \"BUILDPACK_URL\" => buildpack)\n end\n\n display [ info[:web_url], info[:git_url] ].join(\" | \")\n rescue Timeout::Error\n display \"Timed Out! Check heroku info for status updates.\"\n end\n\n create_git_remote(name, remote || \"heroku\")\n end",
"def create_vm(agent_id, stemcell_id, resource_pool,\n network_spec = nil, disk_locality = nil, environment = nil)\n with_thread_name(\"create_vm(#{agent_id}, ...)\") do\n @logger.info('Creating new server...')\n registry_key = \"vm-#{generate_unique_name}\"\n server_params = {\n name: registry_key,\n os_scheduler_hints: resource_pool['scheduler_hints'],\n config_drive: @use_config_drive,\n }\n\n network_configurator = NetworkConfigurator.new(network_spec, resource_pool['allowed_address_pairs'])\n picked_security_groups = pick_security_groups(server_params, network_configurator, ResourcePool.security_groups(resource_pool))\n pick_stemcell(server_params, stemcell_id)\n flavor = pick_flavor(server_params, resource_pool)\n pick_key_name(server_params, resource_pool)\n\n @logger.debug(\"Using scheduler hints: `#{resource_pool['scheduler_hints']}'\") if resource_pool['scheduler_hints']\n\n pick_availability_zone(server_params, disk_locality, resource_pool['availability_zone'])\n configure_volumes(server_params, flavor, resource_pool)\n\n pick_server_groups(server_params, environment)\n\n availability_zone = @az_provider.select(disk_locality, resource_pool['availability_zone'])\n server_params[:availability_zone] = availability_zone if availability_zone\n\n begin\n @openstack.with_openstack { network_configurator.prepare(@openstack, picked_security_groups.map(&:id)) }\n nics = pick_nics(server_params, network_configurator)\n server = create_server(server_params, nics)\n configure_server(network_configurator, server)\n\n server_tags = {}\n tag_server(server_tags, server, registry_key, network_spec, resource_pool.fetch('loadbalancer_pools', []))\n\n update_server_settings(server, registry_key, agent_id, network_configurator.network_spec, environment,\n flavor_has_ephemeral_disk?(flavor))\n\n server.id.to_s\n rescue StandardError => e\n begin\n destroy_server(server, server_tags) if server\n rescue StandardError => destroy_err\n @logger.warn(\"Failed to destroy server: #{destroy_err.message}\")\n end\n\n begin\n @openstack.with_openstack {\n network_configurator.cleanup(@openstack)\n }\n rescue StandardError => cleanup_error\n @logger.warn(\"Failed to cleanup network resources: #{cleanup_error.message}\")\n end\n raise e\n end\n end\n end",
"def create(name)\n configure [\"interface #{name}\", 'no ip address', 'switchport']\n end",
"def create(identity, client, scope, redirect_uri = nil, expires = nil)\n raise ArgumentError, \"Identity must be String or Integer\" unless String === identity || Integer === identity\n scope = Utils.normalize_scope(scope) & client.scope # Only allowed scope\n expires_at = Time.now.to_i + (expires || 300)\n fields = { :_id=>Server.secure_random, :identity=>identity, :scope=>scope,\n :client_id=>client.id, :redirect_uri=>client.redirect_uri || redirect_uri,\n :created_at=>Time.now.to_i, :expires_at=>expires_at, :granted_at=>nil,\n :access_token=>nil, :revoked=>nil }\n collection.insert fields\n Server.new_instance self, fields\n end",
"def create_station\n request = ['Enter station name: ']\n getting(request, :approve_station, :create_station!)\n end",
"def create\n @game_server = Game::Server.new(params[:game_server])\n\n respond_to do |format|\n if @game_server.save\n format.html { redirect_to @game_server, notice: 'Server was successfully created.' }\n format.json { render json: @game_server, status: :created, location: @game_server }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game_server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def run\n super\n # create an ip\n ip_address = \"#{rand(255)}.#{rand(255)}.#{rand(255)}.#{rand(255)}\"\n x = create_entity Entities::Host, { :name => ip_address }\n end",
"def create(args)\n redirect_uri = Server::Utils.parse_redirect_uri(args[:redirect_uri]).to_s if args[:redirect_uri]\n scope = Server::Utils.normalize_scope(args[:scope])\n fields = { :display_name=>args[:display_name], :link=>args[:link],\n :image_url=>args[:image_url], :redirect_uri=>redirect_uri,\n :notes=>args[:notes].to_s, :scope=>scope.join(\",\"),\n :created_at=>Time.now.to_i, :revoked=>nil }\n if args[:id] && args[:secret]\n fields[:id], fields[:secret] = args[:id].to_s, args[:secret]\n collection.insert(fields)\n else\n fields[:secret] = Server.secure_random\n fields[:id] = OpenSSL::Random.random_bytes(12).unpack(\"H*\")[0]\n fields[:internal_id] = collection.insert(fields)\n end\n Server.new_instance self, fields\n end",
"def create_team(opts)\n HelloSign::Resource::Team.new post('/team/create', :body => opts)\n end",
"def create\n authenticate_user!\n @server = Server.new(params[:server])\n\n respond_to do |format|\n if @server.save\n format.html { redirect_to @server, notice: 'Server was successfully created.' }\n format.json { render json: @server, status: :created, location: @server }\n else\n format.html { render action: \"new\" }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n deploy\n end"
] | [
"0.83683974",
"0.6795294",
"0.6512631",
"0.65120524",
"0.6255154",
"0.6223555",
"0.6218063",
"0.6204458",
"0.61825794",
"0.61438614",
"0.60822433",
"0.6000227",
"0.599413",
"0.59688234",
"0.59676874",
"0.5899694",
"0.58654946",
"0.5799056",
"0.57472765",
"0.5745482",
"0.56975704",
"0.5693425",
"0.56684804",
"0.5659372",
"0.56257993",
"0.5607886",
"0.5580496",
"0.55057627",
"0.54450953",
"0.54392785",
"0.5366243",
"0.53481984",
"0.5347881",
"0.53085625",
"0.5287537",
"0.5263076",
"0.5251646",
"0.52270794",
"0.52248204",
"0.5188575",
"0.51864535",
"0.5184864",
"0.51843995",
"0.5180383",
"0.516252",
"0.5158533",
"0.5157563",
"0.5152587",
"0.5146611",
"0.51277477",
"0.5110318",
"0.5103002",
"0.507815",
"0.50771475",
"0.50478554",
"0.50413966",
"0.5036316",
"0.5030851",
"0.5009222",
"0.5002508",
"0.4990067",
"0.49871945",
"0.49864644",
"0.49829656",
"0.49700236",
"0.49599874",
"0.4958879",
"0.49557203",
"0.49472234",
"0.49406675",
"0.49301246",
"0.49301246",
"0.49123293",
"0.49012592",
"0.4891597",
"0.48876712",
"0.48868755",
"0.48684308",
"0.48667762",
"0.48484173",
"0.48438394",
"0.48434693",
"0.48426414",
"0.48383772",
"0.48373225",
"0.48250884",
"0.4820062",
"0.48187375",
"0.48179954",
"0.48171204",
"0.48110133",
"0.48051977",
"0.4803332",
"0.47953844",
"0.47932786",
"0.47749388",
"0.47690523",
"0.4765783",
"0.47654516",
"0.47541872"
] | 0.84140956 | 0 |
Creates a new application to do OAuth authorization with. This allows you to use OAuth to authorize users using Discord. For information how to use this, see the docs: | def create_oauth_application(name, redirect_uris)
response = JSON.parse(API.create_oauth_application(@token, name, redirect_uris))
[response['id'], response['secret']]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_oauth_application(token, name, redirect_uris)\n request(\n __method__,\n :post,\n \"#{api_base}/oauth2/applications\",\n { name: name, redirect_uris: redirect_uris }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def create_oauth_application(token, name, redirect_uris)\n request(\n __method__,\n :post,\n \"#{api_base}/oauth2/applications\",\n { name: name, redirect_uris: redirect_uris }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def create\n authorize @application, policy_class: Oauth::ApplicationPolicy\n @application = Doorkeeper::Application.new(application_params)\n @application.owner = current_user if T.unsafe(Doorkeeper).configuration.confirm_application_owner?\n if @application.save\n flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])\n redirect_to oauth_application_url(@application)\n else\n render :new\n end\n end",
"def bot_application\n return unless @type == :bot\n\n response = API.oauth_application(token)\n Application.new(JSON.parse(response), self)\n end",
"def create_app(name, redirect_uri, scopes = 'read', website = nil)\n perform_request_with_object(:post, '/api/v1/apps',\n {\n client_name: name,\n redirect_uris: redirect_uri,\n scopes: scopes,\n website: website\n }, Mastodon::App)\n end",
"def create\n @application = Doorkeeper::Application.new(application_params)\n @application.uid = SecureRandom.hex(4)\n @application.owner = current_user if Doorkeeper.configuration.confirm_application_owner?\n\n if @application.save\n flash[:notice] = I18n.t(:notice, scope: %i[doorkeeper flash applications create])\n redirect_to oauth_application_url(@application)\n else\n render :new\n end\n end",
"def create\n @application = Doorkeeper::Application.new(application_params)\n @application.owner = current_user if Doorkeeper.configuration.confirm_application_owner?\n if @application.save\n flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])\n respond_with( :oauth, @application, location: oauth_application_url( @application ) )\n else\n render :new\n end\n end",
"def new_client_application\n OAuth2::Client.new(caller_service.client_id, caller_service.client_secret, :site => authorizator_service.site, :raise_errors => false)\n end",
"def create\n @application = Doorkeeper::Application.new(application_params)\n @application.uid = SecureRandom.hex(4)\n @application.owner = current_user if Doorkeeper.configuration.confirm_application_owner?\n\n if @application.save\n flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])\n redirect_to oauth_application_url(@application)\n else\n render :new\n end\n end",
"def create_for_app(app_auth_request = nil)\n build_request(app_auth_request || { api_key: @api_key, client_secret: @secret },\n Requests::AuthenticateApp).\n send_to_api(:post, endpoint_path)\n end",
"def add_client_app\n @client = Strava::OAuth::Client.new(\n client_id: ENV['STRAVA_CLIENT_ID'],\n client_secret: ENV['STRAVA_CLIENT_SECRET']\n )\n end",
"def create_app()\n app = OpenShift::TestApplication.new(self)\n\n $logger.info(\"Created new application #{app.name} for account #{@name}\")\n\n @apps << app\n app\n end",
"def create\n name = shift_argument\n url = shift_argument\n\n unless name && url\n raise(Heroku::Command::CommandFailed, \"Usage: clients:register [NAME] [CALLBACK_URL]\")\n end\n\n validate!(url)\n client = request do\n api.request(\n :body => encode_json(\n { :name => name, :redirect_uri => url }),\n :expects => 201,\n :headers => headers,\n :method => :post,\n :path => \"/oauth/clients\"\n ).body\n end\n\n if options[:shell]\n puts \"HEROKU_OAUTH_ID=#{client[\"id\"]}\"\n puts \"HEROKU_OAUTH_SECRET=#{client[\"secret\"]}\"\n else\n styled_header(%{Registered client \"#{name}\".})\n styled_hash(client)\n end\n end",
"def create\n # find or create an auth_grant for a given user\n application = Opro::Oauth::ClientApp.find_by_client_id(params[:client_id])\n auth_grant = Opro::Oauth::AuthGrant.find_or_create_by_user_app(current_user, application)\n\n # add permission changes if there are any\n auth_grant.update_permissions(params[:permissions])\n redirect_to auth_grant.redirect_uri_for(params[:redirect_uri], params[:state])\n end",
"def set_oauth_application\n @oauth_application = Doorkeeper::Application.find(params[:oauth_application_id])\n end",
"def authorize_application\n # init auth state and oauth url..enter wormhole\n oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, GIFT_AUTH_CALLBACK)\n encoded_auth_state = create_auth_state\n oauth_url = create_oauth_url(oauth.oauth_callback_url, encoded_auth_state)\n redirect_to(:action => \"exit_portal\", :url => oauth_url) and return\n end",
"def oauth(options = {})\n @oauth ||= ApiFactory.new 'Authorizations', options\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n credentials = authorizer.get_credentials('default')\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n\n server = WEBrick::HTTPServer.new(Port: 3000)\n server.mount_proc('/oauth2callback') do |req, res|\n code = req.query['code']\n credentials = authorizer.get_and_store_credentials_from_code(user_id: 'default', code: code, base_url: OOB_URI)\n res.body = 'Authorization successful. You can close this window and return to the terminal.'\n server.shutdown\n end\n\n warn('Open the following URL in your browser and authorize the app:')\n warn(url)\n server.start\n end\n credentials\nend",
"def seed_api_key\n\t\t\tDoorkeeper::Application.create(name: \"sample app\", \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t uid: \"836ec399a145ffafbd7774c57e06960397b77a53bb1ccc03d4e45d95d0c31a3d\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t secret: \"cf8dc84d17c69e17a8b9d74ec971bdb636f231d3ba7d2ad2ebfca45bdc8ae3c9\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t redirect_uri: \"urn:ietf:wg:oauth:2.0:oob\")\n\t\tend",
"def new_app(opts)\n api.app_new(\n applet: opts[:applet_dxid],\n name: AppSeries.construct_dxname(user.username, opts[:name], opts[:scope]),\n title: \"#{opts[:title]} \",\n summary: \" \",\n description: \"#{opts[:readme]} \",\n version: \"r#{opts[:revision]}-#{SecureRandom.hex(3)}\",\n resources: opts[:asset_dxids],\n details: { ordered_assets: opts[:asset_dxids] },\n openSource: false,\n billTo: bill_to,\n access: opts[:internet_access] ? { network: [\"*\"] } : {},\n )[\"id\"]\n end",
"def oauth_application(token)\n request(\n __method__,\n :get,\n \"#{api_base}/oauth2/applications/@me\",\n Authorization: token\n )\n end",
"def create_authorization(opts = {})\n client = opts[:client] || create_pw_client(opts)\n\n return create_authorization_token(client, opts[:two_factor])\n end",
"def create_application(client, options)\n if options[:name].nil? or options[:description].nil?\n puts \"Missing arguments\"\n end\n \n application = client.applications.create({\n name: options[:name],\n description: options[:description]\n })\n puts \"Application created.\"\n\n #TODO: Add exception handling\nend",
"def create_google_apps\n GoogleApps.new(self).generate\n end",
"def create_application_token!(user)\n ApplicationToken.create_token(\n current_user: current_user,\n user_id: user.id,\n params: { application: \"default\" }\n )\n end",
"def create_from_oauth oauth\n create(\n email: oauth.email.downcase,\n display_name: oauth.display_name\n )\n end",
"def oauth\n Auth.new(params[:uid], params[:oauth_token], action_name)\n end",
"def create_app(name, url)\n JSON.parse((@cloudvox_api[\"/applications/create.json\"].post :call_flow => {:name => name}, :agi => {:url => url}).body)\n end",
"def create_client_from_outhAccount(scope, oob_uri, user_id, oauth_cred_file)\n #oob_uri = 'urn:ietf:wg:oauth:2.0:oob'\n #user_id = 'eyemole@gmail.com'\n client_id = Google::Auth::ClientId.from_file(oauth_cred_file)\n token_store = Google::Auth::Stores::FileTokenStore.new(:file => 'tokens.yaml')\n authorizer = Google::Auth::UserAuthorizer.new(client_id, scope, token_store)\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: oob_uri )\n #Launchy.open(url)\n puts \"Open this URL in Browser and enter the code you got from browser below\"\n puts \"URL: #{url}\"\n print \"enter the code you got from browser here and press Enter: \"\n # code = gets\n code = STDIN.gets.chomp\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: oob_uri)\n end\n blogger = Google::Apis::BloggerV3::BloggerService.new\n blogger.authorization = credentials\n return blogger\nend",
"def add\n usage \"jiveapps oauth:add <servicename> <key> <secret>\"\n catch_args :servicename, :key, :secret\n\n display \"=== Registering a new OAuth Service: \\\"#{@servicename}\\\"\"\n response = jiveapps.add_oauth_service(app, @servicename, @key, @secret)\n list\n end",
"def create\n manifest = JSON.parse(params[:manifest])\n manifest['provider'] = params[:provider]\n puts \"Repository type: #{params[:repository_type]}\"\n @client.app_create(params[:id], params[:repository_type])\n @client.app_add_manifest(params[:id], manifest)\n\n respond_to do |format|\n format.html { redirect_to app_path(params[:id]), notice: 'App was successfully created.' }\n #if @client.app_create(params[:id], manifest)\n # format.html { redirect_to app_path(params[:id]), notice: 'App was successfully created.' }\n # # FIXME format.json { render json: @app, status: :created, location: app_path(params[:id]) } \n #else\n # format.html { render action: \"new\" }\n # format.json { render json: @app.errors, status: :unprocessable_entity } # FIXME\n #end\n end\n end",
"def setupApp(pia_url, app_key, app_secret)\n token = getToken(pia_url, app_key, app_secret)\n { \"url\" => pia_url,\n \"app_key\" => app_key,\n \"app_secret\" => app_secret,\n \"token\" => token }\nend",
"def as_app(key = client_id, secret = client_secret, &block)\n if key.to_s.empty? || secret.to_s.empty?\n raise ApplicationCredentialsRequired, \"client_id and client_secret required\"\n end\n app_client = self.dup\n app_client.client_id = app_client.client_secret = nil\n app_client.login = key\n app_client.password = secret\n\n yield app_client if block_given?\n end",
"def create\n\t\t@application = Application.new(params[:application])\n\n\t\tif @application.save\n\t\t\tflash[:developer] = \"Yay! Your application has been registered!\"\n\t\t\tcurrent_developer.applications << @application\n\t\t\t# Randomizer as in http://goo.gl/qpI5Rv\n\t\t\taccess_token = Array.new(32){rand(36).to_s(36)}.join\n\t\t\tkey = ApiKey.create(:access_token => access_token)\n\t\t\tkey.application = @application\n\t\t\tkey.save\n\t\t\tredirect_to developer_home_path\n\t\telse\n\t\t\trender :action => 'register'\n\t\tend\n\tend",
"def create\n if not view_context.can_apply?\n flash[:error] = 'You are not allowed to create new applications. If you have already applied to the guild, you can find a link to your application on your profile page.'\n redirect_to root_path\n return\n end\n\n respond_to do |format|\n if @application.save\n format.html { redirect_to @application, notice: 'Application was successfully created.' }\n format.json { render action: 'show', status: :created, location: @application }\n else\n format.html { render action: 'new' }\n format.json { render json: @application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n id = \"aspace-oauth-#{auth_hash[:provider]}-#{SecureRandom.uuid}\"\n id_path = File.join(Dir.tmpdir, id)\n puts \"Received callback for: #{id}\"\n backend_session = nil\n\n email = get_email auth_hash\n if email\n # ensure this is set regardless of how, required by the backend\n auth_hash[:info][:email] ||= email\n File.open(id_path, 'w') { |f| f.write(JSON.generate(auth_hash)) }\n\n # usernames cannot be email addresses\n username = email.split('@')[0]\n backend_session = User.login(username, id)\n end\n\n if backend_session\n User.establish_session(self, backend_session, username)\n load_repository_list\n else\n flash[:error] = \"Authentication error, unable to login.\"\n end\n\n File.delete id_path if File.exists? id_path\n redirect_to :controller => :welcome, :action => :index\n end",
"def get_access_token_as_app(app_id, app_token)\n response = @oauth_connection.post do |req|\n req.url '/oauth/token', :grant_type => 'app', :client_id => api_key, :client_secret => api_secret, :app_id => app_id, :app_token => app_token\n end\n\n @oauth_token = OAuthToken.new(response.body)\n configure_oauth\n @oauth_token\n end",
"def create_client(oauth)\n\t\t@client = Twitter::REST::Client.new(\n\t\t\tconsumer_key: oauth[\"consumer_key\"],\n\t\t\tconsumer_secret: oauth[\"consumer_secret\"],\n\t\t\taccess_token: oauth[\"access_token\"],\n\t\t\taccess_token_secret: oauth[\"access_token_secret\"]\n\t\t\t)\n\tend",
"def create\n @app = App.new app_params\n @app.user = current_user\n \n if @app.valid?\n\n openid_client = Services::OpenIdConnectionService.new(@app).register\n\n\n if openid_client[\"client_id\"].present?\n @app.openid_client_id = openid_client[\"client_id\"]\n @app.openid_client_secret = openid_client[\"client_secret\"]\n @app.openid_client_access_token = openid_client[\"registration_access_token\"]\n @app.save\n end\n end\n\n respond_to do |format|\n if @app.persisted?\n format.html { redirect_to app_path(@app), notice: 'App was successfully created.' }\n format.json { render :show, status: :created, location: @app }\n else\n format.html { render :new }\n format.json { render json: @app.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(optional_params = {})\n response = Network.post(['Applications'], optional_params)\n Application.new(response)\n end",
"def create\n begin\n req = EvernoteAPI::Request.new(new_evernote_path(:only_path => false),\n session[:request_token])\n # Now verify with Yammer and get the final access token for user\n @result = \"Congratulations - access to Evernote is now set up!\"\n begin\n access_token = req.verify(params[:oauth_verifier])\n # save in db for next time\n current_user.evernote = access_token.token, access_token.secret\n if current_user.evernote\n redirect_to :show\n else\n @result = \"login or database error - Evernote setup failed.\"\n end\n rescue\n @result = \"Evernote authorization failed!\"\n end\n rescue\n flash[:error] = $!\n @result = \"We're sorry but something went wrong.\"\n end\n render \"oauth/show\"\n end",
"def create\n authorize! :create, @app\n @app = App.new(app_params)\n\n respond_to do |format|\n if @app.save\n format.html { redirect_to @app, notice: 'App was successfully created.' }\n format.json { render :show, status: :created, location: @app }\n else\n format.html { render :new }\n format.json { render json: @app.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_app(opts)\n app = nil\n scope = select_scope(opts[:scope])\n\n assets = Asset.accessible_by_user(user).\n where(\n state: Asset::STATE_CLOSED,\n uid: opts[:ordered_assets],\n )\n\n App.transaction do\n app_series = create_app_series(opts[:name], scope)\n release = opts.fetch(:release, UBUNTU_16)\n revision = app_series.latest_revision_app.try(:revision).to_i + 1\n\n applet_dxid = new_applet(\n opts.slice(\n :input_spec,\n :output_spec,\n :code,\n :instance_type,\n :packages,\n :internet_access,\n ),\n release,\n )\n\n app_dxid = new_app(\n opts.slice(\n :name,\n :title,\n :internet_access,\n :readme,\n ).merge(\n applet_dxid: applet_dxid,\n asset_dxids: assets.map(&:dxid),\n revision: revision,\n scope: scope,\n ),\n )\n\n api.project_remove_objects(project, [applet_dxid])\n\n app = App.create!(\n dxid: app_dxid,\n version: nil,\n revision: revision,\n title: opts[:title],\n readme: opts[:readme],\n entity_type: opts[:entity_type] || App::TYPE_REGULAR,\n user: user,\n scope: scope,\n app_series: app_series,\n input_spec: opts[:input_spec],\n output_spec: opts[:output_spec],\n internet_access: opts[:internet_access],\n instance_type: opts[:instance_type],\n ordered_assets: opts[:ordered_assets],\n packages: opts[:packages],\n code: opts[:code].strip,\n assets: assets,\n release: release,\n )\n\n app_series.update!(latest_revision_app: app)\n app_series.update!(latest_version_app: app) if Space.valid_scope?(scope)\n app_series.update!(deleted: false) if app_series.deleted?\n\n Event::AppCreated.create_for(app, user)\n end\n\n app\n end",
"def create\n pw = \"aspace-oauth-#{auth_hash[:provider]}-#{SecureRandom.uuid}\"\n pw_path = File.join(Dir.tmpdir, pw)\n backend_session = nil\n\n uid = auth_hash.uid\n email = AspaceOauth.get_email(auth_hash)\n username = AspaceOauth.use_uid? ? uid : email\n puts \"Received callback for: [uid: #{uid}], [email: #{email}]\"\n if username && email\n username = username.split('@')[0] # usernames cannot be email addresses\n auth_hash[:info][:username] = username # set username, checked in backend\n auth_hash[:info][:email] = email # ensure email is set in info\n File.open(pw_path, 'w') { |f| f.write(JSON.generate(auth_hash)) }\n backend_session = User.login(username, pw)\n end\n\n if backend_session\n User.establish_session(self, backend_session, username)\n load_repository_list\n else\n flash[:error] = 'Authentication error, unable to login.'\n end\n\n File.delete pw_path if File.exist? pw_path\n redirect_to controller: :welcome, action: :index\n end",
"def client\n ::DelegatedAuthentication.new(options[:app_id], options[:app_secret], nil, nil, options[:privacy_url], callback_url)\n end",
"def create_app app_name, dev_name, dev_email\n data[:app_name] = app_name\n data[:dev_name] = dev_name\n data[:dev_email] = dev_email\n end",
"def new_session\n\n @session = DropboxSession.new(@APP_KEY, @APP_SECRET)\n\n #OAuth flow\n\n #step 1: get a request token\n @session.get_request_token\n\n #step 2: ask user to authorize linking app to Dropbox account\n authorize_url = @session.get_authorize_url(\"https://www.dropbox.com/home/Apps/Notational Data CL\")\n\n #make the user sign in and authorize this token\n puts \"AUTHORIZING\", authorize_url\n `open #{authorize_url}` #backticks indicate a bash command. see http://ruby-doc.org/core-2.0/Kernel.html#method-i-__method__\n puts \"Please visit this website and press the 'Allow' button, then hit 'Enter' here.\" #refactor this step into UI layer? perhaps a notify message?\n gets\n\n #step 3: once authorized, exchange the request token for an access token, which will be used for calling Core API\n #this will fail if the user didn't visit the above url and hit 'Allow'\n access_token = @session.get_access_token #shouldn't need to get access token again unless reinstall app or revoke access from Dropbox website\n\n ProcessLayer.store_session(@session.serialize)\n\n end",
"def new\n puts \"Creating new blank Praxis app under #{app_name}\"\n create_root_files\n create_config\n create_app\n create_design\n create_spec\n create_docs\n end",
"def create\n @app = current_user.apps.new(params[:app])\n\n respond_to do |format|\n if @app.save\n format.html { redirect_to @app, :notice => \"The application app was successfully created\" }\n format.xml { render :xml => @app, :status => :created, :location => @app }\n else\n format.html { render :action => :new }\n format.xml { render :xml => @app.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def oauth_app_access_token(client_id, client_secret)\n self.oauth_access_token(client_id, client_secret, :type => 'client_cred')\n end",
"def init_application(application_name)\n if application_name.nil? || application_name == ''\n throw 'Bad application name'\n end\n res = nil\n applicaiton_init_uri = URI(@url + \"sys/auth/#{application_name}\")\n req = Net::HTTP::Post.new(applicaiton_init_uri)\n req['X-Vault-Token'] = @token\n res = Net::HTTP.start(applicaiton_init_uri.hostname, applicaiton_init_uri.port) do |http|\n req.body = { 'type' => 'app-id' }.to_json\n http.request(req)\n end\n res.code.to_i\n end",
"def new\n if pre_authorizable?\n if user_has_signin_permission_to_application?\n auth = authorize_response\n redirect_to auth.redirect_uri, allow_other_host: true\n else\n session[:signin_missing_for_application] = application.try(:id)\n redirect_to signin_required_path\n end\n else\n render :error\n end\n end",
"def initialize(app_id, secret)\n options = {\n site: Parameter::SITE,\n authorize_url: AUTHORIZE_URL,\n token_url: TOKEN_URL\n }\n\n raise 'アプリケーションIDが入力されていません' if app_id.empty?\n raise 'Secretが入力されていません' if secret.empty?\n @client = OAuth2::Client.new(app_id, secret, options)\n end",
"def execute(request)\n Doorkeeper::Application.create(params)\n end",
"def create_client(oauth)\n\t\t@client = Twitter::Client.new(\n\t\t\t consumer_key: oauth[\"consumer_key\"],\n\t\t\t consumer_secret: oauth[\"consumer_secret\"],\n\t\t\t oauth_token: oauth[\"oauth_token\"],\n\t\t\t oauth_token_secret: oauth[\"oauth_token_secret\"]\n\t\t)\n\tend",
"def create_new_app\n rake 'install --trace'\n FileUtils.rm_rf(rails_app)\n sh \"relevance_rails new #{rails_app} --database=#{database} --relevance-dev\"\n end",
"def oauth\n request_token = @oauth_consumer.get_request_token\n authorize_url = request_token.authorize_url(:oauth_consumer_key => \n Netflix::Client.consumer_key)\n Launchy.open(authorize_url)\n puts \"Go to browser, a page has been opened to establish oauth\"\n printf \"Pin from Netflix:\"\n pin = gets.chomp\n access_token = request_token.get_access_token(:oauth_verifier => pin)\n end",
"def new\n next_url = AppConfig.facebook_app_url + \"facebook/callback\"\n #next_url += (\"?request_ids=\" + params[:request_ids]) unless params[:request_ids].nil?\n @auth_url = Authentication.auth.client.web_server.authorize_url(\n :redirect_uri => next_url, :scope => AppConfig.facebook_perms\n )\n end",
"def authenticate_app\n payload = {\n # The time that this JWT was issued, _i.e._ now.\n iat: Time.now.to_i,\n\n # JWT expiration time (10 minute maximum)\n exp: Time.now.to_i + (10 * 60),\n\n # Your GitHub App's identifier number\n iss: APP_IDENTIFIER\n }\n logger.debug \"JWT payload: #{payload}\"\n\n # Cryptographically sign the JWT.\n jwt = JWT.encode(payload, PRIVATE_KEY, 'RS256')\n\n # Create the Octokit client, using the JWT as the auth token.\n @app_client ||= Octokit::Client.new(bearer_token: jwt)\n end",
"def create\n user = validate_user_token\n current_account = find_or_create_parti_account user\n endpoint = AuthorizationEndpoint.new current_account\n rack_response = endpoint.call request.env\n respond_as_rack_app(*rack_response)\n end",
"def applicazioni_oauth2\n #creo jwt\n hash_jwt_app = {\n 'iss' => 'soluzionipa.it',\n 'start' => DateTime.now.new_offset(0).strftime(\"%d%m%Y%H%M%S\") #datetime in formato utc all'invio\n }\n jwt_token = JsonWebToken.encode(hash_jwt_app)\n redirect_to \"#{Settings.app_oauth2_url}/oauth/applications?jwt=#{jwt_token}\"\n end",
"def generate_token(id, optional_params = {})\n response = Network.post(['Applications', id, 'GenerateToken'], optional_params)\n Application.new(response)\n end",
"def create_consumer(username, email, password)\n add_consumer(username, email, password)\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIAL))\n file_store = Google::APIClient::FileStore.new(CREDENTIAL)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(CLIENT_SECRET)\n flow = Google::APIClient::InstalledAppFlow.new({\n :client_id => app_info.client_id,\n :client_secret => app_info.client_secret,\n :scope => SCOPE})\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{CREDENTIAL}\" unless auth.nil?\n end\n auth\n end",
"def create\n @application = Oread::Application.new(application_params)\n @application.owner = current_user\n respond_to do |format|\n if @application.save\n format.html { redirect_to settings_admin_oread_applications_path, notice: 'Application was successfully created.' }\n format.json { render :show, status: :created, location: @application }\n else\n format.html { render :new }\n format.json { render json: @application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new(app_path, generator: Project.new(cli: self, app_path: app_path))\n app = generator.generate\n say <<~SAY\n\n Success! Created #{app.camelized_name} at #{app.absolute_app_path}\n Inside that directory, you can run several commands:\n\n #{cmd :server}\n Starts the development server\n\n #{cmd :test}\n Starts the test runner\n\n #{cmd :generate}\n Add elements you may have skipped, like RSpec or Webpack\n\n We suggest that you begin by typing:\n\n #{cmd :cd, path: app_path}#{cmd :server}\n\n and visiting localhost:3000 in your browser.\n For more information, check out the generated readme file.\n\n SAY\n end",
"def set_application\n @application = current_user.oauth_applications.find(params[:id])\n end",
"def new_client(id, env, private_key, secret)\n app_config = AppConfig.new(\n id: id,\n env: env,\n private_key: private_key,\n secret: secret\n )\n\n Client.new(config: app_config)\n end",
"def create(cli = false)\n $logger.info(\"Creating new gear #{@uuid} for application #{@app.name}\")\n\n if cli\n command = %Q(oo-devel-node app-create -c #{uuid} -a #{@app.uuid} --with-namespace #{@app.account.domain} --with-app-name #{@app.name} --with-secret-token=DEADBEEFDEADBEEFDEADBEEFDEADBEEF)\n $logger.info(%Q(Running #{command}))\n results = %x[#{command}]\n assert_equal(0, $?.exitstatus, %Q(#{command}\\n #{results}))\n end\n\n # Create the container object for use in the event listener later\n begin\n @container = OpenShift::Runtime::ApplicationContainer.new(@app.uuid, @uuid, nil, @app.name, @app.name, @app.account.domain, nil, nil)\n rescue Exception => e\n $logger.error(\"#{e.message}\\n#{e.backtrace}\")\n raise\n end\n\n unless cli\n @container.create('DEADBEEFDEADBEEFDEADBEEFDEADBEEF')\n end\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n file_store = Google::APIClient::FileStore.new(CREDENTIALS_PATH)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(CLIENT_SECRETS_PATH)\n flow = Google::APIClient::InstalledAppFlow.new({\n :client_id => app_info.client_id,\n :client_secret => app_info.client_secret,\n :scope => SCOPE})\n auth = flow.authorize(storage)\n end\n auth\nend",
"def request_access_token\n # An `OAuth::Consumer` object can make requests to the service on\n # behalf of the client application.\n\n # Ask service for a URL to send the user to so that they may authorize\n # us.\n request_token = CONSUMER.get_request_token\n authorize_url = request_token.authorize_url\n\n # Launchy is a gem that opens a browser tab for us\n Launchy.open(authorize_url)\n\n # Because we don't use a redirect URL; user will receive a short PIN\n # (called a **verifier**) that they can input into the client\n # application. The client asks the service to give them a permanent\n # access token to use.\n puts \"Login, and type your verification code in\"\n oauth_verifier = gets.chomp\n access_token = request_token.get_access_token(\n :oauth_verifier => oauth_verifier\n )\nend",
"def oauth_client\n @oauth_client ||= OAuth2::Client.new @app_key, @app_secret, site: @workxp_site do |stack|\n stack.request :multipart\n stack.request :url_encoded\n stack.adapter :net_http\n end\n end",
"def authorized_twitter\n oauth = Twitter::OAuth.new($configure[:twitter][:ctoken], $configure[:twitter][:csecret])\n # Request OAuth authentication if there are no access token yet\n unless($configure[:twitter][:atoken] && $configure[:twitter][:asecret])\n rtoken = oauth.request_token\n puts \"Open next url, authorize this application: #{rtoken.authorize_url}\"\n puts \"Then, enter PIN code:\"\n pin = STDIN.gets.chomp\n # Authrize request token using PIN code (this is required for an application which type is \"Client\")\n atoken = OAuth::RequestToken.new(oauth.consumer, rtoken.token, rtoken.secret).get_access_token(:oauth_verifier => pin)\n # Save access token\n $configure[:twitter][:atoken] = atoken.token\n $configure[:twitter][:asecret] = atoken.secret\n end\n oauth.authorize_from_access($configure[:twitter][:atoken], $configure[:twitter][:asecret])\n # Create Twitter client instance with OAuth\n Twitter::Base.new(oauth)\nend",
"def auth_client(client_id, client_secret, params = {})\n RubyLokaliseApi::OAuth2::Auth.new client_id, client_secret, params\n end",
"def get_api_key\n \n green \"****************************************\"\n green \"****************************************\"\n green \"**** API SETUP TIME! ****\"\n green \"****************************************\"\n green \"****************************************\" \n\n\n puts \"\\n\\nWelcome to Chatterbot. Let's walk through the steps to get a bot running.\\n\\n\"\n\n\n #\n # At this point, we don't have any API credentials at all for\n # this bot, but it's possible the user has already setup an app.\n # Let's ask!\n #\n \n puts \"Hey, looks like you need to get an API key from Twitter before you can get started.\\n\\n\"\n \n app_already_exists = ask_yes_no(\"Have you already set up an app with Twitter?\")\n\n if app_already_exists\n puts \"Terrific! Let's get your bot running!\\n\\n\"\n else\n puts \"OK, I can help with that!\\n\\n\"\n send_to_app_creation\n end\n\n \n print \"\\n\\nPaste the 'Consumer Key' here: \"\n STDOUT.flush\n config[:consumer_key] = STDIN.readline.chomp.strip\n\n print \"Paste the 'Consumer Secret' here: \"\n STDOUT.flush\n config[:consumer_secret] = STDIN.readline.chomp.strip\n\n\n puts \"\\n\\nNow it's time to authorize your bot!\\n\\n\"\n \n if ! app_already_exists && ask_yes_no(\"Do you want to authorize a bot using the account that created the app?\")\n puts \"OK, on the app page, you can click the 'Create my access token' button to proceed.\\n\\n\"\n\n print \"Paste the 'Access Token' here: \"\n STDOUT.flush\n config[:access_token] = STDIN.readline.chomp.strip\n\n\n print \"\\n\\nPaste the 'Access Token Secret' here: \"\n STDOUT.flush\n config[:access_token_secret] = STDIN.readline.chomp.strip\n\n \n # reset the client so we can re-init with new OAuth credentials\n reset_client\n\n # at this point we should have a fully validated client, so grab\n # the screen name\n @screen_name = client.user.screen_name rescue nil\n else\n reset_client\n end\n \n \n #\n # capture ctrl-c and exit without a stack trace\n #\n rescue Interrupt => e\n exit\n end",
"def get_web_auth()\n\treturn DropboxOAuth2Flow.new(APP_KEY, APP_SECRET, url('/OAuth-finish'),\n\t\t\t\t\t\t\t\t session, :dropbox_auth_csrf_token)\nend",
"def app\n BatchConnect::App.from_token(self.token)\n end",
"def create_2f_authorization(client)\n two_factor = Configuration.ask_for_two_factor\n\n create_authorization_token(client, two_factor)\n end",
"def add_oauth(req, consumer, atok, asec)\r\n access_token = OAuth::AccessToken.new(consumer, atok, asec)\r\n consumer.sign!(req, access_token)\r\nend",
"def application!\n res = get!(APPLICATION_PATH)\n build_application(res)\n end",
"def create\n # TODO:\n # * guard based on \"state\" param:\n # if `session['omniauth.state]`, `params[:state]` must match.\n\n authorization = Corkboard::Authorization.create!(auth_attrs)\n subscription = Corkboard::Subscription.create!(provider, authorization)\n\n Corkboard.publish!(subscription.backlog)\n redirect_to(authorizations_path)\n end",
"def generate\n @app = Class.new(Rails::Application) {\n config.eager_load = false\n config.session_store :cookie_store, key: \"_myapp_session\"\n config.active_support.deprecation = :log\n config.root = File.dirname(__FILE__)\n config.log_level = :info\n # Set a fake logger to avoid creating the log directory automatically\n fake_logger = Logger.new(nil)\n config.logger = fake_logger\n Rails.application.routes.default_url_options = {host: \"example.com\"}\n }\n @app.respond_to?(:secrets) && @app.secrets.secret_key_base = \"3b7cd727ee24e8444053437c36cc66c4\"\n\n yield @app if block_given?\n @app.initialize!\n end",
"def create\n megam_rest.post_appreq(to_hash)\n end",
"def authorize\n client_id = create_client_id\n token_store = create_token_store\n\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI\n )\n Rails.logger.debug do\n 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization'\n end\n Rails.logger.debug url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id:, code:, base_url: OOB_URI\n )\n end\n credentials\n end",
"def initialize(app_id, app_secret)\n @app_id = app_id\n @app_secret = app_secret\n end",
"def new\n \n fb_auth = FbGraph::Auth.new('155275974530339', '309d340d359061c890906926e8139e4a')\n fb_auth.client # => Rack::OAuth2::Client\n \n client = fb_auth.client\n client.redirect_uri = \"http://localhost:3000/config_keys\"\n\n # redirect user to facebook\n redirect_to client.authorization_uri(\n :scope => [:email, :read_stream, :offline_access]\n )\n\n # in callback\n client.authorization_code = params[:code]\n access_token = client.access_token! # => Rack::OAuth2::AccessToken\n FbGraph::User.me(access_token).fetch # => FbGraph::User\n \n end",
"def use_oauth\n\t\t\t\n\t\tend",
"def create_from_oauth\n if stored_anonymous_user?\n user, from_registration = update_from_omniauth(env[\"omniauth.auth\"], params[:provider])\n else\n user, from_registration = create_from_omniauth(env[\"omniauth.auth\"], params[:provider])\n end\n\n if user.errors.any?\n redirect_to_registration_page(user)\n else\n change_global_user_id(user.id)\n sign_in(user)\n fandom_play_login(user)\n \n if from_registration\n log_data = { 'form_data' => env[\"omniauth.auth\"], 'user_id' => current_user.id }\n log_synced(\"registration from oauth\", adjust_user_and_log_data_with_utm(user, log_data))\n\n set_account_up()\n cookies[:from_registration] = true \n end\n\n if $site.force_facebook_tab && !request_is_from_mobile_device?(request)\n redirect_to request.site.force_facebook_tab\n else\n redirect_after_oauth_successful_login()\n end\n end\n end",
"def initialize(app_id, app_secret, api_key, email, password)\n\n merge!(\n {\n applicationCredentials: {\n applicationId: app_id,\n applicationSecret: app_secret\n },\n userCredentials: {\n apiKey: api_key,\n email: email,\n password: password \n }\n }\n )\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n \n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\n end",
"def create\n params[:app][:user_id] = current_user.id\n @app = App.create(params[:app])\n if @app.save\n redirect_to source_app_path(@app), notice: 'app was successfully created.'\n else\n render :new\n end\n end",
"def get_new_access_token\n client, auth = google_api_client_auth\n print(\"1. Open this page:\\n%s\\n\\n\" % auth.authorization_uri)\n print(\"2. Enter the authorization code shown in the page: \")\n system( 'open \"'+auth.authorization_uri+'\"' )\n auth.code = $stdin.gets.chomp\n auth.fetch_access_token!\n auth.access_token\n end",
"def create\n auth = request.env[\"omniauth.auth\"]\n user = User.find_by_provider_and_uid(auth[\"provider\"], auth[\"uid\"]) || User.create_with_omniauth(auth)\n session[:user_id] = user.id\n redirect_to app_path\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def o_auth_authorization\r\n OAuthAuthorizationController.instance\r\n end",
"def create_code(client)\n Songkick::OAuth2.generate_id do |code|\n return code\n end\n end",
"def create_authorization(options={})\n post \"/authorizations\", :body => options\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend"
] | [
"0.69873273",
"0.69873273",
"0.69777524",
"0.6779362",
"0.6778442",
"0.6722473",
"0.672169",
"0.66975766",
"0.66803485",
"0.65305084",
"0.62695473",
"0.6241559",
"0.62196136",
"0.62072706",
"0.6128522",
"0.6127108",
"0.60710514",
"0.6049424",
"0.5999127",
"0.5996503",
"0.5982068",
"0.5942786",
"0.59299046",
"0.59005916",
"0.5898365",
"0.58746004",
"0.5869926",
"0.5767291",
"0.57247233",
"0.5720334",
"0.5713578",
"0.571127",
"0.570913",
"0.5704357",
"0.56737447",
"0.5665876",
"0.5629788",
"0.5625486",
"0.5623424",
"0.56134427",
"0.56131274",
"0.5608692",
"0.55990964",
"0.5581316",
"0.55787534",
"0.5557857",
"0.5554582",
"0.55513465",
"0.55508757",
"0.5550376",
"0.5546562",
"0.5526424",
"0.55172026",
"0.55007064",
"0.5497892",
"0.5476638",
"0.54637676",
"0.54560435",
"0.54497004",
"0.54464966",
"0.54442793",
"0.5436815",
"0.54349494",
"0.54303056",
"0.54149055",
"0.5411411",
"0.5400968",
"0.5400946",
"0.53999186",
"0.5390702",
"0.5388363",
"0.53774726",
"0.53762126",
"0.53758264",
"0.5375538",
"0.53703785",
"0.5368737",
"0.5345202",
"0.5340629",
"0.53325754",
"0.53232265",
"0.53209126",
"0.53189564",
"0.5318929",
"0.53112304",
"0.5308845",
"0.5307881",
"0.53038037",
"0.5302204",
"0.52944535",
"0.5291985",
"0.5291479",
"0.52828825",
"0.5281667",
"0.5278878",
"0.5274739",
"0.5274529",
"0.52709144",
"0.5267128"
] | 0.7000048 | 0 |
Changes information about your OAuth application | def update_oauth_application(name, redirect_uris, description = '', icon = nil)
API.update_oauth_application(@token, name, redirect_uris, description, icon)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_oauth_application\n @oauth_application = Doorkeeper::Application.find(params[:oauth_application_id])\n end",
"def update_tokens(oauth_params)\n# binding.pry\n self.oauth_token = oauth_params.credentials.token\n # facebook, google provide this; twitter, linkedin don't\n self.oauth_expires_at = Time.at(oauth_params.credentials.expires_at) if oauth_params.credentials.expires_at\n # twitter\n self.oauth_secret = oauth_params.credentials.secret if oauth_params.credentials.secret\n end",
"def oauth_authentication; end",
"def set_application\n @application = current_user.oauth_applications.find(params[:id])\n end",
"def oauth\n request_token = @oauth_consumer.get_request_token\n authorize_url = request_token.authorize_url(:oauth_consumer_key => \n Netflix::Client.consumer_key)\n Launchy.open(authorize_url)\n puts \"Go to browser, a page has been opened to establish oauth\"\n printf \"Pin from Netflix:\"\n pin = gets.chomp\n access_token = request_token.get_access_token(:oauth_verifier => pin)\n end",
"def update_oauth_application(token, name, redirect_uris, description = '', icon = nil)\n request(\n __method__,\n :put,\n \"#{api_base}/oauth2/applications\",\n { name: name, redirect_uris: redirect_uris, description: description, icon: icon }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def update_oauth_application(token, name, redirect_uris, description = '', icon = nil)\n request(\n __method__,\n :put,\n \"#{api_base}/oauth2/applications\",\n { name: name, redirect_uris: redirect_uris, description: description, icon: icon }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def exchange_oauth_tokens\n end",
"def use_oauth\n\t\t\t\n\t\tend",
"def update_from_omniauth(omniauth)\n extract_credentials_from_omniauth(omniauth)\n extract_info_from_omniauth(omniauth)\n end",
"def callback\n access_token = client.web_server.get_access_token(params[:code], :redirect_uri => oauth_callback_url)\n \n current_user.update_attribute(:oauth2_token, access_token.token)\n flash[:notice] = \"Authorized successfully!\"\n \n redirect_to root_url\n end",
"def update_oauth_user_credentials(oauth_data)\r\n oauth_access_token = oauth_data.credentials.token\r\n raise Totem::Authentication::Session::MissingSessionUserAccessToken, \"Blank oauth access token in oauth data. #{oauth_data.inspect}\" if oauth_access_token.blank?\r\n self.oauth_access_token = oauth_data.credentials.token\r\n if self.respond_to?(:populate_user_oauth_extra_info)\r\n extra_values = oauth_data.extra.user_info || {}\r\n self.populate_user_oauth_extra_info(extra_values)\r\n end\r\n end",
"def oauth_callback\n at = Marshal.load(session[:qb_request_token]).get_access_token(:oauth_verifier => params[:oauth_verifier])\n \n #There can only be one...\n Qbo.destroy_all\n\n # Save the authentication information \n qbo = Qbo.new\n qbo.qb_token = at.token\n qbo.qb_secret = at.secret\n qbo.token_expires_at = 6.months.from_now.utc\n qbo.reconnect_token_at = 5.months.from_now.utc\n qbo.company_id = params['realmId']\n if qbo.save!\n redirect_to qbo_sync_path, :flash => { :notice => \"Successfully connected to Quickbooks\" }\n else\n redirect_to plugin_settings_path(:redmine_qbo), :flash => { :error => \"Error\" }\n end\n end",
"def oauth_data\n {\n consumer_key: CONSUMER_KEY,\n consumer_secret: CONSUMER_SECRET,\n token: session[:token],\n token_secret: session[:secret],\n realm_id: session[:realm_id]\n }\n end",
"def set_oauth_account\n @oauth_account = OauthAccount.find(params[:id])\n end",
"def facebook\n handle_oauth\n end",
"def callback\n self.oaw_callback(params[:oauth_verifier], params[:oauth_token])\n end",
"def update_using_auth o\n\t\tself.user_id = o.info.user_id\n\t\tself.login_name = o.info.profile.login_name\n\t\tself.email = o.info.email\n\t\tself.join_tsz = o.info.profile.join_tsz\n\t\tself.transaction_buy_count = o.info.profile.transaction_buy_count\n\t\tself.transaction_sold_count = o.info.profile.transaction_sold_count\n\t\tself.is_seller = o.info.profile.is_seller\n\t\tself.location = o.info.profile.lon ? [o.info.profile.lon, o.info.profile.lat] : nil\n\t\tself.image_url = o.info.profile.image_url_75x75\n\t\tself.country_id = o.info.profile.country_id\n\t\tself.gender = o.info.profile.gender\n\t\tself.oauth_token = o.extra.access_token.token\n\t\tself.oauth_token_secret = o.extra.access_token.secret\n\t\tsave\n\t\tself\n\tend",
"def app_params\n params.require(:app).permit(:name, :platform, :openid_redirect_urls, :token_endpoint_auth_method, :openid_client_secret, :openid_client_id, :contacts, :client_uri, :policy_uri, :tos_uri, :logo_uri )\n end",
"def authorize_application\n # init auth state and oauth url..enter wormhole\n oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, GIFT_AUTH_CALLBACK)\n encoded_auth_state = create_auth_state\n oauth_url = create_oauth_url(oauth.oauth_callback_url, encoded_auth_state)\n redirect_to(:action => \"exit_portal\", :url => oauth_url) and return\n end",
"def update_omniauth(auth_hash)\n token = auth_hash['credentials']['token']\n secret = auth_hash['credentials']['secret']\n self.access_token = '%s:%s' % [token, secret]\n\n self.save(validate: false)\n end",
"def callback\n # evernote returns a verifier if user authorized the app\n oauth_verifier = params[:oauth_verifier]\n if oauth_verifier\n consumer = get_consumer\n request_token = OAuth::RequestToken.new(consumer, flash[:request_token], flash[:request_secret])\n # contains the real token, user id, shard, and token expiration date\n access_token = request_token.get_access_token(:oauth_verifier => oauth_verifier)\n account = EvernoteAccount.where(\"user_id = \" + access_token.params[:edam_userId]).take\n if !account\n # save this stuff\n account = EvernoteAccount.create(\n user_id: access_token.params[:edam_userId],\n token: access_token.token,\n shard: access_token.params[:edam_shard],\n token_expiration: access_token.params[:edam_expires]\n )\n end\n session[:evernote_account_id] = account.id\n # directs to recipes page (recipe_controller.rb)\n redirect_to action: \"index\", controller: \"recipes\"\n else\n redirect_to action: \"index\"\n end\n end",
"def apply_omniauth(omni)\n self.authentications.build(:provider => omni['provider'],\n :uid => omni['uid'],\n :token => omni['credentials']['token'],\n :token_secret => omni['credentials']['secret'])\n\n self.send(\"set_#{omni['provider']}_info\", omni)\n end",
"def oauth\n puts '*'*50\n puts session[:category]\n session[:category] = nil\n session[:category] = params[:category]\n puts '*'*50\n puts session[:category]\n login_at(auth_params[:provider])\n end",
"def oauth_application(token)\n request(\n __method__,\n :get,\n \"#{api_base}/oauth2/applications/@me\",\n Authorization: token\n )\n end",
"def auth\n require 'oauth'\n say \"This will reset your current access tokens.\", :red if already_authed?\n\n # get the request token URL\n callback = OAuth::OUT_OF_BAND\n consumer = OAuth::Consumer.new $bot[:config][:consumer_key],\n $bot[:config][:consumer_secret],\n site: Twitter::REST::Client::BASE_URL,\n scheme: :header\n request_token = consumer.get_request_token(oauth_callback: callback)\n url = request_token.authorize_url(oauth_callback: callback)\n\n puts \"Open this URL in a browser: #{url}\"\n pin = ''\n until pin =~ /^\\d+$/\n print \"Enter PIN =>\"\n pin = $stdin.gets.strip\n end\n\n access_token = request_token.get_access_token(oauth_verifier: pin)\n $bot[:config][:access_token] = access_token.token\n $bot[:config][:access_token_secret] = access_token.secret\n\n # get the bot's user name (screen_name) and print it to the console\n $bot[:config][:screen_name] = get_screen_name access_token\n puts \"Hello, #{$bot[:config][:screen_name]}!\"\n end",
"def configure\n # Consumer details come from registering an app at https://dev.twitter.com/\n # Once you have consumer details, use \"ebooks auth\" for new access tokens\n self.consumer_key = 't9g6TgrUYsZ4R5aeArsM2C36G' # Your app consumer key\n self.consumer_secret = 'olto6fNhfZz0CZwtx4uaFFpoyW88KG4LZnuaMFtWkvhgWq3897' # Your app consumer secret\n\n # Users to block instead of interacting with\n self.blacklist = ['']\n\n # Range in seconds to randomize delay when bot.delay is called\n self.delay_range = 1..6\n\t\n\t@userinfo = {}\n end",
"def oauth_consumer\n @oauth_consumer\n end",
"def oauth_hash\n {\n :consumer_key => consumer_key || Bountybase.config.twitter_app[\"consumer_key\"],\n :consumer_secret => consumer_secret || Bountybase.config.twitter_app[\"consumer_secret\"],\n :oauth_token => oauth_token,\n :oauth_token_secret => oauth_secret\n }\n end",
"def omniauth(provider, *args); end",
"def oauth_callback\n if params[:state].present?\n oauth2_client = Qbo.get_client\n # use the state value to retrieve from your backend any information you need to identify the customer in your system\n redirect_uri = Setting.host_name + \"/qbo/oauth_callback/\"\n if resp = oauth2_client.auth_code.get_token(params[:code], redirect_uri: redirect_uri)\n \n # Remove the last authentication information\n Qbo.delete_all\n \n # Save the authentication information \n qbo = Qbo.new\n qbo.company_id = params[:realmId]\n \n # Generate Access Token & Serialize it into the database\n access_token = OAuth2::AccessToken.new(oauth2_client, resp.token, refresh_token: resp.refresh_token)\n qbo.token = access_token.to_hash\n qbo.expire = 1.hour.from_now.utc\n \n if qbo.save!\n redirect_to qbo_sync_path, :flash => { :notice => \"Successfully connected to Quickbooks\" }\n else\n redirect_to plugin_settings_path(:redmine_qbo), :flash => { :error => \"Error\" }\n end\n \n end\n end\n end",
"def on_new_oauth!(oauth_response)\n authentications.new(\n \"uid\" => oauth_response[\"uid\"],\n \"provider\" => oauth_response[\"provider\"]\n )\n self\n end",
"def oauth_callback(params)\n update! psp_credentials: payment_provider.get_access_token(params)\n end",
"def facebook_oauth\n # Insert your own Facebook client ID and secret here\n # auth = Koala::Facebook::OAuth.new(ENV[\"FACEBOOK_KEY\"], ENV[\"FACEBOOK_SECRET\"])\n\n @facebook_oauth = Koala::Facebook::OAuth.new(ENV[\"FACEBOOK_KEY\"], ENV[\"FACEBOOK_SECRET\"])\n\n\n\n end",
"def auth_oauth\n @attributes[:auth_oauth]\n end",
"def oauth\n {\n consumer_key: @consumer_key,\n consumer_secret: @consumer_secret,\n token: @token,\n token_secret: @token_secret\n }\n end",
"def oauth\n redirect_to \"#{root_path}auth/#{Setting['omniauth']['provider']}\"\n end",
"def oauth_version\n oauth_merged_params[:oauth_version] || \"1.0\"\n end",
"def authorized_twitter\n oauth = Twitter::OAuth.new($configure[:twitter][:ctoken], $configure[:twitter][:csecret])\n # Request OAuth authentication if there are no access token yet\n unless($configure[:twitter][:atoken] && $configure[:twitter][:asecret])\n rtoken = oauth.request_token\n puts \"Open next url, authorize this application: #{rtoken.authorize_url}\"\n puts \"Then, enter PIN code:\"\n pin = STDIN.gets.chomp\n # Authrize request token using PIN code (this is required for an application which type is \"Client\")\n atoken = OAuth::RequestToken.new(oauth.consumer, rtoken.token, rtoken.secret).get_access_token(:oauth_verifier => pin)\n # Save access token\n $configure[:twitter][:atoken] = atoken.token\n $configure[:twitter][:asecret] = atoken.secret\n end\n oauth.authorize_from_access($configure[:twitter][:atoken], $configure[:twitter][:asecret])\n # Create Twitter client instance with OAuth\n Twitter::Base.new(oauth)\nend",
"def oauth\n login_at(auth_params[:provider])\n end",
"def oauth\n login_at(auth_params[:provider])\n end",
"def callback\n @bluebutton_oauth_service = BluebuttonOauthService.new(session[:bb_acc_token],session[:bb_state])\n @bluebutton_oauth_service.set_access_token(params[:code])\n @bluebutton_oauth_service.refresh_access_token\n redirect_to bluebutton_main_path, :notice => \"you have been successfully authorized!\"\n # Save access token to session. \n session[:bb_acc_token] = @bluebutton_oauth_service.bb_acc_token\n end",
"def auth\r\n OAuth2\r\n end",
"def decide\n @meta = { title: 'Select Application', description: 'Select the application you want to login to' }\n @user_app_access_list = retrieve_user_access_list_for_app(current_user,current_app)\n end",
"def add_oauth(req, consumer, atok, asec)\r\n access_token = OAuth::AccessToken.new(consumer, atok, asec)\r\n consumer.sign!(req, access_token)\r\nend",
"def client_secret=(client_secret); end",
"def client_secret=(client_secret); end",
"def oauth_data\n {\n consumer_key: @consumer_key,\n consumer_secret: @consumer_secret,\n token: @token,\n token_secret: @token_secret\n }\n end",
"def oauth_options\n {\n consumer_key: client_id,\n consumer_secret: client_secret,\n token: access_token,\n token_secret: access_token_secret\n }\n end",
"def bind_with_oauth\n if u = User.find_by_email(params[:user][:email])\n flash[:alert] = I18n.t 'devise.oauth_services.user.email_has_been_token'\n redirect_to new_oauth_user_registration_path and return\n end \n u = build_resource permitted_params.merge(name: session[:oauth].info.name, password: SecureRandom.hex )\n\n u.bypass_humanizer = true\n if u.save\n u.apply_oauth session[:oauth]\n flash[:notice] = I18n.t 'devise.omniauth_callbacks.success', kind: (I18n.t \"devise.oauth_services.providers.#{session[:oauth].provider}\") if session[:oauth].present?\n sign_in_and_redirect @user, :event => :authentication\n else\n flash[:alert] = I18n.t 'devise.oauth_services.user.failure'\n redirect_to new_oauth_user_registration_path\n end\n end",
"def update\n respond_to do |format|\n if @oauth_account.update(oauth_account_params)\n format.html { redirect_to @oauth_account, notice: 'Oauth account was successfully updated.' }\n format.json { render :show, status: :ok, location: @oauth_account }\n else\n format.html { render :edit }\n format.json { render json: @oauth_account.errors, status: :unprocessable_entity }\n end\n end\n end",
"def oauth\n profile = OAuthProfile.from_omniauth(env['omniauth.auth'])\n # TODO check for error\n # temp_password = SecureRandom.hex\n if !profile.user\n oauth_custom_params = request.env[\"omniauth.params\"] || {}\n session[:oauth_reason] = oauth_custom_params.fetch(\"dbdesigner_action\", \"\")\n session[:profile_id] = profile.id\n redirect_to new_registration_path\n # profile.user.create({\n # username: profile.username,\n # email: profile.email,\n # password: temp_password,\n # password_confirmation: temp_password\n # })\n else\n session[:user_id] = profile.user.id\n profile.user.record_login(request: request, oauth_profile: profile)\n redirect_to designer_path\n end\n end",
"def update\n # TODO permissions\n if @app.user_id == current_user.id\n # @app.attributes = params[:app]\n @app.attributes = {'platform_ids' => []}.merge(params[:app] || {})\n # TODO Sanitize links\n # [:name, :website, :twitter, :facebook, :google_plus, :android, :itunes].each do |x|\n # @app.attributes[x] = Sanitize.clean(@app.attributes[x])\n # end\n if @app.save_update_by(current_user.id, request.remote_ip)\n flash[:notice] = \"Successfully updated.\"\n redirect_to app_path(@app)\n else\n render \"edit\"\n end\n else\n flash[:error] = \"You are not allowed to update the app.\"\n redirect_to app_path(@app)\n end\n end",
"def oauth2callback\n @g_cal_api.oauth2callback\n end",
"def callback_phase\n options.client_options[:access_token_path] = \"/oauth/qzoneoauth_access_token?oauth_vericode=#{request['oauth_vericode'] }\" if request['oauth_vericode']\n super\n end",
"def update_from_linkedin(auth, cv)\n cv['email'] = auth.info.email if auth.info.email\n cv['password'] = Devise.friendly_token[0,20] if Devise.friendly_token[0,20]\n cv['name'] = auth.info.first_name if auth.info.first_name\n cv['image'] = auth.info.picture_url if auth.info.picture_url\n cv['language_spoken'] = auth.extra.raw_info.lastName.preferredLocale.country if auth.extra.raw_info.lastName.preferredLocale.country\n cv['linkedin_auth'] = true\n end",
"def setupApp(pia_url, app_key, app_secret)\n token = getToken(pia_url, app_key, app_secret)\n { \"url\" => pia_url,\n \"app_key\" => app_key,\n \"app_secret\" => app_secret,\n \"token\" => token }\nend",
"def update!(**args)\n @auth_provider = args[:auth_provider] if args.key?(:auth_provider)\n end",
"def update!(**args)\n @app_info = args[:app_info] if args.key?(:app_info)\n end",
"def use_oauth1\r\n @auth_method = AuthMethod::OAUTH1_SIGNATURE\r\n @username = nil\r\n @password = nil\r\n @current_oauth_request = nil\r\n end",
"def update!(**args)\n @apple_sign_in_config = args[:apple_sign_in_config] if args.key?(:apple_sign_in_config)\n @client_id = args[:client_id] if args.key?(:client_id)\n @client_secret = args[:client_secret] if args.key?(:client_secret)\n @enabled = args[:enabled] if args.key?(:enabled)\n @name = args[:name] if args.key?(:name)\n end",
"def consumer\n @consumer = OAuth::Consumer.new session[:consumer_key], session[:consumer_secret], :site => MISO_SITE\nend",
"def callback\n\t\tself.twitagent.exchange_request_for_access_token( session[:request_token], session[:request_token_secret], params[:oauth_verifier] )\n\t\t\n\t\tuser_info = self.twitagent.verify_credentials\n\t\t\n\t\t#raise OauthSystem::RequestError unless user_info['id'] && user_info['screen_name'] && user_info['profile_image_url']\n\t\t\n\t\t# We have an authorized user, save the information to the database.\n\t\t@user = User.find_by_screen_name(user_info['screen_name'])\n\t\tif @user\n\t\t\t@user.token = self.twitagent.access_token.token\n\t\t\t@user.secret = self.twitagent.access_token.secret\n\t\t\t@user.profile_image_url = user_info['profile_image_url']\n\t\telse\n\t\t\t@user= User.new({ \n\t\t\t\t:twitter_id => user_info['id'],\n\t\t\t\t:screen_name => user_info['screen_name'],\n\t\t\t\t:token => self.twitagent.access_token.token,\n\t\t\t\t:secret => self.twitagent.access_token.secret,\n\t\t\t\t:profile_image_url => user_info['profile_image_url'] })\n\t\tend\n\t\tif @user.save!\n\t\t\tself.current_user = @user\n\t\telse\n\t\t\traise OauthSystem::RequestError\n\t\tend\n\t\t# Redirect to the show page\n\t\tredirect_to user_path(@user)\n\t\t\n\trescue\n\t\t# The user might have rejected this application. Or there was some other error during the request.\n\t\tRAILS_DEFAULT_LOGGER.error \"Failed to get user info via OAuth\"\n\t\tflash[:error] = \"Twitter API failure (account login)\"\n\t\tredirect_to root_url\n\tend",
"def update_with_omniauth(authentication, omniauth)\n authentication.token = omniauth['credentials']['token']\n authentication.secret = omniauth['credentials']['secret']\n\n self.update_timezone(omniauth['extra']['raw_info']['time_zone'])\n authentication.save\n\n self.nickname = omniauth['info']['nickname']\n self.name = omniauth['info']['name']\n self.save\n end",
"def add_oauth(req)\n @consumer.sign!(req, @access_token)\nend",
"def get_current_application_information\n response = request(\n :oauth2_applications_me, nil,\n :get,\n \"oauth2/applications/@me\"\n )\n Rapture::OauthApplication.from_json(response.body)\n end",
"def callback\n @request_token = session[:request_token]\n @access_token = @request_token.get_access_token\n\n session[:oauth_token] = @access_token.token\n session[:oauth_token_secret] = @access_token.secret\n\n current_user = twitter_api.account_verify_credentials\n \n session[:user_attributes] = {\n id: current_user.id,\n screen_name: current_user.screen_name,\n profile_image_url: current_user.profile_image_url,\n profile_image_url_https: current_user.profile_image_url_https\n }\n\n redirect_to :root\n end",
"def authorise\n @oauth_client = OauthClient.find(params[:id])\n\n response = @oauth_client.exchange(params[:code], request.original_url) if params[:code]\n @oauth_client.access_token = response[\"access_token\"]\n @oauth_client.refresh_token = response[\"refresh_token\"]\n @oauth_client.expires_at = response[\"expires_at\"]\n\n respond_to do |format|\n if @oauth_client.save\n format.html { redirect_to oauth_client_path(@oauth_client), notice: 'OAuth client was successfully authorised.' }\n format.json { head :no_content }\n else\n format.html { render action: \"show\", error: 'OAuth client was not successfully authorised.' }\n format.json { render json: @oauth_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save\r\n SystemConfig.set :auth, to_h, true\r\n end",
"def update_by_twitter(auth)\n self.access_token = auth['credentials']['token']\n self.secret = auth['credentials']['secret']\n self.name = auth['info']['nickname']\n self.nickname = auth['info']['nickname']\n self.image_path = auth['info']['image']\n end",
"def set_app\n @app = current_user.apps.find(params[:app_id])\n end",
"def set_oauth_service\n @oauth_service = @application.oauth_services.find(params[:id])\n end",
"def google_callback\n tokens = get_tokens(params[\"code\"])\n\n @current_user.access_token = tokens[\"access_token\"]\n @current_user.save!\n \n flash[:notice] = \"Authorized\"\n \n redirect_to :root\n end",
"def config\n Simple::OAuth2.config\n end",
"def save_omniauth_details\n authentication = @user.authentications.find_or_create_by(\n provider: auth_info.provider,\n uid: auth_info.uid\n )\n\n authentication.update_attributes!(\n email: auth_email,\n nickname: auth_nickname,\n image: auth_info.image,\n raw_info: @auth.to_json\n )\n end",
"def logged_in_to_facebook_and_app_authorized\n if ensure_application_is_installed_by_facebook_user \n # filter_parameter_logging :fb_sig_friends # commenting out for now because it fails sometimes\n end\n end",
"def prepare_info_for_facebook(oauth_info)\n { uid: oauth_info.uid.to_s,\n token: oauth_info.credentials.token,\n nickname: oauth_info.info.nickname || \"fbuser_#{uid}\",\n name: oauth_info.info.name,\n email: oauth_info.info.email }\n end",
"def grantAccess()\n\t\t\tif File.zero?('lib/data.txt') #if files doesn't exist it then gets the access_tokens\n\t\t\t\t@request_token = @consumer.get_request_token\n\t\t\t\tLaunchy.open(\"#{@request_token.authorize_url}\")\n\t\t\t\tprint \"Enter pin that the page gave you:\" \n\t\t\t\t@pin = STDIN.readline.chomp\n\t\t\t\t@access_token = @request_token.get_access_token(:oauth_verifier => @pin)\n\t\t\t\tputs @access_token.token\n\t\t\t\tFile.open('lib/data.txt','w') do |f|\n\t\t\t\t\tf.puts @access_token.token\n\t\t\t\t\tf.puts @access_token.secret\n\t\t\t\tend\n\t\t\telse #if they exist it simple reads them into token_hash\n\t\t\t\tFile.open('lib/data.txt','r') do |f|\n\t\t\t\t\t@token_hash = { :oauth_token => f.readline.chomp,\n\t\t\t\t\t\t\t\t\t\t\t :oauth_token_secret => f.readline.chomp\n\t\t\t\t\t\t\t\t\t\t \t\t}\n\t\t\t\t\tend\n\t\t\tend\n\t\tend",
"def third_party_apps\n # Displays the user's 3rd party applications profile page\n authorize ::User\n\n @identifier_schemes = IdentifierScheme.for_users.order(:name)\n @tokens = current_user.access_tokens.select { |token| token.revoked_at.nil? }\n end",
"def new_api_key\n @application = Doorkeeper::Application.find(params[:id])\n @application.secret = Doorkeeper::OAuth::Helpers::UniqueToken.generate\n @application.save\n message = I18n.t('new_api_key')\n flash[:notice] = render_to_string partial: 'applications/flash',\n locals: { message: message }\n redirect_to authorizations_path\n end",
"def new\n @verifier = params[:oauth_verifier]\n render \"oauth/new\"\n end",
"def auth_oauth_custom\n @attributes[:auth_oauth_custom]\n end",
"def auth_url\n MiniFB.oauth_url(@app_id, @redirect_to,\n :scope => 'user_about_me') # See MiniFB.scopes\n end",
"def setup(options={})\n get_application_keys unless has_application_keys?\n\n if options[:client_id]\n Datapimp.config.set \"google_client_id\", options[:client_id]\n end\n\n if options[:client_secret]\n Datapimp.config.set \"google_client_secret\", options[:client_secret]\n end\n\n if has_refresh_token?\n refresh_access_token!\n elsif respond_to?(:ask)\n Launchy.open(browser_authorization_url)\n say(\"\\n1. Open this page:\\n%s\\n\\n\" % auth_client.authorization_uri)\n consume_auth_client_code ask(\"2. Enter the authorization code shown in the page: \", String)\n end\n end",
"def oauth\n if params[:code]\n token_response = get_user_tokens(params[:code])\n signup_or_login(token_response)\n end\n\n render json: params\n end",
"def set_app\n @app = App.find_by(token: params[:token])\n end",
"def add_oauth(req)\n access_token = OAuth::AccessToken.new(@consumer,@auth[:token],@auth[:token_secret])\n @consumer.sign!(req,access_token)\n end",
"def finish_oauth\n\tRails.logger.warn 'here'\n\n @consumer = OAuth::Consumer.new('l9tUlXD0IOoGhC9HnDJBA', '9YZWGkxQJgieQ3Ta89mPE4xpXXhryEbRD9GS0WAt4',{:site=>\"http://twitter.com\" })\n @req_token = OAuth::RequestToken.new(@consumer,session[:request_token],session[:request_token_secret])\n \n # Request user access info from Twitter\n @access_token = @req_token.get_access_token\n\n # Store the OAuth info for the user\n #@user = {}\n #@user.update_attributes(:token=>@access_token.token,:token_secret=>@access_token.secret)\n Rails.logger.warn \"Second Request #{@access_token.params['user_id']}\"\n # Send the user on their way\n session[:tokens] ={:token=>@access_token.token, :token_secret=>@access_token.secret}\n session[:id] = @access_token.params['user_id']\n redirect_to '/'\nend",
"def set_code(code)\n credentials = AUTHORIZER.get_and_store_credentials_from_code(\n user_id: USER_ID, code: code, base_url: OOB_URI\n )\n credentials.refresh_token\nend",
"def init\n init_oauth_access_token\n end",
"def client_secret= new_client_secret\n @client_secret = new_client_secret\n end",
"def update\n store = OpenID::Store::Filesystem.new(RAILS_ROOT + '/tmp')\n consumer = OpenID::Consumer.new(session, store)\n response = consumer.complete(params.reject { |k, v| k !~ /^openid\\./ }, session_url)\n if response.status == :success\n # Awesome! Set the user identity url in the session\n session[:url] = response.identity_url\n # redirect somewhere useful\n redirect_to '/'\n else\n flash[:notice] = 'Failure signing in with OpenID.'\n redirect_to new_session_path\n end\n end",
"def set_OAuthTokenSecret(value)\n set_input(\"OAuthTokenSecret\", value)\n end",
"def set_OAuthTokenSecret(value)\n set_input(\"OAuthTokenSecret\", value)\n end",
"def auth\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"params=#{params}\",\n \"\" ] if browse_everything_controller_debug_verbose\n # params contains the access code with with the key :code\n provider_session.token = provider.connect(params, provider_session.data, connector_response_url_options)\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider_session.token=#{provider_session.token}\",\n \"\" ] if browse_everything_controller_debug_verbose\n provider_session.token\n end",
"def show\n if params.has_key? :fetch_auth_tokens\n if Google::AppConfig.fetch_auth_tokens\n flash[:notice] = 'Auth tokens successfully refreshed.'\n else\n flash[:notice] = 'Could not refresh auth tokens. Try to refresh the app code.'\n end\n elsif params.has_key? :refresh_access_token\n if Google::AppConfig.refresh_access_token\n flash[:notice] = 'Access token successfully refreshed.'\n else\n flash[:notice] = 'Could not refresh access token. Try to refresh the app code and refresh token.'\n end\n elsif !params.has_key? :show_notice\n flash.delete(:notice)\n end\n\n @google_app_config = Google::AppConfig.the_app_config\n\n respond_to do |format|\n format.html\n end\n end",
"def set_app\n @app = current_client.apps.find(params[:id] || params[:app_id])\n end",
"def application_instance_api(application_instance, url)\n return nil unless application_instance.present?\n if auth = application_instance.authentications.find_by(provider_url: url)\n CanvasApiSupport.refreshable_auth(auth, url, application_instance)\n end\n end",
"def map_logingov_to_idme\n if @current_user.identity.sign_in[:service_name].include? 'LOGINGOV'\n @current_user.identity.sign_in[:service_name] = 'oauth_IDME'\n end\n end"
] | [
"0.6815656",
"0.6455423",
"0.6445419",
"0.6440646",
"0.6397283",
"0.63802683",
"0.63802683",
"0.6377169",
"0.6307532",
"0.619249",
"0.6080465",
"0.60581374",
"0.604027",
"0.60270953",
"0.6023665",
"0.5967876",
"0.5941198",
"0.5936568",
"0.5898632",
"0.5898611",
"0.58880067",
"0.5876798",
"0.58613855",
"0.5858694",
"0.584918",
"0.58337504",
"0.58254975",
"0.5823127",
"0.5784189",
"0.57836527",
"0.5772793",
"0.57586324",
"0.5739988",
"0.5737741",
"0.5736314",
"0.5728345",
"0.5721936",
"0.5696376",
"0.56954926",
"0.56900555",
"0.56900555",
"0.56843275",
"0.5670757",
"0.5661307",
"0.5659239",
"0.56552786",
"0.56552786",
"0.56540585",
"0.5647284",
"0.56424844",
"0.56404287",
"0.56338394",
"0.5629456",
"0.56290394",
"0.5623728",
"0.56220686",
"0.5610908",
"0.56077075",
"0.559856",
"0.5595227",
"0.55924726",
"0.5592007",
"0.5585971",
"0.5582806",
"0.558094",
"0.55764914",
"0.557625",
"0.5571025",
"0.556873",
"0.55631006",
"0.5562261",
"0.5561795",
"0.5561652",
"0.5551632",
"0.55514604",
"0.55483806",
"0.554826",
"0.55403036",
"0.5538134",
"0.55361974",
"0.55199444",
"0.5510606",
"0.5492176",
"0.5485334",
"0.5482692",
"0.5470825",
"0.54679984",
"0.5459713",
"0.54538745",
"0.54535234",
"0.54521114",
"0.54476553",
"0.54458916",
"0.544546",
"0.5444129",
"0.54395443",
"0.54365104",
"0.54340374",
"0.5431506"
] | 0.66020274 | 1 |
Gets the users, channels, roles and emoji from a string. | def parse_mentions(mentions, server = nil)
array_to_return = []
# While possible mentions may be in message
while mentions.include?('<') && mentions.include?('>')
# Removing all content before the next possible mention
mentions = mentions.split('<', 2)[1]
# Locate the first valid mention enclosed in `<...>`, otherwise advance to the next open `<`
next unless mentions.split('>', 2).first.length < mentions.split('<', 2).first.length
# Store the possible mention value to be validated with RegEx
mention = mentions.split('>', 2).first
if /@!?(?<id>\d+)/ =~ mention
array_to_return << user(id) unless user(id).nil?
elsif /#(?<id>\d+)/ =~ mention
array_to_return << channel(id, server) unless channel(id, server).nil?
elsif /@&(?<id>\d+)/ =~ mention
if server
array_to_return << server.role(id) unless server.role(id).nil?
else
@servers.each_value do |element|
array_to_return << element.role(id) unless element.role(id).nil?
end
end
elsif /(?<animated>^a|^${0}):(?<name>\w+):(?<id>\d+)/ =~ mention
array_to_return << (emoji(id) || Emoji.new({ 'animated' => !animated.nil?, 'name' => name, 'id' => id }, self, nil))
end
end
array_to_return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_discord_user(msg)\n user = msg[NAME_PATTERN, 2].downcase\n raise OutteError.new \"You need to provide a user.\" if user.nil?\n\n parts = user.split('#')\n users = User.search(parts[0], !parts[1].nil? ? parts[1] : nil)\n case users.size\n when 0\n raise OutteError.new \"No user named #{user} found in the server.\"\n when 1\n return users.first\n else\n list = users.map{ |u| u.username + '#' + u.tag }.join(\"\\n\")\n raise OutteError.new \"Multiple users named #{parts[0]} found, please include the numerical tag as well:\\n#{format_block(list)}\"\n end\nend",
"def find_members(event, string)\n if event.respond_to?(:message) && event.message.mentions.empty? && !string\n event.respond I18n.t(\"commands.common.no_user_matched\")\n nil\n elsif event.respond_to?(:message) && !event.message.mentions.empty?\n event.message.mentions\n else\n regex = Regexp.new(string)\n server = resolve_server(event)\n server.members.select { |member|\n member.respond_to?(:display_name) && member.display_name =~ regex ||\n member.respond_to?(:username) && member.username =~ regex ||\n member.respond_to?(:distinct) && member.distinct =~ regex\n }\n end\n rescue NoMethodError\n nil\n end",
"def parse_snmp_users(text)\n text.split(\"\\n\\n\").map do |user_s|\n user_s.scan(/^(\\w+).*?: (.*)/).each_with_object({}) do |(h, v), m|\n key = SNMP_USER_PARAM[h.downcase.intern] || h.downcase.intern\n m[key] = case key\n when :privacy then v =~ /AES/ ? :aes128 : :des\n when :version then v.sub('v2c', 'v2').intern\n when :auth then v.downcase.intern\n when :roles then v.sub(/ \\(.*?\\)/, '')\n else v.downcase\n end\n end\n end\n end",
"def extract_mentions( text )\n regex = /(?:^|\\s)@(\\w*)(?:\\s|\\z|$)/\n usernames_array = text.scan(regex).flatten\n ids = User.where(username: usernames_array).pluck(:id) - [current_user.id] if usernames_array\n ids.blank? ? false : ids\n end",
"def grab_info(text)\n if text =~ /^\\:(.+)\\!\\~?(.+)\\@(.+) PRIVMSG \\#?(\\w+) \\:(.+)/\n return [$1, $2, $3, $4, $5]\n else\n return false\n end\n end",
"def hosts_for(string)\n first = string[/^(\\w+)\\.\\w+/, 1]\n if role = @roles.find { |r| r.name == first }\n return role.hosts\n else\n raise \"Sorry, I didn't understand what hosts to run #{string.inspect} on.\"\n end\n end",
"def parse string\n if match = (string && string.match(/\\b(\\d*)x?(\\d*)\\b([\\>\\<\\#\\@\\%^!])?/i))\n match[1,2]\n end\n end",
"def read_users_string\n read_users.join(', ')\n end",
"def extract_variables_from_string(string)\n string.split(/ /).map do |defintion|\n match = defintion.match STRING_REG_EX\n next nil unless match\n\n { match[1] => match[2] }\n end.reject(&:nil?)\n end",
"def split_userinfo(ui)\n return nil, nil unless ui\n user, password = ui.split(':', 2)\n\n return user, password\n end",
"def g_unpack(str)\n codepoints = str.unpack('U*')\n unpacked = []\n pos = 0\n marker = 0\n eoc = codepoints.length\n while(pos < eoc)\n pos += 1\n previous = codepoints[pos-1]\n current = codepoints[pos]\n if (\n # CR X LF\n one = ( previous == UCD.boundary[:cr] and current == UCD.boundary[:lf] ) or\n # L X (L|V|LV|LVT)\n two = ( UCD.boundary[:l] === previous and in_char_class?(current, [:l,:v,:lv,:lvt]) ) or\n # (LV|V) X (V|T)\n three = ( in_char_class?(previous, [:lv,:v]) and in_char_class?(current, [:v,:t]) ) or\n # (LVT|T) X (T)\n four = ( in_char_class?(previous, [:lvt,:t]) and UCD.boundary[:t] === current ) or\n # X Extend\n five = (UCD.boundary[:extend] === current)\n )\n else\n unpacked << codepoints[marker..pos-1]\n marker = pos\n end\n end \n unpacked\n end",
"def extract(str)\n [str]\n end",
"def get_data; @data = Emoji.elements; end",
"def normalise_string(string)\n # Is it already one of the methods? If so, easy. If not, split and parse.\n if string == \"_\"\n []\n elsif Col::DB.method? string\n [ string.intern ]\n elsif (1..4).include? string.size # say: \"g\", \"gb\", \"gbow\"\n color, style, backg = extract(string)\n color = Col::DB.color(color) # 'g' -> :green\n style = Col::DB.style(style) # 'b' -> :bold\n backg = Col::DB.background(backg) # 'ow' -> :on_white\n [ color, style, backg ].compact # remove nil elements\n else\n raise Col::Error, \"Invalid item: #{string.inspect}\"\n end\n rescue Col::Error => e\n raise Col::Error, \"Invalid item: #{string.inspect} (#{e.message})\"\n end",
"def parse(meme, string)\n MEMES[meme].match(string).to_a[1..-1]\n end",
"def normalize_user_mentions(text)\n users = []\n\n text.gsub!(NORMALIZE_USER_REGEXP) do\n prefix = $1\n user = $2\n users.push(user)\n \"#{prefix}@user#{users.size}\"\n end\n\n users\n end",
"def match_and_parse(string)\n meme = match(string)\n if meme.nil?\n return meme\n end\n bits = parse(meme, string)\n [meme, bits]\n end",
"def _extract(string, subscriber_digits, code_digits)\n [string[0, code_digits], string[code_digits, subscriber_digits]]\n end",
"def parse_rfc822(string)\n require 'utility/enhancements'\n headers, body = string.parse_headers\n log.debug \"headers: #{headers}, body: #{body}\"\n Email.new(\n :senders => headers['from'] ? headers['from'].split(/[;,]/) : [],\n :recipients => headers['to'] ? headers['to'].split(/[;,]/) : [],\n :cc_recipients => headers['cc'] ? headers['cc'].split(/[;,]/) : [],\n :bcc_recipients => headers['bcc'] ? headers['bcc'].split(/[;,]/) : [],\n :subject => headers['subject'] || '',\n :body => body\n )\n end",
"def split_login(str)\n login = []\n # search from the right so we don't pick out ampersands in a\n # password or username\n if i = str.rindex(?@)\n login << str[i+1..-1]\n if 0 < i\n str = str[0..i-1]\n i = str.index(?:)\n if 0 == i\n login << '' << str[i+1..-1]\n elsif i\n login << str[0..i-1] << str[i+1..-1]\n else\n login << str\n end\n else\n login << ''\n end\n else\n login << str\n end\n if login.first.sub!(/:(\\d+)$/,'')\n login << $1.to_i\n else\n login << nil\n end\nend",
"def parse_user_data_str(user_data_str)\n user_data = {}\n line_no = 0\n user_data_str.each_line do |line|\n line_no += 1\n line = line.strip\n next if line =~ /^#/ # skip comments\n next if line.empty? # skip blank lines\n parts = line.split(\"=\")\n if parts.length < 2\n warn \"user-data line #{line_no} does not conform to specification: '#{line}'\"\n else\n key = parts.first\n value = parts[1..-1].join('=') # in case there was an '=' in the value\n # already have a value, so make sure we have an array\n if user_data[key]\n if !user_data[key].is_a?(Array)\n user_data[key] = [user_data[key]]\n end\n user_data[key] << value\n else\n user_data[key] = value\n end\n end\n end\n\n return user_data\n end",
"def extract_protocol(protocol_string)\n [\"name\", \"shared\", \"guest access\", \"inherit perms\"].inject({}) do |hash, key|\n hash[key] = protocol_value_for_key_in_string(key, protocol_string)\n hash\n end\n end",
"def retrieve_string(m, string)\n @bot.debug \"retrieving #{string}\"\n factoid = fetch_fact(string)\n if factoid\n @bot.debug \"Found a factoid.\"\n if factoid[2].gsub!(/^\\<reply\\>/i, '')\n return factoid[2]\n else \n return \"#{factoid[0]} #{factoid[1]} #{factoid[2]}\"\n end\n elsif factoid = fetch_alias(string)\n# factoid = fetch_alias(string)\n return \"#{factoid[0]} #{factoid[1]} #{factoid[2]} (alias of #{string})\"\n else \n return fetch_like_facts(string)\n end\n end",
"def discover_users_string\n discover_users.join(', ')\n end",
"def tweet(str)\n arr = []\n scans = str.scan(/(@\\w+)|(#\\w+)/)\n scans.each do |x|\n x.each do |y|\n if y\n arr.push y\n end\n end\n end\n arr.join ' '\nend",
"def search_contacts(ustring)\n resp = ews.resolve_names(:name => ustring)\n\n users = []\n if(resp.status == 'Success')\n users = resp.response_message[:elems][:resolution_set][:elems]\n # users << Types::MailboxUser.new(ews, mb[:mailbox][:elems])\n elsif(resp.code == 'ErrorNameResolutionMultipleResults')\n users = resp.response_message[:elems][:resolution_set][:elems].select do |u|\n !!u[:resolution][:elems][0][:mailbox]\n end\n elsif resp.code != 'ErrorNameResolutionNoResults'\n raise EwsError, \"Find User produced an error: #{resp.code}: #{resp.message}\"\n end\n users\n end",
"def read_users_string=(users)\n self.read_users = users.split(/[\\s,]+/)\n end",
"def parse(str)\n read_items(tokenize(str))\n end",
"def search_contacts(ustring)\n resp = ews.resolve_names(:name => ustring)\n users = []\n if(resp.status == 'Success')\n users << MailboxUser.new(ews, resp.items.first[:mailbox])\n elsif(resp.code == 'ErrorNameResolutionMultipleResults')\n resp.items.each do |u|\n users << MailboxUser.new(ews, u[:mailbox])\n end\n else\n raise EwsError, \"Find User produced an error: #{resp.code}: #{resp.message}\"\n end\n users\n end",
"def parse(str)\n fields = []\n nest = 0\n field = ''\n str.each_char do |ch|\n got = false\n if nest == 0\n if ch == '('\n nest += 1\n end\n else\n if ch == '('\n nest += 1\n field << ch\n elsif ch == ')'\n nest -= 1\n if nest == 0\n got = true\n else\n field << ch\n end\n else\n field << ch\n end\n end\n\n if got\n fields << field\n field = ''\n end\n end\n\n fields\n end",
"def scrape_emoji_page(url)\n body = @agent.get(clean_url(url)).body\n { unicode: body.scan(/U\\+[\\w\\d]{4,6}/),\n shortcodes: body.scan(/\\:[\\w\\_\\-\\d]+:/) }\n end",
"def mailbox_list(str, opt)\n ret = []\n split_by(Tokenizer.token(str), \",\").each do |m|\n if a1 = m.index(\"<\") and a2 = m.rindex(\">\") and a2 > a1 then\n display_name = m[0..a1-1].join(\" \")\n if opt[:decode_mime_header] then\n display_name = RFC2047.decode(display_name, opt)\n end\n mailaddr = _conv(m[a1+1..a2-1].join, opt)\n local_part, domain = mailaddr.split(/@/, 2)\n ret << RFC2822::Mailbox.new(RFC2822::AddrSpec.new(local_part, domain), _conv(display_name, opt))\n else\n local_part, domain = _conv(m.join, opt).split(/@/, 2)\n ret << RFC2822::Mailbox.new(RFC2822::AddrSpec.new(local_part, domain))\n end\n end\n return ret\n end",
"def extract(string)\n string += \" \"\n color, style, backg = /^(.)(.)(..)/.match(string).captures\n color = nil if [' ', '_'].include? color\n style = nil if [' ', '_'].include? style\n backg = nil if [' ', '__'].include? backg\n [color, style, backg]\n end",
"def id_and_name_from(string)\n string =~ /[^0-9a-f]/i ? [nil, string] : [string, nil]\n end",
"def emojis\n @emojis ||= EmojiData.find_by_str(self.text).uniq { |e| e.unified }\n end",
"def mentions\n @mentions ||= begin\n regex = /@([\\w]+)/\n body.scan(regex).flatten\n end\n end",
"def discover_users_string=(users)\n self.discover_users = users.split(/[\\s,]+/)\n end",
"def parse_args(str)\n return str.split(/\\s+:(.*)|\\s+/)\n end",
"def mentions\n @mentions ||= begin\n regex = /@([\\w]+\\s[\\w]+)/ \n body.scan(regex).flatten\n end\n end",
"def split_author_role_codes(str)\n # we're restrictive in our matching of role codes because\n # there's all kinds of crap inside parens in these strings\n author = str\n roles = []\n if str.present?\n ROLE_CODES.each do |code|\n # sometimes there's a period.\n author_portion = author.gsub(\"(#{code})\", \"\").gsub(\"(#{code}.)\", \"\")\n if author != author_portion\n author = author_portion.strip\n roles << code\n end\n end\n end\n return [author, roles]\n end",
"def parse_string(str)\n return str if str.include?('%')\n constants, *attributes = str.split('#')\n value = Object.const_get(constants)\n while (attribute = attributes.shift)\n value = value.send(attribute) unless attribute.empty?\n end\n return value\n end",
"def split_params(params)\n channels = params.select { |param| param.start_with?(\"#\") }.map { |param| param[1..-1] }\n users = params.select { |param| param.start_with?(\"@\") }.map { |param| param[1..-1] }\n return channels, users\n end",
"def mentions\n @mentions ||= begin\n regex = /@([\\w]+\\s[\\w]+)/ \n tags.scan(regex).flatten\n end\n end",
"def parse(_string, _extension)\n [{}, {}]\n end",
"def get_twitch_emoticons\n # Get Emoticons for Channel\n headers = {\n 'Accept' => 'application/vnd.twitchtv.v3+json',\n 'Client-ID' => 'efq3aoz1vvrtac1wz0ojszl54p6uuw'\n }\n http_response = self.class.get(\n \"https://api.twitch.tv/kraken/chat/#{@twitch_channel}/emoticons\",\n headers: headers\n )\n response = JSON.parse(http_response.body, symbolize_names: true)\n emoticons = response[:emoticons]\n emoticons = emoticons.select do |e|\n e[:state] == 'active' && e[:subscriber_only]\n end\n emoticons\n end",
"def mime_decode(str, charset = \"UTF-8\")\n decstr = \"\"\n items = str.split(/\\s/).collect{|c| c.strip}\n items.each_with_index do |item, i|\n if item.empty?\n decstr += \" \"\n next\n end\n decstr += \" \" unless decstr.empty?\n mis = item.scan(/^=\\?(UTF-8|utf-8)\\?(B|b)\\?(.+)\\?=$/).flatten\n if mis.empty?\n decstr += item\n else\n decstr += Base64.decode64(mis[-1])\n end\n end\n return msg_decode(decstr, charset)\n end",
"def decompose_string(string)\n Types.check( binding, { :string => String } )\n\n str = ComposedString.from_string(string)\n\n str = extract_blanks str\n str = extract_nonblanks str\n\n str\n end",
"def grab_all_ssns(string)\n\tssn = /\\d{3}[^\\d]?\\d{2}[^\\d]?\\d{4}/\n\treturnString = \"\"\n\tif ssn =~ string\n\t\treturnString = string.scan(ssn)\n\t\treturn returnString\n\telse\n\t\t#puts \"not match\"\n\t\treturn []\n\tend\nend",
"def unpack_message(str)\n\t\treturn str.split(\",\").collect {|x| x.to_i}\n\tend",
"def parse_types(string)\n types = []\n letters = ['F', 'I', 'L', 'N', 'P', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']\n letters.each_with_index { |letter,index| \n if string.upcase.include?(letter)\n types << index\n end\n }\n types\n end",
"def find_user_key(str)\n str = str[1..-1] if str[0] == \"@\" # deal with @user\n str = str[2..-1] if (/<@\\w*>/).match(str) # deal with @user that slack has garbled\n if @users.include?(str)\n return str\n else\n @users.each do |key, hash|\n return key if hash.values.include?(str)\n end\n end\n return nil\n end",
"def split_params(params)\n channels = params.select { |param| param.start_with?(\"#\") }.map { |param| param[1..] }\n users = params.select { |param| param.start_with?(\"@\") }.map { |param| param[1..] }\n \n return channels, users\n end",
"def parse_player(\n msg, # Text string to parse\n username, # Name of Discord user, to infer player name\n userlevel = false, # Whether to search in for userlevel players or regular ones\n explicit = false, # Only parse explicit names, without inferring from username\n enforce = false, # Even more, raise exception if no explicit name found\n implicit = false, # The opposite, only infer from username\n third = false # Allow 3rd person specification (e.g. \"is xela\" rather than \"for xela\")\n )\n msg = msg.gsub(/\"/, '')\n p = msg[/(for|of#{third ? '|is' : ''}) (.*)[\\.\\?]?/i, 2]\n playerClass = userlevel ? UserlevelPlayer : Player\n\n # We make sure to only return players with metanet_ids, ie., with highscores.\n if implicit\n parse_player_implicit(username, playerClass)\n else\n if p.nil?\n if explicit\n if enforce\n raise OutteError.new \"You need to specify a player for this function.\"\n else\n nil\n end\n else\n parse_player_implicit(username, playerClass)\n end\n else\n parse_player_explicit(p, playerClass)\n end\n end\nend",
"def attribute(string)\n\n attribute_name = \"\"\n attribute_value = \"\"\n\n length = string.length\n position = 0\n\n return [nil, nil] if length == 0 \n\n while position < (length)\n\n # If character matches 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x2F (ASCII /) then advance position\n if string[position] =~ /[\\u{09}\\u{0A}\\u{0C}\\u{0D}\\u{20}\\u{2f}]/\n \n position += 1\n \n elsif string[position] == '>'\n\n attribute_name = nil\n break\n\n else\n\n while position < length\n \n if string[position] == '=' && attribute_name != ''\n\n attribute_value, position_increment = attribute_value(string[position + 1, length])\n\n position += position_increment + 1\n\n break\n\n elsif string[position] =~ /[\\>\\/]/\n \n break\n \n elsif string[position] =~ /[A-Z]/\n\n attribute_name += string[position].downcase\n position += 1\n\n else\n attribute_name += string[position]\n position += 1\n end\n\n end\n\n break\n\n end\n\n end\n\n if attribute_name\n [{attribute_name: attribute_name, attribute_value: attribute_value}, position]\n else\n [nil, position]\n end\n\n end",
"def pbParseJson(str)\n if !pbIsJsonString(str)\n return nil\n end\n stringRE=/(\\\"(\\\\[\\\"\\'\\\\rntbf]|\\\\u[0-9A-Fa-f]{4,4}|[^\\\\\\\"])*\\\")/ #\"\n strings=[]\n str=str.gsub(stringRE){\n sl=strings.length\n ss=$1\n if ss.include?(\"\\\\u\")\n ss.gsub!(/\\\\u([0-9A-Fa-f]{4,4})/){\n codepoint=$1.to_i(16)\n if codepoint<=0x7F\n next sprintf(\"\\\\x%02X\",codepoint)\n elsif codepoint<=0x7FF\n next sprintf(\"%s%s\",\n (0xC0|((codepoint>>6)&0x1F)).chr,\n (0x80|(codepoint &0x3F)).chr)\n else\n next sprintf(\"%s%s%s\",\n (0xE0|((codepoint>>12)&0x0F)).chr,\n (0x80|((codepoint>>6)&0x3F)).chr,\n (0x80|(codepoint &0x3F)).chr)\n end\n }\n end\n strings.push(eval(ss))\n next sprintf(\"strings[%d]\",sl)\n }\n str=str.gsub(/\\:/,\"=>\")\n str=str.gsub(/null/,\"nil\")\n return eval(\"(\"+str+\")\")\nend",
"def extract\n _, *ret = *self.match(/\\A([^\\s!]+)(?:!([^\\s@]+)@(\\S+))?\\z/)\n ret\n end",
"def channels \n debug [query[\"channels\"], \" are registered channels\"]\n @channels ||= query[\"channels\"].collect(&:strip).reject(&:empty?) \n @channels[0] ||= nil # Every user should have at last one channel\n @channels\n end",
"def parse(text)\n parse_references(text) if @project\n parse_emoji(text)\n\n text\n end",
"def parsePids(str)\n #@run.info_message \"Response from #{host.name} #{response.body}\"\n pidmap = {}\n if (str != nil) \n str.split(',').each { |i|\n i.scan(/(.+)=(.+)/) { |match|\n pidmap[match[0]] = match[1]\n }\n }\n end\n return pidmap\n end",
"def components(host_string)\n host_string = host_string.strip\n\n # IPv6\n if host_string.start_with?('[')\n end_idx = host_string.index(']')\n raise ::Aerospike::Exceptions::Parse, 'Invalid IPv6 host' if end_idx.nil?\n\n # Slice away brackets and what's inside them, then split on : and\n # replace first entry with string inside brackets\n host_string.slice(end_idx+1..-1).split(':').tap do |result|\n result[0] = host_string[1...end_idx]\n end\n else\n host_string.split(?:)\n end\n end",
"def parse(str)\n column_strings = str.split(\" \")\n size = column_strings.size\n raise ArgumentError, \"wrong number of columns (#{size} for #{COLUMNS.size})\" if size != COLUMNS.size\n result = { }\n COLUMNS.each_with_index { |c, i| result[c] = column_parse(column_strings[i], RANGES[c]) }\n result\n end",
"def parse_string_for_messages(text)\n return text.dup if text.empty? # or text.frozen?\n\n # Detect dialog\n text = detect_dialog(text).dup\n # Gsub text\n text.gsub!(/\\\\\\\\/, S_000)\n text.gsub!(/\\\\v\\[([0-9]+)\\]/i) { $game_variables[$1.to_i] }\n text.gsub!(/\\\\n\\[([0-9]+)\\]/i) { $game_actors[$1.to_i]&.name }\n text.gsub!(/\\\\p\\[([0-9]+)\\]/i) { $actors[$1.to_i - 1]&.name }\n text.gsub!(/\\\\k\\[([^\\]]+)\\]/i) { get_key_name($1) }\n text.gsub!('\\E') { $game_switches[Yuki::Sw::Gender] ? 'e' : nil }\n text.gsub!(/\\\\f\\[([^\\]]+)\\]/i) { $1.split('§')[$game_switches[Yuki::Sw::Gender] ? 0 : 1] }\n text.gsub!(/\\\\t\\[([0-9]+), *([0-9]+)\\]/i) { ::PFM::Text.parse($1.to_i, $2.to_i) }\n # text.gsub!(NBSP_B, NBSP_R)\n text.gsub!(*Dot)\n text.gsub!(*Money)\n @variables.each { |expr, value| text.gsub!(expr, value) }\n text.gsub!(KAPHOTICS_Clean, S_Empty)\n return text\n end",
"def parse_elements( string )\n string.scan(/'((?:[^']|'')*)'/).flatten.map do\n |x| x.gsub( ESCAPED_CHARS_RE ){ |c| ESCAPED_CHARS[ c ] || c }\n end\n end",
"def read_string\n\t\t\n\t\t# TODO: Add the ability to have escape characters.\n\t\tstart_char \t= @chars.next # Don't add quotation marks to the string value\n\t\tline_num \t= @chars.get_cur_line\n\t\tcol_num \t= @chars.get_cur_col\n\t\ttok_val \t= ''\n\n\t\twhile true\n\t\t\tbegin\n\t\t\t\tchar = @chars.peak\n\t\t\trescue EOFError\n\t\t\t\traise \"LEXER ERROR: At line: #{line_num}, col: #{col_num} >> String does not end.\"\n\t\t \t\treturn nil\n\t\t \tend\n\n\t\t \tif char == start_char\n\t\t \t\treturn Token.new(\"String\", tok_val, line_num, col_num)\n\t\t \tend\n\t\t \ttok_val += char\n\t\t \t@chars.next\n\t\tend\n\tend",
"def command_from_text(text, username = nil)\n return unless text\n match = text.match CMD_REGEX\n return unless match\n return if match[3] && username != true && match[3] != username\n [match[1], text.split.drop(1)]\n end",
"def grab_all_ssns(string)\n regexp_key = /(\\d{3}-\\d{2}-\\d{4})/\n string.scan(regexp_key).flatten\nend",
"def parsePids(str)\n #@run.info_message \"Response from #{host.name} #{response.body}\"\n pidmap = {}\n str.split(',').each { |i|\n i.scan(/(.+)=(.+)/) { |match|\n pidmap[match[0]] = match[1]\n }\n }\n return pidmap\n end",
"def components\n @components ||= @string.split('/').reject{|x| x == '' || x == nil} rescue []\n end",
"def parse_message message\n message.split(\"=>\").map { |i| i.strip }\n end",
"def fields(string)\n string.split(/\\W+/)\nend",
"def extract_message(input)\n sender = nil\n content = nil\n is_action = false\n \n stripped = input.strip\n if stripped[0...1] == '*' # action\n is_action = true\n stripped = stripped[1..-1].split(' ')\n sender = stripped[0]\n content = stripped[1..-1].join(' ')\n else\n scanned = /<([^>]*)> (.*)/.match(stripped)\n sender = scanned[1].strip\n content = scanned[2]\n end\n \n [{:ident => sender, :name => sender, :host => nil}, content, is_action]\n end",
"def decode_properties(string)\n ::Marshal::load(string.unpack('m')[0])\n end",
"def eval_first_msg(umsg,sock)\n user_info = umsg.split(\" \")\n if umsg =~ /user_info:/\n @user_info.push({:nickname => user_info[1],:role => \"client\", :channels => [], :mode => \"pull\", :time => Time.now})\n sock.write(\"Welcome #{user_info[1]}\\n\")\n @@connection.insert_user user_info[1]\n @user_info.last[:channels] = @@connection.fill_channels_user(user_info[1])\n elsif (umsg =~ /source_info:/) \n @user_info.push({:nickname => user_info[1],:role => \"editor\",:status => \"logging\"}) \n sock.write(\"password:\\n\")\n elsif (umsg =~ /admin_info:/ )\n @user_info.push({:nickname => user_info[1],:role => \"admin\", :status => \"logging\"}) \n sock.write(\"password:\\n\")\n end \n end",
"def parse_user search\n Hash[*search.split(',').map{|pair| pair.split('=').values_at(0..1)}.flatten]['uid']\n end",
"def parse(str)\n str ||= ''\n\n @raw = str\n @parsed = []\n @remainder = str.sub(/\\<@!?[0-9]*\\>/, '')\n\n return self if str == ''\n\n pieces = str.split\n buf = ''\n\n pieces.each do |v|\n if buf != '' || v.start_with?('\"')\n buf += \"#{v.gsub(/^\"/, '').gsub(/\"$/, '')} \"\n\n if v.end_with?('\"')\n @parsed.push buf.strip\n buf = ''\n end\n else\n @parsed.push v\n end\n end\n\n return false if buf != ''\n\n self\n end",
"def parse_mailbox_list(str, opt={})\n mailbox_list(str, opt)\n end",
"def mentions\n result_hash['mention']\n end",
"def _parse(string)\n context = Hash[string.scan(/^(.*): (.*)$/)]\n @conn_context = {}\n context.each do |key, value|\n @conn_context[key.downcase.to_sym] = value\n end\n end",
"def parse(str); end",
"def parse_tags (string)\n tags = nil\n string.scan(LEWTLedger::MATCH_SINGLE_META_REGEX) { |t|\n if tags == nil\n tags = Hash.new\n end\n tag_value = parse_tag_value t[0]\n tag_name = parse_tag_name t[0]\n tags[tag_name.gsub(/\\W/,\"_\").to_sym] = tag_value\n }\n return tags\n end",
"def get_account_message\n url = 'https://mp.weixin.qq.com/cgi-bin/settingpage'\\\n \"?t=setting/index&action=index&token=#{ @token }&lang=zh_CN\"\n res = RestClient.get(url, cookies: @cookies)\n reg_nickname = \\\n /.*\\<h4\\>名称\\<\\/h4\\>\\s*\\<div\\s*class\\=\\\"meta_opr\\\"\\>\\s*\\<\\/div\\>\\s*\\<div\\s*class\\=\\\"meta_content\\\"\\>\\s*(\\S*)/\n reg_type = /.*\\<div\\s*class\\=\\\"meta_content\\\"\\>\\s*(\\S*)\\s*\\<span\\s*class\\=\\\"mini_tips weak_text\\\"\\>/\n reg_img = /.*fakeid\\=(\\d*)/\n head_img = \"https://mp.weixin.qq.com/misc/getheadimg?fakeid=#{ $1 }&token=#{@token}&lang=zh_CN\"\\\n if reg_img =~ res.to_s\n account_type = $1 if reg_type =~ res.to_s\n nickname = $1 if reg_nickname =~ res.to_s\n [nickname, account_type, head_img]\n end",
"def get_community_string(string)\n string\n end",
"def charset_from_meta_content(string)\n\n charset_match = string.match(/charset\\s*\\=\\s*(.+)/i)\n\n if charset_match\n\n charset_value = charset_match[1]\n\n charset_value[/\\A\\\"(.*)\\\"/, 1] ||\n charset_value[/\\A\\'(.*)\\'/, 1] ||\n charset_value[/(.*)[\\s;]/, 1] ||\n charset_value[/(.*)/, 1]\n else\n nil\n end\n\n end",
"def parse(string)\n string.gsub!(\"\\n\", ' ')\n data_type, required, name, options_and_description = string.match(/\\A\\[(\\S*)\\](!)?\\s*([\\w\\[\\]]*)\\s*(.*)\\Z/).captures\n allow_multiple = name.gsub!('[]', '')\n options, description = options_and_description.match(/\\A(\\[.*\\])?(.*)\\Z/).captures\n options = options ? options.gsub(/\\[?\\]?\\s?/, '').split(',') : []\n\n @id = name\n @description = description if description.present?\n @type = Type.new([data_type])\n @required = required\n @options = options\n end",
"def from(string)\n return unless string.present?\n names = Grammar::NgramFactory.new(string).omnigrams\n names = names.map{|g| g.join ' '} << string\n names = names.uniq - Grammar::LanguageHelper::IDENTIFIERS\n objects = names.map do |name|\n name = (name.split(/\\s+/) - Grammar::LanguageHelper::IDENTIFIERS).compact.join(' ')\n if name.present? && found = like(name) || found = where(name: name).first\n result = SearchResult.new(term: name, result: found)\n end\n end.compact\n objects = objects.select{|obj| obj.result.present?}.uniq || []\n objects.sort{|b,a| b.term.length <=> a.term.length}.map(&:result).last\n end",
"def read(str)\n if self.instance_of?(DUID)\n super\n case type\n when 1\n DUID_LLT.new.read(str)\n when 2\n DUID_EN.new.read(str)\n when 3\n DUID_LL.new.read(str)\n else\n self\n end\n else\n private_read str\n end\n end",
"def read(str)\n msg_type = Types::Int8.new.read(str)\n\n case msg_type\n when 12, 13\n DHCPv6::Relay.new.read(str)\n else\n super\n end\n end",
"def parse(message)\n message.strip!\n log message\n did_receive_response!(message)\n \n if /^PING (.+?)$/.match(message)\n reply \"PONG #{$1}\" and return\n end\n \n message = message.gsub(':', '').split(\" \")\n sender, raw, target = message.shift(3)\n user, hostname = sender.split \"!\"\n \n if /\\d+/.match(raw)\n send(\"raw_#{raw}\", raw) if respond_to? \"raw_#{raw}\"\n did_receive_raw!(raw)\n \n elsif raw == 'PRIVMSG'\n did_receive_privmsg!(target, user, message.join(' '))\n\n elsif raw == 'JOIN'\n # Handle new user and new channel\n if (user != @@nickname)\n did_receive_join!(user, target)\n else\n # Blow bubbles\n end\n\n elsif raw == 'KICK'\n did_receive_kick!(target, user, message.shift, message.join(' '))\n elsif raw == 'MODE'\n did_receive_mode_change!(target, message)\n elsif raw == 'PART'\n did_receive_part!(user, target)\n elsif raw == 'QUIT'\n did_receive_quit!(user)\n elsif raw == 'NICK'\n # Old_Nick: User, New Nick: Target\n did_receive_nick_change!(user, target)\n # Handle updating user\n elsif raw == 'TOPIC'\n did_receive_topic_change!(target, message)\n # Handle updating channel\n \n end\n \n end",
"def reply_users_names\n reply_users&.split(/[, ]+/)&.map do |reply_user_id|\n User.find(reply_user_id).real_name\n end&.join(', ')\n end",
"def parse(string)\n data_type, required, name, options_and_description = string.match(/\\A\\[(\\S*)\\](!)?\\s*([\\w\\[\\]]*)\\s*(.*)\\Z/).captures\n allow_multiple = name.gsub!('[]', '')\n\n options, description = options_and_description.match(/\\A(\\[.*\\])?(.*)\\Z/).captures\n options = options ? options.gsub(/\\[?\\]?\\s?/, '').split(',') : []\n\n @name = name\n @description = description\n @type = Type.new([data_type])\n @is_required = required.present?\n @allow_multiple = allow_multiple.present?\n @options = options\n end",
"def parse_metric_dimensions str\n return nil if (str.nil? or str=='')\n dims = [nil,nil,nil]\n str.split('x').each do |dim|\n dim_cm = to_cm(parse_metric_length(dim))\n if (dim_cm != 0)\n dims[0] = dim_cm if dim.match(/w/i) \n dims[1] = dim_cm if dim.match(/[dl]/i)\n dims[2] = dim_cm if dim.match(/h/i) \n end\n end\n return dims unless dims.uniq == [nil]\n return nil\n end",
"def read(str)\n\t\t\tforce_binary(str)\n\t\t\treturn self if str.nil?\n\t\t\tself[:ipv6_v] = str[0,1].unpack(\"C\").first >> 4\n\t\t\tself[:ipv6_class] = (str[0,2].unpack(\"n\").first & 0x0ff0) >> 4\n\t\t\tself[:ipv6_label] = str[0,4].unpack(\"N\").first & 0x000fffff\n\t\t\tself[:ipv6_len].read(str[4,2])\n\t\t\tself[:ipv6_next].read(str[6,1])\n\t\t\tself[:ipv6_hop].read(str[7,1])\n\t\t\tself[:ipv6_src].read(str[8,16])\n\t\t\tself[:ipv6_dst].read(str[24,16])\n\t\t\tself[:body].read(str[40,str.size]) if str.size > 40\n\t\t\tself\n\t\tend",
"def content_from(mesg)\n mesg.slice(6..mesg.length).split(',')\nend",
"def parse(string)\n string.scan(ADDRESS_REGEXP).flatten\n end",
"def awesome_string(string)\n lexers = ::Rouge::Guessers::Source.new(string).filter(R_LEXERS)\n if !lexers.empty?\n format_syntax_string(string, lexers.first)\n elsif string =~ /(?:\\r?\\n)(?!\\z)/\n format_multiline_string(string)\n else\n format_plain_string(string)\n end\n end",
"def parse_connect_string(string)\n #This is a stub, used for indexing\n end",
"def parse_mention(mention)\n # Mention format: <@id>\n return nil unless /<@!?(?<id>\\d+)>?/ =~ mention\n user(id.to_i)\n end",
"def convert_participants(participants_string)\n return nil unless participants_string.is_a?(String)\n \n participants_raw_array = participants_string.split(/[,;]/)\n \n participants = participants_raw_array.map do |p|\n p = p.downcase.strip\n user = (p.include?(\"@\") ? User.find_by_primary_email(p) : User.find_by_downcase_nickname(p))\n user ? user.id.to_s : p.blank? ? nil : p\n end\n \n return participants.compact.uniq\n end",
"def extract_types_from_text(text)\n name, types, text = nil, [], text.strip\n if text =~ /^\\s*(\\S*)\\s*<(.+?)>\\s*(.*)/\n name, text, types = $1, $3, $2.split(\",\").collect {|e| e.strip }\n end\n [name, types, text]\n end",
"def recipients_from_string(emails_str)\n rec_strs = emails_str.to_s.split(/[\\;\\,]+/)\n rec_strs.map! do |rs|\n ValidateEmail.valid?(rs.strip) ? rs.strip : nil\n end\n rec_strs.compact!\n rec_strs.length == 1 ? rec_strs[0] : rec_strs\n end"
] | [
"0.55238605",
"0.53596246",
"0.51066905",
"0.5099445",
"0.5085582",
"0.5076298",
"0.50474715",
"0.50464326",
"0.5017118",
"0.5015652",
"0.5014232",
"0.49684095",
"0.4908837",
"0.48872346",
"0.48647833",
"0.4846756",
"0.48458117",
"0.48421288",
"0.4820095",
"0.47685167",
"0.47658205",
"0.4752556",
"0.4722946",
"0.46994188",
"0.46829152",
"0.46753037",
"0.46698633",
"0.46574062",
"0.4646477",
"0.4639221",
"0.4632981",
"0.46230078",
"0.46165538",
"0.46144196",
"0.4607435",
"0.46028823",
"0.45944083",
"0.45878676",
"0.4567847",
"0.45600563",
"0.45476452",
"0.45386904",
"0.45283914",
"0.4527438",
"0.45258424",
"0.4509354",
"0.44886428",
"0.44761008",
"0.44728708",
"0.44600883",
"0.44573146",
"0.44510075",
"0.44367358",
"0.4435054",
"0.443385",
"0.44310752",
"0.44173613",
"0.44163293",
"0.44104764",
"0.44051626",
"0.44041157",
"0.43852562",
"0.43847772",
"0.4383177",
"0.4377936",
"0.43715304",
"0.43659887",
"0.43646255",
"0.43582332",
"0.43482637",
"0.43444875",
"0.43320316",
"0.43313685",
"0.43224347",
"0.43143338",
"0.43114766",
"0.43083134",
"0.43066064",
"0.4292125",
"0.42919523",
"0.4284197",
"0.42831215",
"0.42830107",
"0.42728052",
"0.42722487",
"0.4267136",
"0.42649385",
"0.42594564",
"0.42552057",
"0.4250545",
"0.42475402",
"0.42471218",
"0.42441484",
"0.4242731",
"0.42414773",
"0.42390087",
"0.42356813",
"0.4233794",
"0.4229091",
"0.42169076"
] | 0.5310083 | 2 |
Gets the user, channel, role or emoji from a string. | def parse_mention(mention, server = nil)
parse_mentions(mention, server).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_discord_user(msg)\n user = msg[NAME_PATTERN, 2].downcase\n raise OutteError.new \"You need to provide a user.\" if user.nil?\n\n parts = user.split('#')\n users = User.search(parts[0], !parts[1].nil? ? parts[1] : nil)\n case users.size\n when 0\n raise OutteError.new \"No user named #{user} found in the server.\"\n when 1\n return users.first\n else\n list = users.map{ |u| u.username + '#' + u.tag }.join(\"\\n\")\n raise OutteError.new \"Multiple users named #{parts[0]} found, please include the numerical tag as well:\\n#{format_block(list)}\"\n end\nend",
"def parse string\n if match = (string && string.match(/\\b(\\d*)x?(\\d*)\\b([\\>\\<\\#\\@\\%^!])?/i))\n match[1,2]\n end\n end",
"def retrieve_string(m, string)\n @bot.debug \"retrieving #{string}\"\n factoid = fetch_fact(string)\n if factoid\n @bot.debug \"Found a factoid.\"\n if factoid[2].gsub!(/^\\<reply\\>/i, '')\n return factoid[2]\n else \n return \"#{factoid[0]} #{factoid[1]} #{factoid[2]}\"\n end\n elsif factoid = fetch_alias(string)\n# factoid = fetch_alias(string)\n return \"#{factoid[0]} #{factoid[1]} #{factoid[2]} (alias of #{string})\"\n else \n return fetch_like_facts(string)\n end\n end",
"def find_user_key(str)\n str = str[1..-1] if str[0] == \"@\" # deal with @user\n str = str[2..-1] if (/<@\\w*>/).match(str) # deal with @user that slack has garbled\n if @users.include?(str)\n return str\n else\n @users.each do |key, hash|\n return key if hash.values.include?(str)\n end\n end\n return nil\n end",
"def grabToken(astring)\r\n if astring =~ /([0-9a-fA-F]{32})/\r\n return $1\r\n end\r\n return nil\r\n end",
"def split_userinfo(ui)\n return nil, nil unless ui\n user, password = ui.split(':', 2)\n\n return user, password\n end",
"def get_community_string(string)\n string\n end",
"def find_members(event, string)\n if event.respond_to?(:message) && event.message.mentions.empty? && !string\n event.respond I18n.t(\"commands.common.no_user_matched\")\n nil\n elsif event.respond_to?(:message) && !event.message.mentions.empty?\n event.message.mentions\n else\n regex = Regexp.new(string)\n server = resolve_server(event)\n server.members.select { |member|\n member.respond_to?(:display_name) && member.display_name =~ regex ||\n member.respond_to?(:username) && member.username =~ regex ||\n member.respond_to?(:distinct) && member.distinct =~ regex\n }\n end\n rescue NoMethodError\n nil\n end",
"def parse_mention(mention)\n # Mention format: <@id>\n return nil unless /<@!?(?<id>\\d+)>?/ =~ mention\n user(id.to_i)\n end",
"def getRole (user)\n case user.role\n when 0\n return 'user'\n when 1\n return 'operator'\n when 2\n return 'cto_user'\n when 3\n return 'owner'\n when 4\n return 'anonymous'\n else\n raise ('invalid user' + user.role)\n end\n end",
"def get(string)\n @strings[string]\n end",
"def extract_user_id(username)\n username[2..-2]\n end",
"def read(str)\n if self.instance_of?(DUID)\n super\n case type\n when 1\n DUID_LLT.new.read(str)\n when 2\n DUID_EN.new.read(str)\n when 3\n DUID_LL.new.read(str)\n else\n self\n end\n else\n private_read str\n end\n end",
"def parse(meme, string)\n MEMES[meme].match(string).to_a[1..-1]\n end",
"def get_role(user, field='role')\n case user\n when String\n user\n when Hash\n user[field] || user[field.to_sym]\n else\n user.send(field.to_sym)\n end\n end",
"def from_string(value)\n const_get(value)\n rescue NameError\n UserRole.send(:new, 'UNKNOWN', value)\n end",
"def role_str\n if (role == nil)\n role_result = \"participant\"\n else\n role_result = role\n end\n role_result\n end",
"def find_one_member(event, string, check_int = false)\n return string if check_int && string == string.gsub(/\\D/, '')\n return nil unless (event.respond_to?(:message) && !event.message.mentions.empty?) || (!string.nil? && !string.empty?)\n members = self.find_members(event, string)\n if members && string && members.size > 1\n member = members.find { |member| member.display_name == string || member.username == string || member.distinct == string}\n if member\n return member\n else\n event.respond I18n.t(\"commands.common.too_many_matches\", {\n matches: members.map(&:distinct).map { |identifier| \"-#{identifier}\" }.join(\"\\n\")\n })\n nil\n end\n else\n members.first\n end\n end",
"def parse_player(\n msg, # Text string to parse\n username, # Name of Discord user, to infer player name\n userlevel = false, # Whether to search in for userlevel players or regular ones\n explicit = false, # Only parse explicit names, without inferring from username\n enforce = false, # Even more, raise exception if no explicit name found\n implicit = false, # The opposite, only infer from username\n third = false # Allow 3rd person specification (e.g. \"is xela\" rather than \"for xela\")\n )\n msg = msg.gsub(/\"/, '')\n p = msg[/(for|of#{third ? '|is' : ''}) (.*)[\\.\\?]?/i, 2]\n playerClass = userlevel ? UserlevelPlayer : Player\n\n # We make sure to only return players with metanet_ids, ie., with highscores.\n if implicit\n parse_player_implicit(username, playerClass)\n else\n if p.nil?\n if explicit\n if enforce\n raise OutteError.new \"You need to specify a player for this function.\"\n else\n nil\n end\n else\n parse_player_implicit(username, playerClass)\n end\n else\n parse_player_explicit(p, playerClass)\n end\n end\nend",
"def normalise_string(string)\n # Is it already one of the methods? If so, easy. If not, split and parse.\n if string == \"_\"\n []\n elsif Col::DB.method? string\n [ string.intern ]\n elsif (1..4).include? string.size # say: \"g\", \"gb\", \"gbow\"\n color, style, backg = extract(string)\n color = Col::DB.color(color) # 'g' -> :green\n style = Col::DB.style(style) # 'b' -> :bold\n backg = Col::DB.background(backg) # 'ow' -> :on_white\n [ color, style, backg ].compact # remove nil elements\n else\n raise Col::Error, \"Invalid item: #{string.inspect}\"\n end\n rescue Col::Error => e\n raise Col::Error, \"Invalid item: #{string.inspect} (#{e.message})\"\n end",
"def slack_user_or_channel(assignee)\n if assignee.include?(\"@\")\n client.lookup_user_by_email(assignee)\n else\n { \"user\" => { \"id\" => assignee } }\n end\n end",
"def parse_string(str)\n return str if str.include?('%')\n constants, *attributes = str.split('#')\n value = Object.const_get(constants)\n while (attribute = attributes.shift)\n value = value.send(attribute) unless attribute.empty?\n end\n return value\n end",
"def extract_class(string)\n uncapitalize(string.split('::').last)\n end",
"def hosts_for(string)\n first = string[/^(\\w+)\\.\\w+/, 1]\n if role = @roles.find { |r| r.name == first }\n return role.hosts\n else\n raise \"Sorry, I didn't understand what hosts to run #{string.inspect} on.\"\n end\n end",
"def awesome_string(string)\n lexers = ::Rouge::Guessers::Source.new(string).filter(R_LEXERS)\n if !lexers.empty?\n format_syntax_string(string, lexers.first)\n elsif string =~ /(?:\\r?\\n)(?!\\z)/\n format_multiline_string(string)\n else\n format_plain_string(string)\n end\n end",
"def id_and_name_from(string)\n string =~ /[^0-9a-f]/i ? [nil, string] : [string, nil]\n end",
"def parse_msg_id(str, opt={})\n msg_id_list(str, opt)[0]\n end",
"def read(str)\n msg_type = Types::Int8.new.read(str)\n\n case msg_type\n when 12, 13\n DHCPv6::Relay.new.read(str)\n else\n super\n end\n end",
"def find_command(command, str)\n #split on first instance of command char\n parsed = str.split(@command_char, 2)\n if parsed.first == command\n return self.parse_value(parsed.last)\n else\n return nil\n end\n end",
"def char_data_for(char_string)\n id = char_string.ord\n @char_data.select{|cd| cd.id == id}.first\n end",
"def[](str)\n user_data[str.to_sym]\n end",
"def attribute(string)\n\n attribute_name = \"\"\n attribute_value = \"\"\n\n length = string.length\n position = 0\n\n return [nil, nil] if length == 0 \n\n while position < (length)\n\n # If character matches 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x2F (ASCII /) then advance position\n if string[position] =~ /[\\u{09}\\u{0A}\\u{0C}\\u{0D}\\u{20}\\u{2f}]/\n \n position += 1\n \n elsif string[position] == '>'\n\n attribute_name = nil\n break\n\n else\n\n while position < length\n \n if string[position] == '=' && attribute_name != ''\n\n attribute_value, position_increment = attribute_value(string[position + 1, length])\n\n position += position_increment + 1\n\n break\n\n elsif string[position] =~ /[\\>\\/]/\n \n break\n \n elsif string[position] =~ /[A-Z]/\n\n attribute_name += string[position].downcase\n position += 1\n\n else\n attribute_name += string[position]\n position += 1\n end\n\n end\n\n break\n\n end\n\n end\n\n if attribute_name\n [{attribute_name: attribute_name, attribute_value: attribute_value}, position]\n else\n [nil, position]\n end\n\n end",
"def find_command(command, str)\n #split on first instance of command char\n parsed = str.split(@command_char, 2)\n if parsed.first == command\n return self.parse_value(parsed.last)\n else\n return nil\n end\n end",
"def grab_ssn(string)\n\tssn = /\\d{3}[^\\d]?\\d{2}[^\\d]?\\d{4}/\n\treturnString = \"\"\n\tif ssn =~ string\n\t\treturnString = string.scan(ssn)\n\t\treturn returnString[0]\n\telse\n\t\t#puts \"not match\"\n\t\treturn nil\n\tend\nend",
"def username\n email.match(/[^@]+/).to_s\n end",
"def gender\n #TODO add check if char is 'm' or 'f' and if necessary\n # throw an exception\n @avatar_string[0].downcase\n end",
"def get_error_message(str)\n tmp=str.scan(/^ERROR MESSAGE --8<------\\n(.*?)ERROR MESSAGE ------>8--$/m)\n return \"Error message not available\" if !tmp[0]\n tmp[0][0].strip\n end",
"def extract_protocol(protocol_string)\n [\"name\", \"shared\", \"guest access\", \"inherit perms\"].inject({}) do |hash, key|\n hash[key] = protocol_value_for_key_in_string(key, protocol_string)\n hash\n end\n end",
"def extract_identity(uri)\n return $1.downcase if uri =~ %r[/user/([a-zA-Z_1-9-]*)] || uri =~ %r[://([a-zA-Z_1-9-]*)?\\.#{AppConfig.host(request.host)}] || uri =~ %r[://(.*?)/?$]\n return nil\n end",
"def extract_login\n key_pieces = self.ssh_key.split(\" \")\n return key_pieces[2] if key_pieces.size == 3\n end",
"def string_username\n CaseInsensitiveString.str(current_user.getUsername())\n end",
"def normalise_nick(nick)\n return /^[@+]?(.*)$/.match(nick)[1]\n end",
"def extract_user(*args)\n user = if args.first.is_a?User\n args.shift\n end\n user\n end",
"def get_user(username)\n Chef::Log.info username\n user = @node[:users][username]\n Chef::Log.info user.inspect\n user\nend",
"def getRole jid\n\t\tuser = @users.read ['role'], ['jid', jid]\n\t\tif user.count > 0\n\t\t\tuser[0]['role']\n\t\telse\n\t\t\tnil\n\t\tend\n\tend",
"def user_name\n decode_string_member(:user_name)\n end",
"def get_user(buf) \r\n return nil if buf[40,4].unpack('L').first <= 0 # UserSidLength\r\n\r\n name = 0.chr * MAX_SIZE\r\n name_size = [name.size].pack('L')\r\n domain = 0.chr * MAX_SIZE\r\n domain_size = [domain.size].pack('L')\r\n snu = 0.chr * 4\r\n \r\n offset = buf[44,4].unpack('L').first # UserSidOffset\r\n \r\n val = LookupAccountSid(\r\n @server,\r\n [buf].pack('P').unpack('L').first + offset,\r\n name,\r\n name_size,\r\n domain,\r\n domain_size,\r\n snu\r\n )\r\n \r\n # Return nil if the lookup failed\r\n return val ? name.nstrip : nil\r\n end",
"def parse_userlevel_author(msg, remove: false)\n name, msg = parse_term(msg, quoted: ['author id'], remove: true)\n if !name.empty? && is_num(name)\n name = name.strip.to_i\n else\n name, msg = parse_string_or_id(msg, quoted: ['by', 'author'], final: ['by'], remove: true)\n name.strip! if name.is_a?(String)\n end\n remove ? [name, msg] : name\nrescue\n remove ? ['', msg] : ''\nend",
"def get_error_message(str)\n tmp=str.split(/\\n/)\n return \"Unknown error\" if !tmp[0]\n tmp[0]\n end",
"def _extract(string, subscriber_digits, code_digits)\n [string[0, code_digits], string[code_digits, subscriber_digits]]\n end",
"def to_type(str)\n if str && type && !mapping\n send(\"parse_#{type}\", str)\n elsif str && mapping && mapping.values.map(&:to_s).include?(str)\n mapping.find { |_, v| v.to_s == str.to_s }[0]\n else\n str\n end\n end",
"def read_string\n\t\t\n\t\t# TODO: Add the ability to have escape characters.\n\t\tstart_char \t= @chars.next # Don't add quotation marks to the string value\n\t\tline_num \t= @chars.get_cur_line\n\t\tcol_num \t= @chars.get_cur_col\n\t\ttok_val \t= ''\n\n\t\twhile true\n\t\t\tbegin\n\t\t\t\tchar = @chars.peak\n\t\t\trescue EOFError\n\t\t\t\traise \"LEXER ERROR: At line: #{line_num}, col: #{col_num} >> String does not end.\"\n\t\t \t\treturn nil\n\t\t \tend\n\n\t\t \tif char == start_char\n\t\t \t\treturn Token.new(\"String\", tok_val, line_num, col_num)\n\t\t \tend\n\t\t \ttok_val += char\n\t\t \t@chars.next\n\t\tend\n\tend",
"def get_user(access_token_str)\r\n @access_token = get_access_token_by(access_token_str)\r\n resp = get_userinfo\r\n case resp\r\n when Net::HTTPSuccess\r\n @userinfo = JSON.parse(resp.body)\r\n parse_user_id(@userinfo)\r\n else\r\n err = \"Can't get user info: <br/>#{resp.body}\"\r\n end\r\n err\r\n end",
"def get_channel_for(level, user = nil)\n if user\n # \"answers\" are in the channel so instead of doing\n # set_level_source to load answers when looking at another user,\n # we have to load the channel here.\n user_storage_id = storage_id_for_user_id(user.id)\n channel_token = ChannelToken.find_channel_token(level, user_storage_id)\n else\n user_storage_id = storage_id('user')\n channel_token = ChannelToken.find_or_create_channel_token(\n level,\n request.ip,\n user_storage_id,\n {\n hidden: true,\n }\n )\n end\n\n channel_token.try :channel\n end",
"def parse! str\n if md = match(str)\n caps = md.captures\n str.replace str[md.offset(0)[1]..-1]\n caps\n else\n nil\n end\n end",
"def str_to_val(str)\n # todo: expand\n if $vars.has_key? str\n $vars[str]\n elsif str == \"line\" or str == \"stdin\" or str == \"readline\"\n $stdin.gets\n else\n str.to_f\n end\nend",
"def get_user_login\n #self.network_login.blank? ? self.login : self.network_login.split('-',2)[1]\n self.get_network_login.blank? ? \"\" : self.get_network_login.gsub(self.primary_network.coded_name+'-', '') rescue ''\n end",
"def read_user_emailtoken(emailtoken)\n filter = Net::LDAP::Filter.eq(ENTITY_ATTR_MAPPING[:emailtoken].to_s, emailtoken)\n return search_map_user_fields(filter, 1)[0]\n end",
"def find_twitter_handle\n self.match(/(\\@\\w+)/i)\n return $1\n end",
"def username\n @username ||= match[3]\n end",
"def g_unpack(str)\n codepoints = str.unpack('U*')\n unpacked = []\n pos = 0\n marker = 0\n eoc = codepoints.length\n while(pos < eoc)\n pos += 1\n previous = codepoints[pos-1]\n current = codepoints[pos]\n if (\n # CR X LF\n one = ( previous == UCD.boundary[:cr] and current == UCD.boundary[:lf] ) or\n # L X (L|V|LV|LVT)\n two = ( UCD.boundary[:l] === previous and in_char_class?(current, [:l,:v,:lv,:lvt]) ) or\n # (LV|V) X (V|T)\n three = ( in_char_class?(previous, [:lv,:v]) and in_char_class?(current, [:v,:t]) ) or\n # (LVT|T) X (T)\n four = ( in_char_class?(previous, [:lvt,:t]) and UCD.boundary[:t] === current ) or\n # X Extend\n five = (UCD.boundary[:extend] === current)\n )\n else\n unpacked << codepoints[marker..pos-1]\n marker = pos\n end\n end \n unpacked\n end",
"def parse_string_or_id(msg, quoted: nil, final: nil, remove: false)\n name, msg = parse_term(msg, quoted: quoted, remove: true)\n return (remove ? [name, msg] : name) if !name.empty?\n name, msg = parse_term(msg, final: final, remove: true)\n name = name.strip.to_i if is_num(name)\n return (remove ? [name, msg] : name)\nrescue\n remove ? ['', msg] : ''\nend",
"def grab_ssn(string)\n regexp_key = /(\\d{3}-\\d{2}-\\d{4})/\n\n if regexp_key.match(string)\n regexp_key.match(string)[0]\n else\n \"\"\n end\nend",
"def get_user_email(role)\n get_user(role).email\n end",
"def naive_string_scraper(string)\n if (is_file?(string) == true)\n return file_provider(string)\n else\n providers = provider_list()\n host = URI.parse(string).host\n if !host.nil?\n return providers[host.downcase]\n else\n return \"none\" # takes care of nil cases, fucking hashes are teh shit\n end\n end\n end",
"def get_role_or_nil\n if user_type == \"UserControl\"\n \"UserControl\"\n elsif user_signed_in?\n current_user.role.name\n else\n nil\n end\n end",
"def from_string(string)\n UUID.parse(string)\n end",
"def get_token(string)\n case string\n when /'(\\S+)/\n $1\n when *$token_table.keys\n $token_table[string]\n when $pats[:int]\n $&.to_i\n when /\\A\n \\[\n (.*)\n \\]\n \\Z/x\n a = $1.split(/\\s*,\\s*/)\n a.collect{|elem| get_token(elem)}\n else\n string\n end\nend",
"def get_message(*args)\n args.last if args.last.is_a?(String)\n end",
"def person_from_person_string( person_string )\n\n # where the values are in the person string\n person_index_ix = 0\n person_cid_index = 1\n person_fn_index = 2\n person_ln_index = 3\n person_dept_index = 4\n person_pub_index = 5\n\n tokens = person_string.split( \"\\n\" )\n return nil if tokens.length < 5\n ix = tokens[ person_index_ix ].to_i\n tokens.each &:chomp!\n return person_construct( ix,\n tokens[ person_fn_index ],\n tokens[ person_ln_index ],\n tokens[ person_cid_index ],\n tokens[ person_dept_index ],\n tokens[ person_pub_index ],\n 'RelatedPerson'\n )\n end",
"def get_role\n return case self.role_id\n when 2\n \"User\"\n else\n \"N/A\"\n end\n end",
"def get_principal(principal_id)\n if principal_id =~ /(.+)-(\\d+)/\n if Regexp.last_match(1).classify == UserGroup.to_s\n UserGroup.find(Regexp.last_match(2))\n elsif Regexp.last_match(1).classify == User.to_s\n User.find(Regexp.last_match(2))\n else\n Exception.new(\"Invalid principal type passed: #{Regexp.last_match(1)}. Must be UserGroup or User.\")\n end\n end\n end",
"def get_user\n instance_variable_get(\"@#{user_type}\")\n end",
"def command_from_text(text, username = nil)\n return unless text\n match = text.match CMD_REGEX\n return unless match\n return if match[3] && username != true && match[3] != username\n [match[1], text.split.drop(1)]\n end",
"def get_user_name(role)\n get_user(role).full_name\n end",
"def provider\n return nil unless user_id\n user_id.split('/').last\n end",
"def provider\n return nil unless user_id\n user_id.split('/').last\n end",
"def tweet_user(tweet) \n if ! tweet.is_a?(String)\n base = tweet.has_key?(:from_user) ? tweet[:from_user] : tweet[:user][:screen_name]\n else\n base = tweet\n end\n base =~ /^@/ ? base : \"@#{base}\"\n end",
"def match_and_parse(string)\n meme = match(string)\n if meme.nil?\n return meme\n end\n bits = parse(meme, string)\n [meme, bits]\n end",
"def user_agent(string)\n string = string.to_s\n return nil if string.empty?\n UserAgent.new(string)\n end",
"def get_username( session, data )\n username = session.gets.chomp\n unless data[username]\n debug_msg \"NOT AUTHORIZED. Unknown username \\\"#{username}\\\". Closing session with #{session.peeraddr[2]} #{Time.now}\"\n session.puts \"NOT AUTHORIZED\"\n session.close\n return false\n end\n return username\n end",
"def protocol_value_for_key_in_string(key, string)\n string.split(/#{key}:\\t*/)[1].to_s.split(\"\\n\").first\n end",
"def username\n @username ||= match[3]\n end",
"def search_for_character(channel, person)\n if @rooms[channel]['characters'].include? person\n return person\n else\n re = /\\A#{Regexp.escape(person)}\\z/i\n @rooms[channel]['characters'].each { |char|\n if char =~ re\n return char\n end\n }\n end\n return nil\n end",
"def [](str)\n letters = (\"a\"..\"h\").to_a\n return nil unless /[a-h][1-8]/.match?(str)\n @board.at([letters.find_index(str[0]), str[1].to_i - 1])\n end",
"def extract_variables_from_string(string)\n string.split(/ /).map do |defintion|\n match = defintion.match STRING_REG_EX\n next nil unless match\n\n { match[1] => match[2] }\n end.reject(&:nil?)\n end",
"def login_user(user)\n case user\n when /ubuntu/\n 'ubuntu'\nwhen /debian/\n 'root'\nwhen /amazon/\n 'ec2-user'\nwhen /rhel/,/centos/,/redhat/\n 'centos'\nend\nend",
"def decode_string_member(member)\n return nil if @cred_struct[member].null?\n\n @cred_struct[member]\n .read_string_dn\n .force_encoding('utf-16le')\n .strip\n end",
"def read(str)\n read_type = str[0].unpack('C').first\n if read_type.zero?\n Pad.new.read(str)\n elsif read_type == 255\n End.new.read(str)\n elsif DHCP_OPTIONS.key?(read_type)\n Option.new(DHCP_OPTIONS[read_type][1] || {}).private_read(str)\n else\n super\n end\n end",
"def get(str)\n puts \"getting \" + str\n char = str[0] || TERM_CHAR\n next_node = find_child(char)\n return nil if next_node.nil?\n if str == ''\n next_node\n else\n next_node.get(str[1..-1])\n end\n end",
"def charset_from_meta_content(string)\n\n charset_match = string.match(/charset\\s*\\=\\s*(.+)/i)\n\n if charset_match\n\n charset_value = charset_match[1]\n\n charset_value[/\\A\\\"(.*)\\\"/, 1] ||\n charset_value[/\\A\\'(.*)\\'/, 1] ||\n charset_value[/(.*)[\\s;]/, 1] ||\n charset_value[/(.*)/, 1]\n else\n nil\n end\n\n end",
"def process_username(pid)\n uid = File.stat(\"/proc/#{pid}\").uid\n File.foreach('/etc/passwd').each do |line|\n if line.split(':')[2] == \"#{uid}\"\n return line.split(':')[0]\n end\n end\n end",
"def get_user(name, user_list = users)\n return name if name.instance_of?(GoodData::Membership)\n name.downcase!\n user_list.each do |user|\n return user if user.uri.downcase == name ||\n user.login.downcase == name ||\n user.email.downcase == name\n end\n nil\n end",
"def user_name\n @message[:user][:name]\n end",
"def determine_status(msg, user = msg.user)\n return \"\" unless msg.channel # This is nil for leaving users\n return \"\" unless user # server-side NOTICEs\n\n user = user.name if user.kind_of?(Cinch::User)\n\n if user == bot.nick\n \"selfbot\"\n elsif msg.channel.opped?(user)\n \"opped\"\n elsif msg.channel.half_opped?(user)\n \"halfopped\"\n elsif msg.channel.voiced?(user)\n \"voiced\"\n else\n \"\"\n end\n end",
"def tag_from(str)\n letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'\n numbers = '0123456789'\n if str.length < 2\n nil\n else\n if (str[0]=='<') && (str[-1]=='>')\n text = str.gsub('<','').gsub('>','').gsub('/','')\n if (text.length == 0) || !letters.include?(text[0])\n nil\n else\n text.split(\" \").first.downcase\n end\n else\n nil\n end\n end\nend",
"def extract_id(str)\n str.to_s.scan(/\\d+/)\n end",
"def parse_types(string)\n types = []\n letters = ['F', 'I', 'L', 'N', 'P', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']\n letters.each_with_index { |letter,index| \n if string.upcase.include?(letter)\n types << index\n end\n }\n types\n end",
"def parse_user search\n Hash[*search.split(',').map{|pair| pair.split('=').values_at(0..1)}.flatten]['uid']\n end",
"def get_token_from_auth_data(auth_data)\n auth_data.split(\" \")[1]\nend"
] | [
"0.5832218",
"0.5755608",
"0.57496285",
"0.5570609",
"0.5467127",
"0.53940785",
"0.53851926",
"0.5309725",
"0.5282062",
"0.5227845",
"0.5220234",
"0.5148466",
"0.5141419",
"0.5109705",
"0.51054627",
"0.5098822",
"0.5064514",
"0.5039539",
"0.50152624",
"0.50080794",
"0.4988408",
"0.49857834",
"0.49295273",
"0.49258828",
"0.49180833",
"0.48966378",
"0.48946303",
"0.48876172",
"0.48840088",
"0.48761544",
"0.48613212",
"0.48563257",
"0.48562524",
"0.48436618",
"0.48351458",
"0.4822011",
"0.4806185",
"0.4799988",
"0.4793222",
"0.4789421",
"0.4762426",
"0.4755901",
"0.47519583",
"0.4740389",
"0.47259563",
"0.47128963",
"0.47101054",
"0.47082168",
"0.47066003",
"0.46871403",
"0.46786824",
"0.46757174",
"0.46749198",
"0.4673923",
"0.46718687",
"0.46712205",
"0.4650798",
"0.46500814",
"0.46419454",
"0.46370703",
"0.46336356",
"0.46318036",
"0.46297702",
"0.46180296",
"0.46177077",
"0.46147817",
"0.46138376",
"0.46062794",
"0.45969158",
"0.4586794",
"0.4582681",
"0.45761216",
"0.45760906",
"0.45668808",
"0.45599863",
"0.45576936",
"0.45576936",
"0.45411968",
"0.45370874",
"0.45245638",
"0.4521843",
"0.4515131",
"0.45018008",
"0.44945595",
"0.44929683",
"0.4490734",
"0.4489255",
"0.44885015",
"0.44867828",
"0.44818342",
"0.44810793",
"0.44791803",
"0.44776288",
"0.44774488",
"0.44766322",
"0.44724587",
"0.44692227",
"0.44652286",
"0.44610646",
"0.44556808"
] | 0.47010303 | 49 |
Sets the currently playing game to the specified game. | def game=(name)
gateway_check
update_status(@status, name, nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_game\n @game = Game.find(params[:game_id] || params[:id])\n end",
"def set_game\n @game = Game.find(params[:game_id] ||= params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = current_user.games.find(params[:id]||params[:game_id])\n end",
"def set_game\n @game = Game.find(params[:game_id])\n end",
"def set_game\n @game = Game.find(params[:game_id])\n end",
"def set_game\n @game = Game.find(params[:game_id])\n end",
"def set_game\n @game = Game.find(params[:game_id])\n end",
"def set_game\n @game = current_creator.games.find(params[:id])\n end",
"def set_game\n @game = game.find(params[:id])\n end",
"def set_game\n @game = current_club_player.games.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n\t\t@game = Game.find(params[:id])\n\tend",
"def set_game\n\t @game = Game.find(params[:id])\n\t end",
"def set_game\n @game = Admin::Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:game_id])\n end",
"def set_game\n @game = Game.find(params[:id])\n if current_user.nil?\n if @game != current_game_owner.game\n redirect_to root_path, alert: 'No tiene permiso para acceder a este juego'\n end\n end\n end",
"def set_game\n @game = Game.find_by(id: params[:id])\n if(!@game)\n respond_to do |format|\n format.html { redirect_to games_path, alert: 'An Error occurred.' }\n format.json { render :show, status: :ok, location: games_path }\n end\n return\n elsif (@game.name != params[:name])\n respond_to do |format|\n format.html { redirect_to games_path, alert: 'Wrong game name.' }\n format.json { render :show, status: :ok, location: games_path }\n end\n return\n end\n\n session[:current_game_name] = @game.name\n if user_signed_in? && @game.user_id == 1\n @game.user_id = current_user.id\n end\n end",
"def set_game\n if Game.where(id: params[:id]).exists?\n @game = Game.find(params[:id])\n else\n @game = Game.new\n end\n end",
"def set_game\n @game = Game.find(params[:id])\n p @game\n end",
"def set_game\n id = params[:id]\n if id == nil\n id = params[:game_id]\n end\n if id != nil \n @game = Game.find(id)\n end\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n end",
"def set_game_player\n @game_player = GamePlayer.find( params[:id] )\n end",
"def set_game_play\n @game_play = GamePlay.find(params[:id])\n end",
"def set_game\n @game = Game.find(params[:id])\n unless @logged_in and @logged_in.update_site?\n @game.readonly!\n end\n end",
"def set_game\n id = params[:id]\n if id != nil \n @game = Game.find(id)\n end\n end",
"def set_game_player\n @game_player = GamePlayer.find( params[:id] )\n end",
"def set_user_game\n @user_game = UserGame.find(params[:id])\n end",
"def set_user_game\n @user_game = UserGame.find(params[:id])\n end",
"def set_gameplay\n @gameplay = Gameplay.find(params[:id])\n end",
"def set_game_name(game)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.Run_set_game_name(@handle.ptr, game)\n end",
"def set_game_name(game)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_set_game_name(@handle.ptr, game)\n end",
"def set_playedgame\n @playedgame = Playedgame.find(params[:id])\n end",
"def set_games_player\n @games_player = GamesPlayer.find(params[:id])\n end",
"def game=(name)\n gateway_check\n update_status(@idletime, name, nil)\n name\n end"
] | [
"0.778316",
"0.77164775",
"0.7599855",
"0.7599855",
"0.7590458",
"0.7547372",
"0.7547372",
"0.7547372",
"0.7547372",
"0.7505413",
"0.7444924",
"0.7390804",
"0.73714924",
"0.73710436",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.73702544",
"0.7370056",
"0.730482",
"0.72188467",
"0.7117297",
"0.7002586",
"0.6997521",
"0.69574153",
"0.69362175",
"0.6925153",
"0.68783015",
"0.6872048",
"0.6872048",
"0.6872048",
"0.6872048",
"0.6872048",
"0.6872048",
"0.6872048",
"0.6872048",
"0.6872048",
"0.6872048",
"0.6872048",
"0.6872048",
"0.68378824",
"0.6753059",
"0.6738532",
"0.67006904",
"0.668603",
"0.6628237",
"0.6628237",
"0.66254663",
"0.65864366",
"0.6577608",
"0.65743",
"0.65591073",
"0.6536562"
] | 0.6583807 | 96 |
Sets the current listening status to the specified name. | def listening=(name)
gateway_check
update_status(@status, name, nil, nil, nil, 2)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def watching=(name)\n gateway_check\n update_status(@status, name, nil, nil, nil, 3)\n end",
"def set_listening\n @listening = Listening.find(params[:id])\n end",
"def name=(name)\n update_channel_data(name: name)\n end",
"def competing=(name)\n gateway_check\n update_status(@status, name, nil, nil, nil, 5)\n end",
"def set(name)\n @name = name\n self\n end",
"def set_status(val)\n self.status = val\n self\n end",
"def game=(name)\n gateway_check\n update_status(@status, name, nil)\n end",
"def on_name_changed(new_name:, **)\n @name = new_name\n end",
"def set_listen\n @listen = Listen.find(params[:id])\n end",
"def set_status(target, status)\n target.status = status\n end",
"def set_status\n self.status = 1\n end",
"def set_Status(value)\n set_input(\"Status\", value)\n end",
"def set_Status(value)\n set_input(\"Status\", value)\n end",
"def set_name(name)\n @name = name\n end",
"def name=(name_to_be_set)\n @name = name_to_be_set\n end",
"def register(song_name)\n prior_play = @current_user.listens.select{|listen| listen.name == song_name}.first\n if prior_play\n @current_listen = prior_play\n @current_listen.plays += 1\n else\n @current_listen = Listen.new\n @current_listen.name = song_name\n @current_listen.plays = 1\n @current_user.listens << @current_listen\n end\n end",
"def change_name=(name)\n @name = name\n end",
"def set_name=(name)\n @name = name\n end",
"def update_listen(l)\n\t\treturn unless listen?\n\t\t\n\t\tbegin\n\t\t\tcase provider\n\t\t\twhen \"facebook\"\n\t\t\t\tupdate_listen_on_facebook(l)\n\t\t\tend\n\t\trescue Exception => e\n\t\t\tlogger.debug \"error updating listen on service: #{provider}\"\n\t\t\tcatch_error(l, e)\n\t\tend\n\tend",
"def name=(new_name)\n changeset.append(:name_changed, old_name: @name, new_name: new_name)\n end",
"def collins_set_needs_rename!\n state = collins_osc_state\n state.merge!({\n 'running' => false,\n 'finished' => Time.now.to_i,\n 'current_state' => \"needs_rename\",\n 'next_state' => \"can_be_altered\"\n })\n\n self.collins_osc_state = state\n end",
"def set_access_vlan(name, opts = {})\n cmd = command_builder('switchport access vlan', opts)\n configure_interface(name, cmd)\n end",
"def set_status(name, deliver_emails_now = true, options = {})\n name = name.to_s if name.is_a?(Symbol)\n @type = ApplicationStatusType.find_or_create_by_name(name)\n @status = self.application_statuses.find_by_application_status_type_id(@type, :order => 'updated_at DESC')\n if @status.nil? || @status != self.current_status || options[:force] == true\n @status = self.application_statuses.create :application_status_type_id => @type.id\n @status.update_attribute(:note, options[:note]) unless options[:note].blank?\n self.save; self.reload\n self.send_status_updates(@status, deliver_emails_now)\n end\n update_attribute(:current_application_status_id, @status.id)\n self.status\n end",
"def set_status\n self.status = Status.find_by(code: \"OPEN\")\n end",
"def service_name(name)\n @name = name\n end",
"def set_portname(switchwwn, portwwns, portname)\n result = @ports.set_portname(switchwwn, portwwns, portname)\n result[1]\n end",
"def name_setter(new_name)\n @name = new_name\n end",
"def on_status(&f)\n @on_status = f\n end",
"def set_name(a_name)\n @name = a_name\n end",
"def status=(val)\n unless [nil, :frozen, :live].include?(val)\n raise ArgumentError.new(\"Status must be :frozen or :live\") \n end\n @status = val\n end",
"def set_event_status( event, status )\n event.instance_exec( namespace ) { |namespace| set_status(status, namespace) }\n end",
"def listen(backlog)\r\n SocketError.check if (ret = Winsock.listen(@fd, backlog)) == -1\r\n ret\r\n end",
"def setName(name)\n @name = name\n end",
"def name=(new_name)\n write_attribute(:name, EventType.event_name_formatter(new_name))\n end",
"def status=(value)\n value = value.to_s.to_sym\n fail Deployment::InvalidArgument, \"#{self}: Invalid task status: #{value}\" unless ALLOWED_STATUSES.include? value\n status_changes_concurrency @status, value\n @status = value\n reset_forward if DEPENDENCY_CHANGING_STATUSES.include? value\n @status\n end",
"def setName(name)\r\n\t\t\t\t\t@name = name\r\n\t\t\t\tend",
"def setName(name)\r\n\t\t\t\t\t@name = name\r\n\t\t\t\tend",
"def setName(name)\r\n\t\t\t\t\t@name = name\r\n\t\t\t\tend",
"def setName(name)\r\n\t\t\t\t\t@name = name\r\n\t\t\t\tend",
"def setName(name)\r\n\t\t\t\t\t@name = name\r\n\t\t\t\tend",
"def status=(status)\n @_status = status\n end",
"def status=(status)\n @_status = status\n end",
"def update_status!\n status = :online\n\n if !is_port_open?(@address, @port)\n status = :offline\n end\n\n if status != @status\n time = Time.now\n if status == :offline\n puts \"Server is currently offline\"\n else\n puts \"Server is currently online\"\n end\n\n @status = status\n if @status == :online\n @last_status_change = @last_launch\n else\n @last_status_change = time\n end\n end\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def status=(value)\n @status = value\n end",
"def setStatusInfo(name, value)\n @device.setStatusInfo(name,value) ;\n end",
"def mark_as(status)\n self.status = status\n self.save\n end",
"def active_set_name(name)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_active_set_name(@handle.ptr, name)\n end",
"def set_StatusUpdate(value)\n set_input(\"StatusUpdate\", value)\n end",
"def on_node_name_set( node, name )\n\t\t\tself.log.debug \"unhandled on_node_name_set: %p is now named %p\" % [ node, name ]\n\t\tend",
"def status=(status)\n validator = EnumAttributeValidator.new('String', ['available', 'assigned', 'activated', 'deprecated'])\n unless validator.valid?(status)\n fail ArgumentError, 'invalid value for \"status\", must be one of #{validator.allowable_values}.'\n end\n @status = status\n end",
"def status=(status)\n validator = EnumAttributeValidator.new('String', [\"LIVE\", \"QUARANTINED\", \"REMOVED\"])\n unless validator.valid?(status)\n fail ArgumentError, \"invalid value for 'status', must be one of #{validator.allowable_values}.\"\n end\n @status = status\n end",
"def status_changed status\n # overwrite\n # eg. server.call_start_callback(self) if status == :ready\n end",
"def status=(status)\n validator = EnumAttributeValidator.new('String', [\"active\", \"paused\", \"ready\", \"delivered\", \"cancelled\", \"reverted\"])\n unless validator.valid?(status)\n fail ArgumentError, \"invalid value for 'status', must be one of #{validator.allowable_values}.\"\n end\n @status = status\n end",
"def set_application_name(name)\n __remote_control_command(\"setScApplicationName\", [name,])\n end",
"def status=(v)\n @status = alma_string v\n end",
"def listening?; end",
"def name=(new_name)\n @name = new_name\n end",
"def name=(new_name)\n @name = new_name\n end",
"def set_player_name(msg, name=nil)\n player = get_player msg\n unless name\n msg.reply player.name\n return\n end\n if player.name\n msg.reply \"The majestic #{player.name} refuses to change his name!\"\n return\n end\n player.name = name\n player.save\n msg.reply \"Welcome, #{player.name}!\"\n end",
"def remote_status=(value)\n if value == Status::ON\n switcher.switch_on\n elsif value == Status::OFF\n switcher.switch_off\n end\n end",
"def name=(new_name=\"\")\n (raise CloudLB::Exception::Syntax, \"Load balancer name must be 128 characters or less\") if new_name.size > 128\n (raise CloudLB::Exception::MissingArgument, \"Must provide a new name\") if new_name.to_s.empty?\n body = {\"name\" => new_name}\n update(body)\n end",
"def name=(new_name)\n @name = new_name\n end",
"def name=(name)\n tinycache_adapter.write(:name, name)\n client.api.set_room_name(id, name)\n name\n end",
"def name=(new_name)\n @name = new_name\n end",
"def name=(new_name)\n @name = new_name\n end",
"def status=(status)\n validator = EnumAttributeValidator.new('String', ['new', 'used', 'expired'])\n unless validator.valid?(status)\n fail ArgumentError, 'invalid value for \"status\", must be one of #{validator.allowable_values}.'\n end\n @status = status\n end",
"def config_update( name )\n @ndev_res.update name\n @@netdev.edit_config( @ndev_res, \"xml\" )\n end",
"def status_enum=(status)\n write_attribute(:status, status)\n end",
"def listen\r\n end",
"def listen(m)\r\n oldmask = m.user.mask.to_s.split('!')\r\n oldmask[0] = m.user.last_nick\r\n oldmask = oldmask.join('!')\r\n s = Justbot::Session.for(oldmask)\r\n if s\r\n synchronize(:session) do\r\n s.mask = m.user.mask\r\n end\r\n else\r\n debug \"no session found for mask '#{oldmask}'\"\r\n end\r\n end",
"def name=(name)\n update_role_data(name: name)\n end",
"def change_status\n\t\tif status.include?(\"available\")\n\t\t\tstatus = \"checked_out\"\n\t\telsif status.include?(\"checked_out\")\n\t\t\tstatus = \"available\"\n\t\tend\n\tend",
"def status=(status)\n check_exists\n oldstatus = SideJob.redis.getset(\"#{redis_key}:status\", status)\n if oldstatus != status && worker_config['status_publish'] != false\n SideJob::Port.group(log: false) do\n publish({status: status})\n end\n end\n end",
"def state(name)\n @state.push(name)\n end",
"def update_status(new_status)\n raise ArgumentError.new\"Invalid Status\" unless new_status == :AVAILABLE || new_status == :UNAVAILABLE\n @status = new_status\n end",
"def listening?\n true\n end",
"def set_online_status(status)\n case status\n when :available, :online\n @notification_server.chg \"NLN\", 0\n when :busy\n @notification_server.chg \"BSY\", 0\n when :idle\n @notification_server.chg \"IDL\", 0\n when :brb, :be_right_back\n @notification_server.chg \"BRB\", 0\n when :away\n @notification_server.chg \"AWY\", 0\n when :phone, :on_the_phone\n @notification_server.chg \"PHN\", 0\n when :lunch, :out_to_lunch\n @notification_server.chg \"LUN\", 0\n else\n raise \"Wrong online status: #{status}\"\n end\n end"
] | [
"0.69050187",
"0.59569013",
"0.58567226",
"0.57740796",
"0.5582599",
"0.5478112",
"0.545065",
"0.541106",
"0.53516525",
"0.5338427",
"0.53139347",
"0.52941483",
"0.52941483",
"0.528751",
"0.52463466",
"0.5237454",
"0.5224092",
"0.5213483",
"0.5198355",
"0.5149401",
"0.51388156",
"0.51357704",
"0.511702",
"0.5105331",
"0.5087936",
"0.50753677",
"0.5067129",
"0.5065393",
"0.5051603",
"0.50349444",
"0.50345695",
"0.5029653",
"0.5026857",
"0.50250834",
"0.5004139",
"0.4998142",
"0.4998142",
"0.4998142",
"0.4998142",
"0.4998142",
"0.4997849",
"0.4997849",
"0.49897268",
"0.49828184",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49820563",
"0.49805686",
"0.4963998",
"0.49529815",
"0.49482015",
"0.49465716",
"0.49461755",
"0.49422237",
"0.49378544",
"0.49333385",
"0.4928569",
"0.49248645",
"0.4917375",
"0.49080178",
"0.49080178",
"0.49048784",
"0.48909405",
"0.4877075",
"0.48687765",
"0.48675615",
"0.48671898",
"0.48671898",
"0.48670614",
"0.48670298",
"0.4865593",
"0.486487",
"0.4864238",
"0.4857881",
"0.48577395",
"0.48564503",
"0.48504254",
"0.48494852",
"0.48475",
"0.4842789"
] | 0.86877954 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.