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 |
---|---|---|---|---|---|---|
Sets the textType property value. The type of text being stored. Must be one of plain or richText | def text_type=(value)
@text_type = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_type=(value)\n self.text_type_ord = @@text_type_to_text_type_ord[value]\n end",
"def text_type\n return @text_type\n end",
"def text_type\n @@text_type_ord_to_text_type[self.text_type_ord]\n end",
"def type_is_text\n self.stimulus_type=\"text\"\n end",
"def set_Text(value)\n set_input(\"Text\", value)\n end",
"def set_Text(value)\n set_input(\"Text\", value)\n end",
"def set_Text(value)\n set_input(\"Text\", value)\n end",
"def set_text(text)\n @text = text\n end",
"def set_text(text)\n @text = text\n self\n end",
"def is_texttype?(); @type == GRT_TEXTTYPE; end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def text=(text)\n end",
"def document_type=(name)\n @document_type = name\n end",
"def document_type=(name)\n @document_type = name\n end",
"def text= t\n self.criterion_type = \"text\"\n write_attribute \"text\", t\n end",
"def set_text(text); end",
"def text=(text)\n\t\tend",
"def text?\n type == :text\n end",
"def type= (type)\n self.tweet_type = type\n end",
"def doc_type=(doc_type)\n if !doc_type.nil? && doc_type.to_s.length > 32\n fail ArgumentError, 'invalid value for \"doc_type\", the character length must be smaller than or equal to 32.'\n end\n\n @doc_type = doc_type\n end",
"def type=(type)\n write_attr :type, type\n end",
"def set_ContentType(value)\n set_input(\"ContentType\", value)\n end",
"def set_ContentType(value)\n set_input(\"ContentType\", value)\n end",
"def set_ContentType(value)\n set_input(\"ContentType\", value)\n end",
"def set_ContentType(value)\n set_input(\"ContentType\", value)\n end",
"def type=(type)\n @type = type\n\n setOption('type', @type)\n end",
"def set(text)\n wait_until_exists\n @text_field.set(text)\n end",
"def control_type \n 'text'\n end",
"def set_ContentType(value)\n set_input(\"ContentType\", value)\n end",
"def set_ContentType(value)\n set_input(\"ContentType\", value)\n end",
"def initialize( text, type = :plain )\n @type = type\n @text = text\n super wrap\n end",
"def text(text)\n @document.add_text(text)\n end",
"def is_text?(); @type == GRT_TEXT; end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def add_type\n @item.type = bibtex_type\n end",
"def type=(type)\n validate_type_values(type)\n @type = type\n end",
"def set_text(text)\n @body = TextElement.new(text)\n end",
"def initialize(type, text)\n @type, @text = type, text\n end",
"def initialize(type, text)\n @type, @text = type, text\n end",
"def set_type\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['Title', 'Body', 'CenteredTitle', 'Subtitle', 'DateAndTime', 'SlideNumber', 'Footer', 'Header', 'Object', 'Chart', 'Table', 'ClipArt', 'Diagram', 'Media', 'SlideImage', 'Picture'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def set_type(val)\n self.type = val\n self\n end",
"def content_type=(new_content_type)\n write_attribute(:content_type, new_content_type)\n end",
"def type=(type)\n self['type'] = type\n end",
"def setContenttype(contenttype)\r\n\t\t\t\t\t@contenttype = contenttype\r\n\t\t\t\tend",
"def content_type=(value)\n @content_type = value\n end",
"def text(text)\n @text = text\n end",
"def typeset!(layout_module)\n TextAreaTypesetter.new(self, layout_module).typeset!\n end",
"def content_type=(type)\n @content_type = type\n end",
"def mime_type_text\n mt = MIME::Types[content_type]&.first if content_type.present?\n\n mt.present? && (mt.friendly || mt.sub_type || mt.media_type) || UnknownMimeTypeText\n end",
"def text_anchor_type=(text_anchor_type)\n validator = EnumAttributeValidator.new('String', ['Top', 'Center', 'Bottom', 'Justified', 'Distributed', 'NotDefined'])\n unless validator.valid?(text_anchor_type)\n fail ArgumentError, 'invalid value for \"text_anchor_type\", must be one of #{validator.allowable_values}.'\n end\n @text_anchor_type = text_anchor_type\n end",
"def content_type=(new_content_type)\n @content_type = new_content_type\n end",
"def type=(type)\n @type = type\n end",
"def default_body_type=(body_type)\n @body_type = body_type\n end",
"def set_NewsType(value)\n set_input(\"NewsType\", value)\n end",
"def text(value)\n attributes[:text] = value\n end",
"def type=(type)\n if type && !VALID_TYPES.include?(type.to_sym)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\"\n end\n write_attr :type, type\n end",
"def type=(type)\n @type = type\n end",
"def set_TypeFormat(value)\n set_input(\"TypeFormat\", value)\n end",
"def type_translation=( mode )\n @type_translation = mode\n end",
"def type=(type)\n if type && !VALID_TYPES.include?(type.to_sym)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\"\n end\n write_attr :type, type\n end",
"def type=(type)\n @type = type\n end",
"def set_plain_text_input\n @plain_text_input = PlainTextInput.find(params[:id])\n end",
"def new_text=(value)\n @new_text = value\n end",
"def object_type=(object_type)\n validator = EnumAttributeValidator.new('String', [\"connector.FileMessage\"])\n unless validator.valid?(object_type)\n fail ArgumentError, \"invalid value for \\\"object_type\\\", must be one of #{validator.allowable_values}.\"\n end\n @object_type = object_type\n end",
"def set_type(name)\n @type = name\n ProcessRecord::TYPE_TABLE[name] = self\n end",
"def type=(type)\n @@type = type\n end",
"def type\n @node[\"type\"] || \"text\"\n end",
"def data_type=(value)\n @data_type = value\n end",
"def type=(value)\n @type = value.to_sym\n end",
"def initialize(type,text)\n @type = type\n @text = text\n end",
"def text?\n [:ascii, :text].include?(type)\n end",
"def type=(type)\n @type = type.to_sym\n end",
"def set_file_type\n if self.is_local?\n if self.attachment_content_type.blank?\n self.file_type = \"misc\"\n elsif self.attachment_content_type == 'application/pdf'\n self.file_type = \"pdf\"\n elsif self.attachment_content_type.include?('powerpoint')\n self.file_type = \"presentation\"\n elsif self.attachment_content_type == 'application/zip'\n self.file_type = \"zip\"\n elsif self.attachment_content_type == \"application/rtf\" || self.attachment_content_type == 'text/plain' || self.attachment_content_type == 'application/msword' || self.attachment_content_type.include?('wordprocessing')\n self.file_type = \"document\"\n elsif self.attachment_content_type.include?('spreadsheet') || self.attachment_content_type == 'ms-excel'\n self.file_type = \"spreadsheet\"\n elsif self.attachment_content_type.include?('image')\n self.file_type = \"image\"\n else\n self.file_type = \"misc\"\n end\n end\n end",
"def initialize(type,text)\r\n\t\t@type = type\r\n\t\t@text = text\r\n\tend",
"def set_type\n case @type\n when :password\n I18n.t('hidden_password')\n when :currency\n formatted_value_currency(@value)\n when :breakable\n formatted_value_breakable(@value, @break_character)\n else\n # Other types can be autodetected\n formatted_value_other(@value, @type)\n end\n end",
"def assign_type(content_type)\n self.type = MimeMapping.class_type_from(content_type).name\n end",
"def text(value)\n @doc << {:type => :text, :value => value}\n nil\n end",
"def content_type=(type)\n\t\t\tif type.index(C_slash)\n\t\t\t\t@content_type = type\n\t\t\telse\n\t\t\t\t@content_type = MIME::Types.type_for(type).first || BINARY_TYPE\n\t\t\tend\n\t\tend",
"def set_text\n @text = Text.find(params[:id])\n end",
"def set_text\n @text = Text.find(params[:id])\n end",
"def set_text\n @text = Text.find(params[:id])\n end",
"def set_text\n @text = Text.find(params[:id])\n end",
"def set_text\n @text = Text.find(params[:id])\n end",
"def type_name=(val)\n self['type_name'] = val\n end",
"def text=(text)\r\n @text = text\r\n create_image\r\n end",
"def set_type(v)\n self.type = v\n self\n end",
"def initialize(type,text)\n\t\t@type = type\n\t\t@text = text\n\tend",
"def type=(type)\n if !type.nil? && type.to_s.length > 100\n fail ArgumentError, 'invalid value for \"type\", the character length must be smaller than or equal to 100.'\n end\n @type = type\n end",
"def chat_type=(value)\n @chat_type = value\n end",
"def text=(text)\n @text = normalize_text text\n self.key= @original_key if @original_key\n end"
] | [
"0.80638033",
"0.6985656",
"0.6818505",
"0.6489027",
"0.6481006",
"0.6481006",
"0.6481006",
"0.6421707",
"0.6261249",
"0.61800843",
"0.6177417",
"0.6177417",
"0.6166765",
"0.6166765",
"0.6156105",
"0.61229956",
"0.61229956",
"0.6041295",
"0.6033856",
"0.6011113",
"0.6009698",
"0.60070074",
"0.59063536",
"0.58981824",
"0.5848486",
"0.5848486",
"0.5848486",
"0.5848486",
"0.5840993",
"0.58109254",
"0.5793923",
"0.5779992",
"0.5779992",
"0.5775519",
"0.5768576",
"0.57604516",
"0.5758718",
"0.5758718",
"0.5758718",
"0.5758718",
"0.5758718",
"0.5758718",
"0.5758718",
"0.57537925",
"0.57430375",
"0.57380444",
"0.5724246",
"0.5724246",
"0.5712729",
"0.57103956",
"0.5701791",
"0.569561",
"0.5666871",
"0.56665534",
"0.56428695",
"0.5639649",
"0.5638244",
"0.563202",
"0.56249285",
"0.56179076",
"0.5613267",
"0.5607816",
"0.5606896",
"0.56025743",
"0.5596568",
"0.5594906",
"0.5592828",
"0.55875355",
"0.55836165",
"0.5573232",
"0.5572545",
"0.5566728",
"0.556405",
"0.5562136",
"0.5549192",
"0.55451566",
"0.5523101",
"0.5520921",
"0.55030864",
"0.549163",
"0.5479178",
"0.54777914",
"0.5473608",
"0.5459796",
"0.54587525",
"0.5456971",
"0.54563624",
"0.54502755",
"0.5448751",
"0.5448751",
"0.5448751",
"0.5448751",
"0.5448751",
"0.5447097",
"0.5446489",
"0.54382396",
"0.5429961",
"0.5429103",
"0.5419713",
"0.5386578"
] | 0.86104095 | 0 |
characterizes the file_node passed into this service Default options are: save: true | def characterize(save: true)
new_file = original_file.new(file_characterization_attributes.to_h)
@file_node.file_metadata = @file_node.file_metadata.select { |x| x.id != new_file.id } + [new_file]
@persister.save(resource: @file_node) if save
@file_node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def characterize(save: true)\n persister.save(resource: @file_node) if save\n @file_node\n end",
"def characterize(save: true)\n @file_characterization_attributes = {\n width: image.width.to_s,\n height: image.height.to_s,\n mime_type: image.mime_type,\n checksum: MultiChecksum.for(file_object),\n size: image.size\n }\n new_file = original_file.new(@file_characterization_attributes.to_h)\n @file_node.file_metadata = @file_node.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n @persister.save(resource: @file_node) if save\n @file_node\n end",
"def characterize(save: true)\n TikaFileCharacterizationService.new(file_node: file_node, persister: persister).characterize\n external_metadata_service.characterize if external_metadata_service.valid?\n end",
"def characterize(save: true)\n TikaFileCharacterizationService.new(file_set: file_set, persister: persister).characterize\n end",
"def characterize(save: true)\n [:original_file, :intermediate_file, :preservation_file].each do |type|\n target_file = @file_set.try(type)\n next unless target_file\n @file_object = Valkyrie::StorageAdapter.find_by(id: target_file.file_identifiers[0])\n new_file = target_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n end\n @file_set = persister.save(resource: @file_set) if save\n @file_set\n end",
"def characterize(save: true)\n [:original_file, :intermediate_file, :preservation_file].each do |type|\n @target_file = @file_set.try(type)\n next unless @target_file\n @file_object = Valkyrie::StorageAdapter.find_by(id: @target_file.file_identifiers[0])\n @dataset_path = filename\n unzip_original_file if zip_file?\n new_file = @target_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n clean_up_zip_directory if zip_file?\n end\n @file_set = persister.save(resource: @file_set) if save\n @file_set\n end",
"def characterize(save: true)\n [:original_file, :intermediate_file, :preservation_file].each do |type|\n target_file = @file_set.try(type)\n next unless target_file\n @file_object = Valkyrie::StorageAdapter.find_by(id: target_file.file_identifiers[0])\n next unless image_valid?\n new_file = target_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n end\n @file_set = persister.save(resource: @file_set) if save\n @file_set\n end",
"def characterize\n metadata = content.extract_metadata\n characterization.ng_xml = metadata if metadata.present?\n append_metadata\n self.filename = [content.original_name]\n save\n end",
"def characterize\n self.characterization.ng_xml = self.content.extract_metadata\n fix_data_characterization!\n self.append_metadata\n self.filename = self.label\n save\n end",
"def characterize(save: true)\n unzip_original_file if zip_file?\n new_file = original_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n @file_set = @persister.save(resource: @file_set) if save\n clean_up_zip_directory if zip_file?\n @file_set\n end",
"def characterize\n self.characterization.ng_xml = self.content.extract_metadata\n self.append_metadata\n self.filename = self.label\n save\n end",
"def characterize\n fits_xml, ffprobe_xml = self.content.extract_metadata\n self.characterization.ng_xml = fits_xml\n fix_mxf_characterization!\n self.ffprobe.ng_xml = ffprobe_xml if ffprobe_xml\n self.append_metadata\n self.filename = self.label\n save unless self.new_object?\n end",
"def file_options; end",
"def file_characterization_attributes\n {\n mime_type: mime_type\n }\n end",
"def uploaded_file=(file_field)\n self.filename = base_part_of(file_field.original_filename)\n\n f_str = Iconv.conv('utf-8', self.encoding, file_field.read)\n\n f = StringIO.new(f_str)\n\n if self.format == 'OBT'\n it = OBNOTextIterator.new(f, self.sentence_delimiter == 'delimiter')\n elsif self.format == 'VRT'\n it = VRTReader.new(f)\n else\n raise RuntimeError\n end\n\n it.each_sentence {|s| sentences << s}\n f.close()\n\n # add postamble stored in iterator after parsing last sentence\n # TODO add support for arbitrary data for OBT format\n if self.format = 'VRT'\n self.postamble = it.postamble\n end\n end",
"def update_upload_attributes\n if document.present? && document_changed?\n self.content_type = document.file.content_type\n self.file_size = document.file.size\n self.file_name = File.basename(document.url)\n end\n end",
"def file_characterization_attributes\n {\n geometry: info_service.geom,\n mime_type: mime_type\n }\n end",
"def file_characterization_attributes\n {\n geometry: info_service.geom,\n mime_type: mime_type\n }\n end",
"def file_characterization_attributes\n {\n bounds: info_service.bounds,\n mime_type: mime_type\n }\n end",
"def override_content_type_and_save_info\n case File.extname(file.file).delete('.').downcase.to_sym\n when :xlsx\n file.content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n when :docx\n file.content_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n when :pptx\n file.content_type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'\n when :rar\n file.content_type = 'application/vnd.rar'\n when :zip\n file.content_type = 'application/zip'\n when :bat\n file.content_type = 'application/x-msdos-program'\n when :cmd\n file.content_type = 'application/cmd'\n when :exe\n file.content_type = 'application/x-msdownload'\n when :msi\n file.content_type = 'application/x-msi'\n when :php\n file.content_type = 'application/x-php'\n when :py\n file.content_type = 'application/x-python'\n when :vbs\n file.content_type = 'application/x-vbs'\n end\n\n model.file_content_type = file.content_type if file.content_type\n model.file_size = number_to_human_size(file.size) if file.size\n end",
"def file_field; end",
"def save_content_type_and_size\n model.content_type = file.content_type if model.respond_to?(:content_type) && file.content_type\n model.file_size = file.size if model.respond_to?(:file_size)\n end",
"def fileable\n tr(' ', '_').downcase\n end",
"def update_file_info\n if self.path\n size = File.exists?(self.path) ? File.size(self.path) : nil\n end\n if size\n (value, units) = bits_to_human_readable(size)\n self.size = value unless value.nil? or value.empty?\n self.size_units = units unless units.nil? or units.empty?\n self.save if self.descMetadata.changed?\n end\n end",
"def add_file_characterization_to_all_basic_files\n logger = Logger.new(STDOUT)\n logger.level = Logger::INFO\n logger.datetime_format = \"%H:%M:%S\"\n bfs = BasicFile.all\n bfs.each do |bf|\n if bf.datastreams['fitsMetadata1'].nil?\n logger.info \"No FITS datastream found for #{bf.pid}, going to add one...\"\n #need to create a new temp file using the content from the datastream\n temp_file = File.new('temp_content_file', 'w+')\n begin\n temp_file.puts bf.content.content\n rescue StandardError => re\n logger.error 'Got error writing BasicFile contents to file'\n logger.error re.to_s\n if re.to_s.match 'from ASCII-8BIT to UTF-8'\n logger.info 'ASCII file detected'\n temp_file.puts bf.content.content.force_encoding('UTF-8')\n end\n end\n #temp_file.puts bf.content.content.force_encoding('UTF-8')\n\n f = ActionDispatch::Http::UploadedFile.new(filename: bf.content.label, type: bf.content.profile['dsMIME'], tempfile: temp_file)\n\n begin\n logger.info 'Generating FITS metadata XML'\n fitsMetadata = Hydra::FileCharacterization.characterize(f, f.original_filename, :fits)\n rescue Hydra::FileCharacterization::ToolNotFoundError => tnfe\n logger.error tnfe.to_s\n abort 'FITS tool not found, terminating, check FITS_HOME environment variable is set and FITS is installed'\n rescue RuntimeError => re\n logger.error 'Something went wrong with extraction of file metadata using FITS'\n logger.error re.to_s\n abort 'FITS tool not found, terminating, check FITS_HOME environment variable is set and FITS is installed'\n end\n fitsDatastream = ActiveFedora::OmDatastream.from_xml(fitsMetadata)\n fitsDatastream.digital_object = bf.inner_object\n\n bf.add_datastream(fitsDatastream, {:prefix => 'fitsMetadata'})\n bf.save\n logger.info 'FITS metadata datastream added, tidying up resources used'\n temp_file.close\n FileUtils.remove_file 'temp_content_file'\n logger.info \"Finished adding FITS metadata for #{bf.pid}\"\n logger.info '********************************************'\n end\n end\n end",
"def notest_should_remove_blank_char_from_filename\n\n document_field = CGI.new( :multipart => true )\n puts document_field.inspect\n document = Document.new(document_field)\n \n puts document.inspect\n \n \n end",
"def document=(document_field)\n self.name = base_part_of(document_field.original_filename)\n self.content_type = document_field.content_type.chomp\n self.data = document_field.read\n end",
"def save_file \n Grit.debug = true\n contents = params[:contents]\n message = params[:commit_message]\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n save_file_to_disk(contents, @node.abspath)\n stage_and_commit_file(@node.repo_base_path, @node.git_repo_path, message)\n flash[:notice] = \"Created New Version\"\n render :action => :file\n end",
"def seo_file_params\n params.require(:seo_file).permit(:filename, :domain, :targeturl, :valid_content)\n end",
"def save_character account, filename, data\n end",
"def uploaded_file=(file); write_attribute(:uploaded_file, file); end",
"def set_file_size\n write_attribute(:file_size, File.size(file_name)) if (file_size.blank? and !file_name.blank?)\n end",
"def transliterate_file_name\n\t\t\tfile_names = Array.new\n\t\t\[email protected] { |a| file_names << a if a.match(/_file_name{1}$/) }\n\t\t\tfile_names.each do |local_file_name|\n\t\t\t\tif self.send(local_file_name).present? && self.send(local_file_name+'_changed?')\n\t\t\t\t\textension = File.extname(send(local_file_name)).gsub(/^\\.+/, '')\n\t\t\t\t\tfilename = send(local_file_name).gsub(/\\.#{extension}$/, '')\n\t\t\t\t\tself.send(local_file_name.gsub(/_file_name{1}$/, '')).instance_write(:file_name, \"#{transliterate(filename)}.#{transliterate(extension)}\")\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def upload\n \tset_up_instances_variable\n \tuploaded_io = @tree.file\n \t@nome_arquivo = Rails.root.join('public', 'uploads', uploaded_io.original_filename)\n \tFile.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'wb') do |file|\n \t\tfile.write(uploaded_io.read)\n \tend\n \tler_texto @nome_arquivo\n end",
"def file_save file\n\t\tfields \t\t\t\t= {}\n \t\tfields[:uid] \t\t= file_uid\n\t\tfields[:fnum] \t\t= file_num_generate\n\t\tfields[:name] \t\t= file[:filename].split('.').first\n\t\tfields[:created]\t= Time.now\n\t\tfields[:type]\t\t= file[:type]\n \t\tfields[:path] \t\t= \"#{file_uid}-#{fields[:created].to_i}#{_random(3)}\"\n\n\t\t# allow these file type to save\n\t\tunless _var(:file_type).include? file[:type]\n\t\t\t_throw Sl[:'the file type isn`t allowed to save']\n\t\tend\n\n\t\t# allow the scope of file size\n\t\tfile_content = file[:tempfile].read\n\t\tif (fields[:size] = file_content.size) > _var(:file_size).to_i\n\t\t\t_throw Sl[:'the file size is too big']\n\t\tend\n\n\t\t# save the info of file\n\t\tSdb[:file_info].insert(fields)\n\n\t\t# save the body of file\n\t\tpath = Spath[:upload_dir] + fields[:path]\n\t\tSimrb.path_write path, file_content\n\t\t_msg :file_save, Sl['saved file successfully']\n\n# \t\t\tFile.open(Spath[:upload_dir] + fields[:path], 'w+') do | f |\n# \t\t\t\tf.write file_content\n# \t\t\tend\n\n# \n# \t\t# return the value\n# \t\tunless reval == nil\n# \t\t\tSdb[:file_info].filter(fields).get(reval)\n# \t\tend\n\tend",
"def uploaded_file=(field)\n if field != \"\"\n mt = field.content_type || \"application/binary\"\n self.filename = base_part_of(field.original_filename) \n self.mime_type = mt\n path = get_path\n data = field.read\n self.size = data.length\n if ! File::exist? path\n Dir::mkdir(path)\n else \n # delete old images\n Dir::new(path).each do |oldfile|\n if oldfile[0].chr != '.'\n File::unlink(path+\"/\"+oldfile)\n end\n end\n end\n f = File.new(path + \"/\" + self.filename,\"w\")\n f << data\n f.close\n end\n end",
"def internal_file_attributes; end",
"def save_file\n if self.file then\n self.file.save\n end\n end",
"def store_file\n # TODO\n # - kick BOM if present\n # - convert to UTF-8 if a different encoding is given\n # - we should check double encoding because the tempfile is always read as utf8\n\n # writes the file binary/raw without taking encodings into account.\n # If we want to convert incoming files this should be done before\n File.open(full_filename, 'wb') do |f| #w:UTF-8\n f.write @uploaded_file.read\n end\n end",
"def manipulate(options = {})\n if options[:path]\n options[:path] = berksfile.find(name).instance_variable_get(:@options)[:path] || options[:path]\n end\n options\n end",
"def save_attached_files; end",
"def save_attached_files; end",
"def save_file_entry\n @user.search_files.create!(file_path: uploaded_file_path.result, file_name: @file.original_filename, status: 'initialized')\n end",
"def filename_cleaner\n @options[:filename_cleaner] || FilenameCleaner.new(@options[:restricted_characters])\n end",
"def file name\n \n end",
"def uploadicon=(file)\n unless( file.blank? )\n logger.info(\"original_filename: \" + file.original_filename )\n self.content_type = file.content_type.chomp\n logger.info(\"content_type: \" + self.content_type )\n filename = base_part_of( file.original_filename ) \n \n if(file.length < 300000 )\n @uploadfile = file \n self.was_upload_successful = true\n else\n self.was_upload_successful = false\n end\n \n end\n end",
"def modify_file\n file_path = \"./app/views/hocr_files/_p#{self.filename}_hocr.html\"\n file = File.open(file_path, \"r\")\n data = file.read\n data = self.replace_bbox(data)\n data = self.add_image(data)\n File.open(file_path, 'w') {|f| f.write(data) }\n end",
"def before_save \n filename.strip!\n filename.gsub(/^(..)+/, \".\")\n filename.gsub(/[^\\s]/, \"\") # replace spaces with \n # replace all non alphanumeric, underscore or periods with underscore\n filename.gsub(/^[\\W]+$/, '_')\n end",
"def save_file\n\t\tif file\n\t\t\tdocuments.create({\n\t\t\t\t:uploaded_file => file,\n\t\t\t\t:user_id => user_id\n\t\t\t})\n\t\tend\n\t\t#`cp \"#{file.path}\" \"#{path}\"` if file\n\tend",
"def perform(file_set, file_id, filepath = nil, user = nil)\n @event_start = DateTime.current\n @relation = file_set.class.characterization_proxy\n file = file_set.characterization_proxy\n raise \"#{@relation} was not found for FileSet #{file_set.id}\" unless file_set.characterization_proxy?\n filepath = Hyrax::WorkingDirectory.find_or_retrieve(file_id, file_set.id) unless filepath && File.exist?(filepath)\n characterize(\n file: file,\n filepath: filepath,\n user: user,\n file_set: file_set\n )\n end",
"def file_size\n number_to_human_size(super)\n end",
"def update_content_type\n if file.present? && file_changed?\n self.content_type = file.file.content_type\n end\n end",
"def to_s\n @file_text\n end",
"def to_s\n @file_text\n end",
"def set_the_field_values\n fn = self.file_name\n unless self.file_ext && !self.file_ext.blank?\n self.file_ext = fn.split('.').last\n end\n ex = self.file_ext\n nm = self.name\n \n pic_name = fn.split('.')\n pic_name.delete(pic_name.last)\n \n pn = pic_name.join('_').to_s.to_go\n \n the_name = ( nm.blank? || nm.start_with?('dcfile_') ) ? pn.titleize : nm.to_s\n the_fname = !nm.blank? ? nm.to_s.to_go : pn\n \n self.name = the_name\n self.original_name = fn\n # => self.file_name = \"#{the_fname}.#{ex}\"\n self.file_name = \"#{ generate_dc_name }.#{ex}\"\n self.image = IMAGE_EXTS.include?( ex.to_s.downcase ) ? true : false\n self.save\n end",
"def file_name\n self.file_file_name\n end",
"def save(upload)\n uploadFile = upload['datafile']\n originalName = uploadFile.original_filename\n self.fileType = File.extname(originalName)\n\n create_or_update()\n\n # write the file\n File.open(self.filePath, \"wb\") { |f| f.write(uploadFile.read) }\n \n # write ID3 metadata to database, to avoid the expense of fetching\n # from the file every time - quite costly as more files are displayed at a time\n begin\n musicFile = TagLib::File.new(self.filePath())\n self.id3Title = musicFile.title\n self.id3Artist = musicFile.artist\n self.id3Length = musicFile.length\n rescue TagLib::BadFile => exc\n logger.error(\"Failed to id track: \\n #{exc}\")\n end\n\n if(self.fileType == '.mp3')\n convertToOGG();\n end\n create_or_update()\n\n end",
"def file_name\n @file_name\n end",
"def override_content_type_and_save_info\n case File.extname(file.file).delete('.').to_sym\n when :xlsx\n file.content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n when :docx\n file.content_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n when :pptx\n file.content_type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'\n end\n\n # if File.extname(file.file).delete('.').to_sym == :xlsx\n # file.content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n # end\n # if File.extname(file.file).delete('.').to_sym == :docx\n # file.content_type='application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n # end\n # if File.extname(file.file).delete('.').to_sym == :pptx\n # file.content_type='application/vnd.openxmlformats-officedocument.presentationml.presentation'\n # end\n\n model.file_content_type = file.content_type if file.content_type\n model.file_size = number_to_human_size(file.size) if file.size\n\n tmp_file = file.path\n photo = MiniExiftool.new \"#{tmp_file}\"\n\n model.latitude = dms_to_float(photo.gpslatitude) if photo && photo.gpslatitude\n model.longitude = dms_to_float(photo.gpslongitude) if photo && photo.gpslongitude\n model.photo_created_at = photo.createdate if photo && photo.createdate\n end",
"def text_file_params\n params.require(:text_file).permit(:name, :content)\n end",
"def save\n # Nothing in base class. This should be used to persist settings in\n # subclasses that use files.\n end",
"def save_file\n if platinum_user_and_above?\n uid = current_user.id\n data_dir = Rails.root.join('shared','data')\n @file = data_dir.join('domains')\n file = File.open(@file, 'r')\n @restore = ''\n file.each_line { |line| @restore += line }\n file.close\n file = File.open(@file, 'w+')\n file.write(params[:file_content])\n file.close\n domain_table_reload(uid,data_dir.to_s)\n render json: { message: 'Saving successful.' }\n else\n render json: { message: 'Saving failed, please check your file again.' }\n end\n rescue Psych::SyntaxError\n file = File.open(@file, 'w+')\n file.write(@restore)\n file.close\n render json: { message: 'Saving failed, please check your file again.' }\n end",
"def employee_file_params\n params.require(:employee_file).permit(:employee_id, :title, :file, :filemime, :filesize)\n end",
"def encode_file(_file_suffix, _options = {})\n # convert to pdf\n self.class.encode(source_path, \"pdf\", Hydra::Derivatives.temp_file_base)\n pdf_file = File.join(Hydra::Derivatives.temp_file_base, [File.basename(source_path, \".*\"), 'pdf'].join('.'))\n\n # persist pdf original as access\n\n output_file_service.call(File.open(pdf_file, \"rb\"), url: directives.fetch(:access))\n\n # create thumbnails from the pdf using Hydra::Derivatives::Processors::Image\n Hydra::Derivatives::Processors::Image.new(pdf_file, thumbnail_directives).process\n Hydra::Derivatives::Processors::Image.new(pdf_file, citi_thumbnail_directives).process\n\n # clean up\n File.unlink(pdf_file)\n end",
"def full_filename (for_file = model.document.file)\n for_file\n end",
"def process_force_save(file_data, file_name, user_address) \n download_uri = file_data['url']\n if download_uri.eql?(nil)\n saved = 1\n return saved\n end\n\n download_ext = \".\"+file_data['filetype'] # get the extension of the downloaded file\n\n cur_ext = File.extname(file_name).downcase # get current file extension\n\n new_file_name = false\n\n # convert downloaded file to the file with the current extension if these extensions aren't equal\n unless cur_ext.eql?(download_ext)\n key = ServiceConverter.generate_revision_id(download_uri) # get the document key\n begin\n percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file\n if new_file_uri == nil || new_file_uri.empty?\n new_file_name = true\n else\n download_uri = new_file_uri\n end\n rescue StandardError => msg\n new_file_name = true\n end\n end\n\n saved = 1\n\n data = download_file(download_uri) # download document file\n if data.eql?(nil)\n return saved\n end\n\n begin\n is_submit_form = file_data[\"forcesavetype\"].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted)\n\n if is_submit_form\n if new_file_name\n file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + \"-form\" + download_ext, user_address) # get the correct file name if it already exists\n else\n file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + \"-form\" + cur_ext, user_address)\n end\n forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file\n else\n if new_file_name\n file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address)\n end\n forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false)\n if forcesave_path.eql?(\"\")\n forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) # if the path to the new file doesn't exist, create it\n end\n end\n\n save_file(data, forcesave_path) # save the downloaded file to the storage directory\n\n if is_submit_form\n uid = file_data['actions'][0]['userid']\n DocumentHelper.create_meta(file_name, uid, \"Filling Form\", user_address) # create file meta information with the Filling form tag instead of user name \n end\n\n saved = 0\n rescue StandardError => msg\n saved = 1\n end\n\n saved\n end",
"def _cleanup_file_to_h( file, attach_h )\r\n file_name = file.xpath('file-name').text.strip\r\n file_h = {}\r\n data = file.xpath('size')\r\n file_h[:size_text] = data.attribute('format').value\r\n file_h[:size] = data.text.to_i\r\n file_h[:date] = file.xpath('date').text.strip\r\n attach_h[file_name] = file_h\r\n file_h \r\n end",
"def update_after_conversion\n #update_attribute(:filename, \"#{filename}.flv\")\n #update_attribute(:content_type,\"video/x-flv\")\n end",
"def force_to_file\n if @data && ! (@file && File.exist?(@file.to_s))\n fh = Tempfile.new([ \"conconv_force_to_file\", @suffix.to_s ])\n @force_to_file = @file = Pathname.new(fh.path)\n fh.write @data\n fh.close\n $stderr.puts \" force_to_file wrote #{@data.size} => #{fh.path.inspect}\" if @verbose\n end\n @file\n end",
"def grid_fs_file_params\n params.require(:grid_fs_file).permit(:filename, :contentType, :author, :topic, :uploadDate, :length, :chunkSize, :md5, :contents)\n end",
"def file_type\r\n\t\t@file_type\r\n\tend",
"def filename\n \"#{options.filename}.#{options.filetype}\"\n end",
"def original_filename; end",
"def file_field(name = \"\", size = 20, maxlength = nil)\n attributes = if name.kind_of?(String)\n { \"TYPE\" => \"file\", \"NAME\" => name,\n \"SIZE\" => size.to_s }\n else\n name[\"TYPE\"] = \"file\"\n name\n end\n attributes[\"MAXLENGTH\"] = maxlength.to_s if maxlength\n input(attributes)\n end",
"def file_attributes\n {}\n end",
"def file_attributes\n {}\n end",
"def update_metadata\n @generic_file.destroy_existing_nested_nodes(params[:generic_file])\n super\n end",
"def document_file_params\n doc_params = params.require(:document_file).permit(:name, :document_file_type_id, :document_id, :content, properties: [:width, :height])\n if (doc_params.has_key?(:content))\n file_upload = doc_params.delete(:content)\n doc_params[:name] = sanitize_filename(file_upload.original_filename)\n doc_params[:document_file_type_id] = DocumentFileType.get_type_by_category(DocumentFileType::Logo, doc_params[:name]).id\n doc_params[:content] = file_upload.read\n dimensions = FastImage.size(file_upload.path)\n unless dimensions.nil?\n doc_params[:properties] = {width: \"#{dimensions[0]}px\", height: \"#{dimensions[1]}px\"}\n end\n end\n\n doc_params\n end",
"def edit_file\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n end",
"def saveFile(filename)\n\t\tpretty = JSON.pretty_generate(filename)\n\t\tpretty_clean = Sanitize.clean(pretty)\n\t\tpretty_clean = pretty_clean.gsub(' \\n', \" <br/>\" )\n\t\tpretty_clean = pretty_clean.gsub(',', \" <br/> \")\n\t\tpretty_clean = pretty_clean.gsub('\"', \" <br/> \")\n\n\t\tFile.open(\"output.txt\", \"w\") do |f|\n\t\tf.write(pretty_clean)\n\tend\nend",
"def deco_file; end",
"def save\n create_file\n true\n end",
"def feature_upload(id, file)\r\n dir = \"home_features\"\r\n file.original_filename = id.to_s + (File.extname file.original_filename)\r\n return write(dir, file)\r\n end",
"def nthfile_params\n params.require(:nthfile).permit(:rename, :filesize, :count, :resize)\n end",
"def to_doc(file)\n return nil if file[\"size\"] == 0\n return {\n path: file[\"path\"] + \"/\" + file[\"name\"],\n size: file[\"size\"],\n name: file[\"name\"]\n }\n end",
"def characterize\n content = source_to_content\n extracted_md = extract_metadata(content)\n terms = parse_metadata(extracted_md)\n store_metadata(terms)\n end",
"def internal_file_attributes=(_arg0); end",
"def create\n @user = User.find(params[:user_id])\n @mycontact = Mycontact.find(params[:mycontact_id])\n @meeting = Meeting.find(params[:meeting_id])\n @userfile = @meeting.userfiles.new(userfile_params)\n\n uploadedIo = params[:userfile][:doc]\n @userfile.filename = uploadedIo.original_filename\n meetingId = @meeting.id\n tmpFileName = meetingId.to_s + \"_\" + [uploadedIo.original_filename.split(\".\").first.downcase.parameterize, \".\", uploadedIo.original_filename.split(\".\").last].join()\n @userfile.file_name_slug = tmpFileName\n\n\n fileName = Rails.root.join('public','uploads', tmpFileName)\n File.open(fileName, 'wb') do |file|\n file.write(uploadedIo.read)\n end\n\n respond_to do |format|\n if @userfile.save\n #format.html { redirect_to @userfile, notice: 'Userfile was successfully created.' }\n format.html { redirect_to user_mycontact_meeting_userfiles_path}\n format.json { render action: 'show', status: :created, location: @userfile }\n else\n format.html { render action: 'new' }\n format.json { render json: @userfile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def upload\n # connected to upload.html.haml form\n # looks for :zernike in params, existence means file is attached\n # significant help from \"http://www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm\"\n if params[:zernike]\n uploaded_file = params[:zernike][:attachment]\n file_name = uploaded_file.original_filename\n jsonified_file = uploaded_file.as_json[\"tempfile\"]\n extract_data = coefficients_extractor(jsonified_file)\n @file = extract_data\n \n if @file.nil? or @file.empty?\n flash[:warning] = \"Unable to upload file\"\n # made it a \"warning\" instead of \"notice\" so we can change the colors/text\n else\n flash[:notice] = \"File successfully uploaded!\"\n end\n \n redirect_to zernikes_path\n end\n \n # if not @file.nil?\n # byebug\n # end\n # self.content = [TEXT INSIDE test.txt]\n # @file = params[:file]\n # byebug\n # @zernike = Zernike.\n # if @zernike.save\n # flash[:notice] = \"File successfully uploaded!\"\n # redirect_to \n # else \n # flash[:notice] = \"Unable to upload file\"\n \n # byebug\n # @file = params[:file]\n # if @file.nil? or @file.empty? \n # flash[:notice] = \"File is empty!\"\n # else \n # flash[:notice] = \"File successfully uploaded!\"\n # end\n \n end",
"def content_type\n self.file_content_type\n end",
"def extract_text\n # check if we have a filter\n return if FILTERS[self.content_type].nil?\n\n # Create temporary working directory directory\n FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', 'documents'))\n\n # Find path to convert script\n convert_script = File.join(RAILS_ROOT, 'script', FILTERS[self.content_type])\n\n # Get paths to temp in/out file\n temp_file_in = self.create_temp_file.path\n temp_file_out = File.join(RAILS_ROOT, 'tmp', 'documents',\"#{self.id}.txt\")\n\n # Convert\n if system \"#{convert_script} #{temp_file_in} #{temp_file_out}\"\n self.content = File.read(temp_file_out)\n File.unlink(temp_file_out)\n else\n self.content = \"NO CONTENT\"\n end\n self.save\n end",
"def file_extension; end",
"def file_extension; end",
"def file_extension; end",
"def scrub_params\n params.require(:scrub).permit(:name, :file_type, :size)\n end",
"def upload_process\n # アップロードファイルを取得\n file = params[:upfile]\n\n # ファイルのベース名(パスを除いた部分)を取得\n name = file.original_filename\n\n # 許可する拡張子を定義\n permits = ['.jpg', '.jpeg', '.gif', '.png']\n\n # 配列 permits にアップロードファイルの拡張子に合致するものがあるか\n if ! permits.include?(File.extname(name).downcase)\n render :text => \"アップロードできるのは画像ファイルのみ( \" + permits.join(', ') + \" )です。\"\n elsif file.size > 1.megabyte\n render :text => 'ファイルサイズは1MBまでです。'\n else\n # utf8 to sjis\n name = name.kconv(Kconv::SJIS, Kconv::UTF8)\n\n # /public/doc フォルダ配下にアップロードファイルを保存\n File.open(\"public/docs/#{name}\", 'wb') { |f| f.write(file.read) }\n render :text => \"#{name.toutf8}をアップロードしました。\"\n end\n end",
"def external_file_attributes; end",
"def original_filename\n @file_representation[:filename]\n end",
"def create_document(file, file_type, object, comment, file_name=nil)\n if object.invoice_no.include?('/')\n file_obj=object.invoice_no.gsub('/','')\n else\n file_obj=object.invoice_no\n end\n filename = (file_name ? \"#{file_name}.#{file_type}\" : nil ) || \"InvoiceNo_#{file_obj}_#{Time.zone.now.to_i}_New.#{file_type}\"\n\n newfile=File.open(\"#{filename}\", \"w\") {|f| f.write(file) }\n\n root_file=File.open(\"#{RAILS_ROOT}/#{filename}\",'r')\n document={:name => \"Test\" ,:data=> root_file}\n document_home = {:document_attributes => document}\n document_home.merge!(:access_rights => 2, :created_by_user_id=>object.created_by_user_id,:company_id=>object.company_id,\n :mapable_id=>comment.id,:mapable_type=>'Comment', :owner_user_id=>object.owner_user_id)\n newdocument_home = comment.document_homes.new(document_home)\n newdocument = newdocument_home.documents.build(document.merge(:company_id=>object.company_id, :created_by_user_id=>object.created_by_user_id))\n newdocument_home.save\n if newdocument_home.save\n root_file.close\n File.delete(\"#{RAILS_ROOT}/#{filename}\")\n end\n end",
"def update_file_content(new_content)\n return false if new_content.nil?\n self.file_content = new_content\n return self.save\n end"
] | [
"0.8107187",
"0.7465022",
"0.7455418",
"0.70079046",
"0.6842894",
"0.671131",
"0.6691431",
"0.6597271",
"0.6553364",
"0.64761275",
"0.6470805",
"0.632564",
"0.56703",
"0.55973125",
"0.559209",
"0.547178",
"0.54607815",
"0.54607815",
"0.54392534",
"0.5427715",
"0.54066885",
"0.5311176",
"0.52681077",
"0.5265448",
"0.5222607",
"0.52147484",
"0.51945496",
"0.51880664",
"0.51848847",
"0.5174335",
"0.5162662",
"0.50704265",
"0.5067421",
"0.50385857",
"0.5035924",
"0.50290996",
"0.5004643",
"0.50005555",
"0.4997245",
"0.49779767",
"0.4970436",
"0.4970436",
"0.49653748",
"0.49609023",
"0.4959125",
"0.4922063",
"0.49146375",
"0.49104187",
"0.4900096",
"0.48950145",
"0.4893778",
"0.48909175",
"0.48894632",
"0.48894632",
"0.48877537",
"0.48858416",
"0.48757",
"0.486723",
"0.4861432",
"0.48440856",
"0.4841104",
"0.48333442",
"0.48297417",
"0.48289013",
"0.4827149",
"0.48235714",
"0.48211664",
"0.48145014",
"0.4801287",
"0.4800147",
"0.47929198",
"0.4786963",
"0.4786692",
"0.47830155",
"0.4774973",
"0.4774973",
"0.4771528",
"0.4769103",
"0.47661182",
"0.476239",
"0.4733078",
"0.473285",
"0.4732837",
"0.47301638",
"0.472975",
"0.47182757",
"0.4708716",
"0.47052205",
"0.47008017",
"0.46996754",
"0.46971962",
"0.46955577",
"0.46955577",
"0.46955577",
"0.46933198",
"0.46870923",
"0.46855694",
"0.46827096",
"0.46812806",
"0.46739584"
] | 0.7559292 | 1 |
Determines the location of the file on disk for the file_node | def filename
return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_node(path)\n file_info(path).first[0..19]\n end",
"def file_node\n @file_node ||= file_log.lookup_id(@file_id) if @file_id ||= nil\n @file_node ||= changeset.file_node(@path) unless @file_id\n @file_node ||= NULL_ID\n end",
"def file_path\n @file_path ||= lookup_file_path\n end",
"def file\n file_id = @attributes[\"file\"]\n file_node = NodeCache.find(file_id)\n file_node ? file_node.name : nil\n end",
"def file_path\n dir\n end",
"def file_path\n end",
"def file_path; end",
"def path\n @file.path\n end",
"def path\n @file\n end",
"def path\n @file\n end",
"def path\n @file.path\n end",
"def file_path\n dir_name + file_name\n end",
"def node_files_path()\n return File.join(@base_path, 'pages')\n end",
"def file_location(options={})\n self.class.file_location(options)\n end",
"def preferred_filename_on_disk_location(node,\n segment,\n filename,\n current_filepath=nil)\n segment_filenames = [\n File.join(segment.to_s, \"#{node[:platform]}-#{node[:platform_version]}\", filename),\n File.join(segment.to_s, node[:platform], filename),\n File.join(segment.to_s, 'default', filename),\n File.join(segment.to_s, filename),\n File.expand_path(filename, @basedir), # keep absolute paths, convert relative paths into absolute paths\n ]\n segment_filenames.find {|filename| File.exist?(filename) }\n end",
"def target_file_path\n model.source_location(target_symbol)[:file_path]\n end",
"def file_path\n File.dirname(__FILE__) + '/' + @file_name\n end",
"def get_file_path\n @path\n end",
"def path\n self.file.to_s\n end",
"def file_path\n\t\tself.class.file_path\n\tend",
"def file_path(path)\n if path.is_a? Symbol\n path = [path, @node.name]\n end\n actual_path = Path.find_file(path)\n if actual_path.nil?\n Util::log 2, :skipping, \"file_path(\\\"#{path}\\\") because there is no such file.\"\n nil\n else\n if actual_path =~ /^#{Regexp.escape(Path.provider_base)}/\n # if file is under Path.provider_base, we must copy the default file to\n # to Path.provider in order for rsync to be able to sync the file.\n local_provider_path = actual_path.sub(/^#{Regexp.escape(Path.provider_base)}/, Path.provider)\n FileUtils.mkdir_p File.dirname(local_provider_path), :mode => 0700\n FileUtils.install actual_path, local_provider_path, :mode => 0600\n Util.log :created, Path.relative_path(local_provider_path)\n actual_path = local_provider_path\n end\n if File.directory?(actual_path) && actual_path !~ /\\/$/\n actual_path += '/' # ensure directories end with /, important for building rsync command\n end\n relative_path = Path.relative_path(actual_path)\n @node.file_paths << relative_path\n @node.manager.provider.hiera_sync_destination + '/' + relative_path\n end\n end",
"def file_path(path)\n if path.is_a? Symbol\n path = [path, @node.name]\n end\n actual_path = Path.find_file(path)\n if actual_path.nil?\n Util::log 2, :skipping, \"file_path(\\\"#{path}\\\") because there is no such file.\"\n nil\n else\n if actual_path =~ /^#{Regexp.escape(Path.provider_base)}/\n # if file is under Path.provider_base, we must copy the default file to\n # to Path.provider in order for rsync to be able to sync the file.\n local_provider_path = actual_path.sub(/^#{Regexp.escape(Path.provider_base)}/, Path.provider)\n FileUtils.mkdir_p File.dirname(local_provider_path), :mode => 0700\n FileUtils.install actual_path, local_provider_path, :mode => 0600\n Util.log :created, Path.relative_path(local_provider_path)\n actual_path = local_provider_path\n end\n if File.directory?(actual_path) && actual_path !~ /\\/$/\n actual_path += '/' # ensure directories end with /, important for building rsync command\n end\n relative_path = Path.relative_path(actual_path)\n @node.file_paths << relative_path\n @node.manager.provider.hiera_sync_destination + '/' + relative_path\n end\n end",
"def filepath\n @filepath\n end",
"def filepath\n @filepath\n end",
"def filepath\n @filepath\n end",
"def root_file_path; end",
"def file() = pathname.relative_path_from(Cnfs.config.paths.definitions)",
"def file_path\n storage.file_path(self.class, @id)\n end",
"def compute_file_path (object)\n\n raise NotImplementedError.new\n end",
"def file_path\n File.join(dir,filename)\n end",
"def path\n file.url\n end",
"def file\n @pathname.to_s\n end",
"def file\n File.join(directory, @file)\n end",
"def file_path_for(role_name:)\n Filesystem.nfs_store_path role_name, container, container_path(no_filename: true), file_name\n end",
"def file_dir\n 'files'\n end",
"def file_system_path\n path_prefix = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s\n [path_prefix, self.parent_type.underscore, attachment_path_id.to_s, self.id.to_s] + partitioned_path(thumbnail_name_for(thumbnail))\n end",
"def path\n ::File.join(@folder, @file)\n end",
"def file_path\n self.class.file_path\n end",
"def file_path\n self.class.file_path\n end",
"def file_path\n self.class.file_path\n end",
"def file_dir # :nodoc:\n nil\n end",
"def file_on_disk\n ActiveStorage::Blob.service.send(:path_for, file.key)\n end",
"def file= location\n @file = case location\n when RDoc::TopLevel then\n location.relative_name\n else\n location\n end\n end",
"def filepath\n base = storage_root_path\n if base\n File.join(base, storage_key)\n else\n raise StandardError.new(\"no filesystem path found for datafile: #{self.web_id}\")\n end\n end",
"def access_file_name\n end",
"def find_location(filename)\n Find.find(path) do |element| \n if element.include? filename\n candidate = Pathname.new(element)\n yield candidate.dirname.to_s\n end \n end\n end",
"def file\n File.join(root, FILENAME)\n end",
"def rel_path(file)\n File.dirname(file)\n end",
"def stored_file_path\n File.join(path, stored_name)\n end",
"def file_path_for(file)\n ActiveStorage::Blob.service.send(:path_for, file.key)\n end",
"def file_path( target )\n # theme.site do not work.\n File.join(page_layout.site.path, self.path, file_name(target)) \n end",
"def file\n @file ||= find_file\n end",
"def path\n @filename\n end",
"def current_file_path\n current_file.to_path\n end",
"def file_dir\n @parent_generator.file_dir\n end",
"def local_path_to_file=(value)\n @attributes[:local_path_to_file] = value\n reset_attributes\n calculate_attributes\n value\n end",
"def file_path(file_name)\n file_map[file_name]['path']\n end",
"def file_path(file_name)\n file_map[file_name]['path']\n end",
"def file_path(was=false)\n if was\n self.site.directory_path.join(name_was)\n else\n self.site.directory_path.join(name)\n end\n end",
"def out_path\n @out_path ||= File.join out_base, node.file_name\n end",
"def current_path\n file.try(:path)\n end",
"def file_path\n File.join device.path, id.to_s(16)\n end",
"def lookup_file_path\n file_path_list.each do |candidate_file_path|\n next unless File.file?(File.expand_path(candidate_file_path))\n return candidate_file_path\n end\n nil\n end",
"def fs_path\n @changeset.fs_path(@path)\n end",
"def file_path( target )\n # theme.site do not work.\n File.join( original_template_theme.store.path, self.path, file_name(target))\n end",
"def fullpath\n File.expand_path( @file )\n end",
"def model_file_path\n model.file_path\n end",
"def filename\n return @file_object.io.path if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def path\n if @file\n @file.name\n elsif @path\n @path.to_s\n elsif @stream.is_a?(File)\n @stream.path\n end\n end",
"def location\n l = line()\n if l == 0\n \"#{file}+#{ip-1}\"\n else\n \"#{file}:#{line}\"\n end\n end",
"def derivative_file_path\n local_derivative = resource.derivative_files.find do |derivative_file|\n derivative_file.file_identifiers.first.to_s.include?(Figgy.config[\"geo_derivative_path\"])\n end\n derivative_id = local_derivative.file_identifiers.first\n Valkyrie::StorageAdapter.find_by(id: derivative_id).io.path\n end",
"def processed_file\n last_dir_in_path = Pathname(@origional_path).each_filename.to_a.last\n file_wo_path = @origional_file.sub('.'+process_tag, '').sub(@origional_path, '')\n File.join($config[\"processed_loc\"], last_dir_in_path, file_wo_path)\n end",
"def generate_storage_path\n update_column(:file, File.join(File.dirname(request.file),\n \"#{id}-response.xml\"))\n end",
"def file\n FILE\n end",
"def determine_path\n if source_line.file == SourceLine::DEFAULT_FILE\n return source_line.file\n end\n\n full_path = File.expand_path(source_line.file)\n pwd = Dir.pwd\n\n if full_path.start_with?(pwd)\n from = Pathname.new(full_path)\n to = Pathname.new(pwd)\n\n return from.relative_path_from(to).to_s\n else\n return full_path\n end\n end",
"def filename\n return Pathname.new(@file_object.io.path) if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def filename\n return Pathname.new(@file_object.io.path) if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def file_name\n return unless @file\n\n @file.absolute_name\n end",
"def file\n file_names[x]\n end",
"def file\r\n LocalFile\r\n end",
"def work\n '/' + File.dirname(file)\n end",
"def nodes_path\n verify_path NODES_PATH\n File.join @tar_contents_path, NODES_PATH\n end",
"def file_dir\n nil\n end",
"def file_path\n Merb::Config[:upload_dir] / self.hash[0..1] / (self.hash[2..-1] + '-' + self.size.to_s )\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def fs(path)\n OodAppkit.files.url(path: path).to_s\n end",
"def path\n '/c/document_library/get_file?folderId=%i&name=%s' % [self.folderid, self.name]\n end",
"def file\n @file\n end",
"def current_dir\n File.dirname(file_path)\n end",
"def file\n @file\n end",
"def file_path=(_arg0); end",
"def path\n return if @file.blank?\n if is_path?\n File.expand_path(@file)\n elsif @file.respond_to?(:path) && [email protected]?\n File.expand_path(@file.path)\n end\n end",
"def file\n @file ||= File.basename(link)\n end",
"def localFile(f)\n fileUri(File::absolute_path(f))\nend",
"def file\n @zip_fs_file\n end"
] | [
"0.73050326",
"0.718163",
"0.69369686",
"0.68615794",
"0.68384445",
"0.6807996",
"0.67915744",
"0.66372097",
"0.662526",
"0.6600508",
"0.6589917",
"0.64892787",
"0.64842886",
"0.64646447",
"0.64401823",
"0.6430259",
"0.64272034",
"0.6408255",
"0.64053416",
"0.63689214",
"0.63485694",
"0.63485694",
"0.633169",
"0.633169",
"0.633169",
"0.63275516",
"0.632445",
"0.6299472",
"0.6276017",
"0.62751615",
"0.6270034",
"0.62470055",
"0.62223846",
"0.6218924",
"0.6212289",
"0.6208054",
"0.61988986",
"0.6184365",
"0.6184365",
"0.6184365",
"0.61562407",
"0.6152525",
"0.61403763",
"0.61067706",
"0.60967773",
"0.6089873",
"0.60890055",
"0.6083857",
"0.60641253",
"0.6056133",
"0.6055462",
"0.6045067",
"0.60414916",
"0.6041047",
"0.60316753",
"0.60207295",
"0.60089636",
"0.60089636",
"0.59957737",
"0.5987202",
"0.59845954",
"0.59765834",
"0.5972901",
"0.5970109",
"0.59696454",
"0.5968874",
"0.5938875",
"0.5928446",
"0.590875",
"0.5898669",
"0.58943653",
"0.5892754",
"0.5886827",
"0.58807176",
"0.58803535",
"0.5880281",
"0.5880281",
"0.5879193",
"0.5864765",
"0.58524454",
"0.5844267",
"0.5840519",
"0.5833684",
"0.5833601",
"0.58261144",
"0.58261144",
"0.58261144",
"0.58261144",
"0.5823799",
"0.5822354",
"0.58121735",
"0.5810747",
"0.5803501",
"0.57986134",
"0.5794901",
"0.5787649",
"0.5776672",
"0.57748574"
] | 0.5845561 | 81 |
Provides the file attached to the file_node | def file_object
@file_object ||= Valkyrie::StorageAdapter.find_by(id: original_file.file_identifiers[0])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file\n file_id = @attributes[\"file\"]\n file_node = NodeCache.find(file_id)\n file_node ? file_node.name : nil\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n return @file\n end",
"def file\n return @file\n end",
"def file\n FILE\n end",
"def path\n @file\n end",
"def file_node\n @file_node ||= file_log.lookup_id(@file_id) if @file_id ||= nil\n @file_node ||= changeset.file_node(@path) unless @file_id\n @file_node ||= NULL_ID\n end",
"def path\n @file\n end",
"def file_node(path)\n file_info(path).first[0..19]\n end",
"def filename\n @file\n end",
"def file\r\n LocalFile\r\n end",
"def path\n self.file.to_s\n end",
"def path\n @file.path\n end",
"def file_name\n @file_name\n end",
"def path\n @file.path\n end",
"def file\n @file ||= File.basename(link)\n end",
"def file_name\n self.file_file_name\n end",
"def file_name\n return @file_name\n end",
"def file_name\n return @file_name\n end",
"def file\n @pathname.to_s\n end",
"def file_path\n end",
"def get_file_path\n @path\n end",
"def file\n File.join(directory, @file)\n end",
"def path\n @filename\n end",
"def file_path; end",
"def filepath\n @filepath\n end",
"def filepath\n @filepath\n end",
"def filepath\n @filepath\n end",
"def file\n @file ||= find_file\n end",
"def file_details\n return @file_details\n end",
"def file\n @file ||= Operations::FileFactory.new(self)\n end",
"def file\n @zip_fs_file\n end",
"def file_form_field\n @attributes[:file_form_field]\n end",
"def file\n files.first\n end",
"def file\n files.first\n end",
"def file\n @files.first ? @files.first[0] : nil\n end",
"def file\n @files.first ? @files.first[0] : nil\n end",
"def file_field; end",
"def full_filename (for_file = model.document.file)\n for_file\n end",
"def file\n project.objects[fileRef]\n end",
"def filename\n return @file_object.io.path if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def file_name\n return unless @file\n\n @file.absolute_name\n end",
"def attached_file\n=begin # TODO: remove when :json resolved\n file || (file_attacher.load_data(file_data) if file_data.present?)\n=end\n file || file_attacher_load\n end",
"def get\n file\n end",
"def filename\n self._filename\n end",
"def file_path\n @file_path ||= lookup_file_path\n end",
"def file_path\n\t\tself.class.file_path\n\tend",
"def filename\n @filename\n end",
"def path\n file.url\n end",
"def filename\n @filename\n end",
"def filename\n @filename\n end",
"def file\n f = nil\n if self.asset_clone_id.present?\n x = self.asset_clone\n f = x.asset if x.present?\n else\n f = self.asset\n end\n return f\n end",
"def file_path\n self.class.file_path\n end",
"def file_path\n self.class.file_path\n end",
"def file_path\n self.class.file_path\n end",
"def access_file_name\n end",
"def file\n File.join(root, FILENAME)\n end",
"def get_file\n\t\t{\n\t\t\tfile_name: File.basename(file.path.to_s),\n\t\t\turl: file.url\n\t\t}\n\tend",
"def file_path\n storage.file_path(self.class, @id)\n end",
"def file\n file_names[x]\n end",
"def filename\n return Pathname.new(@file_object.io.path) if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def filename\n return Pathname.new(@file_object.io.path) if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def file\n @file ||= (file_from_path || file_from_uploaded_file!)\n end",
"def file\n end",
"def file\n end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file_as_body\n @attributes[:file_as_body]\n end",
"def attachment\n record.public_send(\"#{name}_file\")\n end",
"def uploaded_file\n instance_read(:uploaded_file)\n end",
"def file_name\n @file_name ||= File.basename tree\n end",
"def value\n super || file\n end",
"def file_to_render\n file\n end",
"def filename\n @data[:name]\n end",
"def filename\n find_attachment\n end",
"def file\n FileFactory.new(self)\n end",
"def filename\n @file.basename.to_s\n end",
"def assignment_upload_file_name\n read_attribute(:file_name)\n end",
"def filename\n @io.original_filename\n end",
"def filename\n return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)\n end",
"def filename\n return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)\n end",
"def filename\n return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)\n end",
"def file_path\n dir\n end",
"def file_name\n object_file_name\n end",
"def file() nil; end",
"def filename\n get \"filename\"\n end",
"def image_file\n return @image_file\n end"
] | [
"0.7864179",
"0.778853",
"0.778853",
"0.778853",
"0.778853",
"0.77786046",
"0.77315825",
"0.7651197",
"0.7651197",
"0.7518246",
"0.75115186",
"0.7444192",
"0.74193805",
"0.7356936",
"0.73108476",
"0.7172225",
"0.7167996",
"0.71577895",
"0.70562667",
"0.7043463",
"0.704334",
"0.7041285",
"0.70269173",
"0.70269173",
"0.6973517",
"0.6959569",
"0.68900603",
"0.6879393",
"0.68785506",
"0.6876304",
"0.6867714",
"0.6867714",
"0.6867714",
"0.6860048",
"0.6859224",
"0.6852904",
"0.6848208",
"0.67930245",
"0.67880666",
"0.67880666",
"0.6774113",
"0.6774113",
"0.6747926",
"0.67381215",
"0.67232347",
"0.67164963",
"0.67143774",
"0.6689965",
"0.66896635",
"0.668244",
"0.6652177",
"0.6623445",
"0.6617867",
"0.66021156",
"0.66013217",
"0.66013217",
"0.6597956",
"0.65612555",
"0.65612555",
"0.65612555",
"0.65563726",
"0.6538909",
"0.65326107",
"0.6520668",
"0.6503156",
"0.6494666",
"0.6494666",
"0.64941573",
"0.64750355",
"0.64750355",
"0.6458961",
"0.6458961",
"0.6458961",
"0.6458961",
"0.6458961",
"0.6458961",
"0.6458961",
"0.6458961",
"0.6458961",
"0.6458961",
"0.6458961",
"0.6457178",
"0.6446767",
"0.64461297",
"0.6443688",
"0.64426816",
"0.64417034",
"0.6434008",
"0.64339304",
"0.642888",
"0.64200574",
"0.6412162",
"0.6396776",
"0.6383159",
"0.6383159",
"0.6383159",
"0.635793",
"0.634961",
"0.633274",
"0.6326111",
"0.6322703"
] | 0.0 | -1 |
Extract the basic SPARQL results into a hash of arrays | def parse_json(json)
return nil if json.nil?
h = JSON.parse(json)
data = h['results']['bindings']
{
:headings => h['head']['vars'],
:rows => data.map {|i| i.to_a.map {|x| x[1]['value']}}
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wikidata_rows\n sparql_client = SPARQL::Client.new(\n \"https://query.wikidata.org/sparql\",\n method: :get,\n headers: { 'User-Agent': \"Connor's Random Ruby Scripts Data Fetcher/1.0 ([email protected]) Ruby 3.1\" }\n )\n\n # Get the response from the Wikidata query.\n rows = sparql_client.query(sparql_query)\n\n rows.map! do |row|\n key_hash = row.to_h\n {\n name: key_hash[:itemLabel].to_s,\n wikidata_id: key_hash[:item].to_s.sub('http://www.wikidata.org/entity/Q', ''),\n steam_app_id: key_hash[:steamAppId].to_s.to_i\n }\n end\n\n rows\nend",
"def get_object_results(hash, sparql)\n\n # create a new Array to parameterize the query generation\n data = Array.new\n \n data.push(hash)\n \n # generate the query\n query = object_query_generator(data)\n \n # send the query to the sparql database and get back the results\n result = sparql.query(query)\n \n # create a data structure to pass data to the webpage and safe the results in it\n return_value = Array.new\n \n result.each_solution do |solution|\n return_value << solution.inspect\n end\n \n return return_value\n end",
"def all_hash\n results = CONNECTION.execute(\"SELECT * FROM #{get_table_name};\")\n return array_list = make_object_array(results)\n end",
"def results\n content = Nokogiri::XML::Builder.new do |xml|\n xml.get_results(filter: \"first=1 rows=#{MAX_RESULTS} task_id=#{id}\", details: 1)\n end\n Hash.from_xml(@agent.sendrecv(content.to_xml)).deep_symbolize_keys\n end",
"def get_data()\n db = read_db() # open database for querying\n db.results_as_hash = true # format query results as a hash so columns available as keys\n all_records = db.execute('select * from tokens')\n return all_records # get hash of arrays\nend",
"def get_query_results(query)\n hits = execute_query(query).hpath('hits.hits').first\n return [] unless hits && !hits.empty?\n hits.map do |hit|\n hit['_source'].expand.merge(hit.only('_id', '_type', '_index')).kmap do |key|\n key.to_s.gsub('@', '_').to_sym\n end\n end\n end",
"def resultset; end",
"def tuples\n results = run_tuples(@last_query_context.to_sparql_select)\n results[\"results\"][\"bindings\"].map do |h|\n h.keys.each do |k|\n h[k.to_sym] = QL.from_tuple_binding(h[k])\n h.delete(k)\n end\n h\n end\n end",
"def result\n Hash[\n metadata.map do |key, value|\n [key, PostgresValue.for(value).result]\n end\n ]\n end",
"def RunQueries\n if @reqs.empty?\n @error = 'No queries defined, issue AddQuery() first'\n return false\n end\n\n req = @reqs.join('')\n nreqs = @reqs.length\n @reqs = []\n response = PerformRequest(:search, req, nreqs)\n \n # parse response\n begin\n results = []\n ires = 0\n while ires < nreqs\n ires += 1\n result = {}\n \n result['error'] = ''\n result['warning'] = ''\n \n # extract status\n status = result['status'] = response.get_int\n if status != SEARCHD_OK\n message = response.get_string\n if status == SEARCHD_WARNING\n result['warning'] = message\n else\n result['error'] = message\n results << result\n next\n end\n end\n \n # read schema\n fields = []\n attrs = {}\n attrs_names_in_order = []\n \n nfields = response.get_int\n while nfields > 0\n nfields -= 1\n fields << response.get_string\n end\n result['fields'] = fields\n \n nattrs = response.get_int\n while nattrs > 0\n nattrs -= 1\n attr = response.get_string\n type = response.get_int\n attrs[attr] = type\n attrs_names_in_order << attr\n end\n result['attrs'] = attrs\n \n # read match count\n count = response.get_int\n id64 = response.get_int\n \n # read matches\n result['matches'] = []\n while count > 0\n count -= 1\n \n if id64 != 0\n doc = response.get_int64\n weight = response.get_int\n else\n doc, weight = response.get_ints(2)\n end\n \n r = {} # This is a single result put in the result['matches'] array\n r['id'] = doc\n r['weight'] = weight\n attrs_names_in_order.each do |a|\n r['attrs'] ||= {}\n \n case attrs[a]\n when SPH_ATTR_BIGINT\n # handle 64-bit ints\n r['attrs'][a] = response.get_int64\n when SPH_ATTR_FLOAT\n # handle floats\n r['attrs'][a] = response.get_float\n\t\t\t\twhen SPH_ATTR_STRING\n\t\t\t\t # handle string\n\t\t\t\t r['attrs'][a] = response.get_string\n else\n # handle everything else as unsigned ints\n val = response.get_int\n if attrs[a]==SPH_ATTR_MULTI\n r['attrs'][a] = []\n 1.upto(val) do\n r['attrs'][a] << response.get_int\n end\n elsif attrs[a]==SPH_ATTR_MULTI64\n r['attrs'][a] = []\n\t\t\t\t\tval = val/2\n 1.upto(val) do\n r['attrs'][a] << response.get_int64\n end\n else\n r['attrs'][a] = val\n end\n end\n end\n result['matches'] << r\n end\n result['total'], result['total_found'], msecs, words = response.get_ints(4)\n result['time'] = '%.3f' % (msecs / 1000.0)\n \n result['words'] = {}\n while words > 0\n words -= 1\n word = response.get_string\n docs, hits = response.get_ints(2)\n result['words'][word] = { 'docs' => docs, 'hits' => hits }\n end\n \n results << result\n end\n #rescue EOFError\n # @error = 'incomplete reply'\n # raise SphinxResponseError, @error\n end\n \n return results\n end",
"def results(id)\n @pgsql.exec('SELECT key, value FROM result WHERE job = $1', [id]).map do |r|\n [r['key'], r['value']]\n end.to_h\n end",
"def results_as_objects(results)\n array_of_objects = []\n results.each do |hash|\n array_of_objects << self.new(hash)\n end\n return array_of_objects\n end",
"def results\n\t\t\tArray(result)\n\t\tend",
"def results\n @results ||= {}\n end",
"def get_all_by_query_as_hash(query)\n map_to_hash_by_primary_key(get_all_by_query(query))\n end",
"def oracle_sql_results(sql, conn = VACOLS::Case.connection)\n result = conn.execute(sql)\n output = []\n while r = result.fetch_hash\n output << r\n end\n output\nend",
"def convert_pt_query_to_series(pt_query)\n num_series=pt_query.count\n fingerprints=Set.new\n \n # Get list of fingerprints\n pt_query.each do |row|\n row.each {|k,v| fingerprints.add(k)}\n end\n\n fingerprints.delete(nil)\n\n series={}\n # cycle through list\n fingerprints.each do |f|\n series[f]=[]\n (0...num_series).each do |i|\n val = pt_query[i][f]\n series[f].push(val)\n end\n end\n series\nend",
"def search_results_hashes\n wait_until_bus_section_load\n search_results_table.rows_text.map{ |row| Hash[*search_results_table.headers_text.zip(row).flatten] }\n end",
"def conv_results_to_a_of_h( search_results )\n result_objects = []\n\n search_results[:data].each do |row|\n tmp = {}\n row.each_index do |index|\n tmp[ search_results[:headers][index] ] = row[index]\n end\n result_objects.push(tmp)\n end\n\n return result_objects\n end",
"def parse_results(results)\n out = []\n results = [results] if results.is_a?(Hash) # no array if only one result\n results.each do |r|\n out << Result.new(r)\n end\n out\n end",
"def results\n extract_rows.map do |result|\n hash = {}\n hash[:price] = result.xpath(\".//a[contains(concat(' ',normalize-space(@class),' '),' results_price ')]\").text.strip\n hash[:airline] = result.xpath(\".//div[contains(concat(' ',normalize-space(@class),' '),' rsAirlineName ')]\").text.strip\n legs = result.xpath(\".//div[@class='singleleg']\")\n hash[:leg0_departure_time] = legs[0].xpath(\".//div[@class='flighttime']\")[0].text.strip\n hash[:leg0_arrival_time] = legs[0].xpath(\".//div[@class='flighttime']\")[1].text.strip\n hash[:leg0_duration] = legs[0].xpath(\".//div[@class='duration']\")[0].text.strip\n hash[:leg1_departure_time] = legs[1].xpath(\".//div[@class='flighttime']\")[0].text.strip\n hash[:leg1_arrival_time] = legs[1].xpath(\".//div[@class='flighttime']\")[1].text.strip\n hash[:leg1_duration] = legs[1].xpath(\".//div[@class='duration']\")[0].text.strip\n hash[:booking_url] = @base_url + result.xpath(\".//a[@class='dealsinresult']\")[0].attributes['rel'].value\n hash\n end\n end",
"def parse_base_results\n r = HashWithIndifferentAccess.new\n @assessment.questions.each_with_index do |question, order|\n result = HashWithIndifferentAccess.new\n choices = Array.new\n id = question['id']\n label = question['question']\n q_choices = choices_for_question_id(id)\n q_choices.each_with_index do |choice, c_order|\n c_id = choice['id']\n c_label = choice['label']\n c_correct = (answer_for_question_id(id) == c_id)\n c_value = default_choice_value(c_id, c_correct, c_label, c_order)\n choices.push(c_value)\n end\n result['id'] = id\n result['order'] = order\n result['question'] = label\n result['choices'] = choices\n result['total'] = 0.0 # ADDED, if refactor.\n result['percentages'] = percentages_from_decimal(0.0)\n r[id] = result\n end\n r\n end",
"def parse_xml(xml)\n hash = XmlSimple.xml_in(xml)\n hash['query']#return just the results of the query\nend",
"def parse_results_page_and_store_values\n final = {}\n (1..10).each do |i|\n name = search_list_name(i).is_present? ? search_list_name(i).text : nil\n title = search_list_title(i).is_present? ? search_list_title(i).text : nil\n country = search_list_country(i).is_present? ? search_list_country(i).text : nil\n price = search_list_price(i).is_present? ? search_list_price(i).text : nil\n upskill_tags = search_list_upskill_badge(i).is_present? ? search_list_upskill_badge(i).texts : nil\n\n result_hash = {\n \"name\": name,\n \"title\": title,\n \"country\": country,\n \"price\": price,\n \"upskill_tags\": upskill_tags,\n }\n final[i] = result_hash\n end\n return final\n end",
"def grouped_query_terms( results )\n grouped_terms = {}\n \n unless results.empty?\n results.each do |primary_field,results_stash|\n results_stash[\"index\"].each do |field,value|\n grouped_terms_for_field = grouped_terms[field]\n\n unless grouped_terms_for_field \n grouped_terms[field] = []\n grouped_terms_for_field = grouped_terms[field]\n end\n \n if value.is_a?(Array)\n value.each do |val|\n grouped_terms_for_field.push( val )\n end\n else\n grouped_terms_for_field.push( value )\n end\n end\n end\n \n grouped_terms.each do |field,values|\n grouped_terms[field] = values.uniq\n end\n end\n \n return grouped_terms\n end",
"def parsed\n params = { :apiKey => client.api_key }\n resp = Precog.get(client, \"/analytics/v#{VERSION}/queries/#{qid}\", { 'Content-Type' => 'application/json' }, params)\n data = resp.body\n\n if data && data.length >= 2\n output = JSON.parse data\n\n [\n output[\"errors\"].select { |i| !i.nil? }.map { |i| Precog.parse_info i },\n output[\"warnings\"].select { |i| !i.nil? }.map { |i| Precog.parse_info i },\n output[\"data\"]\n ]\n end\n end",
"def create_query_hash(array)\n names = array.shift\n rval = []\n array.each do |r|\n row = {}\n names.each_with_index { |column, idx| row[column] = r[idx] }\n rval << row\n end\n rval\nend",
"def process_query\n @results = str_to_obj.flatten.collect do |url|\n doc = Mechanize.new.get(url)\n els = doc.search(CGI.unescape(@xpath))\n els.map { |el| [el.text] }\n end\n @results = @results.flatten.map { |r| [r] }\n end",
"def raw_results\n results\n end",
"def results_as_objects(results)\n results_as_objects = []\n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects \n end",
"def results\n numOfSearches = numEvents / @OFFSET #the number of searches we must make to return all values\n result = Array.new\n if (complete?)\n for i in 0..numOfSearches\n result.push( @client.get_request(\"/services/search/jobs/#{@sid}/results\", {'output_mode' => @OUTPUT_MODE, 'count' => @OFFSET, 'offset' => (@OFFSET * i)}))\n end\n end\n result\n end",
"def to_results\n info = request :q => @query, :rsz => @opts[:size], :start => ((@opts[:page] - 1) * @opts[:size])\n results = info[:results]\n query_strings = info[:query_strings]\n coder = HTMLEntities.new\n if(results['responseData']['cursor']['currentPageIndex'].nil?)\n new_one = Chen::Results.new\n new_one.estimated = 0\n return new_one\n end\n \n \n current_page = results['responseData']['cursor']['currentPageIndex']+1\n max_result = query_strings[:start] + query_strings[:rsz]\n estimated_results = results['responseData']['cursor']['resultCount']\n result_array = results['responseData']['results']\n \n datas = Chen::Results.new\n datas.estimated = estimated_results\n result_array.each_with_index do |result, i|\n new_data = Chen::SearchResult.new\n new_data.tap do |d|\n d.title = result[\"titleNoFormatting\"]\n d.url = result[\"url\"]\n d.desc = result[\"content\"].squeeze(\" \")\n d.number = (i + query_strings[:start] + 1)\n end\n datas << new_data\n end\n return datas\n end",
"def dissect_to_record_hashes\n end",
"def parse_triples(stream, search_key)\n data_array = []\n parse_uri = 'http://purl.org/dc/terms/'\n full_uri = parse_uri + search_key\n return data_array unless stream.include? full_uri\n RDF::NTriples::Reader.new(stream) do |reader|\n begin\n reader.each_statement do |statement|\n next unless statement.predicate.to_s == full_uri\n data_array << statement.object.to_s\n end\n rescue RDF::ReaderError => e\n @exceptions << \"#{e.inspect}\"\n end\n end\n data_array.reject(&:empty?)\n end",
"def results\n query = parse\n\n results = []\n positive = query[:positive].to_a\n results << Language.where(name: positive)\n results << Language.where(type: positive)\n results << Language.where(designers: positive)\n\n weights = weight_results results\n\n positive = results.flatten.uniq(&:name).index_by &:name\n\n results = []\n negative = query[:negative].to_a\n\n results << Language.where_not(name: negative).map(&:name)\n results << Language.where_not(type: negative).map(&:name)\n results << Language.where_not(designers: negative).map(&:name)\n\n negative = results.inject(results[0]) {|result, array| result & array }.uniq\n\n final_results = positive.slice(*negative).values\n sort_results set_hits(final_results, weights), weights\n end",
"def fetch_hash_all\n fetch_many0(nil, Hash)\n end",
"def get_all_results\n\t\tresult_array = []\n\t\tskip = 0\n\t\ttake = 1000\n\t\tloop do\n\t\t\tcurrent_result = get_data_from_result(execute_request(take, skip)[1])\n\t\t\tresult_array.concat(current_result)\n\t\t\tskip = skip + take\n\t\t\tbreak if current_result.size != take\n\t\tend\n\t\treturn result_array\n\tend",
"def result_tuples(result, id)\n Testing.read_tuples(result, id.to_s).map{|tuples| tuples.to_a}\nend",
"def result_set\n klass.requestor.get(nil, { query: to_s })\n end",
"def results\n unless errors\n if total_results_returned == 1\n [Yahoo::SE::Result.new(self.to_json[\"ResultSet\"][\"Result\"])]\n elsif total_results_available == 0\n []\n else\n self.to_json[\"ResultSet\"][\"Result\"].map do |result_hash|\n Yahoo::SE::Result.new(result_hash)\n end\n end\n end\n end",
"def wql_hash\n metric_ids = unique_metric_ids\n if metric_ids.any?\n { id: [:in] + metric_ids }\n else\n { id: -1 } # HACK: ensure no results\n end\nend",
"def to_a\n\t\tarr = []\n\t\tresults.each do |row|\n\t\t\tarr.push([row[\"user_id\"],row[\"movie_id\"],row[\"rating\"],row[\"predicted\"]])\n\t\tend\n\t\treturn arr\n\tend",
"def get_all\n result = Array.new\n #adding value hash to array\n @elements.each do |element|\n result.push ({\n 'title' => element.css('h3.product_title a').text ,\n 'score' => element.css('span.metascore_w').text.to_i\n })\n end\n #return value\n result\n end",
"def array_result\n [@result['results']].flatten\n end",
"def resultset\n @resultset ||= parse_resultset(stored_data)\n end",
"def hash\n [query, sample_rate].hash\n end",
"def results\n @solr_data[:docs]\n end",
"def query(query)\n raw_query(query).map do |row|\n row = row.map do |item| \n # If the row entry is a String, it is the result already, and not, as \n # Neo4j.build would expect, the URL of a Neo4j node or relationship. The\n # same is true for all non-hashes.\n next item unless item.is_a?(Hash)\n build_from_hash(item)\n end\n \n row = row.first if row.length == 1\n row\n end\n end",
"def generate_dataset\n return nil if query.nil?\n # execute the query\n data = Array ActiveRecord::Base.connection.execute(query)\n return [] if data.empty?\n # Convert the query into an easy to read format\n @dataset = [data.first.keys]+data.map{|dd|dd.values}\n return @dataset\n end",
"def results; end",
"def results; end",
"def results; end",
"def hash\n [additional_query_filters, data_source, group_mode, measure, name, slo_id, slo_query_type].hash\n end",
"def results\n if (@location_type == 'state')\n breweries = brewery_db.locations.all(region: @location)\n elsif (@location_type == 'postal')\n breweries = brewery_db.locations.all(postalCode: @location)\n end\n\n brewery_arr = []\n breweries.each do |b|\n content = {}\n content['name'] = b.brewery.name\n content['id'] = b.breweryId\n content['website'] = b.brewery.website\n brewery_arr << content\n end\n\n return brewery_arr\n end",
"def parse_results(results)\n results.rows.collect do |row|\n record = {}\n row.each_with_index{|val, i| \n val = val.force_encoding('utf-8') if val\n record[results.fields[i].name] = val\n }\n \n record\n end\n end",
"def getResults (allEntryIds, page, resultsPerPage)\n pubLib = Array.new\n @startIndex = (page-1)*resultsPerPage\n @endIndex = @allEntries.size() <= ((page-1)*resultsPerPage)+resultsPerPage ? @allEntries.size() : ((page-1)*resultsPerPage)+resultsPerPage\n #puts \"#{@startIndex} to #{@endIndex}\"\n medline = esummary(allEntryIds.values_at(@startIndex ... @endIndex).join(','))\n d = Hpricot.XML(medline) \n pubmedRank = @startIndex+1\n (d/:DocSum).each do |a|\n entry = Hash.new\n entry[:pubmedRank] = pubmedRank\n entry[:id] = a.at('Id').inner_html\n entry[:Date] = a.at(\"Item[@Name='PubDate']\").inner_html\n autoren = Array.new\n a.at(\"Item[@Name='AuthorList']\").search('Item') do |author|\n if(!author.nil?)\n autoren.push \"#{author.inner_html}\"\n end\n end\n #autoren += a.at(\"Item[@Name='LastAuthor']\").inner_html creates duplicate of LastAuthor, bad!\n entry[:Authors] = autoren\n entry[:Title] = a.at(\"Item[@Name='Title']\").inner_html\n pmcid =\"none\" \n if(a.at(\"Item[@Name='ArticleIds']\").at(\"Item[@Name='pmc']\"))\n pmcid = a.at(\"Item[@Name='ArticleIds']\").at(\"Item[@Name='pmc']\").inner_html\n end\n entry[:PMCid] = pmcid\n pubLib << entry\n pubmedRank += 1\n end \n pubLib\n end",
"def queries\n qrs = []\n self.each_query {|qr| qrs << qr }\n qrs\n end",
"def extract_work_relations\n relation_array = {}\n self.find_by_terms(:vra_work,:relationSet,:relation_imageIs, :relation_relids).each do |relation_imageIs| \n ::Solrizer::Extractor.insert_solr_field_value(relation_array, \"relation_imageIs_tesim\", relation_imageIs.text) \n end\n self.find_by_terms(:vra_work,:relationSet,:relation_preferred, :relation_relids).each do |relation_preferred| \n ::Solrizer::Extractor.insert_solr_field_value(relation_array, \"relation_preferred_tesim\", relation_preferred.text) \n end\n return relation_array\n end",
"def embiggen_grouped_results(values)\n embiggened_results = []\n values.each do |resultset|\n container = {} \n resultset.each do |set|\n data = {}\n set.data.each do |key, value|\n if value.kind_of? Hash\n if value.empty?\n value = []\n else \n value = [value] if value.kind_of? Hash\n end\n end\n data[key] = value\n end\n container.merge!(data) do |key, old, nue|\n if old.kind_of? Array\n old.push nue.first\n else\n nue\n end \n end\n end\n embiggened_results.push container\n end\n\n embiggened_results\n end",
"def results_for_query(query)\n raise ArgumentError unless query.is_a?(Query)\n @results[query] ? @results[query] : []\n end",
"def to_a\n return @results\n end",
"def to_sapint_query\n @dsapi_query.reduce({}) do |res, (key, value)|\n json = sapint_query(key, value)\n res.merge(json || {})\n end\n end",
"def old_query # rubocop:disable Metrics/AbcSize, Metrics/MethodLength\n data = []\n\n query_result = generic_query(params: { 'source-id': 'datacite-usage', 'doi': @doi })\n data += query_result['data'] if query_result['data']\n\n while query_result['links']['next']\n query_result = make_reliable { RestClient.get query_result['links']['next'] }\n query_result = JSON.parse(query_result)\n data += query_result['data'] if query_result['data']\n end\n\n data\n rescue RestClient::ExceptionWithResponse => err\n logger.error(\"#{Time.new} Could not get response from DataCite event data source-id=datacite-usage&doi=#{CGI.escape(@doi)}\")\n logger.error(\"#{Time.new} #{err}\")\n []\n end",
"def map_to_hash_by_primary_key(result) \n hash = {}\n\n result.each do |record|\n hash[record[@primary_key]] = record\n end\n\n hash\n end",
"def all\n results = CONNECTION.execute(\"SELECT * FROM #{get_table_name}\")\n\n results_as_objects = []\n\n results.each do |results_hash|\n results_as_objects << self.new(results_hash)\n end\n\n return results_as_objects\n end",
"def build_key_values(qh)\n # @key_values = {}\n # @query_map = []\n # @counter = 0\n\n qh.each_with_index do |ha,i|\n ha[1] = ha[1].to_a\n query_tag = []\n ha[1].each do |v|\n @key_values[\"-q#{@counter}\"] = ha[0]\n @key_values[\"-q#{@counter}.value\"] = v\n query_tag << \"q#{@counter}\"\n @counter += 1\n end\n @query_map << query_tag\n end\n return @key_values, @query_map\n end",
"def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n # TODO put these lines back in and create another method to turn results_as_objects array of \n # objects in to array of hashes!!!!!!!\n results_as_objects = []\n\n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end",
"def query_data(base_query)\n query = base_query\n result = Hash.new\n\n # Filters\n query = apply_filters(query, tablesorter_params)\n\n # Calculate row counts\n rec_counts = record_counts(base_query, query)\n result[:filtered_rows] = rec_counts[:filtered_rows]\n result[:total_rows] = rec_counts[:total_rows]\n\n # Handle paging afterwards\n query = handle_pagination(query, tablesorter_params, result)\n\n # Sorting\n query = apply_sorting(query, tablesorter_params)\n\n result[:records] = query\n\n result\n end",
"def rows\n @rows ||= if ActiveRecord::Base.connection.adapter_name == \"PostgreSQL\"\n result.entries\n else\n [].tap do |row_hashes|\n result.entries.map do |row|\n hash = {}\n result.fields.each do |field|\n hash[field] = row[result.fields.index(field)]\n end\n row_hashes << hash\n end\n end\n end\n end",
"def get_query_result_docs(query_obj)\n response = @query_server.query(query_obj)\n response.getResults\n end",
"def prepared_results\n prepared = []\n results = WatirNokogiri::Document.new(html).lis(Selectors::FAST_SEARCH_MODAL[:result][:self])\n\n results.each { |result| prepared[] = { title: title(result), price: price(result) } }\n\n prepared\n end",
"def create_result_list(query_result)\n return create_result_list_from_hash(query_result) if query_result.is_a?(Hash)\n create_result_list_from_array(query_result)\n end",
"def results\n @solr_data[:docs]\n end",
"def results ; @@RESULT_DIRS.keys.map{ |k| result k }.compact ; end",
"def list_as_hash solr_list\n # map\n if solr_list.values.first.is_a? Hash\n solr_list\n else\n solr_list.each_with_object({}) do |(key, values), hash|\n hash[key] = if values.first.is_a? Array\n # arrarr\n Hash[values]\n else\n # flat\n Hash[values.each_slice(2).to_a]\n end\n end\n end\n end",
"def query(soql)\n response = api_get 'query', :q => soql\n mashify? ? response.body : response.body['records']\n end",
"def results\n each_node.map do |node|\n [node.expression, node_runs(node)]\n end.to_h\n end",
"def to_hash\n result = {}\n each_pair { |name,results| result[name] = results }\n result\n end",
"def parse_raw_data(result)\r\n jobs = Array.new\r\n return jobs if result['results'].to_s.empty?\r\n result['results'].each do |offer|\r\n job = Hash.new\r\n job[:jobtitle] = offer['jobtitle'] if offer['jobtitle']\r\n job[:location] = \"#{offer['country']}, #{offer['city']}\"\r\n job[:company] = offer['company']\r\n job[:date] = convert_date_to_format(offer['date'],'%d/%m/%y')\r\n job[:url] = offer['url']\r\n job = convert_empty_to_nil(job)\r\n jobs << OpenStruct.new(job)\r\n end\r\n return jobs\r\n end",
"def empty_results(hits = 0)\n {\n 'SearchRequest'=>\n {\n 'SearchCriteria'=>\n {\n 'Queries'=>nil,\n 'SearchMode'=>'',\n 'IncludeFacets'=>'y',\n 'Sort'=>'relevance',\n 'AutoSuggest'=>'n',\n 'AutoCorrect'=>'n'\n },\n 'RetrievalCriteria'=>\n {\n 'View'=>'brief',\n 'ResultsPerPage'=>20,\n 'Highlight'=>'y',\n 'IncludeImageQuickView'=>'n'\n },\n 'SearchCriteriaWithActions'=>\n {\n 'QueriesWithAction'=>nil\n }\n },\n 'SearchResult'=>\n {\n 'Statistics'=>\n {\n 'TotalHits'=>hits,\n 'TotalSearchTime'=>0,\n 'Databases'=>[]\n },\n 'Data'=> {'RecordFormat'=>'EP Display'},\n 'AvailableCriteria'=>{'DateRange'=>{'MinDate'=>'0001-01', 'MaxDate'=>'0001-01'}}\n }\n }\n end",
"def resultset_to_hash(resultset)\n meta = resultset.meta_data\n rows = []\n\n while resultset.next\n row = {}\n\n (1..meta.column_count).each do |i|\n name = meta.column_name i\n row[name] = case meta.column_type(i)\n when -6, -5, 5, 4\n # TINYINT, BIGINT, INTEGER\n resultset.get_int(i).to_i\n when 41\n # Date\n resultset.get_date(i)\n when 92\n # Time\n resultset.get_time(i).to_i\n when 93\n # Timestamp\n resultset.get_timestamp(i)\n when 2, 3, 6\n # NUMERIC, DECIMAL, FLOAT\n case meta.scale(i)\n when 0\n resultset.get_long(i).to_i\n else\n BigDecimal.new(resultset.get_string(i).to_s)\n end\n when 1, -15, -9, 12\n # CHAR, NCHAR, NVARCHAR, VARCHAR\n resultset.get_string(i).to_s\n else\n resultset.get_string(i).to_s\n end\n end\n\n rows << row\n end\n rows\nend",
"def results\n @results ||= with_hit.map(&:first)\n end",
"def new_result_sets_for(searches)\n new_result_sets = Hash.new\n searches.each do |s|\n new_result_sets[s] = s.new_results if s.new_results.count > 0 \n end\n return new_result_sets\n end",
"def query_result_set(query)\n\t result = ValueSet.new\n\t call(:query_result_set, query) do |marshalled_set|\n\t\tfor task in marshalled_set\n\t\t task = local_object(task)\n\t\t Distributed.keep.ref(task)\n\t\t result << task\n\t\tend\n\t end\n\n\t result\n\tend",
"def results\n output = Array.new(size)\n cur = 0\n @data['results'].each do |e|\n output[cur] = DBLRuby::Bot.new(data: e)\n cur += 1\n end\n output\n end",
"def build_results(solr_docs)\n results = Nokogiri::XML::Builder.new do |xml|\n xml.documents( :total => solr_docs[\"response\"][\"numFound\"], :\"page-size\" => solr_docs[\"page_size\"], :\"page-number\" => solr_docs[\"page\"] ) { \n solr_docs[\"response\"][\"docs\"].each do |doc| \n xml.document(:created => check_solr_field(doc[\"fgs_createdDate_date\"]), :\"last-modified\" => check_solr_field(doc[\"fgs_lastModifiedDate_date\"]), :name => doc[\"id\"] ) {\n xml.details {\n solr_docs[\"queries\"].each do |q| \n xml.detail_ check_solr_field(doc[q])\n end\n }\n }\n end\n }\n end\n return results.to_xml\n end",
"def result_response\n [\n total_hits_node,\n results_node(:top_results, @top_results),\n results_node(:other_results, @other_results),\n results_node(:filtered_results, @filtered_results),\n errors_node\n ].inject(&:merge)\n end",
"def get_all_entries()\n jso = Hash.new()\n \n # Connect to database\n dbe = MIDB::API::Dbengine.new(@engine.config, @db)\n dblink = dbe.connect()\n rows = dbe.query(dblink, \"SELECT * FROM #{self.get_structure.values[0].split('/')[0]};\")\n if rows == false\n return MIDB::Interface::Server.json_error(400, \"Bad Request\")\n end\n # Iterate over all rows of this table\n rows.each do |row|\n jso[row[\"id\"]] = self.get_structure\n self.get_structure.each do |name, dbi|\n table = dbi.split(\"/\")[0]\n field = dbi.split(\"/\")[1]\n # Must-match relations (\"table2/field/table2-field->row-field\")\n if dbi.split(\"/\").length > 2\n match = dbi.split(\"/\")[2]\n matching_field = match.split(\"->\")[0]\n row_field = match.split(\"->\")[1]\n query = dbe.query(dblink, \"SELECT #{field} FROM #{table} WHERE #{matching_field}=#{row[row_field]};\")\n else\n query = dbe.query(dblink, \"SELECT #{field} from #{table} WHERE id=#{row['id']};\")\n end\n if query == false\n return MIDB::Interface::Server.json_error(400, \"Bad Request\")\n end\n jso[row[\"id\"]][name] = dbe.length(query) > 0 ? dbe.extract(query,field) : \"unknown\"\n jso[row[\"id\"]][name] = @hooks.format_field(name, jso[row[\"id\"]][name])\n end\n end\n @hooks.after_get_all_entries(dbe.length(rows))\n return jso\n end",
"def query\n <<-SPARQL\n SELECT DISTINCT ?item ?vglistId WHERE {\n ?item wdt:P8351 ?vglistId.\n }\n SPARQL\nend",
"def results\n @dataset.all\n end",
"def questions\n results = CONNECTION.execute(\"SELECT * FROM questions WHERE student_id = #{@id};\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << Question.new(result_hash[\"id\"], result_hash[\"student_id\"], result_hash[\"content\"])\n end\n \n return results_as_objects\n end",
"def extract_query_attributes(hash)\n query = hash.select{ |key, value| !link_attributes.include?key }.flatten\n Hash[*query] unless query.empty?\n end",
"def initial_data\n @query_tracker.results.map.with_index do |data, index|\n data = data.dup\n data['_id'] = data['_id'].to_s\n [index, data]\n end\n end",
"def get_sighting_records(db)\r\n\r\n sighting_records = db.query(\"select * from sighting_details order by id\")\r\n\r\n return sighting_records.to_a\r\n\r\nend",
"def setup\n xml_results = <<BEGIN\n <search:response total=\"2\" start=\"1\" page-length=\"10\" xmlns:search=\"http://marklogic.com/appservices/search\">\n <search:result index=\"1\" uri=\"/documents/discoverBook.xml\" path=\"fn:doc('/documents/discoverBook.xml')\" score=\"243\" confidence=\"0.97047\" fitness=\"1\">\n <search:snippet>\n <search:match path=\"fn:doc('/documents/discoverBook.xml')/*:book/*:bookinfo/*:title\">Discoverers <search:highlight>and</search:highlight> Explorers</search:match>\n <search:match path=\"fn:doc('/documents/discoverBook.xml')/*:book/*:chapter[1]/*:chapterinfo/*:biblioentry/*:title\">Discoverers <search:highlight>and</search:highlight> Explorers</search:match>\n </search:snippet>\n </search:result>\n <search:result index=\"2\" uri=\"/documents/a_and_c.xml\" path=\"fn:doc('/documents/a_and_c.xml')\" score=\"234\" confidence=\"0.952329\" fitness=\"1\">\n <search:snippet>\n <search:match path=\"fn:doc('/documents/a_and_c.xml')/PLAY/PERSONAE/PERSONA[10]\">Officers, Soldiers, Messengers, <search:highlight>and</search:highlight> other Attendants.</search:match>\n </search:snippet>\n </search:result>\n <search:qtext>and</search:qtext>\n <search:metrics>\n <search:query-resolution-time>PT0.009197S</search:query-resolution-time>\n <search:facet-resolution-time>PT0.000083S</search:facet-resolution-time>\n <search:snippet-resolution-time>PT0.019534S</search:snippet-resolution-time>\n <search:total-time>PT0.029033S</search:total-time>\n </search:metrics>\n</search:response>\nBEGIN\n\n xml_results_noh = <<BEGIN\n <search:response total=\"2\" start=\"1\" page-length=\"10\" xmlns:search=\"http://marklogic.com/appservices/search\">\n <search:result index=\"1\" uri=\"/documents/discoverBook.xml\" path=\"fn:doc('/documents/discoverBook.xml')\" score=\"243\" confidence=\"0.97047\" fitness=\"1\">\n <search:snippet>\n <search:match path=\"fn:doc('/documents/discoverBook.xml')/*:book/*:bookinfo/*:title\">Discoverers and Explorers</search:match>\n <search:match path=\"fn:doc('/documents/discoverBook.xml')/*:book/*:chapter[1]/*:chapterinfo/*:biblioentry/*:title\">Discoverers and Explorers</search:match>\n </search:snippet>\n </search:result>\n <search:result index=\"2\" uri=\"/documents/a_and_c.xml\" path=\"fn:doc('/documents/a_and_c.xml')\" score=\"234\" confidence=\"0.952329\" fitness=\"1\">\n <search:snippet>\n <search:match path=\"fn:doc('/documents/a_and_c.xml')/PLAY/PERSONAE/PERSONA[10]\">Officers, Soldiers, Messengers, and other Attendants.</search:match>\n </search:snippet>\n </search:result>\n <search:qtext>and</search:qtext>\n <search:metrics>\n <search:query-resolution-time>PT0.009197S</search:query-resolution-time>\n <search:facet-resolution-time>PT0.000083S</search:facet-resolution-time>\n <search:snippet-resolution-time>PT0.019534S</search:snippet-resolution-time>\n <search:total-time>PT0.029033S</search:total-time>\n </search:metrics>\n</search:response>\nBEGIN\n\n results_with_facets = <<-BEGIN\n<search:response total=\"21973\" start=\"1\" page-length=\"10\" xmlns:search=\"http://marklogic.com/appservices/search\">\n <search:result index=\"9\" uri=\"/Users/clarkrichey/Downloads/wits/wits21402.xml\" path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits21402.xml")\" score=\"196\" confidence=\"0.338805\" fitness=\"0.890659\">\n <search:snippet>\n <search:match path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits21402.xml")/*:Incident/*:Subject\">1 newspaper editor injured in letter <search:highlight>bomb</search:highlight> attack by Informal Anarchist Federation in Turin, Piemonte, Italy</search:match>\n <search:match path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits21402.xml")/*:Incident/*:EventTypeList\">\n<search:highlight>Bombing</search:highlight>\n</search:match>\n <search:match path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits21402.xml")/*:Incident/*:WeaponTypeList/*:WeaponType\">Letter <search:highlight>Bomb</search:highlight></search:match>\n </search:snippet>\n </search:result>\n <search:result index=\"10\" uri=\"/Users/clarkrichey/Downloads/wits/wits23118.xml\" path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits23118.xml")\" score=\"196\" confidence=\"0.338805\" fitness=\"0.890659\">\n <search:snippet>\n <search:match path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits23118.xml")/*:Incident/*:Subject\">1 government employee killed in <search:highlight>bombing</search:highlight> in Ghazni, Afghanistan</search:match>\n <search:match path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits23118.xml")/*:Incident/*:EventTypeList\">\n<search:highlight>Bombing</search:highlight>\n</search:match>\n </search:snippet>\n </search:result>\n <search:facet name=\"Region\">\n <search:facet-value name=\"Africa\" count=\"622\">Africa</search:facet-value>\n <search:facet-value name=\"Central and South America\" count=\"1012\">Central and South America</search:facet-value>\n <search:facet-value name=\"East Asia-Pacific\" count=\"1198\">East Asia-Pacific</search:facet-value>\n <search:facet-value name=\"Eurasia\" count=\"761\">Eurasia</search:facet-value>\n <search:facet-value name=\"Europe\" count=\"1057\">Europe</search:facet-value>\n <search:facet-value name=\"Middle East and Persian Gulf\" count=\"10374\">Middle East and Persian Gulf</search:facet-value>\n <search:facet-value name=\"North America and Caribbean\" count=\"16\">North America and Caribbean</search:facet-value>\n <search:facet-value name=\"South Asia\" count=\"6933\">South Asia</search:facet-value>\n </search:facet>\n <search:facet name=\"Country\">\n <search:facet-value name=\"England\" count=\"200\">England</search:facet-value>\n <search:facet-value name=\"Ireland\" count=\"422\">Ireland</search:facet-value>\n <search:facet-value name=\"Brazil\" count=\"10\">Brazil</search:facet-value>\n </search:facet>\n <search:qtext>bomb</search:qtext>\n <search:metrics>\n <search:query-resolution-time>PT0.420016S</search:query-resolution-time>\n <search:facet-resolution-time>PT0.002873S</search:facet-resolution-time>\n <search:snippet-resolution-time>PT0.039998S</search:snippet-resolution-time>\n <search:total-time>PT0.463759S</search:total-time>\n </search:metrics>\n</search:response>\n BEGIN\n @search_results = ActiveDocument::SearchResults.new(xml_results)\n @search_results_noh = ActiveDocument::SearchResults.new(xml_results_noh)\n @faceted_results = ActiveDocument::SearchResults.new(results_with_facets)\n end",
"def run(results)\n columns_names = rows.first.inject([]) {|m, kv| m << kv[0]; m}\n row_count = rows.size\n initial_data = results.all.map {|r| columns.map {|c| r[c]}}\n asrecordset = ASRecordset.new(row_count,column_names,initial_data)\n \tresult = asrecordset\n \treturn result\n end",
"def results\n d = data\n if d != nil and d.has_key?('results')\n return d['results']\n end\n nil\n end",
"def process_search_results(content)\n extractions = _search_attributes.hmap do |name, expression|\n [name, content.extract(expression)]\n end\n\n [].tap do |results|\n extractions.values.map(&:size).max.times do |index|\n result = {}\n extractions.each do |key, value|\n result[key] = value[index]\n end\n results << new(result)\n end\n end\n end",
"def build_output(query, ori_query, res, sim, offset)\n return { requested_query: query, \n original_query: ori_query, \n offset: offset,\n uri: res[:uri], \n label: res[:label], \n sim: sim,\n }\n\tend",
"def to_hash\n data = Hash.new\n Dynamic.tables.each do |name, value|\n data[name] = Hash.new\n value.all.each do |primary, instance|\n data[name][primary] = instance.to_array\n end\n end\n data\n end",
"def build_search_results_array(doc)\n names = return_names_array(doc)\n descrs = return_descriptions_array(doc)\n durs = return_durations_array(doc)\n diffs = return_difficulties_array(doc)\n links = return_links_array(doc)\n\n search_results = []\n\n names.each_with_index do |_name, i|\n search_results << { name: names[i], descr: descrs[i], dur: durs[i], diff: diffs[i], link: links[i] }\n end\n\n return search_results\n end"
] | [
"0.6852527",
"0.68460184",
"0.6480743",
"0.6252371",
"0.624222",
"0.60889405",
"0.60440075",
"0.6025583",
"0.5962136",
"0.59437436",
"0.59434444",
"0.5936695",
"0.59107465",
"0.5868845",
"0.58679944",
"0.58495873",
"0.58319855",
"0.5831614",
"0.58106416",
"0.58074385",
"0.578951",
"0.5783182",
"0.57735586",
"0.5759493",
"0.57583165",
"0.57137334",
"0.56982255",
"0.568291",
"0.5671997",
"0.5657536",
"0.5637343",
"0.5620043",
"0.5606786",
"0.56037736",
"0.5594455",
"0.5591709",
"0.55748314",
"0.557011",
"0.5565778",
"0.55639875",
"0.55593896",
"0.5559298",
"0.5558802",
"0.55500627",
"0.5545851",
"0.55454844",
"0.55421466",
"0.5538414",
"0.5531908",
"0.55269027",
"0.55269027",
"0.55269027",
"0.5520693",
"0.55156463",
"0.551529",
"0.5515174",
"0.55128723",
"0.55110836",
"0.54967016",
"0.54907167",
"0.5489169",
"0.54887813",
"0.5487327",
"0.54701793",
"0.54570234",
"0.5449286",
"0.54489905",
"0.54432523",
"0.5440419",
"0.54348934",
"0.5434556",
"0.541769",
"0.5415675",
"0.5410429",
"0.5408508",
"0.5405201",
"0.5402699",
"0.54020256",
"0.5398664",
"0.5397982",
"0.53960884",
"0.5395601",
"0.538399",
"0.53772706",
"0.53747356",
"0.5368324",
"0.5363528",
"0.5347204",
"0.53457797",
"0.5343938",
"0.5338349",
"0.5337331",
"0.5334529",
"0.5325901",
"0.5324556",
"0.5321157",
"0.5317662",
"0.53093725",
"0.53068507",
"0.5303295",
"0.53013986"
] | 0.0 | -1 |
Interfaces that must be implemented | def triples(triple, context = nil) # :yields: triple, context
raise StoreException, "not implemented"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def included_interfaces; end",
"def interface; end",
"def interface; end",
"def extended_interfaces; end",
"def interface_methods; end",
"def implemented_in; end",
"def protocol\n raise NotImplementedError\n end",
"def implementation; end",
"def implementation; end",
"def traits; end",
"def interface_decls; end",
"def interface; self.class.interface; end",
"def implements()\n return %i[on_collection on_step on_step_end on_phrase on_source]\n end",
"def implements?() \n return true if self[:implements].length > 0\n end",
"def commence\n raise NotImplementedError\n end",
"def dispatch\n raise NotImplementedError\n end",
"def implementation\n fail 'Subclasses must implement implementation()!'\n end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def visit_upgrade\n raise NotImplementedError, 'This is an interface'\n end",
"def protocol; end",
"def protocol; end",
"def protocol; end",
"def protocol; end",
"def provide\n raise NotImplementedError\n end",
"def interface_cache; end",
"def abstract?; end",
"def protocol\n super\n end",
"def allowed?() raise NotImplementedError end",
"def interfaces\n InterfaceCollection.open\n end",
"def not_implemented\n @errors.add(\"Not implemented.\")\nend",
"def visit_product\n raise NotImplementedError, 'This is an interface'\n end",
"def service; raise NotImplementedError; end",
"def run; raise NotImplementedError; end",
"def run; raise NotImplementedError; end",
"def overrides; end",
"def interfaces\n klass = is_a?(Class) ? self : self.class\n klass.included_modules.select { |mod| mod.is_a?(Abstract) }\n end",
"def support\n raise \"Not implemented\"\n end",
"def required_operations1\n raise NotImplementedError, \"#{self.class} has not implemented method '#{__method__}'\"\n end",
"def type\n\t\traise NotImplementedError\n\tend",
"def abstract_method\n method_not_implemented\n end",
"def private; end",
"def certain?\n fail NotImplementedError\n end",
"def is_valid?\n raise \"Not Implemented. Class #{self.class.name} doesn't implement is_valid?\"\n end",
"def methods() end",
"def conforms_to?(interface)\n # interface must be an Interface\n raise InterfaceError, \"#{interface} is not an Interface\" unless interface < Interface\n interface.abstract_methods.all? { |method| self.respond_to?(method) }\n end",
"def unimplemented_methods\n self.class.interfaces.inject({}) do |hash, interface|\n methods = unimplemented_methods_for(interface)\n methods.empty? ? hash : hash.merge!(interface => methods)\n end\n end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def interfaces\n @interfaces ||= Interface.coercer(attributes[:interfaces])\n end",
"def object\n raise NotImplementedError\n end",
"def implements(intf)\n @intfs[intf.name] = intf\n end",
"def abstract!; end",
"def verify?; raise NotImplementedError; end",
"def respond_to_missing?(_method_name, _include_all)\n ::Kernel.raise ::NotImplementedError\n end",
"def respond_to_missing?(_method_name, _include_all)\n ::Kernel.raise ::NotImplementedError\n end",
"def used\n raise NotImplementedError\n end",
"def instructions; raise NotImplementedError\n end",
"def requirements; end",
"def requirements; end",
"def requirements; end",
"def requirements; end",
"def interface=(_arg0); end",
"def _require_implementation!(method)\n raise ::NotImplementedError, \"#{method} not implemented by #{self.class}\"\n end",
"def type\n raise 'derived should implement'\n end",
"def describe\n raise NotImplementedError\n end",
"def call\n raise NotImplementedError\n end",
"def call\n raise NotImplementedError\n end",
"def k_implements!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n\n\n type = K_IMPLEMENTS\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 365:3: 'implements'\n match( \"implements\" )\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__, 28 )\n\n\n end",
"def unquiesce \n raise NotImplementedError.new\n end",
"def input_events\n raise NotImplementedError\n end",
"def init\n raise NotImplementedError\n end",
"def interfaces\n Vedeu::Interfaces.registered\n end",
"def tag; raise 'Override this method'; end",
"def errors\n raise 'Method should implemented in inherit class'\n end",
"def type\n raise NotImplementedError\n end",
"def respond_to_missing?(*_args); super; end",
"def for_all?\n fail NotImplementedError\n end",
"def magical?\n fail NotImplementedError\n end",
"def accessibility; end",
"def __getobj__\n raise \"Abstract class requires implementation\"\n end",
"def implement_me\n flunk('Test not yet implemented.')\n end",
"def functions(name = nil)\n raise \"Internal Error: Connection adapter did not override abstract function\"\n end",
"def unimplemented_methods_for(interface)\n interface.instance_methods(false).reject { |method| respond_to_missing?(method.to_sym, true) || self.method(method.to_sym).owner != interface }.sort.map(&:to_sym)\n end",
"def sos_piedra?() raise NotImplementedError end",
"def apis; end",
"def dispatch\n raise(NotImplemetedError, \"subclass responsability\")\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def internal_methods; end",
"def type\n\t\t\traise NotImplementedError\n\t\tend",
"def required; end",
"def required; end",
"def required; end",
"def available; end",
"def available; end"
] | [
"0.82600135",
"0.8143838",
"0.8143838",
"0.8038053",
"0.7853838",
"0.7488654",
"0.7318818",
"0.7283394",
"0.7283394",
"0.727682",
"0.71640635",
"0.703358",
"0.69493926",
"0.68615085",
"0.67514664",
"0.66650367",
"0.66645813",
"0.65585035",
"0.65585035",
"0.65585035",
"0.65585035",
"0.65113777",
"0.6463065",
"0.6463065",
"0.6463065",
"0.6463065",
"0.64380276",
"0.64229834",
"0.6418453",
"0.64054656",
"0.64044535",
"0.6380109",
"0.63564",
"0.63315696",
"0.62987155",
"0.629562",
"0.629562",
"0.62953323",
"0.6276575",
"0.6272254",
"0.62616646",
"0.6195046",
"0.61900234",
"0.6170637",
"0.61295515",
"0.6119446",
"0.6117444",
"0.60781944",
"0.6067774",
"0.60676974",
"0.60676974",
"0.60676974",
"0.6048238",
"0.6047107",
"0.60395205",
"0.6030041",
"0.60285276",
"0.60231245",
"0.60231245",
"0.602186",
"0.6003692",
"0.59949183",
"0.59949183",
"0.59949183",
"0.59949183",
"0.5994611",
"0.59805244",
"0.59543043",
"0.5939393",
"0.5924743",
"0.5924743",
"0.5899594",
"0.5894286",
"0.5883346",
"0.58803695",
"0.5878346",
"0.58606696",
"0.5859055",
"0.5846412",
"0.5846093",
"0.5846039",
"0.58451825",
"0.58404887",
"0.5838096",
"0.5815111",
"0.58145994",
"0.58101875",
"0.58033824",
"0.57980573",
"0.5794898",
"0.5791483",
"0.5791483",
"0.5791483",
"0.5791483",
"0.5789158",
"0.5789042",
"0.5783635",
"0.5783635",
"0.5783635",
"0.57657653",
"0.57657653"
] | 0.0 | -1 |
Default (suboptimal) implemenations of interfaces | def inspect
"#{self.class}[identifier=#{identifier.inspect}]"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extended_interfaces; end",
"def interface; end",
"def interface; end",
"def included_interfaces; end",
"def interface_methods; end",
"def interface_decls; end",
"def interface; self.class.interface; end",
"def implements()\n return %i[on_collection on_step on_step_end on_phrase on_source]\n end",
"def implemented_in; end",
"def interface=(_arg0); end",
"def interface_init(interface = {})\r\n if !interface[:dragging].nil?\r\n if interface[:dragging]\r\n @init << enableDragging() \r\n else\r\n @init << disableDragging() \r\n end\r\n end\r\n if !interface[:info_window].nil?\r\n if interface[:info_window]\r\n @init << enableInfoWindow()\r\n else\r\n @init << disableInfoWindow()\r\n end\r\n end\r\n if !interface[:double_click_zoom].nil?\r\n if interface[:double_click_zoom]\r\n @init << enableDoubleClickZoom()\r\n else\r\n @init << disableDoubleClickZoom()\r\n end\r\n end\r\n if !interface[:continuous_zoom].nil?\r\n if interface[:continuous_zoom]\r\n @init << enableContinuousZoom()\r\n else\r\n @init << disableContinuousZoom()\r\n end\r\n end\r\n if !interface[:scroll_wheel_zoom].nil?\r\n if interface[:scroll_wheel_zoom]\r\n @init << enableScrollWheelZoom()\r\n else\r\n @init << disableScrollWheelZoom()\r\n end\r\n end\r\n end",
"def interfaces\n @interfaces ||= Interface.coercer(attributes[:interfaces])\n end",
"def protocol\n raise NotImplementedError\n end",
"def interface_cache; end",
"def implements(intf)\n @intfs[intf.name] = intf\n end",
"def unimplemented_methods\n self.class.interfaces.inject({}) do |hash, interface|\n methods = unimplemented_methods_for(interface)\n methods.empty? ? hash : hash.merge!(interface => methods)\n end\n end",
"def defaults\n {\n interfaces: []\n }\n end",
"def versioned_interface(interface)\n loaded_interfaces[interface] ||= load_interface(interface)\n end",
"def interfaces(direction, collections)\n mode = case direction\n when :input then true\n when :output then false\n else\n raise Bud::CompileError, \"unrecognized interface type #{direction}\"\n end\n collections.each do |tab|\n t_provides << [tab.to_s, mode]\n end \n end",
"def unimplemented_methods_for(interface)\n interface.instance_methods(false).reject { |method| respond_to_missing?(method.to_sym, true) || self.method(method.to_sym).owner != interface }.sort.map(&:to_sym)\n end",
"def implementation; end",
"def implementation; end",
"def interfaces\n klass = is_a?(Class) ? self : self.class\n klass.included_modules.select { |mod| mod.is_a?(Abstract) }\n end",
"def initialize(interface1, interface2)\n @interface1 = interface1\n @interface2 = interface2\n end",
"def traits; end",
"def test_interface_apis\n intf = interfaces[0]\n intf2 = interfaces[1]\n\n # Verify show_name usage\n one = InterfaceChannelGroup.interfaces(intf)\n assert_equal(1, one.length,\n 'Invalid number of keys returned, should be 1')\n assert_equal(Utils.normalize_intf_pattern(intf), one[intf].show_name,\n ':show_name should be intf name when show_name param specified')\n\n # Verify 'all' interfaces\n all = InterfaceChannelGroup.interfaces\n assert_operator(all.length, :>, 1,\n 'Invalid number of keys returned, should exceed 1')\n assert_empty(all[intf2].show_name,\n ':show_name should be empty string when show_name param is nil')\n\n # Test non-existent loopback does NOT raise when calling interfaces\n Interface.new('loopback543', false).destroy if\n Interface.interfaces(nil, 'loopback543').any?\n one = InterfaceChannelGroup.interfaces('loopback543')\n assert_empty(one, 'InterfaceChannelGroup.interfaces hash should be empty')\n end",
"def interfaces\n InterfaceCollection.open\n end",
"def visit_upgrade\n raise NotImplementedError, 'This is an interface'\n end",
"def overrides; end",
"def map_to_interface\n Octothorpe.new(to_h)\n end",
"def Interface(*methods)\n methods.reduce(Types[\"nominal.any\"]) do |type, method|\n type.constrained(respond_to: method)\n end\n end",
"def nonquadport_member_interfaces(interfaces)\n Array(interfaces).map do |interface|\n next unless parsed = parse_interface(interface)\n\n if parsed[:type] == \"Fo\" && switch.facts[\"quad_port_interfaces\"].include?(parsed[:interface])\n quadport_member_interfaces(interface)\n else\n interface\n end\n end.flatten.compact.uniq.sort\n end",
"def [](id)\n interfaces[id]\n end",
"def k_interface!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 35 )\n\n\n\n type = K_INTERFACE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 393:4: 'interface'\n match( \"interface\" )\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__, 35 )\n\n\n end",
"def transformationinterfaceforrepl(*)\n super\n end",
"def get_interfaces(data)\n\n interfaces = Array.new\n @interface = Interface.new\n\n data.each{|value|\n values = get_values(value)\n\n if values.nil?\n next\n end\n\n # New interface\n unless values.nil? || values.interface.eql?(\"\")\n\n unless @interface.empty?\n interfaces << @interface\n end\n\n @interface = Interface.new\n\n 2.times {\n puts \"\"\n }\n puts \"-----------------------\"\n\n @interface.name = values.interface.gsub(/[^a-zA-Z0-9]/,'')\n\n puts \"Interface: #{@interface.name}\"\n\n # In the same line of new Interface, probably a method is defined\n unless values.method.eql?(\"\")\n @method = MethodDef.new\n @method.name = values.method\n @method.output = values.output\n @method.description = values.description\n puts \" Method: #{@method.name} -> #{@method.description} : #{@method.output}\"\n end\n\n unless values.parameter.nil? || values.parameter.eql?(\"\")\n puts \" Parameter: #{values.parameter}\"\n @method.add_parameter values.parameter\n end\n else # Same interface\n # New method\n unless values.method.eql?(\"\")\n @interface.add_method(@method)\n @method = MethodDef.new\n @method.name = values.method\n @method.output = values.output\n @method.description = values.description\n puts \" Method: #{@method.name} -> #{@method.description} : #{@method.output}\"\n end\n # Get parameter for current method\n unless values.parameter.nil? || values.parameter.eql?(\"\")\n puts \" Parameter: #{values.parameter}\"\n @method.add_parameter values.parameter\n end\n end\n }\n @interface << @method\n interfaces << @interface\n interfaces\n end",
"def interfaces=(new_interfaces)\n new_interfaces.each {|i| i.possible_types << self }\n @interfaces = new_interfaces\n end",
"def as(interface)\n # interface must be a class\n raise InterfaceError, \"#{interface} is not a class\" unless interface.is_a?(Class)\n\n # check if object already is an instance of interface\n return self if self.kind_of?(interface)\n\n # check if interface is really an interface\n if interface < Interface\n # cache the resulting interface so that we can load it faster next\n # time and so that it can save state\n cache = self.instance_variable_get(:@interface_cache)\n unless cache\n cache = {}\n self.instance_variable_set(:@interface_cache, cache)\n end\n\n cache[interface] ||= begin\n i = interface.new\n delegate = self\n non_implemented_methods = []\n\n # define singleton methods that delegate back to this object for each abstract method\n interface.abstract_methods.each do |method|\n non_implemented_methods << method unless self.respond_to?(method)\n i.define_singleton_method(method) do |*args|\n delegate.send(method, *args)\n end\n end\n\n # raise an exception if all abstract methods are not overridden\n unless non_implemented_methods.empty?\n raise NonConformingObjectError, \"#{self} does not conform to interface #{interface}. Expected methods not implemented: #{non_implemented_methods.join(\", \")}\"\n end\n\n # define singleton methods that delegate back to this object for each optional method\n interface.optional_methods.each do |method|\n if self.respond_to?(method)\n i.define_singleton_method(method) do |*args|\n delegate.send(method, *args)\n end\n end\n end\n\n i\n end\n else\n # interface is not really an interface, it's just a Class\n # use some built-in conversions\n Castable.convert_type(self, interface)\n end\n end",
"def interface(name = '', &block)\n API::Interface.define({ name: name }, &block)\n end",
"def generic?; true; end",
"def implements?() \n return true if self[:implements].length > 0\n end",
"def set_defaults\n super\n @ifaces ||= [name.to_sym]\n @deps ||= Hash.new []\n @objs = []\n end",
"def provide\n raise NotImplementedError\n end",
"def overload; end",
"def as(interface_name)\n @expected_options[:as] = interface_name\n self\n end",
"def as(interface_name)\n @expected_options[:as] = interface_name\n self\n end",
"def inherited_meths(opts = T.unsafe(nil)); end",
"def iterateinterfacestrategy(interface)\n\t\t@classname=\"#{$MarelliNamespace}_#{@interfacename}\"\n\t\t@methodList=\"\"\n\t\t@signalList=\"\"\n\t\t@privatemethodList=\"\"\n\n#Method\n\t\t#definisci la strategia di iterazione sugli elementi contenuti in \"Method\"\n\t\tdef self.iteratemethodstrategy(method)\n\n\t\t\t#stabilisci quale azione eseguire quando si sono acquisiti i dati di un argomento\n\t\t\t#nello specifico caso si considerano solo gli argomenti con direzione \"in\"\n\t\t\tdef self.argDo\n\t\t\t\targDoIn\n\t\t\tend\n\t\t\t#quindi iterare sugli argomenti\n\t\t\titeratearg(method)\n\n\t\t\t#stabilisci quale azione eseguire quando si sono acquisiti i dati di un argomento\n\t\t\t#nello specifico caso si considerano solo gli argomenti con direzione \"out\"\n\t\t\tdef self.argDo\n\t\t\t\targDoOut\n\t\t\tend\n\t\t\t#quindi iterare sugli argomenti\n\t\t\titeratearg(method)\n\n\t\t\t#stabilisci quale azione eseguire quando è presente almeno un elemento\n\t\t\t#in \"ErrorSubset\"\n\t\t\t#nello specifico caso si aggiunge alla lista degli argomenti un argomento di errore\n\t\t\tdef self.errorDo\n\t\t\t\t\t@arglist += @argseparator+\"int32_t &p_progerror\"\n\t\t\t\t\t@argseparator = \", \"\n\t\t\tend\n\t\t\titerateerror(method,true)\n\n\t\t\tdef self.errorDo\n\t\t\t\t\t@legalErrorList += \"//error return allowed: #{$errornamespace}#{@errorref} - Annotation: #{$error[@errorref][0]}\\n\"\n\t\t\tend\n\n\t\t\titerateerror(method,false)\n\t\tend\n\t\t#end strategia di scansione di \"Method\"\n\n\n\t\t@methodList=\"\"\n\t\t#definisce l'azione da compiere prima di attuare la strategia di iterazione su \"Method\"\n\t\tdef self.methodDo\n\t\t\t@arglist=\"\"\n\t\t\t@argseparator=\"\"\n\t\t\t@legalErrorList=\"\"\n\t\tend\n\n\t\t#definisce l'azione da compiere dopo l'attuazione della strategia di iterazione su \"Method\"\n\t\tdef self.methodDoEnd\n\t\t\t@methodList += \"\\tvirtual int32_t #{@methodname}_imp(#{@arglist}) = 0;\\n\"\n\t\t\t$methodPrototypeList += \"\\tint32_t #{@methodname}_imp(#{@arglist});\\n\"\n\t\t\t$methodSkeletonList += \"\\n\\n#{@legalErrorList}int32_t #{$rootname}_SERVER::#{@methodname}_imp(#{@arglist})\\n{\\n\\tint32_t l_returnedValue=OK;\\n\\t/* TO BE DONE */\\n\\treturn (l_returnedValue);\\n}\\n\\n\"\n\t\tend\n\t\t\n\t\t#quindi itera sui \"Method\"\n\t\titeratemethod(interface)\n\n\n#Signal\n\t\t@signalList=\"\"\n\t\t#definisci la strategia di iterazione sugli elementi contenuti in \"Signal\"\n\t\tdef self.iteratesignalstrategy(signal)\n\t\t\tdef self.argDo\n\t\t\t\targDoSignal\n\t\t\tend\n\t\t\titeratearg(signal)\n\t\t\tdef self.errorDo\n\t\t\t\t\t@arglist += @argseparator+\"int32_t &progerror\"\n\t\t\t\t\t@argseparator = \", \"\n\t\t\t\t\t@imparglist += @impargseparator+\"progerror\"\n\t\t\t\t\t@impargseparator = \", \"\n\t\t\tend\n\t\t\titerateerror(signal)\n\t\tend\n\n\t\t#definisce l'azione da compiere prima dell'attuazione della strategia di iterazione su \"Signal\"\n\t\tdef self.signalDo\n\t\t\t@conversionlist=\"\"\n\t\t\t@dbusarglist=\"\"\n\t\t\t@dbusarglistseparator=\"\"\n\t\t\t@arglist=\"\"\n\t\t\t@argseparator=\"\"\n\t\tend\n\n\t\t#definisce l'azione da compiere dopo l'attuazione della strategia di iterazione su \"Signal\"\n\t\tdef self.signalDoEnd\n\t\t\tsignalcode = <<EOS\n\t\tvoid #{@signalname}_imp(#{@arglist})\n\t\t{\n#{@conversionlist}\n\t\t\t#{@signalname}(#{@dbusarglist});\n\t\t}\n\nEOS\n\n\t\t\t@signalList += signalcode\n\t\t\t$signalPrototypeList += \"\\tvoid #{@signalname}_imp(#{@arglist});\\n\"\n\t\t\t$signalSkeletonList += \"\\tvoid #{$rootname}_CLIENT::#{@signalname}_imp(#{@arglist})\\n{\\n\\t/* TO DO */\\n}\\n\"\n\t\t\t$signalConnectionList += \"\\tconnect_#{@signalname}();\\n\"\n\t\tend\n\n\t\t#quindi itera sui \"Signal\"\n\t\titeratesignal(interface)\n\n#Method\n\t\tdef interfaceDo\n\t\t\t@privatemethodList=\"\"\n\t\tend\n\t\tdef self.iteratemethodstrategy(method)\n\n\t\t\t#stabilisci quale azione eseguire quando si sono acquisiti i dati di un argomento\n\t\t\t#nello specifico caso si considerano solo gli argomenti con direzione \"in\"\n\t\t\tdef self.argDo\n\t\t\t\targDoInDBUS\n\t\t\tend\n\t\t\t#quindi iterare sugli argomenti\n\t\t\titeratearg(method)\n\n\t\t\t#stabilisci quale azione eseguire quando si sono acquisiti i dati di un argomento\n\t\t\t#nello specifico caso si considerano solo gli argomenti con direzione \"out\"\n\t\t\tdef self.argDo\n\t\t\t\targDoOutDBUS\n\t\t\tend\n\t\t\t#quindi iterare sugli argomenti\n\t\t\titeratearg(method)\n\n\t\t\t#stabilisci quale azione eseguire quando è presente almeno un elemento\n\t\t\t#in \"ErrorSubset\"\n\t\t\t#nello specifico caso si aggiunge alla lista degli argomenti un argomento di errore\n\t\t\tdef self.errorDoDBUS\n\t\t\t\t\t@arglist += @argseparator+\"int32_t &progerror\"\n\t\t\t\t\t@argseparator = \", \"\n\t\t\t\t\t@imparglist += @impargseparator+\"progerror\"\n\t\t\t\t\t@impargseparator = \", \"\n\t\t\tend\n\t\t\titerateerror(method)\n\t\tend\n\t\t#end strategia di scansione di \"Method\"\n\t\t#definisce l'azione da compiere prima di attuare la strategia di iterazione su \"Method\"\n\t\tdef self.methodDo\n\t\t\t@arglist=\"\"\n\t\t\t@argseparator=\"\"\n\t\t\t@imparglist=\"\"\n\t\t\t@impargseparator=\"\"\n\t\t\t@declarationList=\"\"\n\t\t\t@assignList=\"\"\n\t\t\t@tmpOutIndex=0\n\t\tend\n\n\t\t#definisce l'azione da compiere dopo l'attuazione della strategia di iterazione su \"Method\"\n\t\tdef self.methodDoEnd\n\t\t\t@privatemethodList += eval( '\"' + @privatemethodtemplate + '\"')\n\t\tend\n\n\t\titeratemethod(interface)\n\tend",
"def abstract?; end",
"def protocol; end",
"def protocol; end",
"def protocol; end",
"def protocol; end",
"def refinement\n raise NotImplementedError\n end",
"def iterateinterfacestrategy(interface)\n\t\t@classname=\"#{$MarelliNamespace}_#{@interfacename}\"\n\t\t@methodList=\"\"\n\t\t@signalList=\"\"\n\t\t@privateSignalList=\"\"\n\n#Method\n\t\t@methodList=\"\"\n\t\t#definisci la strategia di iterazione sugli elementi contenuti in \"Method\"\n\t\tdef self.iteratemethodstrategy(method)\n\n\t\t\t#stabilisci quale azione eseguire quando si sono acquisiti i dati di un argomento\n\t\t\t#nello specifico caso si considerano solo gli argomenti con direzione \"in\"\n\t\t\tdef self.argDo\n\t\t\t\targDoIn\n\t\t\tend\n\t\t\t#quindi iterare sugli argomenti\n\t\t\titeratearg(method)\n\n\t\t\t#stabilisci quale azione eseguire quando si sono acquisiti i dati di un argomento\n\t\t\t#nello specifico caso si considerano solo gli argomenti con direzione \"out\"\n\t\t\tdef self.argDo\n\t\t\t\targDoOut\n\t\t\tend\n\t\t\t#quindi iterare sugli argomenti\n\t\t\titeratearg(method)\n\n\t\t\t#stabilisci quale azione eseguire quando è presente almeno un elemento\n\t\t\t#in \"ErrorSubset\"\n\t\t\t#nello specifico caso si aggiunge alla lista degli argomenti un argomento di errore\n\t\t\tdef self.errorDo\n\t\t\t@argComplexTypeList += @argComplexTypeListSeparator+\"int32_t &progerror\"\n\t\t\t@argComplexTypeListSeparator = \", \"\n\t\t\t@argNameList += @argNameListSeparator+\"progerror\"\n\t\t\t@argNameListSeparator = \", \"\n\t\t\tend\n\t\t\titerateerror(method)\n\t\tend\n\t\t#end strategia di scansione di \"Method\"\n\n\n\t\t@methodList=\"\"\n\t\t#definisce l''azione da compiere prima di attuare la strategia di iterazione su \"Method\"\n\t\tdef self.methodDo\n\t\t\t@argComplexTypeList = \"\"\n\t\t\t@argComplexTypeListSeparator = \"\"\n\t\t\t@argNameList = \"\"\n\t\t\t@argNameListSeparator = \"\"\n\t\tend\n\n\t\t#definisce l'azione da compiere dopo l'attuazione della strategia di iterazione su \"Method\"\n\t\tdef self.methodDoEnd\n\t\t\t@methodList += \"\\tint32_t #{@methodname}_imp(#{@argComplexTypeList})\\n\\t{\\n\\t\\treturn (#{@methodname}(#{@argNameList}));\\n\\t}\\n\\n\"\n\t\tend\n\t\t\n\t\t#quindi itera sui \"Method\"\n\t\titeratemethod(interface)\n\n\n#Signal\n\t\t@signalList=\"\"\n\t\t#definisci la strategia di iterazione sugli elementi contenuti in \"Signal\"\n\t\tdef self.iteratesignalstrategy(signal)\n\tdef argDoOut\n\t\tif @argdirection == \"out\" then\n\t\t\tcpptype=@argtype\n\t\t\tif @Primitive[cpptype].nil? then\n\t\t\t\tif $enum[cpptype].nil? then\n\t\t\t\t\tcpptype = \"#{$MarelliNamespace}_#{@servicename}_#{cpptype}\"\n\t\t\t\telse\n\t\t\t\t\tcpptype = \"uint32_t\"\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tcpptype = @Primitive[cpptype]\n\t\t\tend\n\t\t\tif cpptype == \"std::string\" then\n\t\t\t\tcpptype = \"CMMString\"\n\t\t\tend\n\t\t\t@argComplexTypeList += @argComplexTypeListSeparator+\"const #{cpptype} &p_#{@argname}\"\n\t\t\t@argComplexTypeListSeparator = \", \"\n\t\t\t@argNameList += @argNameListSeparator+\"p_\"+@argname\n\t\t\t@argNameListSeparator = \", \"\n\t\tend\n\tend\n\n\t\t\titeratearg(signal)\n\t\t\tdef self.errorDo\n\t\t\t\t@argComplexTypeList += @argComplexTypeListSeparator+\"int32_t &progerror\"\n\t\t\t\t@argComplexTypeListSeparator = \", \"\n\t\t\t\t@argNameList += @argNameListSeparator+\"progerror\"\n\t\t\t\t@argNameListSeparator = \", \"\n\t\t\tend\n\t\t\titerateerror(signal)\n\t\tend\n\n\t\t#definisce l'azione da compiere prima dell'attuazione della strategia di iterazione su \"Signal\"\n\t\tdef self.signalDo\n\t\t\t@argComplexTypeList=\"\"\n\t\t\t@argComplexTypeListSeparator=\"\"\n\t\t\t@argBaseTypeList=\"\"\n\t\t\t@argBaseTypeListSeparator=\"\"\n\t\t\t@argNameList=\"\"\n\t\t\t@argNameListSeparator=\"\"\n\t\t\t@conversionlist=\"\"\n\t\tend\n\n\t\t#definisce l'azione da compiere dopo l'attuazione della strategia di iterazione su \"Signal\"\n\t\tdef self.signalDoEnd\n\t\t\t@signalList += \"\\tvirtual void #{@signalname}_imp(#{@argComplexTypeList}) {}\\n\\n\"\n\t\tend\n\n\t\t#quindi itera sui \"Signal\"\n\t\titeratesignal(interface)\n\n#Signal\n\t\t@privateSignalList=\"\"\n\t\t@conversionList=\"\"\n\t\tdef self.iteratesignalstrategy(signal)\n\n\t\t\t#stabilisci quale azione eseguire quando si sono acquisiti i dati di un argomento\n\t\t\t#nello specifico caso si considerano solo gli argomenti con direzione \"in\"\n\t\t\tdef self.argDo\n\t\t\t\targDoSignal\n\t\t\tend\n\t\t\t#quindi iterare sugli argomenti\n\t\t\titeratearg(signal)\n\n\t\t\t#stabilisci quale azione eseguire quando è presente almeno un elemento\n\t\t\t#in \"ErrorSubset\"\n\t\t\t#nello specifico caso si aggiunge alla lista degli argomenti un argomento di errore\n\t\t\tdef self.errorDo\n\t\t\t\t@argBaseTypeList += @argBaseTypeListSeparator+\"int32_t &progerror\"\n\t\t\t\t@argBaseTypeListSeparator = \", \"\n\t\t\t\t@argNameList += @argNameListSeparator+\"progerror\"\n\t\t\t\t@argNameListSeparator = \", \"\n\t\t\tend\n\t\t\titerateerror(signal)\n\t\tend\n\t\t#end strategia di scansione di \"Method\"\n\t\t#definisce l''azione da compiere prima di attuare la strategia di iterazione su \"Method\"\n\t\tdef self.signalDo\n\t\t\t@argComplexTypeList=\"\"\n\t\t\t@argComplexTypeListSeparator=\"\"\n\t\t\t@argBaseTypeList=\"\"\n\t\t\t@argBaseTypeListSeparator=\"\"\n\t\t\t@argNameList=\"\"\n\t\t\t@argNameListSeparator=\"\"\n\t\tend\n\n\t\t#definisce l'azione da compiere dopo l'attuazione della strategia di iterazione su \"Method\"\n\t\tdef self.signalDoEnd\n\t\t\t@privateSignalList += eval( '\"' + @privateSignalTemplate + '\"')\n\t\tend\n\n\t\titeratesignal(interface)\n\tend",
"def k_implements!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n\n\n type = K_IMPLEMENTS\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 365:3: 'implements'\n match( \"implements\" )\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__, 28 )\n\n\n end",
"def interface(class_def)\n\n\n\n # 51:7: IMPLEMENTS interface_name[class_def] ( ',' interface_name[class_def] )*\n match(:IMPLEMENTS)\n interface_name(class_def)\n\n # 51:44: ( ',' interface_name[class_def] )*\n while true\n alt7 = 2\n # ()* loopback of 51:44: ( ',' interface_name[class_def] )*\n look_ahead7_0 = look_ahead(1)\n if look_ahead7_0 == :COMMA \n alt7 = 1\n end\n case alt7\n when 1\n # 51:45: ',' interface_name[class_def]\n match(:COMMA)\n interface_name(class_def)\n\n else\n break\n end\n end\n\n\n\n end",
"def dispatch\n raise NotImplementedError\n end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def sorted_interfaces\n process if @interfaces.nil?\n\n sorter.sort.map { |name|\n @interfaces.find { |i| i.name == name } or puts \"ignoring interface: #{name}\"\n }.compact\n end",
"def each_interface(&block)\n\t\tget_interfaces().each(&block)\n\tend",
"def service; raise NotImplementedError; end",
"def visit_product\n raise NotImplementedError, 'This is an interface'\n end",
"def interfaces=(new_interfaces)\n @structural_interface_type_memberships = []\n @inherited_interface_type_memberships = []\n @clean_inherited_fields = nil\n implements(new_interfaces, inherit: true)\n end",
"def interface_ancestors_cache; end",
"def abstract!; end",
"def interface(tag, if_names, address = nil, &block)\n interfaces = [*@interfaces[tag], *if_names].compact.uniq\n raise \"single address, #{address}, given for multiple interfaces, #{interfaces}, on host #{name}\" if interfaces.length > 1 && address\n\n @interfaces[tag] = interfaces\n\n # determine the address for each interface\n interfaces.each do |if_name|\n new_address = \\\n if !address\n if block_given? \n yield(self, if_name)\n else\n if interfaces.length > 1\n \"#{name}_#{tag}_#{if_name}\"\n else\n \"#{name}_#{tag}\"\n end\n end\n else\n address\n end\n @addresses[if_name] = new_address\n end\n\n end",
"def initialize(interface)\n @interface = interface\n end",
"def interfaces\n [\n 'LocalLB.Monitor',\n 'LocalLB.NodeAddressV2',\n 'LocalLB.Pool',\n 'LocalLB.VirtualServer',\n 'Management.DeviceGroup',\n 'System.ConfigSync',\n 'System.Failover',\n 'System.Inet'\n ]\n end",
"def initialize(name, imethods = [])\n @name = name\n @imethods = imethods\n\n mthd :nop # NOP comes by default in the interfaces\n end",
"def protocol\n super\n end",
"def register(interface)\n InvalidInterfaceError.check(interface)\n \n interfaces[interface.to_s.demodulize.underscore.to_sym] = interface\n end",
"def members(*interface_names)\n interface_names.each { |name| add(name) }\n end",
"def implementation=(implementation); end",
"def explicit; end",
"def implementer\n provider\n end",
"def methods(interface)\n mod_hash = interfaces[name_to_key(interface)] || {}\n mod_hash[:methods] || []\n end",
"def stub_implementation; end",
"def interfaces\n Vedeu::Interfaces.registered\n end",
"def setup_interface_from(container)\n container.elements.each do |elem|\n if elem.identifiable?\n eigenclass.send :define_method, elem.name, lambda { instance_variable_get(\"@#{elem.name}\") }\n eigenclass.send :define_method, \"#{elem.name}=\", lambda {|value| instance_variable_set(\"@#{elem.name}\", value) }\n instance_variable_set(\"@#{elem.name}\", elem.default_value)\n if Surveyor::Sequence === elem\n send(elem.name).send(:setup_interface_from, elem)\n end\n else\n # section elements belongs to section's container, not to section\n setup_interface_from(elem)\n end\n end\n end",
"def implements(interfaces, inherit: false, **options)\n if !interfaces.is_a?(Array)\n raise ArgumentError, \"`implements(interfaces)` must be an array, not #{interfaces.class} (#{interfaces})\"\n end\n @clean_inherited_fields = nil\n\n type_memberships = inherit ? @inherited_interface_type_memberships : @structural_interface_type_memberships\n interfaces.each do |iface|\n iface = BaseType.resolve_related_type(iface)\n if iface.is_a?(GraphQL::InterfaceType)\n type_memberships << iface.type_membership_class.new(iface, self, **options)\n end\n end\n end",
"def [](id)\n interfaces_hash.fetch(id.to_s) do\n raise UnknownInterface.new(id.to_s),\n \"Unknown interface: #{id}\"\n end\n end",
"def choose\n raise NotImplementedError.new('Must override')\n end",
"def default(value)\n configure(\"default interface #{value}\")\n end",
"def unquiesce \n raise NotImplementedError.new\n end",
"def abstract(*methods)\n methods.each do |method|\n define_method(method) do |*|\n raise NotImplementedError, \"#{self.class}##{method} must be defined\"\n end\n end\n end",
"def one_interface_ancestors_cache; end",
"def adapters(interface)\n mod_hash = interfaces[name_to_key(interface)] || {}\n mod_hash[:adapters] ? mod_hash[:adapters].keys : []\n end",
"def implementation\n fail 'Subclasses must implement implementation()!'\n end",
"def implausible_common_name; end",
"def default; end",
"def default; end",
"def test_os_classes_have_interface\n assert_send([Mage.build, :os])\n end",
"def for_all?\n fail NotImplementedError\n end",
"def default_wrapper; end",
"def enable_test_interface\n extend Dry::Configurable::TestInterface\n end",
"def internal; end",
"def agent_interface\n super\n end",
"def infer_languages\n raise \"Not Implemented. Class #{self.class.name} doesn't implement infer_languages\"\n end"
] | [
"0.7450552",
"0.7291269",
"0.7291269",
"0.71681386",
"0.7043405",
"0.6821416",
"0.66647965",
"0.6574899",
"0.6418984",
"0.6350546",
"0.6274553",
"0.6193343",
"0.6142262",
"0.61030334",
"0.60533035",
"0.5992716",
"0.5972564",
"0.5962646",
"0.590624",
"0.5888034",
"0.5863259",
"0.5863259",
"0.57775545",
"0.5769106",
"0.57671446",
"0.5759626",
"0.5735988",
"0.5686663",
"0.56739557",
"0.56613785",
"0.5633809",
"0.5627642",
"0.5620948",
"0.5620858",
"0.5607149",
"0.55987144",
"0.55970156",
"0.5588352",
"0.5579824",
"0.5558816",
"0.5524074",
"0.55161107",
"0.5472567",
"0.5454429",
"0.5430892",
"0.5430892",
"0.54253405",
"0.541445",
"0.54006004",
"0.5384585",
"0.5384585",
"0.5384585",
"0.5384585",
"0.5380943",
"0.53563434",
"0.5349841",
"0.5326014",
"0.5324867",
"0.5313769",
"0.5313769",
"0.5313769",
"0.5310958",
"0.5304452",
"0.53014725",
"0.53002006",
"0.5296106",
"0.5295018",
"0.529352",
"0.5272375",
"0.52643585",
"0.5256939",
"0.5241832",
"0.5240286",
"0.52333224",
"0.5225831",
"0.5175322",
"0.51656896",
"0.51601905",
"0.5155333",
"0.51548636",
"0.51502395",
"0.5139334",
"0.5124975",
"0.5124217",
"0.5121653",
"0.50935316",
"0.50908256",
"0.5056119",
"0.5045388",
"0.50440156",
"0.504197",
"0.5038743",
"0.5001123",
"0.5001123",
"0.4999553",
"0.49925876",
"0.49885303",
"0.49800768",
"0.49778524",
"0.4975013",
"0.49730545"
] | 0.0 | -1 |
Bind namespace to store, returns bound namespace | def bind(namespace)
# Over-write an empty prefix
uri = namespace.uri.to_s
@uri_binding[uri] = namespace unless namespace.prefix.to_s.empty?
@uri_binding[uri] ||= namespace
@nsbinding[namespace.prefix.to_s] = namespace
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def namespace=(ns) @namespace = @store.namespace = ns; end",
"def namespace=(ns); end",
"def namespace=(ns); end",
"def namespace(ns)\n if ns == :interpreter\n self\n else\n @storage[ns]\n end\n end",
"def ns(ns)\n self.namespace = ns\n self\n end",
"def namespace\n @namespace.ns\n end",
"def set_namespace(ns = '')\n settings['namespace'] = ns\n end",
"def namespace(namespace = nil, options = {})\n return @namespace unless namespace\n\n @namespace = namespace.to_sym if namespace\n @base_namespace = options[:base].to_sym if options[:base]\n end",
"def namespace\n NAMESPACE\n end",
"def register_handler_namespace(type, ns); end",
"def namespace\n @namespace\n end",
"def namespace\n return NAMESPACE\n end",
"def namespace\n \"#{database.name}.#{name}\"\n end",
"def namespace\n \"#{database.name}.#{name}\"\n end",
"def namespace(ns)\n new_name = namespace_value(ns, @name)\n new_transitions = Hash[@transitions.map do |(event, target)|\n [event, namespace_value(ns, target)]\n end]\n\n new_type = @type\n if new_type == :final\n new_event_cb = ->(_) { Puppet::StateMachine::FINAL_EVENT }\n new_type = nil\n else\n new_event_cb = @event_cb\n end\n Puppet::StateMachine::State.new(new_name, @action_cb, new_event_cb, new_type, new_transitions)\n end",
"def namespace(namespace = nil)\n @namespace = namespace if namespace\n @namespace\n end",
"def namespaces\n ns = {}\n\n JSON.parse(raw_namespaces)[\"results\"][\"bindings\"].each {|x|\n ns[x[\"prefix\"][\"value\"]] = x[\"namespace\"][\"value\"]\n }\n ns\n end",
"def namespace(options={}, &block)\n model = Caracal::Core::Models::NamespaceModel.new(options, &block)\n if model.valid?\n ns = register_namespace(model)\n else\n raise Caracal::Errors::InvalidModelError, 'namespace must specify the :prefix and :href attributes.'\n end\n ns\n end",
"def set_namespace\n @namespace = Namespace.find(params[:namespace_id])\n end",
"def namespace\n @namestack.join(\"::\")\n end",
"def custom_namespace\n @attributes[:custom_namespace]\n end",
"def set_namespace(namespace)\n return unless namespace\n\n @namespace = namespace\n @ext.set_namespace(namespace)\n end",
"def namespace\n cfg_get(:namespace)\n end",
"def namespace\n return @namespace\n end",
"def namespace\n return @namespace\n end",
"def namespace=(v); end",
"def namespace(key)\n if @namespace\n yield interpolate(key)\n else\n # This Redis::Store instance does not use a namespace so we should\n # just pass through the key.\n yield key\n end\n end",
"def namespace\n @namespace || self.class.namespace\n end",
"def namespace\n cfg_get(:namespace)\n end",
"def set_namespace\n @namespace = Namespace.find(params[:id])\n end",
"def set_namespace\n @namespace = Namespace.find(params[:id])\n end",
"def namespace; end",
"def namespace; end",
"def namespace; end",
"def namespace; end",
"def namespace; end",
"def namespace; end",
"def namespace; end",
"def namespace; end",
"def namespace=(value)\n @namespace = value\n end",
"def namespace=(value)\n @namespace = value\n end",
"def namespace\n @options[:space_name]\n end",
"def namespace\n @namespace ||= schema.attributes['Namespace'].value\n end",
"def method_missing(sym, *args)\n @_store[@_namespace].send(sym, *args)\n end",
"def set_namespace(namespace)\n return if !active? ||\n Appsignal::Transaction.current.nil? ||\n namespace.nil?\n Appsignal::Transaction.current.set_namespace(namespace)\n end",
"def namespace name\n declare_namespace(resource, name.intern)\n end",
"def namespace=( namespace )\n\t\t@namespace = namespace.nil? ? nil : namespace.to_sym\n\tend",
"def get_attribute_ns(namespace, name); end",
"def namespace_name\n @namespace_name ||= namespaces.join('::')\n end",
"def namespace(namespace = nil)\n @namespace = namespace if namespace\n @namespace if defined? @namespace\n end",
"def change_space(namespace)\n update!(name: namespace)\n end",
"def namespace\n self.class.new split(NAMESPACE_SEPARATOR).first\n end",
"def namespace=(obj); end",
"def namespace=(value)\n self.namespaces = [value]\n end",
"def get_namespace(node, prefix); end",
"def namespace\n @intf_namespace ||= self.class.name.split('::').last.downcase\n end",
"def register_namespace(name_and_href)\n (@default_namespaces ||= []) <<name_and_href\n end",
"def register_namespace(name_and_href)\n (@default_namespaces ||= []) <<name_and_href\n end",
"def add_namespace(namespace) \n @namespaces[namespace.name] = namespace\n end",
"def namespace(namespace, &block)\n ::Dry::Container::NamespaceDSL.new(\n self,\n namespace,\n config.namespace_separator,\n &block\n )\n\n self\n end",
"def find_or_new_namespace(name, uri)\n namespace = @namespaces.find { |n| n.namespace == name } || (@namespaces << Restfulie::Common::Builder::Rules::Namespace.new(name, uri)).last\n namespace.uri = uri unless uri.nil?\n namespace\n end",
"def namespace(name = nil, url = nil)\n @namespaces[name.to_s] = url\n end",
"def normalize(namespace)\n namespace.to_s.sub(/^[\\/:\\s]*/, '').sub(/[\\/:\\s]*$/, '').gsub(/[\\/\\\\:]+/, '::')\n end",
"def namespace\n self.class.namespace\n end",
"def register_namespace(name, href)\n @registered_namespaces.merge!(name => href)\n end",
"def add_namespace(ns, prefix = \"unknown#{rand 65536}\")\n return nil if ns.nil? || ns.empty?\n unless namespaces.key? ns\n namespaces[ns] = prefix\n return prefix\n end\n end",
"def ns (klass) #name symbol.\n\tklass.name.to_sym\nend",
"def namespace_path(path = '')\n File.expand_path(File.join(store_path, namespace, path))\n end",
"def namespace\n @namespace ||= 'silver_spoon'\n end",
"def prefix_for(ns_href)\n namespaces[ns_href] || add_namespace(ns_href)\n end",
"def namespace=(v)\n cfg_set(:namespace, v)\n end",
"def namespace\n Matsuri::Platform.send(Matsuri::Config.environment).namespace || 'default'\n end",
"def namespace\n @namespace ||= self.class.to_s.split('::').first.gsub('_', '').sub('Application', '')\n end",
"def namespace(value)\n merge(namespace: value.to_s)\n end",
"def ns_constantize\n to_s.gsub('__', '::').constantize\n end",
"def namespace=(v)\n cfg_set(:namespace, v)\n end",
"def namespace(value = nil)\n if value\n @namespace = value\n else\n @namespace\n end\n end",
"def namespace\n self.class.namespace\n end",
"def emit_bnode_namespace(collector, namespace)\n if collector and collector.respond_to? :bnode_namespace=\n collector.bnode_namespace = namespace\n end\n end",
"def namespace(new_namespace=nil,name=nil,&block)\n raise ArgumentError, \"Scope must be a string, a symbol, or a hash with string values.\" if !new_namespace.nil? && !(new_namespace.is_a?(String) || new_namespace.is_a?(Symbol) || new_namespace.is_a?(Hash))\n @namespace ||= '/'\n if new_namespace.is_a?(Hash)\n new_namespace.each do |name,new_namespace|\n block_given? ? namespace(new_namespace,name) { block.call } : namespace(new_namespace,name)\n end\n else\n # Here we have just one namespace and *possibly* a name to save for the first route registered with this namespace.\n # Sanitize new namespace to NOT end with a slash OR begin with a slash.\n @next_route_name = new_namespace if new_namespace.is_a?(Symbol)\n new_namespace = new_namespace.to_s.gsub(/(^\\/|\\/$)/,'') if new_namespace\n @next_route_name = name if name\n # Join namespace to previous namespace by a slash.\n if block_given?\n old_namespace = @namespace\n @namespace = @namespace.gsub(/\\/$/,'')+'/'+new_namespace\n yield\n @namespace = old_namespace\n else\n if new_namespace.nil?\n @namespace\n else\n @namespace = @namespace.gsub(/\\/$/,'')+'/'+new_namespace\n end\n end\n end\n end",
"def ns_camelize\n to_s.gsub('__', '/').camelize\n end",
"def default_namespace=(url); end",
"def default_namespace=(url); end",
"def namespace\n entity_container.namespace\n end",
"def namespace\n entity_container.namespace\n end",
"def wrap_schema_into_namespace(schema, carrier, klass)\n nested_hash = Surrealist::StringUtils.break_namespaces(\n klass, carrier.camelize, carrier.namespaces_nesting_level\n )\n\n inject_schema(nested_hash, Surrealist::Copier.deep_copy(schema))\n end",
"def default_namespace(url)\n @namespaces[''] = url\n end",
"def namespaces; end",
"def namespaces; end",
"def namespaces; end",
"def namespaces; end",
"def namespace_module\n klass.name.to_s.split('::')[0..-4].join('::').constantize\n end",
"def register_space\n Server.redis do |c|\n c.sadd(\"#{QPush::Base::KEY}:namespaces\", @config.namespace)\n end\n end",
"def combineNsBase(namespace, base)\n namespace && !namespace.empty? ? \"#{namespace}.#{base}\".to_sym : base.to_sym\nend",
"def namespace(name, &block)\n @namespace = clean_path(name)\n yield self\n end",
"def current_namespace\n @current_namespace\n end",
"def test_namespace\n N::Namespace.shortcut(:test_namespace, \"http://test_namespace/\")\n assert_equal(:test_namespace, N::URI.new(\"http://test_namespace/\").namespace)\n assert_equal(:test_namespace, N::URI.new(\"http://test_namespace/else\").namespace)\n assert_equal(nil, N::URI.new(\"http://test_namespace/else/other\").namespace)\n end",
"def namespace(path, options = {}, &block)\n path = path.to_s\n\n defaults = {\n module: path,\n as: options.fetch(:as, path),\n shallow_path: options.fetch(:path, path),\n shallow_prefix: options.fetch(:as, path)\n }\n\n path_scope(options.delete(:path) { path }) do\n scope(defaults.merge!(options), &block)\n end\n end",
"def namespace(ns)\n ns.blank? ? \"nil\" : %|\"#{ns.prefix}\"|\nend",
"def inspect\n self.to_hash.merge(\"namespace\" => namespace).inspect\n end"
] | [
"0.75748473",
"0.67924154",
"0.67924154",
"0.6773763",
"0.626833",
"0.61391336",
"0.60608",
"0.6016561",
"0.60015404",
"0.5988713",
"0.59822154",
"0.5964231",
"0.5939458",
"0.5939458",
"0.5933223",
"0.5912131",
"0.590186",
"0.58406216",
"0.5821093",
"0.5765241",
"0.57619566",
"0.573861",
"0.57321274",
"0.5722495",
"0.5722495",
"0.5719609",
"0.5717959",
"0.57053685",
"0.5661127",
"0.56606627",
"0.56606627",
"0.56557107",
"0.56557107",
"0.56557107",
"0.56557107",
"0.56557107",
"0.56557107",
"0.56557107",
"0.56557107",
"0.5655576",
"0.5655576",
"0.5649981",
"0.5648276",
"0.5615619",
"0.56024927",
"0.5601795",
"0.55954766",
"0.55812734",
"0.55685157",
"0.5558595",
"0.55520815",
"0.5540096",
"0.5537863",
"0.55311066",
"0.5524191",
"0.55230725",
"0.5520778",
"0.5520778",
"0.55202436",
"0.5518002",
"0.55120915",
"0.5511038",
"0.5506273",
"0.5500517",
"0.54968005",
"0.5490396",
"0.54825264",
"0.54727995",
"0.5471646",
"0.5466959",
"0.54555607",
"0.5454756",
"0.5452007",
"0.54431987",
"0.54394364",
"0.5438614",
"0.5426062",
"0.54178154",
"0.5414443",
"0.5412869",
"0.54095113",
"0.5397841",
"0.5397841",
"0.5388335",
"0.5388335",
"0.53834",
"0.5382946",
"0.5382134",
"0.5382134",
"0.5382134",
"0.5382134",
"0.53598225",
"0.5356414",
"0.53536445",
"0.5342463",
"0.5337549",
"0.5336411",
"0.53141534",
"0.53127426",
"0.531215"
] | 0.73962915 | 1 |
Get all BNodes with usage count used within graph | def bnodes(context = nil)
bn = {}
triples(Triple.new(nil, nil, nil), context) do |t, ctx|
if t.subject.is_a?(BNode)
bn[t.subject] ||= 0
bn[t.subject] += 1
end
if t.predicate.is_a?(BNode)
bn[t.predicate] ||= 0
bn[t.predicate] += 1
end
if t.object.is_a?(BNode)
bn[t.object] ||= 0
bn[t.object] += 1
end
end
bn
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bnodes\n @graphs.inject([]) {|memo, g| memo += g.bnodes}\n end",
"def total_count\n object.nodes.size\n end",
"def nodes\n @grpc.node_count\n end",
"def nodes_percent\n (nodes_used.to_f / nodes_avail.to_f) * 100\n end",
"def nodes\n @graph.keys.length\n end",
"def total\n object.nodes.size\n end",
"def number_of_nodes(node_name)\n nodes(node_name).count\nend",
"def free_nodes\n nodes.select(&:is_free?)\n end",
"def count_all\n # map all nodes into enumerable\n # then add them all together (reduce :+)\n self.map { |node| node.count }.reduce(:+)\n end",
"def getCount\n return @nodeValues.size\n end",
"def tasks_pending_count\n inject(0) do |sum, node|\n sum + node.graph.tasks_pending_count\n end\n end",
"def tasks_pending_count\n inject(0) do |sum, node|\n sum + node.graph.tasks_pending_count\n end\n end",
"def count\n number_of_trees + number_of_networks\n end",
"def nodes\n state(metrics: \"nodes\").dig(\"nodes\")\n end",
"def tasks_total_count\n inject(0) do |sum, node|\n sum + node.graph.tasks_total_count\n end\n end",
"def tasks_total_count\n inject(0) do |sum, node|\n sum + node.graph.tasks_total_count\n end\n end",
"def calc_gpus_unallocated\n @gpus_unallocated = 0\n #if @cluster_title.eql?('Owens')\n # @gpus_unallocated = nodes_info.lines(\"\\n\\n\").select { |node|\n # !node.include?(\"dedicated_threads = 28\") && node.include?(\"Unallocated\") }.size\n # elsif @cluster_title.eql?('Pitzer')\n # @gpus_unallocated = nodes_info.lines(\"\\n\\n\").select { |node| !node.include?(\"dedicated_threads = 40\") }.to_s.scan(/gpu_state=Unallocated/).size\n # else @cluster_title.eql?('Ruby')\n # # See line 62. Excluding the two debug nodes from the calculation.\n # @gpus_unallocated = nodes_info.lines(\"\\n\\n\").select { |node| node.include?(\"Unallocated\") && !node.include?(\"dedicated_threads = 20\") && node.include?(\"np = 20\") }.size\n # @oodClustersAdapter.info_all_each { |job| p job}\n #end\n end",
"def count\n count = 0\n\n each do |node|\n count += 1\n end\n\n return count\n end",
"def size\n @nodes.size\n end",
"def nodeCount\n count = 1\n\n if @children.size\n @children.each do |key, val|\n count += val.nodeCount\n end\n end\n\n count\n end",
"def current_num_nodes() ; info[:current_num_nodes] ; end",
"def get_stats\n end_reg = /<\\/All_Nodes>/\n start_reg = /<All_Nodes>/\n lines = get_command_response(command: \"sgnodes all\", start_reg: start_reg, end_reg: end_reg)\n xml_string = lines.join(\"\\n\")\n stats = {\"Total\" => {count: 0}}\n doc = Nokogiri::XML(xml_string)\n handle_node(stats: stats, node: doc.root)\n stats\n end",
"def usage_stats\n\t login_filter\n \n\t stats_page = @agent.get(\"/account\")\n\t \n\t stats = stats_page.at('#usage-percent').content.scan(/(\\d+(?:\\.\\d+)?)%\\ used\\ \\((\\d+(?:\\.\\d+)?)([MG])B of (\\d+(?:\\.\\d+)?)GB\\)/).collect{ |d|\n\t { :used => d[1].to_f * ((d[2] == \"G\") ? 1024 : 1),\n\t :total => d[3].to_f * 1024,\n\t :free => (d[3].to_f * 1024 - d[1].to_f * ((d[2] == \"G\") ? 1024 : 1)),\n\t :percent => Percentage.new(d[0].to_f/100)\n\t }\n\t }[0]\n\t \n\t regular_data = stats_page.at('span.bar-graph-legend.bar-graph-normal').next.content.scan(/\\((\\d+(?:\\.\\d+)?)([MG])B/)[0]\n\t stats[:regular_used] = regular_data[0].to_f * ((regular_data[1] == \"G\") ? 1024 : 1) unless regular_data.nil?\n\n\t shared_data = stats_page.at('span.bar-graph-legend.bar-graph-shared').next.content.scan(/\\((\\d+(?:\\.\\d+)?)([MG])B/)[0]\n\t stats[:shared_used] = shared_data[0].to_f * ((shared_data[1] == \"G\") ? 1024 : 1) unless shared_data.nil?\n\n return stats\n end",
"def count_nodes\n @page.xpath(\"//*\").count\n end",
"def nodes\n @conn.nodes\n end",
"def size\n @nodes.length\n end",
"def size\n @nodes.length\n end",
"def number_of_new_nodes\n \t{'New Nodes Added' => aw.node_added_count }\n \tend",
"def number_of_new_nodes\n \t{'New Nodes Added' => aw.node_added_count }\n \tend",
"def prepared_nodes_count\n Bebox::Node.list(self.project_root, self.environment, 'prepared_nodes').count\n end",
"def list_used(&block)\n @driver.list_used(&block)\n end",
"def count_used_instances\n count = 0\n return count\n end",
"def size\n count = 0\n visit_nodes do\n count += 1\n end\n count\n end",
"def calc_total_gpus\n @total_gpus = 0\n #if @cluster_title.eql?(\"Ruby\")\n # # For the Ruby cluster, pbsnodes takes into account two debug nodes with two GPUs along with the other Ruby GPU nodes. The debug nodes will not be considered in the total GPUs and unallocated GPUs calculation, as they cannot be allocated as part of a regular job request with other GPU nodes. Here np = 20 is the number of processors for a GPU node rather than a debug node (np = 16) in a Ruby cluster.\n # @total_gpus = nodes_info.scan(/np = 20/).size\n # else\n # @total_gpus = nodes_info.lines(\"\\n\\n\").size\n #end\n end",
"def node_count\n raise NotImplementedError\n end",
"def getNodeElementCount\n return @nodeElements.size\n end",
"def size\n @graphs.inject(0) {|memo, g| memo += g.size}\n end",
"def singleton_nodes\n all_node_ids = Node_Query.new(analysis_window: aw).run.first[:objects].collect{|n| n.id}.uniq\n all_nodes_in_ways = Way_Query.new(analysis_window: aw).run.first[:objects].collect{|w| w.nodes}.flatten.uniq\n # all_nodes_in_rels = Relation_Query.new(analysis_window: aw).run.first[:objects].collect{|r| r.nodes}.flatten.uniq\n nodes_not_in_ways_or_rels = (all_node_ids - all_nodes_in_ways).length\n puts \"Total Nodes: #{all_node_ids.length}, Nodes not in ways or relations: #{nodes_not_in_ways_or_rels}\"\n puts \"Percentage: #{nodes_not_in_ways_or_rels.to_f / all_node_ids.length.to_f}\"\n end",
"def count_edge\n count = 0\n @f_net.each_with_index do |followees, follower|\n count += followees_of(follower).count\n end\n count\n end",
"def calc_full_nodes_avail\n @full_nodes_available = 0\n #if @cluster_title.eql?(\"Ruby\")\n # # See line 62\n #@full_nodes_available = nodes_info.lines(\"\\n\\n\").select { |node| node.include?(\"dedicated_threads = 0\") && node.include?(\"np = 20\") && node.include?(\"gpu_state=Unallocated\")}.size\n #else\n #@full_nodes_available = nodes_info.lines(\"\\n\\n\").select { |node| node.include?(\"dedicated_threads = 0\") && node.include?(\"gpu_state=Unallocated\") }.size\n #end\n end",
"def total_bags_inside\n children.size + children.map(&:total_bags_inside).sum\n end",
"def remote_node_bags\n bags = []\n bag_query = { admin_node: remote_node.namespace }\n local_client.bags(bag_query) do |response|\n bags << response.body if response.success?\n end\n bags.flatten\n end",
"def usage\n response = @connection.lbreq(\"GET\",@lbmgmthost,\"#{@lbmgmtpath}/loadbalancers/#{CloudLB.escape(@id.to_s)}/usage\",@lbmgmtport,@lbmgmtscheme,{})\n CloudLB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n CloudLB.symbolize_keys(JSON.parse(response.body)[\"loadBalancerUsageRecords\"])\n end",
"def node_count\n @nodes.length - 1\n end",
"def returned_nodes_count\n @traversal_position.returnedNodesCount\n end",
"def edges\n edges = 0\n @graph.each_value do |v|\n edges += v.size\n end\n edges\n end",
"def count(g, u, v)\n g.vertices.each do |v|\n v.data = 0\n v.parent = nil\n end\n\n dfs_count(g, u, v)\n v.data\nend",
"def node_size\n @results.size\n end",
"def log_nodes_count\n @max_nodes += 1\n end",
"def node_count(type = nil)\n if type\n value = @db.m_get(\"node#{type}\")\n if value\n value.to_i\n end\n else\n @db.m_get(\"n\").to_i\n end\n end",
"def unused_nodes\n s = []\n (0..7).each do |i|\n if position[i] && !position[i].used\n s << i\n end\n end\n s\n end",
"def size\n all_nodes.length\n end",
"def get_nodes\n @weights.keys\n end",
"def size_all\n\t\tfname=\"Node:#{__method__}\"\n\t\tret=0\n\t\tlevel=0\n\t\tbegin\n\t\t\tret=self.size_all_(ret, level)\n\t\trescue Exception=>e\n\t\t\tLOG.error(fname){\"EXCEPTION during nodes size calculation: #{e} \"}\n\t\tret=-1\n\t\tend\n\t\tret\n\tend",
"def get_num_connections(params)\n # TODO: deal with node not existing (nil coming back from get_stats)\n get_stats(params)['STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS']\n end",
"def number_of_nodes_edited_by_new_mappers\n \t\tnodes_by_new_mappers = Node_Query.new(analysis_window: aw, constraints: {'user' => {'$in' => aw.new_contributors}}).run\n {'Nodes Edited by New Mappers' => nodes_by_new_mappers.first[:objects].length }\n \tend",
"def number_of_nodes_edited_by_new_mappers\n \t\tnodes_by_new_mappers = Node_Query.new(analysis_window: aw, constraints: {'user' => {'$in' => aw.new_contributors}}).run\n {'Nodes Edited by New Mappers' => nodes_by_new_mappers.first[:objects].length }\n \tend",
"def get_node_counts(sf)\n case sf\n when 100\n $options[:node_counts].reject {|n| n < 8}\n when 10\n $options[:node_counts].reject {|n| n < 2}\n else\n $options[:node_counts]\n end\nend",
"def countNodeStatus(domain)\r\n nON = 0\r\n nOFF = 0\r\n nKO = 0\r\n d = (domain == \"default\") ? OConfig.GRID_NAME : domain\r\n url = \"#{OConfig[:tb_config][:default][:cmc_url]}/allStatus?domain=#{d}\"\r\n response = NodeHandler.service_call(url, \"Can't get node status from CMC\")\r\n doc = REXML::Document.new(response.body)\r\n doc.root.elements.each('//detail/*') { |e|\r\n attr = e.attributes\r\n state = attr['state']\r\n nON = (state.match(/^POWERON/)) ? nON + 1 : nON\r\n nOFF = (state.match(/^POWEROFF/)) ? nOFF + 1 : nOFF\r\n nKO = (state.match(/^NODE/)) ? nKO + 1 : nKO\r\n }\r\n puts \"-----------------------------------------------\"\r\n puts \"Testbed : #{d}\"\r\n puts \"Number of nodes in 'Power ON' state : #{nON}\"\r\n puts \"Number of nodes in 'Power OFF' state : #{nOFF}\"\r\n puts \"Number of nodes in 'Not Available' state : #{nKO}\"\r\n puts \"-----------------------------------------------\"\r\nend",
"def target_num_nodes() ; info[:target_num_nodes] ; end",
"def vertex_count\n @graph.length\n end",
"def node_groups(graph)\n Rails.cache.fetch(\"#{graph.name}_node_group_list\") do\n graph.nodes.flat_map { |n| n.groups.to_a }.sort.uniq\n end\n end",
"def size\n counter = 0\n each { |node| counter += 1 }\n return counter\n end",
"def size\n\t\[email protected]\n\tend",
"def ll_size()\n return @num_nodes\n end",
"def found_blocks\n shares.where(:upstream_result => \"Y\").count + blocks.count\n end",
"def tasks_failed_count\n inject(0) do |sum, node|\n sum + node.graph.tasks_failed_count\n end\n end",
"def tasks_failed_count\n inject(0) do |sum, node|\n sum + node.graph.tasks_failed_count\n end\n end",
"def active_node_count\n Puppet.debug('Querying PuppetDB for Active Nodes')\n pql = ['from', 'nodes',\n ['and',\n ['=', ['node', 'active'], true],\n ]\n ]\n results = query_puppetdb(pql)\n return nil if results.nil?\n Puppet.debug(results)\n results.count\n end",
"def count_nodes(node = @root)\n node.children.map do |child_node|\n @node_count +=1\n # binding.pry if child_node.is_word\n count_nodes(child_node)\n end\n @node_count\n end",
"def graphs(n)\n {\n 'cpu' =>\n \"groupByNode(collectd.#{name(n)}.cpu.*.cpu.*.value, 5, 'sumSeries')\",\n\n 'memory' =>\n \"groupByNode(collectd.#{name(n)}.memory.memory.*.value,4,'sumSeries')\",\n\n 'interface_if_octets_rx' =>\n \"groupByNode(collectd.#{name(n)}.interface.if_octets.*.rx,4,'sumSeries')\",\n\n 'interface_if_octets_tx' =>\n \"groupByNode(collectd.#{name(n)}.interface.if_octets.*.tx,4,'sumSeries')\",\n\n 'qmail_filecount_files' =>\n \"groupByNode(collectd.#{name(n)}.filecount.*.files.value,3,'sumSeries')\",\n\n 'qmail_filecount_files_stacked' =>\n \"groupByNode(collectd.*.filecount.*.files.value,1,'sumSeries')\",\n\n 'qmail_filecount_files_derivative' =>\n \"groupByNode(collectd.#{name(n)}.filecount.*.files.value,3,'derivative')\",\n\n 'qmail_filecount_files_derivative_stacked' =>\n \"groupByNode(collectd.*.filecount.*.files.value,1,'derivative')\",\n\n 'qmail_filecount_files_integral' =>\n \"groupByNode(collectd.#{name(n)}.filecount.*.files.value,3,'integral')\",\n\n 'qmail_filecount_files_integral_stacked' =>\n \"groupByNode(collectd.*.filecount.*.files.value,1,'integral')\",\n\n 'qmail_filecount_size' =>\n \"groupByNode(collectd.#{name(n)}.filecount.*.bytes.value,3,'sumSeries')\",\n\n 'qmail_filecount_size_stacked' =>\n \"groupByNode(collectd.*.filecount.*.bytes.value,1,'sumSeries')\",\n }\n end",
"def usage\n usage = 0\n instance.nodes.each do |node|\n data = DockerVolumeLocal::Node.new(node).remote_exec(\n %Q(sudo bash -c \"du --total --block-size 1024 -s #{DockerVolumeLocal.config[:docker_volume_path]}/#{instance.name}/_data | grep total\")\n )\n usage += data.split(\"\\t\")[0].strip.to_i\n end\n usage\n rescue\n nil\n end",
"def getNodeList\n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s\n result = HTTParty.get(broker_url + \"/resources/nodes\", :verify => false)\n temp2 = JSON.parse(result.body)\n\n node_data = temp2[\"resource_response\"][\"resources\"]\n return node_data\n \n end",
"def top_vuln_graph(limit=10)\n\t\t\t\t\tg = Gruff::Bar.new(GRAPH_WIDTH)\n\t\t\t\t\tg.title = sprintf \"Top 10 Hosts with Notable Findings Count\"\n\t\t\t\t\tg.sort = false\n\t\t\t\t\tg.marker_count = 1\n\t\t\t\t\tg.theme = {\n\t\t\t\t\t\t:colors => Risu::GRAPH_COLORS,\n\t\t\t\t\t\t:background_colors => %w(white white)\n\t\t\t\t\t}\n\n\t\t\t\t\tItem.risks_by_host(limit).to_a.each do |item|\n\t\t\t\t\t\tip = Host.find_by_id(item.host_id).name\n\t\t\t\t\t\tcount = Item.where(:host_id => item.host_id).where(:severity => 4).size\n\n\t\t\t\t\t\tif count > 0\n\t\t\t\t\t\t\tg.data(ip, count)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\tStringIO.new(g.to_blob)\n\t\t\t\tend",
"def total_hits_node\n {total_hits: total_hits_count}\n end",
"def available_node_list\n all_nodes = Node.by_name\n return all_nodes.select {|node| node.status == \"RUNNING\"}\n end",
"def counts\r\n @counts\r\n end",
"def getNodeWeights()\n # (two possible sources: flipped and negated, so \n # add them for each node)\n \n tabRead(@edges){|arr|\n ordered = [arr[0],arr[2]].sort\n @allEdgeWeightScores[ordered.join(\"--\")] += arr[3].to_f\n @nodeList[arr[0]] = 1\n @nodeList[arr[2]] = 1\n }\nend",
"def n_paths(graph, from)\n counter = { from => 1 }\n graph.topsort.each do |v|\n next if v == from\n in_edges = graph.edges.select { |e| e.target == v && graph.adjacent(v, :direction => :in).include?(e.source) }\n counter[v] = in_edges.map { |e| counter[e.source] }.inject(:+)\n end\n counter\nend",
"def nodes\n TestLab::Node.all\n end",
"def get_registered_nodes\n update_nodes\n @registered_nodes\n end",
"def nodes= nodes\n @grpc.node_count = nodes\n end",
"def nodes\n nodes_by_id.values\n end",
"def used_bytes\n size = 0\n unless empty?\n actual_node = @tail_node\n while actual_node != nil do\n size += actual_node.value.value.length\n actual_node = actual_node.next_node\n end\n end\n size\n end",
"def summary\n \" Discovered #{@discovered_nodes.count} live node(s)\"\n end",
"def in_use_graph\n graph = Graph.new\n\n index_to_vertex = build_index\n index_to_vertex.each do |(vrow, vcol), v|\n neighbours_in_use(vrow, vcol)\n .map { |index| index_to_vertex[index] }\n .each { |w| graph.add_edge(v, w) }\n end\n\n graph\n end",
"def node_helper_to_units(path: 'status', type:, value: 'used', output_msg:, unit: 'gb', perf_label: 'Usage')\n http_connect(path: \"api2/json/nodes/#{@options[:node]}/#{path}\")\n data = JSON.parse(@response.body)['data'][type][value]\n convert_bytes_to_unit(data: data, unit: unit)\n build_output(msg: \"#{output_msg}: #{@usage}#{unit.upcase}\")\n build_perfdata(perfdata: \"#{perf_label}=#{@usage}#{unit.upcase}\")\n check_thresholds(data: @usage)\n end",
"def tasks_finished_count\n inject(0) do |sum, node|\n sum + node.graph.tasks_finished_count\n end\n end",
"def tasks_finished_count\n inject(0) do |sum, node|\n sum + node.graph.tasks_finished_count\n end\n end",
"def test_create_graph\n val = create_graph(1234, 5)\n locations_count = val[0].count\n prospectors_count = val[1].count\n assert_equal 7, locations_count\n assert_equal 5, prospectors_count\n end",
"def get_items(count)\n items(@nodename,count)\n end",
"def get_stats(params)\n node_ip = get_ip(params)\n result = {}\n if params.has_key?(:pool)\n pool_name = params[:pool]\n node_port = (params[:port] || 80).to_i\n notify(:msg => \"[#{@name}] Retrieving stats for member #{node_ip}:#{node_port} in pool #{pool_name} on load balancer #{@config[:host]}\",\n :tags => [:f5, :trace])\n stats = with_f5('LocalLB.PoolMember') do\n get_statistics([ pool_name ], [[{ 'address' => node_ip, 'port' => node_port }]])\n end\n # TODO: deal with node not existing (stats is nil)\n stats = stats[0] if stats[0]\n else\n notify(:msg => \"[#{@name}] Retrieving stats for node #{node_ip} on load balancer #{@config[:host]}\",\n :tags => [:f5, :trace])\n stats = with_f5('LocalLB.NodeAddress') do\n get_statistics([ node_ip ])\n end\n end\n # TODO: deal with node not existing (stats is nil)\n if stats['statistics'] && stats['statistics'][0] && stats['statistics'][0]['statistics']\n stats['statistics'][0]['statistics'].each do |stat|\n name = extract_type(stat)\n if name\n # TODO: switch on the type and support all possible values\n if extract_type(stat.value) == 'iControl:Common.ULong64'\n result[name] = (stat.value.high << 32) | stat.value.low\n end\n end\n end\n end\n result\n end",
"def ref_count(node)\n @references.fetch(node, 0)\n end",
"def objects\n @graphs.inject([]) {|memo, g| memo += g.objects}\n end",
"def number_of_living_descendants\n count_descendants_matching { |d| d.alive? }\nend",
"def order\n nodes.length\n end",
"def output_node_hit_rate\n cache_controller = @bmconfig.sp_controller.instance_variable_get(:@hash_tree_controller)\n node_to_load = cache_controller.total_node_to_load\n node_needed = cache_controller.total_node_needed\n puts \"node cache hit rate = 1 - #{node_to_load}/#{node_needed} = #{(1-node_to_load.to_f/node_needed)*100}%\"\n cache_controller.reset_hit_info\n end",
"def member_and_collection_count_for_rails3(node)\n :resources == node.subject.message ? node.grep_nodes_count(:node_type => :call, :message => VERBS) : 0\n end",
"def size\n return 0 if empty?\n count_node(head, 1)\nend",
"def nodes(tag)\n if nodes = @cache_nodes[tag]\n return nodes\n end\n hash_key = @hash_key_slice ? perform_hash_key_slice(tag) : tag\n regular_index = @regular_weight_array.size > 0 ? get_index(hash_key, @regular_weight_array.size) : 0\n standby_index = @standby_weight_array.size > 0 ? get_index(hash_key, @standby_weight_array.size) : 0\n nodes = [@regular_weight_array[regular_index], @standby_weight_array[standby_index]].compact\n @cache_nodes[tag] = nodes\n end"
] | [
"0.6935106",
"0.6489301",
"0.6385032",
"0.63119847",
"0.62400883",
"0.6238676",
"0.6103131",
"0.6090946",
"0.6086095",
"0.6050516",
"0.5909553",
"0.5909553",
"0.59008396",
"0.5892348",
"0.58889264",
"0.58889264",
"0.58876914",
"0.58811575",
"0.58577216",
"0.58576155",
"0.58558387",
"0.58522546",
"0.5815053",
"0.5812706",
"0.5745276",
"0.5711801",
"0.5711801",
"0.57025266",
"0.57025266",
"0.56986415",
"0.5692713",
"0.56736976",
"0.5665932",
"0.5660846",
"0.56572163",
"0.5648508",
"0.5605899",
"0.5601948",
"0.5598428",
"0.559711",
"0.55817926",
"0.5562865",
"0.5556459",
"0.55453414",
"0.55389297",
"0.5529401",
"0.5516556",
"0.5513445",
"0.5504893",
"0.5504888",
"0.5498914",
"0.54945254",
"0.5493934",
"0.54817635",
"0.54703265",
"0.54679704",
"0.54679704",
"0.5441959",
"0.5436699",
"0.5433851",
"0.54165834",
"0.5415324",
"0.54140174",
"0.5402329",
"0.5399877",
"0.5394596",
"0.5376987",
"0.5376987",
"0.53700024",
"0.5364583",
"0.5357479",
"0.5356342",
"0.5353162",
"0.5338899",
"0.53334194",
"0.5332557",
"0.5332377",
"0.53285426",
"0.5318817",
"0.53088707",
"0.53064823",
"0.5304913",
"0.5304672",
"0.5303422",
"0.52989924",
"0.5298842",
"0.5291089",
"0.5287985",
"0.5287985",
"0.528315",
"0.5278405",
"0.5277508",
"0.5269171",
"0.5252729",
"0.5252311",
"0.5252143",
"0.5237122",
"0.5237026",
"0.52341086",
"0.52290183"
] | 0.61101085 | 6 |
This is the basic run loop | def run
if ldr.read < 70
led.on!
else
led.off!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loop\n end",
"def loop\n end",
"def loop\n end",
"def loop; end",
"def run_loop\n end",
"def loop_forever; end",
"def start\n loop do\n run\n end\n end",
"def run\n raise NotImplementedError, 'Generic loop has nothing to do'\n end",
"def run()\n while(true)\n cycle() ;\n sleep(2) ;\n end\n end",
"def run\n while 1\n if step == 1 then break end\n end\n end",
"def testloop\n \n end",
"def run\n while 1\n sleep(0.2)\n #puts \"bezim \"[email protected]_s\n end\n end",
"def start\n main_loop\n end",
"def run\n while @running\n step\n end\n end",
"def post_loop; end",
"def run() end",
"def run\n loop { run_once }\n end",
"def run\n loop do\n break unless app_loop\n end\n end",
"def loop\n puts \"Diet Manager 3000!\"\n puts \"Created by Jesse Jurman\"\n check = 1\n while check != 0\n print \"> \"\n check = step\n end\n end",
"def kloop\n end",
"def pre_loop; end",
"def preloop\n 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 run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def start_loop\n loop do\n sleep 2\n start\n end\n rescue => e\n Torkify.logger.error { e }\n end",
"def postloop\n end",
"def run_forever\n run\n sleep(10) while true\n end",
"def infinite_loop?; end",
"def foreverize\n loop do\n run\n end\n end",
"def run\n loop do\n tick\n sleep settings.service.polling_interval\n end\n end",
"def run\n loop do\n tick\n sleep settings.service.polling_interval\n end\n end",
"def run\n \n end",
"def run\n \n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def main_loop\n @main_loop ||= lambda do\n # Smoother, but slower: GC.start if rand > 0.98\n next_step\n SUBSTEPS.times do\n move\n targeting\n handle_input\n remove_marked\n step_physics\n end\n end\n end",
"def loop( &block )\n sanity_check\n @connection.loop(&block)\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 running; end",
"def running; end",
"def parentloop; end",
"def endless_loop?; end",
"def run()\n end",
"def run(_); end",
"def run(_); end",
"def run\n end",
"def main\n loop do\n unless @context\n begin\n self.process(self.await_input)\n rescue ConsoleInterrupt\n self.replace '^C'\n self.println ':(', 2\n rescue ConsoleError => e\n self.print _INTL(\"{1}: {2}\",self.name,e.message), 0, true\n self.println ':(', 2\n rescue ConsoleExit\n self.exit_session\n break\n end\n end\n end\n end",
"def main_loop\n\t\t\tbegin\n\t\t\t\tloop {\n\t\t\t\t\titerate\n\t\t\t\t\tlog.debug \"Finished iteration; sleeping for #{sleep_time}s.\"\n\t\t\t\t\tsleep sleep_time\n\t\t\t\t}\n\t\t\trescue Exception => e\n\t\t\t\t# We want to avoid crashing if at all possible, so we catch\n\t\t\t\t# everything, log it, sleep (to avoid thrashing or flooding the\n\t\t\t\t# logs completely if the error persists), and go back to the\n\t\t\t\t# main loop.\n\t\t\t\tlog.error(\"#{self.class.inspect}'s main loop crashed \" \\\n\t\t\t\t\t\t \"with #{e.inspect} at #{e.backtrace[0]}!\")\n\t\t\t\tsleep(sleep_time * 10)\n\t\t\t\tretry\n\t\t\tend\n\t\tend",
"def go\n while(true)\n process_event(wait_for_event)\n end\n end",
"def game_loop\n end",
"def run_run_loop time = 1\n NSRunLoop.currentRunLoop.runUntilDate (Time.now + time)\nend",
"def print_1_forever\n while true do\n puts 1\n end\nend",
"def start\n while listen\n # Loop for-ev-er\n end\n end",
"def start_run; end",
"def myloop\n while true\n yield\n end\nend",
"def while(&block)\n\t\t\t\t\trepeat &block\n\t\t\t\tend",
"def run\n loop { sleep 5 while @feeds.alive? }\n end",
"def run\n until halted?\n step\n end\n end",
"def is_loop\n\n true\n end",
"def runs; end",
"def run\n send Rainbow('Running cpgui...').aqua\n @run = true\n input while @run\n end",
"def loop\n while(1==1)\n tse = TestSuiteExecution.find(:all, :conditions => \"status = 'n'\")\n if @threaded\n tse.each {|t| @tasks << Thread.new(t){ |ts| execute(ts) } }\n else\n tse.each {|t| execute(t) }\n end\n sleep 10\n end\n end",
"def run\n prepare_process\n reporter.welcome_message\n exit(1) if print_config_errors\n\n # Set up our console input handling and history\n console = Console.new(config, reporter)\n\n # Start the server\n while console_run_loop(console)\n # just need to run the loop\n end\n\n console.store_history\n\n cleanup_process\n end",
"def thread; end",
"def thread; end",
"def thread; end",
"def run\n puts \"Hello world\"\n end",
"def my_loop\n while true\n yield\n end\nend",
"def run\n raise \"Not implemented yet.\"\n end",
"def run_blinky\n\t\twhile @i<10**3\n\t\t\t@i += 1\n\t\t\t# sleep(0.3)\n\t\t\tsystem(\"clear\")\n\t\t\tpretty_print\n\t\t\tgo_team\n\t\tend\n\tend",
"def run\n log.trace (\"run triggered\")\n while thread_current_running?\n current_time = Time.now.to_i\n\n emit() if thread_current_running?\n while thread_current_running? && Time.now.to_i <= current_time\n sleep @run_interval\n end\n end\n end",
"def game_loop\n end",
"def load(n,m)\n n.times {\n puts \"*\"\n sleep(m)\n}\n \nend",
"def foreground\n connect\n loop do\n run(@config[:interval], @config[:concurrency])\n end\nend",
"def run(vm)\n while step(vm); end\n end",
"def in_loop\n declare_alive\n project.load\n if loop_i == -1\n say '-----------------------------------'\n say 'MiGA:%s launched.' % project.name\n say '-----------------------------------'\n load_status\n @loop_i = 0\n end\n @loop_i += 1\n check_datasets\n check_project\n if shutdown_when_done? and jobs_running.size + jobs_to_run.size == 0\n say 'Nothing else to do, shutting down.'\n return false\n end\n flush!\n if loop_i==4\n say 'Housekeeping for sanity'\n @loop_i = 0\n purge!\n end\n report_status\n sleep(latency)\n true\n end",
"def start\n #method calls for Create and Print initial boardboard\n createBoard\n printBoard\n \n #loop 10 times \n #process board and print\n 10.times do\n processBoard\n printBoard\n end\n end",
"def run\n Thread.new {\n loop do\n @server.update(1000)\n break if @terminate\n end\n }\n end",
"def run\n @running = true\n begin\n while running?\n self.ir = decode(ram.read(self.pc))\n self.pc += 1\n exec(ir[0], ir[1])\n end\n end \n end",
"def go\n catch(:quit) do\n loop do\n step\n end\n end\n end",
"def run\n run_one_instruction while threads.length > 0\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 sleepy_run; end",
"def run_all()\n end",
"def start\n\t\t\t@thread = Thread.new do\n\t\t\t\twhile true\n\t\t\t\t\tupdate\n\t\t\t\tend\n\t\t\tend\n\t\tend"
] | [
"0.8562568",
"0.85275996",
"0.85275996",
"0.8492353",
"0.84090894",
"0.78792995",
"0.76112187",
"0.75437784",
"0.7529084",
"0.74996686",
"0.7450677",
"0.7414697",
"0.7325195",
"0.7316291",
"0.72435015",
"0.7201449",
"0.7172944",
"0.71346426",
"0.7119451",
"0.70555717",
"0.7036998",
"0.7022766",
"0.6963971",
"0.6963971",
"0.6963971",
"0.6963971",
"0.6963971",
"0.6963971",
"0.6963971",
"0.6963971",
"0.6963971",
"0.69212157",
"0.69212157",
"0.69212157",
"0.69212157",
"0.69212157",
"0.69212157",
"0.69212157",
"0.6915441",
"0.69123393",
"0.6902608",
"0.6900972",
"0.6889036",
"0.6877625",
"0.6877625",
"0.684261",
"0.684261",
"0.6828985",
"0.68097574",
"0.68097574",
"0.6787224",
"0.6786734",
"0.67620504",
"0.6749246",
"0.67250514",
"0.67250514",
"0.66901463",
"0.6685625",
"0.66690546",
"0.6623091",
"0.6623091",
"0.65960526",
"0.6579354",
"0.65782523",
"0.6572064",
"0.6545041",
"0.65410745",
"0.65362096",
"0.65293866",
"0.64888394",
"0.6487827",
"0.64399403",
"0.64283395",
"0.6408053",
"0.6398925",
"0.6382275",
"0.6357737",
"0.6356249",
"0.6351591",
"0.6351578",
"0.6351578",
"0.6351578",
"0.6348397",
"0.63459104",
"0.6343262",
"0.6339317",
"0.63328856",
"0.6330601",
"0.63202906",
"0.63197327",
"0.631047",
"0.6305876",
"0.629786",
"0.6293489",
"0.6288267",
"0.62866896",
"0.62847847",
"0.62830853",
"0.62703145",
"0.626909",
"0.6253068"
] | 0.0 | -1 |
Run manifest when in beaker, skip if local | def run_manifest (manifest)
if ENV.has_key? 'LOCAL_TEST'
print 'Notice: Skipping apply_manifest changes, due to local test. Please run puppet apply manually with the manifest above.\n'
else
# with local tests, we can't use beaker function like apply_manifest
let(:manifest) { manifest }
it 'should run without errors' do
expect(apply_manifest(manifest, :catch_failures => true).exit_code).to eq(2)
end
it 'should re-run without changes' do
expect(apply_manifest(manifest, :catch_changes => true).exit_code).to be_zero
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n if !repo_manifest_exists?\n Rails.logger.info \"Creating manifest for #{manifest['name']}\"\n\n create_repo_manifest!\n elsif repo_manifest_changed?\n Rails.logger.info \"Updating manifest for #{manifest['name']}\"\n\n update_repo_manifest!\n else\n Rails.logger.info \"No changes to manifest for #{manifest['name']}, \" \\\n \"skipping...\"\n end\n end",
"def before_deploy(manifest)\n # do nothing by default\n end",
"def first_run?\n not File.exists? '/boot/config/.boxcar'\n end",
"def prepare_manifest_for(entries)\n deploy_manifest\n end",
"def manifest() @opts.manifest; end",
"def manifest\n return refresh if config.auto_build\n\n @manifest ||= load_manifest\n end",
"def prepare_manifest_tests (manifest_path, manifest_file)\n # copy test manifest which includes current module\n rm_rf manifest_path\n mkdir_p manifest_path\n cp manifest_file, manifest_path\nend",
"def apply_manifest(manifest, opts = {}, &block)\n apply_manifest_on(default, manifest, opts, &block)\n end",
"def define_manifest_task\n\n if File.exist?( 'Manifest.static' )\n file 'Manifest.txt' => [ 'Manifest.static' ]\n end\n\n gf = clean_list( spec.generated_files ).sort\n [ :gem, :test ].each { |t| task t => gf }\n\n unless gf.empty?\n task :gen_clean do\n rm_f gf\n end\n task :clean => :gen_clean\n end\n\n desc \"Force update of Manifest.txt\"\n task :manifest do\n spec.generate_manifest\n end\n\n mtask = file 'Manifest.txt' do\n spec.generate_manifest\n end\n\n mtask\n end",
"def pre_setup_suite()\n @cfg['pre_setup'] =\"defined\"\n return true\n end",
"def pre_install; end",
"def on_is_standalone\n end",
"def main\n generate_config unless $dont_gen_conf\n\n if $just_gen_conf\n puts \"\\nSkips installing, just generated the config file!\".pink\n exit(0)\n end\n \n install_dependencies if $install_req\n\n install_to_directory\nend",
"def re_run_basic_smoke_test\n beaker = \"bundle exec beaker --debug --root-keys --repo-proxy\"\n beaker += \" --preserve-hosts always\"\n beaker += \" --type aio\"\n beaker += \" --helper acceptance/lib/helper.rb\"\n beaker += \" --options-file #{BEAKER_OPTIONS_FILE}\"\n beaker += \" --load-path acceptance/lib\"\n beaker += \" --config acceptance/scripts/hosts.cfg\"\n beaker += \" --keyfile ~/.ssh/id_rsa-acceptance\"\n beaker += \" --tests acceptance/suites/tests/00_smoke\"\n\n sh beaker\nend",
"def after_deploy(manifest)\n # do nothing by default\n end",
"def setup\n true\n end",
"def generate\n generate_manifest\n fix_windows_manifest\n end",
"def just_set_up!\n AppConfig[:just_set_up] = false\n end",
"def infer_manifest\n if file = root.glob('manifest{,.txt}', :casefold).first\n set :manifest, File.basename(file)\n end\n end",
"def before_run(ant)\n end",
"def init( args )\n # Make sure we're in a folder with a Sitefile\n options = app.standard_rake_options\n [['--rakefile', 'StratusSite'],\n ['--no-search', nil],\n ['--silent', nil]].each {|opt, value| options.assoc(opt).last.call(value)}\n\n unless app.have_rakefile\n @mode = :app\n end\n\n import_default_tasks\n import_website_tasks\n require_lib_files\n capture_command_line_args(args)\n \n # if args.length == 0 && @mode == :app\n # puts \"Try using:\\n stratus -T\"\n # end\n \n args\n end",
"def mina_app\n Rake.application.instance_eval do\n init \"mina\"\n require \"mina/rake\"\n\n @rakefiles = [\"test/deploy.rb\"]\n load_rakefile\n\n # list of tasks that were \"invoked\"\n @invoked_tasks = []\n\n # helper for invoked tasks\n def invoked_tasks\n @invoked_tasks\n end\n\n # fake invoke command for testing\n def invoke(task)\n invoked_tasks << task\n end\n\n # flag if cleanup method called\n @cleanup_called = false\n\n # helper for cleanup method\n def cleanup_called\n @cleanup_called\n end\n\n # fake mina_cleanup! command for testing\n def mina_cleanup!\n super\n @cleanup_called = true\n end\n\n @deploying = true\n\n # set not deploying!\n def not_deploying!\n @deploying = false\n end\n\n def test_task(task_name = random_task_name, &block)\n task = define_task(Rake::Task, task_name) do |t|\n extend Mina::Helpers\n extend Mina::Hooks::Plugin # simulates a rakefile env\n block.call(self)\n end\n task.invoke\n task\n end\n\n # to avoid rake task enhancing and correct invocation\n def random_task_name\n \"test_task_#{SecureRandom.hex}\"\n end\n\n def reset!\n @before_mina_tasks = []\n @after_mina_tasks = []\n @invoked_tasks = []\n @cleanup_called = false\n @deploying = true\n end\n\n return self\n end\nend",
"def stand_alone?; end",
"def stand_alone?; end",
"def bootstrap_required?\n entry_point.nil?\n end",
"def will_start_up\n end",
"def build_app_caches(app_name, instance_name)\n Dir.chdir RailsPwnerer::Config[app_name, instance_name][:app_path] do\n if File.exist?('Gemfile')\n Kernel.system 'bundle exec rake assets:precompile RAILS_ENV=production'\n else\n Kernel.system 'rake assets:precompile RAILS_ENV=production'\n end\n end\n end",
"def prepare_for_installation; end",
"def manifest\n puts 'running'\n controller_names.each do |name|\n # This option is not necessary while there is only one controller\n # next unless options[:only].empty? || file.start_with?(options[:only])\n copy_file \"chive/#{name}_controller.rb\", \"app/controllers/chive/#{name}_controller.rb\"\n end\n end",
"def manifest(m)\r\n load_paths = load_paths('lazydoc', 'configurable', 'tap')\r\n bin_path = File.join(load_paths.last.chomp('lib'), 'bin/tapexe')\r\n \r\n m.template name, 'tap.erb', {\r\n :load_paths => load_paths,\r\n :bin_path => bin_path\r\n }\r\n \r\n m.on(:generate) do \r\n log :chmod, \"0755 #{name}\"\r\n FileUtils.chmod(0755, name)\r\n end\r\n \r\n m.template profile, 'profile.erb', {\r\n :generator => self.class,\r\n :filename => profile\r\n }\r\n end",
"def prevent_nested_install\n return unless Rails.try(:root) && Rails.root.blank?\n\n abort \"Install generator cannot be run inside Archangel extension.\"\n end",
"def prepare_for_deploy(services:, secrets:, local_environment:, why_run:)\n @local_env = local_environment\n end",
"def check!\n Capistrano::Deploy::Dependencies.new(configuration) do |d|\n d.remote.file(Capistrano::Puppet::Service::Webrick::SERVICE_INIT).or(\"`#{Capistrano::Puppet::Service::Webrick::SERVICE_INIT}' does not exist. Please run `cap deploy:setup'.\")\n end\n end",
"def standalone; end",
"def pkg_manifest_file\n @pkg_manifest_file ||= File.join(staging_dir, \"#{safe_base_package_name}.p5m\")\n end",
"def setup_files\n create_application_rb\n create_production_rb\n end",
"def manifest\n if [email protected]_a?(Condenser::Manifest) && @manifest.respond_to?(:call)\n @manifest = @manifest.call\n else\n @manifest\n end\n end",
"def precompile_assets?\n !File.exist? \"public/assets/manifest.yml\"\n end",
"def send_manifest\n begin\n manifest = JSON.parse(File.read(@manifest))\n manifest['instanceId'] = \"#{Socket.gethostname}_#{SecureRandom.uuid}\" if @generate_instance_ids\n @instance_id = manifest['instanceId']\n rescue\n end\n send_message('APP_MANIFEST', manifest)\n end",
"def assets_manifest; end",
"def assets_manifest; end",
"def just_set_up?\n AppConfig[:just_set_up] == true\n end",
"def verify_rails!\n unless rails?\n abort unless agree \"`#{dest}' does not appear to be a rails app; continue? \"\n end\n end",
"def autorun!\n at_exit do\n exit 1 unless run!\n end\n end",
"def post_fetch local_filename\n if local_filename.end_with?('.tsv')\n logger.info \"Deploying contents of config file: #{local_filename}\"\n process_config_file local_filename\n\n elsif local_filename.end_with?('.gz')\n logger.info \"Deploying R package: #{local_filename}\"\n execute \"install custom R package #{local_filename}\" do\n command \"R CMD INSTALL #{local_filename}\"\n end\n\n elsif local_filename.end_with?('.deb')\n logger.info \"Deploying Debian package: #{local_filename}\"\n package_base = Regexp.new(\".*/([^/]+)_([^_/]+)\\.deb$\").match(local_filename)[1]\n dpkg_package \"#{package_base}\" do\n action :install\n source local_filename\n end\n end\n end",
"def setup(requested_by, opts={ admin: false })\n deployments.each { |d| d.setup requested_by, opts }\n end",
"def add_webpub_manifest!\n system \"cd #{share_path}; #{Rails.root.join('script/create_manifest')} #{edition.store_link}\"\n end",
"def iiif_manifest\n return unless manifestable? && file_set\n manifest_path\n end",
"def preinst\n @package.get_script :preinst\n end",
"def globalSetup()\n # Build\n run(\"cd '#{Embedding::CODE_PATH}' && make clean && make\")\nend",
"def setup_environment; end",
"def manifest\n template \"#{favorite_cleaned}.txt\", 'Song.txt'\n end",
"def setup_fakes\n Fakes::Initializer.development! if Rails.env.development? || Rails.env.demo?\n end",
"def flag_example!\n example.metadata[:run] = true\n end",
"def setup\n # no setup\n\tend",
"def true_app\n InstallFest.latest_instance\n end",
"def prepare!\n if !@is_prepared\n @is_prepared = true\n buildfile = manifest.target.buildfile\n if buildfile.task_defined? 'entry:prepare'\n buildfile.invoke 'entry:prepare',\n :entry => self,\n :manifest => self.manifest,\n :target => self.manifest.target,\n :config => self.manifest.target.config,\n :project => self.manifest.target.project\n end\n end\n return self\n end",
"def use_local_sources()\n return ENV.has_key?('USE_LOCAL_SOURCES') || ENV['TRAVIS_PULL_REQUEST'] == 'false'\nend",
"def setup_app_files\n cp HANAMI_TEMPLATES.join('config/hanami-vite.json'), config.config_path\n inject_line_after root.join('config/environment.rb'), 'environment :development do', ' middleware.use(ViteRuby::DevServerProxy, ssl_verify_none: true) if ViteRuby.run_proxy?'\n inject_line_after_last root.join('apps/web/application.rb'), 'include Web::Assets::Helpers', ' include ViteHanami::TagHelpers'\n inject_line_after root.join('apps/web/application.rb'), 'configure :development do', <<-CSP\n # Allow @vite/client to hot reload changes in development\n security.content_security_policy(\n security.content_security_policy\n .sub('script-src', \"script-src 'unsafe-eval'\")\n .sub('connect-src', \"connect-src ws://\\#{ ViteRuby.config.host_with_port }\")\n )\n CSP\n append root.join('Rakefile'), <<~RAKE\n require 'vite_hanami'\n ViteRuby.install_tasks\n RAKE\n end",
"def needs_manifest?\n needs_external_csv? || enabled_questionings.any?(&:media_prompt?)\n end",
"def bootstrap!\n root_file = Gem::TUF::File.new 'metadata/root.txt',\n Gem::TUF::Serialize.canonical(signed_root)\n\n targets = Gem::TUF::Role::Targets.empty\n targets_file = build_role 'targets', targets\n\n release = Gem::TUF::Role::Release.empty\n release.replace(targets_file)\n release.replace(root_file)\n release_file = build_role 'release', release\n\n timestamp = Gem::TUF::Role::Timestamp.empty\n timestamp.replace(release_file)\n timestamp_file = build_role 'timestamp', timestamp\n\n [root_file, targets_file, release_file].each do |file|\n bucket.create file.path_with_hash, file.body\n end\n bucket.create timestamp_file.path, timestamp_file.body\n end",
"def has_manifest?\n\t\treturn self.manifest_file.readable?\n\tend",
"def on_app_master(&blk) on_roles(%w[solo app_master], &blk) end",
"def assets_manifest=(_arg0); end",
"def assets_manifest=(_arg0); end",
"def autostart; end",
"def first_run?\n ::File.exist?(node['tomcat']['validation_script'])\n end",
"def initial_setup\n # Copy across the application_record_loader.rb unless it already exists\n copy_file '../static_files/application_record_loader.rb',\n 'lib/record_loader/application_record_loader.rb',\n skip: true\n # Copy across the record_loader.rake unless it already exists\n copy_file '../static_files/record_loader.rake',\n 'lib/tasks/record_loader.rake',\n skip: true\n end",
"def ensure_has_environment_files()\n\n end",
"def run_if_installed(output = true, &blk)\n return yield if Config.installed?\n inform \"You need to run `dotify setup` before you can run this task.\" if output\n end",
"def verify_manifest(theme_path)\n manifest_path = File.join(theme_path, \"manifest.yml\")\n manifest_file = File.open( manifest_path )\n abort(\"rake aborted: repo must contain valid manifest.yml\") unless File.exist? manifest_file\n manifest = YAML.load( manifest_file )\n manifest_file.close\n manifest\nend",
"def create_gemfile\n unless options[:skip_gemfile]\n puts \"Create #{name} gemfile manifest\"\n end\n end",
"def run\n reconfigure\n setup_application\n run_application\n end",
"def build_manifest(opts={})\n main_class = (opts[:main_class] ? randomize(opts[:main_class]) : nil)\n app_name = (opts[:app_name] ? randomize(opts[:app_name]) : nil)\n existing_manifest = nil\n meta_inf_exists = @entries.find_all{|item| item.name == 'META-INF/' }.length > 0\n\n @manifest = \"Manifest-Version: 1.0\\r\\n\"\n @manifest << \"Main-Class: #{main_class}\\r\\n\" if main_class\n @manifest << \"Application-Name: #{app_name}\\r\\n\" if app_name\n @manifest << \"Permissions: all-permissions\\r\\n\"\n @manifest << \"\\r\\n\"\n @entries.each { |e|\n next if e.name =~ %r|/$|\n if e.name == \"META-INF/MANIFEST.MF\"\n existing_manifest = e\n next\n end\n #next unless e.name =~ /\\.class$/\n @manifest << \"Name: #{e.name}\\r\\n\"\n #@manifest << \"SHA1-Digest: #{Digest::SHA1.base64digest(e.data)}\\r\\n\"\n @manifest << \"\\r\\n\"\n }\n if existing_manifest\n existing_manifest.data = @manifest\n else\n add_file(\"META-INF/\", '') unless meta_inf_exists\n add_file(\"META-INF/MANIFEST.MF\", @manifest)\n end\n end",
"def load_main_manifest\n parser = Parser::EvaluatingParser.singleton\n parsed_code = Puppet[:code]\n program = if parsed_code != \"\"\n parser.parse_string(parsed_code, 'unknown-source-location')\n else\n file = @environment.manifest\n\n # if the manifest file is a reference to a directory, parse and combine\n # all .pp files in that directory\n if file == Puppet::Node::Environment::NO_MANIFEST\n nil\n elsif File.directory?(file)\n raise Puppet::Error, \"manifest of environment '#{@environment.name}' appoints directory '#{file}'. It must be a file\"\n elsif File.exist?(file)\n parser.parse_file(file)\n else\n raise Puppet::Error, \"manifest of environment '#{@environment.name}' appoints '#{file}'. It does not exist\"\n end\n end\n instantiate_definitions(program, public_environment_loader) unless program.nil?\n program\n rescue Puppet::ParseErrorWithIssue => detail\n detail.environment = @environment.name\n raise\n rescue => detail\n msg = _('Could not parse for environment %{env}: %{detail}') % { env: @environment, detail: detail }\n error = Puppet::Error.new(msg)\n error.set_backtrace(detail.backtrace)\n raise error\n end",
"def prepare\n FileUtils.mkdir_p(veewee_autoyast_dir) unless veewee_autoyast_dir.directory?\n FileUtils.cp(sources_dir.join(\"postinstall.sh\"), veewee_autoyast_dir)\n end",
"def setup(*_)\n require 'reaper-man'\n location = ReaperMan::Signer::HELPER_COMMAND\n if(location.include?('jar!'))\n tmp_file = Tempfile.new('reaper-man')\n new_location = File.join(Dir.home, File.basename(tmp_file.path))\n tmp_file.delete\n File.open(new_location, 'w') do |file|\n file.puts File.read(location)\n end\n File.chmod(0755, new_location)\n ReaperMan::Signer.send(:remove_const, :HELPER_COMMAND)\n ReaperMan::Signer.const_set(:HELPER_COMMAND, new_location)\n warn \"Updated ReaperMan utility script location: #{new_location}\"\n end\n end",
"def ensure_new_app\n if File.exists?(File.join(Rails.root, 'config/innsights.yml')) && !Innsights.test_mode\n puts warning && exit\n end\n end",
"def init!\n # check if configuration file is already created\n puts \"=> [MoIP] Sandbox mode enabled\" if sandbox?\n unless File.exist?(CONFIG_FILE)\n puts \"=> [Moip] The configuration could not be found at #{CONFIG_FILE.inspect}\"\n return\n end\n end",
"def beaker_tests\n ENV['TESTS'] || ENV['TEST'] || 'tests'\nend",
"def run_for_all(&block)\n the_app = node[:zz][:app_name]\n the_role = node[:zz][:deploy_role]\n rails_env = node[:zz][:group_config][:rails_env]\n block.call(the_app.to_sym, the_role.to_sym, rails_env.to_sym)\n end",
"def prebuild(choice)\n case choice\n when :none\n run @main_app\n else\n run @main_app\n end\n end",
"def manifest_name\n \"MANIFEST.#{name}\"\n end",
"def backup_minister_installed?\n software_installed?(APP_NAME)\n end",
"def run_bundle\n # We don't want to run anything here since we have already run a bundle install with our gemset above\nend",
"def check_nondocker_run_env(manifest)\n manifest['roles'].each do |role|\n next if role['type'] == 'docker'\n next unless role['run']\n next unless role['run']['env']\n\n STDOUT.puts \"Non-docker role #{role['name'].red} declares bogus parameters (run.env)\"\n @has_errors += 1\n end\nend",
"def environment_manifest(testdir)\n manifest = <<-MANIFEST\n File {\n ensure => directory,\n owner => puppet,\n mode => 0700,\n }\n\n file { \"#{testdir}\": }\n\n #{generate_environment(\n :modulepath => \"#{testdir}/modules\",\n :manifestpath => \"#{testdir}/manifests\",\n :env_name => \"default environment\")}\n\n #{generate_environment(\n :modulepath => \"#{testdir}/testing-modules\",\n :manifestpath => \"#{testdir}/testing-manifests\",\n :env_name => \"legacy testing environment\")}\n\n file {\n \"#{testdir}/dynamic\":;\n \"#{testdir}/dynamic/testing\":;\n }\n\n #{generate_environment(\n :modulepath => \"#{testdir}/dynamic/testing/modules\",\n :manifestpath => \"#{testdir}/dynamic/testing/manifests\",\n :env_name => \"dynamic testing environment\")}\n\n file {\n \"#{testdir}/environments\":;\n \"#{testdir}/environments/testing\":;\n }\n\n #{generate_environment(\n :modulepath => \"#{testdir}/environments/testing/modules\",\n :manifestpath => \"#{testdir}/environments/testing/manifests\",\n :env_name => \"directory testing environment\")}\n\n file {\n \"#{testdir}/environments/testing_environment_conf\":;\n }\n\n #{generate_environment(\n :modulepath => \"#{testdir}/environments/testing_environment_conf/nonstandard-modules\",\n :manifestpath => \"#{testdir}/environments/testing_environment_conf/nonstandard-manifests\",\n :env_name => \"directory testing with environment.conf\")}\n\n file { \"#{testdir}/environments/testing_environment_conf/environment.conf\":\n ensure => file,\n content => '\n modulepath = nonstandard-modules:$basemodulepath\n manifest = nonstandard-manifests\n config_version = local-version.sh\n '\n }\n\n file {\n \"#{testdir}/environments/testing_environment_conf/local-version.sh\":\n ensure => file,\n content => '#! /usr/bin/env bash\n echo \"local testing_environment_conf\"'\n ;\n }\n\n ###################\n # Services\n\n file {\n \"#{testdir}/services\":;\n \"#{testdir}/services/testing\":;\n #{generate_module('service_mod',\n \"service testing environment\",\n \"#{testdir}/services/testing/modules\")}\n }\n\n #######################\n # Config version script\n\n file {\n \"#{testdir}/static-version.sh\":\n ensure => file,\n content => '#! /usr/bin/env bash\n echo \"static\"'\n ;\n }\n MANIFEST\n end",
"def skip_pub_task_and_post_process_only?\n !pub_options['push_metadata'] && !pub_options['push_files']\n end",
"def after_create\n create_stored_manifest\n super\n end",
"def run\n case action\n when 'new'\n require_relative('templater')\n Templater.new(File.expand_path(directory, Dir.pwd), settings).run!\n when 'console'\n require_relative('console')\n Wukong::Deploy::Console.new.run!\n end\n end",
"def lybunt_setup\n end",
"def start(manifest)\n raise ArgumentError unless manifest.kind_of? Launch::Manifest\n @logger.info \"starting a supervised job for #{manifest.label}\"\n end",
"def on_app_running(_event)\n info \"Running in #{RUBY_DESCRIPTION}\"\n info \"Running Karafka #{Karafka::VERSION} server\"\n\n return if Karafka.pro?\n\n info 'See LICENSE and the LGPL-3.0 for licensing details.'\n end",
"def stage3\n set_temp_options(:nopaludis => true) do\n Athenry::build.target(\"install_pkgmgr\", \"update_everything\", \"update_configs\", \"rebuild\")\n end\n end",
"def setup\n @applications = find_applications(pidfile_dir())\n end",
"def upload_fb_script(args)\n # @setup_script is defined in 10_load_data.rake. This is the local script file.\n nim_master = args[:nim_master]\n nim_remote_user = args[:nim_remote_user]\n nim_local_user = args[:nim_local_user]\n STDOUT.puts \"# Uploading first boot script, #{@setup_script}...\"\n sh \"sudo su - #{nim_local_user} -c \\\" scp -o StrictHostKeyChecking=no #{@setup_script} \\\n #{nim_remote_user}@#{nim_master}:#{@remote_fb_script_path}/#{File.basename(@setup_script)}\\\"\"\nend",
"def has_local_feeds(site)\n File.directory?(\n site.config['releases_dir']\n )\nend",
"def set_present_and_running\n if active_instance_dir_exists?\n return if running?\n elsif inactive_instance_dir_exists?\n activate_instance_dir\n else\n make_instance\n end\n start\n end",
"def execute(*args)\n if Puppet.features.bundled_environment?\n Bundler.with_clean_env do\n super\n end\n else\n super\n end\n end",
"def execute(*args)\n if Puppet.features.bundled_environment?\n Bundler.with_clean_env do\n super\n end\n else\n super\n end\n end"
] | [
"0.61755157",
"0.59666693",
"0.58966637",
"0.5831655",
"0.572444",
"0.5656573",
"0.5608232",
"0.55745554",
"0.5572072",
"0.5567321",
"0.5537589",
"0.55181247",
"0.5496579",
"0.5436343",
"0.5420179",
"0.54004467",
"0.5374038",
"0.5372747",
"0.53539693",
"0.5348446",
"0.5326189",
"0.5323791",
"0.5318745",
"0.5318745",
"0.5307678",
"0.5291206",
"0.52864856",
"0.528095",
"0.5279815",
"0.52616245",
"0.5261465",
"0.5245135",
"0.52220154",
"0.52198076",
"0.52032495",
"0.5202111",
"0.5187558",
"0.5183989",
"0.5183719",
"0.5179407",
"0.51794004",
"0.5179322",
"0.51728696",
"0.5171774",
"0.517142",
"0.5169154",
"0.51674014",
"0.5162175",
"0.51529115",
"0.5138458",
"0.51343095",
"0.5129885",
"0.5124849",
"0.51229376",
"0.5122174",
"0.5119943",
"0.51176935",
"0.5107435",
"0.50925773",
"0.508821",
"0.5083237",
"0.5082511",
"0.507361",
"0.50637114",
"0.50637114",
"0.50626695",
"0.5057296",
"0.50555265",
"0.50541574",
"0.50536406",
"0.50522035",
"0.5039018",
"0.5034974",
"0.50328994",
"0.50248826",
"0.50222325",
"0.50178415",
"0.5012146",
"0.4998083",
"0.4990667",
"0.4989866",
"0.49867338",
"0.4980046",
"0.497697",
"0.49731347",
"0.497283",
"0.49721253",
"0.49658462",
"0.4960963",
"0.4956334",
"0.49554297",
"0.4954764",
"0.4950017",
"0.4947898",
"0.494482",
"0.49395955",
"0.49356556",
"0.49342608",
"0.49320418",
"0.49320418"
] | 0.6647844 | 0 |
GET /api/v1/users/:user_id/ratings optionally GET /api/v1/users/:user_id/ratings?pending | def index
user = User.find_by(id: params[:user_id])
return :ratings => [], :status => :not_found if user.nil?
result = []
# generate pending ratings
if params.has_key?(:pending)
user.rides_as_passenger.each do |ride|
if Rating.find_by(from_user_id: user.id, to_user_id: ride.driver.id, ride_id: ride.id).nil?
pending_rating = {}
pending_rating[:from_user_id] = user.id
pending_rating[:to_user_id] = ride.driver.id
pending_rating[:ride_id] = ride.id
result.append(pending_rating)
end
end
respond_with ratings: result, status: :ok
else
#generate ratings given
ratings = user.ratings_given + user.ratings_received
result = []
ratings.each do |r|
rating = {}
rating[:from_user_id] = r[:from_user_id]
rating[:to_user_id] = r[:to_user_id]
rating[:ride_id] = r[:ride_id]
result.append(rating)
end
respond_with ratings: result, status: :ok
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reports_user_ratings(user_id, rating, start_date, end_date, options)\n options = {\n user: user_id,\n rating: rating,\n start: start_date,\n end: end_date,\n }\n\n get(\"reports/user/ratings\", options)\n end",
"def rate \n @user = User.find_from_param(params[:id])\n if @user.rateable_by?(current_user)\n @user.rate(params[:rate].to_i, current_user)\n render :layout => false, :text => \"#{@user.rating_count} votes\"\n else\n render :nothing => true, :status => :bad_request\n end\n end",
"def find_ratings_by_user(user, options = { })\n Rating.find :all, options.reverse_merge(:conditions => { :user_id => user.id, :rateable_type => rateable_type })\n end",
"def show\n @dev = User.find(params[:id])\n @ratings = RatingService::get_ratings(@dev)\n end",
"def user_rating(user_id)\n if user_rated?(user_id)\n @user_ratings.select { |user_rating| user_rating.user_id == user_id }.first.rating\n else\n 0\n end\n end",
"def rating?(user)\n rates.find_by(user_id: user.id, rating_id: id)\n end",
"def ratings\n Birdman::Requester.get(\"movies/#{id}/ratings\")\n end",
"def rating_by(user)\n\t\tratings.select{ |rating| rating.rater_id == user.id }.first if user.try(:id)\n\tend",
"def rated_by?( user )\n\t\t\t\t\tratings.detect {|r| r.user_id == user.id }\n\t\t\t\tend",
"def find_ratings_by_user(user)\n rateable = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s\n\n Rating.find(:all,\n :conditions => [\"rater_id = ? and rater_type = ? and rateable_type = ?\", user.id, \"User\", rateable],\n :order => \"created_at DESC\"\n )\n end",
"def rating_by(user_id, opts = {})\n rating = ratings.find_by_user_id(user_id, :conditions => opts)\n rating ? rating.score : nil\n end",
"def find_ratings_by_user(user) \n rateable = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s\n \n Rating.find(:all,\n :conditions => [\"user_id = ? and rateable_type = ?\", user.id, rateable],\n :order => \"created_at DESC\"\n )\n end",
"def rate\n\t\t# retrieve user with specified ID and rate him/her \n @user = User.find(params[:id])\n @user.rate(params[:stars], current_user, params[:dimension])\n\n\t\t# automatically display the new rating\n render :update do |page|\n page.replace_html @user.wrapper_dom_id(params), ratings_for(@user, params.merge(:wrap => false))\n page.visual_effect :highlight, @user.wrapper_dom_id(params)\n end\n end",
"def users_rating\n @rating = Rating.find(params[:id])\n redirect_to skate_spot_path(@skate_spot) unless @rating.user_id == current_user.id\n end",
"def rating(user_id, movie_id)\n\t\t@all_users[user_id].rating movie_id\n\tend",
"def current_rating(user)\n rating = ratings.find_by(user_id: user.id)\n rating ? rating.value : 0\n end",
"def rated_by?(user_id, opts = {})\n ratings.exists?(:user_id => user_id, :conditions => opts)\n end",
"def rating_by(user)\n user_rating = rating && rating.user_ratings.find_by_user_id(user.id)\n user_rating ? user_rating.score : nil\n end",
"def rate_comment\n render nothing: true\n comment = Comment.find(params[:id])\n\n if(!comment.user_ratings.include? current_user.id)\n comment.user_ratings.push(current_user.id)\n comment.save\n else\n return redirect_to_back(root_path)\n end\n\n end",
"def rate_post\n render nothing: true\n\n post = Post.find(params[:id])\n\n assert(@post.kind_of?(Post))\n\n if not post.user_ratings.include? current_user.id\n post.user_ratings.push(current_user.id)\n post.save\n else\n redirect_to_back(root_path)\n end\n end",
"def rated_by?(user)\n rating && rating.user_ratings.exists?(:user_id => user)\n end",
"def rating(u, m)\n @user_list[u].rating(m)\n end",
"def rate_student\n AcceptedTutorRequest.where('student_rating IS NULL')\n .where('id = ?', params[:id])\n .update(params[:id], student_rating: params[:student_rating])\n head :ok\n end",
"def lesson_rating_for(lesson, user, *args)\n if user == lesson.instructor || !lesson.owned_by?(user) || lesson.entitled_by_groups(current_user)\n ratings_for(lesson, :static)\n else\n ratings_for(lesson)\n end\n end",
"def rated_by_current_user?(user)\n self.appearance_ratings.exists?(:user_id => user)\n end",
"def rated_by?(user)\n ratings.where(user_id: user.id).exist?\n end",
"def user_bulk_updated_ratings _user, query\n data = {\n category: 'Ratings',\n action: 'Bulk Updated Query Ratings',\n label: query.query_text,\n value: nil,\n bounce: false,\n }\n\n create_event data\n end",
"def rating (user, movie)\n\t\tif @train_data.has_key?(user) && @train_data[user].return_rating(movie)\n\t\t\treturn @train_data[user].return_rating(movie)\n\t\telse\n\t\t\treturn 0\n\t\tend\n\tend",
"def rating\n # review = Review.where(user_id: user.id, video_id: video.id).first\n #review = Review.find_by(user_id: user.id, video_id: video.id)\n review.rating if review\n end",
"def rate(stars, user, dirichlet_method=false)\n\n if can_rate? user\n rates.create! do |r|\n r.stars = stars\n r.rater = user\n end\n if dirichlet_method\n update_rate_average_dirichlet(stars)\n else\n update_rate_average(stars)\n end\n else\n raise 'User has already rated.'\n end\n end",
"def rated_by_user?(user)\n rtn = false\n if user\n self.ratings.each { |b|\n rtn = true if user.id == b.user_id\n }\n end\n rtn\n end",
"def show\n @movie = Movie.find(params[:id])\n @current_users_rating ||= @movie.ratings.where(user: current_user).pick(:rating)\n \n if @movie.ratings.any?\n @average_rating = @movie.ratings.average(:rating).round(2) \n @ratings_count = @movie.ratings.count(:rating)\n end\n end",
"def show\r\n rating = Rating.where(rater_id: current_user.id, ratee_id: params[:id]).first\r\n render json: rating\r\n end",
"def getAvgUserStarRating(u)\n return (getAvgUserNumberRating(u) != \"None\") ? reviewRating(getAvgUserNumberRating(u)) : \"No ratings\".html_safe\n end",
"def rating_params\n params.require(:rating).permit(:user_id, :rate, :answer_id)\n end",
"def rate\n @story = Story.find(params[:id])\n if @story.rate_for_user(params[:rate], current_user)\n respond_to do |format|\n format.html { redirect_to(story_url(@story), :notice => 'Story was rated.') }\n format.xml { head :ok }\n end\n else\n respond_to do |format|\n format.html { redirect_to(story_url(@story), :notice => 'You have already rated.') }\n format.xml { head :ok }\n end\n end\n end",
"def get_ratings\n begin\n plate_no = params[:plate_no]\n taxi = Taxi.find_by!(plate_no: plate_no)\n if params.has_key? :last_timestamp\n #convert unix time to datetime object\n last_timestamp = Time.at(params[:last_timestamp].to_i).to_datetime\n\n rates = taxi.rates.where(\"updated_at < ?\", last_timestamp).order(\"updated_at DESC\").limit(10)\n else\n rates = taxi.rates.order(\"updated_at DESC\").limit(10)\n end\n\n rates = rates.map do |rate|\n {comment:rate.comment,\n timestamp:rate.updated_at.to_i,\n rating: rate.rating}\n end\n\n render json:{success:true, data:rates}\n rescue Exception => e\n render json:{success:false, message: e.to_s}\n end\n end",
"def rates_by\n recommendable_likes.map(&:user_id) + recommendable_dislikes.map(&:user_id)\n end",
"def update_rating\n @rating = params[:value]\n @rated_user = params[:rated_user]\n @previous_rating = Rating.find_by rated_user_id: @rated_user, rating_user_id: @current_user.id\n if @previous_rating.blank?\n Rating.create(rated_user_id: @rated_user, rating_user_id: @current_user.id, value: @rating)\n else\n @previous_rating.value = @rating\n @previous_rating.save\n end\n render nothing: true, status: :ok and return\n end",
"def index\n @user = User.find(params[:uid])\n @reviews = @reviews.where(user_id: @user.id).where(anonymous: false)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end",
"def index\n unless (logged_in? && authorized?)\n redirect_back_or_default('/')\n return\n end\n @ratings = Rating.find(:all, :conditions => {:pending => true})\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ratings }\n end\n end",
"def rated_by_user?(user)\n rtn = false\n if user\n self.ratings.each { |b|\n rtn = true if (user.id == b.rater_id && b.rater_type == \"User\")\n }\n end\n rtn\n end",
"def add_rating(user_id, rating, timestamp)\n @user_ratings << UserRating.new(user_id, rating, timestamp)\n @sum_ratings = nil\n end",
"def recommend_for_user(user,opts={})\n o = slope_one_options\n q = %Q{\n SELECT a.*\n FROM #{o[:resource_table]} a, (#{frequency_matrix}) f\n JOIN #{o[:rating_table]} r1 ON r1.#{o[:resource_key]} = f.target_id\n LEFT JOIN #{o[:rating_table]} r2 ON r2.#{o[:resource_key]} = f.source_id AND r2.#{o[:rater_key]} = r1.#{o[:rater_key]}\n WHERE r1.#{o[:rater_key]} = ?\n AND f.frequency > 0 \n AND a.id = f.source_id\n #{\"AND r2.#{o[:resource_key]} IS NULL\" if opts[:exclusive]}\n GROUP BY f.source_id, a.id\n ORDER BY ( SUM(f.difference + f.frequency * r1.#{o[:rating_property]}) / SUM(f.frequency) ) DESC LIMIT ?;\n }\n find_by_sql [q, user.id, opts[:limit] || 20]\n end",
"def ratings_ranking(*args)\n @client.get \"#{@path}/ratings/ranking\", Hash[*args]\n end",
"def getUserStarRating(u, e)\n return (getUserRating(u, e) != \"None\") ? reviewRating(getUserRating(u, e)) : \"None\".html_safe\n end",
"def rate_by(user, dimension = nil)\n filter = \"find_by_#{self.class.user_class_name}_id\"\n rates(dimension).send filter, user\n end",
"def show\n redirect_to root_path and return\n\n @advertisement = Advertisement.find(params[:id])\n\n if current_user\n @user_rating = @advertisement.user_rating(current_user.id).try(:value)\n @user_rated = @user_rating.present?\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advertisement }\n end\n end",
"def rateable_by?(user)\n self.user.rateable_by?(user)\n end",
"def rateable_by?(user)\n self.user.rateable_by?(user)\n end",
"def user_rating\n document[\"statistics\"][\"userRating\"] rescue nil\n end",
"def rating_params\n params.require(:rating).permit(:rating, :user_id, :post_id)\n end",
"def rate(access_token:, params: {})\n ride_id = require_ride_id(params)\n resp = connection(access_token).put do |req|\n req.url \"/#{Api::VERSION}/rides/#{ride_id}/rating\"\n req.body = params\n end\n handle_response(resp)\n end",
"def _get_selected_ratings\n if !params[:ratings].nil?\n return params[:ratings]\n end\n if !session[:ratings].nil?\n @redirect_required = true\n ratings = session[:ratings]\n session.delete(:ratings)\n ratings\n end\n end",
"def rated_users\n User.where(user_id: ratings.pluck(:user_id))\n end",
"def index\n if params[:show_only]\n @movies = current_user.ratings.where(value: params[:show_only]).map{|r| r.movie}\n else\n @movies = Movie.all\n end\n end",
"def rating(user, movie)\n\t\tif @user_info[user].has_key?(movie)\n\t\t\treturn @user_info[user][movie]\n\t\telse\n\t\t\treturn 0\n\t\tend\n\tend",
"def show\n @myRating= Rating.find_by_wine_id_and_user_id(@wine.id,current_user.id);\n @myRating= Rating.new(user_id: current_user.id) if @myRating.nil?\n \n User.all.each do |i|\n if(! @wine.ratings.any?{|r| r.user_id==i.id})\n curr= Rating.find_by_wine_id_and_user_id(params[:wine_id],current_user.id);\n if(curr.nil?)\n curr= Rating.new()\n curr[:wine_id]= params[@wine.id]\n curr[:user_id]= i.id\n end\n \n @wine.ratings.push(curr)\n end\n end\n \n end",
"def checked_ratings\n if params[:ratings]\n params[:ratings].keys\n else\n @all_ratings\n end\n end",
"def add_rating(value, user)\n current_rating = Rating.find_by(rateable: self, user: user)\n if current_rating\n current_rating.update(value: value)\n else\n ratings.create(value: value, user: user)\n end\n end",
"def show\n food = FoodStore.find(params[:id])\n ratings = User.where(food_store:food)\n render json: {status: 'SUCCESS' , message:'Saved User' , data:ratings},status: :ok\n end",
"def show\n @rating = UserRating.where(movie_id: @movie.id).average(:rating)\n if @rating\n @rating = @rating.round(1)\n else\n @rating = 0\n end\n end",
"def rates_by\n likes.map(&:user_id) + dislikes.map(&:user_id)\n end",
"def rates_by\n likes.map(&:user_id) + dislikes.map(&:user_id)\n end",
"def user_likes\n user = User.find(params[:user_id])\n likes = user.likes\n render json: likes\n\nend",
"def getUserRating(u, e)\n if !hasReviewed(u, e)\n return \"None\"\n else\n return Event.find_by(id: e).reviews.find_by(user_id: u).rating\n end\n end",
"def rating_params\n params.require(:rating).permit(:rank, :fragrance_id, :user_id)\n end",
"def get_ratings\n return @trips.inject(0) do |sum, trip|\n trip.is_in_progress? ? sum + 0 : sum + trip.rating\n end\n end",
"def show_rating(opts={})\r\n opts[:output] = 'json'\r\n opts[:callback] = 'callback'\r\n Yahoo::Request.get(\"http://auctions.yahooapis.jp/AuctionWebService/V1/ShowRating\", Yahoo::Api.merge(opts))\r\n end",
"def ratings_query\n super\n end",
"def user_rating(book_id)\n user_rating = Rating.where(\"book_id = ? AND user_id = ?\",book_id,current_user.id)\n if user_rating.empty?\n return 0\n end\n return user_rating[0].stars\n end",
"def get_rate(id:)\n @client.http_get(\"/#{@resource}/#{id}/rate\")\n end",
"def find_rated_by(user)\n find_statement(:user_id, user.id)\n end",
"def rating_params\n params[:rating]\n end",
"def rating\n response[\"rating\"]\n end",
"def update\n if logged_in?\n @user = current_user\n @rating = Rating.where(user_id: @user.id, movie_id: params[:movie_id]).first\n respond_to do |format|\n if @rating.update(user_id: @user.id, movie_id: params[:movie_id], rating: params[:rating])\n format.json { render json: @rating }\n else\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n end\n else\n format.json { head :no_content }\n end\n end",
"def recommendations\n unless params[:user_id].present?\n render json: { response: 'User id not present' }, status: :bad_request\n end\n\n user = User.find_by_id(params[:user_id])\n recommendations = []\n\n user.movies.each do |movie|\n recommendations_for_movie = Tmdb::Movie.recommendations(movie[:id])\n recommendations_for_movie[:results].each do |recommendation|\n recommendations << recommendation\n end\n end\n\n render json: { response: recommendations }, status: :ok\n end",
"def user_rated?(*user_ids)\n users = @user_ratings.map(&:user_id)\n user_ids.map { |user_id| users.include?(user_id) }.all?\n end",
"def rate(value, ip_address, user_id)\n if can_rate? ip_address\n UserStore.create(:user_id => user_id, :store_id => self.store_id, :role => 'author') if self.store.user_stores.where(:user_id => user_id).blank?\n r = ratings.find_or_initialize_by_user_id(user_id)\n r.value = value\n r.ip_address = ip_address\n r.save!\n else\n errors.add :base, I18n.t(\"already_rated\")\n false\n end\n end",
"def player_ratings\n Player.ratings(galaxy_id, Player.where(alliance_id: id))\n end",
"def rate\n @route = Route.find(params[:id])\n @route.rate_all_dimensions(params[:rating], current_user)\n\n render :update do |page|\n page.hide \"rate\"\n page.replace \"rates\", :partial => \"shared/rates\", :locals => {:rated => @route}\n page.show \"rates\"\n page.visual_effect :highlight, \"rates\"\n page << javascript_rating(@route, params[:rating])\n end\n end",
"def rating(user_id, movie_id)\n training_set.usr_map[user_id][movie_id].nil? ? 0 : training_set.usr_map[user_id][movie_id]\n end",
"def rate\n @box = Box.find(params[:id])\n raise CanCan::AccessDenied unless @box.ordered_by?(current_user)\n @box.update_attributes(params[:box])\n\n flash[:alert] = \"You must provide a rating between 1 and 5\" if params[:box][:rating].blank?\n respond_to do |format|\n if @box.save\n format.html { redirect_to @box }\n format.json { render json: @box }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @box.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n if params[:yelp_rating] && params[:google_rating] && params[:foursquare_rating]\n @ratings = {:yelp_rating => params[:yelp_rating], :foursquare_rating => params[:foursquare_rating], :google_rating => params[:google_rating], :weighted_rating => params[:weighted_rating]}\n end\n @social = {:yelp_id => params[:yelp_id], :foursquare_id => params[:foursquare_id], :google_id => params[:google_id]}\n if params[:google_id]\n @google_place = Restaurant.get_place_from_google params[:google_id]\n @google_reviews = @google_place.reviews\n @google_images = []\n @google_reviews.each do |review|\n str = review.author_url.to_s\n google_plus_id = str[24..-1]\n request = \"https://www.googleapis.com/plus/v1/people/\" + \"#{google_plus_id}\" + \"?fields=image&key=AIzaSyB8fUZUPNYIWKwz6Nss-Hu7J_2VUjFSOWA\"\n response = HTTParty.get(request)\n result = JSON.parse(response.body)\n\n if result[\"image\"]\n @google_images << result[\"image\"][\"url\"]\n else\n @google_images << nil\n end\n end\n\n end\n @yelp_reviews = Restaurant.get_restaurant_reviews_from_yelp params[:yelp_id]\n @foursquare_tips = Restaurant.get_venue_tips_from_foursquare params[:foursquare_id]\n \n @friend_recommendations = Recommendation.get_friend_recommedation_by_restaurant(params[:google_id], @registered_friends)\n end",
"def show\n # @todo comment this out and replace with proper user 'deleted' flag\n if User.where(id: @book.user_id.to_s.to_i).exists?(conditions = :none)\n @book_user = User.find(@book.user_id)\n else\n @book_user = User.find_by(username: 'removedUser')\n end\n @rating = Rate.where(rateable_id: @book.id)\n unless @rating.empty?\n @sum = 0\n @rating.each do |rate|\n @sum += rate.stars_num\n end\n @final_rating = @sum / @rating.length\n @remaining_stars = 5 - @final_rating\n end\n end",
"def rating\n rating_calculator.rate(raters)\n end",
"def rate\n @feature_value = FeatureValue.find(params[:id])\n @feature_value.rate(params[:stars], current_user, params[:dimension])\n # ajaxful-rating-user-featurevalue-255\n id = \"ajaxful-rating-#{!params[:dimension].blank? ? \"#{params[:dimension]}-\" : ''}featurevalue-#{@feature_value.id}\" \n render :update do |page|\n page.replace(id, ratings_for(@feature_value, current_user, :dimension => params[:dimension], :small_stars => true, \n\t\t\t\t:remote_options => {:method => :post, :url => rate_feature_value_path(@feature_value.id)}))\n page.visual_effect :highlight, id\n end\n end",
"def create_ratyrate\n\t\tself.rate(self.rating, self.user, \"rating\", false)\n\tend",
"def requests_with_reviews_for_user(user)\n Request.with_open_reviews_for(by_user: user, target_project: root_project_name)\n end",
"def voted_on?(user)\n return !self.ratings.find_by_user_id(user.id).nil?\n end",
"def rate\n clas = params[:rating_for_class]\n @rate = clas == \"discussion\" ? Discussion.find(params[:id]) : (clas == 'comment' ? Comment.find(params[:id]) : Picture.find(params[:id]))\n @rate.rate_it(params[:score], current_user)\n respond_to do |format|\n format.js\n end\n end",
"def user_question_rate_params\n params[:user_question_rate]\n end",
"def num_ratings \n 5\n end",
"def get_rating(participant_id, is_backfill=false)\n response = request(:get_rating, veteranId: participant_id, isBackfill: is_backfill)\n response.body[:get_rating_response]\n end",
"def user_average_rating(user)\n #av = promedio (avarage), counter = contador(para calcular el total de reviews realizada)\n av, counter = 0.0, 0.0\n \n Review.where(user_id: user.id).each_with_index do |review, i|\n if review.rating\n av = av + review.rating\n counter = counter + 1.0\n end\n end\n\n av / counter\n end",
"def rating_params\n\t\tparams.require(:rating).permit(:ratable, :score, :user)\n\tend",
"def rating u, m\n \tuser_ratings = @userdata[u.to_s.to_sym]\n \tflag = 0\n \tuser_ratings.each do |id, rating|\n \t\tif m.to_s == id\n \t\t\t#puts \"User \" + u.to_s + \" rated movie \" + id + \" with a \" + rating.to_s\n \t\t\tflag = 1\n \t\t\treturn rating\n \t\tend\n \tend\n \tif flag == 0\n \t\treturn 0\n \tend\n end",
"def rating(user_id, movie_id) \n movies = @user_hash[user_id]\n movies.each do |movie|\n if movie[movie_id]\n return movie[movie_id]\n end\n end\n return 0\n end",
"def rate\n @album = Album.find(params[:id])\n authorize! :rate, @album\n @album_rating = AlbumRating.new({\n :user_id => current_user.id,\n :album_id => params[:id],\n :rating => params[:rating]\n })\n\n if @album_rating.save\n flash[:notice] = 'Thanks for rating'\n else\n flash[:alert] = \"Could not save your rating. You may have rated this already!\"\n end\n\n redirect_to :back\n end",
"def ratings_company\n @user = User.find_by(:id => params[:company_id])\n if @user.rating == nil or @user.rating == -1\n @message=\"La companyia no ha estat valorada\"\n render json: @message\n else\n render json: @user.rating.to_json\n end\n end"
] | [
"0.72761905",
"0.70632446",
"0.70621264",
"0.6862334",
"0.6861646",
"0.68398154",
"0.6802701",
"0.67433923",
"0.67391413",
"0.6738941",
"0.67291087",
"0.6636356",
"0.6628182",
"0.6609422",
"0.65861154",
"0.6426611",
"0.6391706",
"0.6390171",
"0.63349617",
"0.6309685",
"0.6287645",
"0.6279449",
"0.62769747",
"0.6251069",
"0.6232218",
"0.6216604",
"0.6213331",
"0.6192437",
"0.61923105",
"0.61888164",
"0.6175168",
"0.6147173",
"0.6146195",
"0.614447",
"0.61441624",
"0.6131492",
"0.6066199",
"0.60104996",
"0.60096216",
"0.6002244",
"0.6000316",
"0.59975934",
"0.59796226",
"0.5972006",
"0.59607923",
"0.5953746",
"0.59317267",
"0.59254295",
"0.5919488",
"0.5919488",
"0.5898012",
"0.5865549",
"0.586054",
"0.58570683",
"0.5849542",
"0.58358973",
"0.58346826",
"0.58286595",
"0.58211654",
"0.58156264",
"0.5815548",
"0.58114487",
"0.5811055",
"0.5811055",
"0.57978463",
"0.5775428",
"0.57656604",
"0.57475275",
"0.5735443",
"0.5730492",
"0.5726918",
"0.57199293",
"0.57191724",
"0.5716467",
"0.57115746",
"0.57095486",
"0.57071626",
"0.5704415",
"0.5685271",
"0.5676751",
"0.56738234",
"0.56719583",
"0.56701857",
"0.566649",
"0.56638676",
"0.5663782",
"0.5663724",
"0.5658138",
"0.5652124",
"0.56515676",
"0.56469506",
"0.5645398",
"0.5640401",
"0.5637252",
"0.5632186",
"0.5632079",
"0.5626918",
"0.5622366",
"0.56211287",
"0.5620874"
] | 0.7492 | 0 |
Modify the sku stock with the associated stock level adjustment value | def adjust_sku_stock
if Store.positive?(self.adjustment)
self.stock_total = self.sku.stock + self.adjustment
self.sku.update_column(:stock, self.sku.stock + self.adjustment)
else
self.stock_total = self.sku.stock - self.adjustment.abs
self.sku.update_column(:stock, self.sku.stock - self.adjustment.abs)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stock_adjustment\n if Store.positive?(self.adjustment)\n self.stock_total = self.sku.stock_adjustments.first.stock_total + self.adjustment\n self.sku.update_column(:stock, self.sku.stock + self.adjustment)\n else\n self.stock_total = self.sku.stock_adjustments.first.stock_total - self.adjustment.abs\n self.sku.update_column(:stock, self.sku.stock - self.adjustment.abs)\n end\n end",
"def reduce_stock(amount)\n self.stock = self.stock - amount\n end",
"def update_stock_levels\n case self.quantity\n when 0...10\n @stock_level = '1 - Reorder Stock!'\n when 10...30\n @stock_level = '2 - Low'\n when 30...60\n @stock_level = '3 - Medium'\n else\n @stock_level = '4 - High'\n end\n self.update()\n return @stock_level[4..-1]\n end",
"def stock\n self.stock_level_adjustments.sum(:adjustment)\n end",
"def update_product\n if inbound_order? || quantity_adjustment?\n product.update(stock: product.stock + quantity)\n else outbound_order?\n product.update(stock: product.stock - quantity)\n end\n end",
"def change_stock_of(commodity, change)\n @stock[commodity_id(commodity)] += change\n end",
"def update_stock\n\t\tincrease_stock unless new_record?\n\t\tyield\n\t\tdecrease_stock\n\tend",
"def normalize_stock\n self.stock = 0 if self.stock.nil?\n end",
"def on_hand=(new_level)\n if Spree::Config[:track_inventory_levels]\n new_level = new_level.to_i\n\n # increase Inventory when\n if new_level > on_hand\n # fill backordered orders before creating new units\n inventory_units.with_state('backordered').slice(0, new_level).each do |iu|\n iu.fill_backorder\n new_level -= 1\n end\n end\n\n self.count_on_hand = new_level\n else\n raise 'Cannot set on_hand value when Spree::Config[:track_inventory_levels] is false'\n end\n end",
"def change_inventory\n order_item_obj = OrderItem.last\n product_id = order_item_obj.product_id\n inventory_of_ordered_product = InventoryStock.where(product_id:product_id)\n quantity_in_inventory = inventory_of_ordered_product[0].quantity\n quantity_in_ordered_item = order_item_obj.quantity\n updated_quantity_in_inventory = quantity_in_inventory.to_i-quantity_in_ordered_item.to_i\n InventoryStock.where(product_id:product_id).update(quantity: updated_quantity_in_inventory)\n end",
"def manage_stock_settings\n smp = Spree::SellerMarketPlace.find(params[:seller_market_place_stock_config_details].keys.first)\n seller = smp.seller\n seller.update_attributes(:stock_config_type => STOCKCONFIG.key(params[:seller][:stock_config_type]).to_i)\n if !params[\"apply_to_all\"].nil? && params[\"apply_to_all\"] == \"true\"\n inf_variant_ids = Spree::QuantityInflation.pluck(:variant_id)\n var_ids = Spree::Variant.where(:id=>inf_variant_ids).pluck(:product_id)\n # products = inf_variant_ids.present? ? (seller.products.where(\"is_approved=true AND kit_id IS NULL\").where(\"id NOT IN (?)\", var_ids)) : (seller.products.where(\"is_approved=true AND kit_id IS NULL\"))\n products = inf_variant_ids.present? ? (seller.products.where(\"is_approved=true\").where(\"id NOT IN (?)\", var_ids)) : (seller.products.where(\"is_approved=true\"))\n products.each do |product|\n product.update_column(:stock_config_type, 0)\n end \n end\n \n if params[:seller][:stock_config_type] == \"percentage_quantity\"\n params[:seller_market_place_stock_config_details].each do |key, value|\n smp = Spree::SellerMarketPlace.find(key)\n smp.update_attributes(:stock_config_details=>value)\n if !params[\"apply_to_all\"].nil? && params[\"apply_to_all\"] == \"true\"\n smpps = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=?\", smp.seller_id, smp.market_place_id)\n smpps.update_all(:stock_config_details=>value)\n end\n end\n end\n res = view_context.update_stock_for_seller(seller, false)\n if res == \"fail\"\n redirect_to admin_seller_seller_market_places_path(seller.id), :error => \"Stock can not be updated properly\"\n else\n redirect_to admin_seller_seller_market_places_path(seller.id), :notice => \"Stock setting updated seccessfully\"\n end\n end",
"def update_stock\n for charge in self.charges\n charge.item.update_attribute(:stock, (charge.item.stock.to_i-1)) \n end\n end",
"def inc_stock\n\t\t@stock += 1\n\tend",
"def update_stock_for_seller(seller, fetch_fba_qty)\n stock_values = {}\n inf_variant_ids = Spree::QuantityInflation.pluck(:variant_id)\n var_ids = Spree::Variant.where(:id=>inf_variant_ids).pluck(:product_id)\n # products = inf_variant_ids.present? ? (seller.products.where(\"is_approved=true AND kit_id IS NULL\").where(\"id NOT IN (?)\", var_ids)) : (seller.products.where(\"is_approved=true AND kit_id IS NULL\"))\n products = inf_variant_ids.present? ? (seller.products.where(\"is_approved=true\").where(\"id NOT IN (?)\", var_ids)) : (seller.products.where(\"is_approved=true\"))\n products.each do |product|\n variants = []\n variants << (product.variants.present? ? product.variants : product.master)\n variants = variants.flatten\n type = STOCKCONFIG[product.stock_config_type] == \"default\" ? STOCKCONFIG[seller.stock_config_type] : STOCKCONFIG[product.stock_config_type]\n smps = seller.seller_market_places.where(:is_active=>true)\n mps = seller.market_places.where(\"spree_market_places.id IN (?)\", smps.map(&:market_place_id))\n variants.each do |variant|\n begin\n Spree::Variant.fetch_qty_from_fba(smps.first,variant) if fetch_fba_qty\n variant = variant.reload\n stock_products = variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", product.sellers_market_places_products.where(\"market_place_id IN (?)\",smps.map(&:market_place_id)).map(&:id))\n if stock_products.present?\n case type\n when \"fixed_quantity\"\n stock_values.merge!(variant.id=>Spree::StockProduct.fixed_quantity_setting(stock_products, variant, mps)) if !fetch_fba_qty\n when \"percentage_quantity\"\n stock_values.merge!(variant.id=>Spree::StockProduct.fixed_quantity_setting(stock_products, variant, mps))\n #stock_values.merge!(variant.id=>Spree::StockProduct.percentage_quantity_setting(stock_products, variant, mps))\n when \"flat_quantity\"\n stock_values.merge!(variant.id=>Spree::StockProduct.flat_quantity_setting(stock_products, variant, mps))\n end # end of case\n end\n rescue Exception => e\n end\n end # end of variant loop\n end # end of product loop\n return update_stock_market_places(stock_values)\n end",
"def create_stock_level\n StockLevel.create(description: 'Initial stock', adjustment: stock, sku_id: id)\n end",
"def update_sell_in\n degrades_sell_in # degrades sell_in by 1\n item.quality = MIN_QUALITY if item.sell_in.negative? # drops to 0 after the concert\n end",
"def apply_default_stock_setting\n self.product.update_attributes(:stock_config_type=>0)\n smp = Spree::SellerMarketPlace.where(\"seller_id=? AND market_place_id=?\",self.seller_id, self.market_place_id)\n self.update_attributes(:stock_config_details=>smp.first.stock_config_details) if smp.present?\n end",
"def standard_update\n lambda do\n update_sell_date\n @quality -= (@sell_in >= 0 ? 1 : 2)\n quality_limits\n end\n end",
"def save_inventory_adjustment_vend(response, quantity)\n location_id = response['inventory_level']['location_id']\n shopify_inventory = retail_shopify.shopify_inventories.find_by(location: location_id)\n new_inventory = response['inventory_level']['available']\n\n InventoryUpdate.create(\n vend_qty: vend_datum.sf_inventory,\n prior_qty: shopify_inventory.inventory,\n adjustment: quantity,\n product_id: id,\n new_qty: new_inventory\n )\n\n shopify_inventory.update_attribute(:inventory, new_inventory)\n end",
"def decrease_stock\n\t\t@stock -= 1\n\tend",
"def show\n @purchased_stock = PurchasedStock.find(params[:id])\n # update purchased_stock's value_in_stocks\n current_value_in_stocks = 0 \n if (@purchased_stock.total_qty > 0)\n new_value = ((YahooStock::Quote.new(:stock_symbols => [@purchased_stock.stock_code]).results(:to_array).output[0][1].to_f) * 100).to_i\n end\n @purchased_stock.value_in_stocks = new_value * @purchased_stock.total_qty\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @purchased_stock }\n end\n end",
"def show\n @purchased_stock = PurchasedStock.find(params[:id])\n # update purchased_stock's value_in_stocks\n current_value_in_stocks = 0 \n if (@purchased_stock.total_qty > 0)\n new_value = ((YahooStock::Quote.new(:stock_symbols => [@purchased_stock.stock_code]).results(:to_array).output[0][1].to_f) * 100).to_i\n end\n @purchased_stock.value_in_stocks = new_value * @purchased_stock.total_qty\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @purchased_stock }\n end\n end",
"def update_value(quantity)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# quantity == crypto value NOT USD\n\t\t# debugger\n\n\t\tif quantity > 0\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# BUY \n\t\t\tself.total_value = self.total_value + quantity\t\t\t# increment wallet value by quantity\n\t\telse \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# SELL\n\t\t\tself.total_value = self.total_value + quantity\t\t\t# quantity is Negative!! so adding, will decrement\n\t\tend\n\n\t\tsave!\n\tend",
"def update_product_qty\n @order = Spree::Order.find_by_id(params[:order_id])\n @line_item = Spree::LineItem.find_by_id(params[:line_item_id])\n request_to_update_qty = params[:quantity].to_i\n # code to find the order_total\n if @order.market_place.present?\n case @order.market_place.code\n when \"qoo10\"\n order_total = @order.market_place_details.present? ? @order.market_place_details[\"total\"] : @order.total\n when \"lazada\", 'zalora'\n order_total = @order.total\n end\n end\n if @line_item.present?\n prev_qty = @line_item.quantity.to_i\n final_qty = prev_qty - request_to_update_qty\n @variant = @line_item.variant\n @product = @variant.product if @variant.present?\n # code to update line item\n @line_item.update_column(:quantity, request_to_update_qty)\n @sellers_market_places_product = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=? AND product_id=?\", @order.seller_id, @order.market_place_id, @product.id).try(:first)\n if @sellers_market_places_product.present?\n @stock_product = Spree::StockProduct.where(\"sellers_market_places_product_id=? AND variant_id=?\", @sellers_market_places_product.id, @variant.id).try(:first)\n if @stock_product.present?\n @stock_product.update_attributes(:count_on_hand=>(@stock_product.count_on_hand + final_qty.to_i) >= 0 ? (@stock_product.count_on_hand + final_qty.to_i) : 0)\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity + final_qty.to_i) >= 0 ? (@variant.fba_quantity + final_qty.to_i) : 0) if [email protected]_inflations.present?\n msg = 'Admin/Orders Controller update_product_qty '\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n end\n end\n end\n # code to update order total after creating line item for order\n @order.update_column(:total, order_total)\n @order.reload\n line_items = @order.line_items\n respond_to do |format|\n format.html { render :partial=>\"modify_shipping\", :locals => { :line_items => line_items }}\n end\n end",
"def update_stock\n \tproduct = FileOperations.search_by_name(self)\n \tproduct = product[0].split(';')\n \tself.id = product[0]\n \tself.name = product[1]\n \tself.price = product[2]\n \tself.company = product[3]\n \tself.stock = product[4].to_i - 1\n \tFileOperations.update(self)\n end",
"def add_product_skus\n @order = Spree::Order.find_by_id(params[:order_id])\n @variant = Spree::Variant.find_by_id(params[:variant_id])\n @product = @variant.product\n requested_qty = params[:quantity]\n is_customer_pickup = @order.market_place_details.present? ? (@order.market_place_details[\"OrderType\"] == \"Pickup\" ? true : false) : false\n # code to find the order_total\n if @order.market_place.present?\n case @order.market_place.code\n when \"qoo10\"\n order_total = @order.market_place_details.present? ? @order.market_place_details[\"total\"] : @order.total\n when \"lazada\",'zalora'\n order_total = @order.total\n end\n end\n # code to create line item\n price = @variant.price.present? ? @variant.price : 0.0 \n @line_item = Spree::LineItem.create!(:variant_id=>@variant.id, :order_id=>@order.id, :quantity=>requested_qty, :price=>price, :currency=>@order.currency, :is_pick_at_store => is_customer_pickup)\n if @line_item.present?\n @sellers_market_places_product = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=? AND product_id=?\", @order.seller_id, @order.market_place_id, @product.id).try(:first)\n if @sellers_market_places_product.present?\n @stock_product = Spree::StockProduct.where(\"sellers_market_places_product_id=? AND variant_id=?\", @sellers_market_places_product.id, @variant.id).try(:first)\n if @stock_product.present?\n @stock_product.update_attributes(:count_on_hand=>(@stock_product.count_on_hand - requested_qty.to_i) >= 0 ? (@stock_product.count_on_hand - requested_qty.to_i) : 0)\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - requested_qty.to_i) >= 0 ? (@variant.fba_quantity - requested_qty.to_i) : 0) if [email protected]_inflations.present?\n msg = 'Admin/Orders Controller add_product_skus Line 182'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n else\n @stock_product = Spree::StockProduct.create!(:sellers_market_places_product_id=>@sellers_market_places_product.id, :variant_id=>@variant.id, :count_on_hand=>requested_qty.to_i, :virtual_out_of_stock=>false)\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - requested_qty.to_i) >= 0 ? (@variant.fba_quantity - requested_qty.to_i) : 0) if [email protected]_inflations.present?\n msg = 'Admin/Orders Controller add_product_skus Line 187'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n end\n end\n end\n # code to update order total after creating line item for order\n @order.update_column(:total, order_total)\n @order.reload\n line_items = @order.line_items\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => @order})\n respond_to do |format|\n format.html { render :partial=>\"modify_shipping\", :locals => { :line_items => line_items }}\n end\n end",
"def update\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n if @stock.update_attributes(params[:stock])\n PostLogger.info(\"Change position - Now: #{@stock.quantity} shares of #{@stock.symbol} in #{@stock.portfolio.user.name}'s - #{@stock.portfolio.name} Portfolio\")\n\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def return_item_to_stock(product_id)\n\t\tproduct = Product.find(product_id)\n\t\tproduct.stock += 1\n\t\tproduct.save\n\tend",
"def update_quant (olist, item, quant)\n olist[item] = quant\n olist\nend",
"def stock_minus(product, amount)\n product = Product.find(product)\n quantity = product.quantity\n quantity -= amount.to_i\n product.update(quantity: quantity)\n end",
"def purchase\n \t@stock -= 1\n end",
"def decrease_stock\n \t\tif @stock > 0\n \t\t\tthen @stock -= 1\n \t\telse \n \t\t\traise OutOfStockError, \"'#{@title}' is out of stock.\"\n \t\tend\n \tend",
"def update_object(object, name, price)\n object.item_variation_data.name = name\n object.item_variation_data.price_money.amount = (price.to_f * 100).to_i\n object\n end",
"def add_brand_stk(brand_hash, stock = 0)\n brand_hash[:stock] = brand_hash[:stock] + stock\nend",
"def update_status_on_inventory_change\n if self.inventory_changed?\n if self.inventory.zero?\n self.status = :out_of_stock\n else\n self.status = :in_stock\n end\n end\n end",
"def quick_update_stock(filename)\n ThinkingSphinx::Deltas.suspend :supply_item do\n @updates.each do |upd|\n si = @supplier.supply_items.where(:supplier_product_code => upd[0]).first\n unless si.nil?\n if si.update_attributes(:stock => upd[1]) == true\n supplier_logger.info(\"[#{DateTime.now.to_s}] Quick stock update: #{si.to_s} now #{si.stock}\")\n else\n supplier_logger.error(\"[#{DateTime.now.to_s}] Quick stock update failed: #{si.to_s}, errors: #{si.errors.full_messages}\")\n end\n end\n end\n end\n Product.update_price_and_stock # Sync available products to the now changed supply items\n end",
"def update_purchase_receival_stock_entry(purchase_receival_entry)\n self.quantity = stock_migration.quantity \n self.save \n \n stock_mutation = StockMutation.where(\n :stock_entry_id => self.id , \n :source_document_entry_id => stock_migration.id,\n :source_document_entry => stock_migration.class.to_s \n ).first \n stock_mutation.quantity = self.quantity \n stock_mutation.save \n end",
"def update_backstage (item)\n if item.sell_in < 11 && item.sell_in > 5\n update_quality_value(item, 2)\n elsif item.sell_in < 6 && item.sell_in > 0\n update_quality_value(item, 3)\n elsif item.sell_in > 0\n update_quality_value(item, 1)\n end\n end",
"def set_stock_of(commodity, stock)\n @stock[commodity_id(commodity)] = stock\n end",
"def price_adjustment \n price_adjustment_fixed / 100.0 \n end",
"def toggle_stock\n @item.toggle!(:stock)\n end",
"def decrease\n @offer.stock -= 1\n @offer.stock += 1 if [email protected]\n render \"stock_update\"\n end",
"def add_stock\n @item.stock += params[:stock].to_i\n @item.save\n flash[:success] = \"Stock updated\"\n redirect_back(fallback_location: root_path)\n end",
"def update_product_details\n\t\t\ttransferorderpricing = TransferOrderPricing.new\n\t\t\tcorporate = Corporate.find(self.corporate_id)\n\t\t\ttransferorderpricing = wholesale_price(self.product_list_id, corporate.state, corporate.commission_percent)\n\t\t\tself.update(stock_value: transferorderpricing.final_total)\n distributor_stock_ledger = DistributorStockLedger.find(self.id)\n\t\t\t #10001\tAdd Stock to Distributor\n\t\t\t #10002\tRemove Stock from Distributor\n\t if distributor_stock_ledger.product_list_id.present?\n\t #product list details from product master id\n\t product_list = ProductList.find(distributor_stock_ledger.product_list_id) #.joins(:product_variant).where(\"product_variants.activeid = 10000\")\n\t if product_list.present?\n\t #product list details from product master id\n\t #distributor_stock_ledger = DistributorStockLedger.find(self.id)\n\t distributor_stock_ledger.update(product_master_id: product_list.product_master_id,\n\t product_variant_id: product_list.product_variant_id,\n\t prod: product_list.extproductcode)\n\n\t\t\t\t\t\t\t message = update_product_stock_summary(distributor_stock_ledger.id)\n\n\t\t\t\t\t\t\tself.flash_notice = \"Ledger details updated with stock nos #{message}\"\n\t end\n\n\t elsif distributor_stock_ledger.type_id == 10000 #mis additions\n\t message = add_corporate_mis_balance(distributor_stock_ledger.corporate_id, distributor_stock_ledger.stock_value.to_f)\n\t\t\t\t\t\t\tself.flash_notice = \"Ledger #{message}\"\n\t # flash[:error] = \"Ledger details #{distributor_stock_ledger.type_id}\"\n\t\t\t \telsif distributor_stock_ledger.type_id == 10020 #mis removal\n\t\t\t\t message = \" \"\n\t message += remove_corporate_mis_balance(distributor_stock_ledger.corporate_id, distributor_stock_ledger.stock_value.to_f)\n\t\t\t\t\t\t\tself.flash_notice = \"Ledger #{message}\"\n\t end\n \t #end\n end",
"def update_product_cache_stock\n\t\t\tself.state_check_details.each do |scd|\n scd.update_product_cache_stock\n end\n\t\tend",
"def update\n @stock_adjustment = StockAdjustment.find(params[:id])\n\n respond_to do |format|\n if @stock_adjustment.update_attributes(params[:stock_adjustment])\n format.html { redirect_to(@stock_adjustment, :notice => 'Stock adjustment was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @stock_adjustment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def return_stock\n skus = Hash[sku_items.map {|i| [i.sku_id, i.quantity]}]\n Sku.return_stock!(skus)\n end",
"def update_value(quantity)\n if quantity > 0 # First If statement is for buying (if there are funds)\n self.total_value = self.total_value + quantity \n\n else # Else statement is for selling because quantity would be negative value \n self.total_value = self.total_value + quantity \n end\n\n save!\n end",
"def return\n \t@stock += 1\n end",
"def update_cart\n product = Product.find_by_cs_sku(params[:sku])\n item = ReservedItem.where('user_id = ? and product_id = ? and session_id = ?', current_user.id,\n product.id,\n session.id).first\n qty = BigDecimal.new(get_qty)\n\n if available?(product, item, qty)\n product.update_attribute(:qty, (product.qty + item.qty) - qty)\n item.update_attribute(:qty, qty)\n respond_with_format { @cart.update_item(params[:sku], get_qty) }\n else\n flash[:error] = 'Not enough item in inventory'\n respond_with_format\n end\n end",
"def get_from_product_stock(product_id, quantity_to_add)\n product = Product.find_by(id: product_id)\n if (product.stock >= quantity_to_add)\n product.stock -= quantity_to_add\n self.quantity += quantity_to_add\n\n if self.valid? && product.valid?\n self.save\n product.save\n return self\n end\n end\n end",
"def update\n @product_stock = ProductStock.find(params[:id])\n\n respond_to do |format|\n ProductStock.transaction do\n if @product_stock.update_stock_history(params[:product_stock], params[:description]) &&\n @product_stock.triggered_update_attributes(params[:product_stock])\n format.html { redirect_to product_product_stocks_path(@product_stock.product), :notice => 'Product stock was successfully updated.' }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end\n end",
"def update_stock_on_update\n # What has changed?\n product_has_changed = product_changed? rescue false\n store_has_changed = store_changed? rescue false\n quantity_has_changed = quantity_changed? rescue false\n # Previous values\n product_prev = product_was rescue product\n store_prev = store_was rescue store\n quantity_prev = quantity_was rescue quantity\n # Stock\n if product_has_changed || store_has_changed\n # Current Stock\n if !update_stock(product, store, quantity, true)\n return false\n end\n # Roll back Previous Stock\n if !update_stock(product_prev, store_prev, quantity_prev, false)\n return false\n end\n elsif quantity_has_changed\n # Current Stock\n if !update_stock(product, store, quantity - quantity_prev, true)\n return false\n end\n end\n true\n end",
"def receive_loudly quantity_to_receive\n \n return if quantity_to_receive < 1\n \n new_level = quantity_to_receive\n \n if self.variant.on_hand > 0\n new_level += self.variant.on_hand\n end\n \n self.variant.on_hand = new_level\n self.variant.save\n \n end",
"def deduct_quantity\n line_items.each do |i|\n i.product.current_stock -= i.quantity\n i.product.save\n end\n end",
"def update_quant(item, quant)\n\t$grocery_list.store(item, quant)\n\tp \"You updated #{item} number to #{quant}.\"\nend",
"def update_stock(_product, _store, _quantity, _is_new)\n if _product.product_type.id != 2\n _stock = Stock.find_by_product_and_store(_product, _store)\n if !_stock.nil?\n _stock.current = _is_new ? _stock.current - _quantity : _stock.current + _quantity\n if !_stock.save\n return false\n end\n end\n end\n true\n end",
"def update_quant(current_list, item, quantity)\n current_list[item] = quantity\n current_list\nend",
"def set_stock\n if params[:id]\n @stock = Stock.find(params[:id])\n elsif params[:ticker_symbol]\n @stock = Stock.find_by_ticker_symbol(params[:ticker_symbol])\n end\n @stock.update_price if @stock and Time.now - @stock.updated_at > 1.minute \n end",
"def stock(size_id = nil)\n if size_id.present?\n return stock_level_adjustments.where(size_id: size_id).sum(:adjustment)\n end\n\n return stock_level_adjustments.sum(:adjustment)\n end",
"def push\n API::SOAP::CatalogInventory::StockItem.update(self.product);\n end",
"def change_delivery_drink_quantity\n # get data to add/update\n @data = params[:id]\n @data_split = @data.split(\"-\")\n @add_or_subtract = @data_split[0]\n @user_delivery_id = @data_split[1]\n \n # get User Delivery info\n @account = Account.find_by_id(current_user.account_id)\n @user_subscription = UserSubscriptionn.where(account_id: current_user.account_id, currently_active: true).first\n @user_delivery_info = UserDelivery.find_by_id(@user_delivery_id)\n @delivery = Delivery.find_by_id(@user_delivery_info.delivery_id)\n @inventory = Inventory.find_by_id(@user_delivery_info.inventory_id)\n \n # adjust drink quantity, price and inventory\n @original_quantity = @user_delivery_info.quantity\n @drink_price = @user_delivery_info.inventory. + @user_subscription.pricing_model\n @current_inventory_reserved = @inventory.reserved\n if @add_or_subtract == \"add\"\n # set new quantity\n @new_quantity = @original_quantity + 1\n \n #set new price totals\n @original_subtotal = @delivery.subtotal\n @new_subtotal = @original_subtotal + @drink_price\n @new_sales_tax = @new_subtotal * @account.delivery_zone.excise_tax\n @new_total_price = @new_subtotal + @new_sales_tax\n \n # update reserved inventory \n @new_inventory_reserved = @current_inventory_reserved + 1\n @inventory.update(reserved: @new_inventory_reserved)\n\n # update user delivery info\n @user_delivery_info.update(quantity: @new_quantity)\n \n else\n # set new quantity\n @new_quantity = @original_quantity - 1\n \n #set new price totals\n @original_subtotal = @delivery.subtotal\n @new_subtotal = @original_subtotal - @drink_price\n @new_sales_tax = @new_subtotal * @account.delivery_zone.excise_tax\n @new_total_price = @new_subtotal + @new_sales_tax\n \n # update reserved inventory \n @new_inventory_reserved = @current_inventory_reserved - 1\n @inventory.update(reserved: @new_inventory_reserved)\n \n # update user delivery info\n @user_delivery_info.update(quantity: @new_quantity)\n end\n \n # update delivery info and note a confirmation email should be sent\n @delivery.update(subtotal: @new_subtotal, sales_tax: @new_sales_tax, total_drink_price: @new_total_price, delivery_change_confirmation: false)\n \n # add change to the customer_delivery_changes table\n @customer_delivery_change = CustomerDeliveryChange.where(user_delivery_id: @user_delivery_id).first\n if !@customer_delivery_change.blank?\n @customer_delivery_change.update(new_quantity: @new_quantity, change_noted: false)\n else\n @new_customer_delivery_change = CustomerDeliveryChange.new(user_id: current_user.id, \n delivery_id: @user_delivery_info.delivery_id,\n user_delivery_id: @user_delivery_id,\n beer_id: @user_delivery_info.beer_id,\n original_quantity: @original_quantity,\n new_quantity: @new_quantity,\n change_noted: false)\n @new_customer_delivery_change.save!\n end\n \n # set new delivery details and delivery info\n @next_delivery = UserDelivery.where(delivery_id: @user_delivery_info.delivery_id)\n @delivery = Delivery.find_by_id(@user_delivery_info.delivery_id)\n \n # count number of drinks in delivery\n @drink_count = @next_delivery.sum(:quantity)\n # count number of drinks that are new to user\n @next_delivery_cooler = 0\n @next_delivery_cellar = 0\n @next_delivery_small = 0\n @next_delivery_large = 0\n # cycle through next delivery drinks to get delivery counts\n @next_delivery.each do |drink|\n @quantity = drink.quantity\n if drink.cellar == true\n @next_delivery_cellar += (1 * @quantity)\n else\n @next_delivery_cooler += (1 * @quantity)\n end\n if drink.large_format == true\n @next_delivery_large += (1 * @quantity)\n else\n @next_delivery_small += (1 * @quantity)\n end\n end \n \n respond_to do |format|\n format.js\n end # end of redirect to jquery\n end",
"def set_stock\n @product_stock = ProductStock.find(params[:id])\n end",
"def souvenir_trading_options(stock_code:, current_position:, current_average_price:, target_average_price:, enter_price: nil, operation_market_value: nil, min_position_delta: 100)\n position_delta = min_multiple_of(operation_market_value / enter_price, min_position_delta)\n\n new_average_price = find_new_average_price(current_position: current_position, current_average_price: current_average_price, position_delta: position_delta, operation_price: enter_price)\n\n result = [\n \"Buy #{position_delta} #{stock_code} at #{format_price(enter_price)} (#{format_price(enter_price * position_delta)}) for a new average of #{format_price(new_average_price)}\"\n ]\n\n result.concat(list_operation_target_price_options(\n current_position: current_position + position_delta,\n current_average_price: new_average_price,\n target_average_price: target_average_price,\n ).select do |operation_target_price_option|\n operation_target_price_option[:price] > (enter_price * 1.025) && operation_target_price_option[:position_delta] > - position_delta\n end.map do |operation_target_price_option|\n final_position = current_position + position_delta + operation_target_price_option[:position_delta]\n\n operation_target_price_option[:text] + \" - keep #{final_position} (#{format_price(final_position * target_average_price)})\"\n end).join \"\\n\"\nend",
"def of_update_description_prices_from_product_store\n product = params[:product]\n store = params[:store]\n supplier = params[:supplier]\n tbl = params[:tbl]\n description = \"\"\n qty = 0\n price = 0\n discount_p = 0\n discount = 0\n code = \"\"\n amount = 0\n tax_type_id = 0\n tax_type_tax = 0\n tax = 0\n current_stock = 0\n if product != '0'\n @product = Product.find(product)\n @prices = @product.purchase_prices\n # Assignment\n description = @product.main_description[0,40]\n qty = params[:qty].to_f / 10000\n # Use purchase price, if any. Otherwise, the reference price\n price, discount_p, code = product_price_to_apply(@product, supplier)\n if discount_p > 0\n discount = price * (discount_p / 100)\n end\n amount = qty * (price - discount)\n tax_type_id = @product.tax_type.id\n tax_type_tax = @product.tax_type.tax\n tax = amount * (tax_type_tax / 100)\n if store != 0\n current_stock = Stock.find_by_product_and_store(product, store).current rescue 0\n end\n end\n # Format numbers\n price = number_with_precision(price.round(4), precision: 4)\n tax = number_with_precision(tax.round(4), precision: 4)\n amount = number_with_precision(amount.round(4), precision: 4)\n current_stock = number_with_precision(current_stock.round(4), precision: 4)\n discount_p = number_with_precision(discount_p.round(2), precision: 2)\n discount = number_with_precision(discount.round(4), precision: 4)\n # Setup JSON\n @json_data = { \"description\" => description, \"price\" => price.to_s, \"amount\" => amount.to_s,\n \"tax\" => tax.to_s, \"type\" => tax_type_id, \"stock\" => current_stock.to_s,\n \"discountp\" => discount_p, \"discount\" => discount, \"code\" => code, \"tbl\" => tbl.to_s }\n render json: @json_data\n end",
"def update\n @sp500_stock = Sp500Stock.find(params[:id])\n\n respond_to do |format|\n if @sp500_stock.update_attributes(params[:sp500_stock])\n format.html { redirect_to @sp500_stock, notice: 'Sp500 stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sp500_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def increase_insurance_premium\n self.insurance_premium += 100\n end",
"def update_level\n new_level_progress = 100 - ((self['level'] * 100) - self['xp'])\n self.update(:level_progress => new_level_progress)\n if self['level_progress'] > 99\n new_level = self['level'] + 1\n self.update(:level => new_level)\n self.update_level\n end\n end",
"def update\n @portfolio = Portfolio.find(params[:portfolio_id])\n @trade = @portfolio.trades.find(params[:id])\n\n # @trade = Trade.new(params[:trade])\n @trade.assign_attributes(params[:trade])\n @stock2 = StockQuote::Stock.quote(\"#{params[:trade][:stock]}\")\n @trade.buy_price = @stock2.last\n\n respond_to do |format|\n # if @trade.update_attributes(params[:trade])\n if @trade.save\n format.html { redirect_to [@portfolio, @trade], notice: 'Trade was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trade.errors, status: :unprocessable_entity }\n end\n end\n end",
"def si_update_description_prices_from_product_store\n product = params[:product]\n store = params[:store]\n supplier = params[:supplier]\n description = \"\"\n qty = 0\n price = 0\n discount_p = 0\n discount = 0\n code = \"\"\n amount = 0\n tax_type_id = 0\n tax_type_tax = 0\n tax = 0\n current_stock = 0\n if product != '0'\n @product = Product.find(product)\n # Assignment\n description = @product.main_description[0,40]\n qty = params[:qty].to_f / 10000\n # Use purchase price, if any. Otherwise, the reference price\n price, discount_p, code = product_price_to_apply(@product, supplier)\n if discount_p > 0\n discount = price * (discount_p / 100)\n end\n amount = qty * (price - discount)\n tax_type_id = @product.tax_type.id\n tax_type_tax = @product.tax_type.tax\n tax = amount * (tax_type_tax / 100)\n if store != 0\n current_stock = Stock.find_by_product_and_store(product, store).current rescue 0\n end\n end\n # Format numbers\n price = number_with_precision(price.round(4), precision: 4)\n tax = number_with_precision(tax.round(4), precision: 4)\n amount = number_with_precision(amount.round(4), precision: 4)\n current_stock = number_with_precision(current_stock.round(4), precision: 4)\n discount_p = number_with_precision(discount_p.round(2), precision: 2)\n discount = number_with_precision(discount.round(4), precision: 4)\n # Setup JSON hash\n @json_data = { \"description\" => description, \"price\" => price.to_s, \"amount\" => amount.to_s,\n \"tax\" => tax.to_s, \"type\" => tax_type_id, \"stock\" => current_stock.to_s,\n \"discountp\" => discount_p, \"discount\" => discount, \"code\" => code }\n render json: @json_data\n end",
"def update\n @stock = Stock.find(params[:symbol])\n binding.pry\n respond_to do |format|\n if @stock.update_attributes(params[:currentPrice])\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :ok }\n else\n if @stock.update_attributes(params[:openingPrice])\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :ok }\n else\n if @stock.update_attributes(params[:closingPrice])\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end\n end\n end",
"def transactiontype(type,product)\n if type == \"purchase\"\n product.stock = product.stock - 1\n elsif type == \"returns\"\n product.stock = product.stock + 1\n end\n\n end",
"def update_level_\n end",
"def update_master_variant()\n @new_product_variant = Spree::Variant.where(\"product_id=?\", @new_product.id).first\n @new_product_variant.update_column(\"sku\", @product_row[:name])\n @new_product_variant.update_column(\"weight\", @product_row[:weight]) if @product_row[:weight].present?\n @new_product_variant.update_column(\"height\", @product_row[:height]) if @product_row[:height].present?\n @new_product_variant.update_column(\"width\", @product_row[:width]) if @product_row[:width].present?\n @new_product_variant.update_column(\"depth\", @product_row[:length]) if @product_row[:length].present?\n @new_product_variant.update_column(\"tax_category_id\", @@auto_tax_category_id)\n @new_product_variant.price = @product_row[:price]\n @new_product_variant.core_price = @product_row[:core]\n @new_product_variant\n end",
"def update_product_cache_stock\n\t\t\tself.product.update_cache_stock if self.product.present?\n\t\tend",
"def perform\n update_null = \" or (stock is null and last_stock_reported_centry is not null)\"\n query = \"stock <> last_stock_reported_centry or ((stock is not null and last_stock_reported_centry is null)#{update_null if ENV[\"UPDATE_NULL_STOCK\"] == \"false\"})\"\n\n ::Product.where(query).each do |local_product|\n resp = centry.put('/conexion/v1/variants/sku.json', {}, {\"sku\": local_product[:sku], \"quantity\": local_product[:stock]})\n if (resp.code == \"200\")\n centry_variant_info = JSON.parse(resp.body)\n local_product[:last_stock_reported_centry] = centry_variant_info[\"quantity\"]\n local_product[:id_product_centry] = centry_variant_info[\"product_id\"]\n local_product.save!\n end\n end\n end",
"def update\n @stockist = Stockist.find(params[:id])\n\n respond_to do |format|\n if @stockist.update_attributes(params[:stockist])\n flash[:notice] = 'Stockist was successfully updated.'\n format.html { redirect_to(admin_stockist_path(@stockist)) }\n format.xml { head :ok }\n else\n assign_lovs\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @stockist.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def change_quant(list, item, new_num)\n list[item] = new_num\n list\nend",
"def update_quality_value(item, qvalue)\n if item.quality < 50\n item.quality = item.quality + qvalue\n end\n end",
"def update_stock_market_places(product_stocks)\n messages = []\n lazada_stock_hash = {}\n zalora_stock_hash = {}\n product_stocks.each do |key, value|\n variant = Spree::Variant.find(key)\n begin\n value.each do |sp_key, stock_count|\n stock_product = Spree::StockProduct.find(sp_key)\n smpp = stock_product.sellers_market_places_product\n market_place = smpp.market_place\n user_market_place = Spree::SellerMarketPlace.where(\"seller_id=? AND market_place_id=?\", smpp.seller_id, market_place.id)\n case market_place.code\n when \"qoo10\"\n res = Spree::StockMovement.stock_update_qoo10(variant.product, market_place.id, stock_count, stock_product, user_market_place.first, smpp, stock_count)\n when \"lazada\"\n if lazada_stock_hash[user_market_place.first.id.to_s].present?\n lazada_stock_hash[user_market_place.first.id.to_s].first.merge!(variant.sku.to_s=>stock_count)\n else\n lazada_stock_hash.merge!(user_market_place.first.id.to_s=>[{variant.sku.to_s=>stock_count}])\n end\n when \"zalora\"\n if zalora_stock_hash[user_market_place.first.id.to_s].present?\n zalora_stock_hash[user_market_place.first.id.to_s].first.merge!(variant.sku.to_s=>stock_count)\n else\n zalora_stock_hash.merge!(user_market_place.first.id.to_s=>[{variant.sku.to_s=>stock_count}])\n end\n end\n messages << (market_place.name+\": \"+ res) if res.present? && res != true\n end\n rescue Exception => e\n messages << e.message\n end\n end # end of stock product loop\n # Update stock for lazada in bulk\n Spree::StockMovement.stock_update_lazada_bulk(lazada_stock_hash) if lazada_stock_hash.present?\n Spree::StockMovement.stock_update_lazada_bulk(zalora_stock_hash) if zalora_stock_hash.present?\n return messages.present? ? \"fail\" : \"success\"\n end",
"def update_sales_line_qty\r\n sales_line = ERP::SalesLine.find params[:id]\r\n result = sales_line.update_sales_qty( params[:value].to_i )\r\n @store_user.my_account_log(sales_line,\"Update Sales Line Qty: #{sales_line.invent_trans_id} (#{sales_line.item_id}), returns #{result}\")\r\n render :text => result\r\n end",
"def update_discounted_price\n self.price = product.price * (100-discount)/100 \n end",
"def set_sku(prod , row)\n prod.sku = at_in(:sku,row) if at_in(:sku,row) \n end",
"def increase!(amount = 1)\n transaction do\n self.quantity += amount\n unless in_stock?\n # fail Shoppe::Errors::NotEnoughStock, ordered_item: ordered_item, requested_stock: self.quantity\n end\n save!\n # order.remove_delivery_service_if_invalid\n end\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end"
] | [
"0.7473148",
"0.6869709",
"0.6855044",
"0.68399686",
"0.67062116",
"0.6670519",
"0.6647786",
"0.6543969",
"0.64892733",
"0.64395046",
"0.64172536",
"0.63896203",
"0.63650733",
"0.63606936",
"0.6349294",
"0.63287437",
"0.6267883",
"0.6258074",
"0.6255039",
"0.62529385",
"0.6157215",
"0.6157215",
"0.6128994",
"0.60916924",
"0.6075173",
"0.60480255",
"0.60205966",
"0.6003803",
"0.5984458",
"0.59800076",
"0.5979662",
"0.59730864",
"0.597111",
"0.59594893",
"0.59519875",
"0.59221655",
"0.5914689",
"0.5880441",
"0.5878811",
"0.58781844",
"0.5870079",
"0.5865751",
"0.5864549",
"0.5858551",
"0.5848079",
"0.5842125",
"0.5840646",
"0.58395976",
"0.5829489",
"0.5828064",
"0.5806466",
"0.57911444",
"0.57869065",
"0.577481",
"0.57628614",
"0.57618386",
"0.5728347",
"0.5715793",
"0.57152027",
"0.57088566",
"0.57039297",
"0.5685495",
"0.56808174",
"0.5675632",
"0.56673247",
"0.5666157",
"0.5662388",
"0.56622165",
"0.5661249",
"0.5646837",
"0.5643273",
"0.5642504",
"0.5633984",
"0.56328183",
"0.56323147",
"0.5615614",
"0.56039923",
"0.56012005",
"0.55984706",
"0.558809",
"0.5582255",
"0.5581809",
"0.5577517",
"0.5573307",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685",
"0.5571685"
] | 0.7983519 | 0 |
Validation to check whether the adjustment value is above or below zero | def adjustment_value
if self.adjustment == 0
errors.add(:adjustment, "must be greater or less than zero.")
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def values_positive?\n is_ok = self.start_value > 0.0\n \n if is_ok\n self.value_changes.each do |offset, setting|\n setting.value > 0.0\n end\n end\n return is_ok\n end",
"def adjustment\n return 0 unless eligible?\n\n calculation\n end",
"def adjust_towards_zero(number, adjustment)\n\t\tif (number - adjustment).abs <= adjustment\n\t\t\t0\n\t\telsif number > 0\n\t\t\tnumber - adjustment\n\t\telsif number < 0\n\t\t\tnumber + adjustment\n\t\telse\n\t\t\traise \"Unexpected conditional branch. \" <<\n\t\t\t\t\t\"Called with arguments: \" <<\n\t\t\t\t\t\"number = \" << number.to_s <<\n\t\t\t\t\t\", adjustment = \" << adjustment.to_s\t\n\t\tend\n\tend",
"def validate_current(current)\n (current < 0 and current > -3.0)\n end",
"def validate_positive_number_excluding_zero(name, value)\n puts \"Error: parameter #{name} must be positive and not zero.\" if value <= 0\n return value\n end",
"def above_zero(value)\n value.negative? ? 0 : value\n end",
"def value_check(amount)\n # if \n if amount < 0\n error\n else\n return false\n end\n end",
"def validate_positive_number_including_zero(name, value)\n puts \"Error: parameter #{name} must be positive or zero.\" if value < 0\n return value\n end",
"def valid_point_value?(value)\n value.is_a?(Integer) && value >= 0\n end",
"def validate_values_greater_than_zero\n raise 'Values is less than zero' unless ValuesLib.remove_currency_format(text_value_one) > 0\n raise 'Values is less than zero' unless ValuesLib.remove_currency_format(text_value_two) > 0\n raise 'Values is less than zero' unless ValuesLib.remove_currency_format(text_value_three) > 0\n raise 'Values is less than zero' unless ValuesLib.remove_currency_format(text_value_four) > 0\n raise 'Values is less than zero' unless ValuesLib.remove_currency_format(text_value_five) > 0\n raise 'Values is less than zero' unless ValuesLib.remove_currency_format(total_values) > 0\n end",
"def positive_price\n errors.add(:price, \"should be positive\") unless price.nil? || price >= 0.01\n end",
"def too_low? temp # check if temp is below absolute zero\n temp < 0\nend",
"def line_positive_and_gt_zero\n errors.add(:line, \"Line number must be a positive number and greater than 0\") if line.blank? || line.to_f < 0.01\n end",
"def valid_loan_amount?(amount)\n amount > 0\nend",
"def input_valid?\n could_refund = @order.total_price - @order.refund_price\n @params[:refund_price].to_f.positive? && @params[:refund_price].to_f <= could_refund\n end",
"def validate #:doc:\n errors.add(:price, \"should be positive\") unless price.nil? || price >= 0.01\n end",
"def near_zero_or_less?(value)\n (value < 0.0 or near_zero?(value))\n end",
"def is_set?\n (@value - NEGATIVE) >= 0.5\n end",
"def negative?\n value < 0\n end",
"def validate_under_age\n self.is_under_age = (self.age < SADHAK_MIN_AGE)\n errors.empty?\n end",
"def failed?\n @value == 0 || @value.to_i < 0\n end",
"def negative?\n return self < 0\n end",
"def negative?\n self < 0\n end",
"def negative?\n self < ZERO\n end",
"def out_of_money()\n @total_money <= 0\n end",
"def valid_value_for_test\n value = @options[:equal_to] || @options[:less_than_or_equal_to] || @options[:greater_than_or_equal_to]\n\n value ||= @options[:less_than] - 1 if @options[:less_than]\n value ||= @options[:greater_than] + 1 if @options[:greater_than]\n\n value ||= 10\n\n if @options[:even]\n value = (value / 2) * 2\n elsif @options[:odd]\n value = ((value / 2) * 2) + 1\n end\n\n value\n end",
"def check_value?(amount)\n if amount > 0 # If amount is greater than 0 (or it is positive)\n return true\n end\n end",
"def ensure_negative_amount\n if (db_amount = read_attribute(:amount)) && db_amount > 0\n self.amount *= -1\n end\n end",
"def positive?\n self > ZERO\n end",
"def valid?\n @errors = [] \n validate_field_types\n \n if integer?(\"point_adjustment\")\n if point_adjustment < 1\n @errors << {message: \"Point adjustment must be greater than 0.\", variable: \"point_adjustment\"}\n end\n end\n\n @errors.empty?\n end",
"def nonnegative?\n return self >= 0\n end",
"def negative?\n self <= 0\n end",
"def is_miss?\n sum < 10 && sum >= 0\n end",
"def max_win_points_validation\n if play_condition.win_points.blank?\n self.errors.add(:base, \"Количество очков за победу должно быть больше 0\")\n elsif play_condition.difficulty_level.present? && play_condition.difficulty_level.difficulty_level_setting.send(\"#{self.class.to_s.underscore}_max_win_points\").to_f < play_condition.win_points.to_f\n self.errors.add(:base, \"Количество очков за победу должно быть не больше #{play_condition.difficulty_level.difficulty_level_setting.send(\"#{self.class.to_s.underscore}_max_win_points\")}\")\n elsif play_condition.win_points.to_f <= play_condition.participation_points.to_f\n self.errors.add(:base, \"Количество очков за победу должно быть больше, чем количество очков за участие.\")\n end\n end",
"def negative?\n self < 0\n end",
"def validate_amount\n errors.add(:claiming_amount, :ads_amount) if claim_amount_required? && ads_amount.to_i < claiming_amount.to_i\n end",
"def valid?(value)\n return value >= 0 && value <= 19\n end",
"def amount_inside_the_pot_bounds\n return if pot.nil?\n return true if pot.upper_bound.nil?\n return true if amount <= pot.upper_bound\n errors.add(:amount, :amount_out_of_bounds)\n false\n end",
"def vdate_is_valid_amount_range?(attr)\n if(attr < 0 || attr > 99999999999999)\n return false\n else\n return true\n end\n end",
"def applicable?\n mandatory || amount != 0\n end",
"def nonpositive?\n return self <= 0\n end",
"def check_amount\n if (mode == 'percentage' and percentage == 0) or (mode == 'fixed' and money.zero?)\n errors.add(:amount, 'a discount cannot be zero')\n end\n end",
"def paid_adjustment_amount_negative\n\t\tself.paid_amount = -(self.paid_amount.abs) if self.paid_amount\n\t\tself.adjustments = -(self.adjustments.abs) if self.adjustments\n\tend",
"def validate_discount_number\n disc = self.discount.to_f\n if disc < 0\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.greater_than_or_equal_to\", :count => 0))\n elsif disc > 100\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.less_than_or_equal_to\", :count => 100))\n end\n end",
"def rest?\n @value < 0\n end",
"def amount_not_negative\n errors.add(:amount, \"can't be negative\") if amount.negative?\n end",
"def out_of_range?\n value < 1 || value > 12\n end",
"def rack_rate_must_be_over_minimum\n if !rack_rate.blank? and rack_rate < self.final_minimum_rate\n errors.add(:rack_rate, I18n.t('room_types.validate.rack_rate_must_be_over_minimum', :minimum => self.final_minimum_rate))\n end\n \n end",
"def validate_value value, params\n variant = Spree::Variant.where(id: params['variant']).first\n return false unless variant\n\n valid_sale = true\n if params['calculator'] == 'Spree::Calculator::AmountSalePriceCalculator'\n unless variant.original_price.to_f > value.to_f\n errors.add(:value, 'value should not be greater than the original price')\n valid_sale = false\n end\n else\n unless value.to_f.between?(0.0, 1.0)\n errors.add(:value, \"percent should between 0 and 1 (#{calculator.class.title})\")\n valid_sale = false\n end\n end\n return valid_sale\n end",
"def duration_hours_must_be_positive\n errors.add(:duration_hours, \"must be selected\") if !duration_hours.blank? and duration_hours < 0\n end",
"def zero?\n cents == 0 \n end",
"def discount_price_cannot_be_greater_than_price_value\n if discount_price.present? && price.present? && discount_price > price\n errors.add(:discount_price, \"can't be greater than price value\")\n end\n end",
"def pay_rate_range\n if self.pay_rate.blank?\n errors.add(:pay_rate, \"can't be blank\")\n elsif self.pay_rate <= 0\n errors.add(:pay_rate, \"must be greater than 0\")\n elsif self.pay_rate >= 1000000\n errors.add(:pay_rate, \"must be less than 1000000\")\n end\n end",
"def validate_input\n\t\tif @options[:num].is_a?(Integer) and @options[:num] >= 0 \n\t\t\t@num = @options[:num].to_i.abs \n\n\t\telse\n\t\t\t@num = \"NAN\"\n\n\t\tend\n\tend",
"def be_around(value, error: 0.01)\n a_value_between (value - error),\n (value + error)\n end",
"def value_limit\n if self.value < 30\n errors.add(:value, 'cannot be below R$ 50')\n elsif self.value > self.wallet\n errors.add(:value, 'cannot exceed your current wallet')\n elsif !self.value.%(50).zero?\n errors.add(:value, 'must be multiple of 50')\n elsif self.value > 5100\n errors.add(:value, 'cannot exceed R$ 5100')\n end\n end",
"def duration_days_and_duration_hours_sum_must_be_positive\n errors.add(:duration_hours, \"must be greater than 0\") if !duration_days.blank? and !duration_hours.blank? and duration_days + duration_hours <= 0\n end",
"def validate_discount_range_values\n curr_val = curr_per = 0\n first = true\n discount_values.each do |val, per|\n if per > 100\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.invalid_range_percentage\"))\n break\n end\n unless first\n if val <= curr_val or per <= curr_per\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.invalid_range_secuence\"))\n break\n end\n end\n first = false\n curr_val, curr_per = val, per\n end\n end",
"def zero?\n amount == 0 \n end",
"def participation_validation\n if play_condition.participation_points.blank?\n self.errors.add(:base, \"Количество очков за участие должно быть больше 0\")\n elsif play_condition.difficulty_level.present? && play_condition.difficulty_level.difficulty_level_setting.send(\"#{self.class.to_s.underscore}_max_points\").to_f < play_condition.participation_points.to_f\n self.errors.add(:base, \"Количество очков за участие должно быть не больше #{play_condition.difficulty_level.difficulty_level_setting.send(\"#{self.class.to_s.underscore}_max_points\")}\")\n end\n end",
"def validate_minimum_down_payment(asking_price, down_payment)\n minimum_dp = minimum_down_payment(asking_price.to_f)\n unless down_payment.to_f.zero? || down_payment.to_f >= minimum_dp\n \"down payment needs to be at least #{minimum_dp}\"\n end\n end",
"def validates_price\n if price.zero?\n errors.add(:display_price, \"cannot be zero\")\n end\n\n nil\n end",
"def applyGrowth(x)\n if (x.parameter_type != 0) == @value\n return true\n else\n return false\n end\n end",
"def zero?\n value == 0 \n end",
"def test_cost_always_positive\n property_of {\n share_price = float\n num_shares = integer\n [share_price, num_shares]\n }.check { |share_price, num_shares|\n value = @market.calculate_cost(share_price, num_shares)\n assert value >= 0\n }\n end",
"def positive(attrs, klass = nil)\n numeric(attrs, klass) if klass\n Array(attrs).each do |attr|\n # invalid numbers convert to 0.0 and fail validation automatically\n error(attr, 'should be greater than zero') unless @object.send(attr).to_f.positive?\n end\n end",
"def noncommissionable_adjustment\n total = Money.new(0)\n self.adjustments.each do |a| \n total += a[:amount] if a[:commissionable] == false \n end\n total\n end",
"def noncommissionable_adjustment\n total = Money.new(0)\n self.adjustments.each do |a| \n total += a[:amount] if a[:commissionable] == false \n end\n total\n end",
"def positive?; end",
"def duration_days_must_be_positive\n errors.add(:duration_days, \"must be selected\") if !duration_days.blank? and duration_days < 0\n end",
"def zero?\n cents == 0\n end",
"def zero?\n cents == 0\n end",
"def negative?() @positive==false end",
"def test_round_value_assume_negative\n item = items(:sals)\n item.value = \"12.99\"\n item.save\n assert_equal -13, item.reload.value\n end",
"def negative_test\r\n @negative = true\r\n end",
"def adjustment_line_is?\r\n adjustment_amounts = [coinsurance_amount, copay_amount, deductible_amount,\r\n denied_amount, discount_amount, noncovered_amount, primary_payment_amount,\r\n prepaid_amount, patient_responsibility_amount, contractual_amount,\r\n miscellaneous_one_adjustment_amount, miscellaneous_two_adjustment_amount,\r\n miscellaneous_balance]\r\n\r\n total_adjustment_amount = adjustment_amounts.inject(0) {|sum, value| sum + value.to_f }\r\n balance_amount = service_procedure_charge_amount.to_f - (service_paid_amount.to_f + total_adjustment_amount)\r\n\r\n non_zero_adjustment_amounts = adjustment_amounts.keep_if {|v| !v.to_f.zero?}\r\n is_there_atleast_one_adjustment_amount = non_zero_adjustment_amounts.length > 0\r\n\r\n balance_amount.to_f.round(2).zero? && service_procedure_charge_amount.blank? && service_allowable.blank? &&\r\n is_there_atleast_one_adjustment_amount\r\n end",
"def positive; end",
"def positive; end",
"def is_benefit_out_of_bal\n @cur_pkg = self.get_latest_effective_package\n #@cur_pkg = self.current_package\n if @cur_pkg != nil\n #if false && @cur_pkg\n @bene_bal = ( self.monthly_benefit.to_f -\n ( self.current_package.calc_hourly_benefit.to_f * self.calc_tot_hours.to_f )\n )\n\n else\n @bene_bal = 0.0000\n end\n if @bene_bal > 0.0005 || @bene_bal < -0.0005\n true\n else\n false\n end\n end",
"def attendance_gap\n attendance - expected_attendance \n # //this should be good if attendance and expected_attendance is an integer\n end",
"def check_age(age)\n raise ArgumentError, \"Enter Positive Number\" unless age > 0\nend",
"def require_minimum?\n self.minimum_positive_votes > 0\n end",
"def zero?\n return amount.zero?\n end",
"def should_be_less_on_rating_value(wrong_song = @wrong_song)\n validate_column_errors(wrong_song, :rating, false, 'errors.messages.less_than_or_equal_to', :count=>5)\n end",
"def filled?\n @value.positive?\n end",
"def is_negative\n\t\t\tunless @balance > 0 \n\t\t\t\traise ArgumentError.new(\"You must enter a positive balance!\")\n\t\t\tend\n\t\tend",
"def is_of_age? age, minimum_age\n check = (minimun_age.to_i) - (age.to_i)\n check >= 0\nend",
"def abs4(x) return x<0?-x:x end",
"def check_new_price\n begin\n new_price = Float(params[:item][:new_price])\n add_price_error if new_price < 0\n rescue\n add_price_error\n end\n end",
"def filled?\n @value > 0\n end",
"def check_age(age)\n\traise ArgumentError, \"Enter Positive Number\" unless age >0\nend",
"def higher_then_amount\n if self.amount > 20\n errors.add(:amount, \"Zakup jednorazowy ograniczono do 20.\") \n end\n end",
"def check_bounds(value)\n return value >= self.bound.lower_bound && value <= self.bound.upper_bound\n end",
"def valid_result_range\n self.result && self.result > -2 ? true : false\n end",
"def positive_adjustment_commission(event)\n additional_charges = event.additional_charges.nil? ? 0 : event.additional_charges\n comm = ((additional_charges + ((event.amount_of_guests - event.minimum_guarantee) * event.base_price)) * COMMISSION_RATE) / BREAKAGE_RATE\n comm.round(2)\n end",
"def balance_negative?\n current_balance.negative?\n end",
"def is_negative(tal)\n if tal < 0\n return true\n else\n return false\n end\nend",
"def validate_around\n validate_down\n validate_up\n end",
"def validate_amount\n\t\tunless self.amount > 0 and self.amount <= MAX_PURCHASE_AMOUNT\n\t\t\tself.errors.add(:amount, 'must be positive and less than 250')\n\t\tend\n\tend"
] | [
"0.69621474",
"0.69361496",
"0.6866838",
"0.68578917",
"0.67058533",
"0.66879404",
"0.6675955",
"0.66038287",
"0.65772283",
"0.6557495",
"0.6515033",
"0.6460465",
"0.6390238",
"0.6361851",
"0.630908",
"0.63079137",
"0.63025403",
"0.62806976",
"0.62733424",
"0.6250561",
"0.62037134",
"0.6167481",
"0.6158722",
"0.612524",
"0.61030394",
"0.6089142",
"0.6082327",
"0.6070999",
"0.60690695",
"0.6063692",
"0.60623777",
"0.60411817",
"0.6037839",
"0.6030443",
"0.6026484",
"0.60219365",
"0.59818006",
"0.5977548",
"0.5970383",
"0.5970359",
"0.5958979",
"0.5943211",
"0.5940863",
"0.59302473",
"0.5929963",
"0.5901865",
"0.58909404",
"0.58899146",
"0.5888881",
"0.5888174",
"0.5861775",
"0.58617246",
"0.5860549",
"0.5843411",
"0.5833667",
"0.5833303",
"0.5830039",
"0.58283794",
"0.58018064",
"0.57789385",
"0.577816",
"0.577635",
"0.57659256",
"0.5764201",
"0.57543564",
"0.5749297",
"0.5745464",
"0.5745464",
"0.5740522",
"0.5736487",
"0.573182",
"0.573182",
"0.57149756",
"0.5710528",
"0.5704199",
"0.56903774",
"0.568823",
"0.568823",
"0.5686709",
"0.56750554",
"0.5673684",
"0.56718117",
"0.5663801",
"0.5649795",
"0.5649751",
"0.5641611",
"0.5640353",
"0.5639446",
"0.5633231",
"0.56311136",
"0.5629784",
"0.5625821",
"0.561488",
"0.56091565",
"0.5603167",
"0.5601163",
"0.55935013",
"0.5591673",
"0.5587568"
] | 0.84540373 | 1 |
Send Stock Notifications to users | def send_stock_notifications
SendStockNotificationsJob.perform_later(sku)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_notifications\n end",
"def order_notification(user)\n @user = user\n @items = @user.items.out_of_stock\n\n mail :subject => \"Keep these items in Sto.ck\",\n :to => user.email\n end",
"def send_notification\n\n\n end",
"def push(notif)\n\n end",
"def notify_via_service\n u = User.first\n u.update(last_notification_mail_sent: 30.days.ago)\n service = NotificationDigest.new(type: :notifications)\n service.notify_user(u, deliver: false)\n end",
"def deliver\n if session[:user_id] then\n EVENT_LOG.tagged(DateTime.now, 'ADMIN') { EVENT_LOG.info('Test-firing message push to devices') }\n User.all.each do |user|\n if rand > 0.5\n user.send_notification('test broadcast', :message)\n else\n user.send_notification(\"Please create a weekly entry\", :reminder)\n end\n end\n Rpush.push\n render nothing: true, status: :ok\n else\n redirect_to admin_login_url\n end\n end",
"def notification\n user = User.first\n comic = Comic.first\n SubscriptionMailer.notification(work: comic, user: user)\n end",
"def low_stock_notification(email, products)\n @products = products\n mail(to: email, subject: \"Notificación de bajas existencias\" )\n end",
"def notify_by_push\n PushNotification.new(user: context.user,\n message: context.message,\n n_type: context.n_type,\n data: { from_id: context.user_from.try(:id), from_name: context.user_from.try(:name),\n donation_id: context.donation.try(:id) })\n .simple_notification\n end",
"def send_execution_notification\n payload = execution_notification_payload\n trade_order.portfolio.user.notify_devices payload, self\n end",
"def notify_user(user, message, action)\n ActionCable.server.broadcast(\n \"message_channel_#{user.aitu_id}\",\n message: {\n action: action,\n order_item: ::MessageBlueprint.render(message).to_json\n }\n )\n send_push(user, message)\n end",
"def notification_for(product)\n \t@product = product \n mail(:to => @product.user.email, :subject => \"Perishab.ly alert regarding your #{@product.name}\")\n end",
"def stock_updates\n my_logger ||= Logger.new(\"#{Rails.root}/log/cron.log\")\n errors = []\n notification_array = []\n if params[\"products\"].present?\n ApiJob.fba_stock_received(params)\n else\n notification_array << ['',\"No Products found\",'',true]\n errors << \"No Products found\" \n end\n Spree::DataImportMailer::stock_update_notification(notification_array).deliver if notification_array.present?\n #view_context.update_stock_market_places(stock_values) if stock_values.present? \n if errors.empty?\n respond_to do |format|\n format.json { render :status => 200, :json => {:success => \"true\", :message => \"Stock updated successfully!\" }}\n end\n else\n respond_to do |format|\n format.json { render :status => 200, :json => {:success => \"false\", :message => errors.join(\"; \") }}\n end\n end\n end",
"def low_stock_notification_weekly(email, products)\n @products = products\n mail(to: email, subject: \"Notificación semanal de bajas existencias\" )\n end",
"def send_notifications(monster)\n nearby_users = User.near([monster.lat, monster.lng], NEARBY_MONSTER_DISTANCE)\n if nearby_users.count(:all) > 0\n notifications = Activity.notifications.where(user_id: nearby_users.map(&:id).join(\",\"))\n .where(monster_number: Monster::MONSTERS.index(monster.name))\n\n airship = Urbanairship::Client.new(key:Figaro.env.ua_application_key, secret:Figaro.env.ua_master_secret)\n push = airship.create_push\n push.notification = Urbanairship.notification(alert: \"A monster you are looking for is nearby!\")\n push.device_types = Urbanairship.device_types(['ios'])\n\n push.audience = Urbanairship.or(*notifications.map{ |n| Urbanairship.ios_channel(n.user.channel_id) } )\n push.send_push\n\n monster.save!\n end\n end",
"def send_notification\n\n # TODO this seems hacky\n if Rails.env.development?\n apn = Houston::Client.development\n else\n apn = Houston::Client.production\n end\n\n apn.certificate = AWS::S3.new.buckets[ENV['S3_BUCKET_NAME']].objects['private/cert.pem'].read\n\n token = self.user.apn_token\n\n notification = Houston::Notification.new(device: token)\n notification.alert = \"You won a free drink!\"\n\n apn.push(notification)\n end",
"def notify(interests, data = {})\n Request.new(\n @eventflit_client,\n :post,\n url(\"/publishes\"),\n {},\n payload(interests, data)\n ).send_sync\n end",
"def push_stock_take\n \t\n \t puts \"push\"\n\n \trequire 'pusher'\n pusher_client = Pusher::Client.new(\n app_id: '226476',\n key: '62217549218f218bf085',\n secret: '3b2d56477030f12e48df',\n cluster: 'eu',\n encrypted: true\n )\n \n \n pusher_client.trigger(\"mezzanine-stocktake\", 'stocktake_event_1', {\n stock_take: {\n \tquantity:self.quantity,\n \tproduct:self.product.name,\n \tclinic:self.clinic.name,\n latitude:self.clinic.latitude.to_f,\n longitude:self.clinic.longitude.to_f,\n \tcreated_at: time_ago_in_words(self.created_at),\n \treplenish_quantity:self.product.replenish_quantity\n }\n })\n \n \tputs \"pushed\"\n\n end",
"def notifications\n end",
"def send_push_notification\n @user = params[:user_id] ? ::User.find_by_id(params[:user_id]) : nil\n @user = ::User.find_by_user_name(params[:user_name].strip) if params[:user_name].present?\n logger.info \"-> #{@user}\"\n if @user\n flash[:error] = nil\n ::Users::UserNotificationToken.send_push_notifications_to(@user, params[:text] || params[:notification_text] )\n else\n flash[:error] = 'Cannot find the user'\n end\n\n respond_to do|format|\n format.js\n format.html { redirect_to last_page(\"t=#{Time.now.to_i}\") }\n end\n end",
"def send_observer_mail(user)\n mail to: user.email, subject: \"Changes to Cart\", from:'[email protected]'\n end",
"def send_notification(method, params); end",
"def send_notification\n\t\tSingleCellMailer.share_notification(self.study.user, self).deliver_now\n\tend",
"def email_user\n Mailer.deliver_nesstar_catalogs_processed(datasets, user_id, base_host) if EMAIL_ENABLED && User.find(user_id).person.send_notifications?\n end",
"def push_updates(data)\n PushService.new.send_update_store(Channel::STAFF_CHANNEL, data)\n PushService.new.send_update_store(Channel.private_channels_for(donor, DONOR_APP), data)\n end",
"def push_notification\n NotificationMailer.push_notification\n end",
"def gift_notification(gift)\n @requester = gift.requester\n @owner = gift.owner\n @lacquer = gift.lacquer\n @user_url = \"http://www.lacquerloveandlend.com/users/#{@requester.id}\"\n @thank_you_email_url = \"http://www.lacquerloveandlend.com/new_transactional_message?gift_id=#{gift.id}\"\n\n mail(to: @requester.email, subject: \"You've received a gift on Lacquer Love&Lend!\")\n\n headers['X-MC-Track'] = \"opens, clicks_all\"\n end",
"def old_notify_user (listing, sender, receiver)\n send_as :notification\n from sender.facebook_session.user \n recipients receiver.facebook_session.user\n #fbml \"<a href='#{FB_APP_HOME_URL}/listings/#{listing.id}'><b>#{listing.title}</b></a> has been approved.\"\n fbml \"Your listing: <a href='#{listings_path(listing.id)}}'><b>#{listing.title}</b></a> has been approved.\"\n end",
"def notify_business\n business.add_message_to_queue(\"Hey #{business.name}, we've just deposited #{amount} into your account! Thanks for being great!\")\n end",
"def notify\n send_email_notification if allow_email_notifications\n send_slack_notification if allow_slack_notifications\n end",
"def notify_users(action)\n sender = user\n recipients = []\n\n # Send to people who have registered interest.\n interests.each do |interest|\n recipients.push(interest.user) if interest.state\n end\n\n # Tell masochists who want to know about all observation changes.\n User.where(email_observations_all: true).find_each do |user|\n recipients.push(user)\n end\n\n # Send notification to all except the person who triggered the change.\n recipients.uniq.each do |recipient|\n next if !recipient || recipient == sender || recipient.no_emails\n\n case action\n when :destroy\n QueuedEmail::ObservationChange.destroy_observation(sender, recipient,\n self)\n when :change\n QueuedEmail::ObservationChange.change_observation(sender, recipient,\n self)\n else\n QueuedEmail::ObservationChange.change_images(sender, recipient, self,\n action)\n end\n end\n end",
"def notification(params)\n mail(params)\n end",
"def send_app_notification\n if message.present?\n message.receipts.unread.each do |receipt|\n user = receipt.receiver\n if user.is_a?(User) #&& user.user_setting.\n user_setting = user.user_setting\n allow_push = false\n if message.message_type == 'user_messages' && user_setting.allow_user_messages?\n allow_push = true\n end\n if message.message_type == 'clan_messages' && !(user_setting.allow_clan_messages.include?(message.notified_object_id.to_s))\n allow_push = true\n end\n if allow_push && (user_setting.android? || user_setting.iphone? ) && user_setting.fcm_token.present?\n # sky start\n\n # fcm = FCM.new(\"AIzaSyCHC77aETrtuaAvNTQQqvnLhjFf6zHOSPc\")\n # options = {data: {message: \"#{sender.username}: #{subject}\", url: nil, id: receipt.id, type: :usermessages}, collapse_key: :updated_score}\n # registration_ids = [user_setting.fcm_token]\n # response = fcm.send(registration_ids, options)\n\n # sky end\n\n fcm = FCM.new(\"AAAAqD6vl5g:APA91bEE1FUBihFLdW6kO9XpN-srDxlama2BzzjimePRN-kBlfq0tKMsblhNPW7a2_CeM1J0Pz7SMAYx4c_notZMCx2schfCDYvizOW6EYWAhnUsYA10azWOenextxFiUaFotLT8Z8er\")\n if user_setting.android?\n options = { data: { title: sender.username, message: subject, url: nil, id: receipt.id, type: message.message_type}, collapse_key: :updated_score}\n else\n options = {notification: {title: sender.username, body: subject, icon: \"myicon\", sound: \"notificationRoster.wav\", url: nil, id: receipt.id, type: message.message_type}, priority: \"high\"}\n end\n\n registration_ids = [user_setting.fcm_token]\n response = fcm.send(registration_ids, options)\n\n end\n end\n end\n end\n end",
"def notify sender_id:, referent:, instance:, users:, params: {}\n notify_push(sender_id: sender_id, referent: referent, instance: instance, users: users, params: params)\n notify_inapp(sender_id: sender_id, referent: referent, instance: instance, users: users, params: params)\n end",
"def send_notification(user_alias, message, base_uri = 'https://notifiable-staging.herokuapp.com', access_id = ENV['ACCESS_ID'], secret_key = ENV['SECRET_KEY'])\n sender = Notifiable::Sender.new access_id, base_uri: base_uri, secret_key: secret_key\n sender.send_notification_to_users([user_alias], message: message)\nend",
"def exchange_request\n @order = Order.find(params[:id])\n if @order\n @exchangeable_books = params[:books]\n user = User.find(@order.seller_id)\n @order.notification_sent = true\n @order.save\n TasksController.send_notification( user,@current_user,\"Book exchange request\", \"https://www.google.com\")\n render json:{status: 'Success', message: \"Your request is sent to book owner (\"+user.name+\")\"},status: :ok\n end\n end",
"def send_notification(message, title = nil, url = nil, label = nil)\n response = JSON.parse(User.notifo.send_notification(self.username, message, title, url, label))\n if response[\"response_code\"] == Pachube::NOTIFO_OK\n # increment global counters\n db.transaction do\n db[:statistics].filter(:id => 1).update(:monthly_count => :monthly_count + 1, :total_count => :total_count + 1)\n # increment count on user record\n db[:users].filter(:username => self.username).update(:message_count => :message_count + 1, :monthly_message_count => :monthly_message_count + 1)\n end\n end\n response\n end",
"def notify_reviewers\n PushService.new.send_notification(Channel::REVIEWER_CHANNEL, ADMIN_APP, {\n category: 'offer_delivery',\n message: delivery_notify_message,\n offer_id: offer.id,\n author_id: offer.created_by_id\n })\n end",
"def notify(params)\n client.post('/notify', params)\n end",
"def send_booking_confirmation_notifications\n\n notify_manager_confirmation\n notify_customer\n \n end",
"def notify(interests, data = {})\n Request.new(\n @pusher_client,\n :post,\n url(\"/notifications\"),\n {},\n payload(interests, data)\n ).send_sync\n end",
"def send_email!\n UserMailer.event_ticket_notification(user, self).deliver_now\n end",
"def send_new_booking_request_notifications\n\n if pay_now\n notify_manager_pay_now\n notify_request_to_customer_pay_now\n else\n notify_manager\n notify_request_to_customer\n end\n\n end",
"def submitted\n @user = @receiver\n @notification = @user.notifications.find_by(path: \"/products/#{@product.id}\")\n mail to: @user.email, subject: \"[bootcamp] #{@message}\"\n end",
"def perform\n User.where(id: @bug.notify_on_deploy).each do |user|\n NotificationMailer.deploy(@bug, user).deliver\n end\n end",
"def notify_rating\n @pack = Packages.find( :all, :conditions => {:senders_id => cookies[:user_id]} )\n if( @pack != nil )\n @pack.each do |t|\n @rating = Packages.find_by_id(t.id).finalDelivery\n @rate = Packages.find_by_id(t.id).carriers_id\n @rates = Packages.find_by_id(t.id).rating\n if( @rating == true ) && ( @rates != nil )\n @notification = Notifications.new\n @notification.users_id = @rate\n @notification.description = \"You have been rated on a specific package\"\n end\n @notification.save\n end\n end\n return;\n end",
"def notify_order\n UserMailer.notify_order\n end",
"def send_notifications(unituser, msg)\n user = unituser.user\n user.send_sms(msg)\n UserMailer.send_email(user, user.email, msg).deliver if user.contact_flags[1] == \"1\"\n UserMailer.send_email(user, user.email2, msg).deliver if user.contact_flags[3] == \"1\"\n end",
"def create\n @notification = Notification.new(notification_params)\n @notification.app = @app\n\n if params[:send] == 'now'\n @notification.update(scheduled_for: Time.now)\n else\n @notification.update(scheduled_for: Time.parse(notification_params['scheduled_for']).utc)\n end\n\n @notification.user = current_user\n @notification.rpush_app = @notification_app\n @notification.save\n\n respond_modal_with @notification, location: app_notifications_url\n end",
"def sent\n @notifications = Notification.where(sender: @current_user)\n .order({created_at: :desc})\n .page(page_params[:page])\n .per(page_params[:page_size])\n render_multiple\n end",
"def send_message_notification(user, message)\n puts \"FFFFFFFF\", user.device_token\n notification = Houston::Notification.new(:device => user.device_token)\n notification.badge = 0\n notification.sound = \"sosumi.aiff\"\n notification.content_available = true\n notification.custom_data = {:user_id => user.id}\n notification.alert = message\n certificate = File.read(\"config/production_driver.pem\")\n pass_phrase = \"push\"\n connection = Houston::Connection.new(\"apn://gateway.push.apple.com:2195\", certificate, pass_phrase)\n connection.open\n connection.write(notification.message)\n connection.close\n end",
"def weekly_progress_report(user)\n @greeting = \"Hi\"\n \n user_email = @user.email\n\n mail to: user_email\n end",
"def notify\n return if @user.email.blank?\n\n Notifier.user_event_analisys(@user, @user.events.future.analisys.first).deliver_now if @user.events.future.analisys.present?\n Notifier.user_event_visit(@user, @user.events.future.visits.first).deliver_now if @user.events.future.visits.present?\n end",
"def product_sold\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def send_email(user_info)\n \t@user_info = user_info\n @users = User.all\n\n @users.each do |user|\n\t mail(\n\t to: user.email,\n\t subject: \"BrightHearts notification\",\n\t from: \"BrightHearts <[email protected]>\",\n\t return_path: \"[email protected]\",\n\t date: Time.now,\n\t content_type: \"text/html\"\n\t )\n\tend\n end",
"def send_email\n AlertNotifier.delay.email_zero_inventory(self)\n end",
"def hotel_notification(hotel, action, current_user)\n @user = current_user\n @action = action\n @hotel = hotel\n mail(to: \"[email protected]\", subject: \"Hotel created/updated/destroyed\")\n end",
"def send_new_listing_notification(merchant)\n @merchant = merchant\n mail to: \"[email protected]\", subject: \"A New Merchant has Subscribed!\"\n end",
"def trade_updates(date)\n @update_date = date\n mail to: \"[email protected]\", subject: \"Mise à jour des trades sur le serveur !\"\n end",
"def notify_shipped(order)\n @order = order\n @info = @order.info\n email = @order.user.email\n subject = \"特快車出貨通知! (訂單編號:#{@order.token})\"\n\n mail(to: email, subject: subject) do |format|\n format.text\n format.html\n end\n end",
"def push(notifications)\n notifications.each do |notif|\n notif.results = WNSConnection.post notif, @access_token, @options\n end\n end",
"def create_notification!\n ::Users::Notifications::NewBuyRequest.create(\n recipient_user_id: buyer.parent_id, sender_user_id: buyer_id, related_model_type:'Trading::BuyRequest', related_model_id: self.id,\n uri: Rails.application.routes.url_helpers.buy_request_path(self)\n )\n ::NotificationMail.create_from_mail(buyer_id, buyer.parent_id, UserMailer.new_buy_request(self.items.first, buyer) )\n end",
"def notification\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def notify_user\n NotiMailer.notification_proposal(self.homework.user.email, self, self.homework).deliver\n end",
"def send_push_notifications!(options = {})\n return false if push_notification_devices.empty?\n return false if daily_deals_requiring_notifications.empty?\n devices = options[:devices] && options[:devices].any? ? push_notification_devices.by_tokens(options[:devices]) : push_notification_devices\n daily_deals_requiring_notifications.each do |deal|\n # TODO: need to set the push_notifications_sent_at for daily deal\n devices.each do |device|\n device.send_notification!(deal.value_proposition)\n end\n deal.push_notifications_sent!\n end\n end",
"def create_push\n PushNotification.push_to_user!(uid: @spot.priest.id, payload: push_payload)\n end",
"def send_notification\n self.target_followers.each do |target_follower|\n @user = User.find(target_follower.follower_id)\n Notification.create_notification(@user.profilable_id, @user.profilable_type, text = \"#{self.name} updated his/her profile\", \"Enterprise\") && reload unless target_follower == self || target_follower.nil?\n end\n end",
"def notify_receiver\n conversation = ConversationBlueprint.render_as_json(self, view: :normal)\n ActionCable.server.broadcast \"user_#{ self.user_two_id }_notification_channel\", conversation\n end",
"def send_status_notification\n message = case @state\n when :hungry then \"I'm hungry!!!\"\n when :sick then \"I'm not feeling so well... :(\"\n when :playful then 'Come play with me!'\n end\n\n DesktopNotifications.notify(message) unless message.nil?\n end",
"def push_notification\n UserMailer.new_message(self).deliver_now\n end",
"def sms_notify(username, source_system, message)\r\n sender = SmsGlobal::Sender.new :user => CONFIG[:sms_global_settings][:user_name].to_s, :password => CONFIG[:sms_global_settings][:password].to_s\r\n\r\n sender.send_text message, username, source_system\r\n Rails.logger.info \"#{Time.now.utc} - sms_notify - #{username} - #{source_system} - #{message}\"\r\n end",
"def votes_notification\n \ttype = 0\n\tcase self.total_votes\n\twhen 10\n\t\ttype = 310\n\twhen 25\n\t\ttype = 311\n\twhen 50\n\t\ttype = 312\n\twhen 100\n\t\ttype = 313\n\twhen 250\n\t\ttype = 314\n\twhen 500\n\t\ttype = 315\n\twhen 1000\n\t\ttype = 316\n\twhen 2500\n\t\ttype = 317\n\twhen 5000\n\t\ttype = 318\n\tend\n\tif type > 0\n\t\top_user_id = self.user_id\n\t\t# create activity \n\t\tcurrent_time = Time.now\n\t\tif Rails.env == 'production'\n\t\t\tRecentActivity.delay.add_activity(op_user_id, type.to_s, nil, nil, \"shout-votes-\"+self.total_votes.to_s+\"-\"+op_user_id.to_s+\"-\"+current_time.to_i.to_s, \"Shout\", self.id, 'You received ' + self.total_votes.to_s + ' votes on your shout \"'+self.body.truncate(23, separator: /\\s/)+'\"')\n\t\t\tWhisperNotification.delay.send_notification_330_level(op_user_id, type, self.total_votes, self.id)\n\t\tend\t\n\tend \n end",
"def notify_admin_about_newbie(user)\n @user = user\n mail \n end",
"def data_update_notification(user)\n @greeting = \"FREE PEPPERLUNCH@@!!!!!111111\"\n\n @lunch_count = user.lunches.count\n\n if @lunch_count > 15\n\n\n mail to: user.email\n end\nend",
"def new_notification\n mail(to: \"[email protected]\", subject: 'New Notification', sent_on: Time.now)\n end",
"def notification(to,f)\n send_as :notification\n recipients to\n from f\n fbml \"Not\"\n end",
"def send_notification(ticket)\n @ticket = ticket\n mail to: \"#{@ticket.name} <#{@ticket.email}>\", subject: \"Issue Ticket Notification: #{@ticket.subject}\"\n end",
"def chore_notification_email(assignment)\n @user = assignment.user\n @chore = assignment.chore\n @due_date = assignment.due_date.to_formatted_s(:long_ordinal)\n @url = complete_chore_url(assignment)\n sendgrid_category \"Chore Notification\"\n # sendgrid_unique_args :key2 => \"newvalue2\", :key3 => \"value3\"\n mail :to => @user.email, :subject => \"#{@user.name}. You've got a chore!\"\n end",
"def send_notifications!\n NotificationMailer.job_notification(account_manager, self).deliver_later\n end",
"def push_notifications\n pending = find_pending\n to_send = pending.map do |notification|\n notification_type.new notification.destinations, notification.data\n end\n pusher = build_pusher\n pusher.push to_send\n pending.each_with_index do |p, i|\n p.update_attributes! results: to_send[i].results\n end\n end",
"def show\n @stock = Stock.find_by(article_id: @article.id, user_id: current_user.id)\n @stocked_users = @article.stocked_users\n @article.remove_user_notification(current_user)\n end",
"def send_notification *args, &block\n if args.length == 1 && args.first.kind_of?( Rpc::Notification )\n _send_request args.first\n elsif args.length == 1 && args.first.kind_of?( Hash )\n h = args.first\n send_notification( h[\"method\"], h[\"params\"], &block )\n elsif args.length == 2\n _send_request Rpc::Notification.new(self, *args)\n else\n raise Rpc::ServerError(-1, extra_msg: \"in Rpc::Connection.send_notification : Wrong number of argument.\", args: args)\n end\n end",
"def notify(type, title, body, time: 5)\n require 'cgi'\n\n puts \"[#{type}] #{title}\"\n puts \" #{body}\"\n\n time_in_ms = time * 1000\n\n cmd = [\"notify-send\"]\n cmd << \"--expire-time=#{time_in_ms}\"\n cmd << \"--app-name=play\"\n cmd << \"--icon=#{type}\"\n cmd += [title, body].map {|s| CGI.escapeHTML s }\n\n system *cmd\nend",
"def send_email(object)\n # SomeNotifier.notification(...).deliver_now\n end",
"def send_notifications\n return if participant.nil?\n return unless participant.phone_number.length == 10\n\n # grab first 95 characters of description to serve as a preview\n description_preview = description[0...95]\n send_sms(participant.phone_number,\n \"An event in Binder has been assigned to you: #{description_preview}...\")\n end",
"def send_notification\n # Getting users of current group\n @group = Group.find(params[:id])\n @users = @group.users\n\n # Subject for mail\n if action_name == \"create\"\n subject = \"New task creation\"\n else\n subject = \"Task update\"\n end\n\n # Sending mail to each user of the group\n @users.each do |user|\n TaskMailer.task_create_notification(subject, user, @group, @task).deliver_now\n end\n\n end",
"def send_notifications!\n # The person who wrote the note, anybody who's left a comment on this note minus \"current\" comment creator\n notification_emails.each do |email|\n Notifier.comment(self, email).deliver\n end\n end",
"def will_notify\n #Resque.safe_enqueue Notification, to_user_id, id, APP::NOTIFICATIONS::MESSAGE\n end",
"def notify_admin_about_newbie(user)\n @user = user\n mail\n end",
"def send_message_notification\n message = MessageBlueprint.render_as_json(self)\n ActionCable.server.broadcast \"conversation_#{ self.conversation_id }_notification_channel\", message\n # receiver = self.conversation.user_one_id == self.user_id ? self.conversation.user_two_id : self.conversation.user_one_id\n # response = self.attributes.merge(user: self.user&.name)\n # ActionCable.server.broadcast \"user_#{ receiver }_notification_channel\", response.as_json.to_s\n end",
"def deliver_push_notification\n return unless push_notification_sent_at.nil? # avoid double send\n return if self.user == self.created_by # dont deliver if user liked own post\n return if event_type == \"push\" || event_type == \"purchase\"\n device_tokens = self.user.push_devices.map(&:token)\n return if device_tokens.blank?\n puts 'CREATING PUSH'\n badge = self.user.events.unread.count\n notification = { :device_tokens => device_tokens,\n :page => push_page,\n :aps => { :alert => push_alert, \n :badge => badge}}\n \n update_attribute(:push_notification_sent_at, Time.now) if Urbanairship.push(notification)\n end",
"def report_notifier(supplier)\n\t @supplier = supplier\n\t mail(:to => supplier.email,\n\t :subject => \"#{supplier.first_name} you just recieved a report on your local market-place\")\n end",
"def send_reply\n if self.response_changed?\n @notifiable = self\n @tutor = User.find(self.user_id)\n @student = User.find(self.pupil_id)\n\n if self.response == \"Declined\"\n @description = self.pupil.title + \" has sadly declined your offer\"\n @notifiable.notifications.create(:user => @tutor ,:receiver_id => @student.id, :message => 'You hve declined the offer by ' + @tutor.title)\n else\n @description = self.pupil.title + \" is now a student at your school\"\n @notifiable.notifications.create(:user => @tutor ,:receiver_id => @student.id, :message => 'You are now a student of ' + @tutor.title)\n end\n @notifiable.notifications.create(:user => @student, :receiver_id => @tutor.id, :message => @description)\n end\n end",
"def notify_rating\n @pack = Packages.get_packages_rating(cookies[:user_id])\n if( @pack != nil )\n @pack.each do |t|\n @rating = Packages.get_packages_find_rating(t.id)\n @rate = Packages.get_packages_find_rate(t.id)\n @rates = Packages.get_packages_find_rates(t.id)\n if( @rating == true ) && ( @rates != nil )\n @notification = Notifications.create(@rate, \"You have been rated on a specific package\")\n end\n end\n end\n return;\n end",
"def review_notification(book,user)\n @greeting = \"Hi\"\n @book=book\n @user=user\n mail to: user.email\n end",
"def follow_notification\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def stream_merchant_notification(stream, merchant)\n @stream = stream\n I18n.locale = merchant.locale.present? ? merchant.locale : 'fr'\n @app_root_url = \"http://#{Willstream::Config.merchant_home}/\"\n @subject = t('emailer.merchant_notif.subject', \n :package_name => (@stream.stream_package.i18n_title.present? ? @stream.stream_package.i18n_title : \"Not Specified\"),\n :from_user => \"@\" + @stream.user.friendly_name,\n :amount => help.number_to_currency((@stream.amount_cents / 100), :unit => Currency.find_by_code(@stream.currency.upcase).name)).html_safe\n @headline = t('emailer.merchant_notif.headline').html_safe\n @welcome = t('emailer.hello').html_safe\n @email_body = t('emailer.merchant_notif.body',\n :from_user => \"@\" + @stream.user.friendly_name,\n :package_name => (@stream.stream_package.i18n_title.present? ? @stream.stream_package.i18n_title : \"Not Specified\"),\n :amount => help.number_to_currency((@stream.amount_cents / 100), :unit => Currency.find_by_code(@stream.currency.upcase).name),\n :stream_number => @stream.code,\n :instructions => @stream.sender_notes.present? ? @stream.sender_notes : \"None Specified\",\n :profile_link => @app_root_url + merchant.username).html_safe\n @goodbye = t('emailer.merchant_notif.goodbye').html_safe\n\n if merchant.cell_number.present?\n begin\n SMS.send(SMS.i18n_dest(merchant.cell_number, merchant.country), t(\"emailer.merchant_notif.#{@stream.stream_package.present? ? @stream.stream_package.merchant.username : ''}.sms\", \n :from_user => @stream.user.friendly_name,\n :package_name => (@stream.stream_package.i18n_title.present? ? @stream.stream_package.i18n_title : \"Not Specified\"),\n :amount => help.number_to_currency((@stream.amount_cents / 100), :unit => Currency.find_by_code(@stream.currency.upcase).name),\n :default => t('emailer.merchant_notif.sms', \n :from_user => @stream.user.friendly_name,\n :package_name => (@stream.stream_package.i18n_title.present? ? @stream.stream_package.i18n_title : \"Not Specified\"),\n :amount => help.number_to_currency((@stream.amount_cents / 100), :unit => Currency.find_by_code(@stream.currency.upcase).name))))\n if @stream.sender_notes.present?\n SMS.send(SMS.i18n_dest(merchant.cell_number, merchant.country), t('emailer.merchant_notif.sms_instructions', \n :from_user => @stream.user.friendly_name,\n :instructions => @stream.sender_notes))\n end\n rescue Exception => e\n Rails.logger.info('Exception in sending SMS stream notification to merchant.')\n end\n end\n \n mail_it_with_bcc(merchant.email, Willstream::Config.outgoing_email, @subject, @@page_stack)\n end",
"def send_notifications\n\t\tphones_sent_to = []\n\t\temails_sent_to = []\n\t\tgather_recipients.each do |recipient|\n\t\t\trecipient.phone_numbers.each do |phone_number|\n\t\t\t\tnext if phones_sent_to.include? phone_number\n\t\t\t\tphones_sent_to << phone_number\n\t\t\t\tresponse = Auth::TwoFactorOtp.send_transactional_sms_new({\n\t\t\t\t\t:to_number => phone_number,\n\t\t\t\t\t:template_name => REPORT_UPDATED_TEMPLATE_NAME,\n\t\t\t\t\t:var_hash => {:VAR1 => self.patient.first_name, :VAR2 => self.patient.last_name, :VAR3 => self.pdf_url, :VAR4 => self.created_by_user.organization.name },\n\t\t\t\t\t:template_sender_id => REPORT_UPDATED_SENDER_ID\n\t\t\t\t})\n\t\t\tend\n\t\t\tunless recipient.email_ids.blank?\n\t\t\t\temail = OrderMailer.report(recipient,self,self.created_by_user,(recipient.email_ids - emails_sent_to))\n\t \temail.deliver_now\n\t \temails_sent_to << recipient.email_ids\n\t \temails_sent_to.flatten!\n \tend\n \tend\n\tend",
"def watching_notification\n @sender = @watchable.user\n @user = @receiver\n path = \"/#{@watchable.class.name.downcase.pluralize}/#{@watchable.id}\"\n @notification = @user.notifications.find_by(path: path)\n subject = \"[bootcamp] #{@sender.login_name}さんの【 #{@watchable.notification_title} 】に#{@comment.user.login_name}さんがコメントしました。\"\n mail to: @user.email, subject: subject\n end",
"def reminder_sent\n end"
] | [
"0.73721886",
"0.73449826",
"0.71610636",
"0.6872814",
"0.6637226",
"0.6635139",
"0.66228795",
"0.6585056",
"0.65536994",
"0.6525725",
"0.6491291",
"0.649094",
"0.64850265",
"0.6447033",
"0.6393853",
"0.63435215",
"0.6330944",
"0.63294995",
"0.63139546",
"0.62862146",
"0.6263799",
"0.6259637",
"0.6238674",
"0.621684",
"0.62055695",
"0.6175671",
"0.6154083",
"0.6153323",
"0.61519873",
"0.61443275",
"0.6143934",
"0.61417514",
"0.6137595",
"0.6132382",
"0.61311215",
"0.61296546",
"0.6127905",
"0.61164194",
"0.6111778",
"0.6106891",
"0.608173",
"0.6060958",
"0.60564375",
"0.6054401",
"0.6042907",
"0.6042137",
"0.6041728",
"0.60215896",
"0.6017558",
"0.6015741",
"0.6004908",
"0.59999514",
"0.5999131",
"0.599848",
"0.59765923",
"0.5962804",
"0.59590673",
"0.59535986",
"0.5946539",
"0.59459776",
"0.5934567",
"0.59302694",
"0.5928023",
"0.5924437",
"0.59198487",
"0.59099936",
"0.59085566",
"0.5905354",
"0.5894236",
"0.5893366",
"0.5892283",
"0.58918446",
"0.58888865",
"0.5888296",
"0.58874893",
"0.58802646",
"0.5877508",
"0.587722",
"0.5870782",
"0.58563566",
"0.5847015",
"0.58177245",
"0.5814974",
"0.58146375",
"0.58043927",
"0.5802159",
"0.5796073",
"0.5791226",
"0.57821244",
"0.5779762",
"0.57744503",
"0.57707465",
"0.57659703",
"0.5765263",
"0.57625306",
"0.57625294",
"0.5762492",
"0.5761222",
"0.576",
"0.5758639"
] | 0.75482106 | 0 |
Sets the current records adjusted_at attribute to the current time and date | def set_current_time_as_adjusted
self.adjusted_at = Time.current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_sighted_at\n\t\tif @sighted_date.present?\n\t\t\tself[:sighted_at] = Time.zone.parse(\"#{@sighted_date} #{@sighted_time}\")\n\t\tend\n\t\tif self[:sighted_at].blank?\n\t\t\tself[:sighted_at] = Time.zone.now\n\t\tend\n\tend",
"def set_updated_at\n if able_to_set_updated_at?\n self.updated_at = Time.configured.now unless updated_at_changed?\n end\n\n clear_timeless_option\n end",
"def issued_at= new_issued_at\n @issued_at = normalize_timestamp new_issued_at\n end",
"def update_reviewed_at\n self.reviewed_at = Time.zone.now if just_reviewed?\n end",
"def extendbyfourteendays\n updated_at = Time.now\n end",
"def _update_timestamps\n if self.respond_to?('updated_at')\n self.updated_at = Time.now\n end\n end",
"def adjust_due_date_for_timezone(dd)\n dd.due_at = dd.due_at.to_s.in_time_zone(current_user.timezonepref) if dd.due_at.present?\n end",
"def update_now_date_time\n @now_date_time = Time.new\n end",
"def update_time_date\n start_year = self.start_at.change(:year => self.lesson_date.year)\n start_month = start_year.change(:month => self.lesson_date.month)\n start_day = start_month.change(:day => self.lesson_date.day)\n self.start_at = start_day\n\n end_year = self.end_at.change(:year => self.lesson_date.year)\n end_month = end_year.change(:month => self.lesson_date.month)\n end_day = end_month.change(:day => self.lesson_date.day)\n self.end_at = end_day\n end",
"def requested_at=(val)\n @requested_at = TicketSharing::Time.new(val)\n end",
"def spent_on=(date)\n super\n self.tyear = spent_on ? spent_on.year : nil\n self.tmonth = spent_on ? spent_on.month : nil\n self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil\n self.spent_from = date\n self.spent_to = self.spent_from.advance(:hours=>hours) if self.spent_from && hours\n end",
"def bump_timestamps\n self.updated_at = Time.now.utc\n end",
"def set_date\n @current_date = Time.now\n end",
"def adjust_admission_date(options ={})\n if options[:days_to_adjust]\n days_to_adjust = options[:days_to_adjust]\n d = Date.strptime(Time.now.strftime('%Y-%m-%d'))\n my_set_date = ((d - days_to_adjust).strftime(\"%d-%b-%y\").upcase).to_s\n end\n Database.connect\n if options[:set_date] # adjust date for specific date\n q = \"update SLMC.TXN_ADM_ENCOUNTER set ADM_DATETIME = '#{options[:set_date]}' where PIN = '#{options[:pin]}'\"\n elsif options[:with_discharge_date]\n q = \"update SLMC.TXN_ADM_ENCOUNTER set ADM_DATETIME = '#{my_set_date}', CREATED_DATETIME = '#{my_set_date}' where PIN = '#{options[:pin]}'\"\n else # adjust date based on days to adjust\n q = \"update SLMC.TXN_ADM_ENCOUNTER set ADM_DATETIME = '#{my_set_date}', UPDATED_DATETIME = '#{Time.now.strftime('%d-%b-%y').upcase}' where PIN = '#{options[:pin]}' and VISIT_NO = '#{options[:visit_no]}'\"\n end\n Database.update_statement q\n Database.logoff\n return my_set_date\n end",
"def set_delivered_at\n self.delivered_at = Date.today\n end",
"def set_completed_at_time\n self.update_attributes completed_at: Time.now\n end",
"def set_record_created_at\n self.record_created_at = Time.current.utc.iso8601(3)\n end",
"def assign_submitted_at!\n @customer_order.assign_attributes(\n submitted_at: Time.now\n )\n end",
"def update_current_price_date\n\t\tself.current_price_date = DateTime.now \n\tend",
"def rates_timestamp=(at)\n @rates_timestamp = Time.at(at)\n end",
"def applied_date_time=(value)\n @applied_date_time = value\n end",
"def assign_date_submitted_to_current_time\n self.date_submitted = DateTime.now unless persisted?\n end",
"def started_at=(started_at)\n self[:started_at]=(started_at)\n update_finish_at\n end",
"def set_updated!\n @updated_at = Time.now\n end",
"def force_updated_on_change\n if @current_journal || changed?\n self.updated_on = current_time_from_proper_timezone\n if new_record?\n self.created_on = updated_on\n end\n end\n end",
"def set_current_time\n current_time = Time.zone.now.strftime(\"%B %e at %I:%M %p\")\n self.start_time = current_time\n end",
"def audit_update\n self.modified_date = DateTime.now\n if self.created_date.blank?\n self.created_date = DateTime.now\n end\n end",
"def expires_at= new_expires_at\n @expires_at = normalize_timestamp new_expires_at\n end",
"def extendbythirthydays\n update_at = update_at + 14.days.from_now\n end",
"def touch\n now = Time.current.utc\n self.updated_at = now\n self.created_at = now if new_record?\n end",
"def convert_happened_at_to_utc\n self[:happened_at] = self.person && self.person.user ? self.person.user.user2utc(self[:happened_at]) : self[:happened_at]\n end",
"def adjust_current_date\n session[:date] = Date.today\n return true\n end",
"def _updated_at(target)\n result = rate(@original, target)\n \n result[:updated_at]\n end",
"def set_target_updated_on_save\n self.target_updated_at = target.updated_at\n end",
"def current_end_time\n self.ends_at = DateTime.current\n save\n end",
"def due_at\n apply_extension(assessment.due_at, extension)\n end",
"def update \n update = object.updated_at\n end",
"def align_times\n # if booking the same day, then starts_at is in one minute from now.\n earliest_possible_starts_at = ( self.starts_at.to_date == Date.today ) ? ( DateTime.now + 1.minute ) : self.starts_at.beginning_of_day\n self.attributes = {\n starts_at: earliest_possible_starts_at,\n ends_at: self.ends_at.end_of_day\n }\n end",
"def at\n Timestamp.utc(@timestamp_value)\n end",
"def pay_date= datetime\n if datetime\n datetime = User.current.system_time(datetime)\n end\n write_attribute(:pay_date, datetime)\n end",
"def updated_at=(value)\n @updated_at = DateTime.parse(value)\n end",
"def set_created_at\n if !timeless? && !created_at\n time = Time.configured.now\n self.updated_at = time if is_a?(Updated) && !updated_at_changed?\n self.created_at = time\n end\n clear_timeless_option\n end",
"def at(*args)\n Time.at(*args).utc.in_time_zone(self)\n end",
"def working!\n @meta[Cworked_at] = Time.now.utc\n put_meta\n end",
"def at\n # Thread-safety: It is possible that the value of @at may be calculated\n # multiple times in concurrently executing threads. It is not worth the\n # overhead of locking to ensure that @at is only calculated once.\n\n @at ||= TimeOrDateTime.new(@timestamp)\n end",
"def format_datetime\n self.start_time = self.start_time.in_time_zone(\"UTC\")\n end",
"def format_datetime\n self.start_time = self.start_time.in_time_zone(\"UTC\")\n end",
"def adjust_timezone(offset)\n if offset\n ActiveSupport::TimeZone[offset]\n adjusted_time = Time.now + offset.seconds\n Time.stub(:now).and_return(adjusted_time)\n end\n end",
"def set_created_at\n self.created_at ||= Date.today if new_record?\n end",
"def current_play_at\n return Time.zone.parse(\"#{Time.now.to_date.year}-#{Time.now.to_date.month}-#{Time.now.to_date.day} #{self.play_at.hour}:#{self.play_at.min}\")\n end",
"def update_timestamp(*_args)\n current_time = current_time_from_proper_timezone\n\n write_attribute('updated_at', current_time) if respond_to?(:updated_at)\n write_attribute('updated_on', current_time) if respond_to?(:updated_on)\n end",
"def set_for_time timestamp\n return nil unless @date\n case timestamp[0,2]\n when \"00\"\n @datetime.hour == 23 ? @date_add_1_hr : @date\n when \"23\"\n @datetime.hour == 00 ? @date_1_hr_ago : @date\n else\n @date\n end\n end",
"def set_now(the_date)\n @@now = the_date\n end",
"def adjust_timeframe(timeframe)\n timeframe\n end",
"def set_starts_at_time_and_date\n self.starts_at_time = starts_at.strftime(\"%H:%M\")\n self.starts_at_date = starts_at.strftime(\"%Y-%m-%d\")\n end",
"def adjust_after_update\n # The record is in @record, do what you will, this precedes a save.\n end",
"def starts_at=(date)\n super(date)\n set_ends_at\n end",
"def acquired_date_time=(value)\n @acquired_date_time = value\n end",
"def adjust_timezone(offset)\n if offset\n ActiveSupport::TimeZone[offset]\n adjusted_time = Time.now + offset.seconds\n allow(Time).to receive(:now).and_return(adjusted_time)\n end\nend",
"def update_status_timestamp\n self.overall_status_modified_at = Time.zone.now\n end",
"def set_last_active_at\n self.last_active_at = Time.now\n end",
"def rent!\n @rented_at = Time.now\n end",
"def mark_no_longer_current\n update_attributes(ended_at: Time.current)\n end",
"def update_relatives_dates\n return if new_record?\n return unless force_relatives_dates\n return unless starts_at_changed? || ends_at_changed?\n return unless recurrence.present?\n return unless future_relatives.any?\n\n future_relatives.each do |outing|\n outing.assign_attributes(metadata: outing.metadata.merge({\n starts_at: outing.metadata[:starts_at] + (self.metadata[:starts_at] - starts_at_was),\n ends_at: outing.metadata[:ends_at] + (self.metadata[:ends_at] - ends_at_was)\n }))\n end\n end",
"def state_changed_at\n if occurred_at\n now = Time.zone.now\n occurred_at + now.hour.hours + now.min.minutes\n else\n Time.zone.now\n end\n end",
"def update_last_activity_at\n current_user.last_activity_at = Time.zone.now if current_user\n end",
"def spent_on=(date)\n super\n if spent_on.is_a?(Time)\n self.spent_on = spent_on.to_date\n end\n self.tyear = spent_on ? spent_on.year : nil\n self.tmonth = spent_on ? spent_on.month : nil\n self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil\n end",
"def track\n if started?\n if @remaining_at_start.nil?\n @remaining_at_start = remaining_now\n end\n if @asap_remaining_at_start.nil?\n @asap_remaining_at_start = asap_remaining_now\n end\n\n if @planned.nil? || !plan_locked?\n @planned = planned_now\n end\n end\n \n if ended?\n if @remaining_at_end.nil?\n @remaining_at_end = remaining_now\n end\n if @completed.nil?\n @completed = completed_now\n end\n if @carry_over.nil?\n @carry_over = carry_over_now\n end\n if @asap_remaining_at_end.nil?\n @asap_remaining_at_end = asap_remaining_now\n end\n if @asap_completed.nil?\n @asap_completed = asap_completed_now\n end\n end\n end",
"def reset_date_for_time_now\n reset_date_for_time Time.now\n end",
"def modify_time(); @modify_time ||= Time.now; end",
"def set_timezone\n Time.zone = current_account.time_zone if current_account.time_zone\n end",
"def set_ends_at\n return unless self.duration && self.starts_at\n self.ends_at = starts_at + duration.hours\n end",
"def setup_start_at\n return unless start_at.blank?\n \n self.start_at = Time.now\n end",
"def setup_start_at\n return unless start_at.blank?\n \n self.start_at = Time.now\n end",
"def salesforce_updated_at=(updated_at)\n updated_at = Time.parse(updated_at) if updated_at.present? && updated_at.kind_of?(String)\n write_attribute(:salesforce_updated_at, updated_at)\n end",
"def save\n self.saved_at = Time.now\n end",
"def set_new_time\n @dt_in = time_in.to_datetime\n update_column(:time_in, @dt_in.change(hour: hour_in.to_i, min: min_in.to_i))\n \n @dt_out = time_out.to_datetime\n update_column(:time_out, @dt_out.change(hour: hour_out.to_i, min: min_out.to_i))\n end",
"def adjust_ph_date(options ={})\n if options[:days_to_adjust]\n days_to_adjust = options[:days_to_adjust]\n d = Date.strptime(Time.now.strftime('%Y-%m-%d'))\n set_date = ((d - days_to_adjust).strftime(\"%d-%b-%y\").upcase).to_s # even though it is incorect in the table, db converts it to correct format\n end\n Database.connect\n q = \"update TXN_PBA_PH_HISTORY set PH_DATE_CLAIM = '#{set_date}' where VISIT_NO = '#{options[:visit_no]}'\"\n Database.update_statement q\n Database.logoff\n return set_date\n end",
"def pay!\n update_attributes paid: true, paid_at: DateTime.now\n end",
"def set_started_at\n if @started_at_date_string && @started_at_time_string\n self.start_date_time = Time.parse(\"#{@started_at_date_string} #{@started_at_time_string}\")\n end\n end",
"def update_coupon!\n coupon.update(last_applied_at: Time.now)\n end",
"def set_timestamps\n self.created_at = Time.now\n #Set updated_at initially before manually setting because column cannot be null.\n self.updated_at = Time.now \n end",
"def stamp_new_rows\n db.query(\"UPDATE #{audit} SET `_copied_at` = NOW() WHERE `_copied_at` IS NULL\")\n end",
"def set_review_date\n self.review_date = Time.now\n end",
"def updated_at_datetime\n @updated_at_datetime ||= DateTime.parse(@updated_at)\n end",
"def set_authorized_at\n\t\tself.authorized_at = Time.now\n\tend",
"def set_akt\n @akt = Akt.notdeleted.find(params[:id])\n @akt.from_date = @akt.from_date.strftime(\"%d.%m.%Y\")\n end",
"def spent_on=(date)\n super\n self.tyear = spent_on ? spent_on.year : nil\n self.tmonth = spent_on ? spent_on.month : nil\n self.tweek = spent_on ? spent_on.cweek : nil\n end",
"def updated_at\n dateChanged\n end",
"def set_expires_at\n self[:expires_at] = case self.expiry_option \n when :in then Time.now.utc + (self.expiry_days || DEFAULT_EXPIRY_DAYS).days\n when :on then self[:expires_at]\n else self[:expires_at]\n end\n end",
"def update_actual_duration\n self.actual_duration = Date.today - self.startDate\n end",
"def next_scheduled_at\n reviewed_at + (24.hours * next_interval)\n end",
"def set_join_date\n membership = current_membership\n membership.join_date = Time.zone.now\n membership.save\n end",
"def acquired_at\n buy_date.present? ? buy_date : stock.create_time\n end",
"def toggle\n if completed_at\n attribute_set(:completed_at, nil)\n else\n attribute_set(:completed_at, DateTime.now) # TODO look into timezone support\n end\n end",
"def toggle\n if completed_at\n attribute_set(:completed_at, nil)\n else\n attribute_set(:completed_at, DateTime.now) # TODO look into timezone support\n end\n end",
"def adjust(start,finish)\n @start=DateTime.new(start.year,start.month,start.day)\n @finish=DateTime.new(finish.year,finish.month,finish.day)\n refresh\n end",
"def update\n @setting = Setting.find(params[:id])\n @setting.notice_at = Time.local(2011, 10, 31, @setting.notice_at.hour, @setting.notice_at.min)\n @setting.update_attributes(params[:setting])\n respond_to do |format|\n format.html { redirect_to(setting_url(@setting))}\n format.xml { head :ok }\n end\n end",
"def updated_at\n Time.at @updated rescue nil\n end",
"def set_now\n @now = Now.find(params[:id])\n end"
] | [
"0.5992446",
"0.592903",
"0.5926469",
"0.5919316",
"0.5898268",
"0.58564746",
"0.5724203",
"0.57104325",
"0.57076234",
"0.5667148",
"0.56484866",
"0.56414944",
"0.56326264",
"0.56251705",
"0.5622111",
"0.56204075",
"0.5602487",
"0.559619",
"0.5578143",
"0.5569054",
"0.54980856",
"0.5484051",
"0.54529923",
"0.54377186",
"0.54334414",
"0.5421096",
"0.5420141",
"0.541942",
"0.5410536",
"0.5398619",
"0.5396425",
"0.53869635",
"0.5384409",
"0.53768134",
"0.5366445",
"0.53472704",
"0.53445363",
"0.5335909",
"0.53308946",
"0.5324325",
"0.5311277",
"0.53079265",
"0.53032583",
"0.53003913",
"0.52940226",
"0.5285362",
"0.5285362",
"0.5279742",
"0.5278969",
"0.5276822",
"0.5265342",
"0.5264708",
"0.5261172",
"0.5256839",
"0.5240933",
"0.52384305",
"0.5227618",
"0.5227573",
"0.5223149",
"0.5220957",
"0.5219413",
"0.5211191",
"0.5199249",
"0.51917934",
"0.5184056",
"0.51761305",
"0.5170257",
"0.51594996",
"0.5147211",
"0.5142405",
"0.51379466",
"0.51376534",
"0.51362956",
"0.51362956",
"0.51353794",
"0.5102849",
"0.51002383",
"0.5097374",
"0.50897443",
"0.5089527",
"0.50889933",
"0.5088081",
"0.5072859",
"0.5065859",
"0.5049989",
"0.50368756",
"0.5030817",
"0.50226724",
"0.5019487",
"0.5014786",
"0.49992633",
"0.49973696",
"0.49946448",
"0.49907178",
"0.49820474",
"0.49820474",
"0.49804443",
"0.4967628",
"0.49508816",
"0.49481198"
] | 0.8532305 | 0 |
vi: set ft=ruby : | def gen_node_infos(cluster_yml)
master_n = 1
master_mem = cluster_yml['master_mem']
master_cpus = cluster_yml['master_cpus']
slave_n = cluster_yml['slave_n']
slave_mem = cluster_yml['slave_mem']
slave_cpus = cluster_yml['slave_cpus']
master_ipbase = cluster_yml['master_ipbase']
slave_ipbase = cluster_yml['slave_ipbase']
master_infos = (1..master_n).map do |i|
{ :hostname => "master#{i}",
:ip => master_ipbase + "#{10+i}",
:mem => master_mem,
:cpus => master_cpus
}
end
slave_infos = (1..slave_n).map do |i|
{ :hostname => "slave#{i}",
:ip => slave_ipbase + "#{10+i}",
:mem => slave_mem,
:cpus => slave_cpus
}
end
analytics_node = cluster_yml['analytics_node']
analytics_mem = cluster_yml['analytics_mem']
analytics_cpus = cluster_yml['analytics_cpus']
analytics_info = {
:node => analytics_node,
:mem => analytics_mem,
:cpus => analytics_cpus
}
return { :master => master_infos, :slave=>slave_infos, :analytics=>analytics_info }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def result_of_executing_the_commands\n @commands = \":set ft=ruby\r\" + @commands\n RobotVim::Runner.new.run(:input_file => @input, :commands => @commands)\nend",
"def ruby\n unless @ruby\n @ruby = \"\"\n @body.each_line do |l|\n @commands << {:ruby => l}\n @ruby << l\n end\n end \n @ruby\n end",
"def pygment_code_block(block)\n write_data block, 'code.rb', false\n system 'pygmentize -o block.html code.rb'\n File.open('block.html', 'r').read\n end",
"def vi\n system \"vim ~/.scratchvim.rb\"\nend",
"def vim_mappings\n { \n \"VI_SELECTED_TEXT\" => \"getreg()\",\n \"VI_FILENAME\" => \"@%\",\n \"VI_CURRENT_LINE\" => \"getline(\\\".\\\")\",\n \"VI_SOFT_TABS\" => \"&expandtab\"\n }\n end",
"def format_code strip = true\n format_ruby self.code, strip\n end",
"def convert_to_ruby (src)\n rb = \"\"\n # dunno how to deal with only leading declarations of ruby code,\n # so replace it with the other markings\n src.gsub!(/-%>/,\"%>\")\n while\tsrc.index(Embedded_ruby_line) != nil\n src.sub!(Embedded_ruby_line) { |match|\n match[match.index '%'] = \" \"\n \"<% \" + match + \" %>\"\n }\n end\n lines = src.split(Embedded_ruby_flag)\n\n is_ruby_line = false\n lines.each { |line|\n if (line.strip != \"\" and line.strip != nil)\n if is_ruby_line\n if line[0,1] == '='\n # line[0] = \" \"\n # rb += \"puts \" + line.strip\n rb+=\"gr_html_puts \"+line.strip\n else\n rb += line.strip\n end\n else\n rb += \"gr_html( \" + line.inspect + \" )\"\n end\n rb += \"\\n\"\n end\n is_ruby_line = (not is_ruby_line)\n }\n #puts rb\n return rb\n end",
"def history_to_vi\n handling_jruby_bug do\n file = Tempfile.new(\"irb_tempfile\")\n get_lines(0..(Readline::HISTORY.size - 1)).each do |line|\n file << \"#{line}\\n\"\n end\n file.close\n system(\"vim #{file.path}\")\n end\nend",
"def vietnamese_writing_instructions\n return '' unless CONF[:locale] == 'vi'\n <<-EOL\n<p>#{vietnamese_smart_questions}</p>\n<p>Nến tránh viết tắt. <b>Dấu câu nên viết vào sát chữ trước nó, dấu câu và chữ sau nó nên cách một khoảng trắng.</b></p>\n<ul>\n <li>\"Tôi là Hòa . Tôi là sinh viên.Bạn tên gì ?\" --> \"Tôi là Hòa. Tôi là sinh viên. Bạn tên gì?\"</li>\n <li>\"2 lựa chọn : bút , thước\" --> \"2 lựa chọn: bút, thước\"</li>\n</ul>\nEOL\n end",
"def textile_ruby( tag, atts, cite, content )\n %(<pre><code class=\"ruby\">#{content}</pre></code>)\n end",
"def rubyize!\n\n self.definition = Ruote::Reader.to_ruby(tree).strip\n end",
"def set_up\n vim.command 'set number'\n vim.command 'hi Visual guifg=#FFFF00 guibg=#003322 gui=none'\n vim.edit filename\n vim.feedkeys '\\\\<esc>'\n sleep 2 if WITH_PAUSES\nend",
"def highlight(code, lang, options = T.unsafe(nil), format = T.unsafe(nil)); end",
"def vix\n Object.class_eval `cat ~/.scratchvim.rb`\nend",
"def indent()\n file = Tempfile.new(\"out\")\n infile = Tempfile.new(\"in\")\n file.write(self.to_s)\n file.flush\n bufc = \"FOO\"\n\n tmppos = @pos\n\n message(\"Auto format #{@fname}\")\n\n if [\"chdr\", \"c\", \"cpp\"].include?(get_file_type())\n\n #C/C++/Java/JavaScript/Objective-C/Protobuf code\n system(\"clang-format -style='{BasedOnStyle: LLVM, ColumnLimit: 100, SortIncludes: false}' #{file.path} > #{infile.path}\")\n bufc = IO.read(infile.path)\n elsif get_file_type() == \"Javascript\"\n cmd = \"clang-format #{file.path} > #{infile.path}'\"\n debug cmd\n system(cmd)\n bufc = IO.read(infile.path)\n elsif get_file_type() == \"ruby\"\n cmd = \"rufo #{file.path}\"\n debug cmd\n system(cmd)\n bufc = IO.read(file.path)\n else\n return\n end\n self.update_content(bufc)\n center_on_current_line #TODO: needed?\n file.close; file.unlink\n infile.close; infile.unlink\n end",
"def to_s # {{{\n c = wrap( self.content.to_s.chomp )\n t = wrap( self.title.to_s.chomp )\n\n<<EOS\n|^\\___________________ [ #{self.source.to_s } ] _________________________________/^|\n\n\\t'#{t}'\n\n\\t#{c}\n\n|/^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\|\n\nEOS\n end",
"def imitate_code(txt)\n \"%#{txt};;\"\n end",
"def beautify; end",
"def beautify; end",
"def lines_of_code; end",
"def lines_of_code; end",
"def to_s_with_ruby(opt=nil)\n (opt != :ruby) ? to_s_without_ruby : begin\n @to_s ||= begin\n res = to_ruby\n res.gsub!(/\\Aproc \\{ /, \"def #{name}\") # Replace proc definition\n res.gsub!(/\\|([^\\|]*)\\|\\n/, \"(#{'\\1'})\\n\") # Use method param declaration\n res.gsub!(/\\}\\z/, 'end') # Replace proc end brace\n res\n end\n end\n end",
"def highlight(code, options = T.unsafe(nil)); end",
"def highlight(code, lang, options = T.unsafe(nil)); end",
"def source_line=(_); end",
"def highlight_code(text, lang, type, opts = T.unsafe(nil)); end",
"def compile_to_ruby\n \"\"\n end",
"def restore_cursor; puts \"\\e[u\" end",
"def highlight_codes\n #@content.gsub!(/%(.*?){(.*?)}%/m) do # %{ some code }%\n @content.gsub!(/^```(.*?)\\n(.*?)\\n```/m) do # github like: http://github.github.com/github-flavored-markdown/\n lang = :text\n lang = $1 if $1 != \"\"\n Albino.colorize($2, lang)\n end\n end",
"def change_quotemarks!\n local_copy.in_place :perl, \"s/\\\"/'/g\"\n end",
"def my_name_is\n # and my code is here\n # two spaces for tabs in Ruby\nend",
"def rubyify(sentence)\r\n\r\nend",
"def source_line; end",
"def parse_lang_for_codeblock(source); end",
"def block_code(text, lang=\"\")\n lang ||= lang.to_s\n result = \"```#{lang}\\n\"\n if lang.match RUBY_LANG\n result << ColorCode::Ruby.new(text).colorize\n else\n result << ColorCode::Unknown.new(text).colorize\n end\n result << \"```\\n\"\n result\n end",
"def formatted_source_file(source_file); end",
"def ruby_code(obj); end",
"def highlight_file(filename, options = T.unsafe(nil), format = T.unsafe(nil)); end",
"def autofinish; end",
"def rl_vi_editing_mode(count, key)\r\n 0\r\n end",
"def vputs(text)\n puts text if $verbose\nend",
"def code_start(language, caption)\n\n if language == 'console'\n column_style = 'columns=fixed,'\n else\n column_style = ''\n end\n\n if caption.nil?\n caption_command = ''\n else\n caption_command = \"title={#{caption}},aboveskip=-0.4 \\\\baselineskip,\"\n end\n\n @io << @templates[:code_start].result(binding)\n end",
"def indentation; end",
"def indentation; end",
"def bf_to_your_syntax(file)\n dsl = read_dsl\n code = read_code(file)\n config = dsl.orenono\n convert(code, config.default_syntaxes, config.syntaxes)\n end",
"def edit\n puts \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n end",
"def visit_script(node, &block)\n raw_first_line = @original_haml_lines[node.line - 1]\n\n # ==, !, !==, &, &== means interpolation (was needed before HAML 2.2... it's still supported)\n # =, !=, &= mean actual ruby code is coming\n # Anything else is interpolation\n # The regex lists the case for Ruby Code. The 3 cases and making sure they are not followed by another = sign\n\n match = raw_first_line.match(/\\A\\s*(=|!=|&=)(?!=)/)\n unless match\n # The line doesn't start with a - or a =, this is actually a \"plain\"\n # that contains interpolation.\n indent = raw_first_line.index(/\\S/)\n @ruby_chunks << PlaceholderMarkerChunk.new(node, 'interpolation', indent: indent)\n lines = extract_piped_plain_multilines(node.line - 1)\n add_interpolation_chunks(node, lines.join(\"\\n\"), node.line - 1, indent: indent)\n return\n end\n\n script_prefix = match[1]\n _first_line_offset, lines = extract_raw_ruby_lines(node.script, node.line - 1)\n # We want the actual indentation and prefix for the first line\n first_line = lines[0] = @original_haml_lines[node.line - 1].rstrip\n process_multiline!(first_line)\n\n lines[0] = lines[0].sub(/(#{script_prefix}[ \\t]?)/, '')\n line_indentation = Regexp.last_match(1).size\n\n raw_code = lines.join(\"\\n\")\n\n if lines[0][/\\S/] == '#'\n # a \"=\" script that only contains a comment... No need for the \"HL.out = \" prefix,\n # just treat it as comment which will turn into a \"-\" comment\n else\n lines[0] = HamlLint::Utils.insert_after_indentation(lines[0], script_output_prefix)\n end\n\n indent_delta = script_output_prefix.size - line_indentation\n HamlLint::Utils.map_after_first!(lines) do |line|\n HamlLint::Utils.indent(line, indent_delta)\n end\n\n prev_chunk = @ruby_chunks.last\n if prev_chunk.is_a?(ScriptChunk) &&\n prev_chunk.node.type == :script &&\n prev_chunk.node == node.parent\n # When an outputting script is nested under another outputting script,\n # we want to block them from being merged together by rubocop, because\n # this doesn't make sense in HAML.\n # Example:\n # = if this_is_short\n # = this_is_short_too\n # Could become (after RuboCop):\n # HL.out = (HL.out = this_is_short_too if this_is_short)\n # Or in (broken) HAML style:\n # = this_is_short_too = if this_is_short\n # By forcing this to start a chunk, there will be extra placeholders which\n # blocks rubocop from merging the lines.\n must_start_chunk = true\n elsif script_prefix != '='\n # In the few cases where &= and != are used to start the script,\n # We need to remember and put it back in the final HAML. Fusing scripts together\n # would make that basically impossible. Instead, a script has a \"first_output_prefix\"\n # field for this specific case\n must_start_chunk = true\n end\n\n finish_visit_any_script(node, lines, raw_code: raw_code, must_start_chunk: must_start_chunk,\n first_output_prefix: script_prefix, &block)\n end",
"def codify(txt)\n enclose('code', txt)\n end",
"def vprint(text)\n print text if $verbose\nend",
"def lex_en_line_begin; end",
"def lex_en_line_begin; end",
"def lex_en_line_begin; end",
"def write(io)\r\n if type == :code\r\n print text\r\n elsif type == :verbatim\r\n output = \" \"*pre_indent + $prefix + \" \"*first_post_indent + text + \"\\n\"\r\n output.entabify! if $retabify\r\n print output\r\n elsif type == :comment\r\n cur_post_indent = first_post_indent\r\n # special case of a line that is just $prefix\r\n if text.length == 0\r\n print \" \"*pre_indent + $prefix + \" \"*cur_post_indent + \"\\n\"\r\n end\r\n while text.length > 0\r\n width = $cols - pre_indent - $prefix.length - cur_post_indent\r\n if first_word.length > width\r\n STDERR.print \"Warning: #{first_word} is too long to fit in column.\"\r\n output = \" \"*pre_indent + $prefix + \" \"*cur_post_indent + \r\n first_word + \"\\n\"\r\n output.entabify! if $retabify\r\n print output\r\n trim(first_word.length)\r\n @text.lstrip!\r\n else\r\n out = words_to(width)\r\n output = \" \"*pre_indent + $prefix + \" \"*cur_post_indent + out + \"\\n\"\r\n output.entabify! if $retabify\r\n print output\r\n trim(out.length)\r\n @text.lstrip!\r\n end\r\n cur_post_indent = post_indent\r\n end\r\n else\r\n STDERR.print \"Confused, never determined block type.\"\r\n end\r\n end",
"def tt; end",
"def commands_for_vm\n [{:write_file => {:filename => @filename, :content => @code}},\n {:execute => {:command => \"#{VM_PYTHON} -c \\\"compile(open('#{@filename}').read(), '', 'exec')\\\" && echo success\",\n :stdout => 'syntaxchecksuccess',\n :stderr => 'syntaxcheckfail'}}]\n # in this case execution only triggers the initial syntax check, the rest is handled\n # in postprocess_print\n end",
"def poem &block\n annotate block do |c|\n c.split(\"\\n\").join(\" \\n\")\n end\nend",
"def file_mode(m)\n Cucumber::RUBY_1_9 ? \"#{m}:#{keyword_hash['encoding']}\" : m\n end",
"def generate_ruby sexp\n ruby = Ruby2Ruby.new.process(sexp)\n ruby.sub!(/\\A(def \\S+)\\(([^\\)]*)\\)/, '\\1 |\\2|') # move args\n ruby.sub!(/\\Adef[^\\n\\|]+/, 'proc { ') # strip def name\n ruby.sub!(/end\\Z/, '}') # strip end\n ruby.gsub!(/\\s+$/, '') # trailing WS bugs me\n ruby\n end",
"def line=(_); end",
"def line=(_); end",
"def current_snippets\n self[Vim.evaluate('&filetype')]\n end",
"def to_ruby\n res = []\n res.push global_code unless global_code.empty?\n res.push \"control #{id.inspect} do\"\n res.push \" title #{title.inspect}\" unless title.to_s.empty?\n res.push \" desc #{descriptions[:default].inspect}\" unless descriptions[:default].to_s.empty?\n res.push \" impact #{impact}\" unless impact.nil?\n tags.each do |t|\n res.push(\" #{t.to_ruby}\")\n end\n res.push control_code unless control_code.empty?\n res.push 'end'\n res.join(\"\\n\")\n end",
"def section_seperator\n puts <<EOF\n\n\n\n=========================\n=========================\nEOF\nend",
"def transcode_script_header\n <<~HEREDOC\n #!/bin/sh\n\n # Check this file, make any changes, and save it. Execute it directly,\n # or execute it with the sh command if it's not executable.\n\n set -e\n\n HEREDOC\n end",
"def putsv(string)\n puts string if $VERBOSE\nend",
"def preamble\n \"// BEGIN METARUBY PREAMBLE\n#include <ruby.h>\n#define RB_COMPARE(x, y) (x) == (y) ? 0 : (x) < (y) ? -1 : 1\ntypedef char * str;\n#define case_equal_long(x, y) ((x) == (y))\n// END METARUBY PREAMBLE\n\" + self.prototypes.join('')\n end",
"def source_lines; end",
"def source_lines; end",
"def source_lines; end",
"def source_lines; end",
"def language()\r\n\t\treturn \"java\" if (@file =~ /java\\Z/ )\r\n\t\treturn \"cpp\" if ( (@file =~ /cpp\\Z/) || (@file =~ /cc\\Z/) || (@file =~ /h\\Z/) || (@file =~ /hpp\\Z/) )\r\n\tend",
"def newline; end",
"def formatPreprocessor(theLines)\n\n\talignEndifs(\t\ttheLines);\n\talignUndefineDefine(theLines);\n\talignDefineValue(\ttheLines);\n\talignContinuations(\ttheLines);\n\n\treturn theLines;\n\nend",
"def code_format_print(code)\n indent = 0\n l = 1\n code.each_line do |ln|\n ln = ln.strip\n if(ln.match(/^end/))\n indent -= 4\n end\n indent = 0 if indent < 0\n ll = \" \"\n if(l<10)\n ll = \"00#{l} \"\n elsif(l<100)\n ll = \"0#{l} \"\n else\n ll = \"#{l} \"\n end\n l += 1\n\n puts ll + \" \"*indent + ln\n\n if(ln.match(/^class/))\n indent += 4\n elsif(ln.match(/^def/))\n indent += 4\n elsif(ln.match(/do$/))\n indent += 4\n end\n\n if(ln.match(/end$/) && !ln.match(/^end/))\n indent -= 4\n end\n end\nend",
"def get_filecode()\n \"__EMIT_#{ARGV[0].gsub(/[^\\w]/, \"_\").upcase}__\"\nend",
"def format=(procedure); end",
"def bleu\n \"\\033[0;96m#{self}\\033[0m\"\n # 96=bleu clair, 93 = jaune, 94/95=mauve, 92=vert\n end",
"def tab\n write(9)\n end",
"def defs(file, line, col); end",
"def defs(file, line, col); end",
"def save_as_ruby(file)\n if File.exist?(file)\n text = File.read(file)\n save_as_ruby_sub!(text, :version, 'VERSION')\n save_as_ruby_sub!(text, :released, 'RELEASED', 'DATE')\n save_as_ruby_sub!(text, :codename, 'CODENAME')\n else\n t = []\n t << %[module #{codename}]\n t << %[ VERSION = \"#{version}\"]\n t << %[ RELEASE = \"#{release}\"]\n t << %[ CODENAME = \"#{codename}\"]\n t << %[end]\n text = t.join(\"\\n\")\n end\n File.open(file, 'w'){ |f| f << text }\n end",
"def inline_code; end",
"def with_repl_like_sigint; end",
"def make_vm_line(vm)\n \"${color2} #{vm}\\n\"\nend",
"def backtick_codeblock(input)\n input.gsub /<p>`{3}\\s(\\w+)<\\/p>\\n\\n<pre><code>([^<]+)<\\/code><\\/pre>\\n\\n<p>`{3}<\\/p>/m do\n lang = $1\n str = $2.gsub('<','<').gsub('>','>')\n highlight(str, lang)\n end\n end",
"def init_tags\n add_tag :BOLD, \"\\e[1m\", \"\\e[m\"\n add_tag :TT, \"\\e[7m\", \"\\e[m\"\n add_tag :EM, \"\\e[4m\", \"\\e[m\"\n end",
"def yyerrok; end",
"def yyerrok; end",
"def convert_it_to_methods(file)\n @command.gsub_file(file, /(?<=\\bit ').*?(?=' do\\b)/) do |match|\n match.gsub(/\\W+/, '_').downcase\n end\n\n @command.gsub_file(file, /it '_?(.*)' do/, 'def test_\\1')\n end",
"def compile_to_ruby\n statements.collect { |s| s.compile_to_ruby }.join(\"\\n\")\n end",
"def exe(s)\n VIM.command s\nend",
"def heredoc_indent_type(node)\n node.source[/^<<([~-])/, 1]\n end",
"def erb(t)\n ERB.new( File.open(t).read, 0, '<>' ).result\nend",
"def reduce_vtab(_production, _range, _tokens, _children)\n Regex::Character.new('\\v')\n end",
"def initialize\n @emit_file_line_as_literals = true\n end",
"def alignEndifs(theLines)\n\n\t# Collapse whitespace after #endif\n\t#\n\t# clang-format inserts IndentWidth spaces between a #endif\n\t# and its comment.\n\ttheLines.each do |theLine|\n\n\t\tif (theLine[:text] =~ /^(#endif\\s)\\s+/ && !theLine[:comment].empty?)\n\t\t\ttheLine[:text] = $1;\n\t\tend\n\n\tend\n\nend",
"def interp\n rboutput = `ruby #{RB_FILE} #{RBTEX_OUT}`\n if rboutput == ''\n puts 'Your ruby file had no puts statments'.green\n end\n return 0\nend",
"def convert_man_to_ansi file\n lines = file.split \"\\n\"\n l = nil\n lines.each_with_index do |line, ix|\n # convert underlined words to yellow or one color, these are usually params\n line.gsub!(/((_\b[^ ])+)/,'\u001b[4;33m\\1\u001b[0m')\n line.gsub!(/_\b/,'')\n # convert bold words to red or one color, these are usually headers and other words\n l= line.gsub(/(([^ ]\b[^ ])+)/,'\u001b[1;31m\\1\u001b[0m').gsub(/[^ ]\b/,'').gsub(/\b/,'')\n lines[ix] = l\n end\n lines\nend",
"def lex_en_line_comment=(_arg0); end",
"def lex_en_line_comment=(_arg0); end",
"def lex_en_line_comment=(_arg0); end"
] | [
"0.5803009",
"0.5457295",
"0.544725",
"0.5440447",
"0.540047",
"0.5387971",
"0.53144646",
"0.520739",
"0.5160547",
"0.5159978",
"0.5159782",
"0.5146485",
"0.5083554",
"0.50814515",
"0.5080929",
"0.5077087",
"0.50639117",
"0.50580174",
"0.50580174",
"0.50380445",
"0.50380445",
"0.4984468",
"0.49724886",
"0.4951048",
"0.49466014",
"0.4903131",
"0.4898179",
"0.48876643",
"0.4886485",
"0.48716843",
"0.48706934",
"0.4865756",
"0.4842234",
"0.48380756",
"0.4824881",
"0.48216367",
"0.48167115",
"0.47925276",
"0.47732988",
"0.47712642",
"0.47588575",
"0.47543994",
"0.47535437",
"0.47535437",
"0.4751234",
"0.47456008",
"0.47312555",
"0.47086927",
"0.4707612",
"0.46990514",
"0.46990514",
"0.46990514",
"0.46928203",
"0.46719205",
"0.46706375",
"0.46674216",
"0.4666785",
"0.4662625",
"0.46609747",
"0.46609747",
"0.46445593",
"0.4638591",
"0.461708",
"0.46070293",
"0.46057227",
"0.46017936",
"0.4601192",
"0.4601192",
"0.4601192",
"0.4601192",
"0.45918658",
"0.45862618",
"0.45857868",
"0.45839486",
"0.45824283",
"0.4574123",
"0.4570657",
"0.45680726",
"0.45640016",
"0.45640016",
"0.4561444",
"0.45584625",
"0.45550445",
"0.45549548",
"0.45528772",
"0.45481703",
"0.4543232",
"0.4543232",
"0.45427603",
"0.4541317",
"0.45403168",
"0.4529151",
"0.4521391",
"0.45182538",
"0.4513595",
"0.45101717",
"0.45076784",
"0.45076165",
"0.45008513",
"0.45008513",
"0.45008513"
] | 0.0 | -1 |
Makes callable into a object that responds to call. | def get_callable(callable, scope)
return callable if callable.respond_to?(:call)
if callable.kind_of?(Symbol)
callable = camel_case(callable.to_s).to_sym
if scope.constants.include?(callable)
c = scope.const_get(callable)
callable = c if c.is_a?(Class)
end
end
if callable.kind_of?(Class)
callable = callable.new
end
if callable.respond_to?(:call)
callable
else
raise ArgumentError, "Could not resolve #{callable.inspect}. Callable must be an object that responds to #call or a symbol that resolve to such an object or a class with a #call instance method."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def be_callable!(thing)\n return if thing.respond_to?(:call)\n return if thing.is_a?(Class) && thing.instance_methods.include?(:call)\n raise TypeError, \"Expecting callable but received `#{thing.class.name}`\"\n end",
"def initialize(callable)\n @callable = callable\n freeze\n end",
"def call(object); end",
"def eval_as_proc(obj)\n obj.respond_to?(:call) ? obj.call : obj\n end",
"def method_missing(method, *args)\n Call.new(self, method, args)\n end",
"def to_proc\n lambda{ call }\n end",
"def new_call logger: nil\n return @callable unless @callable.nil?\n logger ||= FunctionsFramework.logger\n @callable_class.new logger: logger, function_name: name, function_type: type\n end",
"def method_missing(call)\n object.send(call)\n end",
"def double(callable_object)\n callable_object.call * 2\nend",
"def double(callable_object)\n callable_object.call * 2\nend",
"def double(callable_object)\n callable_object.call * 2\nend",
"def double(callable_object)\n callable_object.call * 2\nend",
"def on_call(object, operator, name)\n return Node.new(\n :method,\n [name.children[0], on_params, nil, object],\n metadata(name)\n )\n end",
"def to_proc\n Proc.new {|*args| self.invoke(*args) }\n end",
"def cast_or_call(cc, mod, fun, *args)\n req = t[cc, mod.to_sym, fun.to_sym, args]\n write_berp(req)\n read_response\n end",
"def call(*) end",
"def call(*) end",
"def initialize name, type, callable: nil, request_class: nil, &block\n @name = name\n @type = type\n @request_class = request_class\n @callable = @callable_class = nil\n if callable.respond_to? :call\n @callable = callable\n elsif callable.is_a? ::Class\n @callable_class = callable\n elsif block_given?\n @callable_class = ::Class.new Callable do\n define_method :call, &block\n end\n else\n raise ::ArgumentError, \"No callable given for function\"\n end\n end",
"def to_proc\n ->(*args) {call(*args)}\n end",
"def to_proc\n method(:call).to_proc\n end",
"def call(callable, *args)\n if callable.is_a?(String) || callable.is_a?(Symbol)\n proc = @library.macros(true)[callable.to_sym]\n fun = @library.functions(true)[callable.to_sym]\n if proc\n count = proc.arity >= 0 ? proc.arity : 0\n if args.count != count\n raise ArgumentError, \"Wrong number of arguments passed to macro (#{args.count} for #{count})\" \n end\n self.instance_exec(*args, &proc)\n elsif fun\n @builder.call(fun, *args.map{|arg| Convert(arg, fun.arg_types[args.index(arg)])})\n else\n raise NoMethodError, \"Function or macro, '#{function.to_s}', does not exist.\"\n end\n elsif callable.kind_of?(LLVM::Script::Function)\n @builder.call(callable, *args.map{|arg| Convert(arg, callable.arg_types[args.index(arg)])})\n elsif callable.kind_of?(LLVM::Value) && (callable.type.kind == :function || callable.type.kind == :pointer)\n @builder.call(callable, *args.map{|arg| Convert(arg)})\n else\n raise ArgumentError, \"Callable passed to call must be a LLVM::Value or a name of a Library function or macro.\"\n end\n end",
"def double(callable)\n callable.call * 2\nend",
"def to_proc\n -> target { self.call(target) }\n end",
"def to_proc\n -> target { self.call(target) }\n end",
"def to_proc\n Proc.new { |target| self.call(target) }\n end",
"def to_proc\n Proc.new { |target| self.call(target) }\n end",
"def callable?(obj)\n # Both of these objects response do call\n return true if obj.respond_to? :call\n end",
"def add_conversion_proc(oid, callable=nil, &block)\n conversion_procs[oid] = callable || block\n end",
"def cast_or_call(cc, mod, fun, *args)\n req = t[cc, mod.to_sym, fun.to_sym, args]\n write_berp(req)\n read_berp\n end",
"def proxy meth\n Proxy.new self, meth\n end",
"def _call_of(method)\n proc{ |*args| send(method, *args) }\n end",
"def call() end",
"def make(thing) end",
"def to_proc\n # since we're immutable we can keep this\n @extern_proc ||= method(:call).to_proc\n end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def invoke; end",
"def call(method, arguments)\n # Like a typical class base runtime model, we store\n # methods in the class of the object.\n @awesome_class.lookup(method).call(self, arguments)\n end",
"def send_as_function arg\n case arg\n when Symbol then __send__ arg\n when Array then __send__(*arg)\n else yield_or_eval(&arg)\n end\n end",
"def to_proc\n # Use shadows since instance_eval/exec breaks ivars.\n name, arguments = @name, @arguments\n\n Proc.new { public_send(name, *arguments) }\n end",
"def call (fn, *args)\n elisp([fn.to_sym, *args])\n end",
"def invoke(object, method_name)\n object.send(method_name)\nend",
"def call!(*args)\n new(*args).call!\n end",
"def call\n __proxied_call\n end",
"def get_handler_for_call(call)\n end",
"def to_proc\n ->(input) { call(input) }\n end",
"def to_proc\n ->(**properties) { perform(**properties) }\n end",
"def method_missing(name, *args, &block)\n name = name.to_s\n\n if name =~ /\\?$/\n begin\n RubyPyProxy.reveal(name.to_sym)\n return self.__send__(name.to_sym, *args, &block)\n rescue RuntimeError => exc\n raise NoMethodError.new(name) if exc.message =~ /Don't know how to reveal/\n raise\n end\n end\n\n setter = kwargs = false\n\n if name =~ /=$/\n setter = true\n name.chomp! \"=\"\n elsif name =~ /!$/\n kwargs = true\n name.chomp! \"!\"\n end\n\n if [email protected](name) and !setter\n raise NoMethodError.new(name)\n end\n\n if setter\n return @pObject.setAttr(name, PyObject.convert(*args)[0])\n end\n\n pFunc = @pObject.getAttr(name)\n\n if pFunc.callable?\n if args.empty? and pFunc.class?\n pReturn = pFunc\n else\n if kwargs and args.last.is_a?(Hash)\n pKeywords = PyObject.convert(args.pop).first\n end\n\n orig_args = args\n args = PyObject.convert(*args)\n pTuple = PyObject.buildArgTuple(*args)\n pReturn = if pKeywords\n pFunc.callObjectKeywords(pTuple, pKeywords)\n else\n pFunc.callObject(pTuple)\n end\n\n # cleanup unused python vars instead of waiting on ruby's GC to do it.\n pFunc.xDecref\n pTuple.xDecref\n pKeywords.xDecref if pKeywords\n orig_args.each_with_index do |arg, i|\n # only decref objects that were created in PyObject.convert\n if !arg.kind_of?(RubyPython::PyObject) and !arg.kind_of?(RubyPython::RubyPyProxy)\n args[i].xDecref\n end\n end\n\n if PythonError.error?\n raise PythonError.handle_error\n end\n end\n else\n pReturn = pFunc\n end\n\n return _wrap(pReturn)\n end",
"def call\n end",
"def bind_to_object=(_arg0); end",
"def cast_with_proc(obj, type)\n if (type == :proc || obj.is_a?(::Proc)) && obj.respond_to?(:to_source)\n :proc\n else\n cast_without_proc(obj, type)\n end\n end",
"def wrapper\n -> fn { -> { fn } }\n end",
"def call\n end",
"def method_missing(method, params={})\n call(method, params)\n end",
"def to_proc\n @to_proc ||= method(:coerce).to_proc\n end",
"def test_get_callable\n p = -> {}\n assert_equal Release.get_callable(p, {}), p\n assert_raise(ArgumentError) { Release.get_callable(nil, {}) }\n end",
"def source\n @callable\n end",
"def source\n @callable\n end",
"def to_proc() self ; end",
"def call_a_proc(&my_proc)\n my_proc.call\nend",
"def apply_endpoint(obj, k, v)\n α = -> { endpoint(get(v).body) }\n β = -> { v }\n λ = url?(v) ? -> { α.call } : -> { β.call }\n obj.define_singleton_method(k, &λ) if url?(v)\n obj\n end",
"def to_proc() end",
"def to_proc() end",
"def method_missing(method, *args, &block)\n self.class.define_proxy method\n send(method, *args, &block)\n end",
"def try_call(*args)\n if self.respond_to?(:call)\n self.call(*args)\n else\n self\n end\n end",
"def wrap(object); end",
"def method_missing(method_id, object)\n return object(object)\n end",
"def manual_invoke(what, options)\n what_arr = what.split(':')\n klass = Kernel.const_get(\"::#{what_arr.first.capitalize}\").new\n klass.options = options\n klass.send(what_arr.last)\n end",
"def invoke *o,&b\n @invoker ||= create_invoker()\n invoker.invoke *o,&b\n end",
"def original_method(obj, meth, klass=Object)\n klass.instance_method(meth).bind(obj).call\n end",
"def original_method(obj, meth, klass=Object)\n klass.instance_method(meth).bind(obj).call\n end",
"def __apply__(rule) = public_send(rule)",
"def call(args = {})\n new.call(args)\n end",
"def method_missing(name, *args, &block)\n if name.to_s =~ /^to_(\\w+)$/\n return send(name) if define_conversion($1)\n end\n raise \"Method '#{ name }' unknown\" # TODO use standard exception\n end",
"def foo(&b)\r\n b.call\r\nend",
"def call\n # implement in subclasses\n end",
"def try_call(*args, &block)\n if args.empty?\n TryObject.new(self)\n else\n self.send(*args, &block) if(self.respond_to?(args.first))\n end\n end",
"def as_proc(bind=nil)\n args_ext = self.args.map { |e| \"#{e} = fd[\\\"#{e}\\\"];\" }\n code = \"Proc.new do |fd|; #{args_ext.join \" \"} #{self.to_code}; end\"\n if bind # All objects have eval value, we bind when not nil\n # CAS::Help.assert(bind, Binding)\n bind.eval(code)\n else\n eval(code)\n end\n end",
"def method_missing(method, *arguments, &block); end",
"def register(key, callable)\n actions[key.to_sym] = callable\n end",
"def to_proc\n ->(*args, &blk) do\n receiver = args.first\n if (blk)\n receiver.send(self, &blk)\n else\n args[0] = self\n receiver.send(*args)\n end\n end\n end",
"def callable?(callable, args)\n callable.is_a?(PAnyType) && callable.callable?(args)\n end",
"def make_accessor(called, with_object)\n class << self\n self\n end.send(:define_method, called.to_s) do\n with_object\n end\n end",
"def method_missing(method, *args, &block); end",
"def takes_a_proc( p )\n p.call\nend",
"def method_missing(method, *args, &blk); end",
"def test_method_calls_can_take_and_execute_fn_parm\n result = interpret 'a=~{foo: ->(fn) { %fn }};%a.foo(->() {4})'\n assert_eq result, 4\n end",
"def to_proc()\n #This is a stub, used for indexing\n end",
"def assignAsCommander _obj, _args\n \"_obj assignAsCommander _args;\" \n end",
"def call(method, arguments)\n @can_class.lookup(method).call(self, arguments)\n end",
"def mk_method(proc)\n @klass.send(:define_method, @method_name, proc)\n end",
"def rb_delegate(method, to: nil, alias_of: method, **kwd)\n raise ArgumentError, \"to must be provided\" unless to\n def_delegator(\n to, alias_of, method, **kwd\n )\n end",
"def cloaker(&b)\n (class << self; self; end).class_eval do\n define_method :cloaker_, &b\n meth = instance_method :cloaker_\n remove_method :cloaker_\n meth\n end\n end",
"def to_proc\n @to_proc ||= method(:transform).to_proc\n end"
] | [
"0.6652214",
"0.6414303",
"0.6276644",
"0.6180409",
"0.60772693",
"0.59773386",
"0.59093136",
"0.589361",
"0.5788253",
"0.5759921",
"0.5759921",
"0.5759921",
"0.57502776",
"0.5727496",
"0.57170016",
"0.5691074",
"0.5691074",
"0.5650693",
"0.56310385",
"0.562612",
"0.56204665",
"0.55985016",
"0.55791277",
"0.55791277",
"0.55097365",
"0.55097365",
"0.55091375",
"0.54955167",
"0.5387761",
"0.53742707",
"0.5354751",
"0.5354156",
"0.5354029",
"0.5346938",
"0.5321344",
"0.5321344",
"0.5321344",
"0.5321344",
"0.5321344",
"0.5321344",
"0.5321344",
"0.5321344",
"0.53062034",
"0.52971673",
"0.52640903",
"0.52440464",
"0.52166706",
"0.5197359",
"0.51896757",
"0.5172448",
"0.5172437",
"0.51724356",
"0.51650304",
"0.5162432",
"0.5160593",
"0.51246285",
"0.5113725",
"0.51045924",
"0.5099152",
"0.5096816",
"0.5089224",
"0.50736004",
"0.5065351",
"0.5065351",
"0.50595385",
"0.5054315",
"0.505148",
"0.5038371",
"0.5038371",
"0.50255036",
"0.50180453",
"0.5015875",
"0.5013033",
"0.5008919",
"0.5005379",
"0.50025094",
"0.50025094",
"0.49999833",
"0.4995291",
"0.49919313",
"0.49900007",
"0.49852198",
"0.49714383",
"0.49670482",
"0.4956871",
"0.49299458",
"0.49252823",
"0.49240762",
"0.49222007",
"0.4911172",
"0.49073866",
"0.49062946",
"0.49043688",
"0.49003744",
"0.4898997",
"0.48966354",
"0.48948163",
"0.4894683",
"0.48931816",
"0.48914665"
] | 0.64326954 | 1 |
Nothing genius adjusted from: | def camel_case(string)
return string if string !~ /_/ && string =~ /[A-Z]+.*/
string.split('_').map{|e| e.capitalize}.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def formation; end",
"def terpene; end",
"def suivre; end",
"def anchored; end",
"def verdi; end",
"def malts; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def stderrs; end",
"def berlioz; end",
"def schumann; end",
"def offences_by; end",
"def jack_handey; end",
"def villian; end",
"def blg; end",
"def celebration; end",
"def gounod; end",
"def upc_e; end",
"def trd; end",
"def who_we_are\r\n end",
"def calculated; end",
"def mitch_hedberg; end",
"def mambo_no_5; end",
"def in_law; end",
"def romeo_and_juliet; end",
"def king_richard_iii; end",
"def intensifier; end",
"def ismn; end",
"def original_result; end",
"def original; end",
"def strain; end",
"def dh; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def custom; end",
"def custom; end",
"def silly_adjective; end",
"def from; end",
"def from; end",
"def from; end",
"def from; end",
"def ibu; end",
"def bs; end",
"def sn\n end",
"def extra; end",
"def weber; end",
"def feruchemist; end",
"def lsi; end",
"def refutal()\n end",
"def rassoc(p0) end",
"def iso; end",
"def deco_pos; end",
"def medical_use; end",
"def bellini; end",
"def p15\n\t\nend",
"def origin; end",
"def origin; end",
"def origin; end",
"def transformations; end",
"def starship; end",
"def pos() end",
"def pos() end",
"def pos() end",
"def pos() end",
"def cardinal; end",
"def guct\n end",
"def dv; end",
"def nn\n end",
"def alt; end",
"def buzzword; end",
"def buzzword; end",
"def sub_e\n end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def isolated; end",
"def isolated; end",
"def invention; end",
"def sld; end",
"def herald; end",
"def internal; end",
"def zuruecksetzen()\n end",
"def scientist; end",
"def rossini; end",
"def nasa_space_craft; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end"
] | [
"0.71673167",
"0.6739261",
"0.6570794",
"0.65537924",
"0.6510832",
"0.6503343",
"0.6432707",
"0.63185513",
"0.6305521",
"0.62823653",
"0.62823653",
"0.62823653",
"0.62823653",
"0.62667",
"0.6221262",
"0.6205922",
"0.61905235",
"0.6160562",
"0.6121183",
"0.60640156",
"0.6056903",
"0.6039046",
"0.6003627",
"0.6003169",
"0.5981431",
"0.59738445",
"0.59571785",
"0.5954951",
"0.59327084",
"0.59291196",
"0.59268546",
"0.59265256",
"0.5903373",
"0.5887978",
"0.5883759",
"0.58807933",
"0.5865992",
"0.58657545",
"0.58657545",
"0.58657545",
"0.58657545",
"0.58657545",
"0.58657545",
"0.5854821",
"0.5854821",
"0.58399165",
"0.5827269",
"0.5827269",
"0.5827269",
"0.5827269",
"0.5816587",
"0.580728",
"0.5805896",
"0.57939243",
"0.57774216",
"0.57740754",
"0.57677054",
"0.5744519",
"0.57406455",
"0.57092834",
"0.5708277",
"0.5704194",
"0.5703434",
"0.56873006",
"0.56809086",
"0.56809086",
"0.56809086",
"0.5672207",
"0.56684154",
"0.56683964",
"0.56683964",
"0.56683964",
"0.56683964",
"0.566765",
"0.56674576",
"0.56659734",
"0.56557596",
"0.56548625",
"0.56464744",
"0.56464744",
"0.5640378",
"0.5635767",
"0.5635767",
"0.5635767",
"0.5635767",
"0.5632214",
"0.5632214",
"0.5618043",
"0.5601936",
"0.5599119",
"0.5595181",
"0.55934834",
"0.55933815",
"0.5589977",
"0.5584974",
"0.55846626",
"0.55846626",
"0.55846626",
"0.55846626",
"0.55846626",
"0.55846626"
] | 0.0 | -1 |
Accessor for target_path The target_path is the path where the finalizers will put the release | def target_path
Pathname.new(self.config[:target_path])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def target_path\n Pathname.new(config[:target_path])\n end",
"def target_path(target_name)\r\n File.join(package_dir, target_name)\r\n end",
"def path\n File.join(@base, @target)\n end",
"def getPath(target)\n File.expand_path(File.join(File.dirname(__FILE__), target))\nend",
"def build_target_path\n File.join(destination, configuration[:build_target_path])\n end",
"def targets_path\n self.root.join(TARGETS_DIRECTORY)\n end",
"def release_path\n @release_path ||= Pathname.new(source_dir).join(data['release_path'] || './release').to_s\n end",
"def release_path\n @config[:remote_path]\n end",
"def target_file_path\n model.source_location(target_symbol)[:file_path]\n end",
"def compiled_path; end",
"def file_path( target )\n # theme.site do not work.\n File.join(page_layout.site.path, self.path, file_name(target)) \n end",
"def file_path( target )\n # theme.site do not work.\n File.join( original_template_theme.store.path, self.path, file_name(target))\n end",
"def file_path( target )\n File.join(template_theme.website.path, self.path, template_theme.file_name(target))\n end",
"def capture_path(target_name, mode=0600)\r\n tempfile = _package_.setup_tempfile(target_name, mode)\r\n capture_block(tempfile) do\r\n current = @target_name\r\n \r\n begin\r\n @target_name = target_name\r\n yield\r\n ensure\r\n @target_name = current\r\n end\r\n \r\n end\r\n tempfile.close\r\n \r\n target_path target_name\r\n end",
"def teardown\n teardown_construct(@target_path)\n @release.destroy\n @release = nil\n end",
"def path\n @link.TargetPath\n end",
"def destination\n @destination ||= File.join(tmpdir, File.basename(configuration[:release_path]))\n end",
"def conditional_target_file_path\n return if conditional_target_symbol.nil?\n\n model.source_location(conditional_target_symbol)[:file_path]\n end",
"def destination\n #configuration[:release_path]\n @destination ||= File.join(tmpdir, File.basename(configuration[:release_path]))\n\n end",
"def release_path\n ::File.join(install_path, artifact_name, artifact_version)\n end",
"def output_path=(path)\n @output_path = path\n end",
"def output_path; end",
"def compiled_path=(path); end",
"def target\n filter.into @project.path_to(:target, @usage, :resources) unless filter.target || sources.empty?\n filter.target\n end",
"def target\n return nil unless @target_dir\n unless @target\n @target = file(File.expand_path(@target_dir)) { |task| run if @target == task }\n @target.enhance @include.select {|f| f.is_a?(Rake::FileTask)}\n @target.enhance @exclude.select {|f| f.is_a?(Rake::FileTask)}\n @target.enhance copy_map.values\n end\n @target\n end",
"def build_path\n Pathname.new(self.config[:build_path]) \n end",
"def initialize(path, target=nil)\n self.path = path\n self.target = target\n end",
"def build_path\n end",
"def tar_path\n File.expand_path(@env[\"package.output\"], FileUtils.pwd)\n end",
"def output_path\n \"build\"\n end",
"def build_path(target_word)\n # debugger\n source_to_target_path = [target_word]\n current_word = target_word\n prev_word = @all_seen_words[current_word]\n\n until prev_word.nil?\n source_to_target_path.unshift(prev_word)\n current_word = prev_word\n prev_word = @all_seen_words[current_word]\n end\n @path = source_to_target_path\n @path\n end",
"def source_path; end",
"def output_dir(target_repo = \"\") # rubocop:disable Lint/DuplicateMethods\n @output_dir ||= File.join(@os_name, @os_version, target_repo, @architecture)\n end",
"def public_path(target) \n page_generator.theme.file_path(target) \n end",
"def destination_path\n @destination_path ||= Pathname.new(self.destination_root)\n end",
"def target\n @target ||= begin\n target = static_data(\"target\")\n cache.build(target[\"url\"]) if target && target[\"url\"]\n end\n end",
"def build_path\n Pathname.new(config[:build_path])\n end",
"def target\n \"#{target_repo}/#{target_branch}\"\n end",
"def package_dir\r\n \"${0%/#{target_name}}\"\r\n end",
"def target\n base.image_for(\"#{name}_target\")\n end",
"def file_path(file_name, target_name=file_name, mode=0600)\r\n _package_.build_file(target_name, file_name, mode)\r\n target_path target_name\r\n end",
"def dest_path\n @dest_path ||= File.expand_path(path)\n end",
"def dest_path\n @dest_path ||= File.expand_path(path)\n end",
"def framework_path\n File.join(config.build_products_dir, name)\n end",
"def target\n @target ||= Target.find(options[:target]).new(options[:directory])\n end",
"def output_dir_path\n @output_dir_path ||= download_dir_path\n end",
"def helper_target_dir\n helper_source_dir\n end",
"def target_spec_path\n @target_spec_path ||= begin\n class_name_parts = object_name.split('::')\n\n # drop the module name if the object name contains multiple parts\n class_name_parts.delete_at(0) if class_name_parts.length > 1\n\n \"#{File.join(module_dir, 'spec', 'classes', *class_name_parts)}_spec.rb\"\n end\n end",
"def destination\n @release_destination\n end",
"def compile(target_path:)\n target_path = Pathname.new(target_path)\n mkdir_p target_path\n root = Pathname.new(\"/\")\n cache_resources = @site.cache_resources\n @stdout.puts \"Compiling #{@site.root_path.expand_path}\"\n begin\n @site.cache_resources = true\n @site.resources.each do |resource|\n derooted = Pathname.new(resource.request_path).relative_path_from(root)\n path = target_path.join(derooted)\n mkdir_p path.dirname\n @stdout.puts \" #{path}\"\n File.open(path.expand_path, \"w\"){ |f| f.write render(resource) }\n end\n @stdout.puts \"Successful compilation to #{target_path.expand_path}\"\n ensure\n @site.cache_resources = cache_resources\n end\n end",
"def __path__\n File.join(root, 'tmp', 'build')\n end",
"def target_url(target)\n File.join(\"/\", Pathname.new(target).relative_path_from(Pathname.new(DST_DIR)).to_s)\nend",
"def target_object_path\n @target_pp_path ||= begin\n class_name_parts = object_name.split('::')[1..-1]\n class_name_parts << 'init' if class_name_parts.empty?\n\n \"#{File.join(module_dir, 'manifests', *class_name_parts)}.pp\"\n end\n end",
"def target_filename\n raise NotImplementedError, \"Must be overridden by a subclass\"\n end",
"def output_path(path)\n\t\t\tunless Pathname.new(path).absolute?\n\t\t\t\toutput = @variables['__OUTPUT__']\n\t\t\t\tif output\n\t\t\t\t\tDir.mkdir output unless Dir.exists? output\n\t\t\t\t\tpath = File.join(output, path)\n\t\t\t\tend\n\t\t\tend\n\t\t\tpath\n\t\tend",
"def _target\n @_target ||= @_initializer.call\n end",
"def source_path\n Pathname.new(self.config[:source_path])\n end",
"def recipe_path(recipe_name, target_name=recipe_name, mode=0700)\r\n _package_.build_recipe(target_name, recipe_name, mode)\r\n target_path target_name\r\n end",
"def output_path\n File.join(Musako.destination_path, @url)\n end",
"def path\n asset_source_path\n end",
"def path\n asset_source_path\n end",
"def pathDistSource\n\tpathDist + \"source/\"\nend",
"def initialize(target_path = ApacheConfig::DEFAULT_CONFIG_PATH, config_path = DEFAULT_CONFIG_PATH)\n @target = Pathname.new(target_path).realpath.to_s\n @config_path = config_path\n end",
"def target_recipe_path\n key = Digest::MD5.hexdigest(config.recipe)\n File.join(config.upload_path, \"recipe-#{key}.rb\")\n end",
"def target_dir\n return @target_dir ? @target_dir : Dir.home\n end",
"def destination_rel_dir\n replace_build_path(super)\n end",
"def source_path\n Pathname.new(config[:source_path])\n end",
"def initialize(target_path = \"../../test/fixtures-gh\")\n target_path = File.expand_path( target_path, __FILE__ ) unless Dir.exist?(target_path)\n Dir.chdir(target_path)\n `rm -rf *` # clean\n end",
"def loaded_path; end",
"def source_path\n source[:path]\n end",
"def path\n @path ||= make_path(@module.to_a.concat(outter_class.to_a).push(filename))\n end",
"def file_path path\n File.join(output_path, manifest.lookup(path).split('/')[2..-1])\n end",
"def configuration_file_for(target_dir); end",
"def path\n @path ||= best_qmake\n end",
"def target_root\n APP_ROOT.join(\"deployments/#{target_id}\")\n end",
"def setup_target\n link_target_task project.target, (project.sources + [project.main]).map {|fn| objectsify fn }\n end",
"def target_dir\n without_parent_dir ? \".\" : package_name\n end",
"def target\n @target or raise LifecycleException.new(\"can't call target until you materialize the resource\")\n end",
"def path\n @bundle_filename\n end",
"def source_output_dir(target_repo = \"\") # rubocop:disable Lint/DuplicateMethods\n @source_output_dir ||= output_dir(target_repo)\n end",
"def dsym_path\n Dir[BuildCommandGenerator.archive_path + \"/**/*.dsym\"].last\n end",
"def target_asset_path(asset)\n File.join('public', asset.folder, asset.filename)\n end",
"def post_configure\n super\n @path = File.expand_path(path)\n end",
"def test_path=(value)\r\n @test_path = value\r\n # recreate outputter\r\n if @file_outputter then\r\n @file_outputter.flush\r\n logger.outputters.delete(@file_outputter)\r\n @file_outputter = nil\r\n end\r\n\r\n return test_path\r\n end",
"def output_path(object)\n raise NotImplementedError\n end",
"def target=(target)\n @target = target\n loaded!\n end",
"def target=(target)\n @target = target\n loaded!\n end",
"def min_file_path\n compiled_path || current_file_path\n end",
"def target\n \"\"\n end",
"def build_path\n @build_path ||= \"#{@ant_path}/#{@config[:build_name]}\"\n end",
"def target_path\n @target_path ||= \"app/views/activity_notification\"\n end",
"def path\n http_url @store.rdoc.generator.class_dir\n end",
"def remove_target(target)\n @cache[\"targets\"].delete(target)\n end",
"def target_file\n resource.original_file || resource.intermediate_files.first\n end",
"def path\n # We cache this, since it can be fairly expensive to run the command to figure out\n # what this should be.\n if @path.nil?\n outputproperty, errorproperty = @platform.next_output_properties\n @ant.java(:classname => 'com.tc.object.tools.BootJarSignature',\n :classpath => @module_set['dso-l1'].subtree('src').classpath(@build_results, :full, :runtime).to_s,\n :jvm => @jvm.java,\n :fork => true,\n :failonerror => true,\n :dir => @build_results.tools_home.to_s) do\n @ant.redirector(:outputproperty => outputproperty, :alwayslog => true)\n end\n\n # Parse the output in case the JVM prints out additional messages, only the line\n # that contains the actual boot jar name will be used.\n # On MacOSX the JVM sometimes prints \"HotSpot not at correct virtual address.\n # Sharing disabled.\" for instance. Without parsing the output, the name of the\n # bootjar file will be wrong.\n rawout = @ant.get_ant_property(outputproperty)\n out = rawout\n rawout.each do |line|\n if line =~ /^dso-boot-/\n out = line\n break\n end\n end\n @path = FilePath.new(@directory, out)\n end\n\n @path\n end",
"def target\n Pathname(\"/etc/munin/plugins/#{name}\")\n end",
"def assets_path() = self.class.name.demodulize.delete_suffix('Generator').underscore",
"def path\n @path ||= @project.dir.path\n end",
"def fullDestPath(destPath)\n\t'generated/' + destPath\nend",
"def target(folder = nil)\n @target ||= File.expand_path(folder)\n end"
] | [
"0.7139041",
"0.6819336",
"0.65198714",
"0.64403296",
"0.6364296",
"0.63166183",
"0.6269425",
"0.6257797",
"0.6126756",
"0.59940857",
"0.5950934",
"0.5937046",
"0.59180343",
"0.5803461",
"0.5780271",
"0.57573724",
"0.5749508",
"0.5718683",
"0.57175165",
"0.5708649",
"0.5684692",
"0.56779677",
"0.56763554",
"0.5631321",
"0.56222713",
"0.56063217",
"0.551837",
"0.55155843",
"0.54855055",
"0.5477776",
"0.54537153",
"0.54535514",
"0.542723",
"0.5426004",
"0.5409897",
"0.53710514",
"0.536843",
"0.53642285",
"0.5359595",
"0.53395367",
"0.533946",
"0.53357005",
"0.53357005",
"0.53295356",
"0.53230333",
"0.53206575",
"0.530896",
"0.53089064",
"0.5295051",
"0.529055",
"0.52765006",
"0.5273051",
"0.5268007",
"0.52608263",
"0.5245037",
"0.52329844",
"0.52222323",
"0.5221113",
"0.52165157",
"0.52028537",
"0.52028537",
"0.51996213",
"0.5199615",
"0.51988393",
"0.51949507",
"0.5191252",
"0.5190057",
"0.5187703",
"0.5183762",
"0.5181324",
"0.51780057",
"0.5159941",
"0.5158004",
"0.5155558",
"0.5150045",
"0.51499045",
"0.5149141",
"0.51387817",
"0.51387364",
"0.511674",
"0.5110374",
"0.51045394",
"0.51024586",
"0.5084996",
"0.50844455",
"0.5082763",
"0.5082763",
"0.5073922",
"0.50668037",
"0.50605655",
"0.5053484",
"0.50386983",
"0.5031552",
"0.5020726",
"0.50054085",
"0.50048393",
"0.50017625",
"0.49718243",
"0.4962392",
"0.4960443"
] | 0.72300655 | 0 |
Accessor for build_path The build_path is a temporary directory where the release will be built | def build_path
Pathname.new(self.config[:build_path])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_path\n @build_path ||= Pathname.new(source_dir).join(data['build_path'] || './build').to_s\n end",
"def build_path\n @build_path ||= \"#{@ant_path}/#{@config[:build_name]}\"\n end",
"def build_path\n Pathname.new(config[:build_path])\n end",
"def build_dir\n @build_dir ||= File.join(Crate.project.build_dir, name )\n end",
"def __path__\n File.join(root, 'tmp', 'build')\n end",
"def build_target_path\n File.join(destination, configuration[:build_target_path])\n end",
"def get_build_dir\n if @build_dir\n File.join(@dirname, @build_dir)\n else\n @dirname\n end\n end",
"def get_build_dir\n if @build_dir\n File.join(@dirname, @build_dir)\n else\n @dirname\n end\n end",
"def build_directory\n File.expand_path(config['build_directory'])\n end",
"def build_dir\n File.expand_path(\"#{Config.build_dir}/#{project.name}\")\n end",
"def output_path\n \"build\"\n end",
"def build_root()\n \"#{project_root}/build\"\n end",
"def build\n\t@built_gem_path ||= @helper.build_gem\nend",
"def release_path\n @release_path ||= Pathname.new(source_dir).join(data['release_path'] || './release').to_s\n end",
"def build_root\n Pathname.new(ENV[\"OBJDIR\"] || \"build\")\n end",
"def build_path\n end",
"def build_dir\n Rscons.application.build_dir\n end",
"def component_build_path(cmp)\n File.join WORK_PATH, 'build', cmp\nend",
"def component_build_path(cmp)\n File.join WORK_PATH, 'build', cmp\nend",
"def release_path\n ::File.join(install_path, artifact_name, artifact_version)\n end",
"def path\n @path ||= @project.dir.path\n end",
"def build_archive_dir\n out = config_source['build-archive-dir']\n out = nil if (out != nil && out.downcase == 'none')\n out = FilePath.new(out) unless out.nil?\n out\n end",
"def build_dir\n Puppet::Forge::Cache.base_path + \"tmp-unpacker-#{Digest::SHA1.hexdigest(@filename.basename.to_s)}\"\n end",
"def to_build_rel pn\n pn.relative_path_from(build_dir)\n end",
"def build_file\n @file = \"#{build_publish_date}-#{build_file_name}.#{build_tags}.#{build_filter}\"\n end",
"def build_output_dir\n root.join(public_dir, public_output_dir)\n end",
"def build_info_dir\n File.join base_dir, \"build_info\"\n end",
"def compiled_path; end",
"def build_erb_path\n @build_erb_path ||= \"#{ANT_TEMPLATE_FILEPATH}/#{ANT_BUILD_ERBNAME}\"\n end",
"def framework_path\n File.join(config.build_products_dir, name)\n end",
"def pathDist\n\t\"../../\" + distPackageName + \"_\" + version + \"/\"\nend",
"def build!\n build_to self[:build_path]\n end",
"def project_path\n if(File.directory?(@library_path))\n # library is source dir\n File.join(project_lib, clean_name)\n else\n # library is a binary (like swc, jar, etc)\n File.join(project_lib, File.basename(@file_target.archive_path))\n end\n end",
"def build_to_temp_dir\n @builder.build_project\n\n # Copy build files to temporary directory\n @task.shell.mute do\n @task.directory @project.build_path, ::File.join(@project.package_path, @package_name), :force => true\n end\n end",
"def generate_build_location(id)\n \"#{@config.output_dir}#{@config.prefix}/#{id}\"\n end",
"def stow_buildout_path\n \"#{node['stow']['path']}/stow#{pkg_delim}#{node['stow']['version']}\"\n end",
"def makePath\n\t\t\tbuildMgr.effective(filename).dirname.mkpath\n\t\tend",
"def destination_rel_dir\n replace_build_path(super)\n end",
"def _prepare_dir(project)\n tmp_path = Rails.root.join(\"tmp/git_checkout/#{Rails.env}/#{project.id}/#{project.path_with_namespace}\")\n tmp_path.mkpath unless tmp_path.exist?\n\n return tmp_path\n end",
"def path\n File.expand_path File.join(basepath, version_dir, basename)\n end",
"def destination\n @destination ||= File.join(tmpdir, File.basename(configuration[:release_path]))\n end",
"def build_script\n File.join(data_dir, 'build-script')\n end",
"def build_path *args\n Presto::Utils.build_path *args\n end",
"def toBuildDirFile(filename)\n\t\treturn File.join(@buildDestination, File.basename(filename))\n\tend",
"def carthage_build_path(platform, framework)\n return \"#{carthage_build_dir_for_platform(platform)}/#{framework}\"\nend",
"def compiled_path=(path); end",
"def within_build_path(&block)\n Dir.chdir app.config.build_dir do\n yield\n end\n end",
"def min_file_path\n compiled_path || current_file_path\n end",
"def get_project_path\n return File.absolute_path File.join(root_dir, src)\n end",
"def destination\n #configuration[:release_path]\n @destination ||= File.join(tmpdir, File.basename(configuration[:release_path]))\n\n end",
"def workdir\n result = base.join('cache')\n result.mkpath\n result\n end",
"def work_path\n @work_path ||= tmp_path.join(name)\n end",
"def make_carthage_build_path(name, platform)\n return \"Carthage/Build/#{platform}/#{name}\"\nend",
"def repo_path\n @repo.dirstate.copy_map[@path] || @path\n end",
"def initialize(build_dir)\n @build_dir = build_dir\n end",
"def localPath(taskName)\n self.pipeline.pipe_root + \"/build/prod/\" + taskName\n end",
"def repo_path\n @path\n end",
"def path\n @path ||= File.dirname @config_file\n end",
"def path\n File.join @proj_path_base, @proj_filename\n end",
"def inspect_build_state\n inspect_build_to self[:build_path]\n end",
"def pathDistSource\n\tpathDist + \"source/\"\nend",
"def workfile_path(for_file = original_filename)\n # To be safe, keep this directory outside of the the cache directory\n # because calling CarrierWave.clean_cache_files! will remove any files in\n # the cache directory.\n File.join(work_dir, cache_id, version_name.to_s, for_file)\n end",
"def build_dist_path(item)\n sub_build_dir = File.join(@config.build_dir, item.name)\n return Dir[File.join(sub_build_dir, \"#{item.name}-[0-9.]*.tar.gz\")][0]\n end",
"def path\n File.join(@base, @target)\n end",
"def path\n # We cache this, since it can be fairly expensive to run the command to figure out\n # what this should be.\n if @path.nil?\n outputproperty, errorproperty = @platform.next_output_properties\n @ant.java(:classname => 'com.tc.object.tools.BootJarSignature',\n :classpath => @module_set['dso-l1'].subtree('src').classpath(@build_results, :full, :runtime).to_s,\n :jvm => @jvm.java,\n :fork => true,\n :failonerror => true,\n :dir => @build_results.tools_home.to_s) do\n @ant.redirector(:outputproperty => outputproperty, :alwayslog => true)\n end\n\n # Parse the output in case the JVM prints out additional messages, only the line\n # that contains the actual boot jar name will be used.\n # On MacOSX the JVM sometimes prints \"HotSpot not at correct virtual address.\n # Sharing disabled.\" for instance. Without parsing the output, the name of the\n # bootjar file will be wrong.\n rawout = @ant.get_ant_property(outputproperty)\n out = rawout\n rawout.each do |line|\n if line =~ /^dso-boot-/\n out = line\n break\n end\n end\n @path = FilePath.new(@directory, out)\n end\n\n @path\n end",
"def wrap_xcodebuild\n require 'fileutils'\n @wrapped_xcodebuild_path ||= File.join(Gym::ROOT, \"lib/assets/wrap_xcodebuild/xcbuild-safe.sh\")\n end",
"def initialize(build_path, cache_path=nil)\n @build_path = build_path\n @cache_path = cache_path\n end",
"def initialize(build_path, cache_path=nil)\n @build_path = build_path\n @cache_path = cache_path\n end",
"def build_workspace_dir(root_dir, dirname, uuid)\n \"/#{root_dir}/#{dirname}-#{uuid}\"\nend",
"def current_path\n ::File.join(install_path, artifact_name, 'current')\n end",
"def temporary_file\n # Ensure this is unique so that is doesn't clash with parallel compile processes\n Pathname.new \"#{Origen.root}/tmp/compiler_#{Process.pid}_#{Time.now.to_f}\"\n end",
"def android_build_root()\n \"#{build_root}/android\"\n end",
"def build\n output_filepath = \"#{self.build_path}/#{OUTPUT_FILENAME}\"\n\n Dir.chdir \"#{self.build_path}\"\n\n # Need 1.9.4 version in order have file encoding\n cmd = \"#{ENV['ant']} #{@config[:build_name]}\"\n #cmd = \"/usr/local/bin/ant #{@config[:build_name]}\"\n\n log \"Running '#{cmd}' in #{self.build_path}\"\n output = system(cmd)\n\n return output_filepath\n end",
"def generate_build\n filename = \"#{self.build_path}/#{ANT_BUILD_NAME}\"\n log \"Writing build xml to #{filename}\"\n File.open(filename, 'w') do |f|\n f.write(self.build_doc)\n f.close\n end\n filename\n end",
"def release_path\n @config[:remote_path]\n end",
"def remote_tmp_release_dir\n @remote_tmp_release_dir ||= File.join(remote_dir, File.basename(destination))\n end",
"def file_path\n FileUtils.mkdir_p @path unless Dir.exist? @path\n\n @path\n end",
"def path(key = '')\n @path ||= File.join(File.expand_path(@options[:repo]), key)\n end",
"def path(key = '')\n @path ||= File.join(File.expand_path(@options[:repo]), key)\n end",
"def version_path\n @version_path ||= \"lib/#{namespaced_path}/version.rb\"\n end",
"def iphone_build_root()\n \"#{build_root}/iphone\"\n end",
"def build_root\n self.class.build_root.join(name)\n end",
"def path\n @path ||= Pathname.new(dir) + filename\n end",
"def build_path\n @path_values.inject(base_value){|uri,path| uri.merge URI::Generic.build(path: path) }.path\n end",
"def prep_build\n stdout.out_success(\"\\nPreparing build dir at: '#{settings['build_dir']}'\")\n stdout.verbose(\"Removing build dir at: #{settings['build_dir']}\")\n FileUtils.rm_rf(settings['build_dir'])\n # create the build dir\n stdout.verbose(\"Creating build dir at: #{settings['build_dir']}\")\n FileUtils.mkdir(settings['build_dir'])\n end",
"def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(Rake.application.rakefile.to_s, 'w') { |file| file.write buildfile }\n end",
"def pkg_dir\n @pkg_dir ||= File.join( self.build_dir, \"#{name + ( version ? \"-#{version}\" : \"\" ) }\" )\n end",
"def remote_buildparams(host, build)\n params_file = build.config_to_yaml\n params_file_name = File.basename(params_file)\n params_dir = rand_string\n rsync_to(params_file, host, \"/tmp/#{params_dir}/\")\n \"/tmp/#{params_dir}/#{params_file_name}\"\nend",
"def cache_repository_path\n File.absolute_path(File.join(Rails.root, 'cache', cached_directory))\n end",
"def disk_path\n project.full_path\n end",
"def build_information_file\n dir = FilePath.new(@build_dir, \"cruisecontrol_integrated_xml_files\").ensure_directory\n FilePath.new(dir, \"build-information.xml\")\n end",
"def build_store_path\n prefix = ENV['RST_DATA'] || RST::STOREPATH\n env = ENV['RST_ENV'] || 'development'\n _dir = File.join( prefix, env )\n FileUtils.mkdir_p(_dir)\n File.join(_dir, filename)\n end",
"def path\n Rails.root.join(ROOT, type, name, executable).to_s\n end",
"def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(version_file, 'w') { |file| file.write buildfile }\n end",
"def dependency_cache_path\n self.dependency_cache_path = tmp_path unless defined?(@dependency_cache_path)\n @dependency_cache_path\n end",
"def workdir\n @workdir ||= ::File.join(::File.dirname(@repo_dir), 'download')\n end",
"def render_path\n @render_path ||= generate_file_name(@site.config[\"url\"], @site.config[\"baseurl\"])\n end",
"def bits_full_local_path\n File.join(version_dir, BITS_FILENAME)\n end",
"def version_dir\n products_dir = Product.version_directory\n product_dir = File.join(products_dir, @product.name)\n File.join(product_dir, @version.to_s)\n end",
"def run_dir\n run_base + \"/g4.#{geant_version}_cms_#{cmssw_version}/#{build_type}/CMSSW_#{cmssw_version}/src\"\n end"
] | [
"0.84372586",
"0.8229979",
"0.7963283",
"0.77578425",
"0.7565874",
"0.7471925",
"0.7429258",
"0.7429258",
"0.7265769",
"0.71524256",
"0.7131272",
"0.6965351",
"0.6965163",
"0.6897426",
"0.68804795",
"0.6801705",
"0.67536116",
"0.6709585",
"0.6709585",
"0.6575804",
"0.65496135",
"0.645992",
"0.643385",
"0.64302766",
"0.6425139",
"0.6364435",
"0.63219863",
"0.626471",
"0.61810726",
"0.61505336",
"0.6142962",
"0.60993105",
"0.60848343",
"0.6083968",
"0.6081734",
"0.6071884",
"0.6050367",
"0.6045341",
"0.60299736",
"0.6007852",
"0.6004522",
"0.59775686",
"0.59684277",
"0.5961959",
"0.5960278",
"0.5951512",
"0.5950245",
"0.5946067",
"0.5935271",
"0.59195054",
"0.59181744",
"0.58933496",
"0.5876854",
"0.58532137",
"0.58453727",
"0.58379036",
"0.5828864",
"0.5826773",
"0.5820058",
"0.5780421",
"0.57744896",
"0.5747088",
"0.5742532",
"0.57261866",
"0.57112026",
"0.57082605",
"0.5699591",
"0.5699591",
"0.5687431",
"0.5669981",
"0.5666315",
"0.5656036",
"0.5652422",
"0.56497735",
"0.56326514",
"0.56263345",
"0.5624581",
"0.5622824",
"0.5622824",
"0.5608523",
"0.5604313",
"0.5600391",
"0.55990124",
"0.5585202",
"0.5583905",
"0.5580939",
"0.5579834",
"0.55704784",
"0.55444896",
"0.55392873",
"0.55373657",
"0.5535212",
"0.55305994",
"0.55294526",
"0.55277187",
"0.5525116",
"0.5515786",
"0.55093133",
"0.5509279",
"0.550818"
] | 0.79782736 | 2 |
Accessor for source_path The source path is the root of the mockup | def source_path
Pathname.new(self.config[:source_path])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source_path\n source[:path]\n end",
"def source_path\n Pathname.new(config[:source_path])\n end",
"def source_path; end",
"def source_path\n File.expand_path source unless source.nil?\n end",
"def source_path(arg=nil)\n set_or_return(\n :source_path,\n arg,\n :kind_of => [ String ]\n )\n end",
"def source_path\n return @source_path if !@source_path.nil?\n @source_path = Photo.photos_root_list.find{|path| path[self.path]}\n end",
"def source_root\n File.expand_path(options[:source])\n end",
"def source_dir\n @config.source_dir\n end",
"def source_file\n return @source_file\n end",
"def source\n File.read(source_path)\n end",
"def pathSourceDemo\n\t\"./demo/\"\nend",
"def source_location()\n #This is a stub, used for indexing\n end",
"def source_access_path\n _access_path(source_annotations)\n end",
"def file_with_source_path(source_path)\n source_path = source_path.unicode_normalize\n @source_path_to_file[source_path] || @abs_source_path_to_file[source_path]\n end",
"def source_root\n @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))\n end",
"def source_location\n source_component.source_location\n end",
"def src_path\n File.dirname(__FILE__)\nend",
"def src_path\n File.dirname(__FILE__)\nend",
"def source_file\n @source_file || get_source_file\n end",
"def source_file\n @source_location[0]\n end",
"def source\n @source ||=\n Dassets.config.sources.select{ |source|\n @file_path =~ /^#{slash_path(source.path)}/\n }.last\n end",
"def compute_source_path(source, ext)\n asset_for(source, ext)\n end",
"def path\n asset_source_path\n end",
"def path\n asset_source_path\n end",
"def source_root\n @source_root ||= Pathname.new(File.expand_path(\"..\", __dir__))\n end",
"def source_path\n sp = []\n\n Tml.session.block_options_queue.each do |opts|\n next unless hash_value(opts, :source)\n sp << hash_value(opts, :source)\n end\n\n sp = sp.reverse\n sp.unshift(Tml.session.current_source)\n\n sp.join(Tml.config.source_separator)\n end",
"def source\n @source ||= begin\n source_opts = {\n :folder => File.join(options(:root), options(:source)),\n :cache => Rack::Sprockets.config.cache? ? cache : nil,\n :compress => Rack::Sprockets.config.compress,\n :secretary => {\n :root => options(:root),\n :load_path => options(:load_path),\n :expand_paths => options(:expand_paths)\n }\n }\n Source.new(path_info_resource, source_opts)\n end\n end",
"def source_dir\n Dir.pwd\nend",
"def source\n f = File.open(File.join(root_path, path))\n data = f.read\n f.close\n data\n end",
"def source\n @source\n end",
"def source\n @source\n end",
"def mock_file_path\n source = __dir__\n File.join(source, \"input/input.csv\")\n end",
"def external_path_for_source\n @external_path_for_source ||= File.join('source', 'external_document', external_name)\n end",
"def local_source\n @local_source ||= File.join( build_dir, File.basename( upstream_source.path ) )\n end",
"def source_path options={}\n @source_path ||= if options[:relative]\n File.join collection_path, \"#{id}.md\"\n else\n File.join Rails.root, collection_path, \"#{id}.md\"\n end\n end",
"def source\n @source ||= begin\n source_opts = {\n :folder => File.join(options(:root), options(:source)),\n :cache => Rack::Sprockets.config.cache? ? cache : nil,\n :compress => Rack::Sprockets.config.compress,\n :secretary => {\n :root => options(:root),\n :load_path => options(:load_path),\n :expand_paths => options(:expand_paths)\n }\n }\n Source.new(path_resource_name, source_opts)\n end\n end",
"def target_file_path\n model.source_location(target_symbol)[:file_path]\n end",
"def source_path\n src = File.join *[\n sandbox.path,\n ('..' if sandbox.multiruby?),\n 'src'\n ].compact\n\n FileUtils.mkdir_p src\n\n src\n end",
"def source_path\n File.join(File.expand_path('../../', __FILE__), 'vendor', 'sg_node_mapper', 'nodemapper.js')\n end",
"def source_paths\n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source_paths\n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source_paths\n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source_paths\n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source\n @_source ||= \"#{@rf['directory']}#{base_filename}.#{format}\"\n end",
"def source_file=(value)\n @source_file = value\n end",
"def pathDistSource\n\tpathDist + \"source/\"\nend",
"def source_paths\n [__dir__]\nend",
"def source_paths\n [__dir__]\nend",
"def sources\n source_paths\n end",
"def relative_to_source(properties, key)\n path = properties[key]\n base = @source_dir ? @source_dir : ''\n\n return nil if path == nil\n return path if Pathname.new(path).absolute?\n return File.expand_path(File.join(base, path))\n end",
"def determine_path\n if source_line.file == SourceLine::DEFAULT_FILE\n return source_line.file\n end\n\n full_path = File.expand_path(source_line.file)\n pwd = Dir.pwd\n\n if full_path.start_with?(pwd)\n from = Pathname.new(full_path)\n to = Pathname.new(pwd)\n\n return from.relative_path_from(to).to_s\n else\n return full_path\n end\n end",
"def test_automatically_sets_source_path_argument\n assert_equal( [ 'test/fixtures/target', 'libs/src' ], @cmd.source_path )\n end",
"def test_automatically_sets_source_path_argument\n assert_equal( [ 'test/fixtures/target', 'libs/src' ], @cmd.source_path )\n end",
"def src_path(path)\n app_path('src/' + path)\n end",
"def test_can_add_paths_to_source_path\n Crd::Spec.new 'Testing' do |s|\n s.source_path << 'test/fixtures'\n assert_equal( [ 'test/fixtures' ], s.source_path )\n end\n end",
"def source\n \"#{source_repo}/#{source_branch}\"\n end",
"def source_dir\n @_source_dir ||= File.join(working_dir, 'src')\n create_if_missing(@_source_dir)\n @_source_dir\n end",
"def source_dir\n @_source_dir ||= File.join(working_dir, 'src')\n create_if_missing(@_source_dir)\n @_source_dir\n end",
"def source_dir\n @_source_dir ||= File.join(working_dir, 'src')\n create_if_missing(@_source_dir)\n @_source_dir\n end",
"def source(folder = nil)\n @source ||= File.expand_path(folder)\n end",
"def image_path(source)\n path_to_asset(source)\n end",
"def source_location; end",
"def get_source(workdir)\n if @url\n @source = Vanagon::Component::Source.source(@url, @options, workdir)\n @source.fetch\n @source.verify\n @extract_with = @source.respond_to?(:extract) ? @source.extract(@platform.tar) : ':'\n @cleanup_source = @source.cleanup if @source.respond_to?(:cleanup)\n @dirname = @source.dirname\n\n # Git based sources probably won't set the version, so we load it if it hasn't been already set\n @version ||= @source.version\n else\n warn \"No source given for component '#{@name}'\"\n\n # If there is no source, we don't want to try to change directories, so we just change to the current directory.\n @dirname = './'\n\n # If there is no source, there is nothing to do to extract\n @extract_with = ':'\n end\n end",
"def src_path(path)\n File.join(@git.dir.to_s, path)\n end",
"def source_paths\n source_path = [$RR_PATH] + Array(super)\n # say \"source path = #{source_path}\", :magenta\n source_path\nend",
"def source\n @source ||= config_params(:source) || self.class.const_get(:DEFAULT_SOURCE)\n end",
"def source\n @source ||= config_params(:source) || self.class.const_get(:DEFAULT_SOURCE)\n end",
"def source()\n #This is a stub, used for indexing\n end",
"def source()\n #This is a stub, used for indexing\n end",
"def source_paths\n Array(super) +\n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source_paths\n Array(super) +\n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source_paths\n Array(super) +\n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source_paths\n Array(super) +\n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source_paths\n Array(super) +\n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source_paths\n Array(super) +\n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source_paths\n Array(super) + \n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source_paths\n Array(super) + \n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source_paths\n Array(super) + \n [File.expand_path(File.dirname(__FILE__))]\nend",
"def source_paths\n[File.join(File.expand_path(File.dirname(__FILE__)),'rails_root')]\nend",
"def source_root\n FilePath.new(build_module.root, name).canonicalize\n end",
"def source_for(path)\n read(path, false)\n end",
"def path\n @path ||= @project.dir.path\n end",
"def source\n return @source\n end",
"def source\n return @source\n end",
"def prepared_path\n @prepared_path || @spec[:path]\n end",
"def compiled_path; end",
"def source\n raise NotImplementedError\n end",
"def source_location\n\t\t\tself.method.source_location\n\t\tend",
"def source_vendor_path; \"#{spec_path}/vendor\"; end",
"def get_file_path\n @path\n end",
"def source\n @source || load_file_contents\n end",
"def source\n @source ||= File.join(Rails.root, 'config', 'settler.yml') if defined?(Rails)\n @source\n end",
"def path\n File.join(@base, @target)\n end",
"def image_path(source)\n compute_public_path(source, 'images')\n end",
"def source_url\n settings.source_url\n end",
"def get_source\n raise 'check this!'\n # _reflector = new ReflectionClass($this);\n # $file = _reflector.filename;\n # if (!file_exists($file)) {\n # return;\n # end\n # $source = file($file, FILE_IGNORE_NEW_LINES);\n # array_splice($source, 0, _reflector.getEndLine());\n # $i = 0;\n # while (isset($source[$i]) && '/* */' == substr_replace($source[$i], '', 3, -2)) {\n # $source[$i] = str_replace('*//* ', '*/', substr($source[$i], 3, -2));\n # ++$i;\n # end\n # array_splice($source, $i);\n # return implode(\"\\n\", $source);\n end",
"def path\n @file.path\n end",
"def initialize(source=\"./\")\n @source = Pathname(source).expand_path\n # `data_dir` defaults to the `_data` directory under `source`.\n @data_dir = source.join(\"_data\")\n end",
"def source\n ap get_source\n end",
"def get_project_path\n return File.absolute_path File.join(root_dir, src)\n end"
] | [
"0.8344127",
"0.8238438",
"0.78063005",
"0.7785738",
"0.7176389",
"0.71564126",
"0.71483874",
"0.70960146",
"0.70173323",
"0.6965058",
"0.6963628",
"0.69631183",
"0.6955219",
"0.6911176",
"0.6908136",
"0.68852246",
"0.6868716",
"0.6868716",
"0.68481433",
"0.68187237",
"0.6800048",
"0.6794561",
"0.67864615",
"0.67864615",
"0.67741233",
"0.67367804",
"0.6693624",
"0.66721183",
"0.6651485",
"0.66215765",
"0.66215765",
"0.6613955",
"0.66079855",
"0.65993893",
"0.65835875",
"0.65803033",
"0.65512407",
"0.65420943",
"0.6521418",
"0.6517295",
"0.6517295",
"0.6517295",
"0.6517295",
"0.65168273",
"0.65151083",
"0.651086",
"0.6484849",
"0.6484849",
"0.6459212",
"0.64541703",
"0.6450849",
"0.6443329",
"0.6443329",
"0.64296657",
"0.6421082",
"0.6416847",
"0.6412876",
"0.6412876",
"0.6412876",
"0.63988894",
"0.63969064",
"0.6388465",
"0.63809913",
"0.6378566",
"0.6375418",
"0.63712525",
"0.63712525",
"0.6358592",
"0.6335058",
"0.6331374",
"0.6331374",
"0.6331374",
"0.6331374",
"0.6331374",
"0.6331374",
"0.63251",
"0.63251",
"0.63251",
"0.6306244",
"0.63044757",
"0.62891865",
"0.62775713",
"0.62771344",
"0.62771344",
"0.62682223",
"0.6258448",
"0.62573296",
"0.6250494",
"0.62423295",
"0.62351555",
"0.62294155",
"0.62278587",
"0.62255645",
"0.6206052",
"0.61966324",
"0.61960644",
"0.6134417",
"0.6123494",
"0.6116872",
"0.6109855"
] | 0.8326357 | 1 |
Get the current SCM object | def scm(force = false)
return @_scm if @_scm && !force
case self.config[:scm]
when :git
@_scm = Release::Scm::Git.new(:path => self.source_path)
else
raise "Unknown SCM #{options[:scm].inspect}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scm\n @defaults[ :scm ] ||= SCM::Git.new\n end",
"def scm\n if(@scm.nil?)\n path = path_to_git\n raise GitTaskError.new(\"We don't appear to be inside of a git repository\") if path.nil?\n @scm = Git.open(path)\n end\n\n @scm\n end",
"def scm(force = false)\n return @_scm if @_scm && !force\n\n case config[:scm]\n when :git\n @_scm = Release::Scm::Git.new(path: source_path)\n when :fixed\n @_scm = Release::Scm::Fixed.new\n else\n raise \"Unknown SCM #{options[:scm].inspect}\"\n end\n end",
"def scm config\n # no engine specified\n if !config\n return nil\n end\n\n # git backend\n if config['scm'] == 'git'\n return Git.new(self)\n end\n end",
"def scm_value\n self\n end",
"def scm=(scm)\n @scm = scm\n end",
"def scm\n @scm = menu_with_default \"Which SCM to use for deployment\",\n [:git,:passthrough ], :git\n\n case @scm\n when :passthrough\n %W{ capistrano-deploy-scm-passthrough capistrano-improved-rsync-with-remote-cache}.each do |g|\n append_to_file \"Gemfile\", \"gem '#{g}', :group => :development\\n\"\n end\n end\n @scm\n end",
"def get_scm_data(ref = @config[:ref])\n @_version = scm_version(ref) || \"\"\n @_date = scm_date(ref) || Time.now\n end",
"def current_workspace\n get_ws = Proc.new do\n params['workspace_id'] ? \n Workspace.find(params['workspace_id'].to_i) : current_user.private_workspace\n end\n \n if @workspace\n # Hack: Workspace may be \"Workspace.new\"\n return @workspace if @workspace.id\n return get_ws.call\n end\n return @current_object if @current_object && @current_object.class == Workspace\n @workspace = get_ws.call\n end",
"def version\n get_scm_data if @_version.nil?\n @_version\n end",
"def current\n env[REPO] ||= new(env)\n end",
"def get_current_object\n if @current_object.nil?\n @parent.get_current_object\n else\n @current_object\n end\n end",
"def context\n unless @instance_context\n @instance_context = WorkspaceContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def get_scm(organization, scm, opts = {})\n data, _status_code, _headers = get_scm_with_http_info(organization, scm, opts)\n data\n end",
"def current\n self.versioned? ? self.versions.current.instance : self\n end",
"def current_branch\n self.lib.branch_current\n end",
"def get_current_client\n get_current_hub&.current_client\n end",
"def rb2scm(obj)\n case obj\n when NilClass\n SCM_EMPTY_LIST\n when FalseClass, TrueClass\n rb2scm_bool(obj)\n when Symbol\n rb2scm_symbol(obj)\n when Numeric\n rb2scm_number(obj)\n when Char\n rb2scm_char(obj)\n when String\n rb2scm_string(obj)\n when IO\n rb2scm_port(obj)\n when Pair\n rb2scm_pair(obj)\n when Array\n rb2scm_vector(obj)\n when ScmObject\n # nothing to do, just return\n obj\n else\n raise ArgumentError, \"not supported: %s\" % obj.class\n end\n end",
"def get_current_owner\n sd = get_security_descriptor\n\n sd&.owner\n end",
"def rpc_current_workspace\n db_check\n { \"workspace\" => self.framework.db.workspace.name, \"workspace_id\" => self.framework.db.workspace.id }\n end",
"def current\n R10K::Git::Head.new('HEAD', self)\n end",
"def current_company\n Company.find(1)\n end",
"def current\n add_breadcrumb :current\n @sprint = @project.sprints.find_by_active(true)\n end",
"def scm_list?; SCM_FALSE; end",
"def get_current_scope\n get_current_hub&.current_scope\n end",
"def current\n all_contexts[Thread.current.object_id]\n end",
"def scm_default\n if File.exist? '.git'\n :git\n elsif File.exist? '.accurev'\n :accurev\n elsif File.exist? '.bzr'\n :bzr\n elsif File.exist? '.cvs'\n :cvs\n elsif File.exist? '_darcs'\n :darcs\n elsif File.exist? '.hg'\n :mercurial\n elsif File.exist? '.perforce'\n :perforce\n elsif File.exist? '.svn'\n :subversion\n else\n :none\n end\n end",
"def current_branch\n git.branch.name\n end",
"def current\n @env.first\n end",
"def scm_string?; SCM_FALSE; end",
"def system\n JenkinsApi::Client::System.new(self)\n end",
"def system\n JenkinsApi::Client::System.new(self)\n end",
"def object\n __getobj__\n end",
"def current\n @current ||= Current.new(@session)\n end",
"def scm_default\n if File.exist? '.git'\n :git\n elsif File.exist? '.accurev'\n :accurev\n elsif File.exist? '.bzr'\n :bzr\n elsif File.exist? '.cvs'\n :cvs\n elsif File.exist? '_darcs'\n :darcs\n elsif File.exist? '.hg'\n :mercurial\n elsif File.exist? '.perforce'\n :perforce\n elsif File.exist? '.svn'\n :subversion\n else\n :none\n end\n end",
"def current_client\n @current_client ||= @finder.call\n end",
"def current_branch\n repo.branches.find(&:head?)\n end",
"def get_application_code\n case $scm_type\n when 'git' then\n export_source_from_git $scm_path\n $revision = git_get_revision\n end\nend",
"def git\n # log \"Thread.current[:repo] nil? \" + Thread.current[:repo].nil?.to_s\n Thread.current[:repo] ||= clone(ARGV[0], ARGV[1])\n Thread.current[:repo]\n end",
"def current_branch\n `git symbolic-ref --short -q HEAD`.chomp\n end",
"def current_subcom\n @current_subcom ||= Subcommunity.find(params[:subcommunity_id])\n end",
"def current_branch\n @current_branch ||= `git rev-parse --abbrev-ref HEAD`.strip\n end",
"def new_client\n Svn::Client::Context.new\n end",
"def vcs_type\n @vcs_type ||= (\n dir = nil\n Dir.chdir(root) do\n dir = Dir.glob(\"{.git,.hg,.svn,_darcs}\").first\n end\n dir[1..-1] if dir\n )\n end",
"def sys_source\n @sys_source ||= MakeMakefile.find_executable(\"jscs\")\n end",
"def workspace\n @cue_list.workspace\n end",
"def current(cmd_type, cmd_str)\n @full_path ||= File.expand_path( File.dirname(__FILE__) ).gsub(/\\/config/, '')\n @curr_path ||= @full_path['/releases/'] ? @full_path.gsub(/releases\\/\\d+/, 'current') : @full_path \n \n send(cmd_type, cmd_str, :path => @curr_path)\nend",
"def current_weblab\n return $current_weblab\n end",
"def open(scm, options={}, &block) #:yield: io\n scm.open(self, options, &block)\n end",
"def context\n unless @instance_context\n @instance_context = CpsContext.new(@version, )\n end\n @instance_context\n end",
"def current_branch\n repo.branches.find(&:head?)\n end",
"def current_live\n self.versioned? ? self.versions.current_live.instance : self\n end",
"def current_workplace\n if @workplace && current_admin\n @workplace.name\n else#fail safe\n end \n end",
"def get_current_owner #:doc:\n self.send \"current_#{owner_class.name.underscore}\".to_sym\n end",
"def current\n Thread.current.thread_variable_get(:reactor)\n end",
"def system\n return @system\n end",
"def fetch_workspace\n # @workspace = current_path?(root_path) ? current_user.workspaces.first : Workspace.find(params[:workspace_id])\n @workspace = request.url == root_url ? current_user.workspaces.first : current_user.workspaces.find(params[:workspace_id])\n end",
"def initialize\n @current = LIFECYCLE.first\n end",
"def current_server\n @_current_server\n end",
"def current_server\n @_current_server\n end",
"def current_object\n @current_object ||= if plural?\n current_model.find(current_param)\n else\n parent_objects[-1].send(instance_variable_name)\n end\n end",
"def get_company\n @company ||= current_company\n end",
"def current_company\n Company.find(:first)\nend",
"def current_editor\n @current_editor = User.find_by_id(locked_by)\n return _('unknown') if @current_editor.nil?\n @current_editor.name\n end",
"def get_contract_current()\n self.class.get(\"/api/contracts/current\", :basic_auth => @auth)\n end",
"def current_branch\n `git symbolic-ref --short HEAD`.strip\n end",
"def project \n organizing_city.current_project\n end",
"def repo\n @repo\n end",
"def current_site\n @site = Site.first\n end",
"def current_revision\n @svninfo.current_revision\n end",
"def current_branch\n Dir.chdir @root do\n cmd = \"git rev-parse --abbrev-ref HEAD\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n case stderr\n when /unknown revision/\n raise Error, \"could not determine branch of repo with no commits\"\n when /Not a git repository/\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n return stdout.strip\n end\n end",
"def context\n unless @instance_context\n @instance_context = CompositionContext.new(@version, @params['sid'], )\n end\n @instance_context\n end",
"def current\n LOOPS[Thread.current]\n end",
"def scm_null?; SCM_FALSE; end",
"def current_editor\n @current_editor = User.find_by_id(locked_by)\n return I18n.t('unknown') if @current_editor.nil?\n @current_editor.name\n end",
"def rb2scm_string(str)\n ScmString.new(str)\n end",
"def current_object\n unless self.controller.respond_to? :current_object\n raise ArgumentError, \"#{self.controller} expected to define current_object. Example: UsersController.current_object should return a @user\"\n end\n self.controller.send(:current_object)\n end",
"def resolve_current\n resolve Gem::Resolver::CurrentSet.new\n end",
"def scm_set_car!(scm_obj)\n @scm_car = scm_obj\n SCM_UNDEF\n end",
"def model_class\n ::Ci::Build\n end",
"def repo\n settings.repo\n end",
"def current_editor\n @current_editor || creator\n end",
"def get_site\n controller.send(:current_site)\n end",
"def current_subscription\n self.subscriptions.current.first\n end",
"def currentbranch\n %x{git branch | grep \"*\" | sed \"s;* ;;\"}.squish\n end",
"def branch_name\n $repo.current_branch\n end",
"def client\n Contentful::Management::Client.shared_instance\n end",
"def current\n return nil if @temporary == :none\n return nil if @disabled\n\n name = @temporary || @current ||= if Origen.app.session.origen_core[:default_plugin]\n Origen.app.session.origen_core[:default_plugin]\n elsif Origen.app.config.default_plugin && !Origen.app.session.origen_core[:default_plugin_cleared_by_user]\n Origen.app.config.default_plugin\n end\n\n find { |p| p.name.to_sym == name } if name\n end",
"def status\n GitStatus.new(self)\n end",
"def current_job\n return @job_current\n end",
"def current_cookbook\n @current_cookbook ||= Cookbook.find session[:cookbook_id] if session[:cookbook_id]\n end",
"def current_branch\n return @branch unless @branch.blank?\n @branch = case @svninfo.url\n when /trunk/ then \"trunk\"\n when /branches\\/private\\/([^\\/]+)/ then $1\n when /branches\\/([^\\/]+)/ then $1\n when /tags\\/([^\\/]+)/ then $1\n else @config_source[\"branch\"]\n end \n @branch || \"unkown\"\n end",
"def vcs\n @vcs ||= Nanoc::Extra::VCSes::Dummy.new\n end",
"def resolve_current\n resolve DependencyResolver::CurrentSet.new\n end",
"def current_site\n @current_site ||= Site.find_by_subdomain! subdomain\n end",
"def current_version\n self.historical? ? self.class.find(self.id) : self\n end",
"def current_version\n self.historical? ? self.class.find(self.id) : self\n end",
"def current\n Thread.current[:CURRENT_CONTROLLER]\n end",
"def workspace\n\t\tself.datastore['WORKSPACE'] ||\n\t\t\t(framework.db and framework.db.active and framework.db.workspace and framework.db.workspace.name)\n\tend",
"def date\n get_scm_data if @_date.nil?\n @_date\n end"
] | [
"0.7458993",
"0.6901301",
"0.67117935",
"0.65891117",
"0.65846723",
"0.653226",
"0.6157386",
"0.6155567",
"0.61297804",
"0.60138744",
"0.59655905",
"0.58169913",
"0.5761971",
"0.5724984",
"0.5682817",
"0.5640998",
"0.55145156",
"0.5508112",
"0.5503778",
"0.5501113",
"0.5499637",
"0.54855746",
"0.54676753",
"0.5466487",
"0.5444447",
"0.54185265",
"0.5394431",
"0.5391712",
"0.53680533",
"0.5358573",
"0.5346897",
"0.5346897",
"0.5346456",
"0.5330116",
"0.5318795",
"0.5315476",
"0.53013694",
"0.52857786",
"0.52817136",
"0.52802116",
"0.52769095",
"0.52658963",
"0.52649146",
"0.52580476",
"0.52572846",
"0.5253249",
"0.5252322",
"0.52430606",
"0.5240519",
"0.522157",
"0.52214414",
"0.52103233",
"0.5204494",
"0.5195933",
"0.5180187",
"0.5177304",
"0.51701295",
"0.5170022",
"0.5156054",
"0.5156054",
"0.5144268",
"0.51272047",
"0.51216733",
"0.51190114",
"0.5109246",
"0.5107817",
"0.5103384",
"0.5094417",
"0.50861984",
"0.5079429",
"0.50745285",
"0.5067325",
"0.50556225",
"0.50546384",
"0.5041352",
"0.5031385",
"0.503112",
"0.5026751",
"0.50149924",
"0.50145644",
"0.5006853",
"0.500384",
"0.50034755",
"0.50015265",
"0.50000876",
"0.49973127",
"0.49936777",
"0.49928597",
"0.49928516",
"0.49920145",
"0.49909607",
"0.49898836",
"0.49895534",
"0.49889538",
"0.4977685",
"0.4975856",
"0.4975856",
"0.49748775",
"0.49638253",
"0.49588174"
] | 0.6887394 | 2 |
Use a certain preprocessor | def use(processor, options = {})
@stack << [self.class.get_callable(processor, HtmlMockup::Release::Processors), options]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess(text, defines={})\n defines = defines.dup\n result = []\n active_stack = []\n active = true\n text.each_line do |line|\n case line\n when /^#\\s*define\\s+(\\w+)\\s+(\\w*)\\s*$/\n defines[$1] = $2 if active\n when /^#\\s*if\\s+(\\w+)\\s*$/\n active_stack.push active\n active = active &&\n case preprocessor_expand($1, defines)\n when '0': false \n when '1': true\n else raise \"Can't parse: #{line}\" end\n when /^#\\s*ifdef\\s+(\\w+)\\s*$/\n active_stack.push active\n active = active && defines.has_key?($1)\n when /^#\\s*ifndef\\s+(\\w+)\\s*$/\n active_stack.push active\n active = active && !defines.has_key?($1)\n when /^#\\s*if\\s+[vV][eE][rR]\\s+(<|>)=?\\s+0x[0-9a-zA-Z]{8}\\s*$/\n # Allow version checks, but always consider the version to be higher\n # than the version compared to.\n active_stack.push active\n active = active && ($1 == \">\")\n when /^#\\s*else\\s*$/\n # If we have a parent if, and it's inactive, we don't actually\n # want to do anything here.\n active = !active if active_stack.empty? || active_stack.last\n when /^#\\s*endif(\\s+(\\w+))?\\s*$/\n active = active_stack.pop\n when /^#\\s*error\\s+(.+)$/\n raise $1 if active\n when /^#.*$/\n raise \"Unknown preprocessor command: #{line}\"\n else\n result << line if active\n end\n end\n raise \"Missing #endif\" unless active_stack.empty?\n result.join\n end",
"def preprocess(&block)\n @site.preprocessor = block\n end",
"def macro; end",
"def macro; end",
"def formatPreprocessor(theLines)\n\n\talignEndifs(\t\ttheLines);\n\talignUndefineDefine(theLines);\n\talignDefineValue(\ttheLines);\n\talignContinuations(\ttheLines);\n\n\treturn theLines;\n\nend",
"def inline_macro name, processor\n processor = resolve_processor_class processor\n @inline_macros[name.to_s] = processor\n end",
"def preprocessor_expand str, definitions\n while definitions.has_key? str\n str = definitions[str].to_s\n end\n str\n end",
"def pre_processors\n @pre_processors ||= []\n end",
"def process(source)\n\t\t\t@source = source.respond_to?(:path) ? File.basename(source.path) : 'unknown'\n\t\t\t@line_no = 0\n\t\t\t@last_if = nil\n\t\t\t@outputting = true\n\t\t\tout_lines = []\n\t\t\tsource.each_line do |line|\n\t\t\t\t@line_no += 1\n\t\t\t\tif is_from_preprocessor?(line)\n\t\t\t\t\tparse(line)\n\t\t\t\telse\n\t\t\t\t\tif @outputting\n\t\t\t\t\t\tout_lines << line\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\tif @last_if\n\t\t\t\traise PreprocessorError, \"#@source:#@last_if:error: unmatched #if\"\n\t\t\tend\n\t\t\tFakeIO.new(out_lines)\n\t\tend",
"def on_request( &block )\n @preprocessor = block\n end",
"def register_processor(*args, &block)\n register_preprocessor(*args, &block)\n end",
"def compileif\n\n end",
"def handle_ifdefs_in(body)\n body.gsub(/^#ifdef HAVE_PROTOTYPES.*?#else.*?\\n(.*?)#endif.*?\\n/m, '\\1')\n end",
"def handle_ifdefs_in(body)\n body.gsub(/^#ifdef HAVE_PROTOTYPES.*?#else.*?\\n(.*?)#endif.*?\\n/m) { $1 }\n end",
"def debug_include\n'#ifndef NDEBUG\n#include <iostream>\n#endif'\n end",
"def mock_defines(mock_config)\n family = mock_el_family(mock_config)\n version = mock_el_ver(mock_config)\n defines = \"\"\n if version =~ /^(4|5)$/ or family == \"sles\"\n defines = %(--define \"dist .#{family}#{version}\" \\\n --define \"_source_filedigest_algorithm 1\" \\\n --define \"_binary_filedigest_algorithm 1\" \\\n --define \"_binary_payload w9.gzdio\" \\\n --define \"_source_payload w9.gzdio\" \\\n --define \"_default_patch_fuzz 2\")\n end\n defines\nend",
"def define_rules\n verify_swig_version\n super\n Rake::Task.create_rule(\n /#{env[:swig_cppext]}$/ => [proc {|t| t.sub /#{env[:swig_cppext]}$/, '.'+env[:swigext] }]\n ) do |r|\n sh_cmd :swig, :swig_flags, {'-I' => :swig_includedirs}, {'-I' => :includedirs},\n '-o', r.name, r.sources\n end\n end",
"def define; end",
"def register_preprocessor(mime_type, klass, &block)\n mutate_hash_config(:preprocessors, mime_type) do |processors|\n processors.push(wrap_processor(klass, block))\n processors\n end\n end",
"def macro!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 48 )\n\n type = MACRO\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 169:9: 'macro'\n match( \"macro\" )\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__, 48 )\n\n end",
"def macro(spec)\n @c.macro(*spec.split('='))\n end",
"def define\n end",
"def define\n end",
"def test_preprocessor(preprocessor,input,expected)\n # Prepare the output and the input streams\n puts \"Preparing the input and ouput streams...\"\n output = StringIO.new(\"\")\n # Process the input and exepected arguments.\n if !input.respond_to?(:each_line) or input.is_a?(String) then\n # input is actually a file name, open it.\n input = File.open(input.to_s,\"r\")\n end\n if !expected.respond_to?(:each_line) or expected.is_a?(String) then\n # expected is actually a file name, open it.\n expected = StringIO.new(File.read(expected.to_s))\n end\n\n # Apply the preprocessor\n puts \"Applying the preprocessor...\"\n preprocessor.preprocess(input,output)\n\n # Check the result\n puts \"Checking the result...\"\n output.rewind\n check = output.string == expected.read\n\n unless check\n puts \"*Error*: invalid expansion result.\"\n iline = output.string.each_line\n expected.rewind\n expected.each_line.with_index do |exp_line,i|\n line = iline.next\n puts \"exp_line=#{exp_line}\"\n puts \"line=#{line}\"\n if exp_line != line then\n puts \"Expected line #{i+1}:\\n#{exp_line}\"\n puts \"got:\\n#{line}\"\n end\n end\n return false\n end\n return true\nend",
"def traite_inclusions_in code\n # On regarde si le fichier a des textes inclus\n if code.match(/^[ \\t]*<-/)\n code.gsub!(/^[ \\t]*<-([a-zA-Z0-9_\\/\\.]+)$/){\n finc = search_for_included_file(\"_#{$1}\", fpath)\n \"#{traite_inclusions_in(finc)}\"\n }\n end\n return code\n end",
"def define(arg)\n if arg\n arg = arg.chomp.rstrip.lstrip\n name = arg.split(\" \").first\n value = arg.gsub!(\"#{name} \",\"\")\n # negative\n if value =~ /^-(\\d|x)*$/ \n type = \"long\"\n # negative float\n elsif value =~ /^-(\\d|\\.|x)*$/ \n type = \"float\" \n elsif value =~ /[a-zA-Z]/\n type = \"str\"\n value = \"\\\"#{value}\\\"\"\n elsif value !~ /(\\.|x)/\n type = \"long\"\n elsif value =~ /(\\d*\\.\\d*)/ # and no \n type = \"float\"\n elsif value =~ /0x\\d\\d/\n type = \"byte\"\n else \n raise ArgumentError, \"opps, could not determine the define type, got #{value}\"\n end\n $define_types[name] = type\n arg = \"#define #{name} #{value}\"\n $defines << arg\n dummy_for_testing = arg, type\n end\n end",
"def third_party_processors; end",
"def define(*opts, &block)\n top.append(*(sw = make_switch(opts, block)))\n sw[0]\n end",
"def find(macro_name); end",
"def preproc; end",
"def preprocess(&block); end",
"def make_runnable(code)\n return %Q[\nimport webpiraten as garbledwebpiratenlibraryname\nfrom webpiraten import Dir\nfrom webpiraten import Obj\nfrom webpiraten import look\nfrom webpiraten import move\nfrom webpiraten import put\nfrom webpiraten import take\nfrom webpiraten import turn\n\ngarbledwebpiratenlibraryname.configure_prefix(\"#{VM_PREFIX}\")\n\n] + code\n end",
"def rule\n [ '$(CC)', '-DHAVE_CONFIG_H', '-I.', flags, '$(CFLAGS)', '-c', @sources ].flatten.join(' ')\n end",
"def macros(env = default_environment)\n @macros ||= {}\n @macros[env] ||= {}\n end",
"def filter(s, file = nil)\n\t\tstate = State.new([], \"\", false)\n\t\tstate.file = file\n\t\tstate.line_number = 0\n\t\ts.each_line do |line,index|\n\t\t\tstate.line = line\n\t\t\tstate.line_number += 1\n\t\t\tcheck_no_mix(state, line)\n\t\t\tcase preprocessor_word(line)\n\t\t\t\twhen \"#if\" then process_if(state, line)\n\t\t\t\twhen \"#ifdef\" then process_ifdef(state, line)\n\t\t\t\twhen \"#ifndef\" then process_ifndef(state, line)\n\t\t\t\twhen \"#elif\" then process_elif(state, line)\n\t\t\t\twhen \"#else\" then process_else(state, line)\n\t\t\t\twhen \"#endif\" then process_end(state, line)\n\t\t\t\telse process_line(state, line)\n\t\t\tend\n\t\tend\n\t\terror(state, \"Preprocessor directives not balanced\") if state.scopes.size != 0\n\t\t\n\t\treturn state.out\n\tend",
"def build_framework?; build.include? 'framework'; end",
"def create_value_preprocessor(parameter)\n type_name = parameter.type\n if type_name == TYPE_ARRAY\n if PRIMITIVE_TYPES.include? parameter.items\n preprocessor_for_values = Sinatra::SwaggerExposer::Processing::SwaggerPrimitiveValuePreprocessor.new(\n parameter.name,\n false,\n parameter.items,\n parameter.default,\n parameter.params\n )\n else\n preprocessor_for_values = create_preprocessor_for_type(parameter.name, parameter.items, false)\n end\n Sinatra::SwaggerExposer::Processing::SwaggerArrayValuePreprocessor.new(parameter.name, parameter.required, preprocessor_for_values)\n elsif PRIMITIVE_TYPES.include? type_name\n Sinatra::SwaggerExposer::Processing::SwaggerPrimitiveValuePreprocessor.new(\n parameter.name,\n parameter.required,\n type_name,\n parameter.default,\n parameter.params\n )\n else\n create_preprocessor_for_type(parameter.name, parameter.type, parameter.required)\n end\n end",
"def postproc(source)\n Array(self.class.settings[:postproc]).inject(source) do |result, processor|\n case processor.strip\n when /^moocompat12$/i\n result.gsub(/\\/\\/<1.2compat>.*?\\/\\/<\\/1.2compat>/m, '').\n gsub(/\\/\\*<1.2compat>\\*\\/.*?\\/\\*<\\/1.2compat>\\*\\//m, '')\n when /^mooltie8$/i\n result.gsub(/\\/\\/<ltIE8>.*?\\/\\/<\\/ltIE8>/m, '').\n gsub(/\\/\\*<ltIE8>\\*\\/.*?\\/\\*<\\/ltIE8>\\*\\//m, '')\n else\n Jsus.logger.error \"Unknown post-processor: #{processor}\"\n result\n end\n end\n end",
"def apply_macro(macro, docstring, call_params = T.unsafe(nil), full_source = T.unsafe(nil), block_source = T.unsafe(nil)); end",
"def preprocessor_context\n @preprocessor_context ||= Nanoc3::Context.new({\n :site => self,\n :config => self.config,\n :items => self.items,\n :layouts => self.layouts\n })\n end",
"def get_processor; end",
"def do_compile code, do_eval=true\n\t\t\[email protected]_logger.trace TRACE_ENGINE,\"Compiling #{code.fn} action #{code.action}\"\n\t\t\tbegin\n\t\t\t\t# Translate Cfruby style code into plain Ruby\n\t\t\t\ttranslator = Cfp_Translate.new(@cf,@parser)\n\t\t\t\t# Translate conditional blocks\n\t\t\t\tlines = translator.conditionals(code)\n\t\t\t\t# Line by line translation, depending on function - i.e. control, files, tidy etc.\n\t\t\t\ttranslated_lines = []\n\t\t\t\t# code.each do | line,num |\n\t\t\t\tlines.each do | line |\n\t\t\t\t\ttranslated_lines.push translator.do_translate(code.action,line)\n\t\t\t\tend\n\t\t\t\t# Encapsulate teh code into a class object\n\t\t\t\tbuf = code.encapsulate(translated_lines).join(\"\\n\")\n\t\t\t\[email protected]_logger.trace TRACE_ALL,buf\n\t\t\t\teval buf if do_eval\n\t\t\trescue SyntaxError, RuntimeError\n\t\t\t\tmsg = 'ERROR cfscript ',code.fn,\" line #{code.linenum} - #{$!}\\n\"\n\t\t\t\tcode.dump\n\t\t\t\[email protected]_logger.error LOG_CRIT,msg,'cfruby'\n\t\t\t\traise\n\t\t\tend\n\t\t\tbuf\n\t\tend",
"def register_preprocessor(mime_type, klass, &block)\n expire_index!\n\n if block_given?\n name = klass.to_s\n klass = Class.new(Processor) do\n @name = name\n @processor = block\n end\n end\n\n @preprocessors[mime_type].push(klass)\n end",
"def macro hash\n hash.each do |key, value|\n value = value.latex!.to_latex_math\n define_latex_macro key, value\n define_symbol_macro key, value\n define_global_macro key, value\n end\nend",
"def pre_process\n end",
"def pre_setup_case()\n return \"pre_setup_for_case\"\n end",
"def get_include_system(code)\n return code[2][1][1]\n end",
"def compile_to_ruby\n \"if \" + indent_c(@condition.compile_to_ruby) + \"\\n\" +\n indent_ruby(@then_part.compile_to_ruby) +\n \"\\nelse\\n\" +\n indent_c(@else_part.compile_to_ruby) +\n \"\\nend\"\n end",
"def is_code?(line,labelhash)\n if @to_code && line !~ /^#include \"(page|align|pass).i65\".*/ # filter chaffy includes\n if @code.nil?\n # first line is special, the label\n @label = line\nputs @label if @label == \"STUDIO\"\n @addr = labelhash[@label]\n # start with a code quote and a slider button\n @code =\n \"\\n\\n\\n<$button popup=\\\"$:/state/codeSlider\\\">code</$button>\"\\\n \"<$reveal type=\\\"nomatch\\\" text=\\\"\\\" default=\\\"\\\" \"\\\n \"state=\\\"$:/state/codeSlider\\\" animate=\\\"yes\\\">\\n\\n```\"\n end\n # append code line, filter chaff\n @code += \"\\n\"+line\n end\n # turn on code trigger after checking, to avoid capturing the `#endif`\n if (line =~ /^\\#endif$/) # non-`#if 0` should have a comment after #endif in source\n @to_code = true\n end\n end",
"def __synchromesh_regulate_from_macro(opts, name, already_defined)\n if opts.key?(:regulate)\n yield name => opts[:regulate]\n elsif !already_defined\n yield name => ->(*_args) {}\n end\n end",
"def preprocess\n true\n end",
"def _inter source\n c = compile source\n cifrom c\nend",
"def preprocessors_for(file_path)\n select_matching_file_patterns(preprocess_paths, file_path).values\n end",
"def standard_maps\n\n case self.current_framework\n when :testunit\n map /^controllers/ do\n target /^unit/ do\n file_name do |value, cargo|\n buffer = File.basename(cargo, \".rb\").gsub(\"s_controller\", \"\")\n value =~ /#{buffer}_test.rb/ ? true : false\n end\n end\n target /^functional/ do\n file_name do |value, cargo|\n buffer = File.basename(cargo, \".rb\").gsub(\"_controller\", \"\")\n value =~ /#{buffer}_controller_test.rb/ ? true : false\n end\n end\n end\n map /^models/ do\n target /^unit/ do\n file_name do |value, cargo|\n value =~ /#{File.basename(cargo, \".rb\")}_test.rb/ ? true : false\n end\n end\n target /^functional/ do\n file_name do |value, cargo|\n value =~ /#{File.basename(cargo, \".rb\")}s_controller_test.rb/ ? true : false\n end\n end\n end\n\n when :rspec\n map /^controllers/ do\n target /^models/ do\n file_name do |value, cargo|\n buffer = File.basename(cargo, \".rb\").gsub(\"s_controller\", \"\")\n value =~ /#{buffer}_spec.rb/ ? true : false\n end\n end\n target /^controllers/ do\n file_name do |value, cargo|\n buffer = File.basename(cargo, \".rb\").gsub(\"_controller\", \"\")\n value =~ /#{buffer}_controller_spec.rb/ ? true : false\n end\n end\n end\n map /^models/ do\n target /^models/ do\n file_name do |value, cargo|\n value =~ /#{File.basename(cargo, \".rb\")}_spec.rb/ ? true : false\n end\n end\n target /^controllers/ do\n file_name do |value, cargo|\n value =~ /#{File.basename(cargo, \".rb\")}s_controller_spec.rb/ ? true : false\n end\n end\n end\n end\n\n end",
"def __replace_eval__(line, gen_code)\n # class_eval\n if line =~ \n /(.*)((class_eval)|(module_eval)|(instance_eval)|(eval)) ?\\(?\"(.*)\"\\)? ?(.*)/\n printf \"%s%s {%s} %s\\n\", $1, $2, gen_code[:code], $8\n end\nend",
"def parse_macro(d)\n if d[:body] =~ /define\\s+#{Regexp.quote(d[:name])}\\([^\\)]*\\)[ \\t]*(.*)/m\n d[:value] = join_define($1)\n end\n d[:comments] = d[:rawComments].strip\n end",
"def get_php_string_constant(constant_name, source)\n (source =~ /^define\\('#{constant_name}', '(.*)'\\);$/) ? $1 : nil\nend",
"def skip_cond_incl!\n nest = 0\n while true\n bol = current_file.column == 1\n skip_space!\n c = readc\n if c.nil? # EOF\n return\n end\n if c == '\\''\n skip_char!\n next\n end\n if c == '\"'\n skip_string!\n next\n end\n if (c != '#' || !bol)\n next\n end\n column = current_file.column - 1\n tok = lex\n if (tok.kind != T::IDENT)\n next\n end\n if (nest == 0) && (Token.is_ident?(tok, \"else\") || Token.is_ident?(tok, \"elif\") || Token.is_ident?(tok, \"endif\"))\n unget_token(tok)\n hash = @token_gen.make_keyword('#')\n hash.bol = true\n hash.column = column\n unget_token(hash)\n return\n end\n if Token.is_ident?(tok, \"if\") || Token.is_ident?(tok, \"ifdef\") || Token.is_ident?(tok, \"ifndef\")\n nest += 1\n elsif (nest > 0) && Token.is_ident?(tok, \"endif\")\n nest -= 1\n end\n skip_line!\n end\n end",
"def compile_ohai_plugins\n return super unless $CHEFSPEC_MODE\n return if $CHEFSPEC_PRELOAD\n\n super\n end",
"def set_rpi_flags\n if $platform == :linux_rpi\n add_flags(:c, '-I/opt/vc/include')\n add_flags(:ld, '-L/opt/vc/lib -lbrcmGLESv2')\n end\nend",
"def set_rpi_flags\n if $platform == :linux_rpi\n add_flags(:c, '-I/opt/vc/include')\n add_flags(:ld, '-L/opt/vc/lib -lbrcmGLESv2')\n end\nend",
"def pre_compile(main_file, settings)\n\tFile.read(main_file)\nend",
"def constantize(name, base_object=Monitors)\n begin\n const = base_object.constants.find{|cnst| cnst == name.camelcase }\n base_object.module_eval const\n rescue Exception => e\n puts \"#{name.camelcase} is not defined. #{e}\"\n nil\n end\n end",
"def meta_exec(line, name, constant, path, meta_code = Cache_meta_without_hue)\n module_eval(\n format(\n meta_code,\n cache_name: name,\n cache_constant: constant,\n cache_path: path\n ),\n __FILE__,\n line\n )\n end",
"def precompiled(locals); end",
"def create_preprocessor_for_property(name, type_property, required)\n property_type = type_property.type\n if property_type == TYPE_ARRAY\n if PRIMITIVE_TYPES.include? type_property.items\n preprocessor_for_values = Sinatra::SwaggerExposer::Processing::SwaggerPrimitiveValuePreprocessor.new(\n name,\n false,\n type_property.items,\n type_property.properties[:default],\n type_property.properties\n )\n else\n preprocessor_for_values = create_preprocessor_for_type(name, type_property.items, false)\n end\n Sinatra::SwaggerExposer::Processing::SwaggerArrayValuePreprocessor.new(name, required, preprocessor_for_values)\n elsif PRIMITIVE_TYPES.include? property_type\n Sinatra::SwaggerExposer::Processing::SwaggerPrimitiveValuePreprocessor.new(\n name,\n required,\n property_type,\n type_property.properties[:default],\n type_property.properties\n )\n else\n create_preprocessor_for_type(name, property_type, required)\n end\n end",
"def test_preprocessor_exception(preprocessor,string,exception)\n input = StringIO.new(string)\n output = StringIO.new(\"\")\n begin\n $ppr.preprocess(input,output)\n puts \"*Error*: preprocessed without exception.\"\n return false\n rescue Exception => e\n if e.to_s.include?(exception.to_s) then\n puts \"Got exception: <#{e}> as expected.\"\n return true\n else\n puts \"*Error*: unexpected exception.\", \n \"Got <#{e}> but expecting <#{exception}>.\"\n return false\n end\n end\nend",
"def define!(string=nil, filename=\"(unknown Buildfile)\", &block)\n context = reset_define_context :current_mode => :all\n instance_eval(string, filename) if string\n instance_eval(&block) if block_given?\n load_imports\n reset_define_context context\n return self\n end",
"def inno_setup_4 iss_file, options={}\n defines = (options[:define] || {}).map {|var,value| \"-d#{var}=#{value}\" }\n run 'c:/Program Files/Inno Setup 4/iscc', iss_file, *defines\nend",
"def preprocessText(text)\n output = \"\"\n conditionals = Array.new\n\n text.split(\"\\n\").each do |line|\n currentConditional = conditionals.last\n\n # @if/@ifnot\n ifMatch = line.match(/^@(if[not]*)(.*)\\s*$/)\n if ifMatch\n name = ifMatch[1]\n \n #if must contain an expression\n expression = ifMatch[2].strip\n if expression.length == 0\n puts \"ERROR: @#{name} with no expression\"\n exit 1\n end\n \n # expression must be specific syntax\n expressionMatch = expression.match(/^([A-Z0-9_]+)$/)\n enabled = false\n if expressionMatch\n definitionKey = expressionMatch[1]\n if $defines[definitionKey]\n enabled = true\n end\n else\n puts \"ERROR: Invalid @#{name} expression.\"\n exit 1\n end\n\n if name == \"ifnot\"\n enabled = !enabled\n end\n \n # if the parent conditional is disabled, this is disabled too.\n if currentConditional and !currentConditional.enabled\n enabled = false\n end\n\n newConditional = ConditionalBlock.new\n newConditional.enabled = enabled\n newConditional.name = name\n conditionals.push(newConditional)\n next\n end\n \n # @else\n elseMatch = line.match(/^@(else)$/)\n if elseMatch\n if conditionals.length == 0\n puts \"ERROR: @else without @if\"\n exit 1\n end\n currentConditional.name = elseMatch[1]\n currentConditional.enabled = !currentConditional.enabled\n next\n end\n \n # @endif\n endIfMatch = line.match(/^@endif$/)\n if endIfMatch\n if conditionals.length == 0\n puts \"ERROR: @endif without @if\"\n exit 1\n end\n conditionals.pop\n next\n end\n \n if currentConditional and !currentConditional.enabled\n next\n end\n \n # replace definitions\n $defines.each_key do |key|\n while line[key]\n line[key] = $defines[key]\n end\n end\n \n output += \"#{line}\\n\"\n end\n\n if conditionals.length > 0\n puts \"ERROR: Unterminated @\" + conditionals[-1].name\n exit 1\n end\n\n return output\nend",
"def set_used_rules(rules)\n\t\t@used_rules = rules\n\t\tinclude_file = File.join(@rule_directory,\"@include.list\")\n\t\tFile.open(include_file,\"w:utf-8\") do |file|\n\t\t\t@used_rules.each do |rule|\n\t\t\t\tfile.puts \"include \\\"#{rule.file_path}\\\"\"\n\t\t\tend\n\t\tend\n\t\t@base_command = \"\\\"#{@executable_path}\\\" \\\"#{include_file}\\\"\"\n\tend",
"def constant_enabled(thing)\n Fission.constants.map do |const|\n const.to_s.downcase.to_sym\n end.include?(thing.to_s.downcase.to_sym)\n end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def valid_processors; end",
"def set_up\n @compiler = VishCompiler.new('')\n @compiler.default_optimizers[:constant_folder] = true\n end",
"def define(instruction)\n @def_instr = instruction\n end",
"def load_source_and_set_module; end",
"def header_editor_enabled=(_arg0); end",
"def get_processor\n case @config[\"markdown\"].downcase\n when \"kramdown\" then KramdownParser.new(@config)\n else\n custom_processor\n end\n end",
"def add_compiler_flag(flag)\n if try_cflags(flag)\n $CFLAGS << ' ' << flag\n else\n $stderr.puts(\"WARNING: '#{flag}' not accepted by compiler, skipping it\")\n end\nend",
"def add_compiler_flag(flag)\n if try_cflags(flag)\n $CFLAGS << ' ' << flag\n else\n $stderr.puts(\"WARNING: '#{flag}' not accepted by compiler, skipping it\")\n end\nend",
"def uncomment_lines(path, flag, *args)\n flag = flag.respond_to?(:source) ? flag.source : flag\n\n gsub_file(path, /^(\\s*)#[[:blank:]]*(.*#{flag})/, '\\1\\2', *args)\n end",
"def included(klass)\n Registry.register_implementation(\n Inflector.underscore(klass.name).to_sym,\n klass\n )\n klass.extend(Macros)\n end",
"def replace_keywords(in_file_list)\n in_file_list .each{|src_file_and_mode|\n src_file, mode = src_file_and_mode .split(':')\n dst_file = src_file .sub(/\\.in$/, '')\n print \"creating #{dst_file} ...\"\n replace_keywords1(src_file, dst_file , @macros, mode .oct)\n print \"done.\\n\"\n }\n end",
"def header_guard random_suffix = nil, &block\n defined = \"_#{Project.name.upcase}_#{@dir.upcase}_#{@class.upcase}_#{random_suffix.nil? ? '' : rand.to_s[2..-1]+'_'}\"\n\n Ludy::erbout \"#ifndef #{defined}\n#define #{defined}\", block.binding\n block.call\n Ludy::erbout '#endif', block.binding\nend",
"def use(processor)\n definition << processor\n processor\n end",
"def build_framework?; ARGV.include? '--framework'; end",
"def include=(_arg0); end",
"def define_tasks\n @defines.each { |sym| send( sym ) }\n end",
"def __replace_evals__()\n $__source_files__.each {|file|\n lines = File.new(file).readlines \n lines.each_index {|n|\n # check if the line has any eval(s)\n key = [file, n + 1]\n gen_code = $__gen_code__[key]\n # puts gen_code[:code] if gen_code\n if gen_code\n __replace_eval__(lines[n], gen_code)\n else\n puts lines[n]\n end\n }\n }\nend",
"def include(arg)\n Object.module_eval \"include #{arg}\"\n end",
"def process_line ln, line\r\n # convert inline processor\r\n while /\\#\\#(?<p_>[A-Z][_A-Z0-9]*)(:\\s*(?<a_>.+))?\\#\\#/ =~ line\r\n rst = conv_inline(p_, a_, ln, line)\r\n raise \"do not use '##.*##' inside your inline processor converting result\" if rst =~ /\\#\\#[A-Z][_A-Z0-9]*(:\\s*.+)?\\#\\#/\r\n line.sub!(/\\#\\#[A-Z][_A-Z0-9]*(:\\s*.+)?\\#\\#/, rst)\r\n end\r\n \r\n # create a token, with processor name\r\n token = self.tokenize(ln, line)\r\n # based on the the token indent level, close token stack if any\r\n self.close_stack token.indent_level\r\n \r\n # add token and then close it unless it opens a block\r\n @token_stack << token\r\n self.close_stack token.indent_level unless token.block_open?\r\n\r\n self # for methods chain\r\n end",
"def expand_constants\n\n File.open(\"conftest.c\", \"w\") { |f| f.puts \"#include <FreeImage.h>\" }\n cpp = cpp_command('')\n system \"#{cpp} > confout\"\n\n constants = {}\n headers = []\n\n config = File.readlines(\"confout\")\n config.each do |include|\n next unless include.match(/\"(.*?FreeImage.h)\"/)\n filename = include.split('\"')[1]\n headers << filename\n end\n \n headers.uniq!\n\n # add typedef constants\n config.each do |define|\n next unless define.match(/^\\s*(\\w+)\\s*=\\s*\\d/) # typedef\n name = $1\n next unless name.match(/^(FIT|FICC|FIC|FIF|FILTER)_/)\n constants[$1] ||= []\n constants[$1] << [name]\n end\n\n if RUBY_VERSION >= \"1.9\"\n raw_headers = headers.collect { |i| File.read(i, :encoding => \"ISO-8859-1\") }.join\n else\n raw_headers = headers.collect { |i| File.read(i) }.join\n end\n \n # add #defined constants (load/save flags)\n constants['FLAG'] ||= []\n flag_defines = raw_headers.scan(/(flag constants\\s*---.*?)^\\/\\//m)\n flag_defines.each do |flag_data|\n flag_data[0].split(/\\n/).each do |define|\n next unless define.match(/^\\#define\\s*(\\w+)\\s(.*?(\\/\\/.+)$)?/) # #define\n constants['FLAG'] << [$1, $3]\n end\n end\n\n File.unlink(\"confout\")\n\n constants.keys.each { |i| constants[i].uniq! }\n\n File.open(\"image_science_ext.c\", \"w\") do |newf|\n File.foreach(\"image_science_ext.c.in\") do |l|\n if l.match(/\\/\\* expand FreeImage constants\\s+(\\w+)\\s+(\\w+)\\s*\\*\\//)\n klass_name = $1\n const_type = $2\n const_list = constants[const_type]\n unless const_list\n puts \"warning: no constants found matching #{const_type}\"\n next\n end\n const_list.each do |c, comment|\n if comment\n comment.sub!('//', '')\n comment.sub!(/[\\r\\n]+$/, '')\n comment.gsub!(/:/, '-') # colons break rdoc..\n comment.strip!\n newf.puts %Q{ /* #{comment} */}\n end\n newf.puts %Q{ rb_define_const(#{klass_name}, \"#{c}\", INT2FIX(#{c}));}\n end\n else\n newf.puts l\n end\n end\n end\n\nend",
"def require_with_macro(required_name, delete_expanded_file, *macro_objs)\n source_name = required_name + \".rb\"\n source_directory = File.dirname((search_file($LOAD_PATH, source_name)).first)\n source = File.read(File.join(source_directory, source_name))\n @@GENSYM_TABLE = { }\n @@NONEXISTENT_VAR = nonexistent_var(source)\n expanded_path = File.join(source_directory, (\"macroexpanded_\" + source_name))\n File.open(expanded_path, \"w\") do |macroexpanded_file|\n macroexpanded_file.puts(macro_expand(source, *macro_objs))\n end\n require(\"macroexpanded_\" + required_name)\n if delete_expanded_file\n File.delete(expanded_path)\n end\n end",
"def preproc=(_arg0); end",
"def execute\n\t\t\tres = instance_exec(@node, &Glyph::MACROS[@name]).to_s\n\t\t\tres.gsub(/\\\\*([\\[\\]\\|])/){\"\\\\#$1\"}# : res\n\t\tend",
"def precompile_token_script(script)\n result = ''\n token_index = 0\n script.split(\"\\n\").each do |line|\n line.rstrip!\n next if line.empty?\n next if line.start_with?('#')\n result << \"T#{token_index}: \" << line << \"\\n\"\n token_index += 1\n end\n result\n end",
"def choose_processor\n self.processor = if MiniMagick::Utilities.which('mogrify')\n :mogrify\n elsif MiniMagick::Utilities.which('gm')\n :gm\n else\n nil\n end\n end",
"def folly_flags()\n return NewArchitectureHelper.folly_compiler_flags\nend"
] | [
"0.63092464",
"0.6140463",
"0.60429186",
"0.60429186",
"0.5984884",
"0.5687321",
"0.5481028",
"0.54745466",
"0.54678714",
"0.54376733",
"0.5428714",
"0.53935945",
"0.5370338",
"0.53387177",
"0.5323118",
"0.52336496",
"0.5167644",
"0.51615936",
"0.5161245",
"0.5158813",
"0.5085027",
"0.5075387",
"0.5075387",
"0.505653",
"0.50094175",
"0.4989077",
"0.4953885",
"0.49499696",
"0.4931576",
"0.4930234",
"0.4917548",
"0.4870787",
"0.48496893",
"0.4841845",
"0.48337048",
"0.4829303",
"0.48146507",
"0.4806307",
"0.4790509",
"0.47896236",
"0.4785902",
"0.47827813",
"0.47801214",
"0.47788554",
"0.4762789",
"0.4761525",
"0.47526404",
"0.47383323",
"0.47252727",
"0.47148952",
"0.47126797",
"0.47056967",
"0.46995813",
"0.469706",
"0.46951166",
"0.46910107",
"0.46877334",
"0.46873048",
"0.4686539",
"0.46692172",
"0.46692172",
"0.46688488",
"0.46668765",
"0.4653433",
"0.46414396",
"0.4636173",
"0.46361288",
"0.46360037",
"0.46342787",
"0.4624962",
"0.461988",
"0.46178913",
"0.4615089",
"0.4615089",
"0.4615089",
"0.46123084",
"0.4609127",
"0.46022415",
"0.45970866",
"0.45940518",
"0.45909625",
"0.45808595",
"0.45808595",
"0.4561931",
"0.45615545",
"0.45575914",
"0.4553051",
"0.45513454",
"0.45480806",
"0.4544727",
"0.45411503",
"0.4533337",
"0.4532726",
"0.45313752",
"0.45298854",
"0.45238402",
"0.4523772",
"0.4520224",
"0.4507852",
"0.45062718",
"0.44945997"
] | 0.0 | -1 |
Write out the whole release into a directory, zip file or anything you can imagine finalize can be called multiple times, it just will run all of them. The default finalizer is :dir | def finalize(finalizer, options = {})
@finalizers << [self.class.get_callable(finalizer, HtmlMockup::Release::Finalizers), options]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write()\n entries = Dir.entries(@inputDir); entries.delete(\".\"); entries.delete(\"..\"); entries.delete(\"yamproject.json\"); entries.delete(\".DS_Store\")\n io = Zip::File.open(@outputFile, Zip::File::CREATE);\n writeEntries(entries, \"\", io)\n io.close();\n end",
"def write\n FileUtils.rm @out_file if File.exists? @out_file\n in_progress \"Writing archive #{@out_file} from #{@input_dir}\" do\n Zip::File.open @out_file, Zip::File::CREATE do |zipfile|\n Dir[\"#{@input_dir}/**/**\"].reject{ |f| f == @out_file || [email protected](f) }.each do |file|\n progress \"deflating #{file}\"\n zipfile.add(file.sub(@input_dir + '/', ''), file)\n end\n end\n end\n end",
"def write()\n entries = Dir.entries(@inputDir); entries.delete(\".\"); entries.delete(\"..\")\n io = Zip::File.open(@outputFile, Zip::File::CREATE);\n writeEntries(entries, \"\", io)\n io.close();\n end",
"def write()\n entries = Dir.entries(@inputDir); entries.delete(\".\"); entries.delete(\"..\")\n io = Zip::File.open(@outputFile, Zip::File::CREATE);\n\n writeEntries(entries, \"\", io)\n io.close();\n end",
"def write\n entries = Dir.entries(@input_dir) - %w[. ..]\n\n ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile|\n write_entries entries, '', zipfile\n end\n end",
"def write\n entries = Dir.entries(@input_dir) - %w[. ..]\n\n ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile|\n write_entries entries, '', zipfile\n end\n end",
"def write\r\n entries = Dir.entries(@input_dir) - %w[. ..]\r\n\r\n ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile|\r\n write_entries entries, '', zipfile\r\n end\r\n end",
"def write()\n entries = Dir.entries(@input_dir); entries.delete(\".\"); entries.delete(\"..\")\n io = Zip::ZipFile.open(@output_file, Zip::ZipFile::CREATE);\n write_entries(entries, \"\", io)\n io.close();\n end",
"def write\n ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |io|\n @folders.each do |input_dir, src, dest|\n src = '' if src == '/**' # the whole src directory could be specified by /**\n path = source_dir(File.join(input_dir, src))\n write_entries(path, entries(src, input_dir), dest, io)\n end\n end\n\n @output_file\n end",
"def write\n entries = Dir.entries(@input_dir) - %w(. ..)\n\n ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |io|\n write_entries(entries, '', io)\n end\n end",
"def finalize_dirs\n @finalize_dirs || Dbt::Config.default_finalize_dirs\n end",
"def write\n entries = Dir.entries(@input_dir)\n entries.delete('.')\n entries.delete('..')\n # TODO: delete config file\n io = Zip::File.open(@output_file, Zip::File::CREATE)\n write_entries(entries, '', io)\n io.close\n end",
"def write\n entries = @input_dir.children(false)\n @zip.write entries, @input_dir, ''\n end",
"def write_out\n @all_content.each do |venue_id, venue_content|\n manifest_dir = \"#{@base.deploy_path}\" / \"#{venue_content.sha1_digest}\"\n venue_dir = \"#{@base.deploy_path}\" / \"#{Venue.get!(venue_id).router.identifier}\"\n manifest_file = manifest_dir / \"manifest.json\"\n files_dir = manifest_dir / \"files\"\n venue_content_ln = \"#{venue_dir}\" / \"content\"\n sha1_file = manifest_dir / \"#{venue_content.sha1_digest}.sha1\"\n \n FileUtils.rm(venue_content_ln) if File.exists?(venue_content_ln)\n FileUtils.mkdir_p(venue_dir)\n if File.exists?(sha1_file)\n FileUtils.ln_sf(manifest_dir, venue_content_ln)\n next\n end\n\n FileUtils.mkdir_p(manifest_dir)\n\n open(manifest_file, \"w+\") do |f|\n f << venue_content.manifest.to_json\n end\n\n #FileUtils.mkdir_p(files_dir)\n source_files = venue_content.filelist\n venue_content.filelist.each do |f|\n #UploadManager is using the first 2 bytes of the file digest as directory names.\n #The split('/'[-3..-1].join('') restores the filename to the full digest when it is copied\n #from the upload dir to the deployment dir\n dest = \"#{manifest_dir}\" / \"#{f.split('/')[-3..-1].join('')}\"\n FileUtils.cp(f, dest)\n end\n \n open(sha1_file, \"w+\") do |f|\n f << venue_content.sha1_digest\n end\n \n FileUtils.ln_sf(manifest_dir, venue_content_ln)\n end\n end",
"def write_archives\n self.collated.keys.each do |year|\n if self.layouts.key? 'archive_yearly'\n self.write_archive(year.to_s, 'archive_yearly')\n end\n\n self.collated[year].keys.each do |month|\n if self.layouts.key? 'archive_monthly'\n self.write_archive(File.join(year.to_s, month.to_s),\n 'archive_monthly')\n end\n\n self.collated[year][month].keys.each do |day|\n if self.layouts.key? 'archive_daily'\n self.write_archive(File.join(year.to_s, month.to_s, day.to_s),\n 'archive_daily')\n end\n end\n end\n end\n end",
"def output\n @output ||= File.open(File.join(output_final_directory_path, Metasploit::Credential::Importer::Zip::MANIFEST_FILE_NAME), 'w')\n end",
"def finalize_dirs\n @finalize_dirs || DbTasks::Config.default_finalize_dirs\n end",
"def create_dirs_in_zipfile(created_dirs, entry_path, output_stream); end",
"def write_entries(input_dir, entries, path, io)\n entries.each do |e|\n disk_file_path = File.join(input_dir, e)\n zip_file_path = zip_file_path(path, e, input_dir)\n\n if File.directory? disk_file_path\n recursively_deflate_directory(disk_file_path, io, zip_file_path)\n else\n put_into_archive(disk_file_path, io, zip_file_path)\n end\n end\n end",
"def write\n @zip.write [@input_dir.basename], @input_dir.parent, ''\n end",
"def zipIt\r\n puts \"Creating EPUB package:\"\r\n STDOUT.flush\r\n path = @dirs[:tmp]\r\n FileUtils.rm @epub, :force=>true\r\n Zip::ZipFile.open(@epub, 'w') do |zipfile|\r\n progress = ProgressBar.new(\"Compressing\", Dir[\"#{path}/**/**\"].length)\r\n Dir[\"#{path}/**/**\"].each do |file|\r\n zipfile.add(file.sub(path+'/', ''), file)\r\n progress.inc\r\n end\r\n progress.finish\r\n puts ''\r\n end\r\n end",
"def write_entries(entries, path, zipfile, root_dir)\n entries.each do |e|\n zipfile_path = path == '' ? e : File.join(path, e)\n disk_file_path = File.join(root_dir, zipfile_path)\n\n if File.directory? disk_file_path\n recursively_deflate_directory(disk_file_path, zipfile, zipfile_path, root_dir)\n else\n put_into_archive(disk_file_path, zipfile, zipfile_path)\n end\n end\n end",
"def close\n close_buffers\n # Zip it all up using the zip command for now :p\n pwd = Dir.pwd\n Dir.cd(realdir)\n exec(\"zip -r #{filename} *\")\n Dir.cd(pwd)\n FileUtils.rm_r(realdir)\n end",
"def write\n make_parent_directory\n generate_file\n end",
"def write_entries(entries, dir, io)\n entries.each do |e|\n file = dir == '' ? e : File.join(dir, e)\n disk_file = File.join(scr, file)\n\n if File.directory? disk_file\n recursively_deflate_directory(disk_file, io, file)\n else\n add(disk_file, io, file)\n end\n end\n end",
"def cleanup\n FileUtils.rm(@out_filename)\n\n # XXX: could be rm-rf, but be safe for now. Might have\n # problems if app creates files in $PWD\n FileUtils.rmdir(@opts[:tmpdir])\n end",
"def archive\n files.each do |path|\n path_obj = Pathname.new(path)\n path_name = path_obj.dirname.to_s\n compress = Kellerkind::Compress.new(:target_path => out,\n :source_path => path,\n :tarball_prefix => path_obj.basename.to_s)\n compress.find_at_source_path = true\n if File.exists?(path)\n Kellerkind::Process.verbose(:start_compressing)\n compress.gzip\n if File.exists?(\"#{path_name}/#{compress.tarball_name}\")\n Kellerkind::Process.verbose(:finished_compressing)\n FileUtils.mv(\"#{path_name}/#{compress.tarball_name}\",\n \"#{out}/#{compress.tarball_name}\")\n FileUtils.rm_rf(path)\n FileUtils.touch(path) if self.recreate\n end\n end\n end\n end",
"def write_archive(archive, dir)\n\t\tIO.popen(\"cd #{dir}; tar x\", \"w\") do |p|\n\t\t\tp.write archive\n\t\tend\n\tend",
"def write_entries(input_dir, entries, path, zipfile)\n entries.each do |e|\n zipfile_path = path == '' ? e : File.join(path, e)\n disk_file_path = File.join(input_dir, zipfile_path)\n\n if File.directory? disk_file_path\n recursively_deflate_directory(input_dir, disk_file_path, zipfile, zipfile_path)\n else\n put_into_archive(disk_file_path, zipfile, zipfile_path)\n end\n end\n end",
"def build\n entries = Dir.entries(@input_dir)\n entries.delete_if {|e| @exclude.include?(e)}\n FileUtils.rm_f(@output_file) # Make sure file doesn't exist\n ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile|\n write_entries entries, '', zipfile\n end\n end",
"def write_entries(entries, path, zipfile)\n entries.each do |entry|\n zipfile_path = path == '' ? entry : File.join(path, entry)\n disk_file_path = File.join(src_path, zipfile_path)\n\n if File.directory?(disk_file_path)\n recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)\n else\n put_into_archive(disk_file_path, zipfile, zipfile_path)\n end\n end\n end",
"def write(dest)\n path = destination(dest)\n FileUtils.mkdir_p(File.dirname(path))\n Jekyll.logger.debug \"Writing:\", path\n File.write(path, output, :mode => \"wb\")\n Jekyll::Hooks.trigger hook_owner, :post_write, self\n end",
"def write_entries(entries, path, zipfile)\r\n entries.each do |e|\r\n zipfile_path = path == '' ? e : File.join(path, e)\r\n disk_file_path = File.join(@input_dir, zipfile_path)\r\n\r\n if File.directory? disk_file_path\r\n recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)\r\n else\r\n put_into_archive(disk_file_path, zipfile, zipfile_path)\r\n end\r\n end\r\n end",
"def write(dest)\n path = destination(dest)\n FileUtils.mkdir_p(File.dirname(path))\n Jekyll.logger.debug \"Writing:\", path\n File.write(path, output, :mode => \"wb\")\n\n trigger_hooks(:post_write)\n end",
"def write_entries(entries, path, zipfile)\n entries.each do |e|\n zipfile_path = path == '' ? e : File.join(path, e)\n disk_file_path = File.join(@input_dir, zipfile_path)\n\n if File.directory? disk_file_path\n recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)\n else\n put_into_archive(disk_file_path, zipfile, zipfile_path)\n end\n end\n end",
"def write_entries(entries, path, zipfile)\n entries.each do |e|\n zipfile_path = path == '' ? e : File.join(path, e)\n disk_file_path = File.join(@input_dir, zipfile_path)\n\n if File.directory? disk_file_path\n recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)\n else\n put_into_archive(disk_file_path, zipfile, zipfile_path)\n end\n end\n end",
"def write_entries(entries, path, io)\n entries.each do |e|\n zip_file_path = path == '' ? e : File.join(path, e)\n disk_file_path = File.join(@input_dir, zip_file_path)\n if File.directory?(disk_file_path)\n recursively_deflate_directory(disk_file_path, io, zip_file_path)\n elsif include_filename?(zip_file_path)\n put_into_archive(disk_file_path, io, zip_file_path)\n end\n end\n end",
"def prepare\n FileUtils.rm_rf(output_dir)\n FileUtils.mkdir_p(output_dir)\n end",
"def prepare\n FileUtils.rm_rf(output_dir)\n FileUtils.mkdir_p(output_dir)\n end",
"def finalise\n end",
"def write_entries(entries, path, zipfile)\n entries.each do |e|\n zipfile_path = path == '' ? e : File.join(path, e)\n disk_file_path = File.join(@input_dir, zipfile_path)\n puts \"Deflating #{disk_file_path}\"\n\n if File.directory? disk_file_path\n recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)\n else\n put_into_archive(disk_file_path, zipfile, zipfile_path)\n end\n end\n end",
"def finish\n if @write_options then\n write_options\n exit\n end\n\n @op_dir ||= 'doc'\n\n @rdoc_include << \".\" if @rdoc_include.empty?\n root = @root.to_s\n @rdoc_include << root unless @rdoc_include.include?(root)\n\n @exclude = self.exclude\n\n finish_page_dir\n\n check_files\n\n # If no template was specified, use the default template for the output\n # formatter\n\n unless @template then\n @template = @generator_name\n @template_dir = template_dir_for @template\n end\n\n if @locale_name\n @locale = RDoc::I18n::Locale[@locale_name]\n @locale.load(@locale_dir)\n else\n @locale = nil\n end\n\n self\n end",
"def zip_result_directory\n end",
"def cleanup\n close_file_appender\n archive_run_result if (defined? @results_archive) && @archive_results\n end",
"def close\n return if @closed\n\n finalize_current_entry\n update_local_headers\n @cdir.write_to_stream(@output_stream)\n @output_stream.close\n @closed = true\n end",
"def write_zip(out_path)\n CrxMake.zip(\n :ex_dir => @build_dir,\n :pkey => full_key_path,\n :zip_output => out_path,\n :verbose => false\n )\n end",
"def archive(dir)\n @archiver.archive(dir)\n end",
"def run_dir(root)\n\tDir.foreach(root) { |fn|\n\t\tnext if fn == \".\" || fn == \"..\"\n\t\tcombined = File.join(root, fn)\n\t\tif File.directory?(combined)\n\t\t\trun_dir(combined)\n\t\telsif File.file?(combined) && (fn[\".dll\"] || fn[\".pdb\"])\n\t\t\tfpath = combined\n\t\t\tfpath = fpath[2..-1] if fpath[0..1] == \"./\"\n\t\t\tfpath = fpath.gsub(\"/\", \"\\\\\")\n\t\t\tprint(\"#{fpath}\\n\")\n\t\t\t`compress -R #{fpath}`\n\t\t\texit(1) if $?.exitstatus != 0\n\t\t\t`del #{fpath}`\n\t\tend\n\t}\t\nend",
"def build\n sync\n output_dir.mkpath\n outputs.each(&:build)\n output_dir.touch\n end",
"def run\n assets.each do |asset|\n next if ::File.directory?(asset)\n\n compress(asset)\n checksum(asset)\n end\n\n generate_manifest\n end",
"def write\n entries = Dir.entries(@input_dir); entries.delete(\".\"); entries.delete('..')\n io = Zip::File.open(@server_pack_file, Zip::File::CREATE)\n write_entries(entries, '', io)\n io.close\n end",
"def write\n File.delete(@output_file) if File.exist?(@output_file)\n\n Zip::File.open(@output_file, Zip::File::CREATE) do |zipfile|\n zipfile.add(mimetype_entry(zipfile), \"#{@input_dir}/mimetype\")\n\n all_entries.each do |file|\n zipfile.add(file, \"#{@input_dir}/#{file}\")\n end\n end\n end",
"def output_final_directory_path\n unless instance_variable_defined? :@output_final_directory_path\n tmp_path = Dir.mktmpdir(TEMP_ZIP_PATH_PREFIX)\n @output_final_directory_path = File.join(tmp_path, output_final_subdirectory_name)\n FileUtils.mkdir_p @output_final_directory_path\n end\n @output_final_directory_path\n end",
"def make_output_dir (src_path)\n delete_all_files(src_path) if directory_exists?(src_path) == true\n Dir.mkdir(src_path)\nend",
"def write\n\t\t#clear the directory before doing anything else\n\t\tclear @path\n\n\t\t#write out source code files\n\t\[email protected] do |mold|\n\t\t\twrite_object(mold.name + \".h\", header(mold))\n\t\t\twrite_object(mold.name + \".m\", source(mold))\n\t\tend\n\tend",
"def write_entries(entries, path, zipfile)\n entries.each do |e|\n zipfile_path = path == '' ? e : File.join(path, e)\n disk_file_path = File.join(@input_dir, zipfile_path)\n if File.directory?(disk_file_path)\n recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)\n next\n end\n put_into_archive(disk_file_path, zipfile, zipfile_path)\n end\n end",
"def write(dir, overwrite: true)\n FileUtils.mkdir_p(dir) # Make any parent directories\n @crate.payload.each do |path, entry|\n fullpath = ::File.join(dir, path)\n next if !overwrite && ::File.exist?(fullpath)\n next if entry.directory?\n FileUtils.mkdir_p(::File.dirname(fullpath))\n if entry.symlink?\n ::File.symlink(entry.source.readlink, fullpath)\n else\n temp = Tempfile.new('ro-crate-temp')\n begin\n entry.write_to(temp)\n temp.close\n FileUtils.mv(temp, fullpath)\n ensure\n temp.unlink\n end\n end\n end\n end",
"def write!\n Dir.mkdir @directory unless File.directory? @directory\n\n @locales.each_with_index do |locale, index|\n strings = @strings[locale]\n plurals = @plurals[locale]\n\n l_directory = locale_directory locale, index.zero?\n\n file = @table.to_s.empty? ? @adapter.default_file_name : @table\n\n date = DateTime.now\n\n Dir.mkdir l_directory unless File.directory? l_directory\n\n @adapter.write_locale(l_directory,\n file,\n strings,\n plurals,\n locale,\n date)\n end\n end",
"def _zip_decender(zipstream, folder, path)\n if path.nil?\n path = folder.name\n else\n path = path + \"/\" + folder.name\n end\n zipstream.dir.mkdir(path)\n \n folder.assets.each do |a|\n logger.info(\"[ZIP] Adding #{a.file_name} in #{a.uploaded_file.path}\")\n zipstream.add(\"#{path}/#{a.file_name}\", a.uploaded_file.path)\n end\n folder.children.each do |f|\n _zip_decender(zipstream, f, path)\n end\n end",
"def generate_output_file(zip_out, contents); end",
"def make_zipfile dir, options={}\n zipfile = options[:filename] || \"#{dir}.zip\"\n excludes = ['-x', '*/.git/*', '-x', '*/.gitignore']\n exclude_each options[:excludes] do |exclude|\n excludes.push '-x', exclude\n end\n run 'zip', '-r', zipfile, dir, *excludes\n release zipfile, :cd => 1\nend",
"def initialize_output_directory()\n require 'fileutils'\n FileUtils.mkdir_p(OUTPUT_DIRECTORY)\n end",
"def setup_finalizer\n ObjectSpace.define_finalizer(self, self.class.close_io(@file))\n end",
"def distribute\n output_dir(@spec.meta, @meta_dir)\n output_dir(@spec.path, @path_dir)\n output_dir(@spec.model, @model_dir)\n true\n end",
"def setup_finalizer\n ObjectSpace.define_finalizer(self, self.class.close_io(@file))\n end",
"def sort_out_output_directories \n FileUtils.mkdir_p(output_directory)\n FileUtils.mkdir_p(xml_directory)\n FileUtils.mkdir_p(intermediate_directory) unless run_in_memory\n end",
"def finish!\n # Create our sentinel file\n FileUtils.touch('/etc/.sorted')\n end",
"def releaseFiles\r\n rSuccess = true\r\n\r\n logOp('Copy core files') do\r\n RubyPackager::copyFiles(@RootDir, @ReleaseDir, @ReleaseInfo.core_files)\r\n # Create the ReleaseVersion file\r\n lStrTags = nil\r\n if (@ReleaseTags.empty?)\r\n lStrTags = ':tags => []'\r\n else\r\n lStrTags = \":tags => [ '#{@ReleaseTags.join('\\', \\'')}' ]\"\r\n end\r\n File.open(\"#{@ReleaseDir}/ReleaseInfo\", 'w') do |oFile|\r\n oFile << \"\r\n# This file has been generated by RubyPackager during a delivery.\r\n# More info about RubyPackager: http://rubypackager.sourceforge.net\r\n{\r\n :version => '#{@ReleaseVersion}',\r\n #{lStrTags},\r\n :dev_status => '#{@ReleaseInfo.project_info[:dev_status]}'\r\n}\r\n\"\r\n end\r\n end\r\n @ReleaseInfo.executables_info.each do |iExecutableInfo|\r\n if (iExecutableInfo[:exe_name] != nil)\r\n logOp(\"Create binary #{iExecutableInfo[:exe_name]}\") do\r\n # TODO (crate): When crate will work correctly under Windows, use it here to pack everything\r\n # For now the executable creation is platform dependent\r\n rSuccess = @PlatformReleaseInfo.create_binary(@RootDir, @ReleaseDir, @IncludeRuby, iExecutableInfo)\r\n end\r\n end\r\n end\r\n if (rSuccess)\r\n logOp('Copy additional files') do\r\n RubyPackager::copyFiles(@RootDir, @ReleaseDir, @ReleaseInfo.additional_files)\r\n end\r\n if (@IncludeTest)\r\n logOp('Copy test files') do\r\n RubyPackager::copyFiles(@RootDir, @ReleaseDir, @ReleaseInfo.test_files)\r\n end\r\n end\r\n end\r\n\r\n return rSuccess\r\n end",
"def gen_sub_directories\n @outputdir.mkpath\n end",
"def writeEntries(entries, path, io)\n entries.each { |e|\n zipFilePath = path == \"\" ? e : File.join(path, e)\n diskFilePath = File.join(@inputDir, zipFilePath)\n puts \"==Deflating==\" + diskFilePath\n if File.directory?(diskFilePath)\n io.mkdir(zipFilePath)\n subdir = Dir.entries(diskFilePath)\n subdir.delete(\".\")\n subdir.delete(\"..\")\n writeEntries(subdir, zipFilePath, io)\n else\n io.get_output_stream(zipFilePath) { |f| f.puts(File.open(diskFilePath, \"rb\").read())}\n end\n }\n end",
"def comp(input_dir, output_file)\n @inputDir = input_dir\n # @input_dir = @inputDir\n @outputFile = output_file\n FileUtils.rm @outputFile if File.exists? @outputFile\n # File.open(output_file, 'w')\n entries = Dir.entries(@inputDir); entries.delete(\".\"); entries.delete(\"..\")\n io = Zip::File.open(@outputFile, Zip::File::CREATE)\n\n writeEntries(entries, \"\", io)\n io.close\n puts \"\\n#{output_file} chaching!\\n\\n\"\n end",
"def finalize\n\t\teach_door { |door| door.finalize }\n\tend",
"def generate()\n prepare\n ::Dir.mkdir(@output_path) unless ::File.exists? @output_path\n\n @pages.each do |name, page|\n SiteLog.debug(\"Starting page generation - #{name}\")\n page.generate(@output_path, @version, @preserve_tree)\n SiteLog.debug(\"Finished page generation - #{name}\")\n end\n\n @files.each do |path, data|\n path = ::File.join(@output_path, path)\n ::FileUtils.mkdir_p(::File.dirname(path))\n ::File.open(path, \"w\") do |f|\n f.write(data)\n end\n end\n end",
"def create_output_directory\n FileUtils.mkdir_p @output_dir\n end",
"def write(dir)\n @dir = FileUtils.mkdir_p dir\n @css_file = File.join(@dir, @filename + '.css')\n\n File.delete(@css_file) if File.exist?(@css_file)\n @output = File.open(@css_file, 'w') { |file| file.write(@result) }\n @css_file\n end",
"def cleanup(build_dir)\n build_dir = Pathname(build_dir)\n tmp_build_dir = Pathname('.temp-build')\n\n # copy over files we need to keep\n if File.directory?(build_dir)\n build_dir.glob(\"**/all-product-headers.yaml\").each do |file|\n intermediate = Pathname(file).relative_path_from(build_dir).dirname\n destination_dir = tmp_build_dir + intermediate\n\n FileUtils.mkdir_p(destination_dir)\n FileUtils.mv(file, destination_dir)\n end\n\n build_dir.rmtree if build_dir.directory?\n FileUtils.mv(tmp_build_dir, build_dir)\n end\nend",
"def gen_sub_directories\n\t\[email protected]\n\tend",
"def gen_sub_directories\n\t\[email protected]\n\tend",
"def destination(lang)\n output_path.mkpath\n\n path = output_path.join(\"#{lang}.json\")\n path.open(\"w\") do |f|\n f.write yield\n end\n\n puts \"Created #{path}\"\n end",
"def write\n buffer = create_zip(@entries, @ignore_entries)\n\n puts \"\\nwrite file #{@output_file}\"\n File.open(@output_file, \"wb\") {|f| f.write buffer.string }\n end",
"def bundle!(export_dir= Rails.configuration.gtdinbox_export_dir)\n @bundle_filename = \"#{export_dir}/#{@bundle_id}-translation-export.zip\"\n\n\n Zip::ZipFile.open(@bundle_filename, Zip::ZipFile::CREATE) do |zipfile|\n pp @dir_names\n @dir_names.each {|dirname|zipfile.mkdir(dirname)}\n @dir_files.each do |dir_file|\n dirname, file = dir_file\n zip_filepath = File.basename(file.path).gsub(\"#{dirname}-#{@bundle_id}-\",'')\n zipfile.add([dirname, zip_filepath].join('/'), file.path)\n end\n end\n\n File.chmod(0644, @bundle_filename)\n clean_up\n\n @bundle_filename\n end",
"def cleanup\n cleanup_unpack_path\n cleanup_download_path\n end",
"def write_images\n # Enumerate all the files in the zip and write any that are in the media directory to the output buffer (which is used to generate the new zip file)\n @file.read_files do |entry| # entry is a file entry in the zip\n if entry.name.include? IMAGE_DIR_NAME\n # Check if this is an image being replaced\n current_image = @images.select { |image| !@relationship_manager.get_relationship(image.id).nil? and entry.name.include? @relationship_manager.get_relationship(image.id)[:target] }.first\n\n unless current_image.nil?\n replacement_path = current_image.path\n data = ::File.read(replacement_path)\n else\n entry.get_input_stream { |is| data = is.sysread }\n end\n\n @file.output_stream.put_next_entry(entry.name)\n @file.output_stream.write data\n end\n end\n\n # Create any new images\n @unique_image_paths = []\n @images.select { |image| image.is_new }.each do |new_image|\n next if @unique_image_paths.include? new_image.target # we only want to write each image once\n @unique_image_paths << new_image.target\n @file.output_stream.put_next_entry(\"word/#{new_image.target}\")\n @file.output_stream.write ::File.read(new_image.path)\n end\n end",
"def after_destroy\n super\n\n # Try our best to remove the directory. If it fails there is little\n # else that we could do to resolve the situation -- we already tried to\n # delete it once...\n self.tmpdir and FileUtils.remove_entry_secure(self.tmpdir, true)\n\n # Remove repo directory.\n if self.iso_url\n # Some files in archives are write-only. Change this property so the\n # delete succeeds.\n remove_directory(iso_location)\n end\n end",
"def finish_page_dir\n return unless @page_dir\n\n @files << @page_dir\n\n page_dir = Pathname(@page_dir)\n begin\n page_dir = page_dir.expand_path.relative_path_from @root\n rescue ArgumentError\n # On Windows, sometimes crosses different drive letters.\n page_dir = page_dir.expand_path\n end\n\n @page_dir = page_dir\n end",
"def write(dir = self.dir, filename = self.filename)\n FileUtils.mkdir_p(File.join(WRITE_DIR, dir))\n self.image.write(File.join(WRITE_DIR, dir, filename))\n end",
"def write_repository(product_dir, releases)\n platforms = releases.map { |release| release[:platform] }.uniq\n platforms.each do |platform|\n configuration_directory = File.join(product_dir, platform)\n FileUtils.mkdir_p(configuration_directory)\n releases_by_version = Hash.new { |hash, key| hash[key] = [] }\n releases.each do |release|\n next if release[:platform] != platform\n\n releases_by_version[release[:version]] << extract_release_fields(release)\n end\n releases_by_version.each_pair do |version, version_releases|\n File.write(File.join(configuration_directory, \"#{version.gsub('/', '-')}.json\"),\n JSON.pretty_generate(version_releases))\n end\n end\n end",
"def write\n self.theme_assets_by_priority.each do |asset|\n self.output_resource_op asset\n\n self.open_file(self.target_asset_path(asset), 'wb') do |file|\n content = asset.content\n\n if asset.stylesheet_or_javascript?\n self.replace_asset_urls(content)\n end\n\n file.write(content)\n end\n\n self.output_resource_op_status asset\n end\n end",
"def output(_options, _directory, version, metadata, _output)\n metadata.releases[version].components.each do |_component|\n end\n end",
"def prepare doc_dir\n debug_msg \" preparing for web (gzip)\"\n cwd = Dir.pwd\n begin\n Dir.chdir doc_dir\n zip_file = 'rdoc.zip'\n `zip -r #{zip_file} .`\n ensure\n Dir.chdir cwd\n end\n end",
"def create_zip(name,url)\n @outputFile = (Rails.root.to_s+\"/tmp/cache/downloads/\"+name+\".zip\")\n if File.exist?(@outputFile)\n FileUtils.rm_rf (@outputFile)\n end\n @inputDir = url\n entries = Dir.entries(@inputDir)\n entries.delete(\".\")\n entries.delete(\"..\")\n io = Zip::ZipFile.open(@outputFile, Zip::ZipFile::CREATE)\n writeEntries(entries, \"\", io) #calling recursive write entries method\n io.close();\n return @outputFile\n end",
"def make_output_directory\n puts \"Making output directory\"\n # Double check that we don't clobber an existing dir\n if File.exists? @output_dir\n puts \"\\nSORRY! '#{ @output_dir }' directory already exists. Please try again.\\n\\n\"\n exit\n end\n FileUtils.mkdir_p @output_dir\n end",
"def write_all\n if cached_write?\n then write_cached_assets else write_assets\n end\n end",
"def clearDistributionDirectory(projectDir)\n distDir = projectDir.to_s + '/dist'\n FileUtils.rm_rf(distDir)\n FileUtils.mkdir_p(distDir)\nend",
"def close\n # XXX should optimize to not write anything to unchanged files\n # In update mode, we first write the zip to a temporary zip file,\n # then move it on top of the original file\n out_zip = update? ? tmp_zipfile : @filename\n ZipFileWriter.new(directory, out_zip).write if write?\n @io.close if @io\n File.rename out_zip, @filename if update?\n end",
"def commit\n # TODO\n # Update ./docProps\n # app.xml slides, notes, counts, etc\n # core.xml Times\n entries.each do |path, buffer|\n path = path.to_s\n if @original_files.include? path\n @zip.replace_buffer path, buffer\n else\n @zip.add_buffer path, buffer\n end\n end\n @zip.commit\n end",
"def finalize!\n @finalized = true\n self\n end",
"def clean\n cache = Cache.instance\n # remove all built files\n cache.targets(false).each do |target|\n cache.remove_target(target)\n FileUtils.rm_f(target)\n end\n # remove all created directories if they are empty\n cache.directories(false).sort {|a, b| b.size <=> a.size}.each do |directory|\n cache.remove_directory(directory)\n next unless File.directory?(directory)\n if (Dir.entries(directory) - ['.', '..']).empty?\n Dir.rmdir(directory) rescue nil\n end\n end\n cache.write\n end",
"def run\n puts \"\\nHere we go!\\n\\n\"\n make_output_directory\n build_jar\n create_android\n include_www\n generate_manifest\n copy_libs\n add_name_to_strings\n write_java\n puts \"\\nDone!\\n\\n\"\n `open #{@output_dir}`\n end",
"def write(dest_prefix, dest_suffix = nil)\n #self.render(@site.layouts, @site.site_payload) if self.output == nil\n\n path = File.join(dest_prefix, CGI.unescape(self.url))\n dest = File.dirname(path)\n\n # Create directory\n FileUtils.mkdir_p(dest) unless File.exist?(dest)\n\n # write partials\n #@partials.each do |partial|\n # @settings[partial].write if @settings[partial] != nil\n #end\n\n # Debugging - create html version of PDF\n #File.open(\"#{path}.html\", 'w') {|f| f.write(self.output) } if @settings[\"debug\"]\n #@settings.delete(\"debug\")\n\n self.output = File.read(\"#{path}\") if @name != \"/.pdf\"\n\n # Build PDF file\n fix_relative_paths\n kit = PDFKit.new(self.output, @settings)\n file = kit.to_file(File.join(dest_prefix, @name))\n end"
] | [
"0.66611975",
"0.63739157",
"0.6354527",
"0.63402337",
"0.63046813",
"0.63046813",
"0.6294696",
"0.6264766",
"0.6196943",
"0.61841553",
"0.6175773",
"0.6059485",
"0.6002328",
"0.59890497",
"0.58571506",
"0.584809",
"0.5838678",
"0.58094",
"0.5797564",
"0.5765324",
"0.5765186",
"0.57647336",
"0.56903034",
"0.5689993",
"0.56879026",
"0.56806034",
"0.5680435",
"0.56602794",
"0.5647155",
"0.564384",
"0.56431985",
"0.563843",
"0.56321394",
"0.56241125",
"0.5621582",
"0.5621582",
"0.56196034",
"0.56094646",
"0.56089836",
"0.5601951",
"0.5598222",
"0.5588559",
"0.5583528",
"0.55794644",
"0.55756444",
"0.5571673",
"0.55662864",
"0.55546904",
"0.55484146",
"0.5533613",
"0.55322045",
"0.55254006",
"0.5525274",
"0.5521601",
"0.55134386",
"0.55126494",
"0.551194",
"0.54959565",
"0.5474725",
"0.54739326",
"0.54534227",
"0.5449616",
"0.54273343",
"0.5402656",
"0.5391377",
"0.53845686",
"0.5378026",
"0.5371959",
"0.5371671",
"0.5356712",
"0.53475296",
"0.5343786",
"0.53329885",
"0.5330254",
"0.5327558",
"0.53247285",
"0.53240657",
"0.53240657",
"0.53173983",
"0.5316819",
"0.53030723",
"0.5295998",
"0.52950126",
"0.52777624",
"0.52749264",
"0.52741915",
"0.526819",
"0.52667636",
"0.52631646",
"0.52626956",
"0.52568954",
"0.52562165",
"0.52560425",
"0.52556723",
"0.5231852",
"0.5226854",
"0.522393",
"0.5220489",
"0.5217221",
"0.521556"
] | 0.5361912 | 69 |
Files to clean up in the build directory just before finalization happens | def cleanup(pattern)
@stack << Cleaner.new(pattern)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup\n remove_files(TEST_INPUT_DIR)\n remove_files(TEST_OUTPUT_DIR)\nend",
"def clean\n #rm_r(srcdir)\n rm_r(blddir)\n #rm_r(libdir)\n end",
"def cleanup(build_dir)\n build_dir = Pathname(build_dir)\n tmp_build_dir = Pathname('.temp-build')\n\n # copy over files we need to keep\n if File.directory?(build_dir)\n build_dir.glob(\"**/all-product-headers.yaml\").each do |file|\n intermediate = Pathname(file).relative_path_from(build_dir).dirname\n destination_dir = tmp_build_dir + intermediate\n\n FileUtils.mkdir_p(destination_dir)\n FileUtils.mv(file, destination_dir)\n end\n\n build_dir.rmtree if build_dir.directory?\n FileUtils.mv(tmp_build_dir, build_dir)\n end\nend",
"def clean\n cache = Cache.instance\n # remove all built files\n cache.targets(false).each do |target|\n cache.remove_target(target)\n FileUtils.rm_f(target)\n end\n # remove all created directories if they are empty\n cache.directories(false).sort {|a, b| b.size <=> a.size}.each do |directory|\n cache.remove_directory(directory)\n next unless File.directory?(directory)\n if (Dir.entries(directory) - ['.', '..']).empty?\n Dir.rmdir(directory) rescue nil\n end\n end\n cache.write\n end",
"def clean_up\n @files.each {|file| FileUtils.remove(file.path)}\n end",
"def clean_up(cmd = nil)\n FileUtils.rm(\n Dir.glob('build/{src,lib}.{rb,c,js}') +\n Dir.glob('build/ruby2d-opal.{rb,js}') +\n Dir.glob('build/app.c')\n )\n if cmd == :all\n puts \"cleaning up...\"\n FileUtils.rm_f 'build/app'\n FileUtils.rm_f 'build/app.js'\n FileUtils.rm_f 'build/app.html'\n FileUtils.rm_rf 'build/ios'\n FileUtils.rm_rf 'build/tvos'\n end\nend",
"def clean_files\n FileUtils.rm(Dir[File.join(Rails.root, 'public/sitemap*.xml.gz')])\n end",
"def clean_up(cmd = nil)\n FileUtils.rm(\n Dir.glob('build/*.{rb,c,js}')\n )\n if cmd == :all\n puts \"cleaning up...\"\n FileUtils.rm_f 'build/app'\n FileUtils.rm_f 'build/app.js'\n FileUtils.rm_f 'build/app.html'\n FileUtils.rm_rf 'build/App.app'\n FileUtils.rm_rf 'build/ios'\n FileUtils.rm_rf 'build/tvos'\n end\nend",
"def cleanup\n tmpdir = File.join(OBS_BUILD_DIR,OBS_LOCAL_TMP)\n if File.exists?(tmpdir)\n FileUtils.rm_rf(tmpdir)\n end\n end",
"def cleanall\n FileUtils.rm_r(OUTPUT_DIR, force: true, verbose: true)\n end",
"def cleanup\n FileUtils.rm(@out_filename)\n\n # XXX: could be rm-rf, but be safe for now. Might have\n # problems if app creates files in $PWD\n FileUtils.rmdir(@opts[:tmpdir])\n end",
"def clean!\n stop\n FileUtils.remove_entry(download_path) if File.exists? download_path\n FileUtils.remove_entry(tmp_save_dir, true) if File.exists? tmp_save_dir\n FileUtils.remove_entry(instance_dir, true) if File.exists? instance_dir\n FileUtils.remove_entry(md5sum_path) if File.exists? md5sum_path\n FileUtils.remove_entry(version_file) if File.exists? version_file\n end",
"def clean!\n stop\n FileUtils.remove_entry(download_path) if File.exists? download_path\n FileUtils.remove_entry(tmp_save_dir, true) if File.exists? tmp_save_dir\n FileUtils.remove_entry(instance_dir, true) if File.exists? instance_dir\n FileUtils.remove_entry(md5sum_path) if File.exists? md5sum_path\n FileUtils.remove_entry(version_file) if File.exists? version_file\n end",
"def cleanIntermediateFiles()\n puts \"Deleting intermediate files\"\n deleteTempFilesCmd = \"rm *.sam *.sai\"\n `#{deleteTempFilesCmd}`\n\n # Be careful here, delete only _sorted.bam\n puts \"Deleting intermediate BAM file\"\n deleteTempBAMFileCmd = \"rm *_sorted.bam\"\n `#{deleteTempBAMFileCmd}`\n\n makeDirCmd = \"mkdir casava_fastq\"\n `#{makeDirCmd}`\n moveCmd = \"mv *.fastq.gz ./casava_fastq\"\n `#{moveCmd}`\n end",
"def cleanIntermediateFiles()\n puts \"Deleting intermediate files\"\n deleteTempFilesCmd = \"rm *.sam *.sai\"\n `#{deleteTempFilesCmd}`\n\n # Be careful here, delete only _sorted.bam\n puts \"Deleting intermediate BAM file\"\n deleteTempBAMFileCmd = \"rm *_sorted.bam\"\n `#{deleteTempBAMFileCmd}`\n\n makeDirCmd = \"mkdir casava_fastq\"\n `#{makeDirCmd}`\n moveCmd = \"mv *.fastq.gz ./casava_fastq\"\n `#{moveCmd}`\n end",
"def preclean_project\n # Clean-up non-useful files (if any)\n clean_msg = `make clean 2>&1`\n @log_file.puts \"\\nNettoyage du répertoire :\\n\\n#{clean_msg}\"\n \n # I want to be sure...\n FileUtils::rm_f Dir.glob(\"*.o\")\n FileUtils::rm_f Dir.glob(\"*~\")\n end",
"def cleanup()\n @definition.temporary_files.each do |file|\n if File.exists?(file) && File.writable?(file)\n File.delete(file)\n end\n end\n if @environment.verbose\n puts \"========== END #{@definition.name} ============\"\n end\n end",
"def clean!\n stop\n remove_instance_dir!\n FileUtils.remove_entry(config.download_path) if File.exists?(config.download_path)\n FileUtils.remove_entry(config.tmp_save_dir, true) if File.exists? config.tmp_save_dir\n md5.clean!\n FileUtils.remove_entry(config.version_file) if File.exists? config.version_file\n end",
"def clean_build_directory\n FileUtils.rm_rf Dir.glob(File.join(@project.build_path, '*'))\n end",
"def cleanup\n cleanup_unpack_path\n cleanup_download_path\n end",
"def clean_up\n FileUtils.rm_rf @temp_root\n end",
"def cleanup!\n FileUtils.rm_rf(obsolete_files)\n FileUtils.rm_rf(metadata_file) unless @site.incremental?\n end",
"def cleanup_files\n FileUtils.rm_rf(File.join(Rails.root, \"tmp\"))\n end",
"def clean_files\n ck_valid\n File.unlink(pid_file) if File.exists?(pid_file)\n File.unlink(prof_file) if File.exists?(prof_file)\n File.unlink(socket_file) if File.exists?(socket_file)\n end",
"def cleanup\n reshaper_orig_cleanup\n\n # remove some unwanted pages\n pages.delete_if do |page|\n path = page.destination(source)\n path =~ /shared\\/layouts/ or\n path =~ /shared\\/includes/\n end\n\n # remove some unwanted static files\n static_files.delete_if do |file|\n file.path =~ /shared\\/includes/ or\n file.path =~ /\\.styl$/ or # stylus files should be generated into site.css\n file.path =~ /readme\\./ # readme files are for github\n end\n\n end",
"def clean_up\n FileUtils.rm_rf \"#{@path}\" unless create_in_current_directory?\n FileUtils.rm_rf \"#{@cache}\"\n end",
"def clean\n FileUtils.rm(\"#{build_name}.json\")\n end",
"def clean_up()\n File.delete(ZIP_FILE)\n end",
"def clean_environment\n `rm -rf /tmp/#{@upload_id}` # all sliced pages of the source file\n end",
"def cleanup_dirs\n @cleanup_dirs ||= ['.']\n end",
"def purgeFiles\n Dir[\"#{@pagespath}/*\"].reject{ |f| f[\"#{@pagespath}/.keep\"] }.each do |filename|\n File.delete filename\n end\n\n Dir[\"#{@assetpath}/*\"].reject{ |f| f[\"#{@pagespath}/.keep\"] }.each do |filename|\n File.delete filename\n end\n end",
"def cleanUpWorkingFiles()\n system(\"rm -f #{@tripFile} #{routeFile} #{routeAltFile}\") ;\n end",
"def cleanup\n sh 'rm -rf _site'\n compass('clean')\nend",
"def tidy_up\n Dir[\"*nin\"].each do |file|\n File.delete(file)\n end\n Dir[\"*nhr\"].each do |file|\n File.delete(file)\n end\n Dir[\"*nsq\"].each do |file|\n File.delete(file)\n end\n Dir[\"*blast\"].each do |file|\n File.delete(file)\n end\n end",
"def cleanup\n FileUtils.rm_rf(sfx_cache_path)\n end",
"def clean_up\n puts \"Run the following commands to clean up your test data:\"\n puts \"oc delete pv --all\"\n puts \"oc delete pvc --all\"\n puts \"Deleting temporary test files\"\n `rm -rf #{$templates_path}/*`\nend",
"def clean_up\n Dir.foreach(Dir.pwd) do |f|\n if !f.start_with?('tmp_') then next\n elsif File.directory?(f) then FileUtils.rm_rf(f)\n else FileUtils.rm(f)\n end\n end\nend",
"def cleanup\n @agent_file_history.each { |af| FileUtils.rm_f(af) }\n @key_file_history.each { |kf| FileUtils.rm_f(kf) }\n end",
"def cleanup\n File.delete(temp_file_path)\n end",
"def finalize_dirs\n @finalize_dirs || Dbt::Config.default_finalize_dirs\n end",
"def cleanup\n FileUtils.rm_f Dir.glob(File.join(config.folder, '*.items'))\n end",
"def teardown\n [\"file1\", \"file2\", \"file3\"].each {|f| FileUtils.rm f}\n Dir[\"test/backup/file*\"].each {|f| FileUtils.rm f}\n Dir[\"test/backup/*.tar.gz\"].each {|f| FileUtils.rm f}\n Dir.rmdir \"test/backup\" if File.exists? \"test/backup\"\n end",
"def clean!\n FileUtils.rm(self[:build_path]) if File.exist?(self[:build_path])\n FileUtils.rm(self[:staging_path]) if File.exist?(self[:staging_path])\n return self\n end",
"def cleanup\n\t\tfile_count = 0\n\t\tif File.directory?(@file_path)\n\t\t\tDir.foreach(@file_path) do |f|\n\t\t\t\tfile_count += 1\n\t\t\t fn = File.join(@file_path, f)\n\t\t\t File.delete(fn) if f != '.' && f != '..'\n\t\t\tend\n\t\t\tDir.delete(@file_path)\n\t\t\tmsg = \"Cleaned up #{file_count} files\"\n\t\telse\n\t\t\thalt 422, \"No directory\"\n\t\tend\n\t\t{ msg: msg }\n\tend",
"def cleanup!; end",
"def cleanup!; end",
"def pkg_clean\n sysprint \"#{@name} clean\"\n\n FileUtils::rm_rf(@objdir, :secure => true)\n end",
"def clean_app()\n wd = FileUtils.pwd()\n FileUtils.rm_f( [\n '/app/assets/*',\n '/app/components/*',\n '/app/controllers/*',\n '/app/helpers/*',\n '/app/models/*',\n '/app/views/*'\n ].collect!{|e| Dir.glob(wd + e)}.flatten.compact )\n end",
"def cleanup_oldies\n debug_msg \"Removing old builds\"\n to_remove = []\n @builds.simple_builds.each do |build|\n current = nil\n build.versioned_builds.sort.each do |versioned|\n to_remove << current if current && current.same_minor?(versioned)\n current = versioned\n end\n end\n to_remove.each do |build|\n debug_msg \" - #{build}\"\n FileUtils.rm_rf File.join(@public_dir, build.to_s)\n end\n @builds.merged_builds.each do |merged|\n to_remove.each do |build|\n if merged.include? build\n debug_msg \" - #{merged}\"\n FileUtils.rm_rf File.join(@public_dir, merged.to_s) \n end\n end\n end\n \n end",
"def tidy_up\n return if DEBUG\n\n puts heading(\"Tidying up PWD\")\n\n FileUtils.remove(Dir[\"#{FileUtils.pwd}/bugsnag-*.tgz\"])\nend",
"def cleanup\n\tsh 'del /F /Q .\\_site\\*'\n\t# sh 'rm -rf ./_site'\nend",
"def clean\n Dir.foreach(@wd) do |file|\n next if file.start_with?('.') or (file == \"config\")\n filename = File.join(@wd, file)\n FileUtils.remove_file(filename) if File.file?(filename)\n end\n end",
"def after_destroy\n bundle_dir = File.join( self.userfolder, self.bundle_src_folder )\n logger.info(\"==================> Remove all bundle files for: \" + bundle_dir )\n %x[rm -f -R #{bundle_dir}]\n \n # delete bundle image file name\n %x[rm #{fq_bundle_image_filename('*')}]\n \n #delete sample audio prompt\n %x[rm #{fq_bundle_sample_prompt}]\n end",
"def cleanup_state\n delete_if_exists(state_file_path)\n delete_if_exists(chef_file_path)\n delete_if_exists(past_scripts_path)\n delete_if_exists(log_path)\n end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup\n close_file_appender\n archive_run_result if (defined? @results_archive) && @archive_results\n end",
"def teardown\n FileUtils.rm_rf(\"test/resources/IncludesSinceTestRepository\")\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup(prefix)\n print_header \"Cleaning up ...\"\n Constants::SOFTWARE.each do |sw|\n cmd \"rm #{prefix}/#{sw}.tar.gz; rm -rf #{prefix}/#{sw}\" if File.exist? \"#{prefix}/#{sw}.tar.gz\"\n end\n end",
"def purge_output\n Dir.glob dir(\"output/**/*\") do |item|\n next if File.directory? item\n File.delete item unless @touchedfiles.include? undir(item)\n end\n end",
"def clean\n needs_cleaning = File.exist?(project_dir)\n if needs_cleaning\n log.info(log_key) { \"Cleaning project directory `#{project_dir}'\" }\n FileUtils.rm_rf(project_dir)\n end\n create_required_directories\n deploy\n needs_cleaning\n end",
"def clean(ant)\n @build_dir.delete\n end",
"def clean()\n\t\ttmpdir = Dir.open(@tmpout) do |dir|\n\t\t\tdir.each do |file|\n\t\t\t\tif file != \".\" and file != \"..\" then\n\t\t\t\t\tFile.unlink(@tmpout + \"/\" + file)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tDir.rmdir @tmpout\n\tend",
"def cleanup\n if File.exist?(@scalerui_dir)\n print \"Cleaning up directories...\"\n FileUtils.rm_r(@scalerui_dir)\n puts \"done\"\n else\n puts \"Nothing to clean up!\"\n end\n end",
"def finalise\n end",
"def cleanup\n\n # ----------------------------------------------\n account_name = 'your account name' # <-- change this!\n project_name = 'your project name' # <-- change this!\n # ----------------------------------------------\n\n project_dir = \"/home/#{account_name}/www\"\n Dir.chdir(project_dir)\n\n Dir.entries(project_name).select do |entry1|\n\n dir1 = File.join(project_name,entry1) #dir2 = \"#{project_name}/#{entry1}\"\n if is_directory?(dir1)\n Dir.entries(dir1).select do |entry2|\n \n dir2 = File.join(dir1,entry2) #dir2 = \"#{project_name}/#{entry1}/#{entry2}\"\n if is_directory?(dir2)\n Dir.entries(dir2).select do |entry3|\n \n dir3 = File.join(dir2,entry3) #dir3 = \"#{project_name}/#{entry1}/#{entry2}/#{entry3}\"\n if is_directory?(dir3)\n Dir.entries(dir3).select do |entry4|\n delete_file(File.join(dir3,entry4))\n end\n end\n\n delete_file(dir3)\n delete_dir(dir3)\n end\n end\n\n delete_file(dir2)\n delete_dir(dir2)\n end\n end\n\n delete_file(dir1)\n delete_dir(dir1)\n end\n\n delete_dir(project_name)\nend",
"def cleanup_nontarget_files\n\n delete_dir = File.expand_path(File.join(app.build_dir, 'Resources/', 'Base.lproj/', 'assets/', 'images/'))\n\n puts_blue \"Cleaning up excess image files from target '#{options.Target}'\"\n puts_red \"Images for the following targets are being deleted from the build directory:\"\n\n (options.Targets.keys - [options.Target]).each do |target|\n\n puts_red \"#{target.to_s}\"\n Dir.glob(\"#{delete_dir}/**/#{target}-*.{jpg,png,gif}\").each do |f|\n puts_red \" Deleting #{File.basename(f)}\"\n File.delete(f)\n end\n end\n\n puts_red \"\\nImages prefixed all- are being deleted if a corresponding #{options.Target}- exists.\"\n\n Dir.glob(\"#{delete_dir}/**/all-*.{jpg,png,gif}\").each do |f|\n if File.exist?( f.sub(\"all-\", \"#{options.Target}-\") )\n puts_red \" Deleting #{File.basename(f)}\"\n File.delete(f)\n end\n end\n\n\n end",
"def clean_sprockets_assets\n manifest.clean(backups_to_keep)\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def clean_tests\n puts \"Removing generated tests from '#{Settings[:test_dir]}'...\"\n Dir.foreach(Settings[:test_dir]) do |dir|\n path = Pathname.new(Settings[:test_dir]) + dir\n next if dir == '.' or dir == '..' or dir == 'support' or not path.directory?\n FileUtils.rm_rf(path)\n end\nend",
"def cleanup\n end",
"def cleanup\n end",
"def prepare_for_development\n FileUtils.rm_r(Dir[File.join(@context.gen_root, '*')])\n FileUtils.rm(\n File.join(@context.public_root, 'bundle.css'),\n :force => true\n )\n end",
"def finalize!\n all_files.each { |f| Kernel.require f } if eager_load\n all_files.clear\n self\n end",
"def clear!\r\n @last_build_file.delete()\r\n end",
"def cleanup\n Util.rm_if_necessary(headers_path)\n Util.rm_if_necessary(body_path)\n end",
"def cleanup\r\n end",
"def cleanup\n begin\n File.delete(full_filename, full_filename + \".meta\")\n rescue\n logger.warn \"Unable to delete recordings files: #{full_filename}*\"\n end\n end",
"def remove_files_we_dont_need\n say 'Remove files we don\\'t need'\n build :remove_public_index\n build :remove_readme_rdoc\n end",
"def clean_up\n execute(\"rm -rf #{namespace_dir}\")\n end",
"def cleanup\n winrm.run_cmd( \"del #{base64_file_name} /F /Q\" )\n winrm.run_cmd( \"del #{command_file_name} /F /Q\" )\n end",
"def cleanup_app_caches(app_name, instance_name)\n Dir.chdir RailsPwnerer::Config[app_name, instance_name][:app_path] do\n if File.exist?('Gemfile')\n Kernel.system 'bundle exec rake assets:clean RAILS_ENV=production'\n else\n Kernel.system 'rake assets:clean RAILS_ENV=production'\n end\n end\n end",
"def close_files\n [self.source, self.original, self.destination].each do |f|\n next unless f\n begin\n f.close\n File.unlink(f) if SystemInformation.env == 'production'\n rescue\n nil\n end\n end\n end",
"def clear\n Dir[File.join(@output_dir, '*')].each do |path|\n File.delete(path)\n end\n end",
"def clean_installation\n clean_paths.each { |path| FileUtils.rm_rf(path) }\n end",
"def post_process(file)\n if File.basename(file.to_s).match(/library/)\n oldfile = file\n file = file.to_s.sub(\"library\", @options[:lib_name_u])\n FileUtils.mv(oldfile, file)\n end\n if File.dirname(file.to_s).split(\"/\").last == \"library\"\n origdir = File.dirname(file.to_s)\n dirarr = origdir.split(\"/\")\n dirarr[dirarr.size-1] = @options[:lib_name_u]\n new_dir = File.join(dirarr)\n mkdir(new_dir)\n oldfile = file\n file = File.join(new_dir, File.basename(file))\n FileUtils.mv(oldfile, file)\n FileUtils.rmdir(origdir)\n end\n if file.to_s.match(/\\.seed$/)\n out_file = Pathname.new(file.to_s.sub(/\\.seed$/, ''))\n # Don't overwrite a file of the same name, unless they --force\n if copy_check(out_file)\n template = ::ERB.new(File.read(file))\n # This binding has access to any instance variables of\n # the ProjectCreator instance\n result = template.result(binding)\n File.open(file.to_s.sub(/\\.seed$/,''), 'w+') do |io|\n io.puts result\n end\n end\n # Remove the seed file whether we copied or not\n FileUtils.rm_f(file)\n end\n end",
"def clobber\n rm_r(srcdir)\n rm_r(blddir)\n rm_r(libdir)\n rm_r(config_file)\n end",
"def clean\n FileUtils.remove_dir(@log_dir, true)\n end",
"def finalize_dirs\n @finalize_dirs || DbTasks::Config.default_finalize_dirs\n end",
"def bootstrap_cleanup\n end",
"def clean()\n\t\tSystem::clean target()\n\tend",
"def clean()\n\t\tSystem::clean target()\n\tend",
"def clean_debris \n objdirs = File.join(\"**/\", \"obj\")\n userfiles = File.join(\"**/\", \"*.vcxproj.user\")\n\n delete_list = FileList.new(objdirs, userfiles)\n delete_list.each do |file|\n puts \"Removing #{file}\"\n FileUtils.rm_rf(\"#{file}\")\n end\nend"
] | [
"0.74821997",
"0.73111963",
"0.73092467",
"0.7293423",
"0.72630394",
"0.7204535",
"0.7179331",
"0.71490556",
"0.71440876",
"0.7125522",
"0.7108553",
"0.7068123",
"0.7068123",
"0.703793",
"0.703793",
"0.7036852",
"0.7023799",
"0.7000978",
"0.6981148",
"0.68912953",
"0.6888974",
"0.6886777",
"0.6832849",
"0.6814494",
"0.6803278",
"0.67813146",
"0.67450386",
"0.6738077",
"0.67299974",
"0.6726788",
"0.67222357",
"0.67187685",
"0.66885394",
"0.667036",
"0.6663578",
"0.6656221",
"0.6635587",
"0.6582983",
"0.6576769",
"0.6554373",
"0.6540009",
"0.65246576",
"0.65139025",
"0.64755374",
"0.6470704",
"0.6470704",
"0.6451716",
"0.64490753",
"0.6447817",
"0.64450705",
"0.6443761",
"0.6442451",
"0.64367473",
"0.64289194",
"0.6420085",
"0.6420085",
"0.6420085",
"0.6420085",
"0.64180154",
"0.64121103",
"0.64106196",
"0.64106196",
"0.64106196",
"0.64106196",
"0.64056146",
"0.6396762",
"0.63904524",
"0.63868415",
"0.6382666",
"0.6364573",
"0.6363819",
"0.6362256",
"0.63542753",
"0.63525814",
"0.6348415",
"0.6348415",
"0.6348415",
"0.63434637",
"0.63354826",
"0.63354826",
"0.6333671",
"0.6332015",
"0.6321929",
"0.6318178",
"0.630187",
"0.629847",
"0.6289813",
"0.62897116",
"0.62857795",
"0.6284674",
"0.6281043",
"0.6280863",
"0.6269071",
"0.6268394",
"0.62604797",
"0.6257998",
"0.6257719",
"0.62511796",
"0.6246084",
"0.6246084",
"0.6235525"
] | 0.0 | -1 |
Generates a banner if a block is given, or returns the currently set banner. It automatically takes care of adding comment marks around the banner. The default banner looks like this: ======================= = Version : v1.0.0 = = Date : 20120620 = ======================= | def banner(options = {}, &block)
options = {
:comment => :js
}.update(options)
if block_given?
@_banner = yield.to_s
elsif !@_banner
banner = []
banner << "Version : #{self.scm.version}"
banner << "Date : #{self.scm.date.strftime("%Y-%m-%d")}"
size = banner.inject(0){|mem,b| b.size > mem ? b.size : mem }
banner.map!{|b| "= #{b.ljust(size)} =" }
div = "=" * banner.first.size
banner.unshift(div)
banner << div
@_banner = banner.join("\n")
end
if options[:comment]
self.comment(@_banner, :style => options[:comment])
else
@_banner
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def banner(options = {}, &_block)\n options = {\n comment: :js\n }.update(options)\n\n if block_given?\n @_banner = yield.to_s\n elsif !@_banner\n @_banner = default_banner.join(\"\\n\")\n end\n\n if options[:comment]\n comment(@_banner, style: options[:comment])\n else\n @_banner\n end\n end",
"def banner(context, block)\n context.instance_eval(&block)\n end",
"def banner(arg=nil)\n @banner = arg if arg\n @banner || description\n end",
"def banner\n unless @banner\n @banner = +\"Usage: #{program_name} [options]\"\n visit(:add_banner, @banner)\n end\n @banner\n end",
"def banner\n checkConnection()\n @banner\n end",
"def banner\n checkConnection()\n @banner\n end",
"def showBanner\n\treturn unless $options.show_banner\n\tputs <<BANNER\n ____ ____ ____ ___________ ____ __ __ ______\n / ___\\\\_/ __ \\\\ / \\\\_/ __ \\\\_ __ \\\\/ _ \\\\| | \\\\/ ___/\n / /_/ > ___/| | \\\\ ___/| | \\\\( <_> ) | /\\\\___ \\\\\n \\\\___ / \\\\___ >___| /\\\\___ >__| \\\\____/|____//____ >\n\\\\_____/ \\\\/ \\\\/ \\\\/ project generator \\\\/\n\nBANNER\nend",
"def banner\n self.class.instance_variable_get(:@__banner)\n end",
"def banner\n say %(\n\n ******************************************************************\n\n Your extension has been generated with a gemspec dependency on\n Archangel ~> v#{archangel_version}\n\n I have a feeling you're about to build something amazing.\n\n ******************************************************************\n\n )\n end",
"def banner\n return \"codnar-weave - Weave documentation chunks to a single HTML.\"\n end",
"def print_banner(meta_info = nil)\n banner = meta_info.nil? ? \"#{@banner}\" : \"#{meta_info}\\n #{@banner}\"\n puts banner\n end",
"def banner_copyright\n return unless banner\n\n %(Header photo: © <a href=\"#{banner.url}\">#{banner.author}</a>)\n end",
"def banner(banner_src)\n content_for(:custom_banner) { banner_src.html_safe }\n end",
"def banner\n <<-EOS\nUsage #{$0} GeneratorName [license=#{LICENSES.join('|')}] [migration=true] [dir=/dir/to/install] [named=true]\n\nOptional arguments:\n\n named : When =true, generates a NamedBase generator.\n\n license : The license to install in the generator.\n\n migration : When =true (or when the generator name ends in\n 'migration') adds extra code to the generator.\n\n dir : Directory to install into. vendor/generator/generator_name\n is the default.\n\nEOS\n end",
"def banner(text)\n @__banner = text.strip\n end",
"def banner(value = (not_set = true))\n if not_set\n @properties[:banner]\n else\n @properties[:banner] = value\n end\n end",
"def print_banner\n print_line BANNER\n print_line\n print_line\n end",
"def banner\n lines = []\n \n name_line = \"#{ name } role\"\n lines << name_line\n lines << \"=\" * name_line.length\n lines << ''\n if meta['description']\n lines << meta['description']\n lines << ''\n end\n lines << 'Usage:'\n lines << ''\n lines << \" #{ usage }\"\n lines << ''\n lines << ''\n \n lines.join(\"\\n\")\n end",
"def banner()\n print \"\"\" \n =================================================================\n =================================================================\n\t ==========International Morse Code translator v 0.0.1 =========\n ==========Transates user supplied Morse Code to text ============\n\t =================================================================\n ==========Coded by Rick Flores | nanotechz9l ====================\n ==========E-mail 0xnanoquetz9l<<\\|/>>gmail.com ===================\n\t =================================================================\n =================================================================\n \n\"\"\".foreground(:blue).bright\nend",
"def banner(arg=nil)\n arg.nil? ? @option_parser.banner : (@option_parser.banner = arg)\n end",
"def banner\n\t\t\t@banner || \"Usage: #{program_prefix} [arguments]\"\n\t\tend",
"def banner\n @data['banner']\n end",
"def banner\n puts \"TITO-BOT\\n\"\nend",
"def banner(text, line_width=40)\n banner_text = \"=\" * line_width\n banner_text << \"\\n\"\n banner_text << text.center(line_width)\n banner_text << \"\\n\"\n banner_text << \"=\" * line_width\n puts banner_text\n nil\n end",
"def test_default_banner\n release = @rogerfile.release(scm: :fixed)\n\n # Set fixed version\n date = Time.now\n release.scm.version = \"1.0.0\"\n release.scm.date = date\n\n lines = release.banner.split(\"\\n\")\n\n assert_equal \"/* ====================== */\", lines[0]\n assert_equal \"/* = Version : 1.0.0 = */\", lines[1]\n assert_equal \"/* = Date : #{date.strftime('%Y-%m-%d')} = */\", lines[2]\n assert_equal \"/* ====================== */\", lines[3]\n end",
"def banner_for(user, height=100)\n image_tag(url_for(user.set_banner(height)))\n end",
"def banner\r\n \"Usage: #{$0} generator [options] [args]\"\r\n end",
"def draw_banner\n bmp = Cache.picture(@quest.banner) # Get Picture\n # Shift the hue if requested\n bmp.hue_change(@quest.banner_hue) unless @quest.banner_hue == 0\n x = (contents_width - bmp.rect.width) / 2\n if x < 0 # Stretch horizontally if the banner is too wide\n dest_rect = bmp.rect.dup\n dest_rect.width = contents_width\n contents.stretch_blt(dest_rect, bmp, bmp.rect)\n else\n contents.blt(x, @draw_y, bmp, bmp.rect)\n end\n bmp.dispose\n end",
"def build_doc_block(comment_block)\n yaml_match = /^\\s*---\\s(.*?)\\s---$/m.match(comment_block)\n return unless yaml_match\n markdown = comment_block.sub(yaml_match[0], '')\n\n begin\n config = YAML::load(yaml_match[1])\n rescue\n display_error(\"Could not parse YAML:\\n#{yaml_match[1]}\")\n end\n\n if config['name'].nil?\n puts \"Missing required name config value. This hologram comment will be skipped. \\n #{config.inspect}\"\n else\n doc_block = DocumentBlock.new(config, markdown)\n end\n end",
"def game_banner\n puts <<-GRID\n ####### ####### ########{' '}\n # # ##{' '}\n # # ##{' '}\n # ## #### # #### #### # #### ####{' '}\n # # # # # # # # # ## ## # ##{' '}\n # # # # #### # # # # ######{' '}\n # # ## # # # ## # ## ## ##{' '}\n ### ### #### ### ##### #### ### #### ####\n GRID\nend",
"def banner\n \"#{basename} #{self_command.formatted_usage(self, false)}\"\n end",
"def banner\n \"Usage: #{$0} minimal_cart\"\n end",
"def banner(_config, message )\r\n\t_config.vm.provision \"shell\", privileged: true, inline: <<-BANNER\r\n\t\tdpkg -l | grep -q sysvbanner || apt install -y sysvbanner\r\n\t\techo\t'################################################################################'\r\n\t\techo\r\n\t\twhich banner > /dev/null 2>&1 && banner #{message} || echo #{message}\r\n\t\techo\r\n\t\techo\t'################################################################################'\r\n\tBANNER\r\nend",
"def block_name \n :CodeBlock \n end",
"def block_name \n :CodeBlock \n end",
"def banner\n\tputs\n\tputs \"#{HC}#{FWHT}Linux Log Cleaner\"\n\tputs \"By: #{FGRN}Hood3dRob1n#{RS}\"\n\tputs\nend",
"def banner\n \"Usage: #{$0} #{spec.name} <action>\"\n end",
"def banner s; @order << [:text, s] end",
"def print_banner(banner_text, output)\n banner = Artii::Base.new\n output.puts\n output.puts banner.asciify(\" #{banner_text}\")\n output.puts\nend",
"def banner\n \"Usage #{$0} compass_sass somethingelse whoknowswhat\"\n end",
"def print_banner\n notice( \"\\n=== #{@key} ===\", [:CYAN, :BOLD])\n notice( description, [:CYAN] )\n notice( \"----> OS value: #{os_value.inspect}\", [:CYAN] ) if os_value\n notice( \"----> Recommended value: #{recommended_value.inspect}\", [:CYAN] ) if recommended_value\n end",
"def cli_banner()\n print \"> \"\n end",
"def get_banner\n @server.make_request('show.getbanner', tvdbid: @tvdbid)\n end",
"def to_s\n @banner + \"\\n\\n\" + @doc.join(\"\\n\") + \"\\n\"\n end",
"def block(options)\n [\n %[snippet #{options[:name]} \"#{options[:desc]}\"],\n options[:snip],\n \"endsnippet\"\n ].join(\"\\n\")\n end",
"def sdk_block\n @sdk_block ||=\n Rails.cache.fetch([\"Block\", block_hash, \"object\"], expires_in: 1.hour) do\n CKB::Types::Block.from_h(original_raw_hash)\n end\n end",
"def block_name\n if @split_across\n if @block_method == :count\n \"Block #{@block_num}/#{@num_blocks} (across dataset)\"\n else\n \"Block #{@block_num} of #{@block_size} words (across dataset)\"\n end\n else\n if @block_method == :count\n \"Block #{@block_num}/#{@num_blocks} (within \\\"#{@current_doc.title}\\\")\"\n else\n \"Block #{@block_num} of #{@block_size} words (within \\\"#{@current_doc.title}\\\")\"\n end\n end\n end",
"def show\n banner = Banner.where(area: Banner.areas[:MemberShow]).first\n if banner\n @banner_image = banner.desktop_image.url\n @banner_url = banner.desktop_url\n end\n end",
"def print_banner\n return if @silent\n say_blue \"=== #{@key} ===\", ['BOLD']\n say_blue description\n say_blue \" - os value: #{os_value}\" if os_value\n say_blue \" - os value: #{puppet_value}\" if puppet_value\n say_blue \" - recommended value: #{recommended_value}\" if recommended_value\n say_blue \" - chosen value: #{@value}\" if @value\n end",
"def banner\n \"Usage: #{$0} #{spec.name} #{spec.name.camelize}Name [options]\"\n end",
"def rails_banner\n env = defined?(Rails) ? Rails.env : 'development'\n\n puts Pry::Helpers::Text.__send__(ENV_COLORS[env], Object.const_get(\"#{env.upcase}_BANNER\"))\n\n ''\nend",
"def banner\n \"Usage: #{$0} cmt ModelName field:type, field:type\"\n end",
"def find_banner\n values = {\n left_border: @place.longitude-0.2,\n right_border: @place.longitude+0.2,\n top_border: @place.latitude+0.2,\n bottom_border: @place.latitude-0.2,\n self_id: @place.id\n }\n\n Banner.where(place_id: Place.where('latitude > :bottom_border and latitude < :top_border\n and longitude > :left_border and longitude < :right_border\n and id != :self_id and display_my_banners = true',\n values)).sample\n end",
"def help; summarize(\"#{banner}\".sub(/\\n?\\z/, \"\\n\")) end",
"def banner(msg)\n puts \"\\n #{'*' * (msg.size + 6)}\"\n puts \" * #{msg} *\"\n puts \" #{'*' * (msg.size + 6)}\\n\"\nend",
"def display_banner()\n\n\tr = Random.rand(1..4)\n\n\tcase r\n\twhen 1\n\t\tputs \"\n\t.------..------..------..------..------.\n\t|D.--. ||V.--. ||A.--. ||S.--. ||H.--. |\n\t| :/\\\\: || :(): || (\\\\/) || :/\\\\: || :/\\\\: |\n\t| (__) || ()() || :\\\\/: || :\\\\/: || (__) |\n\t| '--'D|| '--'V|| '--'A|| '--'S|| '--'H|\n\t`------'`------'`------'`------'`------'\n\n\n\t\t\"\n\twhen 2\n\t\tputs \"\n\t@@@@@@@ @@@ @@@ @@@@@@ @@@@@@ @@@ @@@ \n\t@@@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@ @@@ @@@ \n\t@@! @@@ @@! @@@ @@! @@@ !@@ @@! @@@ \n\t!@! @!@ !@! @!@ !@! @!@ !@! !@! @!@ \n\t@!@ !@! @!@ !@! @!@!@!@! !!@@!! @!@!@!@! \n\t!@! !!! !@! !!! !!!@!!!! !!@!!! !!!@!!!! \n\t!!: !!! :!: !!: !!: !!! !:! !!: !!! \n\t:!: !:! ::!!:! :!: !:! !:! :!: !:! \n\t :::: :: :::: :: ::: :::: :: :: ::: \n\t:: : : : : : : :: : : : : :\n\t\n\n\t\t\"\n\twhen 3\n\t\tputs \"\n\n\t\t ^^ .-=-=-=-. ^^\n\t ^^ (`-=-=-=-=-`) ^^\n\t (`-=-=-=-=-=-=-`) ^^ ^^\n\t ^^ (`-=-=-=-=-=-=-=-`) ^^ ^^\n\t ( `-=-=-=-(@)-=-=-` ) ^^\n\t (`-=-=-=-=-=-=-=-=-`) ^^\n\t (`-=-=-=-=-=-=-=-=-`) ^^\n\t (`-=-=-=-=-=-=-=-=-`) ^^\n\t (`-=-=-=-=-=-=-=-=-`) ^^\n\t (`-=-=-=-=-=-=-=-`) ^^\n\t (`-=-=-=-=-=-=-`) ^^ ^^\n\t dvash (`-=-=-=-=-`)\n\t `-=-=-=-=-`\n\n\n\t\t\"\n\twhen 4\n\t\tputs \"\n\n\t _______________\n\t //~~~~~~~~~~~~~~~\\\\\\\\ |\n\t 0 / /_________________\\\\ \\\\| 0\n\t ---------------------------\n\t / /======|=D=V=A=S=H=|======\\\\ \\\\\n\t \\\\_____________________________/\n\t \\\\ _______ _______ /\n\t |\\\\ _/|__|__|\\\\_____/|__|__|\\\\_ /|\n\t | |`V' `---' `V'| |\n\t |______| |______|\n\t\t\n\n\t\t\"\n\tend\nend",
"def get_html_banner()\n\t\t\t\thtml = %Q{\n\t\t\t\t\t<html><body bgcolor=black style=\"color:cyan; font-family: monospace\">\n\t\t\t\t\t\t<pre>#{Xssf::XssfBanner::Logos[2]}</pre><h3 style=\"position:absolute; right:1%; top:75%\" align=\"right\"><u>msf ></u> _</h3>\n\t\t\t\t\t\t<table width=\"300\" height=\"35\" style=\"border: 1px solid green; position:absolute; left:450px; top:30%\">\n\t\t\t\t\t\t\t<tr align=center>\n\t\t\t\t\t\t\t\t<td width=\"33%\" onMouseover=\"this.bgColor='green'\" onMouseout=\"this.bgColor='black'\"\n\t\t\t\t\t\t\t\tonClick=\"parent.location='#{VICTIM_GUI}?#{PARAM_GUI_PAGE}=main';\" style=\"cursor:pointer; border: 1px solid green;\">LOGS</td>\n\t\t\t\t\t\t\t\t<td width=\"33%\" onMouseover=\"this.bgColor='green'\" onMouseout=\"this.bgColor='black'\"\n\t\t\t\t\t\t\t\tonClick=\"parent.location='#{VICTIM_GUI}?#{PARAM_GUI_PAGE}=stats';\" style=\"cursor:pointer; border: 1px solid green;\">STATS</td>\n\t\t\t\t\t\t\t\t<td width=\"33%\" onMouseover=\"this.bgColor='green'\" onMouseout=\"this.bgColor='black'\"\n\t\t\t\t\t\t\t\tonClick=\"parent.location='#{VICTIM_GUI}?#{PARAM_GUI_PAGE}=help';\" style=\"cursor:pointer; border: 1px solid green;\">HELP</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</body></html>\n\t\t\t\t}\n\t\t\t\treturn html\n\t\t\tend",
"def add_doc_block(comment_block)\n yaml_match = /^\\s*---\\s(.*?)\\s---$/m.match(comment_block)\n return unless yaml_match\n\n markdown = comment_block.sub(yaml_match[0], '')\n\n begin\n config = YAML::load(yaml_match[1])\n rescue\n DisplayMessage.error(\"Could not parse YAML:\\n#{yaml_match[1]}\")\n end\n\n if config['name'].nil?\n DisplayMessage.warning(\"Missing required name config value. This hologram comment will be skipped. \\n #{config.inspect}\")\n else\n doc_block = DocumentBlock.new(config, markdown)\n end\n\n @doc_blocks[doc_block.name] = doc_block if doc_block.is_valid?\n end",
"def banner\n \"Usage: #{$0} my_controller controller\"\n end",
"def block_name_declaration(block_name)\n buff_code \"#{block_name} = __blocks.delete('#{block_name}') { __create_block('#{block_name}') }\"\n end",
"def banner?\n @properties.key?(:banner) && !@properties[:banner].nil?\n end",
"def block_definition(block_node)\n buff_code \"__blocks['#{block_node.name}'] = __create_block('#{block_node.name}', #{location_node(block_node)}) do\"\n\n code_indent do\n visit_node_children(block_node)\n end\n\n buff_code 'end'\n end",
"def banner_label\n html_content[0..100]\n end",
"def banner_url\n object.banner_url.url\n end",
"def set_banner\n @banner = Banner.find(params[:id])\n end",
"def set_banner\n @banner = Banner.find(params[:id])\n end",
"def set_banner\n @banner = Banner.find(params[:id])\n end",
"def set_banner\n @banner = Banner.find(params[:id])\n end",
"def set_banner\n @banner = Banner.find(params[:id])\n end",
"def set_banner\n @banner = Banner.find(params[:id])\n end",
"def bannerUrl\n @obj['bannerUrl']\n end",
"def start_comment(description = 'Description')\n str = \"#{@indent}/**\\n\"\n str += \"#{@indent} *\\t@brief\\t<##{description}#>\\n\"\n str \n end",
"def entry_banner\n 'Team Meeting'\n end",
"def basic_blocks\n cfg.blocks\n end",
"def banner\n \"Usage: #{$0} admin_ka ModelName\"\n end",
"def new\n @banner = Banner.new\n @types = Banner::TYPES\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @banner }\n end\n end",
"def banner_line(end_cap_string, center_string, fill_string, banner_width)\n end_cap_string + center_string.center(banner_width, fill_string) + end_cap_string\nend",
"def new\n if params[:duplicate_id] && banner_dup = Banner.find(params[:duplicate_id])\n @banner = banner_dup.dup\n @banner.name += \" (copy)\"\n @banner.confirmed = false\n\n banner_dup.helper_items.each do |hi|\n @banner.helper_items << hi.dup\n end\n\n else\n @banner = Banner.new\n @banner.start_time = Time.now.at_midnight\n @banner.end_time = 1.week.from_now.end_of_day\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @banner }\n end\n end",
"def banner\n packetfu_ascii_art\n puts \">>> PacketFu Shell #{PacketFu.version}.\"\n if Process.euid.zero? && @pcaprub_loaded\n puts \">>> Use $packetfu_default.config for salient networking details.\"\n print \"IP: %-15s Mac: %s\" % [$packetfu_default.ip_saddr, $packetfu_default.eth_saddr]\n puts \" Gateway: %s\" % $packetfu_default.eth_daddr\n print \"Net: %-15s\" % [Pcap.lookupnet($packetfu_default.iface)][0]\n print \" \" * 13\n puts \"Iface: %s\" % [($packetfu_default.iface)]\n puts \">>> Packet capturing/injecting enabled.\"\n else\n print \">>> Packet capturing/injecting disabled. \"\n puts Process.euid.zero? ? \"(no PcapRub)\" : \"(not root)\"\n end\n puts \"<>\" * 36\nend",
"def banner\n if(@all_images.nil?)\n @all_images = Image.all\n end\n\n if(!@all_images.empty?)\n for img in @all_images\n if(img.picture_file_name == \"Company_Logo.png\")\n @imagelogo = img.picture.url\n end\n if(img.picture_file_name == \"Company_Banner.png\")\n @imagebanner = img.picture.url\n end\n end\n end\n end",
"def link_banner(banner)\n raise \"Zone must be saved\" if new_record?\n raise ArgumentError.new(\"Banner must be saved\")if banner.new_record?\n\n session = Base.connection\n server = XMLRPC::Client.new2(\"#{session.url}#{self.class.endpoint}\")\n server.call(\"linkBanner\", session.id, self.id, banner.id)\n end",
"def banner\n out = <<-EOD;\n Usage: #{$0} authenticated ModelName [ControllerName] \n EOD\n end",
"def entry_banner\n 'Four by four'\n end",
"def _extract_block(block)\n src_file_path = block.source_location[0]\n block_start_line_number = block.source_location[1]\n\n src_file_content = File.open(src_file_path).read\n lines_after_block_start = src_file_content.split(\"\\n\")[block_start_line_number..-1]\n\n # block already starts with one \"do\"\n do_counter = 1\n # assuming that \"do themize\" and corresponding \"end\" placed on separate lines\n block_end_index = 1\n lines_after_block_start.each_with_index do |line, i|\n # http://stackoverflow.com/a/11899069/6376451\n do_counter += line.scan(/<%.*?do.*?%>/).size\n do_counter -= line.scan(/<%.*?end.*?%>/).size\n if line =~ /\\s*<%\\s*end\\s*%>/ && do_counter == 0\n block_end_index = i\n break\n end\n end\n return nil if block_end_index == 0\n\n lines_after_block_start[0..block_end_index-1].join(\"\\n\")\n end",
"def block_view(context, block_name)\n \n app = context[:app]\n \n result = case block_name\n \n when 'site_breadcrumb_public'\n\n preffixes = Plugins::Plugin.plugin_invoke_all('ignore_path_prefix_breadcrumb', {:app => self})\n\n if app.request.path_info.empty? or app.request.path_info.start_with?(*preffixes)\n bc = ''\n else\n path = app.request.path_info\n if path.match /\\/page\\/\\d+/\n path.sub!(/\\/page\\/\\d+/,'')\n end\n home_page_path = SystemConfiguration::Variable.get_value('site.anonymous_front_page', nil)\n bc = app.t.breadcrumb.home\n\n if home_page_path != path\n path_array = path.split('/')\n result = \"\"\n summary = \"\\\\\"\n bc = path_array.slice(0, path_array.size-1).inject(\"\") do |result, item| \n if item.empty?\n result << \"<a href=\\\"/\\\">#{app.t.breadcrumb.home}</a>\"\n result\n else \n result << \"<span class=\\\"breadcrumb_separator\\\"> > </span> \" unless result.empty?\n result << \"<a href=\\\"#{summary}#{item}\\\">#{item.capitalize.gsub(/-/,' ')}</a>\"\n summary << \"#{item}\\\\\" \n result\n end\n end\n if path_array.size > 1\n bc << \" <span class=\\\"breadcrumb_separator\\\"> > </span> <span class=\\\"breadcrumb_last\\\">#{path_array.last.capitalize.gsub(/-/,' ')}</span>\"\n end\n end\n end \n\n bc == app.t.breadcrumb.home ? '' : bc\n\n\n when 'site_breadcrumb'\n preffixes = Plugins::Plugin.plugin_invoke_all('ignore_path_prefix_breadcrumb', {:app => self})\n \n if app.request.path_info.empty? or app.request.path_info.start_with?(*preffixes)\n bc = ''\n else\n breadcrumb = Site::BreadcrumbBuilder.build(app.request.path_info, context) \n bc_render = SiteRenders::BreadcrumbRender.new(breadcrumb, context)\n bc = bc_render.render \n end \n\n bc\n\n\n when 'site_adminmenu'\n \n if app.user and app.user.is_superuser?\n \n # Retrieve the admin menu options\n admin_menu = {:name => 'admin_menu', :title => 'Admin menu', :description => 'Administration menu'}\n admin_menu_items = Plugins::Plugin.plugin_invoke_all('menu', context)\n \n menu = Site::Menu.build(admin_menu, admin_menu_items)\n menu.language_in_routes = false\n SiteRenders::MenuRender.new(menu, context).render\n \n end\n \n when /^menu_/\n \n menu_name = block_name.match(/^menu_(.+)/)[1]\n \n if menu = Site::Menu.get(menu_name)\n menu_render = SiteRenders::MenuRender.new(menu, context)\n menu_render.render\n else\n ''\n end\n \n when /^view_/ \n\n view_name = block_name.sub(/view_/,'')\n \n if view = ContentManagerSystem::View.get(view_name)\n arguments = \"\"\n if app.request.path_info and app.request.path_info.split('/').length > 2\n arguments = (x=app.request.path_info.split('/')).slice(2,x.length).join('/')\n end\n ::CMSRenders::ViewRender.new(view, app).render(1, arguments) \n else\n ''\n end\n \n when /^content_/\n \n content_id = block_name.sub(/content_/,'')\n if content = ContentManagerSystem::Content.get(content_id.to_i)\n CMSRenders::ContentRender.new(content, app).render\n else\n ''\n end \n\n\n end\n\n return result\n \n \n end",
"def html_blocklike_show(title, content)\n render('layouts/block', :title => title, :content => content) unless content.blank?\n end",
"def show_beta_banner\n return 1.0 if params[:beta] == 'destinations-next'\n\n # Remove this line for production launch\n false\n\n # Uncomment this for production launch\n # prng = Random.new(Time.now.to_i)\n # prng.rand < 0.0025\n end",
"def create\n @banner = Banner.new(banner_params)\n exchange_attributes_params\n respond_to do |format|\n if @banner.save\n notice = 'Banner was successfully created.' \n notice += ' <span class=\"text-danger\">Error on bidder synch process. Please try again.</span>' if @banner.campaign and not @banner.campaign.update_bidder\n format.html { redirect_to @banner, notice: notice }\n format.json { render :show, status: :created, location: @banner }\n else\n format.html { render :new }\n format.json { render json: @banner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def banner\n \"Usage: #{$0} static_gen_specs ModelName [table_name]\"\n end",
"def entry_banner\n 'Interview'\n end",
"def set_banner\n @banner = Banner.find(params[:id])\n end",
"def link_banner(banner)\n raise \"Zone must be saved\" if new_record?\n raise ArgumentError.new(\"Banner must be saved\")if banner.new_record?\n\n session = self.class.connection\n server = XmlrpcClient.new2(\"#{session.url}\")\n server.call(\"ox.linkBanner\", session, self.id, banner.id)\n end",
"def prepare_block_str!\n raise ParserError, @block_str if @block_str.start_with? '-'\n\n @block_str = @block_str.\n gsub(/(\\d{4})/) { \"#{$1[0..1]}:#{$1[2..3]}\" }. # 4 digits\n gsub(/(\\d{3})/) { \"0#{$1[0]}:#{$1[1..2]}\" }. # 3 digits\n gsub(/now/) { RoundedTime.now.strftime('%H:%M') } # now\n\n return unless @block_str =~ HALF_BLOCK_RGX\n\n # Complete or start an ongoing block.\n @block_str = if (ob = @day.blocks.find(&:ongoing?))\n \"#{ob.start_s}-#{@block_str}\"\n else\n \"#{@block_str}-#{@block_str}\"\n end\n end",
"def card_description(bug_id)\n descr = <<TXT\nBugzilla: #{bz_markdown_link(bug_id)}\n\n---\n## Review\n- Pull Request: *URL here*\nTXT\n\n # just to avoid the trailing blank errors in the heredoc\n descr + \"- \"\nend",
"def blck\n MegaBar::Block.find(1)\nend",
"def create_comment(string, &block); end",
"def create_comment(string, &block); end",
"def banner\n\tpacketfu_ascii_art\n\tputs \">>> PacketFu Shell #{PacketFu.version}.\"\n\tif Process.euid.zero? && @@pcaprub_loaded \n\t\tputs \">>> Use $packetfu_default.config for salient networking details.\"\n\t\tprint \"IP: %-15s Mac: %s\" % [$packetfu_default.ip_saddr, $packetfu_default.eth_saddr]\n\t\tputs \" Gateway: %s\" % $packetfu_default.eth_daddr\n\t\tprint \"Net: %-15s\" % [Pcap.lookupnet($packetfu_default.iface)][0]\n\t\tprint \" \" * 13 \n\t\tputs \"Iface: %s\" % [($packetfu_default.iface)]\n\t\tputs \">>> Packet capturing/injecting enabled.\"\n\telse\n\t\tprint \">>> Packet capturing/injecting disabled. \"\n\t\tputs Process.euid.zero? ? \"(no PcapRub)\" : \"(not root)\"\n\tend\n\tputs \"<>\" * 36\nend",
"def blocker\n \"<div id='blocker'></div>\"\n end",
"def build_vorbis_comment_block\n begin\n vorbis_comm_s = [@tags[\"vendor_tag\"].length].pack(\"V\")\n vorbis_comm_s += [@tags[\"vendor_tag\"]].pack(\"A*\")\n vorbis_comm_s += [@comment.length].pack(\"V\")\n @comment.each do |c|\n vorbis_comm_s += [c.bytesize].pack(\"V\")\n vorbis_comm_s += [c].pack(\"A*\")\n end\n vorbis_comm_s\n rescue\n raise FlacInfoWriteError, \"error building vorbis comment block\"\n end\n end"
] | [
"0.7764316",
"0.7029551",
"0.69917434",
"0.68789756",
"0.6870191",
"0.6870191",
"0.6573407",
"0.656541",
"0.65457445",
"0.63539004",
"0.6275968",
"0.6257269",
"0.6248917",
"0.62445074",
"0.62316394",
"0.6217306",
"0.62162584",
"0.6207513",
"0.6180822",
"0.60489756",
"0.60307795",
"0.5953614",
"0.5942535",
"0.5913531",
"0.58804625",
"0.585444",
"0.5848593",
"0.5777455",
"0.5755928",
"0.57163113",
"0.5693301",
"0.56901497",
"0.55750364",
"0.55577236",
"0.55577236",
"0.5540052",
"0.55310386",
"0.55213404",
"0.551364",
"0.54571027",
"0.54461074",
"0.54424304",
"0.5433639",
"0.54113007",
"0.5391647",
"0.53757906",
"0.533096",
"0.5327009",
"0.532476",
"0.5317385",
"0.5272834",
"0.52692026",
"0.5261432",
"0.52573365",
"0.5256604",
"0.5240334",
"0.52218336",
"0.5172573",
"0.517224",
"0.51442623",
"0.5140342",
"0.5137011",
"0.5113882",
"0.5106839",
"0.5097193",
"0.5097193",
"0.5097193",
"0.5097193",
"0.5097193",
"0.5097193",
"0.5094463",
"0.50889",
"0.5084135",
"0.5082802",
"0.5081071",
"0.50700355",
"0.50686705",
"0.5058299",
"0.50548697",
"0.5054056",
"0.5037655",
"0.5036723",
"0.5031837",
"0.5030373",
"0.50254923",
"0.50239295",
"0.50209737",
"0.5018507",
"0.50176805",
"0.5002904",
"0.5001349",
"0.5000426",
"0.49986646",
"0.49840388",
"0.49833465",
"0.4978221",
"0.4978221",
"0.49723136",
"0.49649265",
"0.49566296"
] | 0.7815564 | 0 |
Extract the mockup, this will happen anyway, and will always happen first This method gives you a way to pass options to the extractor. | def extract(options = {})
self.warn(self, "Don't use the extractor anymore, use release.use(:mockup, options) and release.use(:url_relativizer, options) processors")
@extractor_options = options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract( options )\n \n end",
"def extractable_options?; true end",
"def extractable_options?; end",
"def extractor\n @extractor ||= self.respond_to?(:extract) ? self : instantiate(self.class.get_extractor)\n end",
"def extract\n source = self.options.fetch(:source, nil)\n @raw = OpenContent::Extractor.process(source, ET.logger)\n end",
"def extract(options = {})\n # Ensure that unspecified options have default values.\n file_path = options.has_key?(:file_path) ?\n options[:file_path].to_s :\n @zip_path\n restore_permissions = options.has_key?(:permissions) ?\n options[:permissions] :\n false\n restore_ownerships = options.has_key?(:ownerships) ?\n options[:ownerships] :\n false\n restore_times = options.has_key?(:times) ?\n options[:times] :\n false\n\n # Make the directory.\n FileUtils.mkdir_p(file_path)\n\n # Restore the metadata.\n ::File.chmod(mode, file_path) if restore_permissions\n ::File.chown(uid, gid, file_path) if restore_ownerships\n ::File.utime(atime, mtime, file_path) if restore_times\n\n nil\n end",
"def test_extract_files_and_options\n files, options = public_extract_files_and_options('some')\n assert_equal(['some'], files)\n assert_equal({}, options)\n \n files, options = public_extract_files_and_options('some', 'other')\n assert_equal(['some', 'other'], files)\n assert_equal({}, options)\n \n \n files, options = public_extract_files_and_options('some', 'other', :key => :value)\n assert_equal(['some', 'other'], files)\n assert_equal({:key => :value}, options)\n \n files, options = public_extract_files_and_options('some', 'other', {})\n assert_equal(['some', 'other'], files)\n assert_equal({}, options)\n end",
"def extract_meta\n end",
"def disunity_extract(src: nil)\n end",
"def setup(options); end",
"def setup(options); end",
"def extract\n @extractors.each do |ex|\n @variables.substitute!(ex.field)\n if @request.has_response_field?(ex.field, @target)\n field = @request.get_response_field(ex.field, @target)\n if ex.pattern\n @variables.substitute!(ex.pattern)\n Regexp.new(ex.pattern).match(field)\n if Regexp.last_match\n @variables[ex.variable] = Regexp.last_match(1)\n else\n Log.warn(\"Extraction from response #{@target} field '#{ex.field}' ('#{field}') with pattern '#{ex.pattern}' failed.\")\n end\n else\n @variables[ex.variable] = field\n end\n @variables.mark_for_save(ex.variable) if ex.save\n @variables.export(ex.variable) if ex.export\n else\n Log.warn(\"Extraction from response #{@target} field '#{ex.field}' failed: field not found.\")\n end\n end if @extractors\n end",
"def setup(options = {}); end",
"def extract\n base.say_status 'extract', @file\n if @zip_file\n base.exec(\"cd #{@temp_dir} ; unzip #{@file}\")\n else\n base.exec(\"cd #{@temp_dir} ; tar xvfpz #{@file}\")\n end\n \n # Remove the file\n base.destination_files.rm_rf(@file_path)\n end",
"def populate(options = {})\n opts = options.merge(\n suppress_missing: @suppress_missing,\n output_handler: lambda{ |data, chunk|\n if file_name = options[:response_file]\n data.to_file(file_name,\n file_mode: chunk == 0 ? 'w' : 'a',\n include_col_headers: chunk == 0)\n end\n process_data(data, chunk)\n }\n )\n extract_specs = [extract_specs] unless extract_specs.is_a?(Array)\n @data = []\n extract_specs.each do |extract_spec|\n @layout_mapped = false\n @extract.extract_data(nil, opts)\n end\n sort_data if @sort_required\n filter_data if @filter_required\n @data\n end",
"def setup options\n @out = get_output(options)\n end",
"def extract( options )\n @targets = get_matched_customers( options[:target] )\n @dStart = options[:start]\n @dEnd = options[:end]\n @category = 'Expenses'\n @include_own_expenses = options[:include_own]\n exFile = lewt_settings[\"expenses_filepath\"] || File.expand_path(File.join(File.dirname(__FILE__), \"../../../tests/expenses.csv\"))\n return get_expenses ( exFile )\n end",
"def extract(extractor_name, method_name: extractor_name)\n extractors[extractor_name] = [method_name]\n end",
"def set_extract\n @extract = Extract.find(params[:id])\n end",
"def set_extract\n @extract = Extract.find(params[:id])\n end",
"def extract_extras(*args)\n args.extract_options!\n args.shift\n args\n end",
"def extract_command; end",
"def extract\n nil\n end",
"def extract_metadata; end",
"def extract\n case type\n when /jpe?g/i\n extract_jpg\n when /png/i\n extract_png\n end \n metadata\n rescue Errno::ENOENT, Exiftool::ExiftoolNotInstalled, Exiftool::NoSuchFile, Exiftool::NotAFile => e\n raise ExtractionError, \"#{e.class.name}: #{e.message}\"\n end",
"def extract( options )\n matchData = get_matched_customers( options[:target] )\n @dStart = options[:start].to_date\n @dEnd = options[:end].to_date\n @targets = self.get_matched_customers(options[:target])\n exFile = lewt_settings[\"milestones_filepath\"] || File.expand_path(File.join(File.dirname(__FILE__), \"../../../tests/milestones.csv\"))\n return get_milestones ( exFile )\n end",
"def run_extractors\n begin\n unsanitized_paths = Set.new\n self.class.extractors.available.each do |name|\n exception_jail false do\n unsanitized_paths.merge self.class.extractors[name].new(\n document: document,\n html: body\n ).run\n end\n end\n\n sanitized_paths = Set.new\n unsanitized_paths.map do |path|\n abs = to_absolute( path )\n next if !abs || skip?( abs )\n\n sanitized_paths << abs\n end\n\n sanitized_paths.to_a\n rescue => e\n print_exception e\n []\n end\n end",
"def after_source_extraction(extracted_source)\n end",
"def extract\n case @download\n when /\\.tar/ then untar\n when /\\.gz\\z/ then gunzip\n end\n end",
"def extract(tempfile)\n testdata_filename = save_testdata_file(tempfile)\n ext = TestdataImporter.long_ext(tempfile.original_filename)\n\n extract_dir = File.join(GraderScript.raw_dir, @problem.name)\n if File.exists? extract_dir\n backup_count = 0\n begin\n backup_count += 1\n backup_dirname = \"#{extract_dir}.backup.#{backup_count}\"\n end while File.exists? backup_dirname\n File.rename(extract_dir, backup_dirname)\n end\n Dir.mkdir extract_dir\n\n if ext=='.tar.gz' or ext=='.tgz'\n cmd = \"tar -zxvf #{testdata_filename} -C #{extract_dir}\"\n elsif ext=='.tar'\n cmd = \"tar -xvf #{testdata_filename} -C #{extract_dir}\"\n elsif ext=='.zip'\n cmd = \"unzip -o #{testdata_filename} -d #{extract_dir}\"\n else\n return nil\n end\n\n system(cmd)\n\n files = Dir[\"#{extract_dir}/**/*1*.in\"]\n return nil if files.length==0\n\n File.delete(testdata_filename)\n\n return File.dirname(files[0])\n end",
"def extract\n case type\n when /jpe?g/i\n extract_jpg\n when /png/i\n extract_png\n end\n metadata.except( *REJECTED_TAGS )\n rescue Errno::ENOENT, Exiftool::ExiftoolNotInstalled, Exiftool::NoSuchFile, Exiftool::NotAFile => e\n raise ExtractionError, \"#{e.class.name}: #{e.message}\"\n end",
"def extract_options!\n option_parser.order!(args)\n end",
"def setup_external_text_extractor\n create_external_text_extraction_dialog\n add_extraction_menu_item\n end",
"def parse\n parse_options\n parse_target\n end",
"def extract_options!(*options)\n parser = Cmd::OptionParser.new(@args)\n parsed_options = parser.parse!(*options)\n @args = parser.args\n parsed_options\n end",
"def setup\n add_standard_properties\n #\n create_banner\n create_standard_options\n create_advanced_options\n create_mode_options\n create_application_options\n create_feature_options\n create_tail_options\n #\n parse_options\n load_config_configuration\n create_result_directory\n load_results_archive\n end",
"def extract_custom_settings!(options)\n @heading = options.key?(:heading) ? options.delete(:heading) : default_heading\n @sortable_column = options.delete(:sortable)\n @sortable_start = options.delete(:sortable_start) || 0\n @new_record = options.key?(:new_record) ? options.delete(:new_record) : true\n @destroy_option = options.delete(:allow_destroy)\n options\n end",
"def setup\n begin\n @options = OptParser.parse(ARGV)\n rescue ParserExceptions::MissingArgument\n exit(1)\n end\n\n end",
"def extract\n if @options[:type] == :text\n @potential_names += @content.split(/\\n/)\n elsif @options[:type] == :html\n @potential_names += HTMLNameFinder.new(@content).names\n @potential_names += @nokogiri_doc.css(\"title, p, li, span, a\").map(&:text)\n end\n\n @name_detector = NameDetector.new(@potential_names)\n\n @extract = @name_detector.extract_names\n end",
"def extract_member(member_path, destination_path, options={})\n warn \"Using default #extract_member which may be memory-inefficient\"\n default_extract_member(member_path, destination_path, options)\n end",
"def setup(options)\n NotImplementedError \n end",
"def extract_new_preview\n delete_extract\n extract_preview\n end",
"def extract_option_map\n {\n owner: Archive::EXTRACT_OWNER,\n permissions: Archive::EXTRACT_PERM,\n time: Archive::EXTRACT_TIME,\n no_overwrite: Archive::EXTRACT_NO_OVERWRITE,\n acl: Archive::EXTRACT_ACL,\n fflags: Archive::EXTRACT_FFLAGS,\n extended_information: Archive::EXTRACT_XATTR,\n xattr: Archive::EXTRACT_XATTR,\n no_overwrite_newer: Archive::EXTRACT_NO_OVERWRITE_NEWER,\n }\n end",
"def match_step(options={})\n options[:glob]\n if options.include?(:glob)\n\n end\n end",
"def extract(args, *params)\n args, opts = args.args_and_opts\n name = extract_value opts, :name\n opts.merge!(@singular.to_sym => name ) if name\n params.map do |param| # for every symbol in params Array:\n arg = args.next rescue nil # try to assign sequential argument from args\n arg ||= extract_value opts, param # try to assign named argument from opts\n arg || case param # assign defaults if no other value found\n when :user\n API.auth['login']\n when :branch\n 'master'\n when :public\n !extract_value(opts, :private) unless arg == false\n else\n nil # no default found, parameter is nil\n end\n end\n end",
"def setup_options\n @parser.banner = BANNER\n\n @parser.on('-V', '--version', 'display version and exit') { show_version }\n @parser.on('-h', '--help', 'display help and exit') { show_help }\n @parser.on('-f', '--files=[file1.txt file2.txt ...]', Array, 'text files to read') { |o| @options.files = o }\n @parser.on('-n', '--number=NUM', Integer, 'number of results to show [default = 100]') do |n|\n @options.number = n\n end\n @parser.on('-v', '--verbose', 'verbose output') { @options.verbose = true }\n end",
"def pre_mock_generate(arg_hash); execute_plugins(:pre_mock_generate, arg_hash); end",
"def add_meta!(options)\n flow_file = OrigenTesters::Flow.callstack.last\n called_from = caller.find { |l| l =~ /^#{flow_file}:.*/ }\n if called_from\n # Splitting on ':' when file names are included will yield a different index for everything in Windows\n called_from.gsub!(flow_file, '')\n called_from = called_from.split(':')\n options[:source_file] = flow_file # called_from[0]\n options[:source_line_number] = called_from[1].to_i\n end\n end",
"def extract(entry, dest_path, &block); end",
"def setup(info)\n @info = info \n end",
"def run\n setup\n fuzzing_loop\n end",
"def extract\n @browser.visit @url\n Nokogiri::HTML(@browser.html)\n end",
"def extract\n @store.all_classes_and_modules.each do |klass|\n extract_from_klass(klass)\n end\n @po\n end",
"def setup\n build_defaults\n build_site_stub\n build_context_stub\n end",
"def fetch_setup_details\n\n super\n\n end",
"def after_configuration\n vcard_generator = Middleman::VCard::Generator.new(\n options[:name],\n emails: options[:emails],\n phones: options[:phones],\n addresses: options[:addresses],\n photo: options[:photo],\n logger: logger)\n vcard_generator.generate(@vcard_dir_path.join(@vcard_file_name).to_s)\n end",
"def rack_extractor\n RACK_EXTRACTOR\n end",
"def adopt_extractions extraction_params={}\n if extraction_params.present?\n build_gleaning unless gleaning\n # Declare the attributes needed w/o launching to glean\n # NB: we take ALL proffered attributes, not just those that are priorly needed\n # gleaning.attribs_needed! *extraction_params.keys\n gleaning.accept_attributes extraction_params\n\n # attribs_needed! *extraction_params.keys\n accept_attributes extraction_params\n end\n end",
"def run!\n options = @args.options\n input_files = Dir.glob(options[:input_files_pattern])\n loader = Trapeze::Loader.new(*input_files)\n unless options[:quiet]\n loader.exceptions.each do |filename, exception|\n $stderr.puts \"#{exception.message} in #{filename}\"\n end\n end\n probe = Trapeze::Probe.new(loader)\n generator = Trapeze::SuiteGenerators::TestUnit.new(:input_files_pattern => options[:input_files_pattern],\n :output_dir => options[:output_dir],\n :probe => probe)\n generator.generate!\n end",
"def cli_extract(extract, path, label, store)\n\n begin\n\n require File.join(File.dirname(__FILE__),\n \"workers/#{extract.downcase}_worker.rb\")\n\n require File.join(File.dirname(__FILE__),\n \"extractors/#{extract.downcase}_extractor.rb\")\n\n extractor = \"#{extract.capitalize}Extractor\".constantize\n worker = \"#{extract.capitalize}Worker\".constantize\n bulk = extractor::BULK || 1\n publisher = Publisher.new\n\n if extractor.respond_to?(:parcels)\n\n extractor.parcels(path).each do |job|\n docs = extractor.new(\n project: path,\n label: label\n ).extract(job[:bulk], job[:mark])\n publisher.write(extract.downcase, docs, store)\n end\n\n else\n docs = extractor.new(project: path, label: label).extract\n publisher.write(extract.downcase, docs, store)\n end\n\n rescue Exception => e\n puts e\n end\n end",
"def extract\n # Only used by tar\n compression_switch = \"\"\n compression_switch = \"z\" if downloaded_file.end_with?(\"gz\")\n compression_switch = \"--lzma -\" if downloaded_file.end_with?(\"lzma\")\n compression_switch = \"j\" if downloaded_file.end_with?(\"bz2\")\n compression_switch = \"J\" if downloaded_file.end_with?(\"xz\")\n\n if Ohai[\"platform\"] == \"windows\"\n if downloaded_file.end_with?(*TAR_EXTENSIONS) && source[:extract] != :seven_zip\n returns = [0]\n returns << 1 if source[:extract] == :lax_tar\n\n shellout!(\"tar #{compression_switch}xf #{downloaded_file} --force-local -C#{project_dir}\", returns: returns)\n elsif downloaded_file.end_with?(*COMPRESSED_TAR_EXTENSIONS)\n Dir.mktmpdir do |temp_dir|\n log.debug(log_key) { \"Temporarily extracting `#{safe_downloaded_file}' to `#{temp_dir}'\" }\n\n shellout!(\"7z.exe x #{safe_downloaded_file} -o#{windows_safe_path(temp_dir)} -r -y\")\n\n fname = File.basename(downloaded_file, File.extname(downloaded_file))\n fname << \".tar\" if downloaded_file.end_with?(\"tgz\", \"txz\")\n next_file = windows_safe_path(File.join(temp_dir, fname))\n\n log.debug(log_key) { \"Temporarily extracting `#{next_file}' to `#{safe_project_dir}'\" }\n shellout!(\"7z.exe x #{next_file} -o#{safe_project_dir} -r -y\")\n end\n else\n shellout!(\"7z.exe x #{safe_downloaded_file} -o#{safe_project_dir} -r -y\")\n end\n elsif downloaded_file.end_with?(\".7z\")\n shellout!(\"7z x #{safe_downloaded_file} -o#{safe_project_dir} -r -y\")\n elsif downloaded_file.end_with?(\".zip\")\n shellout!(\"unzip #{safe_downloaded_file} -d #{safe_project_dir}\")\n else\n shellout!(\"#{tar} #{compression_switch}xf #{safe_downloaded_file} -C#{safe_project_dir}\")\n end\n end",
"def extract(_options_str = nil)\n @options_str = _options_str if _options_str # hook for testing\n @extract ||= begin\n lines_containing_options = options_str.split(/\\n/).grep(/^[\\s\\t]+-/)\n all_options = lines_containing_options.inject([]) do |list, line|\n list + line.scan(/(?:^\\s+|,\\s)(-[\\w-]+)/).flatten\n end\n long_options = all_options.grep(/^--/).sort\n short_options = hide_short_flags? ? [] : (all_options - long_options).sort\n long_options + short_options\n end\n end",
"def rack_extractor\n RACK_EXTRACTOR\n end",
"def rack_extractor\n RACK_EXTRACTOR\n end",
"def run\n super\n\n uri = _get_entity_attribute \"name\"\n\n # Scanner options\n @opt_threads = _get_option(\"threads\").to_i\n @opt_max_pages = _get_option(\"max_pages\").to_i\n #@opt_user_agent = _get_option \"user_agent\"\n @opt_extract_uris = _get_option \"extract_uris\" # create an object for each page\n @opt_extract_dns_records = _get_option \"extract_dns_records\" # create an object for each dns_record\n @opt_extract_file_metadata = _get_option \"extract_file_metadata\" # create a Uri object for each page\n @opt_extract_patterns = _get_option(\"extract_patterns\").split(\",\") # only extract entities withthe following patterns\n\n crawl_and_extract(uri)\n\n end",
"def test_extract(files=nil)\n output = 'test/embedded' # Don't think output should be setable.\n\n files = files || 'lib/**/*.rb'\n files = 'lib/**/*.rb' if TrueClass == files\n files = [files].flatten.compact\n\n filelist = files.collect{ |f| Dir.glob(f) }\n filelist.flatten!\n if filelist.empty?\n puts \"No scripts found from which to extract tests.\"\n return\n end\n\n FileUtils.mkdir_p(output) unless File.directory?(output)\n\n #vrunner = VerbosityRunner.new(\"Extracting\", verbosity?)\n #vrunner.setup(filelist.size)\n\n filelist.each do |file|\n #vrunner.prepare(file)\n\n testing = extract_test_from_file( file )\n if testing.strip.empty?\n status = \"[NONE]\"\n else\n complete_test = create_test(testing, file)\n libpath = File.dirname(file)\n testfile = \"test_\" + File.basename(file)\n fp = File.join(output, libpath, testfile)\n unless File.directory?( File.dirname(fp))\n FileUtils.mkdir_p(File.dirname(fp))\n end\n File.open(fp, \"w\"){ |fw| fw << complete_test }\n status = \"[TEST]\"\n end\n\n #vrunner.complete(file, status)\n end\n\n #vrunner.finish(\n # :normal => \"#{filelist.size} files had tests extracted.\",\n # :check => false\n #)\n end",
"def extract_mock_data\n raw_json_data = File.read(File.join(Dir.pwd, 'tests', 'example.json'))\n processed_json_data = JSON.parse(raw_json_data).to_s\nend",
"def setup()\n end",
"def post_mockup(product_id, details)\n init(\"post_mockup(\" + product_id + \", \" + details.to_json + \")\")\n # ACTUALLY ONLY THE FIRST ONE IS PROCESSED, LOOK AT THE EARLY return\n details.each do |detail|\n placements = []\n detail['placements'].each do |placement|\n placements << { placement[0] => nil }\n end\n return _post_mockup(product_id, detail['variants'], placements, detail['printfile'][\"image_url\"])\n end\n end",
"def revive options\n setup options\n end",
"def run_extraction\n\n run_on_all_extractors(@score_card.price) { |e| \n result = e.extract_stock_price()\n @score_card.price = result['price']\n @score_card.currency = result['currency']\n }\n \n run_on_all_extractors(@score_card.return_on_equity) { |e|\n e.extract_roe(@score_card.return_on_equity)\n }\n\n run_on_all_extractors(@score_card.ebit_margin) { |e|\n e.extract_ebit_margin(@score_card.ebit_margin, @score_card.share.financial)\n }\n \n run_on_all_extractors(@score_card.equity_ratio) { |e|\n e.extract_equity_ratio(@score_card.equity_ratio)\n }\n\n run_on_all_extractors(@score_card.current_price_earnings_ratio) { |e|\n e.extract_current_price_earnings_ratio(@score_card.current_price_earnings_ratio)\n }\n\n run_on_all_extractors(@score_card.average_price_earnings_ratio) { |e|\n e.extract_average_price_earnings_ratio(@score_card.average_price_earnings_ratio)\n }\n\n run_on_all_extractors(@score_card.analysts_opinion) { |e|\n e.extract_analysts_opinion(@score_card.analysts_opinion)\n }\n\n run_on_all_extractors(@score_card.reaction) { |e|\n e.extract_reaction_on_figures(@score_card.reaction)\n }\n\n run_on_all_extractors(@score_card.profit_revision) { |e|\n e.extract_profit_revision(@score_card.profit_revision)\n }\n\n run_on_all_extractors(@score_card.stock_price_dev_half_year) { |e|\n e.extract_stock_price_dev_half_year(@score_card.stock_price_dev_half_year)\n }\n \n run_on_all_extractors(@score_card.stock_price_dev_one_year) { |e|\n e.extract_stock_price_dev_one_year(@score_card.stock_price_dev_one_year)\n }\n\n run_on_all_extractors(@score_card.reversal) { |e|\n e.extract_three_month_reversal(@score_card.reversal)\n }\n\n run_on_all_extractors(@score_card.profit_growth) { |e|\n e.extract_profit_growth(@score_card.profit_growth)\n }\n\n run_on_all_extractors(@score_card.insider_info) { |e|\n e.extract_insider_deals(@score_card.insider_info)\n }\n\n end",
"def extract_options(text, options)\n if text.is_a? Hash\n # we need to dup the text object because we're deleting keys from this object which manipulates the object passed in here\n # if this object is reused after beeing injected into this component, the keys would be missing\n self.options = text.dup\n else\n self.text = text\n # we need to dup the options object because we're deleting keys from this object which manipulates the object passed in here\n # if this object is reused after beeing injected into this component, the keys would be missing\n self.options = options.dup || {}\n end\n self.options.symbolize_keys!\n end",
"def extract_method_details; end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def initialize options\r\n super\r\n @target = options[:target]\r\n end",
"def setExtractorsGlobal # MaxentTagger.java:646\n extractors.setGlobalHolder(self)\n extractorsRare.setGlobalHolder(self)\n end",
"def pickUp(simulator)\n end",
"def setup_trait(options);end",
"def extract\n raise NoMethodError, \"#{__method__} not defined for#{self.class.name}\"\n end",
"def perform\n @extracted_files = Array.new\n @files_to_extract.each do |f|\n @extracted_files.push File.basename(@filename, '.tbz') + '/' + f\n end\n\n extract = extract_command(@basename, @extracted_files.join(' '))\n\n result = system \"cd #{@dirname} && #{extract}\"\n\n if result\n _extracted_files = @extracted_files.map{|f| File.join(@dirname, f)}\n @file_entry = FileEntry.new(@filename, Hash[@files_to_extract.zip(_extracted_files)])\n FileUtils.remove_file(@filename, true) unless keep_tbz_after_extract?\n else\n raise \"Unable to extract files '#{@files_to_extract.join(' ')}' from #{@filename}\"\n end\n\n @file_entry\n end",
"def extract_data_from_options(options)\n OPTIONS.each do |option|\n instance_variable_set \"@#{option}\", options[option]\n end\n end",
"def initialize setup\n @requests = setup[:requests]\n @response = setup[:response]\n @vos = setup[:vos]\n @related_scrapers = setup[:related_scrapers] || {}\n @is_root = setup[:is_root] \n @pager = setup[:pager] || {}\n @scrapers = setup[:scrapers] || {}\n @name = setup[:name]\n \n # load in a named helper for this scraper, or the base one\n if @name && Helper.const_defined?(@name)\n @helper = Helper.const_get(@name).new\n else \n @helper = Helper::Base.new\n end\n \n end",
"def perform(druid)\n druid = druid.delete_prefix('druid:')\n LyberCore::Log.debug \"extract-thumbnail working on #{druid}\"\n extract_thumbnail druid\n end",
"def initialize(info = {})\n super(update_info(info,\n 'Name' => 'Backdoor Sniffer',\n 'Description' => %q{\n This module will attempt to sniff out well known backdoors hidden in popular directories and setup/backup files \n that should not be public facing. The list of directories and page names are taken from various repositories of\n backdoors.\n },\n 'Author' =>\n [\n 'h4cklife',\n ],\n 'License' => MSF_LICENSE\n )\n )\n\n deregister_options('RHOST', 'DigestAuthIIS', 'NTLM::SendLM',\n 'NTLM::SendNTLM', 'VHOST', 'RPORT', 'NTLM::SendSPN', 'NTLM::UseLMKey',\n 'NTLM::UseNTLM2_session', 'NTLM::UseNTLMv2')\n\n register_options(\n [\n\t\t\t\tOptString.new('DOMAIN', [true, 'Target domain']),\n OptString.new('OUTFILE', [false, 'A filename to store the results']),\n\t\t\t\tOptBool.new('DATABASE', [false, 'Add search results to thea loot database', false]),\n\t\t\t\tOptBool.new('SSL', [false, 'Use SSL', false]),\n\t\t\t\tOptBool.new('VERBOSE', [false, 'Verbose mode', false]),\n ], self.class)\n\n end",
"def setup(*args) ; end",
"def setup(destination); end",
"def setup!\n super\n @loot_machine = LootMachine.find options[:loot_machine_id]\n end",
"def extract(pattern); end",
"def extract_master_instance_options(options)\n extract_instance_options('master-', options)\n end",
"def extract(force = true)\n ensure_uri\n options = { 'Content-Type' => 'text/plain' }\n response = @client.rest_put(@data['uri'] + \"?extract=true&forceImport=#{force}\", options)\n @client.response_handler(response)\n true\n end",
"def extract_data!(options)\n if options.has_key?(:data)\n data = options.delete :data\n \n if Array === data\n data.each.with_index do |filepath, idx|\n if filepath.is_a?(Faraday::UploadIO)\n options[\"data[#{idx}]\"] = filepath\n else\n mime_type = extract_mimetype(filepath)\n options[\"data[#{idx}]\"] = Faraday::UploadIO.new(filepath, mime_type)\n end\n end\n elsif data.is_a?(Faraday::UploadIO)\n options[\"data\"] = data\n else\n mime_type = extract_mimetype(data)\n options[\"data\"] = Faraday::UploadIO.new(data, mime_type)\n end\n end\n end",
"def set_claro_extract\n @claro_extract = ClaroExtract.find(params[:id])\n end",
"def validate_stack!\n \n mockup_options = {}\n relativizer_options = {}\n run_relativizer = true\n if @extractor_options\n mockup_options = {:env => @extractor_options[:env]}\n relativizer_options = {:url_attributes => @extractor_options[:url_attributes]}\n run_relativizer = @extractor_options[:url_relativize]\n end\n \n unless @stack.find{|(processor, options)| processor.class == HtmlMockup::Release::Processors::Mockup }\n @stack.unshift([HtmlMockup::Release::Processors::UrlRelativizer.new, relativizer_options]) \n @stack.unshift([HtmlMockup::Release::Processors::Mockup.new, mockup_options])\n end\n end",
"def extract_attributes(file_name)\n extract_publish_date(file_name)\n extract_tags(file_name)\n extract_filter(file_name)\n extract_title_and_content(file_name)\n @path = Pathname.new(file_name)\n @file = @path.to_s\n @title = @file.gsub('_', ' ').capitalize if @title.to_s.empty?\n @summary = @content.match(%r{<p>.*</p>}).to_s\n self\n end",
"def initialize(base, url, temp_dir, options)\n @base = base\n @temp_dir = temp_dir\n self.options = options\n @file = File.basename(url)\n @zip_file = @file[/[.]zip$/]\n @file_path = File.join(temp_dir, @file)\n \n # TODO: GET THE FIRST DIRECTORY INSTEAD\n dir_name = @file.gsub(/[.]tar[.]gz$/, '').gsub(/[.]zip$/, '')\n @extracted_path = File.join(temp_dir, dir_name)\n \n @base.say_status 'download and compile', url\n \n download(url)\n extract\n configure unless options[:skip_configure]\n make\n make_install\n end",
"def extract_by_path_with_http_info(path, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ExtractApi.extract_by_path ...'\n end\n # verify the required parameter 'path' is set\n if @api_client.config.client_side_validation && path.nil?\n fail ArgumentError, \"Missing the required parameter 'path' when calling ExtractApi.extract_by_path\"\n end\n pattern = Regexp.new(/.+/)\n if @api_client.config.client_side_validation && path !~ pattern\n fail ArgumentError, \"invalid value for 'path' when calling ExtractApi.extract_by_path, must conform to the pattern #{pattern}.\"\n end\n\n # resource path\n local_var_path = '/cms/v3/source-code/extract/{path}'.sub('{' + 'path' + '}', CGI.escape(path.to_s))\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(['*/*'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type]\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['hapikey', 'oauth2']\n\n new_options = opts.merge(\n :operation => :\"ExtractApi.extract_by_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 => 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: ExtractApi#extract_by_path\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end"
] | [
"0.7113444",
"0.6102033",
"0.5998116",
"0.58821005",
"0.57242876",
"0.57213783",
"0.5571385",
"0.5556986",
"0.55088884",
"0.54472",
"0.54472",
"0.54383665",
"0.5374096",
"0.5367344",
"0.535354",
"0.53401935",
"0.53369206",
"0.5314586",
"0.5248584",
"0.5248584",
"0.5239394",
"0.5235017",
"0.5227586",
"0.5215401",
"0.5209768",
"0.5154811",
"0.51328987",
"0.5114628",
"0.5105582",
"0.50923765",
"0.5062913",
"0.5016928",
"0.49925706",
"0.4982415",
"0.49721745",
"0.49627462",
"0.49375033",
"0.4932129",
"0.49173224",
"0.49096832",
"0.4893421",
"0.48744318",
"0.48662618",
"0.48548326",
"0.48519415",
"0.48342833",
"0.48273364",
"0.48265547",
"0.4823318",
"0.4818868",
"0.47995576",
"0.4781698",
"0.47779197",
"0.47585034",
"0.47496948",
"0.47484145",
"0.47435743",
"0.473542",
"0.4710188",
"0.47068375",
"0.47045323",
"0.47007132",
"0.4686984",
"0.4686984",
"0.46802035",
"0.46718165",
"0.46712792",
"0.46646747",
"0.46638113",
"0.46627024",
"0.46437675",
"0.46414196",
"0.46359548",
"0.46287358",
"0.46287358",
"0.46287358",
"0.46287358",
"0.46287358",
"0.46284622",
"0.46191567",
"0.4619055",
"0.46181005",
"0.46140346",
"0.46088728",
"0.4597701",
"0.45872968",
"0.4583764",
"0.4580151",
"0.45701107",
"0.4563919",
"0.45628116",
"0.45612964",
"0.45552906",
"0.45551085",
"0.45520055",
"0.45488527",
"0.45483497",
"0.45478624",
"0.45475265",
"0.4546925"
] | 0.76932997 | 0 |
Actually perform the release | def run!
# Validate paths
validate_paths!
# Extract mockup
copy_source_path_to_build_path!
validate_stack!
# Run stack
run_stack!
# Run finalizers
run_finalizers!
# Cleanup
cleanup! if self.config[:cleanup_build]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def release\n end",
"def release\n end",
"def release\n end",
"def release(resource); end",
"def release!\n @ec.release_temp self\n end",
"def release\n locked? && release!\n end",
"def release\n # @invObj.releaseObj(self)\n end",
"def release(number)\n \n end",
"def release\n\n a = self.to_a\n self.close\n a\n end",
"def release()\n res = super(self)\n return res\n end",
"def release\n\t\[email protected]\n\tend",
"def release\n action('release')\n end",
"def release(point)\n\t\t\n\tend",
"def release(point)\n\t\t\n\tend",
"def release(point)\n\t\t\n\tend",
"def release(point)\n\t\t\n\tend",
"def release(ptr = nil)\n V2.raptor_free_term(self) unless ptr.null?\n end",
"def release(point)\n\t\t\t\t\n\t\t\tend",
"def release\n fail AlreadyRelease unless prerelease?\n @special = ''\n @metadata = ''\n end",
"def release\n @connection.transactions.release\n end",
"def release(resource)\n\t\t\t\t\t# A resource that is not good should also not be reusable.\n\t\t\t\t\t# unless resource.closed?\n\t\t\t\t\t\treuse(resource)\n\t\t\t\t\t# else\n\t\t\t\t\t# \tretire(resource)\n\t\t\t\t\t# end\n\t\t\t\tend",
"def release!\n upload_io.close if @close_io_on_finish\n end",
"def release_actions; end",
"def release\n variables[:release]\n end",
"def release_lock\n super\n end",
"def release(n = 1)\n raise NotImplementedError\n end",
"def release(plane)\n\n end",
"def dispose; end",
"def release\n @refresh_mutex.synchronize {\n @unlock = true\n\n delete\n\n @refresh_signal.signal\n }\n\n\n @refresh_thread.join if @refresh_thread\n @event_manager.create_event(\n {\n user: Config.current_job.username,\n action: 'release',\n object_type: 'lock',\n object_name: @name,\n task: @task_id,\n deployment: @deployment_name,\n }\n )\n end",
"def release\n chk_conn\n @connected = false\n @db.release(self)\n end",
"def release(key, value)\n return\n end",
"def around_release\n yield\n end",
"def release(resource)\n\t\t\t\t# A resource that is not good should also not be reusable.\n\t\t\t\tif resource.reusable?\n\t\t\t\t\treuse(resource)\n\t\t\t\telse\n\t\t\t\t\tretire(resource)\n\t\t\t\tend\n\t\t\tend",
"def release(resource)\n\t\t\t\t# A resource that is not good should also not be reusable.\n\t\t\t\tif resource.reusable?\n\t\t\t\t\treuse(resource)\n\t\t\t\telse\n\t\t\t\t\tretire(resource)\n\t\t\t\tend\n\t\t\tend",
"def unlock; end",
"def release!\n PoolNode.delete(@id, node)\n end",
"def teardown\n teardown_construct(@target_path)\n @release.destroy\n @release = nil\n end",
"def release(resource)\n\t\t\t\t@available << resource\n\t\t\t\t\t\n\t\t\t\tif task = @waiting.pop\n\t\t\t\t\ttask.resume\n\t\t\t\tend\n\t\t\tend",
"def release(job = ALL_JOBS)\n DRMAA.control(job, DRMAA::ACTION_RELEASE)\n end",
"def release(point)\n\t\tsuper(point)\n\tend",
"def release!\n ensure_service!\n service.delete_session path\n end",
"def finalize()\n # below function is not yet fully functional\n unlock_all_instances()\n end",
"def dispose\n call Memory.deAlloc(self)\n end",
"def dispose\n call Memory.deAlloc(self)\n end",
"def release_data!\n @data = nil\n end",
"def release(job = ALL_JOBS)\n DRMAA.control(job, DRMAA::ACTION_RELEASE)\n end",
"def release_task\n puts\n puts \"Release successful.\"\n end",
"def release()\n fiber = Fiber.current\n if fiber[connection_pool_key]\n @busy_connections.delete(fiber)\n @connections << fiber[connection_pool_key]\n fiber[connection_pool_key] = nil\n end\n end",
"def release(entry)\n @lock.synchronize do\n unlocked_release(entry.id)\n end\n end",
"def dispose\n\n end",
"def release\n if pointer.kind_of?(::FFI::MemoryPointer) && !pointer.null?\n pointer.free\n end\n while uri = @raptor_uri_list.pop\n V1_4.raptor_free_uri(uri) unless uri.nil? || uri.null?\n end\n end",
"def on_release(&blk)\n opts[:on_release] = blk\n end",
"def release\n return unless @lock_file # Skip if we don't have a file\n\n @lock_file.flock(File::LOCK_UN)\n File.delete( @lock_file )\n close_file\n end",
"def release_lease(service=Azure::Blobs)\n service.lease(@blob, :release)\n end",
"def release_resource(resource, authorizer=nil)\n debug \"central release_resource: '#{resource.inspect}'\"\n raise 'Method not implemented because the Central Manager just need to pass the same requisition to the other' \\\n ' brokers and create the concatenated results'\n end",
"def finalize!; end",
"def release_self\n # Release children resource recursively\n children.dup.each do |c|\n if c.release_self\n children.delete(c)\n end\n end\n return false unless children.empty?\n info \"Releasing hrn: #{hrn}, uid: #{uid}\"\n self.before_release if self.respond_to? :before_release\n props = { \n resource_id: uid, \n resource_address: resource_address #OmfCommon::CommProvider::Local::Topic.address_for(uid)\n }\n props[:hrn] = hrn if hrn\n inform :released, props\n\n \n # clean up topics \n @topics.each do |t| \n t.unsubscribe\n end\n \n true \n end",
"def finalize\n close\n end",
"def cleanup\n self.image = nil\n GC.start\n end",
"def cleanup\n self.image = nil\n GC.start\n end",
"def release(machine)\n if (address = address_for(machine))\n @pool[address] = nil\n end\n end",
"def release\n request = Remit::Cancel::Request.new(transaction_id: transaction_id)\n response = remit.cancel request\n response.errors.empty?\n end",
"def release_easy(easy)\n easy.reset\n easy_pool << easy\n end",
"def dispose\n nil\n end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def release\n if self.name!=NO_CATEGORY\n transaction do\n self.concepts.each do |concept|\n concept.update_attribute(:concept_category_id, self.function.no_category().id)\n end\n end\n end\n end",
"def finalize\n end",
"def release_transporter s\n s.close\n end",
"def finalize\n end",
"def finalize\n end",
"def finalize\n end",
"def finalize\n end",
"def finalize\n end",
"def finalize\n end",
"def finalize\n end",
"def finalize\n\n end",
"def release(obj)\n @mut.synchronize do\n if @shutdown_block\n @shutdown_block.call(obj)\n else\n @q.push(obj)\n end\n\n @cond.broadcast\n end\n end",
"def release\n @start_script[:run] = start_run_script\n end",
"def finalize\n replace\n _promote\n end",
"def release(thread)\n checkin_connection(sync{@allocated.delete(thread)})\n nil\n end",
"def release(options = {})\n current_claimant = claimant\n with_hooks(:release, current_claimant, options) do\n log(:release)\n set_claimant(nil)\n end\n end",
"def cleanup!; end",
"def cleanup!; end",
"def released(&block)\n @up_callback = block\n end",
"def release_self\n # Release children resource recursively\n children.each do |c|\n if c.release_self\n self.synchronize do\n children.delete(c)\n end\n end\n end\n\n return false unless children.empty?\n\n info \"Releasing hrn: #{hrn}, uid: #{uid}\"\n self.before_release if self.respond_to? :before_release\n props = {\n res_id: resource_address\n }\n props[:hrn] = hrn if hrn\n inform :released, props\n\n # clean up topics\n @topics.each do |t|\n t.unsubscribe\n end\n\n @membership_topics.each_value do |t|\n if t.respond_to? :delete_on_message_cbk_by_id\n t.delete_on_message_cbk_by_id(@uid)\n end\n t.unsubscribe\n end\n\n true\n end",
"def release(thread)\n conn = @allocated.delete(thread)\n\n if @connection_handling == :disconnect\n disconnect_connection(conn)\n else\n checkin_connection(conn)\n end\n end",
"def release!\n render!\n @index.commit! commit_message\n @index.push!\n end",
"def finish\n release_read_pool_connection\n end",
"def unlock\n end",
"def free\n @pool.shutdown(&:free)\n end",
"def release_a_resource(resource_descr, type_to_release, authorizer)\n debug \"release_a_resource: resource_descr: #{resource_descr}, type_to_create: #{type_to_release}\"\n raise 'Method not implemented because the Central Manager just need to pass the same requisition to the other' \\\n ' brokers and create the concatenated results'\n end",
"def release(fiber, conn)\n\t\t\t\t@busy_connections.delete(fiber)\n\t\t\t\t@connections << conn\n\t\t\tend",
"def release_self\n # Release children resource recursively\n children.each do |c|\n if c.release_self\n self.synchronize do\n children.delete(c)\n end\n end\n end\n\n return false unless children.empty?\n\n info \"Releasing hrn: #{hrn}, uid: #{uid}\"\n\n call_hook(:before_release, self)\n\n props = {\n res_id: resource_address\n }\n props[:hrn] = hrn if hrn\n inform :released, props\n\n # clean up topics\n @topics.each do |t|\n t.unsubscribe(@uid)\n end\n\n @membership_topics.each_value do |t|\n if t.respond_to? :delete_on_message_cbk_by_id\n t.delete_on_message_cbk_by_id(@uid)\n end\n t.unsubscribe(@uid)\n end\n\n true\n end",
"def cleanup\r\n end",
"def finalize\n nil\n end",
"def released_true?\n self.released\n end",
"def release(rel)\n # Find the request with this id\n match = @reqList.select{|r| r.reqid == rel.reqid}\n if match == nil or match[0] == nil\n $Logger.error \"Internal error. Cannot find req with id #{rel.reqid}\"\n return\n end\n req = match[0]\n freeup(req) \n end",
"def release(threat)\n hero = Hero.find_to_batle(threat.rank)\n if hero\n # TODO add more one hero\n batle = Batle.create(threat: threat, heroes: [hero])\n @batles.append(batle)\n else\n # run release again in a thread mode\n Thread.new do\n Rails.application.executor.wrap do\n # waits 10 seconds\n sleep(30)\n release(threat)\n end\n end\n end\n end"
] | [
"0.8604901",
"0.85713875",
"0.85713875",
"0.81487435",
"0.7855286",
"0.7627473",
"0.7470292",
"0.744611",
"0.7424807",
"0.7247099",
"0.7226407",
"0.72063375",
"0.72024286",
"0.72024286",
"0.72024286",
"0.72024286",
"0.7184828",
"0.71420467",
"0.71230716",
"0.71191806",
"0.7099474",
"0.70282066",
"0.69899225",
"0.6935637",
"0.69238216",
"0.6870831",
"0.6862413",
"0.6857181",
"0.6850606",
"0.68100274",
"0.6784747",
"0.67675143",
"0.6765493",
"0.6765493",
"0.6731597",
"0.67225623",
"0.66621166",
"0.66608274",
"0.66596735",
"0.66450775",
"0.66206414",
"0.66161215",
"0.6601586",
"0.6601586",
"0.6561856",
"0.6548412",
"0.6546282",
"0.65331167",
"0.6530326",
"0.6513383",
"0.6469214",
"0.64216876",
"0.6406489",
"0.6399681",
"0.63869977",
"0.6376143",
"0.63757384",
"0.63500404",
"0.6346692",
"0.6346692",
"0.63452965",
"0.63406956",
"0.63297194",
"0.6327245",
"0.63234985",
"0.63234985",
"0.63234985",
"0.63234985",
"0.6319424",
"0.6310576",
"0.6309157",
"0.6284233",
"0.6284233",
"0.6284233",
"0.6284233",
"0.6284233",
"0.6284233",
"0.6284233",
"0.6260995",
"0.623628",
"0.62274516",
"0.62219435",
"0.6210087",
"0.61935604",
"0.6181022",
"0.6181022",
"0.6177639",
"0.6166157",
"0.61618334",
"0.616142",
"0.61546725",
"0.61509126",
"0.6119706",
"0.61160123",
"0.6103131",
"0.6087701",
"0.60808986",
"0.60332304",
"0.6023429",
"0.6021934",
"0.6010501"
] | 0.0 | -1 |
Write out a log message | def log(part, msg, verbose = false, &block)
if !verbose || verbose && self.project.options[:verbose]
self.project.shell.say "\033[37m#{part.class.to_s}\033[0m" + " : " + msg.to_s, nil, true
end
if block_given?
begin
self.project.shell.padding = self.project.shell.padding + 1
yield
ensure
self.project.shell.padding = self.project.shell.padding - 1
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_write(msg)\n puts msg\n end",
"def write(msg)\n @logger.info msg\n end",
"def log(msg)\n @logger.write(msg) if @logger\n end",
"def write( message )\n\t\t\tApache.request.server.log_debug( message )\n\t\tend",
"def output_to_file message\n @log_file.puts message\n @log_file.flush\n end",
"def log (msg, **kwargs) Log.write(msg, :info, kwargs) end",
"def write(message)\n @m.synchronize do\n @logfile.write(message) unless @logfile.nil?\n @responses.each{|res| res.send_event(\"build_log\", strip_control_chars(message)) }\n end\n end",
"def log(message)\n File.open(@log_file, 'a') do |file|\n file.puts message\n end\n end",
"def write(level, message)\n if Boxlet.debug?\n if message.is_a? String\n puts message\n else\n pp message\n end\n else\n if level == :info\n pp message\n end\n @log.call(level, message)\n end\n end",
"def log(message)\n puts \">> #{message}\"\n end",
"def log_message(message)\n\t\tputs(message)\n\tend",
"def log(message)\n\t\t\t\[email protected]_object ['log', message]\n\t\t\tend",
"def log(msg)\n Serv::Log.info(Time.now.to_s+': '+msg+\"\\n\")\n end",
"def log(msg)\n File.open(File.join(runtime_dir, 'content-repo.log'), 'w+') { |f| \n f.puts msg }\n end",
"def log(message, err=nil)\n tstamp = DateTime.now.strftime('[%Y-%m-%d %H:%M:%S] ')\n @log.write(tstamp + message + \"\\n\")\n @log.write(err.backtrace.join(\"\\n\") + \"\\n\") unless err.nil?\n @log.flush\n end",
"def log(msg)\n STDERR.puts msg\n end",
"def log(msg)\n puts msg\n end",
"def write(msg)\n\t\tinfo(msg)\n\tend",
"def log(msg)\r\n STDERR.puts msg\r\n end",
"def log(message); logger.info(message); end",
"def log_message(message)\r\n @log.log_message(message)\r\n end",
"def log_write(level=\"I\",string)\n filepath=LOG_PATH + who?\n if File.exist?(filepath)\n log_file=File.open(filepath,\"a+\")\n else\n log_file=File.new(filepath,\"a+\")\n end\n \n log_file.syswrite(\"[#{get_time}] #{level} #{string}\\n\")\n log_file.close\n end",
"def log(msg)\n # puts msg\n $stdout.write(\"#{msg}\\n\")\n end",
"def log(message)\n open(\"#{logdir}/brief.log\", 'a') { |f| f.puts \"#{Time.now}: #{message}\" }\n end",
"def log(message)\n @logger.info message\n end",
"def write_message(log_file, string)\n File.open(@@logs[log_file], 'a') {|out| out.puts string }\n end",
"def log_message( level, message )\n t = Time.now\n File.open( @options['FILENAME'], 'a') do |f|\n f.puts \"#{t.strftime('%Y%m%d%H%M%S')}\\tMESSAGE\\t#{message}\"\n end\n end",
"def log(msg)\n STDERR.print \"** \", msg, \"\\n\"\n end",
"def do_log( msg )\n log( msg )\n end",
"def write(msg)\n case msg\n when String then @logger.info(msg.chomp)\n when Array then @logger.info(msg.join(\"\\n\"))\n else\n @logger.error(msg.inspect)\n end\n end",
"def <<(msg)\n @logdev.write(msg) if @logdev\n end",
"def writeLog(text)\n\n Utils_visiona.verifyInput(String, text.class)\n\n return if @logFile.nil?\n\n Thread.new do\n\n File.open(@logFile, 'a+') {|file| file.puts \"#{Time.now} #{text}\"}\n end\n\t\tend",
"def write(message = nil)\n info('MultiLogger#write') { message }\n end",
"def log(message)\n puts message\n end",
"def log message\n @logs << message\n end",
"def <<(msg)\n unless @logdev.nil?\n @logdev.write(msg)\n end\n end",
"def write(message)\n logger.info message unless message == \"\\n\"\n end",
"def log(msg)\n logger.info(\"#{tag} #{msg}\")\n end",
"def log(message)\n @collector.sending_stream.puts pack(:log, message)\n end",
"def puts_and_logs(msg)\n @@logger.puts_and_logs msg\n end",
"def log(message)\n SystemdMon::Logger.puts \"#{me}: #{message}\"\n end",
"def log(context, msg)\n @log << \"#{context}: #{msg}\"\n end",
"def log(msg)\n\t\tSyslog.info(msg) if @verbose\n\tend",
"def write_log_file(message)\r\n if RUBY_PLATFORM =~ /win32|win64/i then\r\n outFile = File.new('C:\\temp\\BJLog.txt', \"a\")\r\n outFile.puts message\r\n outFile.close\r\n else\r\n outFile = File.new('tmp/BJLog.txt', \"a\")\r\n outFile.puts message\r\n outFile.close\r\n end\r\n end",
"def log(*args)\n @out.puts(*args)\n end",
"def write(severity, message)\n message = \"[#{tag}] #{message}\" if tag\n SYSLOG.send LEVEL_LOGGER_MAP[severity], clean(message)\n end",
"def log_message(message)\n @log.info(message) if @options[:logging_enabled]\n end",
"def log_message(message)\n @log.info(message) if @options[:logging_enabled]\n end",
"def log_message(message)\n @log.info(message) if @options[:logging_enabled]\n end",
"def log_message(text)\n @log_mutex.synchronize do\n STDERR.puts \"%s %s: %s\" % [ Time.now.strftime(\"%Y/%m/%d %H:%M:%S\"), self.class.name, text ]\n end #synchronize\n end",
"def event_log(msg)\n time = Time.now.strftime(\"%h %d %H:%M:%S\")\n$stdout.puts \"LOG: #{msg}\"\n# _open_sefile('server.log', 'a') { |f| f.puts \"(#{time}) #{msg}\" } rescue nil\nend",
"def log(message)\n STDOUT.puts message\nend",
"def log(message)\n logger.send log_level, message if log?\n end",
"def log(msg)\n if $settings[:log]\n $settings[:log].write(Time.now.inspect + \" \" + msg + \"\\n\")\n $settings[:log].flush\n end\nend",
"def log(msg)\n puts msg\n $stdout.flush\n end",
"def info_msg(msg)\n @log.puts(msg)\n puts msg\nend",
"def logs message\n puts \"#{Time.now}: #{message}\"\n end",
"def log(message)\n puts Time.now.strftime('[%d-%b-%Y %H:%M:%S] ') + message\n end",
"def log(msg)\n puts msg\n $stdout.flush\n end",
"def message(message)\n log.info(message.to_s)\n end",
"def log(msg, level = :info)\n puts(\"ZapUpdater: \" + msg)\n RAILS_DEFAULT_LOGGER.info(\"ZapUpdater: \" + msg)\n @mail_log << msg + \"<br/>\\r\\n\" if level == :info\n end",
"def log(message, level)\n if SEVERITY[@log_level] <= SEVERITY[level]\n message = \"#{level}: #{message}\"\n if @output==:file\n File.open('debug.log', 'ab') {|f| f.puts message }\n elsif @output==:stdout\n puts message\n end\n return message \n end\n return nil\n end",
"def log(msg)\n puts(\"#{Time.now}> #{msg}\")\n end",
"def log(msg)\n (@logger ||= OMF::Common::LObject.new(self.class)).info(msg)\n end",
"def log(message)\n logger.send(log_level, message) if log?\n end",
"def log(message)\n logger.send(log_level, message) if log?\n end",
"def log(s)\n log_stream.puts(s)\n end",
"def log(msg)\n puts msg if @verbose\n end",
"def log(msg)\n puts msg if @verbose\n end",
"def log(message, severity = :info) \n @rake_log ||= ActiveSupport::BufferedLogger.new(ImportProductSettings::LOGFILE)\n message = \"[#{Time.now.to_s(:db)}] [#{severity.to_s.capitalize}] #{message}\\n\"\n @rake_log.send severity, message\n puts message\n end",
"def log(message, severity = :info) \n @rake_log ||= ActiveSupport::BufferedLogger.new(ImportProductSettings::LOGFILE)\n message = \"[#{Time.now.to_s(:db)}] [#{severity.to_s.capitalize}] #{message}\\n\"\n @rake_log.send severity, message\n puts message\n end",
"def logthis(input)\n\t\[email protected]\n\t\tfile = File.open('./serverlog','a')\n\t\twrite = \"#{Time.now}\\t#{input}\\n\"\n\t\tfile.write(write)\n\t\tputs write\n\t\[email protected]\n\tend",
"def write(message)\n f = open(@filename, 'a')\n f.puts(message)\n f.close()\n end",
"def log s\n # Open log, if necessary\n if config[:log]\n puts \"LOG: #{s}\" if config[:debug]\n File.open(config[:logfile], 'a') do |f|\n f.puts \"#{Time.now.strftime(config[:time_format])} #{s}\"\n end\n end\n end",
"def log(msg)\n (@logger ||= OMF::Base::LObject.new(self.class)).info(msg)\n end",
"def log(message, filename=\"logfile.log\")\n File.open(filename, \"a+\") do |f|\n f << \"#{Time.now}: #{message}\\n\"\n end\n end",
"def write(msg)\n @handle.puts(msg)\n end",
"def info(msg) log(6, msg); end",
"def log msg\n history = File.open(@current, \"a\")\n history.puts msg\n history.close\n end",
"def log(msg)\n $logger << msg + \"\\n\"\nend",
"def write_verbose_log(message, level = Honeybadger.configuration.debug ? :info : :debug)\n logger.send(level, LOG_PREFIX + message) if logger\n end",
"def _log(text)\n\t\topen($location+\"/logs/class.log\", 'a') { |f| f.puts(\"[\"+DateTime.now.strftime('%Y-%m-%d %H:%M:%S')+\"] \"+text+\"\\n\") } if (text.is_a?(String) && !text.empty?)\n\tend",
"def log_writer; end",
"def log(text)\n puts text\n end",
"def log(msg)\n\n Puppet::Util::Log.create(\n\n :level => @parameters[:loglevel].value,\n :message => msg,\n\n :source => self\n )\n end",
"def log(object_name, time)\n @log_file.puts \"#{object_name},#{time}\"\n end",
"def log(msg)\n @script = File.basename $0 \n logfile = $config[\"settings\"][\"log_directory\"] + \"/#{@script}.log\"\n if $config[\"settings\"][\"log_file\"]\n File.open(logfile, 'a') do |file|\n now = Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n file.puts \"#{@script} #{now} -> #{msg}\"\n end\n end\n puts \"#{@script} -> #{msg}\"\nend",
"def log(msg)\n Puppet::Util::Log.create(\n :level => resource[:loglevel],\n :message => msg,\n :source => self\n )\n end",
"def log(msg)\n print \" \" if $trace && $verbose\n $stderr.puts msg if $verbose\n end",
"def info(msg); @logger.info(msg); end",
"def log(message)\n if verbose\n output.puts \"*** #{message}\"\n elsif very_verbose\n time = Time.now.strftime('%H:%M:%S %Y-%m-%d')\n output.puts \"** [#{time}] #$$: #{message}\"\n end\n end",
"def log(message, severity = :info)\r\n @rake_log ||= ActiveSupport::Logger.new(ProductImport.settings[:log_to])\r\n message = \"[#{Time.now.to_s(:db)}] [#{severity.to_s.capitalize}] #{message}\\n\"\r\n @rake_log.send severity, message\r\n puts message\r\n end",
"def log message\n @project ? @project.log(message) : puts(message)\n end",
"def log(line)\n\t\tfile=File.open(@output_file,\"a+\")\n\t\tfile.puts(line)\n\t\tfile.close\n\tend",
"def log level, message; write level, message, caller[0] unless level > @level end",
"def log(msg)\n puts\n puts msg\nend",
"def log(level, message)\n @logger ||= Logger.new(Rails.root.join(\"log\", \"open_data.log\"))\n @logger.send(level, message)\n puts message\n end",
"def log(msg)\n puts(msg) if @info_values['enable_debug_logging'] == \"Yes\"\n end",
"def log_message( level, message )\n\n end",
"def log(log)\n # Since only one appender thread will be writing to the file at a time\n # it is not necessary to protect access to the file with a semaphore\n # Allow this logger to filter out log levels lower than it's own\n @log.write(@formatter.call(log) << \"\\n\") if level_index <= (log.level_index || 0)\n end",
"def WriteInLogs(message)\n @rstack.WriteInLogs(message)\n end"
] | [
"0.8347941",
"0.8039214",
"0.78621197",
"0.7694358",
"0.76305073",
"0.76109576",
"0.7555628",
"0.74665546",
"0.74613136",
"0.7431343",
"0.7384371",
"0.7380255",
"0.7376845",
"0.7352448",
"0.7335113",
"0.73316646",
"0.7303281",
"0.72944635",
"0.7233944",
"0.7220944",
"0.7164354",
"0.7152275",
"0.7152197",
"0.71506983",
"0.7136733",
"0.7136293",
"0.71175086",
"0.71059364",
"0.7081708",
"0.7074555",
"0.7062682",
"0.70609933",
"0.7040516",
"0.7029379",
"0.7022955",
"0.70030564",
"0.70010835",
"0.698319",
"0.69793195",
"0.6978847",
"0.6972177",
"0.69656056",
"0.6943891",
"0.69224685",
"0.6917754",
"0.69172925",
"0.691302",
"0.691302",
"0.691302",
"0.69124335",
"0.6907998",
"0.69025207",
"0.6901145",
"0.6899497",
"0.6895052",
"0.6882211",
"0.6880615",
"0.68642044",
"0.6846108",
"0.6825738",
"0.67547566",
"0.67456585",
"0.67418706",
"0.6728622",
"0.6724911",
"0.6724911",
"0.6709341",
"0.67086446",
"0.67086446",
"0.6690727",
"0.6690727",
"0.6687283",
"0.66777045",
"0.6674403",
"0.66578555",
"0.66387314",
"0.6634256",
"0.6627772",
"0.661254",
"0.66112137",
"0.6610217",
"0.66101587",
"0.6588128",
"0.6578615",
"0.6576451",
"0.65606725",
"0.6542175",
"0.65358096",
"0.64960754",
"0.6491709",
"0.6484292",
"0.64788634",
"0.6475747",
"0.6474233",
"0.6462056",
"0.645724",
"0.6450872",
"0.64506614",
"0.64237386",
"0.642315",
"0.6412452"
] | 0.0 | -1 |
Write out a warning message | def warn(part, msg)
self.project.shell.say "\033[37m#{part.class.to_s}\033[0m" + " : " + "\033[31m#{msg.to_s}\033[0m", nil, true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def warning(msg) $stderr.puts(\"Warning: #{msg}\") end",
"def warning(msg) $stderr.puts(\"Warning: #{msg}\") end",
"def warning(msg) $stderr.puts(\"Warning: #{msg}\") end",
"def warning(message)\n write_message message, 'warning'\n end",
"def warn( msg )\n @stringio.puts msg\n end",
"def warn(msg)\n puts \"WARNING: #{msg}\"\n end",
"def warn(message)\n output[:warnings] << message\n end",
"def print_warning(msg)\n tag = '[ WARNING ]'\n print_formatted(tag,msg)\n end",
"def warn(msg)\n stderr \"warning: #{msg}\"\n end",
"def warning text\n print_red(\"WARNING: #{text}\") \n end",
"def warning text\n print_red(\"WARNING: #{text}\") \n end",
"def warning_ln(message)\n write_message message, 'warning', true\n end",
"def warning(string); end",
"def warning(string); end",
"def warning(msg)\n banner(\"Warning: #{msg}\", YELLOW)\n end",
"def warn message\n message = \"WARN: \" + process_message(message)\n output_message message, @warn_color if valid_conditions 2\n end",
"def warning(text); end",
"def warning(text); end",
"def warn message\n @options.warn make_message message\n end",
"def warn message; write WARN, message, caller[0] unless level > @level end",
"def warn( msg )\n Kernel.warn( msg )\n end",
"def warning(msg) log(4, msg); end",
"def warn(message)\n self.warnings << message\n puts \"warn #{message}\"\n end",
"def warning(msg)\n @warnings << msg\n owarn @warnings.last\n end",
"def warning(text)\n STDERR.puts yellow_term_text(text)\n end",
"def warn\n\n end",
"def warning(*args); end",
"def warn_out(msg)\n if $gWarn\n puts \"\\n\\n WARNING: #{msg}\\n\\n\"\n end\n if ($gTest_params[\"logfile\"])\n $fLOG.write(\"\\n\\n WARNING: #{msg}\\n\\n\")\n end\n\n $gWarnings << msg.gsub(/\\n/,'')\n\nend",
"def warn(message)\n err(\"#{color('WARNING:', :yellow, :bold)} #{message}\")\n end",
"def warning(warning)\n end",
"def warn(msg)\n #This is a stub, used for indexing\n end",
"def warn(msg)\n $warnings << msg if $warnings\nend",
"def warning(text)\n GitPusshuTen::Log.warning(text)\n end",
"def warn(p0) end",
"def warning(message)\n log.warn(message.to_s.yellow)\n end",
"def warning?; end",
"def warning?; end",
"def warning?; end",
"def generate_warning_text\n @warnings\n end",
"def lwarn; end",
"def parse_warn(msg); say :warn, msg; end",
"def warning!\n self.severity = :WARNING\n end",
"def warn message\n log Logger::WARN, message\n end",
"def warning(warning_message, *args)\n STDERR.puts(\"#{warning_message} - #{args.join(',')}\")\n end",
"def warning(warning_message, *args)\n STDERR.puts(\"#{warning_message} - #{args.join(',')}\")\n end",
"def warning! opts = nil\n NOCH.evaluate_for \"warning\", opts\n end",
"def warn(string)\n @has_warnings = true\n to_console loggify(string, :warning, :yellow), true\n to_file loggify(string, :warning)\n end",
"def warn(msg)\n Chef::Log.warn(msg)\n end",
"def warning(fmt, *args)\n end",
"def opoo(warning)\n # $stderr.puts \"#{Tty.yellow}Warning#{Tty.reset}: #{warning}\"\n warn \"#{Tty.yellow}Warning#{Tty.reset}: #{warning}\"\n end",
"def warning\n state(\"warning\")\n end",
"def warn message\n super message if @verbosity > 1\n end",
"def warn(message)\n log(\"#{color(\"WARNING:\", :yellow, :bold)} #{message}\")\n end",
"def warned; end",
"def warn(*args); end",
"def warn(*args); end",
"def warning(text)\n puts color.colorize(text, :yellow)\n end",
"def format_compile_warning(file_name, file_path, reason,\n line, cursor); EMPTY; end",
"def warn(part, msg)\n self.project.shell.say \"\\033[37m#{part.class.to_s}\\033[0m\" + \" : \" + \"\\033[31m#{msg.to_s}\\033[0m\", nil, true\n end",
"def warning(type, message, lineno)\n end",
"def warnings; end",
"def warnings; end",
"def warnings; end",
"def warnings; end",
"def warnings; end",
"def warnings; end",
"def warnings; end",
"def warnings; end",
"def warn(msg)\n log.warn msg\n end",
"def warn(msg); @logger.warn(msg); end",
"def alert_warning(statement, question = nil)\n ui.alert_warning statement, question\n end",
"def warn string\n $log.warn string\n Ncurses.beep\n end",
"def alert_warning(statement, question=nil)\n @errs.puts \"WARNING: #{statement}\"\n ask(question) if question\n end",
"def warn s,level=0,token=nil,extra=nil\n\t\t\tif level <= $options.warning_level\n\t $stderr.print \"\\nWarn: #{s} in <#{@input_file_name}> \"\n\t\t\t\tif token\n\t \t $stderr.print \"in line #{token.line_no}, pos #{token.char_no}\"\n\t\t\t\t\t# $stderr.print \"by name <#{token.name}>\" if token and token.name\n\t\t\t\t\t$stderr.print \"\\n\"\n\t\t\t\tend\n\t\t\t\tif $options.debug\n \t\t$stderr.print \"Token=\",token.inspect,\"\\n\" if token\n \t\t$stderr.print extra if extra\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def octokit_warn(*message)\n unless ENV['OCTOKIT_SILENT']\n warn message\n end\n end",
"def bold_warning(*args); end",
"def warn(msg)\r\n logger.warn(msg)\r\n end",
"def warn?; @level <= WARN; end",
"def warn?; @level <= WARN; end",
"def log_warning warning\n message = '[aws-sdk-gem-warning] ' + warning\n if config.logger\n config.logger.warn(message)\n else\n $stderr.puts(message)\n end\n nil\n end",
"def warning(str, opts = { print: true })\n str = str.dup.to_s\n result = \"\"\n result += color? ? ANSI_CODES[:bold] + ANSI_CODES[:color][:yellow] : \"\"\n result += \"WARNING:\"\n result += color? ? ANSI_CODES[:reset] : \"\"\n result += \" \"\n result += str\n result += \"\\n\"\n print_or_return(result, opts[:print])\n end",
"def log_warning(message)\n log(message, DebugType::WARNING)\n end",
"def logWarning(message)\n found = false\n if ($logMessages)\n\tlogServer = get($serverPath+'log')\n\tif (logServer != nil)\n\t\tlogServer.warning(message)\n\t\tfound = true\n\tend\n end\n if (!found or !$logMessages or $printAllMessages)\n\tprint(message)\n end\n\nend",
"def warning(message)\n @warnings = [] unless @warnings.present?\n @warnings.append(message)\n end",
"def warning=(value)\n @warning = value\n end",
"def warning(input)\n puts \"[\\e[35m#{Time.now.strftime('%T')}\\e[0m] \\e[7m#{input}\\e[0m\"\n end",
"def warn(message)\n logger.warn(PROG_NAME) { message }\n end",
"def warn=(value) @warn = true; end",
"def output_specific_warnings\n specific_warnings = self.get_specific_warnings || []\n unless specific_warnings.empty?\n specific_warnings.each do |warning| \n puts warning \n # hash.each do |file_name, arr|\n # puts arr.join(', ') # + ' (' + file_name + ') '\n # end\n end\n else\n puts 'No warnings related to variables.'\n end\n end",
"def warn(log)\n output.puts log if log_level <= WARN\n end",
"def warn(message)\n $stdout.puts(message.red)\nend",
"def licensing_warning(message)\n log.warn(log_key) { message }\n end",
"def err(message)\n warn \" > #{message}\"\nend",
"def warn(message)\n log(2, message)\n end",
"def warning(*args)\n color(33, *args)\n end",
"def warn_out(debmsg)\n if $gWarn \n puts debmsg\n end\n if ($gTest_params[\"logfile\"])\n $fLOG.write(debmsg)\n end\nend",
"def warn(*args); say $terminal.color(format(*args), :magenta); end",
"def warn!(message) #:doc:\n # TODO: log\n nil\n end",
"def warn(message = nil, progname = nil, &block)\n add(WARN, message, progname, &block)\n end",
"def warning\n return @warning\n end"
] | [
"0.809428",
"0.809428",
"0.809428",
"0.8082665",
"0.7972393",
"0.7898887",
"0.78845495",
"0.7679932",
"0.7566553",
"0.7543718",
"0.7543718",
"0.75200576",
"0.75190127",
"0.75190127",
"0.74892706",
"0.74851817",
"0.7484032",
"0.7484032",
"0.74754834",
"0.7429984",
"0.74194634",
"0.7411738",
"0.7408579",
"0.74019194",
"0.73693174",
"0.7356007",
"0.7339675",
"0.7283415",
"0.72793823",
"0.7277525",
"0.7257146",
"0.7257017",
"0.7256334",
"0.72202945",
"0.72190845",
"0.719518",
"0.719518",
"0.719518",
"0.71804273",
"0.7149373",
"0.7113961",
"0.7110435",
"0.7096178",
"0.70912534",
"0.70912534",
"0.7086961",
"0.70609224",
"0.7056915",
"0.7047149",
"0.70389986",
"0.7025236",
"0.6988832",
"0.69733196",
"0.6966599",
"0.69492894",
"0.69492894",
"0.6945599",
"0.69262236",
"0.69184756",
"0.69086474",
"0.6893916",
"0.6893916",
"0.6893916",
"0.6893916",
"0.6893916",
"0.6893916",
"0.6893916",
"0.6893916",
"0.68919224",
"0.68429077",
"0.6837475",
"0.6834476",
"0.6818459",
"0.67964214",
"0.6792728",
"0.6790461",
"0.6782095",
"0.6777949",
"0.6777949",
"0.677249",
"0.6759639",
"0.6727313",
"0.6725187",
"0.67142016",
"0.6712888",
"0.6703208",
"0.6702188",
"0.6699361",
"0.6698675",
"0.6692997",
"0.66839933",
"0.6679032",
"0.6673808",
"0.66590834",
"0.665644",
"0.664916",
"0.6647853",
"0.66370225",
"0.6622835",
"0.66178"
] | 0.69162565 | 59 |
============== = The runway = ============== Checks if build path exists (and cleans it up) Checks if target path exists (if not, creates it) | def validate_paths!
if self.build_path.exist?
log self, "Cleaning up previous build \"#{self.build_path}\""
rm_rf(self.build_path)
end
if !self.target_path.exist?
log self, "Creating target path \"#{self.target_path}\""
mkdir self.target_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_paths!\n ensure_clean_build_path!\n ensure_existing_target_path!\n end",
"def run!\n begin\n found = Project.find(@dir)\n rescue MissingProject\n ask_questions!\n make_directories!\n create_config!\n copy_sources!\n say color(\"Your project was created\", :green)\n say Montage::Commands::BLANK\n else\n raise Montage::ProjectExists, <<-ERROR.compress_lines\n A Montage project exists in a parent directory at\n `#{found.paths.root}'\n ERROR\n end\n end",
"def prep_build\n stdout.out_success(\"\\nPreparing build dir at: '#{settings['build_dir']}'\")\n stdout.verbose(\"Removing build dir at: #{settings['build_dir']}\")\n FileUtils.rm_rf(settings['build_dir'])\n # create the build dir\n stdout.verbose(\"Creating build dir at: #{settings['build_dir']}\")\n FileUtils.mkdir(settings['build_dir'])\n end",
"def stow_target_bin_exists?\n ::File.exist?(\"#{stow_target}/bin/stow\")\n end",
"def check_and_build_target_directory_structure(target_host, target_directory, path_to_create)\n\n unless path_to_create.nil?\n\n @log.info(\"Attempting to create '#{path_to_create}' of target directory' '#{target_host}:#{target_directory}'...\")\n\n path_to_create_parts = path_to_create.split('/')\n remote_path = []\n\n target_directory.split('/').each do | directory |\n if !directory.empty?\n directory_path = directory.start_with?('/') ? directory : \"/#{directory}\"\n remote_path << directory\n\n if path_to_create_parts.include?(directory)\n rsync(@empty_directory, \"#{target_host}:/#{remote_path.join('/')}\", false)\n end\n\n end\n end\n @log.info(\"Successfully created '#{path_to_create}' of directory structure '#{target_host}:#{target_directory}'.\")\n\n else\n @log.info(\"Not attempting to create any of remote path '#{target_directory}' on host '#{target_host}'\")\n end\n end",
"def run!\n # Validate paths\n validate_paths!\n \n # Extract mockup\n copy_source_path_to_build_path!\n \n validate_stack!\n \n # Run stack\n run_stack!\n \n # Run finalizers\n run_finalizers!\n \n # Cleanup\n cleanup! if self.config[:cleanup_build]\n \n end",
"def try_build(m)\n do_cmd(m, \"rake clean\"){ return false }\n do_rake(m){ return false }\n return true\n end",
"def build_target_path\n File.join(destination, configuration[:build_target_path])\n end",
"def setup(target)\n Dir.mkdir(target) unless File.directory?(target)\nend",
"def prepare_target_dir\n begin\n FileUtils.mkdir(@output_dir)\n copy_default_files\n rescue Errno::EEXIST\n puts \"-- #{output_dir} already exists -- canceling initialization. \"\n return\n end\n end",
"def run!\n project.mode = :release\n\n # Validate paths\n validate_paths!\n\n # Extract mockup\n copy_source_path_to_build_path!\n\n validate_stack!\n\n # Run stack\n run_stack!\n\n # Cleanup\n cleanup! if config[:cleanup_build]\n ensure\n project.mode = nil\n end",
"def run_make()\n result = false\n Dir.chdir(PATH_BUILD) do\n result = call_system_command(CMD_BUILD_MAKE)\n puts \"penguin make failed, and return #{result}.\" unless result\n end\n return result\n end",
"def makePath\n\t\t\tbuildMgr.effective(filename).dirname.mkpath\n\t\tend",
"def setup_target\n log \"Setting up #{@target}\"\n\n if File.exists? @target\n raise ArgumentError, %{Target directory \"#{@target}\" already exists}\n end\n\n FileUtils.mkdir @target\n\n run \"git init .\"\n\n # TODO: Create runner file\n end",
"def testDontBuildBuiltDependency\n setRepository('DeliverablesProcessExistingDependency') do |iRepoDir|\n runFSCMS(['Build', '--', '--target', 'TestType/TestID2/0.1/TestDeliverable'])\n assert(File.exists?(\"#{iRepoDir}/TestType/TestID1/0.1/Deliverables/TestDeliverable\"))\n assert(!File.exists?(\"#{iRepoDir}/TestType/TestID1/0.1/Deliverables/TestDeliverable/BuiltFile\"))\n lBuiltFileName = \"#{iRepoDir}/TestType/TestID2/0.1/Deliverables/TestDeliverable/BuiltFile\"\n assert(File.exists?(lBuiltFileName))\n File.open(lBuiltFileName, 'r') do |iFile|\n assert_equal([\n $FSCMSTest_RepositoryToolsDir,\n \"#{iRepoDir}/TestType/TestID1/0.1/Deliverables/TestDeliverable\"\n ], iFile.read.split(\"\\n\"))\n end\n end\n end",
"def in_build\n source_dir, build_dir = find_dirs\n FileUtils.mkdir_p(build_dir) unless File.directory?(build_dir)\n Dir.chdir build_dir do\n yield(source_dir)\n end\nend",
"def prepare_working_dir\n FileUtils.mkdir_p @working_dir unless File.directory?(@working_dir)\n FileUtils.rm_rf Dir[\"#{@working_dir}/*\"] if @force_rebuild\n end",
"def test_if_necessary\n # should return true\n assert Scripto.mkdir_if_necessary(DIR)\n assert Scripto.cp_if_necessary(SRC, DST)\n assert Scripto.ln_if_necessary(SRC, DST2)\n\n assert(File.directory?(DIR))\n assert_equal(File.read(SRC), File.read(DST))\n assert_equal(SRC, File.readlink(DST2))\n\n # should be silent\n assert_fu_output(nil, \"\") do\n assert_nil Scripto.mkdir_if_necessary(DIR)\n assert_nil Scripto.cp_if_necessary(SRC, DST)\n assert_nil Scripto.ln_if_necessary(SRC, DST2)\n end\n end",
"def build_path\n @build_path ||= \"#{@ant_path}/#{@config[:build_name]}\"\n end",
"def execute \n if(@hasExecuted==false and (not File::directory?(@newPath)))\n FileUtils.cp_r(@ogPath, @newPath)\n FileUtils::rm_r(@ogPath)\n @hasExecuted=true\n end\n end",
"def prepare\n if not File.exists?(OBS_BUILD_DIR)\n FileUtils.mkdir_p OBS_BUILD_DIR\n end\n cleanup\n end",
"def scratch_build\n begin\n distgit_pkg.build\n rescue => e\n puts \"Warning: scratch build failed: #{e}\".bold.red\n end\n end",
"def scratch_build\n begin\n distgit_pkg.build\n rescue => e\n puts \"Warning: scratch build failed: #{e}\".bold.red\n end\n end",
"def make_work_folder_if_empty\n unless Dir.exists?(WORKFOLDER)\n FileUtils.mkdir_p(WORKFOLDER)\n print_status(\"Workspace \\\"#{WORKFOLDER}\\\" created\")\n end\nend",
"def build(rakeTask)\n\t\tfilePrereqs = filePrereqs() #remove internal build-system stuff\n\t\tunless FileUtils.uptodate?(target(), filePrereqs) #the check rake does always fails because it includes a non-file prereq task\n\t\t\tstaticLibMaintainer().addOrUpdate(:lib => target(), :objs => filePrereqs)\n\t\t\tstaticLibMaintainer().index(target())\n\t\tend\n\tend",
"def verify_src_dest_dir_paths\n unless File.exists?(@era_root_dir_path) && File.directory?(@era_root_dir_path)\n STDERR.puts \"Source directory does not exist:\\n '#{@era_root_dir_path}'\"\n exit 2\n end\n if File.exists?(@era_root_dir_path_dest)\n STDERR.puts \"Destination directory or file already exists:\\n '#{@era_root_dir_path_dest}'\"\n exit 3\n end\n end",
"def test_nonexistant_files_do_not_exist\n t = Crd::Target.new BAD\n assert_equal( false, t.exists? )\n end",
"def check_build_src_file(rb_file)\n if !rb_file\n puts \"Please provide a Ruby file to build\"\n exit\n elsif !File.exists? rb_file\n puts \"Can't find file: #{rb_file}\"\n exit\n end\nend",
"def ensure_created\n unless @created\n classpath = @module_set['dso-tests-jdk15'].subtree('src').classpath(@build_results, :full, :runtime)\n puts(\"Creating boot JAR with: #{@jvm} and config file: #{@config_file}\")\n \n File.delete(path.to_s) if FileTest.exist?(path.to_s)\n sysproperties = {\n PropertyNames::TC_BASE_DIR => @static_resources.root_dir.to_s,\n PropertyNames::MODULES_URL => @build_results.modules_home.to_url\n }\n \n begin \n @ant.java(:classname => 'com.tc.object.tools.BootJarTool',\n :classpath => classpath.to_s,\n :jvm => @jvm.java,\n :fork => true,\n :failonerror => true,\n :dir => @build_results.tools_home.to_s) do\n\n sysproperties.each do |name, value|\n @ant.sysproperty(:key => name.xml_escape(true),\n :value => value.xml_escape(true))\n end\n\n @ant.arg(:value => '-o')\n @ant.arg(:value => @directory.ensure_directory)\n @ant.arg(:value => '-f')\n @ant.arg(:value => @config_file)\n @ant.arg(:value => '-q')\n end\n rescue\n raise(\"Bootjar creation failed\")\n end\n \n @created = true\n end\n self\n end",
"def globalSetup()\n # Build\n run(\"cd '#{Embedding::CODE_PATH}' && make clean && make\")\nend",
"def cd_into_test?\n !File.exist?(\"app\") && File.exist?(\"test\") &&\n (File.exist?(\"main.tf\") || File.exist?(\"main.rb\"))\n end",
"def pre_build\n puts \"pre_build dir=#{`pwd`}\"\n rbvt = RUBY_V\n rbvm = RUBY_V[/^\\d+\\.\\d+/]\n # remove leftovers from previous rake.\n rm_rf \"#{TGT_DIR}/lib\"\n rm_rf \"#{TGT_DIR}/etc\"\n rm_rf \"#{TGT_DIR}/share\"\n rm_rf \"#{TGT_DIR}/conf.d\"\n mkdir_p \"#{TGT_DIR}/lib\"\n cp_r \"#{EXT_RUBY}/lib/ruby\", \"#{TGT_DIR}/lib\"\n # copy include files\n mkdir_p \"#{TGT_DIR}/lib/ruby/include/ruby-#{rbvt}\"\n cp_r \"#{EXT_RUBY}/include/ruby-#{rbvt}/\", \"#{TGT_DIR}/lib/ruby/include\"\n SOLOCS.each_value do |path|\n cp \"#{path}\", \"#{TGT_DIR}\"\n end\n # do some windows things\n mkdir_p \"#{TGT_DIR}/share/glib-2.0/schemas\"\n if APP['GTK'] == \"gtk+-2.0\" \n cp_r\"#{TGT_SYS_DIR}/share/glib-2.0/schemas/gschema.dtd\",\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n cp_r \"#{ShoesDeps}/share/fontconfig\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/themes\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/xml\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/icons\", \"#{TGT_DIR}/share\"\n elsif APP['GTK'] == \"gtk+-3.0\"\n cp \"#{TGT_SYS_DIR}share/glib-2.0/schemas/gschemas.compiled\" ,\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n cp_r \"#{ShoesDeps}/share/fontconfig\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/themes\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/xml\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/icons\", \"#{TGT_DIR}/share\"\n else\n cp \"#{TGT_SYS_DIR}share/glib-2.0/schemas/gschemas.compiled\" ,\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n end\n sh \"#{WINDRES} -I. shoes/appwin32.rc shoes/appwin32.o\"\n cp_r \"#{ShoesDeps}/etc\", TGT_DIR\n mkdir_p \"#{ShoesDeps}/lib\"\n if APP['GTK'] == \"gtk+-3.0\"\n cp_r \"#{ShoesDeps}/lib/gtk-3.0\", \"#{TGT_DIR}/lib\" # shoes, exerb, ruby here\n else\n cp_r \"#{ShoesDeps}/lib/gtk-2.0\", \"#{TGT_DIR}/lib\" # shoes, exerb, ruby here\n end\n bindir = \"#{ShoesDeps}/bin\"\n #cp_r \"#{bindir}/fc-cache.exe\", TGT_DIR\n cp_r \"#{bindir}/gtk-update-icon-cache.exe\", TGT_DIR\n # below for debugging purposes\n if ENV['GDB'] \n cp \"#{bindir}/fc-cat.exe\", TGT_DIR\n cp \"#{bindir}/fc-list.exe\", TGT_DIR\n cp \"#{bindir}/fc-match.exe\", TGT_DIR\n cp \"#{bindir}/fc-pattern.exe\", TGT_DIR\n cp \"#{bindir}/fc-query.exe\", TGT_DIR\n cp \"#{bindir}/fc-scan.exe\", TGT_DIR\n cp \"#{bindir}/fc-validate.exe\", TGT_DIR\n end\n # disable MS Theme\n if !ENABLE_MS_THEME \n Dir.chdir(\"#{TGT_DIR}/share/themes/MS-Windows/gtk-2.0/\") do\n mv 'gtkrc', 'disabled-gtkrc'\n end\n else\n # add our overrides to the MS-Windows theme\n cp \"platform/msw/gtkrc\", \"#{TGT_DIR}/etc/gtk-2.0/\"\n end\n end",
"def setup\n @build_dir = File.join project.dir, 'build'\n unless Dir.exists? @build_dir\n Dir.mkdir @build_dir\n end\n\n task 'default' => 'build'\n\n desc 'Build the project'\n task 'build' => project.target do\n puts \"Built #{File.basename project.target}\".green\n end\n\n self.setup_target\n self.setup_source_files\n\n if project.test_target\n self.setup_test_target\n self.setup_test_files\n end\n\n desc 'Clean up build artifacts and target'\n task 'clean' do\n sh \"rm -f #{project.target}\"\n project.sources.each do |fn|\n fn = objectsify fn\n sh \"rm -f #{fn}\"\n end\n end\n \n namespace 'test' do\n desc 'Build the test target'\n task 'build' => project.test_target do\n puts \"Built #{File.basename project.test_target}\".green\n end\n desc 'Clean test build artifacts'\n task 'clean' do\n sh \"rm -f #{project.test_target}\"\n project.test_sources.each do |fn|\n fn = objectsify fn\n sh \"rm -f #{fn}\"\n end\n end\n end\n \n end",
"def test_dry_run_bug\n rakefile_dryrun\n\n rake\n\n FileUtils.rm_f \"temp_one\"\n\n rake \"--dry-run\"\n\n refute_match(/No such file/, @out)\n end",
"def configure_phase\n self.project.targets.each do |target|\n begin\n phase = target.sources_build_phase\n next unless phase\n rescue NoMethodError\n next\n end\n\n \n bundle = target.copy_bundle_recources\n\n # remove zombie build files\n phase.files_references.each do |file|\n begin\n file.real_path\n rescue\n phase.files.each do |build_file|\n phase.files.delete(build_file) if build_file.file_ref == file\n end\n end\n end\n \n # remove zombie bundle files\n bundle.files_references.each do |file|\n begin\n file.real_path\n rescue\n bundle.files.each do |bundle_file|\n bundle.files.delete(bundle_file) if bundle_file.file_ref == file\n end\n end\n end\n\n removings = [] # name of seeds going to be removed from the target\n addings = [] # name of seeds going to be added to the target\n\n self.targets.keys.sort.each do |seed_name|\n target_names = self.targets[seed_name]\n if not target_names.include?(target.name)\n removings << seed_name if not removings.include?(seed_name)\n else\n addings << seed_name if not addings.include?(seed_name)\n end\n end\n\n\n self.file_references.each do |file|\n\n removings.each do |seed_names|\n next if not seed_names.include?(file.parent.name)\n \n bundle.files.each do |bundle_file|\n bundle.files.delete(bundle_file) if bundle_file.file_ref == file \n end\n \n phase.files.each do |build_file|\n phase.files.delete(build_file) if build_file.file_ref == file\n end\n end\n\n addings.each do |seed_names|\n next if file.name.end_with? \".h\"\n next if not seed_names.include?(file.parent.name)\n uuid = Xcodeproj::uuid_with_name \"#{target.name}:#{file.name}\"\n \n if self.seeds[seed_names].resources.any? { |s| file.name.end_with? s }\n bundle.add_file_reference_with_uuid(file, uuid, true)\n else \n phase.add_file_reference_with_uuid(file, uuid, true)\n end\n\n end\n end\n end\n end",
"def execute\n if(@hasExecuted==false and (not File::exist?(@newPath)))\n FileUtils.cp(@ogPath, @newPath)\n @hasExecuted=true\n end\n end",
"def create_dir(dirName)\r\n\tif !File.directory?(dirName)\r\n\t\tFileUtils.mkdir(dirName) #creates the /build directory\r\n\tend\r\nend",
"def create_dir(dirName)\r\n\tif !File.directory?(dirName)\r\n\t\tFileUtils.mkdir(dirName) #creates the /build directory\r\n\tend\r\nend",
"def testForceBuildSingleDeliverableOnce\n setRepository('UniqueExistingDeliverable') do |iRepoDir|\n runFSCMS(['Build', '--', '--target', 'TestType/TestID/0.1/TestDeliverable', '--target', 'TestType/TestID/0.1/TestDeliverable', '--force'])\n lBuiltFileName = \"#{iRepoDir}/TestType/TestID/0.1/Deliverables/TestDeliverable/BuiltFile\"\n assert(File.exists?(lBuiltFileName))\n File.open(lBuiltFileName, 'r') do |iFile|\n assert_equal($FSCMSTest_RepositoryToolsDir, iFile.read)\n end\n end\n end",
"def output_path\n \"build\"\n end",
"def generate\n puts \"current path should be: \" + PATH_SCRIPT + \"/core\"\n result = false\n Dir.chdir(PATH_SCRIPT+\"/core\") do\n result = call_system_command(CMD_BUILD_GENERATE)\n puts \"generating source code failed, and return #{result}.\" unless result\n end\n Dir.chdir(PATH_SCRIPT+\"/is\") do\n result = system(CMD_BUILD_GENERATE)\n puts \"generating source code failed, and return #{result}.\" unless result\n end\n return result\n end",
"def build\n system(\"make build\", :chdir => self.config['destination'], :out => :err)\n end",
"def testDontBuildSingleDeliverable\n setRepository('UniqueExistingDeliverable') do |iRepoDir|\n runFSCMS(['Build', '--', '--target', 'TestType/TestID/0.1/TestDeliverable'])\n assert(File.exists?(\"#{iRepoDir}/TestType/TestID/0.1/Deliverables/TestDeliverable\"))\n assert(!File.exists?(\"#{iRepoDir}/TestType/TestID/0.1/Deliverables/TestDeliverable/BuiltFile\"))\n end\n end",
"def stow_path_bin_exists?\n ::File.exist?(\"#{stow_path}/../bin/stow\")\n end",
"def ensure_exists\n create unless Dir.exist? path\n end",
"def ensure_exists(sketch)\n puts \"Couldn't find: #{sketch}\" and exit unless FileTest.exist?(sketch)\n end",
"def make(args)\n # Maybe we should write an \"uncrustify\" fastlane action?...\n Dir.chdir '..' do\n sh 'make ' + args\n end\nend",
"def make(args)\n # Maybe we should write an \"uncrustify\" fastlane action?...\n Dir.chdir '..' do\n sh 'make ' + args\n end\nend",
"def test_copy_using_cp\n @rogerfile.release(blank: true, cleanup_build: false)\n @project.construct.file \"html/test.txt\"\n @project.release.run!\n\n build_path = @project.release.build_path\n\n assert build_path.exist?\n assert_equal 1, build_path.children.size\n assert_equal build_path + \"test.txt\", build_path.children.first\n end",
"def install!\n\t\t\traise \"Target exists\" if target.present?\n\n\t\t\t# Directory entry - create the directory\n\t\t\ttarget.mkpath\n\t\tend",
"def ensure_directory_exists\r\n dir = File.dirname(full_path_from_current_attributes)\r\n FileUtils.mkdir_p(dir) unless File.exists?(dir)\r\n end",
"def build_to_temp_dir\n @builder.build_project\n\n # Copy build files to temporary directory\n @task.shell.mute do\n @task.directory @project.build_path, ::File.join(@project.package_path, @package_name), :force => true\n end\n end",
"def build()\n \n #check dir exists, if not, make it\n if(!File.exists?(@path))\n Dir.mkdir(@path)\n end\n \n #build directory structure\n puts 'Building directory structure'\n build_skeleton(@template.directory_structure)\n \n #execute build tasks\n puts 'Running build tasks'\n execute_tasks(@template.tasks,@template.path)\n \n puts 'Skeleton built'\n \n end",
"def check_or_create_working_dir\n unless Dir.exists?(@working_directory)\n if File.writable?(@working_directory.split(\"/\")[0...-1].join(\"/\"))\n Dir.mkdir(@working_directory)\n return true if Dir.exists?(@working_directory)\n end\n end\n Loggers::Main.log.warn \"Creation of #{@working_directory} failed!\"\n end",
"def testBuildSingleDeliverable_ObjectPath\n setRepository('UniqueDeliverable') do |iRepoDir|\n runFSCMS(['Build', '--', '--target', 'TestType/TestID'])\n lBuiltFileName = \"#{iRepoDir}/TestType/TestID/0.1/Deliverables/TestDeliverable/BuiltFile\"\n assert(File.exists?(lBuiltFileName))\n File.open(lBuiltFileName, 'r') do |iFile|\n assert_equal($FSCMSTest_RepositoryToolsDir, iFile.read)\n end\n end\n end",
"def create_build_directories\n root_dir = generate_build_location(\"\")\n Dir.mkdir root_dir unless Dir.exists?(root_dir)\n img_dir = generate_image_location(\"\",\"\").split(\"/\")[0...-1].join(\"/\")\n Dir.mkdir img_dir unless Dir.exists?(img_dir)\n end",
"def run\n unless !@valid_name || File.exists?(@project_name) || File.directory?(@project_name)\n $stdout.puts \"Creating goliath application under the directory #{@project_name}\"\n FileUtils.mkdir @project_name\n \n create_base_dirs\n copy_files_to_target\n setup_api_module\n copy_files_to_dir 'application.rb','config'\n copy_files_to_dir 'database.yml','config'\n $stdout.puts \"\\e[1;32m \\trun\\e[0m\\tbundle install\"\n Dir.chdir(\"#{@project_name}\")\n system(\"bundle install\")\n else \n unless !@valid_name\n $stdout.puts \"\\e[1;31mError:\\e[0m The directory #{@project_name} already exists, aborting. Maybe move it out of the way before continuing.\"\n end\n end\n end",
"def setup_path\n # The Java Buildpack for WLS creates the complete domain structure and other linkages during staging.\n # The directory used for staging is at /tmp/staged/app\n # But the actual DEA execution occurs at /home/vcap/app. This discrepancy can result in broken paths and non-startup of the server.\n # So create linkage from /tmp/staged/app to actual environment of /home/vcap/app when things run in real execution\n # Also, this script needs to be invoked before starting the server as it will create the links and also tweak the server args\n # (to listen on correct port, use user supplied jvm args)\n\n File.open(@application.root.to_s + '/' + SETUP_ENV_SCRIPT, 'w') do |f|\n\n f.puts '#!/bin/sh '\n f.puts '# There are 4 things handled by this script '\n f.puts ' '\n f.puts '# 1. Create links to mimic staging env and update scripts with jvm options '\n f.puts '# The Java Buildpack for WLS creates complete domain structure and other linkages during staging at '\n f.puts '# /tmp/staged/app location '\n f.puts '# But the actual DEA execution occurs at /home/vcap/app. '\n f.puts '# This discrepancy can result in broken paths and non-startup of the server. '\n f.puts '# So create linkage from /tmp/staged/app to actual environment of /home/vcap/app when things run in real execution '\n f.puts '# Create paths that match the staging env, as otherwise scripts will break!! '\n f.puts ' '\n f.puts 'if [ ! -d \\\"/tmp/staged\\\" ]; then '\n f.puts ' /bin/mkdir /tmp/staged '\n f.puts 'fi; '\n f.puts 'if [ ! -d \\\"/tmp/staged/app\\\" ]; then '\n f.puts ' /bin/ln -s `pwd` /tmp/staged/app '\n f.puts 'fi; '\n f.puts ' '\n f.puts ' '\n end\n end",
"def build_path\n Pathname.new(config[:build_path])\n end",
"def testForceBuildSingleDeliverable\n setRepository('UniqueExistingDeliverable') do |iRepoDir|\n runFSCMS(['Build', '--', '--target', 'TestType/TestID/0.1/TestDeliverable', '--force'])\n lBuiltFileName = \"#{iRepoDir}/TestType/TestID/0.1/Deliverables/TestDeliverable/BuiltFile\"\n assert(File.exists?(lBuiltFileName))\n File.open(lBuiltFileName, 'r') do |iFile|\n assert_equal($FSCMSTest_RepositoryToolsDir, iFile.read)\n end\n end\n end",
"def buildwise_run_sequential_build_target(build_id, task_name) \r\n begin\r\n FileUtils.rm_rf(\"spec/reports\") if File.exist?(\"spec/reports\")\r\n Rake::Task[task_name].invoke\r\n ensure\r\n puts \"Finished: Notify build status\"\r\n sleep 2 # wait a couple of seconds to finish writing last test results xml file out\r\n puts \"[Rake] finish the build\"\r\n buildwise_finish_build(build_id)\r\n end\r\nend",
"def create_target?\n !(project.initialize_with_readme && target_branch == project.default_branch) && target_new_branch\n end",
"def build(rakeTask)\n\t\t#we've called ourselves after updating prereqs and running them; now do our work\n\t\t\n\t\tfilePrereqs = filePrereqs() #remove internal build-system stuff\n\t\tunless FileUtils.uptodate?(target(), filePrereqs) #the check rake does always fails because it includes non-file prereq tasks, so do our own\n\t\t\tlinker().link(:objs => linkDepsOrdered(), :target => target())\n\t\tend\n\tend",
"def build_path\n Pathname.new(self.config[:build_path]) \n end",
"def create_project(invocation_path, arg_app_name, quiet = false, gem_path = nil)\n root_path = File.join(invocation_path, arg_app_name)\n FileUtils.mkpath(root_path)\n puts \"(in #{invocation_path})\" unless quiet\n puts \" created directory: #{arg_app_name}\" unless quiet\n create_app_structure(root_path, arg_app_name, quiet, gem_path)\n puts '' unless quiet\n puts 'Done!' unless quiet\n\n root_path\n end",
"def run_stage_one \n\t# directory tools is needed by stage on, be sure it does not exist yet\n\tif File.exists?(\"/tools\")\n\t\tputs sprintf(\"%015.4f\", Time.now.to_f) + \" error > EXIT! Directory or softlink /tools already exists\"\n\t\tputs sprintf(\"%015.4f\", Time.now.to_f) + \" error > Too risky for me to continue. Remove /tools, then\"\n\t\tputs sprintf(\"%015.4f\", Time.now.to_f) + \" error > try again.\"\n\t\t$stdout.flush\n\t\traise \"SoftlinkAlreadyThere\"\n\tend\n\t# File.symlink(@builddir + \"/stage01/chroot/tools\", \"/tools\")\n\tsystem(\"mkdir /tools\")\n\tsystem(\"mkdir -p \" + @builddir + \"/stage01/chroot/tools\")\n\tsystem(\"mount -o bind \" + @builddir + \"/stage01/chroot/tools /tools\")\n\t[ \"/stage01\", \"/stage01/build\",\"/stage01/chroot\",\"/stage01/chroot/tools\", \"/tmp\" ].each { |d|\n\t\tunless File.exists?(@builddir + d)\n\t\t\tDir.mkdir(@builddir + d)\n\t\tend\n\t}\n\t# Stage 01 abfrühstücken\n\t# Alle Scripte in stage01 suchen\n\tstage_one_objs = get_stage_one_objs\n\t# Download first\n\tstage_one_objs.each { |i| i.download }\n\t# Unpack\n\tstage_one_objs.each { |i|\n\t\ti.unpack\n\t\t### Dir.chdir(@workdir)\n\t\ti.patch(@log_each)\n\t\t### Dir.chdir(@workdir)\n\t\ti.build(@log_each)\n\t\t### Dir.chdir(@workdir)\n\t\ti.install(@log_each)\n\t\t### Dir.chdir(@workdir)\n\t\ti.filecheck\n\t\t### Dir.chdir(@workdir)\n\t}\n\tsystem(\"umount /tools\")\nend",
"def testBuildProcessDirDependency\n setRepository('DeliverablesProcessDependency') do |iRepoDir|\n runFSCMS(['Build', '--', '--target', 'TestType/TestID2/0.2/TestDeliverable'])\n lBuiltFileName = \"#{iRepoDir}/TestType/TestID1/0.1/Deliverables/TestDeliverable/BuiltFile\"\n assert(File.exists?(lBuiltFileName))\n File.open(lBuiltFileName, 'r') do |iFile|\n assert_equal($FSCMSTest_RepositoryToolsDir, iFile.read)\n end\n lBuiltFileName = \"#{iRepoDir}/TestType/TestID2/0.2/Deliverables/TestDeliverable/BuiltFile\"\n assert(File.exists?(lBuiltFileName))\n File.open(lBuiltFileName, 'r') do |iFile|\n assert_equal(\"#{iRepoDir}/TestType/TestID1/0.1/Deliverables/TestDeliverable\", iFile.read)\n end\n end\n end",
"def clean\n needs_cleaning = File.exist?(project_dir)\n if needs_cleaning\n log.info(log_key) { \"Cleaning project directory `#{project_dir}'\" }\n FileUtils.rm_rf(project_dir)\n end\n create_required_directories\n deploy\n needs_cleaning\n end",
"def testBuildSingleDeliverableOnce\n setRepository('UniqueDeliverable') do |iRepoDir|\n runFSCMS(['Build', '--', '--target', 'TestType/TestID/0.1/TestDeliverable', '--target', 'TestType/TestID/0.1/TestDeliverable'])\n lBuiltFileName = \"#{iRepoDir}/TestType/TestID/0.1/Deliverables/TestDeliverable/BuiltFile\"\n assert(File.exists?(lBuiltFileName))\n File.open(lBuiltFileName, 'r') do |iFile|\n assert_equal($FSCMSTest_RepositoryToolsDir, iFile.read)\n end\n end\n end",
"def find_or_create_destination_folder\n Dir.mkdir(HTML_RESULT_FOLDER) if !Dir.exists?HTML_RESULT_FOLDER\n end",
"def check_dest_dir\n dir = File.dirname absolute_filename\n FileUtils.mkdir_p(dir) unless Dir.exist?(dir)\n end",
"def testBuildSingleDeliverableHierarchicalID_ObjectPath\n setRepository('UniqueDeliverableHierarchicalID') do |iRepoDir|\n runFSCMS(['Build', '--', '--target', 'TestType/TestID/SubTestID/SubSubTestID'])\n lBuiltFileName = \"#{iRepoDir}/TestType/TestID/SubTestID/SubSubTestID/0.1/Deliverables/TestDeliverable/BuiltFile\"\n assert(File.exists?(lBuiltFileName))\n File.open(lBuiltFileName, 'r') do |iFile|\n assert_equal($FSCMSTest_RepositoryToolsDir, iFile.read)\n end\n end\n end",
"def touch_directory(path, opt={})\n unless File.exists? path\n FileUtils.mkdir_p path\n STDOUT.write \"Created #{path.relative_to_project_root}\\n\".color(:green) unless opt[:quiet]\n end\n nil\n end",
"def destination_file_up_to_date?\n return false unless compilation_context.incremental_build?\n\n source_db = compilation_context.source_file_database\n target_db = compilation_context.target_file_database\n\n destination_file_exist? && # destination file must exist\n target_db.up_to_date?(source_path) && # source file must be up-to-date from last build of this target\n source_db.file_stat_for(source_path) == target_db.file_stat_for(source_path)\n end",
"def make\n @this_version = extract_version\n check\n with_release_candidate_version do |release_candidate_buildfile|\n args = []\n args << 'buildr' << '--buildfile' << release_candidate_buildfile\n args << '--environment' << Buildr.environment unless Buildr.environment.to_s.empty?\n args << 'clean' << 'upload' << 'DEBUG=no'\n sh *args\n end\n tag_release resolve_tag\n update_version_to_next if this_version != resolve_next_version(this_version)\n end",
"def build_here\n cp_a File.join(root_dir, \"test\", \"setup\", \"#{name}.svn.gz\"), \".\"\n\n puts `gzip -f -d #{name}.svn.gz`\n raise unless $? == 0\n puts `svnadmin create #{name}`\n raise unless $? == 0\n puts `svnadmin load #{name} < #{name}.svn`\n raise unless $? == 0\n end",
"def build\n if phase.has_key?('build')\n execute(\"build\", phase['build'])\n end\n end",
"def archive_build_if_necessary(target_directory)\n # Nothing here in superclass\n end",
"def prepare(module_name, version)\n return if @target.directory?\n\n begin\n @target.mkpath\n Puppet.notice _(\"Created target directory %{dir}\") % { dir: @target }\n rescue SystemCallError => orig_error\n raise converted_to_friendly_error(module_name, version, orig_error)\n end\n end",
"def maybe_build\n return unless @last_notice_at\n if time_to_build?\n UI.info \"Tishadow building at #{Time.now} with \\\"#{@build_command}\\\"\"\n run_or_update\n clear_notified\n stop_clock\n end\n end",
"def ensure_fastfile\n return true if FastlaneCore::FastlaneFolder.setup?\n\n create = UI.confirm('Could not find fastlane in current directory. Make sure to have your fastlane configuration files inside a folder called \"fastlane\". Would you like to set fastlane up?')\n if create\n Fastlane::Setup.start\n end\n return false\n end",
"def create_folder_if_needed path; Dir.mkdir(path) unless File.exists?(path) end",
"def build_root\n Pathname.new(ENV[\"OBJDIR\"] || \"build\")\n end",
"def setup_carthage_env(current_dir)\n # mkdir if folder is NOT existed.\n %W(#{current_dir}/Carthage #{current_dir}/Carthage/.tmp #{current_dir}/Carthage/Checkouts #{current_dir}/Carthage/Build #{current_dir}/Carthage/Repo).each do |each_path|\n FileUtils.mkdir_p each_path.to_s unless File.exist? each_path.to_s\n end\nend",
"def check_dest_dir\n FileUtils.mkdir_p(dest_dir) unless Dir.exist?(dest_dir)\n end",
"def setup(build, launcher, listener, env)\n ignored_paths = @ignored_paths.split(',').collect { |p| p.strip }\n listener.info \"Ignoring paths: #{ignored_paths.inspect}\"\n\n begin\n changeset = build.native.getChangeSet()\n # XXX: Can there be files in the changeset if it's manually triggered?\n # If so, how do we check for manual trigger?\n if changeset.isEmptySet()\n listener.info \"Empty changeset, running build.\"\n return\n end\n\n changeset.each do |change|\n change.getAffectedPaths().each do |path|\n\n # For each path we see if at least one ignore matches, and ignore this\n # file if that's the case.\n should_ignore = false\n ignored_paths.each do |ignore|\n if File.fnmatch(ignore, path)\n should_ignore = true\n break\n end\n end\n\n # If file isn't ignored, we keep on truckin', i.e. run the build.\n if not should_ignore\n listener.info \"Found non-ignored file change, running build.\"\n return\n end\n end\n end\n rescue\n listener.error \"Encountered exception when scanning for ignored paths: #{$!}\"\n end\n\n # We only get here if no unignored file was touched, so skip build.\n listener.info \"All files ignored, skipping build.\"\n build.native.setResult(Java.hudson.model.Result::NOT_BUILT)\n build.halt(\"Build not needed.\")\n end",
"def run!\n # Ensure the package directory exists and is purged\n purge_directory(package_dir)\n\n instance_eval(&self.class.setup) if self.class.setup\n instance_eval(&self.class.validate) if self.class.validate\n instance_eval(&self.class.build) if self.class.build\n instance_eval(&self.class.clean) if self.class.clean\n\n # Ensure the temporary directory is removed at the end of a successful\n # run. Without removal, successful builds will \"leak\" in /tmp and cause\n # increased disk usage.\n #\n # Instead of having this as an +ensure+ block, failed builds will persist\n # this directory so developers can go poke around and figure out why the\n # build failed.\n remove_directory(staging_dir)\n end",
"def build_path\n @build_path ||= Pathname.new(source_dir).join(data['build_path'] || './build').to_s\n end",
"def build\n\t@built_gem_path ||= @helper.build_gem\nend",
"def testBuildSingleDeliverable_VersionedObjectPath\n setRepository('UniqueDeliverable') do |iRepoDir|\n runFSCMS(['Build', '--', '--target', 'TestType/TestID/0.1'])\n lBuiltFileName = \"#{iRepoDir}/TestType/TestID/0.1/Deliverables/TestDeliverable/BuiltFile\"\n assert(File.exists?(lBuiltFileName))\n File.open(lBuiltFileName, 'r') do |iFile|\n assert_equal($FSCMSTest_RepositoryToolsDir, iFile.read)\n end\n end\n end",
"def setup\n return unless git?\n\n Dir.chdir source_path do\n\n path = clone\n\n Dir.chdir path do\n\n if name = build then\n file = File.expand_path name\n\n # private instance variable. When this is set Entry#install looks\n # for a local file instead of trying to download by name\n @entry.instance_variable_set :@file, file\n end\n\n end if path\n\n end\n end",
"def compile(build_folder, check: false, write: false, release: false, verbose: false, use_cache: true)\n @file_resolver = FileResolver.new(Config.instance.project_path, build_folder)\n compilation_context.file_resolver = @file_resolver\n compilation_context.should_check = check\n compilation_context.should_write = write\n compilation_context.release_build = release\n compilation_context.verbose = verbose\n compilation_context.use_cache = use_cache\n\n self.class.globals_tracker.catch do\n @build_folder = build_folder\n\n FileUtils.mkdir_p(build_folder)\n\n puts \" handling target #{@target.name.inspect} in build dir `#{Config.instance.pretty_path_from_project(build_folder)}`\"\n\n file_resolver.add_file(FileTypes::SourceFile.new(Config.instance.pretty_path_from_project(@book.file_path).to_s))\n compilation_context.plugins\n\n parse_toc_item(@target.root_toc)\n parse_target_file_requests\n\n process_all_target_files\n generate_other_files\n\n # build folder cleanup\n remove_unnecessary_files\n remove_empty_folders\n\n source_paths = file_resolver.files.select { |a| a.is_a?(FileTypes::SourceFile) }.map { |a| a.source_path }\n compilation_context.source_file_database.cleanup(source_paths)\n compilation_context.source_file_database.update_all_metadata\n compilation_context.source_file_database.save_to_file\n\n compilation_context.target_file_database.cleanup(source_paths)\n compilation_context.target_file_database.update_all_metadata\n compilation_context.target_file_database.save_to_file\n end\n ensure\n self.class.globals_tracker.clear_all\n end",
"def make_output_dir (src_path)\n delete_all_files(src_path) if directory_exists?(src_path) == true\n Dir.mkdir(src_path)\nend",
"def test_build_no_install\n result = Sprout::Builder.build(@manual_spec, @fixture)\n assert_equal('swfmill', result.executable)\n end",
"def __path__\n File.join(root, 'tmp', 'build')\n end",
"def is_built(module_instance)\n unless module_instance.type.to_sym == :servicebuilder or module_instance.type.to_sym == :ext\n file = File.join(module_instance.path, \"target/#{module_instance.name}-#{Rays::Project.instance.version}.war\")\n File.exist?(file)\n else\n !Rays::Utils::FileUtils.find_down(module_instance.path, /.*\\.war$/).empty?\n end\n end",
"def run(args) # :nodoc\n if args.size > 1\n path = File.expand_path(args[1])\n settings[:directory] = \"#{path}:#{settings[:directory]}\"\n msg \"Source directories searched: #{settings[:directory]}\"\n else\n if confirm('Reintialize source path to empty?', false)\n settings[:directory] = '$cdir:$cwd'\n msg 'Source directories searched: $cdir:$cwd'\n end\n end\n end",
"def within_build_path(&block)\n Dir.chdir app.config.build_dir do\n yield\n end\n end",
"def target_missing(target)\n raise RuntimeError, \"No target named '%s' exists in this build file.\" % target\n end",
"def run_build?\n ENV['BUILD_ASSETS'].to_s == 'true' ||\n build_files.blank? ||\n src_files.select { |f| File.mtime(f) >= File.mtime(cache_file) }.any?\n end"
] | [
"0.6355052",
"0.61925346",
"0.61658",
"0.61321163",
"0.59300494",
"0.5910512",
"0.5828241",
"0.58250076",
"0.5792434",
"0.5781954",
"0.57324976",
"0.5732147",
"0.57173246",
"0.56891644",
"0.5680433",
"0.567948",
"0.5657562",
"0.5652249",
"0.5642904",
"0.56353575",
"0.5631985",
"0.56094426",
"0.56094426",
"0.5598741",
"0.5585745",
"0.5577385",
"0.5570461",
"0.55671567",
"0.55508155",
"0.55446506",
"0.55380785",
"0.5528921",
"0.5528812",
"0.5524958",
"0.5524151",
"0.55162424",
"0.5504795",
"0.5504795",
"0.55038667",
"0.54994774",
"0.5487612",
"0.5477947",
"0.54744035",
"0.5471532",
"0.5465486",
"0.54610264",
"0.54605514",
"0.54605514",
"0.54591936",
"0.5457947",
"0.54421675",
"0.54350096",
"0.54347336",
"0.5413437",
"0.5406882",
"0.5393972",
"0.5389842",
"0.53778034",
"0.5376271",
"0.5366964",
"0.53585374",
"0.53540754",
"0.5351554",
"0.5351171",
"0.53511554",
"0.5341257",
"0.53400666",
"0.5334071",
"0.5332044",
"0.53297853",
"0.53201246",
"0.53117007",
"0.5310674",
"0.5306015",
"0.53044224",
"0.5302214",
"0.5293256",
"0.52931964",
"0.5292897",
"0.52890563",
"0.52826804",
"0.5276861",
"0.5273495",
"0.52719927",
"0.52462935",
"0.5243937",
"0.52419394",
"0.52309257",
"0.52151227",
"0.52149874",
"0.5201246",
"0.51963675",
"0.5195913",
"0.51949537",
"0.51885307",
"0.5185395",
"0.51831985",
"0.5182359",
"0.5176995",
"0.5174992"
] | 0.6942448 | 0 |
Checks if deprecated extractor options have been set Checks if the mockup will be runned | def validate_stack!
mockup_options = {}
relativizer_options = {}
run_relativizer = true
if @extractor_options
mockup_options = {:env => @extractor_options[:env]}
relativizer_options = {:url_attributes => @extractor_options[:url_attributes]}
run_relativizer = @extractor_options[:url_relativize]
end
unless @stack.find{|(processor, options)| processor.class == HtmlMockup::Release::Processors::Mockup }
@stack.unshift([HtmlMockup::Release::Processors::UrlRelativizer.new, relativizer_options])
@stack.unshift([HtmlMockup::Release::Processors::Mockup.new, mockup_options])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def completely_deprecated?\n @deprecated == :completely\n end",
"def deprecated?\n false\n end",
"def handle_deprecations\n DEPRECATED_KEYS.each do |old, new|\n next unless @options.key?(old)\n\n lock_config.errors[old] = \"is deprecated, use `#{new}: #{@options[old]}` instead.\"\n end\n end",
"def warn_for_deprecations\n deprecated_pods = root_specs.select do |spec|\n spec.deprecated || spec.deprecated_in_favor_of\n end\n deprecated_pods.each do |spec|\n if spec.deprecated_in_favor_of\n UI.warn \"#{spec.name} has been deprecated in \" \\\n \"favor of #{spec.deprecated_in_favor_of}\"\n else\n UI.warn \"#{spec.name} has been deprecated\"\n end\n end\n end",
"def change_deprecation_iff_user_requested\n return nil unless @name.deprecated != (params[:name][:deprecated] == \"true\")\n\n [email protected]\n end",
"def deprecated?\n superseded_by.present?\n end",
"def view_with_check_option_support\n # :nocov:\n :local if server_version >= 90400\n # :nocov:\n end",
"def deprecated?\n parsed {\n @status == 'Deprecated'\n }\n end",
"def assert_not_deprecated(deprecator = nil, &block)\n result, deprecations = collect_deprecations(deprecator, &block)\n assert deprecations.empty?, \"Expected no deprecation warning within the block but received #{deprecations.size}: \\n #{deprecations * \"\\n \"}\"\n result\n end",
"def issue_deprecations\n Pkg::Params::DEPRECATIONS.each do |v|\n if self.instance_variable_get(\"@#{v[:var]}\")\n warn v[:message]\n end\n end\n end",
"def deprecated?\n comment.include?(\"(Deprecated)\")\n end",
"def silence_deprecations; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def warn_on_deprecations_used(deprecations_used)\n deprecations_used.each do |deprecator, deprecatee|\n @warnings << \"#{deprecatee}: is deprecated by '#{deprecator}'\"\n end\n end",
"def verify_options_hook; end",
"def disabled?\n deprecated? || deleted?\n end",
"def extract(options = {})\n self.warn(self, \"Don't use the extractor anymore, use release.use(:mockup, options) and release.use(:url_relativizer, options) processors\")\n @extractor_options = options\n end",
"def _validate_deprecated_in_favor_of(d)\n if spec.root.name == Specification.root_name(d)\n results.add_error('deprecated_in_favor_of', 'a spec cannot be ' \\\n 'deprecated in favor of itself')\n end\n end",
"def deprecated_disabled_configured?\n return false if self.name.nil?\n\n key = \"disable_#{self.name}\".to_sym\n return false unless ::NewRelic::Agent.config[key] == true\n\n ::NewRelic::Agent.logger.debug(\"Not installing #{self.name} instrumentation because of configuration #{key}\")\n ::NewRelic::Agent.logger.debug( \\\n \"[DEPRECATED] configuration #{key} for #{self.name} will be removed in the next major release. \" \\\n \"Use `#{config_key}` with one of `#{VALID_CONFIG_VALUES.map(&:to_s).inspect}`\"\n )\n\n return true\n end",
"def deprecation_warnings\n text = @file.read\n deprecations = []\n deprecations << \"`config.ios?' and `config.osx?' are deprecated\" if text. =~ /config\\..?os.?/\n deprecations << \"clean_paths are deprecated and ignored (use preserve_paths)\" if text. =~ /clean_paths/\n deprecations\n end",
"def handle_deprecations(opts_in, &block)\n opts = opts_in.dup\n\n # Determine the default expectation\n opts[:all_others] = opts.delete(:all) if opts.key?(:all) && opts.count == 1\n expectations = {}\n expectations[:all_others] = opts.delete(:all_others) || :tolerate\n expectations.merge!(opts)\n\n # Expand the list of deprecation groups given\n known_group_names = Inspec::Deprecation::ConfigFile.new.groups.keys\n known_group_names.each do |group_name|\n next if opts.key?(group_name)\n\n expectations[group_name] = expectations[:all_others]\n end\n\n # Wire up Insepc.deprecator accordingly using mocha stubbing\n expectations.each do |group_name, expectation|\n inst = Inspec::Deprecation::Deprecator.any_instance\n case expectation\n when :tolerate\n inst.stubs(:handle_deprecation).with(group_name, anything, anything)\n when :expect_something\n inst.stubs(:handle_deprecation).with(group_name, anything, anything).at_least_once\n when :expect_warn\n inst.stubs(:handle_warn_action).with(group_name, anything).at_least_once\n when :expect_fail\n inst.stubs(:handle_fail_control_action).with(group_name, anything).at_least_once\n when :expect_ignore\n inst.stubs(:handle_ignore_action).with(group_name, anything).at_least_once\n when :expect_exit\n inst.stubs(:handle_exit_action).with(group_name, anything).at_least_once\n end\n end\n\n yield\nend",
"def has_warnings?\n @has_warnings ||= false\n end",
"def check_for_missing_enabled_option(hash); end",
"def verify_unused(names) # :nodoc:\n names.each do |name|\n verify_unused_in_option(name,flags,\"flag\")\n verify_unused_in_option(name,switches,\"switch\")\n end\n end",
"def assert_valid_options\n valid_options = {\n skip_gemfile: false,\n skip_bundle: false,\n skip_git: false,\n skip_system_test: false,\n # skip_test: false,\n # skip_test_unit: false,\n edge: false\n }\n valid_options.each do |key, expected|\n next unless options.key?(key)\n actual = options[key]\n unless actual == expected\n fail Rails::Generators::Error, \"Unsupported option: #{key}=#{actual}\"\n end\n end\nend",
"def find_deprecations(config)\n deprecated = false\n if config.key?('editor')\n deprecated = true\n config['editors']['default'] ||= config['editor']\n config.delete('editor')\n Doing.logger.debug('Deprecated:', \"config key 'editor' is now 'editors.default', please update your config.\")\n end\n\n if config.key?('config_editor_app') && !config['editors']['config']\n deprecated = true\n config['editors']['config'] = config['config_editor_app']\n config.delete('config_editor_app')\n Doing.logger.debug('Deprecated:',\n \"config key 'config_editor_app' is now 'editors.config', please update your config.\")\n end\n\n if config.key?('editor_app') && !config['editors']['doing_file']\n deprecated = true\n config['editors']['doing_file'] = config['editor_app']\n config.delete('editor_app')\n Doing.logger.debug('Deprecated:',\n \"config key 'editor_app' is now 'editors.doing_file', please update your config.\")\n end\n\n Doing.logger.warn('Deprecated:', 'outdated keys found, please run `doing config --update`.') if deprecated\n config\n end",
"def setup?\n @options\n end",
"def setup?\n @options\n end",
"def raise_deprecations; end",
"def assert_valid_options\n valid_options = {\n :skip_gemfile => false,\n :skip_bundle => false,\n :skip_git => false,\n :skip_test_unit => false,\n :edge => false\n }\n valid_options.each do |key, expected|\n next unless options.key?(key)\n actual = options[key]\n unless actual == expected\n fail Rails::Generators::Error, \"Unsupported option: #{key}=#{actual}\"\n end\n end\nend",
"def tolerate_all_deprecations(&block)\n handle_deprecations(all: :tolerate, &block)\nend",
"def assert_valid_options\n valid_options = {\n skip_gemfile: false,\n skip_bundle: false,\n skip_git: false,\n skip_system_test: false,\n skip_test: false,\n skip_test_unit: false,\n edge: false\n }\n valid_options.each do |key, expected|\n next unless options.key?(key)\n actual = options[key]\n unless actual == expected\n fail Rails::Generators::Error, \"Unsupported option: #{key}=#{actual}\"\n end\n end\nend",
"def valid_opts\n true\n end",
"def check_option_support\n assert_option_supported(:foodcritic) &&\n assert_option_supported(:scmversion, 'thor-scmversion') &&\n assert_default_supported(:no_bundler, 'bundler')\n end",
"def silence_deprecations=(_arg0); end",
"def warnings?\n !gem?(\"shelly-dependencies\") || gem?(\"shelly\")\n end",
"def disabled_warnings; end",
"def assert_valid_options\n valid_options = {\n skip_gemfile: false,\n skip_git: false,\n skip_test_unit: false,\n edge: false\n }\n valid_options.each do |key, expected|\n next unless options.key?(key)\n actual = options[key]\n unless actual == expected\n fail Rails::Generators::Error, \"Unsupported option: #{key}=#{actual}\"\n end\n end\nend",
"def extractable_options?; true end",
"def bypass_maintenance?\n !!runopts(:bypass_maintenance)\n end",
"def unused_options\n parser.unused_options\n end",
"def verify_unused(names,flags,switches,context) # :nodoc:\n names.each do |name|\n verify_unused_in_option(name,flags,\"flag\",context)\n verify_unused_in_option(name,switches,\"switch\",context)\n end\n end",
"def report\n deprecations = @messages.select { |m| m[:kind] == :deprecation }\n\n if deprecations.any?\n puts\n puts \"Deprecations:\"\n puts\n\n messages = deprecations.map { |m| m[:message] }\n puts messages.join(\"\\n---\\n\\n\")\n puts\n end\n\n # code blocks in chef report callbacks are expected to yield true\n true\n end",
"def needed_if_relevant?\n false\n end",
"def _warn_deprecated_keys(updates)\n _warn_deprecated_key(:unless, updates) if updates.has_key?(:unless)\n _warn_deprecated_key(:if, updates) if updates.has_key?(:if)\n end",
"def needed_if_relevant?\n false\n end",
"def warnings?\n !gem?(\"shelly-dependencies\")\n end",
"def verify_options_hook=(_arg0); end",
"def options_ok?\n end",
"def view_with_check_option_support\n true\n end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def check_for_invalid_deprecations\n schema[:internals].each do |param_key,param_schema|\n deprecated_by = param_schema[:deprecated_by]\n if deprecated_by && !schema[:internals].key?(deprecated_by.to_sym)\n raise \"#{param_key}: deprecated_by target '#{deprecated_by}' not found in schema\"\n end\n end\n end",
"def use_instead\n obsolete? ? @use_instead : nil\n end",
"def test_depth\n begin\n require 'structured_warnings'\n assert_warn(DeprecatedMethodWarning) { do_deprecated_depth }\n rescue LoadError\n # Since the structued_warnings package is not present, we revert to good old Kernel#warn behavior.\n do_deprecated_depth\n end\n end",
"def legacy?\n false\n end",
"def options_parsed?\n opts = OptionParser.new() do |o|\n o.on('-v','--version') { output_version($stdout); exit(0) }\n o.on('-h','--help') { output_help($stdout); exit(0) }\n o.on('-V', '--verbose') { @options.verbose = true }\n o.on('-D', '--debug') { @options.debug = true }\n o.on('-l', '--local') { @options.run_local = true }\n\n o.on(\"-d\",\"--delay\", \"=REQUIRED\") do |amount|\n @options.delay = amount.to_i\n end\n\n o.on(\"-c\",\"--config\", \"=REQUIRED\") do |conf_file|\n @options.config_file = conf_file\n end\n\n o.on(\"-o\",\"--output\", \"=REQUIRED\") do |output_destination|\n @options.output_base = output_destination\n end\n\n o.on(\"-s\",\"--scheduler\", \"=REQUIRED\") do |qopts|\n @options.scheduler_opts = qopts\n end\n\n o.on(\"-t\",\"--tmp\", \"=REQUIRED\") do |topts|\n @options.tmp_dir_base = topts\n end\n end\n\n opts.parse!(@args) rescue return false\n @options.samples = @args\n return true\nend",
"def deprecated?\n self[:slug].nil?\n end",
"def obsolete\n config.obsolete || false\n end",
"def check_useful_options(result, expected, error_message)\r\n i =0\r\n expected.each do |option|\r\n assert(option[0]==result[i][0], error_message)\r\n assert(option[1]==result[i][1], error_message)\r\n i+=1\r\n end\r\n end",
"def allowed_on_commandline?\n @deprecated == :allowed_on_commandline\n end",
"def check_module_deprecated(module_name)\n module_name = module_name.sub('/', '-')\n module_data = get_module_data(module_name)\n version = get_current_version(module_name)\n version.to_s.eql?('999.999.999') || version.to_s.eql?('99.99.99') || !module_data.attribute('deprecated_at').nil?\n end",
"def deprecated\n attributes.fetch(:deprecated)\n end",
"def deprecated\n attributes.fetch(:deprecated)\n end",
"def no_user_opts?\n !(opts[:methods] || opts['instance-methods'] || opts[:ppp] ||\n opts[:globals] || opts[:locals] || opts[:constants] || opts[:ivars])\n end",
"def extractable_options?; end",
"def unrecognized_option(err); end",
"def auto_detected?\n DatabaseCleaner.deprecate \"Calling `DatabaseCleaner[...].auto_detected?` is deprecated, and will be removed in database_cleaner 2.0 with no replacement.\"\n @orm_autodetector.autodetected?\n end",
"def warning?\n check_warnings\n end",
"def use?(opts)\n !(opts.keys & @takes).empty?\n end",
"def should_remove_librun_and_stc_sources\n !(core_developer? or ENV['RETAIN_STX_AND_LIBRUN_SOURCE'] == 'yespleaseretain!')\nend",
"def view_with_check_option_support\n nil\n end",
"def test_add_option02d\n assert_raise( RuntimeError ) { \n ArgumentManager.add_option(\n [ 'f' ],\n :bind => 'boolean opt'\n )\n }\n end",
"def determine_useful_validations\n useful_checks = [\n useful_validations_for_qrda_type,\n useful_validations_for_measure_type\n # TODO: Add useful_validations_for_performance_rate\n ]\n useful_checks.inject(:&)\n end",
"def warning?\n false\n end",
"def school_info_optional?\n true # update if/when A/B test is done and accepted\n end",
"def deprecation(message, options = { })\n unless ENV['GUARD_ENV'] == 'test'\n reset_line if options[:reset]\n STDERR.puts color('DEPRECATION: ', :red) + message\n end\n end",
"def check_pkg_info\n return false if options['package_url'].nil? ||\n options['package_name'].nil?\n true\nend",
"def check_for_installed_software_only\n check_all_installed @options\n end",
"def check_options_values\n # Check if files specified with -f option exist\n if @options[:files].nil?\n @files = ['lib', 'bin', 'app', 'test', 'spec', 'feature']\n else\n @files = @options[:files].split(',')\n @files.delete_if do |filename|\n unless File.exist?(filename)\n puts \"#{filename} does not exist. Ignore it.\"\n true\n end\n end\n if @files.empty?\n puts 'No file to analyze. Aborted!'\n exit\n end\n end\n # Check if files specified with -e option exist\n unless @options[:exclude].nil?\n @excluded_files = @options[:exclude].split(',')\n @excluded_files.delete_if do |filename|\n unless File.exist?(filename)\n puts \"#{filename} does not exist. Ignore it.\"\n true\n end\n end\n end\n end",
"def verify_plugins(toggle:)\n add option: \"-verify-plugins=#{toggle}\"\n end",
"def dev_checks\n checks.select { |ctx| !ctx.functional? }\n end",
"def test_add_option02b\n assert_raise( RuntimeError ) { \n ArgumentManager.add_option(\n [ 'd' ],\n :help => 0\n )\n }\n end",
"def checkTools()\n\n\tif (PATH_CLANG_FORMAT.empty?)\n\t\tabort(\"Unable to find clang-format!\");\n\tend\n\n\tif (PATH_UNCRUSTIFY.empty?)\n\t\tabort(\"Unable to find uncrustify!\");\n\tend\n\nend",
"def on_loaded\n config.log_deprecations\n end",
"def obsolete?\n @obsolete ? true : false\n end",
"def missing?\n ActiveSupport::Deprecation.warn(<<-MSG.squish)\n The missing? predicate is deprecated and will be removed in Rails 6.0.\n Please use not_found? as provided by Rack::Response::Helpers.\n MSG\n not_found?\n end",
"def useless\n @useful = false\n end",
"def validate_hand_off(options = {})\n # Return true until we add validation\n true\n end"
] | [
"0.64725137",
"0.639803",
"0.6256996",
"0.6133459",
"0.611401",
"0.60982275",
"0.609574",
"0.594715",
"0.58884084",
"0.5883327",
"0.58587366",
"0.58298916",
"0.58122057",
"0.58122057",
"0.58122057",
"0.58122057",
"0.58122057",
"0.58122057",
"0.58122057",
"0.58122057",
"0.58122057",
"0.5808074",
"0.5799214",
"0.5760694",
"0.5660821",
"0.5648029",
"0.5630813",
"0.562996",
"0.5618052",
"0.5607194",
"0.5593159",
"0.5589761",
"0.5589533",
"0.55812156",
"0.5568724",
"0.5568724",
"0.556271",
"0.5550244",
"0.55488306",
"0.55479085",
"0.5543453",
"0.5534754",
"0.55241567",
"0.55226636",
"0.5485258",
"0.5460939",
"0.54570925",
"0.5454464",
"0.54536384",
"0.544488",
"0.541644",
"0.5409048",
"0.53905785",
"0.5384861",
"0.5382781",
"0.53767985",
"0.5363469",
"0.5340407",
"0.5331492",
"0.5331492",
"0.5331492",
"0.5331492",
"0.5331492",
"0.5331492",
"0.5325262",
"0.53244835",
"0.5320548",
"0.5299813",
"0.52992487",
"0.5294765",
"0.52885854",
"0.5278481",
"0.52620167",
"0.5248631",
"0.52292025",
"0.52292025",
"0.5225248",
"0.51996225",
"0.5198645",
"0.5197368",
"0.51969695",
"0.5182854",
"0.51755697",
"0.51655406",
"0.5165224",
"0.5148048",
"0.51469743",
"0.51432335",
"0.51267135",
"0.5119519",
"0.51167893",
"0.51095945",
"0.5107618",
"0.5104429",
"0.510091",
"0.5096972",
"0.50948215",
"0.5087485",
"0.50872767",
"0.5080138",
"0.50749093"
] | 0.0 | -1 |
this updates all apt packages (especially important for VirtualBox guest addition packages) | def apt_update(vm)
vm.provision "shell", inline: <<-SHELL
if [ ! -f /root/apt.updated ]; then
apt-get -y update
apt-get -y purge exim4-* libcairo*
apt-get -y autoremove
#apt-get -y upgrade
#apt-get -y dist-upgrade
apt-get -y install htop tree vim aufs-tools screen curl
touch /root/apt.updated
fi
SHELL
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apt_get_update_install\n @app.packages.present? ? install_additional_packages : update_apt\n end",
"def update_apt\n <<~APT\n # Update apt-get\n RUN DEBIAN_FRONTEND=noninteractive apt-get update\n APT\n end",
"def apt_update(vm)\n vm.provision \"shell\", inline: <<-SHELL\n if [ ! -f /root/apt.updated ]; then\n apt-get -y update\n apt-get -y purge exim4-*\n apt-get -y autoremove\n apt-get -y upgrade\n apt-get -y dist-upgrade\n apt-get -y install htop tree vim aufs-tools\n touch /root/apt.updated\n fi\n SHELL\nend",
"def update_apt_if_needed\n if self['platform'] =~ /debian|ubuntu|cumulus/\n if @apt_needs_update\n execute(\"apt-get update\")\n @apt_needs_update = false\n end\n end\n end",
"def update_apt_if_needed\n if self['platform'] =~ /debian|ubuntu|cumulus|huaweios/\n if @apt_needs_update\n execute(\"apt-get update\")\n @apt_needs_update = false\n end\n end\n end",
"def apt_update\n run %{apt-get update -y}\nend",
"def apt_get_update hosts\n block_on hosts do |host|\n host.exec(Command.new(\"apt-get update\")) if /ubuntu|debian|cumulus/.match?(host[:platform])\n end\n end",
"def update(&block)\n ssh.exec! \"apt-get --assume-yes update\", sudo: true\n ssh.exec \"apt-get --assume-yes upgrade\", sudo: true do |ch, stream, data, cmd|\n yield data\n end\n end",
"def packages debs, role\n run \"#{sudo} apt-get -y update && #{sudo} apt-get -y upgrade && #{sudo} apt-get install -y #{debs}\", :role => role\nend",
"def apt_reinstall(packages)\n packages = packages.split(/\\s+/) if packages.respond_to?(:split)\n packages = Array(packages)\n sudo \"#{apt_get} -qyu --force-yes --reinstall install #{packages.join(\" \")}\"\n end",
"def system_update(&block)\n ssh.exec! \"apt-get --assume-yes update\", sudo: true\n ssh.exec \"apt-get --assume-yes upgrade\", sudo: true do |ch, stream, data, cmd|\n yield data\n end\n end",
"def apt_reinstall(packages)\n packages = packages.split(/\\s+/) if packages.respond_to?(:split)\n packages = Array(packages)\n sudo_with_input(\"#{apt_get_preamble} --reinstall install #{packages.join(\" \")}\", /\\?/, \"\\n\")\n end",
"def apt_install(packages)\n packages = packages.split(/\\s+/) if packages.respond_to?(:split)\n packages = Array(packages)\n apt_get=\"DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get\"\n sudo \"#{apt_get} -qyu --force-yes install #{packages.join(\" \")}\"\n end",
"def install_additional_packages\n <<~APT\n # Install app-specific Ubuntu packages\n RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y #{NL_TAB}#{@app.packages.join(\" #{NL_TAB}\")}\n APT\n end",
"def autoinstall(*packages)\n all_packages_installed = packages.all? { |pkg| Path.which pkg }\n\n unless all_packages_installed\n cmd([\"sudo apt-get install ?\", packages.join(' ')])\n end\nend",
"def apt_get_update_script\n <<-ENDSCRIPT\n if [[ ! -f /tmp/apt_sources.md5 ]]; then\n apt-get -q update\n\n md5sum /etc/apt/sources.list > /tmp/apt_sources.md5\n md5sum /etc/apt/sources.list.d/*.list >> /tmp/apt_sources.md5\n else\n md5sum /etc/apt/sources.list > /tmp/apt_sources_compare.md5\n md5sum /etc/apt/sources.list.d/*.list >> /tmp/apt_sources_compare.md5\n\n if [[ `diff /tmp/apt_sources.md5 /tmp/apt_sources_compare.md5` ]]; then\n apt-get -q update\n fi\n\n mv /tmp/apt_sources_compare.md5 /tmp/apt_sources.md5\n fi\n ENDSCRIPT\n end",
"def apt_installed_packages\n @apt_installed_packages ||= Puppet::Type.type(:package).provider(:apt).instances.map(&:name)\n end",
"def apt_install(packages)\n packages = packages.split(/\\s+/) if packages.respond_to?(:split)\n packages = Array(packages)\n sudo_with_input(\"#{apt_get_preamble} install #{packages.join(\" \")}\", /\\?/, \"\\n\")\n end",
"def apt_packages\n PRE_INSTALLED_OS_PACKAGES[@app.release].join(\" #{NL_TAB}\")\n end",
"def ensure_aptitude_installed!\n if not installed?('aptitude')\n Spinner.return :message => \"Ensuring package manager is installed and up to date..\" do\n execute_as_root('apt-get update; apt-get install -y aptitude')\n 'Done!'.color(:green)\n end\n end\n end",
"def install_in_ubuntu\n install_ppa(node['SignalFx_ppa']['collectd']['name'],\n node['SignalFx_ppa']['collectd']['uri'])\n install_ppa(node['SignalFx_ppa']['collectd_plugin']['name'],\n node['SignalFx_ppa']['collectd_plugin']['uri'])\n ubuntu_update\n install_package 'collectd'\nend",
"def install_jaunty_sources\n has_exec(\"apt-get update\", :action => :nothing)\n\n lines =<<-EOF\ndeb http://archive.ubuntu.com/ubuntu/ jaunty main restricted\ndeb http://archive.ubuntu.com/ubuntu/ jaunty universe\ndeb http://archive.ubuntu.com/ubuntu/ jaunty multiverse\ndeb-src http://archive.ubuntu.com/ubuntu/ jaunty main restricted\ndeb-src http://archive.ubuntu.com/ubuntu/ jaunty universe\ndeb-src http://archive.ubuntu.com/ubuntu/ jaunty multiverse\nEOF\n lines.each_line do |l|\n has_line_in_file do \n file \"/etc/apt/sources.list\"\n line l \n notifies get_exec(\"apt-get update\"), :run\n end\n end\n end",
"def install_extras\n p\n p \"====================================\"\n p \"Installing a bevvy of useful utilities\"\n p \"====================================\"\n p\n run %{sudo apt upgrade -y}\n run %{sudo apt install -y zsh ctags git tmux xclip silversearcher-ag guake}\nend",
"def apt_install_from_ppa(ppa,package)\n apt_install_by_command('add-apt-repository')\n # 12.04 has a -y, 10.04 doesn't. (the check assumes all boxes are the same)\n run \"#{sudo} add-apt-repository #{capture(\"lsb_release -rs\") < \"12.04\" ? \"\" : \"-y\" } #{ppa}\"\n apt_update\n apt_install package\n end",
"def cmdUpdate\n return %x_sudo apt update 2>/dev/null_.rstrip.split(/\\n/)\nend",
"def linux_installer(package)\n\t\t\t\tsystem(\"sudo apt-get -y install #{package}\")\n\t\t\tend",
"def install\n self.run_preseed if @resource[:responsefile]\n should = @resource[:ensure]\n\n checkforcdrom\n cmd = %w{-q -y}\n\n keep = \"\"\n if config = @resource[:configfiles]\n if config == :keep\n cmd << \"-o\" << 'DPkg::Options::=--force-confold'\n else\n cmd << \"-o\" << 'DPkg::Options::=--force-confnew'\n end\n end\n\n str = @resource[:name]\n case should\n when true, false, Symbol\n # pass\n else\n # Add the package version and --force-yes option\n str += \"=#{should}\"\n cmd << \"--force-yes\"\n end\n\n cmd << :install << str\n\n aptget(*cmd)\n end",
"def apt_purge(packages)\n packages = packages.split(/\\s+/) if packages.respond_to?(:split)\n packages = Array(packages)\n sudo \"#{apt_get_preamble} purge #{packages.join(\" \")}\"\n end",
"def update\n # Install in pacman can be used for update, too\n self.install\n end",
"def update\n # Install in pacman can be used for update, too\n self.install\n end",
"def install(*packages)\n ssh.exec! \"apt-get --assume-yes install #{packages.join(' ')}\", sudo: true\n return packages.count\n end",
"def apt_install_by_command(command)\n sudo_run_compressed %Q{\n #{apt_get_preamble} install apt-file;\n apt-file update;\n #{apt_get_preamble} install `apt-file --non-interactive --package-only search #{command}`\n }\n end",
"def update_debian_dir(pkginfo, options)\n # Generate the debian directory\n generate_debian_dir(pkginfo, pkginfo.srcdir, options)\n\n if options[:patch_dir] && File.exist?(options[:patch_dir])\n if patch_pkg_dir(pkginfo.name, options[:patch_dir],\n whitelist: nil,\n pkg_dir: pkginfo.srcdir,\n options: patch_options())\n Packager.warn \"Overlay patch applied to #{pkginfo.name}\"\n end\n Dir.chdir(pkginfo.srcdir) do\n process_apaka_control(\"apaka.control\")\n end\n end\n\n dpkg_commit_changes(\"overlay\", pkginfo.srcdir,\n logfile: options[:logfile],\n include_removal: true)\n\n envyml = File.join(pkginfo.srcdir, \"env.yml\")\n Packager.warn(\"Preparing env.yml #{envyml}\")\n patch_yml = {}\n if File.exists?(envyml)\n patch_yml = YAML.load_file(envyml)\n end\n\n env_data = pkginfo.generate_env_data(\"APAKA__\" + Packaging.as_var_name(pkginfo.name), rock_install_directory, base_data: patch_yml)\n File.open(envyml, \"w\") do |file|\n file.write(env_data.to_yaml)\n end\n dpkg_commit_changes(\"envyml\", pkginfo.srcdir,\n logfile: options[:logfile])\n\n\n envsh = File.join(pkginfo.srcdir, \"env.sh\")\n Packager.warn(\"Preparing env.sh #{envsh}\")\n File.open(envsh, \"a\") do |file|\n env_txt = pkginfo.envsh(env_data)\n file.write(env_txt)\n end\n dpkg_commit_changes(\"envsh\", pkginfo.srcdir,\n logfile: options[:logfile])\n\n\n # Run dpkg-source\n # Use the new tar ball as source\n if !system(\"dpkg-source\", \"-I\", \"-b\", pkginfo.srcdir,\n [:out, :err] => redirection(options[:logfile],\"a\"),\n :close_others => true)\n Packager.warn \"Package: #{pkginfo.name} failed to perform dpkg-source -- #{Dir.entries(pkginfo.srcdir)}\"\n raise RuntimeError, \"Debian: #{pkginfo.name} failed to perform dpkg-source in #{pkginfo.srcdir}\"\n end\n [\"#{versioned_name(pkginfo, options[:distribution])}.debian.tar.gz\",\n \"#{plain_versioned_name(pkginfo)}.orig.tar.gz\",\n \"#{versioned_name(pkginfo, options[:distribution])}.dsc\"]\n end",
"def install(*packages)\n ssh.exec! \"apt-get --assume-yes install #{packages.join(' ')}\", sudo: true\n return packages.count\n end",
"def apt_install(pkg, check=false)\n if check && pkg_installed?(pkg)\n info %{Package \"#{pkg}\" is already installed, skipping.}\n else\n run %{apt-get install -y #{pkg}}\n end\nend",
"def update_instace_os\n ssh_command = 'sudo apt-get update &&sudo apt-get dist-upgrade -qq && sudo apt-get autoremove -y'\n result = ''\n Net::SSH.start(get_access_ip, 'ubuntu', keys: @aws_setup_information[@environment.to_sym][:keyPath], timeout: @ssh_timeout_period) do |ssh|\n ssh.exec(ssh_command) do |_channel, _stream, data|\n result += data\n end\n end\n result\n end",
"def update_pacman_if_needed\n if self['platform'] =~ /archlinux/\n if @pacman_needs_update\n execute(\"pacman --sync --noconfirm --noprogressbar --refresh --sysupgrade --ignore linux --ignore linux-docs --ignore linux-headers\")\n @pacman_needs_update = false\n end\n end\n end",
"def install_in_debian\n package 'apt-transport-https'\n package 'dirmngr' if get_debian_os_name == 'stretch'\n collectd_ppa_source = node['SignalFx_debian_ppa'][get_debian_os_name]['collectd']['uri']\n signalfx_collectd_plugin_ppa_source = node['SignalFx_debian_ppa'][get_debian_os_name]['collectd_plugin']['uri']\n signalfx_keyid = node['SignalFx_debian_ppa']['keyid']\n execute 'add SignalFx PPA' do\n command \"apt-key adv --keyserver keyserver.ubuntu.com --recv-keys #{signalfx_keyid} && \n echo #{collectd_ppa_source} > /etc/apt/sources.list.d/signalfx_collectd.list && \n echo #{signalfx_collectd_plugin_ppa_source} > /etc/apt/sources.list.d/signalfx_collectd_plugin.list\"\n action :run\n end\n ubuntu_update\n install_package 'collectd'\nend",
"def update\n Puppet.debug \"Attempting to upgrade #{@resource[:name]}\"\n install unless mas_app\n mas('upgrade')\n end",
"def install_pkgs! pkgs, opts\n log_shell \"Installing packages\", \"#{pkg_cmd} --sync --noconfirm --noedit --noprogressbar #{pkgs.join(' ')}\", :sudo => false\n end",
"def etc_update \n announcing 'Running etc-update' do\n system(\"chroot #{$chrootdir} /scripts/run.sh update_configs\")\n end\n send_to_state('build', 'etc_update')\n end",
"def update\n Puppet.debug(\"Debconf: updating #{resource[:name]}\")\n\n # Build the string to send\n args = [:package, :item, :type, :value].map { |e| resource[e] }.join(' ')\n\n IO.popen('/usr/bin/debconf-set-selections', 'w+') do |pipe|\n Puppet.debug(\"Debconf: debconf-set-selections #{args}\")\n pipe.puts(args)\n\n # Ignore remaining output from command\n pipe.close_write\n pipe.read(nil)\n end\n end",
"def update\n install\n end",
"def package_if_necessary(pkg)\n if !package_is_installed?(pkg)\n banner \"#{pkg}...\"\n run \"apt-get -y install #{pkg}\"\n end\n end",
"def update_everything\n announcing 'Updating All Packages' do\n chroot 'update_everything'\n end\n send_to_state('build', 'update_everything')\n end",
"def install_packages packages\n case DISTRO[0]\n when :opensuse\n installed = %x[rpm -qa].split(\"\\n\")\n packages.select{|pkg| ! installed.detect{|d| d =~ /^#{Regexp.escape(pkg)}/ } }.each do |package|\n # puts \"Installing #{package} ...\"\n %x[sudo zypper install '#{package}']\n end\n when :solaris\n installed = `pkg-get -l`.split(\"\\n\")\n packages.select{|pkg| ! installed.include? pkg }.each do |package|\n sh \"sudo pkg-get install #{package}\"\n end\n else\n installed = `dpkg --list`.split(\"\\n\").map { |x| x.split[1] } # Hm, this is out of scope if defined outside.\n packages.select{ |pkg| ! installed.include? pkg }.each do |package|\n sh \"sudo apt-get -y install #{package}\"\n end\n end\nend",
"def has_apt(*packages)\n [packages].flatten.each do |package|\n @commands << %Q!test \"$(dpkg-query -W -f='${Status}' #{package} 2> /dev/null)\" = 'install ok installed'!\n end\n end",
"def update!(**args)\n @apt = args[:apt] if args.key?(:apt)\n @deb = args[:deb] if args.key?(:deb)\n @desired_state = args[:desired_state] if args.key?(:desired_state)\n @googet = args[:googet] if args.key?(:googet)\n @msi = args[:msi] if args.key?(:msi)\n @rpm = args[:rpm] if args.key?(:rpm)\n @yum = args[:yum] if args.key?(:yum)\n @zypper = args[:zypper] if args.key?(:zypper)\n end",
"def upgrade_npm_packages\n Kernel.exec('bundle exec vite upgrade_packages')\n end",
"def update!(**args)\n @apt_package = args[:apt_package] if args.key?(:apt_package)\n @cos_package = args[:cos_package] if args.key?(:cos_package)\n @googet_package = args[:googet_package] if args.key?(:googet_package)\n @qfe_package = args[:qfe_package] if args.key?(:qfe_package)\n @windows_application = args[:windows_application] if args.key?(:windows_application)\n @wua_package = args[:wua_package] if args.key?(:wua_package)\n @yum_package = args[:yum_package] if args.key?(:yum_package)\n @zypper_package = args[:zypper_package] if args.key?(:zypper_package)\n @zypper_patch = args[:zypper_patch] if args.key?(:zypper_patch)\n end",
"def update_for\n update_for_items.collect(&:package)\n end",
"def install_deps!(node)\n node.vm.provision \"shell\", inline: \"cp -f /vagrant/hosts /etc/hosts\"\n deps = [\n 'java-1.8.0-openjdk',\n 'ed',\n\n # * purely for convenience\n 'the_silver_searcher',\n 'vim',\n 'zip'\n ]\n node.vm.provision \"shell\", inline: \"yum install -y #{deps.join(' ')}\"\nend",
"def update\n r = install(true)\n # 4 == /No updates available for this image./\n return if [0,4].include? r[:exit]\n raise Puppet::Error, _(\"Unable to update %{package}\") % { package: r[:out] }\n end",
"def install(package)\n\n return @results[:install] = 'no route to internet' unless internet?\n return @results[:install] = 'already installed' if installed? package\n \n instructions = \"apt-get update && apt-get install #{package} -y\"\n r = @ssh ? @ssh.exec!(instructions) : `#{instructions}`\n puts 'r: ' + r.inspect if @debug\n @results[:install] = r.chomp\n\n end",
"def upgrade_package(name, cmdline_args = '', opts = {})\n case self['platform']\n when /sles-/\n execute(\"zypper --non-interactive --no-gpg-checks up #{name}\", opts)\n when /el-4/\n @logger.debug(\"Package upgrade is not supported on rhel4\")\n when /fedora-22/\n execute(\"dnf -y #{cmdline_args} update #{name}\", opts)\n when /cisco|fedora|centos|eos|el-/\n execute(\"yum -y #{cmdline_args} update #{name}\", opts)\n when /ubuntu|debian|cumulus/\n update_apt_if_needed\n execute(\"apt-get install -o Dpkg::Options::='--force-confold' #{cmdline_args} -y --force-yes #{name}\", opts)\n when /solaris-11/\n execute(\"pkg #{cmdline_args} update #{name}\", opts)\n when /solaris-10/\n execute(\"pkgutil -u -y #{cmdline_args} ${name}\", opts)\n else\n raise \"Package #{name} cannot be upgraded on #{self}\"\n end\n end",
"def install_postgres(ssh)\n ssh.exec! 'sudo docker exec advocatedefencepayments apt-get update'\n ssh.exec! 'sudo docker exec advocatedefencepayments apt-get -y install postgresql-9.6'\nend",
"def update\n if properties[:ensure] == :absent\n install\n else\n if @portorigin\n do_portupgrade portorigin, upgrade_options, resource[:package_settings]\n else\n warning \"Could not upgrade package '#{name}' which has no port origin.\"\n end\n end\n end",
"def apt_remove(packages)\n packages = packages.split(/\\s+/) if packages.respond_to?(:split)\n packages = Array(packages)\n sudo \"#{apt_get_preamble} remove #{packages.join(\" \")}\"\n end",
"def update\n project.run \"apk update\"\n end",
"def install_python_system_packages\n where_am_i\n\n shell_cmd(\"#{pip_versioned} install --no-compile virtualenv ansible-runner\")\n end",
"def update(args)\n if (args[0] == \"dns\")\n\n if RUBY_PLATFORM.include? \"linux\"\n system('ansible-playbook /usr/local/gdev-env/ansible/ubuntu.yml -i 127.0.0.1, --ask-become-pass --verbose --tags=dns')\n else\n system('ansible-playbook /usr/local/gdev-env/ansible/mac.yml -i 127.0.0.1, --ask-become-pass --verbose --tags=dns')\n end\n\n elsif (args[0].nil?)\n\n if RUBY_PLATFORM.include? \"linux\"\n system('cd /usr/local/gdev-env && git reset HEAD --hard && git pull origin HEAD && bin/ubuntu')\n else\n system('cd /usr/local/gdev-env && git reset HEAD --hard && git pull origin HEAD && bin/bootstrap')\n end\n # Rebuild and reload all services\n puts \"Refreshing all gdev services...\"\n service(['build nginx'])\n service(['reload'])\n\n else\n puts \"Did you mean to run: $ gdev update ?\"\n end\n end",
"def upgrade_repo!\n package 'apt-transport-https'\n include_recipe \"apt-chef::#{new_resource.channel}\"\n package('chefdk') { action :upgrade }\n end",
"def upgrade_package(name, cmdline_args = '', opts = {})\n case self['platform']\n when /opensuse|sles-/\n execute(\"zypper --non-interactive --no-gpg-checks up #{name}\", opts)\n when /el-4/\n @logger.debug(\"Package upgrade is not supported on rhel4\")\n when /fedora-(2[2-9]|3[0-9])/\n execute(\"dnf -y #{cmdline_args} update #{name}\", opts)\n when /cisco|fedora|centos|redhat|eos|el-/\n execute(\"yum -y #{cmdline_args} update #{name}\", opts)\n when /ubuntu|debian|cumulus|huaweios/\n update_apt_if_needed\n execute(\"apt-get install -o Dpkg::Options::='--force-confold' #{cmdline_args} -y --force-yes #{name}\", opts)\n when /solaris-11/\n if opts[:acceptable_exit_codes]\n opts[:acceptable_exit_codes] << 4\n else\n opts[:acceptable_exit_codes] = [0, 4] unless opts[:accept_all_exit_codes]\n end\n execute(\"pkg #{cmdline_args} update #{name}\", opts)\n when /solaris-10/\n execute(\"pkgutil -u -y #{cmdline_args} #{name}\", opts)\n else\n raise \"Package #{name} cannot be upgraded on #{self}\"\n end\n end",
"def update(args)\n if (args[0] == \"dns\")\n system('ansible-playbook /usr/local/gdev-env/ansible/mac.yml -i 127.0.0.1, --ask-become-pass --verbose --tags=dns')\n elsif (args[0].nil?)\n system('cd /usr/local/gdev-env && git reset HEAD --hard && git pull origin HEAD && bin/bootstrap')\n # Rebuild and reload all services\n puts \"Refreshing all gdev services...\"\n service(['build nginx'])\n service(['reload'])\n else\n puts \"Did you mean to run: $ gdev update ?\"\n end\n end",
"def package(name, version=nil, options={:q => true, :y => true})\n name = \"#{name}=#{version}\" unless version.to_s.strip.empty?\n execute \"apt-get install\", name, options\n chain_proxy\n end",
"def upgrade_package host, package_name\n host.upgrade_package package_name\n end",
"def apt(*args)\n Buildr.application.deprecated 'Use Java::Commands.apt instead.'\n Commands.apt(*args)\n end",
"def install(nofail = false)\n name = @resource[:name]\n should = @resource[:ensure]\n is = self.query\n if is[:ensure].to_sym == :absent\n command = 'install'\n else\n command = 'update'\n end\n args = ['--accept']\n if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value(:operatingsystemrelease), '11.2') >= 0\n args.push('--sync-actuators-timeout', '900')\n end\n args.concat(join_options(@resource[:install_options])) if @resource[:install_options]\n unless should.is_a? Symbol\n name += \"@#{should}\"\n end\n self.unhold if self.properties[:mark] == :hold\n begin\n r = exec_cmd(command(:pkg), command, *args, name)\n ensure\n self.hold if @resource[:mark] == :hold\n end\n return r if nofail\n raise Puppet::Error, _(\"Unable to update %{package}\") % { package: r[:out] } if r[:exit] != 0\n end",
"def update\n if properties[:ensure] == :absent\n install\n elsif @portorigin\n do_portupgrade portorigin, upgrade_options, resource[:package_settings]\n else\n warning \"Could not upgrade package '#{name}' which has no port origin.\"\n end\n end",
"def install_python(config)\n config.vm.provision \"shell\",\n inline: \"which python > /dev/null || sudo apt-get -y install python\"\nend",
"def upgrade\n project.run \"apk upgrade\"\n end",
"def braid_update_all\n bundle_exec('braid setup 2>&1 > /dev/null', false)\n bundle_exec('braid update') if 0 == $?.exitstatus\n end",
"def update(packages)\n updated_repo = false\n current_package_filenames = @rp.get_package_files\n future_package_filenames = Array.new\n packages.each do |pkg_name, pkg_objs|\n pkg_objs.each do |pkg|\n pkg_filename = File.basename(pkg.path)\n future_package_filenames << pkg_filename \n # If the package file does not exist, link it\n unless current_package_filenames.include?(pkg_filename)\n updated_repo = true\n File.link(pkg.path, File.join(@path, pkg_filename))\n end\n end\n end\n\n to_del = current_package_filenames - future_package_filenames\n to_del.each do |file|\n updated_repo = true\n File.unlink(File.join(@path, file))\n end\n @rp.update(packages)\n end",
"def upgrade_direct!\n package \"Chef Development Kit v#{package_metadata[:version]}\" do\n source package_metadata[:url]\n checksum package_metadata[:sha256]\n end\n end",
"def get_update_pkgs\n get_update_dirs\n delete_contrib\n return @update_pkgs\n end",
"def update!(**args)\n @apt = args[:apt] if args.key?(:apt)\n @goo = args[:goo] if args.key?(:goo)\n @yum = args[:yum] if args.key?(:yum)\n @zypper = args[:zypper] if args.key?(:zypper)\n end",
"def autoinstPackages\n allpackages = []\n\n # the primary list of packages\n allpackages = Convert.convert(\n Builtins.union(allpackages, PackageAI.toinstall),\n :from => \"list\",\n :to => \"list <string>\"\n )\n\n # In autoinst mode, a kernel should not be available\n # in <packages>\n if Builtins.size(@kernel) == 0\n kernel_pkgs = Kernel.ComputePackages\n allpackages = Convert.convert(\n Builtins.union(allpackages, kernel_pkgs),\n :from => \"list\",\n :to => \"list <string>\"\n )\n else\n if Pkg.IsAvailable(@kernel)\n allpackages = Builtins.add(allpackages, @kernel)\n kernel_nongpl = Ops.add(@kernel, \"-nongpl\")\n\n if Pkg.IsAvailable(kernel_nongpl)\n allpackages = Builtins.add(allpackages, kernel_nongpl)\n end\n else\n Builtins.y2warning(\"%1 not available, using kernel-default\", @kernel)\n kernel_pkgs = Kernel.ComputePackages\n allpackages = Convert.convert(\n Builtins.union(allpackages, kernel_pkgs),\n :from => \"list\",\n :to => \"list <string>\"\n )\n end\n end\n\n deep_copy(allpackages)\n end",
"def package_install\n if distro.is_a?( Debian )\n dist_if_not_installed?( package_names ) do\n dist_install( *package_names, check_install: false )\n pg_stop\n end\n if shared_memory_max\n c = rput( 'etc/sysctl.d/61-postgresql-shm.conf', user: :root )\n unless c.empty?\n sudo \"sysctl -p /etc/sysctl.d/61-postgresql-shm.conf\"\n end\n c\n end\n else\n dist_install( *package_names )\n end\n end",
"def update\n self.install\n end",
"def rearrange_and_reship(rake, target_repo, signing_bundle)\n puts \"Retrieving packages...\"\n system(\"#{rake} -s pl:jenkins:retrieve &> /dev/null\")\n\n puts \"Moving the packages into the new layout...\"\n puts \"Moving debs...\"\n rearrange_packages(\"pkg/deb\", \"new_pkg/deb\", target_repo, [\"\"])\n puts \"Moving rpms...\"\n rearrange_packages(\"pkg/el\", \"new_pkg/el\", target_repo, [\"i386\", \"x86_64\", \"SRPMS\"])\n rearrange_packages(\"pkg/fedora\", \"new_pkg/fedora\", target_repo, [\"i386\", \"x86_64\", \"SRPMS\"])\n\n puts \"Moving new_pkg into place on top of pkg...\"\n FileUtils.mv(\"pkg\", \"old_pkg\")\n FileUtils.mv(\"new_pkg\", \"pkg\")\n\n puts \"uber_shipping relocated packages...\"\n ENV[\"SIGNING_BUNDLE\"] = \"../#{signing_bundle}\"\n ENV[\"TAR\"] = \"FALSE\"\n system(\"#{rake} -s pl:jenkins:sign_all pl:uber_ship pl:remote:update_apt_repo pl:remote:update_yum_repo\")\nend",
"def update\n self.install\n end",
"def update\n self.install\n end",
"def update_gems()\n system \"gem update --system\"\n end",
"def uninstall(*packages)\n ssh.exec! \"apt-get --assume-yes purge #{packages.join(' ')}\", sudo: true\n end",
"def update_appd_cookbook\n @ssh.exec! \"cd #{APPD_COOKBOOK_PATH}; git pull origin master\", sudo: true\n chef_exec \"berks install --path #{@cookbook_path.first} --berksfile #{APPD_COOKBOOK_PATH}/Berksfile\"\n end",
"def update_software(ssh_session,hostname,username,password,local_version,depot_version,filename,mode,doaction,depot_url,reboot)\n update_available = compare_versions(local_version,depot_version,mode)\n if update_available == \"y\" and mode != \"check\"\n if filename.match(/[A-z]/)\n patch_file = File.basename(filename)\n depot_dir = \"/scratch/downloads\"\n depot_file = depot_dir+\"/\"+patch_file\n (ssh_session,output) = ssh_session_exec(ssh_session,\"mkdir #{depot_dir}\")\n puts \"Copying local file \"+filename+\" to \"+hostname+\":\"+depot_file\n Net::SCP.upload!(hostname, username, filename, depot_file, :ssh => { :password => password })\n else\n depot_file = depot_url\n end\n if doaction != \"y\"\n while doaction !~ /y|n/\n print \"Install update [y,n]: \"\n doaction = gets.chomp\n end\n end\n if doaction == \"y\"\n puts \"Installing \"+depot_version+\" from \"+depot_file\n (ssh_session,output) = ssh_session_exec(ssh_session,\"esxcli software vib update -d=#{depot_file}\")\n else\n puts \"Performing Dry Run - No updates will be installed\"\n (ssh_session,output) = ssh_session_exec(ssh_session,\"esxcli software vib update -d=#{depot_file} --dry-run\")\n end\n puts output\n if output.match(/Reboot Required: true/) and reboot == \"y\"\n puts \"Rebooting\"\n (ssh_session,output) = ssh_session_exec(ssh_session,\"reboot\")\n end\n end\n return ssh_session\nend",
"def update_dependencies()\n\t\"berks vendor cookbooks #{(@debug ? '-d' : '-q')}\"\n end",
"def extract_upgraded_packages(output)\n new_packages = []\n\n output.each_line do |line|\n next if line.match(/The following packages will be upgraded:/)\n break if line.match(/\\d+ upgraded, \\d+ newly installed/)\n\n line.split.each do |pkg|\n puts \"pkg #{pkg}\"\n new_packages << PackageManager::Package.new(pkg, @host_name)\n end\n end\n\n new_packages\n end",
"def action_update_all\n if @current_resource.installed\n converge_by 'Updated installed WebSphere packages' do\n imcl :updateAll,\n new_resource._?(:install_fixes, '-iF'),\n new_resource._?(:repositories, '-repositories'),\n base_options\n end\n new_resource.updated_by_last_action(true)\n else\n Chef::Log.info 'No WebSphere packages installed to update - nothing to do'\n end\n load_new_resource_state\n new_resource.installed(true)\n end",
"def update_all_packages(options = {})\n return true if update_all_packages_impl(options)\n \n return false if options[:no_proxy]\n update_all_packages options.merge(:no_proxy => true)\n end",
"def installPackages\n Dir.chdir(\"/tmp\")\n `wget http://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz`\n `wget http://garr.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz`\n `tar -zxf nagios-plugins-1.5.tar.gz`\n `tar -zxf nrpe-2.15.tar.gz`\n Dir.chdir(\"nagios-plugins-1.5\")\n `./configure`\n `make`\n `make install`\n `chown nagios.nagios /usr/local/nagios`\n `chown -R nagios.nagios /usr/local/nagios/libexec`\n Dir.chdir(\"../nrpe-2.15\")\n `./configure`\n `make all`\n `make install-plugin`\n `make install-daemon`\n `make install-daemon-config`\n `make install-xinetd`\n end",
"def package(pkginfo, options = Hash.new)\n options, unknown_options = Kernel.filter_options options,\n :force_update => false,\n :patch_dir => nil,\n :distribution => nil, # allow to override global settings\n :architecture => nil\n\n options[:distribution] ||= target_platform.distribution_release_name\n options[:architecture] ||= target_platform.architecture\n\n debian_pkg_name = debian_name(pkginfo)\n\n if options[:force_update]\n dirname = packaging_dir(pkginfo)\n if File.directory?(dirname)\n Packager.info \"Debian: rebuild requested -- removing #{dirname}\"\n FileUtils.rm_rf(dirname)\n end\n end\n\n options[:packaging_dir] = packaging_dir(pkginfo)\n options[:release_name] = rock_release_name\n\n begin\n # Set the current pkginfo to set the install directory\n # correctly\n # FIXME: needs to be refactored\n #\n @packager_lock.lock\n @current_pkg_info = pkginfo\n\n pkginfo = prepare_source_dir(pkginfo, options.merge(unknown_options))\n\n if pkginfo.build_type == :orogen || pkginfo.build_type == :cmake || pkginfo.build_type == :autotools\n package_default(pkginfo, options)\n elsif pkginfo.build_type == :ruby\n # Import bundles since they do not need to be build and\n # they do not follow the typical structure required for gem2deb\n if pkginfo.name =~ /bundles/\n package_importer(pkginfo, options)\n else\n package_ruby(pkginfo, options)\n end\n elsif pkginfo.build_type == :archive_importer || pkginfo.build_type == :importer_package\n package_importer(pkginfo, options)\n else\n raise ArgumentError, \"Debian: Unsupported package type #{pkginfo.build_type} for #{pkginfo.name}\"\n end\n ensure\n @current_pkg_info = nil\n @packager_lock.unlock\n end\n end",
"def get_install_client\n purge\n s('cd /tmp')\n s('wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb')\n s('sudo apt-get update')\n s('sudo apt-get -y install puppet')\nend",
"def package(pkg, options = Hash.new)\n\n options, unknown_options = Kernel.filter_options options,\n :force_update => false,\n :existing_source_dir => nil,\n :patch_dir => nil\n\n if options[:force_update]\n dirname = File.join(OBS_BUILD_DIR, debian_name(pkg))\n if File.directory?(dirname)\n Packager.info \"Debian: rebuild requested -- removing #{dirname}\"\n FileUtils.rm_rf(dirname)\n end\n end\n\n prepare_source_dir(pkg, options)\n\n if pkg.kind_of?(Autobuild::CMake) || pkg.kind_of?(Autobuild::Autotools)\n package_deb(pkg, options)\n elsif pkg.kind_of?(Autoproj::RubyPackage)\n package_ruby(pkg, options)\n else\n raise ArgumentError, \"Debian: Unsupported package type #{pkg.class} for #{pkg.name}\"\n end\n end",
"def stage_apt_archives(directory)\n find_command = \"find #{Pkg::Config.apt_repo_staging_path} -type d -name #{directory}\"\n find_command = \"find #{Pkg::Config.apt_repo_staging_path} -maxdepth 2 -type f\" if directory == 'main'\n command = <<-CMD\n for stuff in $(#{find_command}); do\n find $stuff -type l -delete\n codename=$(dirname ${stuff##{Pkg::Config.apt_repo_staging_path}/})\n sudo mkdir --parents #{Pkg::Config.freight_archive_path}/$codename\n sudo chown root:release -R #{Pkg::Config.freight_archive_path}/$codename\n sudo chmod g+w -R #{Pkg::Config.freight_archive_path}/$codename\n mv $stuff #{Pkg::Config.freight_archive_path}/$codename\n\n pool_directory=#{Pkg::Config.apt_repo_path}/pool/$codename/#{directory}\n if [ ! -d $pool_directory ]; then\n echo \"Can't find directory $pool_directory, it may have already been archived, skipping . . .\"\n continue\n fi\n sudo mkdir --parents /opt/tmp-apt\n sudo chown root:release -R /opt/tmp-apt\n sudo chmod g+w -R /opt/tmp-apt\n mv $pool_directory /opt/tmp-apt\n done\n CMD\n Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command)\n end",
"def install\n pacman \"--noconfirm\", \"--noprogressbar\", \"-Sy\", @resource[:name]\n\n unless self.query\n raise Puppet::ExecutionFailure.new(\"Could not find package %s\" % self.name)\n end\n end",
"def install(packages, version, options={})\n update\n special_options=\"--allow-unauthenticated\" if version != :stable\n send(run_method, %{\n sh -c \"#{APT_GET} -qyu --force-yes #{special_options.to_s} install #{package_list(packages, version)}\"\n }, options)\n end",
"def package_updated?(pkginfo)\n # append underscore to make sure version definition follows\n registered_orig_tar_gz = reprepro.registered_files(debian_name(pkginfo) + \"_\",\n rock_release_name,\n \"*.orig.tar.gz\")\n orig_file_names = Dir.glob(\"#{debian_name(pkginfo)}*.orig.tar.gz\")\n orig_file_names.each do |file|\n FileUtils.rm file\n end\n\n if registered_orig_tar_gz.empty?\n Packager.info \"Apaka::Packaging::Debian::package_updated?: no existing orig.tar.gz found in reprepro\"\n else\n Packager.info \"Apaka::Packaging::Debian::package_updated?: existing orig.tar.gz found in reprepro: #{registered_orig_tar_gz}\"\n FileUtils.cp registered_orig_tar_gz.first, Dir.pwd\n end\n\n # Find an existing orig.tar.gz in the build directory\n # ignoring the current version-timestamp\n orig_file_name = Dir.glob(\"#{debian_name(pkginfo)}*.orig.tar.gz\")\n if orig_file_name.empty?\n Packager.info \"No filename found for #{debian_name(pkginfo)} (existing files: #{Dir.entries('.')} -- package requires update (regeneration of orig.tar.gz)\"\n return true\n elsif orig_file_name.size > 1\n raise RuntimeError, \"Multiple versions of package #{debian_name(pkginfo)} in #{Dir.pwd} -- you have to fix this first\"\n else\n orig_file_name = orig_file_name.first\n end\n\n !equal_pkg_content?(pkginfo, orig_file_name)\n end",
"def upgrade(options={})\n update\n send(run_method, %{sh -c \"#{APT_GET} -qy upgrade\"}, options)\n end",
"def install_dev_repos_on(package, host, sha, repo_configs_dir, opts={})\n platform = host['platform'] =~ /^(debian|ubuntu)/ ? host['platform'].with_version_codename : host['platform']\n platform_configs_dir = File.join(repo_configs_dir, platform)\n\n case platform\n when /^(fedora|el|centos|sles)-(\\d+)-(.+)$/\n variant = (($1 == 'centos') ? 'el' : $1)\n fedora_prefix = ((variant == 'fedora') ? 'f' : '')\n version = $2\n arch = $3\n\n pattern = 'pl-%s-%s-%s-%s%s-%s.repo'\n\n repo_filename = pattern % [\n package,\n sha,\n variant,\n fedora_prefix,\n version,\n arch\n ]\n\n repo = fetch_http_file(\n \"%s/%s/%s/repo_configs/rpm/\" % [opts[:dev_builds_url],package, sha],\n repo_filename,\n platform_configs_dir\n )\n\n if /sles/i.match(platform)\n scp_to(host, repo, '/etc/zypp/repos.d/')\n else\n scp_to(host, repo, '/etc/yum.repos.d/')\n end\n\n when /^(debian|ubuntu)-([^-]+)-(.+)$/\n variant = $1\n version = $2\n arch = $3\n\n list = fetch_http_file(\n \"%s/%s/%s/repo_configs/deb/\" % [opts[:dev_builds_url],package, sha],\n \"pl-%s-%s-%s.list\" % [package, sha, version],\n platform_configs_dir\n )\n\n scp_to host, list, '/etc/apt/sources.list.d'\n if variant == 'ubuntu' && version.split('.').first.to_i >= 18\n apt_conf_content = 'Acquire::AllowInsecureRepositories \"true\";'\n else\n apt_conf_content = 'APT::Get::AllowUnauthenticated \"true\";'\n end\n create_remote_file(host, '/etc/apt/apt.conf.d/99trust-all', apt_conf_content)\n on host, 'apt-get update'\n else\n host.logger.notify(\"No repository installation step for #{platform} yet...\")\n end\n end"
] | [
"0.80300665",
"0.78911865",
"0.77964854",
"0.77872586",
"0.7715876",
"0.75927037",
"0.7523143",
"0.74980706",
"0.73292875",
"0.7247528",
"0.72381437",
"0.7022791",
"0.69741076",
"0.6876511",
"0.67898434",
"0.6748026",
"0.6708542",
"0.66960686",
"0.667151",
"0.65571916",
"0.6524095",
"0.6419829",
"0.640836",
"0.63902164",
"0.6377872",
"0.63416475",
"0.632961",
"0.6298862",
"0.6288524",
"0.6288524",
"0.62698394",
"0.62274665",
"0.6208588",
"0.6192386",
"0.6183206",
"0.6179161",
"0.61632097",
"0.60979486",
"0.6051226",
"0.6037174",
"0.60133326",
"0.60128206",
"0.5991059",
"0.59533006",
"0.59445685",
"0.5910783",
"0.59045726",
"0.5876724",
"0.5874575",
"0.5864763",
"0.586044",
"0.5809165",
"0.5803328",
"0.5791032",
"0.5737832",
"0.5723433",
"0.5712619",
"0.5710641",
"0.5705813",
"0.5702982",
"0.56675005",
"0.563344",
"0.56316805",
"0.55997103",
"0.55841595",
"0.5583084",
"0.55806553",
"0.5576419",
"0.55525744",
"0.55500174",
"0.5532559",
"0.55314493",
"0.5527046",
"0.55256885",
"0.5516494",
"0.5511433",
"0.5503932",
"0.5501599",
"0.549394",
"0.54930687",
"0.54926467",
"0.54926467",
"0.5491855",
"0.54909885",
"0.5482207",
"0.5477322",
"0.5449054",
"0.54352355",
"0.5413112",
"0.5398356",
"0.53752595",
"0.53729856",
"0.5365137",
"0.53632754",
"0.5358355",
"0.5352591",
"0.53512836",
"0.53393596",
"0.5329501",
"0.53141"
] | 0.80115056 | 1 |
basic/recommended configuration of every machine: | def basic_config(vm)
hosts = NODES.map { |hostname, array| "#{array[0]} #{hostname}" }.join("\n")
bashrc="/home/vagrant/.bashrc"
vm.provision "shell", inline: <<-SHELL
if ! grep -q "git-core" #{bashrc} ; then
echo "customizing ~/bashrc"
echo "\n\n# Customizations from Vagrantfile:" >> #{bashrc}
echo "export PS1='\\[\\033[31;1m\\]\\h\\[\\033[0;32m\\] \\w\\[\\033[00m\\]: '" >> #{bashrc}
echo export PATH="\$PATH:/usr/lib/git-core:/home/vagrant/teleport/build" >> #{bashrc}
echo export GREP_OPTIONS="--color=auto" >> #{bashrc}
echo "alias ll='ls -lh'" >> #{bashrc}
echo "alias tsh='tsh --insecure'" >> #{bashrc}
fi
if ! grep -q "Teleport" /etc/hosts ; then
echo "# Teleport entries added by Vagrant:" >> /etc/hosts
echo -e "#{hosts}" >> /etc/hosts
fi
mkdir -p /var/lib/teleport
chown vagrant:vagrant /var/lib/teleport
SHELL
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure\n @environment = facts.fetch(\"chef_environment\"){\"development\"}.downcase\n @fqdn = facts.fetch(\"fqdn\"){\"\"}\n @app_names = facts.fetch(\"trebuchet\"){[]}\n end",
"def setup_defaults()\n {\n 'box' => {\n 'memory' => '2048',\n 'cpus' => '2'\n }\n }\nend",
"def default_network_configs(communicator)\n winrm = [:forwarded_port, {\n guest: 5985,\n host: 55985,\n host_ip: \"127.0.0.1\",\n id: \"winrm\",\n auto_correct: true,\n protocol: \"tcp\"\n }]\n winrm_ssl = [:forwarded_port, {\n guest: 5986,\n host: 55986,\n host_ip: \"127.0.0.1\",\n id: \"winrm-ssl\",\n auto_correct: true,\n protocol: \"tcp\"\n }]\n ssh = [:forwarded_port, {\n guest: 22,\n host: 2222,\n host_ip: \"127.0.0.1\",\n id: \"ssh\",\n auto_correct: true,\n protocol: \"tcp\"\n }]\n if communicator == :winrm\n [ winrm, winrm_ssl ]\n else\n [ ssh ]\n end\n end",
"def configure_instance(\n machine,\n instance_profile,\n provider = 'virtualbox'\n)\n\n\n return false unless lookup_values_yaml(instance_profile, ['providers', provider])\n\n configure_vagrant_box(machine, instance_profile)\n\n configure_instance_hardware(machine, instance_profile)\n\n configure_networking(machine, instance_profile)\n\n configure_communication(machine, instance_profile)\n\n configure_filesystems(machine, instance_profile, provider)\n\n execute_system_commands(machine, instance_profile, provider)\n\nend",
"def configure_vagrant_machine(hostname, vm, cpus, memory)\n is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)\n\n vm.box = 'bento/ubuntu-16.04'\n vm.hostname = hostname\n\n vm.provider 'virtualbox' do |vb, override|\n # NAT settings so network isn't super slow\n override.vm.network :private_network, ip: \"192.168.100.50\"\n vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']\n vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']\n vb.cpus = cpus\n vb.memory = memory\n vb.name = \"vagrant-#{hostname}\"\n\n if is_windows\n override.vm.synced_folder \".\", \"/vagrant\", mount_options: [\"fmode=700\"]\n end\n end\n\n vm.provider 'parallels' do |prl, override|\n override.vm.network :private_network, ip: \"192.168.100.50\"\n prl.update_guest_tools = true\n prl.optimize_power_consumption = false\n prl.cpus = cpus\n prl.memory = memory\n prl.name = \"vagrant-#{hostname}\"\n end\nend",
"def configure(vm_config, number)\n vm_config.vm.network \"public_network\", ip: \"192.168.1.24#{number}\"\n vm_config.vm.host_name = \"level0#{number}.seoshop.net\"\n \n vm_config.vm.provision :puppet do |puppet|\n puppet.manifests_path = \"puppet\"\n puppet.module_path = \"puppet/modules\"\n puppet.manifest_file = \"site.pp\"\n end\nend",
"def global_config_from(machine)\n env = machine.env.config_global\n end",
"def configure_cloud\n message \"Configuring master\"\n build_and_send_config_files_in_temp_directory\n remote_configure_instances\n \n nodes.each do |node|\n node.configure\n end \n end",
"def configuration_for(host, use_ssh_config); end",
"def setDefaults\n ips = []\n if $IN_AWS\n [\"public-ipv4\", \"local-ipv4\"].each { |addr|\n begin\n Timeout.timeout(2) do\n ip = URI.open(\"http://169.254.169.254/latest/meta-data/#{addr}\").read\n ips << ip if !ip.nil? and ip.size > 0\n end\n rescue OpenURI::HTTPError, Timeout::Error, SocketError\n # these are ok to ignore\n end\n }\n elsif $IN_GOOGLE\n base_url = \"http://metadata.google.internal/computeMetadata/v1\"\n begin\n Timeout.timeout(2) do\n # TODO iterate across multiple interfaces/access-configs\n ip = URI.open(\"#{base_url}/instance/network-interfaces/0/ip\", \"Metadata-Flavor\" => \"Google\").read\n ips << ip if !ip.nil? and ip.size > 0\n ip = URI.open(\"#{base_url}/instance/network-interfaces/0/access-configs/0/external-ip\", \"Metadata-Flavor\" => \"Google\").read\n ips << ip if !ip.nil? and ip.size > 0\n end\n rescue OpenURI::HTTPError, Timeout::Error, SocketError => e\n # This is fairly normal, just handle it gracefully\n end\n end\n\n\n $CONFIGURABLES[\"allow_invade_foreign_vpcs\"][\"default\"] = false\n $CONFIGURABLES[\"public_address\"][\"default\"] = $possible_addresses.first\n $CONFIGURABLES[\"hostname\"][\"default\"] = Socket.gethostname\n $CONFIGURABLES[\"banner\"][\"default\"] = \"Mu Master at #{$CONFIGURABLES[\"public_address\"][\"default\"]}\"\n if $IN_AWS\n # XXX move this crap to a callback hook for puttering around in the AWS submenu\n aws = JSON.parse(URI.open(\"http://169.254.169.254/latest/dynamic/instance-identity/document\").read)\n iam = nil\n begin\n iam = URI.open(\"http://169.254.169.254/latest/meta-data/iam/security-credentials\").read\n rescue OpenURI::HTTPError, SocketError\n end\n # $CONFIGURABLES[\"aws\"][\"subtree\"][\"account_number\"][\"default\"] = aws[\"accountId\"]\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"region\"][\"default\"] = aws[\"region\"]\n if iam and iam.size > 0\n # XXX can we think of a good way to test our permission set?\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_key\"][\"desc\"] = $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_key\"][\"desc\"] + \". Not necessary if IAM Profile #{iam.bold} has sufficient API access.\"\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_secret\"][\"desc\"] = $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_key\"][\"desc\"] + \". Not necessary if IAM Profile #{iam.bold} has sufficient API access.\"\n end\n end\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"log_bucket_name\"][\"default\"] = $CONFIGURABLES[\"hostname\"][\"default\"]\n $CONFIGURABLES[\"google\"][\"subtree\"][\"log_bucket_name\"][\"default\"] = $CONFIGURABLES[\"hostname\"][\"default\"]\n end",
"def try_vmware_workstation\n # Configure A Few VMware Settings\n [\"vmware_fusion\", \"vmware_workstation.rb\"].each do |vmware|\n vmware_workstation = VMwareWorkStation.new(vmware, config, settings)\n vmware_workstation.configure\n end\n end",
"def start\n create_machine :config_id => self.setting, :cluster_number => 1\n end",
"def configure_vm(vagrant,name,apply_to=nil)\n debug(\"virtual machine: #{name}\") unless apply_to\n apply_to ||= name\n\n # config to apply\n vmcfg=$vms[name]\n\n # apply our default config first\n configure_vm(vagrant,'default',apply_to) if apply_to == name\n\n # apply our templates\n vmcfg['templates'] ||= [ ]\n vmcfg['templates'].each do |tmpl|\n configure_vm(vagrant,tmpl,apply_to)\n end\n\n debug(\"applying template: #{name}\",2,2) unless apply_to == name\n debug(\"applying host config: #{name}\",2,2) if apply_to == name\n # apply remaining config\n vagrant.vm.define apply_to do |host|\n # configure our node\n host.vm.box = vmcfg['vm']['box'] if vmcfg['vm']['box']\n host.vm.hostname = vmcfg['vm']['hostname'] if vmcfg['vm']['hostname'] and apply_to == name\n # vagrant is setting the hostname properly. here's a hacky workaround\n host.vm.provision \"shell\", inline: \"hostname #{vmcfg['vm']['hostname']}\" \\\n if vmcfg['vm']['hostname'] and apply_to == name\n\n configure_providers(host,vmcfg)\n\n [ 'provision', 'network' ].each do |setting|\n vmcfg['vm'][setting] ||= [ ]\n vmcfg['vm'][setting].each do |data|\n data.each do |type,opts|\n opts=Hash[opts.map{ |k,v| [k.to_sym,v] }]\n host.vm.send( setting, type.to_sym, {**opts} )\n end\n end\n end\n\n # setup synced folder\n vmcfg['vm']['synced_folder'] ||= [ ]\n vmcfg['vm']['synced_folder'].each do |folders|\n host.vm.synced_folder *folders\n end\n end\nend",
"def configure(machine, config_name, logger = @log, extra_files = [], chef_version = '16.1.16')\n logger.info(\"Configuring machine #{machine['network']} with #{config_name}\")\n remote_dir = '/tmp/provision'\n within_ssh_session(machine) do |connection|\n install_chef_on_server(connection, chef_version, logger).and_then do\n copy_chef_files(connection, remote_dir, extra_files, logger)\n end.and_then do\n run_chef_solo(config_name, connection, remote_dir, logger)\n end.and_then do\n sudo_exec(connection, \"rm -rf #{remote_dir}\", logger)\n end\n end\n rescue Net::SSH::Exception => e\n Result.error(e.message)\n end",
"def enum_configs\n host = session.session_host\n port = session.session_port\n exec_commands = [\n {\n 'cmd' => '/export verbose',\n 'fn' => 'get_config',\n 'desc' => 'Get Device Config on Mikrotik Device'\n },\n ]\n exec_commands.each do |ec|\n command = ec['cmd']\n cmd_out = session.shell_command(command).gsub(/#{command}/, '')\n print_status(\"Gathering info from #{command}\")\n # detect if we're in pagination and get as much data as possible\n if ec['fn'] == 'get_config'\n mikrotik_routeros_config_eater(host, port, cmd_out.strip)\n else\n cmd_loc = store_loot(\"mikrotik.#{ec['fn']}\",\n 'text/plain',\n session,\n cmd_out.strip,\n \"#{ec['fn']}.txt\",\n ec['desc'])\n vprint_good(\"Saving to #{cmd_loc}\")\n end\n end\n end",
"def system_settings\n #\"ports\" : \"phttp 80 shttp 8080 phttps 443 shttps 8443 ptelnet 23 stelnet 8023 telnets 992\"\n # Due to a bug in the BHR, we can't change the primary HTTP port for remote administration yet... leaving out.\n tags = %w(-secondary_http -primary_https -secondary_https -telnet -secondary_telnet -secure_telnet)\n values = tags.inject(\"\") { |x, d| x << \"#{d} #{rand(rand(100)+1 > 10 ? 1023 : 65534)+1} \" }.strip\n condition = values.scan(/-.*?\\d{1,5}/).inject(\"\") { |x, d| x << d.delete(\"-\").capitalize.sub('_', ' ').sub('https', 'HTTPS').sub('http', 'HTTP').sub('telnet', 'Telnet').sub('secure', 'Secure').sub(/(\\d{1,5})/, 'on port \\1')+\"\\n\" }.strip\n return { \"system_settings\" => { \"section\" => \"advanced-system settings\", \"ports\" => values }}, condition\nend",
"def pull_config\n output = VirtualBox.run_command! ['VBoxManage', '--nologo', 'showvminfo',\n '--machinereadable', uid]\n config = self.class.parse_machine_readable output\n \n self.name = config['name']\n self.uid = config['UUID']\n board.from_params config\n \n nic_count = config.keys.select { |key| /^nic\\d+$/ =~ key }.max[3..-1].to_i\n 1.upto nic_count do |index|\n if config[\"nic#{index}\"] == 'none'\n nics[index - 1] = nil\n else\n nics[index - 1] ||= VirtualBox::Vm::Nic.new\n nics[index - 1].from_params config, index\n end\n end\n\n bus_count = 1 + (config.keys.select { |key|\n /^storagecontrollername\\d+$/ =~ key\n }.max || \"storagecontrollername-1\")[21..-1].to_i\n 0.upto bus_count - 1 do |index|\n io_buses[index] ||= VirtualBox::Vm::IoBus.new\n io_buses[index].from_params config, index\n end\n \n self\n end",
"def configure_networking(\n machine,\n instance_profile,\n provider = 'virtualbox'\n)\n\n instance_networking = lookup_values_yaml(instance_profile, ['providers', provider, 'instance', 'networking'])\n\n return false unless instance_networking\n\n name = replace_characters_string(lookup_values_yaml(instance_profile, ['name']))\n\n configure_interfaces(machine, name, instance_networking)\n\n configure_forwarded_ports(machine, name, instance_networking)\n\nend",
"def configure\n load_all_configs \n end",
"def configurations; end",
"def configure_virtualbox(host,vmcfg)\n host.vm.provider \"virtualbox\" do |pcfg|\n pcfg.memory = vmcfg['vm']['memory'] if vmcfg['vm']['memory']\n pcfg.customize [\"modifyvm\", :id, \"--cpus\", vmcfg['vm']['cpu']] if vmcfg['vm']['cpu'] \n end\nend",
"def host_config\n { 'Binds' => @binds,\n 'Privileged' => @privileged,\n 'NetworkMode' => @networkmode.to_s }\n end",
"def configure\n if @opts[:docker]\n Souschef::Print.info 'Creating Docker configuration .kitchen.local.yml'\n write(:docker, Souschef::Testkitchen::Docker.new(@cookbook).yaml)\n end\n if @opts[:solusvm]\n Souschef::Print.info 'Creating SolusVM configuraton .kitchen.local.yml'\n write(:solusvm, Souschef::Testkitchen::Solusvm.new(@cookbook).yaml)\n end\n\n Souschef::Print.info 'Creating Vagrant configuration in .kitchen.yml'\n write(:virtualbox, Souschef::Testkitchen::Virtualbox.new(@cookbook).yaml)\n end",
"def DefProperties\n defProperty('env', 'ORBIT', \"testbed to be used: ORBIT, NEPTUNE\")\n defProperty('initialChannels', '', \"initial channels to be used on all the nodes\")\n defProperty('mdebug', '', \"set to yes if you want to enable debug (currently only for l2r)\")\n defProperty('stats', '', \"number of seconds between each collection of statistics. 0 to avoid at all collecting statistics.\")\n defProperty('setAp', '', \"IBSS id to set on interfaces in ad-hoc mode: the following command is called: iwconfig <interface> ap <value_given>\")\n defProperty('startTcpdump', 'no', \"set to yes to have Tcpdump started on nodes\")\n defProperty('channels', nil, \"comma separated list of channels to use\")\n defProperty('stabilizeDelay', '', \"time to wait for the network to stabilize before starting the experiment\")\n defProperty('wifiStandard', '', \"wifi standard (e.g. a or n)\")\n end",
"def output_current_settings\n output_pe_infrastructure_error_and_exit if unknown_pe_infrastructure?\n\n is_monolithic = monolithic?\n with_compile_masters = with_compile_masters?\n with_external_postgresql = with_external_postgresql?\n\n output_pe_infrastucture_summary(is_monolithic, with_compile_masters, with_external_postgresql)\n\n # Primary Master: Applicable to Monolithic and Split Infrastructures.\n @primary_masters.each do |certname|\n settings, duplicates = get_settings_for_node(certname, tunable_settings)\n output_node_settings('Primary Master', certname, settings, duplicates)\n end\n\n # Replica Master: Applicable to Monolithic Infrastructures.\n @replica_masters.each do |certname|\n settings, duplicates = get_settings_for_node(certname, tunable_settings)\n output_node_settings('Replica Master', certname, settings, duplicates)\n end\n\n unless is_monolithic\n # Console Host: Specific to Split Infrastructures. By default, a list of one.\n @console_hosts.each do |certname|\n settings, duplicates = get_settings_for_node(certname, tunable_settings)\n output_node_settings('Console Host', certname, settings, duplicates)\n end\n\n # PuppetDB Host: Specific to Split Infrastructures. By default, a list of one.\n @puppetdb_hosts.each do |certname|\n settings, duplicates = get_settings_for_node(certname, tunable_settings)\n output_node_settings('PuppetDB Host', certname, settings, duplicates)\n end\n end\n\n # External PostgreSQL Host: Applicable to Monolithic and Split Infrastructures.\n if with_external_postgresql\n @database_hosts.each do |certname|\n settings, duplicates = get_settings_for_node(certname, tunable_settings)\n output_node_settings('External PostgreSQL Host', certname, settings, duplicates)\n end\n if @database_hosts.count.zero?\n settings, duplicates = get_settings_for_node(@pe_database_host, tunable_settings)\n output_node_settings('External PostgreSQL Host', @pe_database_host, settings, duplicates)\n end\n end\n\n # Compile Masters: Applicable to Monolithic and Split Infrastructures.\n if with_compile_masters\n @compile_masters.each do |certname|\n settings, duplicates = get_settings_for_node(certname, tunable_settings)\n output_node_settings('Compile Master', certname, settings, duplicates)\n end\n end\n end",
"def small(config)\n config.vm.provider \"virtualbox\" do |v|\n v.memory = 512 \n v.cpus = 1\n end\nend",
"def configure_tpm2_0_tools(hosts)\n start_tpm2sim_on(hosts)\n config_abrmd_for_tpm2sim_on(hosts)\nend",
"def setup_common(id, options = {})\n node = options[:for_node]\n options[:memory] ||= 1024\n\n # Base setup: Ubuntu Server 14.04 LTS (Trusty Tahr) 64-bit for Parallels\n node.vm.box = \"parallels/ubuntu-14.04\"\n\n # Setup provider\n node.vm.provider \"parallels\" do |provider|\n provider.memory = options[:memory]\n end\n\n # Puppet setup\n node.vm.provision :puppet do |pp|\n pp.module_path = \"Puppet/modules\"\n pp.manifests_path = \"Puppet/manifests\"\n pp.manifest_file = \"init_#{id}.pp\"\n pp.hiera_config_path = \"Hiera/#{id}.yaml\"\n end\nend",
"def configure_vms(config)\n $vms.each do |key,vm_config|\n # pp vm_config\n config.vm.define key, autostart: vm_config['autostart'] || false do |node|\n # node.ssh.insert_key = true\n # node.ssh.username = \"toto\"\n \n configure_node(vm_config, node)\n vm_config_copy = object_clone(vm_config)\n vm_config_copy.delete('packer')\n # generate packer\n packer_gen(vm_config)\n log_to_file(\"vms/#{vm_config['lib']['namespace']}/#{vm_config['lib']['key']}.yaml\", vm_config_copy.sort_by_key(true).to_h.to_yaml)\n end\n end\nend",
"def node_basic_config(node)\n\t\tconfig, service = lib('requirements'), lib('services')\n\t\t{'name' => node, 'selenium-version' => config[\"selenium\"][\"version\"], 'kickstart' => service[\"kickstart-server\"]}\n\tend",
"def apply_system_defaults\n if @region.nil? && @zone.nil?\n @region, @zone = Rudy::DEFAULT_REGION, Rudy::DEFAULT_ZONE\n elsif @region.nil?\n @region = @zone.to_s.gsub(/[a-z]$/, '').to_sym\n elsif @zone.nil?\n @zone = \"#{@region}b\".to_sym\n end\n \n @environment ||= Rudy::DEFAULT_ENVIRONMENT\n @role ||= Rudy::DEFAULT_ROLE\n @localhost ||= Rudy.sysinfo.hostname || 'localhost'\n @auto = false if @auto.nil?\n end",
"def configure_providers(host,vmcfg)\n providers = [ 'virtualbox', 'vmware_fusion' ]\n vmcfg['vm']['gui'] ||= false\n providers.each do |p|\n host.vm.provider p do |pcfg|\n pcfg.gui = true if vmcfg['vm']['gui']\n end\n begin\n send(\"configure_#{p}\",host,vmcfg)\n rescue NoMethodError\n # do nothing\n end\n end\nend",
"def configure; end",
"def define_centos_5\n { 'name' => 'centos-5.10',\n 'driver_config' => { 'template' => 'centos-5.10-x86_64-solus',\n 'plan' => 'VPS2',\n 'node' => 'chefsolushv',\n 'privileged' => 'true',\n 'type' => 'xen',\n 'platform' => 'centos',\n 'use_sudo' => 'false',\n 'username' => 'internal' } }\n end",
"def initialize(machine, config)\n @machine = machine\n @config = config\n end",
"def initialize(machine, config)\n @machine = machine\n @config = config\n end",
"def add_sibling_machine_configs; end",
"def setup\r\n setup_wiki\r\n setup_host_map\r\n setup_host\r\n end",
"def beaker_hosts\n ENV['BEAKER_HOSTS'] || 'centos7-64a'\nend",
"def define_platforms\n [define_centos_5, define_centos_6, define_run_list]\n end",
"def kitchen_config\n {\n 'driver' => driver_config,\n 'transport' => transport_config,\n 'provisioner' => provisioner_config,\n 'platforms' => expand_platforms.map {|name| platform_config(name) },\n 'suites' => [suite_config],\n }\n end",
"def configureStartup\n `chkconfig --add nagios`\n `chkconfig --level 35 nagios on`\n `chkconfig --add httpd`\n `chkconfig --level 35 httpd on`\n `iptables -I INPUT 1 -s #{@ips[0]}/#{@mask} -p tcp -m tcp --dport 80 -j ACCEPT`\n `iptables -I INPUT 1 -s #{@ips[0]}/#{@mask} -p udp -m udp --dport 80 -j ACCEPT`\n `service iptables save`\n `service iptables restart`\n end",
"def defineCommonVM(config)\n\tconfig.ssh.insert_key = true\n\n\t# Configure how much memory and CPU cores each VM should have.\n\tconfig.vm.provider :virtualbox do |vb|\n\t\tvb.gui = $vmGUIEnabled\n\t\tvb.memory = $vmMemory\n\t\tvb.cpus = $vmCPUCores\n\tend\nend",
"def set_cpu_and_ram(vm_name, vm_config, cpu, ram) \n\n ram_in_gb = (ram / 1024.0)\n\n # round evertything that bigger that 1\n if ram_in_gb >= 1\n ram_in_gb = ram_in_gb.round\n end\n\n log_info_light(\"#{vm_name}: #{ram_in_gb}Gb RAM, #{cpu} CPU\")\n\n vm_config.vm.provider \"virtualbox\" do |v|\n \n v.linked_clone = false\n \n v.memory = ram\n v.cpus = cpu\n \n v.gui = false\n \n v.customize ['modifyvm', :id, '--clipboard', 'bidirectional'] \n v.customize [\"modifyvm\", :id, \"--vram\", 32]\n\n v.customize [\"modifyvm\", :id, \"--audio\", \"none\"]\n v.customize [\"modifyvm\", :id, \"--usb\", \"off\"]\n \n # if Vagrant::VERSION >= '2.2.3'\n # # Vagrant has detected a configuration issue which exposes a vulnerability with the installed version of VirtualBox\n # # Ensure the guest is trusted to use this configuration or update the NIC type using one of the methods below:\n # # https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type\n \n # v.default_nic_type = \"82543GC\"\n # end\n\n # https://github.com/hashicorp/vagrant/issues/6812#issuecomment-171981576\n # Vagrant is reconnecting from scratch, sometimes literally before each command in negotiating loop\n v.customize ['modifyvm', :id, \"--natdnshostresolver1\", \"off\"]\n end\n \n # tracking only our own boxes\n # subpoint | uplift\n box_name = 'other'\n box_version = 'other'\n\n begin\n box_name = vm_config.vm.box()\n rescue => e\n box_name = 'not_set'\n end\n\n if( box_name.to_s.downcase.start_with?('subpoint') || box_name.to_s.downcase.start_with?('uplift') ) \n begin\n box_version = vm_config.vm.box_version()\n rescue => e\n box_version = 'not_set'\n end\n else \n box_name = 'other'\n box_version = 'other'\n end\n\n data = {\n 'vm_name': vm_name,\n 'cpus': cpu,\n 'memory': ram,\n 'box_name': box_name,\n 'box_version': box_version\n }\n\n _track_ai_event(__method__, data)\n end",
"def define_vm config, role, index, ip, memory = 512\n id = (index + 1).to_s.rjust(3, '0')\n config.vm.define \"#{role}_#{id}\" do |box|\n box.vm.customize [ \"modifyvm\", :id, \"--memory\", memory ]\n box.vm.box = \"centos_6_3\"\n box.vm.box_url = \"https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box\"\n box.vm.network :hostonly, \"192.168.34.#{ip}\", :netmask => \"255.255.255.0\"\n box.vm.host_name = \"#{role.downcase.gsub(/[^a-z0-9]+/, '-')}-#{id}.esi.dev\"\n #box.vm.provision :shell, :path => \"script/bootstrap-vm.sh\"\n box.vm.provision :puppet, :module_path => \"modules\" do |p|\n p.manifests_path = \"manifests\"\n p.manifest_file = \"site.pp\"\n end\n end\nend",
"def configure_interfaces\n node_servers.each do |svinfo|\n gretap_interfaces(svinfo).each do |ifname, ifcfg|\n host_name = svinfo['hostname']\n virtual_addr = virtual_address(ifcfg)\n\n cloudconductor_server_interface \"#{host_name}_#{ifname}\" do\n action :create\n hostname host_name\n if_name ifname\n network ifcfg['network']\n security_groups ifcfg['security_groups']\n virtual_address virtual_addr\n end\n end\n end\nend",
"def genConf\n conf=\"auto #{@device}\\n\"\n if (ip != nil && netmask != nil)\n conf+=%(iface #{@device} inet static\n address #{@ip}\n netmask #{@netmask}\n)\n else\n conf+=\"iface #{@device} inet dhcp\\n\"\n end\n end",
"def configuring what\n puts \"Configuring: #{what}...\"\n end",
"def set_default_values\n # Ethernet configuration\n self.network_1_id ||= 1\n self.ethernet_ip_assignment_method_id ||=1\n # GRPS\n self.gprs_mtu ||= 1450\n # PSTN\n self.pstn_mtu ||= 1500\n # Time configuration\n self.time_zone ||= 'UTC'\n # Interval configuration\n self.configuration_update_interval ||= 3600\n self.status_interval ||= 3600\n self.send_data_interval ||= 86400\n # Software update configuration\n self.auto_update ||= false\n self.software_update_interval ||= 604800\n self.repo_type ||= 'stable'\n # Log configuration\n self.send_log_files ||= false\n # State XML\n self.state_xml ||= \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n<modified>true</modified>\\n\"\n end",
"def configHost\n unless File.open('nagios.cfg').read() =~ /hosts.cfg/ && File.open('nagios.cfg').read() =~ /services.cfg/\n\tcfg = File.read('nagios.cfg')\n\tcfg = cfg.gsub(/templates.cfg/, \"templates.cfg\\ncfg_file=/usr/local/nagios/etc/hosts.cfg\\ncfg_file=/usr/local/nagios/etc/services.cfg\")\n\tFile.open('nagios.cfg', 'w') { |file| file.puts cfg }\n end\n File.open('hosts.cfg', 'a+') { |file|\n\tfile.puts \"define host{\\nname\\t\\t\\tlinux-box\\nuse\\t\\t\\tgeneric-host\\ncheck_period\\t\\t24x7\\ncheck_interval\\t\\t5\\nretry_interval\\t\\t1\\nmax_check_attempts\\t10\\ncheck_command\\t\\tcheck-host-alive\\nnotification_period\\t24x7\\nnotification_interval\\t30\\nnotification_options\\td,r\\ncontact_groups\\t\\tadmins\\nregister\\t\\t\\t0\\n}\\n\" unless File.open('hosts.cfg').read() =~ /name\\t\\t\\tlinux-box/\n\[email protected] do |x|\n\t file.puts \"define host{\\nuse\\t\\t\\tlinux-box\\nhost_name\\t\\t#{@names[x]}\\nalias\\t\\t\\t#{@names[x]}\\naddress\\t\\t\\t#{@ips[x]}\\n}\\n\\n\"\n\tend\n }\n File.open('services.cfg', 'a') { |file| \n @names.length.times do |x|\n file.puts \"define service{\\n\\tuse\\t\\t\\tgeneric-service\\n\\thost_name\\t\\t#{@names[x]}\\n\\tservice_description\\tCPU Load\\n\\tcheck_command\\t\\tcheck_nrpe!check_load\\n}\\n\\ndefine service{\\n\\tuse\\t\\t\\tgeneric-service\\n\\thost_name\\t\\t#{@names[x]}\\n\\tservice_description\\tTotal Processes\\n\\tcheck_command\\t\\tcheck_nrpe!check_total_procs\\n}\\n\\ndefine service{\\n\\tuse\\t\\t\\tgeneric-service\\n\\thost_name\\t\\t#{@names[x]}\\n\\tservice_description\\tCurrent Users\\n\\tcheck_command\\t\\tcheck_nrpe!check_users\\n}\\n\\ndefine service{\\n\\tuse\\t\\t\\tgeneric-service\\n\\thost_name\\t\\t#{@names[x]}\\n\\tservice_description\\tSSH\\n\\tcheck_command\\t\\tcheck_ssh\\n}\\n\\ndefine service{\\n\\tuse\\t\\t\\tgeneric-service\\n\\thost_name\\t\\t#{@names[x]}\\n\\tservice_description\\tPING\\n\\tcheck_command\\t\\tcheck_ping!100.0,20%!500.0,60%\\n}\\n\\n\" \n end\n }\n end",
"def execute(&each_mach)\n routine_separator(:startup)\n unless @routine\n STDERR.puts \"[this is a generic startup routine]\"\n @routine = {}\n end\n machines = generic_machine_runner(:create) \n machines\n end",
"def tunable_settings\n [\n 'puppet_enterprise::master::puppetserver::jruby_max_active_instances',\n 'puppet_enterprise::master::puppetserver::reserved_code_cache',\n 'puppet_enterprise::profile::amq::broker::heap_mb',\n 'puppet_enterprise::profile::console::java_args',\n 'puppet_enterprise::profile::database::shared_buffers',\n 'puppet_enterprise::profile::master::java_args',\n 'puppet_enterprise::profile::orchestrator::java_args',\n 'puppet_enterprise::profile::puppetdb::java_args',\n 'puppet_enterprise::puppetdb::command_processing_threads',\n ]\n end",
"def configure_vm(vm, **opts)\n\n vm.box = opts.fetch(:box, \"bento/ubuntu-16.04\")\n vm.network :private_network, ip: opts[:private_ip]\n\n vm.provider \"virtualbox\" do |vb|\n vb.memory = 4096\n vb.cpus = 2\n end\n \n # Disable default share, because we dont use it\n vm.synced_folder \".\", \"/vagrant\", disabled: true\nend",
"def settings home = nil\n home ||= '/netnumen/ems'\n\n main_ip = ENV['netnumen_main_ip'].to_s.nil\n\n if not main_ip.nil?\n args = {\n 'home' => home,\n 'main_ip' => main_ip\n }\n\n DistributeCommand::Function::netnumen_sptn_settings args\n end\n\n anodes = ENV['netnumen_anodes'].to_s.nil\n cnodes = ENV['netnumen_cnodes'].to_s.nil\n\n if not anodes.nil? or not cnodes.nil?\n args = {\n 'home' => home,\n 'ip' => docker_ip,\n 'anodes' => anodes,\n 'cnodes' => cnodes\n }\n\n DistributeCommand::Function::netnumen_sptn_cluster_settings args\n end\n end",
"def initial_agent_settings(vm_id, agent_id, network_spec, ephemeral_disk,\n existing_disk, environment, blobstore, mbus)\n disk_letters = ('a'..'z').to_a\n config = { vm: { name: vm_id }, agent_id: agent_id,\n environment: environment, blobstore: blobstore,\n mbus: mbus, networks: network_spec,\n disks: { system: \"/dev/sd#{disk_letters.shift}\",\n persistent: {} } }\n if ephemeral_disk\n config[:disks][:ephemeral] = \"/dev/sd#{disk_letters.shift}\"\n end\n config\n end",
"def configure_instances(\n machine,\n instance_profile,\n provider = 'virtualbox'\n)\n\n name = replace_characters_string(lookup_values_yaml(instance_profile, ['name']))\n\n if $profile_names_loaded.include?(\"#{name}-#{provider}\")\n exit_with_message(\"profile name [#{name}] with provider [#{provider}] is already defined in another location.\")\n else\n $profile_names_loaded.push(\"#{name}-#{provider}\")\n end\n\n provider_dir = \"#{PROVIDERS_DIR}/#{provider}\"\n\n if $provider_loaded_last != provider\n if File.directory?(provider_dir)\n ruby_files = Find.find(provider_dir)\n ruby_files and ruby_files.each do |ruby_file|\n load ruby_file if ruby_file=~/\\.rb/\n end\n else\n handle_message(\"failed to load provider directory [#{provider_dir}].\")\n end\n\n $provider_loaded_last = provider\n end\n\n case provider\n when 'libvirt'\n configure_instance(machine, instance_profile)\n when 'virtualbox'\n configure_instance(machine, instance_profile)\n when 'vmware'\n configure_instance(machine, instance_profile)\n else\n exit_with_message(\"instance provider [#{provider}] for instance [#{name}] is not supported.\")\n end\nend",
"def configure_instance(\n machine,\n instance_profile,\n provider = 'vmware'\n)\n\n name = replace_characters_string(lookup_values_yaml(instance_profile, ['name']))\n\n handle_message(\"instance [#{name}] provider [#{provider}] not implemented.\")\n\nend",
"def initialize(opts)\n resume = opts[:resume]\n source_host_def = define_source(opts[:config])\n source_host_ssh = CLI.spinner(\"Logging in to #{source_host_def[:host]}\") do\n host_login(source_host_def)\n end\n\n profile = CLI.spinner(\"Checking source host\") do\n profile = Profile.new(source_host_ssh)\n profile.build\n profile\n end\n platform = Platform::V2.new(profile[:cpe])\n\n memory = profile[:memory]\n memory_percent = memory[:mem_used].to_f / memory[:total] * 100\n swapping = memory[:swapping?]\n ftag = \"#{CLI.bold}%15s#{CLI.reset}:\"\n hist_mem = profile[:memory_hist][:mem_used]\n\n puts\n puts \"#{CLI.bold}System Information#{CLI.reset}\"\n puts \"#{ftag} #{platform} (#{profile[:cpe]})\" % \"OS\"\n puts \"#{ftag} #{profile[:arch]}\" % \"Arch\"\n puts \"#{ftag} #{profile[:hostname]}\" % \"Hostname\"\n puts\n\n puts \"#{CLI.bold}CPU Statistics#{CLI.reset}\"\n puts \"#{ftag} %d\" % [\"CPU Count\", profile[:cpu][:count]]\n puts \"#{ftag} %d MHz\" % [\"CPU Speed\", profile[:cpu][:speed]]\n puts \n\n puts \"#{CLI.bold}Memory Statistics#{CLI.reset}\"\n puts \"#{ftag} %d MiB\" % [\"Total RAM\", memory[:total]]\n puts \"#{ftag} %d MiB (%2.1f%%)\" % [\"RAM Used\", memory[:mem_used],\n memory_percent]\n puts \"#{ftag} %d MiB\" % [\"Swap Used\", memory[:swap_used]] if swapping\n puts \"#{ftag} %d%%\" % [\"Hist. RAM Used\", hist_mem] unless hist_mem.nil?\n puts \n\n puts \"#{CLI.bold}Hard Disk Statistics#{CLI.reset}\"\n puts \"#{ftag} %2.1f GB\" % [\"Disk Used\", profile[:disk]]\n puts\n\n puts \"#{CLI.bold}System Statistics#{CLI.reset}\"\n puts \"#{ftag} #{profile[:io][:uptime]}\" % \"Uptime\"\n puts \"#{ftag} #{profile[:io][:wait]}\" % \"I/O Wait\"\n puts\n\n puts \"#{CLI.bold}IP Information#{CLI.reset}\"\n puts \"#{ftag} #{profile[:ip][:public].join(', ')}\" % \"Public\"\n puts \"#{ftag} #{profile[:ip][:private].join(', ')}\" % \"Private\"\n puts\n\n puts \"#{CLI.bold}MySQL Databases#{CLI.reset}\"\n puts \"#{ftag} #{profile[:db][:count]}\" % \"Number\"\n puts \"#{ftag} #{profile[:db][:size]}\" % \"Total Size\"\n puts\n\n puts \"#{CLI.bold}Libraries#{CLI.reset}\"\n puts \"#{ftag} #{profile[:lib][:libc]}\" % \"LIBC\"\n puts \"#{ftag} #{profile[:lib][:perl]}\" % \"Perl\"\n puts \"#{ftag} #{profile[:lib][:python]}\" % \"Python\"\n puts \"#{ftag} #{profile[:lib][:ruby]}\" % \"Ruby\"\n puts \"#{ftag} #{profile[:lib][:php]}\" % \"PHP\"\n unless profile.warnings.empty?\n puts\n print CLI.red + CLI.bold\n profile.warnings.each { |warning| puts warning }\n print CLI.reset\n end\n\n source_host_ssh.logout!\n end",
"def gen_nec_config\n config = \"switch :: EtherSwitch; \\\nFromDevice(#{@netif}, PROMISC true) -> [0]switch; \\\nswitch[0] -> Queue -> ToDevice(#{@netif}); \"\n\n i = 1\n @mobiles.each do |mac, client|\n next unless client.ul && client.dl && client.ip\n config << \"AddressInfo(c_#{i} #{client.ip} #{client.mac}); \\\narr_#{i} :: ARPResponder(c_#{i}); \\\narq_#{i} :: ARPQuerier(c_#{i}); \\\n\\\nScript(write arq_#{i}.gateway #{@defgw}, write arq_#{i}.netmask #{@netmask}); \\\n\\\nulgre_#{i} :: FromDevice(#{client.ul}); \\\ndlgre_#{i} :: ToDevice(#{client.dl}); \\\n\\\nswitch[#{i}] -> cf_#{i} :: Classifier(12/0806 20/0001, 12/0806 20/0002, -); \\\ncf_#{i}[0] -> arr_#{i} -> [#{i}]switch; \\\ncf_#{i}[1] -> [1]arq_#{i}; \\\ncf_#{i}[2] -> Strip(14) -> dlgreq_#{i} :: Queue -> dlgre_#{i}; \\\nulgre_#{i} -> GetIPAddress(16) -> arq_#{i} -> [#{i}]switch; \"\n i += 1\n end\n config\n end",
"def define_centos_6\n { 'name' => 'centos-6-5',\n 'driver_config' => { 'template' => 'centos-6.5-x86_64-solus',\n 'plan' => 'VPS2',\n 'node' => 'chefsolushv',\n 'privileged' => 'true',\n 'type' => 'xen',\n 'platform' => 'centos',\n 'use_sudo' => 'false',\n 'username' => 'internal' } }\n end",
"def windows_platform_config(name)\n {\n 'driver' => ec2_driver_config.merge({\n 'instance_type' => 'm3.medium',\n 'retryable_tries' => 120,\n }),\n 'provisioner' => {\n 'product_name' => 'chef',\n 'channel' => chef_version ? 'stable' : 'current',\n 'product_version' => chef_version,\n },\n 'transport' => {\n 'name' => 'winrm',\n 'ssh_key' => \"#{base}/test/ec2/ssh.key\",\n },\n }.tap do |cfg|\n if name == 'windows-2008sp2'\n cfg['driver']['image_id'] = 'ami-f6a043e0'\n cfg['driver']['instance_type'] = 'm1.medium'\n cfg['driver']['subnet_id'] = ENV['AWS_SUBNET_ID'] || DEFAULT_EC2_LEGACY_INSTANCES_SUBNET_ID\n cfg['provisioner']['architecture'] = 'i386'\n end\n end\n end",
"def config\n machined.config\n end",
"def build options\n $conf.machine_name = options.shift\n return say(Help.new.syntax) unless $conf.machine_name\n init\n @core.package 'Machinesfile'\n\n @core.task options if options.any?\n\n ssh_options = {:paranoid => false}\n if $conf.machine.cloud\n username = $conf.machine.cloud.username\n ssh_options[:keys] = [$conf.machine.cloud.private_key_path]\n else\n username = $conf.machine.user\n ssh_options[:password] = $conf.password\n end\n\n if $conf.log_only\n $conf.commands.each do |command|\n command.run\n end\n else\n Kernel.trap(\"INT\") { prepare_to_exit }\n begin\n Command.ssh = Net::SSH.start $conf.machine.address, username, ssh_options\n Command.scp = Net::SCP.new(Command.ssh)\n $conf.commands.each do |command|\n command.run\n Command.file.flush\n exit if $exit_requested\n end\n rescue Errno::ETIMEDOUT => e\n say e.message\n say 'Check the IP address in machines.yml'\n ensure\n Command.ssh.close if Command.ssh\n end\n end\n end",
"def provision_chef_common(chef, key, chef_config, vm_config)\n # set_instance_variable(chef_config, chef, 'environment', '_default' )\n # set_instance_variable(chef_config, chef, 'version', '12.19.36' )\n properties = [\n 'attempts',\n 'enable_reporting',\n 'encrypted_data_bag_secret_key_path',\n 'environment',\n 'run_list',\n 'verbose_logging',\n 'version'\n ]\n properties.each do | property_name |\n set_instance_variable(chef_config, chef, property_name )\n end\nend",
"def configure_ai_vbox_vm(client_name,client_mac,client_arch,client_os,client_rel)\n client_os=\"Solaris11_64\"\n configure_vbox_vm(client_name,client_mac,client_os)\n return\nend",
"def configure_chef_provisioners\n chef_provisioners.each { |prov| configure_chef(prov.config) }\n end",
"def config_lv_define_box2(vm, conf)\n vm.define conf['hostname_box2'] do |box2|\n box2.vm.hostname = conf['hostname_box2']\n box2.vm.box = conf['imagename_box2']\n box2.vm.network :private_network,\n :libvirt__network_name => \"mgmt\",\n :mac => conf['libvirt_mgmt_mac_box2'],\n :ip => conf['libvirt_mgmt_ip_box2'],\n :libvirt__netmask => conf['libvirt_mgmt_netmask_box2'],\n :libvirt__dhcp_enabled => false,\n :libvirt__forward_mode => \"none\",\n :autostart => true\n box2.vm.network :public_network,\n :network_name => \"ext\",\n :ip => conf['libvirt_ext_ip_box2'],\n :netmask => conf['libvirt_ext_netmask_box2'],\n :gateway => conf['libvirt_ext_gateway_box2'],\n :mac => conf['libvirt_ext_mac_box2'],\n :dev => conf['libvirt_dev'],\n :type => conf['libvirt_type'],\n :mode => conf['libvirt_mode']\n box2.vm.network :private_network,\n :libvirt__network_name => \"ceph\",\n :mac => conf['libvirt_ceph_mac_box2'],\n :ip => conf['libvirt_ceph_ip_box2'],\n :libvirt__netmask => conf['libvirt_ceph_netmask_box2'],\n :libvirt__dhcp_enabled => false,\n :libvirt__forward_mode => \"none\",\n :autostart => true\n box2.vm.network :private_network,\n :libvirt__network_name => \"vm_tunnel\",\n :mac => conf['libvirt_tunnel_mac_box2'],\n :ip => conf['libvirt_tunnel_ip_box2'],\n :libvirt__netmask => conf['libvirt_tunnel_netmask_box2'],\n :libvirt__dhcp_enabled => false,\n :libvirt__forward_mode => \"none\",\n :autostart => true\n box2.vm.provider :libvirt do |domain|\n domain.memory = conf['memory_box2']\n domain.cpus = conf['cpus_box2']\n domain.management_network_name = 'vagrantmgmt'\n domain.management_network_address = conf['libvirt_vagrantmgmt_ip_box2']\n domain.management_network_mode = conf['libvirt_mgmt_mode']\n end\n config_provision(box2.vm, conf)\n end\nend",
"def configdir\n\t\tetc/\"cpu-sentinel\"\n\tend",
"def config\n details = Chassis.pkgs.dup\n details << [\"tags\"] + Chassis.tags unless Chassis.tags.empty?\n details << [\"roles\"] + Chassis.roles unless Chassis.roles.empty?\n details << [\"kind\"] + [Chassis.node_kind] if Chassis.node_kind\n details << Chassis.extra_config if Chassis.extra_config\n details\n end",
"def configure_other_parallels_vm(options)\n options['os-type']=\"other\"\n configure_parallels_vm(options)\n return\nend",
"def configure_ai_parallels_vm(options)\n options['os-type']=\"solaris-11\"\n configure_parallels_vm(options)\n return\nend",
"def set_up_server\n node = Chef::Node.new\n node.name 'nothing'\n node.automatic[:platform] = 'kitchen_metal'\n node.automatic[:platform_version] = 'kitchen_metal'\n Chef::Config.local_mode = true\n run_context = Chef::RunContext.new(node, {},\n Chef::EventDispatch::Dispatcher.new(Chef::Formatters::Doc.new(STDOUT,STDERR)))\n recipe_exec = Chef::Recipe.new('kitchen_vagrant_metal',\n 'kitchen_vagrant_metal', run_context)\n\n # We require a platform, but layout in driver is optional\n recipe_exec.instance_eval get_platform_recipe\n recipe = get_driver_recipe\n recipe_exec.instance_eval recipe if recipe\n return run_context\n end",
"def basic_configuration\n b_path = `which barman`.chomp\n self[:binary] = b_path.empty? ? '/usr/bin/barman' : b_path\n self[:barman_home] = ENV['HOME']\n end",
"def customize_cloud_config(cloud_init_yaml, vm_i)\n case vm_i\n when 1 then cloud_init_yaml['coreos']['fleet']['metadata'] = 'role=head'\n when 2 then cloud_init_yaml['coreos']['fleet']['metadata'] = 'role=proxy'\n when 3 then cloud_init_yaml['coreos']['fleet']['metadata'] = 'role=web'\n when 4 then cloud_init_yaml['coreos']['fleet']['metadata'] = 'role=web'\n end\nend",
"def handle_host(config, host, master_ip, bridge)\n config.vm.define host[\"name\"] do |node|\n node.vm.provider \"virtualbox\" do |vb|\n vb.name = host[\"name\"]\n end\n node.vm.box = host[\"box\"]\n node.vm.hostname = host[\"name\"]\n if host[\"private_net\"]\n node.vm.network \"private_network\", ip: host[\"ip\"]\n else\n node.vm.network \"public_network\", bridge: bridge, ip: host[\"ip\"]\n end\n node.vm.provision :salt do |salt|\n # The Salt minion_id config is currently ignored and Salt bootstrap\n # uses one of the hostnames that it finds. This is not necessarily\n # the hostnam set here. It worked on the test box that was used\n # originally that did not have a hostname previously set. But,\n # failed on public boxes that already had set a separate hostname.\n # For now, set it in bootstrap_options.\n #salt.minion_id = \"testminionname\"\n salt.install_type = \"stable\"\n bootstrap_options = \"-D -A #{master_ip} -i #{host[\"name\"]}\"\n salt.minion_key = File.join(KEY_DIR, host[\"name\"]) + \".pem\"\n salt.minion_pub = File.join(KEY_DIR, host[\"name\"]) + \".pub\"\n master_cfg = {}\n if host[\"minions\"]\n # There are relative minions of this node, so set up salt-master and\n # salt-minion. Preseed this nodes master with keys for those minions.\n minion_keys = {}\n host[\"minions\"].each do |minion|\n minion_name = minion[\"name\"]\n minion_keys[minion_name] = File.join(KEY_DIR, \"#{minion_name}.pub\")\n end\n master_cfg[\"syndic_master\"] = master_ip\n salt.seed_master = minion_keys\n salt.install_master = true\n salt.install_syndic = true\n end\n if not master_cfg.empty?\n syndic_cfg = JSON.generate(master_cfg)\n bootstrap_options << \" -J '\" << syndic_cfg << \"'\"\n end\n salt.bootstrap_options = bootstrap_options\n end\n end\n if host[\"minions\"]\n # Now set up any nodes listed as minions to this node.\n host[\"minions\"].each do |minion|\n handle_host(config, minion, host[\"ip\"], bridge)\n end\n end\nend",
"def suite_config\n {\n 'name' => 'default',\n 'run_list' => (File.exist?(File.join(base, 'test', 'cookbook')) || File.exist?(File.join(base, 'test', 'cookbooks'))) ? [\"#{cookbook_name}_test\"] : [cookbook_name],\n }\n end",
"def configure(&block); end",
"def configure(&block); end",
"def kitchen_config\n @kitchen_config ||= {\n defaults: {\n driver: Driver::DEFAULT_PLUGIN,\n provisioner: Provisioner::DEFAULT_PLUGIN,\n verifier: Verifier::DEFAULT_PLUGIN,\n transport: lambda do |_suite, platform|\n platform =~ /^win/i ? \"winrm\" : Transport::DEFAULT_PLUGIN\n end,\n },\n kitchen_root: kitchen_root,\n test_base_path: test_base_path,\n log_level: log_level,\n log_overwrite: log_overwrite,\n debug: debug,\n }\n end",
"def per_host\n @per_host = true\n end",
"def define_driver\n { 'name' => 'solusvm',\n 'privileged' => 'true'\n }\n end",
"def machine_options\n opts = {\n convergence_options: {\n bootstrap_proxy: @bootstrap_proxy,\n chef_config: @chef_config,\n chef_version: @chef_version,\n install_sh_path: @install_sh_path\n },\n bootstrap_options: {\n instance_type: @flavor,\n key_name: @key_name,\n security_group_ids: @security_group_ids\n },\n ssh_username: @ssh_username,\n image_id: @image_id,\n use_private_ip_for_ssh: @use_private_ip_for_ssh\n }\n\n # Add any optional machine options\n require 'chef/mixin/deep_merge'\n @subnet_id = Server::Helpers::Component.subnet_id('us-west-2b')\n if @subnet_id\n opts = Chef::Mixin::DeepMerge.hash_only_merge(opts,\n bootstrap_options: { subnet_id: @subnet_id })\n end\n\n opts\n end",
"def config_master_from_scratch(server)\n behavior(:create_stripe, server)\n object_behavior(server, :spot_check_command, \"service mysqld start\")\n#TODO the service name depends on the OS\n# server.spot_check_command(\"service mysql start\")\n behavior(:run_query, \"create database mynewtest\", server)\n behavior(:set_master_dns, server)\n # This sleep is to wait for DNS to settle - must sleep\n sleep 120\n behavior(:run_script, \"backup\", server)\n end",
"def load_defaults\n @dev_port = @default_dev_port\n @dev_pid = @default_dev_pid\n @dev_log = @default_dev_log\n @prod_port = @default_prod_port\n @prod_pid = @default_prod_pid\n @prod_log = @default_prod_log\nend",
"def default(name)\n configure [\"interface #{name}\", 'default switchport']\n end",
"def is_generic_node settings\n # Instance described in settings files\n instance_type settings[:instance_type]\n image_id AwsServiceData.ami_for(settings)\n availability_zones settings[:availability_zones]\n disable_api_termination settings[:disable_api_termination] if settings[:instance_backing] == 'ebs'\n elastic_ip settings[:elastic_ip] if settings[:elastic_ip]\n set_instance_backing settings\n keypair settings[:cluster_name].to_s, File.join(ENV['HOME'], '.chef', 'keypairs')\n has_role settings, \"base_role\"\n settings[:user_data][:attributes][:cluster_name] = settings[:cluster_name]\n settings[:user_data][:attributes][:cluster_role] = settings[:cluster_role]\n security_group_unless_exists settings[:cluster_name].to_s do\n authorize :group_name => settings[:cluster_name].to_s\n end\n security_group do\n authorize :from_port => 22, :to_port => 22\n authorize :from_port => 80, :to_port => 80\n end\n security_group_unless_exists \"default\"\n user 'ubuntu'\n is_spot_priced settings\n sends_aws_keys settings\nend",
"def platform_config(name)\n {\n 'name' => name,\n # On CI enable poise-profiler automatically. Load it here in case the\n # user defines their own suites.\n 'run_list' => ((ENV['CI'] || ENV['DEBUG'] || ENV['PROFILE']) ? %w{poise-profiler} : []),\n }.tap {|cfg| cfg.update(windows_platform_config(name)) if name.include?('windows') }\n end",
"def configure_node(node)\n node.vm.box = \"ubuntu/bionic64\"\n node.vm.box_check_update = true\n node.vm.synced_folder \"./data\", \"/data\"\n node.vm.network \"public_network\"\n node.vm.network \"private_network\", type: \"dhcp\"\n\n node.vm.provider \"virtualbox\" do |v|\n v.gui = false\n v.memory = \"2048\"\n v.cpus = 2\n v.customize [\"modifyvm\", :id, \"--cpuexecutioncap\", \"100\"]\n v.customize [\"modifyvm\", :id, \"--hpet\", \"on\"]\n v.default_nic_type = \"82545EM\"\n end\n\n node.vm.provision \"shell\", inline: <<-SHELL\n apt -y update\n apt -y install build-essential\n apt -y install emacs25-nox\n apt -y install htop\n apt -y install zsh\n apt -y upgrade\n SHELL\nend",
"def configure_ob_vbox_vm(client_name,client_mac,client_arch,client_os,client_rel)\n client_os = \"Linux_64\"\n configure_vbox_vm(client_name,client_mac,client_os)\n return\nend",
"def _init_configuration\n\t\t# Set defaults\n\t\t@setup = { \"create\" => false, \"environment\" => false, \"test\" => true, \"destroy\" => false }\n\t\t@config = false\n\tend",
"def default_authoritative_config_directory\n case node['platform_family']\n when 'debian'\n '/etc/powerdns'\n when 'rhel'\n '/etc/pdns'\n end\nend",
"def connect_to_machine(machine_spec, machine_options)\n Chef::Log.debug('Connect to machine!')\n end",
"def network_config\n return '--net=host' unless @vpn_tunnel\n\n hostname = `hostname`.chomp\n \"--net=container:#{hostname}\"\n end",
"def create_multi_config\n\t\t\t\tFile.open( \"#{$config_path}/#{@host}_disks.cfg\", 'w' ) do |out|\n\t\t\t\t\t\tout.puts \"# Diskfile for host #{@host} generated at #{Time.now}\"\n\t\t\t\t\t\[email protected] do |disk|\n\t\t\t\t\t\t\t\tnext unless disk[:disk]\n\t\t\t\t\t\t\t\twarn = disk[:warn]\n\t\t\t\t\t\t\t\tcrit = disk[:crit]\n\t\t\t\t\t\t\t\twarn = \"$WARN$\" if disk[:warn].nil?\n\t\t\t\t\t\t\t\tcrit = \"$CRIT$\" if disk[:crit].nil?\n\t\t\t\t\t\t\t\tout.puts \"command[#{disk[:disk].tr(\"/\",\"_\")}::check_disk]=check_nrpe -H #{@host} #{$ssl} -c check_disk -a #{warn} '#{crit} -E' #{disk[:disk]}\" if $isbuggy == true\n\t\t\t\t\t\t\t\tout.puts \"command[#{disk[:disk].tr(\"/\",\"_\")}::check_disk]=check_nrpe -H #{@host} #{$ssl} -c check_disk -a #{warn} #{crit} #{disk[:disk]}\" if $isbuggy == false\n\t\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t$log.info \"check_multi config written for host #{@host}\"\n\t\tend",
"def grub_cfg_contents\n @old_dev_names = true\n kopts = ['ro']\n kopts = kopts + ['net.ifnames=0', 'biosdevname=0'] if @old_dev_names\n kernel_opts_normal = (kopts + ['quiet', 'splash']).join(' ')\n kernel_opts_debug = (kopts + ['debug', 'console=tty0']).join(' ')\n\n lines = [\n \"set default=0\",\n \"set gfxpayload=1024x768x24\",\n \"set timeout=5\",\n ]\n\n self.all_os_partitions.each { |os_part|\n lines += [\n \"# #{os_part.label}\",\n \"menuentry \\\"#{os_part.label}\\\" {\",\n \" insmod ext2\",\n \" search --label --set=root --no-floppy #{os_part.label}\",\n \" linux /vmlinuz root=LABEL=#{os_part.label} #{kernel_opts_normal}\",\n \" initrd /initrd.img\",\n \"}\",\n \"\",\n \"# #{os_part.label} (debug)\",\n \"menuentry \\\"#{os_part.label} (debug)\\\" {\",\n \" insmod ext2\",\n \" search --label --set=root --no-floppy #{os_part.label}\",\n \" linux /vmlinuz root=LABEL=#{os_part.label} #{kernel_opts_debug}\",\n \" initrd /initrd.img\",\n \"}\",\n \"\",\n ]\n }\n\n return lines.join(\"\\n\")\n end",
"def settings_for_node\n cluster_name = self.parent.name.to_sym\n cluster_role = self.name.to_sym\n node_settings = {\n :user_data => { :attributes => { :run_list => [] } },\n :cluster_name => cluster_name,\n :cluster_role => cluster_role,\n }.deep_merge(Settings)\n node_settings.delete :pools\n raise \"Please define the '#{cluster_name}' cluster and the '#{cluster_role}' role in your ~/.chef/cluster_chef.yaml\" if (Settings[:pools][cluster_name].blank? || Settings[:pools][cluster_name][cluster_role].blank?)\n node_settings = node_settings.deep_merge(\n Settings[:pools][cluster_name][:common] ||{ }).deep_merge(\n Settings[:pools][cluster_name][cluster_role] ||{ })\n configure_aws_region node_settings\n node_settings\nend",
"def config_options\n {\n 'datacenter' => new_resource.datacenter,\n 'template_path' => new_resource.template_path,\n 'power_on' => true,\n 'datastore' => new_resource.datastore,\n 'wait' => true,\n 'hostname' => new_resource.hostname,\n 'name' => new_resource.name,\n 'customization_spec' => {\n 'domain' => new_resource.domain,\n 'ipsettings' => {\n 'ip' => new_resource.ip || node['vcac_vm']['ip'],\n 'gateway' => new_resource.gateway,\n 'subnetMask' => new_resource.subnet_mask,\n },\n }\n }\nend",
"def connect_to_machine(machine_spec, machine_options)\n Chef::Log.debug('Connect to machine!')\n machine_for(machine_spec,machine_options)\n end",
"def config\n mode == \"autoinst_config\"\n end",
"def presets\n h = Beaker::Options::OptionsHash.new\n h.merge({\n :project => 'Beaker',\n :department => 'unknown',\n :created_by => ENV['USER'] || ENV['USERNAME'] || 'unknown',\n :host_tags => {},\n :openstack_api_key => ENV.fetch('OS_PASSWORD', nil),\n :openstack_username => ENV.fetch('OS_USERNAME', nil),\n :openstack_auth_url => \"#{ENV.fetch('OS_AUTH_URL', nil)}/tokens\",\n :openstack_tenant => ENV.fetch('OS_TENANT_NAME', nil),\n :openstack_keyname => ENV.fetch('OS_KEYNAME', nil),\n :openstack_network => ENV.fetch('OS_NETWORK', nil),\n :openstack_region => ENV.fetch('OS_REGION', nil),\n :openstack_volume_support => ENV['OS_VOLUME_SUPPORT'] || true,\n :jenkins_build_url => nil,\n :validate => true,\n :configure => true,\n :log_level => 'info',\n :trace_limit => 10,\n :\"master-start-curl-retries\" => 120,\n :masterless => false,\n :options_file => nil,\n :type => 'pe',\n :provision => true,\n :preserve_hosts => 'never',\n :root_keys => false,\n :quiet => false,\n :project_root => File.expand_path(File.join(__dir__, \"../\")),\n :xml_dir => 'junit',\n :xml_file => 'beaker_junit.xml',\n :xml_time => 'beaker_times.xml',\n :xml_time_enabled => false,\n :xml_stylesheet => 'junit.xsl',\n :default_log_prefix => 'beaker_logs',\n :log_dir => 'log',\n :log_sut_event => 'sut.log',\n :color => true,\n :dry_run => false,\n :test_tag_and => '',\n :test_tag_or => '',\n :test_tag_exclude => '',\n :timeout => 900, # 15 minutes\n :fail_mode => 'slow',\n :test_results_file => '',\n :accept_all_exit_codes => false,\n :timesync => false,\n :set_env => true,\n :disable_updates => true,\n :repo_proxy => false,\n :package_proxy => false,\n :add_el_extras => false,\n :consoleport => 443,\n :pe_dir => '/opt/enterprise/dists',\n :pe_version_file => 'LATEST',\n :pe_version_file_win => 'LATEST-win',\n :host_env => {},\n :host_name_prefix => nil,\n :ssh_env_file => '~/.ssh/environment',\n :profile_d_env_file => '/etc/profile.d/beaker_env.sh',\n :dot_fog => File.join(ENV.fetch('HOME', nil), '.fog'),\n :ec2_yaml => 'config/image_templates/ec2.yaml',\n :help => false,\n :collect_perf_data => 'none',\n :puppetdb_port_ssl => 8081,\n :puppetdb_port_nonssl => 8080,\n :puppetserver_port => 8140,\n :nodeclassifier_port => 4433,\n :cache_files_locally => false,\n :aws_keyname_modifier => rand(10**10).to_s.rjust(10, '0'), # 10 digit random number string\n :run_in_parallel => [],\n :use_fog_credentials => true,\n :ssh => {\n :config => false,\n :verify_host_key => false,\n :auth_methods => [\"publickey\"],\n :port => 22,\n :forward_agent => true,\n :keys => [\"#{ENV.fetch('HOME', nil)}/.ssh/id_rsa\"],\n :user_known_hosts_file => \"#{ENV.fetch('HOME', nil)}/.ssh/known_hosts\",\n :keepalive => true,\n },\n })\n end"
] | [
"0.65542275",
"0.6343865",
"0.6261492",
"0.6190671",
"0.61846995",
"0.61779124",
"0.61644",
"0.61380833",
"0.6134117",
"0.6116369",
"0.6109565",
"0.60672516",
"0.60548383",
"0.60488087",
"0.6016297",
"0.60157365",
"0.5986861",
"0.59864205",
"0.59624565",
"0.59523165",
"0.59487325",
"0.5906162",
"0.59021795",
"0.5900798",
"0.5893236",
"0.5882616",
"0.58555484",
"0.5849691",
"0.58480483",
"0.5843091",
"0.58368134",
"0.5834511",
"0.57896024",
"0.5789163",
"0.5771168",
"0.5771168",
"0.57574105",
"0.5750173",
"0.5746404",
"0.574627",
"0.5740447",
"0.57286966",
"0.5720194",
"0.57096016",
"0.5709321",
"0.57085747",
"0.5696059",
"0.5688077",
"0.56878126",
"0.56747514",
"0.56696963",
"0.56588876",
"0.5657767",
"0.5656867",
"0.5647553",
"0.5644009",
"0.563782",
"0.5630497",
"0.5625742",
"0.56180245",
"0.5611361",
"0.5605843",
"0.5605442",
"0.55986977",
"0.55925167",
"0.55924773",
"0.55911934",
"0.5581317",
"0.557781",
"0.5574831",
"0.5573905",
"0.5570884",
"0.5567551",
"0.5565532",
"0.55494744",
"0.55463",
"0.5543528",
"0.5543528",
"0.55394965",
"0.55373126",
"0.55223525",
"0.55159205",
"0.5513488",
"0.55072254",
"0.5505956",
"0.55059475",
"0.5496639",
"0.54954886",
"0.549491",
"0.54943043",
"0.54922575",
"0.5491529",
"0.5491478",
"0.5491019",
"0.5486135",
"0.5483707",
"0.54797125",
"0.54782677",
"0.54759693",
"0.54745704"
] | 0.57209504 | 42 |
recreates clean ~/.ssh on a VM, populated with your (host) ssh credentials | def configure_ssh(vm)
vm.provision "shell", inline: <<-SHELL
mkdir -p /home/vagrant/.ssh
rm -rf /home/vagrant/.ssh/id_rsa*
chown vagrant:vagrant /home/vagrant/.ssh
SHELL
vm.provision "file", source: '~/.ssh/id_rsa', destination: '~/.ssh/id_rsa'
vm.provision "file", source: '~/.ssh/id_rsa.pub', destination: '~/.ssh/id_rsa.pub'
vm.provision "file", source: '~/.ssh/id_rsa.pub', destination: '~/.ssh/authorized_keys'
vm.provision "file", source: '~/.screenrc', destination: '~/' if File.exists? "~/.screnrc"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_ssh(vm)\n vm.provision \"shell\", inline: <<-SHELL\n mkdir -p /home/vagrant/.ssh\n rm -rf /home/vagrant/.ssh/id_rsa*\n chown vagrant:vagrant /home/vagrant/.ssh\n SHELL\n vm.provision \"file\", source: '~/.ssh/id_rsa', destination: '~/.ssh/id_rsa'\n vm.provision \"file\", source: '~/.ssh/id_rsa.pub', destination: '~/.ssh/id_rsa.pub'\nend",
"def setup_ssh\n # create pem certificate\n FileUtils.mkdir_p(\"#{@path}/.ssh\")\n %x(ssh-keygen -t rsa -b 2048 -v -N '' -f #{@path}/.ssh/#{@vm_name})\n # File.rename(\"#{@path}/.ssh/#{@vm_name}\", \"#{@path}/.ssh/#{@vm_name}.pem\")\n File.rename(\n [@path, '.ssh', @vm_name].join('/'),\n [@path, '.ssh', \"#{@vm_name}.pem\"].join('/'))\n end",
"def create_ssh_keys(config)\n system(\"ssh-keygen -t rsa -N '' -f id_rsa\") unless File.exist?('id_rsa')\n\n config.vm.provision 'ssh', type: 'shell', inline: <<-SHELL\n mkdir -m 0700 -p /root/.ssh\n cp /vagrant/id_rsa /root/.ssh/.\n chmod 0600 /root/.ssh/id_rsa\n mkdir -m 0700 -p /root/.ssh\n [ -f /vagrant/id_rsa.pub ] && (awk -v pk=\\\"`cat /vagrant/id_rsa.pub`\\\" 'BEGIN{split(pk,s,\\\" \\\")} $2 == s[2] {m=1;exit}END{if (m==0)print pk}' /root/.ssh/authorized_keys ) >> /root/.ssh/authorized_keys\n chmod 0600 /root/.ssh/authorized_keys\n\n cat > /etc/ssh/ssh_config <<__EOF\n Host *\n StrictHostKeyChecking no\n__EOF\n SHELL\nend",
"def ssh_config\n ssh_config_path = File.expand_path(File.join(@vagrant_path, \"ssh_config\"))\n begin\n File.unlink(ssh_config_path)\n rescue Errno::ENOENT\n end\n self.nodes.each do |k,v|\n Dir.chdir(@vagrant_path) do\n systemu(\"vagrant ssh-config #{k} >> #{ssh_config_path}\")\n end\n end\n ssh_config_path\n end",
"def ssh_config\n ssh_config_path = File.expand_path(File.join(@vagrant_path, \"ssh_config\"))\n begin\n File.unlink(ssh_config_path)\n rescue Errno::ENOENT\n end\n self.nodes.each do |k,v|\n Dir.chdir(@vagrant_path) do\n result = systemu(\"vagrant ssh-config #{k} >> #{ssh_config_path}\")\n end\n end\n ssh_config_path\n end",
"def enable_root_ssh(ip, initial_ssh_user)\n # Capistrano uses the :password variable for sudo commands. Since this setting is generally used for the deploy user,\n # but we need it this one time for the initial SSH user, we need to swap out and restore the password.\n #\n # We special-case the 'ubuntu' user since the Canonical AMIs on EC2 don't set the password for\n # this account, making any password prompt potentially confusing.\n orig_password = fetch(:password)\n initial_ssh_password = fetch(:initial_ssh_password, nil)\n\n if initial_ssh_user == 'ubuntu' || ENV.has_key?('RUN_FROM_VAGRANT')\n set(:password, nil)\n elsif initial_ssh_password\n set(:password, initial_ssh_password)\n else\n set(:password, Capistrano::CLI.password_prompt(\"Password for #{initial_ssh_user} @ #{ip}: \"))\n end\n\n task :_ensure_key_file_present, :hosts => \"#{initial_ssh_user}@#{ip}\" do\n public_key_filename = \"#{cloud.env.key_file}.pub\"\n\n if File.exist?(public_key_filename)\n public_key = File.read(public_key_filename).chomp\n\n rubber.sudo_script 'ensure_key_file_present', <<-ENDSCRIPT\n mkdir -p ~/.ssh\n touch ~/.ssh/authorized_keys\n chmod 600 ~/.ssh/authorized_keys\n\n if ! grep -q '#{public_key}' .ssh/authorized_keys; then\n echo '#{public_key}' >> .ssh/authorized_keys\n fi\n ENDSCRIPT\n end\n end\n\n task :_allow_root_ssh, :hosts => \"#{initial_ssh_user}@#{ip}\" do\n rsudo \"mkdir -p /root/.ssh && cp /home/#{initial_ssh_user}/.ssh/authorized_keys /root/.ssh/\"\n end\n\n task :_disable_password_based_ssh_login, :hosts => \"#{initial_ssh_user}@#{ip}\" do\n rubber.sudo_script 'disable_password_based_ssh_login', <<-ENDSCRIPT\n if ! grep -q 'PasswordAuthentication no' /etc/ssh/sshd_config; then\n echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config\n service ssh restart\n fi\n ENDSCRIPT\n end\n\n begin\n _ensure_key_file_present\n _allow_root_ssh\n _disable_password_based_ssh_login if cloud.should_disable_password_based_ssh_login?\n\n # If the initial_ssh_user is different than the deploy user, we can terminate the SSH connection\n # because from here on out we'll be connecting as the deploy user.\n if initial_ssh_user != fetch(:user, nil)\n teardown_connections_to(sessions.keys)\n end\n rescue ConnectionError, IOError => e\n if e.message =~ /Net::SSH::AuthenticationFailed/\n logger.info \"Can't connect as user #{initial_ssh_user} to #{ip}, assuming root allowed\"\n else\n sleep 2\n logger.info \"Failed to connect to #{ip}, retrying\"\n teardown_connections_to(sessions.keys) if e.message =~ /closed stream/\n retry\n end\n end\n\n # Restore the original deploy password.\n set(:password, orig_password)\n end",
"def cleanup\n\t\tcleanup_ssh\n\n\tend",
"def create_ssh_setup\n command = \"echo 'y\\\\\\n' \\| ssh-keygen -f /tmp/#{@name_args[0]}.key -N \\\"\\\" -P \\\"\\\"\"\n result = run_remote_command(command)\n\n if config[:username].eql? \"root\"\n auth_keys_file = '/root/.ssh/authorized_keys'\n else\n auth_keys_file = \"/home/#{config[:username]}/.ssh/authorized_keys\"\n end\n\n # we don't want to overwrite anything that may already exist here\n command = \"echo \\\"\\##{@name_args[0]}\\\" >> #{auth_keys_file}\"\n result = run_remote_command(command)\n\n command = \"cat /tmp/#{@name_args[0]}.key.pub >> #{auth_keys_file}\"\n result = run_remote_command(command)\n\n command = \"chmod 0600 #{auth_keys_file}\"\n result = run_remote_command(command)\n\n command = \"cat /tmp/#{@name_args[0]}.key\"\n ssh_key = run_remote_command(command)\n end",
"def write_sftp\n content_dir = \"#{platform_root}/sftp\"\n FileUtils.mkdir_p(\"#{content_dir}/host-config/authorized-keys\")\n Dir.chdir(\"#{content_dir}/host-config\") do\n %x(ssh-keygen -P '' -t ed25519 -f ssh_host_ed25519_key < /dev/null)\n %x(ssh-keygen -P '' -t rsa -b 4096 -f ssh_host_rsa_key < /dev/null)\n end\n Dir.chdir(content_dir) { FileUtils.touch('users.conf') }\n end",
"def cleanup_host(machine_spec)\n if machine_spec.location[\"ip_address\"]\n %x(ssh-keygen -R \"#{machine_spec.location[\"ip_address\"]}\")\n end\n end",
"def initialize_ssh; end",
"def setup_ssh_config(config)\n dst = File.expand_path \"#{__dir__}/../ssh_config\"\n\n if config[\"machines\"] != nil\n entries = []\n config[\"machines\"].each do |m|\n entries << {\"Host\" => m[\"hostname\"],\n \"HostName\" => m[\"private_ips\"][0],\n \"User\" => \"stack\"}\n end\n\n str = \"\"\n entries.each do |ent|\n ent.each do |k, v|\n if k == \"Host\"\n str += \"#{k} #{v}\\n\"\n else\n str += \" #{k} #{v}\\n\"\n end\n end\n end\n str.chomp\n\n str += \"Host *\\n\" +\n \" StrictHostKeyChecking no\\n\" +\n \" UserKnownHostsFile=/dev/null\\n\"\n\n open(dst, \"w+\") {|f|\n f.write(str)\n }\n end\n end",
"def update_ssh(nodes, version)\n fqdns = nodes.map { |node| node.fqdn }.join(' ')\n\n ssh = Chef::Knife::Ssh.new\n ssh.ui = ui\n ssh.name_args = [ fqdns, ssh_command(version) ]\n ssh.config[:manual] = true\n ssh.config[:on_error] = :skip\n ssh.config[:ssh_user] = Chef::Config[:knife][:ssh_user] || config[:ssh_user]\n ssh.config[:ssh_password] = config[:ssh_password]\n ssh.config[:ssh_port] = Chef::Config[:knife][:ssh_port] || config[:ssh_port]\n ssh.config[:ssh_gateway] = Chef::Config[:knife][:ssh_gateway] || config[:ssh_gateway]\n ssh.config[:identity_file] = Chef::Config[:knife][:identity_file] || config[:identity_file]\n ssh.config[:host_key_verify] = Chef::Config[:knife][:host_key_verify] || config[:host_key_verify]\n ssh\n end",
"def config_ssh(username, host, options = nil)\n @ssh = SSH.new(username, host, options)\n end",
"def setup(credentials = {})\n requires :public_key, :public_ip_address, :username\n\n credentials[:password] = password unless self.password.nil?\n credentails[:key_data] = [private_key] if self.private_key\n\n commands = [\n %{mkdir .ssh},\n ]\n if public_key\n commands << %{echo \"#{public_key}\" >> ~/.ssh/authorized_keys}\n end\n\n # wait for domain to be ready\n Timeout::timeout(360) do\n begin\n Timeout::timeout(8) do\n Fog::SSH.new(public_ip_address, username, credentials.merge(:timeout => 4)).run('pwd')\n end\n rescue Errno::ECONNREFUSED\n sleep(2)\n retry\n rescue Net::SSH::AuthenticationFailed, Timeout::Error\n retry\n end\n end\n Fog::SSH.new(public_ip_address, username, credentials).run(commands)\n end",
"def connect\n nodes.each do |k,v|\n RSpec.configuration.rs_storage[:nodes][k] ||= {}\n\n chan = ssh_connect(:host => k, :user => 'vagrant', :net_ssh_options => {\n :config => ssh_config\n })\n\n # Copy the authorized keys from vagrant user to root then reconnect\n cmd = 'mkdir /root/.ssh ; cp /home/vagrant/.ssh/authorized_keys /root/.ssh'\n\n output << bold(color(\"#{k}$ \", :green)) << cmd << \"\\n\"\n ssh_exec!(chan, \"cd /tmp && sudo sh -c #{shellescape(cmd)}\")\n\n chan = ssh_connect(:host => k, :user => 'root', :net_ssh_options => {\n :config => ssh_config\n })\n RSpec.configuration.rs_storage[:nodes][k][:ssh] = chan\n end\n\n nil\n end",
"def recreate_local_ssh_keys_for_inception_vm\n unless settings[\"inception\"] && (key_pair = settings[\"inception\"][\"key_pair\"])\n raise \"please run create_inception_key_pair first\"\n end\n private_key_contents = key_pair[\"private_key\"]\n unless File.exist?(inception_vm_private_key_path) && File.read(inception_vm_private_key_path) == private_key_contents\n say \"Creating missing inception VM private key...\"\n mkdir_p(File.dirname(inception_vm_private_key_path))\n File.chmod(0700, File.dirname(inception_vm_private_key_path))\n File.open(inception_vm_private_key_path, \"w\") { |file| file << private_key_contents }\n File.chmod(0600, inception_vm_private_key_path)\n end\n end",
"def provision\n ssh_user = machine.ssh_info[:username]\n sync_dir = Vagrant::Openshift::Constants.sync_dir\n ## pause to stabilize environment to try to correct odd sudo error on aws\n sleep 2\n sudo(machine, \"mkdir -p #{sync_dir} && chown -R #{ssh_user}:#{ssh_user} #{sync_dir}\")\n end",
"def make_ssh_config(workspace_path)\n ssh_path = File.join(workspace_path, '.ssh')\n return if Dir.exist? ssh_path\n\n FileUtils.mkdir_p ssh_path, mode: 0o700\n touch File.join(ssh_path, 'config'), 0o600\n\n # .git_ssh.sh\n git_ssh_path = File.join(workspace_path, '.git_ssh.sh')\n File.write git_ssh_path, <<~SHELL\n #!/bin/sh\n ssh-wrapper \"$@\"\n SHELL\n FileUtils.chmod 0o755, git_ssh_path\n end",
"def sync\n rm_berks_cookbooks\n target_dir = \"/home/#{USER}/provisioning\"\n rsync_current_dir target_dir: target_dir\n ssh_exe \"sudo chown #{USER}:#{USER} -R #{target_dir}\"\n end",
"def setup(credentials = {})\n requires :public_key, :ssh_ip_address, :username\n\n credentials[:proxy]= ssh_proxy unless ssh_proxy.nil?\n credentials[:password] = password unless self.password.nil?\n credentials[:key_data] = [private_key] if self.private_key\n\n commands = [\n %{mkdir .ssh},\n # %{passwd -l #{username}}, #Not sure if we need this here\n # %{echo \"#{Fog::JSON.encode(attributes)}\" >> ~/attributes.json}\n ]\n if public_key\n commands << %{echo \"#{public_key}\" >> ~/.ssh/authorized_keys}\n end\n\n # wait for domain to be ready\n Timeout::timeout(360) do\n begin\n Timeout::timeout(8) do\n Fog::SSH.new(ssh_ip_address, username, credentials.merge(:timeout => 4)).run('pwd')\n end\n rescue Errno::ECONNREFUSED\n sleep(2)\n retry\n rescue Net::SSH::AuthenticationFailed, Timeout::Error\n retry\n end\n end\n Fog::SSH.new(ssh_ip_address, username, credentials).run(commands)\n end",
"def ssh_create(host, user, key)\n\n if key.start_with?('-----BEGIN RSA PRIVATE KEY-----')\n ssh = Net::SSH.start(host, user,\n {\n :key_data => key,\n :user_known_hosts_file => \"/dev/null\"\n } )\n elsif File.exist?(key)\n ssh = Net::SSH.start(host, user,\n {\n :key_data => IO.read(key),\n :user_known_hosts_file => \"/dev/null\"\n } )\n else\n ssh = Net::SSH.start(host, user,\n {\n :password => key,\n :user_known_hosts_file => \"/dev/null\"\n } )\n end\n\n ssh\n end",
"def start\n begin\n SSH::Home.new( ssh_home, @debug_options ).setup\n rescue\n maybe_cleanup_old_key_pair\n ssh_keygen\n retry unless dry_run\n end\n end",
"def migrate_old_ssh_keys\n if migrate_old_ssh_keys?\n say \"-> migrating to cache private key for inception VM...\"\n inception_vm_private_key_path # to setup the path in settings\n settings[\"inception\"][\"key_pair\"] ||= {}\n settings[\"inception\"][\"key_pair\"][\"name\"] = \"fog_default\"\n settings[\"inception\"][\"key_pair\"][\"private_key\"] = File.read(settings[\"local\"][\"private_key_path\"]).strip\n settings[\"inception\"][\"key_pair\"][\"public_key\"] = File.read(settings[\"local\"][\"public_key_path\"]).strip\n settings.delete(\"local\")\n save_settings!\n end\n end",
"def config_provision(vm, conf)\n vm.provision :shell, run: \"always\", inline: \"setenforce 0\"\n vm.provision :shell, run: \"always\", inline: \"sed -i 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config\"\n vm.provision :shell, run: \"always\", inline: \"yum -y install net-tools expect\"\n vm.provision :shell, run: \"always\", path: \"setrootpasswd.sh\"\n vm.provision :shell, run: \"always\", inline: \"ifup eth1\"\n vm.provision :shell, run: \"always\", inline: \"eval `route -n|awk '{ if ($8 ==\\\"eth0\\\" && $2 != \\\"0.0.0.0\\\") print \\\"route del default gw \\\" $2; }'`\"\n vm.provision :shell, run: \"always\", inline: \"sed -i 's/^#PermitRootLogin/PermitRootLogin/' /etc/ssh/sshd_config\"\n vm.provision :shell, run: \"always\", inline: \"sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config && systemctl restart sshd\"\n #vm.provision :ansible do |ansible|\n # ansible.host_key_checking = false\n # ansible.playbook = \"ansible/playbook.yml\"\n # ansible.verbose = \"vv\"\n # #ansible.extra_vars = {}\n #end\n #vm.provision :shell, :inline => \"cd /opt/devstack; sudo -u ubuntu env HOME=/home/ubuntu ./stack.sh\"\n # interface should match external_interface var in devstack.yml\n #vm.provision :shell, :inline => \"ovs-vsctl add-port br-ex enp0s9\"\n #vm.provision :shell, :inline => \"virsh net-destroy default\"\nend",
"def config_local_docker_registry(config)\n\n config.vm.provision \"shell\", inline: <<-SHELL\n mkdir /etc/docker/certs.d/util.io\n sshpass -p 'vagrant' scp -o StrictHostKeyChecking=no util.io:/etc/docker/certs.d/util.io/ca.crt /etc/docker/certs.d/util.io\n docker login --username=testuser --password=testpassword util.io\n SHELL\n\nend",
"def add_keys(vm)\n vm.provision \"file\",\n source: \"./setupfiles/vagrant_testkey\",\n destination: \"/home/vagrant/.ssh/id_ed25519\"\n vm.provision \"file\",\n source: \"./setupfiles/vagrant_testkey.pub\",\n destination: \"/home/vagrant/.ssh/id_ed25519.pub\"\n vm.provision \"shell\", inline: <<-EOS\n chmod 600 /home/vagrant/.ssh/id_ed25519\n chmod 644 /home/vagrant/.ssh/id_ed25519.pub\n EOS\nend",
"def config_root_ssh(vim, vm, auth, state)\n clear_line\n print '[ ' + 'INFO'.green + \" ] Configuring root ssh access. Setting to state #{state}.\"\n if state == 'enabled'\n programpath = '/bin/sed'\n arguments = '-i \\'s/\\(^PermitRootLogin no\\)/PermitRootLogin yes/g\\' /etc/ssh/sshd_config'\n elsif state == 'disabled'\n programpath = '/bin/sed'\n arguments = '-i \\'s/\\(^PermitRootLogin yes\\)/PermitRootLogin no/g\\' /etc/ssh/sshd_config'\n else\n clear_line\n puts '[ ' + 'ERROR'.red + \" ] Invalid state set for configure_root_ssh. State: #{state}\"\n raise 'ERROR'\n end\n spec = { :programPath => programpath, :arguments => arguments }\n\n #run command through GuestOps\n pid = vim.serviceContent.guestOperationsManager.processManager.StartProgramInGuest(:vm => vm, :auth => auth, :spec => spec) \n\n #list process of command and get exit code\n process = vim.serviceContent.guestOperationsManager.processManager.ListProcessesInGuest(:vm => vm, :auth => auth, :pids => [pid]).first\n\n exit_code = vim_wait(vim, vm, auth, process)\n\n #restart sshd\n print '[ ' + 'INFO'.green + \" ] Restarting the sshd service\"\n spec = { :programPath => '/sbin/service', :arguments => 'sshd restart' }\n\n #run command through GuestOps\n pid = vim.serviceContent.guestOperationsManager.processManager.StartProgramInGuest(:vm => vm, :auth => auth, :spec => spec) \n\n #list process of command and get exit code\n process = vim.serviceContent.guestOperationsManager.processManager.ListProcessesInGuest(:vm => vm, :auth => auth, :pids => [pid]).first\n\n exit_code = vim_wait(vim, vm, auth, process)\n\n if exit_code == 0\n clear_line\n print '[ ' + 'INFO'.green + \" ] Succesfully restart SSHD\"\n return 'SUCCESS'\n else\n clear_line\n puts '[ ' + 'ERROR'.red + \" ] Failed to succesfully restart sshd on #{vm}.\"\n raise 'ERROR'\n end\nend",
"def unix_create_remote_frontend\n head = __method__\n set_status(\"Create\")\n log \"#{head}: Creating #{frontend.at_type} #{remote_user}@#{remote_host}. Should already exist!\"\n case frontend.deployment_type\n when /unix/\n uadmin_unix_ssh(\"sudo adduser #{remote_user} --quiet --disabled-password || exit 0\")\n when /ec2/\n uadmin_unix_ssh(\"sudo adduser #{remote_user} --create-home --user-group --groups rvm || exit 0\")\n end\n uadmin_unix_ssh(\"sudo -u #{remote_user} mkdir -p ~#{remote_user}/.ssh\")\n uadmin_unix_ssh(\"sudo -u #{remote_user} chmod 755 ~#{remote_user}\")\n uadmin_unix_ssh(\"sudo -u #{remote_user} chmod 777 ~#{remote_user}/.ssh\")\n file = pub_cert(ssh_cert)\n begin\n uadmin_unix_scp(file.path, \"~#{remote_user}/.ssh/frontend-#{name}.pub\")\n uadmin_unix_ssh(\"cat ~#{remote_user}/.ssh/frontend-#{name}.pub | sudo -u #{remote_user} tee -a ~#{remote_user}/.ssh/authorized_keys\")\n rescue Exception => boom4\n log \"#{head}: error creating ~#{remote_user}/.ssh/frontend-#{name}.pub on #{remote_host} - #{boom4} - trying to ignore\"\n end\n file.unlink\n uadmin_unix_ssh(\"sudo chown -R #{remote_user}:#{remote_user} ~#{remote_user}\")\n uadmin_unix_ssh(\"sudo -u #{remote_user} chmod 700 ~#{remote_user}/.ssh\")\n uadmin_unix_ssh(\"echo \\\"#{remote_user} ALL=(ALL:ALL) NOPASSWD: /etc/init.d/nginx, /bin/ls, /bin/cp, /bin/mkdir, /bin/rm, /bin/cat\\\" | sudo tee /etc/sudoers.d/#{remote_user}\")\n unix_ssh(\"ls -la\")\n unix_ssh(\"test -e .rvm || \\\\curl -L https://get.rvm.io | bash -s stable --autolibs=read-fail\")\n unix_ssh(\"test -e .rvm && bash --login -c \\\"rvm install #{ruby_version}\\\"\")\n unix_ssh(\"test -e #{frontend.git_name} || git clone #{frontend.git_repository} -b #{frontend.git_refspec} #{frontend.git_name}\")\n unix_ssh(\"cd #{frontend.git_name}; rm Gemfile.lock; git submodule init; git submodule update\")\n unix_ssh(\"bash --login -c \\\"cd ~/#{frontend.git_name}; bundle install\\\"\")\n unix_ssh(\"cd ~/#{frontend.git_name}; bash scripts/create_frontend.sh #{frontend.git_name}\")\n log \"#{head}: Remote #{frontend.at_type} #{remote_user}@#{remote_host} exists.\"\n set_status(\"Success:Create\")\n rescue Exception => boom\n log \"#{head}: error creating ~#{remote_user}@#{remote_host} on remote server - #{boom}\"\n set_status(\"Error:Create\")\n end",
"def add_key_access(vm)\n vm.provision \"file\",\n source: \"./setupfiles/vagrant_testkey.pub\",\n destination: \"/tmp/vagrant_testkey.pub\"\n vm.provision \"shell\", inline: <<-EOS\n cat /tmp/vagrant_testkey.pub >> /home/vagrant/.ssh/authorized_keys\n chmod 600 /home/vagrant/.ssh/authorized_keys\n EOS\nend",
"def create_hostfile(config)\n open('hosts', 'w') do |f|\n f.puts <<-__EOF\n127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4\n::1 localhost localhost.localdomain localhost6 localhost6.localdomain6\n\n10.0.10.10 device-scanner1.local device-scanner1\n10.0.10.11 device-scanner2.local device-scanner2\n10.0.30.10 device-aggregator.local device-aggregator\n10.0.40.10 iscsi.local iscsi\n10.0.50.10 iscsi2.local iscsi2\n __EOF\n end\n\n config.vm.provision 'shell', inline: 'cp -f /vagrant/hosts /etc/hosts'\nend",
"def add_keys(vm)\n vm.provision \"file\",\n source: \"./vagrant_testkey\",\n destination: \"/home/vagrant/.ssh/id_ed25519\"\n vm.provision \"file\",\n source: \"./vagrant_testkey.pub\",\n destination: \"/home/vagrant/.ssh/id_ed25519.pub\"\n vm.provision \"shell\", inline: <<-EOS\n chmod 600 /home/vagrant/.ssh/id_ed25519\n chmod 644 /home/vagrant/.ssh/id_ed25519.pub\n EOS\nend",
"def init_sshkeys\n @ssh_keys = []\n @ssh_key = { name: 'nosshkey' }\n\n response = @conn.get do |req|\n req.url \"/api/v1/sshkeys\"\n req.headers = rest_headers\n end\n\n @ssh_keys = json(response.body)[:sshkeys]\n @ssh_key = @ssh_keys.first if @ssh_keys.length\n end",
"def basic_config(vm)\n hosts = NODES.map { |hostname, array| \"#{array[0]} #{hostname}\" }.join(\"\\n\")\n bashrc=\"/home/vagrant/.bashrc\"\n vm.provision \"shell\", inline: <<-SHELL\n if ! grep -q \"git-core\" #{bashrc} ; then \n echo \"customizing ~/bashrc\"\n echo \"\\n\\n# Customizations from Vagrantfile:\" >> #{bashrc}\n echo \"export PS1='\\\\[\\\\033[31;1m\\\\]\\\\h\\\\[\\\\033[0;32m\\\\] \\\\w\\\\[\\\\033[00m\\\\]: '\" >> #{bashrc}\n echo export PATH=\"\\$PATH:/usr/lib/git-core:/home/vagrant/teleport/build\" >> #{bashrc}\n echo export GREP_OPTIONS=\"--color=auto\" >> #{bashrc}\n echo \"alias ll='ls -lh'\" >> #{bashrc}\n echo \"alias tsh='tsh --insecure'\" >> #{bashrc}\n fi\n if ! grep -q \"Teleport\" /etc/hosts ; then \n echo \"# Teleport entries added by Vagrant:\" >> /etc/hosts\n echo -e \"#{hosts}\" >> /etc/hosts\n fi\n mkdir -p /var/lib/teleport\n chown vagrant:vagrant /var/lib/teleport\n SHELL\nend",
"def provision_ansible(box, key, ansible_config, vm_config)\n box.vm.provision :ansible_local do |ansible|\n properties = [\n 'ask_become_pass',\n 'ask_sudo_pass',\n 'ask_vault_pass',\n 'force_remote_user',\n 'host_key_checking',\n 'raw_ssh_args'\n ]\n properties.each do | property_name |\n set_instance_variable(ansible_config, ansible, property_name )\n end\n provision_ansible_common(ansible, key, ansible_config, vm_config)\n end\nend",
"def logout!\n @ssh.close\n @ssh = nil\n end",
"def ssh\n tries = 1\n @ssh ||= begin\n Net::SSH.start(self, self['user'], self['ssh'])\n rescue\n tries += 1\n if tries < 4\n puts \"Try #{tries} -- Host Unreachable\"\n puts 'Trying again in 20 seconds'\n sleep 20\n retry\n end\n end\n end",
"def add_key_access(vm)\n vm.provision \"file\",\n source: \"./vagrant_testkey.pub\",\n destination: \"/tmp/vagrant_testkey.pub\"\n vm.provision \"shell\", inline: <<-EOS\n cat /tmp/vagrant_testkey.pub >> /home/vagrant/.ssh/authorized_keys\n chmod 600 /home/vagrant/.ssh/authorized_keys\n EOS\nend",
"def generate_puppet_user_keys(environment)\n require 'sshkey'\n FileUtils.cd(\"#{self.project_root}/config/environments/#{environment}/keys\") { FileUtils.rm Dir.glob('*') }\n sshkey = SSHKey.generate(:type => \"RSA\", :bits => 1024)\n FileUtils.cd(\"#{self.project_root}/config/environments/#{environment}/keys\") do\n write_content_to_file(\"#{self.project_root}/config/environments/#{environment}/keys/id_rsa\", sshkey.private_key)\n write_content_to_file(\"#{self.project_root}/config/environments/#{environment}/keys/id_rsa.pub\", sshkey.ssh_public_key)\n end\n end",
"def setenv( vm, host )\n return unless host.key?('env')\n cmd=\"tee -a \\\"/etc/profile.d/setenv.sh\\\" > \\\"/dev/null\\\" <<ENDHERE\"\n host['env'].each do |key, val|\n cmd=\"#{cmd}\\nexport #{key}=\\\"#{val}\\\"\"\n end\n cmd=\"#{cmd}\\nENDHERE\"\n vm.provision \"shell\", inline: cmd, run: \"always\"\nend",
"def create_ssh_transport(host, options)\n require 'chef/provisioning/transport/ssh'\n ssh_user = options[:user]\n options = options.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v; }\n Chef::Provisioning::Transport::SSH.new(\n host,\n ssh_user,\n options.to_hash,\n @config[:machine_options][:sudo] ? { prefix: 'sudo ' } : {},\n config\n )\n end",
"def unix_create_remote_endpoint\n head = __method__\n set_status(\"Create\")\n log \"#{head}: Creating #{endpoint.at_type} #{remote_user}@#{remote_host}. Should already exist!\"\n uadmin_unix_ssh(\"sudo adduser #{remote_user} --quiet --disabled-password || exit 0\")\n uadmin_unix_ssh(\"sudo -u #{remote_user} mkdir -p ~#{remote_user}/.ssh\")\n uadmin_unix_ssh(\"sudo -u #{remote_user} chmod 777 ~#{remote_user}/.ssh\")\n file = pub_cert(ssh_cert)\n deploy_cert_path = deploy_cert\n begin\n uadmin_unix_scp(file.path, \"~#{remote_user}/.ssh/endpoint-#{name}.pub\")\n uadmin_unix_ssh(\"cat ~#{remote_user}/.ssh/endpoint-#{name}.pub | sudo -u #{remote_user} tee -a ~#{remote_user}/.ssh/authorized_keys\")\n rescue Exception => boom4\n log \"#{head}: error creating ~#{remote_user}/.ssh/endpoint-#{name}.pub on #{remote_host} - #{boom4} - trying to ignore\"\n end\n file.unlink\n uadmin_unix_ssh(\"sudo chown #{remote_user}:#{remote_user} ~#{remote_user} ~#{remote_user}/.ssh ~#{remote_user}/.ssh/*\")\n uadmin_unix_ssh(\"sudo -u #{remote_user} chmod 700 -f ~#{remote_user}/.ssh ~#{remote_user}/.ssh/*.pem\")\n\n unix_scp(deploy_cert_path, \"~/.ssh/endpoint-#{name}-deploy.pem\")\n unix_ssh(\"chmod 700 ~/.ssh/endpoint-#{name}-deploy.pem\")\n unix_ssh(\"mkdir -p ~/bin\")\n file = Tempfile.new(\"gitssh\")\n file.write(\"exec /usr/bin/ssh -o StrictHostKeyChecking=no -i ~/.ssh/endpoint-#{name}-deploy.pem $@\\n\")\n file.close\n unix_scp(file.path, \"~/bin/endpoint-#{name}-git\")\n unix_ssh(\"chmod +x ~/bin/endpoint-#{name}-git\")\n unix_ssh(\"ls -la\")\n unix_ssh(\"gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3\")\n unix_ssh(\"test -e .rvm || \\\\curl -L https://get.rvm.io | bash -s stable --autolibs=read-fail\")\n unix_ssh(\"test -e .rvm && bash --login -c \\\"rvm install #{ruby_version}\\\"\")\n log \"#{head}: Remote #{endpoint.at_type} #{remote_user}@#{remote_host} exists.\"\n set_status(\"Success:Create\")\n rescue Exception => boom\n log \"#{head}: error creating ~#{remote_user}@#{remote_host} on remote server - #{boom}\"\n set_status(\"Error:Create\")\n end",
"def run\n Shef::Extensions.extend_context_object(self)\n ssh_config = []\n\n ssh_config << \"\\n\\n### BEGIN KNIFE BLOCK ###\"\n ssh_config << \"## This was generated by `knife setup ssh`:\"\n\n STDOUT.sync = true\n\n nodes.all do |n|\n next if /vagrant/.match(n.name)\n name = n.name\n name << '.lisausa.net' unless /\\.lisausa.net\\Z/.match(n.name)\n\n begin\n hostname = n.ipaddress\n rescue => ex\n ui.warn(\"Error (#{ex.inspect}) while getting #ipaddress for #{n.name}\")\n next\n end\n\n ssh_config << [\n \"Host #{name}\",\n \" HostName #{hostname}\",\n \" HostKeyAlias #{[name,hostname,n.macaddress].join('-')}\"\n ]\n end\n\n if (c = Chef::Config.knife).keys.grep(/identity_file|ssh_user/).any?\n ssh_config.push [\n \"Host *.lisausa.net\",\n \" IdentitiesOnly yes\",\n \" PasswordAuthentication no\",\n \" ForwardAgent yes\"\n ]\n ssh_config.push \" IdentityFile #{c[:identity_file]}\" if c[:identity_file]\n ssh_config.push \" User #{c[:ssh_user]}\" if c[:ssh_user]\n end\n\n ssh_config << \"### END KNIFE BLOCK ###\"\n ssh_config = ssh_config.flatten.join(\"\\n\")\n\n file_path = File.join(ENV['HOME'], '.ssh', 'config')\n if config[:write] or ui.ask_question(\"Write config to #{file_path} (Y/N)?\", default: 'N').downcase == 'y'\n FileUtils.copy_file(file_path, \"#{file_path}~\")\n File.open(file_path, File::RDWR|File::CREAT) do |f|\n f.flock(File::LOCK_EX)\n\n contents = f.read.gsub(/\\n*### BEGIN KNIFE BLOCK ###.+?(### END KNIFE BLOCK ###|\\Z)/m, ssh_config)\n unless contents.include?('### BEGIN KNIFE BLOCK ###')\n contents << ssh_config\n end\n f.rewind\n f.truncate(0)\n f.write contents\n end\n ui.msg \"Wrote to #{file_path}. Previous contents were backed up to #{file_path}~\"\n else\n ui.msg \"Copy and paste the following into your #{file_path} file:\"\n ui.msg ssh_config\n end\n end",
"def setup\n create_vagrantfile()\n\n teardown()\n\n output << bold(color(\"localhost$\", :green)) << \" vagrant up\\n\"\n vagrant(\"up\")\n\n # Establish ssh connectivity\n nodes.each do |k,v|\n output << bold(color(\"localhost$\", :green)) << \" ssh #{k}\\n\"\n chan = Net::SSH.start(k, 'vagrant', :config => ssh_config)\n\n RSpec.configuration.rspec_storage[:nodes][k] = {\n :ssh => chan,\n }\n end\n\n nil\n end",
"def destroy account\n destroy_file File.join(@ssh_home, account + \".identity\")\n destroy_file File.join(@ssh_home, account + \".identity.pub\")\n end",
"def set_ssh_user(username, password)\n # Sets the credentials for a the remote SSH user\n @username = username\n @password = password\n end",
"def ssh\n platform_service(:ssh)\n end",
"def provision_ssh(args)\n env = config.env.map { |k,v| \"#{k}=#{quote_and_escape(v.to_s)}\" }\n env = env.join(\" \")\n\n command = \"chmod +x '#{config.upload_path}'\"\n command << \" &&\"\n command << \" #{env}\" if !env.empty?\n command << \" #{config.upload_path}#{args}\"\n\n with_script_file do |path|\n # Upload the script to the machine\n @machine.communicate.tap do |comm|\n # Reset upload path permissions for the current ssh user\n info = nil\n retryable(on: Vagrant::Errors::SSHNotReady, tries: 3, sleep: 2) do\n info = @machine.ssh_info\n raise Vagrant::Errors::SSHNotReady if info.nil?\n end\n\n user = info[:username]\n comm.sudo(\"chown -R #{user} #{config.upload_path}\",\n error_check: false)\n\n comm.upload(path.to_s, config.upload_path)\n\n if config.name\n @machine.ui.detail(I18n.t(\"vagrant.provisioners.shell.running\",\n script: \"script: #{config.name}\"))\n elsif config.path\n @machine.ui.detail(I18n.t(\"vagrant.provisioners.shell.running\",\n script: path.to_s))\n else\n @machine.ui.detail(I18n.t(\"vagrant.provisioners.shell.running\",\n script: \"inline script\"))\n end\n\n # Execute it with sudo\n comm.execute(\n command,\n sudo: config.privileged,\n error_key: :ssh_bad_exit_status_muted\n ) do |type, data|\n handle_comm(type, data)\n end\n end\n end\n end",
"def ssh_data\n <<-SSH_DATA\n ssh-keys = \"#{@user}:#{@public_key_value}}\"\n enable-oslogin = \"FALSE\"\n SSH_DATA\n end",
"def get_ssh_info\n\n h = Hash.new()\n\n if @ssh_info.class.eql?(Hash)\n @logger.debug('using cached SSH info')\n h = @ssh_info\n else\n\n res = self.vagrant(sprintf('ssh-config %s', @name))\n\n res.split(\"\\n\").each do |line|\n if line.match(/HostName (.*?)$/)\n h[:hostname] = $1\n elsif line.match(/User (\\w*?)$/)\n h[:user] = $1\n elsif line.match(/Port (\\d*?)$/)\n h[:ssh_port] = $1\n elsif line.match(/IdentityFile (.*?)$/)\n h[:identity_file] = $1\n @logger.info(sprintf('vagrant specified key[%s] differs from provided[%s], will use both', @sshkey, h[:identity_file]))\n end\n end\n\n @ssh_info = h\n end\n\n h\n end",
"def ssh_login\n deploy_test_on_hosts_as self.host_admin, self.hosts, \"/home/#{self.host_admin}\\n\", \"should be able to connect via ssh\" do\n 'pwd'\n end\n end",
"def ssh\n @ssh ||= Net::SSH.start(self, self['user'] || \"root\" , self['ssh'])\n end",
"def ssh(path_of_servers, command)\n _path_of_servers = path_of_servers.dup\n remove_first_localhost!(_path_of_servers)\n Open3.capture3(ssh_str(_path_of_servers, command))\n end",
"def initialSSHTasks(ssh)\n win_env_fix = %q{echo 'export PATH=\"$PATH:/cygdrive/c/opscode/chef/embedded/bin\"' > \"$HOME/chef-client\"; echo 'prev_dir=\"`pwd`\"; for __dir in /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session\\ Manager/Environment;do cd \"$__dir\"; for __var in `ls * | grep -v TEMP | grep -v TMP`;do __var=`echo $__var | tr \"[a-z]\" \"[A-Z]\"`; test -z \"${!__var}\" && export $__var=\"`cat $__var`\" >/dev/null 2>&1; done; done; cd \"$prev_dir\"; /cygdrive/c/opscode/chef/bin/chef-client.bat $@' >> \"$HOME/chef-client\"; chmod 700 \"$HOME/chef-client\"; ( grep \"^alias chef-client=\" \"$HOME/.bashrc\" || echo 'alias chef-client=\"$HOME/chef-client\"' >> \"$HOME/.bashrc\" ) ; ( grep \"^alias mu-groom=\" \"$HOME/.bashrc\" || echo 'alias mu-groom=\"powershell -File \\\"c:/Program Files/Amazon/Ec2ConfigService/Scripts/UserScript.ps1\\\"\"' >> \"$HOME/.bashrc\" )}\n win_installer_check = %q{ls /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Installer/}\n lnx_installer_check = %q{ps auxww | awk '{print $11}' | egrep '(/usr/bin/yum|apt-get|dpkg)'}\n lnx_updates_check = %q{( test -f /.mu-installer-ran-updates || ! test -d /var/lib/cloud/instance ) || echo \"userdata still running\"}\n win_set_pw = nil\n\n if windows? and !@config['use_cloud_provider_windows_password']\n # This covers both the case where we have a windows password passed from a vault and where we need to use a a random Windows Admin password generated by MU::Cloud::Server.generateWindowsPassword\n pw = @groomer.getSecret(\n vault: @config['mu_name'],\n item: \"windows_credentials\",\n field: \"password\"\n )\n win_check_for_pw = %Q{powershell -Command '& {Add-Type -AssemblyName System.DirectoryServices.AccountManagement; $Creds = (New-Object System.Management.Automation.PSCredential(\"#{@config[\"windows_admin_username\"]}\", (ConvertTo-SecureString \"#{pw}\" -AsPlainText -Force)));$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine); $DS.ValidateCredentials($Creds.GetNetworkCredential().UserName, $Creds.GetNetworkCredential().password); echo $Result}'}\n win_set_pw = %Q{powershell -Command \"& {(([adsi]('WinNT://./#{@config[\"windows_admin_username\"]}, user')).psbase.invoke('SetPassword', '#{pw}'))}\"}\n end\n\n # There shouldn't be a use case where a domain joined computer goes through initialSSHTasks. Removing Active Directory specific computer rename.\n set_hostname = true\n hostname = nil\n if !@config['active_directory'].nil?\n if @config['active_directory']['node_type'] == \"domain_controller\" && @config['active_directory']['domain_controller_hostname']\n hostname = @config['active_directory']['domain_controller_hostname']\n @mu_windows_name = hostname\n set_hostname = true\n else\n # Do we have an AD specific hostname?\n hostname = @mu_windows_name\n set_hostname = true\n end\n else\n hostname = @mu_windows_name\n end\n win_check_for_hostname = %Q{powershell -Command '& {hostname}'}\n win_set_hostname = %Q{powershell -Command \"& {Rename-Computer -NewName '#{hostname}' -Force -PassThru -Restart; Restart-Computer -Force }\"}\n\n begin\n # Set our admin password first, if we need to\n if windows? and !win_set_pw.nil? and !win_check_for_pw.nil?\n output = ssh.exec!(win_check_for_pw)\n raise MU::Cloud::BootstrapTempFail, \"Got nil output from ssh session, waiting and retrying\" if output.nil?\n if !output.match(/True/)\n MU.log \"Setting Windows password for user #{@config['windows_admin_username']}\", details: ssh.exec!(win_set_pw)\n end\n end\n if windows?\n output = ssh.exec!(win_env_fix)\n output = ssh.exec!(win_installer_check)\n raise MU::Cloud::BootstrapTempFail, \"Got nil output from ssh session, waiting and retrying\" if output.nil?\n if output.match(/InProgress/)\n raise MU::Cloud::BootstrapTempFail, \"Windows Installer service is still doing something, need to wait\"\n end\n if set_hostname and !@hostname_set and @mu_windows_name\n output = ssh.exec!(win_check_for_hostname)\n raise MU::Cloud::BootstrapTempFail, \"Got nil output from ssh session, waiting and retrying\" if output.nil?\n if !output.match(/#{@mu_windows_name}/)\n MU.log \"Setting Windows hostname to #{@mu_windows_name}\", details: ssh.exec!(win_set_hostname)\n @hostname_set = true\n # Reboot from the API too, in case Windows is flailing\n if [email protected]?\n @cloudobj.reboot\n else\n reboot\n end\n raise MU::Cloud::BootstrapTempFail, \"Set hostname in Windows, waiting for reboot\"\n end\n end\n else\n output = ssh.exec!(lnx_installer_check)\n if !output.nil? and !output.empty?\n raise MU::Cloud::BootstrapTempFail, \"Linux package manager is still doing something, need to wait (#{output})\"\n end\n if !@config['skipinitialupdates']\n output = ssh.exec!(lnx_updates_check)\n if !output.nil? and output.match(/userdata still running/)\n raise MU::Cloud::BootstrapTempFail, \"Waiting for initial userdata system updates to complete\"\n end\n end\n end\n rescue RuntimeError => e\n raise MU::Cloud::BootstrapTempFail, \"Got #{e.inspect} performing initial SSH connect tasks, will try again\"\n end\n\n end",
"def ssh_url\n uri = URI.parse(git_url)\n uri.scheme = 'ssh'\n uri.path = ''\n uri.fragment = nil\n uri\n end",
"def ssh_url\n uri = URI.parse(git_url)\n uri.scheme = 'ssh'\n uri.path = ''\n uri.fragment = nil\n uri\n end",
"def ssh_url\n uri = URI.parse(git_url)\n uri.scheme = 'ssh'\n uri.path = ''\n uri.fragment = nil\n uri\n end",
"def ssh!(hostspec, script)\n CommandRunner.instance.ssh! hostspec, script\n end",
"def join_cluster(config)\n\n config.vm.provision \"shell\", inline: <<-SHELL\n sshpass -p 'vagrant' scp -o StrictHostKeyChecking=no vagrant@master:join-command.sh /home/vagrant\n chmod +x /home/vagrant/join-command.sh\n ./join-command.sh \n SHELL\n\nend",
"def add_key(ssh)\n output = ssh.exec!('cat ~/.ssh/authorized_keys')\n key_file_content = File.read(@keyfile)\n ssh.exec!('mkdir ~/.ssh')\n ssh.exec!(\"echo '#{key_file_content}' >> ~/.ssh/authorized_keys\") unless output.include? key_file_content\n end",
"def cleanup\n _send_command(\"hosts -d\")\n _send_command(\"services -d\")\n _send_command(\"creds -d\")\n end",
"def clear!\n self.public_key, self.secret_key, self.username, self.password = []\n end",
"def ssh_session\n retry_flag=true\n @log.debug \"ssh is #{@config['ssh'].inspect}\"\n ssh_config = @config['ssh'].clone\n host = ssh_config['host']\n ssh_config.delete('host')\n user = ssh_config['user']\n ssh_config.delete('user')\n # Convert strings to symbols..\n ssh_config = ssh_config.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}\n ssh_config[:port] = @vm_ssh_port\n begin\n Net::SSH.start(host,user,ssh_config) do |session|\n yield session\n end\n rescue EOFError => e\n raise(e) unless retry_flag\n retry_flag = false\n @log.info \"SSH session creation failed, retrying!\"\n retry\n end\n end",
"def configure_server_ssh_key(machine)\n exit_code = SUCCESS_RESULT\n options = Net::SSH.configuration_for(machine['network'], true)\n options[:auth_methods] = %w[publickey none]\n options[:verify_host_key] = false\n options[:keys] = [machine['keyfile']]\n begin\n Net::SSH.start(machine['network'], machine['whoami'], options) do |ssh|\n add_key(ssh)\n end\n rescue StandardError\n @ui.error(\"Could not initiate connection to the node '#{machine['name']}'\")\n exit_code = ERROR_RESULT\n end\n exit_code\n end",
"def set_ssh_service(username = nil, password = nil, elevation_type = nil, elevation_user = nil, elevation_password = nil)\n @user_name = username\n @password = password\n @permission_elevation_type = elevation_type || ElevationType::NONE\n @permission_elevation_user = elevation_user\n @permission_elevation_password = elevation_password\n @service = Service::SSH\n end",
"def stdopt(\n config, hostname:, cpus: 1, memory_mb: 1024, box: \"ubuntu/focal64\"\n)\n config.vm.box = box\n config.vm.hostname = hostname\n\n config.ssh.forward_agent = true\n\n config.vm.synced_folder \".\", \"/host_share\"\n\n config.vm.provider \"virtualbox\" do |vbox|\n vbox.linked_clone = true\n vbox.cpus = cpus\n vbox.memory = memory_mb\n # Force allocation of all specified VM memory at start. Change the 1 below\n # to 0 to allow for \"as needed allocation\".\n vbox.customize [\"setextradata\", :id, \"VBoxInternal/RamPreAlloc\", 1]\n end\nend",
"def addkey\n key = \"#{ENV['HOME']}/.ssh/id_rsa.pub\"\n run \"ssh-keygen -t rsa -N \\\"#{named_options[\"passphrase\"]}\\\" -f #{key}\" unless File.exists?(key)\n\n key_contents = File.read(key)\n run_remote_command \"mkdir ~/.ssh 2>/dev/null; chmod 700 ~/.ssh; echo \\\"#{key_contents}\\\" >> ~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys\"\n end",
"def ssh_string\n uri = ssh_url\n user = \"#{uri.userinfo}@\" if uri.userinfo\n port = \":#{uri.port}\" if uri.port\n [user,uri.host,port].join\n end",
"def ssh_string\n uri = ssh_url\n user = \"#{uri.userinfo}@\" if uri.userinfo\n port = \":#{uri.port}\" if uri.port\n [user,uri.host,port].join\n end",
"def ssh_string\n uri = ssh_url\n user = \"#{uri.userinfo}@\" if uri.userinfo\n port = \":#{uri.port}\" if uri.port\n [user,uri.host,port].join\n end",
"def prepare_master_kubeconfig(config)\n\n config.vm.provision \"shell\", inline: <<-SHELL\n mkdir -p /home/vagrant/.kube\n cp -i /etc/kubernetes/admin.conf /home/vagrant/.kube/config\n chown vagrant:vagrant /home/vagrant/.kube/config\n mkdir -p $HOME/.kube\n cp -i /etc/kubernetes/admin.conf $HOME/.kube/config\n chown $(id -u):$(id -g) $HOME/.kube/config\n SHELL\n\nend",
"def touch_trigger_file(host_ip)\n FileUtils.chmod 0600, %w(ssh/id_rsa)\n\n Net::SSH.start(\n host_ip,\n SSH_USER,\n host_key: \"ssh-rsa\",\n keys: [\"ssh/id_rsa\"],\n verify_host_key: :never,\n ) do |session|\n session.exec!(\"sudo touch #{TRIGGER_FILE} \")\n end\nend",
"def createEc2SSHKey\n\t\t\treturn [@keypairname, @ssh_private_key, @ssh_public_key] if [email protected]?\n\t\t keyname=\"deploy-#{MU.mu_id}\"\n\t\t\tkeypair = MU.ec2(MU.myRegion).create_key_pair(key_name: keyname)\n\t\t\t@keypairname = keyname\n\t\t @ssh_private_key = keypair.key_material\n\t\t\tMU.log \"SSH Key Pair '#{keyname}' fingerprint is #{keypair.key_fingerprint}\"\n\t\t\n\t\t if !File.directory?(\"#{@myhome}/.ssh\") then\n\t\t\t\tMU.log \"Creating #{@myhome}/.ssh\", MU::DEBUG\n\t\t Dir.mkdir(\"#{@myhome}/.ssh\", 0700)\n\t\t end\n\t\t\n\t\t # Plop this private key into our local SSH key stash\n\t\t\tMU.log \"Depositing key '#{keyname}' into #{@myhome}/.ssh/#{keyname}\", MU::DEBUG\n\t\t ssh_keyfile = File.new(\"#{@myhome}/.ssh/#{keyname}\", File::CREAT|File::TRUNC|File::RDWR, 0600)\n\t\t ssh_keyfile.puts @ssh_private_key\n\t\t ssh_keyfile.close\n\n\t\t\t# Drag out the public key half of this\n\t\t\t@ssh_public_key = %x{/usr/bin/ssh-keygen -y -f #{@myhome}/.ssh/#{keyname}}\n\t\t\t@ssh_public_key.chomp!\n\n\t\t\t# Replicate this key in all regions\n\t\t\tMU::Config.listRegions.each { |region|\n\t\t\t\tnext if region == MU.myRegion\n\t\t\t\tMU.log \"Replicating #{keyname} to #{region}\", MU::DEBUG, details: @ssh_public_key\n\t\t\t\tMU.ec2(region).import_key_pair(\n\t\t\t\t\tkey_name: @keypairname,\n\t\t\t\t\tpublic_key_material: @ssh_public_key\n\t\t\t\t)\n\t\t\t}\n\n# XXX This library code would be nicer... except it can't do PKCS8.\n#\t\t\tfoo = OpenSSL::PKey::RSA.new(@ssh_private_key)\n#\t\t\tbar = foo.public_key\n\n\t\t\tsleep 3\n\t\t return [keyname, keypair.key_material, @ssh_public_key]\n\t\tend",
"def setup_private_key\n\n # If we don't have a data dir, we also do nothing (base package)\n return if [email protected]_dir\n\n # If we don't have a generated private key, we do nothing\n path = @vm.data_dir.join(\"private_key\")\n return if !path.file?\n\n # Copy it into our box directory\n dir = Pathname.new(@tmp_path)\n new_path = dir.join(\"vagrant_private_key\")\n FileUtils.cp(path, new_path)\n\n # Append it to the Vagrantfile (or create a Vagrantfile)\n vf_path = dir.join(\"Vagrantfile\")\n mode = \"w+\"\n mode = \"a\" if vf_path.file?\n vf_path.open(mode) do |f|\n f.binmode\n f.puts\n f.puts %Q[Vagrant.configure(\"2\") do |config|]\n f.puts %Q[ config.ssh.private_key_path = File.expand_path(\"../vagrant_private_key\", __FILE__)]\n f.puts %Q[end]\n end\n end",
"def setup_ssh_keys\n @env[:ui].info 'Ensuring ssh-keys have been added via `ssh-add`...'\n current_keys = `ssh-add -l`\n if current_keys.include? 'no identities'\n success = system('ssh-add')\n if success\n @env[:ui].success '...ssh-keys successfully added'\n else\n @env[:ui].warn 'failed to call `ssh-add`, some requirements may fail to install'\n end\n else\n @env[:ui].info '...ssh-keys detected, skipping `ssh-add`'\n end\n end",
"def ssh\n @_ssh ||= Net::SSH.start(host, user, options)\n end",
"def dup_ssh(&block)\n Snapsync.debug \"Opening new ssh session: \"+uri.to_s\n Net::SSH.start(uri.host, uri.user, password: uri.password, non_interactive: true, &block)\n end",
"def provision_ansible_local(box, key, ansible_config, vm_config)\n box.vm.provision :ansible_local do |ansible|\n provision_ansible_common(ansible, key, ansible_config, vm_config)\n properties = [\n 'install',\n 'install_mode',\n 'provisioning_path',\n 'tmp_path',\n 'playbook'\n ]\n properties.each do | property_name |\n set_instance_variable(ansible_config, ansible, property_name )\n end\n end\nend",
"def ssh_cmd_base(host_or_ip)\n return [\"sudo\", \"-i\", \"-u\", \"root\", \"--\", \"ssh\", \"-o\", \"TCPKeepAlive=no\", \"-o\", \"ServerAliveInterval=15\", \"root@#{host_or_ip}\"]\n end",
"def fetch_kubeconfig(config)\n\n config.vm.provision \"shell\", inline: <<-SHELL\n sshpass -p 'vagrant' scp -r -o StrictHostKeyChecking=no vagrant@master:.kube /home/vagrant\n chown vagrant:vagrant /home/vagrant/.kube/config\n sshpass -p 'vagrant' scp -r -o StrictHostKeyChecking=no vagrant@master:.kube /root\n chown root:root /root/.kube/config\n SHELL\n\nend",
"def ssh_login_as_root\n deploy_test_on_hosts_as 'root', self.hosts, '/root', \"Should be able to connect as root via ssh\" do\n 'pwd'\n end\n end",
"def configure_communication(\n machine,\n instance_profile,\n auth_method_default = 'keypair',\n forward_agent_default = false,\n forward_x11_default = false,\n gui_default = false,\n insert_key_default = true,\n password_default = 'vagrant',\n provider = 'virtualbox',\n username_default = 'vagrant'\n)\n\n instance_communication = lookup_values_yaml(instance_profile, ['providers', provider, 'instance', 'communication'])\n\n machine.vm.provider provider do |virtualbox|\n virtualbox.gui = [\n validate_value(lookup_values_yaml(instance_communication, ['display', 'gui'])),\n gui_default\n ].find { |i| !i.nil? }\n end\n\n instance_ssh = lookup_values_yaml(instance_communication, ['ssh'])\n\n if instance_ssh\n\n machine.ssh.forward_agent = [\n validate_value(lookup_values_yaml(instance_ssh, ['forward_agent'])),\n forward_agent_default\n ].find { |i| !i.nil? }\n\n machine.ssh.forward_x11 = [\n validate_value(lookup_values_yaml(instance_ssh, ['forward_x11'])),\n forward_x11_default\n ].find { |i| !i.nil? }\n\n machine.ssh.username = [\n lookup_values_yaml(instance_ssh, ['username']),\n username_default\n ].find { |i| !i.nil? }\n\n machine.ssh.insert_key = [\n validate_value(lookup_values_yaml(instance_ssh, ['insert_key'])),\n insert_key_default\n ].find { |i| !i.nil? }\n\n auth_method = [\n lookup_values_yaml(instance_ssh, ['auth_method']),\n auth_method_default\n ].find { |i| !i.nil? }\n validate_value(auth_method, ['keypair', 'password'])\n\n if auth_method == 'password'\n machine.ssh.password = [\n lookup_values_yaml(instance_ssh, ['password']),\n password_default\n ].find { |i| !i.nil? }\n elsif auth_method == 'keypair'\n # Private key is the default option for connections in Vagrant so no setting required here.\n end\n\n end\n\nend",
"def restore_local_hosts(project_name)\n `sudo cp #{local_hosts_path}/hosts_before_#{project_name} #{local_hosts_path}/hosts`\n `sudo rm #{local_hosts_path}/hosts_before_#{project_name}`\n end",
"def build_ssh_command(host)\n user_opt = ''\n key_opt = ''\n port_opt = ''\n ssh_options = config.rsync_options\n\n if user = host.user || ssh_options[:user]\n user_opt = \" -l #{user}\"\n end\n\n if keys = (host.keys.empty? ? ssh_options[:keys] : host.keys)\n keys = keys.is_a?(Array) ? keys : [keys]\n key_opt = keys.map { |key| \" -i #{key}\" }.join('')\n end\n\n if port = host.port || ssh_options[:port]\n port_opt = \" -p #{port}\"\n end\n\n \"ssh#{user_opt}#{key_opt}#{port_opt}\"\n end",
"def credentials\n if Rails.env.test? || Rails.env.development?\n Rugged::Credentials::SshKeyFromAgent.new(username: username)\n else\n Rugged::Credentials::SshKey.new(username: 'git', publickey: SETTINGS['ssh_public_key'], privatekey: SETTINGS['ssh_private_key'])\n end\n end",
"def run!\n ssh commands(:default)\n end",
"def set_hostname(server)\n server.vm.provision 'shell', inline: \"hostname #{server.vm.hostname}\"\nend",
"def ssh_service_restart\n exec(Beaker::Command.new(\"stopsrc -g ssh\"))\n exec(Beaker::Command.new(\"startsrc -g ssh\"))\n end",
"def create_etc_hosts(cluster)\n if ENV['VAGRANT_CWD'] then\n folder = ENV['VAGRANT_CWD'] + \"/export/.etc_hosts\"\n etc_file = open(folder, \"w\")\n else\n etc_file = open(\"./export/.etc_hosts\", \"w\")\n end\n etc_file.write(\"127.0.0.1 localhost\\n\")\n\n cluster.each do |role, member_list|\n member_list.each do |member_info|\n etc_file.write(\"#{member_info['contiv_control_ip']} #{member_info['name']}\\n\")\n if role == \"master\" then\n\tetc_file.write(\"#{member_info['contiv_control_ip']} netmaster \\n\")\n end\n end\n end\n\n etc_file.close\nend",
"def set_ssh_key\n @ssh_key = current_user.ssh_keys.find(params[:id])\n end",
"def provision_execute(s, commands)\n errors = []\n return errors if (commands.nil? or commands.empty?)\n \n if (!get_field(\"cloud_ips\").nil? and !get_field(\"cloud_ips\").empty?)\n host = get_field(\"cloud_ips\")[0]\n elsif (!get_field(\"cloud_private_ips\").nil? and !get_field(\"cloud_private_ips\").empty?)\n host = get_field(\"cloud_private_ips\")[0]\n else\n msg = \"No IP address associated to the machine #{host} - cannot run SSH command\"\n errors << msg\n log_output(msg, :info)\n return errors\n end\n \n ssh_password = get_field('ssh_password')\n ssh_options = {}\n msg = \"Running SSH Commands On New Machine #{s.username}@#{host}\"\n msg_options = {}\n if (ssh_password and !ssh_password.empty?)\n ssh_options[:password] = ssh_password\n msg_options[:password] = \"*\" * ssh_password.size\n end\n msg_options[:private_key_path] = s.private_key_path if s.private_key_path\n msg_options[:private_key] = mask_private_key(s.private_key.strip) if s.private_key # show only last 5 chars\n log_output(\"#{msg} using #{msg_options}: #{commands.join(\", \")}\", :info)\n\n for i in 1..10\n begin\n log_output(\"[#{host}] Running Commands:\\n #{commands.join(\"\\n \")}\\n\")\n responses = s.ssh(commands, ssh_options) do |data, extended_data|\n write_output(data, :buffer => true) unless data.empty? #stdout\n write_output(extended_data, :buffer => true) unless extended_data.empty? #stderr\n end\n\n responses.each do |result|\n if result.status != 0\n msg = \"[#{host}] Command '#{result.command}' failed with status #{result.status}\"\n errors << msg\n log_output(msg, :info)\n end\n end unless responses.nil?\n break\n rescue Errno::EHOSTUNREACH, Timeout::Error, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Net::SSH::Disconnect => e\n log_output(\"[#{host}] Try #{i} - failed to connect: #{e}, retrying...\", :info)\n if i+1 > 10\n msg = \"[#{host}] Could not connect to remote machine after 10 attempts\"\n errors << msg\n log_output(msg, :warn)\n else\n sleep 5\n next\n end\n rescue Net::SSH::AuthenticationFailed => e\n log_output(\"[#{host}] Try #{i} - failed to connect: authentication failed for user #{e.message}, retrying...\", :info)\n if i+1 > 10\n msg = \"[#{host}] Could not connect to remote machine after 10 attempts, authentication failed for user #{e.message}\"\n errors << msg\n log_output(msg, :warn)\n else\n sleep 5\n next\n end\n end\n end\n return errors\n end",
"def vm_ssh(env, cmd)\n puts \">>> '#{cmd}'\"\n env.primary_vm.ssh.execute do |ssh|\n ssh.exec!(cmd) do |channel, stream, data|\n print data\n $stdout.flush\n end\n end\nend",
"def set_hostname(server)\r\n\tserver.vm.provision 'shell', inline: \"hostname #{server.vm.hostname}\"\r\nend",
"def exec(opts={})\n # Get the SSH information and cache it here\n ssh_info = info\n\n if Util::Platform.windows?\n raise Errors::SSHUnavailableWindows, :host => ssh_info[:host],\n :port => ssh_info[:port],\n :username => ssh_info[:username],\n :key_path => ssh_info[:private_key_path]\n end\n\n raise Errors::SSHUnavailable if !Kernel.system(\"which ssh > /dev/null 2>&1\")\n\n # If plain mode is enabled then we don't do any authentication (we don't\n # set a user or an identity file)\n plain_mode = opts[:plain_mode]\n\n options = {}\n options[:host] = ssh_info[:host]\n options[:port] = ssh_info[:port]\n options[:username] = ssh_info[:username]\n options[:private_key_path] = ssh_info[:private_key_path]\n\n # Command line options\n command_options = [\"-p\", options[:port].to_s, \"-o\", \"UserKnownHostsFile=/dev/null\",\n \"-o\", \"StrictHostKeyChecking=no\", \"-o\", \"LogLevel=FATAL\", \"-p\", options[:password].to_s]\n\n # Solaris/OpenSolaris/Illumos uses SunSSH which doesn't support the IdentitiesOnly option\n # (Also don't use it in plain mode, it'll skip user agents.)\n command_options += [\"-o\", \"IdentitiesOnly=yes\"] if !(Util::Platform.solaris? || plain_mode)\n\n command_options += [\"-i\", options[:private_key_path]] if !plain_mode\n command_options += [\"-o\", \"ForwardAgent=yes\"] if ssh_info[:forward_agent]\n\n # If there are extra options, then we append those\n command_options.concat(opts[:extra_args]) if opts[:extra_args]\n\n if ssh_info[:forward_x11]\n # Both are required so that no warnings are shown regarding X11\n command_options += [\"-o\", \"ForwardX11=yes\"]\n command_options += [\"-o\", \"ForwardX11Trusted=yes\"]\n end\n\n host_string = options[:host]\n host_string = \"#{options[:username]}@#{host_string}\" if !plain_mode\n command_options << host_string\n @logger.info(\"Invoking SSH: #{command_options.inspect}\")\n safe_exec(\"ssh\", *command_options)\n end",
"def ssh_into(instance=nil)\n Kernel.system \"#{ssh_command(instance)}\" if instance\n end",
"def shell_provisioners_once(vm, host)\n if host.has_key?('shell_once')\n host['shell_once'].each do |script|\n vm.provision \"shell\", inline: script['cmd']\n end\n end\nend",
"def salt_provision_saferwall_box(context)\n context.vm.provision \"salt\", run: 'once' do |salt|\n salt.minion_config = \"salt/etc/minion\"\n salt.masterless = true\n salt.run_highstate = false\n salt.verbose = true\n salt.log_level = \"info\"\n salt.colorize = true\n salt.install_type = \"git\"\n salt.version = \"3003\"\n salt.python_version = \"3\"\n salt.bootstrap_options = \"-P -x python3 -c /tmp\"\n end\nend",
"def ssh_common_opts\n [\"-i #{@machine.ssh_info[:private_key_path]}\",\n \"-p #{@machine.ssh_info[:port]}\",\n \"-o StrictHostKeyChecking=no\",\n \"-o UserKnownHostsFile=/dev/null\",\n \"-o IdentitiesOnly=yes\",\n \"-o LogLevel=ERROR\"]\n end",
"def clear_host!\n @host_key_files = []\n @known_host_identities = nil\n self\n end",
"def update_etc_hosts\n comm = machine.communicate\n network_with_hostname = machine.config.vm.networks.map {|_, c| c if c[:hostname] }.compact[0]\n if network_with_hostname\n replace_host(comm, new_hostname, network_with_hostname[:ip])\n else\n add_hostname_to_loopback_interface(comm, new_hostname)\n end\n end"
] | [
"0.75587314",
"0.7197087",
"0.6847204",
"0.6667514",
"0.6529258",
"0.64398086",
"0.64337",
"0.6367353",
"0.63625145",
"0.6337364",
"0.6336996",
"0.6335988",
"0.63244736",
"0.62040335",
"0.61573225",
"0.6138676",
"0.6138652",
"0.6117534",
"0.60967374",
"0.60480905",
"0.59927624",
"0.59612",
"0.5906977",
"0.5886836",
"0.57885253",
"0.57498175",
"0.5740511",
"0.5702579",
"0.56894094",
"0.5685275",
"0.5678092",
"0.5672724",
"0.5656331",
"0.5654751",
"0.56422573",
"0.5637752",
"0.5632748",
"0.5625534",
"0.56210536",
"0.5601877",
"0.55994403",
"0.5599051",
"0.55834395",
"0.5568807",
"0.55686796",
"0.55668724",
"0.5535343",
"0.55158883",
"0.5515843",
"0.54997504",
"0.54735804",
"0.5466391",
"0.5441659",
"0.5437329",
"0.54367644",
"0.54367644",
"0.54367644",
"0.54300684",
"0.54266363",
"0.540837",
"0.5402211",
"0.53969806",
"0.5396501",
"0.53914416",
"0.5371982",
"0.536425",
"0.5360145",
"0.535236",
"0.535236",
"0.535236",
"0.5352322",
"0.53395265",
"0.5337901",
"0.53358227",
"0.5329283",
"0.53147507",
"0.5314677",
"0.5310678",
"0.5309365",
"0.5303805",
"0.53016186",
"0.5287637",
"0.52832085",
"0.5273646",
"0.52663076",
"0.5264159",
"0.5260082",
"0.5257148",
"0.52416587",
"0.523828",
"0.52363",
"0.52360964",
"0.5235841",
"0.52339345",
"0.5231427",
"0.5223886",
"0.5207729",
"0.5200282",
"0.5197979",
"0.5196094"
] | 0.76308215 | 0 |
load the permissions for the current user so that UI can be manipulated | def load_permissions
@current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_permissions \n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]} \n end",
"def load_permissions\n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]}\n end",
"def load_permissions_from_user\n # user_permission_sets = user.permission_sets.entries\n user_permission_sets = user.roles.first ? user.roles.first.permission_sets.entries : []\n\n Hash.new do |h, k|\n h[k] = user_permission_sets.detect { |set| set.name == k } || SessionPermissionSet.new(k, 0)\n end\n end",
"def load_permissions\n authorize! :manage, :all\n end",
"def user_permissions\n if user_signed_in? && (current_user.is_logistics? || current_user.is_clerical? || current_user.is_vendor? || current_user.is_customer?)\n authorize! :edit, Element\n end\n end",
"def load_permissions\n permission_data = self['permissions'].to_s\n \n # Guest = Unauthenticated, User = Authenticated -- maybe...\n if permission_data =~ /(Guest|User)\\[([0-9\\-:T]{25})\\]\\:(.*)/\n permission_cache_source = $1\n permission_cache_last_updated = DateTime.parse($2)\n permission_string = $3\n else\n return update_permission_cache(guest? ? load_permissions_from_guest_role : load_permissions_from_user)\n end\n \n cached_permission_map = Hash[*permission_string.split(';').map { |permission| key, value = permission.split('='); [key, SessionPermissionSet.new(key, value.to_i)] }.flatten]\n loader = lambda { |group_name| cached_permission_map[group_name] || SessionPermissionSet.new(group_name, 0) }\n\n if guest?\n if permission_cache_source != 'Guest' || (guest.updated_at > permission_cache_last_updated) \n update_permission_cache(load_permissions_from_guest_role)\n else\n loader\n end\n else\n if permission_cache_source != 'User' || (user.updated_at > permission_cache_last_updated) \n update_permission_cache(load_permissions_from_user)\n else\n loader\n end\n end\n end",
"def permissions\n\t\tauthorize @user\n\t\t@permissions = []\n\t\tonly_theirs = \"Only theirs\"\n\t\tyes = \"Yes\"\n\t\tno = \"No\"\n\t\tnames = [\"View positions\", \"Create positions\", \"Edit positions\", \"Delete positions\",\n\t\t \"Apply\", \"View applications\", \"Edit applications\", \"Delete applications\",\n\t\t \"Change application submission status\"]\n\t\tadmin_permissions = [yes, yes, yes, yes, yes, \"All\", yes, yes, yes]\n\t\tmod_permissions = [yes, no, yes, no, yes, \"All but incomplete\", only_theirs, only_theirs, yes]\n\t\tuser_permissions = [yes, no, no, no, yes, only_theirs, only_theirs, only_theirs, no]\n\t\tnames.each_with_index do |permission, index|\n\t\t\t@permissions << { name: names[index], admin: admin_permissions[index], mod: mod_permissions[index], user: user_permissions[index]}\n\t\tend\n\n @title = 'Permissions'\n\tend",
"def permissions = {}",
"def permissions\n User.do_find_permissions session_id: kb_session_id\n end",
"def user_permissions\n if current_user.id == params[:id].to_i\n @user = User.find(params[:id])\n else\n flash[:danger] = 'Unauthorized action.'\n redirect_to edit_user_path(current_user) \n end\n end",
"def show\n\t\t@all_permissions = Lockdown::System.permissions_assignable_for_user(current_user)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_group }\n end\n end",
"def set_perms\n self.perms = Access.for_user(self)\n end",
"def permissions\n permissions_menu_button\n wait_for_ajax(2)\n permissions_button\n wait_for_ajax(2)\n self.class.class_eval { include ContentPermissionsPopUp }\n end",
"def admin_grant_permissions\n @user = User.includes(:perms).find(params[:id])\n authorize @user\n user_perms = current_user.perms\n @perms = user_perms & [Perm.grant_permissions, Perm.modify_templates, Perm.modify_guidance, Perm.use_api, Perm.change_org_details]\n end",
"def get_active_permissions\n set_access_token\n if @access_token && !@permissions && set_uid\n # if we don't have permissions set but have an access token\n # grab the user's info\n @rest = Facebook::RestAPI.new(@access_token) \n result = @rest.fql_query(\"select #{all_permissions.join(\",\")} from permissions where uid = #{@uid.to_s}\")\n result.first\n end \n end",
"def custom_permissions\n if current_user.admin?\n can :manage, :all\n end\n end",
"def allow_edit(user)\n permission = self.content_permissions.by_user(user).first\n if !permission # Make sure the user is only added once\n permission = self.content_permissions.create(:user => user)\n end\n permission\n end",
"def get_permissions\n permissions = Hash.new\n permissions[:CanEditAllTeams] = 1\n permissions[:CanEditAllPlayers] = 2\n permissions[:CanEditAllSeasons] = 3\n permissions[:CanEditAllDivisions] = 4\n permissions[:CanEditAllRatings] = 5\n permissions[:CanEditAllRoles] = 6\n permissions[:CanEditAllPermissions] = 7\n permissions[:CanImport] = 8\n permissions[:CanApproveRatings] = 10\n @permissions = permissions\n end",
"def show\n @user = User.find(params[:id])\n can_edit_hash = Permissions.currentLoggedInOrHasMorePermissions(@current_user,@user)\n @can_edit = can_edit_hash[:has_permission]\n\n #max needs\n @can_see_pref= Permissions.is_at_least_manager(@current_user)\n\n profile_attrs = [:first_name,:last_name, :email,:phone_number]\n @first_name = @user.first_name\n @last_name = @user.last_name\n @email = @user.email\n @phone_number = @user.phone_number\n @role = @user.role\n end",
"def init_rac_data\n \n if connected_user and (self.permission_owner.nil? or self.permission_owner.empty?)\n self.permission_owner = connected_user.username\n end\n\n if connected_user and connected_user.usergroups.length > 0 and (self.permission_group.nil? or self.permission_group.empty?)\n self.permission_group = connected_user.usergroups.first.group \n end\n\n if self.permission_modifier_owner.nil? \n self.permission_modifier_owner = 6 \n end\n \n if self.permission_modifier_group.nil?\n self.permission_modifier_group = 2 \n end\n \n if self.permission_modifier_all.nil?\n self.permission_modifier_all = 0\n end \n\n end",
"def permissions( force_reload = false )\n\n # Two levels of joins here, so can't use has_many :through\n if force_reload\n @permissions = nil \n @permissions_by_class_and_op = {}\n end\n\n cond_str = 'role_id in ' + self.class.role_assigned_cond( '?' )\n if !instance_variable_defined?(\"@permissions\") || @permissions.nil?\n @permissions ||= Permission.where([cond_str, self]).to_a\n end\n\n return @permissions\n end",
"def permissions\n Rails.cache.fetch(\"permissions_#{self.id}\", expire_in: 1.month) do\n self.roles.map(&:permissions).flatten\n end\n end",
"def show\n @all_permissions = Permission.all\n end",
"def get_permissions_for_user(user)\n get_filtered_policy(0, user)\n end",
"def apps_permissions_users_list(_user_id=nil)\n #raise StandardError, \"APUL caller #{caller_method_name} user #{_user_id}\"\n return {} unless is_app_token?\n semaphore.synchronize {\n @apps_permissions_users_list ||= (\n r = get('/api/apps.permissions.users.list').parsed\n r['resources'].to_a.inject({}){|h,i| h[i['id']] = i; h} || {}\n )\n _user_id ? @apps_permissions_users_list[_user_id].to_h['scopes'] : @apps_permissions_users_list\n }\n end",
"def edit\n @user = User.find(params[:id])\n logger.tagged(\"edit current user: \") {logger.debug @current_user.attributes}\n #TODO : make sure permissions are handled correctly\n can_edit_hash = Permissions.currentLoggedInOrHasMorePermissions(@current_user,@user)\n logger.tagged(\"edit user perm hash: \") {logger.debug can_edit_hash}\n if can_edit_hash[:has_permission]\n can_destroy_hash = Permissions.hasMorePermissions(@current_user,@user)\n @can_destroy = can_destroy_hash[:has_permission]\n else\n flash[:warning] = can_edit_hash[:permission_message]\n redirect_to user_path(@user)\n end\n\n end",
"def custom_permissions\n alias_action :show, :manifest, to: :read\n alias_action :color_pdf, :pdf, :edit, :browse_everything_files, :structure, :file_manager, to: :modify\n roles.each do |role|\n send \"#{role}_permissions\" if current_user.send \"#{role}?\"\n end\n end",
"def custom_permissions\n alias_action :show, :manifest, to: :read\n alias_action :color_pdf, :pdf, :edit, :browse_everything_files, :structure, :file_manager, to: :modify\n roles.each do |role|\n send \"#{role}_permissions\" if current_user.send \"#{role}?\"\n end\n end",
"def load_user_and_authorization\n @owner_user = User.find( params[:user_id] )\n @current_user_is_owner = ( current_user_id == params[:user_id].to_i )\n end",
"def my_permissions\n @my_permissions ||= self.roles.map {|r| r.permissions.map {|p| p.name}}.flatten.freeze\n end",
"def setup_perms\n perms = []\n controller_actions(perms)\n model_actions(perms)\n perms << cat_perms\n perms << api_perms\n puts 'Permissions gathering finished...'\n puts \"Permissions were loaded from #{perms.size} classes.\"\n return perms\nend",
"def permissions\n read_attribute(:permissions) || {}\n end",
"def custom_permissions\n discover_permissions\n export_sets_permissions\n batches_permissions\n preservation_events_permissions\n end",
"def user_permission\n has_controller_permission?('user')\n end",
"def core_getUsersPermissions\n # definisco permessi iniziali\n initial_permissions = (1...11).to_a\n\n unpermitted = core_getHideUsersPermissionsSettings\n permitted_permissions = initial_permissions\n permitted_permissions = initial_permissions - unpermitted if unpermitted\n\n permissions = []\n names = core_getUsersPermissionsNamesSettings\n return permitted_permissions if !names\n\n permitted_permissions.each do |permission|\n names.each do |name|\n permissions.push([permission, name.last]) if permission === name.first.to_i\n end\n end\n\n return permissions\n end",
"def permissions=(value)\n @permissions = value\n end",
"def fetch_granted_permissions(action:, user:, type:, target:, token:)\n permissions = granted_permissions_for_user(user: user, type: type, target: target, token: token)\n @read = permissions.include?('read')\n @create = permissions.include?('create')\n @update = permissions.include?('update')\n @delete = permissions.include?('delete')\n instance_variable_get(\"@#{action}\")\n end",
"def show\n @permissions = Permission.all\n end",
"def get_permissions(poll_path, polls = read_polls_data)\n if signed_in?\n @user.permissions(poll_path, polls)\n else\n []\n end\n end",
"def show\n @permissions = @role.permissions\n end",
"def permissions_assignable_for_user(usr)\n return [] if usr.nil?\n if administrator?(usr)\n get_permissions.collect{|k| Permission.find_by_name(Lockdown.get_string(k)) }.compact\n else\n user_groups_assignable_for_user(usr).collect{|g| g.permissions}.flatten.compact\n end\n end",
"def admin_grant_permissions\n user = User.find(params[:id])\n authorize user\n\n # Super admin can grant any Perm, org admins can only grant Perms they\n # themselves have access to\n perms = if current_user.can_super_admin?\n Perm.all\n else\n current_user.perms\n end\n\n render json: {\n 'user' => {\n 'id' => user.id,\n 'html' => render_to_string(partial: 'users/admin_grant_permissions',\n locals: { user: user, perms: perms },\n formats: [:html])\n }\n }.to_json\n end",
"def custom_permissions\n if user_groups.include?(\"admin\")\n can :manage, :all\n end\n end",
"def getPermissions\n perms = []\n perms.push :disseminate if params[:disseminate_perm] == \"on\"\n perms.push :withdraw if params[:withdraw_perm] == \"on\"\n perms.push :peek if params[:peek_perm] == \"on\"\n perms.push :submit if params[:submit_perm] == \"on\"\n perms.push :report if params[:report_perm] == \"on\" \n perms \n end",
"def prepare_permissions\n if current_ability.admin?\n else\n # Need to add admin group to current_ability\n # or presenter will not be accessible.\n current_ability.user_groups << \"admin\"\n if presenter.tombstone.present? \n else\n current_ability.user_groups.delete(\"admin\")\n end\n end\n end",
"def permissions_assignable_for_user(usr)\n return [] if usr.nil?\n if administrator?(usr)\n get_permissions.collect do |k| \n ::Permission.find_by_name(Lockdown.get_string(k))\n end.compact\n else\n user_groups_assignable_for_user(usr).collect do |g| \n g.permissions\n end.flatten.compact\n end\n end",
"def user?\n permissions == 'user'\n end",
"def permissions\n if @permissions.nil?\n perm_array = []\n roles.each { |r| perm_array << r.permission_ids }\n @permissions = perm_array.flatten.uniq\n else\n @permissions\n end\n end",
"def permission_resources\n %w{roles sites employees classrooms students gapps_org_units}\n end",
"def header_menu\n return [] unless current_user\n permissions = current_user.permissions.pluck(:name)\n permissions << 'administration_section' if current_user.admin_permission?\n MENU['permissions'].select do |key, value|\n value if permissions.include? key\n end\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 permission\n Ricer::Irc::Permission.by_permission(self.permissions, authenticated?)\n end",
"def permissions_for(game)\n self.permissions.where(\"user_roles.game_id = ?\", game.id)\n end",
"def permissions\n objects_from_response(Code42::Permission, :get, 'permission')\n end",
"def overall_permissions(thing)\n global_permissions.merge!(permissions_for(thing))\n end",
"def authorize_for_user(user, group=nil, actions=Permissions::View)\n # Must save content authorization association 1st\n get_privacy_setting.save\n auth = authorizations.find_or_initialize_by_user_id_and_circle_id(\n :user_id => user ? user.id : 0, \n :circle_id => group ? group.id : 0)\n auth.permissions = Permissions.new(actions)\n if auth.save\n update_privacy_level(ContentAuthorization::AuthPartial)\n end\n end",
"def get_permissions(username)\n p = lookup_permissions(username)\n if p\n return p\n else\n return nil\n end\n end",
"def perms\n if @perms.nil?\n @perms = {}\n permissions = ['comment', 'edit', 'reassign', 'prioritize', 'close', 'milestone']\n permissions.each do |p|\n if @task.project_id.to_i == 0 || current_user.can?(@task.project, p)\n @perms[p] = {}\n else\n @perms[p] = { :disabled => 'disabled' }\n end\n end\n\n end\n\n @perms\n end",
"def grant_permissions( force_reload = false )\n permissions( force_reload ).select( &:is_grant? )\n end",
"def permissions\n frm.link(:text=>\"Permissions\").click\n AssignmentsPermissions.new(@browser)\n end",
"def mode_settings\n authorize!(@user)\n end",
"def permits_read_acccess_for(user)\n end",
"def get_permissions\n permissions.keys\n end",
"def get_permissions\n permissions.keys\n end",
"def permissions_policy(&block); end",
"def edit_user_permission?(permission)\n edit_user_permission = session.dig(:edit_user, 'permissions')\n return if edit_user_permission.nil?\n\n edit_user_permission.include?(permission)\n end",
"def flush_permissions!\n @permissions = load_permissions\n end",
"def permissions\n return @permissions\n end",
"def show\n @permissionviews = Permissionview.all\n @roles = Role.all\n end",
"def index\n\n @launch_permissions = LaunchPermission.find_for_user(session[:user])\n end",
"def fb_permissions\n fb_user = FbGraph::User.new('me', :access_token => self.access_token)\n fb_user.permissions\n end",
"def apply_superuser_permissions(permission_types)\n []\n end",
"def access_rights_for_permission(perm)\n sym = Lockdown.get_symbol(perm)\n\n permissions[sym]\n rescue \n raise SecurityError, \"Permission requested is not defined: #{sym}\"\n end",
"def all_chanperms\n Ricer::Irc::Chanperm.where(:user_id => self.id)\n end",
"def user_permissions(id:, **args)\n params = parameters(args) do\n optional_params\n end\n request(:get, \"users/#{id}/permissions\", params)\n end",
"def show\n \tauthorize! :read, @user\n end",
"def get_user\n @current_user = current_user\n @can_manage = can? :manage, Event\n end",
"def custom_permissions\n can [:file_status, :stage, :unstage], FileSet\n\n if current_user.ingest_from_external_sources?\n end\n\n if current_user.manage_users?\n can [:show, :add_user, :remove_user, :index], Role\n end\n\n if current_user.manage_roles?\n can [:create, :show, :index, :edit, :update, :destroy], Role\n end\n\n if current_user.run_fixity_checks?\n can [:fixity], FileSet\n end\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def load_user\n @user = current_user\n @check_ownership_of = @user\n end",
"def custom_permissions # rubocop:disable Metrics/CyclomaticComplexity\n can :read, ApplicationPresenter, &:can_read?\n can :read, UsersPresenter, &:can_read?\n can :read, UserPresenter, &:can_read?\n can :read, RolesPresenter, &:can_read?\n can :read, RolePresenter, &:can_read?\n\n can :read, Press\n\n grant_press_analyst_abiltites if press_analyst?\n grant_press_editor_abilities if press_editor?\n grant_press_admin_abilities if platform_admin? || press_admin?\n grant_platform_admin_abilities if platform_admin?\n end",
"def has_permissions?(resource_permissions)\n fetch_permissions! resource_permissions.keys unless @fetched_all\n super\n end",
"def authorize_admin\n redirect_to :login unless current_user.permission.manage_app ||\n current_user.permission.manage_attrs ||\n current_user.permission.manage_achievement_categories ||\n current_user.permission.manage_talent_trees ||\n current_user.permission.manage_talents ||\n current_user.permission.manage_quests ||\n current_user.permission.manage_skills ||\n current_user.permission.manage_achievements ||\n current_user.permission.manage_items ||\n current_user.permission.manage_titles\n end",
"def get_permissions\n \t@permissions = Permission.where(\"resource_id = #{params[:resource_id]} AND resource_type = '#{params[:resource_type]}' AND status = 1\") \t\n \trespond_to do |format| \t\n format.js\n end\n end",
"def custom_permissions\n\n campus = \"bakersfield\" if current_user.email.include?(\"bakersfield.edu\")\n campus = \"chancellor\" if current_user.email.include?(\"calstate.edu\")\n campus = \"channel\" if current_user.email.include?(\"ci.edu\")\n campus = \"chico\" if current_user.email.include?(\"chico.edu\")\n campus = \"dominguez\" if current_user.email.include?(\"dh.edu\")\n campus = \"eastbay\" if current_user.email.include?(\"eb.edu\")\n campus = \"fresno\" if current_user.email.include?(\"fresno.edu\")\n campus = \"fullerton\" if current_user.email.include?(\"fullerton.edu\")\n campus = \"humboldt\" if current_user.email.include?(\"humboldt.edu\")\n campus = \"longbeach\" if current_user.email.include?(\"lb.edu\")\n campus = \"losangeles\" if current_user.email.include?(\"la.edu\")\n campus = \"maritime\" if current_user.email.include?(\"maritime.edu\")\n campus = \"mlml\" if current_user.email.include?(\"mlml.edu\")\n campus = \"northridge\" if current_user.email.include?(\"northridge.edu\")\n campus = \"pomona\" if current_user.email.include?(\"bronco.edu\")\n campus = \"sacramento\" if current_user.email.include?(\"sacramento.edu\")\n campus = \"sanfrancisco\" if current_user.email.include?(\"sf.edu\")\n campus = \"sanmarcos\" if current_user.email.include?(\"sanmarcos.edu\")\n campus = \"sonoma\" if current_user.email.include?(\"sonoma.edu\")\n campus = \"stanislaus\" if current_user.email.include?(\"stanislaus.edu\")\n\n user_groups.push(campus)\n\n # admin\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def get_current_permissions()\n\t\t\tkparams = {}\n\t\t\tclient.queue_service_action_call('permission', 'getCurrentPermissions', 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 permission?(permission_key)\n current_user_has_permission? permission_key\n end",
"def get_current_permissions\n sd = get_security_descriptor(DO_NOT_REFRESH_SD)\n permissions = []\n unless sd.nil?\n permissions if sd.dacl.nil?\n sd.dacl.each do |ace|\n permissions << Puppet::Type::Acl::Ace.new(convert_to_permissions_hash(ace), self)\n end\n end\n permissions\n end",
"def index\n \t@users = User.accessible_by(current_ability)\n \tauthorize! :read, User\n end",
"def perms_for(pathname, options = {})\n if @permissions.nil?\n @permissions = {}\n# find root name and get all rules, that are for descendent of root.\n# There can be more than one root, because each site can have its own root\n root = pathname.root.to_s.sub(Rails.root.join('public').to_s,'')\n DcFolderPermission.where(folder_name: /#{root}*/).sort(folder_name: 1).each do |permission|\n folder = permission.folder_name.sub(root,'')\n folder.gsub!(/^\\/|\\/$/, '')\n# root is always ., remove leading and trailing /\n folder = '.' if folder.blank?\n# no rights by default. \n h = {read: false, write: false, rw: false, inherited: permission.inherited}\n# go through policy_rules and set rights if role matches rules role \n permission.dc_policy_rules.each do |r|\n @options[:user_roles].each do |role|\n next unless role == r.dc_policy_role_id\n h[:read] ||= r.permission > 0\n h[:write] ||= r.permission > 1\n h[:rw] ||= r.permission > 8\n end\n @permissions[folder] = h \n end\n end\n end\n# create response. First check for defaults of root folder\n response = {}\n response[:read] = pathname.exist? && @permissions['.'][:read]\n response[:write] = pathname.exist? && @permissions['.'][:write]\n response[:rm] = !pathname.is_root? && @permissions['.'][:rw]\n dir = ''\n# go through every subfolder part. Policy is: if right has been revoked on \n# parent folder it can't be set on child unless inherited is false.\n pathname.path.to_s.split('/').each do |path|\n dir << (dir.size > 0 ? '/' : '') + path\n pe = @permissions[dir]\n next if pe.nil? # ignore if not set\n if pe[:inherited]\n response[:read] &&= pe[:read]\n response[:write] &&= pe[:write]\n response[:rm] &&= pe[:rw]\n else\n response[:read] = pe[:read]\n response[:write] = pe[:write]\n response[:rm] = pe[:rw]\n end \n end\n response[:hidden] = false\n response\nend",
"def user_permission_keys\n new_record? ? [] : self.permissions(true).collect(&:key)\n end",
"def user_access_control_all\n @user = User.find(params[:user_id])\n\n unless [email protected]? && current_user.admin? || current_user?(@user)\n response_access_denied\n end\n\n rescue\n response_access_denied\n end",
"def add_user_permission(u)\n\t\t\n\tend",
"def initialize_rights\n @permissions ||= {}\n @user_groups ||= {}\n\n @public_access ||= []\n @protected_access ||= []\n end",
"def select\n @users ||= User.role_wise_users(params[:user][:role])\n authorize! :read, @user\n end",
"def allowed_users\n @permissions.keys.sort.select {|unix| allowed?(unix) }\n end",
"def custom_permissions_read(_notebook, _user, _use_admin=false)\n true\n end",
"def permissions\n attribute_prop(5)\n end",
"def initialize_permissions\n return [] unless id\n response = self.class.client.describe_permissions(stack_id: id)\n Permission.from_collection_response(response)\n end",
"def permissions\n @resource_permissions\n end",
"def current_permission\n @current_permission ||= Permission.permission_for(current_user, session_id)\n end"
] | [
"0.7986126",
"0.7956271",
"0.72594357",
"0.72403467",
"0.70867306",
"0.6945131",
"0.69420344",
"0.68161803",
"0.67439914",
"0.6737609",
"0.66819453",
"0.66763777",
"0.6664336",
"0.6587977",
"0.6502031",
"0.6396591",
"0.63898",
"0.634672",
"0.63350534",
"0.63145965",
"0.62867826",
"0.628287",
"0.6272602",
"0.62659895",
"0.6236709",
"0.6224795",
"0.6210197",
"0.6210197",
"0.6201204",
"0.61878663",
"0.6184791",
"0.61626303",
"0.61563224",
"0.6148473",
"0.6147516",
"0.6146196",
"0.61364615",
"0.612826",
"0.60967034",
"0.6055694",
"0.6042999",
"0.6035982",
"0.60302985",
"0.60275644",
"0.6018995",
"0.6016289",
"0.5994663",
"0.59738207",
"0.5970008",
"0.59558094",
"0.5948886",
"0.59438753",
"0.5942547",
"0.593063",
"0.5922359",
"0.5889801",
"0.5881778",
"0.587693",
"0.58643436",
"0.58582634",
"0.58540905",
"0.58457434",
"0.5841825",
"0.5841825",
"0.5827516",
"0.5823676",
"0.5822186",
"0.5816691",
"0.5815994",
"0.5810343",
"0.58058196",
"0.5797164",
"0.5795583",
"0.57896954",
"0.57697475",
"0.57690597",
"0.57668585",
"0.5762982",
"0.5760845",
"0.574581",
"0.574146",
"0.57399696",
"0.5736884",
"0.5735279",
"0.5728376",
"0.5727271",
"0.57110894",
"0.57087994",
"0.5705325",
"0.5704927",
"0.5699372",
"0.5685178",
"0.5682295",
"0.5666068",
"0.5659882",
"0.56589067",
"0.5645344",
"0.5641976",
"0.5639726",
"0.5638778"
] | 0.8057048 | 0 |
gem 'devise' and active_job | def send_devise_notification(notification, *args)
devise_mailer.send(notification, self, *args).deliver_later
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devise_modules_hook!; end",
"def user_authentication\n end",
"def auth_browserid(package_dir)\n replace('Gemfile',\n \"gem 'devise'\",\n \"gem 'devise'\\ngem 'devise_browserid_authenticatable'\")\n \n Bundler.with_clean_env do\n system \"bundle install\"\n end\n system \"rails g auth_browserid\"\n \n system \"git add -A\"\n system \"git commit -m 'Add browserid_authentication'\"\nend",
"def active_for_authentication?; end",
"def active_for_authentication?; end",
"def add_gems\n gem 'data-confirm-modal', '~> 1.6.2'\n gem 'devise', '~> 4.4.3'\n gem 'devise-bootstrapped', github: 'excid3/devise-bootstrapped', branch: 'bootstrap4'\n gem 'devise_masquerade', '~> 0.6.0'\n gem 'font-awesome-sass', '~> 4.7'\n gem 'gravatar_image_tag', github: 'mdeering/gravatar_image_tag'\n gem 'jquery-rails', '~> 4.3.1'\n gem 'bootstrap', '~> 4.0.0.beta'\n gem 'webpacker', '~> 3.0'\n gem 'foreman', '~> 0.84.0'\n gem_group :development, :test do\n gem 'rspec-rails', '~> 3.6.0'\n gem \"factory_bot_rails\", \"~> 4.10.0\"\n gem 'spring-commands-rspec'\n end\n\n gem_group :test do\n gem 'shoulda-matchers', '~> 3.1'\n end\nend",
"def development_auth\n @user = User.from_params(development_user_params)\n check_invite(@user)\n handle_sign_in(@user, \"development\")\n end",
"def install\n bin.install \"job\"\n end",
"def add_users\n # Install Devise\n generate \"devise:install\"\n\n # Configure Devise\n environment \"config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }\",\n env: 'development'\n route \"root to: 'home#index'\"\n\n # Devise notices are installed via Bootstrap\n generate \"devise:views:bootstrapped\"\n\n # Create Devise User\n generate :devise, \"User\",\n \"name\",\n \"admin:boolean\"\n\n # Set admin default to false\n in_root do\n migration = Dir.glob(\"db/migrate/*\").max_by{ |f| File.mtime(f) }\n gsub_file migration, /:admin/, \":admin, default: false\"\n end\n\n requirement = Gem::Requirement.new(\"> 5.2\")\n rails_version = Gem::Version.new(Rails::VERSION::STRING)\n\n if requirement.satisfied_by? rails_version\n gsub_file \"config/initializers/devise.rb\",\n / # config.secret_key = .+/,\n \" config.secret_key = Rails.application.credentials.secret_key_base\"\n end\n\n # Add Devise masqueradable to users\n inject_into_file(\"app/models/user.rb\", \"masqueradable, :\", after: \"devise :\")\nend",
"def enqueue_job\n BgJob.enqueue(\n SendDoubleOptIn,\n {\n client_id: @client_id,\n user_id: @user.id\n }\n ) if @client.is_verify_page_active_for_client?\n\n BgJob.enqueue(\n NewUserRegisterJob,\n {\n client_id: @client_id,\n user_id: @user.id,\n browser_user_agent: @browser_user_agent,\n geoip_country: @geoip_country,\n event: {\n client_id: @user.client_id,\n event_source: GlobalConstant::Event.web_source,\n event_name: GlobalConstant::Event.user_register_name,\n event_data: {\n user: @user.get_hash\n },\n event_timestamp: Time.now.to_i\n }\n }\n )\n end",
"def activate\n # admin.tabs.add \"Ae Users Authenticator\", \"/admin/ae_users_authenticator\", :after => \"Layouts\", :visibility => [:all]\n User.send :include, AeUsersAuthenticator\n end",
"def devise_controller?; end",
"def active_for_authentication?\n super && active\n end",
"def active_for_authentication?\n super\n end",
"def capable_login_auth?; end",
"def Job_application\n AccountCreatedMailer.Job_application\n end",
"def active_for_authentication?\n super && !suspended_account\n end",
"def active_for_authentication?\n login_email = multi_email.login_email_record\n\n if login_email && !login_email.primary?\n super && login_email.active_for_authentication?\n else\n super\n end\n end",
"def user_provider; end",
"def plugin_name\n 'auth'\n end",
"def active_for_authentication?\n super && active?\n end",
"def active_for_authentication?\n super && active?\n end",
"def active_for_authentication?\n super && active?\n end",
"def generate_user(package_dir)\n system \"rails generate devise:install\"\n\n replace('config/environments/development.rb',\n \"config.action_mailer.raise_delivery_errors \\= false\",\n \"config.action_mailer.raise_delivery_errors = false\\n\\tconfig.action_mailer.default_url_options = { host: 'localhost:3000' }\")\n system \"rails generate devise User\"\n\n # make the authentication return a json\n dest = \"app/controllers/sessions_controller.rb\"\n File.new(dest, \"w\")\n FileUtils.cp \"#{package_dir}/template/#{dest}\", dest\n\n replace('config/routes.rb', 'devise_for :users', \"devise_for :users, :controllers => { sessions: 'sessions' } \")\n\n system \"git add -A\"\n system \"git commit -m 'Add devise and configure it'\"\nend",
"def run_job\n end",
"def authenticate_with_shibboleth(env)\n\n resource = AdminUser.find_by_email(env['eppn'])\n\n if (!resource.nil? && !Devise.shibboleth_create_user)\n logger.warn(\"User(#{env['eppn']}) not found. Not configured to create the user.\")\n return resource\n end\n\n c4c_group = ( env['gws_groups'] =~ /u_uwc4c/ )\n logger.debug \"in app controllers devise shibboleth_sessions_controller.rb line 39 of gem\"\n logger.debug c4c_group\n logger.debug \"is it nil?\"\n logger.debug c4c_group.nil?\n return nil if c4c_group.nil?\n\n if (c4c_group && resource.nil? && Devise.shibboleth_create_user)\n logger.fatal(\"Creating user(#{env['eppn']}).\")\n resource = AdminUser.new()\n end\n return nil unless resource\n\n save_user_shibboleth_headers(resource, env)\n\n resource.save\n resource\n end",
"def send_devise_notification(notification, *args); end",
"def active_for_authentication?\n super && self.active? # i.e. super && self.active\n end",
"def perform\nsignup\nlogin\nwelcome_screen\nend",
"def initialize_job\n launched_job_initializers\n \n job_template_initializers\n end",
"def active_for_authentication? \n \tsuper && approved?\n \t\n\tend",
"def active_for_authentication?\n super && activation_status == true\nend",
"def run_bundle ; end",
"def run_bundle ; end",
"def active_for_authentication?\n super && is_active?\n end",
"def require_authentication\n\n # No matter what the app does a user can always login, forgot\n # password and register. The controllers provided by this\n # plugin alreaddy have these controllers/actions on an\n # exception list but this prevents a mistake an overridden\n # controller from preventing the normal login behavior.\n %w(session password user).each do |c|\n \t %w(new create).each do |a|\n return if (controller_name == c) && (action_name == a)\n end\n \t end\n\n # If we cannot get the current user store the requested page\n # and send them to the login page.\n if current_user.nil? or current_user.anonymous?\n redirect_to login_url(:return_to => request.url) and false\n end\n end",
"def active_for_authentication?\r\n super && active_status?\r\n end",
"def active_for_authentication?\n super && account_active?\n end",
"def run_bundle; end",
"def active_for_authentication?\n super && isActive\n end",
"def active_for_authentication?\n active? && super\n end",
"def create\n self.resource = warden.authenticate!(auth_options)\n set_flash_message(:notice, :signed_in) if is_flashing_format?\n sign_in(resource_name, resource)\n yield resource if block_given?\n # respond_with resource, location: after_sign_in_path_for(resource)\n if !user_signed_in?\n # All handled by warden.\n\n # if params[:mobile]\n # render 'm/signup_after_job_post', layout: 'mobile' # m_signup_after_job_post_path(resource, job: params[:job_id])\n # # redirect_to m_signup_after_job_post_path(job: @job.id) and return\n # else\n # redirect_to post_job_path(@job)\n # end\n else\n\n if params[:job_id]\n resource.hunter = true\n resource.save\n @job = Job.assign_user_to_job(params[:job_id], resource)\n JobMailer.job_created(@job).deliver \n end\n \n stored_location_for(resource) ||\n if params[:mobile] # post-Job path\n if params[:job_id]\n redirect_to m_dashboard_path and return # TODO: Add job anchor to this.\n else\n redirect_to m_dashboard_path\n end\n else\n if params[:job_id] # post-Job path\n redirect_to job_path(@job) # TODO: Test this.\n else\n redirect_to dashboard_path\n end\n end\n end\n end",
"def devise_install(&block)\n if block_given?\n Devise.setup do |config|\n block.call config\n end\n end\n end",
"def active_for_authentication?\n super && assigned?\n end",
"def after_sign_in_path_for(resource)\n jobs_path\n end",
"def active_for_authentication?\n super && self.is_active?\n end",
"def auth_store; end",
"def active_for_authentication?\n super and self.enabled?\n end",
"def sync_job(first_time = false, user = 'requester')\n\t\tRails.logger.info('Authorisation sync job started for scope: ' + self.scope)\n\t\tGmailSyncerJob.new.async.perform(self, first_time, user)\n\tend",
"def prompt_user_authorisation\n\n require './app/routes/web'\n\n # Start local API\n Launchy.open(\"http://localhost:5000/cli/auth\")\n\n auth_thread = Thread.new do\n Linkedin2CV::Routes::Web.run!\n end\n\n auth_thread\n end",
"def setup\n activate_authlogic\n end",
"def active_for_authentication?\n self.active?\n end",
"def auth\n end",
"def auth\n end",
"def async_bootstrap(environment, manifest, plugin, options = {})\n job = Job.new(:bootstrap)\n async(:bootstrap, job, environment, manifest, plugin, options)\n\n job.ticket\n end",
"def superadminify\n without_access_control do\n User.module_eval do\n def role_symbols\n @role_symbols = [ :superadmin ]\n end\n end\n\n request.session[:auth_via] = 'cas'\n request.session[:user_id] = users(:one)\n end\n end",
"def start_task!\n task.start! if current_user == task.user && task.may_start?\n end",
"def install_devise\n require 'devise'\n if File.exists?(File.join(destination_root, \"config\", \"initializers\", \"devise.rb\"))\n puts \"\\n=================================================================================\\n\"\n puts \"No need to install devise, already done.\"\n if File.exists?(File.join(destination_root, \"app\", \"models\", \"user.rb\"))\n puts \"No need to generate a user model for devise,already done.\"\n application do\n \"config.devise_model_name = 'user'\"\n end #EO application while\n else\n model_name = ask(\"What is the devise model to be called? [user]\")\n generate(\"devise\", model_name)\n application do\n \"config.devise_model_name = '\"+model_name.to_s+\"'\"\n end #EO application while \n end #EO File exists user.rb if\n puts \"\\n=====================================================================================\\n\"\n else\n if yes?(\"Would you like to install Devise?\")\n gem(\"devise\")\n generate(\"devise:install\")\n model_name = ask(\"What would you like the user model to be called? [user]\")\n model_name = \"user\" if model_name.blank?\n generate(\"devise\", model_name)\n application do\n \"config.devise_model_name = '\"+model_name.to_s+\"'\"\n end #EO application while\n puts \"\\n===================================================================================\\n\" \n end #EO Devise install if \n end #EO File exists devise.rb if\n end",
"def authentication_profile\n super\n end",
"def create\n @jobber = Jobber.new(jobber_params)\n authorize @jobber\n @jobber.confirmed_token = Devise.friendly_token\n # raw, enc = Devise.token_generator.generate(self.class, :confirmation_token)\n # @raw_confirmation_token = raw\n # self.confirmation_token = enc\n # self.confirmation_sent_at = Time.now.utc\n\n\n respond_to do |format|\n if @jobber.save\n @jobber.assign_job (current_user||@jobber)\n Message.mail subject: 'Tak for din registrering!',\n who: @jobber.email,\n what: invite_message,\n jobber: @jobber,\n job: @jobber.assignments.first,\n delivery_team: @jobber.delivery_team,\n confirm_link: (confirmation_jobber_url(@jobber, confirmed_token: @jobber.confirmed_token) rescue '- bekræftelseslink mangler -'),\n current_user: current_user || User.first\n\n format.html { redirect_to jobbers_url, notice: 'Jobberen blev oprettet korrekt' }\n format.js { head 220 }\n format.json { render :show, status: :created, location: @jobber }\n else\n format.html { render :new }\n format.js { head 404 }\n format.json { render json: @jobber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def application_packages\n # If you've already told Moonshine about a package required by a gem with\n # :apt_gems in <tt>moonshine.yml</tt> you do not need to include it here.\n package 'aspell', :ensure => :installed\n package 'zip', :ensure => :installed\n package 'libxml2-dev'#, :before => exec('bundle install')\n package 'libxslt1-dev'#, :before => exec('bundle install')\n\n daily_jobs = \"cd #{configuration[:deploy_to]}/current && bundle exec rails runner -e #{ENV['RAILS_ENV']} DailyJobs.run\"\n cron 'daily_jobs', :command => daily_jobs, :user => configuration[:user], :minute => 0, :hour => 6\n\n weekly_jobs = \"cd #{configuration[:deploy_to]}/current && bundle exec rails runner -e #{ENV['RAILS_ENV']} DailyJobs.run_weekly\"\n cron 'weekly_jobs', :command => weekly_jobs, :user => configuration[:user], :minute => 0, :hour => 7, :weekday => 0\n\n prime_cache = \"cd #{configuration[:deploy_to]}/current && nice -n15 bundle exec rails runner -e #{ENV['RAILS_ENV']} PrimeCache.flags >> #{configuration[:deploy_to]}/current/log/prime_cache.log\"\n cron 'prime_cache', :command => prime_cache, :user => configuration[:user], :minute => \"*/10\"\n\n cron 'backup_daily', :command => \"/home/rails/backups/backup.sh\", :hour => 8,:user => configuration[:user], :minute => 0\n\n\n # %w( root rails ).each do |user|\n # mailalias user, :recipient => '[email protected]'\n # end\n\n # farm_config = <<-CONFIG\n # MOOCOWS = 3\n # HORSIES = 10\n # CONFIG\n # file '/etc/farm.conf', :ensure => :present, :content => farm_config\n\n # Logs for Rails, MySQL, and Apache are rotated by default\n # logrotate '/var/log/some_service.log', :options => %w(weekly missingok compress), :postrotate => '/etc/init.d/some_service restart'\n configure(:rails_logrotate => {:options => %w(daily missingok compress delaycompress sharedscripts rotate\\ 52 ) })\n\n # Only run the following on the 'testing' stage using capistrano-ext's multistage functionality.\n # on_stage 'testing' do\n # file '/etc/motd', :ensure => :file, :content => \"Welcome to the TEST server!\"\n # end\n exec 'hostname > /tmp/hostname'\n end",
"def bootstrap\n STDERR.puts \"My oauth authorization URL is: #{@bot.invite_url}\"\n load_plugins\n end",
"def after_database_authentication; end",
"def active_for_authentication? \n super && approved? \n end",
"def activate; end",
"def active_for_authentication?\n super && approved?\n end",
"def load_gem_plugins; end",
"def setup_warden_additions\n @failure_app = Oath::Lockdown::FailureApp\n @lockable_authentication_strategy = Oath::Lockdown::Strategies::LockablePasswordStrategy\n @remember_me_authentication_strategy = Oath::Lockdown::Strategies::RememberMeStrategy\n @warden_authentication_strategies = [:oath_remember_me, :oath_lockable, :oath]\n @warden_no_input_authentication_strategies = [:oath_remember_me]\n end",
"def initialize_auth\n @conf[:use_user_pool_cache] = false\n end",
"def trackable\n apply_devise_schema :sign_in_count, Integer, :default => 0\n apply_devise_schema :current_sign_in_at, DateTime\n apply_devise_schema :last_sign_in_at, DateTime\n apply_devise_schema :current_sign_in_ip, String\n apply_devise_schema :last_sign_in_ip, String\n end",
"def oauth_authentication; end",
"def authenticate_active_admin_user\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n send(active_admin_namespace.authentication_method) if active_admin_namespace.authentication_method\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n end",
"def user_apps\n Application.with_user(session[:user_id])\n end",
"def register_framework_extensions\n register Padrino::Mailer if padrino_mailer?\n register Padrino::Helpers if padrino_helpers?\n register Padrino::Admin::AccessControl if authentication?\n end",
"def create\n unless params[:ex_email].blank? or params[:ex_email].nil? or params[:ex_password].blank? or params[:ex_password].blank? or params[:ex_password].nil? then\n \n @job = Job.new(params[:job])\n @job.activation_key = ActiveSupport::SecureRandom.hex(4)\n\n @user_name = params[:ex_email]\n @password = params[:ex_password]\n\n @user = User.find_by_email(params[:ex_email])\n unless @user.nil? then\n logger.info \"@user.password : #{@user.password}}\"\n if @user.password == params[:ex_password] then\n session[:loggedin_user] = @user.id\n @job.update_attribute(:activate, 0)\n respond_to do |format|\n if @job.save\n flash[:notice] = 'Job was successfully created.'\n format.html { redirect_to \"/jobs/preview/#{@job.id}\" }\n #JobMailer.deliver_job_posting_confirmation(@job)\n format.xml { render :xml => @job, :status => :created, :location => @job }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n \n\n else\n flash[:flash19] = \"the username or password you entered is incorrect.\"\n redirect_to \"/jobs\"\n end\n else\n flash[:flash20] = \"the username or password you entered is incorrect.\"\n redirect_to \"/jobs\"\n end\n\n \n else\n @job = Job.new(params[:job])\n @job.activation_key = ActiveSupport::SecureRandom.hex(4)\n\n respond_to do |format|\n if @job.save\n flash[:notice] = 'Job was successfully created.'\n format.html { redirect_to \"/jobs/preview/#{@job.id}\"}\n # format.html { render :action => \"thanks_for_posting_job\" }\n # JobMailer.deliver_job_posting_confirmation(@job)\n format.xml { render :xml => @job, :status => :created, :location => @job }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end \n end",
"def active_for_authentication?\n super && approved?\n end",
"def active_for_authentication?\n super && approved?\n end",
"def active_for_authentication?\n super && approved?\n end",
"def active_for_authentication?\n super && approved?\n end",
"def active_for_authentication?\n super && approved?\n end",
"def active_for_authentication?\n super && approved?\n end",
"def active_for_authentication?\n super && approved?\n end",
"def devise_scope(scope); end",
"def active_for_authentication?\n\t\tsuper && (self.is_active)\n\tend",
"def require_user\n end",
"def active_for_authentication?\n super && !self.deactivated # i.e. super && self.is_active\n end",
"def create\n build_resource(sign_up_params)\n resource.save\n yield resource if block_given?\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message! :notice, :signed_up\n sign_up(resource_name, resource)\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n flash[:notice] = \"A message with a confirmation link has been sent to your email address. Please follow the link to activate your account.\"\n expire_data_after_sign_in!\n respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n else\n # resource.avatar.purge\n clean_up_passwords resource\n set_minimum_password_length\n respond_to do |format|\n format.js { render :validation_errors }\n end\n end\n SendEmailJob.set(wait: 50.seconds).perform_later(User.find_by(email: sign_up_params[:email]))\n # sign_out(current_user)\n # if sign_up_params[:avatar] == nil\n # flash[:notice] = 'choose image for avatar'\n # redirect_to new_user_registration_path\n # return\n # end\n # build_resource(sign_up_params)\n # super\n # resource.save\n # yield resource if block_given?\n # if resource.persisted?\n # if resource.active_for_authentication?\n # set_flash_message! :notice, :signed_up\n # sign_up(resource_name, resource)\n # respond_with resource, location: after_sign_up_path_for(resource)\n # else\n # set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n # expire_data_after_sign_in!\n # respond_with resource, location: after_inactive_sign_up_path_for(resource)\n # end\n # else\n # clean_up_passwords resource\n # set_minimum_password_length\n # respond_with resource\n # end\nend",
"def enable_authentication (options={})\n config = {\n :after_login_url => '/',\n :after_logout_url => '/',\n :record_url => true,\n :user_model => nil,\n }.update(options)\n\n # the following code prevents the plugin from blowing up when the\n # Rails application does not yet have a User model.\n if config[:user_model].nil? and File.exist?(DEFAULT_MODEL_FILE)\n config[:user_model] = DEFAULT_MODEL_CLASS\n end\n\n class_eval <<-EOT\n def self.rauth_loaded? () true end\n cattr_accessor(:rauth_options)\n @@rauth_options = config\n\n def self.require_authentication (options={})\n before_filter(:authenticate, options)\n end\n EOT\n\n self.send(:include, Rauth::Authentication::ActionControllerInstanceMethods)\n self.send(:include, Rauth::State)\n self.add_template_helper(Rauth::State)\n end",
"def jobs\n\t\t# ...\n\tend",
"def after_custom_authentication; end",
"def developer\n raise 'Invalid Authentication' unless ENV['FAKE_AUTH_ENABLED'] == 'true'\n @user = User.from_omniauth(request.env['omniauth.auth'])\n @user.save\n sign_in_and_redirect @user, event: :authentication\n flash[:notice] = \"Welcome #{@user.email}!\"\n end",
"def send_active_needs_approval_email\n Users::SendNeedsApprovalEmailJob.perform_later(user_id: self.id, active: true)\n end",
"def start_job\n associate(Wesabe::Job.from_xml(Hpricot::XML(post(:url => \"/credentials/#{id}/jobs.xml\")) / :job))\n end",
"def do_bundle\n # Custom bundle command ensures dependencies are correctly installed\n Bundler.with_unbundled_env { run \"bundle install\" }\nend",
"def do_bundle\n # Custom bundle command ensures dependencies are correctly installed\n Bundler.with_unbundled_env { run \"bundle install\" }\nend",
"def sign_in\n trait()\n end",
"def email_login\n end",
"def perform\n\n r = validate_and_sanitize\n return r unless r.success?\n\n fetch_client_token_sale_details\n\n r = validate_client_details\n return r unless r.success?\n\n r = check_if_email_already_registered\n return r unless r.success?\n\n r = generate_login_salt\n return r unless r.success?\n\n create_user\n\n enqueue_job\n\n set_cookie_value\n\n end",
"def support\n @@_cache_support ||= (User.where(email: '[email protected]').take || User.create!(first_name: 'Loverealm', last_name: 'Support', email: '[email protected]', password: ENV['LR_SUPER_USERS_PASSWORD'], password_confirmation: ENV['LR_SUPER_USERS_PASSWORD'], roles: [:user]))\n end",
"def activate(name, *requirements)\n Gems.synchronize do\n begin\n gem(name, *requirements)\n rescue ::Gem::LoadError => e\n handle_activation_error(e, name, requirements)\n end\n end\n end",
"def process_authentication\n\n omniauth = request.env[\"omniauth.auth\"]\n Rails.logger.info(\"[CNTRL][Authentications] Auth process callback #{params} omniauth #{omniauth}\")\n\n if omniauth.nil?\n #TODO: Send back to sign in\n Rails.logger.info(\"[CNTRL][Authentications] Omni auth is nil, back to home\")\n redirect_to \"/\"\n end\n\n provider = params['provider']\n uid = omniauth['uid']\n\n already_existing_auth = Authentication.find_by_provider_and_uid(provider, uid)\n\n if already_existing_auth.nil?\n Rails.logger.info(\"[CNTRL][Authentications] A new foreign auth\")\n if user_signed_in?\n\n Rails.logger.info(\"[CNTRL][Authentications] User is already signed in #{current_user.full_name}\")\n\n query_hash = {}\n query_hash[provider] = uid \n invite_status = Invite.check_if_invite_exists(query_hash)\n\n \n\n any_existing_auth_for_same_provider = current_user.authentications.find_by_provider(provider)\n if any_existing_auth_for_same_provider.nil?\n Rails.logger.info(\"[CNTRL][Authentications] No existing auth for #{provider} for user\")\n authentication=Authentication.create(:provider=>provider,\n :uid=>uid,\n :token=> omniauth['credentials']['token'],\n :secret=> omniauth['credentials']['secret'],\n :user_id=>current_user.id)\n\n Rails.logger.info(\"[CNTRL][Authentications] Cache the new foreign profile\")\n authentication.foreign_profile = ForeignProfile.new\n authentication.foreign_profile.send(\"import_#{provider}\",omniauth)\n \n #redirect back to where you came from\n #\n \n\n if current_user.get_invited_status() == true\n enable_hash = {\n :user_id => current_user.id,\n :provider => provider,\n :uid => uid\n } \n current_user.enable_service(enable_hash)\n end\n redirect_to session[:return_to] || '/'\n \n else\n Rails.logger.info(\"[CNTRL][Authentications] #{current_user.full_name} already has auth for #{provider}\")\n if current_user.get_invited_status() == true\n enable_hash = {\n :user_id => current_user.id,\n :provider => provider,\n :uid => uid\n }\n current_user.enable_service(enable_hash)\n end\n redirect_to session[:return_to] || '/'\n end\n else\n # New authentication for no signed in user\n Rails.logger.info(\"[CNTRL][Authentications] User is not signed in but auth is new.\")\n\n authentication = Authentication.create( :provider => provider,\n :uid => uid,\n :token=> omniauth['credentials']['token'],\n :secret=> omniauth['credentials']['secret'])\n\n\n Rails.logger.info(\"[CNTRL][Authentications] New foreign profile to cache for new auth no signin.\")\n authentication.foreign_profile = ForeignProfile.new\n authentication.foreign_profile.send(\"import_#{provider}\",omniauth)\n\n\n query_hash = {}\n query_hash[provider] = uid\n \n invite_status = Invite.check_if_invite_exists(query_hash)\n if invite_status \n Invite.mark_invite_accepted(provider, uid)\n end\n\n Rails.logger.info(\"[CNTRL][Authentications] Redirecting to auth signup page.\")\n #if validation does not exist and user is not signed in do not allow access\n\n redirect_to :controller => 'authentications',\n :action => 'auth_signup_provider',\n :provider => provider,\n :uid => uid,\n :key => authentication.salt\n\n end\n else\n #save latest auth token\n Rails.logger.info(\"[CNTRL][Authentications] Renew credentials for an existing auth\")\n already_existing_auth.token = omniauth['credentials']['token']\n already_existing_auth.secret = omniauth['credentials']['secret']\n\n if user_signed_in?\n Rails.logger.info(\"[CNTRL][Authentications] User already signed in for a new auth.\")\n if already_existing_auth.user_id.nil?\n Rails.logger.info(\"[CNTRL][Authentications] User is being connected to auth\")\n already_existing_auth.user_id = current_user.id\n already_existing_auth.save!\n \n if current_user.get_invited_status() == true\n enable_hash = {\n :user_id => current_user.id,\n :provider => provider,\n :uid => uid\n }\n current_user.enable_service(enable_hash) \n end\n\n redirect_to session[:return_to] || '/'\n else\n\n if already_existing_auth.user_id == current_user.id\n Rails.logger.info(\"[CNTRL][Authentications] Auth token being updated for user\")\n already_existing_auth.save!\n end\n Rails.logger.info(\"[CNTRL][Authentications] Going back to where we came from\")\n enable_hash = {\n :user_id => current_user.id,\n :provider => provider,\n :uid => uid\n }\n current_user.enable_service(enable_hash) \n redirect_to session[:return_to] || '/'\n end\n else\n Rails.logger.info(\"[CNTRL][Authentications] A new auth and user is not signed in.\")\n if already_existing_auth.user_id.nil?\n Rails.logger.info(\"[CNTRL][Authentications] Auth is not associated to any user.\")\n already_existing_auth.save!\n\n Rails.logger.info(\"[CNTRL][Authentications] Foreign profile being saved for auth.\")\n already_existing_auth.foreign_profile = ForeignProfile.new\n Rails.logger.info(\"[CNTRL][Authentications] Foreign profile import method call.\")\n already_existing_auth.foreign_profile.send(\"import_#{provider}\",omniauth)\n \n\n Rails.logger.info(\"[CNTRL][Authentications] Redirecting to auth sign in\")\n redirect_to :controller => 'authentications',\n :action => 'auth_signup_provider',\n :provider => provider,\n :uid => uid,\n :key => already_existing_auth.salt\n\n else\n # I know the user, allow him to get in\n Rails.logger.info(\"[CNTRL][Authentications] Known auth, user sign in [user id : #{already_existing_auth.user_id}]\")\n \n if already_existing_auth.user.user_type == AppConstants.user_type_crawled \n Rails.logger.info(\"[CNTRL][Authentications] Cache the new foreign profile\")\n already_existing_auth.foreign_profile = ForeignProfile.new\n already_existing_auth.foreign_profile.send(\"import_#{provider}\",omniauth)\n already_existing_auth.save!\n\n redirect_to :controller => 'authentications',\n :action => 'auth_signup_provider',\n :provider => provider,\n :uid => uid,\n :key => already_existing_auth.salt\n return\n end\n\n\n already_existing_auth.save!\n \n invite_status = already_existing_auth.user.get_invited_status \n if invite_status \n enable_hash = {\n :user_id => already_existing_auth.user.id,\n :provider => provider,\n :uid => uid\n }\n already_existing_auth.user.enable_service(enable_hash) \n end\n sign_in_and_redirect(:user, already_existing_auth.user)\n end\n end\n end\n rescue => e\n Rails.logger.error(\"[CNTRL][Authentications] Save raised exception : #{e}\")\n redirect_to \"/\"\n end"
] | [
"0.5648677",
"0.5483095",
"0.54725605",
"0.54268223",
"0.54268223",
"0.52898604",
"0.5030131",
"0.5013897",
"0.4984747",
"0.4964818",
"0.4918824",
"0.49144354",
"0.4870938",
"0.48561317",
"0.48491225",
"0.482679",
"0.48231494",
"0.4804508",
"0.48041457",
"0.47902527",
"0.47879127",
"0.47879127",
"0.47879127",
"0.47864866",
"0.47713628",
"0.47544995",
"0.47487575",
"0.47486004",
"0.47234172",
"0.47115803",
"0.46969554",
"0.46965623",
"0.4696126",
"0.4696126",
"0.4684019",
"0.46824035",
"0.46783385",
"0.46780905",
"0.46752194",
"0.46614465",
"0.46593505",
"0.46459308",
"0.46445242",
"0.4632009",
"0.46305603",
"0.46069533",
"0.46039563",
"0.4598352",
"0.4593953",
"0.45927104",
"0.45894533",
"0.45867112",
"0.45803082",
"0.45803082",
"0.4572375",
"0.45686918",
"0.45620173",
"0.45606613",
"0.45592543",
"0.45557398",
"0.45528805",
"0.45495468",
"0.454573",
"0.45428663",
"0.4531039",
"0.45223647",
"0.45210627",
"0.45172548",
"0.4517163",
"0.45163894",
"0.4516223",
"0.45149198",
"0.4514579",
"0.45129144",
"0.45120627",
"0.45119295",
"0.45119295",
"0.45119295",
"0.45119295",
"0.45119295",
"0.45119295",
"0.45119295",
"0.4507481",
"0.4505508",
"0.45043647",
"0.45036152",
"0.44995737",
"0.44973618",
"0.44967785",
"0.4496267",
"0.44923115",
"0.44889563",
"0.4486141",
"0.44858968",
"0.44858968",
"0.44845188",
"0.44765276",
"0.44700533",
"0.4468496",
"0.44666845",
"0.4463912"
] | 0.0 | -1 |
Internally, Ruby converts your array objects each into a hash (identifier, not object), using hash. By default this is object_id.hash, which is no longer appropriate. The purpose is to recognize which objects have the same hash and which do not, thus they are unique. So, override. | def hash
custom_unique_id.hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n [self.class, id].hash\n end",
"def hash\n\t\t[@id].hash\n\tend",
"def hash\n object_id\n end",
"def dup\n\n # duplicate self\n rta = super\n\n # iterate through array and dup each hash\n rta.each_with_index do |w_hash, index|\n\n # dup the hash at this index\n rta[index] = w_hash.dup\n\n # to be complete, also dup the key/values in the hash, in case another hash/array is nested\n w_hash.each_pair do |k, v|\n rta[index][k] = v.dup if v.is_a? Hash\n end\n end\n\n # now everything should have new object_id's\n rta\n end",
"def hash\n @hash ||= self.to_a.hash\n end",
"def hash\n return @hash_code if defined? @hash_code\n @hash_code = usual_equal_object.hash\n end",
"def my_unique\n dict = Hash.new(false)\n self.each_with_index do |el, idx|\n self[idx] = nil if dict[el]\n dict[el] = true\n end\n self.compact!\n end",
"def _hash(obj)\n obj.transform_values { |v| _renc(v) }\n end",
"def hash\r\n id.hash\r\n end",
"def hash\n @id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n return @id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n [@id].hash\n end",
"def hash()\n #This is a stub, used for indexing\n end",
"def hash_code; end",
"def hash\n id.hash\n end",
"def my_uniq(arr)\n hash = {}\n arr.each { |obj| hash[obj] = true }\n hash.keys\nend",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash #:nodoc:\n __getobj__.hash ^ self.class.hash\n end",
"def hash\n @__set.to_a.hash\n end",
"def hash\n [].hash\n end",
"def hash\n __record_id.hash\n end",
"def hash\n to_h.hash ^ self.class.hash\n end",
"def hash\n id\n end",
"def hash\n @id\n end",
"def hash\n [self.class, to_s].hash\n end",
"def hash(*) end",
"def hash\n [self.class, to_h].hash\n end",
"def hash\n [self.class, to_h].hash\n end",
"def hash\n [self.class, to_h].hash\n end",
"def hash\n to_a.hash\n end",
"def hash\n @id\n end",
"def hash\n value_id.hash\n end",
"def hash\n end",
"def hash\n end",
"def hash\n end",
"def hash; map{|el| \"#{el.name} @ #{el.hash}\"}; map(&:hash).reduce(:+) % 2**32; end",
"def hash\n [self.class, to_s].hash\n end",
"def hash\n [_hash, name, owner].hash\n end",
"def hash\n [self[0], self[1]].hash\n end",
"def deep_duplicate(object)\n case object\n when Array\n object.map { |item| deep_duplicate(item) }\n when Hash\n hash = object.dup\n hash.each_pair { |key, value| hash[key] = deep_duplicate(value) }\n hash\n else\n object\n end\n end",
"def hash\n\t\treturn [ self.class, self.dn ].hash\n\tend",
"def get_id(obj)\n\t\[email protected][obj]\n\tend",
"def hash\r\n @_hash ||= _hash\r\n end",
"def hash\n self.respond_to?(:id) && self.id ? self.id.to_i : self.to_hash.hash\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def __hash\n @hash\n end",
"def hash # Hack for Ruby 1.8.6\n @node.id.hash ^ self.class.hash\n end",
"def hash\n [model, pk.nil? ? @values.sort_by{|k,v| k.to_s} : pk].hash\n end",
"def hash\n @orig.hash\n end",
"def hash\n @orig.hash\n end",
"def hash\n @orig.hash\n end",
"def hash\n [self.class, self.val, self.attribute].hash\n end",
"def hash\n [searchable_id].hash\n end",
"def hash_id\n @hid\n end",
"def hash\n\t\t[@a, @b, self.class::D].hash\n\tend",
"def hash\n @elements.hash\n end",
"def hash\n @elements.hash\n end",
"def hash\n self.atoms.hash\n end",
"def test_no_duplicate_id\n dup = {\"_id\" => \"foo\", :_id => \"foo\"}\n one = {\"_id\" => \"foo\"}\n\n assert_equal @encoder.serialize(one, false, true).to_a, @encoder.serialize(dup, false, true).to_a\n end",
"def convert\n unless should_convert?\n return { _existing_object_id: array.object_id }\n end\n\n dumped_ids << array.object_id\n\n result = array.map do |item|\n UniversalDumper.convert(item, dumped_ids)\n end\n\n {\n _old_object_id: array.object_id,\n _object_data: result\n }\n end",
"def hash\n -element.hash\n end",
"def object_id_cache\n @object_id_cache ||= {\n # appeals: exported_records(Appeal).map { |appeal| [appeal[\"id\"], appeal[\"name\"]] }.to_h,\n orgs: exported_records(Organization).map { |org| [org[\"id\"], org[\"name\"]] }.to_h,\n users: exported_records(User).map { |user| [user[\"id\"], user[\"css_id\"]] }.to_h,\n tasks: exported_records(Task).map { |task| [task[\"id\"], \"#{task['type']}_#{task['id']}\"] }.to_h\n }\n end",
"def hash\n guid.hash\n end",
"def hash()\n #This is a stub, used for indexing\nend",
"def hash\n return super unless has_size?\n\n res = 0\n each do |el|\n res += el.hash\n end\n return res\n end",
"def hash\n [id, banco, agencia, conta_corrente, especie, numero_convenio, carteira, codigo_cedente, especie_tipo, especie_documento, aceite, instrucoes, local_pagamento1, local_pagamento2, endereco_cobranca_emissor, nome_beneficiario, cnpj_beneficiario, operador, data, maquina].hash\n end",
"def obj_fingerprints(ol)\n ol.map do |o|\n case o\n when Hash\n type = (o[:type]) ? o[:type] : o['type']\n id = (o[:id]) ? o[:id] : o['id']\n \"#{type}/#{id}\"\n else\n (o.respond_to?(:fingerprint)) ? o.fingerprint : nil\n end\n end\n end",
"def hash\n type.hash ^ (id.hash >> 1)\n end",
"def hash\n @hash || @hash = (value.hash * -1)\n end",
"def hash\n # We don't use metadata because == does not use metadata\n [event_type, event_id, data].hash ^ self.class.hash\n end",
"def deep_hash\n UniMap.deep_hash( self )\n end",
"def to_hash\n @_hash.dup\n end",
"def hash_dup\n save\n end"
] | [
"0.70497733",
"0.69877523",
"0.6933186",
"0.6661266",
"0.6613222",
"0.6603962",
"0.6597916",
"0.6593305",
"0.6574119",
"0.65711695",
"0.65628237",
"0.65628237",
"0.6532289",
"0.6515633",
"0.65152043",
"0.65152043",
"0.65152043",
"0.65152043",
"0.65152043",
"0.65152043",
"0.65152043",
"0.65152043",
"0.65152043",
"0.6497469",
"0.64849824",
"0.64070153",
"0.63973653",
"0.6377585",
"0.6365763",
"0.6365763",
"0.6365763",
"0.6365763",
"0.6365763",
"0.6365763",
"0.6365763",
"0.6365763",
"0.6365763",
"0.6365763",
"0.63540953",
"0.6318166",
"0.6314011",
"0.63001305",
"0.62969303",
"0.627875",
"0.6255451",
"0.6248025",
"0.6200367",
"0.6196683",
"0.6196683",
"0.6196683",
"0.6192364",
"0.61553097",
"0.6155277",
"0.6138021",
"0.6138021",
"0.6138021",
"0.61375064",
"0.61229044",
"0.61199236",
"0.6115158",
"0.610846",
"0.6062599",
"0.6060997",
"0.605534",
"0.6046133",
"0.6040368",
"0.6040368",
"0.6040368",
"0.6040368",
"0.6040368",
"0.6040368",
"0.6040368",
"0.60305536",
"0.60216534",
"0.6018413",
"0.6015854",
"0.6015854",
"0.6015854",
"0.6015571",
"0.6011402",
"0.60111666",
"0.59885734",
"0.5974425",
"0.5974425",
"0.59669006",
"0.5960647",
"0.59594554",
"0.5944806",
"0.5940953",
"0.5939056",
"0.59351754",
"0.5928876",
"0.590234",
"0.59009564",
"0.5892859",
"0.5887371",
"0.587145",
"0.58695984",
"0.5860172",
"0.58479184"
] | 0.6587536 | 8 |
Instance attributes and methods For Rails Admin, see user.rb: | def name
return "New Firmware" if !id
version + " (" + description.to_s + ") " +
" (" + (for_external ? "internal" : "external") + ")"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin\n @attributes[:admin]\n end",
"def admin_name\n self.user.name\n end",
"def user\n {user_id: self.object.user.id,\n user_name: self.object.user.name\n }\n end",
"def user\n @user\n end",
"def user\n @user\n end",
"def user\n @user\n end",
"def user\n @user\n end",
"def user\n object.user\n end",
"def user_id\n self.title_and_name\n end",
"def user\r\n return @user\r\n end",
"def admin_user_attrs(admin_user_params)\n\t\tadmin_user_attrs = admin_user_params[:user]\n\t\tadmin_user_attrs[:role] = 0\n\t\treturn admin_user_attrs\n\tend",
"def attributes(*args)\n data = super(*args)\n\n if current_user.try(:admin?)\n data[:superpowers] = true\n end\n\n data\n end",
"def user\n return @user\n end",
"def user\n puts self.name\n end",
"def user_name\n self.user.name\n end",
"def user_data\n User.user_data login\n end",
"def admin_user\n if session[:user_id] and session[:position]\n @admin_user = AdminUser.find_by_id(session[:user_id])\n end\n end",
"def user\n return @user\n end",
"def user\n return @user\n end",
"def exposed_attributes\n [:id, :first_name, :last_name, :email, :phone, :role_id, :school_id]\n end",
"def user; end",
"def user; end",
"def user_class()\n @user\n end",
"def user\n User.load(self.user_id)\n end",
"def user\n User.find_by_id self.user_id \n end",
"def user\n User.find(self[:user_id])\n end",
"def model_class\n User\n end",
"def get_user\n @user\n end",
"def get_user\n @user\n end",
"def user\n end",
"def set_user; end",
"def user_id\n self.user.id\n end",
"def user\n user_id.get_object\n end",
"def user\n session[AutoAdmin::AutoAdminConfiguration.admin_model_id] ? AutoAdmin::AutoAdminConfiguration.admin_model.find(session[AutoAdmin::AutoAdminConfiguration.admin_model_id]) : nil\n end",
"def id\n self.user_id\n end",
"def user\n User.new(self)\n end",
"def admin_user\n @admin_user ||= User.first\n end",
"def user\n User.find_by(id: self.object.user_id)\n end",
"def user\n @path = \"/services/Admin\"\n @user ||= Nephophobia::Resource::User.new self\n end",
"def username\n self.user.username \n end",
"def set_admin_user\n @user = User.find(params[:id])\n end",
"def set_admin_user\n @user = User.find(params[:id])\n end",
"def name\n object.user.name\n end",
"def name\n object.user.name\n end",
"def get_user\r\n \tself.user = update_user\r\n end",
"def get_user \n\t\treturn User.find(self.user_id)\n\tend",
"def readonly_user\n super\n end",
"def name\n\t self.username\n end",
"def create_user_information # for new users. runs last according to rails.\n self.dj_name = name\n self.roles = Role.where(:title => 'noob')\n self.active = true\n set_password\n end",
"def admin_user\n @admin_user ||= Typus.user_class.find_by_id(session[:typus_user_id])\n end",
"def current_user\n current_admin_user\n end",
"def current_user\n current_admin_user\n end",
"def set_admin_user\n @user = User.find(params[:id])\n end",
"def set_user\n @user = Event.find(params[:id]).admin_id\n end",
"def set_admin_user\n @admin_user = User.find(params[:id])\n end",
"def set_admin_user\n @admin_user = User.find(params[:id])\n end",
"def set_admin_user\n @admin_user = User.find(params[:id])\n end",
"def user_name\n object.user.name\n end",
"def admin\n @userList = User.all\n end",
"def user_column\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def set_user_admin\n @user_admin = UserAdmin.find(params[:id])\n end",
"def new\n\t\t@admin = User.new\n end",
"def merchant_defined_data1\n @user\n end",
"def set_admin_user\n @admin_user = Admin::User.find(params[:id])\n end",
"def set_admin_user\n @admin_user = Admin::User.find(params[:id])\n end",
"def set_admin_user\n @admin_user = Admin::User.find(params[:id])\n end",
"def set_admin_user\n @admin_user = Admin::User.find(params[:id])\n end",
"def set_admin_user\n @admin_user = Admin::User.find(params[:id])\n end",
"def customer\n self.user\n end",
"def admin_attributes\n {\n :id => id,\n :account_name => account_name,\n :organization_name => organization_name,\n :page_count => page_count,\n :thumbnail_url => thumbnail_url,\n :pdf_url => pdf_url(direct: true),\n :public => public?,\n :title => public? ? title : nil,\n :source => public? ? source : nil,\n :created_at => created_at.to_datetime.strftime(DISPLAY_DATETIME_FORMAT),\n :remote_url => remote_url,\n :detected_remote_url => detected_remote_url\n }\n end",
"def attributes\n attrs = super\n if attrs['user'] && attrs['user']['id']\n attrs.merge!('user_id' => attrs['user']['id'])\n attrs.delete 'user'\n end\n attrs\n end",
"def resource_class\n User\n end",
"def current_user\n @user\n end",
"def set_admin_user\n @admin_user = User.find(params[:id])\n end",
"def os_user\n @os_user\n end",
"def user\n owner\n end",
"def attributes\n end",
"def set_attributes_on_create\n @item.send(\"#{Typus.user_foreign_key}=\", admin_user.id) if @resource.typus_user_id?\n end",
"def show\n set_user\n end",
"def set_admin_user\n\t@admin_user = current_admin_user\n\tend",
"def permitted_attributes\n klass.properties.keys.map(&:to_sym) + %i[id edit_users edit_groups read_groups visibility work_members_attributes]\n end",
"def set_user_admin\n @user_admin = UserAdmin.find(params[:id])\n end",
"def user_name\n\t\tobject.user.full_name \n\tend",
"def set_admin_admin_user\n @admin_admin_user = AdminUser.find(params[:id])\n end",
"def admin_user_account_attrs(admin_user_params)\n\t\tadmin_user_account_attrs = { plan_years: 3,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t is_recurring: false,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t is_paid: true,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t plan_price: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t plan_level: \"RepsEdge\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t billing_city: \"Malverne\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t billing_state: \"New York\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t billing_zip_code: \"11565\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t payment_type: \"Admin Account\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t billing_street_address_line_1: \"P.O. Box 281\" }\n\t\treturn admin_user_account_attrs\n\tend",
"def admin_id\n 9\n end",
"def admin_update_user_attrs(admin_user_params)\n\t\tadmin_update_user_attrs = admin_user_params[:user]\n\t\tadmin_update_user_attrs[:role] = 0\n\t\treturn admin_update_user_attrs\n\tend",
"def user\n # 自インスタンスのuser_idの値に紐付くuserインスタンスを戻り値として返す\n return User.find(self.user_id)\n end",
"def user_attributes\n {\n email: \"[email protected]\",\n username: \"Test\",\n bio: \"bio\",\n url: \"https://example.com\",\n twitter: \"djensenius\",\n portrait: \"head.jpg\"\n }\nend",
"def user_data\n {\n user_id: @user.id,\n email: @user.email\n }\n end",
"def login_attribute\n super\n end"
] | [
"0.69626564",
"0.68878126",
"0.6860858",
"0.68414104",
"0.6830569",
"0.6830569",
"0.6830569",
"0.6687014",
"0.6664593",
"0.6610741",
"0.6594102",
"0.65858823",
"0.65610576",
"0.6547457",
"0.653645",
"0.65302646",
"0.6507274",
"0.6477505",
"0.6477505",
"0.647446",
"0.6472262",
"0.6472262",
"0.6453425",
"0.6451629",
"0.6443397",
"0.64262944",
"0.6420124",
"0.6398662",
"0.6398662",
"0.63975793",
"0.6397091",
"0.638167",
"0.63720024",
"0.6361493",
"0.6358403",
"0.6345121",
"0.63252133",
"0.6305592",
"0.6302089",
"0.629745",
"0.62882316",
"0.62882316",
"0.6288057",
"0.6288057",
"0.62859887",
"0.62825775",
"0.62757915",
"0.6273049",
"0.6260054",
"0.6259895",
"0.6255217",
"0.6255217",
"0.6251012",
"0.62447023",
"0.6229511",
"0.6229511",
"0.6229511",
"0.6223281",
"0.6220464",
"0.6202882",
"0.6195428",
"0.6195428",
"0.6195428",
"0.6195428",
"0.6195428",
"0.6195428",
"0.6195428",
"0.6195428",
"0.6195428",
"0.6195428",
"0.6192609",
"0.61880714",
"0.617796",
"0.6176761",
"0.6176761",
"0.6176761",
"0.6176761",
"0.6176761",
"0.6175009",
"0.617094",
"0.6165582",
"0.61577904",
"0.6156984",
"0.61509544",
"0.6150009",
"0.6149238",
"0.614687",
"0.6141885",
"0.61390644",
"0.6134006",
"0.61243916",
"0.6123667",
"0.61182135",
"0.61170703",
"0.6111732",
"0.6110461",
"0.6109667",
"0.61068547",
"0.610132",
"0.61002403",
"0.6096049"
] | 0.0 | -1 |
Return an array that contains the squares of all elements in an array? | def square_array(some_array)
array_squared = []
some_array.each do |item|
array_squared << item*item
end
return array_squared
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_squares(array)\n arrayFinal = []\n array.each do |element|\n arrayFinal << element * element\n end\n return arrayFinal\nend",
"def square_array(array)\n squared = []\n array.each { |element| squared << element ** 2 }\n squared\nend",
"def square_array(array)\narray.map { |to_square| to_square**2}\nend",
"def square_array(array)\n new_array = []\n array.each { |e| new_array << e ** 2 }\n new_array\nend",
"def square_array(array)\n numbers = []\n array.each do |number| numbers << number ** 2\n end\n numbers\nend",
"def square_array_2(array)\n array.collect { |i| i**2 }\n array\nend",
"def square_array(array)\n array.map! { |ele| ele ** 2 }\nend",
"def get_squares(array)\n array.map! do |x|\n if (x**(1/2)).class == Fixnum\n x\n end\n end\n array.compact.uniq.sort!\nend",
"def square_array2(array)\n return array.collect { |num| num ** 2 }\nend",
"def square_array(array)\n new_array = []\n array.each{|a| new_array.push(a*a)}\n return new_array\nend",
"def square_array(array)\n new_array = []\n array.each { |n| new_array << n*n }\n new_array\nend",
"def square_array(array)\n square = []\n \n array.each do |num|\n square << num * num\n end\n square\nend",
"def squares(array)\n\t\n\tnew_array = array.map { |num| num * num}\n\tp new_array\nend",
"def square_array(some_array)\n array_squared = []\n some_array.each do |number|\n array_squared << number * number\n end \n return array_squared\nend",
"def square_array(array)\r\n solution = []\r\n array.each do |number|\r\n solution << number**2\r\n end\r\n solution \r\nend",
"def square_array(array)\n squared_array = []\n \n array.each do |number| \n squared_array << number**2 \n end\n \n squared_array\nend",
"def square_array(array)\n array.map do |element|\n element ** 2 \n end\nend",
"def square_array(array)\n\n squared = []\n array.each do |num|\n squared.push(num * num)\n end\n\n squared\n \nend",
"def square_array(numbers)\n numbers.map { |e| e ** 2 }\nend",
"def square_array(array)\n squared = []\n array.each do |num|\n num**2\n squared << num**2\n end\n squared\nend",
"def map_to_square(array)\n new_array = array.map{|n| n**2}\n return new_array\nend",
"def square_array(array)\n array.collect {|num| num * num}\n \nend",
"def squares\n map { |i| i ** 2 }\n end",
"def square_array(array)\n squared = []\n count = 0\n while count < array.size do\n squared << (array[count] ** 2)\n count = count + 1\n end\n squared\nend",
"def square_array(array)\n squared = []\n count = 0\n while count < array.size do\n squared << (array[count] ** 2)\n count = count + 1\n end\n squared\nend",
"def square_array_collect(array)\n array.collect{|num| num ** 2}\nend",
"def map_to_square(source_array)\n array = []\n index = 0 \n \n while index < source_array.size do \n array.push(source_array[index] ** 2)\n index += 1 \n end\n return array\nend",
"def square_array (array)\n\nnewarray = []\n\narray.each do |element|\n newarray.push(element**2) \nend\n\nnewarray\n\nend",
"def square_the_values(array_of_integers)\n # TODO\nend",
"def square_array(array)\nnew_array = []\n array.length.times do |squared|\n new_array.push(array[squared]**2)\nend\n new_array\nend",
"def square_array(numbers)\n new_arr = []\n numbers.each do |number|\n new_arr << (number**2)\n end\n return new_arr\nend",
"def square_array(array)\n # Use an Enumerable to square every element in the passed in array\n # Return a new array of the results\n array.map do |n|\n n*n\nend\nend",
"def get_squares(array)\n\tto_return = []\n\tsorted = array.sort\n\tsorted.each do |number|\n\t\tto_return << number if sorted.include?(number*number)\n\n\tend\n\treturn to_return\nend",
"def square_array(array) #build square_array method\r\n\r\n new_array = [] #new array of squared numbers\r\n\r\n array.each do |integer|#implement own logic\r\n new_array << integer ** 2 #shovel /push logic into array \r\n end\r\n return new_array #returns array of these squared numbers\r\nend",
"def square_array(array)\n\tsquared_nums = []\n\n array.each do |number|\n squared_nums << (number * number)\n end\n squared_nums\nend",
"def square_array_with_collect(array)\n array.collect{|element| element**2}\nend",
"def map_to_square(source_array)\n \n i = 0\n new_array = []\n \n while i < source_array.length do\n new_array_value = source_array[i] ** 2\n new_array << new_array_value\n \n i += 1\n end\n \n new_array\nend",
"def square_array(numbers)\n new_numbers = []\n numbers.each do |num|\n new_numbers << (num ** 2)\n end\n return new_numbers\nend",
"def sum_square_array(arr)\n arr.reduce(:+) ** 2\nend",
"def squares\n range.map{|n| n**2 }\n end",
"def square_array(array)\nnew_array = []\ncounter = 0\nwhile counter < array.length do\n new_array << array[counter] ** 2 #**squaring incrments\ncounter += 1 #increments plus 1 after squaring elements\nend\nreturn new_array #can also just write new_array without the retun before it \nend",
"def compute_squares(arr)\r\n\r\n # empty array created\r\n compute_squares = []\r\n\r\n # iterate using each loop method\r\n arr.each {|el| compute_squares << el**2}\r\n\r\n # returns result\r\n compute_squares\r\nend",
"def square_array(square_array)\ncounter = 0\nnew_numbers = [] \n while counter < square_array.count do\n new_numbers << (square_array[counter] ** 2)\n counter += 1\n end\n new_numbers\nend",
"def square_array(array)\n # your code here\n newArray = []\n array.each do |num|\n number = num**2\n newArray.push(number)\n end\n return newArray\nend",
"def square_collect(array)\n\n return array.collect do |x|\n x ** 2\n end\n\nend",
"def square_array(array)\n counter = 0\n new_array = []\n while counter < array.length do\n new_array << array[counter] ** 2\n counter += 1\n end\n p new_array\nend",
"def get_squares my_array\n\t\t@my_array = my_array\n\t\tresult = []\n\t\n\t\tresult = @my_array.select do |nr| \n\t\t\ttrue if @my_array.any? {|double| nr*nr==double}\n\t\tend\n\t\tresult.sort!\n\t\tresult\n\tend",
"def square_array(pancakes)\n elephant = []\n pancakes.each do |num|\n elephant << num**2\n end\n return elephant\nend",
"def square_array(array)\n new_numbers = []\n numbers = 0\n while array[numbers] do\n new_numbers << array[numbers] ** 2\n numbers += 1\n end\nreturn new_numbers\nend",
"def get_squares(array)\n array.select {|x| x % (Math.sqrt x) == 0}.sort.uniq\nend",
"def basic_9 (array_iterate)\n square_array = array_iterate.collect { |n| n * n}\n return square_array\nend",
"def square_array(some_array)\n some_array.map {|number| number ** 2}\nend",
"def square_array(some_array)\n some_array.collect {|num| num*num} \nend",
"def square_array(array)\n squared = []\n counter = 0\n while array[counter] do\n squared.push( array[counter] ** 2)\n counter +=1\n end\n squared\nend",
"def get_squares(arr)\n sorted_arr = arr.sort\n # sorted_arr[3 , 9, 9, 81]\n\n with_sq_arr = []\n sorted_arr.each do |n|\n with_sq_arr << n**2\n # with_sq_arr[9, 81, 81, xxxx]\n end\n\n final_arr = []\n with_sq_arr.each do |n|\n final_arr << Math.sqrt(n).round if sorted_arr.count(n) >= 1\n end\n return final_arr\n # final_arr[3, 9, 9]\nend",
"def transform_array(array)\n i = 0\n array2 = []\n while i < array.length\n num1 = array[i]\n array2.push(square(num1))\n i += 1\n end\n return array2.sum\n end",
"def sum_of_squares(array)\n array.each.map{|num total += num*num}.reduce(:+) #is like fold_left. reduce works on array or collection of enumerables\nend",
"def square_array(some_array)\n\tcontainer = []\n\tsome_array.each do |number|\n\t\tcontainer << number * number\n\tend\nend",
"def square\n\t\tmap { |x| x*x }\n\tend",
"def square_array(numbers)\n counter = 0\n new_array = []\n while numbers[counter] do\n sqrd_nums = numbers[counter]**2\n new_array << sqrd_nums\n counter += 1\n end\n return new_array\nend",
"def square_array(array)\n # your code here\n counter = 0\n squared_array = []\n while counter < array.length do\n squared = array[counter] ** 2\n squared_array.push(squared)\n counter += 1\n end\n squared_array\nend",
"def square_map(array)\n array.map{ |elem| elem**2 }\nend",
"def get_squares array\n\tnew_array = []\n\tarray.each do |number|\n\tif array.include? number**2 \n\tnew_array << number\n\tend\nend \n\treturn new_array.sort \nend",
"def cubed_values (array)\n\n cubed_array = array.map { | number | number ** 3 }\n return cubed_array\n\nend",
"def find_square_of_number(array)\n\tarray.map{|x| x ** 2 }\nend",
"def double_all array\n array.map { |i| i*2 }\nend",
"def square_nums(num_arr)\n num_arr.map{|num| num ** 2}\nend",
"def cubes(array)\n array.map { |number| number ** 3}\n # Return array\nend",
"def transform_array(array)\n i = 0\n array2 = []\n while i < array.length\n num1 = array[i]\n array2.push(square(num1))\n i += 1\n end\n return array2\n end",
"def squares\n [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3]\n\n end",
"def gets_squares(array)\n array.select{ |i| Math.sqrt(i) % 1 == 0}.uniq.sort\nend",
"def get_squares(num_array)\n perfect_squares = num_array.select do |num|\n Math.sqrt(num) % 1 == 0\n end\n perfect_squares.sort.uniq\nend",
"def square! #of each element inside of the array if true\r\n self.map!{|x| x**2} #2. it will return [] blank array if false, not a zero.\r\n end",
"def cubes(array)\n array.map { |number| number ** 3 }\nend",
"def square_each_w_obj(array)\n array.each_with_object([]) { |elem, new_arr| new_arr << elem ** 2 }\nend",
"def sqrts\n map { |i| Math.sqrt(i) }\n end",
"def square\n\t\tself.map {|x| x ** 2}\n\tend",
"def get_squares(array)\n to_return = []\n array.each { |v|\n if (array.include? v) && (array.include? v*v)\n to_return << v\n end\n }\n to_return.sort\nend",
"def get_squares(array)\n\n squares = array.map {|item| item * item} # gives an array of the square values\n in_both = squares & array # returns elements that feature in both arrays\n selects = in_both.map {|x| Math.sqrt(x).to_i} # finds the square root of those elements\n array.select {|x| selects.include?(x)}.sort # selects all the matching elements in the original array\n\nend",
"def square_array(pixel_array_img)\n \tpixel_array_sq_img = []\n \tpixel_array_img.each_with_index do |array_pixel,i|\n \t\tnew_array = []\n \t\tarray_pixel.each_with_index do |number,j|\n \t\t\tnew_array[j] = number*number\n \t\t\t#pixel_array_sq_img1[i][j] = number*number\n \t\tend\n \t\tpixel_array_sq_img[i] = new_array\n \tend\n\n \treturn pixel_array_sq_img\n end",
"def calculate_doubles!(array)\n\t\n\tarray.map! { |num| num * 2}\nend",
"def square_each_idx(array)\n final = Array.new(array.length)\n array.each_index { |i| final[i] = array[i]**2 }\n final\nend",
"def get_squares(array)\n numbers = []\n array.select do |n|\n if array.include? n*n\n numbers << n\n end\n end\n numbers.sort\nend",
"def squared_primes(array)\n multiplication(array).map{|p| p*p}\nend",
"def products_of_all_other_nums(array)\n\n\tresult = Array.new() { [] }",
"def square_inject(array)\n array.inject([]) { |arr, num| arr << num * num }\nend",
"def double_array(array)\n output_array = []\n\n array.each do |thing|\n output_array << thing * 2\n end\n\n return output_array\nend",
"def fun(array)\n puts \"The original array is #{array}\"\n a = array.map {|n| n**2}\n total = 0\n a.each {|n| total += n}\n puts \"The squared numbers of the array are #{a}\"\n puts \"The total of the array is #{total}\"\nend",
"def square_array(array)\n counter=0 \n new_array=[]\n \n while counter < array.length do\n puts new_array.push(array[counter]**2)\n counter += 1 \n end\nnew_array\nend",
"def arr_product(arr)\n product = arr.reduce(:*)\n arr.map { |el| product / el }\nend",
"def double_array(array)\n array*2\nend",
"def squares\r\n [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3]\r\n \r\nend",
"def cubes(array)\narray.map {|number| number ** 3}\n\n\nend",
"def square\n return [] if length == 0\n \n for s in 0..length - 1\n self[ s ] *= self[ s ]\n end\n return self\n end",
"def squareSum(numbers) \r\n numbers.map{|num| num ** 2}.sum \r\n \r\nend",
"def get_squares(range)\n\tresult= []\n\ti= 1\n\twhile( i*i < range.end)\n\t\tresult << i*i\n\t\ti+= 1\n\tend\n\treturn result\nend",
"def squares\n self.map(&:square)\n end",
"def transform_array(array)\n i = 0\n array2 = []\n while i < array.length\n num1 = array[i]\n array2.push(square(num1))\n \n i += 1\n end\n # puts array2\n return return_sum(array2)\n end",
"def cubes(arr)\n p cubies = arr.map {|n| n ** 3}\nend",
"def calculate_doubles(arr)\n doubled_array = []\n arr.each {|int| doubled_array.push(int * 2)}\n doubled_array\nend"
] | [
"0.82418805",
"0.8215701",
"0.8057785",
"0.797745",
"0.7895184",
"0.78538835",
"0.78530765",
"0.77967167",
"0.7790575",
"0.7776725",
"0.77740264",
"0.77727866",
"0.7750432",
"0.77500796",
"0.7744982",
"0.7742994",
"0.77365494",
"0.77351207",
"0.7729818",
"0.7698281",
"0.76717466",
"0.76451576",
"0.7603868",
"0.75786906",
"0.75786906",
"0.7577703",
"0.7572616",
"0.7569497",
"0.7561372",
"0.7549692",
"0.7549627",
"0.7547575",
"0.7525818",
"0.7521323",
"0.75201786",
"0.75029576",
"0.7480805",
"0.7480399",
"0.74155927",
"0.7404496",
"0.7389599",
"0.7384647",
"0.7376895",
"0.7349028",
"0.734051",
"0.7340192",
"0.73381394",
"0.7309928",
"0.7298682",
"0.72656906",
"0.72655904",
"0.7231986",
"0.722936",
"0.7222267",
"0.72011703",
"0.71851116",
"0.71813816",
"0.71744955",
"0.71284425",
"0.7121495",
"0.71174836",
"0.71161455",
"0.70840925",
"0.7077549",
"0.7067225",
"0.7066739",
"0.7044765",
"0.70287114",
"0.70115453",
"0.70071536",
"0.6977002",
"0.696413",
"0.69512117",
"0.6934598",
"0.69251895",
"0.69197667",
"0.6897424",
"0.68950945",
"0.6870058",
"0.6842077",
"0.6826779",
"0.6812547",
"0.6805767",
"0.6797408",
"0.6794528",
"0.6790353",
"0.6763458",
"0.67557734",
"0.6751954",
"0.6745912",
"0.67450714",
"0.6720577",
"0.67155355",
"0.67023844",
"0.66935474",
"0.66907746",
"0.6672573",
"0.6665364",
"0.66542757",
"0.66529113"
] | 0.7542296 | 32 |
GET /posts GET /posts.json | def index
@without_magazine = Post.without_magazine
respond_to do |format|
format.html # index.html.erb
format.json { render json: @posts }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n\n @posts = Post.all\n\n render json: @posts, status: 200\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {render json: @posts}\n end\n end",
"def index\n render json: { posts: Post.all }\n end",
"def index\n @posts = Post.order(\"created_at DESC\").includes(:user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def index\n @posts = Post.all\n \n render json: @posts\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
"def show\n post = Post.find(params[:id])\n render json: post\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def display_posts\n begin\n response = RestClient.get \"#{@@DOMAIN}/api/posts.json?all\", authorization_hash\n\n puts \"Response code: #{response.code}\"\n puts \"Response cookies:\\n #{response.cookies}\\n\\n\"\n puts \"Response headers:\\n #{response.headers}\\n\\n\"\n puts \"Response content:\\n #{response.to_str}\"\n\n js = JSON response.body\n js.each do |item_hash|\n item_hash.each do |k, v|\n puts \"#{k}: #{v}\"\n end\n end\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def posts(opts)\n response = get(\"posts\", opts)\n response\n end",
"def index\n @posts = Post.all.order(created_at: :asc)\n json_response(@posts)\n end",
"def show\n \trender json: Post.find(params[:id])\n end",
"def index\n render json: Post.all\n end",
"def show\n\t \trender json: Post.find(params[:id])\n\t end",
"def show\n @user = User.find(params[:user_id])\n @post = @user.posts.find(params[:id])\n\n render json: @post\n end",
"def index\n @posts = Post.paginate(:page => params[:page], :per_page => 10).order('id DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def index\n render json: { posts: current_user.posts.all.map(&:to_h) }\n end",
"def index\n @posts = Post.all\n @posts = paginate(@posts)\n authorize @posts\n\n render json: @posts, each_serializer: Api::V1::PostSerializer, meta: meta_attributes(@posts)\n end",
"def index\n @posts = Mist::Post.recently_published(20, Mist.authorized?(:view_drafts, self))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def show\n @user = User.find(params[:id])\n @posts = @user.posts\n\n respond_to do |format|\n format.json { render json: {user: User._build(@user), posts: Post.build_posts(@posts)}, location: root_path }\n end\n end",
"def show\n render json: @post\n end",
"def show\n render json: @post\n end",
"def index\n\t\tgon.posts = Post.all.as_json\n\tend",
"def index\n # @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n # format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.atom\n end\n end",
"def get(options = {})\n response= handle_errors { self.class.get('/get', :query => options)}\n if response[\"posts\"][\"post\"].is_a?(Hash)\n Rubycious::Post.new response[\"posts\"][\"post\"]\n elsif response[\"posts\"][\"post\"].is_a?(Array)\n response[\"posts\"][\"post\"].collect{|i| Rubycious::Post.new(i)}\n else\n nil\n end\n end",
"def index\n\n # We display the posts be cronological inverted order\n if authenticated?\n @posts = Post.order('created_at DESC').page(params[:page])\n else\n @posts = Post.order('created_at DESC').where(:status => :true).page(params[:page])\n end\n \n respond_to do |format|\n format.html { render html: @posts }\n format.json { render json: @posts }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n \n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @posts = @game.posts.order(created_at: :desc).paginate(page: params[:page], per_page: 5)\n respond_to do |format|\n format.json { render template: 'api/games/game.json' }\n end\n end",
"def show\n post = Post.find_by(id: params[:id])\n if post \n render json: post\n else\n render json: {errors: 'Not found'}\n end\n end",
"def show\n render :json => @post\n end",
"def get(options = EMPTY_HASH)\n parameters = Specification.new(\n tag: Types::Tags,\n dt: Types::Time,\n url: Types::URL,\n meta: Types::Boolean\n ).parameters(options)\n posts_from client.get(\"/posts/get\", parameters)\n end",
"def index\n @posts = Post.all\n # Post.all returns all of the posts currently in the \n # database as an array of Post records that we store \n # in an instance variable called @posts.\n # http://guides.rubyonrails.org/active_record_querying.html\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n # The respond_to block handles both HTML and JSON calls \n # to this action. If you browse to \n # http://localhost:3000/posts.json, you’ll see a JSON \n # containing all of the posts. \n end",
"def show\n render json: @post, serializer: Api::V1::PostSerializer\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n @posts = PostService.getAllPosts\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render jsonapi: @post }\n end\n end",
"def index\n #@posts = Post.all\n @posts = Post.paginate( :page => params[:page],\n :per_page => 2\n )\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @post = Post.where(:id => params[:id]).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n\t@posts = list_posts\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @post }\n format.json do\n render :json => @post.to_json(:only => [:id, :title, :text, :lat, :lng, :created_at, :post_type, :likes], \n :methods => [:image_url, :video_url], \n :include => [:comments])\n end\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml { render xml: @posts }\n end\n end",
"def posts_list\n posts = Post.all.published.order(score: :desc, created_at: :desc)\n post_tags = Post.published.order(score: :desc, created_at: :desc).map { |post| Post.includes(:tags, :taggings).find_by(id: post.id).tags }\n categories = Category.all\n tags = Tag.all\n\n render_json(posts: posts, categories: categories, tags: tags, post_tags: post_tags)\n end",
"def index\n @posts = Post.all.order_by([:date_published, :desc]).page(params[:page]).per(20)\n #authorize! if cannot? :read, @posts\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @post ||= Mist::Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n page = params[:page]\n per_page = params[:per_page]\n\n posts = Post.order(published_at: :desc).page(page).per(per_page)\n\n # Передаём в заголовке общее количество страниц и записей.\n response.headers['Total-Pages'] = posts.total_pages\n response.headers['Total-Count'] = posts.total_count\n\n render json: posts\n end",
"def index\n render json: Post.all.order(id: :desc), each_serializer: V1::Posts::PostSerializer\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @post }\n format.xml { render xml: @posts }\n end\n end",
"def posts\n posts = @client.entries(content_type: 'post').items\n posts || []\n end",
"def show\n @post = Post.find(params[:id])\n \n respond_to do |format|\n format.html { render 'application/index' }\n format.json { render :json => { :post => @post.as_json } }\n end\n end",
"def show\r\n @post = root_post_of(Post.find(params[:id]))\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @post }\r\n end\r\n end",
"def index\n @posts = Post.order(created_at: :desc)\n respond_to do |format|\n format.html { render }\n format.text { render }\n format.xml { render xml: @posts }\n format.json { render json: @posts.to_json }\n end\n end",
"def index\n @art_posts = ArtPost.all\n\n render json: @art_posts\n end",
"def index\n per_page = params[:per_page] ? params[:per_page] : Post::PER_PAGE\n @posts = Post.by_published_date.paginate(page: params[:page], per_page: per_page)\n # Set count of posts and count of pages to query headers\n add_headers\n render json: @posts\n end",
"def show\n render json: {\n data: @post\n }\n end",
"def show\n @feed = Feed.find(params[:id])\n @posts = @feed.posts.order(\"published desc\").paginate(:page => params[:page], :per_page => 20)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end",
"def index\n # TODO: implement listing all posts\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts, :include => :tags }\n end\n end",
"def list\n comments = Comment.where(post: @post)\n render json: comments, status: 200\n end",
"def show\n @post = current_user.posts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n\t \tif params[:title]\n\t\t render json: Post.search(params[:title])\n \t\telse\n\t \trender json: Post.all\n \tend\n\t end",
"def index\n unless can?(:manage, Post)\n @posts = @posts.published\n end\n \n respond_with @posts\n end",
"def index\n @posts = Post.all\n respond_with(@posts)\n end",
"def index\n @posts = Post.all.reverse\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n render json: current_user.posts.all\n # TODO order posts alphabetically\n end",
"def index\n @posts = Post.includes(:author, channel: [:posts]).order(created_at: :desc)\n @posts = @posts.where(channel: @channel) if params[:channel_id]\n @posts = @posts.page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render jsonapi: @posts }\n end\n end",
"def show\n #@post = Post.find(params[:id])\n\n #respond_to do |format|\n # format.html # show.html.erb\n #format.json { render json: @post }\n #end\n end",
"def index\n @page = params[:page] || 1\n @posts = @exchange.posts.page(@page, context: 0).for_view\n respond_to do |format|\n format.json do\n serializer = PostSerializer.new(\n @posts,\n links: { self: paginated_json_path(@posts.current_page),\n next: paginated_json_path(@posts.next_page),\n previous: paginated_json_path(@posts.previous_page) },\n include: %i[user]\n )\n render json: serializer.serialized_json\n end\n end\n end",
"def index\n @postos = Posto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @postos }\n end\n end",
"def show\n @post = Post.find(params[:id])\n render json: @post, meta: { status: :ok }, meta_key: 'result'\n end",
"def show\n # @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n # format.json { render json: @post }\n end\n end",
"def index\n @api_v1_posts = Api::V1::Post.all\n end",
"def index\n @posts = Post.order(\"created_at DESC\").where(:published => true).limit(5)\n @title = \"Home\"\n @description = \"the blog and website of bassist and programmer Johnny Grubb. no baseball information here.\"\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml\n end\n end",
"def index\n respond_with Post.all\n end"
] | [
"0.7865315",
"0.7494904",
"0.7494433",
"0.7494433",
"0.7488696",
"0.74314564",
"0.728645",
"0.728645",
"0.728645",
"0.72562826",
"0.72522277",
"0.7247287",
"0.7246305",
"0.72221965",
"0.72042215",
"0.72039723",
"0.7169929",
"0.71689725",
"0.71644753",
"0.7121855",
"0.71152896",
"0.7108617",
"0.70960873",
"0.7071454",
"0.7063796",
"0.70486146",
"0.7044637",
"0.7029959",
"0.69793427",
"0.6957234",
"0.6945899",
"0.6921306",
"0.6918641",
"0.6897198",
"0.689313",
"0.6890521",
"0.68769336",
"0.6876437",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6856369",
"0.6854135",
"0.68492866",
"0.6837785",
"0.6814047",
"0.67974555",
"0.67884254",
"0.6782457",
"0.6779375",
"0.6779375",
"0.6770256",
"0.67645854",
"0.6760845",
"0.6751376",
"0.6740988",
"0.6720944",
"0.6703801",
"0.66790265",
"0.6662053",
"0.6649574",
"0.66334385",
"0.6629263",
"0.66292495",
"0.6625863",
"0.6625277",
"0.6619148",
"0.6612677",
"0.6612347",
"0.659554",
"0.65946317",
"0.6584386",
"0.6583931",
"0.6578741",
"0.6564504",
"0.6556115",
"0.65437686",
"0.65419716",
"0.65410036",
"0.6528237",
"0.65246344",
"0.6520045",
"0.65119064",
"0.6511185",
"0.64960027",
"0.64946514",
"0.64891815",
"0.6476575",
"0.64645535",
"0.6463598"
] | 0.0 | -1 |
GET /posts/1 GET /posts/1.json | def show
if params[:short_url]
@post = Post.find_by_short_url(params[:short_url])
else
@post = Post.find(params[:id])
end
raise NotFound unless @post
@articles_side_bar = Post.article_side_bar(@post)
@shop_side_bar = Product.shop_side_bar
respond_to do |format|
format.html # show.html.erb
format.json { render json: @post }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
"def show\n \trender json: Post.find(params[:id])\n end",
"def show\n post = Post.find(params[:id])\n render json: post\n end",
"def show\n\t \trender json: Post.find(params[:id])\n\t end",
"def show\n @post = Post.where(:id => params[:id]).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n\n @posts = Post.all\n\n render json: @posts, status: 200\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @user = User.find(params[:user_id])\n @post = @user.posts.find(params[:id])\n\n render json: @post\n end",
"def index\n @posts = Post.all\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {render json: @posts}\n end\n end",
"def index\n\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def show\n \n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n render json: { posts: Post.all }\n end",
"def show\n @post ||= Mist::Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n @posts = Post.order(\"created_at DESC\").includes(:user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n # when you go to http://localhost:3000/posts/1, rails interprets this\n # as a call to the show action for the resource and passes 1 to the \n # :id paramater. Using this blog app you can do that by clicking the \n # show link for a post on the index page.\n\n @post = Post.find(params[:id])\n # The show action uses Post.find to search for a single record \n # in the database by its id value. After finding the record, Rails \n # displays it by using app/views/posts/show.html.erb\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n post = Post.find_by(id: params[:id])\n if post \n render json: post\n else\n render json: {errors: 'Not found'}\n end\n end",
"def index\n render json: Post.all\n end",
"def index\n @posts = Mist::Post.recently_published(20, Mist.authorized?(:view_drafts, self))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def index\n @posts = Post.all.order(created_at: :asc)\n json_response(@posts)\n end",
"def index\n @posts = Post.all\n \n render json: @posts\n end",
"def show\n @post = Post.find(params[:id])\n \n respond_to do |format|\n format.html { render 'application/index' }\n format.json { render :json => { :post => @post.as_json } }\n end\n end",
"def show\n render json: @post, serializer: Api::V1::PostSerializer\n end",
"def show\r\n @post = root_post_of(Post.find(params[:id]))\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @post }\r\n end\r\n end",
"def show\n render json: @post\n end",
"def show\n @api_v2_post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_v2_post }\n end\n end",
"def show\n render json: @post\n end",
"def index\n @posts = Post.paginate(:page => params[:page], :per_page => 10).order('id DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.atom\n end\n end",
"def index\n render json: Post.all.order(id: :desc), each_serializer: V1::Posts::PostSerializer\n end",
"def show\n render :json => @post\n end",
"def index\n # @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n # format.json { render json: @posts }\n end\n end",
"def index\n @api_v1_posts = Api::V1::Post.all\n end",
"def show\n @post = Post.find(params[:id])\n render json: @post, meta: { status: :ok }, meta_key: 'result'\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render jsonapi: @post }\n end\n end",
"def show\n @posts = @game.posts.order(created_at: :desc).paginate(page: params[:page], per_page: 5)\n respond_to do |format|\n format.json { render template: 'api/games/game.json' }\n end\n end",
"def show\n @post = PostsService.getPostById(params[:id])\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @post }\n format.xml { render xml: @posts }\n end\n end",
"def index\n #@posts = Post.all\n @posts = Post.paginate( :page => params[:page],\n :per_page => 2\n )\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n # Post.all returns all of the posts currently in the \n # database as an array of Post records that we store \n # in an instance variable called @posts.\n # http://guides.rubyonrails.org/active_record_querying.html\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n # The respond_to block handles both HTML and JSON calls \n # to this action. If you browse to \n # http://localhost:3000/posts.json, you’ll see a JSON \n # containing all of the posts. \n end",
"def index\n\n # We display the posts be cronological inverted order\n if authenticated?\n @posts = Post.order('created_at DESC').page(params[:page])\n else\n @posts = Post.order('created_at DESC').where(:status => :true).page(params[:page])\n end\n \n respond_to do |format|\n format.html { render html: @posts }\n format.json { render json: @posts }\n end\n end",
"def show\n @user = User.find(params[:id])\n @posts = @user.posts\n\n respond_to do |format|\n format.json { render json: {user: User._build(@user), posts: Post.build_posts(@posts)}, location: root_path }\n end\n end",
"def index\n\t\tgon.posts = Post.all.as_json\n\tend",
"def index\n @posts = Post.order(\"created_at DESC\").where(:published => true).limit(5)\n @title = \"Home\"\n @description = \"the blog and website of bassist and programmer Johnny Grubb. no baseball information here.\"\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml\n end\n end",
"def display_posts\n begin\n response = RestClient.get \"#{@@DOMAIN}/api/posts.json?all\", authorization_hash\n\n puts \"Response code: #{response.code}\"\n puts \"Response cookies:\\n #{response.cookies}\\n\\n\"\n puts \"Response headers:\\n #{response.headers}\\n\\n\"\n puts \"Response content:\\n #{response.to_str}\"\n\n js = JSON response.body\n js.each do |item_hash|\n item_hash.each do |k, v|\n puts \"#{k}: #{v}\"\n end\n end\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def show\n #@post = Post.find(params[:id])\n\n #respond_to do |format|\n # format.html # show.html.erb\n #format.json { render json: @post }\n #end\n end",
"def index\n @posts = Post.all\n @posts = paginate(@posts)\n authorize @posts\n\n render json: @posts, each_serializer: Api::V1::PostSerializer, meta: meta_attributes(@posts)\n end",
"def index\n @posts = Post.find(:all)\n end",
"def show\n @post = current_user.posts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n render json: { posts: current_user.posts.all.map(&:to_h) }\n end",
"def show\n @feed = Feed.find(params[:id])\n @posts = @feed.posts.order(\"published desc\").paginate(:page => params[:page], :per_page => 20)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end",
"def index\n\t@posts = list_posts\n end",
"def show\n #GET a single post by ID\n @post = Post.find(params[:id])\n end",
"def posts(opts)\n response = get(\"posts\", opts)\n response\n end",
"def show\n @post = Post.find(params[:id])\n @title = @post.title\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n # TODO: implement listing all posts\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml { render xml: @posts }\n end\n end",
"def show\n @blogpost = Blogpost.published.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blogpost }\n end\n end",
"def show\n # @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n # format.json { render json: @post }\n end\n end",
"def post(postid)\n request(:id => postid).posts.first\n end",
"def show\n Rails.logger.debug(\"Inside show \")\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @posto = Posto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @posto }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @post }\n format.json do\n render :json => @post.to_json(:only => [:id, :title, :text, :lat, :lng, :created_at, :post_type, :likes], \n :methods => [:image_url, :video_url], \n :include => [:comments])\n end\n end\n end",
"def display_post\n begin\n # asks the user for the post id\n print \"Enter the post ID: \"\n id = STDIN.gets.chomp\n response = RestClient.get \"#{@@DOMAIN}/api/posts/#{id}.json\", authorization_hash\n\n js = JSON response.body\n js.each do |k, v|\n puts \"#{k}: #{v}\"\n end\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def index\n @posts = Post.all.reverse\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = PostService.getAllPosts\n end",
"def show\n render json: {\n data: @post\n }\n end",
"def show\n @post = Post.find(params[:id])\n @videos = Video.get_for @post #where([\"post_id = ?\", params[:id]]).all\n @background = get_background_for @post #Background::DEFAULT #Background.where([\"post_id = ?\", params[:id]])\n @nav = get_navigation :for => 'post', :current => @post\n @menu = get_menu :for => 'post'\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n @posts = Post.order(created_at: :desc)\n respond_to do |format|\n format.html { render }\n format.text { render }\n format.xml { render xml: @posts }\n format.json { render json: @posts.to_json }\n end\n end",
"def get(options = {})\n response= handle_errors { self.class.get('/get', :query => options)}\n if response[\"posts\"][\"post\"].is_a?(Hash)\n Rubycious::Post.new response[\"posts\"][\"post\"]\n elsif response[\"posts\"][\"post\"].is_a?(Array)\n response[\"posts\"][\"post\"].collect{|i| Rubycious::Post.new(i)}\n else\n nil\n end\n end",
"def show\n if !params[:id]\n @post = Post.find_by_title('Welcome')\n elsif params[:id] =~ /^[a-zA-Z ]+$/\n @post = Post.find_by_title(params[:id])\n else\n @post = Post.find(params[:id].to_i)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @blogpost = Blogpost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blogpost }\n end\n end",
"def show\n @blog_post = BlogPost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blog_post }\n end\n end",
"def index\n @post = Post.find_by_id(params[:post_id])\n if @post.nil?\n return render json: { error: \"Post not found\" }, status: :not_found\n end\n render json: @post.comments,status: 200\n end",
"def show\n @post2 = Post2.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post2 }\n end\n end"
] | [
"0.77110183",
"0.73537844",
"0.73433185",
"0.73379177",
"0.73228735",
"0.7293139",
"0.7275997",
"0.7256934",
"0.7161576",
"0.7158913",
"0.71552676",
"0.71552676",
"0.7119547",
"0.7094749",
"0.7094749",
"0.7094749",
"0.70943594",
"0.7071599",
"0.70607626",
"0.70452625",
"0.7032558",
"0.7020259",
"0.7020259",
"0.7020259",
"0.7020259",
"0.7020259",
"0.7020259",
"0.7020259",
"0.7020259",
"0.7020259",
"0.7020259",
"0.7020259",
"0.7020259",
"0.7020259",
"0.7020259",
"0.69897074",
"0.6955722",
"0.6955722",
"0.6954564",
"0.6937062",
"0.6936725",
"0.69257236",
"0.6917876",
"0.69010335",
"0.69005007",
"0.6894985",
"0.6893989",
"0.68756175",
"0.6860515",
"0.6853294",
"0.6853291",
"0.6847577",
"0.68364173",
"0.68232405",
"0.68093437",
"0.6804144",
"0.67621773",
"0.6743674",
"0.67226875",
"0.6720067",
"0.67147297",
"0.6713107",
"0.6699554",
"0.6693189",
"0.6679935",
"0.6655543",
"0.6644503",
"0.6641595",
"0.66299",
"0.6619761",
"0.66178924",
"0.66124725",
"0.6608166",
"0.66017526",
"0.6597235",
"0.65952027",
"0.65909946",
"0.65858185",
"0.6582703",
"0.658145",
"0.65768254",
"0.65733755",
"0.6568626",
"0.65668",
"0.655592",
"0.65385455",
"0.6525845",
"0.65144473",
"0.6513119",
"0.6497587",
"0.6497312",
"0.6493223",
"0.6491053",
"0.64720887",
"0.6471776",
"0.64655757",
"0.6455566",
"0.64530945",
"0.6448596",
"0.64456475",
"0.64289075"
] | 0.0 | -1 |
GET /posts/new GET /posts/new.json | def new
@post = Post.new
respond_to do |format|
format.html { render layout: "editor" }
format.json { render json: @post }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n \n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @post }\n end\n end",
"def new\n @post = Post.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n post = Post.new\n render json: post\n end",
"def new\n authenticated\n\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new \n @post = Post.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\r\n @post = Post.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @post }\r\n end\r\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n @title = \"New post\"\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @post }\n end\n end",
"def new\n @post = Post.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @title = \"Create New Post\"\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @post }\n end\n end",
"def new\n @post = Post.new\n # Creating a new post involves two actions. \n # The first is the new action, which \n # instantiates an empty Post object\n # The new.html.erb view displays this \n # empty Post to the user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n format.xml { render :xml => @post }\n end\n end",
"def new\n # responsbile for creating a new instance of a post\n @post = Post.new\n end",
"def new\n redirect_to posts_path and return unless Mist.authorized?(:create_post, self)\n @post = Mist::Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @post }\n end\n end",
"def new\n authorize\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n # @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n # format.json { render json: @post }\n end\n end",
"def new\n @post = model.new\n\n respond_to do |format|\n format.html { render :action => resource_template(\"new\") }\n end\n end",
"def new\n @post = Post.new\n @title = \"New Post\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n format.json { render :json => @post }\n end\n end",
"def new\n @user = User.find(params[:user_id])\n @post = Post.new(:user_id => @user.id)\n @title = \"New Post\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @news_post = NewsPost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_post }\n end\n end",
"def new\n @news_post = NewsPost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_post }\n end\n end",
"def new\n @posto = Posto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @posto }\n end\n end",
"def new #http://localhost:3000/posts/new\n\t@post = Post.new #creates a new empty post,if a form is created for it, it will be empty as well \n end",
"def new\n @mypost = Mypost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mypost }\n end\n end",
"def new\n #@post = Post.new\n\n #respond_to do |format|\n # format.html # new.html.erb\n #format.json { render json: @post }\n #end\n end",
"def new\n @newspost = Newspost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newspost }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @news_post }\n end\n end",
"def new\n @posttag = Posttag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @posttag }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html #{ redirect_to '/' }\n format.json { render json: @post }\n end\n end",
"def new\n @posts = Post.find(:all, :order => 'updated_at DESC')\n @post = Post.new\n @post.title = \"Überschrift*\"\n\n respond_to do |format|\n format.html { render :template => \"posts/new\" }\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @posttag = Posttag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @posttag }\n end\n end",
"def new\n \n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n @tags = Tag.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @api_v2_post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @api_v2_post }\n end\n end",
"def new\n @post = Post.new()\n end",
"def new\n @post = Post.new()\n end",
"def new\n @post = Post.new()\n end",
"def new\n @post = Post.new #returns an empty post\n end",
"def new\n @post = current_user.posts.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @post }\n end\n end",
"def new\n @post = Post.new\n respond_with(@post)\n end",
"def new\n @post = Post.new\n respond_with(@post)\n end",
"def new\n\t\t@post = Post.new\n\t\trender :new\n\tend",
"def new\n @test_post = TestPost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_post }\n end\n end",
"def new\n @blogpost = Blogpost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @blogpost }\n end\n end",
"def new\n respond_to do |format|\n format.html { render :template => 'posts/new' } # we specify the template because in theory we could be reverting from a post to create \n format.js { render :partial => 'posts/reply' }\n end\n end",
"def new\n @posting = Posting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @posting }\n end\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end",
"def new\n @post = Post.new\n end"
] | [
"0.8041972",
"0.8015645",
"0.79855055",
"0.7931354",
"0.7921413",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.79208016",
"0.78987646",
"0.786652",
"0.78466773",
"0.7832742",
"0.7832452",
"0.78221315",
"0.7780741",
"0.7681061",
"0.7630426",
"0.7627125",
"0.759086",
"0.7578101",
"0.7537422",
"0.7530161",
"0.74740213",
"0.7448652",
"0.7443649",
"0.74130577",
"0.74130577",
"0.74058706",
"0.7381209",
"0.73476535",
"0.73083013",
"0.72863096",
"0.7285193",
"0.7283697",
"0.7271207",
"0.72540003",
"0.7231295",
"0.7225528",
"0.72142684",
"0.7204498",
"0.7194513",
"0.71823364",
"0.71823364",
"0.71823364",
"0.71744376",
"0.7154436",
"0.7150181",
"0.7150181",
"0.7127834",
"0.71130663",
"0.7111491",
"0.71083105",
"0.71069354",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448",
"0.7096448"
] | 0.0 | -1 |
POST /posts POST /posts.json | def create
@post = Post.new(params[:post])
respond_to do |format|
if @post.save
format.html { redirect_to magazine_post_path(@post.short_url), notice: 'Post was successfully created.' }
format.json { render json: @post, status: :created, location: @post }
else
format.html { render action: "new", layout: "editor" }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n render json: Post.create(params[\"post\"])\n end",
"def create\n respond_with Post.create(params[:posts])\n end",
"def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end",
"def create\n @post = Post.new(post_params)\n @post.user = current_user\n\n if @post.save\n render json: @post, status: :created, location: api_v1_post_path(@post), serializer: Api::V1::PostSerializer\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = current_user.posts.new(post_params)\n\n if @post.save\n render json: {\n data: @post\n }\n else\n render json: {\n errors: @post.errors\n }\n end\n end",
"def create\n post = @current_user.posts.create(post_params)\n\n if post.save\n render json: post\n else\n render json: { errors: post.errors.full_messages }, status: :forbidden\n end\n end",
"def create\n title = params[:title]\n body = params[:body]\n\n @post = current_user.posts.create(title: title, body: body)\n\n if @post.save!\n json_response(@post)\n else\n json_response(@post.errors)\n end\n end",
"def create\n @post = Post.new({ :title => params[:post][:title] })\n \n respond_to do |format|\n if @post.save\n format.json { render :json => { :post => @post.as_json}, :status => :created, :location => @post }\n else\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(params[:user_id])\n @post = @user.posts.new(post_params)\n\n if @post.save\n render json: @post, status: :created, location: [@user, @post]\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = Post.new(post_params)\n\n if @post.save\n render json: {\n message: 'Post was successfully created.'\n }, status: :created\n else\n render json: {\n errors: @post.errors,\n message: 'Post could not be created.'\n }, status: :unprocessable_entity\n end\n end",
"def post(id, opts = {})\r\n uri = url_for(\"posts/#{id}\", opts)\r\n response = RestClient.get(uri)\r\n JSON.parse response\r\n end",
"def create\n\n\n @post = current_user.posts.build(post_params)\n\n if @post.save\n\n render json: \"Posted successfully\", status: 201\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = Post.new(params[:post])\n respond_to do |format|\n if @post.save\n format.json { render :json => @post }\n else\n format.json { render :json => @post.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with Post.create(params[:post])\n end",
"def create\n\t\tpost = @current_user.posts.create(post_params) \n\t\tif post.save\n\t\trender json: {success: true, auth_token: @current_user.authentication_token, post_id: post.id}\n\t else\n\t render json: {success: false, errors: post.errors.full_messages, message: \"Validation failed\"}, status: 422\n\t\tend \n\tend",
"def create_posts\n end",
"def create_posts\n end",
"def create_post\n begin\n #asks the user for the title, body, and whether it should be anonymous\n print \"Title: \"\n title = STDIN.gets.chomp\n print \"Body: \"\n body = STDIN.gets.chomp\n print \"Post as Anonymous? (y/n): \"\n anonymous = STDIN.gets.chomp.upcase == 'Y' ? true : false\n # check user information from login\n\n # Rails will reject this unless you configure the cross_forgery_request check to\n # a null_session in the receiving controller. This is because we are not sending\n # an authenticity token. Rails by default will only send the token with forms /users/new and\n # /users/1/edit and REST clients don't get those.\n # We could perhaps arrange to send this on a previous\n # request but we would then have to have an initial call (a kind of login perhaps).\n # This will automatically send as a multi-part request because we are adding a\n # File object.\n response = RestClient.post \"#{@@DOMAIN}/api/posts.json\",\n\n {\n post: {\n title: title,\n body: body,\n anonymous: anonymous\n },\n }, authorization_hash\n\n if (response.code == 201)\n puts \"Created successfully\"\n end\n puts \"URL for new resource: #{response.headers[:location]}\"\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def create\n @api_post = Api::Post.new(api_post_params)\n\n if @api_post.save\n render json: @api_post, status: :created, location: @api_post\n else\n render json: @api_post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.json { render :show, status: :created, location: @post }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \tif logged_in?\n params[:post][:user_id] = current_user.id\n @post = Post.new(post_params)\n if @post.save\n puts @post.published\n render json: @post\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end\n end",
"def create\n respond_with Post.create(post_params)\n end",
"def posts(opts)\n response = get(\"posts\", opts)\n response\n end",
"def post(*args)\n request(:post, *args)\n end",
"def post(*args)\n request :post, *args\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @api_post = current_user.posts.new(api_post_params)\n if @api_post.save\n render :show\n else\n render json: @api_post.errors, status: :unprocessable_entity\n end\n end",
"def create\n authenticated\n\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new post_params\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n if @post.save\n render :show, status: :created, location: @post\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n puts \"create post: #{post_params.inspect}\"\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n @title = \"Create New Post\"\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, :notice => 'Post was successfully created.' }\n format.json { render :json => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end",
"def create\n post_service = PostService.new(current_user, params)\n post_service.create_post\n #post_service.create\n respond_to do |format|\n if post_service.save?\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { redirect_to new_post_url, alert: post_service.errors }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.json { render json: @post, status: :created, location: @post }\n format.xml { render xml: @post, status: :created, location: @post }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.xml { render xml: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #raise params.inspect\n \n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @posts = Post.page(params[:page]).order('created_at desc')\n @post = Post.new(post_params)\n @user = User.where('account_id == ?', current_account.id)[0]\n respond_to do |format|\n if @post.save\n format.html { redirect_to '/posts' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :index }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\t\t\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user_post_param\n respond_to do |format|\n if @post.save\n format.html do\n redirect_to @post, notice:\n \"Post was successfully created.\"\n end\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json do\n render json: @post.errors, status:\n :unprocessable_entity\n end\n end\n end\n end",
"def create\n @api_v1_post = Api::V1::Post.new(api_v1_post_params)\n\n respond_to do |format|\n if @api_v1_post.save\n format.html { redirect_to @api_v1_post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_post }\n else\n format.html { render :new }\n format.json { render json: @api_v1_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = current_user.posts.new(params[:post])\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n @post.user_id = current_user.id\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { redirect_to posts_path, flash: { error: @post.errors.full_messages } }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def new\n post = Post.new\n render json: post\n end",
"def create\n @user = current_user\n @post = @user.posts.build(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save?\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @post = Post.new(params[:post])\r\n\r\n respond_to do |format|\r\n if @post.save\r\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\r\n format.json { render json: @post, status: :created, location: @post }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @post = Post.create(post_params)\n set_posts\n respond_to do |format|\n format.js\n format.html\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, :notice => \"slam\" }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { redirect_to posts_path }\n flash[:alert] = \"shit.\"\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n post\n end",
"def create\n @post = Post.new(content: params[:post][:content], user_id: @user.id)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @user }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { redirect_to @user }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def create\n @post = Post.new(post_params)\n @post.user_id = params[:user_id]\n if @post.save\n render json: @post, meta: { status: :created }, meta_key: 'result', status: :created\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = current_user.posts.new(post_params.merge(writter: current_user.name))\n\n if @post.save\n render json: {status: 1, id: @post.id.to_s, notice: \"新增成功,标题是:#{@post.title.capitalize}\", number: @post.number, errors: []}\n else\n render json: {status: -1, notice: \"新增失败,请先登录\", errors: @post.errors.full_messages}\n end\n end",
"def create\n puts \"Trying to Create New Post\"\n # Creates new post with given content tied to given userid\n @post = Post.new(post_params) \n if @post.save\n puts \"Post successfully created\"\n response.status=(201)\n render json: {status: \"Success\", message: [\"Post created!\"]}\n else\n # Error handling\n puts \"Something went wrong while creating new Post\"\n puts(@Post.errors.full_messages)\n response.status=(422)\n render json: { status: \"Error\", message: [@post.errors.full_messages]}\n end\n end",
"def create\n @post = current_user.posts.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to list_of_posts_post_path(@post.user), notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n execute(:post, *args)\n end",
"def create\n redirect_to posts_path and return unless Mist.authorized?(:create_post, self)\n coerce_date(params[:post], 'published_at')\n @post = Mist::Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, :notice => 'Post was successfully created.' }\n format.json { render :json => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = current_user.posts.build(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to new_post_successful_posts_path, notice: 'Anúncio criado com sucesso.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end",
"def create\n redirect_to login_path unless session[:user_id]\n message = 'Post was successfully created.'\n @post = Post.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: message }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n @post.user = User.find_by_auth_token!(cookies[:auth_token])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = current_user.posts.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n if @post.save\n redirect_to find_redirect(@post.page)\n else\n render :new\n render json: @post.errors, status: :unprocessable_entity\n end\n end"
] | [
"0.74463975",
"0.73221767",
"0.73072433",
"0.7123966",
"0.7015686",
"0.701327",
"0.69841874",
"0.6939327",
"0.69313824",
"0.69053805",
"0.68196476",
"0.6812792",
"0.6793222",
"0.6792862",
"0.6779654",
"0.6779654",
"0.67625546",
"0.67602354",
"0.67515427",
"0.6735786",
"0.66983837",
"0.6694823",
"0.6676922",
"0.6648634",
"0.6618174",
"0.6609208",
"0.6576672",
"0.6567517",
"0.6535031",
"0.65248317",
"0.6517826",
"0.6512526",
"0.6512526",
"0.65004253",
"0.64875203",
"0.6482612",
"0.64796066",
"0.6479418",
"0.64762664",
"0.64762664",
"0.64762664",
"0.64762664",
"0.64762664",
"0.64762664",
"0.64762664",
"0.6452396",
"0.6443543",
"0.64413923",
"0.6439579",
"0.6431225",
"0.6411242",
"0.64027417",
"0.6402409",
"0.63972473",
"0.63956606",
"0.6388207",
"0.6388207",
"0.6380103",
"0.63764375",
"0.6374259",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.63714516",
"0.6369631",
"0.6361449",
"0.6350474",
"0.6349784",
"0.6345706",
"0.6312865",
"0.63084143",
"0.630361",
"0.63009614",
"0.62957925",
"0.6295694",
"0.62955",
"0.6294854",
"0.62942207",
"0.628781",
"0.62877417",
"0.6283785",
"0.6282612",
"0.6263583"
] | 0.0 | -1 |
PUT /posts/1 PUT /posts/1.json | def update
@post = Post.find(params[:id])
respond_to do |format|
if @post.update_attributes(params[:post])
format.html { redirect_to magazine_post_path(@post.short_url), notice: 'Post was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit", layout: "editor" }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def update\n respond_with Post.update(params[:id], params[:posts])\n end",
"def update\n respond_with post.update(params[:id], params[:post])\n end",
"def update\n title = params[:title]\n body = params[:body]\n\n @post.update!(title: title, body: body)\n\n if @post.save!\n json_response(@post)\n else\n json_response(@post.errors)\n end\n end",
"def update\n authorize @post\n\n if @post.save\n render json: @post\n else\n render json: @post.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def test_update_post\n data = {\n title: \"Roll lemon\",\n content: \"Gingerbread bear claw muffin danish danish marzipan. Toffee lollipop wafer carrot cake dessert.\",\n description: \"Chocolate tootsie roll lemon drops. Chupa chups chocolate bar apple pie\",\n image: \"chocolate.png\",\n status: 1\n }\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update\n respond_with Post.update(params[:id],post_params)\n end",
"def update\n\t\t@post = post.find(params[:id])\n\t\[email protected]_attributes(post_params)\n\t\trespond_to do |format|\n\t\t\tformat.html {redirect_to post_path(@post)}\n\t\t\tformat.json {render json: @post}\n\t\tend\n\tend",
"def update\n if @post.update({\n title: post_params[:title],\n content: post_params[:content],\n })\n render json: Post.all.as_json\n else\n render json: {errors: @post.errors.full_messages}, status: :unprocessable_entity\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def update\n @post = Post.find(params[:id])\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.json { render :json => @post }\n else\n format.json { render :json => @post.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with Post.update(params[:id], params[:post])\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(post_params)\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.xml { render xml: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n if @post.update(post_params)\n head :no_content\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n @post.update_attributes(params[:post])\n format.html { redirect_to posts_url, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n end \n end",
"def update\n @api_post = Api::Post.find(params[:id])\n\n if @api_post.update(api_post_params)\n head :no_content\n else\n render json: @api_post.errors, status: :unprocessable_entity\n end\n end",
"def update\n id = Post.find(params[:id])._id\n \n respond_to do |format|\n if ((@post.update_attributes(params[:post])) && (@post._id = id))\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n redirect_to '/posts'\n end",
"def update\n\t\tif @post.update(post_params)\n\t\t\trender json: @post, status: :success\n\t\telse\n\t\t\trender json: @post.errors, status: :unprocessable_entity #422\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @api_v1_post.update(api_v1_post_params)\n format.html { redirect_to @api_v1_post, notice: 'Post was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_post }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request(:put, *args)\n end",
"def update\n @user = User.find(params[:user_id])\n @post = @user.posts.find(params[:id])\n\n if @post.update(post_params)\n head :no_content\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n if (@post.update(params.permit(:title, :content)))\n render json: @post, status: :ok\n else\n render json: @post.errors, status: 422\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\[email protected] = @post.votes + 1\n\t\t\[email protected]\n\t\telsif params[:flagged] == \"true\"\n\t\t\[email protected] = @post.flagged + 1\n\t\t\[email protected]\n\t\tend\n\t\t\n\t\t# TODO: ask Tom what this does again\n\t\trender :json => @post\n\tend",
"def put!\n request! :put\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to posts_path, notice: 'Post was successfully updated.' }\n format.json { render json: @post }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n update! { posts_url }\n end",
"def update\n if @post.update(post_params)\n render json: {\n data: @post\n }\n else\n render json: {\n errors: @post.errors\n }\n end\n end",
"def update(*args)\n put(*args)\n end",
"def update(*args)\n put(*args)\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.json { render :show, status: :ok, location: @post }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @post.update(post_params)\n head :no_content\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def update\n @post.update_attributes(params[:post])\n respond_with(@post)\n end",
"def update\n @api_v2_post = Post.find(params[:id])\n\n respond_to do |format|\n if @api_v2_post.update_attributes(params[:api_v2_post])\n format.html { redirect_to @api_v2_post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api_v2_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end",
"def update\n post = Post.find_by(id: params[:id])\n # byebug\n\n post.assign_attributes(update_params)\n if post.valid?\n post.save\n render json: post, status: :created\n else\n render json: {errors: post.errors.full_messages}, status: 422\n end\n end",
"def update_post(post_id, post_data)\n uri = \"#{@api_url}/#{@project_id}/posts/#{post_id}?access_token=#{@access_token}\"\n put uri, post_data\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'slam updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authenticated\n\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: '' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, :notice => 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, :notice => 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n update_resource_response(@post, blog_post_params)\n end",
"def update\n @post = Post.find_by_slug(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @post.update(post_params)\n render action: \"show.json.jbuilder\"\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to :action => 'index', notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = current_user\n @post = @user.posts.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n post = current_user.posts.find_by_uuid(params[:id])\n return render_item_not_found('Post') unless post\n post.update_attributes(post_params)\n broadcast(post, 'update')\n head :ok\n end",
"def update\r\n @post = Post.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @post.update_attributes(params[:post])\r\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n @title = \"EDIT\"\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, :notice => 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end",
"def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def update\n if @post.update(post_params)\n render json: {status: 1, id: @post.id.to_s, notice: \"修改成功,标题是:#{@post.title.capitalize}\", errors: []}\n else\n render json: {status: -1, notice: \"修改失败\", errors: @post.errors.fall_message}\n end\n end",
"def update\n respond_to do |format|\n @post.title = params[:title]\n @post.body = params[:body]\n @tags = params[:tags].split(',') unless params[:tags].blank?\n Post.transaction do\n if @post.save\n destroy_tags(@post, @tags)\n create_tags(@post, @tags)\n format.html { redirect_to posts_path, notice: 'Post was successfully updated.' }\n format.json { render :show, status: :ok, location: @post }\n else\n @action_path = post_path @post\n @method = :put\n format.html { render :edit }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update\n redirect_to posts_path and return unless Mist.authorized?(:update_post, self)\n @post = Mist::Post.find(params[:id])\n\n respond_to do |format|\n coerce_date(params[:post], 'published_at')\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, :notice => 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"def update\n @post = Post.update(params[:id], params[:post].permit(:caption))\n end",
"def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end",
"def update\n authorize\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post.update!(post_params)\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to \"/#{session[:username]}\", notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.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 if @post.update(post_params)\n render :show, status: :ok, location: @post\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @post.update(post_params)\n render :show, status: :ok, location: @post\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def update\t\n\t\tpost = @current_user.role == \"admin\" ? Post.find_by(id: params[:id]) : @current_user.posts.find_by(id: params[:id]) \n\t\tif post && post.update_attributes(post_params)\n\t\trender json: {success: true, auth_token: @current_user.authentication_token, post_id: post.id, post_desc: post.description}\n\t else\n\t render json: {success: false, message: \"not found or validation failed\"}, status: 422\n\t\tend \n\tend",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:article])\n format.html { redirect_to @post, notice: 'Article was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = current_user.posts.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to sites_url, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_api_v1_post\n @api_v1_post = Api::V1::Post.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @resource.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { render :show, status: :ok, location: @post }\n else\n format.html { render :edit }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post}\n format.json { render :show, status: :ok, location: @post }\n else\n format.html { render :edit }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n clean = params.require(:post).permit(:title, :body, :tag)\n if @post.update_attributes(clean)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n @post.update_attributes(params[:post])\n flash[:notice] = \"Updated succesfully\"\n respond_with(@post)\n end",
"def update\n respond_to do |format|\n if @post.update_attributes(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { render :show, status: :ok, location: @post }\n else\n format.html { render :edit }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'post was successfully updated.' }\n format.json { render :show, status: :ok, location: @post }\n else\n format.html { render :edit }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7308219",
"0.7123652",
"0.68159384",
"0.66432106",
"0.66181636",
"0.6607148",
"0.6583982",
"0.6564183",
"0.6552021",
"0.6532697",
"0.6511846",
"0.64877653",
"0.6446283",
"0.64321554",
"0.64155626",
"0.638547",
"0.63833165",
"0.63661736",
"0.63641906",
"0.6363359",
"0.63632154",
"0.6359975",
"0.63548297",
"0.63542086",
"0.6352791",
"0.6345763",
"0.63306063",
"0.6318297",
"0.6300069",
"0.6300069",
"0.6273585",
"0.62707883",
"0.62700063",
"0.6267426",
"0.6240362",
"0.6237036",
"0.62367743",
"0.62214875",
"0.6218219",
"0.6213732",
"0.62063664",
"0.61901885",
"0.61901885",
"0.61901885",
"0.61901885",
"0.61853313",
"0.6181859",
"0.6181859",
"0.61765033",
"0.6166637",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.6165114",
"0.61647093",
"0.61509615",
"0.6148211",
"0.6140376",
"0.6134548",
"0.6133479",
"0.61251056",
"0.61222315",
"0.61204594",
"0.6110559",
"0.6108299",
"0.60977256",
"0.6083164",
"0.6059843",
"0.6045384",
"0.60448086",
"0.6027209",
"0.60209423",
"0.60053504",
"0.5995274",
"0.59937966",
"0.598489",
"0.5965054",
"0.5965054",
"0.59429854",
"0.59422094",
"0.59290034",
"0.59253895",
"0.5915753",
"0.5909751",
"0.5909557",
"0.5909293",
"0.5900103",
"0.5898666"
] | 0.6026328 | 83 |
DELETE /posts/1 DELETE /posts/1.json | def destroy
@post = Post.find(params[:id])
@post.destroy
respond_to do |format|
format.html { redirect_to "/magazine" }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n post = Post.find(params[:id])\n if post.destroy\n render json: {status: \"success\", data: {id: params[:id]}}, status: :ok\n end\n end",
"def destroy\n @post.destroy\n render json: {}, status: :ok\n end",
"def destroy\n if @post.destroy\n render json: {\n post: @post\n }, status: :ok\n else\n render status: :bad_request\n end\n end",
"def destroy\n @api_v2_post = Post.find(params[:id])\n @api_v2_post.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v2_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_post.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_posts_url, notice: 'Post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authenticated\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @post = Post.find(params[:id])\n # @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post.destroy\n\n json_response(@post)\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_with Post.destroy(params[:id])\n end",
"def destroy\n r = PostRepository.new\n @post = r.GetPost(\"PostID\", params[:id].to_i)\n r.delete @post\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @api_post.destroy\n\n head :no_content\n end",
"def destroy\n @post.destroy\n render json: {\n data: {\n post: { key: @post.id },\n status: @post.status,\n }\n }\n end",
"def destroy\n\t\tpost = Post.find(params[:id])\n\t\t# byebug\n \tpost.destroy\n\t posts = Post.all\n \trender json: posts\n end",
"def destroy\r\n @post = Post.find(params[:id])\r\n @post.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to posts_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_path, notice: \"Post removed.\" }\n format.json { render 'destroy' }\n end\n end",
"def delete\n @post = Post.find(params[:id])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_path(client_id:current_user.client.id, per_page:5), notice: 'Post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_index_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_with Post.destroy(params[:id])\n end",
"def destroy\r\n @post = Post.find(params[:id])\r\n @post.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to root_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @post.destroy\n\n head :no_content\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/posts' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n\n render json: Post.all.as_json\n end",
"def destroy\n @post.destroy\n head :no_content\n end",
"def destroy\n @post.destroy\n head :no_content\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to blog_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n @title = \"Kill Post\"\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to all_user_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n head :no_content\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html {redirect_to posts_url, notice: 'Post was successfully destroyed.'}\n format.json {head 200}\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_path, notice: 'Post was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_with post.destroy(params[:id])\n end",
"def destroy\n @post.destroy\n \n respond_to do |format|\n format.html { redirect_to post_url, notice: 'Post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n Post.find(params[:id]).delete\n\n redirect_to '/'\n end",
"def destroy\n # @post = Post.find(params[:id])\n #@post.destroy\n\n #respond_to do |format|\n # format.html { redirect_to posts_url }\n #format.json { head :no_content }\n #end\n end",
"def delete(url)\n raise Error, \"Missing URL\" unless url\n get('posts/delete?uri=' << u(url))\n nil\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to news_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post = Post.find_by_slug(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url, notice: \"Anúncio removido com sucesso.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.friendly.find(params[:id])\n @post.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Story deleted' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url, notice: \"Postitus edukalt kustutatud!\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url, notice: 'Postagem excluida com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url, notice: 'Postagem excluída com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mural_post.destroy\n respond_to do |format|\n format.html { redirect_to mural_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @posto = Posto.find(params[:id])\n @posto.destroy\n\n respond_to do |format|\n format.html { redirect_to postos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_post.destroy\n end"
] | [
"0.8046884",
"0.76902676",
"0.7583626",
"0.75803024",
"0.7568048",
"0.75047046",
"0.75031126",
"0.74750155",
"0.74671036",
"0.74650854",
"0.746482",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7423174",
"0.74059606",
"0.73990285",
"0.73928183",
"0.7389498",
"0.7371715",
"0.7371117",
"0.7349121",
"0.7344524",
"0.7342226",
"0.7338908",
"0.7313371",
"0.73123556",
"0.731156",
"0.73095584",
"0.7299751",
"0.7298017",
"0.7298017",
"0.7282874",
"0.7277125",
"0.7266815",
"0.7260945",
"0.72549784",
"0.7254856",
"0.7239102",
"0.7238946",
"0.7229726",
"0.7227931",
"0.7221013",
"0.721375",
"0.7211237",
"0.72097856",
"0.7190222",
"0.71850675",
"0.7171746",
"0.71533066",
"0.71457464",
"0.71434635",
"0.7142048",
"0.7139985",
"0.7137574"
] | 0.0 | -1 |
POST /users POST /users.json | def create
@user = User.find_by_external_id(user_params[:external_id])
if @user.nil?
@user = User.new(user_params)
respond_to do |format|
if @user.save
format.json { render json: {user: @user}, status: 200 }
else
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
else
respond_to do |format|
format.json { render json: {user: @user}, status: 200 }
end
end
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 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.find_by_external_id(params[:id])
@user = User.create!(name: params[:name], email: params[:email], external_id: params[:external_id]) unless @user
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 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 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 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 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 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 init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\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 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 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 default_action; end",
"def callback_phase\n super\n end",
"def advice\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",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def duas1(action)\n action.call\n action.call\nend",
"def _handle_action_missing(*args); end"
] | [
"0.6164095",
"0.6046031",
"0.5945298",
"0.59179014",
"0.58890367",
"0.58341795",
"0.5776118",
"0.5700777",
"0.5700777",
"0.5656277",
"0.56218207",
"0.5423995",
"0.5411516",
"0.5411516",
"0.5411516",
"0.5395004",
"0.53783494",
"0.53593004",
"0.53412604",
"0.534078",
"0.5332865",
"0.53135896",
"0.52999926",
"0.5297309",
"0.5296569",
"0.5261449",
"0.5247048",
"0.52376497",
"0.52376497",
"0.52376497",
"0.52376497",
"0.52376497",
"0.52323204",
"0.52310973",
"0.523081",
"0.5225785",
"0.5219039",
"0.52136266",
"0.5208033",
"0.520763",
"0.5177365",
"0.5175224",
"0.5173357",
"0.5166104",
"0.5162502",
"0.51573396",
"0.5154547",
"0.5153531",
"0.51502854",
"0.51436496",
"0.5142863",
"0.51330835",
"0.5115634",
"0.5115634",
"0.511527",
"0.5109693",
"0.51076853",
"0.5093146",
"0.5090683",
"0.50829846",
"0.50819314",
"0.50670373",
"0.5055505",
"0.5053398",
"0.50504035",
"0.50504035",
"0.5037765",
"0.5027292",
"0.5024484",
"0.50150335",
"0.5014069",
"0.50022113",
"0.5001542",
"0.49981874",
"0.49915564",
"0.49915564",
"0.49880967",
"0.4982312",
"0.49787375",
"0.49786067",
"0.49687737",
"0.49676532",
"0.49602765",
"0.49565676",
"0.49550772",
"0.495342",
"0.49522525",
"0.49463704",
"0.49447197",
"0.49362713",
"0.49328062",
"0.49280638",
"0.49272856",
"0.4927058",
"0.49221697",
"0.4919526",
"0.49185994",
"0.49184805",
"0.49170163",
"0.49168405",
"0.49167764"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def user_params
params.require(:user).permit(:name, :email, :external_id)
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 user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\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 strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\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 listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\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 url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\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 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 filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\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 reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\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 list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; 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 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 url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\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 valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\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 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 user_params\n params.permit(:name, :age, :username, :display_photo, :password)\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 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",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
Fetch a row or rows from the cursor. [direction] A string specifying which row or rows to fetch. See the postgres documentation for the "DECLARE" statement. NEXT PRIOR FIRST LAST ABSOLUTE count RELATIVE count count ALL FORWARD FORWARD count FORWARD ALL BACKWARD BACKWARD count BACKWARD ALL | def fetch(direction = 'NEXT')
@select.fetch_by_cursor(@name, direction, @connection)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch(cursor: -1, count: 50, **options)\n cursor, count = cursor.to_i, count.to_i\n window = count + 2 # Fetch extra two elements for concrete next/prev links\n\n if cursor >= 0\n page = @scope.where(@cursor_key => -Float::INFINITY..cursor).limit(window)\n else\n cursor = cursor == -1 ? 0 : cursor.abs\n page = @scope.where(@cursor_key => cursor..Float::INFINITY).limit(window)\n end\n\n # Ensure result set is in correct order\n page = page.order(@cursor_key => :desc)\n\n Page.new(page, cursor, count: count)\n end",
"def fetch_row\n if @row_buffer.empty?\n if @done\n return nil\n else\n fetch_more\n end\n end\n\n @row_buffer.shift\n end",
"def column_next direction=0\n # right movement or panning cycles back to first column\n # leftward movement stops at first column.\n if direction == 0\n @stact += @grows\n @stact = 0 if @stact >= @vps\n @cursor += @grows\n # 2019-03-18 - zero loses offset. we need to maintain it\n # @cursor = 0 if @cursor >= @vps\n if @cursor - @sta >= @vps\n @cursor -= @grows while @cursor > @sta\n @stact -= @grows while @stact > 0\n @cursor += @grows if @cursor < @sta\n @stact += @grows if @stact < 0\n end\n else\n @stact -= @grows\n @cursor -= @grows\n @stact = 0 if @stact < 0\n # setting cursor as zero loses the position or offset\n # We are trying to maintain offset\n @cursor += @grows if @cursor < 0\n end\nend",
"def next_cursor\n @result[:next_cursor]\n end",
"def slide(direction)\n x, y = @block_to_loc[Block.new(0)]\n # Marshal is needed to perform a deep copy of the object\n new_rows = Marshal::load(Marshal.dump(@rows))\n return_nil = true\n unless is_invalid_move?(x, y, direction, new_rows)\n return_nil = false\n swap_blocks(x, y, direction, new_rows)\n end\n if return_nil == false\n return new_rows.flatten \n else\n return nil\n end\n end",
"def run_cursor_loop(connection, &block)\n Backfiller.log 'Start cursor loop'\n\n total_count = 0\n cursor = build_cursor(connection)\n\n loop do\n finished, count = cursor.transaction do\n run_fetch_loop(cursor, &block)\n end\n\n total_count += count\n\n Backfiller.log \"Total processed #{total_count}\"\n break if finished\n end\n end",
"def fetch_cursor(name='csr')\n raise ArgumentError, \"Cursor #{name} not open\" unless @cursors.has_key?(name)\n fetch_buffer(name) if @cursors[name][:state] == :empty\n return nil if @cursors[name][:state] == :eof\n @cursors[name][:state] = :empty if @cursors[name][:buffer].size <= 1\n row = @cursors[name][:buffer].shift\n row.is_a?(Hash) ? row.symbolize_keys : row\n end",
"def move count\n dir = count <0 ? 'in' : 'out' \n r= db.execute { \"select from ( traverse #{dir}(\\\"tg_grid_of\\\") from #{rrid} while $depth <= #{count.abs}) where $depth = #{count.abs} \" } \n if r.size == 1\n r.first\n else\n nil\n end\n end",
"def next_row\n @rows+=1\n set RGhost::Cursor.next_row\n end",
"def next\n return nil if @eof\n\n @stmt.must_be_open!\n\n unless @first_row\n result = @driver.step( @stmt.handle )\n check result\n end\n\n @first_row = false\n\n unless @eof\n row = []\n @driver.data_count( @stmt.handle ).times do |column|\n case @driver.column_type( @stmt.handle, column )\n when Constants::ColumnType::NULL then\n row << nil\n when Constants::ColumnType::BLOB then\n row << @driver.column_blob( @stmt.handle, column )\n else\n row << @driver.column_text( @stmt.handle, column )\n end\n end\n\n if @db.type_translation\n row = @stmt.types.zip( row ).map do |type, value|\n @db.translator.translate( type, value )\n end\n end\n\n if @db.results_as_hash\n new_row = Hash[ *( @stmt.columns.zip( row ).flatten ) ]\n row.each_with_index { |value,idx| new_row[idx] = value }\n row = new_row\n else\n row.extend FieldsContainer unless row.respond_to?(:fields)\n row.fields = @stmt.columns\n end\n\n row.extend TypesContainer\n row.types = @stmt.types\n\n return row\n end\n\n nil\n end",
"def cursor\n relation = add_params(cursorMark: '*')\n\n # Sort must include a sort on unique key (id).\n if /\\bid\\b/ =~ params[:sort]\n relation\n else\n relation.sort(params[:sort], 'id ASC')\n end\n end",
"def fetch_cursor(name)\n connection.fetch_cursor(name)\n end",
"def cursor_pagedown\n @mode = (@mode + 1) % TABLE.size\n refresh\n end",
"def step_by(field, direction)\n \t\t\tdesired_direction = direction == :next ? \">\" : \"<\"\n \t\t\torder_direction = direction == :next ? \" ASC\" : \" DESC\"\n\t\t\t\n \t\t\tself.class.first :conditions => prepare_condition(field, desired_direction, self.class.read_inheritable_attribute(:browsable_scope)), :order => field.to_s + order_direction\n \t\tend",
"def next\n return nil unless next?\n return nil if end_cursor.nil?\n ensure_service!\n query.start_cursor = cursor.to_grpc # should always be a Cursor...\n query.offset = 0 # Never carry an offset across batches\n unless query.limit.nil?\n # Reduce the limit by the number of entities returned in the current batch\n query.limit.value -= count\n end\n query_res = service.run_query query, namespace, read_time: read_time\n self.class.from_grpc query_res, service, namespace, query, read_time\n end",
"def next(direction)\n return false unless @settled\n \n case direction.cardinal_point\n when \"NORTH\" \n {x: x, y: y+1}\n when \"EAST\"\n {x: x+1, y: y}\n when \"SOUTH\"\n {x: x, y: y-1}\n when \"WEST\"\n {x: x-1, y: y}\n end \n end",
"def select(db_pointer, sql, field_count: nil)\n return 'db_pointer not initialized' unless db_pointer\n return to_enum(__method__, db_pointer, sql) unless block_given?\n\n query_pointer = fetch(db_pointer, sql)\n return last_error if query_pointer.nil? || query_pointer == FFI::Pointer::NULL\n\n field_count ||= column_count(query_pointer)\n loop do\n row = get_next_row(query_pointer, field_count)\n return last_error unless row\n\n yield row\n end\n nil\n end",
"def next_coordinate(coordinate, direction)\n row = coordinate[0]\n col = coordinate[1].to_i\n case direction\n when 'l' #left\n \"#{row}#{col - 1}\"\n when 'r' #right\n \"#{row}#{col + 1 }\"\n when 'u' #up\n \"#{previous_letter(row)}#{col}\"\n when 'd' #down\n \"#{row.succ}#{col}\"\n end\n end",
"def return\n # Enumerator objects don't have `#last`, so we use the following\n Quandl::Return.new(rows.first, rows.reverse_each.first)\n end",
"def next\n return nil if @eof\n\n if @current_row\n result, @current_row = @current_row, nil\n else\n result = API.step( @vm )\n check_eof( result )\n end\n\n unless @eof\n row = result[:row]\n\n if @db.type_translation\n row = @types.zip( row ).map do |type, value|\n @db.translator.translate( type, value )\n end\n end\n\n if @db.results_as_hash\n new_row = Hash[ *( @columns.zip( row ).flatten ) ]\n row.each_with_index { |value,idx| new_row[idx] = value }\n row = new_row\n else\n row.extend FieldsContainer unless row.respond_to?(:fields)\n row.fields = @columns\n end\n\n row.extend TypesContainer\n row.types = @types\n\n return row\n end\n\n nil\n end",
"def cursor_fetch_rows(sql)\n server_opts = {:server=>@opts[:server] || :read_only}\n cursor = @opts[:cursor]\n hold = cursor[:hold]\n cursor_name = quote_identifier(cursor[:cursor_name] || 'sequel_cursor')\n rows_per_fetch = cursor[:rows_per_fetch].to_i\n\n db.send(*(hold ? [:synchronize, server_opts[:server]] : [:transaction, server_opts])) do \n begin\n execute_ddl(\"DECLARE #{cursor_name} NO SCROLL CURSOR WITH#{'OUT' unless hold} HOLD FOR #{sql}\", server_opts)\n rows_per_fetch = 1000 if rows_per_fetch <= 0\n fetch_sql = \"FETCH FORWARD #{rows_per_fetch} FROM #{cursor_name}\"\n cols = nil\n # Load columns only in the first fetch, so subsequent fetches are faster\n execute(fetch_sql) do |res|\n cols = fetch_rows_set_cols(res)\n yield_hash_rows(res, cols){|h| yield h}\n return if res.ntuples < rows_per_fetch\n end\n loop do\n execute(fetch_sql) do |res|\n yield_hash_rows(res, cols){|h| yield h}\n return if res.ntuples < rows_per_fetch\n end\n end\n rescue Exception => e\n raise\n ensure\n begin\n execute_ddl(\"CLOSE #{cursor_name}\", server_opts)\n rescue\n raise e if e\n raise\n end\n end\n end\n end",
"def cursor_query_for(sql, limit, offset)\n cursor = \"__arel_cursor_#{rand(0xffff)}\"\n\n return <<-eosql\n DECLARE #{cursor} SCROLL CURSOR FOR #{sql} FOR READ ONLY\n SET CURSOR ROWS #{limit} FOR #{cursor}\n OPEN #{cursor}\n FETCH ABSOLUTE #{offset+1} #{cursor}\n CLOSE #{cursor}\n DEALLOCATE #{cursor}\n eosql\n end",
"def row_seek(n)\n @result.row_seek(n)\n end",
"def next\n @stmt.step\n end",
"def cursor_right(wrap = false)\n if col_max >= 2 && (index % col_max == col_max - 1)\n select(index + 1 - col_max)\n elsif col_max >= 2 && (index < item_max - 1 || (wrap && horizontal?))\n select((index + 1) % item_max)\n end\n end",
"def next_row\n @next_row ||= _read_row\n end",
"def find_cursor(name, transaction, *findargs)\n count = 0\n begin\n connection.begin_db_transaction if transaction\n open_cursor(name, *findargs)\n while (row = ActiveRecord::Base.fetch_cursor(name)) do\n count+= 1\n yield row\n end\n close_cursor(name)\n ensure\n connection.commit_db_transaction if transaction\n end\n count\n end",
"def get_next_coords(direction)\n x, y = get_head_coords[:x], get_head_coords[:y]\n case direction\n when 'S'\n y += 1\n when 'N'\n y -= 1\n when 'E'\n x += 1\n when 'W'\n x -= 1\n end\n return x, y\n end",
"def each\n if block_given?\n while row = shift\n yield row\n end\n else\n to_enum\n end\n end",
"def horizontal_traversal(horizontal_cursor=@horizontal_cursor)\n @horizontal_cursor=horizontal_cursor\n while @horizontal_cursor != nil\n horizontal_traversal_step()\n @horizontal_cursor = @horizontal_cursor.lateral\n end\n end",
"def mqlread_with_cursor(query, cursor, options={})\n params = { :query => query.to_json, :lang => \"/lang/#{@query_options[:lang]}\", :limit => @query_options[:limit], :cursor => cursor }.merge(options)\n response = get(surl('mqlread'), params, format: :json)\n {result: response['result'], cursor: response['cursor']}\n end",
"def cursor_pageup\n @mode = (@mode + TABLE.size - 1) % TABLE.size\n refresh\n end",
"def next\n @offset = get_current_offset + get_count\n get_results @current_projection\n end",
"def method_missing(sym, *args, &block)\n return @cursor.send(sym, *args)\n end",
"def atomic_cursor( *args )\n \n return cursor( *args ).atomize\n \n end",
"def events(direction = :forward, maxCount = @pgSize)\n set_method, next_method = (direction == :forward) ? [:rewind, :readNext] : [:reset, :readPrevious]\n send(set_method)\n\n readNext if direction == :reverse # Hack to fix issue with VC setting to first page of events\n\n while (events_page = send(next_method, maxCount))\n events_page.each { |event| yield(event) }\n end\n end",
"def page_cursor\n @page_cursor ||= pages.to_enum.lazy\n end",
"def move(direction = 'NEXT')\n statement = \"move #{direction} from #{@name}\"\n @connection.exec(statement)\n end",
"def query_with_cursor(sql_query, limit = nil)\n places = []\n transaction do\n ActiveRecord::Base.uncached do\n cursor = connection.select_value(sql_query)\n place = nil\n begin\n results = many.next_with_attributes(cursor)\n unless results.empty?\n place = with_details(results)\n places << place\n if (limit)\n limit -= 1\n place = nil if limit == 0\n end\n else\n place = nil\n end\n end while !place.nil?\n end\n end\n places\n end",
"def pagy_cursor(collection, vars={}, options={})\n pagy = Pagy::Cursor.new(pagy_cursor_get_vars(collection, vars))\n\n items = pagy_cursor_get_items(collection, pagy, pagy.position)\n pagy.has_more = pagy_cursor_has_more?(items, pagy)\n\n return pagy, items\n end",
"def all_next\n self.class.base_class.where(\"#{scoped_position} > ?\", position)\n end",
"def each\n @cursor = nil\n session = client.send(:get_session, @options)\n server = cluster.next_primary(nil, session)\n result = send_initial_query(server, session, context: Operation::Context.new(client: client, session: session))\n result = send_fetch_query(server, session) unless inline?\n @cursor = Cursor.new(view, result, server, session: session)\n if block_given?\n @cursor.each do |doc|\n yield doc\n end\n else\n @cursor.to_enum\n end\n end",
"def cursor_eachrow(sql, name='csr', transaction=true, buffer_size=10000)\n count = 0\n begin\n begin_db_transaction if transaction\n open_cursor(sql, name, buffer_size)\n while (row = fetch_cursor(name)) do\n count+= 1\n #puts \"EACH CSR #{row.inspect}\"\n yield row\n end\n close_cursor(name)\n ensure\n commit_db_transaction if transaction\n end\n count\n end",
"def fetch\n row = @results[@index += 1]\n return unless row\n\n if @types\n row.map!.with_index { |value, index| translate_type(value, @types[index]) } if @types\n elsif @type_translation == :string\n row.map!(&:to_s)\n end\n\n Hash[*@columns.zip(row).flatten]\n end",
"def mqlread(query, options = {})\n cursor = options[:cursor]\n if cursor\n query_result = []\n while cursor\n response = get_query_response(query, cursor)\n query_result += response['result']\n cursor = response['cursor']\n end\n else\n response = get_query_response(query, cursor)\n cursor = response['cursor']\n query_result = response['result']\n end\n query_result\n end",
"def fetch(seq, attr=\"FULL\")\n fetch_internal(\"FETCH\", seq, attr)\n end",
"def select_cursor(options)\n cursor = ResultFetcher.new(self, options)\n unless options[:type_cast] == false\n cursor = TypeCastingCursor.new(self, options[:table], cursor)\n end\n cursor\n end",
"def lookup_in_direction relation, direction_in\n obj_id = pid_to_fedora_id(@obj.pid)\n \tfedora_connection = Rubydora.connect Rails.application.config.fedora_connection\n \tif direction_in\n sparql = 'select ?m where { ?m <'+relation+'> <'+obj_id+'> }'\n else\n sparql = 'select ?m where { <'+obj_id+'> <'+relation+'> ?m }'\n end\n \tcsv = fedora_connection.sparql(sparql)\n \tcsv['m'].collect{|id| fedora_id_to_numeric_id(id)}\n end",
"def fetch; @data = pager.fetcher[self.begin, pager.per_page]; end",
"def each_row_for_next_chunk\n return nil if finished?\n raise \"#{self.class}: instance not prepared before running the iteration\" unless @prepared\n\n select_sql = @select_sql.present? ? @select_sql : '*'\n sql = \"SELECT #{select_sql} FROM #{data_table_name} WHERE #{data_where_scope} ORDER BY id ASC LIMIT #{Import::CHUNK_ROWS_COUNT} OFFSET #{@iteration_number * Import::CHUNK_ROWS_COUNT}\"\n pg_result = postgres.copy(\"COPY (#{sql}) TO STDOUT WITH CSV DELIMITER ','\") do |row|\n yield row\n end\n\n @iteration_number += 1\n check_if_finished\n end",
"def count(direction)\n i = 0\n node = self\n while (node != nil)\n node = node.send(direction)\n i += 1\n end\n i\n end",
"def next\n next_row = @next_node.next()\n while next_row != nil\n # return row if it matches predicate\n return next_row if @predicate.call(next_row)\n # otherwise, keep calling next\n next_row = @next_node.next()\n end\n return nil\n end",
"def down!(origin, stop)\n x = origin.row\n\n while x <= stop.row\n add_result extract!(IndexPath[x, origin.column])\n\n x += 1\n end\n\n # Begin moving left from the end of this row\n starts_at = IndexPath[stop.row, stop.column - 1]\n ends_at = IndexPath[stop.row, max_columns - stop.column]\n\n left!(starts_at, ends_at)\n end",
"def fetch\n @fetched_record = nil\n return nil if @index >= @records.size\n rec = @records[@index]\n @index += 1\n @fetched_record = rec\n return rec\n end",
"def right!(origin, stop)\n y = origin.column\n\n while y <= stop.column\n add_result extract!(IndexPath[origin.row, y])\n\n y += 1\n end\n\n # Begin moving down from the end of this row\n starts_at = IndexPath[stop.row + 1, stop.column]\n ends_at = IndexPath[max_rows - stop.row, stop.column]\n\n down!(starts_at, ends_at)\n end",
"def next_row\n row = []\n case rc = @stmt_api.step\n when ResultCode::ROW\n result_meta.each_with_index do |col, idx|\n value = nil\n column_type = @stmt_api.column_type( idx )\n case column_type\n when DataType::TEXT\n value = @stmt_api.column_text( idx )\n when DataType::FLOAT\n value = @stmt_api.column_double( idx )\n when DataType::INTEGER\n value = @stmt_api.column_int64( idx )\n when DataType::NULL\n value = nil\n when DataType::BLOB\n # if the rowid column is encountered, then we can use an incremental\n # blob api, otherwise we have to use the all at once version.\n if using_rowid_column? then\n value = Amalgalite::Blob.new( :db_blob => SQLite3::Blob.new( db.api,\n col.schema.db,\n col.schema.table,\n col.schema.name,\n @stmt_api.column_int64( @rowid_index ),\n \"r\"),\n :column => col.schema)\n else\n value = Amalgalite::Blob.new( :string => @stmt_api.column_blob( idx ), :column => col.schema )\n end\n else\n raise ::Amalgalite::Error, \"BUG! : Unknown SQLite column type of #{column_type}\"\n end\n\n row << db.type_map.result_value_of( col.schema.declared_data_type, value )\n end\n row.fields = result_fields\n when ResultCode::DONE\n row = nil\n write_blobs\n else\n self.close # must close so that the error message is guaranteed to be pushed into the database handler\n # and we can can call last_error_message on it\n msg = \"SQLITE ERROR #{rc} (#{Amalgalite::SQLite3::Constants::ResultCode.name_from_value( rc )}) : #{@db.api.last_error_message}\"\n raise Amalgalite::SQLite3::Error, msg\n end\n return row\n end",
"def nearest_neighbor(direction)\n case direction\n when :above\n return if row.first?\n\n adjacent = nil\n adj_distance = nil\n # find closest on next row\n previous_row = row.layout.rows[row.number-1]\n return unless previous_row\n # p1 = {\n # x: row_offset+(width/2),\n # y: number.to_f-(height/2)+height\n # }\n\n previous_row.keys.each_with_index do |key|\n # p2 = {\n # x: (key.row_offset)+(key.width/2),\n # y: next_row.number.to_f-(key.height/2)+key.height\n # }\n\n # len = Math.sqrt( ((p1[:x]-p2[:x]).to_i**2) + ((p1[:y]-p2[:y]).to_i**2) )\n len = distance_to(key)\n if !adj_distance || len < adj_distance\n adjacent = key\n adj_distance = len\n end\n end\n return adjacent\n\n when :below\n return if row.last?\n\n adjacent = nil\n adj_distance = nil\n # find closest on next row\n next_row = row.layout.rows[row.number+1]\n return unless next_row\n # p1 = {\n # x: row_offset+(width/2),\n # y: number.to_f-(height/2)+height\n # }\n\n next_row.keys.each_with_index do |key|\n # p2 = {\n # x: (key.row_offset)+(key.width/2),\n # y: next_row.number.to_f-(key.height/2)+key.height\n # }\n\n # len = Math.sqrt( ((p1[:x]-p2[:x]).to_i**2) + ((p1[:y]-p2[:y]).to_i**2) )\n len = distance_to(key)\n if !adj_distance || len < adj_distance\n adjacent = key\n adj_distance = len\n end\n end\n return adjacent\n\n when :side\n raise NotImplementedError\n else\n raise ArgumentError, \"Unknown direction #{direction.inspect}\"\n end\n end",
"def next_direction #:nodoc:\n loop do\n direction = @tries.pop\n nx, ny = @maze.move(@x, @y, direction)\n\n if @maze.valid?(nx, ny) && (@maze[@x, @y] & (direction | (direction << Maze::UNDER_SHIFT)) == 0)\n if @maze[nx, ny] == 0\n return direction\n elsif [email protected]?(@maze[nx, ny]) && @maze.weave > 0 && rand(100) < @maze.weave\n # see if we can weave over/under the cell at (nx,ny)\n return direction if @maze.weave_allowed?(@x, @y, nx, ny, direction)\n end\n end\n\n while @tries.empty?\n if @stack.empty?\n @pending = false\n return nil\n else\n @x, @y, @tries = @stack.pop\n end\n end\n end\n end",
"def goto_row(row)\n \n set RGhost::Cursor.goto_row(row) \n end",
"def paginate(cursor, opts)\n\n opts = Ruote.keys_to_s(opts)\n\n return cursor.count if opts['count']\n\n cursor.sort(\n '_id', opts['descending'] ? Mongo::DESCENDING : Mongo::ASCENDING)\n\n cursor.skip(opts['skip'])\n cursor.limit(opts['limit'])\n\n from_mongo(cursor.to_a)\n end",
"def next_location(direction)\n @current_location + DIRECTION_VECTORS[direction]\n end",
"def fetch_rows(sql)\n return cursor_fetch_rows(sql){|h| yield h} if @opts[:cursor]\n execute(sql){|res| yield_hash_rows(res, fetch_rows_set_cols(res)){|h| yield h}}\n end",
"def next_row\n @current_row += 1\n end",
"def fetch_buffer(name='csr') #:nodoc:\n return unless @cursors[name][:state] == :empty\n @cursors[name][:result] = execute(\"fetch #{@cursors[name][:buffer_size]} from #{name}\")\n @cursors[name][:buffer] = @cursors[name][:result].collect {|row| row } # result\n @cursors[name][:state] = @cursors[name][:buffer].size > 0 ? :buffered : :eof\n end",
"def read_row\n return if end_of_file?\n\n @current_row = @next_row || _read_row\n @line_number = current_row.nil? ? nil : @line_number + 1\n @next_row = nil\n\n current_row\n end",
"def go_to_next_row()\n turn_left()\n move()\n turn_left()\n end",
"def execute( *bind_vars )\n reset! if active? || done?\n\n bind_params(*bind_vars) unless bind_vars.empty?\n @results = ResultSet.new(@connection, self)\n\n step if 0 == column_count\n\n yield @results if block_given?\n @results\n end",
"def next\n row = pg.execute \"SELECT * FROM events WHERE position = ? AND category = ?\", position, category\n\n position += 1\n\n event_data = Serialize::Read.(row, :postgresql, EventData)\n\n event_data\n end",
"def cursor( *args, & block )\n \n cursor_instance = ::Persistence::Cursor.new( self )\n \n if args.count > 0\n cursor_instance.persisted?( *args )\n end\n \n if block_given?\n cursor_instance = cursor_instance.instance_eval( & block )\n cursor_instance.close\n end\n \n return cursor_instance\n \n end",
"def peek(row, col, direction)\n x, y = [row, col]\n x, y = peek_apply(x, y, direction)\n return 0 unless valid_boundary?(x, y)\n\n begin\n cell = matrix[x][y]\n return 1 if cell == '#'\n return 0 if cell == 'L'\n x, y = peek_apply(x, y, direction)\n end while valid_boundary?(x, y)\n\n 0\n end",
"def fetch(id, client, conn, cursor)\n tputs \"making a request for #{id} cursor: #{cursor}\"\n begin\n fs = client.follower_ids(id, {:cursor => cursor})\n store(fs.ids, id, conn)\n tputs \"Sleeping, length was #{fs.ids.length}\"\n sleep(60)\n rescue Twitter::Error::TooManyRequests => e\n tputs \"Rate limit exceeded, sleeping for #{e.rate_limit.reset_in}\"\n sleep(e.rate_limit.reset_in) \n retry\n end\n if fs.nil?\n return -1\n end\n return fs.next_cursor\nend",
"def next_coordinate(previous, direction)\n case direction\n when 'u'\n [previous[0], previous[1] + 1]\n when 'd'\n [previous[0], previous[1] - 1]\n when 'l'\n [previous[0] - 1, previous[1]]\n when 'r'\n [previous[0] + 1, previous[1]]\n else\n raise 'Incorrect character in direction sequence'\n end\n end",
"def pack_cursor(cursor, options = {})\n \n recordset = []\n column_names = []\n var_cursor = cursor.get_col_names\n \n while current_row = cursor.fetch() \n case options[:return]\n when 'hash'\n current_record = {}\n current_row.each_index{ |index| \n current_record[var_cursor[index]] = current_row[index] \n column_names[index] = var_cursor[index].split('_').join(' ')\n }\n when 'array'\n current_record = []\n current_row.each_index{ |index| \n current_record[index] = current_row[index] \n column_names[index] = var_cursor[index].split('_').join(' ')\n } \n end\n \n recordset.push(current_record)\n end\n \n return recordset, column_names\n end",
"def rows(opts={'start' => nil, 'limit' => nil})\n Cursor.new({'collection' => link('rows'),\n 'start' => opts['start'],\n 'limit' => opts['limit']}.update(@opts))\n end",
"def each(first = 0, last = @rows.count - 1)\n index = first\n while index <= last\n yield(@rows[index], index)\n\n index += 1\n end\n end",
"def next\n\t\t@skip = (@skip || 0) + get_resultcount\n\t\t@result = nil\n\t\treturn self\n\tend",
"def order_by_statement(direction:)\n direction = direction.to_s.upcase\n raise \"Ording direction should be 'asc' or 'desc'\" unless %w[ASC DESC].include?(direction)\n return \"#{degenerate_fragment} #{direction}\" if type == Dimension::TYPES[:degenerate]\n \"#{label_fragment} #{direction}\"\n end",
"def next_row\n raise(\"no more rows available\") unless next?\n self.last_row = self.rows[self.current_row_index]\n self.current_row_index += 1\n\n if self.current_row_index == self.rows.size\n self.rows = nil\n end\n\n self.last_row\n end",
"def track_rows(row_counter)\n column_counter = row_counter\n while row_counter >= 1\n if row_counter % 2 == 0\n print_even_rows(column_counter)\n row_counter -= 1\n elsif row_counter % 2 != 0\n print_odd_rows(column_counter)\n row_counter -= 1\n end\n end\nend",
"def each\n raise ResultsAlreadyConsumedException unless @unread\n\n if block_given?\n @unread = false\n @source.each { |row| yield symbolize_row_keys(row) }\n else\n Enumerator.new(self)\n end\n end",
"def each_row\n return enum_for(__method__) unless block_given?\n yield codec.decode( io ) until io.eof?\n end",
"def fetch_array\n IBM_DB.fetch_array(@stmt) if @stmt\n end",
"def go(direction)\n return @paths[direction]\n end",
"def each_row(q, options = {}, &block)\n current_row = 0\n # repeatedly fetch results, starting from current_row\n # invoke the block on each one, then grab next page if there is one\n # it'll terminate when res has no 'rows' key or when we've done enough rows\n # perform query...\n res = query(q, options)\n job_id = res['jobReference']['jobId']\n # call the block on the first page of results\n if( res && res['rows'] )\n res['rows'].each(&block)\n current_row += res['rows'].size\n end\n # keep grabbing pages from the API and calling the block on each row\n while( current_row < res['totalRows'].to_i && ( res = get_query_results(job_id, :startIndex => current_row) ) && res['rows'] ) do\n res['rows'].each(&block)\n current_row += res['rows'].size\n end\n end",
"def each( & block )\n \n return atomic_cursor.each( & block )\n\n end",
"def turn(direction, cell_selection_block)\n\n\t\[email protected] do |y|\n\n\t\t\ty.each_with_index do |c,i|\n\n\t\t\t\tif cell_selection_block.call(i)\n\t\t\t\t\t# TODO: Push these into a finite state machine\n\t\t\t\t\tif direction.eql? CLOCKWISE\n\t\t\t\t\t\tmodify_status_clockwise(c)\n\t\t\t\t\telsif direction.eql? ANTICLOCKWISE \n\t\t\t\t\t\tmodify_status_anticlockwise(c)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def rewind\n @cursor = 0\n end",
"def goto_matching_bracket_to_the(direction)\n cursor_modifier = { right: 1, left: -1 }[direction]\n initial_cursor = cursor\n nesting = 0\n\n loop do\n case current_instruction\n when \"[\" then nesting += 1\n when \"]\" then nesting -= 1\n end\n\n break if nesting.zero?\n\n begin\n self.cursor += cursor_modifier\n rescue CursorOutOfBoundsError\n raise_bracket_error_at initial_cursor\n end\n end\n end",
"def reverse_each_from_current_pos\n return to_enum(:reverse_each_from_current_pos) unless block_given?\n\n # read the rest of the current line, in case we started in the middle of a line\n start_pos = pos\n fragment = readline rescue \"\"\n seek(start_pos)\n\n while data = reverse_read(4096)\n lines = data.each_line.to_a\n lines.last << fragment unless lines.last[-1] == \"\\n\"\n\n fragment = lines.first\n\n lines[1..-1].reverse_each { |line| yield line }\n end\n\n yield fragment\n end",
"def zscan(key, cursor, **options); end",
"def next?\n unless self.rows\n # Try to load some records\n \n if options[:query] and last_row != nil\n # A query was directly specified and all it's rows were returned\n # ==> Finished.\n return false\n end\n\n if options[:query]\n # If a query has been directly specified, just directly execute it\n query = options[:query]\n else\n # Otherwise build the query\n if last_row\n # There was a previous batch.\n # Next batch will start after the last returned row\n options.merge! :from => last_row, :exclude_starting_row => true\n end\n\n query = connection.table_select_query(options[:table], options)\n\n if options[:row_buffer_size]\n # Set the batch size\n query += \" limit #{options[:row_buffer_size]}\"\n end\n end\n\n self.rows = connection.select_all query\n self.current_row_index = 0\n end\n self.current_row_index < self.rows.size\n end",
"def cursor\n Cursor.new(@meta)\n end",
"def cursor_left(wrap = false)\n if col_max >= 2 && (index % col_max == 0)\n select(index - 1 + col_max)\n elsif col_max >= 2 && (index > 0 || (wrap && horizontal?))\n select((index - 1 + item_max) % item_max)\n end\n end",
"def execute_LOOP(operand)\n\t\tjump_conditionally_to_signed_displacement(operand, !(perform_counting_loop.zero?))\n\tend",
"def next_row\n observation_matrix.observation_matrix_rows.where('position > ?', position).order(:position).first\n end",
"def each_direction(x, y)\n\t\tyield x-1, y if x > 0 #up\n\t\tyield x, y-1 if y > 0 #left\n\t\tyield x, y+1 if @map[x][y+1] #right\n\t\tyield x+1, y if @map[x+1]\n\tend",
"def previous_cursor\n @result[:previous_cursor]\n end",
"def reverse_rows!\n @data = skip_headers &:reverse\n end",
"def each\n # If the caching cursor is closed and was not fully iterated,\n # the documents we have in it are not the complete result set and\n # we have no way of completing that iteration.\n # Therefore, discard that cursor and start iteration again.\n # The case of the caching cursor not being closed and not having\n # been fully iterated isn't tested - see RUBY-2773.\n @cursor = if use_query_cache? && cached_cursor && (\n cached_cursor.fully_iterated? || !cached_cursor.closed?\n )\n cached_cursor\n else\n session = client.send(:get_session, @options)\n select_cursor(session).tap do |cursor|\n if use_query_cache?\n # No need to store the cursor in the query cache if there is\n # already a cached cursor stored at this key.\n QueryCache.set(cursor, **cache_options)\n end\n end\n end\n\n if use_query_cache?\n # If a query with a limit is performed, the query cache will\n # re-use results from an earlier query with the same or larger\n # limit, and then impose the lower limit during iteration.\n limit_for_cached_query = respond_to?(:limit) ? QueryCache.normalized_limit(limit) : nil\n end\n\n if block_given?\n # Ruby versions 2.5 and older do not support arr[0..nil] syntax, so\n # this must be a separate conditional.\n cursor_to_iterate = if limit_for_cached_query\n @cursor.to_a[0...limit_for_cached_query]\n else\n @cursor\n end\n\n cursor_to_iterate.each do |doc|\n yield doc\n end\n else\n @cursor.to_enum\n end\n end",
"def cursor\n @data['cursor']\n end"
] | [
"0.5511997",
"0.5464936",
"0.5221982",
"0.51928717",
"0.51586896",
"0.5156962",
"0.5111007",
"0.51108",
"0.50792515",
"0.5015464",
"0.50079924",
"0.4984491",
"0.48721975",
"0.48582822",
"0.48554346",
"0.48341647",
"0.48302558",
"0.47793752",
"0.4762576",
"0.4760072",
"0.47315904",
"0.47015804",
"0.46953288",
"0.46910775",
"0.46833932",
"0.46637183",
"0.46445256",
"0.46372464",
"0.46371183",
"0.46338686",
"0.4594793",
"0.45917788",
"0.45911238",
"0.45596766",
"0.45514795",
"0.4545451",
"0.45414254",
"0.45369723",
"0.45181754",
"0.45132464",
"0.4510218",
"0.44968462",
"0.44957918",
"0.44844726",
"0.44675174",
"0.44656727",
"0.44480196",
"0.44472438",
"0.44367194",
"0.44150534",
"0.43967584",
"0.43961588",
"0.43930778",
"0.43859985",
"0.43630508",
"0.4361678",
"0.43577358",
"0.43537557",
"0.43508202",
"0.4346784",
"0.4339878",
"0.4318618",
"0.43177623",
"0.43149564",
"0.43017995",
"0.43010134",
"0.42930585",
"0.42901683",
"0.42859662",
"0.4275564",
"0.42717335",
"0.42664912",
"0.42471611",
"0.42449299",
"0.4244346",
"0.42369235",
"0.42368758",
"0.42353165",
"0.42340377",
"0.42315355",
"0.42265865",
"0.422457",
"0.4223839",
"0.42079818",
"0.4206832",
"0.41873202",
"0.41863665",
"0.41826665",
"0.41805834",
"0.4179018",
"0.41778085",
"0.41759133",
"0.41697735",
"0.41683915",
"0.41595364",
"0.4154691",
"0.4153236",
"0.41471907",
"0.41453058",
"0.41407683"
] | 0.73249227 | 0 |
Seek a cursor. Works exactly the same (and takes the same arguments) as fetch, but returns no rows. [direction] See fetch | def move(direction = 'NEXT')
statement = "move #{direction} from #{@name}"
@connection.exec(statement)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_cursor(name='csr')\n raise ArgumentError, \"Cursor #{name} not open\" unless @cursors.has_key?(name)\n fetch_buffer(name) if @cursors[name][:state] == :empty\n return nil if @cursors[name][:state] == :eof\n @cursors[name][:state] = :empty if @cursors[name][:buffer].size <= 1\n row = @cursors[name][:buffer].shift\n row.is_a?(Hash) ? row.symbolize_keys : row\n end",
"def row_seek(n)\n @result.row_seek(n)\n end",
"def rewind\n @cursor = 0\n end",
"def row_seek(n)\n ret = @index\n @index = n\n ret\n end",
"def fetch_cursor(name)\n connection.fetch_cursor(name)\n end",
"def fetch(direction = 'NEXT')\n @select.fetch_by_cursor(@name, direction, @connection)\n end",
"def fetch_row\n if @row_buffer.empty?\n if @done\n return nil\n else\n fetch_more\n end\n end\n\n @row_buffer.shift\n end",
"def next_cursor\n @result[:next_cursor]\n end",
"def advance\n buffer_available_data\n @cursor = @buffer.length\n end",
"def needs_cursor?; end",
"def fetch_buffer(name='csr') #:nodoc:\n return unless @cursors[name][:state] == :empty\n @cursors[name][:result] = execute(\"fetch #{@cursors[name][:buffer_size]} from #{name}\")\n @cursors[name][:buffer] = @cursors[name][:result].collect {|row| row } # result\n @cursors[name][:state] = @cursors[name][:buffer].size > 0 ? :buffered : :eof\n end",
"def data_seek(n)\n @result.data_seek(n)\n end",
"def seek(*rest) end",
"def seek(*rest) end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def cursor_query_for(sql, limit, offset)\n cursor = \"__arel_cursor_#{rand(0xffff)}\"\n\n return <<-eosql\n DECLARE #{cursor} SCROLL CURSOR FOR #{sql} FOR READ ONLY\n SET CURSOR ROWS #{limit} FOR #{cursor}\n OPEN #{cursor}\n FETCH ABSOLUTE #{offset+1} #{cursor}\n CLOSE #{cursor}\n DEALLOCATE #{cursor}\n eosql\n end",
"def seek _value, _type=0\n send_cmd(\"seek #{_value} #{_type}\")\n end",
"def row_tell\n @result.row_tell\n end",
"def cursor!\n cursor(true)\n end",
"def cursor!\n cursor(true)\n end",
"def unbuffered_seek(offset, whence = IO::SEEK_SET)\n unless offset == 0 &&\n ((whence == IO::SEEK_SET && @io.respond_to?(:rewind)) ||\n whence == IO::SEEK_CUR) then\n raise Errno::EINVAL\n end\n\n case whence\n when IO::SEEK_SET\n io.rewind\n initialize_keys\n @total_bytes_out = 0\n when IO::SEEK_CUR\n @total_bytes_out\n end\n end",
"def cursor(*options)\n options = combine_options(*options)\n apply_offset(options)\n @cursor_loc ||= {}\n @cursor_loc[:x] = options[:to][:left]\n @cursor_loc[:y] = options[:to][:top]\n \n compatible_call :cursor, @cursor_loc\n end",
"def cursor\n @data['cursor']\n end",
"def cursor\n @data['cursor']\n end",
"def seek(amount, whence=SEEK_SET)\n #This is a stub, used for indexing\n end",
"def seek\n end",
"def seek\n end",
"def needs_cursor?\n true\n end",
"def cursor_location\n compatible_call :cursor_location\n end",
"def seek(arg0, arg1, *rest)\n end",
"def seek(*args)\n raise ArgumentError, \"no stream\" unless __advance!\n @_st_stream.seek(*args)\n end",
"def cursor\n Cursor.new(@meta)\n end",
"def needs_cursor?\n \ttrue\n end",
"def needs_cursor?\r\n \ttrue\r\n \t end",
"def cursor\n CursorProxy.new(self)\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def unbuffered_seek(offset, whence = IO::SEEK_SET)\n unless offset == 0 &&\n ((whence == IO::SEEK_SET && @io.respond_to?(:rewind)) ||\n whence == IO::SEEK_CUR) then\n raise Errno::EINVAL\n end\n\n case whence\n when IO::SEEK_SET\n @io.rewind\n @total_bytes_out = 0\n when IO::SEEK_CUR\n @total_bytes_out\n end\n end",
"def cursor_home\n @curpos = 0\n @pcol = 0\n set_col_offset 0\n end",
"def rewind(marker)\n raise NotImplementedError\n end",
"def seek(p0) end",
"def unbuffered_seek(offset, whence = IO::SEEK_SET)\n unless offset == 0 &&\n ((whence == IO::SEEK_SET && @io.respond_to?(:rewind)) ||\n whence == IO::SEEK_CUR) then\n raise Errno::EINVAL\n end\n\n case whence\n when IO::SEEK_SET\n @io.rewind\n @total_bytes_in = 0\n when IO::SEEK_CUR\n @total_bytes_in\n end\n end",
"def needs_cursor?\n return true\n end",
"def no_cursor!\n cursor(false)\n end",
"def no_cursor!\n cursor(false)\n end",
"def find_cursor(name, transaction, *findargs)\n count = 0\n begin\n connection.begin_db_transaction if transaction\n open_cursor(name, *findargs)\n while (row = ActiveRecord::Base.fetch_cursor(name)) do\n count+= 1\n yield row\n end\n close_cursor(name)\n ensure\n connection.commit_db_transaction if transaction\n end\n count\n end",
"def rewind\n @offset = 0\n end",
"def sysseek(offset, whence=SEEK_SET) end",
"def read_next()\n return nil if @at_end\n\n begin\n pos = @marker.position\n\n if @marker.character == ?\\n\n pos.line += 1\n pos.column = 0\n end\n\n @marker.character = @reader.next\n @marker.source_index += 1\n pos.column += 1\n rescue StopIteration\n @at_end = true\n @marker.character = nil\n end\n\n @marker.character\n end",
"def cursor(buffer_offset)\n new_cursor = BufferCursor.new(@buffer, buffer_offset)\n new_cursor.push_name(\"space[#{space.name}]\")\n new_cursor.push_name(\"page[#{name}]\")\n\n if block_given?\n # Call the block once and return its return value.\n yield new_cursor\n else\n # Return the cursor itself.\n new_cursor\n end\n end",
"def cursor_fetch_rows(sql)\n server_opts = {:server=>@opts[:server] || :read_only}\n cursor = @opts[:cursor]\n hold = cursor[:hold]\n cursor_name = quote_identifier(cursor[:cursor_name] || 'sequel_cursor')\n rows_per_fetch = cursor[:rows_per_fetch].to_i\n\n db.send(*(hold ? [:synchronize, server_opts[:server]] : [:transaction, server_opts])) do \n begin\n execute_ddl(\"DECLARE #{cursor_name} NO SCROLL CURSOR WITH#{'OUT' unless hold} HOLD FOR #{sql}\", server_opts)\n rows_per_fetch = 1000 if rows_per_fetch <= 0\n fetch_sql = \"FETCH FORWARD #{rows_per_fetch} FROM #{cursor_name}\"\n cols = nil\n # Load columns only in the first fetch, so subsequent fetches are faster\n execute(fetch_sql) do |res|\n cols = fetch_rows_set_cols(res)\n yield_hash_rows(res, cols){|h| yield h}\n return if res.ntuples < rows_per_fetch\n end\n loop do\n execute(fetch_sql) do |res|\n yield_hash_rows(res, cols){|h| yield h}\n return if res.ntuples < rows_per_fetch\n end\n end\n rescue Exception => e\n raise\n ensure\n begin\n execute_ddl(\"CLOSE #{cursor_name}\", server_opts)\n rescue\n raise e if e\n raise\n end\n end\n end\n end",
"def needs_cursor?\n\t\ttrue\n\tend",
"def needs_cursor?\n\t\ttrue\n\tend",
"def each\n @cursor = nil\n session = client.send(:get_session, @options)\n server = cluster.next_primary(nil, session)\n result = send_initial_query(server, session, context: Operation::Context.new(client: client, session: session))\n result = send_fetch_query(server, session) unless inline?\n @cursor = Cursor.new(view, result, server, session: session)\n if block_given?\n @cursor.each do |doc|\n yield doc\n end\n else\n @cursor.to_enum\n end\n end",
"def seek_reverse(amount = opts[:seek_size])\n seek_by(-amount)\n end",
"def fetch(cursor: -1, count: 50, **options)\n cursor, count = cursor.to_i, count.to_i\n window = count + 2 # Fetch extra two elements for concrete next/prev links\n\n if cursor >= 0\n page = @scope.where(@cursor_key => -Float::INFINITY..cursor).limit(window)\n else\n cursor = cursor == -1 ? 0 : cursor.abs\n page = @scope.where(@cursor_key => cursor..Float::INFINITY).limit(window)\n end\n\n # Ensure result set is in correct order\n page = page.order(@cursor_key => :desc)\n\n Page.new(page, cursor, count: count)\n end",
"def row_tell\n @index\n end",
"def move_to_start\n @cursor = 0\n end",
"def move_to_start\n @cursor = 0\n end",
"def check_cursor!\n @current_cursor or raise NoCursor.new(\"You have not defined anything to work with!\")\n end",
"def seek(x); @_io.seek(x); end",
"def seek(new_position)\n end",
"def next\n return nil unless next?\n return nil if end_cursor.nil?\n ensure_service!\n query.start_cursor = cursor.to_grpc # should always be a Cursor...\n query.offset = 0 # Never carry an offset across batches\n unless query.limit.nil?\n # Reduce the limit by the number of entities returned in the current batch\n query.limit.value -= count\n end\n query_res = service.run_query query, namespace, read_time: read_time\n self.class.from_grpc query_res, service, namespace, query, read_time\n end",
"def cursor\n relation = add_params(cursorMark: '*')\n\n # Sort must include a sort on unique key (id).\n if /\\bid\\b/ =~ params[:sort]\n relation\n else\n relation.sort(params[:sort], 'id ASC')\n end\n end",
"def select_cursor(options)\n cursor = ResultFetcher.new(self, options)\n unless options[:type_cast] == false\n cursor = TypeCastingCursor.new(self, options[:table], cursor)\n end\n cursor\n end",
"def needs_cursor?\n return true\n end",
"def each\n # If the caching cursor is closed and was not fully iterated,\n # the documents we have in it are not the complete result set and\n # we have no way of completing that iteration.\n # Therefore, discard that cursor and start iteration again.\n # The case of the caching cursor not being closed and not having\n # been fully iterated isn't tested - see RUBY-2773.\n @cursor = if use_query_cache? && cached_cursor && (\n cached_cursor.fully_iterated? || !cached_cursor.closed?\n )\n cached_cursor\n else\n session = client.send(:get_session, @options)\n select_cursor(session).tap do |cursor|\n if use_query_cache?\n # No need to store the cursor in the query cache if there is\n # already a cached cursor stored at this key.\n QueryCache.set(cursor, **cache_options)\n end\n end\n end\n\n if use_query_cache?\n # If a query with a limit is performed, the query cache will\n # re-use results from an earlier query with the same or larger\n # limit, and then impose the lower limit during iteration.\n limit_for_cached_query = respond_to?(:limit) ? QueryCache.normalized_limit(limit) : nil\n end\n\n if block_given?\n # Ruby versions 2.5 and older do not support arr[0..nil] syntax, so\n # this must be a separate conditional.\n cursor_to_iterate = if limit_for_cached_query\n @cursor.to_a[0...limit_for_cached_query]\n else\n @cursor\n end\n\n cursor_to_iterate.each do |doc|\n yield doc\n end\n else\n @cursor.to_enum\n end\n end",
"def rewind() end",
"def rewind() end",
"def rewind() end",
"def rewind() end",
"def consume_seek(pos)\n orig = consume_pos\n if pos < 0\n pos = consume_pos + pos\n pos = 0 if pos < 0\n end\n @consume_pos = pos\n orig\n end",
"def seek(amount, whence=SEEK_SET) end",
"def first\n @cursor_instance.jump( nil )\n return current\n end",
"def cur_pos\n @cursor.pos\n end",
"def cursor_dn\n @cursor_movement = :down\n @old_cursor = @cursor\n move_to(pos + 1)\nend",
"def cursor_position!\n Vedeu.bind(:_cursor_position_) do |name|\n Vedeu.cursors.by_name(name).position\n end\n end",
"def _restore_cursor\n\t\tfalse\n\tend",
"def record_cursor(offset = :min, direction = :forward)\n RecordCursor.new(self, offset, direction)\n end",
"def fetch\n @fetched_record = nil\n return nil if @index >= @records.size\n rec = @records[@index]\n @index += 1\n @fetched_record = rec\n return rec\n end",
"def next_row\n @rows+=1\n set RGhost::Cursor.next_row\n end",
"def rewind()\n #This is a stub, used for indexing\n end",
"def cursor_pagedown\n @mode = (@mode + 1) % TABLE.size\n refresh\n end",
"def seek(amount, whence=IO::SEEK_SET)\n #This is a stub, used for indexing\n end",
"def mqlread_with_cursor(query, cursor, options={})\n params = { :query => query.to_json, :lang => \"/lang/#{@query_options[:lang]}\", :limit => @query_options[:limit], :cursor => cursor }.merge(options)\n response = get(surl('mqlread'), params, format: :json)\n {result: response['result'], cursor: response['cursor']}\n end",
"def run_cursor_loop(connection, &block)\n Backfiller.log 'Start cursor loop'\n\n total_count = 0\n cursor = build_cursor(connection)\n\n loop do\n finished, count = cursor.transaction do\n run_fetch_loop(cursor, &block)\n end\n\n total_count += count\n\n Backfiller.log \"Total processed #{total_count}\"\n break if finished\n end\n end",
"def read(record, cursor)\n return :NULL if null?(record)\n cursor.name(type.name) { type.reader.read(record, cursor, length(record)) }\n end",
"def next\n @opened && @cur_record_index < @num_records ? _read_next_record : nil\n end",
"def cursor\n Cursor.new(self)\n end",
"def f_cursor\n Cursor.new(\n b_each.inject(Null) { |l, data| Node.new data, l },\n Null\n )\n end"
] | [
"0.6839038",
"0.68363667",
"0.64847374",
"0.6125492",
"0.6078486",
"0.60313755",
"0.60069907",
"0.6002099",
"0.59740347",
"0.5952101",
"0.59491396",
"0.5930051",
"0.5923871",
"0.5923134",
"0.57552224",
"0.57552224",
"0.57552224",
"0.57552224",
"0.57552224",
"0.57552224",
"0.57552224",
"0.56752825",
"0.56690484",
"0.5667798",
"0.5646925",
"0.5646925",
"0.56324005",
"0.562077",
"0.5606297",
"0.5606297",
"0.5599065",
"0.5587105",
"0.5587105",
"0.558087",
"0.5571344",
"0.5565982",
"0.5556091",
"0.5533239",
"0.5533089",
"0.55226713",
"0.54956055",
"0.54862595",
"0.54862595",
"0.54862595",
"0.54862595",
"0.54862595",
"0.54862595",
"0.54862595",
"0.54805076",
"0.5472966",
"0.547069",
"0.5470103",
"0.5460822",
"0.54291797",
"0.5427928",
"0.5427928",
"0.5417313",
"0.53957725",
"0.5381264",
"0.53753096",
"0.53705287",
"0.53601635",
"0.53509694",
"0.53509694",
"0.5345755",
"0.5344941",
"0.5337575",
"0.5336896",
"0.5318012",
"0.5318012",
"0.5316632",
"0.53067386",
"0.5306368",
"0.5306235",
"0.5303319",
"0.53031886",
"0.53010714",
"0.5295519",
"0.5294018",
"0.5294018",
"0.5294018",
"0.5294018",
"0.529327",
"0.5281411",
"0.5279144",
"0.52734405",
"0.5273084",
"0.527172",
"0.5267797",
"0.526408",
"0.5255713",
"0.52491826",
"0.52461153",
"0.5244988",
"0.524353",
"0.5237376",
"0.5231557",
"0.5230629",
"0.52259135",
"0.5206359",
"0.5188848"
] | 0.0 | -1 |
Close the cursor. Once closed, it may not be closed or fetched from again. | def close
statement = "close #{@name}"
@connection.exec(statement)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close\n unless closed?\n begin\n @cursor.close\n rescue Error::OperationFailure, Error::SocketError, Error::SocketTimeoutError, Error::MissingConnection\n # ignore\n end\n @cursor = nil\n end\n end",
"def close_cursor(name)\n connection.close_cursor(name)\n end",
"def close\n if open? then\n @stmt_api.close\n @open = false\n end\n end",
"def close_cursor(name='csr')\n pg_result = execute(\"close #{name}\")\n @cursors.delete(name)\n end",
"def closed?\n @cursor.nil?\n end",
"def dispose\n if @cursor != nil\n @cursor.bitmap.dispose if @cursor.bitmap != nil\n @cursor.dispose\n @cursor = nil\n end\n super\n end",
"def close_query\n invoke_unlimited_cross(:close_query)\n nil\n end",
"def close\n @stmt.close\n end",
"def close\n SQLite::API.close( @handle )\n @closed = true\n end",
"def close\n @stmt.close\n end",
"def close()\n @closed = true\n end",
"def close\n @closed = true\n end",
"def close()\n #This is a stub, used for indexing\n end",
"def close\n @tc_bdb.close\n @tc_bdbcur = nil\n end",
"def cursor_close_test(read=:primary)\n insert_docs\n 10.times do\n cursor = @coll.find({}, :read => read)\n cursor.next\n assert cursor.instance_variable_get(:@pool)\n assert cursor.alive?\n cursor.close\n end\n end",
"def close\n lib.tcidbclose( @db ) || raise_error\n\n lib.tcidbdel( @db )\n\n @db = nil\n end",
"def destroy_cursor(cursor)\n cursor.destroy\n cursors.delete cursor\n end",
"def close\n @closed = true\n end",
"def closed\n @closed = true\n end",
"def close()\n @db.close()\n end",
"def close\n #import\n @insert_point.close if !@insert_point.nil?\n @check_md5.close if !@check_md5.nil?\n @insert_md5.close if !@insert_md5.nil?\n #export\n @export_point_page.close if !@export_point_page.nil?\n @export_point_all.close if !@export_point_all.nil?\n @db.close\n end",
"def close\n @mysql.close\n @mysql = nil\n end",
"def close\n\n @db.connection.close\n end",
"def close\n commit\n end",
"def close\n closed_status = get_closed_status\n return if closed_status.nil?\n self.status = closed_status\n result = self.save\n\n end",
"def close\n @closed = true\n @on_close and @on_close.call\n end",
"def close\n @db.close\n end",
"def close\n IBM_DB.close(@conn)\n end",
"def close\n @ole_connection.Close\n end",
"def close\n @conn.close if @conn && [email protected]?\n @conn = nil\n end",
"def close_connection\n @db.close if @db\n end",
"def close\n @db.close if @db && !(@db.closed?)\n self\n end",
"def close\n @conn.disconnect\n end",
"def close\n copy self.class.close(@id)\n true\n end",
"def close\n # by default do nothing - close any cached connections\n end",
"def close\n @conn.close\n end",
"def closed\n self\n end",
"def close()\n\t\[email protected]\n\t\t@connection = nil\n\tend",
"def close\n\t\[email protected]\n\tend",
"def close() end",
"def close() end",
"def close() end",
"def close() end",
"def close() end",
"def close\n @my.close if @my != nil\n return (@my = nil)\n end",
"def close\n @my.close if @my != nil\n return (@my = nil)\n end",
"def close\n @secondary.close rescue nil\n end",
"def close\n\n # nothing to do here.\n end",
"def close\n\t\t\[email protected]\n\t\tend",
"def close\n close_reader\n close_writer\n end",
"def close\n\t\tself.status = 'closed'\n\t\tself.save\n\tend",
"def closed\n end",
"def close\n # this method may be left unimplemented if that is applicable\n end",
"def close\n @mutex.synchronize { @conn.close }\n end",
"def close\n @mutex.synchronize { @conn.close }\n end",
"def close\n # don't need to close\n end",
"def close\n return if closed?\n _data[:closed] = true\n _data[:on_close].call unless _data[:on_close].nil?\n closing\n end",
"def close\n # this method may be left unimplemented if that is applicable\n end",
"def close\n #active record should do our connections for us so just set to nil\n @connection = nil\n # Remove this connection from the list of open connections.\n #@@open_connection = @@open_connections.reject { |c| c[:db_url] == @db_url }\n Log.instance.debug \"Disconnected from #@db_url\"\n end",
"def close\n return if @conn.nil?\n @conn.close\n @conn = nil\n end",
"def close #:nodoc:#\n update\n end",
"def close\n close!\n end",
"def close\n inactive!\n close_connections\n end",
"def closeDBConn()\n if ( !@db_conn.nil? )\n begin\n @db_conn.finish()\n rescue Exception => e\n #ignore it\n end\n end\n end",
"def closed?; end",
"def closed?; end",
"def closed?; end",
"def closed?; end",
"def close\n update\n end",
"def close\n update\n end",
"def close\n update\n end",
"def close\n flush rescue nil\n sysclose\n end",
"def close\n @reader.close\n end",
"def connection_closed\n close\n end",
"def close()\n @connection.disconnect\n @connection = nil\n end",
"def close!\n safe_close\n end",
"def close\r\n\t\[email protected]\r\n\tend",
"def close\n if @connection\n @connection.close unless @connection.closed?\n end\n @connection = nil\n end",
"def cursor( *args, & block )\n \n cursor_instance = ::Persistence::Cursor.new( self )\n \n if args.count > 0\n cursor_instance.persisted?( *args )\n end\n \n if block_given?\n cursor_instance = cursor_instance.instance_eval( & block )\n cursor_instance.close\n end\n \n return cursor_instance\n \n end",
"def close!\n\t\t\t\t@state = :closed\n\t\t\t\t\n\t\t\t\treturn self\n\t\t\tend",
"def _close\n end",
"def cursor!\n cursor(true)\n end",
"def cursor!\n cursor(true)\n end",
"def close\n @data.close\n @index.close\n end",
"def close\r\n @peek_buffer = nil\r\n reset_read_point\r\n end",
"def close( &block )\n compile!( :close!, &block )\n end",
"def close\n if self.conn && !self.conn.closed?\n self.conn.shutdown\n self.conn.close\n end\n\n self.conn = nil\n end",
"def close\n # no-op\n end",
"def close\n @conn.close\n super\n end",
"def close() \n @my.close()\n @my = nil\n end",
"def close\n Common.uncontain\n self\n end",
"def close\n close_data_file\n end",
"def close\n return unless @_context\n XDo::FFILib.xdo_free @_pointer\n @_pointer = nil\n @_context = nil\n end",
"def close\n close_connection(CLOSED, true)\n end",
"def close\n SAP_LOGGER.debug(\"In #{self.class} close ...\")\n\t \t return nil unless self.handle\n SAP_LOGGER.debug(\"In #{self.class} handle: #{self.handle} ...\")\n res = self.handle.close()\n\t\t \tself.handle = nil\n\t\t\t\t# XXX Should destroy all cached functions and structures and types tied to handle ?\n\t\t \treturn true\n\t\t end",
"def close\n SAP_LOGGER.debug(\"In #{self.class} close ...\")\n\t \t return nil unless self.handle\n SAP_LOGGER.debug(\"In #{self.class} handle: #{self.handle} ...\")\n res = self.handle.close()\n\t\t \tself.handle = nil\n\t\t\t\t# XXX Should destroy all cached functions and structures and types tied to handle ?\n\t\t \treturn true\n\t\t end",
"def close\n # NOOP\n end",
"def close\n # NOOP\n end",
"def close\n self\n end",
"def close\n SLPClose(@handle)\n end"
] | [
"0.84778374",
"0.7345591",
"0.7089643",
"0.70257",
"0.6966311",
"0.66885644",
"0.66645443",
"0.66612524",
"0.6630109",
"0.65949523",
"0.63304836",
"0.63301367",
"0.6291665",
"0.6271475",
"0.6257681",
"0.6191767",
"0.61739504",
"0.6173155",
"0.6161096",
"0.6143233",
"0.61297095",
"0.61254245",
"0.6120104",
"0.6107696",
"0.6105248",
"0.61004096",
"0.60959333",
"0.6090825",
"0.608732",
"0.6074524",
"0.6071264",
"0.60563785",
"0.6056189",
"0.6037808",
"0.6024334",
"0.6002483",
"0.5984965",
"0.59721506",
"0.5964411",
"0.5962641",
"0.5962641",
"0.5962641",
"0.5962641",
"0.596136",
"0.5958427",
"0.5958427",
"0.5945025",
"0.5933057",
"0.5930711",
"0.5927499",
"0.5927398",
"0.5922896",
"0.5920301",
"0.5917261",
"0.5917261",
"0.5912267",
"0.59097534",
"0.59035146",
"0.589937",
"0.58991987",
"0.5882818",
"0.58825105",
"0.58815485",
"0.5878985",
"0.58762366",
"0.58762366",
"0.58762366",
"0.58762366",
"0.5870891",
"0.5870891",
"0.5870891",
"0.5866768",
"0.58578485",
"0.58550626",
"0.58523357",
"0.58453846",
"0.58437985",
"0.5832728",
"0.58273584",
"0.5817795",
"0.581478",
"0.5813171",
"0.5813171",
"0.5811746",
"0.5804483",
"0.580447",
"0.57957315",
"0.5792535",
"0.57916355",
"0.5781548",
"0.5778332",
"0.57766306",
"0.5772819",
"0.5772604",
"0.57717335",
"0.57717335",
"0.57664925",
"0.57664925",
"0.5757805",
"0.57485735"
] | 0.62928873 | 12 |
total weight in oz | def total_weight
order_items.collect { |oi| oi.weight }.inject { |sum, x| sum + x } || 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_total_weight\n 0\n end",
"def total_weight\r\n\t\[email protected](0.0) { |sum, i| sum + i.total_unit_weight * i.quantity }\r\n\tend",
"def total_unit_weight\r\n\t\ttotal = self.unit_weight\r\n\r\n\t\tliovs = self.line_item_option_values\r\n\t\tliovs.each do |cur_liov|\r\n\t\t\ttotal += cur_liov.extra_weight\r\n\t\tend\r\n\r\n\t\ttotal\r\n\tend",
"def total_unit_weight\r\n\t\ttotal = self.unit_weight\r\n\r\n\t\tliovs = self.line_item_option_values\r\n\t\tliovs.each do |cur_liov|\r\n\t\t\ttotal += cur_liov.extra_weight\r\n\t\tend\r\n\r\n\t\ttotal\r\n\tend",
"def total_weight\n order_items.inject(BigDecimal(0)) { |t,i| t + i.total_weight}\n end",
"def weight\n 2 # ounces\n end",
"def compute_weight object\n object.line_items.map { |li| (li.variant.weight || 0) * li.quantity }.sum\n end",
"def total_weight\n line_items.map(&:weight).sum\n end",
"def weight\n @mass * @hopper.size\n end",
"def total_weight(order)\n weight = 0\n order.line_items.each do |line_item|\n line_item.variant.weight ? weight += (line_item.quantity * line_item.variant.weight) : 0\n end\n weight\n end",
"def weight_in_stones\n\t\t((@weight * 2.20462) / 14).to_i\n\tend",
"def weight\n if @weight\n @weight\n else\n @confines.length\n end\n end",
"def weight\n if @weight\n @weight\n else\n @confines.length\n end\n end",
"def unit_weight\n (unit_area * product_thickness * 2.5).round(2)\n end",
"def weight; end",
"def weight\n\t\tweight = 0\n\t\tself.order_line_items.each do |item|\n\t\t\tweight += item.quantity * item.product.weight\n\t\tend\n\t\treturn weight\n\tend",
"def weight\n self.ingredients.map{|i| i.quantity}.reduce(:+)\n end",
"def weight\n sides.map(&:weight).reduce(&:+)\n end",
"def weight\n 0\n end",
"def product_weight\n price_calculator.weight\n end",
"def weight\n return @weight\n end",
"def calculate_weight\n update_attribute :weight, votes.sum(:value)\n weight\n end",
"def total_owed_amount(ower)\n return data[ower] ? data[ower].values.reduce(:+) : 0\n end",
"def prom_weight\n if pet_histories.length > 0\n promw= pet_histories.sum(:weight)\n promw/pet_histories.length\n else\n \"0\"\n end\n end",
"def weight\n product_weight * quantity\n end",
"def weight\n product_weight * quantity\n end",
"def weight\n order_lines.inject(0) { |sum, l| sum + l.weight }\n end",
"def weight\n @weight || @confines.length\n end",
"def weight\n return data.weight\n end",
"def calc_total_weight_to_s\n calc_total_weight.to_s\n end",
"def total_votes\n votes.sum(:weight)\n end",
"def test_total_weight\n assert_equal(0 , @wp00.total_weight)\n assert_equal(384, @wp01.total_weight)\n assert_equal(576, @wp02.total_weight)\n end",
"def wealth\n @gold + inventory_worth\n end",
"def total_weight\n\t\tif catogery_id == 1\n\t\t\tfomular_1 * amount_qty\n\t\telsif category_id == 2\n\t\t\tfomular_2 * amount_qty\n\t\telsif category_id == 3\n\t\t\tfomular_3 * amount_qty\n\t\telse\n\t\t\t0\n\t\tend\n\tend",
"def total_worth\n find_amount = funding_rounds.map{|funding| funding.investment}\n find_amount.inject{|sum, el| sum + el}\n end",
"def get_total_weight(order)\n return 0 unless order.present? and order.line_items.present?\n line_item_weights = order.line_items.map {|item| item.quantity * (item.variant.weight || Spree::EmsShipping::Config[:weight_if_nil])}\n if line_item_weights.include?(0)\n return 0\n else\n return line_item_weights.sum / 1000.00\n end\n end",
"def shipping_cost_based_on_weight\n shipping_weight_price total_weight\n end",
"def cost_of_stay\n num_of_nights * 200.00\n end",
"def weight\n if box\n box.weight * self.quantity\n else\n raise \"Weight not known.\"\n end\n end",
"def bmi\n ( weight.to_f / ( (height.to_f)**2 ) ) * 703.0\n end",
"def get_total_weight(line_items)\n line_items.map do |li|\n # use default item weight if the weight is not defined for a product\n item_weight = li.variant.weight.nil? ? self.preferred_default_item_weight : li.variant.weight\n item_weight * li.quantity\n end.sum\n end",
"def get_total_weight(line_items)\n line_items.map do |li|\n # use default item weight if the weight is not defined for a product\n item_weight = li.variant.weight.nil? ? self.preferred_default_item_weight : li.variant.weight\n item_weight * li.quantity\n end.sum\n end",
"def weight\n return nil if mass.nil?\n mass / 1000.0\n end",
"def calc_total_weight\n @weight + @node_link.calc_total_weight\n end",
"def get_total_weight(line_items)\n line_items.map do |li|\n # use default item weight if the weight is not defined for a product\n item_weight = li.variant.weight.nil? ? self.preferred_default_item_weight : li.variant.weight\n item_weight * li.quantity\n end.sum\n end",
"def rounded_weight\n @atomic_mass.round(4)\n end",
"def calculate_calories(bodyweight)\n\ttotal_calories = bodyweight * 13\n\treturn total_calories\nend",
"def molecular_weight\n @mw ||= begin\n mass = WATER_MASS\n each_aa do |aa|\n mass += AVERAGE_MASS[aa.to_sym]\n end\n (mass * 10).floor().to_f / 10\n end\n end",
"def test_return_total_weight\n calculated_weight = 0\n @order.order_line_items.each do |item|\n calculated_weight += item.quantity * item.product.weight\n end\n assert_equal @order.weight, calculated_weight\n end",
"def measure() @measure ||= (nb_weight == 0.0 ? 0.0 : sum_weight / nb_weight) end",
"def cost\n @beverage.cost + 0.10\n end",
"def cost\n @beverage.cost + 0.10\n end",
"def cost\n @beverage.cost + 0.20\n end",
"def weight()\n\t\t@pokemon_api[\"weight\"]\n\tend",
"def total_weight(dimensions)\n volumetric_weight = (dimensions['width'] * dimensions['height'] * dimensions['length']) / 5000\n volumetric_weight > dimensions['weight'] ? volumetric_weight : dimensions['weight']\n end",
"def box_weight_sum\n num1 = @quantity_per_box\n num2 = @item_weight\n sum = num1 * num2\n sum.round(2)\n end",
"def price_per_g\n\t\tself['price'].to_f / self['unit_weight'].to_f\n\tend",
"def mark_up_amt\n rounder5(self.vehicle.price * 0.082)\n end",
"def number_of_kcal_per_meal\n kcal_per_recipe = recipe_ingredients.each.sum do |recipe_ingredient|\n calories_per_gram = recipe_ingredient.ingredient.calories / 100 \n kilograms_of_ingredient = recipe_ingredient.calculated_weight_in_grams / 1000\n (calories_per_gram * kilograms_of_ingredient) #kcal\n end\n kcal_per_recipe / num_people\n end",
"def total_energy\n potential_energy * kinetic_energy\n end",
"def cost\n @beverage.cost + 0.15\n end",
"def total_cost\n ingredients_cost + components_cost\n end",
"def total_water\r\n t = 0\r\n @positions.each_with_index do | p,index |\r\n\t t += p.water_content\r\n\t t += p.water_bank\r\n\tend\r\n\tt\r\n end",
"def query_all_weight\n d = 0 \n eqs = query_all_wearings\n p \"=>wearing=#{eqs.inspect}\"\n eqs.each {|k,v|\n d+= v.weight if v\n }\n return d\n end",
"def total_cost\n self.ingredients.map{ | ing | ing.cost_per_unit * ing.quantity } .reduce(&:+).round(2)\n end",
"def weightedsum\n ws = 0\n @inputs.each_index { |i| ws = ws + @inputs[i]*@weights[i] }\n ws\n end",
"def total_sodium\n food.sodium * quantity\n end",
"def convert_lbs_to_kg(weight)\n weight * 0.45\nend",
"def cost\n 0.89\n end",
"def total_upvotes\n\t\tself.get_upvotes.sum(:vote_weight)\n\tend",
"def moneys_total\n moneys_total = 0\n mini_map_cells.each do |cell|\n moneys_total += cell.terrain.money\n moneys_total += cell.sp_resource.money unless cell.sp_resource.blank?\n moneys_total += cell.construction.money unless cell.construction.blank?\n end\n return moneys_total\n end",
"def get_total_wages\n self.get_base_wages + self.get_manager_wages\n end",
"def amount_owed\n total_price - amount_paid\n end",
"def character_weight\n total_weight = 0\n items = Inventory.where(character_id: self.id)\n items.each do |i|\n x = Equipment.find(i.equipment_id).weight\n total_weight += x if x \n end\n total_weight\n end",
"def total_benefits_value\n benefits.map{|b| b.total_value_cents}.reduce(:+).to_i\n end",
"def net_worth\n result = self.cash_on_hand\n self.holdings.each do |holding|\n share_price = holding.company.share_price\n result += share_price * holding.amount\n end\n @net_worth = result\n end",
"def total_servingSize\n food.servingSize * quantity\n end",
"def weight\n (kyc_level == 'any' ? 0 : 10) + (group == 'any' ? 0 : 1)\n end",
"def calculated_wounds\n wound_th = brawn\n wound_th += race.wound_threshold if race && race.wound_threshold\n # Then increase based on selected talents.\n talent_alterations.each do |_talent_id, stat|\n stat.each do |type, value|\n wound_th += value if type == :wound\n end\n end\n wound_th\n end",
"def total_kg_ch4\n\t\t(calculations.collect(&:calc_kg_ch4).sum).round 2\n\tend",
"def totalMeters\n (self.floor_width*self.floor_length)\n end",
"def total_charged\n return self.trips.sum(&:cost)\n end",
"def bmi_calc height, weight\n return (weight / height**2).to_i\nend",
"def currentWeight() weighins.last.weight end",
"def total_fuel_gallons\n self.inject(0) do |accum,trip|\n accum += trip.fuel_volume_gal\n accum\n end\n end",
"def weight\n options.reduce(0) { |memo, option| option.weight > 0 ? memo + option.weight : memo }\n end",
"def total_cost\n \tingredients_cost + components_cost\n end",
"def weight_in_words\n wt_kg = self.E16_01.to_f # in kg\n wt_lb = self.E16_88.to_f\n wt_in_lbs = wt_lb > 0 ? wt_lb : wt_kg*2.20462262\n \"%s lbs - %d kg\" % [((wt_in_lbs < 100) ? wt_in_lbs.round(1) : wt_in_lbs.round), wt_kg]\n end",
"def weighted_score\n score * metric.weight\n end",
"def baserunning_total\n self.rating_15 + \n self.rating_16 +\n self.rating_17 +\n self.rating_18\n end",
"def gear_inches\n ratio * wheel.diameter\nend",
"def weight_watchers(hash)\n calories_count = 0\n hash.each do |k, v|\n calories_count = v * CALORIES[k] + calories_count\n end\n return calories_count\nend",
"def total_weight(items, list, *rest)\n\t\ttotal_weight = 0\n\t\t# sorts the lists by price and takes the first \"items\" elements and sums weight and price\n\t\tlist.sort_by{ |key, value| value[0].to_f }[0..items].each{ |key, value| total_weight += value[1].to_i }\n\t\trest.each{|list| list.sort_by{ |key, value| value[0].to_f }[0..items].each{ |key, value| total_weight += value[1].to_i }} \n\t\tputs \"Total Weight:\\t#{total_weight}g\"\n\tend",
"def goods_produced\n (0.2 * base_production + trade_goods_bonus).round(6)\n end",
"def total; end",
"def measurement_weight\n [\n ['ounce'],\n ['pounds']\n ]\n end",
"def total_digestate_phosphorus\n\t\t(calculations.collect(&:calc_digestate_phosphorus).sum).round 3\n\tend",
"def total_cost_for_stay\n number_of_nights? * 200\n end",
"def total\n # extracts all of the values from the hash and sums them up\n cost = @products.values.sum\n # add 7.5% tax and round to two decimal places\n return (cost * 1.075).round(2)\n end",
"def cost\r\n 0\r\n end"
] | [
"0.79434305",
"0.776738",
"0.7549141",
"0.7549141",
"0.74904346",
"0.7430893",
"0.73799187",
"0.7308074",
"0.727979",
"0.7236678",
"0.72099614",
"0.7193675",
"0.7193675",
"0.71743006",
"0.7152409",
"0.71154964",
"0.7067407",
"0.70575905",
"0.7048079",
"0.70345867",
"0.70182014",
"0.6971918",
"0.69617134",
"0.69587165",
"0.69489956",
"0.69489956",
"0.68991446",
"0.6837288",
"0.67989874",
"0.6777563",
"0.6762703",
"0.6754234",
"0.67365444",
"0.6730838",
"0.67071676",
"0.66898686",
"0.6656486",
"0.66489685",
"0.6611247",
"0.6606028",
"0.6602999",
"0.6602999",
"0.6597438",
"0.65796477",
"0.6576599",
"0.65748924",
"0.65747005",
"0.65739787",
"0.6572165",
"0.6571848",
"0.65470266",
"0.65470266",
"0.6541595",
"0.6523671",
"0.6515277",
"0.6513216",
"0.65056753",
"0.6503004",
"0.64907724",
"0.6485544",
"0.6485134",
"0.64769447",
"0.64598846",
"0.64587516",
"0.64569104",
"0.6453791",
"0.644367",
"0.6437463",
"0.6437156",
"0.64357513",
"0.643346",
"0.6419346",
"0.64187175",
"0.6417262",
"0.6409731",
"0.63997364",
"0.63974214",
"0.63920027",
"0.6381794",
"0.6379307",
"0.6368331",
"0.63476944",
"0.6343204",
"0.63347054",
"0.63282204",
"0.63244295",
"0.6323979",
"0.63161594",
"0.6310338",
"0.6307983",
"0.6299693",
"0.6284941",
"0.627977",
"0.6278846",
"0.6275778",
"0.6274601",
"0.62720394",
"0.626925",
"0.62607",
"0.62540483"
] | 0.75848323 | 2 |
take an ID to use as key | def find(id)
@store.transaction do
#return movie object stored under this key
@store[id]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id\n key\n end",
"def key\n raise MissingID if not defined?(@id)\n model.key[id]\n end",
"def key\n id\n end",
"def to_key # :nodoc:\n id\n end",
"def cache_key(id); end",
"def key_id; end",
"def get_key(id)\n @keys[id]\n end",
"def get_key(id)\n if @identity_map.has_key? id\n @identity_map[id]\n end\n end",
"def key_id=(_arg0); end",
"def to_key\n [id.to_s]\n end",
"def id_from_key(key)\n @key_to_id[key]\n end",
"def key\n self.id\n end",
"def key\n self.id\n end",
"def key\n self.id\n end",
"def to_key\n key = id\n [key] if key\n end",
"def key\n @key.id2name\n end",
"def id\n key = self.key\n key.first if key.size == 1\n end",
"def key_id=(value)\n @key_id = value\n end",
"def key_id=(value)\n @key_id = value\n end",
"def key_id=(value)\n @key_id = value\n end",
"def to_key\n [id]\n end",
"def id\n key?(:id) ? method_missing(:id) : nil\n end",
"def id\n @hash[\"id\"]\n end",
"def id\n @hash['id']\n end",
"def key_for(node)\n \"#{id}-#{node.id}\"\n end",
"def add_id\n @item.key = @bib.id\n end",
"def idkey\n post('/api/1/generic/idkey')\n end",
"def redis_key_for(id)\n \"#{redis_prefix}:#{Array(id).join(':')}\"\n end",
"def record_key_for_dom_id(record); end",
"def hash_key\n options[:key] || :id\n end",
"def hash_key\n options[:key] || :id\n end",
"def to_key\n _persisted_obj ? [id] : nil\n end",
"def key_name\n \"#{prefix}:#{@id}\"\n end",
"def default_key\n :\"#{self[:name]}_id\"\n end",
"def initialize(id, key='')\n @_id = id\n @_key = key\n end",
"def default_key\n :\"#{self[:name]}_id\"\n end",
"def lookup_id(arg)\n all_by_id[arg]\n end",
"def id_hash_generator(number)\n{:id => number }\nend",
"def group_key(id)\n nil\n end",
"def to_key\n [object_id]\n end",
"def dataset_key\n :id\n end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def to_key\n new? ? [] : [id]\n end",
"def map_key(key)\n key\n end",
"def get_key record\n record\n end",
"def hash\n @id\n end",
"def to_key\n new? ? [] : [id]\n end",
"def hash\n id\n end",
"def id\n @__metadata__.key || @id\n end",
"def key_id\n return @key_id\n end",
"def key_id\n return @key_id\n end",
"def key_id\n return @key_id\n end",
"def key(list_id)\n key_format % list_id\n end",
"def primary_key\n 'id'\n end",
"def get_cache_key(id)\n memcache_key_object.key_template % @options.merge(id: id)\n end",
"def get_cache_key(id)\n memcache_key_object.key_template % @options.merge(id: id)\n end",
"def id\n self['id']\n end",
"def id\n self['id']\n end",
"def get id\n @map[id] || (raise \"#{id} not registered\")\n end",
"def identifier_map(id, name, id_map)\n if !id_map.include? id\n id_map[id] = name\n end \nend",
"def id\n read_attr :id, :to_sym\n end",
"def id\n return self[:id]\n end",
"def key\n \"User:#{@id}\"\n end",
"def id_key_for(model_class)\n get_key('ID_KEY', model_class) + '_id'\n end",
"def _hashback_id_key\n self.__send__(self.class.__send__(:class_variable_get, :@@_key_method_sym))\n end",
"def key(name = nil)\n \"#{@id}:#{name}\"\n end",
"def _key(*args); args.hash; end",
"def key\n @key ||= name.to_s\n end",
"def make_name_to_id\n build_hash('name', 'id')\n end",
"def set_key\n @key = Key.find(params[:id])\n end",
"def identifier(id)\n Registry.add(id.to_s, self)\n @id = id\n end",
"def id\n object[\"id\"]\n end",
"def id\n data[:id]\n end",
"def polymorphic_id_param\n \"#{key}_id\".to_sym\n end",
"def make_id_to_name\n build_hash('id', 'name')\n end",
"def to_key\n persisted? ? id.to_s : nil\n end",
"def key\n @key\n end",
"def key\n @key\n end",
"def to_key; end",
"def to_key\n persisted? ? [id] : nil\n end",
"def to_key\n persisted? ? [id] : nil\n end",
"def get_kit_cache_key(id)\n fail 'sub class to implement'\n end"
] | [
"0.8109721",
"0.79059756",
"0.7898115",
"0.76118463",
"0.761003",
"0.75992256",
"0.74754834",
"0.7465422",
"0.74245554",
"0.73717666",
"0.7301578",
"0.7245898",
"0.7245898",
"0.7245898",
"0.71900666",
"0.7179912",
"0.71632576",
"0.71606594",
"0.71606594",
"0.71606594",
"0.71371216",
"0.71261734",
"0.70955694",
"0.70771986",
"0.7063973",
"0.7037132",
"0.7034578",
"0.6962504",
"0.6947008",
"0.6922209",
"0.6922209",
"0.6873136",
"0.68458444",
"0.6832516",
"0.6831021",
"0.68198025",
"0.67836976",
"0.6773536",
"0.67572623",
"0.6735089",
"0.67292064",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.6727566",
"0.67272645",
"0.6724414",
"0.67244136",
"0.66982365",
"0.66907585",
"0.6681087",
"0.6680997",
"0.6667771",
"0.6667771",
"0.6667771",
"0.666009",
"0.66560024",
"0.6639358",
"0.6639358",
"0.663892",
"0.663892",
"0.66255885",
"0.6608658",
"0.660374",
"0.6602373",
"0.6599174",
"0.6590083",
"0.6579614",
"0.65758216",
"0.65688616",
"0.6550198",
"0.6546875",
"0.6537007",
"0.6531986",
"0.65261245",
"0.65131134",
"0.6508155",
"0.6504797",
"0.6501365",
"0.6500182",
"0.6500182",
"0.6499138",
"0.64966726",
"0.64966726",
"0.6490533"
] | 0.0 | -1 |
returns all movies in the store | def all
@store.transaction do
@store.roots.map {|id| @store[id] }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def movies\n get('Movies')\n end",
"def index\n @movies = Movie.all\n end",
"def index\n @movies = Movie.all\n end",
"def index\n @movies = Movie.all\n end",
"def index\n @movies = Movie.all\n end",
"def index\n @movies = Movie.all\n end",
"def index\n @movies = Movie.all\n end",
"def index\n @movies = Movie.all\n end",
"def index\n @movies = Movie.all\n end",
"def index\n @movies = Movie.all\n end",
"def index\n @movies = Movie.all \n end",
"def movies()\n sql = \"SELECT movies.* FROM movies INNER JOIN castings ON movies.id = castings.movie_id WHERE star_id = $1\"\n values = [@id]\n movie_data = SqlRunner.run(sql, values)\n return Movie.map_items(movie_data)\n end",
"def index\n @genres_movies = GenresMovie.all\n end",
"def movies\n @movies ||= parse_movie_infos\n end",
"def index\n @theatre_movies = TheatreMovie.all\n end",
"def index\n @movie_shows = MovieShow.all\n end",
"def index\n @movie_models = MovieModel.all\n end",
"def index\n page_number = params[:page] && params[:page][:number] ? params[:page][:number] : Rails.configuration.default_page\n page_size = params[:page] && params[:page][:size]? params[:page][:size] : Rails.configuration.default_per_page\n @movies = Movie.includes(:actors).all.page(page_number).per(page_size)\n end",
"def index\n @omdb_movies = OmdbMovie.all\n end",
"def index\n @movies = Movie.all.order(:title)\n end",
"def index\n @movies = current_user.movies.page(params[:page]).per(Movie::PER_PAGE)\n end",
"def movies\n movies = []\n @rating_list.each_value do |rating|\n movies << rating.movie_id\n end\n return movies\n end",
"def index\n\t\t@movies = Movie.all\n\t\trespond_with @movies\n\tend",
"def index\n respond_with Movie.all\n end",
"def index\n @actors_movies = ActorsMovie.all\n end",
"def index\n @moviies = Moviie.all\n end",
"def index\n @tmdbmovies = Tmdbmovie.all\n end",
"def index\n @categories_movies = CategoriesMovie.all\n end",
"def movies\n # .each - visit everything once\n # .select - select only some whole things\n # .filter - synonym for select\n # .reject - opposite of select/filter\n # .map - 1:1 transformation of array\n # turns each one thing into something\n # given: [1, 2, 3].map {|n| n*n} \n # get: [1, 4, 9]\n self.showings.map do |showing|\n showing.movie\n end.uniq\n end",
"def index\n @cinema_movies = CinemaMovie.all\n end",
"def all_movies\n sql = %Q[\n select title from #{@movies_table}\n order by title asc\n ]\n\n # output a header\n puts \"Movies\"\n puts \"------------------------\"\n\n # execute query and iterate through the result set\n results = @db.exec(sql)\n results.each do |movie|\n puts \"#{movie[\"title\"]}\"\n end \n end",
"def index\n @movie_types = MovieType.all\n end",
"def index\n @movie_categories = MovieCategory.all\n end",
"def index\n @film_genres = FilmGenre.all\n end",
"def index\n @movies_ive_watcheds = MoviesIveWatched.all\n end",
"def index\n @type_movies = TypeMovie.all\n end",
"def index\n @movies = current_user.movies\n end",
"def index\n @movies = Movie.order(:title).page params[:page]\n end",
"def index\n @movies = Movie.all.order(:title) \n end",
"def index\n @movie_crews = MovieCrew.all\n end",
"def index\n @movies = Movie.all\n @top_movies = Tmdb::Movie.upcoming\n end",
"def movies()\n Movie.all().select() { | movie | movie.characters().include?(self) }\n end",
"def index\n @movies = Movie.where(user_id: current_user.id)\n end",
"def index\n @movies = Movie.get_movies(MAX_RECORDS)\n @increment = 0\n @ages = Age.all\n @genres = GENRES\n end",
"def results\n documents = [conditions, variables].any?(&:present?) ? IndexTankClient.new.search(conditions, variables) : []\n movie_results = documents.inject([]) do |movies, document|\n movies << Movie.convert_from_index_tank(document)\n end\n movie_results.sort_by(&:name)\n end",
"def index\n @movie_roles = @movie.roles\n end",
"def movies\n # output = []\n # Review.all.each do |review|\n # if review.user == self\n # output << review.movie\n # end\n # end\n # output\n reviews.map { |review| review.movie }\n end",
"def index\n @movieposts = Moviepost.all\n end",
"def index\n @theatre_movies = TheatreMovie.all\n @movie = Movie.all\n @theatre = Theatre.all\n @show = Show.all\n end",
"def index\n @movie_casts = MovieCast.all\n end",
"def index\n # @movies = Movie.all\n @movies = Movie.order('id desc').page(params[:page]).per(params[:per])\n end",
"def index\n @countrys_movies = CountrysMovie.all\n end",
"def index\n @movs = Mov.all\n end",
"def all_movies_by_watched\n Movie.by_recently_watched_by_user(self)\n end",
"def index\n page_number = params[:page] && params[:page][:number] ? params[:page][:number] : Rails.configuration.default_page\n page_size = params[:page] && params[:page][:size]? params[:page][:size] : Rails.configuration.default_per_pagege\n @crews = Crew.includes(:movies).all.page(page_number).per(page_size)\n end",
"def index\n @movies = Movie.all.paginate(page: params[:page])\n end",
"def get_movies\n\t\t@movies = Movie.order(\"RANDOM()\").where(\"release_date > ?\", 3.years.ago).order('random()').joins(:critic_movies).group('movies.id').having(\"count(movie_id) >= #{CUTOFF}\")\n\t\t.limit(750).to_a\n\t\[email protected] do | movie | \n\t\t\tmovie.title = movie.title.split.map(&:capitalize).join(' ')\n\t\tend\n\t\t@movies = @movies.to_a.map(&:serializable_hash).to_json\n\t\trender :json => @movies\n\tend",
"def index\n @movie_records = []\n if user_signed_in?\n @movie_records = MovieRecord.where(user_id: current_user.id)\n end\n end",
"def movies_list\n return top_rated if query.nil?\n\n content = {}\n encoded_query = CGI.escape(@query)\n html = parse_html(\"/search/?q=#{encoded_query}\")\n all_series = html.css('table.catalogTable').search('tr')\n all_series[1...-1].each do |movie|\n ru_title = movie.css('td > a')[0].text\n content[:\"#{ru_title}\"] = {\n en_title: movie.css('td > .catalogTableSubHeader')[0].text,\n link: movie.css('td > a')[0]['href'],\n movie_id: movie.css('td > a')[0]['href'][/\\d+/],\n watchers: movie.css('td')[2].text,\n seasons: movie.css('td')[4].text,\n year: movie.css('td')[5].text\n }\n end\n content\n rescue NoMethodError\n logger.error \"Can't apply selectors in '#{__method__}' method. DOM structure apparently was changed.\"\n end",
"def index\n @movies = Movie.paginate(page: params[:page], per_page: 120).order(\"title ASC\")\n end",
"def show\n @movies = Genre.find(params[:id]).movies\n p @movies\n end",
"def rated_movies\n Enceladus::MovieCollection.new(\"account/#{id}/rated/movies\", { session_id: session_id }) if authenticated?\n end",
"def index\n @films = Film.all\n end",
"def load_movie_details (movies)\n\t\tmovies.each do |movie|\n\t\t\tload_ratings(movie)\n\t\t\tload_reviews(movie)\n\t\t\tload_genres(movie)\n\t\tend\n\t\treturn movies\n\tend",
"def index\n @movie_events = MovieEvent.all\n end",
"def index\n options = { order: movie_sort_order(params),\n include: :genre,\n page: params[:page],\n per_page: params[:max_pages] || 10 }\n\n search_options = {}\n\n if params[:letter].present? && params[:letter] != \"All\"\n search_options[:starts_with] = true\n term = params[:letter]\n end\n\n term ||= params[:search]\n\n @movies = if term\n Movie.search(term, search_options, options) || []\n else\n Movie.all.paginate(page: params[:page])\n end\n end",
"def favorite_movies\n Enceladus::MovieCollection.new(\"account/#{id}/favorite/movies\", { session_id: session_id }) if authenticated?\n end",
"def index\n @movie = Movie.find(params[:movie_id])\n end",
"def index\n page = 1\n request_url = MOVIE_DB_URL + \"&api_key=#{ENV[\"API_KEY\"]}\"\n request_url += \"&page=#{page}\"\n # if sort by release date\n # request_url += RELEASE_DATE_DESC_URL\n # if sort by title\n # request_url += RELEASE_DATE_DESC_URL;\n @movies = Unirest.get(request_url).body[\"results\"]\n end",
"def movies\n movie_characters = MovieCharacter.all.select {|movie_character| movie_character.character == self}\n movie_characters.map {|movie_character| movie_character.movie}\n end",
"def movies(u)\n\t\tmovie_array=[]\n\t\[email protected]_movie_by_user(u,:base).each do |movie,rate|\n\t\t\tmovie_array.push(movie)\n\t\tend\n\t\treturn movie_array\n\tend",
"def movies\n char_movies = Char_Movie.all.select{ |char_movie| char_movie.character.actor == self}\n char_movies.collect{ |char_movie| char_movie.movie }\n end",
"def movies(user_id)\n\t\t@all_users[user_id].movies\n\tend",
"def movies\n CharacterMovieActing.all.filter do |cma|\n cma.character == self\n end.map do |cm|\n cm.movie\n end\n end",
"def index\n @movies = @category.movies.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @movies }\n end\n end",
"def index\n @movie_stocks = MovieStock.all\n end",
"def movie_list\n self.lists\n end",
"def index\n @movie_showtimes = MovieShowtime.all\n end",
"def index\n @movie_companies = MovieCompany.all\n end",
"def index\n @omdb_genres = OmdbGenre.all\n end",
"def index\n\t\t@reviews = @movie.reviews\n\tend",
"def index\n @movies = PlatformMovie.current.sort { |a, b| b.meta_score <=> a.meta_score }.collect do |movie|\n {\n image_url: movie.movie.image_url,\n platform_link: movie.platform_link,\n platform: (movie.type == 'HboMovie') ? 'hbo' : 'Showtime',\n meta_score: movie.meta_score,\n youtube: movie.movie.youtube,\n title: movie.movie.title,\n summary: movie.movie.summary,\n rating: movie.movie.rating,\n year: movie.movie.year,\n created_at: movie.started\n }\n end\n end",
"def actors\n Actor.where(:movie_id => id)\n end",
"def index\n @movies = Movie.all.order(sort_column + ' ' + sort_direction).search(search_params).paginate(page: params[:page], per_page: 20)\n end",
"def index\n @movies = Movie.all\n @search = Movie.search(params[:search]) \n @movies = @search.all \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @movies }\n end\n end",
"def movies u\n \tuser_ratings = @userdata[u.to_s.to_sym]\n \tsize = user_ratings.size\n \tmovies = []\n \tuser_ratings.each do |id, rating|\n \t\tmovies.push(id)\n \tend\n\n \t#puts size\n \t#puts movies.size\n \treturn movies\n end",
"def index\n @film_categories = FilmCategory.all\n end",
"def search_movies(name)\n # The TMDB api wrapper returns an instance of a 'results' object\n # This object (OpenStruct?) contains the meta data of the request made to the api\n # in a instance variable called table, which also contains a list of TMDB::Movie\n # Objects that represent the movies the api returned as results of the search\n\n # Store the raw results object from the api\n results_object = Tmdb::Search.movie(name)\n\n # Check if the part of the 'results' object that contains the actual list of movies\n # is empty and if it is return nil (Meaning movie was not found) and exit the function\n if results_object.instance_variable_get('@table')[:results][0] == nil\n return nil\n end\n\n # Strip the results object of the attributes and store them in the results hash\n results_hash = results_object.instance_variable_get('@table')\n # Get the list of movies and store them in an array\n movie_array = results_hash[:results]\n # map over the array to substitute a hash for each movie object containing only their\n # name and id (also stored under @table instance variable on the object)\n movie_array.map do |movie|\n {\n name: movie.instance_variable_get('@table')[:title],\n id: movie.instance_variable_get('@table')[:id]\n }\n end\n # returns the array\n end",
"def index\n page_number = params[:page] && params[:page][:number] ? params[:page][:number] : Rails.configuration.default_page\n page_size = params[:page] && params[:page][:size]? params[:page][:size] : Rails.configuration.default_per_page\n @directors = Director.includes(:movies).all.page(page_number).per(page_size)\n end",
"def index\n @movie_countries = MovieCountry.all\n end",
"def index\n @movies = Movie.all.each(&:retrieve!)\n @movies = @movies - current_user.hiding if user_signed_in?\n end",
"def show\n @movie_list = MovieList.find(params[:id])\n @movies = Movie.search(params, current_user, @movie_list.movies)\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @movie_list }\n end\n end",
"def index\n if params[:tag]\n @movies = Movie.tagged_with(params[:tag])\n else\n @movies = Movie.all\n end\n end",
"def index\n movie = params[:movie]\n if movie.blank?\n @movies = Movie.all.reverse\n else\n @movies = Movie.all\n @movies = Movie.where(\"lower(title) LIKE ?\", \"%#{movie.downcase}%\")\n end\n @queries = Query.all\n end",
"def index\n @films = Film.search(params[:search])\n end",
"def movies(u)\n @user_list[u].movies\n end",
"def index\n @actormovies = Actormovie.all\n end",
"def index\n @musical_genres = MusicalGenre.all\n end",
"def movies(u_id=nil)\n if u_id.nil? then\n @movie_index.keys\n else\n data=@user_index[u_id]\n data.nil? ? [] : data.col(:m_id)\n end\n end",
"def index\n options = { order: movie_sort_order(params),\n include: [movie: :genre],\n page: params[:page],\n per_page: params[:max_pages] || 10 }\n\n search_options = {}\n\n if params[:letter].present? && params[:letter] != \"All\"\n search_options[:starts_with] = true\n term = params[:letter]\n end\n\n term ||= params[:search]\n\n @users_movies = current_user.users_movies.search(term, search_options, options)\n end",
"def get_popular_movies\n\t\t\tmovies = Array.new\n\t\t\tname = \"TmdbService#GetPopularMovies\"\n\t\t\tpath = \"/3/movie/popular\"\n\t\t\tparams = {\n api_key: @key\n\t\t\t}\n\t\t\[email protected]('X-Service-Name' => name)\n\t\t\tbegin\n \traw_response = @conn.get(path, params, @headers)\n\t\t\trescue\n\t\t\t\t#do something exceptional\n\t\t\tend\n\t\t\tmovies = @data_mapper.list_of_movies(raw_response)\n\t\tend"
] | [
"0.7627571",
"0.75497407",
"0.75497407",
"0.75497407",
"0.75497407",
"0.75497407",
"0.75497407",
"0.75497407",
"0.75497407",
"0.75497407",
"0.7483413",
"0.74135906",
"0.7360778",
"0.73511744",
"0.73441386",
"0.73128897",
"0.7305203",
"0.7268398",
"0.72306263",
"0.72174567",
"0.72082114",
"0.7187489",
"0.71713096",
"0.71706355",
"0.71409106",
"0.71236444",
"0.70701826",
"0.7025175",
"0.70001614",
"0.69791037",
"0.69778675",
"0.69773954",
"0.69677645",
"0.6933017",
"0.6919685",
"0.69173086",
"0.6907881",
"0.68864506",
"0.6883829",
"0.68607205",
"0.6860675",
"0.685529",
"0.6849818",
"0.6849721",
"0.68356323",
"0.6816894",
"0.6808761",
"0.6793239",
"0.6784494",
"0.6769469",
"0.67623335",
"0.6757649",
"0.6757387",
"0.6742063",
"0.6741201",
"0.67348474",
"0.6712486",
"0.6697127",
"0.6686417",
"0.66732424",
"0.6666718",
"0.6661121",
"0.6655948",
"0.66559213",
"0.66392756",
"0.6620263",
"0.6616392",
"0.6612861",
"0.6609726",
"0.66036475",
"0.6581003",
"0.6577025",
"0.657546",
"0.65670514",
"0.6563004",
"0.65541154",
"0.65518016",
"0.6544627",
"0.6525703",
"0.6507316",
"0.6506611",
"0.65051275",
"0.6501939",
"0.6498771",
"0.6478028",
"0.6476324",
"0.6468578",
"0.6454961",
"0.64543635",
"0.64345735",
"0.6431555",
"0.64305806",
"0.6409604",
"0.63944435",
"0.6393724",
"0.6390156",
"0.63884866",
"0.63874584",
"0.6381633",
"0.6377536",
"0.6361817"
] | 0.0 | -1 |
saves a movie to the store | def save(movie)
@store.transaction do
#if movie doesn't have an id
unless movie.id
highest_id = @store.roots.max || 0 #find the highest id
movie.id = highest_id + 1 #and increment it
end
@store[movie.id] = movie
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(movie)\n @store.transaction do\n # if the movie doesn't have an ID\n unless movie.id \n # find the highest key \n highest_id = @store.roots.max || 0\n # and increment it \n movie.id = highest_id + 1\n end\n @store[movie.id] = movie\n end\n end",
"def add_movie\n @movie = Tmdb::Movie.detail(params['id'])\n @movie_director = Tmdb::Movie.director(@movie.id)[0].name\n\n @new_movie = Movie.create(\n title: @movie.title,\n release_date: @movie.release_date,\n director: @movie_director,\n overview: @movie.overview,\n poster_url: \"https://image.tmdb.org/t/p/w640#{@movie.poster_path}\"\n )\n\n redirect_to movie_path(@new_movie), notice: \"#{@new_movie.title} was added.\"\n end",
"def after_save sender\n\n #Video.store\n end",
"def save\n\t\tconn = Video.open_connection\n\t\tif !self.id\n\t\t\tsql = \"INSERT INTO video (body,title,link,genre) VALUES ('#{self.body}', '#{self.title}', '#{self.link}', '#{self.genre}')\"\n\t\telse\n\t\t\tsql = \"UPDATE video SET title = '#{self.title}',body = '#{self.body}', link = '#{self.link}', genre = '#{self.genre}' WHERE id = #{self.id}\"\n\t\tend\n\t\tconn.exec(sql)\n\n\n\tend",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to movie_url(@movie), notice: \"Movie was successfully created.\" }\n else\n format.html { render :edit, status: :unprocessable_entity }\n end\n end\n end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save_to(path); end",
"def movie_stored(movie)\n\tputs \"\\n\\nMovie stored\\n\"\n\tputs \"#{movie.title} is a #{movie.genre} movie.\"\n\tputs \"#{movie.title} is #{movie.run_time} long.\"\n\tputs \"#{movie.title} is currently rated #{movie.rating} chocolate bunnies.\"\n\tputs \"#{movie.title} can be watched #{movie.where_to_watch}.\"\nend",
"def save\n end",
"def save\n file_name = ask_save_file\n save_file = File.open(file_name, 'w')\n save_file.puts(serialize)\n save_file.close\n puts \"Game has been saved to Save File #{file_name[-5]}!\"\n puts \"\\n\\n\"\n end",
"def create\n @saved_title = SavedTitle.new(saved_title_params)\n respond_to do |format|\n if @saved_title.save\n format.html { redirect_to @saved_title, notice: 'Movie was successfully added to list.' }\n format.json { render :show, status: :created, location: @saved_title }\n else\n format.html { render :new }\n format.json { render json: @saved_title.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save\n SAVE\n end",
"def save\n #code\n end",
"def save\n file_path = self.class.file_path(@save_id)\n File.open(file_path, 'w') { |file| \n bytes = file.write @items.inspect\n if bytes > 0\n puts \"saved to #{file_path}\"\n else\n puts \"save to #{file_path} failed\"\n end\n }\n end",
"def create\n @movie = Movie.new(movie_params)\n\n if @movie.save\n redirect_to movies_path, notice: \"#{@movie.title} was submitted successfully!\"\n else\n render :new\n end\n end",
"def autosave; end",
"def save\n end",
"def save\n end",
"def save_to_file()\n File.open(@filename,\"w\") do |f|\n movies_hash = []\n @items.each do |movie|\n movies_hash.push(movie.to_hash)\n end\n f.write(JSON.pretty_generate(movies_hash))\n end\n end",
"def save\n end",
"def save\n end",
"def save_page\n page = xml_page()\n AR.save_all_videos(page)\nend",
"def create\n @movie = Movie.new(movie_params)\n\n \n if @movie.save\n redirect_to index_url\n flash[:success] = \"Movie was successfully created.\" \n\n else\n render 'new'\n \n end\n end",
"def save\n\n end",
"def create\n prepare_movie(true)\n \n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(movie_params)\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def on_save_success\r\n Sound.play_save\r\n return_scene\r\n end",
"def save\n files = MyBiaDJ::Table(:files)\n record = files.create(:path => relative_path, :name => name)\n tracks.each do |track|\n track.save(record) if track.mp3?\n end\n end",
"def save\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n @movie\n end",
"def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to(@movie, :notice => 'Movie was successfully created.') }\n format.xml { render :xml => @movie, :status => :created, :location => @movie }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @movie.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'La pelicula ha sido creada correctamente.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @saving = Saving.new(saving_params)\n\n # video_uploader.rbのstore_dirは、DBへのレコード登録後である\n # よって、savings_controller.rbでパスをDBセーブした値を持ってくる\n # そのパスは、ユニークになるよう秒までをディレクトリに含める\n # 注意:storepathは最後に/をつけない。\n\n pathpart = Date.today\n pathpart2 = Time.now\n pathconcat = \"uploads/grpvideo/\" + pathpart.strftime(\"%Y/%m/%d/\") + pathpart2.strftime(\"%H%M%S\")\n @saving.storepath = sprintf(\"%s\",pathconcat)\n\n respond_to do |format|\n if @saving.save\n format.html { redirect_to @saving, notice: 'Saving was successfully created.' }\n format.json { render :show, status: :created, location: @saving }\n else\n format.html { render :new }\n format.json { render json: @saving.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_object\n end",
"def create\n new_movie = Movie.new\n\n new_movie.title = params[:title]\n new_movie.year = params[:year]\n new_movie.director = params[:director]\n new_movie.actors = params[:cast_members]\n new_movie.plot = params[:plot]\n new_movie.mpaa_rating = params[:mpaa_rating]\n new_movie.favorite = params[:favorite]\n new_movie.save\n\n redirect_to new_movie\n end",
"def create\n @movie = Movie.new(movie_params)\n end",
"def create\n @movie = Movie.new(movie_params)\n end",
"def savevid\n tmp = params[:vids][:video].tempfile\n #require 'ftools'\n file = File.join(\"app/assets/videos\", params[:vids][:video].original_filename) # use public if you want\n FileUtils.cp tmp.path, file\n\n redirect_to \"/admin\"\nend",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render action: 'show', status: :created, location: @movie }\n else\n format.html { render action: 'new' }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render action: 'show', status: :created, location: @movie }\n else\n format.html { render action: 'new' }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save(options = {})\n save_to(@path, options)\n end",
"def save\n File.open(@file, 'w') do |file|\n file.write(Psych.dump(@params))\n end\n @saved = true\n end",
"def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to root_path, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save(*_)\n end",
"def saving_params\n params.require(:saving).permit(:recdate, :title, :owner, :note, :video, :video_cache, :storepath)\n end",
"def save!\n end",
"def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save\n object.save\n end",
"def subject_save\n self.save_button.click\n end",
"def store_video\n ActiveRecord::Base.transaction do\n @video = Video.create(video_path: @video_url, description: @description, released: @released, title: @video_title, poster_path: @poster_url, producer: @producer)\n\t\t\t@latest = Latest.create(media_id: @video.id, title: @video_title, description: @description, released: @released, media_poster: @poster_url, media_producer: @producer, media_type: @type)\n end\n end",
"def can_be_instantiated_and_then_saved\n movie = Movie.new #___\n movie.title = \"This is a title.\"\n movie.save #__ # undefined method `save' for #<Class:0x00007f983cbb4b18>\nend",
"def create\n @omdb_movie = OmdbMovie.new(omdb_movie_params)\n\n respond_to do |format|\n if @omdb_movie.save\n format.html { redirect_to @omdb_movie, notice: 'Omdb movie was successfully created.' }\n format.json { render action: 'show', status: :created, location: @omdb_movie }\n else\n format.html { render action: 'new' }\n format.json { render json: @omdb_movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save *args\n @save = args.first if args.size > 0\n end",
"def create\n parameters = movie_params.dup\n parameters.delete(:images)\n parameters.delete(:genres)\n parameters.delete(:videos)\n parameters.delete(:actors)\n\n @movie = Movie.new(parameters)\n\n respond_to do |format|\n if @movie.save\n @movie.save_attachments(movie_params)\n format.json { render :show, status: :created }\n else\n format.json do\n render json: @movie.errors, status: :unprocessable_entity\n end\n end\n end\n end",
"def create\r\n # session is a rails way of storing data temporarily in a cookie\r\n if session[:movies] == nil\r\n session[:movies] = []\r\n end\r\n\r\n session[:movies].push(params[:movie])\r\n puts \"session movie data\"\r\n puts session[:movies]\r\n\r\n redirect_to movie_path(session[:movies].length - 1) #pass the last movie we just added to the show page and redirect there\r\n # puts \"===================\"\r\n # puts params[:movie]\r\n # puts \"===================\"\r\n # @movies = []\r\n # @movies.push(params[:movie])\r\n end",
"def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html {redirect_to @movie, notice: 'Movie was successfully created.'}\n format.json {render :show, status: :created, location: @movie}\n else\n format.html {render :new}\n format.json {render json: @movie.errors, status: :unprocessable_entity}\n end\n end\n end",
"def save\n put_object\n true\n end",
"def create\n @movie = Movie.new(movie_params)\n @movie.address = @movie.city + \" \" + @movie.country\n @movie.thumnail_url = \"https://mood2travel.s3.amazonaws.com/thumnails/\" + @movie.videoId.to_s + \".png\"\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render action: 'show', status: :created, location: @movie }\n else\n format.html { render action: 'new' }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save(filename)\n File.write(filename, self.to_s)\n end",
"def create\n # Create a new movie instance that will be used in the form:\n @movie = Movie.new(movie_params);\n\n if(@movie.save)\n # Present a 1-time flash message to the user after redirect:\n flash[:notice] = \"Movie created successfully.\";\n\n # If saved to DB successfully, go to show page:\n redirect_to @movie;\n else\n # If validations prevented save, reload form (with error message):\n render 'new';\n end\n end",
"def save; record.save; end",
"def save\r\n # Draw a frame.\r\n frame = Draw.new\r\n frame.stroke(\"black\")\r\n frame.stroke_width(2)\r\n frame.fill_opacity(0)\r\n frame.rectangle(0, 0, @image.columns-1, @image.rows-1)\r\n frame.draw(@image)\r\n \r\n @image.write(name + '.png')\r\n end",
"def create\n @store = Store.new(params[:store])\n @store.save\n unless params[:image].nil?\n params[:image].each_value do |image|\n unless image.nil? || image[:photo].nil?\n @picture = Image.new\n @picture.source_file_name = image[:photo].original_filename\n @picture.source_content_type = image[:photo].original_filename.split(\".\").last\n #@picture.source_file_size = File.size(params[:image][:photo])\n @picture.source_updated_at =Time.now\n\n @picture.photo = image[:photo]\n @picture.save\n\n @asset=Asset.new\n @asset.assetable_id = @picture.id\n @asset.assetable_type = \"image\"\n @asset.price = image[:price][:price]\n @asset.store_id = @store.id\n @asset.save!\n end\n end\n end\n\n unless params[:video].nil?\n params[:video].each_value do |video|\n unless video.nil? || video[:file].nil?\n file = video[:file]\n @movie=Video.new\n name= video[:file].original_filename\n dir= RAILS_ROOT + \"/public/movies\"\n Dir.mkdir(dir) unless File.directory?(dir)\n path=File.join(dir,name)\n if File.extname(path) == \".swf\" || File.extname(path) == \".mpeg\" || File.extname(path) == \".wmv\" || File.extname(path) == \".flv\" || File.extname(path) == \".mpeg4\" || File.extname(path) == \".mpg\" || File.extname(path) == \".avi\"\n parse_file = File.open(path, \"wb\") { |f| f.write(file.read) }\n\n @video=Video.new(:source_file_name => name, :source_file_size => File.new(path).size, :source_updated_at => Time.now, :source_content_type => File.extname(path))\n @video.title = video[:title]\n @video.description = video[:description]\n @video.save!\n @video.category_videos.create(:category_id => video[:category][:category_id].to_i)\n set_video_search(@video.id,video[:title], video[:description])\n image_file=video[:image][:photo]\n @image=VideoImage.new\n dir=RAILS_ROOT + \"/public/video_image\"\n name= video[:image][:photo].original_filename\n path=File.join(dir,name)\n Dir.mkdir(dir) unless File.directory?(dir)\n parse_file = File.open(path, \"wb\") { |f| f.write(image_file.read) }\n system(\"convert #{path} -resize 400x225\\! #{path}\")\n @image.source_file_name = video[:image][:photo].original_filename\n @image.source_content_type = video[:image][:photo].original_filename.split(\".\").last\n @image.photo = video[:image][:photo]\n # @image.source_file_size = File.size(video[:image][:photo])\n @image.source_updated_at =Time.now\n @image.video_id = @video.id\n @image.save!\n\n @asset = Asset.new\n @asset.assetable_id = @video.id\n @asset.assetable_type = \"video\"\n @asset.store_id = @store.id\n @asset.price = video[:price][:price]\n @asset.save!\n end\n end\n end\n end\n respond_to do |format|\n format.html { redirect_to stores_path }\n format.xml { render :xml => @store, :status => :created, :location => @store }\n end\n end",
"def movie_params\n params.require(:movie).permit(:title, :description, :rating, :runtime, :released, :url, :checked_out_to_id, :override_checkout, :team_id)\n end",
"def create\n @genres_movie = GenresMovie.new(genres_movie_params)\n\n respond_to do |format|\n if @genres_movie.save\n format.html { redirect_to @genres_movie, notice: 'Genres movie was successfully created.' }\n format.json { render :show, status: :created, location: @genres_movie }\n else\n format.html { render :new }\n format.json { render json: @genres_movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_file\n if self.file then\n self.file.save\n end\n end",
"def create\n @theatre_movie = TheatreMovie.new(theatre_movie_params)\n\n respond_to do |format|\n if @theatre_movie.save\n format.html { redirect_to @theatre_movie, notice: 'Theatre movie was successfully created.' }\n format.json { render :show, status: :created, location: @theatre_movie }\n else\n format.html { render :new }\n format.json { render json: @theatre_movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def movie_params\n params.require(:movie).permit(:content, :imdb_id, :year, :filename, :imdb_rating, :name)\n end",
"def save_file\r\n @saved = true\r\n saving\r\n Dir.mkdir(\"saves\") unless Dir.exists? \"saves\"\r\n File.open(\"my_save.yaml\", \"w\") {|f| f.puts YAML::dump(self) }\r\n end",
"def movie_params\n params.require(:movie).permit(:title, :description, :director, :genre_id, :movie_img)\n end",
"def save filename = nil\n filename = find_free_name filename\n save! filename\n end",
"def create\n @movie = Movie.new(movie_params)\n\n movie_id = Tmdb::Movie.find(@movie.title)[0].id\n\n title_info_2 = Tmdb::Movie.detail(movie_id)\n genre = title_info_2['genres'][0]['name']\n vote = title_info_2['vote_average']\n year = title_info_2['release_date'].byteslice(0,4)\n\n cast = Tmdb::Movie.casts(movie_id)\n cast_members = []\n\n cast.each do |member|\n cast_members << member['name']\n end\n\n @movie.actors = cast_members.join(', ')\n @movie.genre = genre\n @movie.year = year\n @movie.metascore = vote\n @movie.user_id = current_user.id\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_movie\n @movie = Movie.find(params[:id])\n redirect_to movies_path, alert: 'Il film non è stato trovato' unless @movie\n end",
"def movie_params\n\t\t\tparams.require(:movie).permit(:title, :description, :rating, :released_on, :total_gross, :cast, :director, :duration, :image_file_name, genre_ids: [])\n\t\tend",
"def save(env)\n locals = {title: params['title'], attachment: params['attachment']}\n [201, {}, haml(:saved, :locals => locals )]\n end",
"def set_saved_video\n @saved_video = SavedVideo.find(params[:id])\n end",
"def save\n create_file\n true\n end",
"def save_wiki_media( filename, url )\n path =\n if @media_dir.nil?\n filename\n else\n \"#{@media_dir}/#{filename}\"\n end\n save_wiki_body( path, url )\n end",
"def save\n\t\tend",
"def save(game)\n\t\tprint \"Name the save: \"\n\t\tsave_name = gets.chomp.downcase\n\t\tDir.mkdir \"saves\" unless Dir.exists? \"saves\"\n\t\tfile_path = File.join(\"saves\", \"#{save_name}\")\n\t\tFile.open(file_path, \"w\") { |f|\n\t\t\tf.write(YAML.dump(game))\n\t\t}\n\t\tputs \"The game has been saved!\"\n\tend"
] | [
"0.6913982",
"0.6431513",
"0.6394737",
"0.6306452",
"0.62602955",
"0.62509793",
"0.62509793",
"0.62509793",
"0.62509793",
"0.62509793",
"0.62509793",
"0.62509793",
"0.62509793",
"0.62393373",
"0.623586",
"0.62209177",
"0.6205019",
"0.615468",
"0.6149299",
"0.6126187",
"0.6118289",
"0.6091957",
"0.6073035",
"0.6054429",
"0.6054429",
"0.60367525",
"0.6025426",
"0.6025426",
"0.59977704",
"0.5991379",
"0.5963676",
"0.5956374",
"0.59563315",
"0.5945415",
"0.5945415",
"0.5945415",
"0.5945415",
"0.5945415",
"0.5945415",
"0.5945415",
"0.5945415",
"0.5945415",
"0.5941632",
"0.5940244",
"0.59377414",
"0.59214336",
"0.5895202",
"0.5886159",
"0.5881532",
"0.5876527",
"0.5872687",
"0.5854912",
"0.5854912",
"0.5854847",
"0.5852105",
"0.5852105",
"0.5848321",
"0.584673",
"0.5845117",
"0.5844121",
"0.5840913",
"0.5834306",
"0.58320004",
"0.58320004",
"0.58320004",
"0.58320004",
"0.58320004",
"0.5823913",
"0.58164877",
"0.58085936",
"0.57855743",
"0.57849765",
"0.57826483",
"0.57754207",
"0.5772031",
"0.5754189",
"0.5753684",
"0.5741885",
"0.57383037",
"0.57347006",
"0.5715563",
"0.5703984",
"0.57034105",
"0.5702955",
"0.56963074",
"0.5695093",
"0.5692065",
"0.5672681",
"0.5666678",
"0.5665209",
"0.56651545",
"0.56567395",
"0.56545",
"0.56544363",
"0.564976",
"0.56496364",
"0.56442374",
"0.5642866",
"0.5641602",
"0.56364864"
] | 0.66130215 | 1 |
everything should be in AA coords! | def extend_borders!(target)
keys = detect_keys target
opposite_keys = opposite_keys target
left, right = [data[keys[:start]], data[keys[:finish]]].sort
op_left, op_right = [data[opposite_keys[:start]], data[opposite_keys[:finish]]].sort
op_len = data[opposite_keys[:len]]
left_shift = op_left
right_shift = op_len-op_right
new_left = left - left_shift
new_left = 1 if new_left < 1
new_right = right + right_shift
new_right = data[keys[:len]] if new_right > data[keys[:len]]
@extended = true
@unextended_data ||= {}
@unextended_data[keys[:start]] = data[keys[:start]]
@unextended_data[keys[:finish]] = data[keys[:finish]]
data[keys[:start]] = data[keys[:start]] < data[keys[:finish]] ? new_left : new_right
data[keys[:finish]] = data[keys[:start]] < data[keys[:finish]] ? new_right : new_left
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanity_check_ballot_coords\n \n end",
"def valid_new_aoe_pos(tx, ty, sx, sy, v_range_aoe) # mod MGC\n return false unless $game_map.valid?(tx, ty) \n return true\n end",
"def chk_safe_coords(x, y)\n # If x or y is negative or greater than 4\n if x < 0 || x > 4 || y < 0 || y > 4\n return false # Return \"unsafe\"\n else\n return true # Return \"safe\"\n end\nend",
"def coords; {:x => @x, :y => @y} end",
"def valid_new_aoe_pos(tx, ty, sx, sy, v_range_aoe) # mod MGC\n result = valid_new_aoe_pos_mgc_lm_gtbs(tx, ty, sx, sy, v_range_aoe) # mod MGC\n if (result && Layy_Meta.active)\n sAlt = $game_map.get_altitude(sx, sy)\n tAlt = $game_map.get_altitude(tx, ty)\n result = false if (tAlt - sAlt).abs > v_range_aoe # mod MGC\n end\n return result\n end",
"def test_the_coordinates_are_valid\n assert_equal true, @board.valid_coordinate?(\"A1\")\n assert_equal false, @board.valid_coordinate?(\"ZZ\")\n end",
"def safe_position?(x, y)\n x >= 0 &&\n x <= 4 &&\n y >= 0 &&\n y <= 4\n end",
"def coordinates\n return 166, 72\n end",
"def points; end",
"def geometry( b)\n\t\t# over-ride where neeeded, e.g. UONActor\n\tend",
"def geo; end",
"def spritestack_coordinates\n return 25, 125\n end",
"def would_fit(offs_x, offs_y)\r\n # Check at the center/top and center/bottom for map collisions\r\n not $state.map.solid?(@x + offs_x, @y + offs_y) and\r\n not $state.solid?(@x + offs_x, @y + offs_y - 45)\r\n end",
"def would_fit(offs_x, offs_y)\n # Check at the center/top and center/bottom for map collisions\n not @map.solid?(@x + offs_x, @y + offs_y) and\n not @map.solid?(@x + offs_x, @y + offs_y - 45)\n end",
"def location\n [@posX, @posY, @facing]\n end",
"def coordquery(p)\r\nend",
"def would_fit(offs_x, offs_y)\n # Check for map collisions\n not @map.solid?(@x + offs_x - 10, @y + offs_y) and\n not @map.solid?(@x + offs_x + 10, @y + offs_y) and\n not @map.solid?(@x + offs_x - 10, @y + offs_y - 45) and\n not @map.solid?(@x + offs_x + 10, @y + offs_y - 45)\n end",
"def aabb_vs_aabb(a, b, type: AabbShape)\n return unless a[type] && b[type]\n\n nx, ny = [b[Position].x - a[Position].x,\n b[Position].y - a[Position].y]\n\n aex, aey = [(a[type].max_x - a[type].min_x) * 0.5,\n (a[type].max_y - a[type].min_y) * 0.5]\n\n bex, bey = [(b[type].max_x - b[type].min_x) * 0.5,\n (b[type].max_y - b[type].min_y) * 0.5]\n\n overx, overy = [aex + bex - nx.abs,\n aey + bey - ny.abs]\n\n if overx > 0 && overy > 0\n if overx < overy\n\n if nx < 0\n [-1, 0, overx]\n else\n [1, 0, overx]\n end\n\n else\n\n if ny < 0\n [0, -1, overy]\n else\n [0, 1, overy]\n end\n\n end\n end\n end",
"def am(amida, y, x)\n #p \"==== NOW ===\"\n #p y \n #p x\n #p amida\n\n if y == H \n #p \"=====GOAL\"\n if x + 1 == K\n $cnt = $cnt + 1\n end\n return\n end\n\n if x < W - 1\n to_right_amida = Marshal.load(Marshal.dump(amida))\n to_right_amida[y][x] = 1\n am(to_right_amida, y + 1, x + 1)\n end\n\n to_streight_amida = Marshal.load(Marshal.dump(amida))\n am(to_streight_amida, y + 1, x)\n\n if x > 0\n to_left_amida = Marshal.load(Marshal.dump(amida))\n to_left_amida[y][x - 1] = 1\n am(to_left_amida, y + 1, x - 1)\n end\nend",
"def center_origins\n return if !self.bitmap\n self.ox = self.bitmap.width / 2\n self.oy = self.bitmap.height / 2\n end",
"def valid_coords(i, j)\n (0...height) === i && (0...width) === j\n end",
"def sector_a_intfx_coords\n [ [-1.5 * @radius, @radius], [-1.5 * @radius, -@radius], \n [-1.5 * @radius, 3 * @radius], [-3 * @radius, 2 * @radius],\n [-3 * @radius, 0], [-3 * @radius, -2 * @radius],\n [-1.5 * @radius, -3 * @radius] ]\n end",
"def convert_location_to_coordinates(alpha)\n coord = []\n alpha.split(/(\\d+)/).each do |ch|\n if is_number?(ch)\n coord.push(ch.to_i)\n else\n coord.push(letter_to_index(ch))\n end\n end\n coord\n end",
"def en_passant_capture?( from_coord, to_coord ) \n with ( self[from_coord] ) do |pawn|\n return false unless pawn.function == :pawn\n return false unless self.en_passant_square\n return (from_coord.file != to_coord.file) && (self[to_coord]==nil)\n end\n end",
"def valid?(coordinates) ##this will need to check if the placement of coorindates is valid, sequential in row/number\n\t\thorizontal_valid?(coordinates) || vertical_valid?(coordinates)\n\tend",
"def valid_position?(x, y)\n !!(x && y && x > 0 && y > 0 && x <= 8 && y <= 8)\n end",
"def asteroid_relative(x,y,grid)\n\tpoints = Hash.new\n\tx_root, y_root = x, y\n\tgrid.each do |(x, y), value|\t\t\n\t\tpoints[[x,y]] = Point.from_offset(x_root, y_root, x, y)\n\tend\n\tpoints\nend",
"def over_bound?(x, y)\n if (x != @x || y != @y) && $game_map.valid?(x, y)\n max_w = $game_map.max_width ; max_h = $game_map.max_height\n screen_x = $game_map.adjust_x(x) * 32 + 16\n screen_y = $game_map.adjust_y(y) * 32 + 32\n sx = (screen_x / 32).to_i; sy = (screen_y / 32).to_i\n if sx.between?(0 - out_offset, max_w + out_offset) && \n sy.between?(0 - out_offset, max_h + out_offset)\n \n return false\n end # sx, sy\n end # xy != @xy && map_valid\n return true\n end",
"def test_alignTopLeft\n [@window, @sprite, @bitmap].each{|container|\n uc = UCCharacterGraphic.new(container, Rect.new(0, 80, @window.contents.width, 120), $data_actors[1], 0)\n uc.draw()\n }\n return true\n end",
"def color_valid_positions\n return if @item.nil?\n \n center_color = Color.new(83,142,250)\n outer_color = Color.new(250,40,100)\n \n cx = cy = (contents.width-@grid_square_size)/@grid_square_size/2 * @grid_square_size + 1\n sq = @grid_square_size-1\n\n points = !(t = @item.tbs_spec_range).nil? ? t[$game_temp.tb_event.dir_to_sym_era] : simple_range\n \n return if points.nil?\n \n points.each do |v|\n offset_x, offset_y = v.x * @grid_square_size, v.y * @grid_square_size\n sz = grid_side\n px,py = cx + offset_x + sq, cy + offset_y + sq\n contents.fill_rect(px-sq,py-sq,sq,sq, outer_color) if px < sz && py < sz\n end\n contents.fill_rect(cx, cy,sq,sq, center_color) # center\n end",
"def ship_coords_are_all_on_board\n all_aboard = true\n @ship.coords.each do |coord|\n row, col = coord\n # if row & col are NOT between 0 and 9...\n unless row.between?(0,9) && col.between?(0,9)\n # ...then not all the coords are ok.\n all_aboard = false\n end\n break unless all_aboard == true\n end\n return all_aboard\n end",
"def set_coordinates\n [rand(-100..100), rand(-100..100)]\n end",
"def aabb_visible?\n @debug_aabb\n end",
"def aabb_visible?\n @debug_aabb\n end",
"def can_you_see?(map, dim, direction)\n plus = case direction\n when 1 then [-1,-1]\n when 2 then [-1, 0]\n when 3 then [-1, 1]\n when 4 then [ 0,-1]\n when 6 then [ 0, 1]\n when 7 then [ 1,-1]\n when 8 then [ 1, 0]\n when 9 then [ 1, 1]\n end\n\n #print \"whereami: \"\n whereami = whereami(map)\n coord = whereami\n\n while dim > 0 do\n whereamfrom = coord\n coord = [coord,plus].transpose.map{|ary| ary.inject(&:+) }\n\n #print \"distance: \"\n distance = distance(whereamfrom, coord)\n\n if whereamfrom == whereami || coord == whereami\n # 最初は0.5しか進まないわけだが...。\n if plus.any?{|e| e==0}\n dim -= 0.5\n else #角度を付けて入ってきた場合\n dim -= Math.sqrt(0.5**2 + 0.5**2)\n end\n else\n dim -= distance\n end\n return false if dim < 0\n #print \"now: \"\n #p coord\n #print \"dim: \"\n #p dim\n if myself?(coord, map)\n return true\n elsif mirror?(coord, map)\n # print \"!!! mirror #{plus} -> \"\n # TODO: 入った角度による。これはきれいに反射した場合\n plus = plus.map{|e| -1*e }\n # print \"#{plus}\\n\"\n end\n end\nend",
"def valid_coordinate?(coord)\n if coord.size == 2 && coord[0].between?(0, 7) && coord[1].between?(0, 7)\n true\n else\n false\n end\n end",
"def valid?(x, y)\n return (x >= 0 and x < $game_map.width and y >= 0 and y < $game_map.height)\n end",
"def valid?(x, y)\n return (x >= 0 and x < $game_map.width and y >= 0 and y < $game_map.height)\n end",
"def encode(x, y, tool)\n (x << X_OFFSET) | (y << Y_OFFSET) | tool\nend",
"def position=(point); end",
"def convert_coords(screen, x, y, z)\n\t\txd = x * $persp / (z + $space_size) + screen.width / 2\n\t\tyd = y * $persp / (z + $space_size) + screen.height / 2\n\t\treturn xd, yd\n\tend",
"def coordinate_valid?(x, y)\n (x >= 0) && (y >= 0) && (x < @width) && (y < @height)\n end",
"def coordinate_valid?(x, y)\n (x >= 0) && (y >= 0) && (x < @width) && (y < @height)\n end",
"def check_coord_marked?(coord)\n case coord\n when \"a1\"\n if @array[0][0] != \" \"\n true\n end\n when \"a2\"\n if @array[0][1] != \" \"\n true\n end\n when \"a3\"\n if @array[0][2] != \" \"\n true\n end\n when \"b1\"\n if @array[1][0] != \" \"\n true\n end\n when \"b2\"\n if @array[1][1] != \" \"\n true\n end\n when \"b3\"\n if @array[1][2] != \" \"\n true\n end\n when \"c1\"\n if @array[2][0] != \" \"\n true\n end\n when \"c2\"\n if @array[2][1] != \" \"\n true\n end\n when \"c3\"\n if @array[2][2] != \" \"\n true\n end\n end\n end",
"def name_text_coordinates\n return 8, 5, 98, 16\n end",
"def to_a\n if defined?(@to_a)\n @to_a\n else\n cs = self.coord_seq\n @to_a = if self.has_z?\n [ cs.get_x(0), cs.get_y(0), cs.get_z(0) ]\n else\n [ cs.get_x(0), cs.get_y(0) ]\n end\n end\n end",
"def carve_walls_from_point(x, y, grid)\n \nend",
"def on_map?(boat)\n x, y, length, orientation = *boat\n if orientation == :down\n y + length <= 10\n else\n x + length <= 10\n end\n end",
"def user_coordinate\r\n\t\tconvert_coordinate(1)\r\n\tend",
"def initialize\n @x\n @y\n @facing\n @placed = false\n end",
"def legal(coords)\n row_dist = (@row - coords[0]).abs\n col_dist = (@column - coords[1]).abs\n if row_dist > 1 || col_dist > 1\n return false\n elsif check\n puts \"cant move into check\"\n return false\n else\n return occupied?(coords)\n end\n end",
"def normalize_coordinates\n minY = minX = 1000000\n maxX = maxY = -minX\n @passages.each do |passage|\n if passage.x < minX then minX = passage.x end\n if passage.x > maxX then maxX = passage.x end\n if passage.y < minY then minY = passage.y end\n if passage.y > maxY then maxY = passage.y end\n end\n x_distance = 0 - minX\n y_distance = 0 - minY\n @extentX = maxX + x_distance\n @extentY = maxY + y_distance\n @passages.each do |passage|\n passage.x += x_distance\n passage.y += y_distance\n end\n end",
"def valid?\n lat && lng && lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180\n end",
"def panoramic_pairs(landmarks)\n\nend",
"def valid_location(x, y)\n return (x >= 0) && (x < Settings.get_horizontal_size) && (y >= 0) && (y < Settings.get_vertical_size)\n end",
"def attacking_coordinates(piece_type = 'Queen')\n attacking_pairs(piece_type).map { |pair| pair.map(&:coordinates) }\n end",
"def atlas_visible?\n return quality_checked? && open_access? && geom?\n end",
"def lvl_text_coordinates\n return 121, 5, 35, 16\n end",
"def valid_board_coordinates?(x, y)\n x >= 0 && y >= 0 && x < 3 && y < 3\n end",
"def bounds\n \"#{top},#{left}:#{bottom},#{right}\"\n end",
"def start_coords\n marker_coords('S')\n end",
"def boundaries(x, y)\n return false if x > 7 || x < 0 || y > 7 || y < 0\n return true\n\n end",
"def lat_check(l)\n circ_bounds(l * 1.0, 90.0, -90.0)\n end",
"def amino_acid_2 (bases)\n bases_to_aa = []\n aa_list = []\n base1 = bases[0].to_list\n base2 = bases[1].to_list\n base3 = bases[2].to_list\n l1 = base1.size - 1\n l2 = base2.size - 1\n l3 = base3.size - 1\n (0..l1).each do |n1|\n b1 = base1[n1]\n (0..l2).each do |n2|\n b2 = base2[n2]\n (0..l3).each do |n3|\n b3 = base3[n3]\n bases_all = b1 + b2 + b3\n bases_to_aa << bases_all\n end\n end\n end\n\n bases_to_aa.each do |base|\n case base\n when /^TT[TCY]$/\n aa = \"F\"\n when /^TT[AGR]$/\n aa = \"L\"\n when /^CT.$/\n aa = \"L\"\n when /^AT[TCAHYWM]$/\n aa = \"I\"\n when \"ATG\"\n aa = \"M\"\n when /^GT.$/\n aa = \"V\"\n when /^TC.$/\n aa = \"S\"\n when /^CC.$/\n aa = \"P\"\n when /^AC.$/\n aa = \"T\"\n when /^GC.$/\n aa = \"A\"\n when /^TA[TCY]$/\n aa = \"Y\"\n when /^TA[AGR]$/\n aa = \"*\"\n when /^T[GR]A$/\n aa = \"*\"\n when /^CA[TCY]$/\n aa = \"H\"\n when /^CA[AGR]$/\n aa = \"Q\"\n when /^AA[TCY]$/\n aa = \"N\"\n when /^AA[AGR]$/\n aa = \"K\"\n when /^GA[TCY]$/\n aa = \"D\"\n when /^GA[AGR]$/\n aa = \"E\"\n when /^TG[TCY]$/\n aa = \"C\"\n when \"TGG\"\n aa = \"W\"\n when /^CG.$/\n aa = \"R\"\n when /^AG[TCY]$/\n aa = \"S\"\n when /^[AM]G[AGR]$/\n aa = \"R\"\n when /^GG.$/\n aa = \"G\"\n when /^[ATW][CGS][CTY]$/\n aa = \"S\"\n when /^[TCY]T[AGR]$/\n aa = \"L\"\n else\n aa = \"-\"\n end\n aa_list << aa\n end\n aa_out = aa_list.uniq.join\n return aa_out\n end",
"def coordinates\n [rand(50), rand(90)]\n end",
"def isBoundedBy(coord)\n inBox(getBox([nw_lon,nw_lat],[se_lon,se_lat]),coord)\n end",
"def bounding_box\r\n unless with_z\r\n [Point.from_x_y(@x,@y),Point.from_x_y(@x,@y)]\r\n else\r\n [Point.from_x_y_z(@x,@y,@z),Point.from_x_y_z(@x,@y,@z)]\r\n end\r\n end",
"def to_xy\n a = self\n a = [a[0].x, a[0].y] if length == 1\n return *a\n end",
"def valid_coordinates?(x_coord, y_coord)\n (0..width).include?(x_coord) && (0..height).include?(y_coord)\n end",
"def valid_coordinates\n input.length == 2 && input.all? { |value| value.match? /\\A\\d+\\z/ }\n end",
"def s_coords(attrs)\n height = (attrs['HEIGHT'] || 0).to_i\n width = (attrs['WIDTH'] || 0).to_i\n hpos = (attrs['HPOS'] || 0).to_i\n vpos = (attrs['VPOS'] || 0).to_i\n [hpos, vpos, width, height]\n end",
"def out_of_bounds?\n (0..@grid_size[0]).cover?(@coordinates[0]) &&\n (0..@grid_size[1]).cover?(@coordinates[1])\nend",
"def find_area\n\t\t@area = 0.5 * ((@point1.x - @point3.x)*(@point2.y - @point1.y) - (@point1.x - @point2.x)*(@point3.y - @point1.y)).abs\n\tend",
"def coordinate\n x = ((position-1) / area.x_max) + 1\n y = position - (x-1) * area.x_max\n \"(#{x}, #{y})\"\n end",
"def valid_position?(p)\n c = []\n c.push(p[0])\n c.push(p[1])\n if (p.length == 3 && valid_xy?(c) && Navigation.COMPASS.include?(p.last))\n return true\n end\n false\n end",
"def area_wrt_ground ()\n \n end",
"def text_coordinate\n return 39, 5, 222, 16\n end",
"def legal(coords)\n offsets = [ [1, 2], [-1, 2], [1, -2], [-1, -2], [2, 1], [-2, 1], [2, -1], [-2, -1] ]\n moves = []\n offsets.each do |offset|\n move = [@row+offset[0], @column+offset[1]]\n moves << move\n end\n #loop through possible moves\n moves.each do |move|\n #if chosen coords = moves array coords check if occupied\n if coords === move\n return occupied?(coords)\n end\n end\n return false \n end",
"def antipodal\n Location.new(:longitude => 180 - (longitude.abs),\n :latitude => -latitude )\n end",
"def source_pts; end",
"def validate_x_y_coords(x, y)\n validate_x_coords(x)\n validate_y_coords(y)\n end",
"def test_player_coord_input\n # true if finalize_ship_coords == true\n @ship.valid_coords = finalize_ship_coords(@player_orientation,\n @player_base_coords)\n end",
"def to_coord\n self[:to_coord].to_sym unless self[:to_coord].blank?\n end",
"def latlng_good?\n self.addr_latlng && self.addr_latlng.lat && self.addr_latlng.lng\n end",
"def airship_land_ok?(x, y)\n return passable?(x, y, 0x08)\n end",
"def check_valid_position(xcoord, ycoord)\n\tif xcoord >= GRID_SIZE || xcoord < 0\n\t\treturn false\n\telsif ycoord >= GRID_SIZE || ycoord < 0\n\t\treturn false\n\telse\n\t\treturn true\n\tend\nend",
"def collect_coords\n if $new_game.lives == 0\n self.game_over\n elsif $new_game.targets == 0\n self.win\n else\n $new_game.print_grid\n self.info\n row = \"z\"\n while $abc.index(row) == nil\n puts \"Enter row coordinate (A - J):\"\n row = gets.chomp.downcase.to_s\n row_num = $abc.index(row)\n end\n col = \"\"\n while (\"0\"..\"9\").to_a.index(col) == nil\n puts \"Enter column coordinate (0 - 9):\"\n col = gets.chomp\n end\n self.check_coords([row_num,col.to_i])\n end\n end",
"def area(box)\n nw_lon = box[0][0]\n nw_lat = box[0][1]\n se_lon = box[1][0]\n se_lat = box[1][1]\n y = abs(nw_lat - se_lat)\n x = abs(nw_lon - se_lon)\n x = x < 180 ? x : 360-x\n return x*y\n end",
"def interior?(coords)\n x, y, z = coords\n x >= @origin_x && x <= @max_x &&\n y >= @origin_y && y <= @max_y &&\n z >= @origin_z && z <= @max_z\n end",
"def text_coordinates\n return 28, 5, 152, 16\n end",
"def alpha; end",
"def airship_land_ok_rect?(x, y, rect)\r\r\n x2 = x + (rect.x / 32.0)\r\r\n y2 = y + (rect.y / 32.0)\r\r\n x3 = x2 + (rect.width / 32.0)\r\r\n y3 = y2 + (rect.height / 32.0)\r\r\n return false unless check_passage(x2, y2, 0x0800) && check_passage(x2, y2, 0x0f)\r\r\n return false unless check_passage(x2, y3, 0x0800) && check_passage(x2, y3, 0x0f)\r\r\n return false unless check_passage(x3, y2, 0x0800) && check_passage(x3, y2, 0x0f)\r\r\n return check_passage(x3, y3, 0x0800) && check_passage(x3, y3, 0x0f)\r\r\n end",
"def convert_to_piece_position(coordinates)\n alpha = ('a'..'h').to_a\n\n row_index, column_index = coordinates\n\n alpha[row_index-1] + column_index.to_s\n end",
"def construct_coordinates\n construct_latitude\n construct_longitude\n end",
"def geom_coords\n# self.geom.geometry_n(0).y.to_s + \" \" + self.geom.geometry_n(0).x.to_s\n \"\" + self.latitude.to_s + \" \" + self.longitude.to_s\n end",
"def paint_coordinates\n result = []\n areas.each do |a|\n # TODO: This is a hack so that only land is painted.\n # Fix this up with a mapping in from type => col the\n # XML file.\n result |= a.coordinates if a.type == 'a'\n end\n result\n end",
"def isLegalCoord(row, col)\n legal = false\n if row == '1' || row == '7'\n if col == 'A' || col == 'D' || col == 'G'\n legal = true\n end\n elsif row == '2' || row == '6'\n if col == 'B' || col == 'D' || col == 'F'\n legal = true\n end\n elsif row == '3' || row == '5'\n if col == 'C' || col == 'D' || col == 'E'\n legal = true\n end\n elsif row == '4'\n if col == 'A' || col == 'B' || col == 'C' || col == 'E' || col == 'F' || col == 'G'\n legal = true\n end\n end\n\n return legal\n end",
"def valid_xy?(c)\n if (c.length == 2 && c[0].is_i? && c[1].is_i?)\n return true\n else\n return false\n end\n end",
"def en_passant_coords(from)\n pawn = @board.at(from)\n [1, -1].each do |x|\n next_coords = [from[0] + x, from[1]]\n next_piece = @board.at(next_coords)\n if next_piece.class == Pawn && next_piece == @last_piece &&\n next_piece.moves_count == 1 && from[1].between?(3, 4)\n return [from[0] + x, from[1] + pawn.direction]\n end\n end\n nil\n end",
"def coord_within_map?(array)\n array.map!(&:to_i)\n map = Socrata::Map.all.last\n if array.first <= map.x && array.first >= 0 && array.last <= map.y && array.last >= 0\n true\n else\n false\n end\n end",
"def display(world,i)\n puts \"Generation #{i+1}:\"\n x_list = []\n y_list = []\n world.each do |item|\n x_list.push(item[0])\n y_list.push(item[1])\n end\n ###############print the map###################\n for y in (y_list.min-3..y_list.max+3) do\n for x in (x_list.min-3..x_list.max+3) do\n if world.include?([x,y])\n print \"1\"\n else\n print \"0\"\n end\n end\n puts\n end\nend"
] | [
"0.63943475",
"0.62359285",
"0.58059454",
"0.5781434",
"0.5739325",
"0.56117046",
"0.5534256",
"0.55108815",
"0.5475754",
"0.54735243",
"0.5465022",
"0.54584366",
"0.54516125",
"0.54269564",
"0.5425684",
"0.5421114",
"0.53969896",
"0.53943986",
"0.53925246",
"0.5392404",
"0.5391805",
"0.5371204",
"0.536003",
"0.5350411",
"0.53286415",
"0.5328513",
"0.531482",
"0.5302841",
"0.52983",
"0.5284645",
"0.5236597",
"0.52342427",
"0.5228743",
"0.5228743",
"0.5225028",
"0.52246934",
"0.5220154",
"0.5220154",
"0.5218176",
"0.52130926",
"0.52070606",
"0.5206656",
"0.5206656",
"0.5194946",
"0.5192167",
"0.519182",
"0.5181825",
"0.51817584",
"0.5179242",
"0.5179186",
"0.5170468",
"0.5167502",
"0.51612616",
"0.51597756",
"0.51594186",
"0.5153318",
"0.5151448",
"0.5147939",
"0.5138523",
"0.5137337",
"0.51331514",
"0.51301366",
"0.51254505",
"0.512521",
"0.5124654",
"0.5124379",
"0.51225024",
"0.5119309",
"0.5118714",
"0.51169205",
"0.51152164",
"0.51137984",
"0.51111823",
"0.51098585",
"0.5109718",
"0.51031345",
"0.5103097",
"0.510042",
"0.5094967",
"0.50945586",
"0.5094415",
"0.5093508",
"0.5093492",
"0.5092329",
"0.5092091",
"0.50885487",
"0.5080167",
"0.5075817",
"0.5075448",
"0.5074369",
"0.5069804",
"0.50662494",
"0.506421",
"0.5064065",
"0.5063834",
"0.50583035",
"0.50573945",
"0.5057345",
"0.50535035",
"0.50506437",
"0.50464284"
] | 0.0 | -1 |
Used by the threadsafe testing | def method_missing(method_name,*args)
if PedantMysql2.respond_to?(method_name, true)
PedantMysql2.send(method_name,*args)
else
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lock; end",
"def lock; end",
"def lock; end",
"def synchronized?; end",
"def executor; end",
"def executor; end",
"def executor; end",
"def thread()\n #This is a stub, used for indexing\n end",
"def lock!; end",
"def test_readwrite_thread_safe\n @cache[:num] = 0\n @num = 0\n\n threads = []\n 15.times do\n threads << Thread.new{ @cache[:num] = Thread.current.object_id }\n end\n 15.times do\n threads << Thread.new{ assert @cache[:num] }\n end\n threads.each do |t|\n t.join\n end\n end",
"def allow_concurrency; end",
"def allow_concurrency; end",
"def mutex; end",
"def mutex; end",
"def mutex; end",
"def mutex; end",
"def thread; end",
"def thread; end",
"def thread; end",
"def refork; end",
"def private; end",
"def sync; end",
"def pausable; end",
"def sleepy_run; end",
"def sync() end",
"def sync() end",
"def sync() end",
"def in_new_thread; end",
"def in_parallel?; end",
"def locked; end",
"def running_test_case; end",
"def __dummy_test__\n end",
"def sync()\n #This is a stub, used for indexing\n end",
"def do_not_thread; true; end",
"def do_not_thread; true; end",
"def do_not_thread; true; end",
"def io_lock; end",
"def spec; end",
"def spec; 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 test_cyclic\n end",
"def run() end",
"def ready; end",
"def ready; end",
"def self_test; end",
"def self_test; end",
"def __mock_reset; end",
"def _test_threads\n m = Mutex.new \n threads = []\n @custom_number_of_users.times do\n threads << Thread.new do\n m.synchronize {threaded_mage_checkout}\n threaded_mage_checkout\n end\n end\n threads.each {|x| x.join}\n end",
"def pre_sleep; end",
"def waiting; end",
"def waiting; end",
"def running_test_step; end",
"def testloop\n \n end",
"def before_run; end",
"def ready=(_); end",
"def robots_mutex; end",
"def allow_concurrency=(_arg0); end",
"def allow_concurrency=(_arg0); end",
"def work_pool; end",
"def wait; end",
"def wait; end",
"def wait; end",
"def running; end",
"def running; end",
"def run(_); end",
"def run(_); end",
"def multithreaded\n get_value :multithreaded\n end",
"def used?; end",
"def example_pending; end",
"def implicit_wait; end",
"def allowing_other_threads; end",
"def future; end",
"def monitor; end",
"def thread_safe?\n false\n end",
"def before_teardown; end",
"def test_connection\n end",
"def access_locked?; end",
"def lock\n end",
"def try_lock\n end",
"def lock_timeout; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end"
] | [
"0.68034595",
"0.68034595",
"0.68034595",
"0.6732229",
"0.6650597",
"0.6650597",
"0.6650597",
"0.65836334",
"0.64832175",
"0.6458959",
"0.64279455",
"0.64279455",
"0.6419668",
"0.6419668",
"0.6419668",
"0.6419668",
"0.64191043",
"0.64191043",
"0.64191043",
"0.64079213",
"0.63163066",
"0.6310219",
"0.63024056",
"0.6280702",
"0.6266216",
"0.6266216",
"0.6266216",
"0.622684",
"0.62224424",
"0.6188689",
"0.6132711",
"0.61090916",
"0.6099573",
"0.60981566",
"0.60981566",
"0.60981566",
"0.60908693",
"0.6056356",
"0.6056356",
"0.60412884",
"0.60412884",
"0.60412884",
"0.60412884",
"0.60412884",
"0.60412884",
"0.60412884",
"0.60412884",
"0.60412884",
"0.6037318",
"0.602892",
"0.59626853",
"0.59626853",
"0.5960551",
"0.5960551",
"0.59516776",
"0.59077764",
"0.5900186",
"0.58821434",
"0.58821434",
"0.5877849",
"0.58736956",
"0.58718896",
"0.58478415",
"0.58431745",
"0.58351994",
"0.58351994",
"0.5831562",
"0.58270276",
"0.58270276",
"0.58270276",
"0.58223915",
"0.58223915",
"0.5814508",
"0.5814508",
"0.5811173",
"0.58059597",
"0.5799452",
"0.5793447",
"0.57780194",
"0.5777887",
"0.5766258",
"0.5727335",
"0.572707",
"0.5724185",
"0.5719216",
"0.57150406",
"0.5711295",
"0.5709749",
"0.5698058",
"0.5698058",
"0.5698058",
"0.5698058",
"0.5698058",
"0.5698058",
"0.5698058",
"0.5698058",
"0.5698058",
"0.5698058",
"0.5698058",
"0.5698058",
"0.5698058"
] | 0.0 | -1 |
Return the argument with all its lowercase characters removed. | def destructive_uppercase(str)
my_str = ""
str.chars{|ch| my_str += ch if ch.upcase == ch}
my_str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toLower _args\n \"toLower _args;\" \n end",
"def squash\n upcase.delete('^A-Z0-9')\n end",
"def normalize\n input.upcase\n end",
"def destructive_uppercase(str)\n str.delete(\"abcdefghijklmnopqrstuvwxyz\")\nend",
"def normalized\n @original.downcase\n end",
"def do_magic(str)\n str.gsub!(/[^A-Z]/, '').to_s #delete small leters and uprinted sumbols\n str.downcase.to_s #make all leters small\nend",
"def downcase!() end",
"def downcase\n `return self.toLowerCase();`\n end",
"def downcase\n `return self.toLowerCase();`\n end",
"def mixed_case(name)\n name.downcase.gsub(/\\b\\w/, &:upcase)\nend",
"def shout(a)\n return a.upcase\nend",
"def xyzzy(a_value)\n a_value.upcase\nend",
"def sanitize(param)\n result = param.sub(/_/,' ')\n result.upcase!\n end",
"def to_lower_case(s)\n s.dup.downcase\nend",
"def downcase(input); end",
"def remove_letter_a(words)\nend",
"def remove_letter_a(words)\n\nend",
"def downcase() end",
"def remove_capital_letters_from_string(string)\n string.gsub(/[A-Z]/,\"\") \nend",
"def remove_capital_letters_from_string(string)\n string.gsub(/[A-Z]/, \"\")\nend",
"def shout(str)\n return str.upcase\nend",
"def downcase; end",
"def upcase!() end",
"def titlecase!\n replace(titlecase)\n end",
"def downer2(string)\n string.downcase!\nend",
"def clean_string(input)\n input.downcase.strip\n end",
"def constantize(string)\n return string.downcase.gsub(/[^a-z]/i, '') \n end",
"def downcase\n\t\tcollect(&:downcase)\n\tend",
"def mixed_case(name)\n\tname.downcase.gsub(/\\b\\w/) {|first| first.upcase}\nend",
"def shout(str)\n str.upcase\nend",
"def woolong(argu)\n if argu.length.to_i > 10\n argu.upcase!\n else\n argu\n end\nend",
"def question5(str) # Modify str, returning a lowercased version\n\n end",
"def downcase!\n @raw.downcase!\n end",
"def shout(word)\n\treturn word.upcase\nend",
"def destructive_uppercase(str)\n str.each_char {|x| str.delete!(x) if x == x.downcase}\n str\nend",
"def remove_capital_letters_from_string(string)\n string.gsub!(/[A-Z]/,'')\nend",
"def only_letters(word)\n word.delete(\"^A-z\")\nend",
"def normalize(str) return str.upcase end",
"def alphafilter\n self.gsub(/[^a-zA-Z\\s]/, '')\n end",
"def lowercase_name\n name.downcase\n end",
"def name_case!\n self.gsub!(self, self.name_case)\n end",
"def strip_and_downcase_name\n if name.present?\n name.strip!\n name.downcase!\n end\n end",
"def cleanup(str)\n str.gsub(/[^a-z]/i, '')\nend",
"def bar(s)\n s.upcase\nend",
"def shout(str); str.upcase end",
"def downcase_name\n name.downcase!\n end",
"def to_param\n lowercase_name.parameterize\n end",
"def clean_string(string)\n return string.downcase.gsub(/[^a-z0-9]/, '')\nend",
"def normalize_name\n @normalize_name ||= begin\n return '' if name.empty?\n\n exclude = %w[corporation institute organization university\n all and of the].join('|')\n tmp = name.dup\n tmp.gsub!(/#{exclude}/i, '')\n tmp.gsub!(/\\s+/, ' ')\n tmp.strip!\n tmp.downcase # it's not case sensitive\n end\n end",
"def fixInput()\n\t# Debug output\n\tif $DEBUG then STDERR.puts \"in fixInput()\" end\n\n\tremainingChars = 10\n\tmodifiedInput = \"\"\n\n\tARGV.each do |arg| \n\t\tif arg.length > remainingChars then\n\t\t\tmodifiedInput += arg[0...remainingChars]\n\t\t\tbreak\n\t\telse\n\t\t\tmodifiedInput += arg\n\t\t\tremainingChars -= arg.length\n\t\tend\n\tend\n\n\treturn modifiedInput.downcase\nend",
"def shout(string)\n\treturn string.upcase\nend",
"def mixed_case_2(name)\n\tname.downcase.gsub(/\\b\\w/, &:upcase)\nend",
"def smash\n downcase.scan(/\\w+/).join\n end",
"def upcase(input); end",
"def shout(word)\n upper_case = word.upcase\nend",
"def shout string\n string.upcase\nend",
"def fdowncase\n downcase.cdowncase\n end",
"def sanitize_case(value, kase)\n return value if value.nil?\n\n if kase == :camelcase\n value.camelcase(:lower)\n elsif kase == :pascalcase\n value.camelcase(:upper)\n else\n value.send(kase)\n end\n end",
"def toUpper _args\n \"toUpper _args;\" \n end",
"def destructive_uppercase(str)\n str.each_char do |c|\n str.delete!(c) if c == c.downcase\n end\nend",
"def caps(string)\n return string.upcase\nend",
"def caps(string)\n return string.upcase\nend",
"def shout (s)\n s.upcase\nend",
"def sanatise_input(input)\n if input == nil\n ''\n else\n input.strip.downcase\n end\n end",
"def string_normalizer(string)\n string.downcase.gsub(/[^0-9a-z ]/i, '')\n end",
"def downer(string)\n string.downcase\nend",
"def downcase_username\n self.username.downcase!\n end",
"def sanitize(words)\n#lowercases the string\n lower_case = lowerCase(words)\n#removes all the special elements\nclean_string = clean(lower_case)\nend",
"def lower_case!(words)\n raise NotImplementedError # TODO\nend",
"def cleanup(text)\n text.gsub(/[^a-z]/i, '')\nend",
"def sanitize_attribute_name(name)\n name.gsub(/[^\\w\\-_]/, '').downcase\n end",
"def destructive_uppercase(str)\n upcase_only = \"\"\n str.each_char do |char|\n upcase_only += char unless char.downcase == char\n end\n upcase_only\nend",
"def clean_str(word)\n word.gsub(/[^\\w]/, '').downcase\n end",
"def destructive_uppercase(str)\n new_string = str.chars.select {|el| el == el.upcase}\n new_string.join(\"\")\nend",
"def sanitize(string)\n downcase_string = string.chars.sort.join.downcase\n result = string_to_characters(downcase_string) #returns a sanitized string\nend",
"def downer1(string)\n string.downcase\nend",
"def titlecase(input)\n input.titlecase\n end",
"def titlecase\n gsub(/\\b\\w/){ $`[-1,1] == \"'\" ? $& : $&.upcase }\n end",
"def upcase() end",
"def spell_out str\n str.downcase\nend",
"def normalize(incoming_str)\n if normalizer\n return normalizer.call(incoming_str)\n end\n\n str = incoming_str\n str = str.downcase\n str = str.gsub(/[^a-z0-9]/, \" \")\n # squish whitespace\n str = str.gsub(/\\s+/, \" \").strip\n str\n end",
"def input_downcase(input)\n @input = input.downcase.to_s\n end",
"def my_upcase\n upcased_arg = ARGV[0].gsub(/[a-z]/) { |char| (char.ord - 0x20).chr }\n $stdout.puts(upcased_arg)\nend",
"def caps(str)\n str.upcase\n end",
"def remove_non_words_and_downcase str\n # \\W means charcaters not in range [a-zA-z0-9_]\n # dash '-' is removed, but underscore '_' is kept\n # whitespace is not part of \\w so they are removed, too!\n str.downcase\n .gsub(/\\W/, '')\nend",
"def normalize_input\n self.name = name.downcase\n end",
"def cleanCategoryTitle string\n string.strip.upcase\n end",
"def underscorize!\n self.replace(self.scan(/[A-Z][a-z]*/).join(\"_\").downcase)\n end",
"def shout (text)\n text = text.upcase\n return text\nend",
"def destructive_uppercase(str)\n result = \"\"\n (0...str.length).each do |idx|\n result << str[idx] if str[idx] != str[idx].downcase\n end\n result\nend",
"def vwl_rmv string\n # .downcase changes to lowercase, .delete! removes vowels\n string.downcase.delete!('aeiou')\nend",
"def shout(word)\n puts word.upcase\n end",
"def downcase_word\n word.downcase!\n end",
"def clean_for_comp( address = '' )\n address.upcase.gsub /[^0-9A-Z]/, ''\nend",
"def sanitize_name(name)\n name.gsub(/\\//,\"\").gsub(/\\s/, \"-\").downcase\nend",
"def reverse_upcase_noLTA(str)\n str.upcase.reverse.delete\"LTA\"\nend",
"def theBeatles string\n string.downcase.delete \"aeiou\"\nend",
"def sanitize_alpha(input_word)\n input_word.chars.each do |c|\n input_word.delete!(c) unless $alpha.include?(c)\n end\n return input_word\nend",
"def upcase; end",
"def downCaseFirst(original)\n original[0].chr.downcase + original[1..-1]\n end",
"def downcase_first\n\t\treturn self.blank? ? \"\" : self[0].downcase + self[1..-1]\n\tend"
] | [
"0.7506067",
"0.7171146",
"0.6986691",
"0.69201416",
"0.69054854",
"0.6856572",
"0.6830009",
"0.6782394",
"0.6782394",
"0.6773672",
"0.67507994",
"0.6733905",
"0.67071605",
"0.6702155",
"0.6677236",
"0.6655953",
"0.66153115",
"0.6611506",
"0.6610638",
"0.65936375",
"0.6591416",
"0.65814203",
"0.65777534",
"0.6567375",
"0.6555216",
"0.6549599",
"0.6548658",
"0.6518465",
"0.6506041",
"0.6503552",
"0.6498905",
"0.6494937",
"0.6484023",
"0.64837325",
"0.6482325",
"0.6480192",
"0.6461884",
"0.6450418",
"0.64464843",
"0.6435554",
"0.6433081",
"0.641899",
"0.6414107",
"0.6411588",
"0.64070165",
"0.63940716",
"0.6390641",
"0.63739234",
"0.6371951",
"0.63662076",
"0.6366059",
"0.63538545",
"0.6346303",
"0.6344303",
"0.6328472",
"0.63268954",
"0.6322775",
"0.6312974",
"0.6311103",
"0.6306972",
"0.629832",
"0.629832",
"0.62970555",
"0.6294229",
"0.6287198",
"0.6272039",
"0.6257138",
"0.62558585",
"0.62443715",
"0.6236065",
"0.6235847",
"0.6233806",
"0.62285244",
"0.62177825",
"0.6213874",
"0.6203376",
"0.61994886",
"0.6199228",
"0.61986923",
"0.6192586",
"0.6192508",
"0.61924034",
"0.6190032",
"0.6174082",
"0.6173858",
"0.61736035",
"0.6168935",
"0.6156983",
"0.6149334",
"0.61394256",
"0.6134519",
"0.61344904",
"0.61246526",
"0.6122646",
"0.61190206",
"0.61160773",
"0.6115261",
"0.61138344",
"0.6107184",
"0.60949796",
"0.60948455"
] | 0.0 | -1 |
Return the middle character of a string. Return the middle two characters if the word is of even length, e.g. middle_substring("middle") => "dd", middle_substring("mid") => "i" | def middle_substring(str)
length = str.length
if length.odd?
str[length/2]
else
str[length/2-1,2]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def middle_substring(str)\n mid = str.length / 2\n str.length.odd? ? str[mid] : str[mid-1..mid]\nend",
"def middle_substring(str)\n mid = str.length / 2\n str.length.odd? ? str[mid] : str[mid - 1] + str[mid]\nend",
"def middle_substring(str)\n mid = str.length / 2\n str.length.even? ? str[mid-1..mid] : str[mid]\nend",
"def middle_substring(str)\n middle_left = str.length / 2\n middle_right = middle_left - 1\n if str.length % 2 == 0\n return \"#{str[middle_right]}#{str[middle_left]}\"\n else\n return \"#{str[middle_left]}\"\n end\nend",
"def middle_substring(str)\n return str[str.length/2] if str.length % 2 != 0\n str[str.length/2-1] + str[str.length/2]\nend",
"def middle_substring(str)\n mid = str.length/2\n if str.length%2==0\n return str[mid-1..mid]\n else\n return str[mid]\n end\nend",
"def middle_string(str)\n mid = str.length / 2\n if str.length.odd?\n return str.[mid]\n else\n return str[middle -1 ] + [str.middle]\n end\nend",
"def middle_substring(str)\r\n # your code goes here\r\n x = str.length\r\n if x % 2 == 1\r\n return str[x/2]\r\n else\r\n str[x/2 - 1] + str[x/2]\r\n end\r\nend",
"def middle_substring(str)\n output_str = ''\n\n if str.length % 2 == 1\n odd_i = str.length / 2\n output_str += str[odd_i]\n else\n even_i1 = str.length / 2 - 1\n even_i2 = (str.length / 2)\n\n output_str += str[even_i1]\n output_str += str[even_i2]\n end\n\n output_str\nend",
"def get_middle(str)\n l = str.length\n return str.chars[l / 2] if l.odd?\n\n str.chars[l / 2 - 1] + str.chars[l / 2]\nend",
"def middle_substring(str)\n median = (str.size / 2)\n str.length.even? ? str[(median - 1)..median] : str[median]\nend",
"def middle_substring(str)\n n = str.length / 2\n if str.length % 2 == 0\n str[(n-1)..(n)]\n else\n str[n]\n end\nend",
"def get_middle(str)\n str.length.even? ? str.slice(str.length / 2 - 1, 2) : str.slice(str.length / 2)\nend",
"def middle_character(string)\n array = string.split('')\n middle_index = (array.size / 2.0).floor\n if array.size.odd?\n array.slice(middle_index)\n else\n array.slice((middle_index - 1), (middle_index)).join\n end\nend",
"def middle_word(string)\n words = string.split\n word_count = words.length\n mid_index = word_count / 2\n if word_count == 0\n ''\n elsif word_count.even?\n # if even number of words, return the two words across the middle.\n \"#{words[mid_index - 1]} #{words[mid_index]}\"\n else\n words[mid_index]\n end\nend",
"def middle(str)\r\n words = str.split\r\n n = words.size\r\n case\r\n when (0..1).include?(n)\r\n return str\r\n when n.even?\r\n middle_ind = (n / 2) - 1\r\n else\r\n middle_ind = (n / 2)\r\n end\r\n words[middle_ind]\r\nend",
"def middle_character(string)\n array = string.split('')\n middle_char = ''\n middle_index = (array.size / 2.0).floor\n if array.size.odd?\n middle_char << array[middle_index]\n else\n middle_char << array[middle_index - 1] << array[middle_index]\n end\n middle_char\nend",
"def get_middle(string)\n if string.length.even?\n return string[string.length/2-1] + string[string.length/2]\n else\n return string[string.length/2]\n end\nend",
"def middle_word(str)\n words = str.split(\" \")\n middle_word = words[words.size/2]\nend",
"def middle_two(str)\n mid = str.length / 2\n str[mid - 1...mid + 1]\n end",
"def get_middle(string)\n half, remainder = string.size.divmod(2)\n middle = (half + remainder) - 1\n string.size.even? ? string[middle..(middle + 1)] : string[middle]\nend",
"def get_middle(s)\n if s.length % 2 == 0\n return \"#{s[(s.length / 2) - 1]}#{s[s.length / 2]}\"\n else\n return \"#{s[(s.length - 1) / 2]}\"\n end\nend",
"def middle_word(string)\n words = string.split\n case words.size.odd?\n when true\n index = (words.size/2) \n words[index]\n when false\n \"Unable to determine middle word. An odd number of words are necessary.\"\n end\nend",
"def get_middle(s)\n count = s.length\n count % 2 == 0 ? s[count/2-1..count/2] : s[count/2]\nend",
"def middle(string)\n index = string.split.size/2\n size = string.split.size\n if size == 1\n string\n elsif size.odd?\n string.split[index]\n else\n \"#{string.split[index - 1]} #{string.split[index]}\"\n end\nend",
"def middle(str)\n words = str.split\n\n if words.size == 0\n 'empty string provided'\n elsif words.size == 1\n words[0]\n elsif words.size.odd?\n words[(words.size / 2.0).floor]\n else\n words[(words.size / 2) - 1] + ' ' + words[(words.size / 2)]\n end\nend",
"def get_middle(s)\n if s.length % 2 == 0\n s[s.length/2-1] + s[s.length/2]\n else\n s[s.length/2]\n end\nend",
"def center_of(string)\n if string.size.odd?\n middle_character = string[string.size / 2]\n else\n middle_characters = string[string.size / 2 - 1, 2]\n end\nend",
"def middle(string)\n words = string.split\n size = words.size\n if size < 2\n puts 'Sorry, you have to provide a string with at least 2 words'\n nil\n else\n size.even? ? middle = (size / 2) - 1 : middle = (size / 2)\n words[middle]\n end\nend",
"def middle_substring(str)\n\ta = str.chars\n\twhile (a.length >= 3)\n\t\ta.pop\n\t\ta.shift\n\tend\n\ta.join\nend",
"def get_middle(s)\n len = s.length\n return s if len == 1\n\n half = len / 2\n return s[half - 1..half] if len % 2 == 0\n\n s[half]\nend",
"def middle_word(text)\n words = text.split\n return '' if words.size <= 1\n\n words[words.size / 2]\nend",
"def get_middle(s)\n mid = (s.length - 1) / 2\n s.length.odd? ? s[mid] : s[mid..mid+1]\nend",
"def get_middle(s)\n mid = (s.length - 1) / 2\n s.length.odd? ? s[mid] : s[mid..mid+1]\nend",
"def get_middle(s)\nreturn s.length % 2 == 0 ? s[s.length / 2 - 1] + s[s.length / 2] : s[(s.length / 2).floor]\n\nend",
"def middle(string)\n\ta=string.size/2\n\treturn string[a-1]<<string[a] if string.size.even?\n\tstring[a]\n\t\nend",
"def get_middle(s)\n s.length.even? ? s[s.length/2 -1] + s[s.length/2] : s[s.length/2]\nend",
"def get_middle(s)\r\n s.length.odd? ? s[s.length / 2] : s[s.length / 2 - 1] + s[s.length / 2]\r\nend",
"def center_of(string)\n str_length = string.size\n middle = \"\"\n \n return string if str_length < 3\n \n if str_length.odd?\n middle = string[str_length / 2, 1]\n else\n middle = string[(str_length / 2) - 1, 2]\n end\n \n middle\nend",
"def get_middle(s)\n s.length.even? ? s[s.length/2 - 1] + s[s.length/2] : s[s.length/2]\nend",
"def center_of(string)\n middle = string.length / 2\n string.length.even? ? string.slice(middle - 1, 2) : string.slice(middle)\nend",
"def get_middle(s)\n\tif s.size.odd?\n\t\taverage_letter = s.size.div 2 #3\n\t\treturn s[average_letter]\n\telsif s.size.even?\n\t\taverage_letter = s.size.div 2\n\t\treturn s[(average_letter - 1)..average_letter]\n\tend\nend",
"def center_of(str)\n middle = (str.length/2)\n if str.length.odd?\n str[middle]\n else\n str[(middle-1)..middle]\n end\nend",
"def get_middle(s)\n if (s.length.odd?)\n return (s[(s.length / 2).ceil])\n else\n return (s[(s.length / 2) - 1] + s[(s.length/2)])\n end\nend",
"def center_of(string)\n middle = string.size / 2\n string.size.odd? ? string[middle] : string[middle-1, 2]\nend",
"def center_of(string)\n middle = string.size/2\n string.size.odd? ? string[middle] : string[middle-1, 2]\nend",
"def center_of(str)\n middle_range = (str.length/2 -1..str.length/2 )\n middle_index = str.length / 2\n index = str.length.odd? ? middle_index : middle_range\n str[index]\nend",
"def middle_sign(string)\n\n a_string = string.chars\n\n if a_string.length % 2 == 0\n middle = [a_string[a_string.length / 2], a_string[a_string.length / 2 - 1]].join\n else\n middle = a_string[a_string.length / 2]\n end\n\nmiddle\nend",
"def center_of(string)\n middle = string.size / 2\n return string[middle] if string.size % 2 == 1\n string[middle - 1..middle] if string.size % 2 == 0\nend",
"def center_of(str)\n if str.length.odd?\n str[str.length / 2]\n else\n str[str.length / 2 - 1, 2] # this sets length of 2 char from position\n end\nend",
"def get_middle(s)\n if s.length.even? == true\n else\n end\nend",
"def get_middle(s)\n return s if s.size == 1 || s.size == 2\n get_middle(s[1..-2])\nend",
"def center_of(string)\n middle_index = string.size / 2\n\n if string.size.odd?\n string[middle_index]\n else\n string[middle_index - 1] + string[middle_index]\n end\nend",
"def center_of(string)\n center = string.length / 2\n\n if string.length.odd?\n string[center]\n else\n \"#{string[center - 1]}#{string[center]}\"\n end\nend",
"def center_of(str)\n midpoint = str.length / 2\n if str.length.even?\n str[midpoint - 1..midpoint]\n else\n str[midpoint]\n end\nend",
"def middle_of(sentence)\n return \"\" if sentence == \"\"\n words = sentence.split\n if words.size % 2 == 0 \n words[words.size/2-1] + \" \" + words[words.size/2]\n else\n words[words.size/2]\n end\nend",
"def center_of(string)\n center_index = string.size / 2\n if string.size.odd?\n string[center_index]\n else\n string[center_index -1, 2]\n end\nend",
"def center_of(string)\n center_index = string.size / 2\n if string.size.odd?\n string[center_index]\n else\n string[center_index - 1, 2]\n end\nend",
"def center_of(str)\n count = str.size\n middle = count / 2\n count.odd? ? str[middle] : str[middle-1..middle]\nend",
"def center_of(string)\n length = string.length\n\n case length % 2\n when 1 then string[length / 2]\n else string[(length /2) - 1, 2]\n end\nend",
"def center_of(string)\n half = (string.length / 2) - 1\n center = string[(string.length / 2)] if string.length.odd?\n center = string[half..half+1] if string.length.even?\n center\nend",
"def center_of(str)\n length = str.length\n center = length / 2\n if length.even?\n center_right = center\n center_left = center - 1\n str[center_left .. center_right]\n else\n str[center]\n end\nend",
"def middle_word(string)\n if (string.is_a? String) == false || string.empty? || (string.split.size == 1)\n puts 'You did not enter a valid String, please try again'\n elsif string.split.size.even?\n puts \"Your string doesn't have a middle word, it's an even amount of words\"\n else\n words = string.split\n words[words.size / 2]\n end\nend",
"def center_of(string)\n index = string.size/2\n if string.size.odd?\n string[index]\n else\n string[index - 1, 2]\n end\nend",
"def center_of(string)\n string_length = string.size\n string_center = string_length / 2\n \n if string_length.odd?\n string[string_center]\n else\n string[(string_center - 1)..string_center]\n end\nend",
"def get_middle(s)\n (s.size.odd?) ? s[(s.size / 2)] : s[(s.size - 1) / 2, 2]\nend",
"def center_of(str)\n mid_point = str.size / 2.0\n if str.size.odd?\n str[mid_point]\n else \n str[(mid_point - 1), 2]\n end\nend",
"def center_of(str)\n str.length.odd? ? str[str.length / 2] : str[(str.length / 2) - 1, 2]\nend",
"def center_of(string)\n center_index = string.size / 2\n if string.size.odd?\n string[center_index]\n else\n string[center_index - 1, 2] # 2 is the number of character contained in 'slice'\n end\nend",
"def middle_word(string)\n words = string.split(' ')\n size = words.size\n if size == 0\n \"Invalid input! Empty string!\"\n elsif size.even?\n \"Invalid input! Even number of words in sentance!\"\n elsif size == 1\n \"Invalid input! Only one word in the string!\"\n else\n words[-(size/2)-1]\n end\nend",
"def get_first_half_of_string(string)\n string[0..(string.length - 1)/2]\nend",
"def center_of(str)\n str.chars.size.odd? ? str.slice(str.chars.length/2, 1) : str.slice(str.chars.length/2-1, 2)\nend",
"def get_first_half_of_string(string)\n string[0..(string.length-1)/2]\nend",
"def center_of(string)\n midpoint = string.size / 2\n string.length.odd? ? string[midpoint] : string[midpoint - 1..midpoint]\nend",
"def center_of(string)\n char = ''\n if string.size.odd?\n char << string[string.size / 2]\n else\n char << string[(string.size / 2) - 1, 2]\n end\nend",
"def center_of(str)\n index = str.size / 2\n str.size.even? ? str[index - 1, 2] : str[index]\nend",
"def center_of(str)\n half_point = str.size / 2 \n \n if str.size.odd?\n str[half_point]\n else\n str[half_point-1,2]\n end\nend",
"def center_of(string)\n center = ''\n\n if string.size.even?\n center = string[string.size/2 - 1 .. string.size/2]\n else\n center = string[string.size/2]\n end\n center\nend",
"def center_of(string)\n half_size = string.size / 2\n case \n when string.size.odd? then string[half_size]\n when string.size.even? then string[half_size - 1, 2] \n end\nend",
"def get_middle(s)\n s[(s.size - 1) / 2..s.size / 2] # s.size / 2 will round down == .floor\nend",
"def get_first_half_of_string(string)\n half_string = (string.length.to_f/2).ceil\n string[0,half_string] \nend",
"def center_of(string)\n size = string.size\n mid = size / 2\n \n size.odd? ? string[mid] : string[mid - 1] + string[mid]\nend",
"def first_half(str)\n str[0...str.length / 2]\n end",
"def middle_name\n name.split[1..-2].join(' ')\n end",
"def center_of(str)\n sz = str.size\n sz.even? ? str[sz / 2 - 1, 2] : str[sz / 2]\nend",
"def center_of(string)\n array = string.chars\n if array.size.odd?\n array[array.length/2]\n else\n array[(array.length/2 -1)..array.length/2].join\n end \nend",
"def center_of(str)\n return str[str.size/2] if str.size.odd?\n return str[(str.size/2)-1] + str[(str.size/2)]\nend",
"def center_of(string)\n if string.size.odd?\n p string[string.size / 2] # no need: string[(string.size - 1) / 2], since/2 get an integer\n else\n p string[(string.size / 2 - 1), 2]\n end\nend",
"def center_of(str)\n new_str = ''\n if str.length.odd?\n new_str = str[str.length / 2]\n else\n new_str = str[(str.length / 2) - 1] + str[str.length / 2] \n end\n p new_str\nend",
"def get_first_half_of_string(string)\n # Find string length\n # half string length\n # if odd, add one\n string_length = string.size\n string_length += 1 if string_length.odd?\n half_string_length = string_length/2\n string[0..(half_string_length-1)]\n #return string up to half\nend",
"def get_first_half_of_string(string)\n\tnumber_of_characters = string.chars.count\n\thalf = (number_of_characters/2.0).ceil\n\tstring.slice(0, half)\nend",
"def center_of(string)\n middle = (string.size - 1) / 2.0\n string[middle.floor..middle.ceil]\nend",
"def center_of(str)\n str.size.odd? ? str[str.size/2] : str[str.size/2 - 1..str.size/2]\nend",
"def center_of2(str)\n sz = str.size\n str[(sz - 1) / 2..sz / 2]\nend",
"def center_of(str)\ncharacters = str.chars\naverage = characters.size / 2\nif characters.size.even?\ncharacters[average - 1] + characters[average]\nelse\ncharacters[average]\nend\nend",
"def center_of(string)\n quotient, remainder = (string.size - 1).divmod(2)\n string.slice(quotient, remainder + 1)\nend",
"def middle_sign(words)\n length_words = words.size\n if length_words.odd?\n words[length_words / 2]\n else\n words[length_words / 2 - 1..length_words / 2]\n end\nend",
"def center_of(str)\n p str.size.odd? ? str[str.size / 2] : str[(str.size / 2) - 1..(str.size / 2)]\nend",
"def part_of_word\n @str[@first_letter..@last_letter]\n end",
"def center_of(string)\n if string.size.odd?\n index1 = string.size / 2\n elsif string.size.even?\n index1 = string.size / 2\n index2 = (string.size / 2) - 1\n end\n\n new_string = []\n string_array = string.chars\n if string.size.odd?\n new_string << string_array[index1]\n elsif string.size.even?\n new_string << string_array[index2]\n new_string << string_array[index1]\n end\n new_string.join\nend"
] | [
"0.87034416",
"0.8670274",
"0.8669532",
"0.86034125",
"0.85772747",
"0.85714513",
"0.85622585",
"0.8475449",
"0.84118396",
"0.84047246",
"0.8358755",
"0.8351223",
"0.8342785",
"0.8339462",
"0.82862604",
"0.8273304",
"0.8259641",
"0.82200766",
"0.8187455",
"0.81295437",
"0.81170684",
"0.81031466",
"0.80581015",
"0.8047783",
"0.8002048",
"0.7929923",
"0.791291",
"0.78960866",
"0.78790987",
"0.78778005",
"0.78660476",
"0.78471327",
"0.7819543",
"0.7819543",
"0.77786136",
"0.77288043",
"0.77285224",
"0.77053297",
"0.76794213",
"0.76764137",
"0.7617825",
"0.7612771",
"0.7567141",
"0.7530757",
"0.75044274",
"0.7474629",
"0.74391997",
"0.7432543",
"0.741114",
"0.7365839",
"0.73428935",
"0.7341478",
"0.7322915",
"0.7320811",
"0.7318758",
"0.72848165",
"0.72838116",
"0.7278572",
"0.7277471",
"0.724993",
"0.72356534",
"0.72271025",
"0.7226899",
"0.71807957",
"0.71780884",
"0.71736676",
"0.71670127",
"0.71337914",
"0.7120899",
"0.711871",
"0.71180975",
"0.7106202",
"0.71038073",
"0.7102474",
"0.7085857",
"0.7062224",
"0.7060255",
"0.70481133",
"0.70464766",
"0.7034612",
"0.70022655",
"0.6994852",
"0.6988864",
"0.69836044",
"0.6981237",
"0.6946986",
"0.69263774",
"0.6882019",
"0.6851082",
"0.6846883",
"0.6837505",
"0.680309",
"0.68021876",
"0.6794424",
"0.67471766",
"0.6746482",
"0.6742286",
"0.67375296",
"0.6664186",
"0.6630631"
] | 0.8838202 | 0 |
Return the factoral of the argument (num). A number's factorial is the product of all whole numbers between 1 and the number itself. Assume the argument will be > 0. | def factorial(num)
product = num
(1...num).each{|n| product *= n}
product
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factorial(num)\n\treturn nil if num < 0\n\treturn 1 if num.equal?(0)\n\ti = 1\n\ttotal = 1\n\tnum.times do\n\t\ttotal *= i\n\t\ti += 1\n\tend\n\treturn total\nend",
"def factorial(num)\n\tif num <= 1\n\t\treturn 1\n\telse\n\t\tnum * factorial(num - 1)\n\tend\nend",
"def factorial num\n\tfactorial = 1\n\twhile num > 0\n\t\tfactorial *= num\n\t\tnum -= 1\n\tend\n\treturn factorial\nend",
"def factorial(num)\n\tproduct = 1\n\twhile num > 1\n\t\tproduct = product*num\n\t\tnum -= 1\n\tend\n\tproduct\nend",
"def factorial_of num \n\t(2..num).inject(1) {|product, x| product * x }\nend",
"def factorial(num)\n if num == 0\n 1\n else\n num * factorial(num - 1)\n end\nend",
"def factorial(num)\n raise ArgumentError if num < 0\n if num == 1 || num == 0 # base case\n return 1\n else\n return num * factorial(num - 1)\n end\nend",
"def iterative_factorial(num)\n\tif num < 0 || !(is_integer?(num))\n\t\tFloat::NAN\n\telsif num == (0 || 1)\n\t\t1\n\telse\n\t\tnum.downto(1).reduce(:*)\n\tend\nend",
"def factorial(num)\n if num == 1\n 1\n else\n num * factorial(num - 1)\n end\nend",
"def factorial(num)\n if num <= 1\n 1\n else\n num * factorial(num-1)\n end\nend",
"def factorial(num)\n if num.class != Fixnum || num < 0 || num > 10079\n raise ArgumentError.new(\"this bad\")\n elsif num == 0\n 1\n else\n answer = 1\n while num > 1\n answer *= num\n num -= 1\n end\n answer\n end\nend",
"def factorial(num)\n\tfactor = 1\n\tfact = [0]\n\tif num == 0\n\t\tfactor\n\telse\n\t\tnum.times do |i|\n\t\t\tfact[i] = i+1\n\t\tend\n\t\tp fact\n\t\t(num-1).times do |i|\n\t\t\tfactor = factor * fact[i+1]\n\t\tend\n\t\tfactor\n\tend\nend",
"def factorial(num)\n fact = 1\n (1..num).each { |i| fact *= i }\n return fact\nend",
"def getFactorial(number)\n factorial = 1\n if number > 0\n for i in 1..number\n factorial *= i\n end\n end\n return factorial\n end",
"def factorial(num)\n if num < 2 \n return 1\n end \n fac = num * factorial(num - 1)\nend",
"def iterative_factorial(num)\n if num < 0 || !is_integer?(num)\n return Float::NAN\n elsif num == 0 || num==1\n 1\n else\n (1..num).inject(:*) || 1\n end\nend",
"def factorial(num)\n\t(1..num).reduce(1,:*) \nend",
"def factorial(number)\n if number <= 1\n 1\n else\n number.downto(1).reduce(:*)\n end\nend",
"def factorial(num)\n num == 1 ? num * 1 : num * factorial(num - 1)\nend",
"def factorial(num)\n if num == 0\n return 1\n else\n value = num - 1\n until value == 0\n num *= value\n value -= 1\n end\n return num\n end\nend",
"def getFactorial(num)\n if (num == 1)\n sum = 1\n else\n sum = getFactorial(num-1)*num\n end\n return sum\nend",
"def factorial(number)\n\ttotal = 1\n\tif number == 0\n\t\treturn 1\n\telse\n\t\twhile number > 1\n\t\t\ttotal *= number\n\t\t\tnumber -= 1\n\t\tend\n\t\treturn total\n\tend\nend",
"def iterative_factorial(num)\n return Float::NAN if !num.is_a?(Integer) || num < 0\n fact = 1\n (1..num).each {|i| fact *= i}\n fact\nend",
"def factorialrecursion num\n\tif num < 0\n\t\tnil\n\tend\n\t\n\tif num <= 1\n\t\t1\n\t\telse\n\t\t\tnum * factorial(num - 1)\n\t\tend\n\tend",
"def factorial(num)\n return 1 if num.zero?\n\n num * factorial(num - 1)\nend",
"def factorial(num)\n product = 1\n\n while num > 0\n product *= num\n num -= 1\n end\n \n return product\nend",
"def factorial(num)\n i = 1\n fact = i\n while i <= num\n fact *= i\n i += 1\n end\n return fact\nend",
"def factorial(number)\n if number <= 1\n 1\n else\n (1..number).each.reduce(:*)\n end\nend",
"def factorial(num)\n\tproduct = num\n \titer = num-1\n \twhile(iter>1)\n \tproduct *=iter\n \titer-= 1\n end\n return product\nend",
"def Factorial(num)\ncurrent = num\nproduct = 1\n\n\twhile current > 0\n\t\tproduct = product * current\n\t\tcurrent -= 1\n\tend\n\tproduct\nend",
"def factorial(num)\n (1..num).inject(1) {|a, b| a * b}\nend",
"def factorial num\n if num < 0\n return 'You can\\'t take the factorial of a negative number!'\n end\n if num <= 1\n 1\n else\n num * factorial(num-1)\n end\nend",
"def factorial(number)\n\tproduct = 1\n\tif number == 0\n\t\treturn product\n\telse\n\t\twhile (number > 0)\n\t\t\tproduct *= number\n\t\t\tnumber -= 1\n\t\tend\n\t\treturn product\n\tend\nend",
"def factorial(num)\n return 1 if num == 1\n num * factorial(num - 1)\nend",
"def iterative_factorial(num)\n\tif num < 0\n\t\treturn Float::NAN # a constant meaning \"Not a Number\"\n\tend\n\tmemo = 1\n\t(1..num).each do |i|\n\t\tmemo = memo*i\n\tend\n\tmemo\nend",
"def factorial(number)\n if number == 0\n \treturn 1\n elsif number == 1\n \treturn 1\n end\n i=number-1\n f=number*i\n while i > 1\n \ti=i-1\n \tf=f*i\n end\n return f\nend",
"def factorial(num)\n if num < 0\n return \"You can't take the factorial of a negative number.\"\n end\n\n if num <= 1\n 1\n else\n num * factorial(num - 1)\n end\nend",
"def factorial_1(num)\n factorial_count = 1\n while num > 0\n factorial_count *= num\n num -= 1\n end\n factorial_count\nend",
"def factorial(num)\n product = 1\n\n i = 2 # 1 * 2 = 2, so just start from 2 and skip 1 as it doesn't matter\n while i <= num\n product *= i\n\n i += 1\n end\n\n return product\nend",
"def factorial(number)\n raise 'Only postive numbers allowed' unless number >= 0\n if number == 0 then 1 else number * factorial(number-1) end\nend",
"def factorial(num)\n product = 1\n i = 1\n while i <= num\n product *= i\n i += 1\n end\n\n return product\nend",
"def factorial(number)\n\tresult = 1\n\twhile number > 0\n\t\tresult *= number\n\t\tnumber -= 1\n\tend\n\treturn result\nend",
"def factorial(number)\n raise ArgumentError.new(\"L'argomento deve essere un numero\") unless number.is_a?(Numeric)\n return 1 if number.zero?\n (1..number).reduce :*\nend",
"def get_fact(num)\n factorial = 1\n for i in 1..num\n factorial *= i\n end\n factorial\nend",
"def factorial(num)\n result = 1\n (1..num).each {|num| result *=num}\n result\nend",
"def factorial(num)\n return 1 if num == 0\n return num if num < 3\n\n output = 1\n i = 2\n while i <= num\n output *= i\n i += 1\n end\n\n output\nend",
"def factorial(number)\n\tif number == 0 || number == 1\n\t\treturn 1\n\telse\n\t\tproduct = number\n\t\twhile number > 1\n \t\t product = product*(number - 1)\n \t\t number = (number - 1)\n \t\tend\n \tend\n\treturn product\nend",
"def factorial (number)\n if number == 0\n return 1\n else\n\n total = 1\n for i in 1..number\n total *= i\n i += 1\n end\n return total\n end\nend",
"def factorial(num)\n \n mult = 1\n i = 1\n \n while i <= num\n mult *= i\n i += 1\n end\n return mult\nend",
"def factorial((number))\nif number == 0\n return 1\n else\n result = 1\n while number > 1\n result = result * number\n number -= 1\n end\nend\n return result\nend",
"def factorial(num)\n product = 1\n i = 1\n\n while i <= num\n product *= i\n i += 1\n end\n\n return product\nend",
"def FirstFactorial(num)\n if num > 1\n return num*(FirstFactorial(num-1)) \n end\n return num \nend",
"def factorial num\n # Guard clause\n return 0 if num === 0\n num === 1 ? 1 : num * factorial( num - 1 )\nend",
"def factorial(num)\n\tif num != 1\n\tputs num \n\n\tnum * factorial(num-1)\n\telse \n\treturn 1\n\tend\t\n\n\nend",
"def factorial(num)\n product = 1 \n\n i = 1\n while i <= num\n product *= i\n \n i += 1\n end \n\n return product\nend",
"def factorial(number)\n raise ArgumentError if number.nil?\n if number == 0 || number == 1\n return 1\n end\n\n i = 0\n result = 1\n\n while i < number\n result *= (number - i)\n i += 1\n end\n return result\nend",
"def factorial(num)\n product = 1\n for factor in 1..num\n product *= factor\n end\n product\nend",
"def factorial(num)\n if num > 0\n #until num == 1\n return num * factorial(num - 1)\n else\n return 1\n end\nend",
"def factorial(num)\n\tproduct = 1\n\t1.upto(num) do |i|\n\t\tproduct *= i\n\tend\n\tputs product\nend",
"def factorial(num)\n result = 1\n (2..num).each do |number|\n result *= number\n end\n result\nend",
"def factorial(number)\n\tnumber.downto(2).inject(1) {|sum, element| sum *= element}\nend",
"def factorial(number)\n raise ArgumentError, \"number can't be nil\" if !number\n factorial = number > 1 ? number: 1\n while number >= 2\n factorial *= (number - 1)\n number -= 1\n end\n return factorial\nend",
"def factorial(num)\n product = 1\n (1..num).each {|n| product *= n}\n product\nend",
"def factorial(num)\n factor = num\n # factor is 4\n sum = num\n # sum = 4\n if (num != 0)\n while factor != 1\n sum = sum * (factor-1)\n factor -= 1\n end\n end\n return sum\nend",
"def factorial(number)\n if number == 0 \n return 1\n elsif number > 1 \n return number * factorial(number - 1)\n else\n return number\n end\nend",
"def factorial(number)\n\tvalue = 1\n\tif number == 0 || number == 1\n\t\tvalue\n\telse\n\t\t(2..number).each {|element| value *= element}\n\t\tvalue\n\tend\nend",
"def FirstFactorial(num)\n (1..num).reduce(:*) || 1\nend",
"def factorial(num)\n counter = 1\n product = 1\n while counter <= num\n product = counter * product\n counter += 1\n end\n return product\nend",
"def factorial(num)\n i = num - 1\n out = num\n while i > 0\n out = out * i \n i -= 1\n end\n return out\nend",
"def FirstFactorial(num)\n product = 1\n for x in num..1\n product *= x\n end\n return product\nend",
"def factorial(num)\n(1..num).reduce(:*)\nend",
"def factorial(num)\n puts (1..(num.zero? ? 1 : num)).inject(:*)\nend",
"def factorial(number)\n if number == 0 \n \treturn 1\n end\n result = 1\n while number > 0\n \tresult = result * number\n \tnumber -= 1\n end\n return result\nend",
"def factorial(number)\n if number == nil\n raise ArgumentError.new(\"Not an integer\")\n end\n\n factorial = 1\n\n while number >= 1\n factorial *= number\n number -= 1\n end\n\n return factorial\nend",
"def factorial_n(num)\n result = 1\n num.times { |i| result *= i + 1 }\n result\nend",
"def factorial(number)\n if number == 0\n return 1\n elsif number == 1\n return 1\n elsif number > 1 \n product = number\n while number > 1 do \n number -=1\n product *= number \n end\n return product\n end \nend",
"def factorial(number)\n i = number\n total = number\n if number == 0 || number == 1\n return 1\n else\n while i > 1\n total=total * (i - 1)\n i -= 1\n end\n end\n return total\nend",
"def first_factorial(num)\r\n (1..num).reduce(&:*)\r\nend",
"def factorial(number)\n if number == 0\n return 1\n elsif number == 1\n return 1\n else\n number*factorial(number-1)\n end\nend",
"def factorial(factor)\n return 1 if factor == 1\n factor*factorial(factor-1)\nend",
"def factorial(number)\n\ttotal = 1\n\treturn 1 if number == 0\n\tnumber.downto(2) do |n|\n\t\ttotal = total * n\n\tend\n\ttotal\nend",
"def factorial(num)\n i = num -1\n output = num\n while i > 0\n output *= i\n i -= 1\n end\n return output\nend",
"def factorial(number)\n\tfactorial = 1\n\t(1..number).each do |x|\n\t\tfactorial *= x\n\tend\n\treturn factorial\nend",
"def find_factorial(num)\n pro=1\n for i in (1..num) do\n pro =pro*i\n\n end\n return pro\n\nend",
"def FirstFactorial(num)\n result = 1\n \n while num > 1\n result *= num\n num -= 1\n end\n \n return result\nend",
"def factorial(number)\n if number == 0\n return 1\n else\n i = number-1\n while i >= 1\n number = number * i\n i = i - 1\n end\n return number\n end\nend",
"def factorial(number)\n if number == 0\n return 1\n else\n i = number-1\n while i >= 1\n number = number * i\n i = i - 1\n end\n return number\n end\nend",
"def factorial(number)\n total = 1\n if number == 0\n total\n else \n while number > 0\n total *= number\n number -= 1\n end\n end\n return total\nend",
"def factorial(number)\n result=1\n if number == 0\n return 1\n else\n while (number>0)\n result *= (number)\n number -= 1\n end\n end\nreturn result\nend",
"def factorial(n)\n if n == 0 || n == 1 \n \treturn 1\n else\n numbers = []\n n.downto(1) { |x| numbers << x }\n numbers.inject(1) { |x,y| x * y }\n end\nend",
"def factorial(number)\n\treturn 1 if number == 1 \n\treturn number * factorial(number-1)\nend",
"def factorial(number)\n if number == 0\n return 1\n else\n n = number - 1\n while n >= 1\n number *= n\n n -= 1\n end\n return number\n end\nend",
"def factorial(number)\n if number <= 1\n return 1\n else\n result = 1\n (1..number).each {|x| result = result * x}\n return result\n end\nend",
"def factorial(number)\n if number\n factorial = 1\n while number > 0\n factorial *= number\n number -= 1\n end\n return factorial\n else\n raise ArgumentError, \"Input must be an integer\"\n end\nend",
"def factorial(n)\n\tif 0 == n or 1 == n\n\t\treturn 1\n\telse\n\t\treturn n * factorial(n - 1)\n\tend\nend",
"def factorial(number)\n if number\t== 0\n \treturn 1\n end \t\n result = number \n i = 1\n while i < number\n result = result * i\n i += 1 \n end\n return result\nend",
"def factorial(number)\n if number == 0\n return 1\n else\n final_factorial = 1\n\n for x in 1..number\n final_factorial = final_factorial * x\n end\n\n return final_factorial\n end\nend",
"def factorial(number)\n return 1 if number == 0\n result = 1\n while number > 0\n result = result * number\n number -= 1\n end\n return result\nend",
"def factorial(number)\n return 1 if number <= 1\n number * factorial(number - 1)\nend",
"def factorial(number)\n\tif zero_and_one(number) == true\n\t\treturn 1\n\telse\n\t\tproduct = number *factorial(number-1)\n\tend\nend"
] | [
"0.8438145",
"0.83617294",
"0.82316047",
"0.8102202",
"0.8030714",
"0.8010633",
"0.7981912",
"0.79702514",
"0.79697794",
"0.79659307",
"0.7948791",
"0.7947433",
"0.789379",
"0.7872387",
"0.7859212",
"0.78373146",
"0.7796337",
"0.7781423",
"0.77753896",
"0.7772721",
"0.7771955",
"0.7759",
"0.7740286",
"0.77219975",
"0.771718",
"0.77164584",
"0.77143264",
"0.7713288",
"0.76940405",
"0.769302",
"0.7691062",
"0.76841897",
"0.76821977",
"0.76796126",
"0.7677754",
"0.76685905",
"0.76301646",
"0.7630163",
"0.76128936",
"0.7598549",
"0.7595962",
"0.7594049",
"0.75890714",
"0.75875473",
"0.7577119",
"0.756786",
"0.75655985",
"0.7564746",
"0.75621784",
"0.7559924",
"0.75541174",
"0.7553582",
"0.7550351",
"0.7535639",
"0.75318915",
"0.7528677",
"0.7527575",
"0.7521496",
"0.7519539",
"0.75179935",
"0.7508802",
"0.7505879",
"0.75032526",
"0.74963635",
"0.7492275",
"0.7490807",
"0.7484064",
"0.74786335",
"0.7477346",
"0.74770766",
"0.74691105",
"0.74621826",
"0.74595916",
"0.7454236",
"0.7453063",
"0.74443823",
"0.7441311",
"0.74393946",
"0.74385035",
"0.7436386",
"0.74361694",
"0.7426647",
"0.7426061",
"0.7423744",
"0.741954",
"0.741714",
"0.741714",
"0.7414861",
"0.7411144",
"0.74099725",
"0.7399999",
"0.73994",
"0.73907346",
"0.73906225",
"0.7390028",
"0.7389377",
"0.73890764",
"0.73842716",
"0.738072",
"0.7376163"
] | 0.764877 | 36 |
MEDIUM Write your own version of the join method. separator = "" ensures that the default seperator is an empty string. | def my_join(arr, separator = "")
if arr.empty?
return ""
else
new_str = ''
arr[0..-2].each{|n| new_str+= (n+separator)}
new_str + arr[-1]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join(separator=nil)\n to_a.join(separator)\n end",
"def join(separator = $OFS)\n '' + _join(separator)\n end",
"def join(separator = T.unsafe(nil)); end",
"def my_join(separator = '')\n out_str = ''\n each do |x|\n out_str << x\n out_str << separator\n end\n out_str[0..-1 * separator.length]\n end",
"def join(separator = $,)\n result = \"\"\n if separator\n each_with_index { |obj, i| result << separator if i > 0; result << obj.to_s }\n else\n each { |obj| result << obj.to_s }\n end\n result\n end",
"def my_join(sep='')\n str = ''\n self.each_with_index do |ele, i|\n if i == self.length-1\n str += ele \n else\n str += ele + sep\n end\n end\n str\n end",
"def my_join(separator = \"\")\n ret = \"\"\n each_with_index do |el, i|\n if i == count - 1\n ret << el\n else\n ret << el + separator\n end\n end\n ret\n end",
"def custom_join(array, delimiter = \"\")\r\n array.join(delimiter)\r\nend",
"def join(sep = $,)\n map(&:to_s).join(sep)\n end",
"def join(sep=$,)\n self.to_a.join(sep)\n end",
"def my_join(arr, separator = \"\")\n join = \"\"\n idx = 0\n while idx < arr.length\n join = join + arr[idx]\n if idx != arr.length - 1 # Don't want to add the separator after the last element\n join = join + separator\n end\n idx = idx + 1\n end\n join\nend",
"def join(delimiter=' ')\n if rest\n first.to_s + delimiter + rest.join\n else\n first.to_s\n end\n end",
"def my_join(arr, separator = \"\")\n result = \"\"\n arr.each_index do |index|\n if index != arr.length-1\n result += (arr[index] + separator)\n else\n result += arr[index]\n end\n end\n result\nend",
"def my_join(array, separator)\n\tarray_string = \" \"\n\tarray.each{ |a| array_string << a + separator }\n\treturn array_string\nend",
"def my_join(arr, separator = \"\")\n result = \"\"\n (0...arr.length).each do |idx|\n if idx != arr.length - 1\n result << arr[idx] << separator\n else\n result << arr[idx]\n end\n end\n\n return result\n\nend",
"def my_join(arr, separator=\"\")\r\n # your code goes here\r\n my_join = \"\"\r\n\r\n i=0\r\n while i<arr.length\r\n if i < arr.length - 1\r\n my_join += arr[i] + separator\r\n else\r\n my_join += arr[i]\r\n end\r\n i+=1\r\n end\r\n my_join\r\nend",
"def my_join(arr, separator = \"\")\nr = \"\"\narr.each_with_index { |c, i| r += separator if i != 0; r += c.to_s }\nr\nend",
"def my_join(arr, separator = \"\")\n return \"\" if arr.empty?\n joined_str = \"\"\n arr[0...-1].each {|elem| joined_str << elem + separator}\n joined_str << arr[-1]\nend",
"def my_join(arr, separator = \"\")\n str = \"\"\n arr.each_with_index { |el, i| str += el + separator}\n return str[0..separator.length*-1-1]\nend",
"def my_join(arr, separator = \"\")\n result = \"\"\n arr.each_with_index do |ele, idx|\n idx < arr.size - 1 ? result += (ele + separator) : result += ele\n end\n result\nend",
"def safe_join(array, sep = T.unsafe(nil)); end",
"def join(*args,sep)\n args.reject { |x| !x }.uniq.join(sep)\n end",
"def custom_join(array, delimiter = \"\")\r\n string = \"\"\r\n last_index = array.length - 1\r\n array.each_with_index do |elem, index|\r\n string << elem\r\n string << delimiter unless index == last_index\r\n end\r\n string\r\nend",
"def join(delimiter); @args.join(delimiter) end",
"def join\n str = @feedback.join(@separator)\n str << @separator.strip if @trailing_separator\n str\n end",
"def my_join(array, separator)\n\n string = ''\n array.each_with_index do |elem, index|\n if index < array.length - 1\n string << elem + separator\n else\n string << elem\n end\n end\n \n string\nend",
"def my_join(arr, separator = \"\")\n result = ''\n arr.each do |x|\n result << x.to_s\n result << separator unless x == arr[-1]\n end\n result\nend",
"def my_join(arr, separator = '')\n new_str = ''\n return new_str if arr.empty?\n\n arr.each do |c|\n new_str << c + separator unless c == arr.last\n end\n new_str + arr.last\nend",
"def safe_join(array, sep = $OFS)\n helpers.safe_join(array, sep)\n end",
"def join(array, delimiter = \"\")\n result = \"\"\n i = 1\n array.each do |item|\n result += item.to_s\n unless i == array.length\n result += delimiter\n end\n i += 1\n end\n result\nend",
"def my_join(arr, separator = \"\")\n output_str = arr[0].to_s\n arr.each do |el|\n if el != arr[0]\n output_str += (separator.to_s + el.to_s)\n end\n end\n\n output_str\nend",
"def my_join(arg='')\n joined_str = ''\n self.my_each {|el| joined_str += el + arg}\n joined_str\n end",
"def join_split(arr=nil)\n\t\tarr.join.split(\"\") if not arr.nil? and arr.respond_to? :push\n\tend",
"def my_join(spacer = '')\n str = ''\n\n self.each_with_index do |char, idx|\n str += char\n str += spacer if idx != self.length - 1\n end\n\n str\n end",
"def join(*rest) end",
"def join(s = Undefined)\n # this is mostly Rubinius code, but modified for our API\n # Put in delta since we need the recursion guard found in common.\n my_size = size\n return \"\" if my_size._equal?(0)\n if s._equal?(Undefined)\n sep = $,\n elsif s._equal?(nil)\n sep = nil\n else\n sep = s.to_str # let any NoMethodError be seen by caller\n end\n\n out = \"\"\n# out.taint if sep.tainted? or self.tainted?\n i = 0\n ts = Thread.__recursion_guard_set\n while (i < my_size)\n elem = at(i)\n out << sep unless (sep._equal?(nil) || i == 0)\n\n if elem._isArray\n\tadded = ts.__add_if_absent(self)\n\tbegin\n if ts.include?(elem)\n out << \"[...]\"\n else\n out << elem.join(sep)\n end\n\tensure\n if added\n\t ts.remove(self)\n\t end\n end\n else\n out << elem.to_s\n# out.taint if elem.tainted? and not out.tainted?\n end\n i += 1\n end\n out\n end",
"def join(list, sep = '')\n return '' if list.length == 0\n first_word = list.shift\n list.each do |item|\n first_word << sep << item\n end\n\n first_word\n end",
"def join(strings, seperator)\n result = strings.first.clone\n strings[1..-1].each do |str|\n result << seperator\n result << str\n end\n\n return result\nend",
"def my_join(link=\"\")\n str = \"\"\n i = 0\n while i < self.length\n if i != 0\n str += link\n end\n str += self[i].to_s\n i += 1\n end\n return str\n end",
"def joinor(arr, separator = \", \", ending = \"or\")\n final_string = \"\"\n n = 0\n\n case arr.length()\n when 1\n final_string = arr[0].to_s\n when 2\n final_string = arr[0].to_s + \" \" + ending + \" \" + arr[1].to_s\n when 3..\n while n < (arr.length()-1)\n final_string += (arr[n].to_s) + separator\n n += 1\n end\n final_string += ending + \" \" + (arr[-1].to_s)\n end\nend",
"def fn_join(value)\n unless value.last.is_a?(Array)\n val = value.last.to_s.split(\",\")\n else\n val = value.last\n end\n val.join(value.first)\n end",
"def join\n a = []\n each{|s| a << s}\n a.join\n end",
"def joinor(arr, sep = \", \", art = \"or \")\n case arr.size\n when 0 then \"\"\n when 1 then arr.first\n when 2 then arr.join(\" #{art} \")\n else\n arr[-1] = \"#{art} #{arr.last}\"\n arr.join(sep)\n end\nend",
"def join_split(array=nil, *rest)\n\tarray.join.split(//) if not array.nil? and array.respond_to? :join\nend",
"def to_s\n join\n end",
"def joiner(arr, delimiter = ', ', word = 'or')\n case arr.size\n when 0 then ''\n when 1 then arr.first\n when 2 then arr.join(\" #{word} \")\n else\n all_but_last = arr[0, arr.length - 1].join(delimiter)\n \"#{all_but_last}#{delimiter}#{word} #{arr[-1]}\"\n end\nend",
"def english_join(conjunction = 'and', separator = ', ', oxford_comma = true)\n len = length\n # Return empty string for empty array\n return '' if len == 0\n # Return only element as string if length is 1\n return self[0].to_s if len == 1\n # Return comma-less conjunction of elements if length is 2\n return \"#{self[0]} #{conjunction} #{self[1]}\" if len == 2\n # Return comma joined conjunction of elemements\n join_str = ''\n each_with_index{|ele, i|\n str = if !oxford_comma && i == len - 2\n \"#{ele} #{conjunction} \" # rubocop:disable Layout/IndentationWidth\n elsif i == len - 2\n \"#{ele}#{separator}#{conjunction} \"\n elsif i == len - 1\n ele.to_s\n else\n \"#{ele}#{separator}\"\n end\n join_str << str\n }\n join_str\n end",
"def sep(separator)\n ->(a, b){ a << separator.html_safe << b }\n end",
"def append_separator!(*separators)\n len = length\n each_with_index do |element, i|\n next if i == len - 1\n separators.each do |separator|\n element << separator\n end\n end\n end",
"def join_with str = nil\n @join_with = str if str\n @join_with || ', '\n end",
"def fn_join(separator, lines)\n {\n \"Fn::Join\" => [\n separator, lines\n ]\n }\n end",
"def join(args, joiner=nil)\n raise Error, 'argument to Sequel.join must be an array' unless args.is_a?(Array)\n if joiner\n args = args.zip([joiner]*args.length).flatten\n args.pop\n end\n\n return SQL::StringExpression.new(:NOOP, '') if args.empty?\n\n args = args.map do |a|\n case a\n when Symbol, ::Sequel::SQL::Expression, ::Sequel::LiteralString, TrueClass, FalseClass, NilClass\n a\n else\n a.to_s\n end\n end\n SQL::StringExpression.new(:'||', *args)\n end",
"def __joinStrings\n # called from generated code\n str = ''\n n = 0\n siz = self.__size\n while n < siz\n str << self.__at(n).to_s\n n += 1\n end\n str\n end",
"def strjoin strs, before = \"\", after = \"\", joiner = ',', line_end=' '\n if strs.keep_if { |str| !str.blank? }.size > 0\n last = strs.pop\n liststr = strs.join (joiner+line_end)\n liststr += \" and#{line_end}\" unless liststr.blank?\n before+liststr+last+after\n else\n \"\"\n end\nend",
"def join_with_and list, seperator=\", \"\n return list.first if list.count==1\n result = \"\"\n list.each do |item|\n result << item\n unless item==list.last\n if item==list[-2]\n result << \" and \"\n else\n result << seperator\n end\n end\n end\n result\n end",
"def joinor(arr, delimiter = ', ', conjunction = 'or')\n return '' if arr.empty?\n arr.map!(&:to_s)\n return arr[0] if arr.size == 1\n str = arr.size > 2 ? arr[0..-2].join(delimiter) + delimiter : arr[0] + ' '\n # str = arr[0..-2].join(delimiter)\n # str << (arr.size > 2 ? delimiter : ' ')\n str << conjunction + ' ' + arr[-1]\nend",
"def join(input, glue = T.unsafe(nil)); end",
"def join()\n raise \"Missing implementation 'join'\"\n end",
"def join_list(delim, list) { :'Fn::Join' => [ delim, list ] } end",
"def joinor(elements, separator = ', ', conjunction = 'or')\n temp = []\n elements.each.with_index do |element, index|\n if index == elements.size - 1\n if elements.size > 1\n temp << \" #{conjunction} #{element}\"\n else\n temp << \"#{element}\"\n end\n else\n if elements.size > 2\n temp << \"#{element}#{separator}\"\n else\n temp << \"#{element}\"\n end\n end\n end\n temp.join.gsub(' ', ' ')\nend",
"def map_join(list, *opts, &block)\n options = opts.extract_options!\n if options[:nowrap]\n options[:surround] = [raw('<span style=\"white-space: nowrap;\">'), raw(''), raw('</span> ')]\n end\n separator = options[:separator] || opts[0] || raw(options[:surround] ? ',' : ', ')\n last_separator = options[:last_separator] || opts[1] || separator\n\n results = list.map &block\n case results.length\n when 0 then ''\n when 1 then results[0]\n else\n # Array#join doesn't support html_safe => concatenate with inject\n if options[:surround]\n s1,s2,s3 = options[:surround]\n s1 + results[0..-2].inject { |a,b| a.to_s + s2 + separator + s3 + s1 + b.to_s } +\n s2 + last_separator + s3 + results.last\n else\n results[0..-2].inject {|a,b| a.to_s + separator + b.to_s } + last_separator + results.last\n end\n end\n end",
"def joinor(array, separator = ', ', word = 'or')\n case array.size\n when 0, 1\n array.join\n when 2\n array.join(\" #{word} \")\n else\n last_element = array.pop.to_s\n array.join(separator) << last_element.prepend(\"#{separator}#{word} \")\n end\nend",
"def list_join(*args)\n args.count == 1 ? \" #{args[0]}\" : \"#{$/}* #{args.join(\"#{$/}* \")}\"\n end",
"def join_strings(a, b)\n a + \" \" + b\nend",
"def _eval_join(*args)\n args = args.compact\n args.delete_if &:empty?\n args.slice(1, args.size).to_a.inject(args.first) do |memo, item|\n if item.start_with?(\"[\")\n memo += item\n else\n memo += \".#{item}\"\n end\n end\n end",
"def join_with_and(list, seperator = ', ')\n return list.first if list.count == 1\n result = ''\n list.each do |item|\n result << item\n next if item == list.last\n result << if item == list[-2]\n ' and '\n else\n seperator\n end\n end\n result\n end",
"def join_with_and(list, seperator = ', ')\n return list.first if list.count == 1\n result = ''\n list.each do |item|\n result << item\n next if item == list.last\n result << if item == list[-2]\n ' and '\n else\n seperator\n end\n end\n result\n end",
"def key_with_separator(separator)\n segments.join(separator)\n end",
"def to_s\n self.join\n end",
"def joinor(arr, delimiter=', ', word='or')\n case arr.size\n when 0 then ''\n when 1 then arr.first\n when 2 then arr.join(\" #{word} \")\n else\n arr[-1] = \"#{word} #{arr.last}\"\n arr.join(delimiter)\n end\nend",
"def stringify_joiner\n \"__\"\n end",
"def translate_and_join(separator = ', ', description = '', options = {})\n self.translate(description, options).join(separator).tml_translated\n end",
"def join(x, sep = \",\")\n y = []\n x.each do |element|\n y.push element.text\n end\n y.join(sep)\n end",
"def join; end",
"def joinor(arr, str1 = ', ', str2 = 'or')\n case arr.size\n when 0 then ''\n when 1 then arr.first\n when 2 then arr.join(\" #{str2} \")\n else\n arr[-1] = \"#{str2} #{arr.last}\"\n arr.join(str1)\n end\nend",
"def joinor(arr, delimiter=', ', word='or')\n arr[-1] = \"#{word} #{arr.last}\" if arr.size > 1\n arr.join(delimiter)\nend",
"def join(array, separator)\n first = true\n array.each do |widget_or_text|\n if !first\n text separator\n end\n first = false\n text widget_or_text\n end\n end",
"def comma_join(data)\n if data.is_a?(Array)\n data.join(',')\n else\n data || ''\n end\n end",
"def join_strings(first_string, second_string)\n\n joint_string = first_string + ' ' + second_string\n\n return(joint_string)\n\nend",
"def join(seperator = \" | \")\n\t\tflags.map { |flag| flag.name }.join(seperator)\n\tend",
"def join_strings_reject_empty(display_array, separator = \" ,\")\n display_array = display_array.reject { |display| display.empty? }\n return display_array.join(separator).html_safe\n\n end",
"def join(array, separator)\n first = true\n array.each do |item|\n if !first\n if separator.is_a? Widget\n widget separator\n else\n text separator\n end\n end\n first = false\n if item.is_a? Widget\n widget item\n else\n text item\n end\n end\n end",
"def join_strings(parameter1, parameter2)\r\n\treturn parameter1 + \" \" + parameter2\r\nend",
"def join_strings(string_1, string_2)\n \"#{string_1} #{string_2}\"\nend",
"def join(list1, list2,\n separator = identifier(\"auto\"), bracketed = identifier(\"auto\"),\n kwargs = nil, *rest)\n if separator.is_a?(Hash)\n kwargs = separator\n separator = identifier(\"auto\")\n elsif bracketed.is_a?(Hash)\n kwargs = bracketed\n bracketed = identifier(\"auto\")\n elsif rest.last.is_a?(Hash)\n rest.unshift kwargs\n kwargs = rest.pop\n end\n\n unless rest.empty?\n # Add 4 to rest.length because we don't want to count the kwargs hash,\n # which is always passed.\n raise ArgumentError.new(\"wrong number of arguments (#{rest.length + 4} for 2..4)\")\n end\n\n if kwargs\n separator = kwargs.delete(\"separator\") || separator\n bracketed = kwargs.delete(\"bracketed\") || bracketed\n\n unless kwargs.empty?\n name, val = kwargs.to_a.first\n raise ArgumentError.new(\"Unknown argument $#{name} (#{val})\")\n end\n end\n\n assert_type separator, :String, :separator\n unless %w(auto space comma).include?(separator.value)\n raise ArgumentError.new(\"Separator name must be space, comma, or auto\")\n end\n\n list(list1.to_a + list2.to_a,\n separator:\n if separator.value == 'auto'\n list1.separator || list2.separator || :space\n else\n separator.value.to_sym\n end,\n bracketed:\n if bracketed.is_a?(Sass::Script::Value::String) && bracketed.value == 'auto'\n list1.bracketed\n else\n bracketed.to_bool\n end)\n end",
"def to_joined_str (item)\n if (item.class == Array) then\n item.join(\", \")\n else\n item.to_s\n end\nend",
"def row_join_string\n @row_join_string ||= \" \"\n end",
"def test_join\n assert_equal('1 2 Bar 4 Baz Bar 7 8 Bar Baz 11 Bar 13 14 BarBaz', @kbb.join)\n end",
"def separator\n ','\n end",
"def joinor(ary, delimiter = ', ', final_word = 'or')\n result = ''\n count = 0\n\n case ary.size\n when 0 then ''\n when 1 then ary[0].to_s\n when 2 then \"#{ary[0]} #{final_word} #{ary[1]}\"\n else\n while count <= ary.length - 2\n result += ary[count].to_s + delimiter\n count += 1\n end\n\n result + final_word + ' ' + ary[-1].to_s\n end\nend",
"def joinstrings(str1, str2)\n newstring = str1 << \", \" << str2\n return newstring\nend",
"def separate (string, joiner = \"-\")\n string.split(//).join(joiner)\nend",
"def default_separator(value = T.unsafe(nil)); end",
"def join_path(*parts)\n File.join(*parts.reject { |x| x.nil? || x.empty? })\n end",
"def uri_join(*parts)\n parts = parts.compact.map(&URI.method(:escape))\n URI.parse(parts.join('/')).normalize.to_s\nend",
"def uri_join(*paths)\n return nil if paths.length == 0\n leadingslash = paths[0][0] == '/' ? '/' : ''\n trailingslash = paths[-1][-1] == '/' ? '/' : ''\n paths.map! { |path| path.sub(/^\\/+/, '').sub(/\\/+$/, '') }\n leadingslash + paths.join('/') + trailingslash\n end",
"def sep; end",
"def sep; end",
"def try_join_arr(val)\n val.join(\"\\n\") rescue val\n end",
"def separator; end"
] | [
"0.86138403",
"0.85405743",
"0.85213625",
"0.83767635",
"0.82474196",
"0.8217411",
"0.8038485",
"0.80141306",
"0.7988668",
"0.7850436",
"0.7848108",
"0.78456444",
"0.78402287",
"0.7834805",
"0.7807889",
"0.7798162",
"0.7795482",
"0.76860136",
"0.7685144",
"0.7638092",
"0.7573091",
"0.7543009",
"0.754093",
"0.7526124",
"0.751638",
"0.7512203",
"0.74919695",
"0.7428339",
"0.7398914",
"0.7313031",
"0.7302669",
"0.72561693",
"0.72251326",
"0.71884036",
"0.71154016",
"0.7048078",
"0.7022755",
"0.6962563",
"0.6939252",
"0.69317484",
"0.69124347",
"0.68823195",
"0.68776846",
"0.68290114",
"0.6811568",
"0.67773175",
"0.672689",
"0.66354907",
"0.6629456",
"0.65813214",
"0.6578459",
"0.6563418",
"0.6522333",
"0.6513674",
"0.65106946",
"0.6506699",
"0.6506243",
"0.64999557",
"0.64980674",
"0.64743274",
"0.64742893",
"0.645637",
"0.64559513",
"0.6407128",
"0.6356943",
"0.63414496",
"0.63414496",
"0.6322129",
"0.6319075",
"0.63017726",
"0.62878066",
"0.6269726",
"0.62341166",
"0.623158",
"0.6212667",
"0.61773837",
"0.6176509",
"0.6173912",
"0.6163828",
"0.60891527",
"0.60745406",
"0.60663944",
"0.6063022",
"0.6059855",
"0.60480624",
"0.6045492",
"0.60419446",
"0.60342526",
"0.600234",
"0.59988576",
"0.5995895",
"0.5986992",
"0.5970552",
"0.59541744",
"0.59531295",
"0.59461564",
"0.5945083",
"0.5945083",
"0.5932561",
"0.5912011"
] | 0.7787051 | 17 |
Write a method that converts its argument to weirdcase, where every odd character is lowercase and every even is uppercase, e.g. weirdcase("weirdcase") => "wEiRdCaSe" | def weirdcase(str)
is_upcase = false
new_str = ''
str.chars.each do |ch|
if is_upcase
new_str += ch.upcase
else
new_str += ch.downcase
end
is_upcase = !is_upcase
end
new_str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weirdcase(str)\n new_str = \"\"\n str.chars.each_with_index do |c, i|\n if i%2==0 #reverse because odd characters have even indices\n new_str += c.downcase\n else\n new_str += c.upcase\n end\n end\n return new_str\nend",
"def weirdcase(str)\n result = \"\"\n str.chars.each_with_index do |ch, i|\n result += i.odd? ? ch.upcase : ch.downcase\n end\n result\nend",
"def weirdcase(str)\n (0...str.length).each do |idx|\n if idx % 2 == 0\n str[idx] = str[idx].downcase\n else\n str[idx] = str[idx].upcase\n end\n end\n str\nend",
"def weirdcase(str)\n result = ''\n arr_str = str.chars\n arr_str.each_index{|x| x.odd? ? result << arr_str[x].upcase : result << arr_str[x].downcase }\n result\nend",
"def weirdcase(str)\n arr = str.split('')\n arr.each_index do |i|\n (i % 2).zero? ? arr[i].downcase! : arr[i].upcase!\n end.join\nend",
"def weirdcase(str)\n output_str = ''\n str.each_char.with_index do |el, i|\n if i % 2 == 0\n output_str += el.downcase\n else\n output_str += el.upcase\n end\n end\n\n output_str\nend",
"def weirdcase(str)\n result = \"\"\n str.downcase.each_char.with_index do |char, i|\n i.even? ? result += char.downcase : result += char.upcase\n end\n result\nend",
"def weirdcase(str)\r\n # your code goes here\r\n weirdcase = \"\"\r\n\r\n i = 0\r\n while i < str.length\r\n if i % 2 == 0\r\n weirdcase << str[i].downcase\r\n else\r\n weirdcase << str[i].upcase\r\n end\r\n i += 1\r\n end\r\n weirdcase\r\n\r\nend",
"def weirdcase(str)\n for i in 0..str.length-1\n if i % 2 != 0\n str[i] = str[i].upcase\n else\n str[i] = str[i].downcase\n end\n end\n str\nend",
"def weirdcase(str)\n\tstr.each_char.with_index { |c, i| i % 2 == 0 ? str[i] = str[i].downcase : str[i] = str[i].upcase }\n\tstr\nend",
"def weirdcase string\n string.split(\" \").map{|word| toWeirdCase(word)}.join(\" \")\nend",
"def weirdcase(string)\n string.split(\" \").map do |word|\n word.split(\"\").each_with_index.map do |char, i|\n i.even? ? char.upcase : char.downcase\n end.join(\"\")\n end.join(\" \")\nend",
"def weirdcase(str)\n str.split.map do |word|\n word.chars.map.with_index { |char,i| i.even? ? char.upcase : char.downcase}.join\n end.join(' ')\nend",
"def weirdcase str\n str.split.map(&:chars).map do |word|\n word.map.with_index { |letter, index| index.even? ? letter.capitalize : letter }.join\n end.join(' ')\nend",
"def weirdcase(string)\n result = []\n string.split(' ').each do |word|\n i = 0\n while i < word.length\n word[i] = if i.odd?\n word[i].upcase\n else\n word[i].downcase\n end\n i += 1\n end\n result << word\n end\n result.join\nend",
"def weirdcase(string)\n string = string.split(' ').each.map do |word|\n word = word.split('').each_with_index.map do |letter, index|\n if index.even?\n letter.capitalize\n else\n letter.downcase\n end\n end\n word.join('')\n end\n return string.join(' ')\nend",
"def weirdcase(string)\n words = string.split(' ')\n\n words.map do |word|\n word.chars.map.with_index do |letter, index|\n index.even? ? letter.upcase : letter.downcase\n # if index.even?\n # letter.upcase\n # else\n # letter.downcase\n # end\n end.join\n end.join(' ')\n\nend",
"def weirdcase(string)\n #gets array of strings, creates empty results array\n arr = string.split (' ')\n result = []\n\n #iterates over array of strings..\n arr.each do |i|\n #..breaking apart each string into another array of characters\n temp = i.chars\n #then iterating over that array of characters..\n (0..temp.length-1).each do |j|\n #..checking to see if that index is even. If so, make that letter uppercase\n if j.even?\n temp[j] = temp[j].upcase\n end\n end\n #after iterating through each letter and uppercasing the even indexes,\n #join the chars into a string, then append that string to results array\n result << temp.join('')\n end\n #after each individual word is modified, join the chars of results into one string,\n #then return that as the final result!\n return result.join(' ')\nend",
"def weirdcase(string)\n counter = 0\n string.split('').map do |char|\n if char == ' '\n counter = 0\n char\n else\n counter += 1\n counter.odd? ? char.upcase : char.downcase\n end\n end.join('')\nend",
"def weirdcase(string)\n string.split(' ').map do |word|\n word.split('').map.with_index do |letter, index|\n if index % 2 == 0\n letter.capitalize\n else\n letter\n end\n end.join('')\n end.join(' ')\nend",
"def weirdcase string\n result = []\n string.split(\" \").each do |string|\n count = 0\n string.chars.each do |str|\n if str == \" \"\n result << str\n elsif\n count.even?\n result << str.upcase\n count += 1\n else\n result << str.downcase\n count += 1\n end\n end\n result << \" \"\n end\n result.join.chop\nend",
"def downcase(input); end",
"def weirdcase1(string)\n string.gsub(/(\\w{1,2})/) { |s| $1.capitalize }\nend",
"def staggered_case(str)\n spongebob_case = str.split('').map.with_index do |char, index|\n if index.odd?\n char.upcase\n elsif index.even?\n char.downcase\n else\n char\n end\n end.join\n\n spongebob_case\nend",
"def staggered_case(str)\n arry = str.chars \n\n arry.each_with_index do |ch, index|\n index.odd? ? ch.downcase! : ch.upcase!\n end\n arry.join('')\nend",
"def upcase(input); end",
"def staggered_case(string)\n iterator = 0\n characters = string.chars.map do |char|\n iterator += 1 if char =~ /[a-zA-Z]/\n #if char =~ /[a-z]/i <--LS\n if iterator.odd?\n char.upcase\n elsif iterator.even?\n char.downcase\n else\n char\n end\n end\n characters.join\nend",
"def swapcase!() end",
"def to_alternating_case(string)\n return string.swapcase\nend",
"def shout(a)\n return a.upcase\nend",
"def staggered_case(str)\n new_str = str.downcase\n new_str.chars.each_with_index do |el, idx| \n new_str[idx] = el.upcase if idx.even?\n end\n new_str\nend",
"def staggered_case(string)\n result_array = string.chars\n result_array.each_with_index do |item, i|\n i.odd? ? item.downcase! : item.upcase!\n end.join\nend",
"def shout(str)\n str.upcase\nend",
"def swapcase() end",
"def shout(str)\n return str.upcase\nend",
"def upcase!() end",
"def shout(word)\n upper_case = word.upcase\nend",
"def staggered_case(string)\n string_arr = string.chars\n string_arr.each_with_index do |char, index|\n if index == 0\n char.upcase!\n elsif index.even?\n char.upcase!\n else\n char.downcase!\n end\n end\n string_arr.join\nend",
"def weirdcase(string)\n i = 0\n string.gsub(/./) do |letter|\n if letter == \" \"\n i = 0\n letter\n elsif i.even?\n i += 1\n letter.upcase\n else\n i += 1\n letter.downcase\n end\n end\n # string.gsub(/./) do |letter|\n # string.index(letter).even? ? letter.upcase : letter.downcase\n # end\nend",
"def staggered_case(string)\n iterator = 0\n characters = string.chars.map do |char|\n iterator += 1\n if iterator.odd?\n char.upcase\n elsif iterator.even?\n char.downcase\n else\n char\n end\n end\n characters.join\nend",
"def staggered_case(str)\n str.chars.map.with_index {|el, i| i.even? ? el.upcase : el.downcase}.join\nend",
"def do_magic(str)\n str.gsub!(/[^A-Z]/, '').to_s #delete small leters and uprinted sumbols\n str.downcase.to_s #make all leters small\nend",
"def staggered_case(string)\n string.downcase.chars.each_with_index { |x, idx| x.upcase! if idx.even? }.join\nend",
"def caps(string)\n return string.upcase\nend",
"def caps(string)\n return string.upcase\nend",
"def staggered_case(str)\n str.chars.map.with_index { |e, i| i.even? ? e.upcase : e.downcase }.join\nend",
"def downcase; end",
"def downcase!() end",
"def swap_case(parameter)\n\toutput = \"\"\n\tif parameter.class == String\n\t\tparameter.split(\" \").each do |word|\n\t\t\toutput += word.swapcase + \" \"\n\t\tend\n\t\treturn output\n\telse\n\t\treturn check the input\n\tend\n\nend",
"def shout(str); str.upcase end",
"def mixed_case_2(name)\n\tname.downcase.gsub(/\\b\\w/, &:upcase)\nend",
"def swap_case(str)\n str.swapcase\nend",
"def shout (s)\n s.upcase\nend",
"def SwapCase(str)\n\n return str.swapcase! \n \nend",
"def weirdcase(string)\n final_string = []\n string.split(' ').map do |word|\n capitalized_words = []\n word.split('').map.with_index do |letter, index|\n if index % 2 == 0\n letter = letter.capitalize\n else\n letter\n end\n capitalized_words << letter\n end\n final_string << capitalized_words.join('')\n end\n return final_string.join(' ')\nend",
"def alternating_case(string)\n if !(string.instance_of?(String))\n raise \"The argument should be a String\"\n end\n\n words = string.split(\" \")\n\n words.each_with_index do |word, index| \n index % 2 == 0 ? word.upcase! : word.downcase!\n end\n\n words.join(\" \")\nend",
"def mixed_case(name)\n name.downcase.gsub(/\\b\\w/, &:upcase)\nend",
"def upcase; end",
"def SwapCase(str)\n str.swapcase\nend",
"def SwapCase(str)\n str.swapcase\nend",
"def downcase() end",
"def downer2(string)\n string.downcase!\nend",
"def capitalize!() end",
"def staggered_case(string)\n index = 1\n array = string.chars\n array.each do |char|\n if char =~ /[a-zA-Z]/\n char.upcase! if index.odd?\n char.downcase! if index.even?\n index += 1\n else \n char \n end\n end \n p array.join \n \nend",
"def staggered_case(str)\n str.chars.map.with_index { |element, index| index.even? ? element.upcase : element.downcase }.join\nend",
"def staggered_case(str) \n str.chars.map.with_index do |el, idx|\n idx.even? ? el.upcase : el.downcase\n end.join\nend",
"def staggered_case(str)\narray = str.split(\"\")\nresult = array.each_with_index do |char, index|\n if index % 2 == 0 && char.match(/[a-zA-Z]/)\n char.upcase!\n elsif index % 2 == 1 && char.match(/[a-zA-Z]/)\n char.downcase!\n end\nend\nresult.join(\"\")\nend",
"def shout(word)\n\treturn word.upcase\nend",
"def upcase() end",
"def crazy_strings(first_word, second_word)\nputs \"#{first_word} #{second_word.gsub(\"s\",\"z\").swapcase}!\"\nend",
"def staggered_case(str)\n str.chars.map.with_index \\\n { |chr, idx| idx.even? ? chr.upcase : chr.downcase }.join('')\nend",
"def staggered_case(string)\n count = 1\n string_chars = string.downcase.chars\n result = String.new\n for i in 0..(string.size-1)\n result << string_chars[i].upcase if (i+1).odd?\n result << string_chars[i] if (i+1).even?\n end\n result\nend",
"def staggered_case(string)\n even, odd = string.chars.partition.with_index { |_, idx| idx.even? }\n upcased = even.map(&:upcase)\n downcased = odd.map(&:downcase)\n upcased.zip(downcased).flatten.join\nend",
"def staggered_case(string)\n chars = string.chars\n chars.map.with_index do |char, index|\n index.even? ? char.upcase : char.downcase\n end.join\nend",
"def titlecase(input)\n input.titlecase\n end",
"def shout(word)\n puts word.upcase\n end",
"def staggered_case(string)\n result = string.chars.map.with_index do |char, index|\n if (index.even? || index == 0) && char == char.downcase\n char.upcase\n elsif index.odd? && char == char.upcase\n char.downcase\n else\n char\n end \n end \n result.join\nend",
"def capitalize(input); end",
"def shout string\n string.upcase\nend",
"def staggered_case(string)\n result = string.downcase.chars\n result.map.with_index do |char, i|\n i.even? ? char.capitalize! : char\n end\n result.join\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 case_fix(name)\r\n fixed_name = name.split(' ')\r\n fixed_name.each do |word|\r\n word.capitalize!\r\n end\r\n fixed_name.join(' ')\r\nend",
"def SwapCase(str)\n\n # code goes here\n return str \n \nend",
"def make_upper_case(str)\n str.upcase\nend",
"def code_letter(name)\nname = name.downcase.tr(\"aeiou\", \"eioua\")\nname = name.downcase.tr(\"bcdfghjklmnpqrstvwxyz\", \"cdfghjklmnpqrstvwxyzb\")\nend",
"def staggered_case(string)\n index = 0\n characters = string.split('')\n loop do\n break if index >= characters.size\n if characters[index] =~ /[a-zA-Z]/ && index.even?\n characters[index].upcase!\n elsif characters[index] =~ /[a-zA-Z]/ && index.odd?\n characters[index].downcase!\n end\n index += 1\n end\n characters.join('')\nend",
"def xyzzy(a_value)\n a_value.upcase\nend",
"def snakify\n return downcase if match(/\\A[A-Z]+\\z/)\n gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2').\n gsub(/([a-z])([A-Z])/, '\\1_\\2').\n downcase\n end",
"def camelize!\n self.titleize!\n self.replace(self[0, 1].downcase + self[1..-1])\n end",
"def titlecase!\n replace(titlecase)\n end",
"def shout(input)\n \"#{input.upcase}\"\nend",
"def shout(words)\n\twords.upcase\nend",
"def staggered_case(string)\n staggered = []\n string.chars.each_with_index do |char, index|\n if index.odd?\n staggered << char.downcase\n else\n staggered << char.upcase\n end\n end\n staggered.join\nend",
"def staggered_case(input)\n input = input.downcase\n new_arr = []\n \n input.chars.each_with_index do |char, idx|\n if idx % 2 == 1 || (!(('a'..'z').to_a).include?(char) && !(('A'..'Z').to_a).include?(char))\n new_arr << char\n else\n new_arr << char.capitalize!\n end\n end\n new_arr.join\nend",
"def staggered_case(string)\n string.downcase.each_char.map.with_index do |char, index|\n if index.even?\n char.upcase\n else\n char\n end\n end.join\nend",
"def capitalize(word)\n\nend",
"def fdowncase\n downcase.cdowncase\n end",
"def mixed_case(name)\n\tname.downcase.gsub(/\\b\\w/) {|first| first.upcase}\nend",
"def shout(string)\n\treturn string.upcase\nend",
"def shout str\n str.to_s.upcase\nend"
] | [
"0.8193509",
"0.81549597",
"0.81168276",
"0.8098166",
"0.8064706",
"0.8024832",
"0.80095166",
"0.79280037",
"0.7901919",
"0.79010344",
"0.78614455",
"0.7782618",
"0.7765896",
"0.76191705",
"0.7535391",
"0.7523811",
"0.75206393",
"0.74539953",
"0.7414967",
"0.7341723",
"0.7323689",
"0.73036486",
"0.7296202",
"0.7292711",
"0.7288074",
"0.72737336",
"0.72525764",
"0.7250969",
"0.72495484",
"0.7238041",
"0.7222752",
"0.7203451",
"0.7203065",
"0.7160149",
"0.71584344",
"0.7133202",
"0.7128733",
"0.7118237",
"0.7104497",
"0.7103091",
"0.7086447",
"0.70827854",
"0.7081913",
"0.7063091",
"0.7063091",
"0.70512134",
"0.7044897",
"0.7033265",
"0.7023114",
"0.70170695",
"0.70118356",
"0.70039696",
"0.700208",
"0.6992365",
"0.69892937",
"0.69879913",
"0.6987785",
"0.6983705",
"0.69814914",
"0.69814914",
"0.697197",
"0.6963126",
"0.69594264",
"0.69347113",
"0.6931329",
"0.6928043",
"0.6916003",
"0.6915604",
"0.69058627",
"0.69046766",
"0.69039816",
"0.6902985",
"0.69016904",
"0.6895342",
"0.68901825",
"0.68804634",
"0.6877496",
"0.687536",
"0.68639666",
"0.6861718",
"0.6853673",
"0.6853128",
"0.6842537",
"0.6830678",
"0.68257844",
"0.682553",
"0.682208",
"0.68157935",
"0.6809579",
"0.68093497",
"0.6805832",
"0.67965883",
"0.6793072",
"0.6777198",
"0.6768867",
"0.6763006",
"0.6760075",
"0.67568994",
"0.67548835",
"0.6752583"
] | 0.7338746 | 20 |
Reverse all words of five more more letters in a string. Return the resulting string, e.g., reverse_five("Looks like my luck has reversed") => "skooL like my luck has desrever") | def reverse_five(str)
arr = str.split
new_str = []
arr.each do |word|
if word.length >= 5
word.reverse!
end
new_str.push(word)
end
new_str.join(" ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_words(string)\n string.split.each { |word| word.reverse! if word.length >= 5 }.join(' ')\nend",
"def reverse_words(string)\n string.split.each { |word| word.reverse! if word.length >= 5 }.join(' ')\nend",
"def reverse_words(string)\n words = string.split\n words.each { |word| word.reverse! if word.length >= 5 }\n words.join(' ')\nend",
"def reverse_words(string)\n words = string.split(' ')\n words.each do |word|\n word.reverse! if word.length >= 5\n end\n reverse = words.join(' ')\nend",
"def reverse_words(string)\n words = string.split.each do |word|\n words = word.reverse! if word.length >= 5\n end\n words.join(' ')\nend",
"def reverse_words(string)\n array = string.split(\" \").each do |word|\n if word.length >= 5\n word.reverse!\n else\n word\n end\n end\n array.join(\" \")\nend",
"def reverse_five(str)\n words = str.split\n words.each {|word| word.reverse! if word.length >= 5}\n words.join(\" \")\nend",
"def reverse_words(str)\n str.split.each { |word| word.reverse! if word.length >= 5 }.join(' ')\nend",
"def reverse_words(string)\n string.split.map { |word| word.length >= 5 ? word.reverse : word }.join(' ')\nend",
"def reverse_words(string)\n words_array = string.split\n words_array.each do |word|\n word.reverse! if word.size >= 5\n end\n words_array.join(' ')\nend",
"def reverse_words(string)\n string.split.map {|x| x.length >= 5 ? x.reverse : x}.join(\" \")\nend",
"def reverse_words(string)\n string.split.map { |word| (word.length >= 5) ? word.reverse : word }.join(' ')\nend",
"def reverse_words(string)\n words = string.split\n new_words = []\n words.each do |word|\n if word.length >= 5\n new_words << word.reverse\n else\n new_words << word\n end\n end\n new_words.join(' ')\nend",
"def reverse_words(str)\n str.split.each { |word| word.reverse! if word.size >= 5 }.join(' ')\nend",
"def reverse_words(string)\n words = []\n string.split.each do |word|\n word.reverse! if word.length >= 5\n words << word\n end\n words.join(\" \")\nend",
"def reverse_words(string)\n reversed_string = string.split.map do |word|\n word.size >= 5 ? word.reverse : word\n end\n reversed_string.join(' ')\nend",
"def reverse_five(str)\n arr = str.split\n arr.each do |word|\n if word.length >= 5\n word.reverse!\n end\n end\n arr.join(\" \")\nend",
"def reverse_words(str)\n str.gsub(/\\w{5,}/) { |word| word.reverse }\nend",
"def reverse_words(string)\n reversed = string.split.map do |word|\n word.reverse! if word.length >= 5\n word\n end\n reversed.join(' ')\nend",
"def reverse_words(string)\n words = []\n \n string.split.each do |word|\n word.reverse! if word.length >= 5\n words << word\n end \n\n words.join(' ')\nend",
"def reverse_words(str)\n new_words = []\n str.split(' ').each do |s|\n new_words << s.length >= 5 ? s.chars.reverse.join : s\n end\n new_words.join(' ')\nend",
"def reverse_word(string)\n words = []\n\n string.split each do |word|\n word.reverse! if word.size >= 5\n words << word\n end\n\n words.join(' ')\nend",
"def reverse_words(string)\n words = []\n words = string.split\n for word in words\n if word.size >= 5\n word.reverse!\n end\n end\n words.join(\" \")\nend",
"def reverse_words(string)\n words = []\n\n string.split.each do |word|\n word.reverse! if word.size >= 5\n words << word\n end\n\n words.join(' ')\nend",
"def reverse_five(str)\n arr = str.split\n new_arr = []\n arr.each do |word|\n word.length >= 5 ? new_arr << word.reverse : new_arr << word\n end\n new_arr.join(' ')\nend",
"def reverse_words(string)\n if string.split.size >= 2\n counter = 0\n array = string.split\n loop do \n current_element = array[counter] \n if current_element.size >= 5\n array[counter] = current_element.chars.reverse.join\n end\n counter += 1\n break if counter == array.size\n end\n array.join(' ')\n else\n string.chars.reverse.join\n end\nend",
"def reverse_words(string)\n words = []\n\n string.split.each do |word|\n word.reverse! if word.size >= 5\n words.push(word)\n end\n words.join(' ')\nend",
"def reverse_words1(string)\n words = []\n\n string.split.each do |word|\n word.reverse! if word.size >= 5\n words << word\n end\n\n words.join(' ')\nend",
"def nj_reverse_words(str)\n str.gsub(/\\w{5,}/, &:reverse)\nend",
"def reverse_words(string)\n result = []\n\n string.split.each do |word|\n word.reverse! if word.size >= 5\n result.push(word)\n end\n\n result.join(' ')\n\nend",
"def reverse_words(string)\n array_words = string.split(\" \")\n array_words.map! do |word|\n if word.length >= 5\n word.reverse!\n else\n word\n end\n end\n array_words.join(\" \")\nend",
"def reverse_words(words)\n words = words.split\n i = 0\n\n while i < words.count do\n words[i].replace(words[i].reverse) if words[i].size >= 5\n i += 1\n end\n\n words.join(' ')\nend",
"def reverse_words(input_string)\n words_array = input_string.split\n\n words_array.map! do |word|\n word.size >= 5 ? word.reverse : word\n end\n\n words_array.join(' ')\nend",
"def reverse_five(str)\n result = str.split(' ').map do |word|\n word.size >= 5 ? word.reverse : word\n end\n result.join(' ')\nend",
"def reverse_five(str)\n str_arr = str.split(' ')\n output_arr = []\n\n str_arr.each do |word|\n if word.length >= 5\n output_arr << word.reverse\n else\n output_arr << word\n end\n end\n\n output_arr.join(' ')\nend",
"def reverse_words(string)\n \n array_words = string.split\n \n array_reverse = \n array_words.map do |str|\n if str.size >= 5\n str.reverse\n else\n str\n end\n end\n array_reverse.join(' ')\nend",
"def reverse_words(string)\n words = string.split\n \n words.map! do |word|\n if word.length >= 5\n word.reverse\n else\n word\n end\n end\n words.join(\" \")\nend",
"def reverse_five(str)\n new_str_arr = str.split.map do |word|\n if word.length >= 5\n word.reverse\n else\n word\n end\n end\n return new_str_arr.join(\" \")\nend",
"def reverse_words(str)\n words = []\n\n str.split.each do |word|\n word.reverse! if word.size >= 5\n words << word\n end\n\n words.join(\" \")\nend",
"def reverse_words(string)\n \n if string.class == String\n \n array = string.split\n result = array.map do |word|\n \n word.reverse! if word.length >= 5\n word\n\n end\n\n result.join(' ') \n \n else\n \"Strings only!\"\n end\nend",
"def reverse_words(str)\n arr = str.split.map do |item|\n item.reverse! if item.size >= 5\n item\n end\n arr.join(' ')\nend",
"def reverse_words(str)\n str.split.map do |word|\n word = word.reverse if word.size > 5\n\n word\n end.join(' ')\nend",
"def reverse_five(str)\n str = str.split(\" \")\n str.each do |s|\n s.to_s\n s.reverse! if s.length >= 5\n end\n str.join(\" \")\nend",
"def reversal2(string)\n array = string.split\n array.map! do |word|\n if word.length >= 5\n word.reverse\n else\n word\n end\n end\n array.join(' ')\nend",
"def reverse_words3(str)\n str.split.map { |word| word.length >= 5 ? word.reverse : word }.join(' ') \nend",
"def reverse_words(str)\n words = []\n \n str.split.each do |word|\n word.reverse! if word.size >= 5\n words << word\n end\n \n words.join(' ')\n \nend",
"def reverse_words(string)\n words = string.split(' ')\n words = words.map do |word|\n if word.length >= 5\n word.reverse\n else\n word\n end\n end\n words.join(' ')\n\nend",
"def reverse_five(str)\n result = []\n str = str.split(\" \")\n str.each do |word|\n if word.length > 4\n result << word.reverse\n else\n result << word\n end\n end\n result.join(\" \")\nend",
"def reverse_words(string)\n reverted_string = []\n string.split.each do |word|\n word.length > 4 ? reverted_string << word.reverse : reverted_string << word\n end\n reverted_string.join(\" \")\nend",
"def reverse_words(str)\n result_array = []\n str.split.each do |word|\n if word.size >= 5\n result_array << word.reverse\n else\n result_array << word\n end\n end\n if result_array.size > 1\n answer = result_array.join(' ')\n else\n answer = result_array.join('')\n end\n answer\nend",
"def reverse_sentence(str)\n str.split.map { | word | word.length > 5 ? word.reverse : word }.join(\" \")\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 reverse_words(str)\n new_str = []\n str.split.each do |word|\n new_str.push(word.chars.reverse.join) if word.length > 4\n new_str.push(word) if word.length < 5\n end\n new_str.join(\" \")\nend",
"def reverse_words(str)\r\n arr = str.split\r\n arr.map do |x| \r\n if x.length >= 5 \r\n x.reverse!\r\n else\r\n x\r\n end\r\n end\r\n arr.join(' ')\r\nend",
"def reverse_words(str)\n new_array = str.split(' ').map do |word|\n if word.size >= 5\n word.reverse!\n else\n word\n end\n end\n new_array.join(' ')\nend",
"def reverse_five(str)\n\t(str.split.map { |c| c.length >= 5 ? c.reverse : c } ).join(\" \")\nend",
"def reverse_words(str)\n\tarr = []\n\n\tstr.split.map do |word| \n\tword.reverse if word.size >= 5\n\tarr << word\n\tend\n\n\tarr.join(' ')\nend",
"def reverse_words(string)\n new_string = string.split.each do |word|\n if word.size > 4 #next time use single line\n word.reverse!\n end\n end\n new_string.join(' ')\nend",
"def reverse_words(string)\n loop do\n string.split.each do |word|\n if word.length >= 5\n print word.reverse, ' '\n else\n print word, ' '\n end\n end\n break\n end\nend",
"def another_way(string)\n words = []\n \n string.split.each do |word|\n word.reverse! if word.size >= 5\n words << word\n end\n \n words.join(' ')\nend",
"def reverse_sentence(str)\n word_array = str.split(\" \")\n word_array.each do |item| \n item.reverse! if item.size >= 5\n end\n word_array.join(\" \")\nend",
"def reverse_five(string)\n arr = string.split(' ')\n i = 0\n while i < string.length\n if arr[i].length >= 5\n arr[i] = arr[i].reverse\n else\n arr[i] = arr[i]\n end\n i +=1\n end\n arr.join(' ')\n end",
"def reverse_five(str)\nnew_sent = []\nwords = str.split(\" \")\nwords.each do |x|\n if x.length > 4\n new_sent << x.reverse\n else\n new_sent << x\n end\nend\n new_sent.join(\" \")\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 spinWords(string)\n string.gsub(/\\w{5,}/, &:reverse)\nend",
"def reverse_words(sentence)\n words = sentence.split\n word_array = []\n words.each do |word|\n if word.length < 5\n word_array << word\n else\n word_array << word.reverse\n end\n end\n word_array.join(' ')\nend",
"def reverse_words(words)\n arr_words = words.split(\" \")\n reverse_array = []\n arr_words.each do |word|\n if word.length >= 5\n reverse_array << word.reverse\n else\n reverse_array << word\n end\n end\n reverse_array.join(\" \")\nend",
"def reverse_words(sentence)\n words = []\n sentence.split.each do |word|\n if word.size >= 5\n word.reverse!\n end\n words << word\n end\n words.join(' ')\nend",
"def reverse_five(str)\r\n # your code goes here\r\n temp = str.split(\" \")\r\n\r\n for i in 0 ... temp.length\r\n if temp[i].length >= 5\r\n temp[i].reverse!\r\n end\r\n end\r\n temp.join(\" \")\r\n\r\nend",
"def reverse_words(sentence)\n arr = []\n sentence.split(' ').each do |word| \n if word.length >= 5\n arr << word.split(//).reverse!.join\n else \n arr << word\n end \n end\n arr.join(\" \")\nend",
"def reverse_words(string)\n string_split = string.split\n word_count = string_split.length-1\n reversed_string = []\n string_split.each do | word |\n reversed_string << string_split[word_count]\n word_count -= 1\n end\n reversed_string.join(' ')\nend",
"def spinWordsAlt( string )\n #Split words in the string into an array\n words = string.split(' ')\n for i in ( 0...words.length() ) do\n if words[i].length() >= 5\n words[i] = reverse( words[i] )\n end\n end\n return words.join(' ')\nend",
"def reverse_five(str)\n final = []\n str.split.each do |x|\n x.reverse! if x.length > 4\n final << x\n end\n\n final.join(' ')\nend",
"def reverse_words(string)\n words = string.split(' ')\n reverse_str = []\n\n words.length.times do |i|\n reverse_str[i] = words[i].reverse\n end\n\n return reverse_str.join(\" \")\nend",
"def reverse_words(string)\n words = string.split(' ')\n reverse_string = []\n\n words.length.times do |i|\n reverse_string[i] = words[i].reverse\n end\n\n return reverse_string.join(\" \")\nend",
"def reverse_words(string)\n\t\ta = string.split(\" \")\n\t\tb = a.length\n\t\t\n\t\tif b > 1\n\t\t\t a.map{|value| value = value.reverse}.join(\" \")\n\t\t\telse\n\t\t\t string.reverse\n\t\tend\n\tend",
"def reverse_words (string)\n array = string.split(\"\")\n array.reverse!\n final = array.join(\"\")\n return final\nend",
"def reverse_words(s)\n s.split(/\\s+/).map\n {|w|wl=w.length-1;\n (0..wl).map{|i|w[wl-i]}.join}.join(' ')\n end",
"def reverse_words (string)\n string_array = string.split(\" \").to_a\n string_array.each {|word| word.reverse!}\n new_string = string_array.join(\" \")\nend",
"def reverse_words(words = ' ')\n if words.to_s =~ /\\d+/\n puts 'Invalid input: only letters and spaces allowed.'\n else\n array = words.split.map { |x| x.length >= 5 ? x.reverse : x }\n array.join(' ')\n end\nend",
"def reverse_each_word(string)\n string.split\n string.split.collect do |s|\n s.reverse!\n s.split.join(\" \")\n end\n .join(\" \")\nend",
"def reverse_each_word(string)\n string.split.collect {|word| word.reverse}.join(\" \")\nend",
"def reverse_each_word(string)\n string.split.collect {|word| word.reverse}.join(\" \")\nend",
"def reverse_each_word(string)\n string.split.collect {|word| word.reverse}.join(\" \")\nend",
"def reverse_each_word(string)\n string.split.collect {|word| word.reverse}.join(\" \")\nend",
"def q5_reverse(str)\n str.split('').reverse.join('')\nend",
"def reverse_each_word(string)\n string.reverse.split.collect { |word| word }.reverse.join(\" \")\nend",
"def reverse_each_word(string)\n rev_string = string.split\n rev_string.collect do |rev|\n rev.reverse!\n end\n return rev_string.join(\" \")\nend",
"def reverse_each_word(string)\n string.split(\" \").collect {|word| word.reverse!}.join(\" \")\nend",
"def reverse_words(string)\n words = string.split()\n words.each_with_index { |word, index| words[index] = word.reverse() }\n p words.join(\" \")\nend",
"def reverse_each_word(string)\n string.split(\" \").collect {|x| x.reverse!}.join(\" \")\nend",
"def reverse_each_word(string)\n words_arr = string.split\n reverse = words_arr.collect {|word| word.reverse}\n reverse.join(\" \")\nend",
"def wordReverse (string_of_words)\n\n new_string = string_of_words.split(' ').reverse().join(' ')\n puts new_string\n\nend",
"def reverse_string_5(string)\n string = string.to_s\n result = ''\n string.split('').each_index do |i|\n result += if i != 0\n string[-1 * (i + 1)]\n else\n string[i - 1]\n end\n end\n result\nend",
"def reverse_each_word(string)\n array = string.split\n array.each do |word|\n word.reverse!\n end\n array.join(\" \")\nend",
"def reverse_each_word(string)\n array = string.split\n array.collect {|words| words.reverse}.join(\" \")\nend",
"def reverse_each_word(string)\n array = string.split(\" \")\n reverse_array = array.collect {|word| word.reverse}\n reverse_string = reverse_array.join(\" \")\n return reverse_string\nend",
"def reverse_words(string)\n\tinput = string.split(\" \")\n\treversed = []\n\tinput.each do |x|\n\t\treversed << x.reverse\n\tend\n\treversed.join(\" \")\nend",
"def reverse_words(string)\n p string.split.map!{|word| word.reverse}.join(\" \")\nend",
"def reverse_words(string)\n p string.split.map!{|word| word.reverse}.join(\" \")\nend"
] | [
"0.8558179",
"0.8558179",
"0.855638",
"0.8515907",
"0.84918094",
"0.8464054",
"0.8432539",
"0.84237075",
"0.84180295",
"0.84021336",
"0.8378752",
"0.83561283",
"0.8354957",
"0.83407587",
"0.83191276",
"0.8316872",
"0.82911116",
"0.82754487",
"0.8258919",
"0.8240712",
"0.82387894",
"0.8221386",
"0.8214237",
"0.81885016",
"0.8179371",
"0.8155955",
"0.8118712",
"0.80880696",
"0.80740494",
"0.80648386",
"0.80598944",
"0.8057208",
"0.80321133",
"0.8024756",
"0.8024685",
"0.8020372",
"0.8013365",
"0.7999293",
"0.79956836",
"0.79931366",
"0.7966186",
"0.7954658",
"0.7936022",
"0.7924062",
"0.79186445",
"0.791125",
"0.7875387",
"0.7864525",
"0.7848512",
"0.7847147",
"0.7827822",
"0.78118426",
"0.7807902",
"0.7794741",
"0.77761954",
"0.7768392",
"0.77202535",
"0.7719186",
"0.77183366",
"0.77165",
"0.76951414",
"0.7632183",
"0.7619603",
"0.7614536",
"0.7599065",
"0.75899994",
"0.75856805",
"0.75719726",
"0.75382787",
"0.750411",
"0.75019217",
"0.7459867",
"0.74252003",
"0.74155986",
"0.74129987",
"0.73859364",
"0.73859006",
"0.73780835",
"0.7376494",
"0.7369971",
"0.73545146",
"0.7330454",
"0.7330454",
"0.7330454",
"0.7330454",
"0.7326932",
"0.73116124",
"0.7303137",
"0.7302355",
"0.72982186",
"0.729589",
"0.7281675",
"0.72785395",
"0.7278316",
"0.7264407",
"0.7257927",
"0.72484416",
"0.72470266",
"0.7235223",
"0.7235223"
] | 0.82281363 | 21 |
Return an array of integers from 1 to n (inclusive), except for each multiple of 3 replace the integer with "fizz", for each multiple of 5 replace the integer with "buzz", and for each multiple of both 3 and 5, replace the integer with "fizzbuzz". | def fizzbuzz(max)
arr =[]
(1..max).each do |n|
if n % 3 != 0 && n % 5 != 0
arr.push n
else
val = ''
if n % 3 == 0
val = "fizz"
end
if n % 5 == 0
val += "buzz"
end
arr.push val
end
end
arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fizzbuzz(n)\n array = []\n (1..n).each do |num|\n if num % 15 == 0\n array << \"fizzbuzz\"\n elsif num % 3 == 0\n array << \"fizz\"\n elsif num % 5 == 0\n array << \"buzz\"\n else\n array << num\n end\n end\n return array\nend",
"def fizzbuzz(n)\n arr = []\n (1..n).each do |i|\n case\n when (i % 3 == 0) && (i % 5 == 0) then arr << \"fizzbuzz\"\n when i % 3 == 0 then arr << \"fizz\"\n when i % 5 == 0 then arr << \"buzz\"\n else arr << i\n end\n end\n arr\nend",
"def fizzbuzz(n)\n output_arr = []\n\n (1..n).each do |num|\n if num % 5 == 0 && num % 3 == 0\n output_arr << 'fizzbuzz'\n elsif num % 5 == 0\n output_arr << 'buzz'\n elsif num % 3 == 0\n output_arr << 'fizz'\n else\n output_arr << num\n end\n end\n\n output_arr\nend",
"def fizzbuzz(n)\n array = (1..n).to_a\n answer = []\n for i in array do\n if (i % 15 == 0)\n answer.push('FizzBuzz')\n elsif (i % 3 == 0)\n answer.push('Fizz')\n elsif (i % 5 == 0)\n answer.push('Buzz')\n else \n answer.push(i)\n end\n end\n answer\nend",
"def fizzbuzz(n)\n result = []\n (1..n).each do |num|\n if num % 3 == 0 && num % 5 == 0\n result << \"fizzbuzz\"\n elsif num % 3 == 0\n result << \"fizz\"\n elsif num % 5 == 0\n result << \"buzz\"\n else\n result << num\n end\n end\n result\nend",
"def fizzbuzz(n)\n range = [*1..n]\n range.map! do |num|\n if num % 3 == 0 && num % 5 == 0\n num = \"fizzbuzz\"\n elsif num % 5 == 0\n num = \"buzz\"\n elsif num % 3 == 0\n num = \"fizz\"\n else\n num\n end\n end\nend",
"def fizzbuzz(n)\n numbers = []\n (1..n).each do |num|\n if num % 3 == 0\n value = (num % 5 == 0) ? \"fizzbuzz\" : \"fizz\"\n numbers << value\n elsif num % 5 == 0\n numbers << \"buzz\"\n else\n numbers << num\n end\n end\n numbers\nend",
"def fizzbuzz(n)\n numbers = (1..n).to_a\n numbers.map do |num|\n if (num % 15 == 0)\n \"FizzBuzz\"\n elsif (num % 5 == 0)\n \"Buzz\"\n elsif (num % 3 == 0)\n \"Fizz\"\n else num\n end\n end\n end",
"def fizzbuzz(n)\n myary = []\n myn = 1\n (0...n).each do\n if myn % 15 == 0\n myary << \"FizzBuzz\"\n myn += 1\n elsif myn % 5 == 0\n myary << \"Buzz\"\n myn += 1\n elsif myn % 3 == 0\n myary << \"Fizz\"\n myn += 1\n else\n myary << myn\n myn += 1\n end\n end\n myary\nend",
"def fizzbuzz(n)\n arr = []\n (1..n).each do |num|\n mod3 = (num % 3).zero?\n mod5 = (num % 5).zero?\n result = ''\n result += 'fizz' if mod3\n result += 'buzz' if mod5\n result.empty? ? arr.push(num) : arr.push(result)\n end\n arr\nend",
"def fizzbuzz(n)\n\t(1..n).map do |n|\n\t\tif n % 15 == 0\n\t\t\t\"fizzbuzz\"\n\t\telsif n % 3 == 0\n\t\t\t\"fizz\"\n\t\telsif n % 5 == 0\n\t\t\t\"buzz\"\n\t\telse\n\t\t\tn\n\t\tend\n\tend\nend",
"def fizzbuzz(n)\n (1..n).map do |n|\n if n%3==0 && n%5==0\n \"fizzbuzz\"\n elsif n%3==0\n \"fizz\"\n elsif n%5==0\n \"buzz\"\n else\n n\n end\n end\nend",
"def fizzbuzz(n)\n (1..n).map do |num|\n if num % 3 == 0 && num % 5 == 0\n 'FizzBuzz'\n elsif num % 3 == 0\n 'Fizz'\n elsif num % 5 == 0\n 'Buzz'\n else\n num\n end\n end\nend",
"def super_fizzbuzz(array)\n new_array = []\n array.each do |x|\n if x % 3 == 0 && x % 5 == 0\n new_array << \"FizzBuzz\"\n elsif x % 3 == 0\n new_array << \"Fizz\"\n elsif x % 5 == 0\n new_array << \"Buzz\"\n else\n new_array << x\n end\n end\n new_array\nend",
"def super_fizzbuzz(array)\n new_array = []\n array.each do |i|\n if i % 15 == 0\n new_array << \"FizzBuzz\"\n elsif i % 3 == 0\n new_array << \"Fizz\"\n elsif i % 5 == 0\n new_array << \"Buzz\"\n else\n new_array << i\n end\n end\n\nreturn new_array\nend",
"def super_fizzbuzz(array)\n new_array = []\n array.each do |i|\n if i % 15 == 0\n new_array << \"FizzBuzz\"\n elsif i % 3 == 0\n new_array << \"Fizz\"\n elsif i % 5 == 0\n new_array << \"Buzz\"\n else\n new_array << i\n end\n end\n\nreturn new_array\nend",
"def super_fizzbuzz(array)\n\tnew_array = []\n\tarray.each do |num| \n\t\tif num % 15 == 0\n\t\t\tnew_array << \"FizzBuzz\"\n\t\telsif num % 3 == 0\n\t\t\tnew_array << \"Fizz\"\n\t\telsif num % 5 == 0\n\t\t\tnew_array << \"Buzz\"\n\t\telse \n\t\t\tnew_array << num\n\t\tend\n\tend\n\tnew_array\nend",
"def super_fizzbuzz(array)\n\ti = 0\n\tarray.each do |num|\n\t\t\tarray[i] = \"Fizz\" if num % 3 == 0 && num % 5 != 0\n\t\t array[i] = \"Buzz\" if num % 5 == 0 && num % 3 != 0\n\t\t\tarray[i] = \"FizzBuzz\" if num % 3 == 0 && num % 5 == 0\n\t\t\ti += 1\n\t end\nend",
"def super_fizzbuzz(array)\n array.map! do |x| \n if x % 3 == 0 && x % 5 != 0\n x = \"Fizz\"\n elsif x % 5 == 0 && x % 3 != 0\n x = \"Buzz\"\n elsif x % 15 == 0\n x = \"FizzBuzz\"\n else x = x\n end\n end\nend",
"def fizzbuzz(n)\n new_sent = []\n(1..n).each do |x|\n if x % 15 == 0\n new_sent << \"fizzbuzz\"\n elsif x % 5 == 0\n new_sent << \"buzz\"\n elsif x % 3 == 0\n new_sent << \"fizz\"\n else\n new_sent << x\n end\n end\n new_sent\nend",
"def fizzbuzz\narray = []\n\tfor i in 1..100\n\t\tif i%3 == 0 && i%5 == 0\n\t\t\tarray << 'FizzBuzz'\n\t\telsif i%3 == 0\n\t\t\tarray << 'Fizz'\n\t\telsif i%5 == 0 \n\t\t\tarray << 'Buzz'\n\t\telse\n\t\t\tarray << i\n \t\t\ti+= 1\n\t\tend\n\tend\n\t\t\treturn array\nend",
"def super_fizzbuzz(array)\n\tnew_arr = []\n\tarray.each do |x|\n\t\tif x % 3 == 0 && x % 5 == 0\n\t\t\tnew_arr << \"FizzBuzz\"\n\t\telsif x % 5 == 0\n\t\t\tnew_arr << \"Buzz\"\n\t\telsif x % 3 == 0\n\t\t\tnew_arr << \"Fizz\"\n\t\telse\n\t\t\tnew_arr << x\n\t\tend\n\tend\n\treturn new_arr\n\nend",
"def fizzbuzz\n zz_array = []\n 1.upto(100) do |num|\n if num % 3 == 0 && num % 5 == 0\n zz_array << 'FizzBuzz'\n elsif num % 3 == 0\n zz_array << 'Fizz'\n elsif num % 5 == 0\n zz_array << 'Buzz'\n else\n zz_array << num\n end\n end\n return zz_array\nend",
"def super_fizzbuzz(array)\n array.map! {|num| puts \"#{'Fizz' if num % 3 == 0}#{'Buzz' if num % 5 == 0}#{num if num % 5 != 0 && num % 3 != 0}\"}\nend",
"def fizz_buzz_no_cons\n\tpossible_fizz = [1, 0, 0]\n possible_buzz = [2, 0, 0, 0, 0]\n words = [None, \"Fizz\", \"Buzz\", \"FizzBuzz\"]\n \n n.times do |i|\n words[0] = i\n puts(words[possible_fizz[i%3] + possible_buzz[i%5]])\n end\n \nend",
"def super_fizzbuzz(array)\n\tarray.map! {|i|\n\t\tif i % 3 == 0 && i % 5 == 0\n\t\t\ti = \"FizzBuzz\"\n\t\telsif i % 3 == 0\n\t\t\ti = \"Fizz\"\n\t\telsif i % 5 == 0\n\t\t\ti = \"Buzz\"\n\t\telse i = i\n\t\tend\n\t\t}\t\t\n\treturn array\nend",
"def fizzbuzz\n\tnum_arr = Array.new(100) {|index| index+1}\n\tarr = Array.new(100) {''}\n\tnum_arr.each do |i|\n\n\t \tif i%3 == 0\n\t \t\tif i%5 == 0\n\t \t\t\tarr[i-1] = 'FizzBuzz'\n\t \t\telse\n\t \t\t\tarr[i-1] = 'Fizz'\n\t \t\tend\n\t \telsif i%5 == 0\n\t \t\tarr[i-1] = 'Buzz'\n\t \telse\n\t \t\tarr[i-1] = i.to_s\n\t \tend\n\t end\n \tarr\nend",
"def super_fizzbuzz(array)\n array.map do |i|\n if i%15 == 0\n i = 'FizzBuzz'\n elsif i%5 == 0\n i = 'Buzz'\n elsif i%3 == 0\n i = 'Fizz'\n else \n i\n end\n end\nend",
"def super_fizzbuzz(array)\n array.map! do |num|\n if (num % 3 == 0 && num % 5 == 0 && num % 15 == 0)\n \"FizzBuzz\"\n elsif (num % 3 == 0)\n \"Fizz\"\n elsif (num % 5 == 0)\n \"Buzz\"\n else\n num\n end\n end\n array\nend",
"def super_fizzbuzz(array)\n array.map do |number|\n if number % 15 == 0\n number = \"FizzBuzz\"\n elsif number % 3 == 0\n number = \"Fizz\" \n elsif number % 5 == 0\n number = \"Buzz\"\n else\n number = number\n end \n end\nend",
"def super_fizzbuzz(array)\nbuzz_array=[]\narray.map { |number| \n if number % 15 == 0\n \tbuzz_array << \"FizzBuzz\"\n elsif number % 3 == 0\n \tbuzz_array << \"Fizz\"\n elsif number % 5 == 0\n \tbuzz_array << \"Buzz\" \n else\n \tbuzz_array << number\n end\n}\nreturn buzz_array\nend",
"def fizzbuzz\r\n # your code goes here\r\n arr = []\r\n\r\n for i in 1 .. 30\r\n if i % 5 == 0 && i % 3 == 0\r\n arr << \"fizzbuzz\"\r\n\r\n elsif i % 3 == 0\r\n arr << \"fizz\"\r\n\r\n elsif i % 5 == 0\r\n arr << \"buzz\"\r\n\r\n else arr << i\r\n end\r\n end\r\n arr\r\nend",
"def fizzbuzz_array(n)\n (1..n).map do |i|\n fizzbuzz(i)\n end\nend",
"def super_fizzbuzz(array)\n array.map! { |num|\n if num % 3 == 0 && num % 5 == 0\n num = \"FizzBuzz\"\n elsif num % 3 == 0\n num = \"Fizz\"\n elsif num % 5 == 0\n num = \"Buzz\"\n else\n num\n end\n }\n array\nend",
"def super_fizzbuzz(array)\n array.map do |num|\n if (num % 15 == 0)\n num = \"FizzBuzz\"\n elsif (num % 3 == 0)\n num = \"Fizz\"\n elsif (num % 5 == 0)\n num = \"Buzz\"\n else\n num\n end\n end\nend",
"def super_fizzbuzz(array)\n array.map! do |element|\n if element % 15 == 0\n element = \"FizzBuzz\"\n elsif element % 5 == 0\n element = \"Buzz\"\n elsif element % 3 == 0\n element = \"Fizz\"\n else\n element = element\n end\n end\nend",
"def super_fizzbuzz(array)\n array.map do |x|\n if (x % 15 ==0)\n x = \"FizzBuzz\"\n elsif (x % 5 ==0)\n x = \"Buzz\"\n elsif (x % 3 ==0)\n x = \"Fizz\"\n else\n x\n end\n end\nend",
"def fizzbuzz\n # TODO write your code here\n fizz_array = []\n\n for count in 1..100\n if (count%3 == 0 && count%5 == 0)\n fizz_array[count] = 'FizzBuzz'\n elsif count%3 == 0\n fizz_array[count] = 'Fizz'\n elsif count%5 == 0\n fizz_array[count] = 'Buzz'\n else\n fizz_array[count] = count\n end\n end\n\n fizz_array\nend",
"def fizzbuzz(num1, num2)\n array = (num1..num2).to_a\n fizzbuzz = array.map do |n|\n if n % 3 == 0 && n % 5 == 0\n 'FizzBuzz'\n elsif n % 5 == 0\n 'Buzz'\n elsif n % 3 == 0\n 'Fizz'\n else \n n\n end\n end\n fizzbuzz.join(' ')\nend",
"def super_fizzbuzz(array)\n array.map! do |x|\n if x % 15 == 0\n \"FizzBuzz\"\n elsif x % 5 == 0\n \"Buzz\"\n elsif x % 3 == 0\n \"Fizz\"\n else\n x\n end\n end\nend",
"def super_fizzbuzz(array)\n\tarray.map! do |num|\n\t\tif num % 15 == 0\n\t\t\t\"FizzBuzz\"\n\t\telsif num % 3 == 0\n\t\t\t\"Fizz\"\n\t\telsif num % 5 == 0\n\t\t\t\"Buzz\"\n\t\telse\n\t\t\tnum\n\t\tend\n\tend\nreturn array\t\t\nend",
"def super_fizzbuzz(array)\n\tarray.map.with_index do |num, index|\n\t\tif array[index] % 15 == 0\n\t\t\tarray[index] = \"FizzBuzz\"\n\t\telsif array[index] % 3 == 0\n\t\t\tarray[index] = \"Fizz\"\n\t\telsif array[index] % 5 == 0\n\t\t\tarray[index] = \"Buzz\"\n\t\tend\n\tend\n\treturn array\nend",
"def super_fizzbuzz(array)\n array.map do |num|\n if num % 15 == 0\n num = 'FizzBuzz'\n elsif num % 5 == 0\n num = 'Buzz'\n elsif num % 3 == 0\n num = 'Fizz'\n else\n num\n end\n end\nend",
"def super_fizzbuzz(array)\n array.map do |x|\n if x % 15 == 0\n x = x.to_s.replace(\"FizzBuzz\")\n elsif x % 5 == 0\n x = x.to_s.replace(\"Buzz\")\n elsif x % 3 == 0\n x = x.to_s.replace(\"Fizz\")\n else\n x = x\n end\nend\nend",
"def fizzbuzz\n (1..100).map do |i|\n\tif (i % 15).zero?\n\t 'FizzBuzz'\n\telsif (i % 3).zero?\n\t 'Fizz'\n\telsif (i % 5).zero?\n\t 'Buzz'\n\telse\n\t i\n\tend\n end\nend",
"def fizz_buzz(max)\n\tnewArr = []\n i = 1\n while i < max\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n newArr << i\n end\n i += 1\n end\n return newArr\nend",
"def super_fizzbuzz(array)\n\tarray.collect do |i|\n \tif i % 15 == 0\n \t\t\"FizzBuzz\"\n \telsif i % 5 == 0\n \t\t\"Buzz\"\n \telsif i % 3 == 0\n \t\t\"Fizz\"\n \telse\n \t\ti\n \tend\n \tend\nend",
"def fizzbuzz\n an_array = Array.new(100)\n for cnt in 1..100\n l3_rem = cnt%3\n l5_rem = cnt%5\n if l3_rem == 0 && l5_rem != 0\n an_array[cnt -1 ] = 'Fizz'\n elsif l3_rem != 0 && l5_rem == 0\n an_array[ cnt -1 ] = 'Buzz'\n elsif l3_rem == 0 && l5_rem == 0\n an_array[ cnt - 1] = 'FizzBuzz'\n else\n an_array[ cnt - 1] = cnt\n end\n end\n return an_array\nend",
"def super_fizzbuzz(array)\n\tfizzbuzzed_array = []\n\tarray.each do |element|\n\t\tif element % 15 == 0\n\t\t\tfizzbuzzed_array << \"FizzBuzz\"\n\t\telsif element % 3 == 0\n\t\t\tfizzbuzzed_array << \"Fizz\"\n\t\telsif element % 5 == 0\n\t\t\tfizzbuzzed_array << \"Buzz\"\n\t\telse\n\t\t\tfizzbuzzed_array << element\n\t\tend\n\tend\n\tfizzbuzzed_array\nend",
"def fizz_buzz(max)\n new_array = []\n \n i = 0\n while i <= max\n if (i % 4 == 0 && i % 6 != 0) || (i % 6 == 0 && i % 4 != 0)\n new_array << i\n end\n \n i += 1\n end\n \n return new_array\nend",
"def fizz_buzz(max)\n\ti = 0\n\tnewArr = []\n \twhile i < max\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n newArr << i\n end\n i += 1\n end\n return newArr\nend",
"def fizz_buzz(max)\n newArray = []\n for i in 0..max\n if (i > 0) && (i < max)\n \tif (i % 4 == 0) ^ (i % 6 == 0)\n newArray << i\n end\n end\n end\n return newArray\nend",
"def fizzbuzz\n\tcount = 0\n\tan_array = []\n\twhile count <100\n\t\tan_array[count] = count\n\t\tif count%5 == 0\n\t\t\tan_array[count] = 'Buzz'\n\t\tend\n\t\tif count%3 == 0\n\t\t\tif count%5 == 0\n\t\t\t\tan_array[count] = 'FizzBuzz'\n\t\t\telse\n\t\t\t\tan_array[count] = 'Fizz'\n\t\t\tend\n\t\tend\n\t\tcount +=1\n\tend\n\treturn an_array\nend",
"def super_fizzbuzz(array)\n array.map do |i| \n if i % 15 == 0 then 'FizzBuzz'\n elsif i % 3 == 0 then 'Fizz' \n elsif i % 5 == 0 then 'Buzz'\n else i\n end\n end\nend",
"def fizzBuzz2(max)\n sol = []\n\n (1...max).each do |num|\n if !(num % 5 == 0 && num % 3 == 0) && (num % 5 == 0 || num % 3 == 0)\n sol << num\n end\n end\n\n sol\nend",
"def fizz_buzz\n [*1..100].map do |num|\n if num % 5 == 0 && num % 3 == 0\n 'FizzBuzz'\n elsif num % 5 == 0\n 'Buzz'\n elsif num % 3 == 0\n 'Fizz'\n else\n num\n end\n end\nend",
"def super_fizzbuzz(array)\n\tarray.map do |num| #got rid of the ! that I had in the original solution. There's no need to alter the underlying array here.\n\t\tif num % 15 == 0\n\t\t\t\"FizzBuzz\"\n\t\telsif num % 5 == 0\n\t\t\t\"Buzz\"\n\t\telsif num % 3 == 0\n\t\t\t\"Fizz\"\n\t\telse\n\t\t\tnum\n\t\tend\n\tend\nend",
"def fizzbuzz(n) n%15==0 ? \"FizzBuzz\" : n%3==0 ? \"Fizz\" : n%5==0 ? \"Buzz\" : nil end",
"def fizzbuzz\n fizzBuzzArray = Array.new\n for num in 1..100\n if num.to_f / 3.to_f == num/3 && num.to_f / 5.to_f == num/5 then\n\tfizzBuzzArray << 'FizzBuzz'\n elsif num.to_f / 3.to_f == num/3 then\n\tfizzBuzzArray << 'Fizz'\n elsif num.to_f / 5.to_f == num/5 then\n\tfizzBuzzArray << 'Buzz'\n else\n fizzBuzzArray << num\n end\n end\n fizzBuzzArray\nend",
"def super_fizzbuzz(array)\n array.map do |value|\n if (value % 3 == 0 && value % 5 == 0)\n 'FizzBuzz'\n elsif (value % 3 == 0)\n 'Fizz'\n elsif (value % 5 == 0)\n 'Buzz'\n else\n value\n end\n end\nend",
"def fizzbuzz\n i =0\n arr=[]\n while i<=100 do\n if i%3 ==0 && i%5==0\n\t arr.push \"FizzBuzz\"\n\n\t elsif i%3==0\n\t arr.push \"Fizz\"\n\n\t elsif i%5==0\n\t arr.push \"Buzz\"\n\t else\n\t arr.push i\n\t end\n i+=1\n end\n return arr\nend",
"def super_fizzbuzz(array)\n\tarray.map do |x|\n\t\tif (x % 15 == 0)\n\t\t\tx = \"FizzBuzz\"\n\t\telsif (x % 5 == 0)\n\t\t\tx = \"Buzz\"\n\t\telsif (x % 3 == 0)\n\t\t\tx = \"Fizz\"\n\t\telse \n\t\t\tx\n\t\tend\n\tend\nend",
"def fizzBuzz(max)\n arr = []\n (1...max).each do |num|\n if num % 3 == 0 && num % 5 !==0\n arr << num\n end\n if num % 3 !== 0 && num % 5 ==0\n arr << num\n end\n puts num\n end\n return arr\nend",
"def super_fizzbuzz(array)\n array.map! do |x|\n if x % 3 == 0 \n x = \"Fizz\"\n elsif x % 5 == 0 \n x = \"Buzz\"\n elsif x % 15 == 0 \n x = \"FizzBuzz\"\n else x % 3 == 0 || x % 5 == 0 || x % 15 == 0\n p x\n end\n end\nend",
"def fizzbuzz(start_num, end_num)\n new_arr = []\n (start_num..end_num).each do |num|\n case \n when (num % 3 == 0) && (num % 5 == 0)\n new_arr << \"FizzBuzz\"\n when num % 5 == 0\n new_arr << \"Buzz\"\n when num % 3 == 0 \n new_arr << \"Fizz\" \n else\n new_arr << num\n end\n end\n puts new_arr.join(', ')\nend",
"def super_fizzbuzz(array)\n\n array.map do |number|\n \n case\n when number % 15 === 0 then 'FizzBuzz'\n when number % 3 === 0 then 'Fizz'\n when number % 5 === 0 then 'Buzz'\n else number\n end\n end\n\nend",
"def fizzbuzz\n\n fb_array = (1..100).to_a\n for i in fb_array\n if i % 3 == 0\n if i % 5 == 0\n fb_array[i-1] = 'FizzBuzz'\n else \n fb_array[i-1] = 'Fizz'\n end\n elsif i % 5 == 0\n fb_array[i-1] = 'Buzz'\n end\n end\n\nend",
"def fizz_buzz(max)\n fizzed = []\n\n i = 1\n while i < max\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n fizzed << i\n end\n i += 1\n end\n\n return fizzed\nend",
"def super_fizzbuzz(array)\n fizzy=[]\n\tarray.each do |x| \n\t if x%3==0 && x%5==0\n\t\t fizzy << \"FizzBuzz\"\n\t elsif x%5==0\n\t\t fizzy << \"Buzz\"\n\t elsif x%3==0\n\t\t fizzy << \"Fizz\"\n\t else\n\t\t fizzy << x\n\t end\n\tend\nreturn fizzy\nend",
"def super_fizzbuzz (array)\n array.map do |num|\n if num % 15 == 0 then num = \"FizzBuzz\"\n elsif num % 3 == 0 then num = \"Fizz\"\n elsif num % 5 == 0 then num = \"Buzz\"\n else num = num\n end\n end\nend",
"def super_fizzbuzz(array)\n array.map do |element|\n if (element % 3 == 0 && element % 5 == 0)\n element = \"FizzBuzz\"\n elsif (element % 3 == 0)\n element = \"Fizz\"\n elsif (element % 5 == 0)\n element = \"Buzz\"\n else\n element\n end\n end \nend",
"def super_fizzbuzz(array)\r\n\r\n\treturn array.map do |number|\r\n\t\tif number % 3 == 0 && number % 5 == 0\r\n\t\t\tnumber = \"FizzBuzz\"\r\n\t\telsif number % 3 == 0 \r\n\t\t\tnumber = \"Fizz\"\r\n\t\telsif number % 5 == 0\r\n\t\t\tnumber = \"Buzz\"\r\n\t\telse\r\n\t\t\tnumber = number\r\n\t\tend\r\n\tend\r\n\r\nend",
"def fizz_buzz(n)\n\t1.upto(n) do |i|\n\t\tif i % 3 == 0\n\t\t\tputs \"Buzz\"\n\t\telsif i % 5 == 0\n\t\t\tputs \"Fizz\"\n\t\telsif i% 15 == 0\n\t\t\tputs \"FizzBuzz\"\n\t\telse\n\t\t\tputs i\n\t\tend\n\tend\nend",
"def super_fizzbuzz(array)\n array.each_with_index do |element, index|\n if element % 15 == 0\n array.delete_at(index)\n array.insert(index, \"FizzBuzz\")\n \n elsif element % 5 == 0\n array.delete_at(index)\n array.insert(index, \"Buzz\")\n \n elsif element % 3 == 0\n array.delete_at(index)\n array.insert(index, \"Fizz\") \n \n end\n end\n return array\nend",
"def super_fizzbuzz(array)\n\tarray.map! do |num|\n\t\tif num % 15 == 0\n\t\t\tnum = 'FizzBuzz'\n\t\telsif num % 5 == 0\n\t\t\tnum = 'Buzz'\n\t\telsif num % 3 == 0\n\t\t\tnum = 'Fizz'\n\t\telse num\n\t\tend\n\tend\n\tp array\nend",
"def pre_fizz(n)\n (1..n).to_a\nend",
"def super_fizzbuzz(array)\n fizzbuzz_array = []\n counter = 0\n while counter < array.length\n if array[counter] % 3 == 0 && array[counter] % 5 != 0\n fizzbuzz_array << \"Fizz\"\n elsif array[counter] % 5 == 0 && array[counter] % 3 != 0\n fizzbuzz_array << \"Buzz\"\n elsif array[counter] % 3 == 0 && array[counter] % 5 == 0\n fizzbuzz_array << \"FizzBuzz\"\n else\n fizzbuzz_array << array[counter]\n end\n counter += 1\n end\n p fizzbuzz_array\nend",
"def super_fizzbuzz(array)\n array.map! {|variable|\n if variable % 15 == 0\n variable = \"FizzBuzz\"\n elsif variable % 5 == 0\n variable = \"Buzz\"\n elsif variable % 3 == 0\n variable = \"Fizz\"\n else\n variable = variable\n end\n }\n\n return array\n\nend",
"def fizzbuzz( n )\n results = ''\n results << \"Fizz\" if n % 3 == 0\n results << \"Buzz\" if n % 5 == 0\n results.empty? ? n : results\nend",
"def super_fizzbuzz(array)\n array.map {|x|\n if x % 15 == 0\n \"FizzBuzz\"\n elsif x % 3 == 0\n \"Fizz\"\n elsif x % 5 == 0\n \"Buzz\"\n else\n x\n end\n }\nend",
"def fizz_buzz(max)\n array = []\n i = 1\n while i < max\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n array << i\n end\n i += 1\n end\n return array\n end",
"def super_fizzbuzz(array)\narray.map!{|item|\n if item % 3 == 0 && item % 5 == 0\n item = \"FizzBuzz\"\n elsif item % 3 == 0\n item = \"Fizz\"\n elsif item % 5 == 0\n item = \"Buzz\"\n else item = item\n end\n}\n\nend",
"def fizz_buzz(max)\n\n new_arr=[]\n\n i = 1\n while i < max\n if i % 4 == 0 && i % 6 != 0\n new_arr << i \n\n elsif i % 6 == 0 && i % 4 != 0\n new_arr << i \n else \n end\n i += 1\n end\n\n return new_arr\nend",
"def super_fizzbuzz(array)\n length = array.length\n # print length\n i = 0\n while i < length\n if (array[i] % 3 == 0 && array[i] % 5 != 0)\n array[i] = \"Fizz\"\n elsif (array[i] % 5 == 0) && (array[i] % 3 != 0)\n array[i] = \"Buzz\"\n elsif (array[i] % 3 == 0) && (array[i] % 5 == 0)\n array[i] = \"FizzBuzz\"\n\n end\n i += 1\n end\n\n return array\n\nend",
"def fizz_buzz(max)\n\ti = 1\n \tarry = []\n while i < max\n if i % 4 == 0 && i % 6 != 0 || i % 4 != 0 && i % 6 == 0\n arry << i\n end\n i += 1\n end\n return arry\nend",
"def super_fizzbuzz(array)\n array.map do |x|\n if x % 15 ==0\n x = \"FizzBuzz\"\n elsif x % 5 == 0\n x = \"Buzz\"\n elsif x % 3 == 0\n x = \"Fizz\"\n else\n x = x\n end\n end\n\nend",
"def fizz_buzz_fancy (n)\n (1..n).each do |i|\n x = ''\n x += 'Fizz' if i % 3 == 0\n x += 'Buzz' if i % 5 == 0\n puts(x.empty? ? i : x)\n end\nend",
"def super_fizzbuzz(array)\n buzz_array = []\n array.each do |x|\n if x % 3 == 0 && x % 5 != 0\n buzz_array.push(\"Fizz\")\n elsif x % 3 != 0 && x % 5 == 0\n buzz_array.push(\"Buzz\")\n elsif x % 3 == 0 && x % 5 == 0\n buzz_array.push(\"FizzBuzz\")\n else\n buzz_array.push(x)\n end\n end\n p buzz_array\nend",
"def fizz_buzz(max)\n arr = [] \n index = 1 \n \n while index < max\n if (index % 4 == 0 || index % 6 == 0) && !(index % 4 == 0 && index % 6 == 0)\n arr << index\n end \n index += 1 \n end \n \n return arr \nend",
"def fizz_buzz(max)\n answer = []\n i = 1\n while i < max\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n answer << i\n end\n i += 1\n end\n return answer\nend",
"def fizzbuzz_group(number)\n if number % 3 == 0 && number % 5 == 0\n \"FizzBuzz\"\n elsif number % 3 == 0\n \"Fizz\"\n elsif number % 5 == 0\n \"Buzz\"\n end\nend",
"def fizzbuzz(start_num, end_num)\n (start_num..end_num).map do |n|\n if n % 3 == 0 && n % 5 == 0\n 'FizzBuzz'\n elsif n % 3 == 0\n 'Fizz'\n elsif n % 5 == 0\n 'Buzz'\n else\n n\n end\n end\nend",
"def fizz_buzz(max) # Define method\n \n i = 0 # Set iteration start\n \n new_array = [] # Create array\n \n while i < max # Set condition that determines how long loop iterates\n\n \tif (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n\n \t\tnew_array << i\n\n \tend\n\n \ti += 1 # Increment loop by 1\n end\n return new_array\n\nend",
"def super_fizzbuzz(array)\n\t# this iterator will keep track of the location of the current element\n\ti = 0 \n\n\t# go through each item in the array\n\tarray.each do |x| \n\t\t# see if it is divisible by 3 \t\t\n\t\tif (x % 3 == 0)\n\t\t\t# see if it is divisible by 15\n\t\t\tif (x % 15 == 0)\n\t\t\t\tarray[i] = \"FizzBuzz\"\n\t\t\telse\n\t\t\t\tarray[i] = \"Fizz\"\n\t\t\tend\n\t\t# if no divisible by 3, see if \n\t\t# divisible by 5\n\t\telsif (x % 5 == 0)\n\t\t\tarray[i] = \"Buzz\" \t\t\n\t\tend\n\n\t\ti +=1\n\tend \nend",
"def fizz_buzz(max)\n result = [] \n (1...max).each do |num|\n if (num % 4 == 00 || num % 6 == 0) && !(num % 4 == 0 && num % 6 == 0)\n result << num\n end\n\n end\n return result\nend",
"def dynamic_fizz_buzz(range, rules)\n range.each do |i|\n result = ''\n\n rules.each do |(text, divisor)|\n result << text if (i % divisor == 0)\n end\n\n puts result == '' ? i : result\n end\nend",
"def fizzbuzz(num1 , num2)\n result = []\n arr = (num1..num2).to_a\n arr.each do |n|\n if n % 3 == 0 && n % 5 == 0\n result << 'FizzBuzz'\n elsif n % 3 == 0\n result << 'Fizz'\n elsif n % 5 == 0\n result << 'Buzz'\n else\n result << n\n end\n end\n puts result.join(', ')\nend",
"def fizzBuzz(max)\n\tarr = []\n\n\t(1...max).each do |num|\n\t\tif num % 3 == 0 && num % 5 != 0\n\t\t\tarr << num\n\t\tend\n\t\tif num % 3 != 0 && num % 5 == 0\n\t\t\tarr << num\n\t\tend\n\tend\n\n\treturn arr\nend",
"def fizzbuzz(num1, num2)\n numbers = num1..num2\n fizzbuzz_array = []\n numbers.each do |x|\n case\n when x % 3 == 0 && x % 5 == 0\n fizzbuzz_array << \"FizzBuzz\"\n when x % 3 == 0\n fizzbuzz_array << \"Fizz\"\n when x % 5 == 0\n fizzbuzz_array << \"Buzz\"\n else\n fizzbuzz_array << x\n end\n end\n\n p fizzbuzz_array.join(\", \")\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"
] | [
"0.7965208",
"0.78761595",
"0.78654754",
"0.7844762",
"0.77889717",
"0.7785351",
"0.7761416",
"0.7693393",
"0.7665432",
"0.76649815",
"0.7532192",
"0.7477176",
"0.74470556",
"0.74005646",
"0.72847",
"0.72847",
"0.72701806",
"0.72695476",
"0.7258598",
"0.7225696",
"0.72227347",
"0.72049075",
"0.7168799",
"0.7166541",
"0.7162471",
"0.71619624",
"0.7160416",
"0.71346825",
"0.71198976",
"0.71134824",
"0.71035075",
"0.7100552",
"0.7098038",
"0.7080226",
"0.7079569",
"0.7077086",
"0.706542",
"0.70412505",
"0.70393914",
"0.70350695",
"0.703217",
"0.70289886",
"0.70286393",
"0.70266813",
"0.70171285",
"0.70096636",
"0.70007014",
"0.69963086",
"0.69960284",
"0.6993358",
"0.69931114",
"0.6988819",
"0.6969527",
"0.6967861",
"0.6963752",
"0.69520104",
"0.6942939",
"0.6937112",
"0.6936111",
"0.69268745",
"0.6922361",
"0.6916397",
"0.6911503",
"0.69092864",
"0.6905083",
"0.6899073",
"0.6893644",
"0.6892753",
"0.6892131",
"0.68892086",
"0.6887803",
"0.68856364",
"0.68817276",
"0.68764365",
"0.6872965",
"0.6869837",
"0.68583244",
"0.6855239",
"0.68459153",
"0.684181",
"0.6840898",
"0.6835227",
"0.6834106",
"0.68340033",
"0.68148696",
"0.681279",
"0.6809613",
"0.6802733",
"0.6797676",
"0.6796096",
"0.6787752",
"0.6777011",
"0.67760205",
"0.6765042",
"0.67632955",
"0.67578095",
"0.67545044",
"0.674429",
"0.67430854",
"0.674179"
] | 0.7294275 | 14 |
HARD Write a method that returns a new array containing all the elements of the original array in reverse order. | def my_reverse(arr)
idx = arr.length - 1
rev = []
while idx >= 0
rev.push(arr[idx])
idx -= 1
end
rev
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_array(array_new)\n array_new.reverse \n end",
"def my_reverse(arr)\n new_array = arr.reverse\n return new_array\n end",
"def my_reverse\n new_arr = []\n i = self.length-1\n while i >= 0\n new_arr << self[i]\n i -= 1\n end\n new_arr\n end",
"def reverse(array)\n result_array = []\n array.reverse_each { |element| result_array << element }\n result_array\nend",
"def reverse(array)\n result_array = []\n array.reverse_each { |element| result_array << element }\n result_array\nend",
"def reverse_array (array) \n return array.reverse\nend",
"def reverse(array)\n new_array = []\n \n array.reverse_each { |element| new_array << element }\n \n new_array\nend",
"def reverse_array(array)\n array.reverse!\n array\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse \nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(array)\n array.reverse\nend",
"def reverse_array(arr)\n arr.reverse\nend",
"def my_reverse\n arr = []\n\n idx = self.length - 1\n while idx >= 0\n arr << self[idx]\n idx -= 1\n end\n\n arr\n end",
"def reverse_array(array)\narray.reverse\nend",
"def reverse_array(array)\narray.reverse\nend",
"def reverse_array(array)\narray.reverse\nend",
"def reverse!(old_array)\n new_array = []\n while old_array.length > 0\n new_array << old_array.pop\n end\n while new_array.length > 0\n old_array << new_array.shift\n end\n old_array\nend",
"def reverse_every_element_in_array(array)\n new_array = Array.new\n array.each {|element|\n new_array << element.reverse\n } \n new_array\nend",
"def reverse_array(array)\n array.reverse!\nend",
"def reverse_array(array)\n array.reverse!\nend",
"def reverse_array(arry)\n arry.reverse\n\nend",
"def reverse_array(array)\n\tarray.reverse\nend",
"def reverse(array)\n results = []\n array.reverse_each{ |x| results << x }\n results\nend",
"def reverse_array(arr_rev)\n arr_rev.reverse\nend",
"def reverse(array)\r\n new_array = []\r\narray.reverse_each do |element|\r\n new_array << element\r\nend\r\nnew_array\r\nend",
"def reverse_array(array)\n new_array = []\n index = -1\n while index * (-1) <= array.length\n new_array << array[index]\n index -= 1\n end\n new_array\nend",
"def reverseArray(array)\n tmp_array = Array.new(array.length)\n index = array.length - 1\n\n for i in 0...array.length\n tmp_array[index] = array[i]\n index -= 1\n # puts \"#{i} = #{array[i]}\"\n end\n\n return tmp_array\nend",
"def my_reverse(arr)\n result = []\n for i in (0..arr.length-1).reverse_each #maybe this is cheating?\n result << arr[i]\n end\n result\nend",
"def reverse_array(array)\n flipped = []\n array.each{ |el| flipped.unshift(el) }\n flipped\nend",
"def reverse_array(i)\r\n i.reverse!\r\nend",
"def reverse_array(a)\n a.reverse{|b| b}\nend",
"def reverse(array)\n result_array = []\n array.each { |element| result_array.unshift(element) }\n result_array\nend",
"def reverse(arr)\n output = []\n arr.reverse_each {|x| output.push x}\n output\nend",
"def reverse!(array)\n copy = array.clone\n index = -1\n\n copy.each do |element|\n array[index] = element\n index -= 1\n end\n\n array\nend",
"def reverse(a)\n new = []\n (0...a.size).each { |i| new << a[a.size - i - 1] }\n new\nend",
"def reverse(array)\n new_array = []\n array.length.times do \n new_array << array.pop\n end\n new_array\nend",
"def reverse!(array)\n copy_array = array.dup\n array.map! { |_| copy_array.pop }\nend",
"def reversearray arr\n len = arr.length\n idx = len - 1 \n arr2 = []\n while idx >= 0 \n arr2.push arr[idx] \n idx = idx - 1\n end\n return arr2\nend",
"def reverse_array(array)\n output = []\n (array.length).times do |_|\n output << array.pop \n end\n output\nend",
"def reverse_array(array)\n reversed_arr = []\n (array.size - 1).downto(0) do |index|\n reversed_arr << array[index]\n end\n\n reversed_arr\nend",
"def reverse_array(arr)\n new_arr = []\n arr.length.times do |i|\n new_arr = new_arr.unshift(arr[i])\n end\n new_arr\nend",
"def reverse_array(int_array)\n int_array.reverse\nend",
"def reverse!(arr)\n copy = []\n cp_index = arr.size-1\n (0...arr.size).each do |arr_index|\n copy[arr_index] = arr[cp_index]\n cp_index -= 1\n end\n copy.each_with_index do |el, index|\n arr[index] = el\n end\n arr\nend",
"def reverse(an_array)\n\tlen = an_array.length\n\tnew_arr = Array.new(an_array.length)\n\twhile len > 0 do\n\t\tnew_arr[len-1] = an_array[an_array.length - len]\n\t\tlen -= 1\n\tend\n\tnew_arr\nend",
"def reverse_array(integers)\n integers.reverse \nend",
"def reverse(arr)\n new_arr = []\n arr.each do |element|\n new_arr.prepend(element)\n end\n new_arr\nend",
"def reverse(array)\n new_array = array.dup\n counter, finish, max = 0, -1, (array.length)\n while counter < max\n new_array[finish] = array[counter]\n counter += 1\n finish -= 1\n end\n new_array\nend",
"def reverse_array(integers)\n integers.reverse\nend",
"def my_reverse\n reverse = []\n i = self.length - 1\n while i >= 0\n reverse << self[i]\n i -= 1\n end\n return reverse\n end",
"def my_reverse(arr)\n len = arr.length - 1\n new_arr = []\n while len >= 0\n new_arr << arr[len]\n len -= 1\n end\n new_arr\nend",
"def reverse!(arr)\n values = arr.dup\n arr.each.with_index do |_, index|\n arr[index] = values[-index - 1]\n end\nend",
"def reverse_array(array)\n return nil if array.class != Array\n local_stack = Stack.new()\n array.each do |element|\n local_stack.push(element)\n end\n array.size.times do |i|\n array[i] = local_stack.pop()\n end\n array\nend",
"def reverse_array(array_i)\n array_i = array_i.reverse\nend",
"def reverse(array)\n new_array = []\n array.reverse.each do |outer|\n new_inner = []\n outer.reverse.each do |inner|\n new_inner << inner\n end\n new_array << new_inner\n end\n return new_array\nend",
"def reverse_each(array)\n new_array = []\n array.each do |el|\n new_array.push(el.reverse)\n end\n return new_array\nend",
"def reverse_array(array_int)\n array_int.reverse!\nend",
"def using_reverse(array)\n reversed_array=array.reverse\nend",
"def reverse!(arr)\n arr_orignal = arr.map{ |element| element }\n index = 0\n loop do\n break if index == arr.size\n arr[index] = arr_orignal[-(index+1)]\n index +=1\n end\n arr\nend",
"def reverse!(array)\n reversed_array = []\n array.size.times { reversed_array << array.pop }\n reversed_array.size.times { array << reversed_array.shift }\n array\nend",
"def reverse(array)\n result = []\n array.each do |item|\n result.prepend(item)\n end\n result\nend",
"def flip\n arr = Array.new(self.length)\n (0..self.length / 2).each do |index|\n arr[index] = self[self.length - 1 - index]\n arr[self.length - 1 - index] = self[index]\n end\n arr\n end",
"def reverse(arr)\n new_arr = []\n arr.each { |elem| new_arr.unshift(elem) }\n new_arr\nend",
"def reverse!(arr)\n temp = arr.dup\n arr.map!.with_index(1) { |_, i| p temp[-i] }\nend",
"def reverse_array(array)\n reversed = []\n while array != []\n reversed << array.last\n array = array[0..-2]\n end\n reversed\nend",
"def reverse(arr)\n temp = arr.dup\n result = []\n result << temp.pop until temp.empty?\n result\nend",
"def reverse_array(array)\n reverse_arr = []\n array.each_with_index do |val, index|\n reverse_arr[array.size - 1 - index] = val\n end\n reverse_arr\nend",
"def reverse_arr(arr)\n return_arr = []\n arr.each do |item|\n return_arr.unshift(item)\n end \n return_arr\nend",
"def reverse_every_element_in_array(array)\n array.map(&:reverse)\nend",
"def reverse(arr)\n\nnew_arr = []\n\n arr.each do |element|\n new_arr.unshift(element)\n end\n new_arr\n\nend",
"def reverse_every_element_in_array(array)\n array.map!{|element|element.reverse}\nend",
"def reverse(array)\n final = []\n i = array.length - 1\n loop do\n break if i < 0\n\n final << array[i]\n i -= 1\n end\n final\nend",
"def reverse_array(array)\nreversed_array = []\nindex = array.length - 1\n while index >= 0\n reversed_array.push(array[index])\n index -= 1\n end\nreversed_array\nend",
"def using_reverse(array)\narray.reverse\nend",
"def using_reverse(array)\narray.reverse\nend",
"def my_reverse(arr)\n new_arr = []\n arr.each {|i| new_arr.unshift(i) }\n new_arr\nend",
"def my_reverse(arr)\n new_arr = []\n arr.each { |ele| new_arr.unshift(ele) }\n new_arr\nend",
"def reverse_array(array)\n reversed_array = []\n array.each {|e| reversed_array.unshift(e)}\n reversed_array\n\n #could just use #reverse but don't think that's what the lab was asking for\n # reversed_array = array.reverse\nend",
"def reverse(array)\n reversed_array = []\n array.each { |item| reversed_array.unshift(item) }\n reversed_array\nend",
"def reverse!(array)\n iteration = array.length / 2\n iteration.times do |index|\n array[index], array[-index - 1] = array[-index - 1], array[index]\n end\n array\nend",
"def using_reverse(array)\n array.reverse \nend"
] | [
"0.8609501",
"0.84842646",
"0.84591293",
"0.84588814",
"0.84588814",
"0.8396383",
"0.83960843",
"0.83671093",
"0.8327724",
"0.8325782",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8278918",
"0.8277992",
"0.826775",
"0.82646054",
"0.82646054",
"0.82646054",
"0.8260379",
"0.8244332",
"0.8241978",
"0.8241978",
"0.82383716",
"0.822732",
"0.8203118",
"0.8198504",
"0.81889784",
"0.8186623",
"0.8156768",
"0.8141428",
"0.81237596",
"0.8101085",
"0.808699",
"0.80857897",
"0.80775905",
"0.8075865",
"0.8073034",
"0.80702126",
"0.8065471",
"0.8053199",
"0.8049841",
"0.80488497",
"0.8021658",
"0.8004125",
"0.80030656",
"0.799404",
"0.7988746",
"0.7984019",
"0.79753506",
"0.7966417",
"0.7947155",
"0.79434884",
"0.7934486",
"0.792268",
"0.7921807",
"0.79187936",
"0.79011804",
"0.79007936",
"0.7900025",
"0.78852785",
"0.7883602",
"0.7880214",
"0.78793156",
"0.787465",
"0.7870073",
"0.7857551",
"0.7848691",
"0.7838364",
"0.7834781",
"0.78324443",
"0.7825535",
"0.7823368",
"0.7820946",
"0.7802691",
"0.7802455",
"0.7802455",
"0.7791878",
"0.7772792",
"0.7765087",
"0.7751615",
"0.7731096",
"0.7717758"
] | 0.7819486 | 91 |
Write a method that returns a boolean indicating whether the argument is prime. | def prime?(num)
return false if num < 2
(2..num/2).each{ |n| return false if num % n == 0 }
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime?(num)\nend",
"def prime?(arg)\n Prime.prime?(arg)\nend",
"def prime?(n)\n\tPrime.prime?(n)\nend",
"def prime?(int)\n \nend",
"def is_prime?(num)\n # Write your code here\nend",
"def is_prime?(num)\n\nend",
"def is_prime?(n)\n end",
"def prime?(n)\n primes(n).size == 1\nend",
"def prime?\n Prime.prime?(self)\n end",
"def is_prime?(n)\n 2.upto(Math.sqrt(n).to_i) { |num| return false if n % num == 0 }\n n == 1 ? false : true\nend",
"def is_prime?(i)\r\n 2.upto(Math.sqrt(i).to_i) {|j|\r\n return false if i % j == 0\r\n }\r\n true\r\nend",
"def is_prime?(num)\n return true if num == 1\n (2...num).all? {|i| (num % i) != 0}\nend",
"def is_prime?(number)\n\nend",
"def is_prime?(number)\n\nend",
"def is_prime(x)\n return true if x.prime? == true\n else false\nend",
"def prime?(num)\n Math.sqrt(num).to_i.downto(2).each { |i| return false if (num % i).zero? }\n true\nend",
"def prime?(num)\n factors(num) == [1, num]\nend",
"def is_prime?(num)\n (2...num).each {|el| return false if num % el == 0}\n true\nend",
"def isPrime?(n)\n\ti = 2\n\twhile i < n\n\t\treturn false if n % i == 0\n\t\ti += 1\n\tend\n\treturn true\nend",
"def is_prime?(num)\n (2...num).each do |el|\n return false if num % el == 0\n end\n true\nend",
"def is_prime?(number)\n remainders = (2...number).map { |d| number % d}\n !remainders.include?(0) && number > 1\nend",
"def is_prime?(number)\r\n (2...number).each do |n|\r\n return false if number % n == 0\r\n end\r\n true\r\nend",
"def prime?(n)\n (2...n).each { |x| return false if n % x == 0 }\n true\nend",
"def prime?(num)\n if 0 == num or 1 == num\n return false\n else\n return (2..Math.sqrt(num)).all? { |x| num % x != 0}\n end\nend",
"def is_prime?(num)\n (2...num).each do |i|\n return false if num % i == 0\n end\n true\nend",
"def is_prime?(num)\n 2.upto(num / 2) do |n|\n return false if num % n == 0\n end\n true\nend",
"def prime?(num)\n return false if num == 1\n return true if num == 2\n (2...num).each do |divisor|\n return false if num % divisor == 0\n end\n true\nend",
"def prime?(number)\n (2...number).each do |x|\n return false if (number % x).zero?\n end\n true\n end",
"def is_prime?(num)\n return false if num < 2\n (2...num).none? { |factor| num % factor == 0 }\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).none? { |factor| num % factor == 0 }\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).none? { |factor| num % factor == 0 }\nend",
"def is_prime?(num)\n\n return false if num <= 1\n return true if num == 2\n\n i = 2\n while i < num\n return false if num % i == 0\n i += 1\n end\n\n true\n\nend",
"def is_prime? (number)\n return false if number < 1\n 2.upto(Math.sqrt(number)) do |x|\n return false if number % x == 0\n end \n true\nend",
"def is_prime?(number)\n (2...number).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\n \nend",
"def prime?(number)\n return false if 2 > number\n (2...number).each { |i| return false if number % i == 0 }\n true\nend",
"def prime?(num)\n\treturn false if num == 1\n\t(2...num).each { |n| return false if num % n == 0 }\n\ttrue\nend",
"def prime?(x)\n for i in 2..Math.sqrt(x).floor\n return false if x % i == 0\n end\n return true\nend",
"def is_prime?(num)\n (2...num).none? { |div| num % div == 0 }\nend",
"def is_prime?\n return true if self == 2\n return false if self < 3\n for divisor in 2..(Math.sqrt(self).to_i)\n return false if self%divisor == 0\n end\n true\n end",
"def prime?(n)\n 2.upto(Math.sqrt(n).floor) do |i|\n return false if n%i == 0\n end\n\n true\nend",
"def prime?(n)\n 2.upto(Math.sqrt(n).floor) do |i|\n return false if n%i == 0\n end\n\n true\nend",
"def is_prime?(n)\n (2...n).each { |factor| return false if n % factor == 0 } \n n > 1\nend",
"def is_prime?(num)\n (2...num).none? { |el| num % el == 0 }\nend",
"def isPrime?(num)\n\treturn false if num <= 1\n\n\ti = 2\n\twhile i < num\n\t\treturn false if num % i == 0\n\t\ti += 1\n\tend\n\treturn true\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).each { |factor| return false if num % factor == 0}\n true\nend",
"def is_prime?(num)\n return if num <= 1\n (2..Math.sqrt(num)).none? { |i| (num % i).zero? }\nend",
"def is_prime?(integer)\n return false if integer == 1\n (2...integer).to_a.all? {|num| integer % num != 0}\nend",
"def is_prime?(num)\n (2..num / 2).each do |n|\n return false if num % n == 0\n end\n true\nend",
"def is_prime?(num)\n i = 2\n while i < num\n return false if num % i == 0\n i+=1\n end\n true\nend",
"def is_prime?(num)\n i = 2\n while i < num\n return false if num % i == 0\n i+=1\n end\n true\nend",
"def prime?(num)\n return false if num == 1\n (2...num).each do |number|\n return false if num % number == 0\n end\n return true\nend",
"def is_prime?(num)\n (2...num).none? { |n| num % n == 0 }\nend",
"def is_prime?(num)\n for i in (2..Math.sqrt(num))\n return false if num % i == 0\n end\n true\nend",
"def is_prime?(num)\n return false if num == 1\n return true if num == 2 \n (2..Math.sqrt(num)+1).each do |x|\n return false if num%x == 0\n end\n true\nend",
"def is_prime?(n) \n Math.sqrt(n).to_i.downto(2).each do |i| \n return false if n % i == 0\n end\nend",
"def is_prime?(num)\n return 2 if num == 2\n (2...num).each do |n|\n return false if num % n == 0\n end\n true\nend",
"def prime?(num)\n\t(2 .. Math.sqrt(num)).each {|i| return false if num % i == 0}\n\treturn true\nend",
"def is_prime?(num)\n return false if num <= 1\n\n (2...num).each do |fact|\n return false if num % fact == 0\n end\n\n true\nend",
"def is_prime?(num)\n (2...num).none? {|i| num % i == 0}\nend",
"def is_prime?(num)\n (2..num/2).none?{|el| num % el == 0}\nend",
"def prime?(num)\n\treturn false if num < 2\n\t\n\t(2...num).each do |i|\n\t\treturn false if num % i == 0\n\tend\n\ttrue\nend",
"def is_prime?(num)\n (2..(num/2)).each { |divisor| return false if num % divisor == 0 }\n true\nend",
"def prime?( number )\n self.class.prime? number\n end",
"def prime?(input)\n\t(2..(input ** 0.5 + 1).to_i).each do |x|\n\t\treturn false if (input % x).zero?\n\tend\n\ttrue\nend",
"def prime?(num)\n return true if num == 2\n (2...num).each { |x| return false if num % x == 0 }\n true\nend",
"def is_prime?(num)\n\treturn false if (num < 1 || num.class == Float)\n\t(2...num).each { |n| return false if num % n == 0 }\n\ttrue\nend",
"def prime?(num)\n return false if num < 2\n (2...num).none? { |fact| num % fact == 0 }\nend",
"def prime?(num)\n return false if num < 2\n (2...num).none? { |fact| num % fact == 0 }\nend",
"def is_prime?(num)\n\t(2..Math.sqrt(num)).each do |target|\n\t\treturn false if num % target == 0\n\tend\n\treturn true\nend",
"def is_prime?(number)\n (2..(number-1)).each do |divisor| # this is a range (2..number -1)\n return false if number % divisor == 0\n end\n true # code intentionally, return true, otherwise it would return a truthy value anyway but that's not the point\nend",
"def isPrime(num)\n# returns whether num is a prime number\n num > 1 && (2...num).none?{|n| num % n == 0}\nend",
"def is_prime?(x)\n\ti = 2\n\twhile i < x\n\t\tif x % i == 0\n\t\t\treturn false\n\t\tend\n\t\ti += 1\n\tend\n\treturn true\nend",
"def is_prime?(num)\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n true\nend",
"def is_prime?(num)\n\n return false if num<2\n\n (2...num).none? {|factor| num%factor == 0}\n\nend",
"def is_prime?(num)\n return false if num <2\n return (2..num/2).none? {|i| num%i==0}\nend",
"def prime?(int)\n return false if int <= 1\n (2..Math.sqrt(int)).none? { |i| (int % i).zero? }\nend",
"def is_prime?(number)\n return false if number < 2\n (2...number).to_a.none?{ |integer| number % integer == 0 }\nend",
"def prime?(num) \n return false if num < 2\n (2...num).none? { |factor| num % factor == 0}\nend",
"def prime?(number)\n\nreturn false if number < 2\n\n (2...number).each do |x|\n return false if number % x == 0\n end\nreturn true\n\nend",
"def is_prime?(num)\n Math.sqrt(num).floor.downto(2).each do |i|\n false if num % i == 0\n end\n true\nend",
"def prime?(num)\n return false if num <= 1\n (2...num).none? { |i| num % i == 0 }\nend",
"def prime?(num)\n return false if num < 2\n (2...num).none? { |f| num % f == 0 }\nend",
"def is_prime?(num)\n (2..(num - 1)).each do |divisor|\n return false if num % divisor == 0\n end\n\n true\nend",
"def is_prime? n\n x = n -1\n while x > 1\n return false if (n % x).zero?\n x -= 1\n end\n true\nend",
"def is_prime?(num)\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n true\nend",
"def is_prime?(num)\n\tfor i in 2..Math.sqrt(num)\n\t\tif num % i == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend",
"def is_prime?(num)\n\tfor i in 2..Math.sqrt(num)\n\t\tif num % i == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend",
"def isprime(a)\n\treturn true if a == 2\n\t2.upto(Math.sqrt(a).to_i + 1) {|i| return false if a%i == 0 }\n\treturn true\nend",
"def is_prime?(num)\n 2.upto(num-1) do |i|\n return false if num%i==0\n end\n true\nend",
"def prime?(num)\n if num == 2\n true\n elsif num > 1 && num % num == 0 && num % 1 == 0 && !(2 .. (num - 1)).to_a.any?{|number| num % number == 0}\n true\n else\n false\n end\nend",
"def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend",
"def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend",
"def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend",
"def is_prime?\n return false if num <= 1\n Math.sqrt(num).to_i.downto(2).each {|i| return false if num % i == 0}\n true\nend",
"def is_prime?\r\n\t#Your code here\r\nend",
"def prime?(n)\n return false if n == 1\n return true if n == 2\n\n (2..(Math.sqrt(n).to_i + 1)).each { |rn| return false if n % rn == 0 }\n\n true\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).each do |i|\n return false if num%i == 0\n end\n return true\nend",
"def is_prime?(num)\n i = 2\n while i < num\n divisible = ((num % i) == 0)\n if divisible\n return false\n end\n i += 1\n end\n true\nend",
"def is_prime?(num)\n (2...num).each do |i|\n if num % i == 0\n return false\n end\n end\n num > 2\nend",
"def is_prime?(number)\r\n if number <= 1\r\n # only numbers > 1 can be prime.\r\n return false\r\n end\r\n\r\n idx = 2\r\n while idx < number\r\n if (number % idx) == 0\r\n return false\r\n end\r\n\r\n idx += 1\r\n end\r\n\r\n return true\r\nend",
"def prime?(num)\n\t(2..Math.sqrt(num)).each do |x|\n\t\tif num % x == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend"
] | [
"0.83982253",
"0.8387713",
"0.83654135",
"0.8345047",
"0.8294106",
"0.82382286",
"0.8210866",
"0.8181966",
"0.81580824",
"0.81545854",
"0.81363606",
"0.8132913",
"0.812148",
"0.812148",
"0.8116212",
"0.81146556",
"0.8065454",
"0.80530596",
"0.80353",
"0.80329394",
"0.80289924",
"0.802489",
"0.8015555",
"0.8014012",
"0.8004888",
"0.79980016",
"0.79961294",
"0.7993686",
"0.7991102",
"0.7991102",
"0.7991102",
"0.79902846",
"0.79901916",
"0.79836947",
"0.79819405",
"0.797924",
"0.79756075",
"0.7973608",
"0.7967272",
"0.7957413",
"0.7957413",
"0.7950752",
"0.7946454",
"0.79462665",
"0.79377645",
"0.7936016",
"0.79329586",
"0.7932468",
"0.7931464",
"0.7931464",
"0.79257905",
"0.79225916",
"0.7918747",
"0.7917477",
"0.7917437",
"0.79120237",
"0.79110646",
"0.79057527",
"0.79056007",
"0.7902621",
"0.7901122",
"0.7900497",
"0.78970116",
"0.7895561",
"0.7894271",
"0.7891705",
"0.7889154",
"0.7889154",
"0.78866225",
"0.7884124",
"0.78836465",
"0.78774834",
"0.78766656",
"0.7875673",
"0.78615266",
"0.7858041",
"0.7856086",
"0.7854946",
"0.7852408",
"0.78435534",
"0.7841598",
"0.7840951",
"0.7838783",
"0.7837806",
"0.7835638",
"0.7833563",
"0.7833563",
"0.78310484",
"0.7830445",
"0.7829456",
"0.78285307",
"0.78285307",
"0.78285307",
"0.78278154",
"0.78274375",
"0.7821604",
"0.7818811",
"0.7816986",
"0.781358",
"0.7805324",
"0.78047574"
] | 0.0 | -1 |
Write a method that returns a sorted array of the factors of its argument. | def factors(num)
facs = [1]
(2..num/2).each{|n| facs.push(n) if num % n == 0 }
facs.push(num)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factors(num)\n output_arr = []\n\n (1..num).each do |el|\n if num % el == 0\n output_arr << el\n end\n end\n\n output_arr.sort\nend",
"def factors(num)\n array = []\n (1..num).each do |number|\n array << number if num % number == 0\n end\n array.sort!\nend",
"def factors\n factors = []\n for divisor in 2..(Math.sqrt(self).to_i)\n if self%divisor == 0\n factors << divisor \n factors << (self/divisor)\n end\n end\n return factors.sort!.reverse!\n end",
"def factors n\n 1.upto(Math.sqrt(n)).select{ |x| (n % x).zero?}.inject([]) do |arr,x|\n arr << x\n arr << n/x unless x == n/x\n arr.sort\n end\nend",
"def factors_of(num)\n factor_arr = []\n\n (1...num).reverse_each do |factor|\n if (num % factor).zero?\n factor_arr << factor\n end\n end\n\n factor_arr\nend",
"def factors(num)\n arr = [1]\n i = 1\n while i <= num\n arr << i if (num % i).zero?\n i += 1\n end\n arr.uniq.sort\nend",
"def factors(num)\n result = []\n for i in 1..num\n if num % i == 0\n result << i\n end\n end\n result.sort\nend",
"def factors\n all_factors = []\n (1..Math.sqrt(self).to_i).each do |x|\n all_factors.push(x, self/x) if (self % x == 0)\n end\n\n all_factors.sort.uniq\n end",
"def proper_factors(n)\n f = []\n 1.step((n/2).to_i, 1).each do |x|\n if n % x == 0\n f.push(x)\n end\n end\n f.sort\nend",
"def factors(num)\n\t((1..num).select {|n| num % n == 0 } ).sort\nend",
"def factors(num)\n factors = []\n for factor in 1..num\n factors << factor if num % factor == 0\n end\n factors.sort\nend",
"def factors(n)\n\n\t#create an Array\n\tarray = []\n\t\n\t(1..n).each do |num|\n\t\tif (n % num) == 0\n\t\t\tarray.push(num)\n\t\tend\n\tend\n\treturn array\nend",
"def factors num\n f = Array.new # creates a new array to store factors\n 1.upto(num) do |i|\n f << i if num%i == 0\n end\n f # returns factors\nend",
"def factors_of(num)\n\ti = 1\n \tarry = []\n while i <= num\n if num % i == 0\n arry << i\n end\n\n i += 1\n end\n return arry\nend",
"def prime_factors(num)\n all_factors = factors(num)\n output_arr = []\n\n all_factors.each do |el|\n if prime?(el)\n output_arr << el\n end\n end\n\n output_arr.sort\nend",
"def factors(num)\n arr = []\n (1..num).each { |n| arr << n if num%n==0}\n return arr\nend",
"def factors(num)\n pn = num.prime_division\n ans = []\n pn.each_index do |i|\n ans << pn[i][0]\n end\n return ans\nend",
"def factors(num)\n arr = []\n (2..num).each do |ele|\n if (num % ele == 0)\n arr << ele\n end\n end\n return arr\nend",
"def factors(num)\n arr = (1..num).to_a\n factored_arr = []\n i = 0\n while i < arr.length\n if num % arr[i] == 0\n factored_arr = factored_arr + arr[i]\n end\n i +=1\n end\n factored_arr\nend",
"def factors(num)\n factors = Prime.prime_division(num)\n result = []\n factors.each { |factor, power| result += [factor] * power }\n result\nend",
"def factors(num)\n arr = []\n (1..num).each do |el|\n arr << el if num % el == 0\n end\n arr\nend",
"def factors_of(num)\n array = []\n i = 1\n while i <= num\n if num % i == 0\n array << i\n end\n i += 1\n end\n return array\n end",
"def factors_of(num)\n new_arr = []\n\n i = 1\n while i <= num\n if num % i == 0\n new_arr << i\n else \n end \n i += 1\n end\n return new_arr\nend",
"def factors_of(num)\n arr = []\n\n i = 1\n\n while i <= num\n if num % i == 0\n arr << i\n end\n i += 1\n end\n\n return arr\nend",
"def factors_of(num)\n i = 1\n newArr = []\n while i <= num\n if num % i == 0\n newArr << i\n end\n i += 1\n end\n return newArr\n end",
"def get_factors(num)\n factors = []\n (1..num).each do |i|\n factors << i if num % i == 0\n end\n factors\nend",
"def factors(num)\n array = []\n (1..num).each do |x|\n if num % x == 0\n array << [x, num/x]\n end\n end\n array\nend",
"def factors_of(num)\n\tnewArray = []\n \tfor i in 1..num\n if num % i == 0\n \tnewArray << i\n end\n end\n return newArray\nend",
"def factors(num)\n arr = []\n for i in 1..num\n if num%i == 0\n arr << i\n end\n end\n arr\nend",
"def factors\n k = 1\n max = Math.sqrt(self).ceil\n lofacs = []\n hifacs = []\n while k <= max.ceil\n if (self.to_f/k) == (self.to_i/k)\n lofacs << k\n hifacs << self/k unless self/k == k\n end\n k += 1\n end\n lofacs + hifacs.reverse\n end",
"def factors(n)\n new_arr = []\n (1...n).each do |i|\n if n % i == 0 \n new_arr << i \n end\n end\n new_arr \nend",
"def factors_of(n)\n\tfactors = []\n\tsqrt = (Math.sqrt(n)).floor\n\t(1..sqrt).each do |f|\n\t\tif n % f == 0\n\t\t\tfactors << f\n\t\t\tfactors << n / f if (n / f) != f\n\t\tend\n\tend\n\tfactors.sort\nend",
"def mutual_factors(*nums)\n\n hash = Hash.new(0)\n new_arr = []\n return_arr = []\n\n nums.each do |num|\n new_arr << factors(num) # this would give one array of all divisors of that number\n end\n new_arr = new_arr.flatten # one array of all the factors for all teh nums\n\n new_arr.each do |factor|\n hash[factor] += 1\n end\n \n hash.each do |k, v|\n if v == nums.length\n return_arr << k\n end\n end\n\n return_arr\n\nend",
"def factors(n)\n factors_array = []\n i = 1\n while i <= n\n factors_array.push(i) if n % i == 0\n i += 1\n end\n factors_array\nend",
"def prime_factors(num)\n array = []\n (1..num).each do |number|\n array << number if prime?(number) && num % number == 0\n end\n array.sort!\nend",
"def factors_of(num) # Define method with one param\n \n i = 1 # To prevent dividing by zero start at one because of future modula expression\n new_array = [] # Create and empty array to shovel numbers while they meet requirements of the if statement\n \n while i <= num \n \n if num % i == 0 # Parameter entered must be a factor of i since we are cycling through iterations and i is incrementing upwards\n \n new_array << i # Shovel iterations that fulfill logical conditions\n end\n \n i += 1 # Increment up 1 at a time\n end\n return new_array # Prints array after while loop ends; while loop conditions are met\n\nend",
"def factors(num)\n answer = []\n (1...num).each {|i| answer << i if num % i == 0 }\n answer\nend",
"def factors_of(num)\n divide_by = []\n \n i = 1\n while i <= num\n if num % i == 0\n divide_by << i\n end\n \n i += 1\n end\n \n return divide_by\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n # evaluate statement on right side of shovel operator and if\n # divisor evenly divides number then add into factors array \n factors << number / divisor if number % divisor == 0\n # decrement divisor by 1\n divisor -= 1\n # stops when divisor is 0\n end until divisor == 0\n \n # return all factors in an array that divides evenly with \n # the number passed in as an argument when calling the function\n factors\nend",
"def factors_of(num)\n \n index = 1 \n \n factors = []\n \n while index <= num\n if num % index == 0 \n factors << index \n end \n \n index += 1 \n end \n \n return factors \n \nend",
"def remove_factors\n a=Array.new\n self.each do | x | \n a << x if 0 == ( self.inject(0) { | memo, y | memo + (x!=y && y%x==0 ? 1 : 0) } )\n end\n a\n end",
"def factors(num)\n\nend",
"def factors(num)\n\nend",
"def factors(num)\n\nend",
"def factors (n)\n return (1..n).select {| x | n % x == 0}.to_a\nend",
"def find_factors(number)\n factors =[]\n for i in 1..number\n factors << i if number % i == 0\n end\n factors\nend",
"def factors(num)\n factors = []\n (1..num).each do |factor|\n factors << factor if num % factor == 0\n end\n factors\nend",
"def prime_factors\n if prime?\n [self]\n else\n pair = factorize\n (pair[0].prime_factors + pair[1].prime_factors).sort.uniq\n end\n end",
"def factors(num)\n factors = []\n (1..num).each do |n|\n factors << n if num % n == 0\n end\n factors\nend",
"def factors(number)\n fs = [1,number]\n (2..Math.sqrt(number).to_i).each do |i|\n if number % i == 0\n fs << i\n fs << number/i unless number/i == i\n end\n end\n fs.sort\n end",
"def factors\n exponents = ::NArray.int(PRIMES.size, 2)\n self.each_with_index do |y, i|\n exponents[true,i] = ::NArray.to_na(PRIMES.to_a.map do |x|\n exp_count = 0\n while y % x == 0\n exp_count += 1\n y /= x\n end\n exp_count\n end)\n end\n # Will be an NArray of exponents (negative numbers are denominators)\n exponents[true,0] - exponents[true,1]\n end",
"def find_factors(num)\n raise ArgumentError, \"num must be >= 0\" if num < 0\n return [n] if num <= 1\n result = []\n\n n = num\n if n.even?\n while n % 2 == 0\n result << 2\n n /= 2\n end\n end\n\n div = 3\n\n while (n > 1)\n while n % div == 0\n result << div\n n /= div\n end\n div += 2\n\n if (div * div > n)\n result << n\n break\n end\n end\n\n result\nend",
"def factors (n)\r\n factors = Array.new(n) { |index| index+=1 }\r\n return factors.select { |x| n%x == 0}\r\nend",
"def factors(num)\n factors = []\n (1..num).each do |i| \n factors << i if num % i === 0\n end\n factors\nend",
"def factors(num)\n result = [1]\n\n (2..num).each do |el|\n result << el if num % el == 0\n end\n result\nend",
"def factors(number)\r\n divisor = number\r\n factors = []\r\n while divisor > 0 do \r\n factors << number / divisor if number % divisor == 0\r\n divisor -= 1\r\n end \r\n factors\r\nend",
"def factors_of(n)\n result = []\n (1..n/2).each do |x|\n quotient, remainder = n.divmod x\n if remainder.zero?\n result << quotient\n result << x\n end\n end\n result.uniq\nend",
"def factors(num)\n factors = Prime.prime_division(num)\n result = []\n factors.each { |factor, power| result += [factor] * power }\n result\n end",
"def prime_factors(num)\n arr = factors(num)\n new_arr = []\n arr.each do |n|\n new_arr << n if prime?(n)\n end\n new_arr\nend",
"def factors() (1..self).select { |n| (self % n).zero? } end",
"def factors(num)\n factors = []\n (1..num/2).each {|n| factors << n if num % n == 0}\n factors << num\nend",
"def prime_factors(number)\n return [] if number < 2\n return [number] if number < 4\n factors = []\n\n factor = 2\n while factor < number\n break if number % factor == 0\n factor += 1\n end\n factors << factor\n factors.concat(prime_factors(number / factor))\n factors.sort\nend",
"def prime_factors(number)\n return [] if number < 2\n return [number] if number < 4\n factors = []\n\n factor = 2\n while factor < number\n break if number % factor == 0\n factor += 1\n end\n factors << factor\n factors.concat(prime_factors(number / factor))\n factors.sort\nend",
"def factorize(n)\n factorize_greater_than(1, n).flatten.sort\nend",
"def factors(num)\n\n factors = []\n # iterate through all nums from 1 to num\n # add to factors if evenly divisible\n # return factors\n\n i = 1\n while i <= num\n factors << i if num % i == 0\n i += 1\n end\n\n factors\n\nend",
"def factors_of(num)\n\tnums = []\n \n\ti = 1\n\twhile i <= num\n\t\tif num % i == 0\n\t\t\tnums << i\n end\n\t\ti += 1\n end\n \n\treturn nums\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def fuck_the_factors(n)\n f = []\n i = 2\n while n > 1\n while n % i == 0\n f.push(i)\n n /= i\n end\n i += 1\n end\n return f\nend",
"def arrPrimeFactors (n)\n result = Array.new\n while n != 1\n (2 .. n).each do |i|\n if n % i == 0\n result.push i\n n /= i\n break\n end\n end\n end\n result\nend",
"def factors(number)\n dividend = 1\n divisors = []\n while dividend <= number\n divisors << dividend if number % dividend == 0\n dividend += 1\n end\n divisors\nend",
"def factors(n)\n return [n] if n == 1\n 2.upto(n).select {|x| n%x == 0}\nend",
"def factors(num)\n ret = []\n for i in (1..num)\n ret << i if num % i == 0\n end\n ret\nend",
"def factorize\n x = self\n o = []\n loop do\n break unless (c = (2..x).find { |i| x % i == 0 })\n x /= c\n o << c\n end\n o\n end",
"def factors(num)\n factors = []\n (1..num).each do |i|\n factors << i if num % i == 0\n end\n \n factors\nend",
"def old_factors(num)\n factors = []\n (1..num).each do |i|\n if num % i == 0\n factors << i\n end\n end\n factors\nend",
"def factor(n)\n return [] if n.zero?\n Prime.prime_division n\n end",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend == 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\n\n # number % dividend == 0 checks if the number is divisable with no remainder\n # returns the divisors array\nend",
"def factors(num1, num2)\n arr = []\n\n (1..num1).each do |ele|\n # compare if ele is divisible for both numbers\n arr << ele if num1 % ele == 0 && num2 % ele == 0\n end\n \n return arr\nend",
"def factors_of(num)\n factors = []\n \n i = 1\n while i <= num\n # if num is divided by i\n if num % i == 0\n factors << i\n end\n \n i += 1\n end\n \n return factors\n end",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << (number / divisor) if ((number % divisor) == 0)\n divisor -= 1\n end\n factors\nend",
"def factors(num)\r\n # your code goes here\r\n\r\n factors = []\r\n for i in 1 .. num\r\n if num % i == 0\r\n factors << i\r\n end\r\n end\r\n factors\r\nend",
"def mutual_factors(*nums)\n factors = []\n\n (1..nums.max).each do |i|\n mutual = 0\n nums.each do |num|\n mutual += 1 if num % i == 0\n end\n factors << i if mutual == nums.length\n end\n \nfactors\nend",
"def at_least_n_factors(numbers, n)\n arr = []\n numbers.each {|number| arr.push(number) if num_factors(number) >= n}\n arr\nend",
"def factors(number)\n dividend = number\n divisors = []\n number.times do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors_for( num )\n facts = []\n (1..(num/2)).each {|divisor| facts << divisor if (num % divisor == 0)}\n facts\nend",
"def factors(number)\n divisors = []\n # 1 is always a divisor\n divisors << 1\n if number > 1\n # target number is also always a divisor\n divisors << number\n # start looking for other divisors from 2 on up.\n i = 2\n while (i <= Math.sqrt(number).to_i)\n # if number is evenly divisible by i, then retain i, and possibly also\n # the division of number/i.\n if (number % i == 0)\n divisors << i\n divisors << number/i if (i != number/i)\n end\n i += 1\n end\n divisors.sort!\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\nend",
"def greatest_factor_array(arr)\n\tarray = []\n \tarr.each do |i|\n \tif i.even?\n \tarray << prime_factors(i)\n else\n \tarray << i\n end\n end\n \treturn array\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend"
] | [
"0.7904064",
"0.7902955",
"0.77490956",
"0.77448606",
"0.7737135",
"0.7637974",
"0.75834125",
"0.7557235",
"0.7518705",
"0.75077593",
"0.75072306",
"0.74821216",
"0.7452686",
"0.7440315",
"0.7437962",
"0.74183434",
"0.7413723",
"0.7375539",
"0.73751694",
"0.7374454",
"0.73714906",
"0.7348573",
"0.7347421",
"0.73349196",
"0.73298126",
"0.73238575",
"0.73051",
"0.7299991",
"0.7292186",
"0.7290393",
"0.728046",
"0.7268716",
"0.72645456",
"0.7257099",
"0.7214232",
"0.7210888",
"0.7205611",
"0.7192961",
"0.71644545",
"0.7145805",
"0.7142618",
"0.71365535",
"0.71365535",
"0.71365535",
"0.7127214",
"0.71241504",
"0.7113181",
"0.7105258",
"0.7105019",
"0.7091883",
"0.70832425",
"0.7064983",
"0.7064068",
"0.706359",
"0.7063358",
"0.70618576",
"0.7050168",
"0.7047413",
"0.70394963",
"0.7036532",
"0.70329624",
"0.7013132",
"0.7013132",
"0.70106053",
"0.7002579",
"0.6995578",
"0.6979199",
"0.6974483",
"0.6974334",
"0.69666964",
"0.6954838",
"0.6952303",
"0.69407976",
"0.69389015",
"0.69325495",
"0.69285434",
"0.69226044",
"0.69226044",
"0.69226044",
"0.69226044",
"0.69226044",
"0.69226044",
"0.69214946",
"0.6919472",
"0.69146633",
"0.6909433",
"0.68962485",
"0.68876636",
"0.6879566",
"0.68629295",
"0.6862326",
"0.6851308",
"0.68474853",
"0.6841998",
"0.68412393",
"0.68356645",
"0.68356645",
"0.68356645",
"0.68356645",
"0.68356645"
] | 0.7119335 | 46 |
Write a method that returns a sorted array of the prime factors of its argument. | def prime_factors(num)
facs = factors(num)
p_facs = []
facs.each{|n| p_facs.push(n) if prime?(n)}
p_facs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prime_factors(num)\n all_factors = factors(num)\n output_arr = []\n\n all_factors.each do |el|\n if prime?(el)\n output_arr << el\n end\n end\n\n output_arr.sort\nend",
"def prime_factors(num)\n array = []\n (1..num).each do |number|\n array << number if prime?(number) && num % number == 0\n end\n array.sort!\nend",
"def prime_factors(num)\n arr = factors(num)\n new_arr = []\n arr.each do |n|\n new_arr << n if prime?(n)\n end\n new_arr\nend",
"def prime_factors\n if prime?\n [self]\n else\n pair = factorize\n (pair[0].prime_factors + pair[1].prime_factors).sort.uniq\n end\n end",
"def prime_factors(num)\n arr = []\n (1...num).each do |number|\n if is_prime(number) && num % number == 0\n arr << number\n end\n end\n return arr\nend",
"def factors(num)\n output_arr = []\n\n (1..num).each do |el|\n if num % el == 0\n output_arr << el\n end\n end\n\n output_arr.sort\nend",
"def arrPrimeFactors (n)\n result = Array.new\n while n != 1\n (2 .. n).each do |i|\n if n % i == 0\n result.push i\n n /= i\n break\n end\n end\n end\n result\nend",
"def factors(num)\n array = []\n (1..num).each do |number|\n array << number if num % number == 0\n end\n array.sort!\nend",
"def prime_factors(num)\n arr = []\n (1..num).each { |n| arr << n if num%n==0 && prime?(n)}\n return arr\nend",
"def prime_factors(number)\n return [] if number < 2\n return [number] if number < 4\n factors = []\n\n factor = 2\n while factor < number\n break if number % factor == 0\n factor += 1\n end\n factors << factor\n factors.concat(prime_factors(number / factor))\n factors.sort\nend",
"def prime_factors(number)\n return [] if number < 2\n return [number] if number < 4\n factors = []\n\n factor = 2\n while factor < number\n break if number % factor == 0\n factor += 1\n end\n factors << factor\n factors.concat(prime_factors(number / factor))\n factors.sort\nend",
"def factors(num)\n pn = num.prime_division\n ans = []\n pn.each_index do |i|\n ans << pn[i][0]\n end\n return ans\nend",
"def prime_factors(num)\n arr = (2..Math.sqrt(num).round).to_a\n primes = arr.each do |i|\n arr.select! {|j| j%i != 0 or j==i}\n end\n pfacts = primes.select {|i| num%i == 0}\n\n return [num] if pfacts.empty?\n return pfacts\nend",
"def prime_factors(num)\n factors = factors(num)\n result = []\n factors.each do |fac|\n if prime?(fac)\n result << fac\n end\n end\n result\nend",
"def prime_factors(num)\n arr = []\n\tPrime.each(num) { |prime| num % prime == 0 ? arr.push(prime) : false }\n return arr\nend",
"def factors(num)\n result = []\n for i in 1..num\n if num % i == 0\n result << i\n end\n end\n result.sort\nend",
"def prime_factors(num)\n #initialize an array\n primeFacts = []\n \n #iterate each number from 1 until num\n (1..num).each do |nums|\n #if the remainder is 0 and nums is prime push nums\n if num % nums == 0 && prime?(nums)\n primeFacts << nums\n end\n end\n return primeFacts\nend",
"def factors(num)\n factors = Prime.prime_division(num)\n result = []\n factors.each { |factor, power| result += [factor] * power }\n result\nend",
"def factors_of(num)\n factor_arr = []\n\n (1...num).reverse_each do |factor|\n if (num % factor).zero?\n factor_arr << factor\n end\n end\n\n factor_arr\nend",
"def factors(num)\n arr = [1]\n i = 1\n while i <= num\n arr << i if (num % i).zero?\n i += 1\n end\n arr.uniq.sort\nend",
"def prime_factors(num)\n\n if prime?(num)\n return [num]\n end\n\n primes = (2...num).to_a.select { |factor| prime?(factor) }\n\n \n \n factors = []\n\n while num > 1\n candidate = primes.shift\n\n if num % candidate == 0\n factors << candidate\n while num % candidate == 0\n num /= candidate\n end\n end\n end\n\n return factors\n \nend",
"def prime_factors(integer)\n primes = Prime.take(20)\n arr = []\n i = 0\n loop do \n if integer % primes[i] == 0\n integer = integer / primes[i]\n arr << primes[i]\n else\n i += 1\n end\n break if integer == 1\n end\n arr\nend",
"def prime_factorization(n)\n new_arr = []\n (2...n).each do |i|\n if n % i == 0\n dividend = n / i\n return [*prime_factorization(i), *prime_factorization(dividend)]\n end\n end\n new_arr << n\nend",
"def factors(num)\n arr = []\n (2..num).each do |ele|\n if (num % ele == 0)\n arr << ele\n end\n end\n return arr\nend",
"def factors(num)\n\t((1..num).select {|n| num % n == 0 } ).sort\nend",
"def factors(num)\n factors = []\n for factor in 1..num\n factors << factor if num % factor == 0\n end\n factors.sort\nend",
"def factors n\n 1.upto(Math.sqrt(n)).select{ |x| (n % x).zero?}.inject([]) do |arr,x|\n arr << x\n arr << n/x unless x == n/x\n arr.sort\n end\nend",
"def prime_factors num\n\tfactors = []\n\ttest_value = 2\n\twhile num > 1 do\n\t\twhile num % test_value == 0 do\n\t\t\tfactors.push num\n\t\t\tnum = num / test_value\n\t\tend\n\t\ttest_value += 1\n\tend\n\treturn factors\nend",
"def prime_factors\n n = self\n factors = Hash.new(0)\n\n # Pull out twos manually\n while n % 2 == 0 do\n factors[2] += 1\n n /= 2\n end\n\n # Then use Fermat's method\n a = Math.sqrt(n).ceil\n b2 = a**2 - n\n until (b2**0.5).round**2 == b2 do\n a += 1\n b2 = a**2 - n\n end\n\n candidates = [(a - Math.sqrt(b2)).round, (a + Math.sqrt(b2)).round]\n candidates.each do |candidate|\n next if candidate == 1\n if candidate == n\n factors[n] += 1\n else\n candidate_factors = candidate.prime_factors\n if candidate_factors.length == 1\n factors[candidate_factors.first] += 1\n else\n candidates.concat candidate_factors\n end\n end\n end\n \n expanded = []\n factors.each do |prime, count|\n count.times { expanded << prime }\n end\n expanded.sort\n end",
"def proper_factors(n)\n f = []\n 1.step((n/2).to_i, 1).each do |x|\n if n % x == 0\n f.push(x)\n end\n end\n f.sort\nend",
"def factors_of(num)\n\ti = 1\n \tarry = []\n while i <= num\n if num % i == 0\n arry << i\n end\n\n i += 1\n end\n return arry\nend",
"def prime_factors(num)\n require \"prime\"\n primes = []\n Prime.each{|prime| primes << prime if num % prime ==0 ; break if prime > num }\n primes\nend",
"def factors(n)\n\n\t#create an Array\n\tarray = []\n\t\n\t(1..n).each do |num|\n\t\tif (n % num) == 0\n\t\t\tarray.push(num)\n\t\tend\n\tend\n\treturn array\nend",
"def prime_factors(n)\n\tfps = []\n\t# check for even\n\tif n % 2 == 0\n\t\tfps.push(2)\n\t\tn = div_factor(n, 2)\n\tend\n\t# check odd factors\n\tfact = 3\n\tmaxFact = Math.sqrt(n)\n\twhile n > 1 && fact < maxFact\n\t\tif n % fact == 0\n\t\t\tfps.push(fact)\n\t\t\tn = div_factor(n, fact)\n\t\t\tmaxFact = Math.sqrt(n)\n\t\tend\n\t\tfact = fact + 2\n\tend\n\tif n > fps.last\n\t\tfps.push(n)\n\tend\n\tfps.sort!\nend",
"def factors\n factors = []\n for divisor in 2..(Math.sqrt(self).to_i)\n if self%divisor == 0\n factors << divisor \n factors << (self/divisor)\n end\n end\n return factors.sort!.reverse!\n end",
"def factors(num)\n arr = []\n (1..num).each do |el|\n arr << el if num % el == 0\n end\n arr\nend",
"def prime_factors(n)\n return [] if n == 1\n factor = (2..n).find {|x| n % x == 0}\n [factor] + prime_factors(n / factor)\nend",
"def prime_factors(number, array = [])\n return if number == 1\n 2.upto(number).each do |num|\n if number % num == 0\n number /= num\n array << num\n else\n end\n end\n prime_factors(number, array)\nend",
"def factors_of(num)\n new_arr = []\n\n i = 1\n while i <= num\n if num % i == 0\n new_arr << i\n else \n end \n i += 1\n end\n return new_arr\nend",
"def factors(num)\n arr = []\n for i in 1..num\n if num%i == 0\n arr << i\n end\n end\n arr\nend",
"def factor(n)\n return [] if n.zero?\n Prime.prime_division n\n end",
"def factors(num)\n arr = []\n (1..num).each { |n| arr << n if num%n==0}\n return arr\nend",
"def factors_of(num)\n array = []\n i = 1\n while i <= num\n if num % i == 0\n array << i\n end\n i += 1\n end\n return array\n end",
"def factors_of(num)\n\tnewArray = []\n \tfor i in 1..num\n if num % i == 0\n \tnewArray << i\n end\n end\n return newArray\nend",
"def factors_of(num)\n i = 1\n newArr = []\n while i <= num\n if num % i == 0\n newArr << i\n end\n i += 1\n end\n return newArr\n end",
"def prime_factors(number, array=[])\n 2.upto(number) do |factor|\n if number % factor == 0\n array << factor\n number /= factor\n prime_factors(number, array)\n break\n end\n end\n array\nend",
"def factors_of(num)\n arr = []\n\n i = 1\n\n while i <= num\n if num % i == 0\n arr << i\n end\n i += 1\n end\n\n return arr\nend",
"def prime_factors(number)\n fs = []\n f1 = factor(number)\n return [number] if f1 == 1\n f2 = number/f1\n fs.concat(prime_factors(f1))\n fs.concat(prime_factors(f2))\n return fs\n end",
"def factors(num)\n prime?(num) ? [1, num].uniq : [*1..num].select { |i| num % i == 0}\nend",
"def prime_factors\n return self.prime_factorization.uniq\n end",
"def factors(n)\n new_arr = []\n (1...n).each do |i|\n if n % i == 0 \n new_arr << i \n end\n end\n new_arr \nend",
"def factors(n)\n factors_array = []\n i = 1\n while i <= n\n factors_array.push(i) if n % i == 0\n i += 1\n end\n factors_array\nend",
"def prime (n)\n\n\t#create an Array\n\tprime_num = []\n\n\tfor num in (2..n)\n\t\tis_prime = factors(num)\n\t\tif (is_prime.length ==2)\n\t\t\tprime_num.push(num)\n\t\tend\n\tend\n\treturn prime_num\nend",
"def prime_factors(number)\n factors = []\n i = 0\n if prime?(number)\n return [number]\n else\n new_prime = @primes[-1] + 2\n while @primes[-1] * 2 <= number\n if prime?(new_prime)\n @primes << new_prime\n end\n new_prime += 2\n end\n while @primes[i] <= Math.sqrt(number)\n if number % @primes[i] == 0\n factors << @primes[i]\n number /= @primes[i]\n i = 0\n else\n i += 1\n end\n end\n factors << number\n end\n return factors\nend",
"def prime_factors(num)\n\tprimeFactors = []\n \t\n \t(1..num).each do |i|\n \tif num % i == 0 && isPrime(i)\n \tprimeFactors.push(i)\n end\n end\n \n \treturn primeFactors\nend",
"def factors(num)\n arr = (1..num).to_a\n factored_arr = []\n i = 0\n while i < arr.length\n if num % arr[i] == 0\n factored_arr = factored_arr + arr[i]\n end\n i +=1\n end\n factored_arr\nend",
"def factors num\n f = Array.new # creates a new array to store factors\n 1.upto(num) do |i|\n f << i if num%i == 0\n end\n f # returns factors\nend",
"def factors(num)\n factors = Prime.prime_division(num)\n result = []\n factors.each { |factor, power| result += [factor] * power }\n result\n end",
"def get_factors(num)\n factors = []\n (1..num).each do |i|\n factors << i if num % i == 0\n end\n factors\nend",
"def factors\n exponents = ::NArray.int(PRIMES.size, 2)\n self.each_with_index do |y, i|\n exponents[true,i] = ::NArray.to_na(PRIMES.to_a.map do |x|\n exp_count = 0\n while y % x == 0\n exp_count += 1\n y /= x\n end\n exp_count\n end)\n end\n # Will be an NArray of exponents (negative numbers are denominators)\n exponents[true,0] - exponents[true,1]\n end",
"def factors(num)\n array = []\n (1..num).each do |x|\n if num % x == 0\n array << [x, num/x]\n end\n end\n array\nend",
"def factors_of(num) # Define method with one param\n \n i = 1 # To prevent dividing by zero start at one because of future modula expression\n new_array = [] # Create and empty array to shovel numbers while they meet requirements of the if statement\n \n while i <= num \n \n if num % i == 0 # Parameter entered must be a factor of i since we are cycling through iterations and i is incrementing upwards\n \n new_array << i # Shovel iterations that fulfill logical conditions\n end\n \n i += 1 # Increment up 1 at a time\n end\n return new_array # Prints array after while loop ends; while loop conditions are met\n\nend",
"def prime_factorization num\n acc = 1\n ans = Array.new\n for i in 2..num\n if num % i == 0\n if isPrime?(i)\n temp = num\n count = 0\n ans.push(i)\n while (temp % i == 0)\n count = count + 1\n temp = temp / i\n acc = acc * i\n end\n ans.push(count)\n if acc == num\n return ans\n end\n end\n end\n end\nend",
"def prime_factors( n )\nend",
"def prime_factorization(num)\n (2...num).each do |fact|\n if (num % fact == 0)\n otherFact = num / fact\n return [ *prime_factorization(fact), *prime_factorization(otherFact) ]\n end\n end\n\n [num]\nend",
"def factors(num)\n answer = []\n (1...num).each {|i| answer << i if num % i == 0 }\n answer\nend",
"def factors_of(num)\n divide_by = []\n \n i = 1\n while i <= num\n if num % i == 0\n divide_by << i\n end\n \n i += 1\n end\n \n return divide_by\nend",
"def prime_factors(options = {})\n options[:nrs] ||= Math.sqrt(self).floor.prime_numbers\n options[:nrs].each_with_index do |n,i|\n if self%n == 0\n return [n, (self/n).prime_factors(:nrs => options[:nrs])].flatten.except(1)\n elsif i == options[:nrs].size-1\n return [self]\n end\n end\n end",
"def factors(num)\n facs = [1]\n (2..num/2).each{|n| facs.push(n) if num % n == 0 }\n facs.push(num)\nend",
"def prime_factorization(num)\n\n (2...num).each do |i|\n if num % i == 0\n i2 = num / i\n return [*prime_factorization(i), *prime_factorization(i2)]\n end \n end\n [num]\nend",
"def prime_factorization(num)\n return [num] if is_prime?(num)\n\n prime_factors = []\n prime_factors << first_factor(num)\n next_num = num / first_factor(num)\n prime_factors << prime_factorization(next_num)\n prime_factors.flatten\nend",
"def prime_factorization(num)\n (2...num).each do |fact|\n if num % fact == 0 \n fact_2 = num / fact\n return [ *prime_factorization(fact), *prime_factorization(fact_2) ]\n end\n end\n\n [ num ]\nend",
"def prime_factors(num)\r\n # your code goes here\r\n prime_factors = []\r\n for i in 1 .. num\r\n if num % i == 0 && prime?(i)\r\n prime_factors << i\r\n end\r\n end\r\n prime_factors\r\nend",
"def prime_factor(n)\n factors = []\n p = 2\n\n\n while (p < n)\n\n return factors if ( factors.inject(:*).to_i >= n )\n\n if ( n % p == 0 )\n factors.push(p)\n end\n\n p += 1\n\n end\n\n\n return factors\nend",
"def prime_factors(number)\n divisors = []\n divisor = 2\n\n while number > 1\n if number % divisor == 0\n number /= divisor\n divisors << divisor\n else\n divisor += 1\n end\n end\n\n divisors.uniq\nend",
"def prime_factors(n)\n factors = []\n old_n = n\n @primes.each { |prime|\n if @factors_hash[n]\n factors += @factors_hash[n]\n factors.uniq!\n break\n end\n if n % prime == 0\n factors.push(prime)\n n /= prime\n end\n break if prime >= n\n # If the remainder is a prime, add and break\n if @prime_hash[n]\n factors.push(n)\n break\n end\n }\n @factors_hash[old_n] = factors\n return factors\nend",
"def factors_of(n)\n\tfactors = []\n\tsqrt = (Math.sqrt(n)).floor\n\t(1..sqrt).each do |f|\n\t\tif n % f == 0\n\t\t\tfactors << f\n\t\t\tfactors << n / f if (n / f) != f\n\t\tend\n\tend\n\tfactors.sort\nend",
"def factors(num1, num2)\n arr = []\n\n (1..num1).each do |ele|\n # compare if ele is divisible for both numbers\n arr << ele if num1 % ele == 0 && num2 % ele == 0\n end\n \n return arr\nend",
"def factors(num)\n result = [1]\n\n (2..num).each do |el|\n result << el if num % el == 0\n end\n result\nend",
"def find_factors(number)\n factors =[]\n for i in 1..number\n factors << i if number % i == 0\n end\n factors\nend",
"def factors (n)\n return (1..n).select {| x | n % x == 0}.to_a\nend",
"def factors\n all_factors = []\n (1..Math.sqrt(self).to_i).each do |x|\n all_factors.push(x, self/x) if (self % x == 0)\n end\n\n all_factors.sort.uniq\n end",
"def prime_factorization(num)\n (2...num).each do |fact|\n if num % fact == 0\n other_fact = num / fact\n return [ *prime_factorization(fact), *prime_factorization(other_fact) ]\n end\n end\n [ num ]\nend",
"def factors_of(num)\n\tnums = []\n \n\ti = 1\n\twhile i <= num\n\t\tif num % i == 0\n\t\t\tnums << i\n end\n\t\ti += 1\n end\n \n\treturn nums\nend",
"def prime_factors(n)\n factors = []\n d = 2\n while n > 1\n while n % d == 0\n factors << d\n n /= d\n end\n d = d + 1\n if d*d > n\n if n > 1\n factors << n\n break\n end\n end\n end\n return factors\nend",
"def prime_factorization(num)\n (2...num).each do |fact|\n if num % fact == 0\n other_fact = num / fact\n return [*prime_factorization(fact), *prime_factorization(other_fact)]\n end\n end\n [num]\nend",
"def prime_factors(num)\n prime_facts = []\n\n (1..num).each do |i|\n if num % i == 0 && prime?(i)\n prime_facts << i\n end\n end\n\n return prime_facts\nend",
"def prime_factorization(n)\n (2...n).each do |num|\n if n % num == 0\n othernum = n / num\n return [*prime_factorization(num),*prime_factorization(othernum)]\n end\n end\n [n]\nend",
"def prime_factors(num)\n\tfactors = []\n\tfactor = 2\n\tremainder = num\n\n\twhile (remainder > 1) && (factor <= num)\n\t\twhile (remainder % factor == 0)\n\t\t\tfactors << factor\n\t\t\tremainder /= factor\n\t\tend\n\n\t\tfactor += 1\n\tend\n\tfactors\nend",
"def prime_factorization(num)\n return [num] if is_prime?(num)\n prime_fact = []\n (2..num).each do |n|\n return [n] + prime_factorization(num / n) if num % n == 0\n end\n prime_fact\n end",
"def prime_factors(num)\n factors = []\n # Store all the factors in an array\n (2..num).each do |divisor|\n if num % divisor == 0\n factors << divisor\n end\n end\n\n # loop through factors array and return only the prime prime prime factors\n if factors.length > 0\n return factors.select { |factor| checkIfPrime(factor) }\n else\n return factors\n end\nend",
"def prime_factorization(num)\n\n return [num] if prime?(num)\n\n (2...num).each do |divisor|\n if num % divisor == 0\n next_factor = num / divisor\n return [divisor, *prime_factorization(next_factor)]\n end\n end\n\nend",
"def factors(num)\n ret = []\n for i in (1..num)\n ret << i if num % i == 0\n end\n ret\nend",
"def primeFactors(n, verbose = false, checked = {})\n\n if verbose then puts \"=======================\" end\n\n pFactors = Array.new()\n\n # for pretty-printing verbosity\n if verbose then puts \"looking at #{n}\" end\n\n for d in 2..(Math.sqrt(n))\n\n # this acts asthe base case -- if we get below 2 this will always fail\n if divides?(d,n) then\n\n if verbose then puts \" #{d} divides\" end\n\n if checked[d] != true then \n if primeFactors(d, verbose).length == 0\n # if d is prime, add it.\n if verbose then puts \"#{d} is prime\" end\n pFactors.push(d)\n else\n # if d is NOT prime, \n if verbose then puts \" #{d} NOT prime\" end\n pFactors = pFactors | primeFactors(d, verbose)\n end\n else \n if verbose then puts \"already checked #{d}\" end\n end\n checked[d] = true\n\n # and find the prime factors of d's co-divisor. \n # if no factors, d's co-divisor is prime\n if checked[n/d] != true then \n if primeFactors(n/d, verbose).length == 0 then\n if verbose then puts \"#{n/d} is prime\" end\n pFactors.push(n/d)\n else\n pFactors = pFactors | primeFactors(n/d, verbose)\n end\n else\n if verbose then puts \"already checked #{d}\" end\n end\n\n checked[n/d] = true\n end\n end\n\n return pFactors\nend",
"def prime_factorization(num)\n (2...num).each do |fact|\n if num % fact == 0\n other_fact = num/fact\n return [*prime_factorization(fact),*prime_factorization(other_fact)]\n end\n end\n\n return [num]\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n puts \"Prime!!\" if divisors.length < 3\n divisors\nend",
"def prime_factor(num)\n i = 2\n factors = []\n while i <= num\n if num % i == 0\n factors << i\n num = num / i\n else\n i += 1\n end\n end\n factors\nend",
"def factors(num)\n factors = []\n (1..num).each do |factor|\n factors << factor if num % factor == 0\n end\n factors\nend",
"def factors_of(num)\n \n index = 1 \n \n factors = []\n \n while index <= num\n if num % index == 0 \n factors << index \n end \n \n index += 1 \n end \n \n return factors \n \nend",
"def prime_factors(num)\n prime_facts = []\n \n (1..num).each do |i|\n if num % i == 0 && prime?(i)\n prime_facts << i\n end\n end\n \n return prime_facts\n end"
] | [
"0.8321737",
"0.8214368",
"0.8024582",
"0.7942682",
"0.7887547",
"0.78781176",
"0.7876123",
"0.7858201",
"0.78339076",
"0.7825693",
"0.7825693",
"0.7779158",
"0.7753471",
"0.7732609",
"0.77198684",
"0.7625415",
"0.7618718",
"0.76001966",
"0.7599118",
"0.75832766",
"0.7575698",
"0.75603586",
"0.75597376",
"0.7546273",
"0.74890953",
"0.7466536",
"0.7462247",
"0.7453996",
"0.7445498",
"0.74439764",
"0.7441313",
"0.7439322",
"0.74361134",
"0.74328005",
"0.7426256",
"0.7412325",
"0.74056983",
"0.738364",
"0.73833895",
"0.73748386",
"0.7374213",
"0.7369831",
"0.7368006",
"0.73594564",
"0.7358114",
"0.7353556",
"0.7353383",
"0.7343477",
"0.73411125",
"0.73393714",
"0.73388535",
"0.7288427",
"0.72858804",
"0.7280426",
"0.72733635",
"0.7268018",
"0.7254479",
"0.7237396",
"0.7219715",
"0.7205518",
"0.7200335",
"0.7194423",
"0.71910554",
"0.7180016",
"0.7169538",
"0.7157555",
"0.71556664",
"0.7153267",
"0.71514004",
"0.7149597",
"0.7146578",
"0.71379906",
"0.7137027",
"0.7135365",
"0.71221596",
"0.71204096",
"0.7107736",
"0.7107205",
"0.7103701",
"0.7102621",
"0.7101103",
"0.70993227",
"0.7097333",
"0.7097011",
"0.70969445",
"0.70935243",
"0.7092115",
"0.7091965",
"0.7079166",
"0.70773953",
"0.70767856",
"0.7071237",
"0.7063671",
"0.7061007",
"0.70570284",
"0.7054659",
"0.7050167",
"0.7048848",
"0.7043656",
"0.7042342"
] | 0.76855034 | 15 |
Write a method that returns the number of prime factors of its argument. | def num_prime_factors(num)
prime_factors(num).length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_prime_factors(num)\n prime_factors(num).count\nend",
"def num_prime_factors(num)\n prime_factors(num).length\n\nend",
"def num_prime_factors(num)\n prime_factors(num).length\nend",
"def num_prime_factors(num)\r\n # your code goes here\r\n prime_factors(num).length\r\n\r\nend",
"def num_prime_factors(num)\n return prime_factors(num).length\nend",
"def num_prime_factors(num)\n return prime_factors(num).length\nend",
"def num_prime_factors(num)\n return prime_factors(num).size\nend",
"def num_prime_factors(num)\n (prime_factors(num)).length\nend",
"def prime_factors( n )\nend",
"def num_prime_factors(num)\n\tprime_factors(num).length\nend",
"def primeFactors(n)\n i = 2\n npf = 0 #number of prime factors\n while i < n-1\n if n % i == 0 && Prime.prime?(i)\n npf += 1\n end\n i+=1\n end\n npf\nend",
"def factors(number)\n # TODO: can optimise by only going up to the square of the number\n (1..number).select { |x| number % x == 0 }.count\nend",
"def prime_factors(n)\r\n num=Math.sqrt(n).round\r\n while num>0\r\n if n%num==0\r\n return num if prime?(num)\r\n end\r\n num-=1\r\n end\r\nend",
"def prime_factors_mult( n )\nend",
"def count_factors num\n count = 0\n if num == 1\n return 1\n end\n\n lim = Math.sqrt(num)\n for i in 1...lim\n if num % i == 0\n count = count + 1\n end\n end\n\n if is_a_square?(num)\n return (2*count) + 1\n end\n\n return 2*count\nend",
"def prime_factors(num)\n factors(num).select {|n| prime?(n)}\nend",
"def factors_of(num)\n # Write your code here\nend",
"def num_factors(n)\n pf = prime_factors(n)\n freq = Hash.new(0)\n pf.each{ |i| freq[i] += 1 }\n freq.inject(1){ |t,(k,v)| t * (v+1) }\nend",
"def factors num\n if num != 1\n #Start with 1 and num as the first factors\n c = 2\n 2.upto(num/2) { |f|\n if num % f == 0\n c += 1\n end\n }\n else\n c = 1\n end\n\n c\nend",
"def prime_factors(num)\n factors(num).select { |factor| prime?(factor) }\nend",
"def factors( n )\n p = Primer.ld( n )\n return n if p == n\n factors n.div( p )\nend",
"def prime_factors(num)\n facs = (1..num).select {|x| num % x == 0 }\n facs.select {|x| prime?(x)}\nend",
"def number_of_factors(n)\n # bruteforce, simplest\n # least efficient way\n count = 0\n\n (1..n).each do |i|\n if n % i == 0\n count += 1\n end\n end\n\n count\nend",
"def prime_factors (n)\n return factors(n) & primes(n)\nend",
"def prime_factorization(num)\nend",
"def prime_factors(n)\n return factors(n) & primes(n)\nend",
"def prime_factors (n)\r\n return factors(n).select { |x| factors(x).length == 2 }\r\nend",
"def prime_factorization(num)\n \nend",
"def prime_factorization(num)\n \nend",
"def prime_factorization(num)\n \nend",
"def prime_factors(num)\n\tfactors(num).select { |n| prime?(n) }\nend",
"def factor_count(x)\n range = 2..Math.sqrt(x)\n count = range.count { |i| x % i == 0 }\n count * 2\nend",
"def num_of_prime_factors(num)\n all_factors = factors(num)\n only_prime = []\n i = 0\n while i < all_factors.length\n if prime?(all_factors[i])\n only_prime += all_factors[i]\n end\n i += 1\n end\n only_prime.length\nend",
"def prime_factors(num)\n require \"prime\"\n primes = []\n Prime.each{|prime| primes << prime if num % prime ==0 ; break if prime > num }\n primes\nend",
"def prime_factors(num)\n primes = (2..num).select { | n | isprime?(n) }\n primes.select { |prime| num % prime == 0 }\nend",
"def factors(num)\n\nend",
"def factors(num)\n\nend",
"def factors(num)\n\nend",
"def factors(num)\n prime?(num) ? [1, num].uniq : [*1..num].select { |i| num % i == 0}\nend",
"def prime_factors(num)\n (2..num).select {|n| num%n ==0 && prime?(n)} \nend",
"def divisor_count_of(number)\n # Count the divisors by computing the prime factorization of the number and\n # multiplying PF exponents. 1 is added to the exponents since each base can\n # be raised to the 0 power, which is still a divisor of the given number.\n prime_factorization = prime_factorization_of(number)\n exponents = prime_factorization.values\n result = exponents.inject(1) {|accum, val| accum * (val + 1)}\n\n return result\nend",
"def GetPrimeFactors (number, primes)\n\tfactorCount = 0\n\tlastFactor = 0\n\tremainder = number\n\t\n\t# Keep looping until we reach the end of our dividing\n\twhile (remainder != 1 )\n\t\t# Determine the lowest prime that we can use to divide the remainder\n\t\tfor i in 0...primes.count\n\t\t\tif (remainder <= 1) # Sanity check\n\t\t\t\tbreak\n\t\t\tend\n\t\t\t\n\t\t\t# Found a prime factor\n\t\t\tif (0 == remainder % primes[i])\n\t\t\t\t# If the current factor is the same as\n\t\t\t\t# the last one then don't count it\n\t\t\t\tif (primes[i] != lastFactor)\n\t\t\t\t\tfactorCount += 1\n\t\t\t\t\tlastFactor = primes[i]\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tremainder /= primes[i]\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend\n\n\treturn factorCount\nend",
"def n_prime_factors(number)\n n_prime = 0\n (2..number / 2).each do |n|\n next unless (number % n).zero?\n n_prime += 1 if Prime.prime?(n)\n end\n n_prime\n end",
"def list_factors(n)\r\n m = 0\r\n #even\r\n if (n % 2 == 0)\r\n for i in 1..n\r\n if (n%i == 0)\r\n m+=1\r\n end\r\n end\r\n #odd\r\n else\r\n for i in (1..n).step(2) do\r\n if (n%i == 0)\r\n m+=1\r\n end\r\n end\r\n end \r\n return m\r\nend",
"def prime_factor(num)\n i = 2\n factors = []\n while i <= num\n if num % i == 0\n factors << i\n num = num / i\n else\n i += 1\n end\n end\n factors\nend",
"def prime_factors(num)\n factors = []\n # Store all the factors in an array\n (2..num).each do |divisor|\n if num % divisor == 0\n factors << divisor\n end\n end\n\n # loop through factors array and return only the prime prime prime factors\n if factors.length > 0\n return factors.select { |factor| checkIfPrime(factor) }\n else\n return factors\n end\nend",
"def prime_factors(number)\n factors = []\n i = 0\n if prime?(number)\n return [number]\n else\n new_prime = @primes[-1] + 2\n while @primes[-1] * 2 <= number\n if prime?(new_prime)\n @primes << new_prime\n end\n new_prime += 2\n end\n while @primes[i] <= Math.sqrt(number)\n if number % @primes[i] == 0\n factors << @primes[i]\n number /= @primes[i]\n i = 0\n else\n i += 1\n end\n end\n factors << number\n end\n return factors\nend",
"def factors(num)\n (1..Math::sqrt(num)).each do |x|\n if num % x == 0\n puts x\n puts num/x\n end\n end\n nil\nend",
"def factors(num)\n pn = num.prime_division\n ans = []\n pn.each_index do |i|\n ans << pn[i][0]\n end\n return ans\nend",
"def factors() (1..self).select { |n| (self % n).zero? } end",
"def factors_of(num)\n (1..num).select{|ele| num % ele == 0}\nend",
"def factors(num)\n 1.upto(num).select { |x| num % x == 0 }\nend",
"def prime_factors(n)\n return [] if n == 1\n factor = (2..n).find {|x| n % x == 0}\n [factor] + prime_factors(n / factor)\nend",
"def prime_factors (n)\n return (1..n).select { |x| n%x==0 and x.prime? }\nend",
"def prime_factors num\n\tfactors = []\n\ttest_value = 2\n\twhile num > 1 do\n\t\twhile num % test_value == 0 do\n\t\t\tfactors.push num\n\t\t\tnum = num / test_value\n\t\tend\n\t\ttest_value += 1\n\tend\n\treturn factors\nend",
"def prime_factors(num)\r\n # your code goes here\r\n prime_factors = []\r\n for i in 1 .. num\r\n if num % i == 0 && prime?(i)\r\n prime_factors << i\r\n end\r\n end\r\n prime_factors\r\nend",
"def prime_factors\n n = self\n factors = Hash.new(0)\n\n # Pull out twos manually\n while n % 2 == 0 do\n factors[2] += 1\n n /= 2\n end\n\n # Then use Fermat's method\n a = Math.sqrt(n).ceil\n b2 = a**2 - n\n until (b2**0.5).round**2 == b2 do\n a += 1\n b2 = a**2 - n\n end\n\n candidates = [(a - Math.sqrt(b2)).round, (a + Math.sqrt(b2)).round]\n candidates.each do |candidate|\n next if candidate == 1\n if candidate == n\n factors[n] += 1\n else\n candidate_factors = candidate.prime_factors\n if candidate_factors.length == 1\n factors[candidate_factors.first] += 1\n else\n candidates.concat candidate_factors\n end\n end\n end\n \n expanded = []\n factors.each do |prime, count|\n count.times { expanded << prime }\n end\n expanded.sort\n end",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n puts \"Prime!!\" if divisors.length < 3\n divisors\nend",
"def factors(num)\n factors = Prime.prime_division(num)\n result = []\n factors.each { |factor, power| result += [factor] * power }\n result\nend",
"def count_factors\n factors.count\n end",
"def prime_factors(num)\n prime_facts = []\n\n (1..num).each do |i|\n if num % i == 0 && prime?(i)\n prime_facts << i\n end\n end\n\n return prime_facts\nend",
"def prime_factors(num)\n\n if prime?(num)\n return [num]\n end\n\n primes = (2...num).to_a.select { |factor| prime?(factor) }\n\n \n \n factors = []\n\n while num > 1\n candidate = primes.shift\n\n if num % candidate == 0\n factors << candidate\n while num % candidate == 0\n num /= candidate\n end\n end\n end\n\n return factors\n \nend",
"def prime_factors(num)\n facs = factors(num)\n p_facs = []\n facs.each{|n| p_facs.push(n) if prime?(n)}\n p_facs\nend",
"def factors(num)\n (1..num).select{|i| num % i == 0 }\nend",
"def prime_factors(num)\n factors = factors(num)\n result = []\n factors.each do |fac|\n if prime?(fac)\n result << fac\n end\n end\n result\nend",
"def factors(num)\n (1..num).select {|x| num % x == 0 }\nend",
"def prime_factor(num)\n\t\n\t(1..num).select {|n| (num % n).zero?}\n\t#zero? will return true when num has zero\nend",
"def prime_factors(n)\n\tfps = []\n\t# check for even\n\tif n % 2 == 0\n\t\tfps.push(2)\n\t\tn = div_factor(n, 2)\n\tend\n\t# check odd factors\n\tfact = 3\n\tmaxFact = Math.sqrt(n)\n\twhile n > 1 && fact < maxFact\n\t\tif n % fact == 0\n\t\t\tfps.push(fact)\n\t\t\tn = div_factor(n, fact)\n\t\t\tmaxFact = Math.sqrt(n)\n\t\tend\n\t\tfact = fact + 2\n\tend\n\tif n > fps.last\n\t\tfps.push(n)\n\tend\n\tfps.sort!\nend",
"def prime_factors(num)\n factors = num.prime_division\n factors.to_a\n largest_factor = factors[-1][0]\n p largest_factor\nend",
"def factors(num)\n (1..num).select { |el| num % el == 0 }\nend",
"def prime_factors(num)\n arr = (2..Math.sqrt(num).round).to_a\n primes = arr.each do |i|\n arr.select! {|j| j%i != 0 or j==i}\n end\n pfacts = primes.select {|i| num%i == 0}\n\n return [num] if pfacts.empty?\n return pfacts\nend",
"def factors(num)\n return nil if num < 0\n return 1 if num == 1\n (1..num).select { |n| num % n == 0}\n\n\nend",
"def prime_factor(n)\n factors = []\n p = 2\n\n\n while (p < n)\n\n return factors if ( factors.inject(:*).to_i >= n )\n\n if ( n % p == 0 )\n factors.push(p)\n end\n\n p += 1\n\n end\n\n\n return factors\nend",
"def find_factors(number)\n\t# start with lowest prime number\n\tinteger = 2\n\n\t# make sure integer doesn't exceed the actual number\n\twhile integer <= number do\n\t\t# integer will be returned when if it is a factor of number\n\t\treturn integer if number % integer == 0\n\n\t\t# if integer is not a factor move to next integer\n\t\tinteger += 1\n\tend\nend",
"def num_factors(elem, rest)\n rest.select { |n| (elem % n).zero? }\nend",
"def factors(num)\n (1..num).select { |n| num%n == 0}\nend",
"def prime_factorization num\n acc = 1\n ans = Array.new\n for i in 2..num\n if num % i == 0\n if isPrime?(i)\n temp = num\n count = 0\n ans.push(i)\n while (temp % i == 0)\n count = count + 1\n temp = temp / i\n acc = acc * i\n end\n ans.push(count)\n if acc == num\n return ans\n end\n end\n end\n end\nend",
"def factors(n)\n return (1..n).select {|x| n % x == 0}\nend",
"def primes (n)\r\n primes = Array.new(n) { |index| index+=1 }\r\n return primes.select { |x| factors(x).length == 2 }\r\nend",
"def prime_factors(n)\n factors = []\n d = 2\n while n > 1\n while n % d == 0\n factors << d\n n /= d\n end\n d = d + 1\n if d*d > n\n if n > 1\n factors << n\n break\n end\n end\n end\n return factors\nend",
"def factors(num)\r\n factors = []\r\n sqrt = Math.sqrt(num)\r\n until num == 1\r\n\r\n factor_founded = false\r\n (2..sqrt).each do |i|\r\n if (num % i).zero?\r\n num /= i\r\n factors << i\r\n factor_founded = true\r\n break\r\n end\r\n end\r\n unless factor_founded\r\n factors << num\r\n num /= num\r\n end\r\n end\r\n return factors\r\nend",
"def factors\n exponents = ::NArray.int(PRIMES.size, 2)\n self.each_with_index do |y, i|\n exponents[true,i] = ::NArray.to_na(PRIMES.to_a.map do |x|\n exp_count = 0\n while y % x == 0\n exp_count += 1\n y /= x\n end\n exp_count\n end)\n end\n # Will be an NArray of exponents (negative numbers are denominators)\n exponents[true,0] - exponents[true,1]\n end",
"def factors(num)\r\n # your code goes here\r\n\r\n factors = []\r\n for i in 1 .. num\r\n if num % i == 0\r\n factors << i\r\n end\r\n end\r\n factors\r\nend",
"def primes(n)\n return (2..n).select {|x| factors(x).size() == 2}\nend",
"def n_prime_factors(number)\n detected_primes = n_detected_prime_fatores(number)\n\n start_factor = @primes.last ? @primes.last + 1 : 2\n not_detected_primes = n_not_detected_prime_factors(start_factor, number)\n detected_primes + not_detected_primes\n end",
"def prime?(num)\n fail_count = 0\n if num < 0\n num = num * (-1)\n end\n factors = []\n range = (1..num)\n range.each do |range_number|\n remain = num % range_number\n if remain == 0\n factors.push(num)\n else fail_count += 1\n end\n end\n puts fail_count\n if factors[-1] == 1\n return false\n elsif num == 0\n return false\n elsif factors.count > 2\n return false\n elsif factors.count == 2\n return true\n else return nil\n end\nend",
"def primeFactors(x)\n\tlargestFactor = 1\n\tcurrentFactor = 1\n\twhile currentFactor <= x # limit of the problem\n\t\tif x % currentFactor == 0 \n\t\t\tx = x / currentFactor\n\t\t\tif currentFactor > largestFactor\n\t\t\t\tlargestFactor = currentFactor\n\t\t\t\tcurrentFactor = 0\n\t\t\tend\n\t\tend\n\t\tcurrentFactor += 1\n\tend\n\treturn largestFactor\nend",
"def solution(n)\n factors = 0\n (1..Math.sqrt(n)).each do |i|\n if n % i == 0\n factors += i == Math.sqrt(n) ? 1 : 2\n end\n end\n factors\nend",
"def factors(num)\n return nil if num <= 0\n return [1] if num == 0\n (1..num).select { |i| (num % i) == 0 }\nend",
"def factor(num)\n (1..num).select { |f| (num % f).zero? }\nend",
"def number_of_divisors\n return 1 if self == 1\n self.prime_division.map{|num, power| power + 1 }.inject(&:*)\n end",
"def number_of_divisors(num)\r\n\tprime_array = num.prime_division\r\n\tnum_of_divisors = 1\r\n\t(0..prime_array.length - 1).each do |x|\r\n\t\tnum_of_divisors *= (prime_array[x][1] + 1)\r\n\tend\r\n\treturn num_of_divisors\r\nend",
"def prime_factors(num)\n\tfactors = []\n\tfactor = 2\n\tremainder = num\n\n\twhile (remainder > 1) && (factor <= num)\n\t\twhile (remainder % factor == 0)\n\t\t\tfactors << factor\n\t\t\tremainder /= factor\n\t\tend\n\n\t\tfactor += 1\n\tend\n\tfactors\nend",
"def factor_primes(num)\n\n return \"Not a valid number\" if num < 2\n\n for divisor in 2..(num - 1)\n while num % divisor == 0 \n (divisor * divisor > num) ? (return num) : (num /= divisor)\n # puts \"The divisor is #{divisor}\"\n # puts \"The new num is #{num}\"\n end\n end\n puts \"only divisible by 1 and itself\"\nend",
"def prime_factors(num)\n #initialize an array\n primeFacts = []\n \n #iterate each number from 1 until num\n (1..num).each do |nums|\n #if the remainder is 0 and nums is prime push nums\n if num % nums == 0 && prime?(nums)\n primeFacts << nums\n end\n end\n return primeFacts\nend",
"def prime_factors(num)\n facts = []\n\n (1..num).each do |i|\n if num % i == 0 && prime?(i)\n facts << i\n end\n end\n \n return facts\nend",
"def prime_factor\n max = 600851475143**0.5\n\n for i in (1..max).step(2)\n if 600851475143 % i == 0\n if is_prime(i)\n ans = i\n end\n end\n end\n ans\nend",
"def factor(n)\n i=2 # start at 2 since all is divisible by one\n prime = true\n #print \"Factors of #{n}: \"\n while( i < Math.sqrt(n)+1 ) # only test up to the square root of the number\n if(n%i == 0)\n # print \"#{i},\"\n prime = false\n end\n i += 1\n end\n if (prime == true) \n puts \"#{n} is a prime number. Found in: #{Time.now - $start} seconds\" # since last prime number found\n $start = Time.now \n end\n \nend"
] | [
"0.87944657",
"0.8692755",
"0.8644713",
"0.86063844",
"0.84600616",
"0.84600616",
"0.8443473",
"0.84298766",
"0.8379911",
"0.82761544",
"0.8150427",
"0.8008973",
"0.79603446",
"0.79120946",
"0.7788769",
"0.7751828",
"0.7732856",
"0.7686826",
"0.768163",
"0.7656219",
"0.76314384",
"0.7618493",
"0.76130015",
"0.7608731",
"0.75928104",
"0.75774616",
"0.75770193",
"0.7566073",
"0.7566073",
"0.7566073",
"0.75466835",
"0.7534363",
"0.75329983",
"0.75042665",
"0.7492024",
"0.7491326",
"0.7491326",
"0.7491326",
"0.7455112",
"0.7427982",
"0.74124694",
"0.74109703",
"0.7397664",
"0.7377784",
"0.73775494",
"0.7347391",
"0.7344691",
"0.73422444",
"0.7335851",
"0.7332798",
"0.7327025",
"0.73244166",
"0.7317706",
"0.7314371",
"0.73033386",
"0.7301031",
"0.7295057",
"0.72935134",
"0.7287155",
"0.72826135",
"0.7281421",
"0.72745156",
"0.726726",
"0.72547597",
"0.7251143",
"0.7244976",
"0.72435343",
"0.72420293",
"0.72344226",
"0.72290194",
"0.7225565",
"0.7222712",
"0.72117394",
"0.71947366",
"0.71868557",
"0.71789473",
"0.7138693",
"0.7138344",
"0.71223336",
"0.7118535",
"0.71161854",
"0.711477",
"0.7094633",
"0.7090723",
"0.7087487",
"0.7086606",
"0.70833874",
"0.7075802",
"0.7067936",
"0.70512354",
"0.7048114",
"0.7043133",
"0.70261616",
"0.70234203",
"0.70175314",
"0.7014485",
"0.6990781",
"0.69865817"
] | 0.8615301 | 5 |
EXPERT Return the one integer in an array that is even or odd while the rest are of opposite parity, e.g. oddball([1,2,3]) => 2, oddball([2,4,5,6] => 5) | def oddball(arr)
a, b, c = arr
if a %2 == b %2
expected = a %2
arr.drop(2).each{|n| return n if n != a}
elsif a%2 == c %2
return b
else
return a
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def oddball(arr)\n is_even = []\n is_odd = []\n i = 0\n while i < arr.length\n if arr[i] % 2 = 0\n is_even += arr[i]\n else\n is_odd += arr[i]\n end\n i += 1\n end\n if is_even.length == 1\n return is_even[0]\n else\n return is_odd[0]\n end\nend",
"def oddball(arr)\n\tnew_arr = arr.map { |n| n % 2}\n\tnew_arr.count(0) == 1 ? arr[new_arr.index(0)] : arr[new_arr.index(1)]\nend",
"def oddball(arr)\n evens = arr.select(&:even?)\n odds = arr.select(&:odd?)\n evens.length == 1 ? evens[0] : odds[0]\nend",
"def oddities(arry)\n arry.select { |n| n if arry.index(n).even? }\nend",
"def oddities(array)\r\n array.select.with_index { |_, i| i.even? }\r\n end",
"def oddball(arr)\n odd = arr.select {|x| x.odd? }\n even = arr.select {|x| x.even? }\n if even.length > odd.length\n odd[0]\n else\n even[0]\n end\nend",
"def oddball(arr)\n evens = []\n odds = []\n arr.each do |int|\n if int.even?\n evens << int\n else\n odds << int\n end\n end\n evens.length > 1 ? odds[0] : evens[0]\nend",
"def oddOne(arr)\n\tif arr.all? { |i| i.even? }\n\t\treturn -1\n\telsif arr.all? { |i| i.odd? }\n\t\treturn -1\n\telse\n\t\tx = arr.count { |i| i.even? }\n\t\ty = arr.count { |i| i.odd? }\n\t\todd_one_out = arr.find { |i| i.odd? } if x > 1\n\t\todd_one_out = arr.find { |i| i.even? } if y > 1\n\t\tarr.index(odd_one_out)\n\tend\nend",
"def odd_integers(array)\nend",
"def oddities(array)\n array.select.with_index { |e, i| (i + 1).odd? }\nend",
"def evenies(array)\n array.select.with_index { |e, idx| e if idx.odd? }\nend",
"def oddities(array)\n array.select { |element| array.index(element).even? }\nend",
"def oddities_1(array)\n array.select { |element| array.index(element) % 2 == 0 }\nend",
"def oddball(arr)\n even_arr = arr.select { |n| n % 2 == 0 }\n odd_arr = arr.reject { |n| n % 2 == 0 }\n\n return even_arr[0] if even_arr.length == 1\n return odd_arr[0]\nend",
"def oddities(arr)\n\tarr.select.with_index { |num, index| num if index.even? }\nend",
"def oddball(arr)\n oddcount = evencount = 0\n arr.each do |num|\n if num % 2 == 0\n evencount +=1\n else\n oddcount +=1\n end\n if oddcount > 1 || evencount > 1\n break\n end\n end\n if oddcount > 1\n arr.each do |num| return num if num % 2 == 0 end\n elsif evencount > 1\n arr.each do |num| return num if num % 2 != 0 end\n end\nend",
"def odd_occurances_in_array(a)\n res = 0\n a.each { |el| res ^= el }\n res\nend",
"def oddities(arr)\n arr.select{ |a| arr.index(a).even? }\nend",
"def oddities(array)\nresult = []\narray.each_with_index do |value, idx|\n result << value if (idx + 1).odd?\nend\nresult\nend",
"def evenies(array)\n even_array = []\n array.each_with_index { |e, idx| even_array << e if idx.odd? }\n even_array\nend",
"def odds_only array\n array.select do |value|\n value.odd?\n end\nend",
"def oddball(arr)\n odds = arr.select {|num| num.odd?}\n evens = arr.select {|num| num.even?}\n odds.size > evens.size ? evens[0] : odds[0]\nend",
"def oddities(array)\n array.select {|element| array.index(element).even?}\nend",
"def oddities(array)\n array.select.with_index { |e, idx| e if idx.even? }\nend",
"def oddities(array)\n new_array = []\n array.each_with_index { |num, idx| new_array << num if idx.even? }\n new_array\nend",
"def oddities(array)\n array.select {|item| array.index(item).even?}\nend",
"def oddities(array)\n odd_array = []\n array.each_with_index { |e, idx| odd_array << e if idx.even? }\n odd_array\nend",
"def oddities(arr)\n arr.select.with_index do |_,index|\n (index + 1).odd?\n end\nend",
"def oddities(array)\n odd_array = []\n array.each_with_index do |e, idx|\n odd_array << e if idx.even?\n end\n odd_array\nend",
"def oddities(array)\n array.partition {|element| array.index(element).even?}\nend",
"def oddities(arr)\r\n arr2 = arr.select do |x|\r\n arr.index(x).even?\r\n end\r\n arr2\r\nend",
"def oddball(arr)\r\n # your code goes here\r\n evens = []\r\n odds = []\r\n\r\n arr.each do |int|\r\n\r\n if int % 2 == 0\r\n evens << int\r\n else\r\n odds << int\r\n end\r\n\r\n end\r\n if evens.length == 1\r\n return evens[0]\r\n else\r\n return odds[0]\r\n end\r\n\r\nend",
"def oddities(arr)\n index = 0\n arr.select do |e|\n index += 1\n index.odd?\n end\nend",
"def odd_numbers(array)\n end",
"def oddities(array)\n new_array = []\n array.each_with_index { |val, idx| new_array << val if idx.even? }\n new_array\nend",
"def oddies(numerals, odd = true)\n odd ? numerals.select { |item| numerals.index(item).even? } : arr.select { |item| numerals.index(item).odd? } \nend",
"def oddities(array)\n odd_elements = []\n array.each do |element|\n odd_elements << element if array.index(element).even?\n end\n odd_elements\nend",
"def oddities(array)\n ret_array = []\n array.each_with_index do |value, index|\n if index.even?\n ret_array << value\n end\n end\n ret_array\nend",
"def oddities(array)\n new_array = []\n array.each_with_index do |num, index|\n new_array << num if index.odd?\n end\n new_array\nend",
"def oddities(arr)\n arr.select.with_index do |_, idx|\n idx.even?\n end\nend",
"def find_odd(arr)\n arr.find { |i| arr.count(i).odd? }\nend",
"def odd_or_even(array)\n sum = 0\n array.each { |x| sum += x}\n if sum.even? == true\n p \"even\"\n else\n p \"odd\"\n end\nend",
"def odds(arr)\n\tret = []\n\tarr.each_index { |i|\n\t\tif i % 2 == 1\n\t\t\tret << arr[i]\n\t\tend\n\t}\n\tret\nend",
"def odd_indexed_integers(array)\n\nend",
"def evens_and_odds(arr)\r\n arr.partition{ |num| num.odd?}\r\nend",
"def separate_arr_into_even_and_odd_num(arr)\n arr.select { |e| e.even? || e == odd }\nend",
"def odd_only arr\n arr.select{|value| value % 2 != 0}\nend",
"def oddOrEven(arr)\n even = false\n evenCnt = 0\n for i in 0..2 do\n if arr[i] % 2 == 0 then\n evenCnt += 1\n end\n end\n\n if evenCnt > 1 then\n even = true\n for x in arr do\n if x % 2 != 0 then\n return x\n end\n end\n else\n for x in arr do\n if x % 2 == 0 then\n return x\n end\n end\n end\n\nend",
"def return_odd(input)\n input.select do |i|\n i.odd?\n end\nend",
"def find_even(array)\nend",
"def another_example_of_even_odd(array)\n arr_evens = []\n arr_odds = []\n\n array.each { |num| num.even? ? arr_evens << num : arr_odds << num }\n p arr_evens \n p arr_odds\nend",
"def oddities(arr)\n new_arr = []\n arr.each_with_index { |v, idx| new_arr << v if idx.even? }\n new_arr\nend",
"def non_oddities(arr)\n arr_length = arr.size\n index = 0\n even_elements = []\n\n loop do\n even_elements << arr[index] if index.odd?\n\n index += 1\n break if index > arr_length\n end\n even_elements.compact\nend",
"def oddities(array)\n new_array = []\n array.each_with_index do |element, index|\n new_array.push(element) if (index + 1).odd?\n end\n new_array\nend",
"def oddities(array)\n new_array = []\n index_range = (1..array.size-1)\n for n in index_range do \n new_array << array[n] if n.odd?\n end\n new_array\nend",
"def odd_only(arr)\n arr.select{|el| el % 2 != 0}\nend",
"def oddNum arr\n puts (1..255).select {|i| i%2 != 0}\nend",
"def oddities(array)\n result = []\n array.select do |element|\n result << element if array.index(element).even?\n end\n result\nend",
"def oddball(arr)\n # first_even = 1\n # first_odd = 2\n # arr.each do |n|\n # # puts \"checking #{n}\"\n # if n%2==0\n # if first_even==1\n # first_even = n\n # # puts \"set first_even to #{n}\"\n # else\n # return first_odd\n # end\n # else\n # if first_odd==2\n # first_odd = n\n # # puts \"set first_odd to #{n}\"\n # else\n # return first_even\n # end\n # end\n # end\n odds = []\n evens = []\n arr.each do |n|\n if n%2==0\n evens << n\n else\n odds << n\n end\n end\n if odds.length > 1\n return evens[0]\n else\n return odds[0]\n end\nend",
"def is_even array\n array.select do |value|\n value.even?\n end\nend",
"def odd_index_nums(array)\n array.select do |num|\n current_index = array.index(num)\n \n if current_index % 2 == 1\n num\n end\n end\nend",
"def oddities(arr)\n arr.select.with_index do |element, index|\n index.even?\n end\nend",
"def oddities1(arr)\n (arr.map.with_index { |element,i| element if i.even? }).compact\nend",
"def oddities(array)\n result = []\n count = 0\n array.each do |element|\n result << element if count.even?\n count += 1\n end\n result\nend",
"def separate_array_into_even_and_odd_numbers(array)\n array.partition {|x| x.even?}\nend",
"def oddities(init_array)\n odd_bods = []\n init_array.each_with_index do |element, index|\n odd_bods << element if index.odd?\n end\n odd_bods\nend",
"def even_numbers(num_array)\n\tnum_array.select! { |num| num.even? }\nend",
"def oddities(arr)\n new_arr = []\n arr.each.with_index do |item, idx|\n new_arr << item if idx == 0 || idx.even?\n end\n new_arr\nend",
"def oddities(array)\n return_array =[]\n array.each_with_index do |element, index|\n return_array << element if index.even?\n end\n return_array\nend",
"def oddNum arr\r\n puts (1..255).select {|i| i%2 != 0}\r\nend",
"def alternate_order(array)\n array.select{ |a| a % 2 != 0 }\nend",
"def oddities(array)\n new_array = []\n\n index = 0\n while index < array.size\n new_array << array[index] if index.even?\n index += 1\n end\n new_array\nend",
"def puts_even_odd(array = [1, 2, 3, 4, 5, 6, 7, 8, 9])\n puts array.select { |el| el.even? }\n puts array.select { |el| el.odd? }\nend",
"def oddities(arr)\n arr2 = []\n arr.each_with_index { |elem, ndx| arr2 << elem if ndx.even? }\n arr2\nend",
"def oddities(array)\n odd_element_array = []\n index = 0\n loop do\n break if index >= array.size\n odd_element_array << array[index] if index.even?\n index += 1\n end\n odd_element_array\nend",
"def oddities(array)\n result = []\n index = 0\n\n loop do\n result << array[index]\n index += 2\n break if index >= array.size\n end\n\n result\nend",
"def even_numbers(array)\n array.select{ |num| num.even? }\n\n # TODO: Return the even numbers from a list of integers.\n # You should use Enumerable#select\nend",
"def oddities(input)\n input.select.with_index {|_, index| index.even?}\nend",
"def oddities(array)\n odd_values = []\n index = 0\n \n while index < array.size\n odd_values << array[index]\n index += 2\n end\n odd_values\nend",
"def find_even(array)\n array.select { |number| number.even? } #http://www.ruby-doc.org/core-2.2.0/Array.html#method-i-select\nend",
"def is_even(n)\n !n.odd?\nend",
"def oddities(arr)\n new_arr = []\n arr.each_with_index do |val, index|\n new_arr << val if index.even?\n end\n new_arr\nend",
"def is_odd?(int)\n int.odd?\nend",
"def is_even array\n array.select.with_index do |value, index|\n index.even?\n end\nend",
"def odd_num\n y = []\n [*1..255].map do |i| \n if i % 2 != 0\n y << i\n end\n end\n y\nend",
"def evens(arr)\n even_places = []\n arr.each_with_index do |el, idx|\n even_places << el if idx.odd?\n end\n even_places\nend",
"def odd_even_true_false(array)\neven = true\narray.each do |i|\n if i.even?\n even = false\n end\nend\nputs even\nend",
"def oddities(int_array)\n index = 0\n odds = []\n\n while index < int_array.size\n odds.push(int_array[index])\n index += 2\n end\n odds\nend",
"def find_it(seq)\n seq.detect{|num| seq.count(num).odd?}\nend",
"def odd_numb array\n new_arr= array.select! do |value|\n value.class == Integer\n end\n new_arr.select { |value| value % 2 != 0 }.sort\nend",
"def odd_even arr\n arr.map! { |value|\n if value % 2 == 0\n \"even\"\n else\n \"odd\"\n end\n }\nend",
"def oddities(array)\n new_array = []\n array.each_with_index do |item, index|\n new_array << item if index.even?\n end\n new_array\nend",
"def every_other_array(array)\n result = []\n array.each_with_index { |item, index| result << item if (index + 1).odd?}\n p result\nend",
"def is_other_odd?(n)\n n.abs.remainder(2) == 1\nend",
"def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend",
"def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend",
"def solution(a)\n # write your code in Ruby 2.2\n\n # sort a\n a = a.sort\n odd = 0\n\n # loop over the array\n (0..(a.length-1)).step(2) do |i|\n if((i+1 >= a.length) || ((i+1 < a.length) && (a[i] != a[i+1])))\n odd = a[i]\n break\n end\n end\n\n odd\nend",
"def only_even(arr)\n\tnumsOnly = arr.select { |num| num.is_a? Integer } \n\toddOnly = numsOnly.select { |num| num % 2 != 0 }\n\treturn oddOnly.sort()\nend",
"def is_odd?(num)\n num.remainder(2) == 1 || num.remainder(2) == -1\nend",
"def select_every_odd(arr)\n arr.each_index.select {|index| index%2!=0}.map{|index| index=arr[index]}\nend"
] | [
"0.8097777",
"0.80582494",
"0.79378325",
"0.78846085",
"0.78202075",
"0.77989274",
"0.7789699",
"0.77869767",
"0.7783659",
"0.7769034",
"0.77633584",
"0.7735252",
"0.77309644",
"0.77302516",
"0.7723545",
"0.7687903",
"0.76857364",
"0.76700634",
"0.7669797",
"0.76612425",
"0.7639144",
"0.7632509",
"0.7626675",
"0.76209444",
"0.7596957",
"0.7588148",
"0.7585352",
"0.7570925",
"0.7554642",
"0.7552012",
"0.75409865",
"0.7539209",
"0.7528081",
"0.7497583",
"0.749663",
"0.7488086",
"0.74729395",
"0.7472181",
"0.7468946",
"0.74666643",
"0.74539167",
"0.7435557",
"0.74144065",
"0.74072677",
"0.74000466",
"0.7366466",
"0.7357467",
"0.73476434",
"0.733442",
"0.7332477",
"0.73199505",
"0.73044676",
"0.72990495",
"0.7291849",
"0.72871554",
"0.7286264",
"0.72846985",
"0.72723967",
"0.7269674",
"0.72625256",
"0.72569126",
"0.72564685",
"0.7255051",
"0.7251386",
"0.7240423",
"0.7237466",
"0.7231544",
"0.72307414",
"0.7226605",
"0.7225759",
"0.7225213",
"0.7224049",
"0.7203698",
"0.71866435",
"0.7181459",
"0.7177344",
"0.71762997",
"0.7169799",
"0.71604913",
"0.71597356",
"0.71402967",
"0.71354544",
"0.7129991",
"0.7118765",
"0.71076745",
"0.7104282",
"0.70968664",
"0.70859694",
"0.708484",
"0.70653224",
"0.70549023",
"0.7046535",
"0.70363116",
"0.7035552",
"0.703541",
"0.703538",
"0.7005475",
"0.6986868",
"0.69793516",
"0.6974725"
] | 0.7865907 | 4 |
Override render_document to pass `turtle` as a local `turtle` is entityescaped Turtle serialization of graph | def render_document(subjects, options = {})
super(subjects, options.merge(:extracted => graph.dump(:rdfa, :haml => RDF::Linter::TABULAR_HAML))) do |subject|
yield(subject) if block_given?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(document)\n renderer = find_renderer(document)\n renderer.render(document) unless renderer.nil?\n end",
"def render_document; end",
"def _render_\n document.to_s\n end",
"def render(obj = Object.new, locals = {})\n output = template.result(obj.instance_eval { binding })\n (view == 'document' || view == 'embedded') ? output.gsub(BLANK_LINES_PATTERN, '').gsub(LINE_FEED_ENTITY, \"\\n\") : output\n end",
"def render\n @document.playback_attributes @attributes\n renderer.render(@template_name, self)\n end",
"def render_document\n info = {\n :registers => { :site => site, :page => payload[\"page\"] },\n :strict_filters => liquid_options[\"strict_filters\"],\n :strict_variables => liquid_options[\"strict_variables\"],\n }\n\n output = document.content\n if document.render_with_liquid?\n Jekyll.logger.debug \"Rendering Liquid:\", document.relative_path\n output = render_liquid(output, payload, info, document.path)\n end\n\n Jekyll.logger.debug \"Rendering Markup:\", document.relative_path\n output = convert(output.to_s)\n document.content = output\n\n Jekyll.logger.debug \"Post-Convert Hooks:\", document.relative_path\n document.trigger_hooks(:post_convert)\n output = document.content\n\n if document.place_in_layout?\n Jekyll.logger.debug \"Rendering Layout:\", document.relative_path\n output = place_in_layouts(output, payload, info)\n end\n\n output\n end",
"def to_s(&blk)\n # The @__to_s variable is used as a cache. \n # If it's useful we should add a test for it. -ac\n return @__to_s if @__to_s\n render(&blk)\n @__to_s = @doc.to_s\n end",
"def render_to_file(output_path, context, properties = T.unsafe(nil)); end",
"def render_to_body(options = T.unsafe(nil)); end",
"def render_to_string(context, properties = T.unsafe(nil)); end",
"def render( render_state )\n\t\traw = super\n\t\treturn escape_uri( raw.to_s )\n\tend",
"def render(context)\n api = URI.parse('https://www.planttext.com/api/scripting')\n http = Net::HTTP.new(api.host, api.port)\n http.use_ssl = true\n request = Net::HTTP::Post.new(api.request_uri)\n request['Content-Type'] = 'application/x-www-form-urlencoded'\n uml = \"\\n@startuml\\n#{super}\\n@enduml\\n\"\n request.set_form_data(type: 'svg', plantuml: uml)\n response = http.request(request)\n return \"<p>Can't render PlantUML diagram.</p>\" unless response.code == '200'\n url = response.body.gsub(/^\"|\"$/, '')\n puts \"PlantUML SVG generated: #{url}\"\n \"<p><object data='#{url}' type='image/svg+xml' #{@markup}></object></p>\"\n end",
"def render(options = nil, extra_options = {}, &block) #:doc:\n @flash=flash\nputs \"RENGINE RENDER #1\"\n options=interpret_rengine_options(options)\nputs \"RENGINE RENDER #2\"\n #no layout\n super(options,extra_options,&block)\nputs \"RENGINE RENDER #3\"\n unless self.no_wrap\nputs \"RENGINE RENDER #4a\"\n \n \n txx=render_weblab(setUserJavascript+ self.response_body.join(\"\\n\"))\n puts \"RENGINE RENDER #4b\"\n\n # puts \"===========================\\n\"+txx.join(\"\\n\")+\"\\n!================================!\"\n\n if $render_translation_link\n txx << \"\\n<div style=\\\"background-color:#aaa;color:#0ff;\\\">\\n\"\n txx << translation_tool(@displayed_blurb_names)\n txx << \"\\n</div>\\n\"\n end\nputs \"RENGINE RENDER #5\"\n\n self.response_body=txx\n \n end\n end",
"def render_simple_node(page, locals={})\n @current_node = page\n locals.reverse_merge!(:level => 0, :simple => false).merge!(:page => page)\n render :partial => 'wysiwyg/node', :locals => locals\n end",
"def render(params={})\n into, text, part = parameters(params, :to, :text, :partial)\n\n engine = prepare_engine(params)\n\n case into\n when :html, nil\n if part\n engine.to_html\n else\n engine.to_html_document\n end\n when :latex #, :pdf\n if part\n engine.to_latex\n else\n engine.to_latex_document\n end\n else\n super(params)\n end\n end",
"def render(no_follow = false)\n sanitize = no_follow ?\n @wiki.history_sanitizer :\n @wiki.sanitizer\n\n data = extract_tex(@data.dup)\n data = extract_code(data)\n data = extract_tags(data)\n begin\n data = GitHub::Markup.render(@name, data)\n if data.nil?\n raise \"There was an error converting #{@name} to HTML.\"\n end\n rescue Object => e\n data = %{<p class=\"gollum-error\">#{e.message}</p>}\n end\n data = process_tags(data)\n data = process_code(data)\n if sanitize || block_given?\n doc = Nokogiri::HTML::DocumentFragment.parse(data)\n doc = sanitize.clean_node!(doc) if sanitize\n yield doc if block_given?\n data = doc_to_html(doc)\n end\n data = process_tex(data)\n data.gsub!(/<p><\\/p>/, '')\n data\n end",
"def render_xml\n end",
"def document\n return \"\\\\documentclass{article}\\n\\\\input{Qcircuit}\\n\\\\usepackage[landscape]{geometry}\\n\\\\usepackage{amsmath}\\n\\\\pagestyle{empty}\\n\\\\begin{document}\\n#{@code}\\n\\\\end{document}\"\n end",
"def render\n Node.new.instance_eval(template)\n end",
"def render\n Tilt.new(@file)\n .render(OpenStruct.new(@binds))\n .delete!(\"\\n\")\n end",
"def render_document_view(document, options = {})\n options.symbolize_keys!\n\n # Render based on active_source -- unless an alternative is passed in\n @active_source ||= active_source\n options[:source] ||= @active_source\n\n template = options.delete(:template) || raise('Must specify template')\n formats = determine_formats(document, @active_source, options.delete(:format))\n partial_list = formats.map { |format| \"/_formats/#{format}/#{template}\" }\n\n @add_row_style = options[:style]\n view = render_first_available_partial(partial_list, options.merge(document: document))\n @add_row_style = nil\n\n view\n end",
"def render\n\n\t\t\tcontent = render_object.render\n\n\t\t\tif params[:output_file]\n\t\t\t\tcreate_output_file(content)\n\t\t\telse\n\t\t\t\tputs content\n\t\t\tend\n\n\t\tend",
"def test_render_drawing_object_without_node_path\n remote_file_name = 'TestGetDocumentDrawingObjectByIndexWithFormatWithoutNodePath.docx'\n\n upload_file File.join(local_test_folder, local_file), remote_data_folder + '/' + remote_file_name\n\n request = RenderDrawingObjectRequest.new(name: remote_file_name, format: 'png', index: 0, folder: remote_data_folder)\n\n result = @words_api.render_drawing_object(request)\n assert_equal false, result.nil?\n end",
"def render\n return unless valid?\n Structurograme.new(@document.root, FONT, params[:size].to_i, \n params[:width].to_i).render\n end",
"def save_as(filename)\n document.render_file(filename)\n end",
"def render opts = {}\n renderer.render opts\n end",
"def create_page\n @outfile.puts <<'EOF'\n<!DOCTYPE html>\n<html>\n <head>\n <title>Fun Fun Fun</title>\n <meta charset=\"utf-8\">\nEOF\n\n include_stylesheets\n include_javascript\n add_data(@batch)\n @outfile.puts <<'EOF'\n </head>\n <body>\n <svg class=\"chart\">\n </svg>\n </body>\n</html>\nEOF\n end",
"def render r\n end",
"def render(scope = T.unsafe(nil), locals = T.unsafe(nil)); end",
"def render_evaluate_and_send(options)\n response = render_and_evaluate(options)\n Skates.router.connection.send_xml response \n end",
"def render_to_string(*args, &block)\n options = _normalize_render(*args, &block)\n render_to_body(options)\n end",
"def save_as_xhtml document, filename\n @document = document\n remove_remaining_tags\n FileWriter.write document.to_html, get_full_path(filename.force_html_extension)\n end",
"def render_to_string(*args, &block)\n options = _normalize_render(*args, &block)\n render_to_body(options)\n end",
"def display document\n page do |io|\n text = document.accept formatter(io)\n io.write text\n end\n end",
"def export_to_rtf\n respond_to do |format|\n format.rtf do\n render rtf: @conclusion_draft_review.to_rtf(current_organization),\n filename: @conclusion_draft_review.rtf_name\n end\n end\n end",
"def pretty_print document\n doc = REXML::Document.new document.to_xml\n doc.context[:attribute_quote] = :quote\n out = \"\"\n formatter = REXML::Formatters::Pretty.new\n formatter.compact = true\n formatter.write doc, out\n\n out.strip\n end",
"def to_rtf\n rtf = StringIO.new\n\n # keyword properties\n rtf << \"\\\\shpleft#{@left}\" unless @left.nil?\n rtf << \"\\\\shpright#{@right}\" unless @right.nil?\n rtf << \"\\\\shptop#{@top}\" unless @top.nil?\n rtf << \"\\\\shpbottom#{@bottom}\" unless @bottom.nil?\n rtf << \"\\\\shpz#{@z_index}\" unless @z_index.nil?\n rtf << \"\\\\shpbxpage\" if @horizontal_reference == HORIZONTAL_REFERENCE_DICTIONARY[\"PAGE\"]\n rtf << \"\\\\shpbxmargin\" if @horizontal_reference == HORIZONTAL_REFERENCE_DICTIONARY[\"MARGIN\"]\n rtf << \"\\\\shpbxcolumn\" if @horizontal_reference == HORIZONTAL_REFERENCE_DICTIONARY[\"COLUMN\"]\n rtf << \"\\\\shpbxignore\" unless @vertical_reference.nil?\n rtf << \"\\\\shpbypage\" if @vertical_reference == VERTICAL_REFERENCE_DICTIONARY[\"PAGE\"]\n rtf << \"\\\\shpbymargin\" if @vertical_reference == VERTICAL_REFERENCE_DICTIONARY[\"MARGIN\"]\n rtf << \"\\\\shpbypara\" if @vertical_reference == VERTICAL_REFERENCE_DICTIONARY[\"PARAGRAPH\"]\n rtf << \"\\\\shpbyignore\" unless @vertical_reference.nil?\n rtf << \"\\\\shpwr#{@text_wrap[\"WRAP\"]}\" unless @text_wrap.nil? || @text_wrap[\"WRAP\"].nil?\n rtf << \"\\\\shpwrk#{@text_wrap[\"SIDE\"]}\" unless @text_wrap.nil? || @text_wrap[\"SIDE\"].nil?\n rtf << \"\\\\shpfblwtxt#{@below_text}\" unless @below_text.nil?\n rtf << \"\\\\shplockanchor\" if @lock_anchor\n\n rtf << \"\\n\"\n\n # object properties\n rtf << build_property(\"shapeType\", @type) unless @type.nil?\n rtf << build_property(\"rotation\", @rotation) unless @rotation.nil?\n rtf << build_property(\"posh\", @horizontal_alignment) unless @horizontal_alignment.nil?\n rtf << build_property(\"posrelh\", @horizontal_reference) unless @horizontal_reference.nil?\n rtf << build_property(\"posv\", @vertical_alignment) unless @vertical_alignment.nil?\n rtf << build_property(\"posrelv\", @vertical_reference) unless @vertical_reference.nil?\n rtf << build_property(\"fAllowOverlap\", @allow_overlap) unless @allow_overlap.nil?\n rtf << build_property(\"pctHoriz\", @width) unless @width.nil? || @width_units != '%'\n rtf << build_property(\"pctVert\", @height) unless @height.nil? || @height_units != '%'\n rtf << build_property(\"sizerelh\", @width_reference) unless @width_reference.nil?\n rtf << build_property(\"sizerelv\", @height_reference) unless @height_reference.nil?\n rtf << build_property(\"fFilled\", @has_fill) unless @has_fill.nil?\n rtf << build_property(\"fillColor\", @fill_color) unless @fill_color.nil?\n rtf << build_property(\"fLine\", @has_line) unless @has_fill.nil?\n rtf << build_property(\"lineColor\", @line_color) unless @line_color.nil?\n rtf << build_property(\"lineWidth\", @line_width) unless @line_width.nil?\n rtf << build_property(\"dxTextLeft\", @text_margin_left) unless @text_margin_left.nil?\n rtf << build_property(\"dxTextRight\", @text_margin_right) unless @text_margin_right.nil?\n rtf << build_property(\"dyTextTop\", @text_margin_top) unless @text_margin_top.nil?\n rtf << build_property(\"dyTextBottom\", @text_margin_bottom) unless @text_margin_bottom.nil?\n rtf << build_property(\"anchorText\", @text_anchor) unless @text_anchor.nil?\n rtf << build_property(\"fBehindDocument\", @below_text) unless @below_text.nil?\n rtf << build_property(\"fFitShapeToText\", @fit_to_text) unless @fit_to_text.nil?\n rtf << build_property(\"fFitTextToShape\", @fit_text_to_shape) unless @fit_text_to_shape.nil?\n rtf << build_property(\"fFlipH\", @flip_horizontal) unless @flip_horizontal.nil?\n rtf << build_property(\"fFlipV\", @flip_vertical) unless @flip_vertical.nil?\n rtf << build_property(\"geoLeft\", @path_coordinate_origin[0]) unless @path.nil? || @path_coordinate_origin.nil?\n rtf << build_property(\"geoTop\", @path_coordinate_origin[1]) unless @path.nil? || @path_coordinate_origin.nil?\n rtf << build_property(\"geoRight\", @path_coordinate_limits[0]) unless @path.nil? || @path_coordinate_limits.nil?\n rtf << build_property(\"geoBottom\", @path_coordinate_limits[1]) unless @path.nil? || @path_coordinate_limits.nil?\n rtf << build_property(\"pVerticies\", @path_verticies) unless @path.nil? || @path_verticies.nil?\n rtf << build_property(\"pSegmentInfo\", @path_segment_info) unless @path.nil? || @path_segment_info.nil?\n rtf << build_property(\"pConnectionSites\", @path_connection_sites) unless @path.nil? || @path_connection_sites.nil?\n rtf << build_property(\"fLineOK\", 1)\n rtf << build_property(\"fFillOK\", 1)\n rtf << build_property(\"f3DOK\", 1)\n\n rtf.string\n end",
"def document\n @_data ||= OpenStruct.new(@_renderer.data)\n end",
"def render(scope = T.unsafe(nil), locals = T.unsafe(nil), &block); end",
"def to_s\n if is_xhtml?\n @doc.to_xhtml(:encoding => nil)\n else\n @doc.to_html(:encoding => nil)\n end\n end",
"def render namespace\n context = Context.new(namespace)\n context.push(\n :ruty => RUTY_CONTEXT,\n :nil => nil,\n :true => true,\n :false => false\n )\n result = ''\n @nodelist.render_node(context, result)\n result\n end",
"def render(object = T.unsafe(nil)); end",
"def preview_doc\n @tpl = Template.find(params[\"template_id\"]) \n output = @tpl.render_by_model_id(params[:id], 'print', 'www.freightoperations.com:8080')\n render(:text => output, :layout => false) \n end",
"def to_xhtml()\n nil\n end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def document; end",
"def render(options = {})\n r = renderer(options)\n @options.merge(options)[:header_footer] ? r.render('document', self) : content\n end",
"def render(no_follow = false, encoding = nil, include_levels = 10)\n @sanitize = no_follow ?\n @wiki.history_sanitizer :\n @wiki.sanitizer\n\n @encoding = encoding\n @include_levels = include_levels\n\n data = @data.dup\n data = process_graphviz(data) if @wiki.dot\n filter_chain = @wiki.filter_chain.map do |r|\n Gollum::Filter.const_get(r).new(self)\n end\n\n # Since the last 'extract' action in our chain *should* be the markup\n # to HTML converter, we now have HTML which we can parse and yield, for\n # anyone who wants it\n if block_given?\n yield Nokogiri::HTML::DocumentFragment.parse(data)\n end\n\n process_chain data, filter_chain\n end",
"def render(options = nil, extra_options = {}, &block)\n if params[:format] == 'xml' # dump the view state as XML\n put_xml @view_state\n else\n super options\n end\n end",
"def write_xhtml_to(io, options = T.unsafe(nil)); end",
"def write_xhtml_to(io, options = T.unsafe(nil)); end",
"def render\n generate_content\n @pdf.render\n end",
"def render\n erb_page = ERB.new(content).result(binding)\n Kramdown::Document.new(erb_page).to_html.html_safe\n end",
"def to_s(&block)\n if block_given?\n root.to_s(&block)\n elsif parsed? || should_parse?\n self.class.render root\n else\n @raw\n end\n end",
"def display document\n page do |io|\n f = formatter(io)\n f.width = @width if @width and f.respond_to?(:width)\n text = document.accept f\n\n io.write text\n end\n end",
"def render(&block)\n self.renderer = block\n end",
"def to_pdf\n to_prawn.render\n end",
"def render\n @pdf.render\n end",
"def to_s\n document.xml? ? to_xml : to_html\n end",
"def render(options={}, &block)\n if options[:nothing]\n return \"\" \n end\n \n if options[:text]\n options.reverse_merge!(:render_children => false)\n end\n \n options.reverse_merge! :render_children => true,\n :locals => {},\n :invoke => {},\n :suppress_js => false\n \n \n rendered_children = render_children_for(options)\n \n options[:locals].reverse_merge!(:rendered_children => rendered_children)\n \n @suppress_js = options[:suppress_js] ### FIXME: implement with ActiveHelper and :locals.\n \n \n render_view_for(options, action_name) # defined in Cell::Base.\n end",
"def render(context)\n file = Tempfile.new('')\n file.write(super)\n file.close # close temp file; flush content\n output = `python #{file.path}`\n file.unlink # Delete temp file\n \"<figure><embed src=\\\"#{output}\\\" /></figure>\"\n end",
"def render\n FileUtils.makedirs(directory)\n\n Prawn::Document.generate(filename, page_size: \"A4\") do |pdf|\n pdf.font \"fonts/Aller_Lt.ttf\"\n pdf.font_size 18\n pdf.text \"Invoice number #{@order.order_number}\"\n pdf.move_down 24\n pdf.font_size 10\n pdf.text \"Invoice created at: #{@order.created_at}\"\n pdf.move_down 24\n\n address_top = 700\n\n pdf.bounding_box([0, address_top], width: 200, height: 200) do\n pdf.text \"#{COMPANY_NAME}\\n14 Murrayfield Drive\\nEdinburgh\\nMidlothian\\nEH12 6EB\\nUnited Kingdom\\nCompany no. SC391840\\nVAT no. 111 7832 38\", leading: 4\n end\n\n pdf.bounding_box([300, address_top], width: 200, height: 200) do\n pdf.text(\"Customer:\\n\" + @order.user.business_name + \"\\n\" + @order.address.strip + \"\\n\" + @order.postcode + \"\\n\" + @order.country.to_s + \"\\nCustomer VAT number: #{@order.customer_vat_number}\", leading: 4)\n end\n\n cells = []\n headers = [\"Product\", \"Price\"]\n headers <<= \"Sterling\" if @order.sterling_in_euros\n cells << headers\n @order.order_lines.each do |line|\n cells << [line.description, euros_from_cents(line.amount)]\n end\n tax_line = [@order.tax_description, euros_from_cents(@order.tax_amount)]\n tax_line <<= @order.tax_amount / @order.sterling_in_euros if @order.sterling_in_euros\n cells << tax_line\n total_line = [\"Order total:\", euros_from_cents(@order.total)]\n total_line <<= @order.total / @order.sterling_in_euros if @order.sterling_in_euros\n cells << total_line\n\n t = Prawn::Table.new(cells, pdf)\n t.draw\n\n if @order.sterling_in_euros\n pdf.move_down 24\n pdf.text \"1 GBP = #{@order.sterling_in_euros} EUR\"\n end\n\n logopath = \"#{Rails.root}/public/images/my-chalet-finder-logo.png\"\n pdf.bounding_box([300, 770], width: 126, height: 22) do\n pdf.image logopath, width: 126, height: 22\n end\n end\n end",
"def show\n\tcnv = ODT_to_XHTML.new\n\txmldata = cnv.get_html(@document.content, @document.styles)\n\t@head = xmldata[:head].get_text(\"style\")\n\t@body = xmldata[:body].to_s.sub(/<body>/,\"<div class=\\\"document\\\">\").sub(/<\\/body>/,\"</div>\")\n end",
"def render(options = T.unsafe(nil), locals = T.unsafe(nil), &block); end",
"def renderer; end",
"def render( render_state )\n\t\traw = super\n\t\tbuf = String.new( '' )\n\t\tPP.pp( raw, buf )\n\t\treturn self.escape( buf.chomp, render_state )\n\tend",
"def to_xhtml(options = T.unsafe(nil)); end",
"def to_xhtml(options = T.unsafe(nil)); end",
"def to_rtf(document, options = {})\n # load default options\n options = {\n \"uglify\" => false,\n \"base_indent\" => 0\n }.merge(options)\n # build formatting helpers\n base_prefix = options[\"uglify\"] ? '' : ' '*options[\"base_indent\"]\n name_prefix = options[\"uglify\"] ? ' ' : ''\n suffix = options[\"uglify\"] ? '' : ' '\n\n rtf = StringIO.new\n\n rtf << base_prefix\n rtf << \"{\\\\*\\\\ds#{handle}#{suffix}\"\n rtf << \"#{rtf_formatting(document)}#{suffix}\"\n rtf << \"\\\\additive#{suffix}\" if @additive\n rtf << \"\\\\sbasedon#{@based_on_style_handle}#{suffix}\" unless @based_on_style_handle.nil?\n rtf << \"\\\\sautoupd#{suffix}\" if @auto_update\n rtf << \"\\\\snext#{@next_style_handle}#{suffix}\" unless @next_style_handle.nil?\n rtf << \"\\\\sqformat#{suffix}\" if @primary\n rtf << \"\\\\spriority#{@priority}#{suffix}\" unless @priority.nil?\n rtf << \"\\\\shidden#{suffix}\" if @hidden\n rtf << \"#{name_prefix}#{name};}\"\n\n rtf.string\n end",
"def render\n \n raise \"files not specified\" if self.files.empty?\n \n self.xml.instruct! :xml, version: \"1.0\", encoding: \"UTF-8\"\n self.xml.metalink( xmlns: \"urn:ietf:params:xml:ns:metalink\" ) do |metalink|\n \n metalink.generator(\"Sudrien/metalink-ruby 0.2.0\") #may\n metalink.origin( self.origin, dynamic: self.origin_dynamic ) if self.origin\n \n metalink.published( self.published.strftime('%FT%T%:z') ) if self.published\n metalink.updated( self.updated.strftime('%FT%T%:z') ) if self.updated\n \n self.files.each do |file|\n file.render(self, metalink)\n end\n end\n self.xml.target!\n end",
"def parse\n return @document if @document\n\n @document = super @text, @format\n @document.file = @location\n @document\n end",
"def render_dryml(view, local_assigns = {})\n stack = view.instance_variable_get(:@_render_stack)\n stack.push(self)\n\n # This is only used for TestResponse to set rendered_template\n unless is_a?(ActionView::InlineTemplate) || view.instance_variable_get(:@_first_render)\n view.instance_variable_set(:@_first_render, self)\n end\n\n view.send(:_evaluate_assigns_and_ivars)\n view.send(:_set_controller_content_type, mime_type) if respond_to?(:mime_type)\n\n result = Hobo::Dryml::TemplateHandler.new.render_for_rails22(self, view, local_assigns)\n\n stack.pop\n result\n end",
"def to_rdf\n self\n end",
"def to_tex_file\n check_security!\n\n Dir.mktmpdir(ident) do |output_directory|\n tex_path = File.join(output_directory, ident + '.tex')\n File.open(tex_path, 'w') { |f| f.puts wrapped_equation }\n yield tex_path\n File.unlink tex_path\n end\n end",
"def text(node)\r\n RenderErb.(erb: TEMPLATE, object: node)\r\n end",
"def render_to_body(options); end",
"def to_latex_document\n body = to_latex\n\n if get_setting(:maruku_signature)\n body << render_latex_signature\n end\n\n required = self.latex_required_packages.map do |p|\n \"\\\\usepackage{#{p}}\\n\"\n end.join\n\n #=begin maruku_doc\n # Attribute: latex_cjk\n # Scope: document\n # Output: latex\n # Summary: Support for CJK characters.\n #\n # If the `latex_cjk` attribute is specified, then appropriate headers\n # are added to the LaTeX preamble to support Japanese fonts.\n # You have to have these fonts installed -- and this can be a pain.\n #\n # If `latex_cjk` is specified, this is added to the preamble:\n #\n # <?mrk puts \"ciao\" ?>\n #\n # <?mrk md_codeblock(Maruku::MDDocument::Latex_preamble_enc_cjk) ?>\n #\n #\n # while the default is to add this:\n #\n # <?mrk md_codeblock(Maruku::MDDocument::Latex_preamble_enc_utf8) ?>\n #\n #=end\n\n encoding = get_setting(:latex_cjk) ? Latex_preamble_enc_cjk : Latex_preamble_enc_utf8\n\n #=begin maruku_doc\n # Attribute: latex_preamble\n # Scope: document\n # Output: latex\n # Summary: User-defined preamble.\n #\n # If the `latex_preamble` attribute is specified, then its value\n # will be used as a custom preamble.\n #\n # For example:\n #\n # Title: My document\n # Latex preamble: preamble.tex\n #\n # will produce:\n #\n # ...\n # \\input{preamble.tex}\n # ...\n #\n #=end\n\n user_preamble = (file = @doc.attributes[:latex_preamble]) ? \"\\\\input{#{file}}\\n\" : \"\"\n\n \"\\\\documentclass{article}\n\n% Packages required to support encoding\n#{encoding}\n\n% Packages required by code\n#{required}\n\n% Packages always used\n\\\\usepackage{hyperref}\n\\\\usepackage{xspace}\n\\\\usepackage[usenames,dvipsnames]{color}\n\\\\hypersetup{colorlinks=true,urlcolor=blue}\n\n#{user_preamble}\n\n\\\\begin{document}\n#{body}\n\\\\end{document}\n\"\n end",
"def renderer r\n @renderer = r\n end",
"def renderer r\n @renderer = r\n end",
"def show\n respond_to do |format|\n format.html {}\n format.json {}\n format.rdf { render rdf: @paper }\n end\n end",
"def render(model, &content)\n template = Neapolitan.file(path, :stencil=>site.config.stencil)\n\n # update the model's metadata\n #model.update(template.metadata)\n\n result = template.render(model, &content).to_s\n\n layout_name = template.metadata['layout']\n\n if layout_name\n layout = site.lookup_layout(layout_name)\n\n raise \"No such layout -- #{layout}\" unless layout\n\n result = layout.render(model){ result }\n end\n\n result.to_s\n end"
] | [
"0.6253246",
"0.6128175",
"0.6103045",
"0.58074194",
"0.56445646",
"0.5542434",
"0.54631513",
"0.5391891",
"0.535961",
"0.5296519",
"0.5257945",
"0.5233452",
"0.51590407",
"0.50982",
"0.5094695",
"0.49739802",
"0.4929019",
"0.49227482",
"0.49211338",
"0.49209684",
"0.4917407",
"0.48977822",
"0.48922902",
"0.4880042",
"0.4876657",
"0.48739135",
"0.4872339",
"0.4872097",
"0.48617044",
"0.48485038",
"0.48419464",
"0.48368928",
"0.4834666",
"0.48297587",
"0.48264086",
"0.48168707",
"0.48164368",
"0.48088664",
"0.4808612",
"0.48040557",
"0.48003656",
"0.479987",
"0.47669074",
"0.47615403",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47556922",
"0.47541404",
"0.4752188",
"0.4750912",
"0.4749874",
"0.4749874",
"0.47449493",
"0.4741913",
"0.473827",
"0.47316194",
"0.47242564",
"0.47236356",
"0.47179896",
"0.4713125",
"0.4704862",
"0.4701198",
"0.46984187",
"0.46983737",
"0.46977678",
"0.4694463",
"0.46934247",
"0.46841943",
"0.46841943",
"0.4674525",
"0.46603858",
"0.46602893",
"0.46453837",
"0.46410322",
"0.46399838",
"0.46367636",
"0.463373",
"0.46235937",
"0.46233365",
"0.46233365",
"0.4619187",
"0.46130627"
] | 0.53232867 | 9 |
Override render_subject to look for a :rel template if this is a relation. In which case, we'll also pass the typeof the referencing resource | def render_subject(subject, predicates, options = {}, &block)
options = options.merge(:haml => haml_template[:rel]) if options[:rel] && haml_template[:rel]
super(subject, predicates, options) do |predicate|
if predicate.is_a?(Symbol)
# Special snippet processing
# Render associated properties with associated or default formatting
case predicate
when :other
props = predicates.map(&:to_s)
props -= haml_template[:title_props] || []
props -= haml_template[:body_props] || []
props -= haml_template[:description_props] || []
format = lambda {|list| list.map {|e| yield(e)}.join("")}
when :other_nested
props = predicates.map(&:to_s)
props -= haml_template[:nested_props] || []
format = lambda {|list| list.map {|e| yield(e)}.join("")}
else
# Find appropriate entires from template
props = haml_template["#{predicate}_props".to_sym]
add_debug "render_subject(#{subject}, #{predicate}): #{props.inspect}"
format = haml_template["#{predicate}_fmt".to_sym]
end
unless props.nil? || props.empty?
format ||= lambda {|list| list.map {|e| yield(e)}.join("")}
format.call(props, &block)
end
else
yield(predicate)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rel_type\n getType().name()\n end",
"def get_resource_templates\n @model.get.mixins.select { |mixin| mixin.related.select { |rel| rel.end_with? 'resource_tpl' }.any? }\n end",
"def part_of_title_by_type(resource_type)\n if self.type == resource_type\n self.title\n elsif self.is_part_of && self.is_part_of.type == resource_type\n self.is_part_of.title\n else\n nil\n end\n end",
"def render subject,\n repo: nil, graph: nil, type: nil, language: nil, rewriter: nil\n repo ||= @repo\n # process type\n # process language\n\n # retrieve forward and reverse structs from repo\n # retrieve yr mom\n end",
"def render_subject(subject, predicates, **options, &block)\n options = options.merge(haml: @prev_templ[:rel]) if options[:rel] && @prev_templ[:rel]\n @prev_templ = haml_template\n super(subject, predicates, **options) do |predicate|\n if predicate.is_a?(Symbol)\n # Special snippet processing\n # Render associated properties with associated or default formatting\n case predicate\n when :other\n props = predicates.map(&:to_s)\n props -= haml_template[:title_props] || []\n props -= haml_template[:body_props] || []\n props -= haml_template[:description_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n when :other_nested\n props = predicates.map(&:to_s)\n props -= haml_template[:nested_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n else\n # Find appropriate entires from template\n props = haml_template[\"#{predicate}_props\".to_sym]\n log_debug \"render_subject(#{subject}, #{predicate}): #{props.inspect}\"\n format = haml_template[\"#{predicate}_fmt\".to_sym]\n end\n unless props.nil? || props.empty?\n format ||= lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n format.call(props, &block)\n end\n else\n yield(predicate)\n end\n end\n end",
"def render_belongs_to(profile)\n context = @context || params[:context] || \"network\"\n if profile.user_profile?\n return render_workgroup_link(profile.user.workgroup_user.workgroup, context) if profile.user and profile.user.workgroup_user and profile.user.workgroup_user.workgroup\n else\n return render_physician_links(profile.workgroup, context) if profile.workgroup\n end\n\n return \"\"\n end",
"def linkify(*args)\n if args.first.is_a?(String)\n case args.first\n when /^render:(\\S+)/\n old_type = options.delete(:type)\n output = super\n options.type = old_type\n return output\n end\n end\n super\n end",
"def rel? kind\n rel.include? kind\n end",
"def load_type\n :relation\n end",
"def partial\n mod = self.class.name.split(\"::\")[-2]\n partial_name = ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self.class.name))\n File.join(STREAMLINED_TEMPLATE_ROOT, \"relationships/#{mod.underscore}/_#{partial_name}.rhtml\")\n end",
"def part_title_by_type(resource_type)\n if self.type == resource_type\n self.title\n elsif self.has_part && self.has_part.type == resource_type\n self.has_part.title\n else\n nil\n end\n end",
"def render_related_resource_language(presenter)\n return nil if presenter.related_resource.empty?\n\n is_multiple = presenter.related_resource.count > 1\n translation_key = \"spot.collections.show.related_resource_#{is_multiple ? 'multiple' : 'single'}\"\n\n links = presenter.related_resource.map { |url| link_to(url, url, target: '_blank').html_safe }\n t(translation_key, link_html: links.to_sentence).html_safe\n end",
"def get_source_relationship(options)\n options[:relationship]&.to_sym || @request.resource_klass._type\n end",
"def linked_issues\n @matter = Matter.find(params[:id])\n @matter_issues = @matter.matter_issues\n @issue_type = params[:issue_type]\n @path = params[:path]\n case @issue_type\n when 'matter_research'\n object = MatterResearch.find(params[:matter_research_id])\n when 'matter_fact'\n object = MatterFact.find(params[:matter_fact_id])\n when 'matter_risk'\n object = MatterRisk.find(params[:matter_risk_id])\n when 'document_home'\n object = DocumentHome.find(params[:matter_document_id])\n end\n @submodel = object\n @matter_issueid = object.matter_issues.find(:all, :select => ['id']).collect{|a| a.id}\n if params[:link] \n object.link_submodule(params, :matter_issue_ids)\n redirect_to params[:path]\n else\n render :partial => \"linked_issues\", :layout => false\n end\n end",
"def render_content_type_partial(object, engage)\n if engage == false\n if object.class.name == \"Job\"\n render 'website/jobs/job', job: object\n elsif object.class.name == \"Post\"\n render 'website/posts/post', post: object\n elsif object.class.name == \"Offer\"\n render 'website/offers/offer', offer: object\n elsif object.class.name == \"BeforeAfter\"\n render 'website/before_afters/before_after', before_after: object\n elsif object.class.name == \"Gallery\"\n render 'website/galleries/gallery', gallery: object\n elsif object.class.name == \"Event\"\n render 'website/events/event', event: object\n elsif object.class.name == \"EventDefinition\"\n render 'website/event_definitions/event_definition', event_definition: object\n elsif object.class.name == \"QuickPost\"\n render 'website/quick_posts/quick_post', quick_post: object\n end\n elsif engage == true\n # if object.class.name == \"Job\"\n # render 'listing/listings/job', job: object\n if object.class.name == \"Post\"\n render 'listing/listings/post', post: object\n elsif object.class.name == \"Offer\"\n render 'listing/listings/offer', offer: object\n elsif object.class.name == \"BeforeAfter\"\n render 'listing/listings/before_after', before_after: object\n elsif object.class.name == \"Gallery\"\n render 'listing/listings/gallery', gallery: object\n elsif object.class.name == \"Event\"\n render 'listing/listings/event', event: object\n elsif object.class.name == \"EventDefinition\"\n render 'listing/listings/event_definition', event_definition: object\n elsif object.class.name == \"QuickPost\"\n render 'listing/listings/quick_post', quick_post: object\n end\n end\n end",
"def resource_belongs_to(subject, resource_helper: true, urls: true, **options)\n resource_helper(subject) if resource_helper\n collection = options[:collection] || resource_class.model_name.plural\n source_relation_proc = BelongsTo.source_relation(subject, collection, options)\n protected define_method(:source_relation, &source_relation_proc)\n protected define_method(:index_url, &BelongsTo.index_url(subject, urls)) if urls\n end",
"def relationship_tag(rel_attr); end",
"def set_reltype\n @reltype = Reltype.find(params[:id])\n end",
"def render_issue_relations(issue, relations)\n manage_relations = User.current.allowed_to?(:manage_issue_relations, issue.project)\n s = ''.html_safe\n relations.each do |relation|\n other_issue = relation.other_issue(issue)\n css = \"issue hascontextmenu #{other_issue.css_classes}\"\n buttons =\n if manage_relations\n link_to(\n l(:label_relation_delete),\n relation_path(relation),\n :remote => true,\n :method => :delete,\n :data => {:confirm => l(:text_are_you_sure)},\n :title => l(:label_relation_delete),\n :class => 'icon-only icon-link-break'\n )\n else\n \"\".html_safe\n end\n buttons << link_to_context_menu\n s <<\n content_tag(\n 'tr',\n content_tag('td',\n check_box_tag(\n \"ids[]\", other_issue.id,\n false, :id => nil),\n :class => 'checkbox') +\n content_tag('td',\n relation.to_s(@issue) {|other|\n link_to_issue(\n other,\n :project => Setting.cross_project_issue_relations?)\n }.html_safe,\n :class => 'subject',\n :style => 'width: 50%') +\n content_tag('td', other_issue.status, :class => 'status') +\n content_tag('td', format_date(other_issue.start_date), :class => 'start_date') +\n content_tag('td', format_date(other_issue.due_date), :class => 'due_date') +\n content_tag('td', link_to_user(other_issue.assigned_to), :class => 'assigned_to') +\n content_tag('td',\n (if other_issue.disabled_core_fields.include?('done_ratio')\n ''\n else\n progress_bar(other_issue.done_ratio)\n end),\n :class=> 'done_ratio') +\n content_tag('td', buttons, :class => 'buttons'),\n :id => \"relation-#{relation.id}\",\n :class => css)\n end\n content_tag('table', s, :class => 'list issues odd-even')\n end",
"def get_relation(ref_key)\n if @generic_relations_store.key?(ref_key)\n\n if @generic_relations_store[ref_key]['relationsubject']\n gr_subject = @generic_relations_store[ref_key]['relationsubject'].match('^http://d.opencalais.com') ?\n get_entity(@generic_relations_store[ref_key]['relationsubject']) :\n @generic_relations_store[ref_key]['relationsubject']\n else\n gr_subject = 'N/A'\n end\n\n\n if @generic_relations_store[ref_key]['relationobject']\n gr_object = @generic_relations_store[ref_key]['relationobject'].match('^http://d.opencalais.com') ?\n get_entity(@generic_relations_store[ref_key]['relationobject']) :\n @generic_relations_store[ref_key]['relationobject']\n else\n gr_object = 'N/A'\n end\n\n GenericRelation.new(gr_subject,\n @generic_relations_store[ref_key]['verb'],\n gr_object,\n @generic_relations_store[ref_key]['instances'][0]['exact'] ||= 'N/A')\n else\n nil\n end\n end",
"def replacer\n lambda do |resource_id, graph|\n url = Hyrax::Base.id_to_uri(resource_id)\n klass = graph.query([:s, ActiveFedora::RDF::Fcrepo::Model.hasModel, :o]).first.object.to_s.constantize\n\n # if the subject URL matches\n if graph.query([RDF::URI(url), ActiveFedora::RDF::Fcrepo::Model.hasModel, nil]).first\n subject_replacer(klass, resource_id)\n elsif resource_id.start_with? solr_document.id\n subresource_replacer(resource_id, klass)\n else\n object_replacer(resource_id, graph)\n end\n end\n end",
"def linked_facts\n @matter = Matter.find(params[:id])\n @matter_facts = @matter.matter_facts\n @fact_type = params[:fact_type]\n @path = params[:path]\n case @fact_type\n when 'matter_research'\n object = MatterResearch.find(params[:matter_research_id])\n when 'document_home'\n object = DocumentHome.find(params[:matter_document_id])\n end\n @submodel = object\n @matter_factid = object.matter_facts.find(:all, :select => ['id']).collect{|a| a.id}\n if params[:link]\n object.link_submodule(params, :matter_fact_ids)\n redirect_to params[:path]\n else\n render :partial => \"linked_facts\", :layout => false\n end\n end",
"def relation_type(identifier:)\n return 'isReferencedBy' unless identifier.present? && identifier.descriptor.present?\n # Due to a conflict between ActiveRecord's 'references' method we store that\n # descriptor as 'does_reference'\n return 'References' if identifier.descriptor == 'does_reference'\n\n identifier.descriptor.to_s.split('_').map(&:capitalize).join\n end",
"def resource_type\n document_type\n end",
"def resource_type\n document_type\n end",
"def render_resources\n render partial: resource_name, collection: resources_instance_variable\n rescue ActionView::MissingTemplate\n render partial: \"resource\", collection: resources_instance_variable\n end",
"def display_resource(ticket_type)\n \"#{ticket_type.name}\"\n end",
"def render(options={}, result=Result.new)\n name = options[:as] || wrapped_model_name.underscore\n result[name] = view = self.view\n _include_associations(result, view, options[:include])\n end",
"def subject\n adapter.id_to_uri(resource.id) if resource.try(:id)\n end",
"def relation_subjects(record)\n query = ActiveFedora::SolrQueryBuilder.construct_query_for_rel(\n [[:has_model, proxy_class.to_rdf_representation], [:proxyFor, record.id]]\n )\n rows = ActiveFedora::SolrService::MAX_ROWS\n ActiveFedora::SolrService.query(query, fl: 'id', rows: rows).map(&:rdf_uri)\n end",
"def reference_resource\n return super if defined?(super)\n\n raise NotImplementedError\n end",
"def type\n if entity.respond_to?(:resource_type)\n entity.resource_type\n else\n entity.class\n end.to_s\n end",
"def related?\n self.rel == \"related\"\n end",
"def link_for(type)\n if link = self.links.find { |link| link.type == type }\n link.to_s\n end\n end",
"def render_resources\n render :partial => resource_name, :collection => resources_instance_variable\n rescue ActionView::MissingTemplate\n render :partial => 'resource', :collection => resources_instance_variable\n end",
"def handle_association_links\n @type = @normalized_type = @subtype\n obj = model.with_pk(@type, request, request.id)\n association_links(obj)\n end",
"def getResourceType() \n @obj.getResourceType() \n end",
"def relation(associated_resource)\n if associated_resource && associated_resource.object\n name = associated_resource.as || plural_name\n associated_resource.klass.reflect_on_association(name) ? \n associated_resource.object.send(name) : associated_resource.object.send(klass.to_s.demodulize.underscore.pluralize)\n else\n klass\n end\n end",
"def related\n @work = Work.find(params[:id])\n mode = params[:mode]\n logger.debug \"MODE:#{mode}\"\n \n retrieve_frbr_objects_using_mode(@work, \"frbr_\"+mode) #hide frbr_ from URL\n @sub_partial_path = \"shared/frbr/objects/full/work/frbr_list_wrapper\"\n end",
"def find_by_rel(matching_rel)\n resource_templates.select{|resource_template| matching_rel === resource_template.rel}\n end",
"def resolve(resource, position: :subject)\n case position\n when :subject\n RDF::Literal(as_literal(resource.first).to_s, datatype: resource.last)\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def template_for(post)\n render(\n :partial => \"#{post.type.pluralize}/#{post.type}\",\n :locals => { :post => post }\n )\n end",
"def subject\n subtype_instance\n end",
"def render_document(subjects, options = {})\n super(subjects, options.merge(:extracted => graph.dump(:rdfa, :haml => RDF::Linter::TABULAR_HAML))) do |subject|\n yield(subject) if block_given?\n end\n end",
"def relation(rel, &relation_definition)\n raise NotImplementedError, 'relation is not supported yet'\n end",
"def resource\n return Object unless resource_type\n return resource_type.constantize unless resource_id\n return _resource\n end",
"def resourceType\n 'Person'\n end",
"def related_objects_by_type(related_str)\n rels = Relationship.all(:conditions => [\"subject_type = ? and object_type = ? and object_id =? \",\n related_str, self.class.name, self.id] )\n \n related_str.constantize.find(rels.collect{ |r| r.subject_id})\n end",
"def render(what, *args, &blk)\n case what\n when NilClass then ''\n when String then render_template(what, *args, &blk)\n when Enumerable then what.map { |i| render(i, *args, &blk) }.join\n else render_resource(what, *args)\n end\n end",
"def transform_Resource(o, scope)\n Types::TypeFactory.resource(o.type, o.title)\n end",
"def href\n to_polymorphic_args\n end",
"def type_objects\n pre = Prereq.new(:need_type => params[:type])\n pre.id = params[:id].to_i\n respond_to do |format|\n format.js {render :partial => 'prereqs/prereq_items_by_type', :locals => {:prereq => pre}}\n end\n end",
"def render_resource(r)\n data = {\n \"title\" => r[:title],\n \"content\" => r.html\n }\n\n populate(data)\n end",
"def to_partial_path\n \"/fields/belongs_to/#{page}\"\n end",
"def relation_filter_for_relation_type(relation_type)\n self.class.relation_filter_for_relation_type(relation_type)\n end",
"def resource_singular() self.class.read_inheritable_attribute(:resource_singular) end",
"def render_partial(template, types, context)\n templates.get(template, types).render(context)\n end",
"def rel_type=(value)\n @children['rel-type'][:value] = value\n end",
"def resolve(resource, position: :subject)\n case position\n when :subject\n RDF::Literal(as_literal(resource.first).to_s, language: resource.last.to_s.to_sym)\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def method_missing(m, *args, &block)\n if m.to_s =~ /^to_(\\w+)$/\n renderer = m.to_s.split('_')[1]\n renderer = renderer[0].upcase + renderer[1..-1]\n try_require(renderer)\n render(renderer)\n else\n super\n end\n end",
"def linked_risks\n @matter = Matter.find(params[:id])\n @matter_risks = @matter.matter_risks\n @risk_type = params[:risk_type]\n @path = params[:path]\n case @risk_type\n when 'matter_research'\n object = MatterResearch.find(params[:matter_research_id])\n when 'document_home'\n object = DocumentHome.find(params[:matter_document_id])\n end\n @submodel = object\n @matter_riskid = object.matter_risks.find(:all, :select => ['id']).collect{|a| a.id}\n if params[:link]\n object.link_submodule(params, :matter_risk_ids)\n redirect_to params[:path]\n else\n render :partial => \"linked_risks\", :layout => false\n end\n end",
"def visit_reference(binding_type)\n visit(binding_type.resolved_type)\n end",
"def linked_tasks\n @matter = Matter.find(params[:id])\n @matter_tasks = @matter.matter_tasks\n @task_type = params[:task_type]\n @path = params[:path]\n case @task_type\n when 'matter_research'\n object = MatterResearch.find(params[:matter_research_id])\n when 'document_home'\n object = DocumentHome.find(params[:matter_document_id])\n end\n @submodel = object\n @matter_taskid = object.matter_tasks.find(:all, :select => ['id']).collect{|a| a.id}\n if params[:link]\n object.link_submodule(params, :matter_task_ids)\n redirect_to params[:path]\n else\n render :partial => \"linked_tasks\", :layout => false\n end\n end",
"def representer_klass\n resource_module::Representer::Resource\n end",
"def add_relation\n rel = @bib.relation.detect { |r| r.type == \"partOf\" }\n if rel\n title_main = rel.bibitem.title.detect { |t| t.type == \"main\" }\n @item.booktitle = title_main.title.content\n end\n end",
"def render_edit_field_partial_with_action(record_type, field_name, locals)\n partial = find_edit_field_partial(record_type, field_name)\n render partial, locals.merge(key: field_name)\n end",
"def has_one(rel_type)\n\n module_eval(%Q{def #{rel_type}=(value)\n r = Relations::HasN.new(self,'#{rel_type.to_s}')\n r << value\n end}, __FILE__, __LINE__)\n \n module_eval(%Q{def #{rel_type}\n r = Relations::HasN.new(self,'#{rel_type.to_s}')\n r.to_a[0]\n end}, __FILE__, __LINE__)\n relations_info[rel_type] = Relations::RelationInfo.new\n end",
"def haml_object_ref\n model.class.to_s.underscore\n end",
"def resource_path_for_entity(entity)\n check_property_value(entity.properties, :type)\n resource_path_for_entity_type(entity.properties[:type])\n end",
"def resource_type\n return @resource_type\n end",
"def resource_type\n return @resource_type\n end",
"def resource_type\n return @resource_type\n end",
"def resource_type\n return @resource_type\n end",
"def to_resource_declaration(type)\n if type.respond_to?(:type_name) && type.respond_to?(:title)\n title = type.title\n type_name = type.type_name\n elsif type_result = /(\\w+)\\['?(\\w+)'?\\]/.match(type.to_s)\n # not all types have a type_name and title so we\n # output to a string and parse the results\n title = type_result[2]\n type_name = type_result[1]\n else\n return type\n end\n res = scope.catalog.resource(type_name, title)\n return res.to_ral if res\n # don't return anything or returns nil if item is not in the catalog\n end",
"def to_partial_path() \n \"activities/#{target_type.downcase}\" \n end",
"def show\n\t\tshow_\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml { render :xml => @relation }\n\t\tend\n\tend",
"def relation\n raise NotImplementedError\n end",
"def serialize_resource(resource)\n link_id, link_type = link_id_and_type(resource)\n\n linkage = if link_id\n {\n inverse_id => link_id,\n :type => link_type\n }\n else\n nil\n end\n\n {\n linkage: linkage,\n related: url_for(resource)\n }\n end",
"def rdfa_relation(name,tag,relation,options={})\n property_value = relation\n property_uri = name\n property_datatype = options[:datatype]\n if(name.instance_of?(Symbol))\n key = self.class.resource_mapping.keys.detect do |k|\n k == name\n end\n raise Exception.new(\"Unknown rdfa property #{name} for object #{self}\") if key.nil?\n property_uri = \"#{SemanticResource::Configuration.namespaces_map[self.class.resource_mapping[key].first]}#{self.class.resource_mapping[key].last}\"\n end\n options.delete(:datatype)\n\n rdfa = StringIO.new\n\n rdfa << \"<#{tag} rel='#{property_uri}'\"\n rdfa << \" href='#{property_value}'\"\n\n options.each_pair do |k,v|\n rdfa << \"#{k}='#{v}' \"\n end\n if(block_given?)\n rdfa << \">\"\n rdfa << yield if block_given?\n rdfa << \"</#{tag}>\"\n else\n rdfa << \" />\"\n end\n\n rdfa.string\n end",
"def type_link(type)\n type ? \"<a href='/types/#{type}'>#{type.upcase}</a>\" : ''\n end",
"def find_relation\n if relation_name.present?\n self.relation = Relation.mode(sender_subject.class.to_s,\n receiver_subject.class.to_s).\n find_by_name(relation_name)\n end\n end",
"def subresources\n if any?\n { collection_rel => self }\n else\n {}\n end\n end",
"def relation_name\n klass.relation\n end",
"def is_resource\n return self.resource_type == Resource::RESOURCE;\n end",
"def to_s\n \"Relview #{name} #{definition.inspect}\"\n end",
"def polymorphic_url(record_or_hash_or_array, options = {})\n { href: @controller.polymorphic_url(record_or_hash_or_array, options = {}) }\n end",
"def render_link_rel_alternates(document=@document, options = {})\n return if document.nil?\n presenter(document).link_rel_alternates(options)\n end",
"def relation_of(field)\n meta = meta_of(field)\n meta ? meta.relation : nil\n end",
"def show\n if params[:show_temporally_related] == \"true\"\n @temporally_related = Document.find(:all, \n :from => \"/documents/#{@document.id}/temporally_related\"\n )\n end\n respond_to do |wants|\n wants.html # show.html.erb\n wants.xml { render :xml => @document }\n wants.json { render :json => @document }\n end\n end",
"def render\n content_tag :a, subject.title, render_options\n end",
"def rel; end",
"def as_resource(options = {})\n links = self_link\n\n if is_collection?\n links[:web] = {\n :href => \"#{@@web_url}/#{pk}\"\n }\n end\n \n resource = {\n :id => pk,\n :accession => objectnumber,\n :sort_number => sortnumber,\n :sort_title => sort_title,\n :sort_name => sort_name,\n :constituents => constituents.map {\n |c| c.as_resource({'no_objects' => true, 'no_bio' => true})\n },\n :titles => titles.as_resource,\n :series => series == nil ? nil : series.as_resource,\n :dates => date_resource(datebegin, dateend, dated),\n :sites => sites.count > 0 ? sites.map {\n |s| s.as_resource({'no_objects' => true})} : nil,\n :movements => movements.count > 0 ? movements.map {\n |m| m.as_resource({'no_objects' => true})} : nil,\n :acquisition => acquisition != nil ? \n acquisition.as_resource({'no_objects' => true}) : nil,\n :exhibitions => exhibitions.count > 0 ? exhibitions.map {\n |e| {\n :location => location(e.pk) != nil ? location(e.pk).as_resource : nil,\n :exhibition => e.as_resource({'no_objects' => true})\n }\n } : nil,\n :edition => edition,\n :medium => medium,\n :dimensions => dimensions,\n :credit => creditline,\n :has_essay => has_essay?,\n :has_extended_label => has_essay?,\n :copyright => copyright,\n :current_location => current_location == nil ? \n nil : current_location.as_resource,\n :media => media.count > 0 ? media.map { |m|\n m.as_resource\n } : nil,\n :object_types => object_types.count > 0 ? object_types.map { |t|\n t.as_resource({'no_objects' => true})\n } : nil,\n :permanent_collection => permanent_collection?,\n :recent_acquisition => is_recent_acquisition?,\n :_links => links\n }\n\n if options['no_essay'] != 'true'\n resource[:essay] = essay\n resource[:extended_label] = extended_label\n end\n\n return resource\n end",
"def set_relation_type\n @relation_type = RelationType.find(params[:id])\n @project = @relation_type.project\n end",
"def get_relations_referring_to_object(type, id)\n api_call_with_type(type, id, \"#{type}/#{id}/relations\")\n end",
"def resource_type\n :collection if collection?\n end",
"def resource_type\n :collection if collection?\n end",
"def _type\n @link['type']\n end",
"def resourceType\n 'Patient'\n end",
"def resourceType\n 'Patient'\n end",
"def render_node(node)\n instance_variable_set(\"@#{node.class.name.singularize.underscore}\", node)\n render :template => \"#{node.class.name.tableize}/show\"\n rescue ActionView::MissingTemplate\n render :template => \"nodes/show\"\n end"
] | [
"0.5615752",
"0.5476091",
"0.5431551",
"0.54190505",
"0.53665394",
"0.53199923",
"0.53156286",
"0.528927",
"0.5266104",
"0.52639693",
"0.5240948",
"0.5223452",
"0.5221651",
"0.5201447",
"0.51953125",
"0.51744705",
"0.5148638",
"0.5144806",
"0.5121389",
"0.5102442",
"0.5046121",
"0.5043097",
"0.5025729",
"0.4989048",
"0.4989048",
"0.4977413",
"0.49715182",
"0.496831",
"0.49628603",
"0.4949386",
"0.49471527",
"0.4927541",
"0.4896946",
"0.4891722",
"0.48881632",
"0.4888147",
"0.48866835",
"0.48773274",
"0.48636335",
"0.4852652",
"0.4838222",
"0.48306885",
"0.48229623",
"0.48213094",
"0.48195618",
"0.48180097",
"0.48090756",
"0.4804856",
"0.47862667",
"0.4775666",
"0.4773024",
"0.4772666",
"0.47691533",
"0.47584823",
"0.4756818",
"0.4754407",
"0.47518015",
"0.47418413",
"0.47264338",
"0.47243842",
"0.4719695",
"0.4709794",
"0.47097144",
"0.4704219",
"0.46985146",
"0.46960896",
"0.46946737",
"0.4680497",
"0.46765074",
"0.4674763",
"0.4674763",
"0.4674763",
"0.4674763",
"0.4673993",
"0.46738073",
"0.46721905",
"0.4653515",
"0.4646333",
"0.46458533",
"0.4641967",
"0.46416017",
"0.4636061",
"0.46292165",
"0.4620906",
"0.46201566",
"0.46189153",
"0.46156535",
"0.46094865",
"0.4601181",
"0.45970702",
"0.45962778",
"0.45938548",
"0.45935446",
"0.4588023",
"0.45869377",
"0.45869377",
"0.45847628",
"0.45809692",
"0.45809692",
"0.4573959"
] | 0.5366286 | 5 |
Override order_subjects to prefer subjects having an rdf:type Subjects are first sorted in topographical order, by highest (lowest numerical) snippet priority. | def order_subjects
subjects = super
add_debug "order_subjects: #{subjects.inspect}"
# Order subjects by finding those with templates, and then by the template priority order
prioritized_subjects = []
other_subjects = []
subjects.each do |s|
template = find_template(s)
next unless template
priority = template[:priority] || 99
add_debug " priority(#{s}) = #{priority}"
prioritized_subjects[priority] ||= []
prioritized_subjects[priority] << s
end
ordered_subjects = prioritized_subjects.flatten.compact
other_subjects = subjects - ordered_subjects
add_debug "ordered_subjects: #{ordered_subjects.inspect}\n" +
"other_subjects: #{other_subjects.inspect}"
ordered_subjects + other_subjects
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order_subjects\n subjects = super\n other_subjects = []\n templates = {}\n\n log_debug \"order_subjects: #{subjects.inspect}\"\n\n # Order subjects by finding those with templates, and then by the template priority order and name\n\n # Get template priorities for each subject\n subjects.each do |s|\n if (t = find_template(s)) && !t[:skip]\n t[:priority] ||= 99\n templates[s] = t\n else\n other_subjects << s\n end\n end\n\n # Order subjects by priority or identifier\n ordered_subjects = templates.keys.sort do |s1, s2|\n if templates[s1][:priority] == templates[s2][:priority]\n templates[s1][:identifier] <=> templates[s2][:identifier]\n else\n templates[s1][:priority] <=> templates[s2][:priority]\n end\n end\n\n log_debug \"ordered_subjects: #{ordered_subjects.inspect}\\n\" + \n \"other_subjects: #{other_subjects.inspect}\"\n\n ordered_subjects + other_subjects\n end",
"def order_subjects\n seen = {}\n subjects = []\n\n # Start with base_uri\n if base_uri && @subjects.keys.select(&:uri?).include?(base_uri)\n subjects << base_uri\n seen[base_uri] = true\n end\n\n # Add distinguished classes\n top_classes.each do |class_uri|\n graph.query({predicate: RDF.type, object: class_uri}).\n map {|st| st.subject}.sort.uniq.each do |subject|\n log_debug(\"order_subjects\") {subject.to_sxp}\n subjects << subject\n seen[subject] = true\n end\n end\n\n # Add formulae which are subjects in this graph\n @formulae.each_key do |bn|\n next unless @subjects.key?(bn)\n subjects << bn\n seen[bn] = true\n end\n\n # Mark as seen lists that are part of another list\n @lists.values.flatten.each do |v|\n seen[v] = true if @lists.key?(v)\n end\n\n list_elements = [] # Lists may be top-level elements\n\n # Sort subjects by resources over bnodes, ref_counts and the subject URI itself\n recursable = (@subjects.keys - list_elements).\n select {|s| !seen.include?(s)}.\n map {|r| [r.node? ? 1 : 0, ref_count(r), r]}.\n sort\n\n subjects += recursable.map{|r| r.last}\n end",
"def handle_subjects(subjects)\n subjects.each do |link|\n subject = link['_resolved']\n term, *terms = subject['terms']\n code, ind2 = case term['term_type']\n when 'uniform_title'\n ['630', source_to_code(subject['source'])]\n when 'temporal'\n ['648', source_to_code(subject['source'])]\n when 'topical'\n ['650', source_to_code(subject['source'])]\n when 'geographic', 'cultural_context'\n ['651', source_to_code(subject['source'])]\n when 'genre_form', 'style_period'\n ['655', source_to_code(subject['source'])]\n when 'occupation'\n ['656', '7']\n when 'function'\n ['656', '7']\n else\n ['650', source_to_code(subject['source'])]\n end\n sfs = [['a', term['term']]]\n\n terms.each do |t|\n tag = case t['term_type']\n when 'uniform_title'; 't'\n when 'genre_form', 'style_period'; 'v'\n when 'topical', 'cultural_context'; 'x'\n when 'temporal'; 'y'\n when 'geographic'; 'z'\n end\n sfs << [tag, t['term']]\n end\n\n if ind2 == '7'\n sfs << ['2', subject['source']]\n end\n\n # add authority ID as subject 6xx $0\n authority_id = subject['authority_id']\n subfield_0 = authority_id ? [0, authority_id] : nil\n sfs.push(subfield_0) unless subfield_0.nil?\n\n ind1 = code == '630' ? \"0\" : \" \"\n df!(code, ind1, ind2).with_sfs(*sfs)\n end\n end",
"def handle_subjects(subjects)\n subjects.each do |link|\n subject = link['_resolved']\n term, *terms = subject['terms']\n ind1 = ' '\n code, *ind2 = case term['term_type']\n when 'uniform_title'\n value = term['term'].split(\" \")[0]\n first_indicator = '0'\n if value\n hsh = {}\n hsh['A'] = '2'\n hsh['An'] = '3'\n hsh['The'] = '4'\n articles = []\n articles = hsh.keys\n first_indicator = hsh[value] if articles.include?(value)\n end\n ['630', first_indicator, source_to_code(subject['source'])]\n when 'temporal'\n ['648', source_to_code(subject['source'])]\n when 'topical'\n ['650', source_to_code(subject['source'])]\n when 'geographic', 'cultural_context'\n ['651', source_to_code(subject['source'])]\n when 'genre_form', 'style_period'\n ['655', source_to_code(subject['source'])]\n when 'occupation'\n ['656', '7']\n when 'function'\n ['656', '7']\n else\n ['650', source_to_code(subject['source'])]\n end\n\n sfs = [['a', term['term']]]\n\n terms.each do |t|\n tag = case t['term_type']\n when 'uniform_title'; 't'\n when 'genre_form', 'style_period'; 'v'\n when 'topical', 'cultural_context'; 'x'\n when 'temporal'; 'y'\n when 'geographic'; 'z'\n end\n sfs << [tag, t['term']]\n end\n\n # code borrowed from Yale to export subject authority id\n unless subject['authority_id'].nil?\n sfs << ['0', subject['authority_id']]\n end\n\n \n # N.B. ind2 is an array at this point.\n if ind2[0] == '7'\n sfs << ['2', subject['source']]\n end\n\n # adding this code snippet because I'm making ind2 an array\n # for code 630 if the title begins with an article\n if (ind2.is_a?(Array) && code == '630')\n ind1, ind2 = ind2\n else\n ind2 = ind2[0]\n end\n\n df!(code, ind1, ind2).with_sfs(*sfs)\n end\n end",
"def subjects\n bib_subjects || get_item_data_by_name('Subject')\n end",
"def subject_titles\n @subject_titles ||= sw_subject_titles\n end",
"def index\n \n @subjects = Subject.sorted\n \n end",
"def handle_subjects(subjects)\n subjects.each do |link|\n subject = link['_resolved']\n term, *terms = subject['terms']\n code, ind2 = case term['term_type']\n when 'uniform_title'\n ['630', source_to_code(subject['source'])]\n when 'temporal'\n ['648', source_to_code(subject['source'])]\n # LOCAL: hack to export buildings as 610s, part 1\n when 'topical'\n if subject['source'] == 'built'\n ['610', '7']\n else\n ['650', source_to_code(subject['source'])]\n end\n when 'geographic', 'cultural_context'\n ['651', source_to_code(subject['source'])]\n when 'genre_form', 'style_period'\n ['655', source_to_code(subject['source'])]\n when 'occupation'\n ['656', '7']\n when 'function'\n ['656', '7']\n else\n ['650', source_to_code(subject['source'])]\n end\n sfs = [['a', term['term']]]\n\n terms.each do |t|\n tag = case t['term_type']\n when 'uniform_title'; 't'\n when 'genre_form', 'style_period'; 'v'\n # LOCAL: occupation == 'x'\n when 'topical', 'cultural_context', 'occupation'; 'x'\n when 'temporal'; 'y'\n when 'geographic'; 'z'\n end\n sfs << [tag, t['term']]\n end\n\n # LOCAL: hack to export buildings as 610s, part 2\n if ind2 == '7'\n if subject['source'] == 'built'\n sfs << ['2', 'local']\n else\n sfs << ['2', subject['source']]\n end\n end\n\n ind1 = code == '630' ? \"0\" : \" \"\n df!(code, ind1, ind2).with_sfs(*sfs)\n end\n end",
"def sorted(subjects)\n subjects.sort_by {|subject| subject['updated_at'] }.reverse\n end",
"def tie_breaking_sort\n { \"content_id\" => { order: \"asc\" } }\n end",
"def index\n @subjects = Subject.all.sort_by { |m| m.name.downcase }\n @user = current_user\n end",
"def add_subject_terminology(t)\n t.subject(:attributes=>{:authority=>\"UoH\"}) {\n t.topic\n t.temporal\n t.geographic\n }\n t.subject_topic(:proxy=>[:subject, :topic], :index_as=>[:displayable, :facetable])\n t.subject_geographic(:proxy=>[:subject, :geographic], :index_as=>[:displayable])\n t.subject_temporal(:proxy=>[:subject, :temporal], :index_as=>[:displayable])\n end",
"def for_subjects(subjects)\n result = Hash[subjects.map {|node| [node, false]}]\n subjects_by_id = Hash[subjects.map {|subject| [subject.id, subject]}]\n subject_rlshp_sources = Hash.new { |h, k| h[k] = [] }\n [:subject, :subject_agent_subrecord, :subject_agent_subrecord_place].each do |t|\n Subject.relationship_dependencies[t].each { |d| subject_rlshp_sources[d] << t }\n end\n\n subject_rlshp_sources.each do |model, sources|\n sources.each do |source|\n # i.e. one or more: subject_rlshp, subject_agent_subrecord_rlshp, subject_agent_subrecord_place_rlshp\n link_relationship = model.find_relationship(source)\n link_table = link_relationship.table_name\n\n link_relationship.reference_columns_for(model).each do |model_link_column|\n link_relationship.reference_columns_for(Subject).each do |subject_link_column|\n # Join subject_rlshp to (e.g.) accession\n linked_records = model\n .join(link_table,\n Sequel.qualify(link_table, model_link_column) => Sequel.qualify(model.table_name, :id))\n .filter(Sequel.qualify(link_table, subject_link_column) => subjects_by_id.keys)\n .select(Sequel.qualify(model.table_name, :id),\n Sequel.qualify(model.table_name, :publish),\n Sequel.qualify(model.table_name, :suppressed),\n Sequel.as(Sequel.qualify(link_table, subject_link_column),\n :subject_id))\n\n if model.columns.include?(:repo_id)\n linked_records = linked_records\n .select_append(Sequel.as(Sequel.qualify(model.table_name, :repo_id),\n :repository_id))\n end\n\n published_status = if model.included_modules.include?(TreeNodes)\n for_tree_nodes(linked_records\n .select_append(Sequel.qualify(model.table_name, :parent_id),\n Sequel.qualify(model.table_name, :root_record_id))\n .all)\n elsif model.to_s =~ /^Agent/\n for_agents_linked_to_subject(linked_records.all)\n else\n for_top_level_records(linked_records.all)\n end\n\n published_status.each do |linked_record, published|\n if published\n result[subjects_by_id.fetch(linked_record[:subject_id])] = true\n end\n end\n end\n end\n end\n end\n\n result\n end",
"def sort_name\n sort_constituent\n end",
"def order_categories!(sort_priorities)\n base = \"sort_priority = CASE id\\n\"\n update_statements = sort_priorities.reduce(base) do |sql, (cat_id, priority)|\n sql + \"WHEN #{cat_id} THEN #{priority}\\n\"\n end\n update_statements += \"END\"\n\n @current_community.categories.update_all(update_statements)\n end",
"def sort_relevant_rules\r\n # sort array in rule priority order\r\n @relevant_rules = @relevant_rules.sort do |r1, r2| \r\n r2.priority <=> r1.priority \r\n end\r\n end",
"def subject_names\n @subject_names ||= sw_subject_names\n end",
"def predicate_order\n [\n RDF.type,\n RDF::RDFS.label,\n RDF::RDFS.comment,\n RDF::URI(\"http://purl.org/dc/terms/title\"),\n RDF::URI(\"http://purl.org/dc/terms/description\"),\n RDF::OWL.sameAs,\n RDF::N3::Log.implies\n ]\n end",
"def subject_topics\n @subject_topics ||= term_values([:subject, :topic])\n end",
"def order_by(class_name)\n if class_name == 'Group'\n 'name'\n elsif class_name == 'EmailMessage'\n 'subject' # TODO or add created_at to model and use as sort field\n else \n 'id'\n end\n end",
"def combine_subjects\n @sentences.each_cons(2) do |s1, s2|\n if s1.subject == s2.subject\n s2.subject = Pronoun.new(s1.subject.gender)\n end\n end\n end",
"def optimize_order!(rules)\n first_can_in_group = -1\n rules.each_with_index do |rule, i|\n (first_can_in_group = -1) && next unless rule.base_behavior\n (first_can_in_group = i) && next if first_can_in_group == -1\n next unless rule.subjects == [:all]\n\n rules[i] = rules[first_can_in_group]\n rules[first_can_in_group] = rule\n first_can_in_group += 1\n end\n end",
"def index\n #assemlbe a list of all the subjects\n # @subjects = Subject.all or\n @subjects = Subject.sorted #defined in lambda\n end",
"def subjects_without_concidering_versions(options={})\n render_without_concidering_versions(options.merge(:only => :subjects)) unless @subjects_rendered\n @subjects\n end",
"def sort_by_type!\n children.sort! do |x, y|\n if x.is_a?(PBXGroup) && y.is_a?(PBXFileReference)\n -1\n elsif x.is_a?(PBXFileReference) && y.is_a?(PBXGroup)\n 1\n else\n x.display_name <=> y.display_name\n end\n end\n end",
"def sort_by_type!\n children.sort! do |x, y|\n if x.is_a?(PBXGroup) && y.is_a?(PBXFileReference)\n -1\n elsif x.is_a?(PBXFileReference) && y.is_a?(PBXGroup)\n 1\n else\n x.display_name <=> y.display_name\n end\n end\n end",
"def sort_by(att, options = {})\n sort(options.merge(:by => model.key(\"*\", att)))\n end",
"def studies_order\n order = sortable_column_order do |column, direction|\n case column\n when \"name\"\n \"LOWER(studies.name) #{direction}\"\n when \"active\", \"public\", \"promoted\"\n \"studies.#{column} #{direction}\"\n else\n 'LOWER(studies.name) ASC'\n end\n end\n end",
"def subjects(list=[], [email protected]_css('article-meta article-categories'), prefix = nil)\n return unless root\n subj_node = root.at_css('> subject')\n\n subj_text = subj_node && subj_node.text\n\n if subj_text.present?\n prefix = [prefix, subj_text].compact.join(\" - \")\n list << prefix\n end\n\n root.css('> subj-group').each do |node|\n subjects(list, node, prefix)\n end\n\n list.presence\n end",
"def doc2dc_subject(doc)\n # # ALL subjects?\n # doc.xpath(\"//idinfo/keywords/theme/themekey\").map { |node|\n # node.text.strip\n # }\n\n # filter by vocabulary - anything labeled ISO 19115\n subjects = []\n if iso_theme = doc.at_css('theme:has(themekt[text() *= \"ISO 19115\"])')\n iso_theme.xpath(\".//themekey\").each { |node|\n subjects << node.text.sub(/^./, &:upcase)\n }\n end\n subjects.flatten.sort\n end",
"def index\n @subject_types = SubjectType.order(:position)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def subject=(subject)\n self.subjects = [subject]\n end",
"def <=>(other)\n return nil unless other.is_a?(Subject)\n self.abbreviation <=> other.abbreviation\n end",
"def sort_order\n super\n end",
"def sort_by(att, options = {})\n sort(options.merge(:by => to_key(att)))\n end",
"def subject_map(terms, rel = :subjects)\n {\n :obj => :subject,\n :rel => rel,\n :map => {\n 'self::subfield' => proc { |subject, node|\n subject.publish = true\n subject.terms = terms.call(node)\n subject.source = node.parent.at_xpath(\"subfield[@code='2']\").inner_text unless node.parent.at_xpath(\"subfield[@code='2']\").nil?\n subject.vocabulary = '/vocabularies/1'\n subject.authority_id = set_auth_id(node) unless node.parent.at_xpath(\"subfield[@code='0']\").nil?\n }\n },\n :defaults => {\n :source => 'Source not specified'\n }\n }\n end",
"def sortItems()\n @usableItems = (@usableItems ||= []).sort_by { |x| x.to_s }\n end",
"def subjects\n subjects_array = object.syncable_subjects.to_a\n\n return subjects_array unless object.is_send?\n\n subjects_array << Subject.new(subject_code: \"U3\", subject_name: \"Special Educational Needs\")\n\n subjects_array\n end",
"def by_priority; end",
"def sort_titles_by_index\n validate_titles.sort_by { |titles| titles.second.to_i }\n end",
"def cellect_subjects(workflow_id)\n cellect.get '/subjects', workflow_id: workflow_id\n end",
"def ordering\n @topic.ordering(params[:to_priority].to_i)\n render nothing:true\n end",
"def process_subjects(subjects_arr)\n return_arr = []\n subjects_arr.each do |subject|\n unless subject['_resolved'].blank?\n return_arr.push(subject['_resolved'])\n end\n end\n return_arr\n end",
"def sort\n raise l(:priority_sort_no_project_error) if !parent_object\n \n @priorities = parent_object.priorities\n \n params.keys.select{|k| k.include? UL_ID }.each do |key|\n Priority.sort_priorities(@priorities, params[key])\n end\n \n render :nothing => true\n end",
"def extract_subjects(mods_subject_nodes, template_subject_nodes)\n subjects = {}\n mods_subject_name_nodes, template_subject_name_nodes = get_subject_name_nodes(mods_subject_nodes, template_subject_nodes)\n mods_subject_other_nodes, template_subject_other_nodes = get_subject_other_nodes(mods_subject_nodes, template_subject_nodes, mods_subject_name_nodes)\n mods_subject_name_nodes.each_with_index do |sn, i|\n subjects.merge!(extract_subject_values_and_attributes(sn, template_subject_name_nodes[i]))\n end\n mods_subject_other_nodes.each_with_index do |su, i|\n subjects.merge!(extract_subject_values_and_attributes(su, template_subject_other_nodes[i]))\n end\n subjects.merge!(extract_other_geo_subjects(mods_subject_nodes, template_subject_nodes))\n end",
"def subjectify(options = {})\n result = []\n all_subjects = []\n sub_array = []\n options[:value].each_with_index do |subject, i|\n spl_sub = subject.split(QUERYSEP)\n sub_array << []\n subject_accum = ''\n spl_sub.each_with_index do |subsubject, j|\n spl_sub[j] = subject_accum + subsubject\n subject_accum = spl_sub[j] + QUERYSEP\n sub_array[i] << spl_sub[j]\n end\n all_subjects[i] = subject.split(QUERYSEP)\n end\n options[:value].each_with_index do |_subject, i|\n lnk = ''\n lnk_accum = ''\n all_subjects[i].each_with_index do |subsubject, j|\n lnk = lnk_accum + link_to(subsubject,\n \"/?f[subject_facet][]=#{CGI.escape sub_array[i][j]}\",\n class: 'search-subject', title: \"Search: #{sub_array[i][j]}\")\n lnk_accum = lnk + content_tag(:span, SEPARATOR, class: 'subject-level')\n end\n result << sanitize(lnk)\n end\n result\n end",
"def sort_using(xs, sidebar)\n # caching is possible but doesn't improve significantly the build times\n\n rank_lookup = rank_lookup_from_sidebar(sidebar)\n\n xs.sort {|x, y|\n # The default rank is very high so that pages that don't appear in the sidebar are put at the end\n rx = rank_lookup[x.url] || 10000\n ry = rank_lookup[y.url] || 10000\n\n rx <=> ry\n }\n\n end",
"def articles_asc\n articles.sort_by(&:published)\n end",
"def sort_methods\n [\n 'score desc',\n 'authors_sort asc',\n 'authors_sort desc',\n 'title_sort asc',\n 'title_sort desc',\n 'journal_sort asc',\n 'journal_sort desc',\n 'year_sort asc',\n 'year_sort desc'\n ]\n end",
"def render_subject(subject, predicates, **options, &block)\n options = options.merge(haml: @prev_templ[:rel]) if options[:rel] && @prev_templ[:rel]\n @prev_templ = haml_template\n super(subject, predicates, **options) do |predicate|\n if predicate.is_a?(Symbol)\n # Special snippet processing\n # Render associated properties with associated or default formatting\n case predicate\n when :other\n props = predicates.map(&:to_s)\n props -= haml_template[:title_props] || []\n props -= haml_template[:body_props] || []\n props -= haml_template[:description_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n when :other_nested\n props = predicates.map(&:to_s)\n props -= haml_template[:nested_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n else\n # Find appropriate entires from template\n props = haml_template[\"#{predicate}_props\".to_sym]\n log_debug \"render_subject(#{subject}, #{predicate}): #{props.inspect}\"\n format = haml_template[\"#{predicate}_fmt\".to_sym]\n end\n unless props.nil? || props.empty?\n format ||= lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n format.call(props, &block)\n end\n else\n yield(predicate)\n end\n end\n end",
"def subjects\r\n subjects = []\r\n range =\"#{group[:first_message]}-\"\r\n connection.query(:xhdr, \"Subject\", range) do |status, data|\r\n if status[:code] == 221\r\n data.each do |line|\r\n message = Message.new\r\n message.num, message.subject = line.split(' ', 2)\r\n subjects << message\r\n end\r\n end\r\n end\r\n subjects\r\n end",
"def add_corridor_subjects(specialization_id, type, *ids)\n ids.each {|i|\n type.create(:subject_id => i, :specialization_id => specialization_id)\n }\n end",
"def active_topics_by_subject(opts={})\n h = {}\n \n # Compute local site taggings count for all topics\n Topic.site_topics(self).collect { |t|\n num_taggings = Story.count(:joins => \"JOIN taggings t1 ON t1.taggable_type='Story' AND t1.taggable_id = stories.id AND t1.tag_id = #{t.tag.id} JOIN taggings t2 ON t2.taggable_type='Story' AND t2.taggable_id = stories.id AND t2.tag_id = #{constraint.id}\")\n t.subjects.each { |s|\n h[s.id] ||= []\n h[s.id] << [t.id, num_taggings] if num_taggings >= 3\n }\n }\n\n # Sort by frequency (descending order), and pick first 5\n h.keys.each { |s| h[s].sort! { |v1,v2| v2[1] <=> v1[1] }; h[s]= h[s].take(5) }\n\n return h\n end",
"def sort_parts!\n @parts.each do |p|\n p.body.set_sort_order(@part_sort_order)\n p.body.sort_parts!\n end\n @parts.sort!(@part_sort_order)\n end",
"def index\n @chunker_subjects = ChunkerSubject.all.order(:name)\n end",
"def collect_compare_priority\n @compare_quque = []\n @compare_quque = ComparisonTable.sort_by{|k, dar|\n DisplayOrder[StringTable[dar.first]] ? DisplayOrder[StringTable[dar.first]] : DisplayOrder[MISC_text]\n }.collect{|p| p[0]}\n end",
"def show_subjects\n @kw_by_code_keys.each{|key|\t# Iterate thru tags in the same order we read them\n # For this instance (parent ID) of this tag...\n pid, tag = key\n\n h_tag = @kw_by_code[key]\n next unless h_tag['a']\n\n h_tag['a'].each{|s|\n subject = s.sub(/ *thesis *$/i, '')\t# Remove \"thesis\" from end of 695.a\n puts \" <meta tagcode=\\\"subjects.fixed1\\\">#{subject}</meta>\"\n }\n }\n end",
"def sort!\n unless sorted?\n @sources = topsort\n insert_extensions!\n insert_replacements!\n @sources.uniq!\n @sorted = true\n end\n self\n end",
"def per_file\n self.class.new(group_by(&:path).values.map { |subjects| subjects.sort_by(&:name).first })\n end",
"def sort_schemas_by_category(schemas)\n sorted_schemas=[]\n categories = {\n documents: %w(document invoice credit_note order estimate payment_reminder recurring line_item divider_item sub_total_item),\n contacts: %w(contact address),\n templates: %w(pdf_template email_template text_template export_template),\n system: %w(company user language sub auth_permission),\n supportive: %w(task tag email comment attachment export payment product),\n accounting: %w(account account_entry account_billing),\n }\n categories.each do |cat, obj_types|\n sorted_schemas << cat\n sorted_schemas << schemas.select{|obj| obj_types.include?(obj[:title]) }.sort{|a,b| a[:title].humanize <=> b[:title].humanize }\n end\n sorted_schemas\nend",
"def get_ead_subject_facets(subjects = Array.new)\n subjects << search(\"//*[local-name()='subject' or local-name()='function' or local-name() = 'occupation']\")\n return clean_facets_array(subjects.flatten.map(&:text))\n end",
"def sort\n @sort ||= Vidibus::Words.sort_by_occurrence(list)\n end",
"def sort_bibliography!(texts)\n sort_fields = [@command_processor.style._sort_bibliography_by].flatten\n texts.sort_by! do |text|\n sort_fields.map do |field|\n val = text[field]\n if val.is_a?(BibTeX::Names)\n [val.tokens.map { |name| [name.last, name.first] }]\n else\n val\n end\n end.flatten + [text.key]\n end\n end",
"def sort_by_sex_then_ln!\n @entries.sort! { |a,b| [a.sex, a.ln] <=> [b.sex, b.ln] }\n end",
"def __sort_pair__\n { first => Mongoid::Criteria::Translator.to_direction(last) }\n end",
"def index\n @subjects = subject_scope\n end",
"def list_subjects(study_id)\n act = SubjectListAction.new(self)\n act.get(study_id)\n end",
"def subject_names\n ret = []\n if cn = self.subject_component('CN')\n ret << cn\n end\n # Merge in san_names if we got anything.\n if sn = self.san_names\n ret.concat(sn)\n end\n\n return ret.sort.uniq\n end",
"def set_order_of_articles_if_ordering_specifying_type!\n if ordering_type == ORDERING_SPECIFYING\n set_order_of_articles!\n end\n end",
"def all_subjects\n observations + profile_users + glossary_terms\n end",
"def list_subjects\r\n #TODO only list subjects from my own schools \r\n #because then people can still it \r\n school = School.find(params[:nid]) rescue render_return\r\n render_return if !logged_in_user.see_course?(school)\r\n render_p 'course_display/course_selection',{'caller'=>params[:caller],'school'=>school}\r\n end",
"def show\n @subject=Subject.find_by_id(params[:id])\n @questions = @subject.questions.order(\"qtype, created_at DESC\").paginate(page: params[:page])\n end",
"def sorted_by_frequency\n @categories.sort { |a, b| b[1] <=> a[1] }\n end",
"def enroll(subject)\n\t\tsubjects[subject] = []\n\t\tsubjects\n\tend",
"def add_hierarchy_sort(solr_params)\n solr_params[:sort] = 'sort_ii asc' if %w[online_contents collection_context].include? blacklight_params[:view]\n solr_params\n end",
"def apply_sorting(chain)\n chain\n end",
"def all_other_subject\n @user = User.find(params[:data])\n\n\n @all_other_subjects = @user.other_subject_assesses.order(\"id\")\n @title_groups_other_subjects = TitleGroupsOtherSubject.order(\"id\")\n\n render :layout => false\n end",
"def render_subject(subject, predicates, options = {}, &block)\n options = options.merge(:haml => haml_template[:rel]) if options[:rel] && haml_template[:rel]\n super(subject, predicates, options) do |predicate|\n if predicate.is_a?(Symbol)\n # Special snippet processing\n # Render associated properties with associated or default formatting\n case predicate\n when :other\n props = predicates.map(&:to_s)\n props -= haml_template[:title_props] || []\n props -= haml_template[:body_props] || []\n props -= haml_template[:description_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n when :other_nested\n props = predicates.map(&:to_s)\n props -= haml_template[:nested_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n else\n # Find appropriate entires from template\n props = haml_template[\"#{predicate}_props\".to_sym]\n add_debug \"render_subject(#{subject}, #{predicate}): #{props.inspect}\"\n format = haml_template[\"#{predicate}_fmt\".to_sym]\n end\n unless props.nil? || props.empty?\n format ||= lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n format.call(props, &block)\n end\n else\n yield(predicate)\n end\n end\n end",
"def ordering(to_topic_id, to_priority)\n to_topic = Topic.find to_topic_id\n \n Selection.transaction do\n if topic == to_topic\n ordering_within_topic(topic, self.priority, to_priority)\n else\n ordering_between_topics(topic, to_topic, self.priority, to_priority)\n end\n self.update!(priority: to_priority, topic_id: to_topic.id)\n end\n end",
"def get_subject_other_nodes(mods_subject_nodes, template_subject_nodes, mods_subject_name_nodes)\n mods_subject_other_nodes = mods_subject_nodes.xpath(\"#{@ns}:topic|#{@ns}:geographic|#{@ns}:temporal|#{@ns}:genre\").map {|x| x.parent}.uniq\n mods_subject_other_nodes.map {|x| mods_subject_other_nodes.delete(x) if mods_subject_name_nodes.include?(x)}\n template_subject_other_nodes = template_subject_nodes.grep(/su[\\d]+:/)\n return mods_subject_other_nodes, template_subject_other_nodes\n end",
"def preferredsubject_params\n params.require(:preferredsubject).permit(:user_id, :course_id)\n end",
"def apply_sorting(relation)\n relation.order(@q.sorting.to_sql)\n end",
"def ordered_titles\n sort_titles_by_index.map { |titles| titles.first }\n end",
"def sort_sections\n titles = @sections.map { |title, _| title }\n\n if titles.length > 1 and\n TOMDOC_TITLES_SORT ==\n (titles | TOMDOC_TITLES).sort_by { |title| title.to_s } then\n @sections.values_at(*TOMDOC_TITLES).compact\n else\n @sections.sort_by { |title, _|\n title.to_s\n }.map { |_, section|\n section\n }\n end\n end",
"def sort_text\n attributes.fetch(:sortText)\n end",
"def default_sort\n 'name asc'\n end",
"def randomize(subject)\n @subject_questions = [subject.title]\n #put each question into a hash, then put into the @subject_questions array\n #subject.questions.where(:state => 1).order(\"RANDOM()\").each do |question|\n subject.questions.order(\"RANDOM()\").each do |question|\n @append_question = { \n :question_id => question.id,\n :question => question.question,\n :answer => question.answer,\n :answer_explanation => question.answer_explanation\n }\n # add question hash to the array\n @subject_questions.push(@append_question)\n end\n #push subject to vault\n $vault.push(@subject_questions)\n end",
"def default_sort_order\n ::Mincer.config.sorting.order_attribute\n end",
"def default_ordering(field_name)\n case field_name\n when \"status\"; return(\"ascending\")\n when \"from\"; return(\"ascending\")\n when \"subject\"; return(\"ascending\")\n when \"date\"; return(\"descending\")\n end \n end",
"def ja_sort\n [{ :created_at => :desc }]\n end",
"def index\n #You can use the subject model to call the scopes\n #@subjects = Subject.all\n\n #you could write it like @subjects = Subject.order(:position)\n #But we can use the scopes in the subject.rb model as below\n @subjects = Subject.sorted\n #You can render the subject:index view using\n #render('index').\n #But with sensible defaults, We do not have to do that\n end",
"def subjectless\n pre_subject = []\n has = []\n subject = nil\n members.each do |sseq_or_op|\n if subject\n has << sseq_or_op\n elsif sseq_or_op.is_a?(String) || !sseq_or_op.subject?\n pre_subject << sseq_or_op\n else\n subject = sseq_or_op.dup\n subject.members = sseq_or_op.members.dup\n subject.subject = false\n has = []\n end\n end\n\n return self unless subject\n\n unless has.empty?\n subject.members << Pseudo.new(:class, 'has', nil, CommaSequence.new([Sequence.new(has)]))\n end\n Sequence.new(pre_subject + [subject])\n end",
"def sort\n super { |x, y| x.file_name <=> y.file_name }\n end",
"def index\n @students = Student.order(:family_name).order(:preferred_name).order(:given_name)\n end",
"def subjects_with_permission(type, permission)\n raise Exceptions::NotACanHazSubject unless type.respond_to?(:acts_as_canhaz_subject)\n permissions = self.permissions_subjects.where(:type => self.class.to_s, :permission => permission.to_s)\n type.in(:id => permissions.collect(&:csubject_id))\n end",
"def subjects_person\n get_item_data_by_name('SubjectPerson')\n end",
"def index\n @categories = Category.includes(:topic).order('topics.order', :order).all\n end",
"def subjectsOptions(selected_id, options_all=false, tree_type_id)\n if options_all\n ret = [['All', '']]\n else\n ret = []\n end\n Subject.where(\"tree_type_id = ? AND min_grade < ?\", tree_type_id, 999).order(\"max_grade desc\", \"min_grade asc\", \"code\").each do |s|\n # ret << [ @translations[\"sector.#{s.code}.name\"], s.id ]\n ret << [s.code, s.id]\n end\n return ret\n end",
"def subjects\n @graphs.inject([]) {|memo, g| memo += g.subjects}\n end",
"def process_scores\n applicable_subjects = []\n subjects.group_by(&:batch_subject_group).each_pair do |batch_group, batch_subjects|\n (batch_subjects << batch_group).compact.each do |sub|\n applicable_subjects << sub\n end\n end\n applicable_subjects.sort_by{|as| as.priority.to_i}.each do|sub|\n mark = student.converted_assessment_marks.detect{|cam| cam.markable_id == sub.id and \n cam.markable_type == sub.class.name and cam.assessment_group_batch_id == agb.id}\n next unless mark\n build_score(sub, mark)\n process_skills(sub,mark) if consider_skills_of_subjects(sub)\n process_attributes(sub, mark, agb.subject_attribute_assessments) if agb.subject_attribute_assessments.present? and sub.is_a?(Subject)\n end\n\n add_to_exam_totals_hash(@total_score)\n end"
] | [
"0.804792",
"0.72038674",
"0.55669224",
"0.54452723",
"0.5338515",
"0.5289578",
"0.52037513",
"0.5199704",
"0.5168435",
"0.5110567",
"0.5096804",
"0.5024326",
"0.49352625",
"0.49262598",
"0.4909191",
"0.48932308",
"0.48865318",
"0.4877155",
"0.48666078",
"0.4864642",
"0.4856226",
"0.484892",
"0.48200232",
"0.48064423",
"0.48060894",
"0.4802935",
"0.47752357",
"0.47712377",
"0.47508124",
"0.47349444",
"0.47302386",
"0.4726297",
"0.46991244",
"0.4695511",
"0.46865106",
"0.46739507",
"0.4672087",
"0.46651307",
"0.4664334",
"0.46589482",
"0.46405837",
"0.46344718",
"0.46235722",
"0.46216705",
"0.46165544",
"0.46123332",
"0.46102324",
"0.460395",
"0.4598055",
"0.45823586",
"0.45696968",
"0.45571086",
"0.45556006",
"0.45451444",
"0.45393085",
"0.453317",
"0.45272025",
"0.45143312",
"0.4511185",
"0.4499854",
"0.44984332",
"0.44952127",
"0.44922617",
"0.4471607",
"0.4464443",
"0.44617653",
"0.44605598",
"0.44581202",
"0.44562846",
"0.44507957",
"0.44418195",
"0.44308197",
"0.44261825",
"0.44229597",
"0.44197044",
"0.44093496",
"0.44073516",
"0.44024006",
"0.4401938",
"0.44001642",
"0.43922266",
"0.4388634",
"0.43881124",
"0.43719938",
"0.43706363",
"0.43673873",
"0.43659985",
"0.436125",
"0.43549123",
"0.43546158",
"0.43537486",
"0.4351341",
"0.4351044",
"0.43444198",
"0.43442753",
"0.43427587",
"0.43420893",
"0.43414456",
"0.43396",
"0.4339492"
] | 0.8143512 | 0 |
Find a template appropriate for the subject. Use type information of subject to select among multiple templates In this implementation, find all templates matching on permutations of types of this subjects and choose the one with the lowest :priority Keep track of matched templates | def find_template(subject)
properties = @graph.properties(subject)
types = (properties[RDF.type.to_s] || [])
matched_templates = []
(1..types.length).each do |len|
types.combination(len) do |set|
templ = @options[:haml] && @options[:haml][set]
templ ||= haml_template[set]
if len == 1
templ ||= @options[:haml] && @options[:haml][set.first]
templ ||= haml_template[set.first]
end
add_debug "find_template: look for #{set.inspect}"
add_debug "find_template: look for #{set.first.inspect}" if len == 1
# Look for regular expression match
templ ||= if len == 1
key = haml_template.keys.detect {|k| k.is_a?(Regexp) && set.first.to_s.match(k)}
haml_template[key]
end
next unless templ
matched_templates[len] ||= []
matched_templates[len] << templ
end
end
if matched_templates.empty?
add_debug "find_template: no template found for any #{types.inspect}"
return nil
end
list = matched_templates.last
# Order the list of templates by priority
list = list.sort_by {|templ| templ[:priority] || 99}
# Choose the lowest priority template found
templ = list.first
add_debug "find_template: found #{templ[:identifier] || templ.inspect}"
@options[:matched_templates] << templ[:identifier]
templ
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_template(subject)\n properties = @graph.properties(subject)\n types = (properties[RDF.type.to_s] || [])\n \n matched_templates = []\n \n (1..types.length).each do |len|\n types.combination(len) do |set|\n templ = @options[:haml] && @options[:haml][set]\n templ ||= haml_template[set]\n if len == 1\n templ ||= @options[:haml] && @options[:haml][set.first]\n templ ||= haml_template[set.first]\n end\n\n #log_debug \"find_template: look for #{set.inspect}\"\n\n # Look for regular expression match\n templ ||= if len == 1\n key = haml_template.keys.detect {|k| k.is_a?(Regexp) && set.first.to_s.match(k)}\n haml_template[key]\n end\n\n next unless templ\n \n matched_templates[len] ||= []\n matched_templates[len] << templ\n end\n end\n\n if matched_templates.empty?\n log_debug \"find_template: no template found for any #{types.inspect}\"\n return nil\n end\n \n list = matched_templates.last\n \n # Order the list of templates by priority\n list = list.sort_by {|templ| templ[:priority] || 99}\n \n # Choose the lowest priority template found\n templ = list.first\n\n log_debug \"find_template: found #{templ[:identifier] || templ.inspect}\"\n\n @options[:matched_templates] << templ[:identifier]\n \n templ\n end",
"def find_template(template)\n template = locate_config_value(:template_regex) if template.nil?\n # if we got a string then try to find that template exact\n # if no exact template matches, search\n if template.is_a?(String)\n found = get_template(template)\n return found if found\n end\n\n # make sure our nil template gets set to default\n if template.nil?\n template = locate_config_value(:template_regex)\n end\n\n Chef::Log.debug \"Name: #{template.class}\"\n # quick and dirty string to regex\n unless template.is_a?(Regexp)\n template = /#{template}/\n end\n\n # loop over all vm's and find the template\n # Wish there was a better API method for this, and there might be\n # but i couldn't find it\n Chef::Log.debug \"Using regex: #{template}\"\n xapi.VM.get_all_records.each_value do |vm|\n if vm['is_a_template'] && vm['name_label'] =~ template\n Chef::Log.debug \"Matched: #{h.color(vm['name_label'], :yellow)}\"\n found = vm # we're gonna go with the last found\n end\n end\n\n # ensure return values\n if found\n ui.msg \"Using Template: #{h.color(found['name_label'], :cyan)}\"\n return get_template(found['name_label']) # get the ref to this one\n end\n nil\n end",
"def find_template(template=XAPI_TEMP_REGEX)\n # if we got a string then try to find that template exact \n # if no exact template matches, search\n if template.is_a?(String)\n found = get_template(template)\n return found if found\n end\n\n # make sure our nil template gets set to default\n if template.nil?\n template = XAPI_TEMP_REGEX\n end \n\n Chef::Log.debug \"Name: #{template.class}\"\n # quick and dirty string to regex\n unless template.is_a?(Regexp)\n template = /#{template}/ \n end\n\n # loop over all vm's and find the template \n # Wish there was a better API method for this, and there might be\n # but i couldn't find it\n Chef::Log.debug \"Using regex: #{template}\"\n xapi.VM.get_all_records().each_value do |vm|\n if vm[\"is_a_template\"] and vm[\"name_label\"] =~ template\n Chef::Log.debug \"Matched: #{h.color(vm[\"name_label\"], :yellow )}\"\n found = vm # we're gonna go with the last found \n end\n end\n\n # ensure return values\n if found\n puts \"Using Template: #{h.color(found[\"name_label\"], :cyan)}\"\n return get_template(found[\"name_label\"]) # get the ref to this one\n end\n return nil\n end",
"def get_query_template( type, templates = [] ) \n\ttype = type.gsub(/[^a-z0-9-]+/, '')\n\n\ttemplates = [type] if templates.blank?\n\n\t# Filters the list of template filenames that are searched for when retrieving a template to use.\n\t#\n\t# The last element in the array should always be the fallback template for this query type.\n\t#\n\t# Possible values for `$type` include: 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date',\n\t# 'embed', 'home', 'frontpage', 'privacypolicy', 'page', 'paged', 'search', 'single', 'singular', and 'attachment'.\n\t#\n\t# @param array $templates A list of template candidates, in descending order of priority.\n\ttemplates = apply_filters( \"#{type}_template_hierarchy\", templates )\n\n\tif true # TS_INFO: It returns here all the templates, because the check will be done in the controller\n\t\treturn templates\n\tend\n\n\ttemplate = locate_template( templates )\n\n\t# Filters the path of the queried template by type.\n\t#\n\t# The dynamic portion of the hook name, `$type`, refers to the filename -- minus the file\n\t# extension and any non-alphanumeric characters delimiting words -- of the file to load.\n\t# This hook also applies to various types of files loaded as part of the Template Hierarchy.\n\t#\n\t# Possible values for `$type` include: 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date',\n\t# 'embed', 'home', 'frontpage', 'privacypolicy', 'page', 'paged', 'search', 'single', 'singular', and 'attachment'.\n\t#\n\t# @param string $template Path to the template. See locate_template().\n\t# @param string $type Sanitized filename without extension.\n\t# @param array $templates A list of template candidates, in descending order of priority.\n\tapply_filters( \"#{type}_template\", template, type, templates )\nend",
"def order_subjects\n subjects = super\n other_subjects = []\n templates = {}\n\n log_debug \"order_subjects: #{subjects.inspect}\"\n\n # Order subjects by finding those with templates, and then by the template priority order and name\n\n # Get template priorities for each subject\n subjects.each do |s|\n if (t = find_template(s)) && !t[:skip]\n t[:priority] ||= 99\n templates[s] = t\n else\n other_subjects << s\n end\n end\n\n # Order subjects by priority or identifier\n ordered_subjects = templates.keys.sort do |s1, s2|\n if templates[s1][:priority] == templates[s2][:priority]\n templates[s1][:identifier] <=> templates[s2][:identifier]\n else\n templates[s1][:priority] <=> templates[s2][:priority]\n end\n end\n\n log_debug \"ordered_subjects: #{ordered_subjects.inspect}\\n\" + \n \"other_subjects: #{other_subjects.inspect}\"\n\n ordered_subjects + other_subjects\n end",
"def order_subjects\n subjects = super\n \n add_debug \"order_subjects: #{subjects.inspect}\"\n\n # Order subjects by finding those with templates, and then by the template priority order\n prioritized_subjects = []\n other_subjects = []\n subjects.each do |s|\n template = find_template(s)\n next unless template\n \n priority = template[:priority] || 99\n add_debug \" priority(#{s}) = #{priority}\"\n prioritized_subjects[priority] ||= []\n prioritized_subjects[priority] << s\n end\n\n ordered_subjects = prioritized_subjects.flatten.compact\n \n other_subjects = subjects - ordered_subjects\n \n add_debug \"ordered_subjects: #{ordered_subjects.inspect}\\n\" + \n \"other_subjects: #{other_subjects.inspect}\"\n\n ordered_subjects + other_subjects\n end",
"def get_template(matching_options_hash, matching_tags_hash)\n log(:info, \"Processing get_template...\", true)\n\n template_search_by_guid = matching_options_hash[:guid] rescue nil\n template_search_by_name = matching_options_hash[:name] || matching_options_hash[:template] rescue nil\n template_search_by_product = matching_options_hash[:os] rescue nil\n templates = []\n\n unless template_search_by_guid.nil?\n # Search for templates tagged with 'prov_scope' => 'all' & match the guid from option_?_guid\n if templates.empty?\n log(:info, \"Searching for templates tagged with 'prov_scope' => 'all' that match guid: #{template_search_by_guid}\")\n templates = $evm.vmdb('miq_template').all.select do |template|\n template.ext_management_system && template.tagged_with?('prov_scope', 'all') && template.guid == template_search_by_guid\n end\n end\n end\n unless template_search_by_name.nil?\n # Search for templates that tagged with 'prov_scope' => 'all' & match the name from option_?_template || option_?_name - then load balance them across different providers based on vm count\n if templates.empty?\n log(:info, \"Searching for templates tagged with 'prov_scope' => 'all' that are named: #{template_search_by_name}\")\n templates = $evm.vmdb('miq_template').all.select do |template|\n template.ext_management_system && template.tagged_with?('prov_scope', 'all') && template.name == template_search_by_name\n end.sort { |template1, template2| template1.ext_management_system.vms.count <=> template2.ext_management_system.vms.count }\n end\n end\n unless template_search_by_product.nil?\n # Search for templates tagged with 'prov_scope' => 'all' & product_name include option_?_os (I.e. 'windows', red hat') - then load balance them across different providers based on vm count\n if templates.empty?\n log(:info, \"Searching for templates tagged with 'prov_scope' => 'all' that inlcude product: #{template_search_by_product}\")\n templates = $evm.vmdb('miq_template').all.select do |template|\n template.ext_management_system && template.tagged_with?('prov_scope', 'all') && template.operating_system[:product_name].downcase.include?(template_search_by_product)\n end.sort { |template1, template2| template1.ext_management_system.vms.count <=> template2.ext_management_system.vms.count }\n end\n end\n raise \"No templates found\" if templates.empty?\n\n # get the first template in the list\n template = templates.first\n log(:info, \"Found template: #{template.name} product: #{template.operating_system[:product_name].downcase rescue 'unknown'} guid: #{template.guid} on provider: #{template.ext_management_system.name}\")\n matching_options_hash[:name] = template.name\n matching_options_hash[:guid] = template.guid\n log(:info, \"Processing get_template...Complete\", true)\n end",
"def find_and_take template\n message = nil\n\n tsync do\n index = nil\n\n @takable.each_with_index do |m, i|\n if m =~ template\n index = i\n message = m\n break\n end\n end\n\n @takable.delete_at index if index\n end\n\n message\n end",
"def find_templates(name, details, prefix, partial)\n raise NotImplementedError\n end",
"def find_matching_template(context_node)\n @templates.find {|tpl| tpl===context_node}\n end",
"def findClosestMatch(records, templateName)\n # Build a placeholder to store the selected notification template\n selected_record = nil\n recipient_language = @recipient_json['language'].to_s\n recipient_region = @recipient_json['region'].to_s\n\n # Return an error if no notification template was found\n if records.length == 0\n @error_message = \"The following Notification Template or snippet was not located: #{templateName}\\n\\n\"\n # If only one template is returned, or the user has no preferences use the first match\n elsif records.length == 1 || (recipient_language.empty? && recipient_region.empty?)\n selected_record = records[0]['values']\n puts \"Only one record returned for #{templateName}, OR no preferences found so selected first\" if @debug_logging_enabled\n else\n # Select a template based on users preferences\n # Define an array of preferences for each record returned\n recordPreferences = records.map do |record|\n {\n 'id' => record['id'],\n 'language' => record['values']['Language'],\n 'region' => record['values']['Region'],\n 'score' => 0,\n }\n end\n # Loop over each record and try to match it\n recordPreferences.each do |record|\n language = record['language'].to_s\n region = record['region'].to_s\n # Test to see if both language and region match if neither are empty\n if recipient_language == language && recipient_region == region && (!recipient_region.empty? && !region.empty?) && (!recipient_language.empty? && !language.empty?)\n record['score'] += 3\n puts \"Matched on Language and Region for Template #{templateName}\" if @debug_logging_enabled\n # Test to see if a language matches if they are not empty\n elsif recipient_language == language && (!recipient_language.empty? && !language.empty?)\n record['score'] += 2\n puts \"Matched on Language only for Template #{templateName}\" if @debug_logging_enabled\n # Test to see if a region matches\n elsif recipient_region == region && (!recipient_region.empty? && !region.empty?)\n record['score'] += 1\n puts \"Matched on Region only for Template #{templateName}\" if @debug_logging_enabled\n end\n puts \"Score is #{record['score']} for Template #{templateName}\" if @debug_logging_enabled\n end\n\n # Determine which record should be choosen as the selected record\n closestMatch = recordPreferences.max_by { |element| element['score'] }\n # Get the ID so we can select this record. If multiple had the same score, choose the first\n closestMatch.kind_of?(Array) ? closestMatch = closestMatch[0]['id'] : closestMatch = closestMatch['id']\n # Set the selected record to be returned\n selected_record = records.find { |match| match['id'] == closestMatch }['values']\n end\n # Return the selected record\n return selected_record\n end",
"def get_type_template(types)\n default_template = File.join(@template_dir, \"default\")\n template = default_template\n \n # For each of the types, check if the type template exists\n for type in types\n assit_kind_of(N::URI, type)\n type_uri = type.to_name_s('_')\n template = if(Dependencies.mechanism == :require)\n @@type_templates[type_uri] ||= check_type_template(type_uri)\n else\n check_type_template(type_uri)\n end\n \n # When a template is found, break out\n return template unless(template == default_template)\n end\n \n template # Otherwise this will return \"default\"\n end",
"def select_template\n templatelist = []\n templatelist\n end",
"def find(match)\n hits = search(match)\n raise(MissingTemplate, \"No matching templates.\") if hits.size == 0\n if hits.size > 1\n message = \"More than one match:\\n \" + hits.map{|name, dir| name}.join(\"\\n \")\n raise(DuplicateTemplate, message)\n end\n hits.first\n end",
"def find_templates(name, prefix, partial, details)\n conditions = {\n path: normalize_path(name, prefix),\n locale: normalize_array(details[:locale]).first,\n format: normalize_array(details[:formats]).first,\n handler: normalize_array(details[:handlers]),\n partial: partial || false\n }\n\n ::Page.visible(user_sign_in_status).where(conditions).map do |record|\n initialize_template(record)\n end\n end",
"def find_template(opts={})\n if template = opts[:template]\n path = _template_root / template\n elsif action = opts[:action]\n segment = self.class.name.snake_case.split('::').join('/')\n path = _template_root / segment / action\n elsif _layout = opts[:layout]\n path = _template_root / 'layout' / _layout\n else\n raise \"called find_template without an :action or :layout\" \n end \n glob_template(path, opts)\n end",
"def search(match)\n if File.directory?(match)\n name = File.basename(match)\n return [Template.new(name, match, :type=>:project)]\n end\n\n hits = templates.select do |template|\n match == template.name\n end\n if hits.size == 0\n hits = templates.select do |template|\n /^#{match}/ =~ template.name\n end\n end\n return hits\n end",
"def find_template_by_language(language_code=Utility.language_code)\n find(:first, :conditions => [\"kases.template = ? AND kases.language_code = ?\", true, language_code])\n end",
"def find_template(options)\n if options[:template] && (template_opts, meth = opts[:named_templates][template_name(options)]; meth)\n if template_opts\n options = template_opts.merge(options)\n else\n options = Hash[options]\n end\n\n options[:inline] = send(meth)\n\n super(options)\n else\n super\n end\n end",
"def template\n possible_templates.find {|t| File.exists? \"#{t}.html\"}\n end",
"def find_template_sub(t)\n for path in [File.join(juli_repo, Juli::REPO), Juli::TEMPLATE_PATH] do\n template = File.join(path, t)\n return template if File.exist?(template)\n end\n raise Errno::ENOENT, \"no #{t} found\"\n end",
"def extract_subjects(mods_subject_nodes, template_subject_nodes)\n subjects = {}\n mods_subject_name_nodes, template_subject_name_nodes = get_subject_name_nodes(mods_subject_nodes, template_subject_nodes)\n mods_subject_other_nodes, template_subject_other_nodes = get_subject_other_nodes(mods_subject_nodes, template_subject_nodes, mods_subject_name_nodes)\n mods_subject_name_nodes.each_with_index do |sn, i|\n subjects.merge!(extract_subject_values_and_attributes(sn, template_subject_name_nodes[i]))\n end\n mods_subject_other_nodes.each_with_index do |su, i|\n subjects.merge!(extract_subject_values_and_attributes(su, template_subject_other_nodes[i]))\n end\n subjects.merge!(extract_other_geo_subjects(mods_subject_nodes, template_subject_nodes))\n end",
"def find_templates(name, prefix, partial, details)\n # checks if the format has a fallback chain\n if @fallback_formats.has_key?(details[:formats].first)\n details = details.dup\n details[:formats] = Array.wrap(@fallback_formats[details[:formats].first]) \n end\n super(name, prefix, partial, details)\n end",
"def find_by_rel(matching_rel)\n resource_templates.select{|resource_template| matching_rel === resource_template.rel}\n end",
"def find_template(name)\n TEMPLATES.find do |fn, _|\n fn == name || fn.split('.').first == name\n end\n end",
"def search_document_with_template_get(type, id, template, opts = {})\n data, _status_code, _headers = search_document_with_template_get_with_http_info(type, id, template, opts)\n return data\n end",
"def find_by_type(types); end",
"def find_by_type(types); end",
"def select_template template\n\t\tpage_div = $browser.div(:xpath => \"//div[@class='template-categories_category-name'][contains(text(), '\"+template+\"')]\")\n\t\tpage_div.click\n\tend",
"def lookup_template(name)\n @templates.fetch(name.to_s) { |k| @parent ? @parent.lookup_template(k) : nil }\n end",
"def list_find_by_type(type, options = {})\n list_find({\n :type => subject,\n }.merge(options))\n end",
"def find_subject(name)\n self.subjects.each { |subject|\n if subject.name == name\n return subject\n end\n }\n return nil\n end",
"def pdf_template\n valid_templates = %w(standard f90)\n params[:template] && valid_templates.include?(params[:template]) ? params[:template] : valid_templates.first\n end",
"def selecttemplate\n\t@templates = JobTemplate.all\n end",
"def try_picking_template_for_path(template_path)\n self.view_paths.find_template(template_path, template_format)\n end",
"def try_picking_template_for_path(template_path)\n self.view_paths.find_template(template_path, template_format)\n end",
"def find(template, &b)\n if key = domain(template)\n # indexed search\n return @bin[key]\n else\n # liner search\n return @bin.values.find {|val| yield(val)}\n end\n end",
"def find_templates(path)\n templates = []\n Find.find(path) do |path|\n templates << path if template?(path)\n end\n templates\n end",
"def get_template(template); end",
"def templates\n @templates ||= TemplateFinder.new(path, types)\n end",
"def get_templates(type)\n Dir[get_template_location << type << '/*']\n end",
"def search_templates(opts = {})\n data, _status_code, _headers = search_templates_with_http_info(opts)\n data\n end",
"def find_templates( name, prefix, partial, details )\n Rails.logger.debug \"Called RedisTemplateResolver\"\n\n return [] unless name.start_with?( \"redis:\" ) \n if respond_to?( :resolver_guard, true )\n return [] unless resolver_guard( name, prefix, partial, details )\n end\n\n\n _, @template_name = name.split(':', 2 )\n Rails.logger.debug \"RedisTemplateResolver fetching template with name: #{@template_name}\"\n\n template_body = fetch_template\n\n path = ActionView::Resolver::Path.build( name, prefix, nil )\n handler = ActionView::Template.handler_for_extension( self.template_handler_name )\n \n template = ActionView::Template.new( template_body, path, handler,\n :virtual_path => path.virtual,\n :format => [ :html ],\n :updated_at => Time.now )\n return [ template ]\n end",
"def find_template(state)\n view.find_template expanded_view_templates_for(state)\n end",
"def determine_template(options); end",
"def template_options(org_id, funder_id)\n @templates = []\n\n if org_id.present? || funder_id.present?\n if funder_id.blank?\n # Load the org's template(s)\n if org_id.present?\n org = Org.find(org_id)\n @templates = Template.valid.where(published: true, org: org, customization_of: nil).to_a\n @msg = _(\"We found multiple DMP templates corresponding to the research organisation.\") if @templates.count > 1\n end\n\n else\n funder = Org.find(funder_id)\n # Load the funder's template(s)\n @templates = Template.valid.where(published: true, org: funder).to_a\n\n if org_id.present?\n org = Org.find(org_id)\n\n # Swap out any organisational cusotmizations of a funder template\n @templates.each do |tmplt|\n customization = Template.valid.find_by(published: true, org: org, customization_of: tmplt.dmptemplate_id)\n if customization.present? && tmplt.updated_at < customization.created_at\n @templates.delete(tmplt)\n @templates << customization\n end\n end\n end\n\n @msg = _(\"We found multiple DMP templates corresponding to the funder.\") if @templates.count > 1\n end\n end\n\n # If no templates were available use the generic templates\n if @templates.empty?\n @msg = _(\"Using the generic Data Management Plan\")\n @templates << Template.default\n end\n\n @templates = @templates.sort{|x,y| x.title <=> y.title } if @templates.count > 1\n end",
"def get_templates_in_page(title, limit = @query_limit_default)\n params = {\n prop: 'templates',\n titles: title,\n tllimit: get_limited(limit)\n }\n\n query(params) do |return_val, query|\n pageid = query['pages'].keys.find { |id| id != '-1' }\n return unless pageid\n templates = query['pages'][pageid].fetch('templates', [])\n return_val.concat(templates.collect { |template| template['title'] })\n end\n end",
"def resource_and_found_template(template_path, options = {})\n resource, template = template_path.split('/')\n\n raw_template_path = find_template_path(resource, template, options)\n found_template = raw_template_path.split('/').last if raw_template_path\n\n [resource, found_template]\n end",
"def possible_templates\n\t\tif !params[:funder].nil? && params[:funder] != \"\" && params[:funder] != \"undefined\" then\n\t\t\tfunder = Organisation.find(params[:funder])\n\t\telse\n\t\t\tfunder = nil\n\t\tend\n\t\tif !params[:institution].nil? && params[:institution] != \"\" && params[:institution] != \"undefined\" then\n\t\t\tinstitution = Organisation.find(params[:institution])\n\t\telse\n\t\t\tinstitution = nil\n\t\tend\n\t\ttemplates = {}\n\t\tunless funder.nil? then\n\t\t\tfunder.published_templates.each do |t|\n\t\t\t\ttemplates[t.id] = t.title\n\t\t\tend\n\t\tend\n\t\tif templates.count == 0 && !institution.nil? then\n\t\t\tinstitution.published_templates.each do |t|\n\t\t\t\ttemplates[t.id] = t.title\n\t\t\tend\n\t\t\tinstitution.children.each do |o|\n\t\t\t\to.published_templates.each do |t|\n\t\t\t\t\ttemplates[t.id] = t.title\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: templates.to_json }\n\t\tend\n\tend",
"def get_resource(resource_type, filter = {})\n fail \"resource_type must be specified\" if resource_type.nil?\n\n # Ensure the hash key is correct when searching\n hash_key = resource_type.to_s.upcase\n hash_key = 'VMTEMPLATE' if hash_key == 'TPL' || hash_key == 'TEMPLATE'\n\n if filter.empty?\n Chef::Log.warn(\"get_resource: 'name' or 'id' must be provided\")\n return nil\n end\n pool = get_pool(resource_type)\n\n if resource_type.to_s != 'user' && filter[:id] && !filter[:id].nil?\n pool.info!(-2, filter[:id].to_i, filter[:id].to_i)\n return pool.first\n end\n\n if resource_type.to_s == 'user'\n pool.info\n else\n pool.info!(-2, -1, -1)\n end\n resources = []\n pool.each do |res|\n next unless res.name == filter[:name]\n next if filter[:uname] && res.to_hash[hash_key]['UNAME'] != filter[:uname]\n resources << res\n end\n return nil if resources.empty?\n return resources[0] if resources.size == 1\n resources\n end",
"def set_mail_templates\n @site = Site.find(params[:contact][:site_id])\n @user_template = MailTemplate.find_by(site_id: @site.id, locale: I18n.locale, recipient_type: 'user', template_type: 'contact')\n @admin_template = MailTemplate.find_by(site_id: @site.id, recipient_type: 'admin', template_type: 'contact')\n end",
"def xxx_find_templates_on_img_with_dynamic_threshold(template_path, image_path, output_path = '')\n logc(\"method: #{__method__}, params: '#{template_path}', #{image_path}, #{output_path}\")\n\n ts = Time.now\n\n calculated_threshold = nil\n current_density = nil\n\n min_threshold = 0.6\n max_threshold = 0.8\n threshold_with_no_results = max_threshold\n threshold_step = 0.02\n accepted_density = 80.0\n\n\n res = find_templates_on_img(template_path, image_path, output_path)\n\n # case of 'not found'\n # decrease threshold to ensure that image does not contains templates or find templates\n if res[\"found\"] == 0\n logc(\"Enter to cycle of decreasing threshold to ensure that image does not contains templates or find templates\")\n while true\n logc(\"Cycle of decreasing threshold\")\n\n threshold_with_no_results = res[\"threshold\"]\n previous_threshold = res[\"threshold\"]\n next_threshold = previous_threshold - threshold_step\n\n logc(\"Can't find templates on the screen with threshold '#{threshold_with_no_results}'.\" +\n \" Decreasing threshold to '#{next_threshold}'\")\n\n if next_threshold <= min_threshold\n calculated_threshold = previous_threshold\n logc(\"Next threshold value '#{next_threshold}' smaller or equal than min threshold '#{min_threshold}'.\" +\n \" End calculation with threshold value '#{calculated_threshold}'.\")\n break\n end\n\n res = find_templates_on_img(template_path, image_path, nil, next_threshold)\n if res[\"found\"] != 0\n logc(\"Found '#{res[\"found\"]}' templates on the screen with threshold '#{next_threshold}'\" +\n \" Exit from 'decreasing threshold' cycle to function to find accepted level of density\")\n break\n end\n end\n end\n\n # case of 'found' or 'calculated_threshold' is still 'nil'\n # increase threshold to reach 'accepted_density' or 'max_threshold' or 'threshold_with_no_results'\n if calculated_threshold.nil? && !res[\"point_clouds\"].to_s.empty?\n logc(\"Enter to cycle of increasing threshold to\" +\n \" reach 'accepted_density' or 'max_threshold' or 'threshold_with_no_results'\")\n while true\n logc(\"Cycle of increasing threshold\")\n\n previous_threshold = res[\"threshold\"]\n current_density = res[\"found\"].to_f / res[\"point_clouds\"].to_f\n next_threshold = previous_threshold + threshold_step\n\n logc(\"Found '#{res[\"point_clouds\"]}' point clouds.\" +\n \" Increasing threshold to '#{next_threshold}'\")\n\n if current_density <= accepted_density\n calculated_threshold = previous_threshold\n logc(\"Accepted density '#{accepted_density}' reached with value '#{current_density}'.\" +\n \" End calculation with threshold value '#{calculated_threshold}'.\")\n break\n end\n\n if next_threshold >= threshold_with_no_results\n calculated_threshold = previous_threshold\n logc(\"Next threshold value '#{next_threshold}' greater or equal\" +\n \" than threshold with no results '#{threshold_with_no_results}'.\" +\n \" End calculation with threshold value '#{calculated_threshold}'.\")\n break\n end\n\n if next_threshold >= max_threshold\n calculated_threshold = previous_threshold\n logc(\"Next threshold value '#{next_threshold}' greater or equal than max threshold '#{max_threshold}'.\" +\n \" End calculation with threshold value '#{calculated_threshold}'.\")\n break\n end\n\n res = find_templates_on_img(template_path, image_path, nil, next_threshold)\n\n if res[\"point_clouds\"].to_s.empty?\n calculated_threshold = previous_threshold\n\n logc(\"Next threshold value '#{next_threshold}' cause 'not found' result.\" +\n \"Exit from 'increasing threshold' cycle with threshold value '#{calculated_threshold}'.\")\n break\n end\n end\n end\n\n assert_false_custom(calculated_threshold.nil?,\n \"Function logic fail. After set of conditions threshold value must be found.\")\n\n\n logc(\"Threshold for template '#{File.basename(template_path)}' calculated.\" +\n \"\\n Accepted threshold value: '#{calculated_threshold}'.\" +\n \"\\n Calculated density: '#{current_density}'.\" +\n \"\\n Time spent for threshold calculating: #{(Time.now - ts)}s\" +\n \"\\n In the end - Finding template with calculated threshold to return it\")\n\n if !res.nil? && (res[\"threshold\"] == calculated_threshold)\n # result with calculated threshold is already exist and saved in res variable\n logc(\"Template with calculated threshold is already found and saved in 'res' variable. Return it\")\n else\n # get result with calculated threshold\n res = find_templates_on_img(template_path, image_path, output_path, calculated_threshold)\n end\n\n return res\nend",
"def template_for(filename, opts = {})\n # A bunch of potential matches in order of preference.\n candidates = if Gluttonberg.localized?\n # Locale and dialect\n # Locale only\n # Default\n [\n \"#{filename}.#{opts[:locale].slug}.#{opts[:dialect].code}\",\n \"#{filename}.#{opts[:locale].slug}\",\n \"#{filename}\"\n ]\n elsif Gluttonberg.translated?\n # Dialect\n # Default\n [\n \"#{filename}.#{opts[:dialect].code}\",\n \"#{filename}\"\n ]\n else\n [\"#{filename}.*\"]\n end\n # Loop through them and return the first match\n for candidate in candidates \n path = template_dir / candidate + \".*\"\n matches = Dir.glob(path)\n return candidate unless matches.empty?\n end\n # This nil has to be here, otherwise the last evaluated object is \n # returned, in this case the candidates hash.\n nil\n end",
"def get_resource_tpl(term)\n list_resource_tpl.to_a.select { |m| m.term == term }.first\n end",
"def search_validate_with_template_get(type, template, opts = {})\n data, _status_code, _headers = search_validate_with_template_get_with_http_info(type, template, opts)\n return data\n end",
"def scan_templates\r\n @templates = Dir.glob(File.join(path, \"*\")).inject([]) do |list, file_path|\r\n log.debug \"Checking if #{file_path} is a recognised template file.\"\r\n if File.file?(file_path)\r\n file_name = File.basename(file_path)\r\n log.debug \"#{file_path} is a template file.\" if !(Tilt[file_name]).nil?\r\n list << file_path if !(Tilt[file_name]).nil?\r\n end\r\n list\r\n end\r\n end",
"def find_templates_on_the_screen(template_path, output_file_path = '', threshold = 0.8)\n logc(\"method: #{__method__}, params: '#{template_path}', #{output_file_path}, '#{threshold}',\")\n\n screenshot_path = prepare_screenshot(\"screenshot.png\", true, false)\n\n res_of_finding = find_templates_on_img(template_path, screenshot_path, output_file_path, threshold)\n\n return res_of_finding\nend",
"def search_mappings_with_template_get(type, template, opts = {})\n data, _status_code, _headers = search_mappings_with_template_get_with_http_info(type, template, opts)\n return data\n end",
"def find_unread template, read, fetch = true\n each_unread(read) do |m|\n if m =~ template\n if fetch\n return m\n else\n return m.id\n end\n end\n end\n\n nil\n end",
"def pmatch(subject)\n return nil unless (Hash === subject)\n \n b = MatchBinding.new\n\n # this pattern is successful iff each key value pair in it\n # successfully matches some key value pair in the subject.\n n_matched = 0\n\n patternhash = @args[0]\n\n patternhash.each { |pk,pv|\n if pk.instance_of? Literal # special case this to avoid linear search\n realkey = pk.val\n\n return nil unless (subject.has_key? realkey)\n bb = PatternMatch::matchfunc(pv, subject[realkey])\n return nil if !bb\n\n b.mix bb\n \n # match succeeded\n n_matched += 1\n else\n # Search for a key matching the pattern. Search is in arbitrary order.\n subject.each { |sk,sv|\n key_b = PatternMatch::matchfunc(pk, sk)\n next if !key_b\n\n val_b = PatternMatch::matchfunc(pv, sv)\n next if !val_b\n \n b.mix key_b\n b.mix val_b\n\n # match succeeded, stop searching\n n_matched += 1\n break\n }\n end\n }\n\n return nil if (n_matched < @args.size)\n\n b\n end",
"def get_templates_on_the_screen(template_path, threshold = 0.8)\n logc(\"method: #{__method__}, params: '#{template_path}', '#{threshold}',\")\n\n res_image_path = File.join(@report_path,\n \"#{@scenario_name.to_s.gsub(\" \", \"_\").downcase}\" +\n \"_result_find_template_\" +\n \"#{File.basename(template_path)}\")\n\n res_of_finding = find_templates_on_the_screen(template_path, res_image_path, threshold)\n\n return res_of_finding, res_image_path\nend",
"def try_templates(*templates)\n try_sources(templates, :templates)\n end",
"def find_by_generic(name, type = nil)\n if name.nil?\n return nil\n elsif not name.is_a? String\n name = name.to_s\n end\n\n name = name.downcase\n @ghash.dup.each_value do |o|\n if type.nil?\n if o.generic.downcase == name or o.name.downcase == name or o.alt_names.find {|n| n.downcase == name }\n return o\n end\n else\n if o.is_a? type and (o.generic.downcase == name or o.name.downcase == name or o.alt_names.find {|n| n.downcase == name })\n return o\n end\n end\n end\n\n return nil\n end",
"def test_subject_templates\n @subject_templates.each { |template| \n puts render_subject(template) \n }\n end",
"def find_template(template, environment = nil)\n if template == File.expand_path(template)\n return template\n end\n\n if template_paths = templatepath(environment)\n # If we can find the template in :templatedir, we return that.\n template_paths.collect { |path|\n File::join(path, template)\n }.each do |f|\n return f if FileTest.exist?(f)\n end\n end\n\n # check in the default template dir, if there is one\n if td_file = find_template_in_module(template, environment)\n return td_file\n end\n\n nil\n end",
"def find(name)\n Template.find(name)\n end",
"def dereference_template(t_key, template, parameters, flagged = [])\n template = template.to_smash\n translator = translator_for(t_key, template, parameters)\n flagged.each do |item|\n translator.flag_ref(item)\n end\n template.keys.each do |t_key|\n next if [\"Outputs\", \"Resources\"].include?(t_key)\n template[t_key] = translator.dereference_processor(\n template[t_key], [\"DEREF\"]\n )\n end\n translator.original.replace(template)\n [\"Outputs\", \"Resources\"].each do |t_key|\n if template[t_key]\n template[t_key] = translator.dereference_processor(\n template[t_key], [\"DEREF\", :all]\n )\n end\n end\n if template[\"Resources\"]\n valid_resources = template[\"Resources\"].map do |resource_name, resource_value|\n if resource_value[\"OnCondition\"]\n if translator.apply_condition(resource_value[\"OnCondition\"])\n resource_name\n end\n else\n resource_name\n end\n end.compact\n (template[\"Resources\"].keys - valid_resources).each do |resource_to_remove|\n template[\"Resources\"].delete(resource_to_remove)\n end\n end\n translator.original.replace({})\n template\n end",
"def search(type, name, return_type = \"default\")\n\n #Search in exercise_list\n if type == \"exercise\"\n\n #Stops if exercise list is empty\n if @exercise_list.empty? == true\n return -1\n end\n\n #Search the array for the given name\n for i in 0..@exercise_list.size-1 do\n\n if @exercise_list[i].name == name\n\n if return_type == \"default\"\n return i\n elsif return_type == \"object\"\n return @exercise_list[i]\n end\n end\n end\n return -1\n\n #Search in workout_routines\n elsif type == \"workout\"\n\n #Stops if workout_routines is empty\n if @workout_routines.empty? == true\n return -1\n end\n\n #Search the array for the given name\n for i in 0..@exercise_list.size-1 do\n\n if @workout_routines[i].name == name\n\n if return_type == \"default\"\n return i\n elsif return_type == \"object\"\n return @workout_routines[i]\n end\n end\n end\n return -1\n\n #Error handling\n else\n return -1\n end\n end",
"def get_course_template_by_name(org_unit_name)\n course_template_not_found = true\n course_template_results = []\n puts \"[+] Searching for templates using search string: \\'#{org_unit_name}\\'\".yellow\n results = get_all_course_templates\n results.each do |x|\n if x['Name'].downcase.include? org_unit_name.downcase\n course_template_not_found = false\n course_template_results.push(x)\n end\n end\n if course_template_not_found\n puts '[-] No templates could be found based upon the search string.'.yellow\n end\n course_template_results\n # return: JSON array of matching course template data objects\nend",
"def subject_type(classification=nil)\n type = generates_subject_type\n config = sub_tool_config classification\n # If this task specifies an array of tools, look for tool-specific subject type:\n if config && config[:generates_subject_type]\n type = config[:generates_subject_type]\n end\n\n type\n end",
"def candidate_job_templates\n company_candidate_docs.where(document_for: 'Candidate', title_type: 'Job', is_require: 'signature')\n end",
"def get(templates = nil)\n templates = QuestionTemplate.random(5) if templates.nil? || templates.empty?\n\n questions = []\n templates.each do |template|\n existing_question = Question.where(question_template_id: template, place_id: @place).order(\"random()\").first\n if existing_question.blank?\n questions += QuestionGenerator.generate!([template], @place)\n else\n questions << existing_question\n end\n end\n return questions unless questions.empty?\n\n QuestionGenerator.generate! templates, @place\n end",
"def subject_type(classification=nil)\n type = generates_subject_type\n # If classification has subToolIndex and this task specifies a tools array, determine the tool-specific generates_subject_type\n if ! classification.nil? && ! (subToolIndex = classification.annotation[\"subToolIndex\"]).nil?\n type = find_tool_box(subToolIndex.to_i)[:generates_subject_type]\n end\n\n type\n end",
"def search_explain_with_template_get(type, id, template, opts = {})\n data, _status_code, _headers = search_explain_with_template_get_with_http_info(type, id, template, opts)\n return data\n end",
"def templates_select_tag\r\n templates = MailTasks::Template.find( :all, :order => \"name\" )\r\n template_options = templates.collect{ |template| [template.name, template.id] }.unshift( ['-- Pre-set templates --', nil] )\r\n select :tasks, :template_id, template_options\r\n end",
"def params_by_type(type)\n @params_types[type] ||= @params.select do |k, v|\n @params[k][:options]['tagPosition'] == type.to_s.capitalize\n end\n end",
"def take_all template\n messages = []\n\n tsync do\n indexes = []\n\n @takable.each_with_index do |m, i|\n if m =~ template\n indexes << i\n messages << m\n end\n end\n\n indexes.each do |i|\n @takable[i] = nil\n end\n\n @takable.compact! if indexes.any?\n end\n\n messages\n end",
"def get_template(params)\n if params[:file_path]\n return get_template_from_file(params[:file_path])\n elsif params[:template]\n return params[:template]\n else\n raise 'A valid template file path or template text is required.'\n end\n end",
"def get_template(template)\n xapi.VM.get_by_name_label(template).first\n end",
"def get_template(template)\n xapi.VM.get_by_name_label(template).first\n end",
"def template_id_for_test\n if not_tested_yet_template_ids.any?\n # templates were never checked in the past. Order is not important.\n not_tested_yet_template_ids.first\n elsif recent_template_tests.any?\n # all templates to be scheduled were tested in the past\n # return farthest tested in time template_id\n farthest_tested_template_id\n end\n end",
"def get_item_template\n get_type_template(@source.types)\n end",
"def subject_for(template, attributes = {})\n subject = EmailTemplate.subject_for(template)\n subject = I18n.t(\"email_templates.#{template}.default_subject\") if subject.nil?\n subject = \"No Subject\" if subject.nil?\n Florrick.convert(subject, add_default_attributes(attributes))\n end",
"def _pick_template(template_path)\n return template_path if template_path.respond_to?(:render)\n\n path = template_path.sub(/^\\//, '')\n if m = path.match(/(.*)\\.(\\w+)$/)\n template_file_name, template_file_extension = m[1], m[2]\n else\n template_file_name = path\n end\n\n # OPTIMIZE: Checks to lookup template in view path\n if template = self.view_paths[\"#{template_file_name}.#{template_format}\"]\n template\n elsif template = self.view_paths[template_file_name]\n template\n elsif (first_render = @_render_stack.first) && first_render.respond_to?(:format_and_extension) &&\n (template = self.view_paths[\"#{template_file_name}.#{first_render.format_and_extension}\"])\n template\n elsif template_format == :js && template = self.view_paths[\"#{template_file_name}.html\"]\n @template_format = :html\n template\n else\n template = ActionView::Template.new(template_path, view_paths)\n template.registerView(self)\n\n if self.class.warn_cache_misses && logger\n logger.debug \"[PERFORMANCE] Rendering a template that was \" +\n \"not found in view path. Templates outside the view path are \" +\n \"not cached and result in expensive disk operations. Move this \" +\n \"file into #{view_paths.join(':')} or add the folder to your \" +\n \"view path list\"\n end\n\n template\n end\n end",
"def extract_subject_values_and_attributes(mods_node, template_node)\n return {} if mods_node == nil || template_node == nil\n subject_values_and_attributes = {}\n subject_values_and_attributes.merge!(extract_attributes(mods_node, template_node))\n # Skip empty-space text nodes\n mods_children = mods_node.children.map {|x| x if x.content.match(/\\S/)}.compact\n template_children = template_node.children.map {|x| x if x.content.match(/\\S/)}.compact\n # Skip titleInfo in template if not present in data - template uses snX:p2\n # for both titleInfo and topic etc. subject type, throwing off the index matching if the\n # data uses the second p2 pattern and not the first.\n child_subject_types = mods_children.map {|x| x.name}\n if child_subject_types.include?('name') && !child_subject_types.include?('titleInfo')\n template_children.delete(template_children[1])\n end\n mods_children.each_with_index do |s, i|\n subject_values_and_attributes.merge!(extract_subject_child_attributes_and_values(s, template_children[i]))\n end\n subject_values_and_attributes\n end",
"def xxx_find_templates_on_the_screen(template_path, output_file_path = '')\n logc(\"method: #{__method__}, params: '#{template_path}', #{output_file_path}\")\n\n screenshot_path = prepare_screenshot(\"screenshot.png\", true, false)\n\n res_of_finding = find_templates_on_img_with_dynamic_threshold(template_path, screenshot_path, output_file_path)\n\n return res_of_finding\nend",
"def select_and_fill_templates\n template = @user_input.select_template(@label_printer)\n label = fill_in_the_template(template[:text], LABEL_TEMPLATE_NAME)\n @labels << {TEMPLATE_KEY => template[:name]}.merge!(label)\n\n # ask if the user would like to add another label to the print\n select_and_fill_templates if @user_input.another_label?\n\n {:labels => @labels }\n end",
"def template_content(name)\n templates.select { |t| t[:name] = name || 'index' }.first[:template]\n end",
"def get_subject_other_nodes(mods_subject_nodes, template_subject_nodes, mods_subject_name_nodes)\n mods_subject_other_nodes = mods_subject_nodes.xpath(\"#{@ns}:topic|#{@ns}:geographic|#{@ns}:temporal|#{@ns}:genre\").map {|x| x.parent}.uniq\n mods_subject_other_nodes.map {|x| mods_subject_other_nodes.delete(x) if mods_subject_name_nodes.include?(x)}\n template_subject_other_nodes = template_subject_nodes.grep(/su[\\d]+:/)\n return mods_subject_other_nodes, template_subject_other_nodes\n end",
"def for_subjects(subjects)\n result = Hash[subjects.map {|node| [node, false]}]\n subjects_by_id = Hash[subjects.map {|subject| [subject.id, subject]}]\n subject_rlshp_sources = Hash.new { |h, k| h[k] = [] }\n [:subject, :subject_agent_subrecord, :subject_agent_subrecord_place].each do |t|\n Subject.relationship_dependencies[t].each { |d| subject_rlshp_sources[d] << t }\n end\n\n subject_rlshp_sources.each do |model, sources|\n sources.each do |source|\n # i.e. one or more: subject_rlshp, subject_agent_subrecord_rlshp, subject_agent_subrecord_place_rlshp\n link_relationship = model.find_relationship(source)\n link_table = link_relationship.table_name\n\n link_relationship.reference_columns_for(model).each do |model_link_column|\n link_relationship.reference_columns_for(Subject).each do |subject_link_column|\n # Join subject_rlshp to (e.g.) accession\n linked_records = model\n .join(link_table,\n Sequel.qualify(link_table, model_link_column) => Sequel.qualify(model.table_name, :id))\n .filter(Sequel.qualify(link_table, subject_link_column) => subjects_by_id.keys)\n .select(Sequel.qualify(model.table_name, :id),\n Sequel.qualify(model.table_name, :publish),\n Sequel.qualify(model.table_name, :suppressed),\n Sequel.as(Sequel.qualify(link_table, subject_link_column),\n :subject_id))\n\n if model.columns.include?(:repo_id)\n linked_records = linked_records\n .select_append(Sequel.as(Sequel.qualify(model.table_name, :repo_id),\n :repository_id))\n end\n\n published_status = if model.included_modules.include?(TreeNodes)\n for_tree_nodes(linked_records\n .select_append(Sequel.qualify(model.table_name, :parent_id),\n Sequel.qualify(model.table_name, :root_record_id))\n .all)\n elsif model.to_s =~ /^Agent/\n for_agents_linked_to_subject(linked_records.all)\n else\n for_top_level_records(linked_records.all)\n end\n\n published_status.each do |linked_record, published|\n if published\n result[subjects_by_id.fetch(linked_record[:subject_id])] = true\n end\n end\n end\n end\n end\n end\n\n result\n end",
"def handle_subjects(subjects)\n subjects.each do |link|\n subject = link['_resolved']\n term, *terms = subject['terms']\n ind1 = ' '\n code, *ind2 = case term['term_type']\n when 'uniform_title'\n value = term['term'].split(\" \")[0]\n first_indicator = '0'\n if value\n hsh = {}\n hsh['A'] = '2'\n hsh['An'] = '3'\n hsh['The'] = '4'\n articles = []\n articles = hsh.keys\n first_indicator = hsh[value] if articles.include?(value)\n end\n ['630', first_indicator, source_to_code(subject['source'])]\n when 'temporal'\n ['648', source_to_code(subject['source'])]\n when 'topical'\n ['650', source_to_code(subject['source'])]\n when 'geographic', 'cultural_context'\n ['651', source_to_code(subject['source'])]\n when 'genre_form', 'style_period'\n ['655', source_to_code(subject['source'])]\n when 'occupation'\n ['656', '7']\n when 'function'\n ['656', '7']\n else\n ['650', source_to_code(subject['source'])]\n end\n\n sfs = [['a', term['term']]]\n\n terms.each do |t|\n tag = case t['term_type']\n when 'uniform_title'; 't'\n when 'genre_form', 'style_period'; 'v'\n when 'topical', 'cultural_context'; 'x'\n when 'temporal'; 'y'\n when 'geographic'; 'z'\n end\n sfs << [tag, t['term']]\n end\n\n # code borrowed from Yale to export subject authority id\n unless subject['authority_id'].nil?\n sfs << ['0', subject['authority_id']]\n end\n\n \n # N.B. ind2 is an array at this point.\n if ind2[0] == '7'\n sfs << ['2', subject['source']]\n end\n\n # adding this code snippet because I'm making ind2 an array\n # for code 630 if the title begins with an article\n if (ind2.is_a?(Array) && code == '630')\n ind1, ind2 = ind2\n else\n ind2 = ind2[0]\n end\n\n df!(code, ind1, ind2).with_sfs(*sfs)\n end\n end",
"def find_by_type( type )\n\t\t\treturn @messages[ type ]\n\t\tend",
"def getpsu_t (questionChild,type,number,ask,hashNames)\r\n name=\"#{type}_#{number}\"\r\n getContainsKey(hashNames,type,name)\r\n erbTemplate = getTemplate(\"../encuestas/templates/psu_t.template\",binding)\r\n return erbTemplate.to_s\r\n end",
"def current_subject_from_session\n return unless session[:subject_type].present? && session[:subject_id].present?\n\n session[:subject_type].constantize.find session[:subject_id]\n end",
"def extract_other_geo_subjects(mods_subject_nodes, template_subject_nodes)\n geo_subjects = {}\n ['cartographics', 'hierarchicalGeographic'].each do |gs|\n mods_subject_geo_nodes = mods_subject_nodes.xpath(\"#{@ns}:#{gs}\")\n next if mods_subject_geo_nodes == nil\n template_subject_geo_nodes = template_subject_nodes.xpath(\"#{@ns}:#{gs}\")\n mods_subject_geo_nodes.each_with_index do |c, i|\n geo_subjects.merge!(extract_child_attributes_and_values(c, template_subject_geo_nodes[i]))\n end\n end\n geo_subjects\n end",
"def subjects_with_permission(type, permission)\n raise Exceptions::NotACanHazSubject unless type.respond_to?(:acts_as_canhaz_subject)\n permissions = self.permissions_subjects.where(:type => self.class.to_s, :permission => permission.to_s)\n type.in(:id => permissions.collect(&:csubject_id))\n end",
"def template_folder_for clazz\n # Search the potential matches in reverse order\n # because subclasses have registered AFTER their\n # superclasses and superclasses match the ===\n # check...\n generator_paths.reverse.each do |options|\n if options[:class] === clazz\n return options[:templates]\n end\n end\n nil\n end",
"def matching_attribute_subject_type\n attribute_subject_type.present? ? table[:attribute_subject_type].eq(attribute_subject_type) : nil\n end",
"def apply(template)\n result = JMESPath.search(search_expression, template)\n run(result, template)\n end",
"def get_subject_name_nodes(mods_subject_nodes, template_subject_nodes)\n mods_subject_name_nodes = mods_subject_nodes.xpath(\"#{@ns}:name|#{@ns}:titleInfo\").map {|x| x.parent}.uniq\n template_subject_name_nodes = template_subject_nodes.grep(/sn[\\d]+:/)\n return mods_subject_name_nodes, template_subject_name_nodes\n end"
] | [
"0.81796455",
"0.58211565",
"0.5803445",
"0.57706887",
"0.5744465",
"0.5616418",
"0.5597275",
"0.55395097",
"0.5475793",
"0.5350764",
"0.5311171",
"0.52903205",
"0.5176038",
"0.5120756",
"0.51200044",
"0.5076966",
"0.5029992",
"0.50119627",
"0.4992376",
"0.4988387",
"0.49409124",
"0.49186",
"0.4913945",
"0.48968548",
"0.48965773",
"0.48942807",
"0.48879123",
"0.48879123",
"0.48704195",
"0.48690894",
"0.4858717",
"0.48565876",
"0.4853997",
"0.48398712",
"0.48385775",
"0.48385775",
"0.48330477",
"0.48308682",
"0.4788294",
"0.4776465",
"0.4758381",
"0.47379816",
"0.4733367",
"0.47276193",
"0.47101775",
"0.46976694",
"0.46958247",
"0.46929532",
"0.46811247",
"0.46796998",
"0.46776512",
"0.466125",
"0.4660842",
"0.46600774",
"0.46228507",
"0.46180707",
"0.45912537",
"0.45744285",
"0.45728832",
"0.4569007",
"0.4564345",
"0.45641866",
"0.45601374",
"0.45573914",
"0.45398903",
"0.4531489",
"0.4523357",
"0.45086968",
"0.45043865",
"0.44941634",
"0.44941422",
"0.4484556",
"0.44683167",
"0.44673553",
"0.44506824",
"0.44504386",
"0.4444667",
"0.44355652",
"0.44216764",
"0.44216764",
"0.44201428",
"0.4419161",
"0.440069",
"0.43986493",
"0.43951607",
"0.43882573",
"0.438818",
"0.43820992",
"0.43801534",
"0.43786806",
"0.43763578",
"0.4372142",
"0.435702",
"0.43521577",
"0.43497992",
"0.43464118",
"0.4345086",
"0.43440917",
"0.4330754",
"0.4329986"
] | 0.8161067 | 1 |
Override get_value to perform lexical matching over selected values, infer datatype and perform datatypespecific formatting | def get_value(literal)
if literal.typed?
literal.humanize
else
# Hack to fix incorrect dattime
case literal.to_s
when RDF::Literal::Duration::GRAMMAR
get_value(RDF::Literal::Duration.new(literal))
when RDF::Literal::Date::GRAMMAR
get_value(RDF::Literal::Date.new(literal))
when RDF::Literal::Time::GRAMMAR
get_value(RDF::Literal::Time.new(literal))
when RDF::Literal::DateTime::GRAMMAR
get_value(RDF::Literal::DateTime.new(literal))
when %r(\A-?\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(([\+\-]\d{2}:\d{2})|UTC|Z)?\Z)
# Hack to fix incorrect DateTimes in examples:
get_value(RDF::Literal::DateTime.new(literal))
else
literal.to_s
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatted_value_other(value, type)\n if type == :boolean || (type == :automatic && looks_like_boolean?(value))\n formatted_value_boolean(value)\n elsif type == :date || (type == :automatic && looks_like_date?(value))\n I18n.l(value)\n else # Number or String\n formatted_value_string(value)\n end\n end",
"def formatted_value\n return @value if @value.blank?\n\n set_type\n end",
"def get_value(literal)\n if literal.typed?\n literal.humanize\n else\n # Hack to fix incorrect dattime\n case literal.to_s\n when RDF::Literal::Duration::GRAMMAR\n get_value(RDF::Literal::Duration.new(literal))\n when RDF::Literal::Date::GRAMMAR\n get_value(RDF::Literal::Date.new(literal))\n when RDF::Literal::Time::GRAMMAR\n get_value(RDF::Literal::Time.new(literal))\n when RDF::Literal::DateTime::GRAMMAR\n get_value(RDF::Literal::DateTime.new(literal))\n when %r(\\A-?\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2})?(\\.\\d+)?(([\\+\\-]\\d{2}:\\d{2})|UTC|Z)?\\Z)\n # Hack to fix incorrect DateTimes in examples:\n get_value(RDF::Literal::DateTime.new(literal))\n else\n literal.humanize\n end\n end\n end",
"def value_field_for(rc, v)\n case rc\n when 'datetime'; 'datetime_value'\n when 'date'; Date === v ? 'datetime_value' : 'date_value'\n when 'time'; 'time_value'\n when 'float'; 'float_value'\n when 'integer'; 'integer_value'\n when 'string'; 'string_value'\n when 'text'; 'text_value'\n end\n end",
"def format(value, match)\n return value unless value.is_a? DataAccessor\n return match.get value.name\n end",
"def value_for(**options)\n\t\t\t\t\tif value = raw_value_for(**options)\n\t\t\t\t\t\tself.format(value, **options)\n\t\t\t\t\tend\n\t\t\t\tend",
"def parse_value(val, type)\n return nil if val.nil? || val.to_s.strip == ''\n \n case type\n when :raw then\n val\n \n when :string then\n if val.is_a?(Float)\n # Sometimes float values come in for \"integer\" columns from Excel,\n # so if the user asks for a string, strip off that \".0\" if present\n val.to_s.gsub(/\\.0+$/, '')\n else\n # Strip whitespace and we're good to go\n val.to_s.strip\n end\n \n when :integer, :int then \n if val.class < Numeric\n # If numeric, verify that there's no decimal places to worry about\n if (val.to_f % 1.0 == 0.0)\n val.to_i\n else\n nil\n end\n else \n # Convert to string, strip off trailing decimal zeros\n val = val.to_s.strip.gsub(/\\.0*$/, '')\n if val.integer?\n val.to_i\n else\n nil\n end\n end\n \n when :float then\n if val.class < Numeric\n val.to_f\n else \n # Clean up then verify it matches a valid float format & convert\n val = val.to_s.strip\n if val.match(/\\A-?[0-9]+(?:\\.[0-9]+)?\\z/)\n val.to_f\n else\n nil\n end\n end\n \n when :cents then\n if val.is_a?(String)\n val = val.gsub(/\\s*\\$\\s*/, '')\n end\n intval = parse_value(val, :integer)\n if !val.is_a?(Float) && intval\n intval * 100\n else\n floatval = parse_value(val, :float)\n if floatval\n (floatval * 100).round\n else\n nil\n end\n end\n \n when :date then\n # Pull out the date part of the string and convert\n date_str = val.to_s.extract(/[0-9]+[\\-\\/][0-9]+[\\-\\/][0-9]+/)\n date_str.to_date rescue nil\n \n when :bool then\n val_str = parse_value(val, :string).to_s.downcase\n if ['true','yes','y','t','1'].include?(val_str)\n return true\n elsif ['false','no','n','f','0'].include?(val_str)\n return false\n else\n nil\n end\n \n else\n raise \"Unknown column type #{type.inspect} - unimplemented?\"\n end\n end",
"def parse_value; end",
"def format_value(value, is_const) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/AbcSize\n case value\n when Integer\n format_value_to_integer(value)\n when Float\n format_value_to_float(value)\n when String\n format_value_to_string(value)\n when TrueClass, FalseClass\n format_value_to_boolean(value)\n when NilClass\n format_value_to_null(value)\n when Symbol\n if value.start_with?('$')\n format_value_to_variable(value, is_const)\n else\n format_value_to_enum(value)\n end\n when Array\n format_value_to_list(value, is_const)\n when Hash\n format_value_to_object(value, is_const)\n else\n raise Error.new('Unsupported value type', class: value.class.name, value: value)\n end\n end",
"def get_value(object)\n case value_type\n when 'integer' then object.value_integer\n when 'float' then object.value_float\n when 'string' then object.value_string\n else raise_invalid_type\n end\n end",
"def format(value, match)\n return value unless value.is_a? DataAccessor\n return match.get value.name\n end",
"def format_source(value); end",
"def value\n typecast.present? ? typecasted_value : super\n end",
"def simple_value_type_code\n value_type_code\nend",
"def internal_value_of(value)\n return value if value.respond_to?(:nan?) && value.nan?\n return Float::NAN if [nil, '?'].include?(value)\n return parse_date(value.to_s) if date?\n return value.to_f if numeric?\n return index_of_value(value.to_s) if nominal? || string?\n end",
"def cast_value(v)\r\n return nil if v.nil?\r\n if @type == :date\r\n self.style = STYLE_DATE if self.style == 0\r\n v\r\n elsif (@type == :time && v.is_a?(Time)) || (@type == :time && v.respond_to?(:to_time))\r\n self.style = STYLE_DATE if self.style == 0\r\n # one simple little fix. I DO NOT WANT TIME IN LOCAL TIME!\r\n unless v.is_a?(Time)\r\n v = v.respond_to?(:to_time) ? v.to_time : v\r\n end\r\n v\r\n elsif @type == :float\r\n v.to_f\r\n elsif @type == :integer\r\n v.to_i\r\n elsif @type == :boolean\r\n v ? 1 : 0\r\n elsif @type == :iso_8601\r\n #consumer is responsible for ensuring the iso_8601 format when specifying this type\r\n v\r\n else\r\n @type = :string\r\n # TODO find a better way to do this as it accounts for 30% of\r\n # processing time in benchmarking...\r\n Axlsx::trust_input ? v.to_s : ::CGI.escapeHTML(v.to_s)\r\n end\r\n end",
"def format _label, _value\n raise NotImplementedError, self\n end",
"def value=(val)\n data_type = @data_type = data_type_for_value(val)\n if data_type == TYPE_STRING\n # percentage detection\n percentage_search = PERCENTAGE_RE.match(val)\n if percentage_search && val.strip != '%'\n val = val.gsub('%', '').to_f / 100.0\n set_value_explicit(val, TYPE_NUMERIC)\n style.number_format.format_code = Xl::NumberFormat::FORMAT_PERCENTAGE\n return true\n end\n\n # time detection\n # time_search = TIME_RE.match(val)\n # if time_search\n # sep_count = val.count(':')\n # if sep_count == 1\n # h, m = val.split(':').map(&:to_i)\n # s = 0\n # elsif sep_count == 2\n # h, m, s = val.split(':').map(&:to_i)\n # end\n # days = (h / 24.0) + (m / 1440.0) + (s / 86400.0)\n # set_value_explicit(days, TYPE_NUMERIC)\n # style.number_format.format_code = Xl::NumberFormat::FORMAT_DATE_TIME3\n # return true\n # end\n elsif data_type == TYPE_NUMERIC\n # date detection\n if (Xl::DateHelper.datelike?(val))\n val = Xl::DateHelper.ruby_to_excel(val)\n set_value_explicit(val, TYPE_NUMERIC)\n style.number_format.format_code = Xl::NumberFormat::FORMAT_DATE_YYYYMMDD2\n return true\n end\n end\n set_value_explicit(val, data_type)\n end",
"def format_value(value)\n case value_format\n when Proc\n value_format.call(value)\n when nil\n value.to_f\n else\n value.send value_format\n end\n end",
"def convert_value_by_type\n case self.value_type\n when 'Numeric'\n unless self.multiplier.nil? || self.multiplier.blank?\n val = self.value.include?('.') ? self.value.to_f : self.value.to_i\n return val.send(self.multiplier.to_sym)\n else\n return self.value.to_f\n end\n when 'Boolean'\n return self.value == '1'\n else\n return self.value\n end\n end",
"def value\n dt = raw_value\n return nil if dt.nil? || dt.values.all?(&:blank?)\n\n dt[\"raw_value\"].nil? ? new_style_value_text_repr(dt) : old_style_value_text_repr(dt)\n end",
"def parse_local_value(valuetype)\n value = CGI.unescapeHTML(@cell.xpath(\"text:p//text()\").to_s)\n value = value == \"\" ? nil : value\n case valuetype\n when \"integer\"\n value = @cell.xpath(\"@office:value\").to_s.to_i\n when \"float\"\n value = @cell.xpath(\"@office:value\").to_s.to_f\n value = value.to_i unless @cell.xpath(\"@office:value\").to_s =~ /\\./ # sadly most integers are typed as floats...\n when \"date\"\n value = DateTime.parse(@cell.xpath(\"@office:date-value\").to_s)\n end\n value\n end",
"def prepare_format(value)\n return value.name if value.is_a? Symbol\n IMPLICIT_CONVERSION.inject(value) do |value, (method, type)|\n next value unless value.respond_to? method\n type === value ? value : value.public_send(method)\n end\n end",
"def extract_value_from_default(default)\n super ||\n extract_escaped_string_from_default(default) ||\n extract_time_from_default(default) ||\n extract_empty_array_from_default(default) ||\n extract_decimal_from_default(default)\n end",
"def process_field_value(value)\r\n value\r\n end",
"def formatted_value\n value = params[:value].to_s\n case value\n when value.to_i.to_s\n value.to_i\n when value.to_f.to_s\n value.to_f\n when 'true', 'false'\n value == 'true'\n else\n value\n end\n end",
"def determine_dataype(value)\n return validate_field(value)\n end",
"def value_coercion(value); end",
"def typecast(value)\n if value.kind_of?(Range) then Range.new(typecast(value.first), typecast(value.last))\n elsif value.kind_of?(Array) then value.map{|v| typecast(v)}\n elsif primitive == BigDecimal then super(value).to_f\n elsif primitive == DateTime then Time.parse(super(value).to_s).to_i\n elsif primitive == Date then Time.parse(super(value).to_s).to_i\n elsif primitive == Time then super(value).to_i\n else\n super(value) # Good luck\n end\n end",
"def result\n value.value.each_with_index.map do |literal, idx|\n language = languages[idx]\n type = datatypes[idx]\n if language == \"eng\" && type == \"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString\"\n literal\n elsif language.present?\n RDF::Literal.new(literal, language: language, datatype: type)\n else\n RDF::Literal.new(literal, datatype: type)\n end\n end\n end",
"def cell_type_from_value(v)\n if v.is_a?(Date)\n :date\n elsif v.is_a?(Time)\n :time\n elsif v.is_a?(TrueClass) || v.is_a?(FalseClass)\n :boolean\n elsif v.respond_to?(:to_i) && Axlsx::NUMERIC_REGEX.match?(v.to_s)\n :integer\n elsif v.respond_to?(:to_f) && (Axlsx::SAFE_FLOAT_REGEX.match?(v.to_s) || ((matchdata = MAYBE_FLOAT_REGEX.match(v.to_s)) && matchdata[:exp].to_i.between?(Float::MIN_10_EXP, Float::MAX_10_EXP)))\n :float\n elsif Axlsx::ISO_8601_REGEX.match?(v.to_s)\n :iso_8601\n elsif v.is_a? RichText\n :richtext\n else\n :string\n end\n end",
"def format_value(value)\n case value\n when Numeric\n value.to_s.color(:cyan)\n when String\n value\n when TrueClass\n value.to_s.color(:green)\n when FalseClass\n value.to_s.color(:red)\n when NilClass\n 'nil'.color(:blue)\n else\n value\n end\n end",
"def value_from_lookup string, type\n type == :multi_category ? string.split(VALUE_JOINT) : string\n end",
"def cast_value\n value.mongoize\n end",
"def cast_value(v)\n return v if v.nil? || v.is_a?(RichText)\n\n case type\n when :date\n self.style = STYLE_DATE if style.zero?\n if !v.is_a?(Date) && v.respond_to?(:to_date)\n v.to_date\n else\n v\n end\n when :time\n self.style = STYLE_DATE if style.zero?\n if !v.is_a?(Time) && v.respond_to?(:to_time)\n v.to_time\n else\n v\n end\n when :float\n v.to_f\n when :integer\n v.to_i\n when :boolean\n v ? 1 : 0\n when :iso_8601\n # consumer is responsible for ensuring the iso_8601 format when specifying this type\n v\n else\n v.to_s\n end\n end",
"def type_conversion(value_data, type) \n case type\n when 'boolean'\n return to_boolean(value_data) \n when 'int'\n val = Integer(value_data)\n if (val < -2147483648) || (val > 2147483647)\n raise \"Integer out of range: #{val}\" \n end\n return val\n when 'long'\n val = Integer(value_data)\n if (val < -9223372036854775808) || (val > 9223372036854775807)\n raise \"Long out of range: #{val}\" \n end\n return val\n when 'double'\n return Float(value_data)\n when 'string'\n return value_data\n else\n raise \"Unsupported type: #{type}\" \n end \n end",
"def apply_formatting(value, format = @place.content_format)\n case (format || :raw).to_sym\n when :html\n wiki_as_html(value)\n when :text\n wiki_as_text(value)\n else\n value\n end\n end",
"def value\n @casted_value ||= type_cast_value(@value)\n end",
"def value_type\n return @value_type\n end",
"def casted_value\n case qtype.name\n when 'date' then date_value\n when 'time' then time_value\n when 'datetime' then datetime_value\n when 'integer' then value.blank? ? nil : value.to_i\n when 'decimal' then value.blank? ? nil : value.to_f\n else value.blank? ? nil : value\n end\n end",
"def lenient_value_coercions; end",
"def formatted_value\n @formatted_value\n end",
"def format_value(value, should_format)\n return Hyc::EdtfConvert.convert_from_edtf(value) if should_format && value.to_s.strip =~ /^(\\d{4}|\\d{3}(u|x)|\\d{2}xx|[u]{4})/\n\n value\n end",
"def typecast(value)\n value\n end",
"def value_types; end",
"def formats=(values); end",
"def oracle_data_type_conversion(in_var, data_type, data_scale)\n \n case\n when data_type == \"VARCHAR2\"\n if in_var.nil? or in_var.empty?\n in_var = \"\"\n end\n this_in_var = in_var.to_s\n this_data_type = String\n \n when data_type == \"CHAR\"\n if in_var.nil? or in_var.empty?\n in_var = \"\"\n end\n this_in_var = in_var.to_s\n this_data_type = String\n \n when data_type == \"NUMBER\"\n if !data_scale.nil? and data_scale > 0\n \n this_in_var = in_var.to_f\n this_data_type = Float\n else\n this_in_var = in_var.to_i\n this_data_type = Fixnum\n end\n \n when data_type == \"TIMESTAMP\"\n this_in_var = in_var\n this_data_type = DateTime\n \n when data_type == \"DATE\"\n this_in_var = in_var\n this_data_type = DateTime\n \n else nil\n end \n \n return this_in_var, this_data_type \n end",
"def display_value\n case self.value_type\n when 'Numeric'\n unless self.multiplier.nil? || self.multiplier.blank?\n \"#{self.value} #{self.multiplier}(s) <span class='badge'>#{self.convert_value_by_type} bytes</span>\"\n else\n self.value\n end\n when 'Boolean'\n self.value == '1' ? 'Yes' : 'No'\n else\n self.value\n end\n end",
"def get_value\n if @value != nil\n return @value\n else\n return @df_str\n end\n end",
"def typecast(value)\n value\n end",
"def convert_format(value, definition)\n value || 'html'\n end",
"def value\n to_type(@value)\n end",
"def value_type= value_type\n self.type = value_type.gsub(\"-\", \"_\").camelize\n end",
"def value\n if eng_unit_type\n \"#{data} #{eng_unit_type.tag}\"\n else\n data.to_s\n end\n end",
"def show_value_label_method\n value.to_s\n end",
"def type_cast_for_schema(value)\n cast(value).value.inspect\n end",
"def xml_format_value(value)\n case value\n when Hash\n xml_format(value)\n when Array\n value.map{|v| xml_format_value(v)}\n else\n value.strip!\n if(value == 'true')\n true\n elsif(value == 'false')\n false\n elsif(value.to_i.to_s == value)\n value.to_i\n elsif(value.to_f.to_s == value)\n value.to_f\n else\n value\n end\n end\n end",
"def type_cast_for_solr(value, dest_type = nil)\n return nil if value.nil?\n return coder.dump(value) if encoded?\n\n case (dest_type || type)\n when :boolean then value ? 'true' : 'false'\n when :date, :time, :datetime, :timestamp then value.to_time.utc.strftime(Format::SOLR_TIME_FORMAT)\n when :list, :set then list_to_solr_value(value)\n when :map then map_to_solr_value(value)\n when :uuid, :timeuuid then value.to_s\n else value\n end\n end",
"def type_cast_for_schema(value) # :nodoc:\n value.inspect\n end",
"def format_value row, key\n key_sym = key.to_sym\n if @formatter.has_key? key_sym\n @formatter[key_sym].call row, row[key_sym]\n else\n row[key_sym]\n end\n end",
"def this_value(code, lookup, format, placeholder)\n return placeholder unless placeholder.nil?\n\n values = send(code)\n values = [values] unless values.respond_to? :each\n\n if lookup && format == :list\n this_value_list_format(code, values)\n else\n this_value_standard_format(code, values, lookup, format)\n end\n end",
"def handle_to_get_exotic_type(value)\n data_type = get_data_type\n result = nil\n\n if data_type == TYPE_CSV || data_type == TYPE_IP_LIST\n result = value.join(';')\n elsif data_type == TYPE_IP_RANGE\n ip_ranges = value.map do |range|\n range.split('-').map(&:strip).reject(&:empty?)\n end\n result = IPHelper.to_string ip_ranges\n end\n\n result\n end",
"def value_for(value)\n return value.to_s(:db) if value.kind_of?(Time) \n return value.to_s(:db) if value.kind_of?(Date)\n return value.to_s\n end",
"def datatype_extract(valid_types, value)\n valid_types.find do |type|\n begin\n return type.parse(value) if type.respond_to?(:parse)\n rescue ArgumentError\n end\n end\n nil\n end",
"def type *val\n return @chars_allowed if val.empty?\n\n dtype = val[0]\n #return self if @chars_allowed # disallow changing\n if dtype.is_a? Regexp \n @chars_allowed = dtype\n return self\n end\n dtype = dtype.to_s.downcase.to_sym if dtype.is_a? String\n case dtype # missing to_sym would have always failed due to to_s 2011-09-30 1.3.1\n when :integer, Integer\n @chars_allowed = /\\d/\n when :numeric, :float, Numeric, Float\n @chars_allowed = /[\\d\\.]/ \n when :alpha\n @chars_allowed = /[a-zA-Z]/ \n when :alnum\n @chars_allowed = /[a-zA-Z0-9]/ \n else\n raise ArgumentError, \"Field type: invalid datatype specified. Use :integer, :numeric, :float, :alpha, :alnum \"\n end\n self\n end",
"def render_value(value)\n value.kind_of?(Class) ? value.inspect : value\n end",
"def parse_values; end",
"def format_value(prop,value)\n case prop\n when :plan_id\n case value\n when 'free' then 'Free'\n when 'silver' then 'Silver'\n else value && value.capitalize || nil\n end\n when :visible_to_ssh?\n value || nil\n when :creation_time, :created_at\n date(value)\n when :scales_from,:scales_to\n (value == -1 ? \"available\" : value)\n when :gear_info\n format_gear_info(value)\n when :base_gear_storage,:additional_gear_storage\n ((value.nil? or value == 0) ? \"None\" : \"#{value}GB\")\n when :aliases\n value.kind_of?(Array) ? value.join(', ') : value\n when :expires_in_seconds\n distance_of_time_in_words(value)\n when :activations\n value.collect{|item| date(item.created_at.to_s)}.join(\"\\n\")\n when :auto_deploy\n value ? 'auto (on git push)' : \"manual (use 'rhc deploy')\"\n else\n case value\n when Array then value.empty? ? '<none>' : value.join(', ')\n else value\n end\n end\n end",
"def valid_type_for_conditional_formatting\n {\n 'cell' => 'cellIs',\n 'date' => 'date',\n 'time' => 'time',\n 'average' => 'aboveAverage',\n 'duplicate' => 'duplicateValues',\n 'unique' => 'uniqueValues',\n 'top' => 'top10',\n 'bottom' => 'top10',\n 'text' => 'text',\n 'time_period' => 'timePeriod',\n 'blanks' => 'containsBlanks',\n 'no_blanks' => 'notContainsBlanks',\n 'errors' => 'containsErrors',\n 'no_errors' => 'notContainsErrors',\n '2_color_scale' => '2_color_scale',\n '3_color_scale' => '3_color_scale',\n 'data_bar' => 'dataBar',\n 'formula' => 'expression'\n }\n end",
"def value_type\n @type.value_type\n end",
"def valid_type_for_conditional_formatting\n {\n 'cell' => 'cellIs',\n 'date' => 'date',\n 'time' => 'time',\n 'average' => 'aboveAverage',\n 'duplicate' => 'duplicateValues',\n 'unique' => 'uniqueValues',\n 'top' => 'top10',\n 'bottom' => 'top10',\n 'text' => 'text',\n 'time_period' => 'timePeriod',\n 'blanks' => 'containsBlanks',\n 'no_blanks' => 'notContainsBlanks',\n 'errors' => 'containsErrors',\n 'no_errors' => 'notContainsErrors',\n '2_color_scale' => '2_color_scale',\n '3_color_scale' => '3_color_scale',\n 'data_bar' => 'dataBar',\n 'formula' => 'expression',\n 'icon_set' => 'iconSet'\n }\n end",
"def value_column\n case value_type\n when 'integer' then 'value_integer'\n when 'float' then 'value_float'\n when 'string' then 'value_string'\n else raise_invalid_type\n end\n end",
"def result_value_of(declared_type, value)\n if value.is_a?(::Amalgalite::Blob)\n SQL::Blob.new(value.to_s)\n elsif value.is_a?(String) && declared_type\n (meth = self.class.sql_to_method(declared_type.downcase)) ? send(meth, value) : value\n else\n super\n end\n end",
"def result\n map_value(converted_value: RDF::Literal.new(\n value.value,\n datatype: PermissiveSchema.valkyrie_id\n ))\n end",
"def result\n map_value(converted_value: RDF::Literal.new(\n value.value,\n datatype: PermissiveSchema.valkyrie_id\n ))\n end",
"def convert(value) value end",
"def formatted_value\n formatter = @format.downcase.split(' ').map do |part|\n if (parsed_format = parse_date_or_time_format(part))\n parsed_format\n else\n warn 'Unable to parse custom format. Using \"YYYY-mm-dd HH:MM:SS\" format.'\n return @value.strftime('%F %T')\n end\n end.join(' ')\n\n @value.strftime(formatter)\n end",
"def raw_value; end",
"def datavalue(value)\n merge(datavalue: value.to_s)\n end",
"def get_field_deserializers()\n return super.merge({\n \"unit\" => lambda {|n| @unit = n.get_string_value() },\n \"value\" => lambda {|n| @value = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n })\n end",
"def cast_as_value(as_type,as_property)\n if(as_type == :date)\n return \"XMLUtils.dateToXML(#{as_property})\"\n elsif(as_type == :datetime)\n return \"TolDateUtils.toTimeParam(#{as_property})\"\n else\n return as_property\n end\n end",
"def edit_value(val)\n if data_type == \"string\"\n self.text_raw_value = val\n elsif data_type == \"number\"\n self.number_raw_value = val\n end\n # Note: *_validated_value field is set in the set_validated_values\n # validator.\n end",
"def fetch_value(value); end",
"def this_value_standard_format(code, values, lookup, format)\n return_values = []\n values.each do |v|\n expand_value = expand_value(code, v, lookup, format)\n return_values << expand_value unless expand_value.nil?\n end\n return_values.join(', ')\n end",
"def normalize(options = {})\n return unless valid? # Only normalize valid value\n\n @value = case datatype\n when XSD.boolean then %(1 true).include?(@value.to_s.downcase) ? \"true\" : \"false\"\n when XSD.integer then @value.to_i.to_s\n when XSD.decimal then normalize_decimal(@value, options)\n when XSD.double then normalize_double(@value, options)\n when XSD.time then @value.is_a?(Time) ? @value.strftime(\"%H:%M:%S%Z\").sub(/\\+00:00|UTC/, \"Z\") : @value.to_s\n when XSD.dateTime then @value.is_a?(DateTime) ? @value.strftime(\"%Y-%m-%dT%H:%M:%S%Z\").sub(/\\+00:00|UTC/, \"Z\") : @value.to_s\n when XSD.date then @value.is_a?(Date) ? @value.strftime(\"%Y-%m-%d%Z\").sub(/\\+00:00|UTC/, \"Z\") : @value.to_s\n when RDF.XMLLiteral then normalize_xmlliteral(@value, options)\n else @value.to_s\n end\n end",
"def typecast(value)\n return value if type === value || (value.nil? && type != TrueClass)\n\n if type == TrueClass then %w[ true 1 t ].include?(value.to_s.downcase)\n elsif type == String then value.to_s\n elsif type == Float then value.to_f\n elsif type == Fixnum then value.to_i\n elsif type == BigDecimal then BigDecimal(value.to_s)\n elsif type == DateTime then DateTime.parse(value.to_s)\n elsif type == Date then Date.parse(value.to_s)\n elsif type == Class then find_const(value)\n end\n end",
"def literalize\n value = self\n case value\n when /^-?\\d+$/ then value.to_i\n when /^-?\\d+\\.\\d+$/ then value.to_f\n when 'false', 'FALSE' then false\n when 'true', 'TRUE', 'yes', 'on', 'y' then true\n when 'nil' then nil\n else\n if (value.index(':') == 0) && (value.size > 1)\n value[1..-1].to_sym\n else\n value\n end\n end\n end",
"def convert_metric_value_type view\n case view.aggregation\n when OpenCensus::Stats::Aggregation::Distribution\n Google::Api::MetricDescriptor::ValueType::DISTRIBUTION\n when OpenCensus::Stats::Aggregation::Count\n Google::Api::MetricDescriptor::ValueType::INT64\n when OpenCensus::Stats::Aggregation::Sum,\n OpenCensus::Stats::Aggregation::LastValue\n if view.measure.int64?\n Google::Api::MetricDescriptor::ValueType::INT64\n else\n Google::Api::MetricDescriptor::ValueType::DOUBLE\n end\n end\n end",
"def datatables_instance_get_value(instance, column)\n if column[:attribute]\n val = instance.send(column[:attribute].to_sym)\n return I18n.t(val.to_s.to_sym, :default => val.to_s) if not val.nil?\n return ''\n elsif column[:special]\n special = column[:special]\n \n if special[:method]\n return method(special[:method].to_sym).call(instance)\n elsif special[:eval]\n proc = lambda { obj = instance; binding }\n return Kernel.eval(special[:eval], proc.call)\n end\n end\n return \"value not found\"\n end",
"def value row_or_value = nil, scope = nil, &proc\n\n return @value_proc = proc if proc\n\n # extracting value\n value = scope == :save ?\n row_or_value :\n (row_or_value.respond_to?(@name) ? row_or_value.send(@name) : (row_or_value||{})[@name])\n\n @row, @scope = row_or_value, scope\n\n if @options && summary?\n value = @options[value] unless checkbox? || multiple?\n end\n\n if boolean? && summary?\n value = Saint::Utils::BOOLEAN_OPTIONS[value]\n end\n\n if @value_proc && val = self.instance_exec(value, &@value_proc)\n value = val\n end\n\n # passwords are not wrapped\n return value if password?\n\n # typecasting\n if summary? || crud?\n return format_date__time(@type, value, scope == :summary) if date? || date_time? || time?\n return '%.2f' % value if ::BigDecimal === value\n end\n\n @row, @scope = nil\n @rbw && value = @rbw.wrap(value)\n value.is_a?(String) ? (html? ? value : escape_html(value)) : value\n end",
"def describe_value(value)\r\n\t\tvalue\r\n\tend",
"def get_double_value(field_name)\n\t\tend",
"def column_value(rec, drawer)\n if (enum = drawer.vc.get_enum(rec.class, @ar_column_info))\n drawer.vc.draw_column_enum(rec, @ar_column_info, enum)\n else\n case @ar_column_info.type\n when :datetime\n drawer.vc.datetime_fmt(rec.send(name))\n when :date\n drawer.vc.date_fmt(rec.send(name))\n when :integer\n rec.send(name).to_s\n when :boolean\n rec.send(name) ? '√' : ''\n else\n # NOTE: rec.send(col.name) is not used since sssn.send(:data)\n # becomes hash rather than actual string-data so that following\n # split() fails for Hash.\n if str = rec.attributes[name]\n draw_trimmed_str(str)\n else\n ''\n end\n end\n end\n end",
"def expand_value(code, value, lookup, format)\n return nil if value.blank?\n\n return lookup_ref_data_value(code, value) if lookup\n return value.to_date.strftime('%d %B %Y') if format == :date\n\n value\n end",
"def format_cell(val, istruct, width: nil, decorate: false)\n case val\n when Numeric\n str = format_numeric(val, istruct)\n str = format_string(str, istruct, width)\n decorate ? decorate_string(str, istruct) : str\n when DateTime, Date\n str = format_datetime(val, istruct)\n str = format_string(str, istruct, width)\n decorate ? decorate_string(str, istruct) : str\n when TrueClass\n str = format_boolean(val, istruct)\n str = format_string(str, istruct, width)\n true_istruct = istruct.dup\n true_istruct.color = istruct.true_color\n true_istruct.bgcolor = istruct.true_bgcolor\n decorate ? decorate_string(str, true_istruct) : str\n when FalseClass\n str = format_boolean(val, istruct)\n str = format_string(str, istruct, width)\n false_istruct = istruct.dup\n false_istruct.color = istruct.false_color\n false_istruct.bgcolor = istruct.false_bgcolor\n decorate ? decorate_string(str, false_istruct) : str\n when NilClass\n str = istruct.nil_text\n str = format_string(str, istruct, width)\n decorate ? decorate_string(str, istruct) : str\n when String\n str = format_string(val, istruct, width)\n decorate ? decorate_string(str, istruct) : str\n else\n raise UserError,\n \"cannot format value '#{val}' of class #{val.class}\"\n end\n end",
"def format_cell(val, istruct, width: nil, decorate: false)\n case val\n when Numeric\n str = format_numeric(val, istruct)\n str = format_string(str, istruct, width)\n decorate ? decorate_string(str, istruct) : str\n when DateTime, Date\n str = format_datetime(val, istruct)\n str = format_string(str, istruct, width)\n decorate ? decorate_string(str, istruct) : str\n when TrueClass\n str = format_boolean(val, istruct)\n str = format_string(str, istruct, width)\n true_istruct = istruct.dup\n true_istruct.color = istruct.true_color\n true_istruct.bgcolor = istruct.true_bgcolor\n decorate ? decorate_string(str, true_istruct) : str\n when FalseClass\n str = format_boolean(val, istruct)\n str = format_string(str, istruct, width)\n false_istruct = istruct.dup\n false_istruct.color = istruct.false_color\n false_istruct.bgcolor = istruct.false_bgcolor\n decorate ? decorate_string(str, false_istruct) : str\n when NilClass\n str = istruct.nil_text\n str = format_string(str, istruct, width)\n decorate ? decorate_string(str, istruct) : str\n when String\n str = format_string(val, istruct, width)\n decorate ? decorate_string(str, istruct) : str\n else\n raise UserError,\n \"cannot format value '#{val}' of class #{val.class}\"\n end\n end",
"def value_type\n 'UNKNOWN'\n end",
"def get_value val=nil\n if @klass == 'String'\n return @value\n elsif @klass == 'Hash'\n return @value[val]\n elsif @klass == 'Array'\n return @value[val]\n else\n return @value\n end\n end",
"def safe_value\n if self.value.nil?\n result = \"\"\n elsif self.format == :no_dash || self.format == :number\n result = self.value.strftime(\"%Y%m%d\")\n else\n result = self.value.strftime(\"%Y-%m-%d\")\n end\n\n if self.format == :number\n result.to_i.to_s\n else\n self.single_quoter_switch(result)\n end\n end",
"def datatypes\n value.document.fetch(\"#{value.key}_type\", [])\n end"
] | [
"0.68830705",
"0.66187906",
"0.6442266",
"0.6315576",
"0.6222422",
"0.6218922",
"0.6162796",
"0.6160508",
"0.60996014",
"0.6093866",
"0.6046954",
"0.6005339",
"0.59773886",
"0.59702265",
"0.59496546",
"0.5945018",
"0.5918942",
"0.59053427",
"0.5902997",
"0.58867675",
"0.58725244",
"0.585113",
"0.5827958",
"0.58099836",
"0.5796012",
"0.57935166",
"0.5748636",
"0.5724994",
"0.57100683",
"0.56996626",
"0.5695865",
"0.5671712",
"0.5670569",
"0.56500953",
"0.5644537",
"0.5643219",
"0.55979806",
"0.55974996",
"0.5595067",
"0.55700207",
"0.5567029",
"0.5558698",
"0.5550718",
"0.554563",
"0.55388325",
"0.5528881",
"0.5527939",
"0.55159307",
"0.5513832",
"0.5513772",
"0.5509615",
"0.5507193",
"0.5507111",
"0.54830426",
"0.5482786",
"0.5474383",
"0.5473784",
"0.5471537",
"0.5467142",
"0.5451816",
"0.54481906",
"0.54460067",
"0.5439039",
"0.54357743",
"0.5430318",
"0.54293925",
"0.5423879",
"0.5415059",
"0.54150194",
"0.54000443",
"0.5399289",
"0.5394807",
"0.53945017",
"0.53918505",
"0.53918505",
"0.5386531",
"0.5383378",
"0.53823984",
"0.53814435",
"0.53813314",
"0.5380182",
"0.53794366",
"0.53751063",
"0.5373276",
"0.5368291",
"0.5365355",
"0.5363316",
"0.5360347",
"0.5351397",
"0.5348226",
"0.53481245",
"0.53458136",
"0.5343907",
"0.534262",
"0.5335616",
"0.5335616",
"0.53303784",
"0.5324901",
"0.5322555",
"0.53206193"
] | 0.6397479 | 3 |
course is editable if the signed in user is a University Admin and belongs to the same institution as the course | def set_editability
@editable = user_signed_in? && (current_user.member.role.name.eql? "University Admin") &&
current_user.member.institution.id == @course.department.institution.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_edit?(user)\n course.can_edit? user\n end",
"def can_edit(user)\n\t\tif user\n\t\t\tcan_edit = user.courses.include?(self)\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def updatable_by?(user)\n user.admin_for?(resource.course)\n end",
"def course_owner\n @course = Course.find(params[:id])\n user = User.find(@course.user_id)\n\n unless is_admin?\n if !current_user?(user)\n flash[:danger] = \"You are not authorized to edit this course.\"\n redirect_back(fallback_location: root_path)\n end\n end\n end",
"def authenticated_as_course_editor\n authenticated_as_user\n return if performed?\n\n set_current_course\n bounce_user unless current_course.can_edit?(current_user)\n end",
"def edit\n\t\t# must have admin access or be in the course\n\tend",
"def edit #this action allow admin to edit single course value\n end",
"def edit\n #Validate\n id = params[:id]\n @course = Course.find(id)\n requires({'role' => ['admin','faculty'],'course_id' => id})\n if(@course.nil?)\n flash[:error] = 'Something has gone horribly wrong. A system administrator has been contacted.'\n else\n student_ids = StudentInCourse.where(:course_id => id).collect(&:user_id)\n ta_ids = TaForCourse.where(:course_id => id).collect(&:user_id)\n \n @students = User.find_all_by_id(student_ids)\n @tas = User.find_all_by_id(ta_ids)\n end\n end",
"def can_edit?(user)\n user && self.creator_id == user.id\n end",
"def edit\n c_user = current_user()\n return ( render status: 401, json: { result: \"Not Authorized\" } ) unless logged_in? # Ensure the user is logged in\n course = Course.where(id: params[:course_id]).first()\n\n # Course Not Found case\n if course.nil?\n return ( render status: 404, json: { result: \"Not Found\" } )\n end\n\n # Attaches a schema \n schema = {\n title: :text,\n description: :textarea,\n tier: Tier.schema,\n visibility: Visibility.schema\n }\n\n unless c_user.role == Role.admin or c_user.role == Role.moderator\n schema[:visibility].delete(:published)\n schema[:visibility].delete(:reviewing)\n end\n\n # Draft Course case\n if course.visibility == Visibility.draft and course.user_id == c_user.id\n render status: 200, json: { result: course, schema: schema }\n\n # Privledged User case\n elsif c_user.role == Role.admin or c_user.role == Role.moderator\n render status: 200, json: { result: course, schema: schema }\n\n # Course is not (owned by user and editable) AND (user is not privledged)\n else\n render status: 401, json: { result: \"Not Authorized\" }\n end\n end",
"def update\n if [email protected]\n respond_to do |format|\n format.html { redirect_to :action => 'index' ,:controller=>\"courses\", notice: 'You are Not Authorized' }\n end\n return false\n end\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Create course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def can_read?(user)\n (self.user == user) || course.can_edit?(user)\n end",
"def set_user_course\n @user_course = UserCourse.find(params[:id])\n authorize(@user_course)\n end",
"def set_course\n @course = Course.find(params[:id])\n authorize @course\n end",
"def edited_by?(user)\n lecture.edited_by?(user)\n end",
"def can_edit_study(study_id)\n study = Study.find(study_id)\n if study \n if study.admin == self\n return true\n end\n study.users.each do | user | \n if user == self\n return true\n end\n end\n end\n return false\n end",
"def edit\n set_student\n @courses = Course.all\n end",
"def user_can_edit(user)\n if (self.editor == user) or self.book.project.owner == user or user.id == 1 then\n return true\n else\n return false\n end\n end",
"def authorize_user_for_course\n @course = Course.find(params[:course_id] || params[:id])\n unless @course\n flash[:error] = \"Course #{params[:course]} does not exist!\"\n redirect_to controller: :home, action: :error and return\n end\n\n # set course logger\n begin\n COURSE_LOGGER.setCourse(@course)\n rescue Exception => e\n flash[:error] = e.to_s\n redirect_to controller: :home, action: :error and return\n end\n\n uid = current_user.id\n # don't allow sudoing across courses\n if (session[:sudo]) then\n if (@course.id == session[:sudo][\"course_id\"]) then\n uid = session[:sudo][\"user_id\"]\n else\n session[:sudo] = nil\n end\n end\n\n # set @cud\n cud, reason = CourseUserDatum.find_or_create_cud_for_course @course, uid\n case reason\n when :found\n @cud = cud\n\n when :admin_created\n @cud = cud\n flash[:info] = \"Administrator user added to course\"\n\n when :admin_creation_error\n flash[:error] = \"Error adding user: #{current_user.email} to course\"\n redirect_to controller: :home, action: :error and return\n\n when :unauthorized\n flash[:error] = \"User #{current_user.email} is not in this course\"\n redirect_to controller: :home, action: :error and return\n end\n\n # check if course was disabled\n if @course.disabled? and [email protected]_auth_level?(:instructor) then\n flash[:error] = \"Your course has been disabled by your instructor. Please contact them directly if you have any questions\"\n redirect_to controller: :home, action: :error and return\n end\n\n # should be able to unsudo from an invalid user and\n # an invalid user should be able to make himself valid through edit page\n invalid_cud = [email protected]?\n nicknameless_student = @cud.student? && @cud.nickname.blank?\n in_edit_or_unsudo = (params[:controller] == \"course_user_data\") &&\n (params[:action] == \"edit\" or params[:action] == \"update\" or\n params[:action] == \"unsudo\")\n\n if (invalid_cud or nicknameless_student) and !in_edit_or_unsudo then \n flash[:error] = \"Please complete all of your account information before continuing\"\n redirect_to edit_course_course_user_datum_path(id: @cud.id, course_id: @cud.course.id)\n end\n end",
"def correct_user_to_edit\n not_allow if (@job.user.id != current_user.id) \n end",
"def edit_user\n @course = Course.find(params[:id])\n @user = User.find(params[:user_id])\n end",
"def edit\n authorize @user_information\n end",
"def can_edit?(user)\n\n end",
"def update\n c_user = current_user()\n return ( render status: 401, json: { result: \"Not Authorized\" } ) unless logged_in? # Ensure the user is logged in\n course = Course.where(id: params[:course_id]).first()\n\n # Course Not Found case\n if course.nil?\n return ( render status: 404, json: { result: \"Not Found\" } )\n end\n\n # Privledged User case\n if c_user.role == Role.admin or c_user.role == Role.moderator\n status = course.update(course_params)\n if status\n render status: 200, json: { result: course }\n else\n render status: 400, json: { result: course.errors }\n end\n\n # Draft Course case\n elsif course.user_id == c_user.id\n # Ensure the data doesn't change visiblity (Standard user cannot publish)\n if course_params[:visibility].to_i != Visibility.published\n status = course.update(course_params)\n if status\n render status: 200, json: { result: course }\n else\n render status: 400, json: { result: course.errors }\n end\n\n else\n render status: 400, json: { result: \"Not Authorized\" }\n end\n\n # Course is not (owned by user and editable) AND (user is not privledged)\n else\n render status: 401, json: { result: \"Not Authorized\" }\n end\n end",
"def editable_by?(usr)\n if wiki.project &&\n wiki.project.module_enabled?('wiki') &&\n wiki.project.module_enabled?('redmine_advanced_wiki_permissions')\n !protected? || usr.wiki_allowed_to?(self, :protect_wiki_pages)\n else\n !protected? || usr.allowed_to?(:protect_wiki_pages, wiki.project)\n end\n end",
"def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end",
"def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end",
"def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end",
"def can_edit?(user)\n user == current_user\n end",
"def can_edit?(user)\n user == self.user\n end",
"def authorized_to_edit?(recipe)\n current_user == recipe.user\n end",
"def edit\n\t\t@assignment = Assignment.find_by_id(params[:id])\n\t\tif @assignment.nil?\n\t\t\trender \"problem_not_found\"\n\t\telse\n\t\t\t@course = @assignment.course\n\t\t\t@can_edit = @course.can_edit(current_lecturer)\n\t\t\t@can_edit||= @course.can_edit(current_teaching_assistant)\n\t\tend\n\tend",
"def set_admin_course\n @admin_course = Course.find(params[:id])\n end",
"def can_edit\n return current_user && (current_user.id == Integer(params[:id]) || current_user.is_admin)\n end",
"def can_edit?(user)\n return user == self.user || user.has_role?(:admin)\n end",
"def can_edit?(user)\n self == user\n end",
"def can_edit?(user)\n self == user\n end",
"def can_edit?(user)\n self == user\n end",
"def can_edit?(user)\n (self.user == user) || !!(user && user.admin?)\n end",
"def update\n authorize! :update, Course\n redirect_to courses_path\n end",
"def can_edit?\n allows_current_user_access_to? :edit\n end",
"def can_edit_study?(user)\n if self.study.queued_for_deletion?\n return false\n else\n return self.study.can_edit?(user)\n end\n end",
"def can_edit? record\n return true if current_user.admin?\n case record.class.to_s\n when 'TypusUser'\n record.id == current_user.id\n else\n true # record.user_id == current_user.id # created_by\n end\n end",
"def edit_authorized(current_user)\n return self.user_id == current_user.id\n end",
"def edit_authorized(current_user)\n return self.user_id == current_user.id\n end",
"def readable_by?(user)\n user.in_session?(resource) || user.admin_for?(resource.course)\n end",
"def can_edit?\n can_write? && (account_is_owner? || account_is_collaborator?)\n end",
"def edit\n @semester = Semester.find(params[:id])\n authorize @semester\n end",
"def can_edit?(obj)\n return true if obj.user_id == user_id || is_admin?\n false\n end",
"def user_can_edit?\n current_user == @list.user\n end",
"def can_edit(user)\n unless user.nil?\n user.admin? || ((user.id == user_id) && (updated_at < 5.minutes.ago)) #TODO add to Configuration class\n else\n false\n end\n end",
"def edit\n authorize! :update, @user\n end",
"def can_be_modified_by?( user )\n return false if ( user.restricted? )\n return true if ( user.admin? )\n return self.active\n end",
"def edit\n authorize @volunteer_position\n end",
"def can_edit?\n object.editable_by?(current_user)\n end",
"def editable_by? editor=nil\n\t\treturn true if((editor)&&(self.school.editable_by? editor))\n\tend",
"def editable_by?(user)\n user && self.user_id == user.id\n end",
"def editable_by?(user)\n user && self.user_id == user.id\n end",
"def editable_by?(user)\n return false if user.blank?\n project.project_users.exists?([\"role IN ('curator', 'manager') AND user_id = ?\", user])\n end",
"def edit\n return unless find_project!\n return unless find_candidate!\n return if @project.is_admin?(@user)\n\n must_be_project_admin!(@project.id)\n end",
"def editable? usr\r\n (seller?(usr) || pixter?(usr) || usr.has_role?(:admin)) || usr.has_role?(:support)\r\n end",
"def editable_by?(user)\n \tuser && user == owner\n\tend",
"def require_owner\n @course = Course.find_by_id(params[:id])\n if (!@course || @course.user != current_user)\n redirect_to :root, notice: 'Not yours. Pas touche.' \n end\n end",
"def can_edit\n producer.admin?(user) || group_admin?\n end",
"def user_can_edit\n unless logged_in? and can_edit?\n respond_with_error(\n \"You must have editor permissions to edit this content.\", \n root_path)\n end\n end",
"def can_edit?(current_user_id)\n\t\tif User.find(current_user_id) == creator\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def edit\n if current_user.access == 2\n redirect_to \"/users/indexU\"\n end\n end",
"def can_edit?(project)\n current_user.id == project.created_by\n end",
"def editable_by?(user_id)\n user_id = user_id.id if user_id.is_a?(User)\n has_role(user_id, :editor)\n end",
"def update?\n !record.private? || record.user_id == user.id || record.user_collaborators.include?(user)|| user.admin?\n end",
"def self_edit_only\n #if current_user.id != Integer(params[:id]) && !current_user.is_admin\n if !can_edit\n redirect_to user_url, :notice => \"You don't have permission to do that.\"\n else\n end\n end",
"def can_edit=(value)\n @can_edit = value\n end",
"def authorize_edit\n authorize! :edit, @opportunity\n end",
"def set_resource\n @course = Course.find(params[:id])\n authorize @course\n end",
"def edit\n @user = current_user\n\n authorize! @tool\n end",
"def can_edit?(someone)\n owner_id.to_s == someone.id.to_s\n end",
"def correct_user\n @course = Course.find(params[:id])\n @user = @course.users\n unless current_user == @user\n redirect_to(root_url) \n flash[:danger] = \"You are not the authorised user\"\n end\n end",
"def edit\n require_user\n end",
"def can_edit?(user)\n Article.can_edit?(user)\n end",
"def editable_by?(user)\n\t\tuser && user == author\n\tend",
"def edit\n authorize! :edit, @user, :id => current_user.id\n end",
"def edit\n\n #Make sure only logged in admins can manipulate users\n\n if @loggedinuser && @loggedinuser.authorizationlevel >= 4\n \t@user = User.find(params[:id])\n else \n redirect_to '/'\n end\n end",
"def editable_by?(user)\n return true unless has_limited_editors?\n\n (editor_roles & user.alchemy_roles).any?\n end",
"def is_editable?\n is_public\n end",
"def index\n \n if can? :update, @course #instructor \n @courses = current_user.subjects #Course.where(:user_id => current_user.id) #courses that person teaches\n else\n @courses = current_user.courses \n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def course_owner?(course)\n tutor? && current_user?(course.tutor)\n end",
"def edit\n enforce_update_permission(@user)\n end",
"def editable_by?(user)\n\t \t# user && user == owner\n\t user == user\n \tend",
"def edit\n @company = Company.find( params[:company_id])\n @training = Training.find( params[:training_id])\n @course = Course.find( params[:id])\n #ALL USERS EXCEPT ROOT (role != 0) AND INACTIVE USERS state == 0\n @users = @company.users.find( :all, :conditions => [\"role != ? AND state == ?\", ROOT, STATE[:active]])\n end",
"def can_edit?(user)\n !!(user && (user.admin? || users.include?(user)))\n end",
"def check_courses\n\t\t# Check permissions\n\t\tif (not @current_user.is_administrator?) && (not @current_user.courses.include?(@course))\n\t\t\tredirect_to root_path, notice: \"Access Denied\"\n\t\t\treturn\n\t\tend\n\tend",
"def check_courses\n\t\t# Check permissions\n\t\tif (not @current_user.is_administrator?) && (not @current_user.courses.include?(@course))\n\t\t\tredirect_to root_path, notice: \"Access Denied\"\n\t\t\treturn\n\t\tend\n\tend",
"def edit\n @user = User.find(params[:id])\n authorize! :update, @user \n end",
"def edit\n if !(current_user.id == @user.id || is_admin?)\n indicate_illegal_request I18n.t('users.not-your-account')\n end\n end",
"def can_edit?(required_role)\n \n perm = current_user.permissions.select { |p| p.role.name == required_role}[0]\n \n @readonly= perm.nil? ? false : perm.readOnly?\n \n end",
"def can_edit? record\n return true if current_user.admin? # admins can edit anything\n case record.class.to_s\n when 'User'\n record.id == current_user.id # regular users can't edit other users\n when 'Warning', 'Interaction', 'Treatment', 'Bulletin', 'ThreadedDiscussionPost', 'Price', 'Comment', 'Guideline'\n record.created_by == current_user.id # these posts can only be edited by their creators\n else true # everyone can edit anything else\n end\n end",
"def change_student_crn\n return unless load_course( params[:course] )\n return unless ensure_course_instructor_or_ta_with_setting( @course, @user, 'ta_course_users' )\n \n crn = Crn.find(params[:crn]) rescue crn = nil\n found = false\n found = true if params[:crn].eql?(\"0\")\n @course.crns.each do |course_crn|\n found = found || course_crn.id = crn.id\n end \n return unless found\n \n @course.courses_users.each do |u|\n if u.user_id.to_i == params[:id].to_i && u.course_student\n u.crn_id = params[:crn].to_i\n if u.save\n flash[:notice] = \"Section assignment has been updated for student: #{u.user.display_name}\"\n end\n @course.save\n end\n end\n \n redirect_to :action => 'index', :course => @course, :id => nil, :crn => nil\n end",
"def accountant_allow_edit(permission)\n return accountant_right(permission) == 2\n end",
"def editable\n if scope && scope[:user_id] && object.user_id == scope[:user_id]\n return true\n else\n return false\n end\n end",
"def editable\n if scope && scope[:user_id] && object.user_id == scope[:user_id]\n return true\n else\n return false\n end\n end"
] | [
"0.77455914",
"0.75101346",
"0.7456505",
"0.73456204",
"0.71519035",
"0.6946149",
"0.68935764",
"0.68794024",
"0.68114877",
"0.67774683",
"0.6747436",
"0.6737102",
"0.6717443",
"0.67048657",
"0.66837156",
"0.66336876",
"0.6614074",
"0.66133416",
"0.6606802",
"0.6604033",
"0.6587739",
"0.65789706",
"0.65741885",
"0.6572814",
"0.6571134",
"0.6563461",
"0.6563461",
"0.6563461",
"0.65400666",
"0.6517728",
"0.6516992",
"0.6497283",
"0.64906126",
"0.64837027",
"0.64712274",
"0.6467001",
"0.6467001",
"0.6467001",
"0.6460905",
"0.64500886",
"0.64216095",
"0.64096063",
"0.6407286",
"0.6401832",
"0.6401832",
"0.6395191",
"0.6384603",
"0.6383135",
"0.6380149",
"0.636423",
"0.63605833",
"0.63581717",
"0.6356739",
"0.6355107",
"0.63528436",
"0.6349621",
"0.6310956",
"0.6310956",
"0.63030994",
"0.62955827",
"0.6295199",
"0.62914634",
"0.6285033",
"0.6261219",
"0.6251048",
"0.62447864",
"0.62445915",
"0.6241316",
"0.62404144",
"0.62355393",
"0.6213414",
"0.6210643",
"0.62049586",
"0.6200425",
"0.61974216",
"0.6197036",
"0.6195814",
"0.619201",
"0.619144",
"0.6190908",
"0.6186407",
"0.6182874",
"0.6176004",
"0.6171152",
"0.6170986",
"0.6167157",
"0.6162472",
"0.6153752",
"0.6151114",
"0.6150938",
"0.6144054",
"0.6144054",
"0.6138251",
"0.613288",
"0.6125867",
"0.6115398",
"0.6114924",
"0.61112404",
"0.6107839",
"0.6107839"
] | 0.8348009 | 0 |
next few methods are for updating/editing course | def get_course_params
course_params = params.require(:course)
if !empty_new_end_qual
course_params = course_params.except(:end_qualification_id)
end
if !empty_new_del_mode
course_params = course_params.except(:delivery_mode_id)
end
return course_params.permit!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n set_student\n @courses = Course.all\n end",
"def edit #this action allow admin to edit single course value\n end",
"def update\n \n #don't need to add user_id here.. already exists.\n \n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n #Validate\n id = params[:id]\n @course = Course.find(id)\n requires({'role' => ['admin','faculty'],'course_id' => id})\n if(@course.nil?)\n flash[:error] = 'Something has gone horribly wrong. A system administrator has been contacted.'\n else\n student_ids = StudentInCourse.where(:course_id => id).collect(&:user_id)\n ta_ids = TaForCourse.where(:course_id => id).collect(&:user_id)\n \n @students = User.find_all_by_id(student_ids)\n @tas = User.find_all_by_id(ta_ids)\n end\n end",
"def edit\n\t\t# must have admin access or be in the course\n\tend",
"def edit\n\t\t@course = Course.find(params[:id])\n\t\t@majors = @course.major\n\t\t@distributions = @course.distribution\n\t\t@minors = @course.minor\n\t\t@concentrations = @course.concentration\n\tend",
"def update\n if @course.update(course_params)\n redirect_to courses_path, notice: \"Course was successfully updated.\"\n else\n render action: 'edit'\n end\n \n end",
"def edit\n\tfaculty_course = FacultyCourse.find(params[:id])\n\tcourses = params[:courses]\n\tif ((courses[:course1_id] == courses[:course2_id]) && courses[:course1_id] != \"\") || ((courses[:course1_id] == courses[:course3_id]) && courses[:course1_id] != \"\") || ((courses[:course2_id] == courses[:course3_id]) && courses[:course2_id] != \"\")\n\t\tflash[:error] = \"Please choose a different course in each box\"\n\t\tredirect_to faculty_course_path(faculty_course)\n\telse\n \t\tfaculty_course = FacultyCourse.find(params[:id])\n\t\tfaculty_course.update_attributes!(params[:courses].permit(:course1_id,:course2_id,:course3_id))\n\t\tflash[:success] = \"Courses information updated successfully\"\n\t\tredirect_to faculty_courses_path\n\tend\n end",
"def update\n @course = Course.find(params[:id])\n \n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, :notice => t('selecao_admin.flash_messages.successfully_updated', :model => @course.class.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n @course = Course.find(params[:id])\n end",
"def edit\n @course = Course.find(params[:id])\n end",
"def update\n\t\t@course = @teacher.courses.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to [:teacher, @course], :notice => 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@course = Course.find(params[:id])\n\n\t if @course.update_attributes(course_params)\n\n\t @course.major.clear\n\t @course.minor.clear\n\t @course.concentration.clear\n\t @course.distribution.clear\n\n\t params[:course][\"major_id\"].each do |major_id|\n\t if !major_id.empty?\n\t @course.major << Major.find(major_id)\n\t end\n\t end\n\n\t params[:course][\"minor_id\"].each do |minor_id|\n\t if !minor_id.empty?\n\t @course.minor << Minor.find(minor_id)\n\t end\n\t end\n\n\t params[:course][\"concentration_id\"].each do |concentration_id|\n\t if !concentration_id.empty?\n\t @course.concentration << Concentration.find(concentration_id)\n\t end\n\t end\n\n\t params[:course][\"distribution_id\"].each do |distribution_id|\n\t if !distribution_id.empty?\n\t @course.distribution << Distribution.find(distribution_id)\n\t end\n\t end\n\n\t flash[:success] = \"Successfully updated\"\n\t redirect_to :action => 'show', :id => @course\n\n\t end\n\tend",
"def edit\n @course = Course.find_by_id params[:id]\n end",
"def edit\n @course = Course.find(params[:id])\n end",
"def update\n @course = Course.find(params[:id])\n if @course.update(course_params)\n flash[:success] = \"Course Updated\"\n redirect_to @course\n else\n render 'edit'\n end\n end",
"def update\n @course = Course.find(params[:id])\n @course.user_id=current_user.id\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to(@course, :notice => 'Course was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n expire_fragment(\"preview_courses_#{params[:id]}\")\n\n respond_to do |format|\n checks = form_lang_combo_valid? && !critical_changes?(@course)\n if checks && @course.update_attributes(params[:course])\n flash[:notice] = 'Course was successfully updated.'\n format.html { redirect_to(@course) }\n format.xml { head :ok }\n else\n if not @course.form.abstract_form_valid?\n flash[:error] = \"The selected form is not valid. Please fix it first.\"\n elsif !form_lang_combo_valid?\n flash[:error] = \"The selected form/language combination isn’t valid. #{flash[:error]}\"\n elsif critical_changes?(@course)\n flash[:error] = \"Some of the changes are critical. Those are currently not allowed.\"\n else\n flash[:error] = \"Could not update the course.\"\n end\n\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n @course = Course.find_by_id(params[:id])\n end",
"def update\n @course = Course.find(params[:id])\n \n if (!params[:course])\n params[:course] = {:name=>params[:title], \n :f_day=>params[:description], \n :l_day=>params[:price]\n } \n end\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, :notice => 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n if @course.update_attributes(course_params)\n flash[:notice] = \"Course updated!\"\n redirect_to course_url(@course)\n else\n render :action => :edit\n end\n end",
"def update\n @course = Admin::Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to [:admin, @course], :notice => 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @lecture = Lecture.find(params[:id])\n @course= Course.find(params[:course_id])\n \n respond_to do |format|\n if @lecture.update_attributes(params[:lecture])\n format.html { redirect_to [@course, @lecture], notice: 'Lecture was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lecture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to user_course_path(current_user,@course), notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, :notice=> 'Curso actualizado' }\n format.json { head :ok }\n else\n format.html { render :action=> \"edit\" }\n format.json { render :json=> @course.errors, :status=> :unprocessable_entity }\n end\n end\n end",
"def updateCourse(course, updater)\n course.title = updater.courseTitle\n course.course_name = updater.courseName\n course.description = updater.description\n \n updater.courseSections.each do |newSection|\n section = course.sections.find_by section_name: newSection.sectionNumber\n if section.blank? then\n section = Section.new\n end\n updateSection(section, newSection)\n course.sections << section\n end\n \n course.save\nend",
"def update\n if @course.update(course_params)\n redirect_to @course, notice: 'Course was successfully updated.'\n else\n render action: :edit\n end\n end",
"def update\n @course = Course.find(params[:id])\n respond_to do |format|\n if @course.update(courses_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n flash[:notice] = 'Course was successfully updated.'\n format.html { redirect_to courses_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n flash[:notice] = 'Course was successfully updated.'\n format.html { redirect_to :action => 'index' }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n begin\n @course = Course.find(params[:id])\n raise if @course.nil?\n \n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to club_course_path }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end",
"def update\n @coursemod = Coursemod.find(params[:id])\n #if @coursemod.update_attributes(params[:coursemod])\n if @coursemod.update_coursemod(params[:coursemod])\n flash[:success]= \"Module updated\"\n redirect_to @course\n else\n @title=\"Edit module\"\n flash.now[:error]=\"something went wrong\"\n render 'edit'\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n flash[:notice] = 'Course was successfully updated.'\n format.html { redirect_to( :back) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to(@course, :notice => 'Course was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @course.update_attributes(parama[:course])\n respond_with(@course)\n end",
"def update\n @course = Course.find(params[:id])\n authorize! :update, @course\n\n if (params[:course][:is_configured]) #The previous page was configure action\n if params[:course][:curriculum_url].include?(\"info.sv.cmu.edu\")\n @course.twiki_url = params[:course][:curriculum_url].sub(\"https\", \"http\")\n end\n @course.configured_by_user_id = current_user.id\n end\n\n params[:course][:faculty_assignments_override] = params[:teachers]\n respond_to do |format|\n @course.updated_by_user_id = current_user.id if current_user\n @course.attributes = params[:course]\n if @course.save\n flash[:notice] = 'Course was successfully updated.'\n format.html { redirect_back_or_default(course_path(@course)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"configure\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @course.update(course_params)\n flash[:success] = \"Curso atualizado com sucesso\"\n redirect_to course_path(@course)\n else\n flash[:error] = \"Não foi possível atualizar o curso\"\n redirect_to courses_path\n end\n end",
"def update\n c_user = current_user()\n return ( render status: 401, json: { result: \"Not Authorized\" } ) unless logged_in? # Ensure the user is logged in\n course = Course.where(id: params[:course_id]).first()\n\n # Course Not Found case\n if course.nil?\n return ( render status: 404, json: { result: \"Not Found\" } )\n end\n\n # Privledged User case\n if c_user.role == Role.admin or c_user.role == Role.moderator\n status = course.update(course_params)\n if status\n render status: 200, json: { result: course }\n else\n render status: 400, json: { result: course.errors }\n end\n\n # Draft Course case\n elsif course.user_id == c_user.id\n # Ensure the data doesn't change visiblity (Standard user cannot publish)\n if course_params[:visibility].to_i != Visibility.published\n status = course.update(course_params)\n if status\n render status: 200, json: { result: course }\n else\n render status: 400, json: { result: course.errors }\n end\n\n else\n render status: 400, json: { result: \"Not Authorized\" }\n end\n\n # Course is not (owned by user and editable) AND (user is not privledged)\n else\n render status: 401, json: { result: \"Not Authorized\" }\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n flash[:notice] = 'Course was successfully updated.'\n format.html { redirect_to(@course) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n flash[:notice] = 'Course was successfully updated.'\n format.html { redirect_to(@course) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n c_user = current_user()\n return ( render status: 401, json: { result: \"Not Authorized\" } ) unless logged_in? # Ensure the user is logged in\n course = Course.where(id: params[:course_id]).first()\n\n # Course Not Found case\n if course.nil?\n return ( render status: 404, json: { result: \"Not Found\" } )\n end\n\n # Attaches a schema \n schema = {\n title: :text,\n description: :textarea,\n tier: Tier.schema,\n visibility: Visibility.schema\n }\n\n unless c_user.role == Role.admin or c_user.role == Role.moderator\n schema[:visibility].delete(:published)\n schema[:visibility].delete(:reviewing)\n end\n\n # Draft Course case\n if course.visibility == Visibility.draft and course.user_id == c_user.id\n render status: 200, json: { result: course, schema: schema }\n\n # Privledged User case\n elsif c_user.role == Role.admin or c_user.role == Role.moderator\n render status: 200, json: { result: course, schema: schema }\n\n # Course is not (owned by user and editable) AND (user is not privledged)\n else\n render status: 401, json: { result: \"Not Authorized\" }\n end\n end",
"def update_courses(course_list)\n end",
"def edit\n # create will route here with that value\n # then we open up the view edit.html.erb with \n # their fields and when they submit\n # it will redirect to update and we can save it there\n\n\n \n @object = Applicant.find(params[:id])\n\n @courses= Course.all\n # Need them to be in three different categories. What we need to to is actully\n # link them like make the actual belongs to relationship.\n # For now, this works.\n #@coursesPref= Course.where({ name: @object.preferences})\n @coursesPref = []\n @object.preferences.each do |course|\n @coursesPref.push(Course.find_by({name: course}))\n end\n @coursesIndif= []\n @object.indifferent.each do |course|\n @coursesIndif.push(Course.find_by({name: course}))\n end\n @coursesAntiPref = []\n @object.antipref.each do |course|\n @coursesAntiPref.push(Course.find_by({name: course}))\n end\n \n end",
"def update\n authorize! :update, @course\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @course.update_attributes(update_course_params)\n flash[:success] = \"Module \\\"#{@course.title}\\\" updated\"\n redirect_to stafftools_course_path(@course)\n else\n render :edit\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course ' + @course.course_id + ' was successfully updated!' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n invalid_redirect_action = updating_course_info?(params[:course]) ? \"edit\" : \"show\"\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: invalid_redirect_action }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to courses_path(:option=>2), notice: 'El curso fue exitosamente editado!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_course\n #@course = Course.find(params[:course_id])\n @course = Course.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to admin_course_url(@course), notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Curso editado satisfactoriamente' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if [email protected]\n respond_to do |format|\n format.html { redirect_to :action => 'index' ,:controller=>\"courses\", notice: 'You are Not Authorized' }\n end\n return false\n end\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Create course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to admin_courses_path, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Curso atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def submit_edit\n id = params[:course_id]\n requires({'role' => ['admin','faculty'],'course_id'=>id})\n course_number = params[:number]\n course_term = params[:term]\n course_name = params[:name]\n course_section = params[:section]\n\n studentsToRemove = params[:students_to_remove]\n tasToRemove = params[:tas_to_remove]\n\n course = Course.find(id)\n \n\n\n course.course_number = course_number\n course.term = course_term\n course.name = course_name\n course.section = course_section\n course.save\n \n StudentInCourse.delete_all(:course_id => id, :user_id => studentsToRemove)\n TaForCourse.delete_all(:course_id => id, :user_id => tasToRemove)\n\n flash[:notice] = \"Changes saved.\"\n \n end",
"def set_course\n if params[:id]\n @course = Course.find(params[:id])\n else\n @course = Course.find(params[:course_id])\n end \n end",
"def update\n @course.update(course_params)\n render_jsonapi_response(@course)\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to professors_courses_url, notice: 'Course was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n # format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n # format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_course.update(admin_course_params)\n format.html { redirect_to (params[:ref] || @admin_course), notice: t('crud.updated_successfully!', name: Admin::Course.model_name.human) }\n format.json { render :show, status: :ok, location: @admin_course }\n else\n format.html { render :edit }\n format.json { render json: @admin_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ptcourse = Ptcourse.find(params[:id])\n\n respond_to do |format|\n if @ptcourse.update_attributes(params[:ptcourse])\n flash[:notice] = t('ptcourse.title')+\" \"+t('updated')\n format.html { redirect_to(@ptcourse) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ptcourse.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @course = current_user.courses.find(params[:course_id])\n @course_lesson = @course.course_lessons.find(params[:id])\n respond_to do |format|\n if @course_lesson.update_attributes(params[:course_lesson])\n format.html { redirect_to @course, notice: 'Course lesson was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course_lesson.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @exercise = Exercise.find_by_id(params[:id])\n @textbook = @exercise.textbook\n @course_asset = CourseAsset.find_by_id(params[:exercise][:course_asset_id])\n \n if params[:commit] == \"Cancel\"\n @ujsNotice = \"Update exercise action canceled.\"\n @ujsAlert = nil\n render \"cancel\"\n \n elsif params[:commit] == \"Update\"\n old_section_title = @exercise.section_title\n @exercise.assign_attributes(params[:exercise].except(:course_asset_id, :course_id, :subject_id))\n @section_title = @exercise.section_title\n if @section_title && @section_title.new_record?\n @new_section_title = true;\n render \"new\"\n elsif @exercise.save\n if old_section_title.exercises.count == 0\n old_section_title.delete\n end\n @ujsAlert = nil\n @ujsNotice = \"Successfully updated exercise.\"\n @exercises = @textbook.exercises.sort{|a,b| a.page.to_i <=> b.page.to_i}\n render \"update\"\n else \n @ujsNotice = nil\n @ujsAlert = \"Error! \" + @exercise.errors.full_messages.first\n render \"edit\"\n end\n \n elsif params[:commit] == \"Yes\"\n @filterstring = nil\n @exercise.assign_attributes(params[:exercise].except(:course_asset_id))\n if @exercise.save\n @ujsAlert = nil\n @ujsNotice = \"Successfully updated exercise.\"\n render \"update\"\n else \n @ujsNotice = nil\n @ujsAlert = \"Error! \" + @exercise.errors.full_messages.first\n render \"edit\"\n end\n \n else # params[:commit] == \"No\"\n @ujsNotice = \"Please re-enter the section title.\"\n render('edit')\n end\n\n \n end",
"def update!(**args)\n @course_id = args[:course_id] if args.key?(:course_id)\n end"
] | [
"0.7805154",
"0.76788527",
"0.7629602",
"0.7628735",
"0.7623742",
"0.762186",
"0.7529985",
"0.7457346",
"0.7445963",
"0.74367666",
"0.74367666",
"0.74346626",
"0.74154264",
"0.741338",
"0.7411294",
"0.7399746",
"0.7356317",
"0.7351276",
"0.7346413",
"0.7326563",
"0.7304887",
"0.72994107",
"0.7286037",
"0.7275973",
"0.7258909",
"0.72582597",
"0.725712",
"0.725712",
"0.725712",
"0.725712",
"0.725712",
"0.725712",
"0.725712",
"0.725712",
"0.7255743",
"0.725267",
"0.72487104",
"0.72482914",
"0.7240008",
"0.7239649",
"0.7236018",
"0.7233961",
"0.7205343",
"0.7201002",
"0.71936876",
"0.7192999",
"0.71836615",
"0.716323",
"0.7158034",
"0.7158034",
"0.7155146",
"0.71505445",
"0.7143713",
"0.71405244",
"0.7125216",
"0.71249527",
"0.7107836",
"0.7100189",
"0.7088337",
"0.7078008",
"0.7075593",
"0.7069369",
"0.70681685",
"0.70630175",
"0.70630175",
"0.70630175",
"0.70630175",
"0.70391196",
"0.70315313",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.7031176",
"0.6995243",
"0.6975156",
"0.6968175",
"0.6965537",
"0.69611484",
"0.69591063",
"0.69589126",
"0.6946959",
"0.69463086",
"0.6935827"
] | 0.0 | -1 |
all existing fees have both fields filled | def edit_fee_fields_filled
if !params[:edit_fees].nil?
edit_fees_vals = params[:edit_fees].values
edit_fees_vals.each_slice(3) do |fee, time, remove|
if fee.empty? || time.empty?
return false
end
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validatable_basic_fee_types\n @fee_types.select do |fee_type|\n fee_type.calculated == true && !fee_type.defendant_uplift?\n end\n end",
"def verify_fees(test_data)\n fees = test_data[CoreUseOfCollectionsData::FEE_GRP.name] || [CoreUseOfCollectionsData.empty_fee]\n fees.each_with_index do |fee, index|\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_CURRENCY.name], element_value(fee_currency_input index))\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_VALUE.name], element_value(fee_value_input index))\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_NOTE.name], element_value(fee_note_input index))\n end\n end",
"def verify_fees(test_data)\n fees = test_data[UseOfCollections::FEE_GRP.name] || [UseOfCollections.empty_fee]\n fees.each_with_index do |fee, index|\n verify_values_match(fee[UseOfCollections::FEE_CURRENCY.name], element_value(fee_currency_input index))\n verify_values_match(fee[UseOfCollections::FEE_VALUE.name], element_value(fee_value_input index))\n verify_values_match(fee[UseOfCollections::FEE_NOTE.name], element_value(fee_note_input index))\n end\n end",
"def add_fee_filled_or_empty\n if !params[:add_fee].nil?\n add_fee_keys = params[:add_fee].keys\n add_fee_vals = params[:add_fee].values\n add_fee_vals.each_slice(3) do |student_type, amount, time_period|\n if !((!student_type.empty? && !amount.empty? && !time_period.empty?) ||\n (student_type.empty? && amount.empty? && time_period.empty?))\n return false\n end\n end\n end\n return true\n end",
"def fixed_fees\n fixed_fee.nil? ? [] : [fixed_fee]\n end",
"def fees\n @fees ||= {\n \"insurance_fee\" => (commission * ASSURANCE_SHARE).round(0),\n \"assistance_fee\" => (ASSISTANCE_COST * rental.duration).round(0)\n }.tap { |fees| fees[\"drivy_fee\"] = commission - fees.values.inject(:+) }\n end",
"def free?\n self.setupFee == 0 && self.laborFee == 0 && self.oneTimeFee == 0 && self.recurringFee == 0 && self.hourlyRecurringFee == 0\n end",
"def fees\n raise Sibit::NotSupportedError, 'Blockchair doesn\\'t implement fees()'\n end",
"def total_fee_is_valid\n errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid?\n end",
"def fees\n raise Sibit::NotSupportedError, 'Btc.com doesn\\'t provide recommended fees'\n end",
"def fees_state?\n self.form_state == :fees\n end",
"def free?\n\t\t\t\tnot(fee?)\n\t\t\tend",
"def fees_particulars_new\n @finance_fee_particular = FinanceFeeParticular.new(params[:finance_fee_particular])\n @master_fee_particulars = MasterFeeParticular.core\n @tax_slabs = TaxSlab.all if @tax_enabled\n fy_id = current_financial_year_id\n @fees_categories = FinanceFeeCategory.all(:select => \"DISTINCT finance_fee_categories.*\",\n :joins => \"INNER JOIN category_batches ON category_batches.finance_fee_category_id = finance_fee_categories.id\n INNER JOIN batches ON batches.id = category_batches.batch_id AND batches.is_active = true AND batches.is_deleted = false\",\n :conditions => [\"finance_fee_categories.is_deleted = 0 AND finance_fee_categories.is_master = 1 AND\n financial_year_id #{fy_id.present? ? '=' : 'IS'} ?\", fy_id], :order => \"name ASC\")\n\n @student_categories = StudentCategory.active\n @all = true\n @student = false\n @category = false\n end",
"def enter_fees(test_data)\n fees = test_data[UseOfCollections::FEE_GRP.name] || [UseOfCollections.empty_fee]\n prep_fieldsets_for_test_data([fieldset(UseOfCollections::FEE_GRP.name)], fees)\n fees.each_with_index do |fee, index|\n wait_for_options_and_select(fee_currency_input(index), fee_currency_options(index), fee[UseOfCollections::FEE_CURRENCY.name])\n wait_for_element_and_type(fee_value_input(index), fee[UseOfCollections::FEE_VALUE.name])\n wait_for_element_and_type(fee_note_input(index), fee[UseOfCollections::FEE_NOTE.name])\n wait_for_element_and_click(fee_paid_input(index)) if fee[UseOfCollections::FEE_PAID.name]\n end\n end",
"def fee\n @fee || DEFAULT_FEE\n end",
"def fee_for_additional_materials_is_valid\n errors.add(:fee_for_additional_materials, 'The fee for additional materials is invalid.') unless fee_for_additional_materials_is_valid?\n end",
"def all_fees\n services.map{|el| el[:fee]}\n end",
"def retrieve_fees\n return if stripe_charge_id.nil?\n\n transaction = Stripe::BalanceTransaction.retrieve(stripe_charge.balance_transaction)\n return if transaction.nil?\n\n self.fee = transaction.fee / 100.0\n self.received_amount = transaction.net / 100.0\n save\n end",
"def federal_and_local_funding_complete?\n draft_budgets.where(default: true).each do |budget|\n if budget.funding_source_type.try(:name).in? [\"Federal\", \"Local\"]\n return false\n end\n end\n return true \n end",
"def fees_defaulters\n @courses = Course.all(\n :joins => {\n :batches => [\n {:students => :finance_fees}, :finance_fee_collections\n ]\n },\n :conditions => [\"courses.is_deleted=? and finance_fees.balance > ? and finance_fee_collections.is_deleted=? and finance_fee_collections.due_date < ? and batches.is_active =?\", false, 0, false, Date.today, true],\n :group => \"courses.id\")\n @batchs = []\n @dates = []\n end",
"def fees\n total_input - total_output\n end",
"def total_fee\n fee + fee2 + fee3 + fee4\n end",
"def fees(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/fees\", options).body)\n fees = response.key?('fees') ? response['fees'] : []\n fees.map { |attributes| Promisepay::Fee.new(@client, attributes) }\n end",
"def fees(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/fees\", options).body)\n fees = response.key?('fees') ? response['fees'] : []\n fees.map { |attributes| Promisepay::Fee.new(@client, attributes) }\n end",
"def fees(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/fees\", options).body)\n fees = response.key?('fees') ? response['fees'] : []\n fees.map { |attributes| Promisepay::Fee.new(@client, attributes) }\n end",
"def fee_params\n params.require(:fee).permit(:student_id, :amount, :user_id, :month)\n end",
"def fee_for_additional_materials_is_valid?\n return ((self.fee_for_additional_materials != nil) and (self.fee_for_additional_materials >= 0))\n end",
"def fee\n params['amount_fee']\n end",
"def total_fees\n staffing.present? ? staffing.compensation : nil\n end",
"def enter_fees(test_data)\n fees = test_data[CoreUseOfCollectionsData::FEE_GRP.name] || [CoreUseOfCollectionsData.empty_fee]\n hide_notifications_bar\n prep_fieldsets_for_test_data([fieldset(CoreUseOfCollectionsData::FEE_GRP.name)], fees)\n fees.each_with_index do |fee, index|\n logger.info \"Entering fee data set at index #{index}: #{fee}\"\n wait_for_options_and_select(fee_currency_input(index), fee_currency_options(index), fee[CoreUseOfCollectionsData::FEE_CURRENCY.name])\n wait_for_element_and_type(fee_value_input(index), fee[CoreUseOfCollectionsData::FEE_VALUE.name])\n wait_for_element_and_type(fee_note_input(index), fee[CoreUseOfCollectionsData::FEE_NOTE.name])\n wait_for_element_and_click(fee_paid_input(index)) if fee[CoreUseOfCollectionsData::FEE_PAID.name]\n end\n end",
"def apply_fees\n remove_fees\n unless waive_fees\n #CHALKLE\n self.chalkle_gst_number = Finance::CHALKLE_GST_NUMBER\n self.chalkle_fee = course.chalkle_fee_no_tax\n self.chalkle_gst = course.chalkle_fee_with_tax - chalkle_fee\n \n self.processing_fee = course.processing_fee\n self.processing_gst = course.processing_fee*3/23\n self.processing_fee = course.processing_fee-self.processing_gst\n\n #TEACHER FEE\n if provider_pays_teacher?\n self.teacher_fee = 0\n self.teacher_gst = 0\n else\n if fee_per_attendee?\n self.teacher_fee = course.teacher_cost\n elsif flat_fee?\n confirmed_booking_count = course.bookings.fees_not_waived.paid.confirmed.count\n if confirmed_booking_count > 0\n self.teacher_fee = course.teacher_cost / confirmed_booking_count\n else\n self.teacher_fee = course.teacher_cost\n end\n end\n end\n\n #TEACHER TAX\n if course.teacher.present? && course.teacher.tax_registered?\n self.teacher_gst_number = course.teacher.tax_number\n self.teacher_gst = teacher_fee*3/23\n self.teacher_fee = teacher_fee-teacher_gst\n else\n self.teacher_gst = 0\n self.teacher_gst_number = nil\n end\n\n #PROVIDER\n self.provider_fee = course.provider_fee\n if provider.tax_registered?\n self.provider_gst_number = provider.tax_number\n self.provider_gst = course.provider_fee*3/23\n self.provider_fee = self.provider_fee-self.provider_gst\n else\n self.provider_gst_number = nil\n self.provider_gst = 0\n end\n\n #adjust in case calc_cost is not course cost, should only happen if flat_fee\n difference = course.cost - calc_cost\n if difference != 0\n self.provider_fee = course.provider_fee + difference\n if provider.tax_registered?\n self.provider_gst_number = provider.tax_number\n self.provider_gst = course.provider_fee*3/23\n self.provider_fee = self.provider_fee-self.provider_gst\n else\n self.provider_gst_number = nil\n self.provider_gst = 0\n end\n end\n\n #adjust in case payment has been made already\n difference = cost - calc_cost\n if difference != 0\n #adjust processing_fee\n self.processing_fee = cost * course.provider_plan.processing_fee_percent\n self.processing_gst = self.processing_fee*3/23\n self.processing_fee = self.processing_fee-self.processing_gst\n\n #reset difference to adjust for processing_fee changes\n difference = cost - calc_cost\n\n #if payment exists then adjust provider fee to ensure the payment amount matches calc_cost\n adjustment_for_provider = difference\n adjustment_for_teacher = 0\n\n if provider_fee+provider_gst+difference < 0\n #if adjusted provider_fee is negative then deduct that negative amount from teacher_fee and make provider_fee 0\n adjustment_for_teacher = provider_fee+provider_gst+difference \n self.provider_fee = 0\n self.provider_gst = 0\n else\n self.provider_fee = provider_fee+provider_gst+adjustment_for_provider\n if provider.tax_registered?\n self.provider_gst = provider_fee*3/23\n self.provider_fee = provider_fee - provider_gst\n end\n end\n \n if adjustment_for_teacher != 0\n self.teacher_fee = teacher_fee+teacher_gst+adjustment_for_teacher\n if course.teacher.present? && course.teacher.tax_registered?\n self.teacher_gst = teacher_fee*3/23\n self.teacher_fee = teacher_fee-teacher_gst\n end\n end\n end\n end\n cost\n end",
"def set_fee\n @book = Book.find(params[:book_id])\n @fee = @book.fees.find(params[:id])\n end",
"def fees_particulars_create2\n batch=Batch.find(params[:finance_fee_particular][:batch_id])\n @tax_slabs = TaxSlab.all if @tax_enabled\n if params[:particular] and params[:particular][:receiver_id]\n\n all_admission_no = admission_no=params[:particular][:receiver_id].split(',')\n all_students = batch.students.map { |stu| stu.admission_no }.flatten\n rejected_admission_no = admission_no.select { |adm| !all_students.include? adm }\n unless (rejected_admission_no.empty?)\n @error = true\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{rejected_admission_no.join(',')} #{t('does_not_belong_to_batch')} #{batch.full_name}\")\n end\n\n selected_admission_no = all_admission_no.select { |adm| all_students.include? adm }\n selected_admission_no.each do |a|\n s = Student.first(:conditions => [\"admission_no LIKE BINARY(?)\", a])\n if s.nil?\n @error = true\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{a} #{t('does_not_exist')}\")\n end\n end\n unless @error\n unless selected_admission_no.present?\n @finance_fee_particular=batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{t('admission_no_cant_be_blank')}\")\n @error = true\n else\n selected_admission_no.each do |a|\n s = Student.first(:conditions => [\"admission_no LIKE BINARY(?)\", a])\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.receiver_id=s.id\n @error = true unless @finance_fee_particular.save\n end\n end\n end\n elsif params[:finance_fee_particular][:receiver_type]==\"Batch\"\n\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.receiver_id=batch.id\n @error = true unless @finance_fee_particular.save\n else\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @error = true unless @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{t('category_cant_be_blank')}\") if params[:finance_fee_particular][:receiver_id]==\"\"\n end\n @batch=batch\n @finance_fee_category = FinanceFeeCategory.find(params[:finance_fee_particular][:finance_fee_category_id])\n include_associations = @tax_enabled ? [:tax_slabs] : []\n @particulars = FinanceFeeParticular.paginate(:page => params[:page],\n :include => include_associations, :conditions => [\"is_deleted = '#{false}' and\n finance_fee_category_id = '#{@finance_fee_category.id}' and batch_id='#{@batch.id}' \"])\n\n end",
"def total_fee_is_valid?\n return ((self.total_fee != nil) and (self.total_fee >= 0))\n end",
"def fee_filter\n [\n ['Equal','equal'],\n ['Greater than','greater_than'],\n ['Less than','less_than']\n ]\n\n end",
"def miscellaneous_fees\n object.fees.each_with_object([]) do |fee, memo|\n misc_fee_adapter.call(fee).tap do |f|\n memo << f if f.claimed?\n end\n end\n end",
"def billing_fluctuates?\n return false if self.expired\n return false if self.end_date < Date.today\n start_dates = line_items.reject { |l| l.list_price.nil? || l.list_price == 0 }.map { |line| line.begins }\n end_dates = line_items.reject { |l| l.list_price.nil? || l.list_price == 0 }.map { |line| line.ends }\n return false if start_dates.uniq.length == 1 && end_dates.uniq.length == 1\n return false if payment_schedule.uniq.length == 1\n true\n end",
"def fee_params\n params.require(:fee).permit(:user_id, :name, :price, :serial, :end_at, :deleted_at)\n end",
"def total_non_insured_fees\n total_fee - total_insured_fees\n end",
"def fee_per_meeting_is_valid?\n return ((self.fee_per_meeting != nil) and (self.fee_per_meeting >= 0))\n end",
"def other_business_expenses\n return forms(\"Unreimbursed Partnership Expense\") { |f|\n f.line[:ssn] == @ho_form.line[:ssn]\n }.lines(:amount, :sum)\n end",
"def fee_per_meeting_is_valid\n errors.add(:fee_per_meeting, 'The fee per meeting is invalid.') unless fee_per_meeting_is_valid?\n end",
"def add_fees\n @proposal.fees.each do |bank_account, amounts_by_category|\n amounts_by_category.each do |category, amount|\n category_for_key = category&.downcase&.gsub(' ', '_') || 'none'\n run_task \"add_fees_#{bank_account}_#{category_for_key}\" do\n if transaction = add_fee_transaction(bank_account, amount, category)\n current_state[:transaction_id] = transaction['BankTransactionID']\n end\n end\n end\n end\n end",
"def edit_fee_is_integer\n if !params[:edit_fees].nil?\n edit_fees_vals = params[:edit_fees].values\n edit_fees_vals.each_slice(3) do |fee, time, remove|\n if !(fee.to_i.to_s.eql? fee)\n return false\n end\n end\n end\n return true\n end",
"def early_departure_fees\n path = \"CheckInOut.EarlyDepartureFees.EarlyDepartureFee\"\n get_fees_by_path(path)\n end",
"def total_insured_fees\n services.select{|i| i[:btype] && i[:btype] < CASH_BILLING}.sum{|s| s[:fee]} rescue 0\n end",
"def fulfillment_fee\n begin\n if variant.product_costs.where(:retailer_id => self.order.retailer_id).first.fulfillment_fee > 0\n variant.product_costs.where(:retailer_id => self.order.retailer_id).first.fulfillment_fee * quantity\n else\n self.order.retailer.fulfillment_fee * quantity\n end\n rescue\n begin\n self.order.retailer.fulfillment_fee * quantity\n rescue\n 0.0\n end\n end\n end",
"def calculate_fee\n Application::courses_fee(course_selections_count > 1 ? :multiple : :single)\n end",
"def add_fee_is_integer\n if !params[:add_fee].nil?\n add_fee_vals = params[:add_fee].values\n add_fee_vals.each_slice(3) do |student_type, amount, time_period|\n if !amount.empty? && !(amount.to_i.to_s.eql? amount)\n return false\n end\n end\n end\n return true\n end",
"def fee_params\n params.require(:fee).permit(:description, :amount)\n end",
"def fees(period = (Time.now.beginning_of_month - 1).beginning_of_month .. (Time.now.beginning_of_month - 1).end_of_month)\n subscription_payments.where({ :created_at => period }).collect(&:affiliate_amount).sum\n end",
"def document_fee\n 0\n end",
"def fee_params\n params.require(:fee).permit(:fee_name)\n end",
"def update_funding_and_estimates\n self.save_without_validating\n end",
"def fee_collection_new\n @fines = Fine.active\n fy_id = current_financial_year_id\n @fee_categories = FinanceFeeCategory.all(:select => \"DISTINCT finance_fee_categories.*\",\n :joins => [{:category_batches => :batch}, :fee_particulars],\n :conditions => [\"batches.is_active = 1 AND batches.is_deleted = 0 AND finance_fee_categories.is_deleted=0 AND\n finance_fee_particulars.is_deleted = 0 AND financial_year_id #{fy_id.present? ? '=' : 'IS'} ?\", fy_id])\n\n @finance_fee_collection = FinanceFeeCollection.new({:discount_mode => @school_discount_mode,\n :financial_year_id => fy_id})\n @start_date, @end_date = FinancialYear.fetch_current_range\n\n deliver_plugin_block :fedena_reminder do\n @finance_fee_collection.build_alert_settings\n end\n end",
"def build_detail_fee_based\n details = self.invoice_details.new(:created_user => self.created_user, :record_type => InvoiceDetail::FEE, :provider_name => 'a',\n :patient_name => 'a', :dos => Date.today, :disposition => InvoiceDetail::INCLUDE)\n end",
"def charge_fee\r\n\t\tif_member = Participant.find_by(participantID: participantID)\r\n\t\tif_course = Course.find_by(courseID: courseID)\r\n\t\t\r\n\t\tif if_course != nil && if_member != nil\r\n\t\t\tearlyBirdTime = if_course.startDate.months_ago(1)\r\n\t\t\tif if_member.expirydate > Date.today\r\n\t\t\t\tif Date.today >= earlyBirdTime && Date.today < if_course.startDate\r\n\t\t\t\t\treturn if_course.earlybirdPrice\r\n\t\t\t\telse\r\n\t\t\t\t\treturn if_course.memberPrice\r\n\t\t\t\tend\r\n\t\t\telse\r\n\t\t\t\treturn if_course.nonmemberPrice\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def show\n @franchisee = Franchisee.find(params[:id])\n @installment_detail = InstallmentDetail.where(franchisee_id: params[:id])\n if @installment_detail.present?\n balance = @installment_detail.pluck(:due_balance)\n if balance.include?(0)\n @due_fully_paid = true\n end\n end\n #@installment_detail = InstallmentDetail.where(franchisee_id: params[:id], paid_status: true)\n end",
"def fees_report\n if validate_date\n #@batches= FinanceTransaction.total_fees(@start_date, @end_date)\n\n filter_by_account, account_id = account_filter\n\n if filter_by_account\n ft_joins = [:finance_transaction_receipt_record]\n filter_conditions = \"AND finance_transaction_receipt_records.fee_account_id #{account_id == nil ? 'IS' : '='} ?\"\n filter_values = [account_id]\n filter_select = \", finance_transaction_receipt_records.fee_account_id AS account_id\"\n else\n ft_joins = []\n filter_conditions = \"\"\n filter_values = []\n filter_select = \"\"\n end\n\n @target_action = \"fees_report\"\n fee_id = FinanceTransactionCategory.find_by_name(\"Fee\").id\n @grand_total = FinanceTransaction.all(:select => \"amount\",\n :joins => ft_joins,\n :conditions => [\"finance_type = 'FinanceFee' and category_id = #{fee_id} and\n transaction_date <= '#{@end_date}' and \n transaction_date >= '#{@start_date}' #{filter_conditions}\"] + filter_values).\n map { |x| x.amount.to_f }.sum\n\n @collections = FinanceFeeCollection.paginate(:page => params[:page], :per_page => 10,\n :joins => {:finance_fees => {:finance_transactions => ft_joins}}, :group => :fee_collection_id,\n :conditions => [\"finance_transactions.finance_type = 'FinanceFee' AND finance_transactions.category_id = ? AND\n (finance_transactions.transaction_date BETWEEN ? AND ?) #{filter_conditions}\",\n fee_id, @start_date.to_s, @end_date] + filter_values,\n :order => \"finance_fee_collections.id DESC\",\n :select => \"finance_fee_collections.id AS collection_id,\n finance_fee_collections.name AS collection_name,\n finance_fee_collections.tax_enabled,\n SUM(finance_transactions.amount) AS amount,\n IF(finance_fee_collections.tax_enabled,\n SUM(finance_transactions.tax_amount),0) AS total_tax,\n SUM(finance_transactions.fine_amount) AS total_fine #{filter_select}\")\n\n collection_ids = @collections.collect(&:collection_id) << 0\n conditions = [\"((`particular_payments`.`transaction_date` BETWEEN '#{@start_date}' AND\n '#{@end_date}') OR particular_payments.id is null) AND\n `ffc`.`id` IN (#{collection_ids.join(',')}) #{filter_conditions}\"] + filter_values\n\n joins = \"LEFT JOIN particular_payments\n ON particular_payments.finance_fee_particular_id = finance_fee_particulars.id AND\n particular_payments.is_active = true\n LEFT JOIN particular_discounts\n ON particular_discounts.particular_payment_id = particular_payments.id AND\n particular_discounts.is_active = true\n INNER JOIN finance_fees ff\n ON ff.id = particular_payments.finance_fee_id\n INNER JOIN finance_fee_collections ffc\n ON ffc.id = ff.fee_collection_id\"\n joins += filter_by_account ?\n \" LEFT JOIN finance_transactions ON finance_transactions.id = particular_payments.finance_transaction_id\n LEFT JOIN finance_transaction_receipt_records ON finance_transaction_receipt_records.id = finance_transactions.id\" : \"\"\n\n tax_select = \",(SELECT SUM(tax_amount) FROM tax_payments WHERE\ntax_payments.taxed_entity_id = particular_payments.finance_fee_particular_id AND\ntax_payments.taxed_entity_type = 'FinanceFeeParticular' AND\ntax_payments.taxed_fee_id = particular_payments.finance_fee_id AND\ntax_payments.taxed_fee_type = 'FinanceFee') AS tax_paid\"\n\n collection_and_particulars = FinanceFeeParticular.find(:all, :joins => joins, :conditions => conditions,\n :select => \"finance_fee_particulars.name, ffc.id AS collection_id,\n (SUM(particular_payments.amount)) AS amount_paid,\n IFNULL(SUM(particular_discounts.discount),0) AS discount_paid #{tax_select} #{filter_select}\",\n :group => \"finance_fee_particulars.name, ffc.id\")\n\n @collection_and_particulars = collection_and_particulars.group_by(&:collection_id)\n\n if request.xhr?\n render(:update) do |page|\n page.replace_html \"fee_report_div\", :partial => \"fees_report\"\n end\n end\n else\n render_date_error_partial\n end\n #fees_id = FinanceTransactionCategory.find_by_name('Fee').id\n #@fee_collections = FinanceFeeCollection.find(:all,:joins=>\"INNER JOIN finance_fees ON finance_fees.fee_collection_id = finance_fee_collections.id INNER JOIN finance_transactions ON finance_transactions.finance_id = finance_fees.id AND finance_transactions.transaction_date >= '#{@start_date}' AND finance_transactions.transaction_date <= '#{@end_date}' AND finance_transactions.category_id = #{fees_id}\",:group=>\"finance_fee_collections.id\")\n end",
"def shipping_fee\n @admin_options = Admin::Option.where(\"id = ?\" , 44) \n end",
"def invoices_all_paid?\n self.invoices.pluck(:paid_at).map {|i| not i.nil?}.reduce(:&)\n end",
"def late_arrival_fees\n path = \"CheckInOut.LateArrivalFees.LateArrivalFee\"\n get_fees_by_path(path)\n end",
"def check_only_one_entry\n if self.credit != nil && self.debit != nil\n false\n end\n end",
"def fees(period = (Time.now.beginning_of_month - 1).beginning_of_month .. (Time.now.beginning_of_month - 1).end_of_month)\n subscription_payments.all(:conditions => { :created_at => period }).collect(&:affiliate_amount).sum \n end",
"def compare_report\n @accounts_enabled = (Configuration.get_config_value 'MultiFeeAccountEnabled').to_i == 1\n @accounts = FeeAccount.all if @accounts_enabled\n end",
"def landlord_listing_fee\n if campus == SINGAPORE\n ApartmentType.singapore_campus.landlord_listing_fee\n else\n ApartmentType.fontainebleau_campus.landlord_listing_fee\n end\n end",
"def fees_submission_student\n if params[:date].present?\n @date = @fee_collection = FinanceFeeCollection.find(params[:date])\n @transaction_date= params[:transaction_date].present? ? Date.parse(params[:transaction_date]) : Date.today_with_timezone.to_date\n @target_action='fees_submission_student'\n @target_controller='finance'\n @student = Student.find(params[:id])\n \n # calculating total collected advance fee amount\n @advance_fee_used = @fee_collection.finance_fees.all(:conditions => {:student_id => @student.id, :batch_id => @student.batch.id}).collect(&:finance_transactions).flatten.compact.sum(&:wallet_amount).to_f\n \n @fee = @student.finance_fee_by_date(@date)\n @fine_waiver_val = params[:fine].present? && params[:fine][:is_fine_waiver].present?? params[:fine][:is_fine_waiver] : 'false'\n financial_year_check\n unless @fee.nil?\n @particular_wise_paid = (@date.discount_mode != \"OLD_DISCOUNT\" && @fee.finance_transactions.map(&:trans_type).include?(\"particular_wise\"))\n # @particular_wise_paid = @fee.finance_transactions.map(&:trans_type).include?(\"particular_wise\")\n flash.now[:notice]=\"#{t('particular_wise_paid_fee_payment_disabled')}\" if @particular_wise_paid\n @batch = @fee.batch\n @financefee = @student.finance_fee_by_date @date\n # @financefee.update_attributes(:is_fine_waiver=>true) if params[:is_fine_waiver]\n # @linking_required = @fee_collection.has_linked_unlinked_masters(false, @student.id) if @student.present? and [email protected]_paid\n @due_date = @fee_collection.due_date\n @paid_fees = @fee.finance_transactions\n @fee_category = FinanceFeeCategory.find(@fee_collection.fee_category_id, :conditions => [\"is_deleted = false\"])\n @fine=nil\n @fine=params[:fine][:fee] if (params[:fine].present? and params[:fine][:fee].present?)\n particular_and_discount_details\n bal=(@total_payable-@total_discount).to_f\n days=(@[email protected]_date.to_date).to_i\n [email protected]\n if days > 0 and auto_fine and [email protected]_fine_waiver\n if Configuration.is_fine_settings_enabled? && @financefee.balance <= 0 && @financefee.is_paid == false && [email protected]_fine.nil?\n @fine_amount = @financefee.balance_fine\n else\n @fine=params[:fine][:fee].to_f if params[:fine].present? and params[:fine][:fee].present? and params[:fine][:fee].to_f > 0.0\n @fine_rule=auto_fine.fine_rules.find(:last, :conditions => [\"fine_days <= '#{days}' and created_at <= '#{@date.created_at}'\"], :order => 'fine_days ASC')\n @fine_amount=@fine_rule.is_amount ? @fine_rule.fine_amount : (bal*@fine_rule.fine_amount)/100 if @fine_rule\n if @fine_rule and @financefee.balance==0\n @fine_amount=@[email protected]_auto_fine\n end\n end\n elsif @financefee.is_fine_waiver \n @fine_amount =0.0\n end\n @fine_amount=0 if @financefee.is_paid\n render :update do |page|\n if params[:add_fine].present?\n page.replace_html 'modal-box', :partial => 'individual_fine_submission'\n page << \"Modalbox.show($('modal-box'), {title: ''});\"\n elsif @fine.nil? or @fine.to_f > 0\n # page.replace_html \"fee_submission\",\n # :partial => \"finance/fees_payment/#{@linking_required ? 'notice_link_particulars' : 'fees_submission_form'}\",\n # :with => @fine\n page.replace_html \"fee_submission\",\n :partial => \"finance/fees_payment/fees_submission_form\", :with => @fine\n page << \"Modalbox.hide();\"\n elsif @fine.to_f <=0\n page.replace_html 'modal-box', :text => 'fine_submission'\n page.replace_html 'form-errors', :text => \"<div id='error-box'><ul><li>#{t('finance.flash24')}</li></ul></div>\"\n end\n end\n else\n render :update do |page|\n page.replace_html \"fee_submission\", :text => '<p class=\"flash-msg\">No students have been assigned this fee.</p>'\n end\n end\n else\n render :update do |page|\n page.replace_html \"fee_submission\", :text => ''\n end\n end\n\n end",
"def get_convenience_fee\n @invoice.amount ? CalcTotal::get_convenience_fee(sales_price).round(2) : 0.0\n end",
"def state_fulfillment_fee\n adjustments.eligible.where(:label => 'Additional State Fulfillment Fee').first.amount rescue 0.0\n end",
"def get_fee(detail_page)\n fee_array = []\n first_table = detail_page.search('div#ctl00_MainBodyContent_group_19 table.ContentPanel')\n if first_table != nil\n list_tr = first_table.search('tr')\n for i in 1..list_tr.length-1\n list_td = list_tr[i].search('td')\n fee_obj = {}\n fee_obj[:application_fee_type] = clean_whitespace(list_td[0].inner_text)\n fee_obj[:accepted_fee_amount] = clean_whitespace(list_td[1].inner_text)\n fee_obj[:paid] = clean_whitespace(list_td[2].inner_text)\n fee_obj[:balance] = clean_whitespace(list_td[3].inner_text)\n fee_array << fee_obj\n end\n else\n return \"\"\n end\n return fee_array\nend",
"def get_fee(detail_page)\n fee_array = []\n first_table = detail_page.search('div#ctl00_MainBodyContent_group_19 table.ContentPanel')\n if first_table != nil\n list_tr = first_table.search('tr')\n for i in 1..list_tr.length-1\n list_td = list_tr[i].search('td')\n fee_obj = {}\n fee_obj[:application_fee_type] = clean_whitespace(list_td[0].inner_text)\n fee_obj[:accepted_fee_amount] = clean_whitespace(list_td[1].inner_text)\n fee_obj[:paid] = clean_whitespace(list_td[2].inner_text)\n fee_obj[:balance] = clean_whitespace(list_td[3].inner_text)\n fee_array << fee_obj\n end\n else\n return \"\"\n end\n return fee_array\nend",
"def check_paid\n self.paid_amount = 0\n self.paid = false\n payments.each do |payment|\n self.paid_amount += payment.amount\n end\n \n if self.paid_amount - self.gross_amount >= 0\n self.paid = true\n end\n end",
"def validate_funding\n # randomize funding method!\n validate_random_day 'Funding Method', EngagementRequest::FUNDING_METHODS[self.funding_method]\n\n # sponsor is funding it!\n if self.cost_center != self.sponsor.department.cost_center\n add_validation \"Cost Center should match the Sponsor's cost center\"\n end\n\n # detailed estimate must be funding approved!\n if self.detailed_estimate? && ! (self.approved? || self.budget?)\n add_validation EngagementRequest::ENGAGEMENT_TYPES[self.engagement_type] + ' must have budget ' +\n EngagementRequest::FUNDING_STATUSES[\"approved\"] + ' or ' +\n EngagementRequest::FUNDING_STATUSES[\"budget\"]\n end\n # scheduling or rescue must have budget!\n if (self.scheduling? || self.rescue?) && ! self.budget?\n add_validation EngagementRequest::ENGAGEMENT_TYPES[self.engagement_type] + ' must have ' +\n EngagementRequest::FUNDING_STATUSES[\"budget\"]\n end\n\n # must have a decent budget!\n if self.budget_allocated < 100_000\n add_validation 'Projects with a budget of less than $100,000 are not accepted'\n end\n end",
"def invoice_possible?\n # 1. facture globale ?\n invoices = Invoice.find :first,\n \t:conditions => ['order_id = ? AND ds_id IS NULL', self.order_id]\n return false if (!invoices.nil?)\n # 2. facture pour cette livraison ?\n invoices = Invoice.find :first, :conditions => ['ds_id = ?', self.id]\n return false if (!invoices.nil?)\n # 3. bon de commande pour cette livraison ?\n return false if (self.order_id.nil?)\n return true\n end",
"def getFees(airplane, fbo, timeUnit = nil, timeLength = 0, landingTime = nil)\n\n\t\tif !landingTime.nil?\n\t\t\tlandingTime = timeToMinutes(landingTime)\n\t\tend\n\n\t\tfees = Fee.where( :fbo => fbo )\n\t\tisEstimate = false\n\n\t\tfees.each do |curFee|\n\n\t\t\tclassificationDesc = curFee.classification.classification_description\n\t\t\tcurCategory = curFee.category.category_description\n\n\t# Figure out if categories are missing so that the data retrieval is more complete\n\t# WWWWHHHEEEEEEEEE\n\t\t\tif classificationDesc == \"engine type\"\n\t# doesn't have piston multi light\n\t\t\t\tif !hasCategory(fees, \"piston multi light\") and hasCategory(fees, \"piston multi heavy\") and airplane.engine_class == \"piston multi light\"\n\t\t\t\t\tairplane.engine_class = \"piston multi heavy\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have piston multi heavy\n\t\t\t\telsif !hasCategory(fees, \"piston multi heavy\") and hasCategory(fees, \"piston multi light\") and airplane.engine_class == \"piston multi heavy\"\n\t\t\t\t\tairplane.engine_class = \"piston multi light\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have turboprop single heavy\n\t\t\t\telsif !hasCategory(fees, \"turboprop single heavy\") and hasCategory(fees, \"turboprop single light\") and airplane.engine_class == \"turboprop single heavy\"\n\t\t\t\t\tairplane.engine_class = \"turboprop single light\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have turboprop single light\n\t\t\t\telsif !hasCategory(fees, \"turboprop single light\") and hasCategory(fees, \"turboprop single heavy\") and airplane.engine_class == \"turboprop single light\"\n\t\t\t\t\tairplane.engine_class = \"turboprop single heavy\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have turboprop twin light\n\t\t\t\telsif !hasCategory(fees, \"turboprop twin light\") and hasCategory(fees, \"turboprop twin medium\") and airplane.engine_class == \"turboprop twin light\"\n\t\t\t\t\tairplane.engine_class = \"turboprop twin medium\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"turboprop twin light\") and hasCategory(fees, \"turboprop twin heavy\") and airplane.engine_class == \"turboprop twin light\"\n\t\t\t\t\tairplane.engine_class = \"turboprop twin heavy\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have turboprop twin medium\n\t\t\t\telsif !hasCategory(fees, \"turboprop twin medium\") and hasCategory(fees, \"turboprop twin heavy\") and airplane.engine_class == \"turboprop twin medium\"\n\t\t\t\t\tairplane.engine_class = \"turboprop twin heavy\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"turboprop twin medium\") and hasCategory(fees, \"turboprop twin light\") and airplane.engine_class == \"turboprop twin medium\"\n\t\t\t\t\tairplane.engine_class = \"turboprop twin light\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have turboprop twin heavy\n\t\t\t\telsif !hasCategory(fees, \"turboprop twin heavy\") and hasCategory(fees, \"turboprop twin medium\") and airplane.engine_class == \"turboprop twin heavy\"\n\t\t\t\t\tairplane.engine_class = \"turboprop twin medium\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"turboprop twin heavy\") and hasCategory(fees, \"turboprop twin light\") and airplane.engine_class == \"turboprop twin heavy\"\n\t\t\t\t\tairplane.engine_class = \"turboprop twin light\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have light jet\n\t\t\t\telsif !hasCategory(fees, \"light jet\") and hasCategory(fees, \"midsize jet\") and airplane.engine_class == \"light jet\"\n\t\t\t\t\tairplane.engine_class = \"midsize jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"light jet\") and hasCategory(fees, \"super midsize jet\") and airplane.engine_class == \"light jet\"\n\t\t\t\t\tairplane.engine_class = \"super midsize jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"light jet\") and hasCategory(fees, \"heavy jet\") and airplane.engine_class == \"light jet\"\n\t\t\t\t\tairplane.engine_class = \"heavy jet\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have midsize jet\n\t\t\t\telsif !hasCategory(fees, \"midsize jet\") and hasCategory(fees, \"super midsize jet\") and airplane.engine_class == \"midsize jet\"\n\t\t\t\t\tairplane.engine_class = \"super midsize jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"midsize jet\") and hasCategory(fees, \"light jet\") and airplane.engine_class == \"midsize jet\"\n\t\t\t\t\tairplane.engine_class = \"light jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"midsize jet\") and hasCategory(fees, \"heavy jet\") and airplane.engine_class == \"midsize jet\"\n\t\t\t\t\tairplane.engine_class = \"heavy jet\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have super midsize jet\n\t\t\t\telsif !hasCategory(fees, \"super midsize jet\") and hasCategory(fees, \"heavy jet\") and airplane.engine_class == \"super midsize jet\"\n\t\t\t\t\tairplane.engine_class = \"heavy jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"super midsize jet\") and hasCategory(fees, \"midsize jet\") and airplane.engine_class == \"super midsize jet\"\n\t\t\t\t\tairplane.engine_class = \"midsize jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"super midsize jet\") and hasCategory(fees, \"light jet\") and airplane.engine_class == \"super midsize jet\"\n\t\t\t\t\tairplane.engine_class = \"light jet\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have heavy jet\n\t\t\t\telsif !hasCategory(fees, \"heavy jet\") and hasCategory(fees, \"super midsize jet\") and airplane.engine_class == \"heavy jet\"\n\t\t\t\t\tairplane.engine_class = \"super midsize jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"heavy jet\") and hasCategory(fees, \"midsize jet\") and airplane.engine_class == \"heavy jet\"\n\t\t\t\t\tairplane.engine_class = \"midsize jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"heavy jet\") and hasCategory(fees, \"light jet\") and airplane.engine_class == \"heavy jet\"\n\t\t\t\t\tairplane.engine_class = \"light\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tfees = fees.reject do |curFee|\n\t\t\tclassificationDesc = curFee.classification.classification_description\n\t\t\tcurCategory = curFee.category.category_description\n\n\t\t\tif classificationDesc == \"engine type\" and curCategory != \"flat rate\" and curCategory != \"no fee\" and curCategory != \"weight\" and curCategory != \"weight range\"\n\t\t\t\tif curCategory == \"jet\"\n\t\t\t\t\t!airplane.engine_class =~ /jet/\n\t\t\t\telsif curCategory == \"turboprop\"\n\t\t\t\t\t!airplane.engine_class =~ /turboprop/\n\t\t\t\telsif curCategory == \"turboprop single\"\n\t\t\t\t\t!airplane.engine_class =~ /turboprop single/\n\t\t\t\telsif curCategory == \"turboprop multi\"\n\t\t\t\t\t!airplane.engine_class =~ /turboprop multi/\n\n\t\t\t\telsif curCategory == \"piston\"\n\t\t\t\t\t!airplane.engine_class =~ /piston/\n\t\t\t\telsif curCategory == \"piston multi\"\n\t\t\t\t\t!airplane.engine_class =~ /piston multi/\n\n\t\t\t\telse\n\t\t\t\t\tcurCategory != airplane.engine_class\n\t\t\t\tend\n\t\t\tend\n\n\t\tend\n\n\t\t# For fees with the wrong engine type\n\t\tfees = fees.reject do |curFee|\t\n\t\t\tif isEstimate\n\t\t\t\tcurFee.is_estimate = true\n\t\t\tend\n\t\t\tcurCategory = curFee.category.category_description\n\t\t\tclassificationDesc = curFee.classification.classification_description\n\n\t\t\tif classificationDesc == \"engine type\" and curCategory != \"flat rate\" and curCategory != \"no fee\" and curCategory != \"weight\" and curCategory != \"weight range\"\n\t\t\t\tif curCategory == \"jet\"\n\t\t\t\t\t!airplane.engine_class =~ /jet/\n\n\t\t\t\telsif curCategory == \"turboprop\"\n\t\t\t\t\t!airplane.engine_class =~ /turboprop/\n\t\t\t\telsif curCategory == \"turboprop single\"\n\t\t\t\t\t!airplane.engine_class =~ /turboprop single/\n\t\t\t\telsif curCategory == \"turboprop multi\"\n\t\t\t\t\t!airplane.engine_class =~ /turboprop multi/\n\n\t\t\t\telsif curCategory == \"piston\"\n\t\t\t\t\t!airplane.engine_class =~ /piston/\n\t\t\t\telsif curCategory == \"piston multi\"\n\t\t\t\t\t!airplane.engine_class =~ /piston multi/\n\n\t\t\t\telse\n\t\t\t\t\tcurCategory != airplane.engine_class\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# For fees that have a start time and end time that are in the wrong range\n\t\tfees = fees.reject do |curFee|\n\t\t\tcurCategory = curFee.category.category_description\n\t\t\tclassificationDesc = curFee.classification.classification_description\n\n\t\t\tif !curFee.start_time.nil? and !curFee.end_time.nil? and !landingTime.nil? # If the fee has a start time and an end time, make sure it falls in the right time period.\n\t\t\t\t\n\t\t\t\tstartTime = curFee.start_time\n\t\t\t\tendTime = curFee.end_time\n\t\t\t\t# If the fee skips over midnight, add 1440 minutes (1 day) to the end time so the comparison works properly\n\t\t\t\tif startTime > endTime\n\t\t\t\t\tendTime += 1440\n\t\t\t\tend\n\n\t\t\t\tlandingTime < startTime or landingTime > endTime\n\t\t\tend\n\t\tend\n\n\t\t# For fees that use the wrong time unit\n\t\tfees = fees.reject do |curFee|\n\t\t\tif !curFee.time_unit.nil? # reject fees that use the wrong time unit\n\t\t\t\tcurFee.time_unit != timeUnit\n\t\t\tend\n\t\tend\n\n\t\t# For fees that are the wrong make/model\n\t\tfees = fees.reject do |curFee|\n\t\t\tcurCategory = curFee.category.category_description\n\t\t\tclassificationDesc = curFee.classification.classification_description\n\n\t\t\tif classificationDesc == \"make and model\" and curCategory != \"flat rate\" and curCategory != \"no fee\" and curCategory != \"weight\" and curCategory != \"weight range\"\n\t\t\t\tcurCategory != airplane.model\n\t\t\tend\n\t\tend\n\n\t\t# For fees where the airplane weight doesn't fall in the weight range\n\t\tfees = fees.reject do |curFee|\n\t\t\tcurCategory = curFee.category.category_description\n\n\t\t\tif curCategory == \"weight range\" and !curFee.unit_minimum.nil? and !curFee.unit_maximum.nil?\n\t\t\t\tairplane.weight < curFee.unit_minimum or airplane.weight > curFee.unit_maximum # reject fees if the airplane weight is less than the minimum or greater than the maximum\n\t\t\tend\n\t\tend\n\n\t\tfees = applyConditionalFees(airplane, fees, timeUnit, timeLength, landingTime)\n\t\tif fees.nil? or fees.length == 0\n\t\t\tputs \"check\"\n\t\t\treturn nil\n\t\telse\n\t\t\treturn fees\n\t\tend\n\tend",
"def fees_particulars_create\n if request.get?\n redirect_to :action => \"fees_particulars_new\"\n else\n @finance_category=FinanceFeeCategory.find_by_id(params[:finance_fee_particular][:finance_fee_category_id])\n @tax_slabs = TaxSlab.all if @tax_enabled\n @batches= Batch.find(:all,\n :joins => \"INNER JOIN `category_batches` ON `batches`.id = `category_batches`.batch_id\n INNER JOIN finance_fee_categories on finance_fee_categories.id=category_batches.finance_fee_category_id \n INNER JOIN courses on courses.id=batches.course_id\",\n :conditions => [\"finance_fee_categories.name = ? and finance_fee_categories.description = ?\",\n \"#{@finance_category.name}\", \"#{@finance_category.description}\"],\n :order => \"courses.code ASC\") if @finance_category\n if params[:particular] and params[:particular][:batch_ids]\n batches=Batch.find(params[:particular][:batch_ids])\n @cat_ids=params[:particular][:batch_ids]\n if params[:particular][:receiver_id].present?\n all_admission_no = admission_no=params[:particular][:receiver_id].split(',')\n all_students = batches.map { |b| b.students.map { |stu| stu.admission_no } }.flatten\n rejected_admission_no = admission_no.select { |adm| !all_students.include? adm }\n unless (rejected_admission_no.empty?)\n @error = true\n @finance_fee_particular = FinanceFeeParticular.new(params[:finance_fee_particular])\n @finance_fee_particular.batch_id=1\n @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{rejected_admission_no.join(',')} #{t('does_not_belong_to_batch')} #{batches.map { |batch| batch.full_name }.join(',')}\")\n end\n\n selected_admission_no = all_admission_no.select { |adm| all_students.include? adm }\n selected_admission_no.each do |a|\n s = Student.first(:conditions => [\"admission_no LIKE BINARY(?)\", a])\n if s.nil?\n @error = true\n @finance_fee_particular = FinanceFeeParticular.new(params[:finance_fee_particular])\n @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{a} #{t('does_not_exist')}\")\n end\n end\n unless @error\n\n selected_admission_no.each do |a|\n s = Student.first(:conditions => [\"admission_no LIKE BINARY(?)\", a])\n batch=s.batch\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.receiver_id=s.id\n @error = true unless @finance_fee_particular.save\n end\n end\n else\n batches.each do |batch|\n if params[:finance_fee_particular][:receiver_type]==\"Batch\"\n\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.receiver_id=batch.id\n @error = true unless @finance_fee_particular.save\n elsif params[:finance_fee_particular][:receiver_type]==\"StudentCategory\"\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @error = true unless @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{t('category_cant_be_blank')}\") if params[:finance_fee_particular][:receiver_id]==\"\"\n else\n\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @error = true unless @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{t('admission_no_cant_be_blank')}\")\n end\n\n end\n end\n else\n @error=true\n @finance_fee_particular =FinanceFeeParticular.new(params[:finance_fee_particular])\n @finance_fee_particular.save\n end\n\n if @error\n @fees_categories = FinanceFeeCategory.find(:all, :group => :name, :conditions => \"is_deleted = 0 and is_master = 1\")\n @student_categories = StudentCategory.active\n @master_fee_particulars = MasterFeeParticular.core\n @render=true\n if params[:finance_fee_particular][:receiver_type]==\"Student\"\n @student=true\n elsif params[:finance_fee_particular][:receiver_type]==\"StudentCategory\"\n @category=true\n else\n @all=true\n end\n\n render :action => 'fees_particulars_new'\n else\n flash[:notice]=\"#{t('particulars_created_successfully')}\"\n redirect_to :action => \"fees_particulars_new\"\n end\n end\n end",
"def remaining_funds()\n films = self.find_films_for_each_customer()\n film_fees = films.map{|film| film.price}\n combined_fees = film_fees.sum\n return @funds - combined_fees\n end",
"def request_entry_fee(guests, room)\n # for each guest in the guests array pay the entry_fee for the room\n # pay_entry_fee method checks if they can afford it\n guests.each { |guest| guest.pay_entry_fee(room.entry_fee()) }\n end",
"def allow_entry?\n #current_financial_year.is_freezed?\n @financial_year.is_freezed?\n end",
"def fee_receipts\n unless params[:search].present?\n @start_date=@end_date=FedenaTimeSet.current_time_to_local_time(Time.now).to_date\n else\n @start_date=date_fetch('start_date_as')\n @end_date=date_fetch('end_date_as')\n end\n @search_params = params[:search] || Hash.new\n @search_params[:start_date_as] = @start_date\n @search_params[:end_date_as] = @end_date\n @search = fetched_fee_receipts.search(@search_params)\n @[email protected] AdvanceFeeCollection.fetch_advance_fees_receipts(@start_date, @end_date, params)\n @fee_receipts = @receipts.sort_by{|o| o.transaction_date.to_date}.reverse.paginate(\n :per_page => 20,\n :page => params[:page])\n @grand_total = 0.00\n @fee_receipts.each {|f| @grand_total += f.amount.to_f }\n end",
"def folios_coherent?\n nomen.folios.each do |f|\n nomen.errors.add(:folio, \"Le folio #{f.name} indique une incohérence : #{f.errors.full_messages}\") unless f.coherent?\n end\n end",
"def membership_fee\n if business_admin?\n {\"amount\" => 29900, \"id\" => \"business-29900\"}\n elsif church_admin?\n {\"amount\" => 9900, \"id\" => \"church-9900\"}\n elsif alliance_admin?\n {\"amount\" => 9900, \"id\" => \"alliance-9900\"}\n else\n {\"amount\" => 4900, \"id\" => \"individual-4900\"}\n end\n end",
"def validate_on_update\n quantity_count = SupplierOrderFulfillment.sum(:quantity,\n :conditions => ['supplier_order_id=?',supplier_order_id])\n #total quantity in order >= all quantity in fulfillment\n current_quantity = SupplierOrderFulfillment.find(id).quantity\n puts quantity_count\n if supplier_order.total_quantity >= quantity_count + quantity - current_quantity\n return true\n else\n errors.add_to_base('total quantity < fulfillment quantity')\n return false\n end\n end",
"def all_paid?\n people.sort == paid_infos.keys.sort\n end",
"def fixed_fee_quantity\n qty = billing_frequency.total_months\n sub_starting_at = subscriber.starting_at\n sub_ending_at = subscriber.ending_at\n if self.reading_type_id == ReadingType::RETIRADA && !self.reading_date.blank?\n sub_ending_at = self.reading_date.to_date\n end\n bp_billing_starting_date = billing_period.billing_starting_date\n bp_billing_ending_date = billing_period.billing_ending_date\n begin\n if sub_starting_at > bp_billing_starting_date && sub_starting_at < bp_billing_ending_date\n # Subscriber registerd during the period\n # qty = (bp_billing_ending_date - sub_starting_at).to_i.days.seconds / 1.month.seconds\n qty = ((bp_billing_ending_date - sub_starting_at).days.seconds / 1.month.seconds).round\n end\n if (!sub_ending_at.nil?) && (sub_ending_at > bp_billing_starting_date && sub_ending_at < bp_billing_ending_date)\n # Subscriber withdrawn during the period\n qty = ((sub_ending_at - bp_billing_starting_date).days.seconds / 1.month.seconds).round\n end\n rescue\n qty = billing_frequency.total_months\n end\n return qty\n end",
"def fee\n (amount * 0.005) if amount\n end",
"def calculation_required?\n [editable?, calculated?, agfs? || (lgfs? && is_fixed?)].all?\n end",
"def fees_student_dates\n @student = Student.find(params[:id])\n @dates = FinanceFeeCollection.find(:all,\n :joins => \"LEFT JOIN fee_accounts fa ON fa.id = finance_fee_collections.fee_account_id\n INNER JOIN collection_particulars on collection_particulars.finance_fee_collection_id=finance_fee_collections.id\n INNER JOIN finance_fee_particulars on finance_fee_particulars.id=collection_particulars.finance_fee_particular_id\n INNER JOIN finance_fees on finance_fees.fee_collection_id=finance_fee_collections.id\",\n :conditions => \"finance_fees.student_id='#{@student.id}' AND\n finance_fee_collections.is_deleted = false AND #{active_account_conditions} AND \" +\n # (finance_fee_collections.fee_account_id IS NULL OR\n # (finance_fee_collections.fee_account_id IS NOT NULL AND fa.is_deleted = false)) AND\n \"((finance_fee_particulars.receiver_type='Batch' and finance_fee_particulars.receiver_id=finance_fees.batch_id) or\n (finance_fee_particulars.receiver_type='Student' and finance_fee_particulars.receiver_id='#{@student.id}') or\n (finance_fee_particulars.receiver_type='StudentCategory' and\n finance_fee_particulars.receiver_id=finance_fees.student_category_id))\").uniq\n render \"finance/fees_payment/fees_student_dates\"\n end",
"def has_debit?\n entries.any?(&:debit?)\n end",
"def edit_delivery\n if !test_present_attributes([:fact_firstname, :fact_lastname, :fact_address, :fact_zipcode, :fact_city])\n redirect_to payments_fact_path\n end\n end",
"def fee\n\tparams['mc_fee']\n end",
"def verifica_anulacion_del_cierre\n if Cierre.where(\"fechaproceso > ? and activo = ? and empresa_id = ? \", self.fechaproceso.to_date + 1.day, true, 1).exists?\n errors.add(:fechaproceso, \"Existen fechas posteriores que estan cerradas.\")\n end\n end",
"def is_listing_fee?\n sku_type.to_s == Product::SKU_TYPE_LISTING_FEE && self.internal?\n end",
"def bar_accepts_fee(fee)\n @bar_cash += fee\n end",
"def contains_clearance_fees_price\n hash[\"CCFPrice\"]\n end",
"def calculate(t, fraud, type)\r\n#\t\tpp \"1\"\r\n\t\treturn 0.0 if type == 'billable' && self.bid_fee #if this fee is a bid fee and we are not looking at the bid fees then return 0, else continue on\r\n\t#\tpp \"2\"\r\n \t\r\n \tfee = self.fixed if self.price_type == 'F'\r\n \r\n fee = (self.fixed + (t.amount * self.percent) + (fraud == '1' ? self.fraud : 0)).at_least(self.min).at_most(self.max) if self.price_type == 'V' #calculate the fee\r\n \r\n return fee if self.sign == '>=' && self.threshold == 0 #if there is no threshold to worry about get out quick...this is what happens the majority of the time\r\n\t\r\n\t\t#if we get here we know we are dealing with a variable fee\r\n\t\t#puts (self.fixed + (t.amount * self.percent) + (fraud == '1' ? self.fraud : 0)).at_least(self.min)\r\n\t#\tfee = (self.fixed + (t.amount * self.percent) + (fraud == '1' ? self.fraud : 0)).at_least(self.min).at_most(self.max) #calculate the fee\r\n\t#\tpp fee\r\n\t#\tpp \"3\"\r\n\t#\treturn fee if self.sign == '>=' && self.threshold == 0 #if there is no threshold to worry about get out quick...this is what happens the majority of the time\r\n\t\t\r\n\t\t#otherwise we need to determine the sign and threshold before we can return\r\n\t\tcase self.sign\r\n\t\t\twhen '>'\r\n\t\t\t #pp \">\"\r\n\t\t\t\treturn fee if t.amount > self.threshold\r\n\t\t\twhen '>='\r\n\t\t\t #pp \">=\"\r\n\t\t\t\treturn fee if t.amount >= self.threshold\r\n\t\t\twhen '<'\r\n\t\t\t #pp \"<\"\r\n\t\t\t\treturn fee if t.amount < self.threshold\r\n\t\t\twhen '<='\r\n\t\t\t #pp \"<=\"\r\n\t\t\t\treturn fee if t.amount <= self.threshold\r\n\t\t\telse\r\n\t\t\t #pp \"4\"\r\n\t\t\t\treturn 0.0\r\n\t\tend\r\n\t\t\r\n\t\t#if we get here then we have no idea what to do so just return 0\r\n\t\treturn 0.0\r\n\tend",
"def addFees(filename)\n\tresponseText = open(Rails.root.join(\"db\", \"seed_data\", filename)).read\n\tresponseText.each_line do |curRow|\n\t\tcurRow = curRow.strip.downcase # get rid of new lines and make everything lowercase\n\n\t\t# split the excel sheet into individual variables using split\n\t\t# Note that each fee is itself a list of fees separated by commas.\n\t\tstate, city, airportName, airportCode, fboName, phoneNumbers, hasFees, classificationDesc, otherClassification, landingFee, rampFee, tieDownFee, facilityFee, callOutFee, hangarFee, otherFee, changeFrequency, feesWaived, fuelNeeded, contactPerson, callDate, infoQuality, hasFeeSheet, feeSheetLink, additionalInfo = curRow.split(\"\\t\")\n\t\t# If the FBO didn't or wouldn't answer, then we have no data for them and we should skip forward\n\t\tnext if hasFees == \"did not/would not answer\"\n\n\t\t#feeClassification = Classification.find_by( :classification_description => classificationDesc )\n\n\t\tcurAirport = Airport.find_by( :name => airportName)\n\t\tif curAirport.nil?\n\t\t\tcurAirport = Airport.find_by( :airport_code => airportCode )\n\t\t\t# If the airport wasn't found, try adding a k to the front of the airport code and try again\n\t\t\tif curAirport.nil? and airportCode.length == 3\n\t\t\t\tnewCode = \"k\" + airportCode\n\t\t\t\tcurAirport = Airport.find_by( :airport_code => newCode )\n\t\t\telsif curAirport.nil? and airportCode.length == 4\n\t\t\t# If the airport wasn't found, try removing the k from the front and trying again\n\t\t\t\tnewCode = airportCode[1..3]\n\t\t\t\tcurAirport = Airport.find_by( :airport_code => newCode )\n\t\t\tend\n\t\tend\n\n# I guess hypothetically this wouldn't work if there were two FBOs at an airport with the same name, but I don't think that has ever happened yet.\n\t\tcurFbo = Fbo.find_by(:name => fboName, :airport => curAirport)\n\n\t\tif !curFbo.nil?\n\t\t\t# this is what should happen\n\t\t\tif !hasFees.nil? and hasFees.strip == \"no\"\n\t\t\t\t#curFbo.update( :classification => Classification.find_by( :classification_description => \"flat rate\"))\n\t\t\t\tFeeType.find_each do |curFeeType|\n\t\t\t\t\tif curFeeType.fee_type_description == \"call out\"\n\t\t\t\t\t\tsingleFeeHelper(callOutFee, curFbo, curFeeType.fee_type_description, \"flat rate\")\n\t\t\t\t\telsif curFeeType.fee_type_description == \"hangar\"\n\t\t\t\t\t\t# do nothing\n\t\t\t\t\telse\n\t\t\t\t\t\tsingleFeeHelper(\"0\", curFbo, curFeeType.fee_type_description, \"flat rate\")\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t#elsif feeClassification.nil?\n\t\t\t\t#puts curFbo.name\n\t\t\t\t# do nothing\n\n\t\t\t# If the FBO has fees, so most of the time.\n\t\t\telse\n\t\t\t\t#curFbo.update( :classification => feeClassification )\n\t\t\t\t\n\t\t\t\t# For each type of fee, if it isn't nil, the split it up into its individual fees, then call the fee helper method on those fees.\n\t\t\t\t# landing fees\n\t\t\t\tif !landingFee.nil?\n\t\t\t\t\tlandingFee.split(\",\").each do |curFee|\n\t\t\t\t\t\tsingleFeeHelper(curFee, curFbo, \"landing\", classificationDesc)\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# ramp fees\n\t\t\t\tif !rampFee.nil?\n\t\t\t\t\trampFee.split(\",\").each do |curFee|\n\t\t\t\t\t\tsingleFeeHelper(curFee, curFbo, \"ramp\", classificationDesc)\n\t\t\t\t\tend\t\n\t\t\t\tend\n\n\t\t\t\t# tie down fees\n\t\t\t\tif !tieDownFee.nil?\n\t\t\t\t\ttieDownFee.split(\",\").each do |curFee|\n\t\t\t\t\t\tsingleFeeHelper(curFee, curFbo, \"tie down\", classificationDesc)\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# facility fees\n\t\t\t\tif !facilityFee.nil?\n\t\t\t\t\tfacilityFee.split(\",\").each do |curFee|\n\t\t\t\t\t\tsingleFeeHelper(curFee, curFbo, \"facility\", classificationDesc)\n\t\t\t\t\tend\t\n\t\t\t\tend\t\n\n\t\t\t\t# call out fees\n\t\t\t\tif !callOutFee.nil?\n\t\t\t\t\tcallOutFee.split(\",\").each do |curFee|\n\t\t\t\t\t\tsingleFeeHelper(curFee, curFbo, \"call out\", classificationDesc)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\t#puts fboName\n\t\tend\n\tend\nend",
"def set_derived_fields\n set_fac_code_terms if ok_to_sum?\n\n true\n end",
"def fbo_update_form\n @fbo= Fbo.new\n @fee_types = [1,3,4,2,5]\n @id= 0\n @count= 0\n end",
"def add_fee(args)\n result = Spreedly.post(\"/subscribers/#{id}/fees.xml\", :body => Spreedly.to_xml_params(:fee => args))\n\n case result.code.to_s\n when /2../\n when '404'\n raise \"Not Found\"\n when '422'\n raise \"Unprocessable Entity - #{result.body}\"\n else\n raise \"Could not add fee to subscriber: result code #{result.code}.\"\n end\n end"
] | [
"0.69060236",
"0.6772932",
"0.6761408",
"0.6740688",
"0.660252",
"0.65942687",
"0.6486096",
"0.6436056",
"0.63311875",
"0.63245404",
"0.6315531",
"0.62102324",
"0.6156142",
"0.6149327",
"0.6124711",
"0.61027366",
"0.6074607",
"0.6059176",
"0.6004836",
"0.5988711",
"0.5981289",
"0.5951895",
"0.59321254",
"0.59321254",
"0.59321254",
"0.5928728",
"0.59230614",
"0.59193367",
"0.5917218",
"0.5883694",
"0.5878482",
"0.5872385",
"0.58542114",
"0.5836438",
"0.58359706",
"0.58242756",
"0.57887673",
"0.57777524",
"0.577073",
"0.57139206",
"0.5702885",
"0.5698666",
"0.5690987",
"0.56783086",
"0.5662087",
"0.5645799",
"0.56360126",
"0.5635458",
"0.5631533",
"0.5630841",
"0.5627461",
"0.56086373",
"0.55944157",
"0.5579224",
"0.55703676",
"0.55359536",
"0.55349046",
"0.5516576",
"0.5516222",
"0.5507206",
"0.5499759",
"0.54870516",
"0.54868644",
"0.54809684",
"0.5477576",
"0.54726064",
"0.54571193",
"0.54546356",
"0.5439842",
"0.54249346",
"0.54249346",
"0.54180825",
"0.54135275",
"0.5391693",
"0.5374367",
"0.5370483",
"0.5353172",
"0.5353083",
"0.53505564",
"0.53501225",
"0.5334851",
"0.533465",
"0.53126645",
"0.531127",
"0.53101754",
"0.53072584",
"0.5289436",
"0.5288655",
"0.52831715",
"0.52801955",
"0.52793425",
"0.5278781",
"0.5276077",
"0.5267199",
"0.52518094",
"0.52508676",
"0.5245628",
"0.523946",
"0.5233776",
"0.5229506"
] | 0.73601407 | 0 |
edit fee fields have valid integers | def edit_fee_is_integer
if !params[:edit_fees].nil?
edit_fees_vals = params[:edit_fees].values
edit_fees_vals.each_slice(3) do |fee, time, remove|
if !(fee.to_i.to_s.eql? fee)
return false
end
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_fee_is_integer\n if !params[:add_fee].nil?\n add_fee_vals = params[:add_fee].values\n add_fee_vals.each_slice(3) do |student_type, amount, time_period|\n if !amount.empty? && !(amount.to_i.to_s.eql? amount)\n return false\n end\n end\n end\n return true\n end",
"def edit_fee_fields_filled\n if !params[:edit_fees].nil?\n edit_fees_vals = params[:edit_fees].values\n edit_fees_vals.each_slice(3) do |fee, time, remove|\n if fee.empty? || time.empty?\n return false\n end\n end\n end\n return true\n end",
"def fee\n params['amount_fee']\n end",
"def total_fee_is_valid\n errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid?\n end",
"def fee_params\n params.require(:fee).permit(:description, :amount)\n end",
"def apply_validations_for_integer\n options = { :numericality => { :only_integer => true } }\n options[:allow_nil] = true unless not_nullable?\n flex_column_class.validates field_name, options\n end",
"def set_fee\n @fee = Fee.friendly.friendly.find(params[:fee_id])\n end",
"def document_fee\n 0\n end",
"def fee_params\n params.require(:fee).permit(:student_id, :amount, :user_id, :month)\n end",
"def fee\n\tparams['mc_fee']\n end",
"def fee_params\n params.require(:fee).permit(:user_id, :name, :price, :serial, :end_at, :deleted_at)\n end",
"def vdate_pin(attr)\nvalidates_presence_of attr , :message => \"^Please Fill #{attr}\"\nvalidates_format_of attr , :with => /^\\d{6}$/ ,\n :message => \"^invalid #{attr}, #{attr} is 6 digit number\"\nend",
"def fee_for_additional_materials_is_valid\n errors.add(:fee_for_additional_materials, 'The fee for additional materials is invalid.') unless fee_for_additional_materials_is_valid?\n end",
"def check_integer(field_info, field)\n if should_be_integer?(field_info, field) && !integer?(field) && !foreign_key?(field)\n add_integer_message_to_errors(field)\n end\n end",
"def validade_field_boleto\n puts field_number_boleto.text\n if field_number_boleto.include?('03399')\n puts \"Boleto OK\"\n else\n puts \"Boleto invalid\"\n end\n end",
"def budget_fee_id\n if doc_type==9\n #差旅费\n Fee.find_by_code('03').id\n elsif doc_type==10\n #交际费用\n Fee.find_by_code('02').id\n elsif doc_type==11\n #加班费用\n Fee.find_by_code('06').id \n elsif doc_type==13\n Fee.find_by_code('04').id\n else\n #其他\n -1\n end\n end",
"def set_fee\n @book = Book.find(params[:book_id])\n @fee = @book.fees.find(params[:id])\n end",
"def fee_params\n params.require(:fee).permit(:fee_name)\n end",
"def fee\n @fee || DEFAULT_FEE\n end",
"def get_numeric_field(value, id, field, *args)\n puts \"#{field} : #{value.class.to_s}\"\n opt = args.extract_options!\n if is_numeric?(value)\n if (value < 0)\n if (opt[:if_neg].eql?(:error)) # generate an error if value < 0\n invalid = \"#{field} doit etre > 0\"\n add_invalid(invalid, id)\n nil\n elsif opt[:if_neg].eql?(:warning) # generate a warning if value < 0\n warning = \"#{field} n'est pas > 0\"\n add_warning(warning, id)\n nil\n else\n #return value even if value<0\n end\n end\n value\n # branche elsif ci-dessous ajoutee car OpenOffice ne semble pas renvoyer de classe Integer pour les nombres\n elsif (value.class.eql?(String) || value.class.eql?(Fixnum))\n value = value.to_f\n if (value < 0)\n if (opt[:if_neg].eql?(:error)) # generate an error if value < 0\n invalid = \"#{field} doit etre > 0\"\n add_invalid(invalid, id)\n nil\n elsif opt[:if_neg].eql?(:warning) # generate a warning if value < 0\n warning = \"#{field} n'est pas > 0\"\n add_warning(warning, id)\n nil\n else\n #return value even if value<0\n end\n end\n value\n else\n if (opt[:invalid].eql?(:error)) # required => generate an error\n invalid = \"#{field} doit etre un nombre valide (class : #{field.class.to_s})\"\n add_invalid(invalid, id)\n elsif opt[:invalid].eql?(:warning) # not required => generate a warning\n warning = \"#{field} n'est pas un nombre valide\"\n add_warning(warning, id)\n end\n return nil\n end\n end",
"def validatable_basic_fee_types\n @fee_types.select do |fee_type|\n fee_type.calculated == true && !fee_type.defendant_uplift?\n end\n end",
"def french_siret_number; end",
"def validate\n if self.iso_week_code.to_i == 0\n errors.add(\"iso_week_code\",\"must be a number\")\n return\n end\n \n if self.iso_week_code.length == 1\n self.iso_week_code = \"0\" + self.iso_week_code\n end\n end",
"def invalid_south_african_id_number; end",
"def update\n @account_type = AccountType.find(params[:id])\n @account_type.price = params[:price].to_money unless params[:price].blank?\n @account_type.flat_fee = params[:flat_fee].to_money unless params[:flat_fee].blank? \n \n respond_to do |format|\n if @account_type.update_attributes(params[:account_type])\n format.html { redirect_to [:admin, @account_type] }\n format.xml { render :nothing => true }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account_type.errors.to_xml } \n end\n end\n end",
"def fee\n params['mc_fee']\n end",
"def fee\n params['mc_fee']\n end",
"def set_fee\n @fee = Fee.find(params[:id])\n end",
"def set_fee\n @fee = Fee.find(params[:id])\n end",
"def set_fee\n @fee = Fee.find(params[:id])\n end",
"def should_be_integer?(field_info, field)\n field_info[\"type\"] == \"INTEGER\"\n end",
"def amount_required\n @data['amountRequired'].to_f\n end",
"def enforce_integer_columns(options = {})\n # first get the non-integers\n options[:allow_nil] = true\n args = build_validation_args(options, :numeric, :not_a_number)\n validates_numericality_of(*args) unless args.first.is_a? Hash\n # now do the integers\n options[:only_integer] = true\n args = build_validation_args(options, :integer, :not_a_number)\n validates_numericality_of(*args) unless args.first.is_a? Hash\n end",
"def amount_is_valid\n errors.add(:amount, 'ticket amount is not right. Please double check') if amount < 40 || amount > 200\n end",
"def fee_per_meeting_is_valid\n errors.add(:fee_per_meeting, 'The fee per meeting is invalid.') unless fee_per_meeting_is_valid?\n end",
"def form_transportation_fee_params\n params\n .permit(:funeral_id)\n end",
"def fee\n @ipn['mc_fee']\n end",
"def test_editability(model_instance)\n return unless fee_classes.include?(model_instance.class)\n model_instance.errors.add(:base, 'uneditable_state') unless model_instance.claim.editable?\n rescue StandardError\n true\n end",
"def correct_format_for_values\n self.value.to_i\n end",
"def fee_type_params\n params.require(:fee_type).permit(:title, :amount)\n end",
"def apply_validations_for_float\n flex_column_class.validates field_name, :numericality => true, :allow_nil => true\n end",
"def validate_integer_type(field)\n if field.is_a?(Integer)\n return true\n else\n return false\n end\n end",
"def validates_integer(atts, opts={})\n validatable_attributes(atts, opts) do |a,v,m|\n begin\n Kernel.Integer(v.to_s)\n nil\n rescue\n m || 'is not a number'\n end\n end\n end",
"def set_expense_entry_expense_amount\n data=params\n @tne_invoice_expense_entry = TneInvoiceExpenseEntry.find(data[:id])\n expense_amount = !data[:value].blank? ? data[:value].to_i : 0\n @error=false\n if expense_amount > 0\n @tne_invoice_expense_entry.update_attribute(:expense_amount,expense_amount)\n @final_expense_amount = @tne_invoice_expense_entry.calculate_final_expense_amount\n else\n @error=true\n flash[:error]= t(:flash_enter_valid_expense_amt)\n end\n end",
"def french_siren_number; end",
"def update_fee\n\t\tmoney_info = money_info()\n\t\t@fee = money_info['Trade_Fee'] / 100.0\n\tend",
"def french_insee_number; end",
"def validate\n errors.add_to_base \"That was tricky! Passangers must be an integer between 1 and 10 inclusive.\\nYou tried:\"+passengersToBoard.to_s if number_of_passangers?\n #errors.add(\"passengers\", \"tried:\"+passengersToBoard.to_s) if number_of_passangers? \n end",
"def legal_person_id_format\n unless CPF.new(self.legal_id).valid?\n self.errors.add(:legal_id, 'must be a valid CPF')\n raise ActiveRecord::Rollback\n end\n end",
"def total_fee\n fee + fee2 + fee3 + fee4\n end",
"def valid_south_african_id_number; end",
"def check_numericality(klass, filter)\n filter.attributes.each do |attr|\n qry = ''\n shoulda = ''\n if filter.options[:only_integer].present?\n qry = \"CEIL(#{attr}) != #{attr}\"\n shoulda = 'been an integer'\n end\n if filter.options[:greater_than].present?\n qry += qry.blank? ? '' : ' OR '\n shoulda += shoulda.blank? ? '' : ' and '\n qry += \"#{attr} <= #{filter.options[:greater_than]}\"\n shoulda += \" length > #{filter.options[:greater_than]}\"\n end\n if filter.options[:less_than].present?\n qry += qry.blank? ? '' : ' OR '\n shoulda += shoulda.blank? ? '' : ' and '\n qry += \"#{attr} >= #{filter.options[:less_than]}\"\n shoulda += \" length < #{filter.options[:less_than]}\"\n end\n\n ids = klass.where(qry).pluck(:id)\n msg = \" #{ids.count} records that are an invalid #{filter.attributes} because it should #{shoulda}\"\n # rubocop:disable Lint/Void\n [ids, msg]\n # rubocop:enable Lint/Void\n end\n end",
"def edit\n if [email protected]\n @question.answer = @question.answer.to_i\n end\n end",
"def verify_fees(test_data)\n fees = test_data[CoreUseOfCollectionsData::FEE_GRP.name] || [CoreUseOfCollectionsData.empty_fee]\n fees.each_with_index do |fee, index|\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_CURRENCY.name], element_value(fee_currency_input index))\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_VALUE.name], element_value(fee_value_input index))\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_NOTE.name], element_value(fee_note_input index))\n end\n end",
"def fixed_fees\n fixed_fee.nil? ? [] : [fixed_fee]\n end",
"def set_fee_type\n @fee_type = FeeType.find(params[:id])\n end",
"def price_field\n \"#{field_name.parameterize.gsub('-', '_')}_value_as_integer\"\n end",
"def fbo_update_form\n @fbo= Fbo.new\n @fee_types = [1,3,4,2,5]\n @id= 0\n @count= 0\n end",
"def appraisal_fee_params\n params.require(:appraisal_fee).permit(:duration_from, :duration_to, :percentual, :fixed_min, :fixed_max, :loan_id)\n end",
"def create\n params[:fee][:amount].gsub!(/[$,]/, '')\n params[:fee][:amount] = (params[:fee][:amount].to_f * 100).to_i\n\n @fee = Fee.new(fee_params)\n @fee.booth = Booth.find(params[:booth_id])\n\n respond_to do |format|\n if @fee.save\n format.html { redirect_to @fee.booth, notice: 'Fee was successfully created.' }\n format.json { render :show, status: :created, location: @fee }\n else\n format.html { render :new }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def verify_fields\n fbe_current_offset = 0\n\n currency.fbe_offset = fbe_current_offset\n fbe_field_size = currency.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n amount.fbe_offset = fbe_current_offset\n fbe_field_size = amount.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n # noinspection RubyUnnecessaryReturnValue\n fbe_current_offset\n end",
"def update\n respond_to do |format|\n if @appraisal_fee.update(appraisal_fee_params)\n format.html { redirect_to appraisal_fees_path, notice: 'Appraisal fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @appraisal_fee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cast_tinyint_integer?(field)\n field.length != 1\n end",
"def fee_for_additional_materials_is_valid?\n return ((self.fee_for_additional_materials != nil) and (self.fee_for_additional_materials >= 0))\n end",
"def verify_fees(test_data)\n fees = test_data[UseOfCollections::FEE_GRP.name] || [UseOfCollections.empty_fee]\n fees.each_with_index do |fee, index|\n verify_values_match(fee[UseOfCollections::FEE_CURRENCY.name], element_value(fee_currency_input index))\n verify_values_match(fee[UseOfCollections::FEE_VALUE.name], element_value(fee_value_input index))\n verify_values_match(fee[UseOfCollections::FEE_NOTE.name], element_value(fee_note_input index))\n end\n end",
"def toll_free_number\n FFaker.numerify('1800 ### ####')\n end",
"def updateNewAvaible(quantity)\n \n if self.unit_type != \"KG\" \n #Solo puede acceptar numeros naturales o enteros xq es Unidad\n naturalN = quantity.to_i # convierte numero float a integer \n newAvaible= self.avaible- naturalN\n #self.update_column(:avaible, newAvaible.to_f)# se convierte numero entero a float de nuevo para que se pueda actualizar\n else\n newAvaible= self.avaible- quantity\n #self.update_column(:avaible, newAvaible) \n end\n\n end",
"def vdate_std_code_phone(std,phone)\n validates_numericality_of std , :only_integer => true ,\n :message => \"^STD Code only numerals no + sign\"\n validates_numericality_of phone , :only_integer => true , :message => \"^Field Phone can have only numerals\"\n\n validates_length_of std , :maximum => 5 , :message => \"^Field STD Code contains more than 5 digits\"\n validates_length_of phone , :maximum => 10 , :message => \"^Field Phone contains more than 10 digits\"\n=begin\nTODO - correct the following code to insert the logic of phone number validation\n if(phone.length == 10)# mobile phone number \n errors.add(std,'must be 91 if a cell phone number') if std != 91\n else\n# TODO - make sure first character in not ZERO. => same logic as in case to check the sign \n end\n=end\nend",
"def update\n @bounty = Bounty.find(params[:id])\n @chore = Chore.find(@bounty.chore_id)\n if @chore.nil?\n puts \"OH GOD WHY JESUS USE VALIDATORS COME ON NOW SERRIOUSLY GUYS\"\n end\n @chore.value=params[:value][:val].to_i\n @chore.save\n respond_to do |format|\n if @bounty.save\n format.html { redirect_to @bounty, :notice => 'bounty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bounty.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @invoice = Invoice.find(params[:id])\n @invoice.update_attributes(params[:invoice])\n @[email protected]_sum\n respond_to do |format|\n if @invoice.save\n format.html { redirect_to(@invoice, :notice => 'Facture modifiée avec succes.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @invoice.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @fee = Fee.find(params[:id])\n\n respond_to do |format|\n if @fee.update_attributes(params[:fee])\n format.html { redirect_to fees_path, notice: 'Fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @egreso = Egreso.find(params[:id])\n @total=dinero_actual\n \n if @egreso.update(egreso_params)\n if @egreso.monto>@total\n flash[:warning] = 'El monto de egreso no puede ser mayor al monto actual'\n render action: \"edit\"\n else\n flash[:success] = \"Egreso actualizado exitosamente\"\n redirect_to '/egresos'\n end\n end\n end",
"def valid_amount?\n Float(params[:amount]) rescue false\n end",
"def update\n respond_to do |format|\n if @fee.update(fee_params)\n format.html { redirect_to @fee, notice: 'Fee was successfully updated.' }\n format.json { render :show, status: :ok, location: @fee }\n else\n format.html { render :edit }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fee.update(fee_params)\n format.html { redirect_to @fee, notice: 'Fee was successfully updated.' }\n format.json { render :show, status: :ok, location: @fee }\n else\n format.html { render :edit }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def total_fee_is_valid?\n return ((self.total_fee != nil) and (self.total_fee >= 0))\n end",
"def validateFI(vat_number)\r\n total = 0\r\n multipliers = [7,9,10,5,8,4,2]\r\n 0.upto(6) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i]\r\n end\r\n # Establish the check digit\r\n total = 11 - total % 11\r\n total = 0 if total > 9\r\n return true if total == vat_number[7..8].to_i\r\n return false\r\n end",
"def test_should_deny_non_integer_institution_id\n registration = create(:institution_id => 'a')\n assert registration.errors.invalid?(:institution_id), \":institution_id should have had an error\"\n assert_invalid registration, \"registration shouldn't be created\"\n \n registration = create(:institution_id => 1.397)\n assert registration.errors.invalid?(:institution_id), \":institution_id should have had an error\"\n assert_invalid registration, \"registration shouldn't be created\"\n end",
"def test_numericality_of_max_jobs_per_user_payer_wise\n client = Client.new(:name => \"MVG\", :internal_tat => 11 , :tat => 22, \n :max_jobs_per_user_payer_wise => \"yu\", :partener_bank_group_code => 'HJ',\n :group_code => 'JO', :max_jobs_per_user_client_wise => 15, :max_eobs_per_job => 5)\n assert_equal(false, client.save, \"Max# Jobs Per User Payer Wise is not a number!\")\n end",
"def valid_attributes\n { \"amount\"=>1245.to_s, 'book_id'=>@od.to_param,\n \"narration\"=>'Premier virement', \"date\"=>Date.today.to_formatted_s('%d-%m-%Y'),\n :compta_lines_attributes=>{'0'=>{account_id:@ba.to_param}, '1'=>{account_id:@bb.to_param}}\n }\n end",
"def validate_discount_number\n disc = self.discount.to_f\n if disc < 0\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.greater_than_or_equal_to\", :count => 0))\n elsif disc > 100\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.less_than_or_equal_to\", :count => 100))\n end\n end",
"def switch_to_int\n params['meal']['meal_foods_attributes']['food_id'] = params['meal']['meal_foods_attributes']['food_id'].to_i\n params['meal']['meal_foods_attributes']['amount'] = params['meal']['meal_foods_attributes']['amount'].to_i\n end",
"def validate_integer(input)\n input.to_s.to_i = input\nend",
"def update\n @membership_fee = MembershipFee.find(params[:id])\n\n respond_to do |format|\n if @membership_fee.update_attributes(params[:membership_fee])\n format.html { redirect_to @membership_fee, notice: 'Membership fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @membership_fee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@klass_fee = KlassFee.find(params[:id])\n\n respond_to do |format|\n if @klass_fee.update_attributes(params[:klass_fee])\n format.html { redirect_to klass_klass_fees_path(@klass), notice: 'Klass fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @klass_fee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def valid_salary(salary)\n salary > 0 && salary.to_s.to_i == salary\nend",
"def set_numeric_field\n @numeric_field = NumericField.find(params[:id])\n end",
"def test_declination_coordinate_must_be_a_number\n \[email protected] = \"abc\"\n \tassert [email protected], \"Worked? Saved a non-number declination value.\"\n end",
"def update\n respond_to do |format|\n if @fee.update(fee_params)\n format.html { redirect_to book_fee_path(@book,@fee), notice: '费项更新成功.' }\n format.json { render :show, status: :ok, location: @fee }\n else\n format.html { render :edit }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def before_save\n \n self.proyecto=self.proyecto.upcase\n \n if self.accion_especifica.to_i < 10 \n if self.accion_especifica.to_s.length!=2\n self.accion_especifica=\"0\"+self.accion_especifica.to_s \n end\n end \n \n if self.partida.to_i < 10 \n if self.partida.to_s.length!=3\n self.partida=\"00\"+self.partida.to_s \n end\n elsif self.partida.to_i < 100\n if self.partida.to_s.length!=3\n self.partida=\"0\"+self.partida.to_s \n end\n end\n \n if self.generica.to_i < 10 \n if self.generica.to_s.length!=2\n self.generica=\"0\"+self.generica.to_s \n end\n end\n \n if self.especifica.to_i < 10 \n if self.especifica.to_s.length!=2\n self.especifica=\"0\"+self.especifica.to_s\n end \n end\n \n if self.sub_especifica.to_i < 10 \n if self.sub_especifica.to_s.length!=2\n self.sub_especifica=\"0\"+self.sub_especifica.to_s\n end\n end\n end",
"def active_scaffold_input_number(column, options)\n active_scaffold_number_input :number_field, column, options, :format\n end",
"def valid_age?(age)\n is_integer?(age) ? (age > 0 and age <= 100) : age_data_type_format_msg\nend",
"def validate?\n integer? && more_than_nine?\n end",
"def test_number_of_pictures_should_be_an_integer\n # make sure duration_text is null\n \[email protected]_text = nil\n \t\n \t# try to enter a non-integer\n \[email protected]_of_pictures = \"f\"\n assert [email protected], \"Worked? Saved a string.\" \n \[email protected]_of_pictures = 2.01\n assert [email protected], \"Worked? Saved a float.\" \n \n # should be able to save when an integer is entered\n \[email protected]_of_pictures = 2\n \tassert @schedule.save\n end",
"def mfee(fee, size)\n return fee.to_i if fee.is_a?(Integer)\n raise Error, 'Fee should either be a String or Integer' unless fee.is_a?(String)\n mul = 1\n if fee.start_with?('+', '-')\n mul = -1 if fee.start_with?('-')\n fee = fee[1..-1]\n end\n sat = fees[fee.to_sym]\n raise Error, \"Can't understand the fee: #{fee.inspect}\" if sat.nil?\n mul * sat * size\n end",
"def added_time_cannot_be_of_invalid_format\r\n errors.add(:task, \"added time has to be an integer!\") unless\r\n added_time.instance_of?(Fixnum)\r\n end",
"def update\n\n price_schedule_params[:basis] = price_schedule_params[:basis].to_i\n price_schedule_params[:break_type] = price_schedule_params[:break_type].to_i\n price_schedule_params[:qualifier] = price_schedule_params[:qualifier].to_i\n price_schedule_params[:fee_calculation_type] = price_schedule_params[:fee_calculation_type].to_i\n price_schedule_params[:usual_customary_calculation] = price_schedule_params[:usual_customary_calculation].to_i\n price_schedule_params[:customer_assigned_schedule] = price_schedule_params[:customer_assigned_schedule].to_i\n price_schedule_params[:percentage_fee_type] = price_schedule_params[:percentage_fee_type].to_i\n price_schedule_params[:amount_fee_type] = price_schedule_params[:amount_fee_type].to_i\n\n respond_to do |format|\n if @price_schedule.update(price_schedule_params)\n format.html { redirect_to @price_schedule, notice: 'Price Schedule was successfully updated.' }\n format.json { render :show, status: :ok, location: @price_schedule }\n else\n format.html { render :edit }\n format.json { render json: @price_schedule.errors, status: :unprocessable_entity }\n end\n end\n end",
"def phone_number_value\n # byebug\n\n if self.phone_number.present?\n numbers_array = self.phone_number.split(\",\")\n numbers_array.each do |nn|\n nn = nn.gsub(\"-\",\"\").gsub(\"+91\",\"\").gsub(\" \",\"\") \n # byebug\n if nn.to_i.to_s.length != 10\n # byebug\n self.errors[:phone_number]<< \"must be 10 digit number\"\n end \n end\n end\n end",
"def fee_per_meeting_is_valid?\n return ((self.fee_per_meeting != nil) and (self.fee_per_meeting >= 0))\n end",
"def edit\n @fee_account = FeeAccount.find(params[:id])\n render_form\n end"
] | [
"0.66417956",
"0.653504",
"0.61343735",
"0.6095732",
"0.58294827",
"0.58216184",
"0.5797963",
"0.5797407",
"0.570779",
"0.57003444",
"0.5690185",
"0.56842583",
"0.5656483",
"0.5639606",
"0.5638781",
"0.5627222",
"0.56193477",
"0.5585738",
"0.558181",
"0.55663365",
"0.55463916",
"0.5522192",
"0.55190045",
"0.5513914",
"0.55067855",
"0.5501569",
"0.5501569",
"0.5498297",
"0.5498297",
"0.5498297",
"0.54969805",
"0.5493979",
"0.5486706",
"0.5449974",
"0.54467314",
"0.5446575",
"0.54452264",
"0.5439775",
"0.54387146",
"0.5432196",
"0.54177654",
"0.5416464",
"0.5410678",
"0.5402724",
"0.5397728",
"0.5391027",
"0.5377474",
"0.53688586",
"0.53617734",
"0.5359137",
"0.5348329",
"0.5322693",
"0.5317617",
"0.531664",
"0.5310948",
"0.5306978",
"0.5303376",
"0.5300503",
"0.5298972",
"0.5297538",
"0.5295268",
"0.5294363",
"0.5285692",
"0.5284392",
"0.5280119",
"0.5278792",
"0.52738786",
"0.52680445",
"0.52517223",
"0.5249896",
"0.5246857",
"0.5240604",
"0.52401394",
"0.52359515",
"0.52359515",
"0.52334505",
"0.52237594",
"0.52122015",
"0.5203204",
"0.51997614",
"0.5198431",
"0.5190681",
"0.5172983",
"0.51714206",
"0.51593554",
"0.5157935",
"0.51547474",
"0.5147576",
"0.5146918",
"0.5138974",
"0.51362616",
"0.51220226",
"0.5116728",
"0.5116674",
"0.5113838",
"0.5112228",
"0.51092017",
"0.51090354",
"0.5108153",
"0.50977695"
] | 0.7614905 | 0 |
add fee fields are all filled or all empty | def add_fee_filled_or_empty
if !params[:add_fee].nil?
add_fee_keys = params[:add_fee].keys
add_fee_vals = params[:add_fee].values
add_fee_vals.each_slice(3) do |student_type, amount, time_period|
if !((!student_type.empty? && !amount.empty? && !time_period.empty?) ||
(student_type.empty? && amount.empty? && time_period.empty?))
return false
end
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_fee_fields_filled\n if !params[:edit_fees].nil?\n edit_fees_vals = params[:edit_fees].values\n edit_fees_vals.each_slice(3) do |fee, time, remove|\n if fee.empty? || time.empty?\n return false\n end\n end\n end\n return true\n end",
"def total_fee_is_valid\n errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid?\n end",
"def validatable_basic_fee_types\n @fee_types.select do |fee_type|\n fee_type.calculated == true && !fee_type.defendant_uplift?\n end\n end",
"def fee_for_additional_materials_is_valid\n errors.add(:fee_for_additional_materials, 'The fee for additional materials is invalid.') unless fee_for_additional_materials_is_valid?\n end",
"def total_fee\n fee + fee2 + fee3 + fee4\n end",
"def free?\n self.setupFee == 0 && self.laborFee == 0 && self.oneTimeFee == 0 && self.recurringFee == 0 && self.hourlyRecurringFee == 0\n end",
"def fee\n @fee || DEFAULT_FEE\n end",
"def fixed_fees\n fixed_fee.nil? ? [] : [fixed_fee]\n end",
"def fee_for_additional_materials_is_valid?\n return ((self.fee_for_additional_materials != nil) and (self.fee_for_additional_materials >= 0))\n end",
"def fee_per_meeting_is_valid\n errors.add(:fee_per_meeting, 'The fee per meeting is invalid.') unless fee_per_meeting_is_valid?\n end",
"def free?\n\t\t\t\tnot(fee?)\n\t\t\tend",
"def presence_of_mandatory_fields\n if promo_amount.blank? and info.blank?\n errors[:base] << 'Au moins un des champs doivent être remplis'\n end\n end",
"def add_check_fields\n @check_fields = []\n if @signature.require_full_address?\n new_fields = %w[\n person_street\n person_city\n person_street_number\n person_postalcode]\n @check_fields.push(*new_fields)\n end\n @check_fields.push('person_country') if @signature.require_person_country?\n @check_fields.push('person_born_at\\(3i\\)') if @signature.require_born_at?\n @check_fields.push('person_born_at\\(2i\\)') if @signature.require_born_at?\n @check_fields.push('person_born_at\\(1i\\)') if @signature.require_born_at?\n end",
"def total_fee_is_valid?\n return ((self.total_fee != nil) and (self.total_fee >= 0))\n end",
"def fee\n params['amount_fee']\n end",
"def add_fee_is_integer\n if !params[:add_fee].nil?\n add_fee_vals = params[:add_fee].values\n add_fee_vals.each_slice(3) do |student_type, amount, time_period|\n if !amount.empty? && !(amount.to_i.to_s.eql? amount)\n return false\n end\n end\n end\n return true\n end",
"def enter_fees(test_data)\n fees = test_data[UseOfCollections::FEE_GRP.name] || [UseOfCollections.empty_fee]\n prep_fieldsets_for_test_data([fieldset(UseOfCollections::FEE_GRP.name)], fees)\n fees.each_with_index do |fee, index|\n wait_for_options_and_select(fee_currency_input(index), fee_currency_options(index), fee[UseOfCollections::FEE_CURRENCY.name])\n wait_for_element_and_type(fee_value_input(index), fee[UseOfCollections::FEE_VALUE.name])\n wait_for_element_and_type(fee_note_input(index), fee[UseOfCollections::FEE_NOTE.name])\n wait_for_element_and_click(fee_paid_input(index)) if fee[UseOfCollections::FEE_PAID.name]\n end\n end",
"def total\n (amount + fee) if amount\n end",
"def submit_all_blank_and_validate\n blank_dates\n click_on 'Add'\n validate_fields(@fields)\n end",
"def fee_params\n params.require(:fee).permit(:description, :amount)\n end",
"def fee_params\n params.require(:fee).permit(:user_id, :name, :price, :serial, :end_at, :deleted_at)\n end",
"def total_fees\n staffing.present? ? staffing.compensation : nil\n end",
"def verify_fees(test_data)\n fees = test_data[UseOfCollections::FEE_GRP.name] || [UseOfCollections.empty_fee]\n fees.each_with_index do |fee, index|\n verify_values_match(fee[UseOfCollections::FEE_CURRENCY.name], element_value(fee_currency_input index))\n verify_values_match(fee[UseOfCollections::FEE_VALUE.name], element_value(fee_value_input index))\n verify_values_match(fee[UseOfCollections::FEE_NOTE.name], element_value(fee_note_input index))\n end\n end",
"def verify_fees(test_data)\n fees = test_data[CoreUseOfCollectionsData::FEE_GRP.name] || [CoreUseOfCollectionsData.empty_fee]\n fees.each_with_index do |fee, index|\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_CURRENCY.name], element_value(fee_currency_input index))\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_VALUE.name], element_value(fee_value_input index))\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_NOTE.name], element_value(fee_note_input index))\n end\n end",
"def fbo_update_form\n @fbo= Fbo.new\n @fee_types = [1,3,4,2,5]\n @id= 0\n @count= 0\n end",
"def fee\n\tparams['mc_fee']\n end",
"def fee_params\n params.require(:fee).permit(:fee_name)\n end",
"def set_derived_fields\n set_fac_code_terms if ok_to_sum?\n\n true\n end",
"def fees\n @fees ||= {\n \"insurance_fee\" => (commission * ASSURANCE_SHARE).round(0),\n \"assistance_fee\" => (ASSISTANCE_COST * rental.duration).round(0)\n }.tap { |fees| fees[\"drivy_fee\"] = commission - fees.values.inject(:+) }\n end",
"def fee_per_meeting_is_valid?\n return ((self.fee_per_meeting != nil) and (self.fee_per_meeting >= 0))\n end",
"def fee_collection_new\n @fines = Fine.active\n fy_id = current_financial_year_id\n @fee_categories = FinanceFeeCategory.all(:select => \"DISTINCT finance_fee_categories.*\",\n :joins => [{:category_batches => :batch}, :fee_particulars],\n :conditions => [\"batches.is_active = 1 AND batches.is_deleted = 0 AND finance_fee_categories.is_deleted=0 AND\n finance_fee_particulars.is_deleted = 0 AND financial_year_id #{fy_id.present? ? '=' : 'IS'} ?\", fy_id])\n\n @finance_fee_collection = FinanceFeeCollection.new({:discount_mode => @school_discount_mode,\n :financial_year_id => fy_id})\n @start_date, @end_date = FinancialYear.fetch_current_range\n\n deliver_plugin_block :fedena_reminder do\n @finance_fee_collection.build_alert_settings\n end\n end",
"def fee_params\n params.require(:fee).permit(:student_id, :amount, :user_id, :month)\n end",
"def build_detail_fee_based\n details = self.invoice_details.new(:created_user => self.created_user, :record_type => InvoiceDetail::FEE, :provider_name => 'a',\n :patient_name => 'a', :dos => Date.today, :disposition => InvoiceDetail::INCLUDE)\n end",
"def enter_fees(test_data)\n fees = test_data[CoreUseOfCollectionsData::FEE_GRP.name] || [CoreUseOfCollectionsData.empty_fee]\n hide_notifications_bar\n prep_fieldsets_for_test_data([fieldset(CoreUseOfCollectionsData::FEE_GRP.name)], fees)\n fees.each_with_index do |fee, index|\n logger.info \"Entering fee data set at index #{index}: #{fee}\"\n wait_for_options_and_select(fee_currency_input(index), fee_currency_options(index), fee[CoreUseOfCollectionsData::FEE_CURRENCY.name])\n wait_for_element_and_type(fee_value_input(index), fee[CoreUseOfCollectionsData::FEE_VALUE.name])\n wait_for_element_and_type(fee_note_input(index), fee[CoreUseOfCollectionsData::FEE_NOTE.name])\n wait_for_element_and_click(fee_paid_input(index)) if fee[CoreUseOfCollectionsData::FEE_PAID.name]\n end\n end",
"def fees_state?\n self.form_state == :fees\n end",
"def fee\n (amount * 0.005) if amount\n end",
"def fees_particulars_new\n @finance_fee_particular = FinanceFeeParticular.new(params[:finance_fee_particular])\n @master_fee_particulars = MasterFeeParticular.core\n @tax_slabs = TaxSlab.all if @tax_enabled\n fy_id = current_financial_year_id\n @fees_categories = FinanceFeeCategory.all(:select => \"DISTINCT finance_fee_categories.*\",\n :joins => \"INNER JOIN category_batches ON category_batches.finance_fee_category_id = finance_fee_categories.id\n INNER JOIN batches ON batches.id = category_batches.batch_id AND batches.is_active = true AND batches.is_deleted = false\",\n :conditions => [\"finance_fee_categories.is_deleted = 0 AND finance_fee_categories.is_master = 1 AND\n financial_year_id #{fy_id.present? ? '=' : 'IS'} ?\", fy_id], :order => \"name ASC\")\n\n @student_categories = StudentCategory.active\n @all = true\n @student = false\n @category = false\n end",
"def document_fee\n 0\n end",
"def call\n add_fields(possible_fraud: true)\n end",
"def add_fees\n @proposal.fees.each do |bank_account, amounts_by_category|\n amounts_by_category.each do |category, amount|\n category_for_key = category&.downcase&.gsub(' ', '_') || 'none'\n run_task \"add_fees_#{bank_account}_#{category_for_key}\" do\n if transaction = add_fee_transaction(bank_account, amount, category)\n current_state[:transaction_id] = transaction['BankTransactionID']\n end\n end\n end\n end\n end",
"def empty?\n a = @data_object\n\n (a.add_line1.nil? || a.add_line1.empty?) &&\n (a.add_line2.nil? || a.add_line2.empty?) &&\n (a.add_city.nil? || a.add_city.empty?) &&\n (a.add_county.nil? || a.add_county.empty?) &&\n (a.add_state.nil? || a.add_state.empty?) &&\n (a.add_zip.nil? || a.add_zip.empty?) &&\n (a.add_country.nil? || a.add_country.empty?)\n end",
"def apply_fees\n remove_fees\n unless waive_fees\n #CHALKLE\n self.chalkle_gst_number = Finance::CHALKLE_GST_NUMBER\n self.chalkle_fee = course.chalkle_fee_no_tax\n self.chalkle_gst = course.chalkle_fee_with_tax - chalkle_fee\n \n self.processing_fee = course.processing_fee\n self.processing_gst = course.processing_fee*3/23\n self.processing_fee = course.processing_fee-self.processing_gst\n\n #TEACHER FEE\n if provider_pays_teacher?\n self.teacher_fee = 0\n self.teacher_gst = 0\n else\n if fee_per_attendee?\n self.teacher_fee = course.teacher_cost\n elsif flat_fee?\n confirmed_booking_count = course.bookings.fees_not_waived.paid.confirmed.count\n if confirmed_booking_count > 0\n self.teacher_fee = course.teacher_cost / confirmed_booking_count\n else\n self.teacher_fee = course.teacher_cost\n end\n end\n end\n\n #TEACHER TAX\n if course.teacher.present? && course.teacher.tax_registered?\n self.teacher_gst_number = course.teacher.tax_number\n self.teacher_gst = teacher_fee*3/23\n self.teacher_fee = teacher_fee-teacher_gst\n else\n self.teacher_gst = 0\n self.teacher_gst_number = nil\n end\n\n #PROVIDER\n self.provider_fee = course.provider_fee\n if provider.tax_registered?\n self.provider_gst_number = provider.tax_number\n self.provider_gst = course.provider_fee*3/23\n self.provider_fee = self.provider_fee-self.provider_gst\n else\n self.provider_gst_number = nil\n self.provider_gst = 0\n end\n\n #adjust in case calc_cost is not course cost, should only happen if flat_fee\n difference = course.cost - calc_cost\n if difference != 0\n self.provider_fee = course.provider_fee + difference\n if provider.tax_registered?\n self.provider_gst_number = provider.tax_number\n self.provider_gst = course.provider_fee*3/23\n self.provider_fee = self.provider_fee-self.provider_gst\n else\n self.provider_gst_number = nil\n self.provider_gst = 0\n end\n end\n\n #adjust in case payment has been made already\n difference = cost - calc_cost\n if difference != 0\n #adjust processing_fee\n self.processing_fee = cost * course.provider_plan.processing_fee_percent\n self.processing_gst = self.processing_fee*3/23\n self.processing_fee = self.processing_fee-self.processing_gst\n\n #reset difference to adjust for processing_fee changes\n difference = cost - calc_cost\n\n #if payment exists then adjust provider fee to ensure the payment amount matches calc_cost\n adjustment_for_provider = difference\n adjustment_for_teacher = 0\n\n if provider_fee+provider_gst+difference < 0\n #if adjusted provider_fee is negative then deduct that negative amount from teacher_fee and make provider_fee 0\n adjustment_for_teacher = provider_fee+provider_gst+difference \n self.provider_fee = 0\n self.provider_gst = 0\n else\n self.provider_fee = provider_fee+provider_gst+adjustment_for_provider\n if provider.tax_registered?\n self.provider_gst = provider_fee*3/23\n self.provider_fee = provider_fee - provider_gst\n end\n end\n \n if adjustment_for_teacher != 0\n self.teacher_fee = teacher_fee+teacher_gst+adjustment_for_teacher\n if course.teacher.present? && course.teacher.tax_registered?\n self.teacher_gst = teacher_fee*3/23\n self.teacher_fee = teacher_fee-teacher_gst\n end\n end\n end\n end\n cost\n end",
"def add_klarna_fee!\n if add_klarna?\n\n # FIXME require validation that order restrict partitial payments\n paymeth = payments.first.payment_method\n\n fee = paymeth.preferred(:invoice_fee)\n adj = adjustments.create(amount: fee,\n source: self,\n label: Spree.t(:invoice_fee))\n # FIXME define correct originator\n # paymenthod is not correct spree/core/app/models/spree/adjustment.rb\n # adj.originator = paymeth\n # adj.save!\n adj.lock!\n update!\n end\n end",
"def bar_accepts_fee(fee)\n @bar_cash += fee\n end",
"def total_fte\n staffing.present? ? staffing.total_fte : nil\n end",
"def calculate_fee\n Application::courses_fee(course_selections_count > 1 ? :multiple : :single)\n end",
"def fee_filter\n [\n ['Equal','equal'],\n ['Greater than','greater_than'],\n ['Less than','less_than']\n ]\n\n end",
"def fee\n params['mc_fee']\n end",
"def fee\n params['mc_fee']\n end",
"def edit_fee_is_integer\n if !params[:edit_fees].nil?\n edit_fees_vals = params[:edit_fees].values\n edit_fees_vals.each_slice(3) do |fee, time, remove|\n if !(fee.to_i.to_s.eql? fee)\n return false\n end\n end\n end\n return true\n end",
"def miscellaneous_fees\n object.fees.each_with_object([]) do |fee, memo|\n misc_fee_adapter.call(fee).tap do |f|\n memo << f if f.claimed?\n end\n end\n end",
"def has_required_fields\n return unless format.is_a?(LocalPostal::Format)\n\n format.required_fields.each do |field|\n field_name = self.class.formatting_variables_lookup_table[field.to_sym]\n value = public_send(field_name)\n errors.add(field_name, 'is required') if \"#{value}\".empty?\n end\n end",
"def fulfillment_fee\n begin\n if variant.product_costs.where(:retailer_id => self.order.retailer_id).first.fulfillment_fee > 0\n variant.product_costs.where(:retailer_id => self.order.retailer_id).first.fulfillment_fee * quantity\n else\n self.order.retailer.fulfillment_fee * quantity\n end\n rescue\n begin\n self.order.retailer.fulfillment_fee * quantity\n rescue\n 0.0\n end\n end\n end",
"def required_fields\n if self.controller_name == \"registrations\"\n param_name = \"user\"\n elsif self.controller_name == \"merchants\"\n param_name = \"merchant\"\n else\n return\n end\n empty_fields = Array.new\n empty = false\n params[param_name].each_pair do |k, v|\n if v == \"\"\n empty_fields << k.gsub(\"_\", \" \")\n empty = true\n end\n end\n if empty == true\n (0..empty_fields.length - 3).each do |i|\n empty_fields[i] << \",\"\n end\n empty_fields.insert(-2, \"and\") unless empty_fields.length < 2\n field_list = empty_fields.join(\" \")\n message = \"You cannot leave empty fields. The field\" \n if empty_fields.length > 1\n message << \"s \"\n else\n message << \" \"\n end\n message << field_list \n if empty_fields.length > 1\n message << \" were left blank.\"\n else\n message << \" was left blank.\"\n end\n flash[:notice] = message\n redirect_to request.referrer\n else\n return\n end\n end",
"def any_present?\n if name.blank? and phone.blank? and license_plate.blank?\n errors.add :base, \"You must fill in at least one field\"\n end\n end",
"def no_all_zero_quantity\n if ok_quantity.present? and broken_quantity.present? and repairable_quantity.present? and\n ok_quantity == 0 and broken_quantity == 0 and repairable_quantity == 0 \n errors.add(:ok_quantity , \"OK, gagal, dan perbaiki tidak boleh bernilai 0 bersamaan\" ) \n errors.add(:broken_quantity , \"OK, gagal, dan perbaiki tidak boleh bernilai 0 bersamaan\" ) \n errors.add(:repairable_quantity , \"OK, gagal, dan perbaiki tidak boleh bernilai 0 bersamaan\" ) \n end\n end",
"def fees\n raise Sibit::NotSupportedError, 'Blockchair doesn\\'t implement fees()'\n end",
"def approve_setup_fee_collection( current_user )\n self.is_setup_fee_collection_approved = true \n self.setup_fee_collection_approver_id = current_user.id \n self.save\n \n # create all those payment payable : loan disbursement \n end",
"def fees_particulars_create2\n batch=Batch.find(params[:finance_fee_particular][:batch_id])\n @tax_slabs = TaxSlab.all if @tax_enabled\n if params[:particular] and params[:particular][:receiver_id]\n\n all_admission_no = admission_no=params[:particular][:receiver_id].split(',')\n all_students = batch.students.map { |stu| stu.admission_no }.flatten\n rejected_admission_no = admission_no.select { |adm| !all_students.include? adm }\n unless (rejected_admission_no.empty?)\n @error = true\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{rejected_admission_no.join(',')} #{t('does_not_belong_to_batch')} #{batch.full_name}\")\n end\n\n selected_admission_no = all_admission_no.select { |adm| all_students.include? adm }\n selected_admission_no.each do |a|\n s = Student.first(:conditions => [\"admission_no LIKE BINARY(?)\", a])\n if s.nil?\n @error = true\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{a} #{t('does_not_exist')}\")\n end\n end\n unless @error\n unless selected_admission_no.present?\n @finance_fee_particular=batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{t('admission_no_cant_be_blank')}\")\n @error = true\n else\n selected_admission_no.each do |a|\n s = Student.first(:conditions => [\"admission_no LIKE BINARY(?)\", a])\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.receiver_id=s.id\n @error = true unless @finance_fee_particular.save\n end\n end\n end\n elsif params[:finance_fee_particular][:receiver_type]==\"Batch\"\n\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.receiver_id=batch.id\n @error = true unless @finance_fee_particular.save\n else\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @error = true unless @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{t('category_cant_be_blank')}\") if params[:finance_fee_particular][:receiver_id]==\"\"\n end\n @batch=batch\n @finance_fee_category = FinanceFeeCategory.find(params[:finance_fee_particular][:finance_fee_category_id])\n include_associations = @tax_enabled ? [:tax_slabs] : []\n @particulars = FinanceFeeParticular.paginate(:page => params[:page],\n :include => include_associations, :conditions => [\"is_deleted = '#{false}' and\n finance_fee_category_id = '#{@finance_fee_category.id}' and batch_id='#{@batch.id}' \"])\n\n end",
"def add_fee(args)\n result = Spreedly.post(\"/subscribers/#{id}/fees.xml\", :body => Spreedly.to_xml_params(:fee => args))\n\n case result.code.to_s\n when /2../\n when '404'\n raise \"Not Found\"\n when '422'\n raise \"Unprocessable Entity - #{result.body}\"\n else\n raise \"Could not add fee to subscriber: result code #{result.code}.\"\n end\n end",
"def edit_delivery\n if !test_present_attributes([:fact_firstname, :fact_lastname, :fact_address, :fact_zipcode, :fact_city])\n redirect_to payments_fact_path\n end\n end",
"def shipping_fee\n @admin_options = Admin::Option.where(\"id = ?\" , 44) \n end",
"def debit_factype_null_perdu\n test = init_test('Debit (Facture) avec factype NULL mais sans labour ni pulve associes', LOW)\n Debit.find(:all).each do |facture| \n if facture.factype_id.equal?(Factype.find_by_name('null').id) && facture.pulves.empty? && facture.labours.empty?\n test.num += 1\n error = init_error(facture.name, facture.id, 'factures', '')\n test.errors << error\n end\n end\n test.result = (test.num == 0) \n return test\n end",
"def check_paid\n self.paid_amount = 0\n self.paid = false\n payments.each do |payment|\n self.paid_amount += payment.amount\n end\n \n if self.paid_amount - self.gross_amount >= 0\n self.paid = true\n end\n end",
"def get_convenience_fee\n @invoice.amount ? CalcTotal::get_convenience_fee(sales_price).round(2) : 0.0\n end",
"def processor_input_field_count(facility, eob_type)\n total_field_count_with_data = 0\n configured_fields = []\n constant_fields = [check_amount, check_number, payment_method]\n fc_ui_date_fields = [check_mailed_date, check_received_date]\n \n if eob_type == 'nextgen'\n # Adding all the two check amount fields in the NextGen grid.\n selected_fields = [check_amount]\n else\n selected_fields = [check_date]\n end\n\n configured_fields << payment_type if facility.details[:payment_type]\n configured_fields << alternate_payer_name if facility.details[:re_pricer_info]\n total_field_array = constant_fields + configured_fields + selected_fields +\n fc_ui_date_fields\n total_field_array_with_data = total_field_array.select{|field| !field.blank?}\n total_field_count_with_data = total_field_array_with_data.length\n total_field_count_with_data\n end",
"def validate_not_all_mandatory\n errors.add(:service_codes, :invalid_cafm_helpdesk_billable) if (service_codes - self.class::MANDATORY_SERVICES).empty?\n end",
"def membership_fee\n if business_admin?\n {\"amount\" => 29900, \"id\" => \"business-29900\"}\n elsif church_admin?\n {\"amount\" => 9900, \"id\" => \"church-9900\"}\n elsif alliance_admin?\n {\"amount\" => 9900, \"id\" => \"alliance-9900\"}\n else\n {\"amount\" => 4900, \"id\" => \"individual-4900\"}\n end\n end",
"def validate\n errors.add(:post_office, \"- must be filled for postalcode #{self.postal_code}\") if self.post_office.blank? && !self.postal_code.blank?\n errors.add(:postal_code, \"- must be filled for #{self.post_office}\") if self.postal_code.blank? && !self.post_office.blank? \n errors.add_to_base(\"- Person must have at least one phonenumber\") if (self.phone_home.blank? && self.phone_cell.blank? && self.phone_work.blank?) \n end",
"def cache_additional_tx_fields(tx, fee, value_in, value_out)\n tx.additional_fields = {\n :fee => fee,\n :total_in_value => value_in,\n :total_out_value => value_out\n }\n end",
"def add_money\n @total += fee\n end",
"def user_details_complete(user)\n\n user_details_fields_presence = []\n\n user_details_fields_presence.push(user.name.present?)\n user_details_fields_presence.push(user.date_of_birth.present?)\n user_details_fields_presence.push(\n (\n user.line1.present? &&\n user.townCity.present? &&\n user.county.present? &&\n user.postcode.present?\n )\n )\n\n user_details_fields_presence.all?\n\n end",
"def create\n @fee = Fee.new(fee_params)\n student = Student.find(params[:fee][:student_id])\n temp = student.due_date.to_date\n if student.term == 'Monthly'\n student.due_date = (temp + 1.month).to_s\n elsif student.term == \"Quarterly\"\n student.due_date = (temp + 3.month).to_s\n elsif student.term = \"Bi-annualy\"\n student.due_date = (temp + 6.month).to_s\n end\n student.save\n @fee.save\n redirect_to fee_path(@fee.id), notice: \"Fee Submitted Successfully\"\n end",
"def empty?\n @fields.empty?\n end",
"def update_total\n self.total = self.note_1 + self.note_2 + self.note_3 + self.note_4 if self.note_1 && self.note_2 && self.note_3 && self.note_4\n end",
"def update_total\n self.total = self.note_1 + self.note_2 + self.note_3 + self.note_4 if self.note_1 && self.note_2 && self.note_3 && self.note_4\n end",
"def update_any_data?\n add_name? || add_events? || set_wheel_sizes? || add_volunteers? || add_contact_details? || lodging? || expenses? || set_organization_membership?\n end",
"def donation\n @donation = FinanceDonation.new(params[:donation])\n @donation_additional_details = DonationAdditionalDetail.find_all_by_finance_donation_id(@donation.id)\n @additional_fields = DonationAdditionalField.find(:all, :conditions => \"status = true\", :order => \"priority ASC\")\n if request.post? && @donation.valid?\n @error=false\n mandatory_fields = DonationAdditionalField.find(:all, :conditions => {:is_mandatory => true, :status => true})\n mandatory_fields.each do |m|\n unless params[:donation_additional_details][m.id.to_s.to_sym].present?\n @donation.errors.add_to_base(\"#{m.name} must contain atleast one selected option.\")\n @error=true\n else\n if params[:donation_additional_details][m.id.to_s.to_sym][:additional_info]==\"\"\n @donation.errors.add_to_base(\"#{m.name} cannot be blank.\")\n @error=true\n end\n end\n end\n unless @error==true\n @donation.save\n additional_field_ids_posted = []\n additional_field_ids = @additional_fields.map(&:id)\n if params[:donation_additional_details].present?\n params[:donation_additional_details].each_pair do |k, v|\n addl_info = v['additional_info']\n additional_field_ids_posted << k.to_i\n addl_field = DonationAdditionalField.find_by_id(k)\n if addl_field.input_type == \"has_many\"\n addl_info = addl_info.join(\", \")\n end\n prev_record = DonationAdditionalDetail.find_by_finance_donation_id_and_additional_field_id(params[:id], k)\n unless prev_record.nil?\n unless addl_info.present?\n prev_record.destroy\n else\n prev_record.update_attributes(:additional_info => addl_info)\n end\n else\n addl_detail = DonationAdditionalDetail.new(:finance_donation_id => @donation.id,\n :additional_field_id => k, :additional_info => addl_info)\n addl_detail.save if addl_detail.valid?\n end\n end\n end\n if additional_field_ids.present?\n DonationAdditionalDetail.find_all_by_finance_donation_id_and_additional_field_id(params[:id], (additional_field_ids - additional_field_ids_posted)).each do |additional_info|\n additional_info.destroy unless additional_info.donation_additional_field.is_mandatory == true\n end\n end\n flash[:notice] = \"#{t('flash1')}\"\n redirect_to :action => 'donation_receipt', :id => @donation.id\n end\n end\n end",
"def fees\n raise Sibit::NotSupportedError, 'Btc.com doesn\\'t provide recommended fees'\n end",
"def create\n #@klass_fee = KlassFee.new(params[:klass_fee])\n ap params[:fee]\n begin\n params[:fee].each do |fee_type_id, amount|\n puts \"=======xx==========\"\n ap KlassFee.create({klass_id: @klass.id, fee_type_id: fee_type_id, amount: amount[:amount]})\n end\n \n redirect_to klass_klass_fees_path(@klass), notice: 'Klass fee was successfully created.'\n #rescue Exception => e\n # render action: \"new\" \n end\n end",
"def anything_blank?\n max_payment.blank? || min_payment.blank? || deposit.blank? || term.blank?\n end",
"def fill_all_form_data()\n if verbose_messages\n p @fillable_form_fields\n p @current_page_data_object\n end\n\n @fillable_form_fields.each do |field|\n value = @current_page_data_object.retrieve_data_for(field)\n enter_element_value(field, value) if value and (value != \"nil\")\n end\n end",
"def flexible_budget_checker(budget, total)\n\nend",
"def fee\n @ipn['mc_fee']\n end",
"def calculate(t, fraud, type)\r\n#\t\tpp \"1\"\r\n\t\treturn 0.0 if type == 'billable' && self.bid_fee #if this fee is a bid fee and we are not looking at the bid fees then return 0, else continue on\r\n\t#\tpp \"2\"\r\n \t\r\n \tfee = self.fixed if self.price_type == 'F'\r\n \r\n fee = (self.fixed + (t.amount * self.percent) + (fraud == '1' ? self.fraud : 0)).at_least(self.min).at_most(self.max) if self.price_type == 'V' #calculate the fee\r\n \r\n return fee if self.sign == '>=' && self.threshold == 0 #if there is no threshold to worry about get out quick...this is what happens the majority of the time\r\n\t\r\n\t\t#if we get here we know we are dealing with a variable fee\r\n\t\t#puts (self.fixed + (t.amount * self.percent) + (fraud == '1' ? self.fraud : 0)).at_least(self.min)\r\n\t#\tfee = (self.fixed + (t.amount * self.percent) + (fraud == '1' ? self.fraud : 0)).at_least(self.min).at_most(self.max) #calculate the fee\r\n\t#\tpp fee\r\n\t#\tpp \"3\"\r\n\t#\treturn fee if self.sign == '>=' && self.threshold == 0 #if there is no threshold to worry about get out quick...this is what happens the majority of the time\r\n\t\t\r\n\t\t#otherwise we need to determine the sign and threshold before we can return\r\n\t\tcase self.sign\r\n\t\t\twhen '>'\r\n\t\t\t #pp \">\"\r\n\t\t\t\treturn fee if t.amount > self.threshold\r\n\t\t\twhen '>='\r\n\t\t\t #pp \">=\"\r\n\t\t\t\treturn fee if t.amount >= self.threshold\r\n\t\t\twhen '<'\r\n\t\t\t #pp \"<\"\r\n\t\t\t\treturn fee if t.amount < self.threshold\r\n\t\t\twhen '<='\r\n\t\t\t #pp \"<=\"\r\n\t\t\t\treturn fee if t.amount <= self.threshold\r\n\t\t\telse\r\n\t\t\t #pp \"4\"\r\n\t\t\t\treturn 0.0\r\n\t\tend\r\n\t\t\r\n\t\t#if we get here then we have no idea what to do so just return 0\r\n\t\treturn 0.0\r\n\tend",
"def no_all_zero_quantity\n if ok_quantity.present? and broken_quantity.present? and bad_source_quantity.present? and \n ok_quantity == 0 and broken_quantity == 0 and bad_source_quantity == 0 \n errors.add(:ok_quantity , \"OK, gagal, dan perbaiki tidak boleh bernilai 0 bersamaan\" ) \n errors.add(:broken_quantity , \"OK, gagal, dan perbaiki tidak boleh bernilai 0 bersamaan\" ) \n errors.add(:bad_source_quantity , \"OK, gagal, dan perbaiki tidak boleh bernilai 0 bersamaan\" ) \n end\n end",
"def state_fulfillment_fee\n adjustments.eligible.where(:label => 'Additional State Fulfillment Fee').first.amount rescue 0.0\n end",
"def fee_type_params\n params.require(:fee_type).permit(:title, :amount)\n end",
"def billing_fluctuates?\n return false if self.expired\n return false if self.end_date < Date.today\n start_dates = line_items.reject { |l| l.list_price.nil? || l.list_price == 0 }.map { |line| line.begins }\n end_dates = line_items.reject { |l| l.list_price.nil? || l.list_price == 0 }.map { |line| line.ends }\n return false if start_dates.uniq.length == 1 && end_dates.uniq.length == 1\n return false if payment_schedule.uniq.length == 1\n true\n end",
"def must_fill_all_fields(surfboard)\n \t\tif surfboard.surfboard_owner != current_user || !form_is_filled?\n \t\t\tflash[:errors] = \"All fields must be filled.\"\n \t\t\tredirect \"/surfboards/#{@surfboard.id}/edit\"\n \t\tend\n \tend",
"def free?\n price.blank? || price.zero?\n end",
"def appraisal_fee_params\n params.require(:appraisal_fee).permit(:duration_from, :duration_to, :percentual, :fixed_min, :fixed_max, :loan_id)\n end",
"def empty?()\n fields.empty?\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n if @total_servicos.nil?\n return false\n end\n\n \n \n \n \n \n if @total_parcelado_nacionais.nil?\n return false\n end\n\n \n \n \n \n \n if @total_parcelado_internacionais.nil?\n return false\n end\n\n \n \n \n \n end",
"def total_non_insured_fees\n total_fee - total_insured_fees\n end",
"def no_booking\n self.flights.empty?\n end",
"def validate_funding\n # randomize funding method!\n validate_random_day 'Funding Method', EngagementRequest::FUNDING_METHODS[self.funding_method]\n\n # sponsor is funding it!\n if self.cost_center != self.sponsor.department.cost_center\n add_validation \"Cost Center should match the Sponsor's cost center\"\n end\n\n # detailed estimate must be funding approved!\n if self.detailed_estimate? && ! (self.approved? || self.budget?)\n add_validation EngagementRequest::ENGAGEMENT_TYPES[self.engagement_type] + ' must have budget ' +\n EngagementRequest::FUNDING_STATUSES[\"approved\"] + ' or ' +\n EngagementRequest::FUNDING_STATUSES[\"budget\"]\n end\n # scheduling or rescue must have budget!\n if (self.scheduling? || self.rescue?) && ! self.budget?\n add_validation EngagementRequest::ENGAGEMENT_TYPES[self.engagement_type] + ' must have ' +\n EngagementRequest::FUNDING_STATUSES[\"budget\"]\n end\n\n # must have a decent budget!\n if self.budget_allocated < 100_000\n add_validation 'Projects with a budget of less than $100,000 are not accepted'\n end\n end",
"def retrieve_fees\n return if stripe_charge_id.nil?\n\n transaction = Stripe::BalanceTransaction.retrieve(stripe_charge.balance_transaction)\n return if transaction.nil?\n\n self.fee = transaction.fee / 100.0\n self.received_amount = transaction.net / 100.0\n save\n end",
"def fees\n total_input - total_output\n end",
"def validate_telefones\n # must have one or more telefones\n return false if @telefones.empty?\n @telefones.each do |t|\n # each telefone must have ddd and numero\n return false if t.ddd == \"\" || t.numero == \"\"\n end\n return true\n end"
] | [
"0.7955136",
"0.693547",
"0.67354393",
"0.65347356",
"0.64389837",
"0.62996155",
"0.62626946",
"0.62066674",
"0.6140506",
"0.6088533",
"0.60844463",
"0.60794795",
"0.60560393",
"0.6041833",
"0.5974108",
"0.5929109",
"0.5889821",
"0.5887308",
"0.5871929",
"0.5866521",
"0.5861029",
"0.585033",
"0.5835924",
"0.58067256",
"0.5773138",
"0.5766262",
"0.5746092",
"0.5724187",
"0.5706823",
"0.5697564",
"0.5696581",
"0.56880873",
"0.56744355",
"0.5634871",
"0.5619334",
"0.56134427",
"0.560262",
"0.5592175",
"0.55624825",
"0.5561059",
"0.5557172",
"0.55519503",
"0.55302113",
"0.55148673",
"0.5474605",
"0.54595685",
"0.5458306",
"0.5448373",
"0.5448373",
"0.5446746",
"0.5440106",
"0.541375",
"0.5410765",
"0.5401639",
"0.53795975",
"0.53662705",
"0.5365342",
"0.5356087",
"0.5349792",
"0.5345386",
"0.53385985",
"0.533325",
"0.5325079",
"0.53045785",
"0.5298113",
"0.5297042",
"0.52863765",
"0.5280955",
"0.5264946",
"0.52608436",
"0.52586913",
"0.52562803",
"0.5254515",
"0.5232966",
"0.523124",
"0.523124",
"0.5231131",
"0.52302784",
"0.52266544",
"0.522519",
"0.52180535",
"0.5213701",
"0.5200558",
"0.51901144",
"0.5181659",
"0.5178037",
"0.5176586",
"0.51759714",
"0.51738226",
"0.51688635",
"0.5162055",
"0.51492983",
"0.5144424",
"0.5138487",
"0.5134941",
"0.5130606",
"0.5127614",
"0.5123411",
"0.5122074",
"0.51200265"
] | 0.76635987 | 1 |
add fee is an integer | def add_fee_is_integer
if !params[:add_fee].nil?
add_fee_vals = params[:add_fee].values
add_fee_vals.each_slice(3) do |student_type, amount, time_period|
if !amount.empty? && !(amount.to_i.to_s.eql? amount)
return false
end
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_money\n @total += fee\n end",
"def total_fee\n fee + fee2 + fee3 + fee4\n end",
"def total\n (amount + fee) if amount\n end",
"def fee\n (amount * 0.005) if amount\n end",
"def bar_accepts_fee(fee)\n @bar_cash += fee\n end",
"def fee\n params['amount_fee']\n end",
"def add_fee(args)\n result = Spreedly.post(\"/subscribers/#{id}/fees.xml\", :body => Spreedly.to_xml_params(:fee => args))\n\n case result.code.to_s\n when /2../\n when '404'\n raise \"Not Found\"\n when '422'\n raise \"Unprocessable Entity - #{result.body}\"\n else\n raise \"Could not add fee to subscriber: result code #{result.code}.\"\n end\n end",
"def node_fee(fee_base_msat, fee_proportional_millionths, amount_to_forward)\n fee_base_msat + (amount_to_forward * fee_proportional_millionths) / 1000000\n end",
"def fee\n\tparams['mc_fee']\n end",
"def fee\n @fee || DEFAULT_FEE\n end",
"def document_fee\n 0\n end",
"def mfee(fee, size)\n return fee.to_i if fee.is_a?(Integer)\n raise Error, 'Fee should either be a String or Integer' unless fee.is_a?(String)\n mul = 1\n if fee.start_with?('+', '-')\n mul = -1 if fee.start_with?('-')\n fee = fee[1..-1]\n end\n sat = fees[fee.to_sym]\n raise Error, \"Can't understand the fee: #{fee.inspect}\" if sat.nil?\n mul * sat * size\n end",
"def fee\n params['mc_fee']\n end",
"def fee\n params['mc_fee']\n end",
"def mfee(fee, size)\n return fee.to_i if fee.is_a?(Integer)\n raise Error, 'Fee should either be a String or Integer' unless fee.is_a?(String)\n mul = 1\n if fee.start_with?('+', '-')\n mul = -1 if fee.start_with?('-')\n fee = fee[1..-1]\n end\n sat = fees[fee.to_sym]\n raise Error, \"Can't understand the fee: #{fee.inspect}\" if sat.nil?\n mul * sat * size\n end",
"def qty_to_add\n 0\n end",
"def qty_to_add\n 0\n end",
"def update_fee\n\t\tmoney_info = money_info()\n\t\t@fee = money_info['Trade_Fee'] / 100.0\n\tend",
"def add_klarna_fee!\n if add_klarna?\n\n # FIXME require validation that order restrict partitial payments\n paymeth = payments.first.payment_method\n\n fee = paymeth.preferred(:invoice_fee)\n adj = adjustments.create(amount: fee,\n source: self,\n label: Spree.t(:invoice_fee))\n # FIXME define correct originator\n # paymenthod is not correct spree/core/app/models/spree/adjustment.rb\n # adj.originator = paymeth\n # adj.save!\n adj.lock!\n update!\n end\n end",
"def add(cash)\n @current_balance = @current_balance + cash\n end",
"def fee\n @ipn['mc_fee']\n end",
"def fees\n total_input - total_output\n end",
"def fee_as_percentage\n (merchant.fee * 100).to_i\n end",
"def total_affiliate_fee\n total = 0.0\n @lines.each {|line| total += (line.li_aff_fee * line.li_qty) }\n total\n end",
"def calculate_fee_amount base_amount\n (base_amount * SITE_FEE_PERCENTAGE).round(2)\n end",
"def charged_fee(amount)\n (amount * merchant.fee)\n end",
"def add(number)\n set_value(@value + number.to_i)\n end",
"def pay_entry_fee(entry_fee)\n # if the guest has enough cash for entry_fee\n if @cash >= entry_fee\n # decrement guest cash by entry_fee\n @cash -= entry_fee\n # update guest entry_paid to true\n update_entry_paid()\n end\n end",
"def add_ppe\n update_basic_fee('PPE',quantity: 800, amount: 200)\n end",
"def fulfillment_fee\n\t line_items.inject(0.0) {|charge, line_item| charge = charge + (line_item.fulfillment_fee)}\n end",
"def add_amount(amount)\n @balance += amount\n end",
"def add_foam amount\n @foam = amount\n end",
"def total_fee_is_valid\n errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid?\n end",
"def transaction_fee\n Money.new(-WITHDRAWAL_FEE_IN_CENTS, self.currency)\n end",
"def withdraw(amount)\n amount += TRANSACTION_FEE\n super(amount)\n end",
"def withdraw(amount)\n amount += TRANSACTION_FEE\n super(amount)\n end",
"def sum(num, total) => total += num",
"def add(val)\n \n end",
"def fee_cents\n (fee.to_f * 100.0).round\n end",
"def add(first_num, second_num)\n first_num.to_f + second_num.to_f\nend",
"def amount; end",
"def calculate_fee\n cost = (shooter.current_member? or join_psac) ? 15 : 20\n has_shooter = persisted? ? match.has_more_than_one_shooter?(shooter) : match.has_shooter?(shooter)\n if has_shooter\n cost = 3\n self.squad = 5\n end\n if join_psac\n cost += 30\n end\n self.fee = cost\n end",
"def add_taxes(amt, good_tax, import_tax)\n amt += good_tax + import_tax\n amt.round(2)\n end",
"def order_fee extra_fee=false, bitcoin=false\n fee = APPLICATION_FEE\n fee += FAIL_FEE if extra_fee\n number = bitcoin ? bitcoin_amount : price\n ((number.to_f * fee) * 100.0).to_i\n end",
"def pay_in(balance)\n @balance += balance\nend",
"def create\n params[:fee][:amount].gsub!(/[$,]/, '')\n params[:fee][:amount] = (params[:fee][:amount].to_f * 100).to_i\n\n @fee = Fee.new(fee_params)\n @fee.booth = Booth.find(params[:booth_id])\n\n respond_to do |format|\n if @fee.save\n format.html { redirect_to @fee.booth, notice: 'Fee was successfully created.' }\n format.json { render :show, status: :created, location: @fee }\n else\n format.html { render :new }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_bet_amount(amount_added)\n @bet_amount = bet_amount + amount_added\n end",
"def simple_budget_checker(total)\n\nend",
"def insurance_fee\n (COMMISSION_RATE * INSURANCE_PART_RATE * price).round\n end",
"def reward\n business.add_to_balance(amount)\n end",
"def add_money(value)\n @calculator.add_money value\n end",
"def host_fee\n (total - net_rate).round(2)\n end",
"def total_amount(bill_tip)\n\treturn tip_amount(bill_amount) + bill_tip\nend",
"def add(a, b)\n\tputs \"Adding funds...£#{a} + £#{b}\"\n\treturn a + b\nend",
"def add_fees\n @proposal.fees.each do |bank_account, amounts_by_category|\n amounts_by_category.each do |category, amount|\n category_for_key = category&.downcase&.gsub(' ', '_') || 'none'\n run_task \"add_fees_#{bank_account}_#{category_for_key}\" do\n if transaction = add_fee_transaction(bank_account, amount, category)\n current_state[:transaction_id] = transaction['BankTransactionID']\n end\n end\n end\n end\n end",
"def get_paid(salary)\n self.bank_account += salary\n self.happiness += 1\n \"all about the benjamins\"\n end",
"def set_fee\n @book = Book.find(params[:book_id])\n @fee = @book.fees.find(params[:id])\n end",
"def add ( num_1, num_2)\n num_1.to_i + num_2.to_i\nend",
"def application_fee\n self[:application_fee] || (unit_price * (COMMISSION_RATE / 100) + TRANSACTION_COST / 100).round(2) || BigDecimal(0)\n end",
"def add_to_total(food)\n Farm.add_food(food)\n end",
"def membership_fee\n if business_admin?\n {\"amount\" => 29900, \"id\" => \"business-29900\"}\n elsif church_admin?\n {\"amount\" => 9900, \"id\" => \"church-9900\"}\n elsif alliance_admin?\n {\"amount\" => 9900, \"id\" => \"alliance-9900\"}\n else\n {\"amount\" => 4900, \"id\" => \"individual-4900\"}\n end\n end",
"def channel_fee\n 1\n end",
"def add(value)\n \n end",
"def pvcycle_total_fees\n pvcycle_membership_fee + pvcycle_contribution_fee\n end",
"def create_finance_fee(collection, student)\n last_receipt_no = FinanceFee.last.receipt_no if FinanceFee.last\n fee = FinanceFee.new\n fee.finance_fee_collection_id = collection\n fee.student_id = student\n fee.is_paid = false\n if last_receipt_no.nil?\n fee.receipt_no = 001\n else\n fee.receipt_no = last_receipt_no.next\n end\n fee.save\n end",
"def assistance_fee\n ROADSIDE_ASSISSTANCE_FEE_PER_DAY * duration\n end",
"def edit_fee_is_integer\n if !params[:edit_fees].nil?\n edit_fees_vals = params[:edit_fees].values\n edit_fees_vals.each_slice(3) do |fee, time, remove|\n if !(fee.to_i.to_s.eql? fee)\n return false\n end\n end\n end\n return true\n end",
"def fee_params\n params.require(:fee).permit(:user_id, :name, :price, :serial, :end_at, :deleted_at)\n end",
"def suma(numero_uno:0,numero_dos:0)\n\treturn numero_uno+numero_dos\n\t\nend",
"def amount\n return self.fee['amount'].to_f\n end",
"def add_money_to_till(amount)\n @till += amount\nend",
"def gross_salary(salary, bonus)\n bonus == true ? (salary += (salary*0.5)).to_i : salary.to_i\nend",
"def calculate(t, fraud, type)\r\n#\t\tpp \"1\"\r\n\t\treturn 0.0 if type == 'billable' && self.bid_fee #if this fee is a bid fee and we are not looking at the bid fees then return 0, else continue on\r\n\t#\tpp \"2\"\r\n \t\r\n \tfee = self.fixed if self.price_type == 'F'\r\n \r\n fee = (self.fixed + (t.amount * self.percent) + (fraud == '1' ? self.fraud : 0)).at_least(self.min).at_most(self.max) if self.price_type == 'V' #calculate the fee\r\n \r\n return fee if self.sign == '>=' && self.threshold == 0 #if there is no threshold to worry about get out quick...this is what happens the majority of the time\r\n\t\r\n\t\t#if we get here we know we are dealing with a variable fee\r\n\t\t#puts (self.fixed + (t.amount * self.percent) + (fraud == '1' ? self.fraud : 0)).at_least(self.min)\r\n\t#\tfee = (self.fixed + (t.amount * self.percent) + (fraud == '1' ? self.fraud : 0)).at_least(self.min).at_most(self.max) #calculate the fee\r\n\t#\tpp fee\r\n\t#\tpp \"3\"\r\n\t#\treturn fee if self.sign == '>=' && self.threshold == 0 #if there is no threshold to worry about get out quick...this is what happens the majority of the time\r\n\t\t\r\n\t\t#otherwise we need to determine the sign and threshold before we can return\r\n\t\tcase self.sign\r\n\t\t\twhen '>'\r\n\t\t\t #pp \">\"\r\n\t\t\t\treturn fee if t.amount > self.threshold\r\n\t\t\twhen '>='\r\n\t\t\t #pp \">=\"\r\n\t\t\t\treturn fee if t.amount >= self.threshold\r\n\t\t\twhen '<'\r\n\t\t\t #pp \"<\"\r\n\t\t\t\treturn fee if t.amount < self.threshold\r\n\t\t\twhen '<='\r\n\t\t\t #pp \"<=\"\r\n\t\t\t\treturn fee if t.amount <= self.threshold\r\n\t\t\telse\r\n\t\t\t #pp \"4\"\r\n\t\t\t\treturn 0.0\r\n\t\tend\r\n\t\t\r\n\t\t#if we get here then we have no idea what to do so just return 0\r\n\t\treturn 0.0\r\n\tend",
"def fixed_fee_quantity\n qty = billing_frequency.total_months\n sub_starting_at = subscriber.starting_at\n sub_ending_at = subscriber.ending_at\n if self.reading_type_id == ReadingType::RETIRADA && !self.reading_date.blank?\n sub_ending_at = self.reading_date.to_date\n end\n bp_billing_starting_date = billing_period.billing_starting_date\n bp_billing_ending_date = billing_period.billing_ending_date\n begin\n if sub_starting_at > bp_billing_starting_date && sub_starting_at < bp_billing_ending_date\n # Subscriber registerd during the period\n # qty = (bp_billing_ending_date - sub_starting_at).to_i.days.seconds / 1.month.seconds\n qty = ((bp_billing_ending_date - sub_starting_at).days.seconds / 1.month.seconds).round\n end\n if (!sub_ending_at.nil?) && (sub_ending_at > bp_billing_starting_date && sub_ending_at < bp_billing_ending_date)\n # Subscriber withdrawn during the period\n qty = ((sub_ending_at - bp_billing_starting_date).days.seconds / 1.month.seconds).round\n end\n rescue\n qty = billing_frequency.total_months\n end\n return qty\n end",
"def fee_params\n params.require(:fee).permit(:student_id, :amount, :user_id, :month)\n end",
"def add(num_1, num_2)\n\tnum_1.to_i + num_2.to_i\n#add(2, 4)\nend",
"def calculate_sum\n 1000000000000\n end",
"def set_fee\n @fee = Fee.find(params[:id])\n end",
"def set_fee\n @fee = Fee.find(params[:id])\n end",
"def set_fee\n @fee = Fee.find(params[:id])\n end",
"def add(num1, num2)\n num1.to_f + num2.to_f;\nend",
"def add_profit(amount)\n amount * 1.005\n end",
"def add_trivia(amount)\n if amount < 10\n @credits = @credits + amount * 2\n else\n @credits = @credits + 20\n end\n end",
"def addup_total\n\t\tget_total\n\t\tupdate_total = {}\n\t\tupdate_total[\"c_ExpScopingTotal\"] = @total\n\t\tif(@total>0)\n\t\t\trally = @query_result.get_rally_object\n\t\t\tupdate = rally.update(\"portfolioitem\",\"FormattedID|#{@feature_id}\",update_total)\n\t\t\tif(update)\n\t\t\t\[email protected](\"Total for #{@feature_id} is updated to #{@total}\")\n\t\t\telse\n\t\t\t\[email protected](\"Total could not be updated\")\n\t\t\tend\n\t\tend\n\tend",
"def spend(amount)\r\n @spend += amount\r\n end",
"def add_interst\n return @balance + (@balance*@interest_rate)\n end",
"def restaurant_bill(meal_cost, tax, tips)\n tax_amount = meal_cost * tax\n tip_amount = meal_cost * tips\n meal_cost + tax_amount + tip_amount\nend",
"def credit(amount)\n\t\t@revenue += amount\n\tend",
"def add_digits(number)\nend",
"def membership_fixed_total\n applied_subscriptions.select {|h| h[:type] == :fixed}.map {|h| h[:amount] }.flatten.reduce(:+).to_i || 0\n end",
"def add\n @input1 = params[:input1]\n @input2 = params[:input2]\n @input1 = @input1.to_i\n @input2 = @input2.to_i\n @add = @input1 + @input2\n end",
"def add_fee_transaction(bank_account, amount, description = nil)\n return if amount.zero?\n\n logger.debug \"Creating fee transaction for #{amount} from #{bank_account} (#{description})\"\n\n @api.post('BankTransactions', {\n 'Type' => amount.negative? ? 'RECEIVE' : 'SPEND',\n 'Contact' => {\n 'ContactID' => find_or_create_xero_contact(@export.payment_providers[bank_account] ||\n 'Generic Payment Processor')\n },\n 'Date' => @export.date.strftime('%Y-%m-%d'),\n 'BankAccount' => { 'Code' => bank_account },\n 'Reference' => @export.reference,\n 'LineItems' => [\n {\n 'Description' => description || 'Fees',\n 'UnitAmount' => amount.abs,\n 'AccountCode' => @export.fee_accounts[bank_account] || '404',\n 'Tracking' => tracking_options\n }\n ]\n })['BankTransactions'].first\n end",
"def add_monthly_interest\n\t\t@debt *= 1.015\n\t\t@balance *= 1.0003\n\tend",
"def fees\n @fees ||= {\n \"insurance_fee\" => (commission * ASSURANCE_SHARE).round(0),\n \"assistance_fee\" => (ASSISTANCE_COST * rental.duration).round(0)\n }.tap { |fees| fees[\"drivy_fee\"] = commission - fees.values.inject(:+) }\n end",
"def deposit(cash)\n @balance += cash\n end",
"def add_credits(qty)\n update_column(:credits, credits + qty)\n end",
"def add_money\n\t\t# get current user's money\n \t@user = current_user\n\t\t@money = @user.money\n\t\t# get refill limit\n\t\t@allowed = @user.money_refill\n\n\t\t# if limit has not been reached, add money to account\n\t\tif @allowed > 0\n\t\t\[email protected] = @money + 1000\n\t\t\[email protected]_refill = @allowed - 1\n\t\t\[email protected]\n\t\t\tgflash :success => \"Money Successfully Transferred to your account!\"\n\t\t\tredirect_to :action => 'profile', :username => @user.login\n\t\telse\n\t\t\t# otherwise flash pop up regarding depleted money reserve\n\t\t\tgflash :error => \"You have depleted your money reserve.\"\n\t\t\tredirect_to :action => 'profile', :username => @user.login\n\t\tend\n end",
"def add(first_number, second_number)\n return first_number + second_number\nend",
"def add(num_1, num_2)\n\tnum_1.to_i + num_2.to_i\n# add(10, 5)\nend",
"def add_rate(from, to, rate); end"
] | [
"0.7869563",
"0.76108587",
"0.7365345",
"0.71690035",
"0.71125776",
"0.6906227",
"0.68922806",
"0.67977655",
"0.66506",
"0.6647953",
"0.64599144",
"0.63451695",
"0.633986",
"0.633986",
"0.6328",
"0.6302088",
"0.6302088",
"0.62671804",
"0.62576467",
"0.6249384",
"0.6243939",
"0.6221005",
"0.6218333",
"0.6191965",
"0.61598945",
"0.61480355",
"0.6137678",
"0.6136179",
"0.6128324",
"0.61184293",
"0.6118182",
"0.6110814",
"0.6093929",
"0.606074",
"0.6022113",
"0.6022113",
"0.60162127",
"0.5988892",
"0.595797",
"0.59579307",
"0.5952863",
"0.5943907",
"0.59416085",
"0.5932663",
"0.5931362",
"0.5929409",
"0.59284985",
"0.5922786",
"0.5892277",
"0.58865994",
"0.5870902",
"0.5854227",
"0.584217",
"0.58362067",
"0.5829194",
"0.5826173",
"0.5815156",
"0.58069766",
"0.58066064",
"0.5805275",
"0.5801027",
"0.57990354",
"0.57845724",
"0.578356",
"0.5779079",
"0.5773588",
"0.576369",
"0.57482266",
"0.57466173",
"0.5744561",
"0.57438713",
"0.57407725",
"0.5735192",
"0.5733774",
"0.5726778",
"0.5721339",
"0.57141316",
"0.57055694",
"0.57055694",
"0.57055694",
"0.56924975",
"0.5689765",
"0.5681869",
"0.56735635",
"0.56728894",
"0.566929",
"0.5664107",
"0.5659712",
"0.56551796",
"0.56551194",
"0.565355",
"0.56493616",
"0.56473076",
"0.56448156",
"0.5644263",
"0.5637148",
"0.563236",
"0.5630458",
"0.5628716",
"0.56286967"
] | 0.639711 | 11 |
Grade can't be empty | def valid_edit_entry_reqs
if !params[:edit_entry_req].nil?
edit_reqs_vals = params[:edit_entry_req].values
edit_reqs_vals.each_slice(3) do |grade, info, remove|
if grade.empty?
return false
end
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grade_is_valid\n errors.add(:grade, 'Invalid grade entered.') unless grade_is_valid?\n end",
"def grade_or_blank\n grade || \"None\"\n end",
"def grade_is_valid?\n if not_nil_and_string(self.grade)\n if GRADES.include? self.grade\n if self.grade == \"k\";self.grade = \"K\";end #force uppercase K\n return true\n end\n end\n return false\n end",
"def safe_to_destroy?\n grades.empty?\n end",
"def letter_grade (number_grade, default = '?')\n return default if number_grade.blank? || !number_grade.instance_of?(Fixnum)\n Review.letter_grade(number_grade) || default\n end",
"def validate\n ModelHelper::Validations.validate_combos([{:grade_code => self.grade_code}],self,true) \n \n end",
"def grade_no\n\t\tgrade.nil? ? 0 : grade.split(\"-\").last\n\tend",
"def valid_for_grading?(_)\n true\n end",
"def correctness_for(question, grade)\n grade >= question.maximum_grade\n end",
"def grade_params\n params.require(:grade).permit(:number, :grade)\n end",
"def assign_grade grade\n \n if grade>90 && grade<100\n p \"A\"\n elsif grade>80 && grade<90\n p \"B\"\n elsif grade>70 && grade<80\n p \"C\"\n end\nend",
"def getGrade\n if 0 > @grade || @grade > 100\n return \"not a valid grade.\"\n elsif @grade <= 60\n return \"F\"\n elsif @grade <= 69\n return \"D\"\n elsif @grade <= 79\n return \"C\"\n elsif @grade <= 89\n return \"B\"\n else\n return \"A\"\n end\n end",
"def get_grade (grade)\n if grade <= 59\n return \"F\"\n elsif grade > 59 && grade < 70\n return \"D\"\n elsif grade > 69 && grade < 80\n return \"C\"\n elsif grade > 79 && grade < 90\n return \"B\"\n elsif grade > 89 && grade <= 100\n return \"A\"\n else\n return \"Invalid Grade\"\n end\nend",
"def assign_grade number\n \n if number <0 || number>100\n \"Invalid Number\"\n elsif number <=100 && number >90\n \"A\"\n elsif number <=90 && number >80\n \"B\"\n elsif number <=80 && number >70\n \"C\"\n elsif number <=70 && number >60\n \"D\"\n else\n \"F\"\n end\nend",
"def passed?\n @grade >= 2.0\n end",
"def division_grade_consistency\n return false if self.student.nil? || self.team.nil?\n if self.student.junior? && self.team.junior?\n return true\n elsif !self.student.junior? && !self.team.junior? \n return true\n else \n errors.add(:student, \"'s grade is inappropriate for this team\")\n end\n end",
"def get_grade(avg)\n if avg.to_i >= 90\n return \"A\"\n elsif avg.to_i >= 80\n return \"B\"\n elsif avg.to_i >= 70\n return \"C\"\n elsif avg.to_i >= 60\n return \"D\"\n elsif avg.to_i < 60\n return \"F\"\n else\n return \"Error. Please enter a number grade from 0-100.\"\n end\nend",
"def get_grade(average)\n return \"A\" if average <= 100 && average >= 90\n \n return \"B\" if average < 90 && average >= 80\n \n return \"C\" if average < 80 && average >= 70\n \n return \"D\" if average < 70 && average >= 60\n \n return \"F\" if average < 60\nend",
"def assign_grade_letter num\n if num == 100 && num >= 90\n puts \"A\"\n elsif num >= 80 && num < 90\n puts \"B\"\n elsif num >= 70 && num < 80\n puts \"C\"\n elsif num >= 60 && num < 70\n puts \"D\"\n elsif num > 100\n puts \"Please enter a valid percentage\"\n elsif num < 0 \n puts \"Please a grade percentage above 0\"\n else\n puts \"F\"\n end\nend",
"def assign_grade(num)\n if num > 100 or num < 0\n puts 'please enter a number from 0 to 100'\n elsif num >= 90\n puts 'A'\n elsif num >= 80 and num < 90\n puts 'B'\n else\n puts 'C'\n end\n\nend",
"def assign_grade\n if params[:num].to_i > 100\n render html: 'Grade is above 100'\n elsif params[:num].to_i < 0\n render html: 'Grade is below 0'\n elsif params[:num].to_i >= 90\n render html: 'A'\n elsif params[:num].to_i >= 80\n render html: 'B'\n elsif params[:num].to_i >= 70\n render html: 'C'\n elsif params[:num].to_i >= 60\n render html: 'D'\n else\n render html: 'F'\n end\nend",
"def grade(num)\n if num >= 90 && num <= 100\n p \"A\"\n elsif num >= 80 && num <= 89\n p \"B\"\n elsif num >= 70 && num <= 79\n p \"C\"\n elsif num >= 60 && num <= 69\n p \"D\"\n elsif num > 0 && num <= 59\n p \"F\"\n else\n p \"Cannot recieve higher than 100 or lower than 0\"\n end\nend",
"def get_grade(grade)\n if grade >=1 && grade <=59 then\n letter_grade = 'F'\n elsif grade >=60 && grade <=69 then\n letter_grade = 'D'\n elsif grade >=70 && grade <=79 then\n letter_grade = 'C'\n elsif grade >=80 && grade <=89 then\n letter_grade = 'B'\n elsif grade >=90 && grade <=100 then\n letter_grade = 'A'\n end\n return letter_grade\nend",
"def grade_params\n params.require(:grade).permit(:student_id, :course_id, :value)\n end",
"def assign_grade(num = nil)\n num = num.to_i\n if num != nil\n if num >= 90\n return \"A\"\n elsif num >= 80\n return \"B\"\n elsif num >= 70\n return \"C\"\n elsif num >= 60\n return \"D\"\n elsif num < 60\n return \"F\"\n else\n return \"n/a\"\n end\n else\n return \"n/a\"\n end\nend",
"def grade_display_text(grade)\n (grade && grade.score) || 'N'\n end",
"def get_grade(grade)\n if grade >= 0 and grade <= 59\n p \"F\"\n elsif grade >= 60 and grade <= 69\n p \"D\"\n elsif grade >= 70 and grade <=79\n p \"C\"\n elsif grade >= 80 and grade <= 89\n p \"B\"\n else grade >=90 and grade <= 100\n p \"A\"\n end \nend",
"def proficient_by_grade(grade)\n case grade\n when(3)\n data[:threerd_grade_students_scoring_proficient_or_above_on_the_csap_tcap]\n when(8)\n data[:eightth_grade_students_scoring_proficient_or_above_on_the_csap_tcap]\n else\n raise UnknownDataError\n end\n end",
"def get_grade(num)\n if num >= 90 \n\tgrade = \"A\"\nelsif num >= 80\n\tgrade = \"B\"\nelsif num >= 70\n\tgrade = \"C\"\nelsif num >= 60\n\tgrade = \"D\"\nelse\n\tgrade = \"F\"\nend\n\tend",
"def get_grade(*grades)\n average = grades.sum / grades.size\n \n case \n when average > 90\n \"A\"\n when average >= 80 && average < 90\n \"B\"\n when average >= 70 && average < 80\n \"C\"\n when average >= 60 && average < 70\n \"D\"\n else\n \"F\"\n end\nend",
"def junior?\n grade <=6\n end",
"def get_grade(grade)\n\tif grade.to_i >= 90\n\t\treturn \"A\"\n\telsif grade.to_i >= 80\n\t\treturn \"B\"\n\telsif grade.to_i >= 70\n\t\treturn \"C\"\n\telsif grade.to_i >= 60\n\t\treturn \"D\"\n\telsif grade.to_i < 60\n\t\treturn \"F\"\nend\nend",
"def assign_grade (num)\n if num >= 90\n p 'A'\n elsif num <= 89 && num >= 80\n p 'B'\n elsif num <= 79 && num >= 70\n p 'C'\n elsif num <= 69 && num >= 60\n p 'D'\n elsif num <= 59 \n p 'F'\n end\nend",
"def assign_grade number\n if number <= 100 && number >= 90\n puts 'A'\n elsif number <= 89 && number >= 80\n puts 'B'\n elsif number <= 79 && number >= 70\n puts 'C'\n elsif number <= 69 && number >= 60\n puts 'D'\n elsif number <= 59 && number >= 0\n puts 'F'\n else\n puts 'Not a valid grade, try 0-100'\n end\nend",
"def assign_grade number\n if number <= 100 && number >= 90\n puts 'A'\n elsif number <= 89 && number >= 80\n puts 'B'\n elsif number <= 79 && number >= 70\n puts 'C'\n elsif number <= 69 && number >= 60\n puts 'D'\n elsif number <= 59 && number >= 0\n puts 'F'\n else\n puts 'Not a valid grade, try 0-100'\n end\nend",
"def max_grade_greater_than_min_grade\n if(self.max_grade.to_i < self.min_grade.to_i)\n return \"must be greater than min grade\"\n end\n end",
"def grade(grade_percentage)\n case grade_percentage\n when 100..110\n \"A+\"\n when 93..99\n \"A\"\n when 90..92\n \"A-\"\n when 87..89\n \"B+\"\n when 83..86\n \"B\"\n when 80..82\n \"B-\"\n when 77..79\n \"C+\"\n when 73..76\n \"C\"\n when 70..72\n \"C-\"\n when 67..69\n \"D+\"\n when 63..66\n \"D\"\n when 60..62\n \"D-\"\n else\n \"F\"\n end\nend",
"def get_grade(*grades)\n av_grade = grades.sum(0.0) / grades.length\n case av_grade\n when 100..Float::INFINITY then 'A+'\n when 90..99 then 'A'\n when 80..89 then 'B'\n when 70..79 then 'C'\n when 60..69 then 'D'\n else 'F'\n end\nend",
"def assign_grade number\n \n if number <=100 && number >90\n \"A\"\n elsif number <=90 && number >80\n \"B\"\n elsif number <=80 && number >70\n \"C\"\n elsif number <=70 && number >60\n \"D\"\n else\n \"F\"\n end\nend",
"def ==(grade)\n self.number_value == grade.number_value\n end",
"def has_grades?\n for grade in Annotation.extract_grades(self.text) do\n if Annotation.has_grade?(grade) then\n return true\n end\n end\n return false\n end",
"def grade_params\n params.require(:grade).permit(:student_id, :assignment_id, :score)\n end",
"def check_grades (name, final_student)\n\tif \n\t\tfinal_student[name] > 75\n\t\tputs \"Your final score is #{final_student[name]}. Congratulations, you passed!\"\n\telse\n\t\tputs \"Your final score is #{final_student[name]}. Sorry, you did not pass.\"\n\tend\nend",
"def bonus_grade?\n return false if grade_entry_item.nil?\n grade_entry_item.bonus?\n end",
"def assign_grade (num)\n return 'A' if num > 89\n return 'B' if num > 79\n return 'C' if num > 69\n return 'D' if num > 59\n return 'F'\nend",
"def assign_grade (num)\n if num>=90\n puts \"A\"\n elsif num>=80\n puts \"B\"\n elsif num>=70\n puts \"C\"\n elsif num>=60\n puts \"D\"\n elsif num>=50 || num>=0\n puts \"F\"\n end\nend",
"def grade\n @grade\n end",
"def validate_letter_grade(raw_score)\n mapping_rule.has_key?(raw_score.to_s.upcase)\n end",
"def grade_params\n params.require(:grade).permit(:score, :verify)\n end",
"def update_grade(student)\n # Set homeroom grade level to be first student's grade level, since\n # we don't have any crosswalk between homerooms and grades in\n # Somerville's Student Information System\n\n return if self.grade.present?\n return if student.grade.blank?\n\n update_attribute(:grade, student.grade)\n end",
"def assign_grade int\n if int > 100 || int < 0\n \"Please enter a valid score between 0 & 100\"\n elsif int >= 90\n \"A\"\n elsif int >= 80\n \"B\"\n elsif int >= 70\n \"C\"\n elsif int >= 60\n \"D\"\n else\n \"F\"\n end\nend",
"def load_gradebook_breakdown_for_grade(grade)\n raise(ArgumentError, \"Failed to load gradebook entry breakdown from scenario.\") if @scenario.nil? or @scenario['GRADEBOOK_ENTRIES_BY_GRADE'].nil?\n breakdown = @scenario['GRADEBOOK_ENTRIES_BY_GRADE'][GradeLevelType.to_string(grade)]\n raise(ArgumentError, \"Failed to load gradebook entry breakdown for specified grade (#{GradeLevelType.to_string(grade)}).\") if breakdown.nil?\n breakdown.each do |assignment, guidelines|\n # traverse the gradebook entry breakdown for the grade and make sure guidelines are well-formed\n raise(ArgumentError, \"Nil or empty key for grade: #{GradeLevelType.to_string(grade)}\") if assignment.nil? or assignment.size == 0\n raise(ArgumentError, \"Malformed gradebook entry breakdown for grade: #{GradeLevelType.to_string(grade)}\") if guidelines['min'].nil? or guidelines['max'].nil?\n end\n breakdown\n end",
"def get_grade(num_grade)\n\n\tif num_grade >= 90\n\t\tgrade = 'A'\n\t\tp grade\n\telsif num_grade >= 80\n\t\tgrade = 'B'\n\t\tp grade\n\telsif num_grade >= 70\n\t\tgrade = 'C'\n\t\tp grade\n\telsif num_grade >= 60\n\t\tgrade = 'D'\n\t\tp grade\n\telse\n\t\tgrade = 'F'\n\t\tp grade\n\tend\nend",
"def get_grade(letter_grade)\n return \"A\" if letter_grade >= 90\n return \"B\" if letter_grade >= 80\n return \"C\" if letter_grade >= 70\n return \"D\" if letter_grade >= 60\n return \"F\" if letter_grade < 60\nend",
"def assign_grade num\n if num >= 90\n \"A\"\n elsif num >= 80\n \"B\"\n elsif num >= 70\n \"C\"\n elsif num >= 60\n \"D\"\n else\n \"F\"\n end\nend",
"def allotment_is_not_100\n if not allot_for_item.blank? and not allot_for_const.blank? and not allot_for_research.blank?\n errors.add(:base, I18n.t('activerecord.errors.models.houdd_user.attributes.allotment_is_not_100')) if (allot_for_item + allot_for_const + allot_for_research) != 100\n end\n end",
"def grade_params\n params.require(:grade).permit(:assignment_name, :grade, :student_id, :teacher_id)\n end",
"def get_grade(average)\n if average <=100 && average >=90\n p \"A\"\n elsif average <=89 && average >=80\n p \"B\"\n elsif average <=79 && average >=70\n p \"C\"\n elsif average <=69 && average >=60\n p \"D\"\n else\n p \"F\"\n end\nend",
"def grade_params\n params.require(:grade).permit(:student_has_subject_id, :aplicar_parcial, :grade_type, :calificacion)\n end",
"def get_grade(avg)\n\tif avg <= 100 and avg > 89\n\t\treturn \"A\"\n\telsif avg < 90 and avg > 79\n\t\treturn \"B\"\n\telsif avg < 80 and avg > 69\n\t\treturn \"C\"\n\telsif avg < 70 and avg > 59\n\t\treturn \"D\"\n\telse avg < 60 and avg > 0\n\t\treturn \"F\"\n\tend\nend",
"def get_grade(gr1, gr2, gr3)\n average = (gr1 + gr2 + gr3) / 3\n return \"A\" if average >= 90\n return \"B\" if average >= 80\n return \"C\" if average >= 70\n return \"D\" if average >= 60\n \"F\"\nend",
"def test_create_invalidgrade\n begin\n Grade.new(\"ABD\")\n rescue ArgumentError\n assert(true) # this is a specifc error we throw\n rescue\n assert(false) # uncaught exception\n end\n end",
"def assign_grade (score)\n if (score > 100 || score < 1)\n puts \"Score (#{score}) is out of range (1-100).\"\n elsif score > 90\n puts \"A (#{score})\"\n elsif score > 80\n puts \"B (#{score})\"\n elsif score > 70\n puts \"C (#{score})\"\n elsif score > 60\n puts \"D (#{score})\"\n else\n puts \"F (#{score})\"\n end\nend",
"def get_grade(grade)\n if 90 <= grade\n return \"A\"\n elsif 80 <= grade\n return \"B\"\n elsif 70 <= grade\n return \"C\"\n elsif 60 <= grade\n return \"D\"\n else return \"F\"\n end\nend",
"def get_grade(num_grade)\n\n if num_grade > 89\n return 'A'\n\n elsif num_grade > 79\n return 'B'\n\n elsif num_grade > 69\n return 'C'\n\n elsif num_grade > 59\n return 'D'\n\n else\n return 'F'\n\n end\n\nend",
"def grade!\n # default method does nothing and leaves a score of 0\n end",
"def what_is_my_grade(score)\n if(score < 0 || score > 100)\n return \"Please enter a number between 0 and 100\"\n end\n if(score > 90)\n return \"A\"\n end\n if(score > 80)\n return \"B\"\n end\n if(score > 70)\n return \"C\"\n end\n if(score > 60)\n return \"D\"\n end\n return \"F\"\nend",
"def grade_result_name\n case grade_result\n when '', nil\n ''\n when 'N'\n 'Negatywna'\n when 'P'\n 'Pozytywna'\n else\n 'Error grade_result value !'\n end \n end",
"def get_grade(ave)\r\n\tif ave>=90\r\n\t\tp \"A\"\r\n\telsif ave>=80\r\n\t\tp \"B\"\r\n\telsif ave>=70\r\n\t\tp \"C\"\r\n\telsif ave>=60\r\n\t\tp \"D\"\r\n\telsif ave<=50\r\n\t\tp \"F\"\r\n\telsif \r\n\t\tp \"Unable to Calculate\"\r\n\tend\r\nend",
"def check(*args)\n process_using(*args.unshift(:grade_as_hash))\n end",
"def get_grade(average)\n if average < 60\n p \"F\"\n elsif average < 70 && average >= 60\n p \"D\"\n elsif average < 80 && average >= 70\n p \"C\"\n elsif average < 90 && average >= 80\n p \"B\"\n else average < 101 && average >= 90\n p \"A\"\n end\nend",
"def assign_grade\n if params[:num].to_i >= 90\n render html: 'A'\n elsif params[:num].to_i >= 80\n render html: 'B'\n elsif params[:num].to_i >= 70\n render html: 'C'\n elsif params[:num].to_i >= 60\n render html: 'D'\n else\n render html: 'F'\n end\nend",
"def get_grade(avg)\n if avg >= 90 then\n return \"A\"\n elsif avg > 79 then\n return \"B\"\n elsif avg > 69 then\n return \"C\"\n elsif avg > 59 then\n return \"D\"\n else \n return \"F\"\n end\nend",
"def get_grade(average)\n case average\n when 90..100\n then \"A\"\n when 80..89\n then \"B\"\n when 70..79\n then \"C\"\n when 60..69\n then \"D\"\n when 0..60\n then \"F\"\n end\n end",
"def grade_status(student)\n\tif student[:grade] == \"F\"\n\t\t\"failed\"\n\telse\n\t\t\"passed\"\n\tend\nend",
"def grade\n @grades ||= case score\n when 10.0..100.0\n 16\n when 9.0..10.0\n 13\n when 8.5..9.0\n 12\n when 8.0..8.5\n 11\n when 7.5..8.0\n 10\n when 7.0..7.5\n 9\n when 6.5..7.0\n 8\n when 6.0..6.5\n 7\n when 5.5..6.0\n 6\n when 5.0..5.5\n 5\n else\n 4\n end\n end",
"def grade(student_grade)\n roster[student_grade]\n end",
"def get_grade(average)\n if average >= 90\n return \"A\"\n elsif average >= 80 && average <= 89\n return \"B\"\n elsif average >= 70 && average <= 79\n return \"C\"\n elsif average >= 60 && average <= 69\n return \"D\"\n else\n return \"F\"\n end\nend",
"def valid_add_entry_req\n if !params[:add_entry_req].nil?\n add_er_vals = params[:add_entry_req].values\n add_er_vals.each_slice(3) do |incoming_qual, grade, info|\n if (!incoming_qual.empty? && grade.empty?) ||\n (incoming_qual.empty? && (!grade.empty? || !info.empty?))\n return false\n end\n end\n end\n return true\n end",
"def letter_grade(average)\n if average >= 90\n 'A'\n elsif average >= 80\n 'B'\n elsif average >= 70\n 'C'\n elsif average >= 60\n 'D'\n else\n 'F'\n end\nend",
"def senior?\n\t\tgrade == 12\n\tend",
"def grade_params\n params.require(:grade).permit(:user_id, :grade, :course_id, :lesson_id, :lesson_module_id)\n end",
"def get_grade(grades)\n\t@grades = grades\n\t@average = (@grades.inject(:+)/@grades.length)\n\tif @average >= 90\n\t\treturn 'A'\n\telsif @average >= 80\n\t\treturn 'B'\n\telsif @average >= 70\n\t\treturn 'C'\n\telsif @average >= 60\n\t\treturn 'D'\n\telse\n\t\treturn 'F'\n\tend\nend",
"def assign_grade num\n if num <= 100 && num >= 90\n puts \"A\"\n elsif num >= 80 && num < 90\n puts \"B\"\n elsif num >= 70 && num < 80\n puts \"C\"\n elsif num >= 60 && num < 70\n puts \"D\"\n else\n puts \"F\"\n end\nend",
"def grade\n if @data.attribute_names.include?(:cmustudentclass)\n @grade ||= @data[:cmustudentclass].last\n else\n @grade ||= nil\n end\n end",
"def on_grade_now?\n !self.grades.where(:due_date => Time.now).blank?\n end",
"def letter_grade(score)\n if score >= 90\n \"A\"\n elsif score <= 89 && score >= 80\n \"B\"\n elsif score <= 79 && score >= 70\n \"C\"\n elsif score <= 69 && score >= 60\n \"D\"\n else\n \"F\"\n end\nend",
"def get_grade(avg_score)\n\tif avg_score >= 90\n\t\t\"A\"\n\telsif avg_score >= 80\n\t\t\"B\"\n\telsif avg_score >= 70\n\t\t\"C\"\n\telsif avg_score >= 60\n\t\t\"D\"\n\telse\n\t\t\"F\"\n\tend\nend",
"def add_student(name, grade)\n #check if empty\n if roster[grade] != nil\n roster[grade] << name\n else\n roster[grade] = [name]\n end\n end",
"def letter_grade(score)\n if score >= 90\n grade = \"A\"\n elsif score >= 80\n grade = \"B\"\n elsif score >= 70\n grade = \"C\"\n elsif score >= 60\n grade = \"D\"\n else\n grade = \"F\"\n end\nend",
"def get_grade(grade1, grade2, grade3)\n grades_min_score = {\n a: 90,\n b: 80,\n c: 70,\n d: 60,\n f: 0\n }\n grades = [grade1, grade2, grade3]\n\n average = average(grades)\n\n case\n when average >= grades_min_score[:a] && average <= 100\n \"A\"\n when average >= grades_min_score[:b]\n \"B\"\n when average >= grades_min_score[:c]\n \"C\"\n when average >= grades_min_score[:d]\n \"D\"\n when average >= grades_min_score[:f]\n \"F\"\n end\nend",
"def get_grade(x)\nif x <= 59\nreturn \"F\"\nelsif x <= 69\nreturn \"D\"\nelsif x <= 79\nreturn \"C\"\nelsif x <= 89\nreturn \"B\"\nelsif x <= 99\nreturn \"A\"\nelse\nreturn \"Not a number\"\nend\nend",
"def get_grade(x)\n return \"A\" if x >= 90\n\n return \"B\" if x < 90 && x >= 80\n\n return \"C\" if x < 80 && x >= 70\n\n return \"D\" if x < 70 && x >= 60\n\n return \"F\" if x < 60\n end",
"def junior?\n\t\tgrade == 11\n\tend",
"def get_grade(num)\n if num >= 90\n p \"A\"\n elsif (num >= 80) && (num < 90)\n p \"B\"\n elsif (num >= 70) && (num < 80)\n p \"C\"\n elsif (num >= 60) && (num < 70)\n p \"D\"\n else (num >= 50) && (num < 60)\n p \"F\"\n end\nend",
"def get_grade(average)\n if average >= 90 && average <= 100\n return \"A\"\n elsif average < 90 && average >= 80\n return \"B\"\n elsif average <80 && average >= 70\n return \"C\"\n elsif average < 70 && average >= 60\n return \"D\"\n else average < 60\n return \"F\"\n end\nend",
"def get_grade(average)\n if average >= 90\n return \"A\"\n elsif average >= 80\n return \"B\"\n elsif average >= 70\n return \"C\"\n elsif average >=60\n return \"D\"\n else\n return \"F\"\n end\nend",
"def get_grade (average)\r\n\r\n\tif average > 89\r\n\t\tthen letter_grade = 'A'\r\n\telsif average > 79\r\n\t\tthen letter_grade = 'B'\r\n\telsif average > 69\r\n\t\tthen letter_grade = 'C'\r\n\telsif average > 59\r\n\t\tthen letter_grade = 'D'\r\n\telse\r\n\t\tletter_grade = 'F'\r\n\tend\t\t\r\n\r\n\treturn letter_grade\r\n\r\nend",
"def get_grade scores\n average = 0\n scores.each do |num|\n if num < 0 || num > 100\n p \"Please input a list of valid scores (0-100).\"\n else\n average += num\n end\n end\n average /= scores.length\n if average >= 90\n \"A\"\n elsif average >= 80\n \"B\"\n elsif average >= 70\n \"C\"\n elsif average >= 60\n \"D\"\n else\n \"F\"\n end\nend",
"def approved?(grade = 5)\n $students.each do |student|\n if get_avggrades(student) >= grade\n print \"#{student[:name]} ha aprobado con un #{get_avggrades(student)}\\n\"\n end\n end\nend"
] | [
"0.7560349",
"0.7542708",
"0.7293533",
"0.6466168",
"0.63290566",
"0.63017464",
"0.6279586",
"0.6249708",
"0.62176436",
"0.6185592",
"0.6182905",
"0.6166327",
"0.61450225",
"0.61365336",
"0.6106052",
"0.6102391",
"0.60613227",
"0.6041784",
"0.60280734",
"0.6018244",
"0.6004664",
"0.5987604",
"0.59819704",
"0.5973732",
"0.5973062",
"0.5958231",
"0.59563",
"0.59421164",
"0.5930567",
"0.59219104",
"0.5915553",
"0.59153306",
"0.590909",
"0.5893247",
"0.5893247",
"0.58753026",
"0.58586323",
"0.5849157",
"0.5845654",
"0.58419687",
"0.5837795",
"0.5835161",
"0.58340573",
"0.5832355",
"0.58269775",
"0.58265316",
"0.58248484",
"0.5820017",
"0.5813722",
"0.58107466",
"0.5809197",
"0.5808453",
"0.5805303",
"0.5794785",
"0.57867736",
"0.5772727",
"0.576379",
"0.57631665",
"0.57578945",
"0.57571775",
"0.5754233",
"0.5749314",
"0.57336193",
"0.57333606",
"0.57281363",
"0.57277036",
"0.5726602",
"0.57220703",
"0.5721079",
"0.5718676",
"0.5711659",
"0.5710756",
"0.57097113",
"0.57078606",
"0.5699353",
"0.56978863",
"0.5696719",
"0.568918",
"0.56882405",
"0.5685893",
"0.5680139",
"0.5679823",
"0.5672845",
"0.5666337",
"0.5663575",
"0.5662585",
"0.5662406",
"0.5656117",
"0.56534654",
"0.5651069",
"0.5646776",
"0.5645836",
"0.56409836",
"0.5634721",
"0.56327844",
"0.56302625",
"0.5629757",
"0.56253564",
"0.56236905",
"0.56230724"
] | 0.60914916 | 16 |
valid is all fields empty or incoming_qual and grade filled | def valid_add_entry_req
if !params[:add_entry_req].nil?
add_er_vals = params[:add_entry_req].values
add_er_vals.each_slice(3) do |incoming_qual, grade, info|
if (!incoming_qual.empty? && grade.empty?) ||
(incoming_qual.empty? && (!grade.empty? || !info.empty?))
return false
end
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grade_is_valid\n errors.add(:grade, 'Invalid grade entered.') unless grade_is_valid?\n end",
"def validate_required\n [\n :project_name,\n :status,\n :requester_id,\n :subject_expert_id,\n :sponsor_id,\n :vision,\n :goal,\n :description,\n :scope,\n :advice_required,\n :program_id,\n :train_id,\n :funding_method,\n :cost_center,\n :funding_status,\n :budget_allocated,\n :priority,\n :start_date,\n :end_date,\n :risk_rating,\n :risks,\n :projected_revenue,\n ].each do |field|\n if self.attributes[field.to_s].nil? || self.attributes[field.to_s].blank?\n # intentionally vague!\n add_validation 'All fields are required to perform further validations'\n return false\n end\n end\n true\n end",
"def validate_mandatory_fields\n validate_for_card unless self.cc_number.blank?\n validate_for_transaction_tag unless self.transaction_tag.blank?\n validate_for_track1 unless self.track1.blank?\n validate_for_track2 unless self.track2.blank?\n end",
"def validate\n ModelHelper::Validations.validate_combos([{:grade_code => self.grade_code}],self,true) \n \n end",
"def validate_fields\n %w[email author].each do |field|\n value = self.send(field)\n abort \"Hoe #{field} value not set. aborting\" if value.nil? or value.empty?\n end\n end",
"def validate!\n required_attributes.each do |attribute|\n if form_data[attribute].nil? || form_data[attribute].empty?\n raise Adyen::REST::RequestValidationFailed, \"#{attribute} is empty, but required!\"\n end\n end\n end",
"def valid_edit_entry_reqs\n if !params[:edit_entry_req].nil?\n edit_reqs_vals = params[:edit_entry_req].values\n edit_reqs_vals.each_slice(3) do |grade, info, remove|\n if grade.empty?\n return false\n end\n end\n end\n return true\n end",
"def validate\n#\tfirst check whether combo fields have been selected\n is_valid = true\n end",
"def validate\n#\tfirst check whether combo fields have been selected\n is_valid = true\n end",
"def any_present?\n if name.blank? and phone.blank? and license_plate.blank?\n errors.add :base, \"You must fill in at least one field\"\n end\n end",
"def valid?\n @errors = []\n \n # checks each field type and adds error messages if it does not meet requirements from the table\n validate_field_types\n \n \n if integer?(\"num_quarter_hours\")\n if num_quarter_hours < 1\n @errors << {message: \"Number of quarter hours must be greater than 0.\", variable: \"num_quarter_hours\"}\n end\n end\n \n @errors.empty?\n end",
"def not_blank\n if (name.blank? and email.blank? and phone.blank?)\n errors.add(\"name, email, and phone cannot all be blank\")\n end\n end",
"def validate!\n # Require that at least one field exist.\n if fields.length == 0\n raise SkyDB::Query::ValidationError.new(\"At least one selection field is required for #{self.inspect}.\")\n end\n\n fields.each do |field|\n field.validate!\n end\n\n groups.each do |group|\n group.validate!\n end\n end",
"def valid?\n filled?\n end",
"def validate \n #\tfirst check whether combo fields have been selected\n is_valid = true\n if is_valid\n is_valid = ModelHelper::Validations.validate_combos([{:qc_test_id => self.qc_test_id}],self) \n end\n # #now check whether fk combos combine to form valid foreign keys\n # if is_valid\n # is_valid = set_qc_test\n # end\n # if is_valid\n # is_valid = ModelHelper::Validations.validate_combos([{:qc_inspection_type_code => self.qc_inspection_type_code}],self) \n # end\n # #now check whether fk combos combine to form valid foreign keys\n # if is_valid\n # is_valid = set_qc_inspection_type\n # end\n end",
"def valid?\n validate_field_types\n # only do a database query if you have good enough data to check the database\n if @errors.length == 0\n if duplicate_user_assignment?\n @errors << \n {message: \n \"The database already has this user and assignment combination. It is record \n #{this_user_and_assignment.id}. Change this assignment or user or the assignment or user of that record.\", \n variabe: \"assignment_id, user_id\"}\n end\n end \n @errors.length == 0\n end",
"def validate\n # first check whether combo fields have been selected\n is_valid = true\n end",
"def required_fields\n if self.controller_name == \"registrations\"\n param_name = \"user\"\n elsif self.controller_name == \"merchants\"\n param_name = \"merchant\"\n else\n return\n end\n empty_fields = Array.new\n empty = false\n params[param_name].each_pair do |k, v|\n if v == \"\"\n empty_fields << k.gsub(\"_\", \" \")\n empty = true\n end\n end\n if empty == true\n (0..empty_fields.length - 3).each do |i|\n empty_fields[i] << \",\"\n end\n empty_fields.insert(-2, \"and\") unless empty_fields.length < 2\n field_list = empty_fields.join(\" \")\n message = \"You cannot leave empty fields. The field\" \n if empty_fields.length > 1\n message << \"s \"\n else\n message << \" \"\n end\n message << field_list \n if empty_fields.length > 1\n message << \" were left blank.\"\n else\n message << \" was left blank.\"\n end\n flash[:notice] = message\n redirect_to request.referrer\n else\n return\n end\n end",
"def valid?\n !blank? && rets? && !error?\n end",
"def valid?()\n if( requiredFieldsPresent? )\n # check each condition, saving off error if one exists (ugh...)\n @errors << \"byr is not valid #{@args[\"byr\"]}\" if !byrValid?(@args[\"byr\"])\n @errors << \"iyr is not valid #{@args[\"iyr\"]}\" if !iyrValid?(@args[\"iyr\"])\n @errors << \"eyr is not valid #{@args[\"eyr\"]}\" if !eyrValid?(@args[\"eyr\"])\n @errors << \"hgt is not valid #{@args[\"hgt\"]}\" if !hgtValid?(@args[\"hgt\"])\n @errors << \"hcl is not valid #{@args[\"hcl\"]}\" if !hclValid?(@args[\"hcl\"])\n @errors << \"ecl is not valid #{@args[\"ecl\"]}\" if !eclValid?(@args[\"ecl\"])\n @errors << \"pid is not valid #{@args[\"pid\"]}\" if !pidValid?(@args[\"pid\"])\n end\n @errors.empty?\n end",
"def custom_validations\n self.validate_baseline && validate_baseline_date && \n self.validate_trial_days && self.validates_goal_name && self.validation_due_date\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:mark_code => self.mark_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_mark\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend",
"def presence_of_mandatory_fields\n if promo_amount.blank? and info.blank?\n errors[:base] << 'Au moins un des champs doivent être remplis'\n end\n end",
"def validate \n # first check whether combo fields have been selected\n#\t is_valid = true\n#\t if is_valid\n#\t is_valid = ModelHelper::Validations.validate_combos([{:stock_type_code => self.stock_type_code}],self)\n#\t end\n#\t if is_valid\n#\t is_valid = set_stock_type\n#\t end\n#\n#\t if is_valid\n#\t is_valid = ModelHelper::Validations.validate_combos([{:location_code => self.location_code}],self)\n#\t end\n#\t if is_valid\n#\t is_valid = set_location\n#\t end\n#\n#\t #if is_valid\n#\t # is_valid = ModelHelper::Validations.validate_combos([{:party_name => self.party_name}],self)\n#\t #end\n#\t #if is_valid\n#\t # is_valid = set_party\n#\t #end\n#\n#\t if is_valid\n#\t is_valid = set_parties_role\n#\t end\n#\n#\t #if is_valid\n#\t # is_valid = set_current_location\n#\t #end\n#\n# if is_valid\n# is_valid = set_status\n# end\n\t \n end",
"def valid?\n !vendor_no.nil? && !name.nil?\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t \n\t if is_valid\n\t is_valid = set_drench_concentrate_status\n\t end\n#\t if is_valid\n#\t\t is_valid = ModelHelper::Validations.validate_combos([{:drench_line_type_code => self.drench_line_type_code}],self) \n#\tend\n#\t#now check whether fk combos combine to form valid foreign keys\n#\t if is_valid\n#\t\t is_valid = set_drench_station\n#\t end\n#\t if is_valid\n#\t\t is_valid = ModelHelper::Validations.validate_combos([{:concentrate_code => self.concentrate_code}],self) \n#\tend\n#\t#now check whether fk combos combine to form valid foreign keys\n#\t if is_valid\n#\t\t is_valid = set_concentrate_product\n#\t end\nend",
"def valid?\n\t\t@errors['name'] = \"can't be blank\" if name.blank?\n @errors['breed'] = \"can't be blank\" if breed.blank?\n @errors['weight'] = \"can't be blank\" if weight.blank?\n @errors.empty? #-->true\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def check_required_fields(data)\r\n @field_names[1..-1].each do |f|\r\n raise(ArgumentError,\r\n 'A value for this field is required: %s' % f) if \\\r\n @field_requireds[@field_names.index(f)] and data[f].nil? \r\n end\r\n end",
"def validate_essential_attributes #:nodoc:\n if @month.to_i.zero? || @year.to_i.zero?\n errors.add :month, \"is required\" if @month.to_i.zero?\n errors.add :year, \"is required\" if @year.to_i.zero?\n else\n errors.add :month, \"is not a valid month\" unless valid_month?(@month)\n errors.add 'card', \"has expired\" if expired?\n errors.add :year, \"is not a valid year\" unless valid_expiry_year?(@year)\n end\n end",
"def schools_valid?\n valid = true\n self.schools.each do |school|\n unless school.qualifications_valid?\n self.errors.add(:school, \"'#{school.name}' does not have any qualifications\")\n valid = false\n end\n end\n valid\n end",
"def valid?\n @errors << :title if [email protected]_a?(String) || @title.empty?\n @errors << :author if [email protected]_a?(String) || @author.empty?\n @errors << :release_date unless @release_date.is_a?(Date)\n @errors << :publisher if [email protected]_a?(String) || @publisher.empty?\n @errors << :isbn unless @isbn.is_a?(Integer) && @isbn < 10**10 && @isbn >= 10**9\n \n @errors.empty?\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:target_market_name => self.target_market_name}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_target_market\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend",
"def validate_params\n if lat.blank? || lng.blank? || property_type.blank? || offer_type.blank?\n @properties = []\n @message = \"Looks like some search parameters are missing!\"\n fail!(:validation_failed) && abort!\n end\n end",
"def validations\n {}\n end",
"def valid_for_grading?(_)\n true\n end",
"def validate\n errors.add_to_base \"Enter atleast one product\" if items.empty?\n end",
"def valid; end",
"def valid?\n return false if !@external_id.nil? && @external_id.to_s.length > 64\n return false if !@first_name.nil? && @first_name.to_s.length > 128\n return false if @last_name.nil?\n return false if @last_name.to_s.length > 64\n return false if @last_name.to_s.length < 1\n return false if !@middle_name.nil? && @middle_name.to_s.length > 64\n gender_validator = EnumAttributeValidator.new('String', [\"M\", \"F\"])\n return false unless gender_validator.valid?(@gender)\n return false if [email protected]? && @language.to_s.length > 32\n return false if [email protected]? && @phone.to_s.length > 64\n return false if [email protected]? && @email.to_s.length > 128\n return false if !@doc_type.nil? && @doc_type.to_s.length > 32\n return false if !@doc_issuer_info.nil? && @doc_issuer_info.to_s.length > 256\n return false if !@doc_series.nil? && @doc_series.to_s.length > 64\n return false if !@doc_number.nil? && @doc_number.to_s.length > 64\n return false if !@department_code.nil? && @department_code.to_s.length > 64\n return false if !@department_name.nil? && @department_name.to_s.length > 256\n return false if !@building_no.nil? && @building_no.to_s.length > 8\n return false if [email protected]? && @city.to_s.length > 32\n return false if !@country_code.nil? && @country_code.to_s.length > 8\n return false if !@country_name.nil? && @country_name.to_s.length > 64\n return false if [email protected]? && @district.to_s.length > 64\n return false if !@flat_no.nil? && @flat_no.to_s.length > 8\n return false if !@house_no.nil? && @house_no.to_s.length > 16\n return false if [email protected]? && @region.to_s.length > 64\n return false if !@room_no.nil? && @room_no.to_s.length > 8\n return false if !@settlement_type.nil? && @settlement_type.to_s.length > 32\n return false if [email protected]? && @street.to_s.length > 64\n return false if !@raw_address.nil? && @raw_address.to_s.length > 512\n true\n end",
"def validate\n\t#first check whether combo fields have been selected\n\t is_valid = true\n\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:farm_code => self.farm_code}],self)\n\t end\n\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:commodity_code => self.commodity_code}],self)\n\t end\n\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:rmt_variety_code => self.rmt_variety_code}],self)\n\t end\n\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:pack_material_product_code => self.pack_material_product_code}],self)\n\t end\n\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:season_code => self.season_code}],self)\n\t end\n\n\t #now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_farm\n\t end\n\n\t if is_valid\n\t\t is_valid = set_rmt_variety\n\t end\n\n\t if is_valid\n\t\t is_valid = set_pack_material_product\n\t end\n\n\t if is_valid\n\t\t is_valid = set_season\n\t end\n\n\t#validates uniqueness for this record\n#\t if self.new_record? && is_valid\n#\t\t validate_uniqueness\n#\t end\nend",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:commodity_code => self.commodity_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_commodity\n\t end\n\t \n\tif is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:equivalent_count_from => self.equivalent_count_from}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_equivalent_count_from\n\t end\n\t \n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:equivalent_count_to => self.equivalent_count_to}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_equivalent_count_to\n\t end\n\t \n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend",
"def validated?; end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:account_code => self.account_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_account\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:party_type_name => self.party_type_name},{:party_name => self.party_name},{:role_name => self.role_name}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_parties_role\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend",
"def validity\n msg=\"\"\n valid=true\n unless self.default_location.nil?\n # test si la salle est deja allouee a une classe\n unless self.default_location.class_school.nil? || self.default_location.class_school==self\n msg=\"La salle est déja occupée (#{self.default_location.class_school.ident}) !!\"\n valid=false\n else\n if self.nb_max_student > self.default_location.location_nb_max_person\n msg=\"La salle est trop petite (#{self.default_location.location_nb_max_person}) !!\"\n valid=false\n end\n end\n end\n self.errors.add(:base, \"Class school is not valid:#{msg}\") unless valid\n valid\n end",
"def validate\n errors.add(:post_office, \"- must be filled for postalcode #{self.postal_code}\") if self.post_office.blank? && !self.postal_code.blank?\n errors.add(:postal_code, \"- must be filled for #{self.post_office}\") if self.postal_code.blank? && !self.post_office.blank? \n errors.add_to_base(\"- Person must have at least one phonenumber\") if (self.phone_home.blank? && self.phone_cell.blank? && self.phone_work.blank?) \n end",
"def new_quality_must_complete\n if (id.nil? && half==2)\n if (!indicator_desc_quality.blank? && !target_quality.blank? && !achievement_quality.blank? && !progress_quality.blank?)\n return true\n elsif (!indicator_desc_quality.blank? && target_quality.blank? && achievement_quality.blank? && progress_quality.blank?) || (!indicator_desc_quality.blank? && !target_quality.blank? && achievement_quality.blank? && progress_quality.blank?) || (!indicator_desc_quality.blank? && !target_quality.blank? && !achievement_quality.blank? && progress_quality.blank?) || (!indicator_desc_quality.blank? && !target_quality.blank? && achievement_quality.blank? && !progress_quality.blank?) || (indicator_desc_quality.blank? && !target_quality.blank? && !achievement_quality.blank? && !progress_quality.blank?)|| (indicator_desc_quality.blank? && target_quality.blank? && !achievement_quality.blank? && !progress_quality.blank?) || (indicator_desc_quality.blank? && target_quality.blank? && achievement_quality.blank? && !progress_quality.blank?) || (indicator_desc_quality.blank? && target_quality.blank? && !achievement_quality.blank? && progress_quality.blank?) \n return false\n end\n end \n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate\r\n\r\n end",
"def valid?\n self.errors = []\n self.content_type.fields.each do |field|\n if field.required\n if self.dynamic_getter(field.name).blank?\n self.errors << field.name\n end\n end\n end\n self.errors.blank?\n end",
"def extra_validations\n success\n end",
"def grade_is_valid?\n if not_nil_and_string(self.grade)\n if GRADES.include? self.grade\n if self.grade == \"k\";self.grade = \"K\";end #force uppercase K\n return true\n end\n end\n return false\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:commodity_code => self.commodity_code},{:rmt_variety_code => self.rmt_variety_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_rmt_variety\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:season_code => self.season_code},{:id => self.id}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_season\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend",
"def valid?\n return false if @name.nil?\n return false if @value.nil?\n return false if @timestamp.nil?\n return false if @source_id.nil?\n return false if @source_label.nil?\n return false if @source.nil?\n source_validator = EnumAttributeValidator.new('String', [\"IMPORT\", \"API\", \"FORM\", \"ANALYTICS\", \"MIGRATION\", \"SALESFORCE\", \"INTEGRATION\", \"CONTACTS_WEB\", \"WAL_INCREMENTAL\", \"TASK\", \"EMAIL\", \"WORKFLOWS\", \"CALCULATED\", \"SOCIAL\", \"BATCH_UPDATE\", \"SIGNALS\", \"BIDEN\", \"DEFAULT\", \"COMPANIES\", \"DEALS\", \"ASSISTS\", \"PRESENTATIONS\", \"TALLY\", \"SIDEKICK\", \"CRM_UI\", \"MERGE_CONTACTS\", \"PORTAL_USER_ASSOCIATOR\", \"INTEGRATIONS_PLATFORM\", \"BCC_TO_CRM\", \"FORWARD_TO_CRM\", \"ENGAGEMENTS\", \"SALES\", \"HEISENBERG\", \"LEADIN\", \"GMAIL_INTEGRATION\", \"ACADEMY\", \"SALES_MESSAGES\", \"AVATARS_SERVICE\", \"MERGE_COMPANIES\", \"SEQUENCES\", \"COMPANY_FAMILIES\", \"MOBILE_IOS\", \"MOBILE_ANDROID\", \"CONTACTS\", \"ASSOCIATIONS\", \"EXTENSION\", \"SUCCESS\", \"BOT\", \"INTEGRATIONS_SYNC\", \"AUTOMATION_PLATFORM\", \"CONVERSATIONS\", \"EMAIL_INTEGRATION\", \"CONTENT_MEMBERSHIP\", \"QUOTES\", \"BET_ASSIGNMENT\", \"QUOTAS\", \"BET_CRM_CONNECTOR\", \"MEETINGS\", \"MERGE_OBJECTS\", \"RECYCLING_BIN\", \"ADS\", \"AI_GROUP\", \"COMMUNICATOR\", \"SETTINGS\", \"PROPERTY_SETTINGS\", \"PIPELINE_SETTINGS\", \"COMPANY_INSIGHTS\", \"BEHAVIORAL_EVENTS\", \"PAYMENTS\", \"GOALS\", \"PORTAL_OBJECT_SYNC\", \"APPROVALS\", \"FILE_MANAGER\", \"MARKETPLACE\", \"INTERNAL_PROCESSING\", \"FORECASTING\", \"SLACK_INTEGRATION\", \"CRM_UI_BULK_ACTION\", \"WORKFLOW_CONTACT_DELETE_ACTION\"])\n return false unless source_validator.valid?(@source)\n return false if @selected_by_user.nil?\n return false if @selected_by_user_timestamp.nil?\n return false if @source_vid.nil?\n return false if @source_metadata.nil?\n return false if @request_id.nil?\n true\n end",
"def valid?\n @errors = []\n # check thename exists and is not empty\n if name.to_s.empty?\n @errors << {message: \"Name cannot be empty.\", variable: \"name\"}\n end\n \n # check the description exists and is not empty\n if description.to_s.empty?\n @errors << {message: \"Description cannot be empty.\", variable: \"description\"}\n end\n \n # check the description exists and is not empty\n if studio_id.to_s.empty? \n @errors << {message: \"Studio id cannot be empty.\", variable: \"studio_id\"}\n elsif studio.blank?\n @errors << {message: \"Studio id must be a member of the studios table.\", variable: \"studio_id\"}\n end \n \n # check the description exists and is not empty\n if rating_id.to_s.empty?\n @errors << {message: \"Rating id cannot be empty.\", variable: \"rating_id\"}\n elsif rating.blank?\n @errors << {message: \"Rating id must be a member of the ratings table.\", variable: \"rating_id\"}\n end\n \n # checks the number of time slots\n if length.to_s.empty?\n @errors << {message: \"Length cannot be empty.\", variable: \"length\"}\n elsif length.is_a? Integer\n if length < 0\n @errors << {message: \"Length must be greater than 0.\", variable: \"length\"}\n end\n else\n @errors << {message: \"Length must be a number.\", variable: \"length\"}\n end\n \n # returns whether @errors is empty\n @errors.empty?\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:artist_name => self.artist_name}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_artist\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend",
"def field_validations\n @filters.each do |filter|\n validate_field_presence(filter.field_name) if filter.required?\n end\n end",
"def validate\n # add errors if not validate\n end",
"def required_fields_valid?\n check_required\n errors.empty?\n end",
"def required_fields_valid?\n check_required\n errors.empty?\n end",
"def valid?\n return false if @ach_type.nil?\n return false if @routing_number.nil?\n return false if @routing_number.to_s.length > 9\n return false if @routing_number.to_s.length < 9\n return false if @routing_number !~ Regexp.new(/^[0-9]+$/)\n return false if @account_number.nil?\n return false if @account_number.to_s.length > 56\n return false if @account_number.to_s.length < 1\n return false if @account_number !~ Regexp.new(/^[0-9]+$/)\n return false if @account_type.nil?\n account_type_validator = EnumAttributeValidator.new('String', [\"C\", \"S\"])\n return false unless account_type_validator.valid?(@account_type)\n return false if !@check_number.nil? && @check_number.to_s.length > 10\n return false if !@check_number.nil? && @check_number !~ Regexp.new(/^[0-9]+$/)\n return false if @check_type.nil?\n check_type_validator = EnumAttributeValidator.new('String', [\"P\", \"C\"])\n return false unless check_type_validator.valid?(@check_type)\n return false if !@product_code.nil? && @product_code.to_s.length > 6\n return false if !@product_code.nil? && @product_code !~ Regexp.new(/^[0-9]+$/)\n return false if !@agent_id.nil? && @agent_id.to_s.length > 6\n return false if !@agent_id.nil? && @agent_id !~ Regexp.new(/(?=.*[^\\s])^[^|]+$/)\n return false if !@terminal_id.nil? && @terminal_id.to_s.length > 10\n return false if !@terminal_id.nil? && @terminal_id !~ Regexp.new(/^[0-9]+$/)\n return false if !@registration_id.nil? && @registration_id.to_s.length > 50\n return false if !@registration_id.nil? && @registration_id !~ Regexp.new(/(?=.*[^\\s])^[^|]+$/)\n release_type_validator = EnumAttributeValidator.new('String', [\"C\", \"D\", \"P\", \"T\"])\n return false unless release_type_validator.valid?(@release_type)\n vip_customer_validator = EnumAttributeValidator.new('String', [\"Y\", \"N\"])\n return false unless vip_customer_validator.valid?(@vip_customer)\n return false if @session_id.nil?\n return false if @session_id.to_s.length > 128\n return false if @session_id !~ Regexp.new(/(?=.*[^\\s])^[^|]+$/)\n return false if !@terminal_state.nil? && @terminal_state.to_s.length > 2\n return false if !@terminal_state.nil? && @terminal_state !~ Regexp.new(/^[A-Z]{2}$/)\n return false if !@terminal_city.nil? && @terminal_city.to_s.length > 16\n return false if !@terminal_city.nil? && @terminal_city !~ Regexp.new(/(?=.*[^\\s])^[^|]+$/)\n true\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:rule_code => self.rule_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_rule\n\t end\nend",
"def validate_fields_for_calculations(params)\n rpe = params[:player_rpe_rating]\n performance = params[:player_personal_performance]\n full_practice = params[:participated_in_full_practice]\n minutes = params[:minutes_participated]\n # nill checks\n if rpe.nil? || performance.nil? || full_practice.nil?\n return false\n # type checks\n elsif (!validate_integer_type(rpe) || !validate_integer_type(performance) || !validate_boolean_type(full_practice) || !validate_integer_type(minutes))\n return false\n # practice + minutes check\n elsif (full_practice == false && minutes.nil?)\n return false\n # pass preliminary checks\n else\n return true\n end\n\n end",
"def valid?\n validate_survivors and validate_items && validate_records\n end",
"def validate!\n # pass\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:postal_address_type_code => self.postal_address_type_code},{:city => self.city},{:address1 => self.address1}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_postal_address\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:party_type_name => self.party_type_name},{:party_name => self.party_name}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_party\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:contact_method_type_code => self.contact_method_type_code},{:contact_method_code => self.contact_method_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_contact_method\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:party_type_name => self.party_type_name},{:party_name => self.party_name}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_party\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend",
"def verify_nilness_params(yearly_cost, yearly_consumption, floor_space, heat_type, water_cooking_type, nb_residents)\n if yearly_cost.zero? # if he forgot the yearly cost\n false\n else\n if yearly_consumption.zero? # if the consumption is not entered, all the other field must be present\n if [floor_space, nb_residents].include?(0) || [heat_type, water_cooking_type].include?('')\n false\n else\n true\n end\n else\n true\n end\n end\n end",
"def valid?\n @errors = []\n if id.blank?\n @errors << {message: \"#{class_name} id cannot be blank.\", variable: \"id\"}\n elsif !possible_values.include?(id)\n @errors << {message: \"#{class_name} id must be included in the table.\", variable: \"id\"}\n end\n \n if class_name.blank?\n @errors << {message: \"Class cannot be blank.\", variable: \"class\"}\n end\n \n @errors.empty?\n end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid_params?; end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend",
"def is_valid?\n instructor_approved || (non_rejected_student_memberships.size >= assignment.group_min)\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t #is_valid = ModelHelper::Validations.validate_combos([{:commodity_code => self.commodity_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t #is_valid = set_spray_program_result\n\t end\nend",
"def is_valid; end",
"def validate\n end",
"def has_required_fields\n return unless format.is_a?(LocalPostal::Format)\n\n format.required_fields.each do |field|\n field_name = self.class.formatting_variables_lookup_table[field.to_sym]\n value = public_send(field_name)\n errors.add(field_name, 'is required') if \"#{value}\".empty?\n end\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_rails_error\n\t end\nend",
"def validation; end",
"def validation; 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 validate_required_fields\n user = new_record? ? author : current_journal.try(:user)\n\n required_attribute_names(user).each do |attribute|\n if /^\\d+$/.match?(attribute)\n attribute = attribute.to_i\n v = custom_field_values.detect {|v| v.custom_field_id == attribute}\n if v && Array(v.value).detect(&:present?).nil?\n errors.add(v.custom_field.name, l('activerecord.errors.messages.blank'))\n end\n else\n if respond_to?(attribute) && send(attribute).blank? && !disabled_core_fields.include?(attribute)\n next if attribute == 'category_id' && project.try(:issue_categories).blank?\n next if attribute == 'fixed_version_id' && assignable_versions.blank?\n\n #####\n # START PATCH\n next if attribute == 'typology_id' && !project.module_enabled?('typologies')\n next if attribute == 'typology_id' && project.typologies.blank?\n # END PATCH\n #####\n\n errors.add attribute, :blank\n end\n end\n end\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate_params\n validate_size\n validate_mine_density\n validate_first_click\n type_specific_checks\n end",
"def valid_attributes\n { :free => false,\n :details => nil,\n :expense_item_id => @exp.id\n }\n end",
"def valid?\n return false if @default_department_id.nil?\n return false if !@default_email.nil? && @default_email.to_s.length > 250\n return false if @default_location_id.nil?\n return false if !@default_phone.nil? && @default_phone.to_s.length > 15\n return false if @expense_approver.nil?\n return false if @first_name.nil?\n return false if @first_name.to_s.length > 30\n return false if !@home_email.nil? && @home_email.to_s.length > 250\n return false if !@home_extension.nil? && @home_extension.to_s.length > 10\n return false if !@home_phone.nil? && @home_phone.to_s.length > 15\n return false if @identifier.nil?\n return false if @identifier.to_s.length > 15\n return false if @last_name.nil?\n return false if @last_name.to_s.length > 30\n return false if @license_class.nil?\n license_class_validator = EnumAttributeValidator.new('String', [\"F\", \"A\", \"C\", \"X\"])\n return false unless license_class_validator.valid?(@license_class)\n return false if !@mobile_email.nil? && @mobile_email.to_s.length > 250\n return false if !@mobile_extension.nil? && @mobile_extension.to_s.length > 10\n return false if !@mobile_phone.nil? && @mobile_phone.to_s.length > 15\n return false if !@office_email.nil? && @office_email.to_s.length > 250\n return false if !@office_extension.nil? && @office_extension.to_s.length > 10\n return false if !@office_phone.nil? && @office_phone.to_s.length > 15\n return false if @sales_default_location_id.nil?\n return false if @time_approver.nil?\n return false if @time_zone.nil?\n return false if [email protected]? && @title.to_s.length > 50\n return false if @work_role.nil?\n return true\n end",
"def valid?\n @errors = []\n # check thename exists and is not empty\n if name.to_s.empty?\n @errors << {message: \"Name cannot be empty.\", variable: \"name\"}\n end\n \n # check the description exists and is not empty\n if description.to_s.empty?\n @errors << {message: \"Description cannot be empty.\", variable: \"description\"}\n end\n \n # check the description exists and is not empty\n # if studio_id.to_s.empty?\n # @errors << {message: \"Studio id cannot be empty.\", variable: \"studio_id\"}\n # elsif studio.blank?\n # @errors << {message: \"Studio id must be a member of the studios table.\", variable: \"studio_id\"}\n # end \n \n if !studio_id.valid?\n @errors += studio_id.errors\n end\n \n # check the description exists and is not empty\n # if rating_id.to_s.empty?\n # @errors << {message: \"Rating id cannot be empty.\", variable: \"rating_id\"}\n # elsif rating.blank?\n # @errors << {message: \"Rating id must be a member of the ratings table.\", variable: \"rating_id\"}\n # end\n \n if !rating_id.valid?\n @errors += rating_id.errors\n end\n # checks the number of time slots\n if length.to_s.empty?\n @errors << {message: \"Length cannot be empty.\", variable: \"length\"}\n elsif length.is_a? Integer\n if length < 1\n @errors << {message: \"Length must be greater than 0.\", variable: \"length\"}\n end\n else\n @errors << {message: \"Length must be a number.\", variable: \"length\"}\n end\n \n # returns whether @errors is empty\n @errors.empty?\n end",
"def validated; end",
"def all_required(data, fields)\t\t\n\t\tif fields.nil? == true\n\t\t\treturn true\n\t\tend\n\t\t@api_errmsg = Array.new\n\t\tfields = fields.split(',')\n\t\tflag = true\n\t\tfields.each do |name|\n\t\t\tif data[name].nil?\n\t\t\t @api_errmsg.push(name)\n\t\t\t flag = false\n\t\t\tend\n\t\tend\n\t\tif flag == true\n\t\t return true\n\t\tend\n\t\treturn false\n\tend",
"def profile_complete?\n\t\t!self.fname.blank? and !self.lname.blank? and !self.email.blank? and !self.company_name.blank? and !self.country.blank? and !self.locale.blank?\n\tend",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:farm_group_code => self.farm_group_code},{:id => self.id}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_farm_group\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:party_type_name => self.party_type_name},{:party_name => self.party_name},{:role_name => self.role_name},{:id => self.id}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_parties_role\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend",
"def validate\n super\n errors.add(:name, \"can't be empty\") if name.blank?\n errors.add(:category_id, \"can't be empty\") if category_id.blank?\n errors.add(:price, \"can't be empty\") if price.blank?\n end",
"def valid?\n super\n errors.empty?\n end",
"def valid?\n return false if @subject_property.nil?\n return false if @proprietorship.nil?\n proprietorship_validator = EnumAttributeValidator.new('String', [\"Unknown\", \"Sole\", \"Joint\"])\n return false unless proprietorship_validator.valid?(@proprietorship)\n return false if @surname.nil?\n return false if @forename.nil?\n return false if @middle_name.nil?\n return true\n end",
"def okay?\n\t\tself.missing.empty? && self.invalid.empty?\n\tend",
"def design_data_filled_in?\n !self.description.blank? && \n !self.platform.blank? && \n !self.product_type.blank? && \n !self.project.blank? &&\n !self.design_directory.blank? &&\n !self.incoming_directory.blank?\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:report_type_code => self.report_type_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_report_type\n\t end\nend"
] | [
"0.7050975",
"0.7010043",
"0.65794116",
"0.65639305",
"0.656047",
"0.6557604",
"0.64929855",
"0.6391397",
"0.6391397",
"0.6359351",
"0.6329575",
"0.6321248",
"0.62965274",
"0.6296428",
"0.6292145",
"0.62892175",
"0.6275817",
"0.6264646",
"0.6252959",
"0.62178636",
"0.6158149",
"0.61458886",
"0.6143142",
"0.6119361",
"0.6090514",
"0.60874873",
"0.6085237",
"0.6082091",
"0.6078891",
"0.60669607",
"0.60666704",
"0.60459006",
"0.60442305",
"0.6040143",
"0.6020042",
"0.5987377",
"0.59873235",
"0.59860075",
"0.5984224",
"0.598376",
"0.5975301",
"0.5964068",
"0.596186",
"0.5957514",
"0.595041",
"0.5949659",
"0.59474075",
"0.5946702",
"0.5945425",
"0.5938615",
"0.5938345",
"0.59374577",
"0.5935203",
"0.59314525",
"0.5930061",
"0.59291345",
"0.59191954",
"0.59163284",
"0.59163284",
"0.5915653",
"0.59144837",
"0.59099585",
"0.5909648",
"0.5906703",
"0.59060943",
"0.59001493",
"0.5897901",
"0.5893914",
"0.588903",
"0.588903",
"0.588903",
"0.588903",
"0.588903",
"0.58884263",
"0.5887207",
"0.58859897",
"0.5885839",
"0.5885358",
"0.5882502",
"0.5881951",
"0.5880555",
"0.5875629",
"0.5875629",
"0.58736825",
"0.58712405",
"0.5867649",
"0.58627415",
"0.58619523",
"0.58612037",
"0.58598673",
"0.58556247",
"0.5854845",
"0.58544195",
"0.58531684",
"0.5848954",
"0.58476806",
"0.58443946",
"0.5843164",
"0.5836781",
"0.58239734"
] | 0.6816034 | 2 |
This is for the "send_reminders" functionality | def user_response
Rails.logger.info(:event => "action_response", :response => params["payload"].class)
begin
payload = ActiveSupport::JSON.decode(params["payload"])
user = payload["user"]
actions = payload["actions"]
id = user["id"]
value = actions[0]["value"]
if value == "done"
# TODO:
# - I think we might need to hide the instance name in the value? Or maybe another field?
# - Once I can identify the instance that's "done", retrieve it from the database and
# mark it as vacant.
# - After successfully updating the instance, send lily a message letting her know what happened.
elsif value == "not_done"
render :status => 200, :body => "No problem!"
return
else
# this... shouldn't be possible
end
rescue StandardError => e
Rails.logger.error(:event => "user_response_crash", :error => e, :backtrace => e.backtrace)
return nil
end
render :status => 200, :body => "Thanks for the update!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reminder_sent\n end",
"def reminder\n RequestMailer.reminder\n end",
"def reminder\n UsersMailer.reminder\n end",
"def reminder\n send_reminders self.charges.where(:completed => false)\n end",
"def add_reminder; end",
"def reminder\n DateEventApplicationsMailer.reminder\n end",
"def send_reminders\n User.send_reminders\n redirect_to :back, notice: \"Email reminders sent.\"\n end",
"def send_travel_reminders\n @title = 'Send reminders'\n @travels = Travel.pending.where(\"reminder_sent IS ? AND member_id IS NOT ?\", nil, nil)\n @messages = []\n @travels.each do |travel|\n if travel.member.email\n @messages << Notifier.travel_reminder(travel) \n travel.update_attribute(:reminder_sent, Date.today)\n#puts \"**Reminder_sent set to #{travel.reload.reminder_sent}\"\n end\n end\n @messages.each {|m| m.deliver}\n flash[:notice] = \"Sent #{@messages.count} travel reminder messages\"\n AppLog.create(:severity=>'info', :code=>'Notice.travel_reminder', :description => flash[:notice])\n redirect_to travels_path\n end",
"def send_reminder_email \n UserMailer.reminder_email(self).deliver\n end",
"def send_reminder\n @reminder = Reminder.find(params[:id])\n @order = @reminder.order\n \n @reminder.send_email(params)\n \n flash[:notice] = \"Your email was successfully sent at #{current_time}\"\n redirect_to :action => :reminders, :id => @order\n end",
"def send_reminder\r\n\t\tif Date.today == expiration_date - 1\r\n\t\t\tReminderMailer.food_reminder_msg(@user).deliver\r\n \t\tflash[:notice] = \"#{@user.username} has been notified by email.\" \r\n \tend\r\n end",
"def send_user_reminder(referral,num_of_times)\n @referral = referral\n @num_of_times = num_of_times\n set_receiver(@referral)\n set_sender(@referral)\n\n if @num_of_times == 1\n mail(to: @receiver_email,subject: \"Reminder - Please indicate your interest for your referral\").deliver\n else\n mail(to: @receiver_email,subject: \"Last Reminder - Please indicate your interest for your referral\").deliver\n end\n end",
"def auto_reminder_email(class_date)\n @response_email = ResponseEmail.find_by_purpose(\"auto_reminder\")\n @body = format_auto_reminder(@response_email.body, class_date)\n recipients = class_date.registrations.map {|reg| reg.user.email }\n mail(:to => \"[email protected]\", :bcc => recipients, :subject => @response_email.subject, :reply_to => @response_email.reply_to)\n end",
"def schedule_reminder_email\n \tstart_time = Time.at(available_slot.start_time).strftime(' %H:%M')\n \tdate = appointment_date.to_s\n \tschedule_time = (Date.parse(date + start_time) - 30.minutes)\n \tReminderMailer.send_reminder(patient).deliver_later(wait_until: schedule_time)\n end",
"def reminder\n\n end",
"def send_feedback_reminders_emails\n # Send the emails\n feedback_reminders.each do |fr|\n fr.send_feedback_reminder_email\n end\n\n # Shift the send_feedback_reminders_after date of\n # FEEDBACK_REMINDERS_INTERVAL seconds in the future\n self.send_feedback_reminders_after =\n Time.zone.today + FEEDBACK_REMINDERS_INTERVAL\n\n # Increment feedback_reminders_count\n self.feedback_reminders_count += 1\n\n # save the connection\n save\n end",
"def send_sms_reminder\n return true # Disable sms sender\n if phone_number and sms_opt_in?\n _participation_requests = participation_requests.where(date: Date.tomorrow, state: 'accepted')\n return false if _participation_requests.empty?\n\n if _participation_requests.length > 1\n message = I18n.t('sms.users.day_before_reminder.multiple_course',\n nb_courses: _participation_requests.length,\n start_time: I18n.l(_participation_requests.first.start_time, format: :short))\n else\n message = _participation_requests.first.decorate.sms_reminder_message\n end\n\n self.delay.send_sms(message, phone_number)\n end\n end",
"def notify\n ReminderMailer.notify\n end",
"def order_reminders(if_log, recipients, reminders)\n subject = \"[#{ENV['DEPLOY_SITE_NAME']} Material Tracker] Purchase Order Reminders\"\n #@body = {:reminders => reminders}\n @reminders = reminders\n recipients = recipients # [email protected]\n bcc = ALWAYS_SEND_TO_EMAILS\n from = \"no-reply@#{ENV['MAIL_DOMAIN']}\"\n #@headers = {}\n #@content_type = \"text/html\"\n\n if if_log\n RequestMailer.create_event_for(to: recipients, from: @from, subject: subject,\n content: RequestMailer.preview('order_reminders', recipients, reminders))\n end\n mail(from: from,to: recipients,subject: subject,bcc: bcc)\n end",
"def send_lesson_reminder_email\n UserMailer.lesson_reminder(mentor).deliver_now\n end",
"def show_reminder\n mail to: @guest.email, subject: \"Reminder: \"[email protected]+\" house show\"\n end",
"def reminder(user)\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def send_reminder_email(user, expiringtasks)\n @user = user\n @expiringtasks = expiringtasks\n mail( :to => @user.email ,\n :subject => '[Todo Manager] Task Reminder')\n end",
"def schedule_sms_reminder\n @twilio_number = ENV['TWILIO_NUMBER']\n @client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN']\n users = get_sms_list\n users.each do |user|\n reminder = \"DCB Reminder: Don't forget! #{self.title} on #{self.start.to_formatted_s(:long_ordinal)} at #{self.location}\"\n message = @client.account.messages.create(\n :from => @twilio_number,\n :to => user.phone,\n :body => reminder,\n )\n end\n\n end",
"def job_reminder\n UserMailer.job_reminder(User.first, Job.first)\n end",
"def email_reminder(week_id,day)\n # can we use a template?\n puts \"checking #{self.name}\"\n my_result = self.weekly_results.find_by(week_id: week_id) ||\n self.weekly_results.create(week_id: week_id)\n if my_result.send(\"#{day}_drinks\").nil? && !self.unsubscribed\n # generate a token and save to Redis\n puts \"No data for #{self.name} - #{Date.today}. Sending email\"\n my_token = SecureRandom.urlsafe_base64\n packet = {\n user: self.id,\n result: my_result.id,\n parameter: day\n }\n $redis.set(my_token,packet.to_json,{ex: 604800})\n # TODO: fix this bad workaround\n u = self\n # send email\n message = Mail.new do\n from ENV['EMAIL_FROM']\n to \"#{u.name} <#{u.email}>\"\n subject 'BoozeTracker Reminder'\n content_type 'text/html; charset=UTF-8'\n body \"<p>Did you have a drink yesterday?</p><p><a href='#{BASEURL}/token/#{my_token}?result=yes'>Yes</a> | <a href='#{BASEURL}/token/#{my_token}?result=no'>No</a></p><p>--</p><p>Brought to you by <a href='#{BASEURL}'>BoozeTracker</a> | <a href='#{BASEURL}/user/toggle-subscription?token=#{my_token}'>Unsubscribe</a></p>\"\n delivery_method Mail::Postmark, api_token: ENV['POSTMARK_API_TOKEN']\n end\n message.deliver\n\n else\n end\n\n\n end",
"def control_reminder\n UserMailer.control_reminder(User.control.first)\n end",
"def reminder(user)\n @reminder = \"Hallo #{user.name}, je hebt nog niet aangegeven of je aanwezig bent voor de aankomende wedstrijd of training. Doe dit vandaag nog anders wordt je automisch afwezig gemeld. Dit is een automatisch bericht, niet op reageren aub.\"\n\n mail to: user.email, subject: \"Parkstad, doorgeven van je aanwezigheid\", bcc: \"[email protected]\"\n end",
"def send_email_reminder(day)\n recipient = \"#{name} <#{email}>\"\n body = email_body(day)\n message = Mail.new do\n from ENV['EMAIL_FROM']\n to recipient\n subject 'BoozeTracker Reminder'\n content_type 'text/html; charset=UTF-8'\n body body\n delivery_method Mail::Postmark, api_token: ENV['POSTMARK_API_TOKEN']\n end\n message.deliver\n end",
"def turn_reminder(player)\n @player = player\n mail to: \"#{@player.name} <#{@player.notification_email}>\"\n end",
"def send_one_week_reservation_reminder(email)\n @email = email\n mail(to: email, subject: 'Your Pet Boarding Reservation Reminder [RCN]')\n end",
"def event_reminder(reminder)\n @event_start = reminder.event.event_start.to_s(:long)\n mail subject: reminder.event.title,\n bcc: reminder.event.subscribers.collect(&:email)\n end",
"def send_pre_lesson_reminder_email\n UserMailer.lesson_reminder(mentor).deliver_now\n end",
"def send_reminder()\n return MicrosoftGraph::IdentityGovernance::AccessReviews::Definitions::Item::Instances::Item::SendReminder::SendReminderRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def reschedule\n reminders = DB.read_all(:shrk_reminders)\n reminders.each do |reminder|\n begin\n if Time.parse(reminder[:at]) <= Time.now\n send_reminder(\n SHRK.user(reminder[:user]),\n SHRK.channel(reminder[:channel]),\n Time.parse(reminder[:scheduled]),\n reminder[:message],\n )\n DB.delete_value(:shrk_reminders, :job_id, reminder[:job_id])\n else\n schedule_reminder(\n SHRK.user(reminder[:user]),\n SHRK.channel(reminder[:channel]),\n reminder[:at],\n reminder[:message],\n renew: true\n )\n end\n rescue Exception\n # Bot doesn't have the permissions to send a reminder somewhere.\n DB.delete_value(:shrk_reminders, :job_id, reminder[:job_id])\n end\n end\n end",
"def send_auto_reminder?\n self.auto_reminder_days > 0\n end",
"def instructor_reminder_email(class_date)\n @response_email = ResponseEmail.find_by_purpose(\"auto_instructor_reminder\")\n @body = format_instructor_auto_reminder(@response_email.body, class_date)\n mail(:to => class_date.instructors, :subject => @response_email.subject, :reply_to => @response_email.reply_to) unless class_date.instructors.blank?\n end",
"def send_user_reminder_notice(user)\n return if user.email.nil?\n return if user.last_reminder.sent_at < one_week_ago\n EmailSender.send_notice_to(user.email)\nend",
"def prebooking_reminder(service)\n notification = Notification.find_by_name(\"Pre booking reminder\")\n vehicle = service.fleet\n setting = vehicle.truck_fleet.setting.email_notifications.find_by_notification_id(notification.id)\n emails = self.find_emails(vehicle, setting)\n if emails.present?\n mail :to => emails,\n :subject => \"Prebooking reminder. For #{vehicle.fleet_number}\"\n end\n end",
"def send_reminder(guid)\n post \"/api/documents/#{guid}/send_reminders.xml\", {}\n end",
"def send_reminder\n superuser = authorized? @reservation\n \n if @reservation.user != current_user && !superuser\n flash[ :alert ] = \"Reminders can only be sent by their owner, an admin, or an instructor.\"\n elsif @reservation.session.in_past? && !superuser\n flash[ :alert ] = \"Reminders cannot be sent once the session has ended.\" \n else\n @reservation.send_reminder\n flash[ :notice ] = \"A reminder has been sent to #{@reservation.user.name}.\"\n end\n \n if @reservation.user == current_user\n redirect_to reservations_path\n elsif superuser\n redirect_to sessions_reservations_path( @reservation.session )\n else\n redirect_to root_url\n end\n end",
"def regular_reminder_email\n @retailers = Spree::Retailer.active\n \n respond_to do |format|\n format.html { render :template => \"spree/order_mailer/regular_reminder_email.html.erb\", :layout => false }\n end\n end",
"def send_admin_mail\n admins = Admin.all\n\n admins.each do |admin|\n if admin.reminder\n AdminMailer.new_user_waiting_for_approval(admin.email).deliver_now\n end\n end\n end",
"def email_reminder(day)\n return if result(day) || unsubscribed\n send_email_reminder(day)\n end",
"def regular_reminder_email\n @retailers = Spree::Retailer.active\n\n respond_to do |format|\n format.html { render :template => \"spree/order_mailer/regular_reminder_email.html.erb\", :layout => false }\n end\n end",
"def send_reminder_no_activity(options)\n mailer_content = options['mailer_content']\n MemberMailer.send_reminder_no_activity(mailer_content).deliver if mailer_content.present?\n end",
"def send_day_before_reservation_reminder(email)\n @email = email\n mail(to: email, subject: 'Your Pet Boarding Reservation Reminder [RCN]')\n end",
"def reminder_email2(all_payments)\n @all_payments = all_payments\n @url = generate_url(User.find_by_email(@all_payments.first.email))\n #loaner_email = User.find(@all_payments.first.user_id).email\n\n mail(:to => @all_payments.first.email, :subject => \"Reminder that you owe some money\")\n end",
"def schedule_appointment(appointment, which)\n # sendgrid_category \"Sell Request\"\n @appointment = appointment\n if which == 1\n mail to: @appointment.user.email, subject: \"Appointment schedule confirmation\"\n else\n email = \"[email protected]\" if [email protected]\n mail to: email, subject: \"Appointment schedule confirmation\"\n end\n end",
"def survey_reminder(user)\n @user = user\n mail to: user.email, subject: \"Reminder: Complete Post-Lesson Survey\"\n end",
"def reminder\n twilio_number = ENV['TWILIO_NUMBER']\n account_sid = ENV['TWILIO_ACCOUNT_SID']\n client = Twilio::REST::Client.new account_sid, ENV['TWILIO_AUTH_TOKEN']\n time_str = ((self.exact_time).localtime(\"+00:00\")).strftime(\"%I:%M%p on %b. %d, %Y\")\n reminder = \"Hi #{self.name}. TASK ALERT: This is your #{task_category} reminder: #{task_title}. You set your reminder for #{time_str}. To see details, check your profile for more information. \\n -Own Up Grown Up\"\n message = client.api.account.messages.create(\n :from => twilio_number,\n :to => phone_number,\n :body => reminder,\n )\n end",
"def send_notifications\n end",
"def user_welcome_reminder(user,subject,message)\n @from = \"REIMatcher <[email protected]>\"\n @recipients = user.email\n @subject = \"#{subject}\"\n @sent_on = Time.now\n user_activation_link = \"#{REIMATCHER_URL}user_activate/#{user.activation_code}\"\n unless message.blank?\n @body = message.to_s.gsub(\"[User Email]\",user.email.to_s).gsub(\"[User First Name]\",user.first_name.to_s).gsub(\"[User Last Name]\",user.last_name.to_s).gsub(\"[User Login]\",\"<a href='#{user.login.to_s}'>#{user.login.to_s}</a>\").gsub(\"[User Full Name]\",user.first_name.to_s + \" \" + user.last_name.to_s).gsub(\"[User Activation Link]\",\"<a href='#{user_activation_link}'>#{user_activation_link}</a>\")\n else\n @body = \"\"\n end\n @content_type = \"text/html\"\n reminder_welcome_email_header = {:category => EMAIL_CATEGORIES[:ar]}\n @headers[\"X-SMTPAPI\"] = reminder_welcome_email_header.to_json unless reminder_welcome_email_header.blank?\n# @headers[\"X-SMTPAPI\"] = header\n end",
"def reminder\n @headhunter = Headhunter.first.id\n HeadhunterMailer.reminder(@headhunter)\n end",
"def reminder\n @rest_name = self.restaurant.name\n @rest_phone = self.restaurant.phone\n @twilio_number = ENV['TWILIO_NUMBER']\n @client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN']\n time_str = ((self.datetime).localtime).strftime(\"%I:%M%p on %b. %d, %Y\")\n reminder = \"Hi #{self.diner_name}. Don't forget your reservation for #{@rest_name} coming up at #{time_str}! Call to cancel: #{@rest_phone}.\"\n message = @client.account.messages.create(\n :from => @twilio_number,\n :to => self.diner_phone,\n :body => reminder\n )\n end",
"def make_reminder(minutes_before = 510)\n Google::Apis::CalendarV3::EventReminder.new({\n minutes: minutes_before,\n reminder_method: 'popup'\n })\nend",
"def send_pledge_reminder!\n UserMailer.payment_reminder_pledge(user, self).deliver\n end",
"def reminder_sms(email)\n @url = 'http://onebreath.io'\n mail(to: email, subject: '', from: '_onebreath')\n end",
"def send_reminder_for_all(rss_user_id)\n assigned_documents = get_assigned_documents(rss_user_id)\n ids = []\n types = []\n assigned_documents.each do |doc|\n ids << doc['assignmentid']\n types << doc['type']\n end\n reminder_ids = ids.join(',')\n reminder_types = types.join(',')\n send_reminder(rss_user_id, reminder_ids, reminder_types)\n end",
"def reminder_received(event)\n @event = event\n\n mail :to => event.email, :subject => 'Reminder alert'\n end",
"def reminder\n @twilio_number = ENV['TWILIO_NUMBER']\n @client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN']\n time_str = (self.time).strftime(\"%I:%M%p\") #on %b. %d, %Y\n app_id = self.id\n reminder = \"Hi #{self.name}. You shold be waking up soon. If you don't want to be disturbed eliminate the alarm whithin the next 7 minutes. Otherwise I'll really make sure you wake up, trust me.\"\n message = @client.account.messages.create(\n :from => @twilio_number,\n :to => self.phone_number,\n :body => reminder,\n )\n puts message.to\n end",
"def email_students\n date = params[:date][:send_email]\n reminder = params[:date][:reminder]\n #@emails = Survey.pluck(:student_email)\n @surveys = Survey.where.not(student_email: nil)\n\n if date == \"0\"\n delay = 0\n\n elsif date == \"1\"\n delay = Date.tomorrow.noon\n\n elsif date == \"2\"\n delay = 2.days.from_now.noon\n\n else\n delay = 1.week.from_now.noon\n end\n\n @surveys.each do |survey|\n #survey = Survey.find_by(student_email: email)\n section = Section.find_by(class_num: survey.class_num)\n if reminder == \"0\"\n StudentMailer.eval_email(survey, section).deliver_later(wait_until: delay)\n else\n StudentMailer.eval_reminder(survey, section).deliver_later(wait_until: delay)\n end\n\n end\n end",
"def reminder\n ENV['TWILIO_NUMBER'] = '+19803656325'\n ENV['TWILIO_ACCOUNT_SID']= 'AC42b26049da2a7e3556c17a940b75d163'\n ENV['TWILIO_AUTH_TOKEN'] = 'e099f1d5f14b1ddcfcf9376bafb5e3c5'\n \n @twilio_number = ENV['TWILIO_NUMBER']\n @client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN']\n \n #time_str = ((self.interviewdate).localtime).strftime(\"%I:%M%p on %b. %d, %Y\")\n reminder = \"Hi. Just FUCK OFF\"\n \n message = @client.account.messages.create(\n :from => @twilio_number,\n :to => '+17043450672',\n :body => reminder,\n )\n puts message.to\n end",
"def reminder(person, time_slots)\n @person = person\n @time_slot_text = \"#{time_slots.first.day} #{time_slots.first.time.strftime('%l:%M%P')} - #{(time_slots.last.time + 30.minutes).strftime('%l:%M%P')}\"\n\n mail to: @person.email, subject: 'Adoration Reminder'\n end",
"def reminder(attendance_id, type)\n sendgrid_category \"Tea Time Reminder\"\n\n @attendance = Attendance.includes(:tea_time, :user).find(attendance_id)\n @user = @attendance.user\n @type = type\n @tea_time = @attendance.tea_time\n\n mail.attachments['event.ics'] = {\n mime_type: \"text/calendar\",\n content: IcalCreator.new(@tea_time).call.to_ical\n }\n\n cancel_delivery unless @attendance.pending?\n\n mail(to: @user.email,\n from: @tea_time.host.friendly_email(at_tws: true),\n subject: \"Your tea time is coming up!\") do |format|\n format.text\n format.html\n end\n end",
"def reminder(reminder, to)\n setup_reminder(reminder, to)\n hound_addresses = HoundAddressList.new(reminder.fetched_mail)\n\n @to_addresses = reminder.fetched_mail.to - hound_addresses\n @cc_addresses = reminder.fetched_mail.cc - hound_addresses\n\n mail(to: to, subject: \"Re: #{reminder.subject}\",\n in_reply_to: \"<#{reminder.fetched_mail.message_id}>\")\n end",
"def perform(reminder, number)\n \tclient = Twilio::REST::Client.new Rails.application.secrets.twilio_account_sid, Rails.application.secrets.twilio_auth_token\n \tmessage = client.messages.create from: '8326482121', to: 'number', body: 'Hi, This is a reminder to text @reminder.contact regarding @reminder.occasion.'\n \t\n ##Do something later\n end",
"def send_notifications\n return if participant.nil?\n return unless participant.phone_number.length == 10\n\n # grab first 95 characters of description to serve as a preview\n description_preview = description[0...95]\n send_sms(participant.phone_number,\n \"An event in Binder has been assigned to you: #{description_preview}...\")\n end",
"def reminding_exec\n return nil unless @timelog_active\n @log.debug(\"Sending reminder through notify.\")\n Knj::Notify.send(\"time\" => 5, \"msg\" => sprintf(_(\"Tracking task: %s\"), @timelog_active[:descr]))\n end",
"def send_diary_reminder( user_email, user_goal, date = Time.now, token = nil )\n subj = '#whatdidyoudo on ' + Date::DAYNAMES[ date.wday] + \n date.strftime(\" %d \") + \n Date::MONTHNAMES[ Time.now.month ] + user_goal + \" ?\"\n if !token or token.to_s == smtp_settings[:token].to_s\n mail from: smtp_settings[:sender_email], to: user_email, subject: subj\n end\n end",
"def lesson_reminder(user)\n @user = user\n @lesson = user.next_lesson\n @school = @lesson.school.name\n @date = @lesson.date.to_s\n mail to: user.email, subject: \"Reminder: Lesson Scheduled Today\"\n end",
"def pre_lesson_reminder(user)\n @day = day_of_week_string(Date.tomorrow)\n @user = user\n mail to: user.email, subject: \"Reminder: Complete Pre-Lesson Information\"\n end",
"def update_schedule\n role_id = current_user.role_id\n schedule = Schedule.get_schedule_array\n create_schedule = Schedule.get_create_schedule_array\n delete_schedule = Schedule.get_delete_schedule_array\n if Schedule.send_email(role_id,schedule,create_schedule,delete_schedule)\n flash[:success] = \"Users Notified!\"\n redirect_to root_path\n else\n flash[:error] = \"Some error occured! Please try again!\"\n redirect_to (:back)\n end\n end",
"def send_self_eval_reminders\n users = User.all.select{|u| u.has_current_registration && u.current_registration.participant && !u.current_registration.has_complete_eval}\n @sent = []\n users.each do |u| \n if u.bounced_at \n Rails.logger.error(\"Found bounced email #{u.email} in sending self eval_reminder\")\n else\n begin\n RegistrationMailer.self_eval_reminder(u)\n puts(\"Succeed on #{u.email}\")\n @sent << u.email\n rescue => e\n puts(\"Failed on #{u.email}\")\n Rails.logger.error(\"Send eval throws #{e}, skipping #{u.email}\")\n end\n end\n end\n end",
"def fund_reminder(user_id)\n @user = User.find_by_id(user_id)\n mail :to => recipient(@user.email), :subject => t('user_mailer.fund_reminder.subject')\n end",
"def create\n SellersMailer.delay.apply_reminder(current_user.id)\n\n # Delay slightly to make it seem like it wasn't automatic ;)\n SellersMailer.delay_for(rand(5.minutes..15.minutes)).apply(current_user.id)\n \n render json: {}, status: 200\n end",
"def event_mail\n NoticePlannerMailer.delay.notice_planner_email('[email protected]', 'test', 'cron-test', 'https://yahoo.co.jp')\n end",
"def send_email_changed_notification; end",
"def reminder_email(payment)\n @payment = payment\n @url = generate_url(User.find_by_email(@payment.email))\n #loaner_email = User.find(@payment.user_id).email\n\n mail(:to => @payment.email, :subject => \"Reminder that you owe some money\")\n end",
"def reschedule_schedule_email\n begin\n \n id = \"I_dtFt2ZNPW5QD9-FaDU1A\"\n send_at = \"2020-06-01 08:15:01\"\n result = @mandrill.messages.reschedule id, send_at\n # {\"subject\"=>\"This is a scheduled email\",\n # \"created_at\"=>\"2013-01-20 12:13:01\",\n # \"_id\"=>\"I_dtFt2ZNPW5QD9-FaDU1A\",\n # \"to\"=>\"[email protected]\",\n # \"from_email\"=>\"[email protected]\",\n # \"send_at\"=>\"2021-01-05 12:42:01\"}\n\n rescue Mandrill::Error => e\n # Mandrill errors are thrown as exceptions\n puts \"A mandrill error occurred: #{e.class} - #{e.message}\"\n # A mandrill error occurred: Mandrill::UnknownMessageError - No message exists with the id 'McyuzyCS5M3bubeGPP-XVA'\n raise\n end\n\n end",
"def send_booking_reminder(user, booking)\n @user = user\n @booking = booking\n\n mail( :to => @user.email,\n :subject => \"You have an upcoming booking in 24 hours\" )\n end",
"def task_schedule\n user = User.find(2)\n name = user.name\n tasks = user.tasks.where(scheduled_date: Date.today).where.not(status: 2).where(send_mail: true)\n UserMailer.task_schedule(user, name, tasks)\n end",
"def send_notification\n\n\n end",
"def notification(params)\n mail(params)\n end",
"def set_reminder\n @reminder = Reminder.only_from_user(current_user).find(params[:id])\n end",
"def send_job_reminder(job)\n UserMailer.job_reminder(self, job).deliver_now\n end",
"def sendQuestionnaire\n email=params[:email]\n emails=email.split(\",\")\n description=params[:description]\n questionnaire_id = params[:questionnaire_id]\n emails.each do |one|\n ReviewerInviter.task_invitation(one, description, \"http://localhost:3000/questionnaires/answer_show?id=\"+questionnaire_id).deliver()\n end\n respond_to do |format|\n format.html { redirect_to(:back) } #, flash[:success] = \"holder updated\") \n end\n end",
"def send_invoice_reminder(project)\n MemberMailer.invoice_reminder_for_project_admin(self, project).deliver_now\n end",
"def message\n \"You have a new reminder!\"\n end",
"def event_reminder_to_chef(evt)\n @evt = evt\n @chef = User.find_by_id(@evt.user_id)\n @guests = @evt.signups.where('confirmation_status in (?)', 'Attending')\n @comments = @evt.messages.where(\"public_flag = ?\", 1).group(\"messagechain_id\", \"order_id\", \"message_content\", \"sender_id\").sort{|a,b| b[:messagechain_id] <=> a[:messagechain_id]}\n if @guests.sum(:guest_count) > 0\n @paid_communal = @guests.where(\"own_group_flag = 0\")\n @own_table = @guests.where(\"own_group_flag = 1\")\n mail(:to => @chef.email, :subject => \"Your upcoming event on Local Yum\", :from => \"\\\"Local Yum\\\" <[email protected]>\")\n end\n end",
"def send_email_changed_notification?; end",
"def appointment\n ReminderMailer.appointment\n end",
"def notify_of_redemption(user, redemption)\n @user = user\n @admin = redemption.reward.manager_with_default\n @reward = redemption.reward\n @redemption = redemption\n @mail_styler = company_styler(user.company)\n I18n.with_locale(user.locale) do\n mail(to: @user.email, subject: t(\"rewards.your_redemption_is_pending\", title: redemption.reward.title), track_opens: true)\n end\n end",
"def set_reminder\n @reminder = Reminder.find(params[:id])\n end",
"def set_reminder\n @reminder = Reminder.find(params[:id])\n end",
"def extend()\n # Get the appointment\n appointment = current_user.appointments.last\n student_id = current_user.id\n tutor_id = appointment.tutor.id\n # Get the sidekiq job\n jids = appointment.jids.split('|')\n jid_reminder = jids[0]\n jid_complete = jids[1]\n job_reminder = Sidekiq::ScheduledSet.new.find_job(jid_reminder)\n job_complete = Sidekiq::ScheduledSet.new.find_job(jid_complete)\n complete_new_time = job_complete.at + Settings.call_extend_time\n reminder_new_time = complete_new_time - Settings.call_speak_reminder_time\n\n if job_complete.reschedule(complete_new_time) &&\n job_reminder.reschedule(reminder_new_time)\n # update the appointment cost and call time\n appointment.update_attribute(:amount, appointment.amount + Settings.call_extend_cost)\n appointment.update_attribute(:tutor_earned, appointment.tutor_earned + Settings.call_extend_earned)\n # notify the student and the tutor\n msg = I18n.t('appointment.conference_room.call_extend', \n time: Settings.call_extend_time)\n MessageBroadcastJob.perform_later(msg, 'notification',\n student_id: student_id,\n tutor_id: tutor_id)\n else\n msg = I18n.t('students.errors.appointment.call_extend')\n MessageBroadcastJob.perform_later(msg, 'notification',\n student_id: student_id)\n end\n end",
"def grad_reminder\n UserMailer.grad_reminder(User.grad.first)\n end",
"def setup_reminder(reminder, to)\n @reminder = reminder\n @original_subject = reminder.subject || \"<No subject>\"\n @body = reminder.body.html_safe\n @created_at = reminder.created_at.strftime('%d-%b')\n @snoozed = reminder.snooze_count\n @visibility = @reminder.other_recipients.empty? ? 'private' : 'shared'\n end",
"def send_three_week_reservation_reminder(email)\n @email = email\n mail(to: email, subject: 'Your Pet Boarding Reservation Reminder [RCN]')\n end",
"def broadcast_to_channel\n if Setting.first.reminders_enabled\n ActionCable.server.broadcast 'notification_channel', notification: self.to_serialize\n end\n end",
"def set_email_reminder\n @email_reminder = EmailReminder.find(params[:id])\n end"
] | [
"0.82073325",
"0.80129164",
"0.77377504",
"0.7703594",
"0.7659824",
"0.7638564",
"0.754223",
"0.7479497",
"0.74484354",
"0.7372904",
"0.73094285",
"0.728429",
"0.72125155",
"0.7143733",
"0.71231854",
"0.7121898",
"0.7109078",
"0.7100921",
"0.70985067",
"0.7089291",
"0.70757544",
"0.7074611",
"0.70690745",
"0.706845",
"0.70528555",
"0.70276123",
"0.70136094",
"0.70070016",
"0.6996668",
"0.6975405",
"0.69602627",
"0.69576323",
"0.6953833",
"0.6945721",
"0.6940606",
"0.6904699",
"0.69006896",
"0.6897582",
"0.68737924",
"0.68625396",
"0.6858284",
"0.6856336",
"0.6841455",
"0.68163556",
"0.68035537",
"0.6803218",
"0.6740751",
"0.67324746",
"0.67162573",
"0.66983145",
"0.6693561",
"0.66900223",
"0.66845506",
"0.6672888",
"0.6663364",
"0.6662996",
"0.66542906",
"0.66508865",
"0.66453475",
"0.6642754",
"0.6640956",
"0.6629517",
"0.66189426",
"0.66117865",
"0.66030383",
"0.65773225",
"0.6574192",
"0.65693223",
"0.6567144",
"0.65488654",
"0.65474343",
"0.64907676",
"0.64906836",
"0.64824325",
"0.64642394",
"0.6460289",
"0.6422191",
"0.6414797",
"0.64125615",
"0.64091206",
"0.64082336",
"0.6399088",
"0.63934696",
"0.638823",
"0.63830334",
"0.6375047",
"0.6371801",
"0.63683707",
"0.6360178",
"0.6335216",
"0.63347584",
"0.6318145",
"0.6305502",
"0.6295499",
"0.6295499",
"0.6292679",
"0.6281692",
"0.6276908",
"0.6274047",
"0.62638956",
"0.62630206"
] | 0.0 | -1 |
to modify board size would initialize board with a diff size | def initialize
@squares = (0..8).to_a
@free_squares = squares.dup
@dimension = Math.sqrt(@squares.length).to_i
@indeces = (squares.dup)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_board(size)\n board = []\n board_rows = []\n size.times {|i| board_rows << i}\n size.times {board << board_rows}\n @board = board\n end",
"def initialize(size)\n @board_size = size\n @board = []\n @board_size.times { @board << Array.new(@board_size, EMPTY_SYMBOL) }\n end",
"def initialize(size)\n @board = Array.new(size[0])\n @board.each_index do |i|\n @board[i] = Array.new(size[1])\n end\n end",
"def board_size\n\t\[email protected]\n\tend",
"def initialize(size)\n @board = Array.new(size) {Array.new(size){ '*' } }\n end",
"def initializeBoard()\n\t\tfor i in ([email protected])\n\t\t\tfor j in ([email protected])\n\t\t\t\t@board[i][j] = EMPTY\n\t\t\tend\n\t\tend\n\n\t\t@board[@size/2][@size/2] = BLACK\n\t\t@board[@size/2 - 1][@size/2 - 1] = BLACK\n\t\t@board[@size/2 - 1][@size/2] = WHITE\n\t\t@board[@size/2][@size/2 - 1] = WHITE\n\n end",
"def initializeBoard()\n #\n # TO DO: complete this method\n #\n for j in 0...@size\n for i in 0...@size\n @board[j][i]=EMPTY\n end\n end\n center = (@size/2)-1\n @board[center][center] = BLACK\n @board[center+1][center+1] = BLACK\n @board[center+1][center] = WHITE\n @board[center][center+1] = WHITE\n\n\n\n\n end",
"def initializeBoard()\n\n # TO DO: COMPLETE THIS METHOD\n maxMid = @size / 2\n minMid = @size / 2 - 1\n for i in 0..size-1\n for j in 0..size-1\n if i == maxMid && j == maxMid\n @board[i][j] = \"B\"\n elsif i == minMid && j == minMid\n @board[i][j] = \"B\"\n elsif (i == minMid || i == maxMid) && (j == maxMid || j == minMid)\n @board[i][j] = \"W\"\n else\n @board[i][j] = \"-\";\n end\n end\n end\n end",
"def create_board(size)\n return (0...size).map{|b| (0...size).map{|bb| 0}}\n end",
"def initialize_board\n board = Array.new(8) {Array.new(8)}\n populate_board(board)\n end",
"def populate_board\n rows_of_pieces = (size - 2) / 2\n make_pieces([0, 1], 'red', rows_of_pieces, 1)\n make_pieces([size - 1, 0], 'black', rows_of_pieces, -1)\n end",
"def setup_board!\n\t\t@board = Array.new($dimensions[:y]){ Array.new($dimensions[:x]) {:empty} }\n\tend",
"def initialize\n @board = (0...8).map { [nil] * 8 }\n populate_board\n\n\tend",
"def initialize(row_size=3)\n @row_size = row_size\n @board = Array.new(@row_size) {Array.new(@row_size, 0)}\n end",
"def size \n\n\t\t# Set the basic metrics\n\t\tcase @board_size\n\t\twhen :small \t\t\t\t# A 20x20 grid\n\t\t\t@width = 30\n\t\t\t@height = 20\n\t\t\t@dragon_count = 50 * @board_level\n\t\t\t@cell_size = 30\n\t\t\t@cover_png = 'sprites/cover_30.png'\n\t\t\t@dragon_png = 'sprites/dragon_30.png'\n\t\t\t@gold_png = 'sprites/gold_30.png'\n\t\t\t@cell_png = [ 'sprites/cell0_30.png', 'sprites/cell1_30.png', 'sprites/cell2_30.png', \n\t\t\t\t\t\t 'sprites/cell3_30.png', 'sprites/cell4_30.png', 'sprites/cell5_30.png',\n\t\t\t\t\t\t 'sprites/cell6_30.png', 'sprites/cell7_30.png', 'sprites/cell8_30.png' ]\n\t\tend\n\n\t\t# Clear and resize the board array\n\t\t@spawned = false\n\t\t@victorious = false\n\t\t@burniation = -1\n\t\t@burn_size = 1\n\t\t@dragons = Array.new( @width * @height, 0 )\n\t\t@cell_status = Array.new( @width * @height, :status_covered )\n\n\t\t# Decide how big the stuff on the right hand side should be\n\t\t@label_size = -2.5\n\t\t@size_restart = $gtk.calcstringbox( \"Restart\", @label_size )\n\t\t@size_dragon = $gtk.calcstringbox( \"888 Dragons To Find\", @label_size )\n\t\t@size_time = $gtk.calcstringbox( \"88:88:88\", @label_size )\n\n\t\twhile [ @size_restart.x, @size_dragon.x, @size_time.x ].max < ( $gtk.args.grid.w - ( ( @width + 6 ) * @cell_size ) )\n\n\t\t\t# Try some slightly bigger sizes then\n\t\t\t@size_restart = $gtk.calcstringbox( \"Restart\", @label_size+0.1 )\n\t\t\t@size_dragon = $gtk.calcstringbox( \"888 Dragons To Find\", @label_size+0.1 )\n\t\t\t@size_time = $gtk.calcstringbox( \"88:88:88\", @label_size+0.1 )\n\n\t\t\t# And nudge up the label size\n\t\t\t@label_size += 0.1\n\t\tend \n\n\t\t@label_size -= 0.1\n\t\t@size_restart = $gtk.calcstringbox( \"Restart\", @label_size )\n\t\t@size_dragon = $gtk.calcstringbox( \"888 Dragons To Find\", @label_size )\n\t\t@size_time = $gtk.calcstringbox( \"88:88:88\", @label_size )\n\t\t\n\t\t# Lastly, work out some sensible offsets\n\t\t@board_w = @width * @cell_size\n\t\t@board_h = @height * @cell_size\n\t\t@board_x = 2 * @cell_size \n\t\t@board_y = $gtk.args.grid.center_y - ( @board_h / 2 )\n\n\t\t@label_x = @board_x + @board_w + ( 2 * @cell_size )\n\t\t@label_time_y = $gtk.args.grid.center_y + ( @size_time.y + 20 ) * 1.5\n\t\t@label_dragon_y = @label_time_y - 20 - @size_dragon.y - 20\n\t\t@label_restart_y = @label_dragon_y - 20 - @size_restart.y - 20\n\n\t\t@label_width = [ @size_restart.x, @size_dragon.x, @size_time.x ].max + 20\n\n\tend",
"def init_board(size=5, handicap=0)\n @game = GameLogic.new\n @game.new_game(size, handicap)\n @goban = @game.goban\n @grid = Grid.new(size)\n @filler = ZoneFiller.new(@goban, @grid)\n end",
"def create_board\n cols = Array.new(7) { Array.new(6, 0) }\n cols\n end",
"def initialize \n @rows = 8\n @columns = 8\n @grid = create_board\n end",
"def create_board(size, num_mines)\n\t\tfinal_board = []\n\t\t# Create outer loop\n\t\t1.upto(size) do |row|\n\t\t\trow_buffer = []\n\t\t\t# Create inner loop\n\t\t\t1.upto(size) do |column|\n\t\t\t\trow_buffer << Square.new([column,((size+1)-row)], size)\n\t\t\tend\n\t\t\t# Once each row is composed add it to \n\t\t\t# the final board.\n\t\t\tfinal_board << row_buffer\n\t\tend\n\t\tset_mines(final_board, num_mines) # Now that we have the board, lets add some mines\n\t\tfinal_board\n\tend",
"def create_board\n\t\t8.times{|x| @board.push([nil,nil,nil,nil,nil,nil,nil,nil])}\n\t\tpopulate_board\n\tend",
"def initialize_board\n b = []\n 9.times { b << ' ' } \n b\nend",
"def generate_board\n [0, 1, 2].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :B) if offset.odd?\n end\n end\n\n [5, 6, 7].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :W) if offset.odd?\n end\n end\n end",
"def initialize\n @board = Array.new(3) { Array.new(3) }\n end",
"def initialize\n @board = Array.new(3) { Array.new(3) }\n end",
"def initBoard\n cellNum = 0\n while cellNum < (@columns * @rows)\n @board.push(rand < @genWeighting ? 1 : 0)\n cellNum += 1\n end\n @board\n end",
"def initialize(grid_size)\n @grid_size = grid_size\n @cell_ct = (grid_size * 2) + 1\n @board = Array.new(cell_ct){Array.new(cell_ct)}\n\n populate_board_guide(board)\n end",
"def size=(dimension); end",
"def build_grid size\n self.tiles.clear\n size.to_i.times do |row|\n size.to_i.times do |column|\n self.tiles.build({\n x: column,\n y: row\n })\n end\n end\n end",
"def create_board\n\n 8.times do |row|\n 8.times do |col|\n new_cell = Cell.new([col + 1, row + 1])\n @@cells.push(new_cell)\n end\n end\n\n end",
"def setup\n (1..12).each do |num|\n @board[num] = %W[_ _ _ _]\n end\n end",
"def init_board(n, def_val)\n\t\tArray.new(n) { Array.new(n) { def_val } }\n\tend",
"def build_square size\n #starting positions\n x,y = size/2,0\n\n # build square\n (1..size**2).inject(Array.new(size){[]}) do |arr,i|\n\n # store current number in square\n arr[y][x] = i\n\n # move up and left\n x = (x+1)%size\n y = (y-1)%size\n\n # undo move and move down if space is taken\n if arr[y][x]\n y = (y+2)%size\n x = (x-1)%size\n end\n arr\n end\n end",
"def initialize_board\n init_board = \"-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1\"\n if self.update(board: init_board)\n return [[ 0,-1,0,-1,0,-1, 0,-1 ],[-1,0,-1,0,-1,0,-1,0],[0,-1,0,-1,0,-1,0,-1],\n [0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],\n [1,0,1,0,1,0,1,0],[0,1,0,1,0,1,0,1],[1,0,1,0,1,0,1,0]]\n end\n end",
"def initialize\n @@BOARD_SIZE = 8\n @board = create_board\n @god_mode = false\n end",
"def reset\n\t\t@board = Array.new(3) {Array.new(3,\" \")}\n\tend",
"def initialize(size)\n @board_size = size\n @matched_cards = {}\n @known_cards = {} \n @previous_guess = nil\n end",
"def tile_board\n @board_array.each_with_index do |row_array, row|\n 10.times{|column| row_array << Tile.new(row,column)}\n end\n end",
"def build_board(board_length, board_height)\n (board_height).times do\n row = []\n (board_length).times do\n row << \" \"\n end\n @board << row\n end\n end",
"def create_board\n (1..(@width * @width).to_i).each do |i|\n values = i <= @amount_mines ? @bomb : @empty\n @board.push({\n value: values,\n revealed?: false\n })\n end\n @board.shuffle!\n @board\n end",
"def initialize(setup = true)\n @board = Array.new(8) {Array.new(8)}\n setup_board if setup\n end",
"def initialize\n @board_array = [[],[],[],[],[],[],[],[],[],[]]\n # tile_board\n # set_mines\n end",
"def test_it_has_the_correct_number_of_cells\n assert_equal 16, @board.cells.length\n end",
"def initialize(boardSize)\n\t\t\t@moves = Array.new\n\t\t\t@size = boardSize\n\t\tend",
"def initialize\n\t\t@board = []\n\t\t3.times do |i|\n\t\t\t@board[i] = []\n\t\t\t3.times do\n\t\t\t\t@board[i] << 0\n\t\t\tend\n\t\tend\n\tend",
"def populate_board(board)\n #Fills in the top and bottom rows\n [0, 7].each do |row|\n 4.times do |col|\n board[row][col] = create_piece(row, col)\n board[row][(7-col)] = create_piece(row, (7-col))\n end\n end\n\n #Fills in the pawns\n 8.times do |col|\n board[1][col] = BlackPawn.new(1, col)\n board[6][col] = WhitePawn.new(6, col)\n end\n\n board\n end",
"def make_board\n board = Array.new(8) { Array.new(8) { Array.new(2) } }\n board.each_with_index do |row, row_i|\n row.each_with_index { |column, column_i| column[0], column[1] = row_i, column_i }\n end\n end",
"def newBoard\n\t\t\t[['r', 'n', 'b', 'k', 'q', 'b', 'n', 'r'],\n\t\t\t ['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p'],\n\t\t\t ['', '', '', '', '', '', '', ''],\n\t\t\t ['', '', '', '', '', '', '', ''],\n\t\t\t ['', '', '', '', '', '', '', ''],\n\t\t\t ['', '', '', '', '', '', '', ''],\n\t\t\t ['P', 'P', 'P', 'P', 'P', 'P', 'P', 'P'],\n\t\t\t ['R', 'N', 'B', 'K', 'Q', 'B', 'N', 'R']]\n\tend",
"def initialize(size=10, max_height=5)\n if !size.positive?\n raise ArgumentError, \"Board size must be greater than zero!\"\n else\n @size = size\n @max_height = max_height\n @min_word_length = 2\n @grid = Hash.new do |h, (row, col)|\n if row < 0 || col < 0 || num_rows <= row || num_columns <= col\n raise IllegalMove, \"#{row}, #{col} is out of bounds!\"\n else\n h[[row, col]] = [] # Initialize with empty array\n end\n end\n end\n end",
"def fill_board\n MAXY.times do |t|\n @board << Array.new(MAXX, 0) if @board[t].nil?\n end\n\n @board.map! do |row|\n row << [0] * (MAXX - row.size)\n row.flatten\n end\n end",
"def initialize_board\r\n board = {}\r\n (1..9).each {|position| board[position] = ' '}\r\n board\r\nend",
"def new_board\n board = []\n 8.times do |row|\n board << case row\n when 0\n add_back_row(\"white\", row)\n when 1\n add_pawn_row(\"white\", row)\n when 6\n add_pawn_row(\"black\", row)\n when 7\n add_back_row(\"black\", row)\n else\n Array.new(8)\n end\n end \n board\n end",
"def map_board\n\t\t@cell_at = []\n\t\[email protected] do |row|\n\t\t\t@cell_at[row] = []\n\t\t\[email protected] do |col|\n\t\t\t\t@cell_at[row][col] = Cell.new\n\t\t\tend\n\t\tend\n\tend",
"def build_board\n @original_board\n @working_board.collect! { |row|\n row.collect! { |cell|\n cell = @original_board.shift\n }\n }\n @working_board\n end",
"def piece_size=(v)\n return unless v\n @piece_count = nil\n @piece_size = [v, 1024].max\n end",
"def setup_board\n @startup = true\n @board = @board.map{|col| col.map{|piece| Piece.new if piece.nil?}}\n clear_matches\n @startup = false\n @pieces_removed = 0\n end",
"def create_board\n\t\t@board = Hash.new\n\t\t(0..7).each do |x|\n\t\t\t@board[x] = []\n\t\t\t(0..7).each do |y|\n\t\t\t\t@board[x][y] = Square.new([x, y])\n\t\t\tend\n\t\tend\n\tend",
"def setup_board\n gameboard.build_board\n build_white_side\n build_black_side\n end",
"def initialize(args={})\n @size = args[:size] || 10\n @seed = args[:seed] || 20\n raise ArgumentError, \"seed is larger than board size (size**2)\" if size**2 < seed\n @born = 0\n @died = 0\n @prospered = 0\n\n @board = Table.new(rows: size, cols: size, obj: Cell)\n #seed_board\n end",
"def initialize\r\n @board = Array.new(9, \" \") \r\n end",
"def init_board\n @board =\n if board_state.present?\n Board.new(width: rows, height: cols, mines_count: mines).tap do |b|\n b.load_state!(board_state)\n end\n else\n Board.new(width: rows, height: cols, mines_count: mines).tap do |b|\n b.setup!\n end\n end\n end",
"def populate_board\n #the six rows get updated\n players.each do |player|\n rows = player == players[0] ? [ 0,1,2 ] : [ 5,6,7 ]\n piece_count = 0\n col = 0\n\n player.pieces.each do |piece|\n\n rows.shift if piece_count % 4 == 0 and piece_count != 0\n\n col_start = rows[0] % 2 == 1 ? 0 : 1\n col = 0 if (col_start == 0 || col_start == 1) && piece_count % 4 == 0\n\n piece.position = [col + col_start, rows[0]]\n squares[[col + col_start, rows[0]]] = piece\n\n col += 2\n piece_count += 1\n\n end\n\n end\n\n end",
"def initialize\n\t\t@board=Hash.new \n\t\t(0..6).each{ |i|\n\t\t\t(0..6).each{ |j|\n\t\t\t\t@board[[i,j]]=Cell.new(0,0,\"\")\n\t\t\t}\n\t\t}\n\t\t#==== intitial cells\n\t\t@board[[1,1]].value=2\n\t\t@board[[2,3]].value=4\n\t\t@move_result=0\n\tend",
"def initialize_board\n board = {}\n (1..9).each { |position| board[position] = ' ' }\n board\nend",
"def new_board\n @board = {'a1'=>' ','a2'=>' ','a3'=>' ','b1'=>' ','b2'=>' ','b3'=>' ','c1'=>' ','c2'=>' ','c3'=>' '}\n end",
"def initialize\n @board = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n end",
"def initialize\n @board=Array.new(9) {Array.new(9, false)}\n self.populate_mines\n self.fill_up_board_with_tiles\n @game_over = false\n end",
"def initialize_board\n board = {}\n (1..9).each {|position| board[position] = ' ' }\n board\nend",
"def new_board\n (\"1\"..\"7\").to_a.each_with_object({}) do |key, hash|\n hash[key] = Array.new(6) { |i| (i + 1).to_s }\n end\n end",
"def real_piece_size\n piece_size + connector_size\n end",
"def populate_board\n\t\t8.times{|x|\t@board[x][6] = Pawn.new([x, 6], \"black\", @board)}\n\t\t@board[0][7] = Rook.new([0, 7], \"black\", @board)\t\n\t\t@board[1][7] = Knight.new([1, 7], \"black\", @board)\n\t\t@board[2][7] = Bishop.new([2, 7], \"black\", @board)\n\t\t@board[3][7] = Queen.new([3, 7], \"black\", @board)\n\t\t@board[4][7] = King.new([4, 7], \"black\", @board)\t\t\n\t\t@board[5][7] = Bishop.new([5, 7], \"black\", @board)\n\t\t@board[6][7] = Knight.new([6, 7], \"black\", @board)\n\t\t@board[7][7] = Rook.new([7, 7], \"black\", @board)\n\t\t\t\t\n\t\t 8.times{|x|\t@board[x][1] = Pawn.new([x, 1], \"white\", @board)}\n\t\t@board[0][0] = Rook.new([0, 0], \"white\", @board)\t\n\t\t@board[1][0] = Knight.new([1, 0], \"white\", @board)\n\t\t@board[2][0] = Bishop.new([2, 0], \"white\", @board)\n\t\t@board[3][0] = Queen.new([3, 0], \"white\", @board)\n\t\t@board[4][0] = King.new([4, 0], \"white\", @board)\t\t\n\t\t@board[5][0] = Bishop.new([5, 0], \"white\", @board)\n\t\t@board[6][0] = Knight.new([6, 0], \"white\", @board)\n\t\t@board[7][0] = Rook.new([7, 0], \"white\", @board)\n\tend",
"def board_generator\r\n y = Array.new(8)\r\n y.each_index {|i| y[i] = Array.new(8)}\r\n end",
"def initialize(fill_board = true)\n @grid = Array.new(8) { Array.new(8) }\n\n setup_grid if fill_board\n end",
"def create_empty_board(position)\n 9.times { |i| position[i] = \" \"}\nend",
"def place_ship(size)\n span = free_squares.select { |span| span.count >= size }.sample\n raise \"We're getting crowded here\" unless span\n offset = rand(0..span.count - size)\n @ship_squares << span.slice(offset, size)\n @ship_squares.last.each { |cell| cell.ship = size }\n end",
"def resize!\n @arr.size *=2\n end",
"def initialize\n\n\t\t# Set up some default values here; things like the size of board,\n\t\t# level of complexity and suchlike.\n\t\t@board_size = :small\n\t\t@board_level = 1\n\t\tsize \n\t\trender_board\n\n\tend",
"def setup(size, random, best_of3)\n @size = size\n\n if best_of3 && @board_player1 && @board_player2\n @board_player1 = Board.new(size, @board_player1.player)\n @board_player2 = Board.new(size, @board_player2.player)\n else\n @board_player1 = Board.new(size, Player.new(\"abrahan\"))\n @board_player2 = Board.new(size, Player.new(\"bot\"))\n end\n\n @boards = [@board_player1, @board_player2]\n @players = @boards.map(&:player)\n @random = random\n @board_turn = random ? @boards.sample : @boards.first\n end",
"def main_setter(board, score, gameover)\n @board = board\n @size = 4\n @score = score\n @gameover = gameover\n end",
"def initialize board = nil, turn = \"x\"\n\t\t@dim = 3\n\t\t@size = @dim * @dim \n\t\t@board = board || Array.new(@size, \"-\")\n\t\t@turn = turn\n\t\t@movelist = []\n\tend",
"def initialize\n\t\t\t@empty_cell = '_'\n\t\t\t@board = Array.new(3) {Array.new(3,@empty_cell)}\n\t\tend",
"def initialize\n @board = Array.new(8) { Array.new(8) }\n @all_pieces = []\n @board_history = []\n @move_record = []\n end",
"def initialize\n # The board is an array of rows, each containing an array of cells\n @board = Array.new(BOARD_HEIGHT){Array.new(BOARD_WIDTH)}\n @board.each_with_index do |y, yi|\n y.each_with_index do |x, xi|\n @board[yi][xi] = \".\"\n end\n end\n end",
"def initialize()\n grid = BOARD_NUMBERS.map{ |x| BOARD_ALPHABET.map{ |y| y + x}}.flatten\n @board = Hash[grid.collect { |k| [k, EMPTY]} ]\n end",
"def set_playground_size(size)\n @playground.size = size\n end",
"def create\n (0..7).each do |row|\n @board << []\n (0..7).each do |col| \n @board[row] << \"[ ]\"\n end\n end\n end",
"def board_setup\n\t\tinitial_position = [\"rook\", \"knight\", \"bishop\", \"queen\", \"king\", \"bishop\", \"knight\", \"rook\"]\n\t\tspecial_position = [8,1]\n\t\tpawn_position = [7,2]\n\t\tinitial_color = [\"black\",\"white\"]\n\t\ti = 0\n\t\tx = 0\n\t\t#loops through ranks 8 and 1 setting each class piece in his corresponding position.\n\t\tspecial_position.each do |num|\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\t@board[letter+num.to_s].name = initial_position[i]\n\t\t\t\t@board[letter+num.to_s].color = initial_color[x]\n\t\t\t\ti += 1\n\t\t\tend\n\t\t\ti = 0\n\t\t\tx += 1\n\t\tend\n\n\t\ty = 0\n\t\t#loos through ranks 7 and 2 setting the pawn's pieces in his corresponding position.\n\t\tpawn_position.each do |num|\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\t@board[letter+num.to_s].name = \"pawn\"\n\t\t\t\t@board[letter+num.to_s].color = initial_color[y]\n\t\t\tend\n\t\t\ty += 1\n\t\tend\n\tend",
"def starting_board\n init_rows([0, 2], :black)\n init_rows([5, 7], :red)\n end",
"def initialize(pop = true)\n @board = Array.new(8) { Array.new(8) }\n populate_board if pop\n end",
"def initialize_board\n b = {}\n (1..9).each {|position| b[position] = ' '}\n b\nend",
"def initialize_board\n b = {}\n (1..9).each {|position| b[position] = ' '}\n b\nend",
"def initialize(fill_board = true)\n @sentinel = Null_piece.instance\n\n @rows = Array.new(8) { Array.new(8, @sentinel) }\n\n fill_board_tiles if fill_board\n end",
"def initialize size\n raise \"Size must be odd\" unless size%2 == 1\n @size = size\n @square = build_square size\n self\n end",
"def start_board\n @board = []\n @board.push(\"|-------\")\n 5.times do\n @board.push(\"|\")\n end\nend",
"def fill_board\n\t\tfill_row_pieces(0, 'b')\n\t\tfill_row_pawn(1, 'b')\n\t\tfill_row_pieces(7, 'w')\n\t\tfill_row_pawn(6, 'w')\n\tend",
"def initialize\n super\n self.board = Array.new(3).map{[nil, nil, nil]}\n end",
"def initialize\n @piece_count = 0\n\n @grid = []\n (0..6).each do |col|\n @grid[col] = []\n (0..5).each do |row|\n @grid[col][row] = \"-\"\n end\n end\n end",
"def initialize(initial_board=nil)\n\t\t@size = initial_board && initial_board.length || 10\n\t\t@initial_board = initial_board # used when existing patterns are passed\n\t\t@cells = []\n\t\t\n\t\tif @initial_board\n\t\t\[email protected] do |x|\n\t\t\t\[email protected]([])\n\t\t\t\[email protected] do |y|\n\t\t\t\t\t@cells[x].push(Cell.new(self, x, y, @initial_board[x][y]))\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\[email protected] do |x|\n\t\t\t\[email protected]([])\n\t\t\t\[email protected] do |y|\n\t\t\t\t\t@cells[x].push(Cell.new(self, x, y))\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\tend",
"def initialize_board\n b = {}\n (1..9).each { |position| b[position] = ' ' }\n b\nend",
"def generate_board\n board_array = @board_string.split(\"\")\n @board = Array.new(9){board_array.shift(9)}\n for row in [email protected]\n for col in [email protected]\n @board[row][col] = Square.new(@board[row][col], row, col)\n end\n end\n create_starting_numbers\n @board\n end",
"def initialize_board\n b = {}\n (1..9).each {|pos| b[pos] = ' '}\n b\nend",
"def initialize(size)\n @grid = Array.new(size) {Array.new(size, :N)}\n @size = size * size\n end"
] | [
"0.76676244",
"0.73507553",
"0.72536045",
"0.72424364",
"0.72154063",
"0.72072756",
"0.7175099",
"0.7023512",
"0.70039284",
"0.70019114",
"0.69003695",
"0.6768323",
"0.67066026",
"0.6691676",
"0.6662086",
"0.6657223",
"0.6603936",
"0.6597341",
"0.65850925",
"0.6553482",
"0.6548177",
"0.65054184",
"0.6450801",
"0.6450801",
"0.64487386",
"0.6443185",
"0.64116853",
"0.64063334",
"0.6374254",
"0.6347039",
"0.6344342",
"0.6344287",
"0.63297665",
"0.6327353",
"0.6321299",
"0.6313443",
"0.6308427",
"0.63065976",
"0.62965685",
"0.6288732",
"0.627219",
"0.6264341",
"0.6260029",
"0.62287176",
"0.6226597",
"0.6223381",
"0.62076956",
"0.62056893",
"0.61932683",
"0.619033",
"0.6174551",
"0.6165422",
"0.6164494",
"0.61640227",
"0.6163318",
"0.6159474",
"0.61498225",
"0.61399037",
"0.6139481",
"0.61370015",
"0.6133731",
"0.6130101",
"0.61291206",
"0.61288875",
"0.61191493",
"0.6118613",
"0.6118209",
"0.6113515",
"0.60960346",
"0.6090414",
"0.608582",
"0.6082169",
"0.6067879",
"0.606128",
"0.60531116",
"0.60530645",
"0.60452586",
"0.60385734",
"0.6037446",
"0.60328716",
"0.6032647",
"0.6032153",
"0.6031207",
"0.6028815",
"0.60232264",
"0.6019182",
"0.6018111",
"0.60166866",
"0.6010134",
"0.6010134",
"0.60053927",
"0.6004459",
"0.5999281",
"0.5997252",
"0.598671",
"0.59843",
"0.5981641",
"0.5978965",
"0.5975405",
"0.5972542",
"0.59640914"
] | 0.0 | -1 |
Ruby method can take argument without (..) | def my_method2 argument1, argument2
print argument1, " ", argument2, "\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method(a, *b)\r\n\tb\r\nend",
"def method(arg0)\n end",
"def method(arg0)\n end",
"def method(a, b=-2, *c)\r\nend",
"def argue(argument)\n argument\nend",
"def args(*) end",
"def method(a=2, *b)\r\n\tb\r\nend",
"def nothing(param1)\n end",
"def /(arg0)\n end",
"def /(arg0)\n end",
"def call(*args); end",
"def meth(\n # this is important\n arg)\nend",
"def meth(\n\n\n\n *args)\n\nend",
"def method(*a)\r\n\ta\r\nend",
"def method(*a, b)\r\nend",
"def method(arg_1, arg_2, *other_args)\n p arg_1 # \"a\"\n p arg_2 # \"b\"\n p other_args # []\nend",
"def meth(\n **\n ); end",
"def foo(a, b)\n :two_args\n end",
"def `(*args); forbidden(__method__); end",
"def method(*a, b=2)\r\nend",
"def not _args\n \"not _args;\" \n end",
"def %(*args); end",
"def %(*args); end",
"def method(*\r\n\ta)\r\nend",
"def one_parameter_method (argument=\"nothing\")\n return argument\nend",
"def method(arg1, arg2, *other_args)\n p arg1 # 'a'\n p arg2 # 'b'\n p other_args # []\nend",
"def method (a=3,\r\n\tb)\r\nend",
"def method(*a=10)\r\nend",
"def method (a=3, b=4)\r\nend",
"def arg; end",
"def other_method(name:, age:)\n puts \"Person #{name} is aged #{age}.\"\n # It's an error to call this method without specifying\n # values for name and age.\nend",
"def what_am_i arg arg2\n \nend",
"def subtrair(*args)\n end",
"def hello(place=\"world\", *args)\n #...\n end",
"def *(arg0)\n end",
"def *(arg0)\n end",
"def argue(argument)\n return argument\nend",
"def argument?; end",
"def do_something(something, something_else, another_thing)\n\nend",
"def methodWithArgument(first, second = \"all\")\r\n\treturn \"Message: #{first} #{second}\"\r\nend",
"def do_something (one, two, three)\nend",
"def method (a=3, b)\r\nend",
"def foo(arg); end",
"def method(arg_1, arg_2)\n p arg_1\n p arg_2\nend",
"def %(arg0)\n end",
"def %(arg0)\n end",
"def filter_argument; end",
"def meth(*args)\n\n\n\nend",
"def call(*) end",
"def call(*) end",
"def exclude=(_arg0); end",
"def method(a=-3, b=-4)\r\n\ta + b\r\nend",
"def -(arg0)\n end",
"def -(arg0)\n end",
"def foo(x,y)\nend",
"def foo(x,y)\nend",
"def skips=(_arg0); end",
"def nothing(p1=1,p2=2,p3=3)\nend",
"def method(a,b,c)\nend",
"def mah_method!(method_param)\nend",
"def method ( a ,b ,c ) \nend",
"def do_something(thing_one, two, three)\n end",
"def method=(_arg0); end",
"def method=(_arg0); end",
"def method=(_arg0); end",
"def method(*p1)\n\nend",
"def |(arg0)\n end",
"def |(arg0)\n end",
"def |(arg0)\n end",
"def ignore(*args); end",
"def do_something *param\n puts param\nend",
"def do_something *param\n puts param\nend",
"def do_something *param\n puts param\nend",
"def PO114=(arg)",
"def tricky_method!(a_string_param, an_array_param)\n a_string_param << \", rutabega\"\n an_array_param << \"rutabega\"\nend",
"def returns=(_arg0); end",
"def args=(_arg0); end",
"def args=(_arg0); end",
"def args=(_arg0); end",
"def args=(_arg0); end",
"def args=(_arg0); end",
"def method(a=2, b, *c)\r\n\treturn a, b, c\r\nend",
"def &(arg0)\n end",
"def &(arg0)\n end",
"def &(arg0)\n end",
"def pass=(_arg0); end",
"def <=>(arg1, *rest); end",
"def p(*rest) end",
"def method(**a)\r\nend",
"def meth(\n arg1,\n arg2 , arg3 = 7 , *rest,\n\n\n last,\n required:,\n not_required: 7, **options)\nend",
"def meth(\n arg1,\n arg2 , arg3 = 7 , *rest,\n\n\n last,\n required:,\n not_required: 7, **options)\nend",
"def accept=(_arg0); end",
"def assignment_without_argument_usage(argument); end",
"def method(arg_1, arg_2, *other_args)\n p arg_1 # \"a\"\n p arg_2 # \"b\"\n p other_args # [\"c\", \"d\", \"e\"]\nend",
"def other_arguments(method)\n\n\n\n # 219:7: ',' argument[method]\n match(:COMMA)\n argument(method)\n\n\n\n\n end",
"def in_kwarg; end",
"def PO109=(arg)",
"def meth(arg1)\nend",
"def a_method(arg1, arg2='default value')\n do_stuff\n end",
"def PO110=(arg)",
"def method(p0) end"
] | [
"0.6794627",
"0.6692541",
"0.6692541",
"0.6525113",
"0.6508942",
"0.64719373",
"0.6467577",
"0.6453179",
"0.639138",
"0.639138",
"0.63777286",
"0.6368883",
"0.6365956",
"0.6363147",
"0.6363055",
"0.63630104",
"0.6346795",
"0.63424075",
"0.6321722",
"0.6315374",
"0.6305821",
"0.62919104",
"0.62919104",
"0.6268464",
"0.6264702",
"0.6264132",
"0.6255533",
"0.6247024",
"0.624121",
"0.6222794",
"0.6218561",
"0.6171001",
"0.6161615",
"0.6157853",
"0.6155319",
"0.6155319",
"0.6150842",
"0.61491627",
"0.6147734",
"0.61385256",
"0.6121824",
"0.611644",
"0.60883355",
"0.6070152",
"0.60622776",
"0.60622776",
"0.6055004",
"0.6046412",
"0.60261023",
"0.60261023",
"0.6019087",
"0.601376",
"0.601013",
"0.601013",
"0.60002005",
"0.60002005",
"0.6000163",
"0.5998476",
"0.5996642",
"0.5995878",
"0.59927726",
"0.5986309",
"0.59849966",
"0.59849966",
"0.59849966",
"0.59751725",
"0.5975095",
"0.5975095",
"0.5975095",
"0.5974527",
"0.59725535",
"0.59725535",
"0.59725535",
"0.59574574",
"0.595684",
"0.5952713",
"0.5949484",
"0.5949484",
"0.5949484",
"0.5949484",
"0.5949484",
"0.59479016",
"0.5941611",
"0.5941611",
"0.5941611",
"0.59347093",
"0.5924227",
"0.5918737",
"0.5918536",
"0.5916948",
"0.59153783",
"0.5903349",
"0.59021217",
"0.58983105",
"0.58966035",
"0.587386",
"0.58728975",
"0.5859447",
"0.5851254",
"0.58472836",
"0.584213"
] | 0.0 | -1 |
Variable number of arguments | def my_method3(*arguments)
print "Arguments class is ", arguments.class, "\n"
print "#{arguments.join(' ')}", "\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def how_many_args (*input)\n input.count\n end",
"def how_many_args(*args)\n\targs.length\nend",
"def how_many_args *args\n args.length\n # accepts any number of arguments without complaint\n # returns the total number of arguments passed to the function\n # Hint: google ruby *args\nend",
"def how_many_args *args\n args.length\nend",
"def how_many_args(*args)\n args.length\nend",
"def method_name_with_different_number_of_arguments(*arguments)\n puts(arguments)\nend",
"def how_many_args(*arg)\n arg.length\nend",
"def how_many_args(*args)\n args.count\nend",
"def how_many_args *args\n args.count\nend",
"def args(*) end",
"def how_many_args(*args)\n args.count\n end",
"def variable_length( *args )\n return args\nend",
"def varargs(arg1,*rest)\n puts \"Got #{arg1} and #{rest.join(',')}\"\nend",
"def multipleArgs(*args)\n args.each do | argument |\n puts argument\n end\nend",
"def number_of_arguments(*args)\n puts \"The number of parameters is #{args.length}\"\n for i in 0...args.length\n puts \"The parameters are #{args[i]}\"\n end\nend",
"def xargs *args\r\n m = args.shift\r\n args.slice!(-1).each {|a|\r\n method(m).call(*(args + [a]))\r\n }\r\nend",
"def func *args\n puts \"Argument's length is #{args.length}\"\n for arg in args\n puts \"arg: #{arg}\"\n end\nend",
"def varargs(arg1, *rest)\n puts \"Got #{arg1} and #{rest.join(', ')}\"\nend",
"def third_method(*my_args)\n puts \"I have benn passed #{my_args.length} arguments in #{my_args}\"\n for arg in my_args\n puts \"Argument: #{arg}\"\n end\nend",
"def arguments; end",
"def arguments; end",
"def arguments; end",
"def arguments(required, *optional)\n puts \"required: #{required}\"\n puts \"optional: #{optional}\"\nend",
"def unique_args(*args)\n args\n end",
"def my_args(first, *args, last)\n # Use the splat (i.e. *) in front of an \n # argument to take in any number of args\n # into an array (like gather in JS i.e. ...).\n # Unlike gather, it can be placed at the beginning,\n # the middle, or the end of a list of args\n puts(\"first: #{first}\")\n puts(\"args: #{args}\")\n puts(\"last: #{last}\")\nend",
"def arg_size; end",
"def varargs(arg1, *rest)\n \"arg1=#{arg1}. rest=#{rest.inspect}\"\nend",
"def different_args(one, two, three, four, five, six)\n puts \"#{one}, #{two}, #{three}, #{four}, #{five}, #{six}\"\nend",
"def arguments=(_arg0); end",
"def my_args(first, *args, last)\n # Use the splat '*' in front of an argument to take any number of args into\n # an array, just like gather (i.e. '...') in JavaScript. Unlike gather,\n # it can be placed at the beginning, middle, or end of a list of arguments.\n puts \"first: #{first}\"\n puts \"args: #{args}\"\n puts \"last: #{last}\"\nend",
"def call(*args); end",
"def addArgs(vals); vals.each { |v| addArg v }; self end",
"def varios_args(*args)\n puts \"Tamanho de args: #{args.size}\"\n args.each { |x| p x}\n end",
"def args() return @args end",
"def mixed_args(a,b,*c,d)\n puts \"\\nArguments:\"\n p a,b,c,d\nend",
"def required_arguments(args, n)\n n = (n..n) if Fixnum === n\n unless n.include? args.size\n STDERR.puts usage_text()\n exit!\n end\n args\n end",
"def arguments_method(*arguments)\n arguments.each do |argument|\n puts argument\n end\nend",
"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 echo_at_least_two( first_arg, *middle_args, last_arg)\r\n pp \"The first argument is #{first_arg}\"\r\n middle_args.each { |arg| pp \"A middle argument is #{arg}\" }\r\n pp \"The last argument is #{last_arg}\"\r\nend",
"def %(*args); end",
"def %(*args); end",
"def variableNumberOfArguments (*test)\n puts \"Number of parameters #{test.length}\"\n for i in test\n puts \"The parameters are #{i}\"\n end\n end",
"def length; @args.length end",
"def manage_args(*args)\n end",
"def args()\n #This is a stub, used for indexing\n end",
"def arbitrary_params( *args)\n args.each do |arg|\n puts arg\n end\n # other method of iterating through array\n # args.each { |arg| puts arg }\nend",
"def with_arguments(*typenames)\n\t types = typenames.map { |n| library.registry.build(n) }\n\t @arguments.concat(types)\n\t @arity += typenames.size\n\t self\n\tend",
"def splat_mth(*mult_arg)\n p mult_arg #it's array :) !\n p mult_arg.class\n p mult_arg.object_id\n mult_arg.map {|arg| }\n end",
"def extra_args; end",
"def g *args # accept multiple arguments as an array\n\targs # returns an array\nend",
"def method(arg_1, arg_2, *other_args)\n p arg_1 # \"a\"\n p arg_2 # \"b\"\n p other_args # [\"c\", \"d\", \"e\"]\nend",
"def set_arguments (args)\n end",
"def q1 *rest\n puts \"The number of parameters is #{rest.length}.\"\n puts rest\nend",
"def arg_val_list(args_count)\n return \"void\" if (args_count == 0)\n arguments = []\n args_count.times { |i| arguments << \"ARG#{i}_TYPE arg#{i}\" }\n arguments.join(\", \")\nend",
"def margs *args\r\n m = args.shift\r\n args.slice!(-1).each {|a|\r\n a.method(m).call(*(args))\r\n }\r\nend",
"def third_method(*my_args)\n\tputs \"I have been passed #{my_args.length} arguments in #{my_args}.\"\n\tfor arg in my_args\n\t\tputs \"Argument: #{arg}\"\n\tend\nend",
"def all(*args); end",
"def my_function(argument_a, argument_b, *args)\n puts argument_a\n puts argument_b\n p args.class.name # this is now an array\n puts args\nend",
"def meth(\n arg1,\n arg2 , arg3 = 7 , *rest,\n\n\n last,\n required:,\n not_required: 7, **options)\nend",
"def meth(\n arg1,\n arg2 , arg3 = 7 , *rest,\n\n\n last,\n required:,\n not_required: 7, **options)\nend",
"def args_unleashed(a, b=1, *c, d, e)\n puts \"Arguments:\"\n p a,b,c,d,e\nend",
"def args=(_arg0); end",
"def args=(_arg0); end",
"def args=(_arg0); end",
"def args=(_arg0); end",
"def args=(_arg0); end",
"def varargs(arg1, *args)\n # \"arg1=#{arg1}, args=#{args.inspect}\"\n \"arg1 = #{arg1}, arg2 = #{args}\"\nend",
"def function(argument1, argument2, *splat)\n puts argument1\n puts argument2\n #Is there a better way to detect an empty splat argument?\n if splat == []\n puts \"empty splat!\"\n else\n #Iterate over a variable number of arguments.\n splat.each { |splat_n| puts splat_n }\n end\nend",
"def method(*a=10)\r\nend",
"def arity(*) end",
"def variadic_method(first, *args, last)\n p first\n args.each { |arg| puts arg }\n p last\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 to_args(arity)\n case arity\n when -1\n full_arguments\n when (min_argument_count..full_argument_count)\n full_arguments.slice(full_argument_count - arity, arity)\n else\n raise ArgumentError, \"Arity must be between #{min_argument_count} \"\\\n \"and #{full_argument_count}\"\n end\n end",
"def to_args(arity)\n case arity\n when -1\n full_arguments\n when (min_argument_count..full_argument_count)\n full_arguments.slice(full_argument_count - arity, arity)\n else\n raise ArgumentError, \"Arity must be between #{min_argument_count} \"\\\n \"and #{full_argument_count}\"\n end\n end",
"def positional_args\n result = required_args + optional_args\n result << remaining_arg if remaining_arg\n result\n end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end"
] | [
"0.7546812",
"0.750412",
"0.74718434",
"0.7461837",
"0.7456489",
"0.73960036",
"0.73612213",
"0.7339796",
"0.73243415",
"0.7307468",
"0.7290838",
"0.7257489",
"0.70177597",
"0.69750077",
"0.6868659",
"0.6867352",
"0.68528336",
"0.6845597",
"0.68259865",
"0.6760111",
"0.6760111",
"0.6760111",
"0.66649467",
"0.6619151",
"0.66161305",
"0.66134655",
"0.6611104",
"0.66045326",
"0.6580862",
"0.6574337",
"0.65500623",
"0.6544348",
"0.6499125",
"0.6484982",
"0.64734894",
"0.64593005",
"0.643981",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64368093",
"0.64356315",
"0.6425627",
"0.6425627",
"0.6416703",
"0.639273",
"0.63707125",
"0.6362137",
"0.6349464",
"0.6329317",
"0.6324784",
"0.63134277",
"0.63045883",
"0.62976736",
"0.6291845",
"0.6286553",
"0.6286384",
"0.62711245",
"0.62711036",
"0.6259293",
"0.6247181",
"0.62400913",
"0.6238334",
"0.6230805",
"0.6221559",
"0.6221559",
"0.6221559",
"0.6221559",
"0.6221559",
"0.6204229",
"0.6177417",
"0.6170332",
"0.6160926",
"0.6155784",
"0.615421",
"0.61351246",
"0.6133488",
"0.61307377",
"0.612943",
"0.612943",
"0.612943",
"0.612943",
"0.612943",
"0.612943",
"0.612943"
] | 0.0 | -1 |
GET /pictures/1 GET /pictures/1.json | def show
@picture = Picture.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @picture }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pictures = @album.pictures #JRD111115\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @pictures}\n end\n end",
"def show\n @picture = @album.pictures.find(params[:id]) #JRD111115\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @picture}\n end\n end",
"def index\n @pictures = Picture.where(foodscape_id: params[:foodscape_id])\n render json: @pictures\n end",
"def index\n @pictures = Picture.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pictures }\n end\n end",
"def index\n @activity = Activity.find(params[:activity_id])\n @pictures = @activity.pictures\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pictures }\n end\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/photos/#{params[:id]}.json?token=#{ENV['API_KEY']}\"\n\t response = RestClient.get(url)\n\t @photo = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/photos.json?token=#{ENV['API_KEY']}\"\n response = RestClient.get(url)\n @photos = JSON.parse(response.body)\t\t \n\tend\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pictures }\n end\n end",
"def index\n id = (params[:id].to_i || 0) * 8\n @pictures = current_user.pictures.limit(8).offset(id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pictures }\n end\n end",
"def show\n @pictures_of_cat = PicturesOfCat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pictures_of_cat }\n end\n end",
"def show\n render json: @picture\n end",
"def show\n @pic = Pic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pic }\n end\n end",
"def show\n render json: @picture, status: :ok\n end",
"def index\n render json: Picture.all\n end",
"def show\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json=>@picture }\n end\n end",
"def index\n @pictures = @museum.pictures.all #Picture.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pictures }\n end\n end",
"def show\n #@picture = Picture.find(params[:id])\n @picture = @museum.pictures.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @picture }\n end\n end",
"def images\n @picturesandmeta = Pictureandmeta.all\n @kind = Kind.find(params[:kind_id])\n Rails.logger.info(\"Kind: #{@kind.inspect}\")\n end",
"def image_list\n @images = Picture.where(album_id: params[:album_id])\n respond_to do |format|\n format.json { render json: @images.to_json(methods: [:path])}\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @picture }\n end\n end",
"def show\n @picture = @album.pictures.find(params[:id])\n end",
"def show\n @photo = Photo.find(params[:id])\n\n render json: @photo\n end",
"def index\n @pictures = Picture.all\n end",
"def index\n @pictures = Picture.all\n end",
"def index\n @pictures = Picture.all\n end",
"def index\n @pictures = Picture.all\n end",
"def index\n @pictures = Picture.all\n end",
"def getresourcepicture\n \n if(params[:store_id])\n \n @pictures = Picture.find_all_by_store_id(params[:store_id]); \n \n end\n if(params[:item_id])\n \n @pictures = Picture.find_all_by_item_id(params[:item_id]); \n\n \n elsif(params[:first_pic] =='true')\n \n @pictures = @pictures.first();\n \n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pictures }\n end\n \n end",
"def show\n @image = Image.find(params[:id])\n\n render json: @image\n end",
"def show\n @image = Image.find(params[:id])\n\n render json: @image\n end",
"def photos options={}\n response = client.get(\"/#{id}/photos\", options)\n end",
"def index\n @pictures = Picture.where(key: params[:key])\n end",
"def show\n\n @picture = Picture.find(params[:id])\n @activity = @picture.album.imageable\n\n respond_to do |format|\n format.html { render 'show' }\n format.json { render json: @picture }\n end\n end",
"def show\n @photo = @allbum.photos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n photo_obj = API.get_one(params[:id])\n if photo_obj['error'].nil?\n photo = PhotoPresenter.new(photo_obj['photo'])\n render :json => photo.as_json\n else\n render :json => photo_obj\n end\n end",
"def show\n @grm_pic = GrmPic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @grm_pic }\n end\n end",
"def new\n @pic = Pic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pic }\n end\n end",
"def show\n @baby_pic = BabyPic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @baby_pic }\n end\n end",
"def index\n\t\t@pictures = @boat.pictures\n\tend",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def index\n @category = Category.find(params[:category_id])\n @pictures = @category.pictures\n end",
"def show\n @sermon_picture = SermonPicture.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sermon_picture }\n end\n end",
"def show\n @photo1 = Photo1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo1 }\n end\n end",
"def index\n @photos = Photo.all\n\n render json: @photos\n end",
"def show\n @property_picture = PropertyPicture.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property_picture }\n end\n end",
"def index\n @pictures = @album.pictures.all\n end",
"def show\n\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @photo }\n end\n end",
"def index\n @album = Album.find(params[:album_id])\n @photos = @album.photos.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @photos }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def show\n @look_book = LookBook.find(params[:id])\n\n @photos = @look_book.photos\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @look_book }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @photo }\n end\n end",
"def index\n @pictures = current_user.pictures.all\n end",
"def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @image }\n end\n end",
"def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @image }\n end\n end",
"def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @image }\n end\n end",
"def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @image }\n end\n end",
"def show\n @gallery = Gallery.find_by_permalink params[:id]\n unless @gallery.nil?\n @pictures = Picture.paginate_by_gallery_id @gallery.id, :page => params[:page],\n :per_page => 12\n else\n render :status => 404\n end\n end",
"def show\n @user = User.find(params[:id])\n @pic = Pic.new\n \n \n @pics = Pic.where(\"user_id = ?\", session[:user_id]).limit(3).order(\"created_at DESC\")\n\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @user }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @picture }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @picture }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @picture }\n end\n end",
"def new\n @picture = Picture.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @picture }\n end\n end",
"def index\n @pictures = Picture.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pictures }\n end\n end",
"def index\n @picturesperpage = PICTURES_PER_PAGE\n if params.fetch(:page, 0).to_i < 0\n @page = 0\n else\n @page = params.fetch(:page, 0).to_i\n end\n @allpictures = Picture.all.count.to_i\n @pictures = Picture.offset(@page * PICTURES_PER_PAGE).limit(PICTURES_PER_PAGE)\n end",
"def show\r\n @photo = Photo.find(params[:id])\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @photo }\r\n end\r\n end",
"def show\n @image = Image.find(params[:id])\n\t\t\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @image }\n end\n end",
"def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @image }\n end\n end",
"def new\n @picture = @museum.pictures.new #Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @picture }\n end\n end",
"def index\n @photos = Photo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @photos }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json=>@picture}\n end\n end",
"def index\n @photos = get_possible_photos\n paginate json: @photos, per_page: 10\n end",
"def show\n @pic_story = PicStory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pic_story }\n end\n end",
"def show\n render json: @sample_photo\n end",
"def show\n render json: @rock_photo\n end",
"def show\n @photo = Photo.find(params[:id])\n\t@album = Album.find(@photo.album_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def index\n @pictures = current_user.pictures\n end",
"def show\n @imagem = Imagem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @imagem }\n end\n end",
"def new\n @pictures_of_cat = PicturesOfCat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pictures_of_cat }\n end\n end",
"def index\n @images = Image.all\n\n render json: @images\n end",
"def show\n @plate_photo = PlatePhoto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plate_photo }\n end\n end",
"def show\n @photo_library = PhotoLibrary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo_library }\n end\n end",
"def index\n @photos = Photo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @photos }\n end\n end",
"def index\n @album = Album.find(params[:album_id])\n @photos = @album.photos\n @photos_j = @album.photos.map { |p| p.json }\n @photo = Photo.new\n @album.add_one_view\n\n # @images = Dir.glob(\"app/assets/images/*.jpg\")\n # pic_hash = @images.first(10).map { |i| {:pic_url => i}}\n # @photos = pic_hash.each_with_index.map {|i,v| {:photo_id => v.to_s + \"1\" }.merge(i) }\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @photos_j }\n end\n end",
"def index\n # @photos = Photo.all\n data = Photo.all\n render status: :ok, json: data\n end"
] | [
"0.78861046",
"0.77967006",
"0.7703738",
"0.7652336",
"0.75105095",
"0.75022507",
"0.74907297",
"0.74695826",
"0.744514",
"0.7441424",
"0.7422313",
"0.7395833",
"0.739197",
"0.7329584",
"0.7298408",
"0.7228419",
"0.71639085",
"0.7159588",
"0.71483576",
"0.70885813",
"0.70407426",
"0.7016005",
"0.7016005",
"0.7016005",
"0.7016005",
"0.7016005",
"0.69801426",
"0.6930058",
"0.6930058",
"0.69195306",
"0.6895365",
"0.68750703",
"0.68532383",
"0.68341553",
"0.68114454",
"0.6795458",
"0.6775058",
"0.6721831",
"0.6714099",
"0.6714099",
"0.6714099",
"0.6714099",
"0.6714099",
"0.6714099",
"0.6714099",
"0.6714099",
"0.6714099",
"0.6714099",
"0.6714099",
"0.6714099",
"0.6714099",
"0.6704215",
"0.6697342",
"0.6685355",
"0.6684022",
"0.66797405",
"0.66771674",
"0.665487",
"0.66547686",
"0.66468054",
"0.6646058",
"0.6643143",
"0.66352963",
"0.6626116",
"0.6626116",
"0.6626116",
"0.6626116",
"0.6622976",
"0.66202474",
"0.66183805",
"0.66183805",
"0.66183805",
"0.66159457",
"0.6615249",
"0.6607661",
"0.66056836",
"0.6588508",
"0.65781146",
"0.6558019",
"0.6550493",
"0.65413594",
"0.65376014",
"0.65348744",
"0.65306824",
"0.65154445",
"0.65141296",
"0.65121514",
"0.6508954",
"0.6506001",
"0.6504414",
"0.6502605",
"0.65019906",
"0.65003264",
"0.6496806",
"0.6489279"
] | 0.7424227 | 15 |
GET /pictures/new GET /pictures/new.json | def new
@project = Project.find(params[:project_id])
@picture = @project.pictures.build
respond_to do |format|
format.html # new.html.erb
format.json { render json: @picture }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @picture = Picture.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @picture }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @picture }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @picture }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @picture }\n end\n end",
"def new\n @pic = Pic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pic }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json=>@picture}\n end\n end",
"def new\n @pictures_of_cat = PicturesOfCat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pictures_of_cat }\n end\n end",
"def new\n @picture = @museum.pictures.new #Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @picture }\n end\n end",
"def new\n @photo = @allbum.photos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n render json: @photo\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image }\n end\n end",
"def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image }\n end\n end",
"def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image }\n end\n end",
"def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image }\n end\n end",
"def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image }\n end\n end",
"def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @photo }\n end\n end",
"def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @image }\n end\n end",
"def new\n @image = Image.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @image }\n end\n end",
"def new\n @property_picture = PropertyPicture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @property_picture }\n end\n end",
"def new\n @profile_picture = ProfilePicture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @profile_picture }\n end\n end",
"def new\n @photo = Photo.new \n \n #@photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @gallery = Gallery.new\n @rights = {'Moderators' => 'moderators', 'Members' => 'members', 'Anybody' => 'all'}\n\n @gallery.parent_type = params[:parent_type]\n @gallery.parent_id = params[:parent_id]\n set_session_parent_pictures_root_path(@gallery.get_parent_object)\n\n @new_pictures = Array.new\n 1.upto(3) { @new_pictures << Picture.new }\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gallery }\n end\n end",
"def new\n @pic = Pic.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pic }\n end\n end",
"def create\n @picture = Picture.create!(picture_params)\n render json: @picture, status: :created\n end",
"def new\n @photoid = Photoid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photoid }\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 @grm_pic = GrmPic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @grm_pic }\n end\n end",
"def new\n @image_url = ImageUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image_url }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @picture }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @picture }\n end\n end",
"def new\n @photo_library = PhotoLibrary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo_library }\n end\n end",
"def new\n @baby_pic = BabyPic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @baby_pic }\n end\n end",
"def new\n @activity = Activity.find(params[:activity_id])\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @picture }\n end\n end",
"def new\n @album = Album.find(params[:album_id])\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n authorize! :new, @photo\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @album = Album.find(params[:album_id])\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @photo }\n end\n end",
"def new\n @project_photo = ProjectPhoto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project_photo }\n end\n end",
"def new\n @pic_story = current_user.pic_stories.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pic_story }\n end\n end",
"def create\n @picture = current_user.pictures.new(params[:picture])\n\n respond_to do |format|\n if @picture.save\n format.html { redirect_to @picture, notice: 'Picture was successfully created.' }\n format.json { render json: @picture, status: :created, location: @picture }\n else\n format.html { render action: \"new\" }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @photo1 = Photo1.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo1 }\n end\n end",
"def new\n \n @page = Page.new\n @page.images.build\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end",
"def new\n @pic_space = PicSpace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pic_space }\n end\n end",
"def new\n @plate_photo = PlatePhoto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plate_photo }\n end\n end",
"def new\n @image_gallery = ImageGallery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image_gallery }\n end\n end",
"def new\n @phile = Phile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @phile }\n end\n end",
"def create\n @picture = Picture.new(params[:picture])\n\n respond_to do |format|\n if @picture.save\n format.html { redirect_to @picture, notice: 'Picture was successfully created.' }\n format.json { render json: @picture, status: :created, location: @picture }\n else\n format.html { render action: \"new\" }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @picture = Picture.new(params[:picture])\n\n respond_to do |format|\n if @picture.save\n format.html { redirect_to @picture, notice: 'Picture was successfully created.' }\n format.json { render json: @picture, status: :created, location: @picture }\n else\n format.html { render action: \"new\" }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @gallery = Gallery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @gallery }\n end\n end",
"def new\n @gallery = Gallery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @gallery }\n end\n end",
"def new\n @page = Page.new\n @photos = Photo.all\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n @photo = Photo.new\n @albums = Album.where('user_id=?',session[:user_id]).latest\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\t@albums = Album.find_all_by_twit_id(params[:view_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @collage = Collage.new\n @images = Image.order('created_at DESC')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collage }\n end\n end",
"def new\n @pix = Pix.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pix }\n end\n end",
"def new\n @image_upload = ImageUpload.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image_upload }\n end\n end",
"def create\n @pic = Pic.new(params[:pic])\n\n respond_to do |format|\n if @pic.save\n format.html { redirect_to @pic, notice: 'Pic was successfully created.' }\n format.json { render json: @pic, status: :created, location: @pic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @gallery = Gallery.new(:public => true)\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gallery }\n end\n end",
"def create\n @picture = Picture.new(params[:picture])\n \n respond_to do |format|\n if @picture.save\n format.html { redirect_to @picture, flash: {success: \"Picture was successfully created!\"}}\n format.json { render json: @picture, status: :created, location: @picture }\n else\n format.html { render action: \"new\" }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @photobook = Photobook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photobook }\n end\n end",
"def new\n @gist = Gist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gist }\n end\n end",
"def new\r\n @place_id=\r\n @photo = Photo.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @photo }\r\n end\r\n end",
"def new\n @picture = Picture.new\n end",
"def new\n @picture = Picture.new\n end",
"def new\n @picture = Picture.new\n end",
"def new\n @picture = Picture.new\n end",
"def new\n @wallpaper = Wallpaper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wallpaper }\n end\n end",
"def new\n @gallery = Gallery.new\n \n respond_to do |format|\n format.html{ redirect_to edit_portfolio_project_path(params[:project_id])+\"?new_gallery=1\" }\n format.json { render json: @gallery }\n end\n end",
"def new\n @album2photo = Album2photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album2photo }\n end\n end",
"def new\n @project = Project.new\n @project.photos.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @admin_photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_photo }\n end\n end",
"def new\n @photographer = Photographer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photographer }\n end\n end",
"def new\n @sermon_picture = SermonPicture.new(key: params[:key])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sermon_picture }\n end\n end",
"def new\n @photographer = Photographer.new\n\n respond_to do |format|\n # format.html # new.html.erb\n format.json { render json: @photographer }\n end\n end",
"def create\n @picture = @imageable.pictures.new(picture_params)\n respond_to do |format|\n if @picture.save\n format.html do\n redirect_to @imageable, notice: I18n.t('pictures.save_success')\n end\n format.json { render :show, status: :created, location: @imageable }\n else\n format.html do\n redirect_to @imageable, notice: I18n.t('pictures.save_failure')\n end\n format.json do\n render json: @picture.errors, status: :unprocessable_entity\n end\n end\n end\n end",
"def new\n @users_photo = UsersPhoto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @users_photo }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @picture }\n end\n end",
"def create\n @pictures_of_cat = PicturesOfCat.new(params[:pictures_of_cat])\n\n respond_to do |format|\n if @pictures_of_cat.save\n format.html { redirect_to @pictures_of_cat, notice: 'Pictures of cat was successfully created.' }\n format.json { render json: @pictures_of_cat, status: :created, location: @pictures_of_cat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pictures_of_cat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\t\t@picture = Picture.new\n\tend",
"def create\n @picture = Picture.new(picture_params)\n\n respond_to do |format|\n if @picture.save\n format.html { redirect_to @picture, notice: 'Picture was successfully created.' }\n format.json { render :show, status: :created, location: @picture }\n else\n format.html { render :new }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @photo = current_user.photos.build(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n @photo.album_id = params[:album_id]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @hotel_pic = HotelPic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hotel_pic }\n end\n end",
"def new\n @album = Album.new\n @photo = @album.photos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @slide_image = SlideImage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @slide_image }\n end\n end",
"def new\n @image_datum = ImageDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image_datum }\n end\n end"
] | [
"0.8038981",
"0.79874873",
"0.79874873",
"0.79874873",
"0.7922598",
"0.78247064",
"0.7807926",
"0.7776248",
"0.7542473",
"0.74994177",
"0.7460262",
"0.74600285",
"0.74600285",
"0.74600285",
"0.74600285",
"0.74600285",
"0.74600285",
"0.74600285",
"0.74600285",
"0.74600285",
"0.74600285",
"0.74600285",
"0.74600285",
"0.7385532",
"0.7385532",
"0.7385532",
"0.7385532",
"0.7385532",
"0.7385532",
"0.73835313",
"0.73835313",
"0.73230344",
"0.72994083",
"0.72681725",
"0.72429717",
"0.72177875",
"0.7211009",
"0.7207751",
"0.71993864",
"0.71876824",
"0.71661705",
"0.71651995",
"0.71547455",
"0.7130093",
"0.7130093",
"0.71236545",
"0.7123561",
"0.7116863",
"0.7103562",
"0.708599",
"0.7075487",
"0.7061439",
"0.70564723",
"0.7045625",
"0.70400774",
"0.70364916",
"0.703567",
"0.7021766",
"0.6971057",
"0.69703317",
"0.6961872",
"0.6961872",
"0.6955631",
"0.6955631",
"0.6955034",
"0.6954778",
"0.69456637",
"0.69325334",
"0.6931507",
"0.6919006",
"0.6907797",
"0.69069886",
"0.68842906",
"0.6860006",
"0.68539184",
"0.6848221",
"0.684105",
"0.684105",
"0.684105",
"0.684105",
"0.6836926",
"0.68363786",
"0.68322843",
"0.6829958",
"0.6824304",
"0.68162966",
"0.68150663",
"0.6796626",
"0.6794747",
"0.678682",
"0.6782845",
"0.6780393",
"0.67787355",
"0.67749816",
"0.6766438",
"0.6762157",
"0.6757587",
"0.67484224",
"0.6726719",
"0.6720888"
] | 0.7421645 | 23 |
PUT /pictures/1 PUT /pictures/1.json | def update
@picture = Picture.find(params[:id])
respond_to do |format|
if @picture.update_attributes(params[:picture])
format.html { redirect_to @picture, notice: 'Picture was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @picture.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @pictures = Picture.all.order(created_at: :desc)\n @picture.update(picture_params)\n render json: @pictures\n # head :no_content\n end",
"def update\n if @picture.update(picture_params)\n head :no_content\n else\n render json: @picture.errors, status: :unprocessable_entity\n end\n end",
"def update\n @picture = @album.pictures.find(params[:id]) #JRD111115\n\n respond_to do |format|\n if @album.pictures.find(params[:id]).update_attributes(picture_params)\n format.html { redirect_to album_pictures_url(@album), notice: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @album.picture }\n else\n format.html { render :edit }\n format.json { render json: @album.picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @event = Event.find(params[:id])\n\n\t\tparams[:event][:pictures_attributes].each do |key, value|\n\t\t\[email protected] << Picture.create(value)\n\t\tend\n\n respond_to do |format|\t\t\t\n if @event.save\n format.html { redirect_to \"/#{@event.url}\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n if @picture.update_attributes(params[:picture])\n format.html { redirect_to '/main', notice: 'upload' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n if @picture.update_attributes(picture_params)\n format.html { redirect_to @picture, :notice=>\"Picture was successfully updated.\"}\n format.json { head :ok }\n else\n format.html { render :action=>\"edit\" }\n format.json { render :json=>@picture.errors, :status=>\"unprocessable_entry\" }\n end\n end\n end",
"def update\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n if @picture.update_attributes(params[:picture])\n format.html { redirect_to @picture, flash: {success: \"Picture was successfully updated!\"}}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @picture.update(picture_params)\n format.html { redirect_to album_pictures_path, notice: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @picture }\n else\n format.html { render :edit }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @picture.update(picture_params)\n create_image_tumb(@picture)\n format.html { redirect_to @picture, notice: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @picture }\n else\n format.html { render :edit }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @picture = @album.pictures.find(params[:id])\n \n if @picture.update_attributes(params[:picture])\n flash[:notice] = 'Picture was successfully updated.'\n redirect_to(album_pictures_path(@album))\n else\n render :action => \"edit\" \n end\n end",
"def update\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n if @picture.update_attributes(params[:picture])\n format.html { redirect_to [@picture.imageable, @picture], notice: 'Picture was successfully updated.' }\n format.json { respond_with_bip(@picture) }\n else\n format.html { render action: \"edit\" }\n format.json { respond_with_bip(@picture) }\n end\n end\n end",
"def update\n @pic = Pic.find(params[:id])\n\n respond_to do |format|\n if @pic.update_attributes(params[:pic])\n format.html { redirect_to @pic, notice: 'Pic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @picture.update(picture_params)\n format.html { redirect_to @picture, notice: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @picture }\n else\n format.html { render :edit }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @picture.update(picture_params)\n format.html { redirect_to @picture, notice: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @picture }\n else\n format.html { render :edit }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @picture.update(picture_params)\n format.html { redirect_to @picture, notice: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @picture }\n else\n format.html { render :edit }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @picture.update(picture_params)\n format.html { redirect_to @picture, notice: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @picture }\n else\n format.html { render :edit }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @picture.update(picture_params)\n redirect_to picture_path(@picture)\n end",
"def update\n respond_to do |format|\n if @picture.update(picture_update_params)\n format.html { redirect_to @picture, success: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @picture }\n else\n format.html { render :edit }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @picture.update(picture_params)\n format.html { redirect_to @picture, notice: \"La imagen se actualizó correctamente.\" }\n format.json { render :show, status: :ok, location: @picture }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:image].delete :created_at\n params[:image].delete :updated_at\n params[:image].delete :id\n @image = Image.find(params[:id])\n if @image.update_attributes(params[:image])\n render json: @image\n else\n render json: @image.errors, status: :unprocessable_entity\n end\n end",
"def update\n if !params[:event][:picture].nil?\n bucket = ENV['S3_BUCKET']\n pic = params[:event][:picture]\n content_type = pic.content_type.split('/').last\n\n if content_type == 'jpeg'\n content_type = 'jpg'\n end\n\n s3 = Aws::S3::Client.new(region: 'us-west-2')\n md5 = Digest::MD5.file(params[:event][:picture].tempfile).hexdigest\n filename = md5 + '.' + content_type\n s3.put_object(bucket: bucket, key: 'pictures/' + filename, body: pic,\n acl: 'public-read', content_type: pic.content_type)\n link = 'https://s3-us-west-2.amazonaws.com/' + bucket + '/pictures/' + filename\n old_pic = @event.pictures.first\n old_pic.delete\n @event.pictures.new(name: filename, url: link)\n end\n\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @picture = Picture.new(picture_params)\n\n if @picture.save\n @picture.update(foodscape_id: params[:foodscape_id])\n render json: @picture, status: :created\n else\n render json: @picture.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @pic.update(pic_params)\n format.html { redirect_to @pic, notice: 'Pic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @image = Image.find(params[:id])\n\n respond_to do |format|\n if @image.update_attributes(params[:image])\n format.html { redirect_to mypictures_path}\n format.json { head :no_content }\n flash[:success] = \"Image updated\"\n\n else\n format.html { render action: \"edit\" }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @picture = Picture.find(params[:id])\n respond_with do |format|\n if @picture.update_attributes(params[:picture])\n format.html { redirect_to picture_path(@picture), notice: 'Picture was successfully updated.' }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @listing.update_attributes(listing_params)\n if params[:pictures]\n #===== The magic is here ;)\n params[:pictures].each { |image| \n @listing.pictures.create(file: image)\n } \n end\n format.html { redirect_to admin_listings_url, notice: 'Listing was successfully updated.' }\n format.json { render :show, status: :ok, location: @listing }\n else\n format.html { render :edit }\n format.json { render json: @listing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @picture = Picture.find(params[:id])\n if @picture.update_attributes(params[:picture])\n respond_to do |format|\n format.js\n end\n else\n render :action => 'edit'\n end\n end",
"def update\n if params[:file].present?\n req = Cloudinary::Uploader.upload params[:file]\n @picture.image = req['public_id']\n end\n respond_to do |format|\n if @picture.update(picture_params)\n format.html { redirect_to @picture, notice: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @picture }\n else\n format.html { render :edit }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pictures_of_cat = PicturesOfCat.find(params[:id])\n\n respond_to do |format|\n if @pictures_of_cat.update_attributes(params[:pictures_of_cat])\n format.html { redirect_to @pictures_of_cat, notice: 'Pictures of cat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pictures_of_cat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @image = Image.find(params[:id])\n\n #we can allow updating an image name and description and unit, but not the image data. for that we need to create a new image\n update_params = image_params\n update_params.delete(\"image\")\n\n if @image.update(update_params)\n head :no_content\n else\n render json: @image.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @car.update(car_params)\n unless params[:photos].blank?\n params[:photos]['image'].each do |p|\n @photo = @car.photos.create!(:image => p, :car_id => @car.id)\n end\n end\n format.html { redirect_to @car, notice: 'Car was successfully updated.' }\n format.json { render :show, status: :ok, location: @car }\n else\n format.html { render :edit }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @picture.update_attributes(params[:picture])\n flash[:notice] = 'Picture was successfully updated.'\n format.html { redirect_to pictures_url(@picture.user_id) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n @artwork = Artwork.find(params[:artwork_id])\n @picture = @artwork.pictures.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @smartphone.update(smartphone_params)\n if params[:images]\n params[:images].each do |val|\n temp = @smartphone.pictures.find_by(image_file_name: val.original_filename)\n if temp\n temp.update_attributes(:image => val)\n else\n @smartphone.pictures.create(image: val)\n end\n end\n end\n format.html { redirect_to @smartphone, notice: 'Smartphone was successfully updated.' }\n format.json { render :show, status: :ok, location: @smartphone }\n else\n format.html { render :edit }\n format.json { render json: @smartphone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @photo = current_user.photos.find_by_id(params[:id])\n if @photo.nil?\n render json: {error: 'foto no encontrada'}, status: :not_found\n elsif @photo.update(photo_params)\n render json: @photo\n else\n render json: @photo.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @picture.update(picture_params)\n format.html { redirect_to profiles_path(current_trader.id), notice: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @picture }\n else\n format.html { render :edit }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n if @picture.update_attributes(params[:picture])\n flash[:notice] = 'Picture was successfully updated.'\n format.html { redirect_to(@picture) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @picture.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n if @picture.update_attributes(params[:picture])\n flash[:notice] = 'Picture was successfully updated.'\n format.html { redirect_to(@picture) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @picture.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n # ref = request.referrer\n @picture = current_user.pictures.find(params[:id])\n\n respond_to do |format|\n if @picture.update_attributes(params[:picture])\n format.html { redirect_to session[:ref] , notice: 'Picture was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @event = Event.find(params[:id])\n\n # set picture if input\n @picture = @event.pictures.first\n unless params[:internet_url_path].empty?\n @picture.set_photo_from_url(params[:internet_url_path])\n end\n unless params[:picture].nil?\n #TODO: NOT SAVING RIGHT\n @picture.picture = params[:picture]\n end\n\n unless @picture.save\n puts \" TRACE: EventsController:update - picture update failed\"\n end\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n puts y params['photo'].keys\n params['photo'].keys.each do |photo_id|\n photo = Photo.find(photo_id)\n photo.update_attributes(params['photo'][photo_id])\n end\n respond_to do |format|\n if true \n format.html { redirect_to photos_path, notice: 'Photos were successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"index\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n \n respond_to do |format|\n if @album.update_attributes(params[:album])\n @album.images.clear\n @album.images << Image.find([params[:images]].flatten)\n @album.save!\n format.html { redirect_to(albums_path, :notice => 'Album was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n \n if zim_params[:picture]\n uploaded_io = zim_params[:picture]\n s3 = Aws::S3::Resource.new(\n credentials: Aws::Credentials.new('AKIAJAE7VUWCVE6MJZTA ', 'IKIwmRHirTwvre4OacyNJgNXntSv3tKZSNxxSeTZ'),\n region: 'us-west-2')\n \n obj = s3.bucket('zimcher').object(\"zimsimages/#{@zim.id}\")\n obj.put(body: uploaded_io)\n @zim.image_url = obj.public_url\n end\n \n @zim.name = zim_params[:name]\n @zim.description = zim_params[:description]\n \n respond_to do |format|\n if @zim.save\n format.html { redirect_to @zim, notice: 'Zim was successfully updated.' }\n format.json { render json: @zim, status: :ok}\n else\n format.html { render :edit }\n format.json { render json: @zim.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @spot.update(spot_params)\n if params[:photos]\n params[:photos]['image'].each do |a|\n @photo = @spot.photos.create!(:image => a, :imageable_id => @spot.id)\n end\n end\n\n format.html { redirect_to [ @country, @spot ] , notice: 'Spot was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n respond_to do |format|\n if @spot.update(spot_params)\n if params[:photos]\n params[:photos]['image'].each do |a|\n @photo = @spot.photos.create!(:image => a, :imageable_id => @spot.id)\n end\n end\n\n format.html { redirect_to [ @country, @spot ] , notice: 'Spot was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n @property_picture = PropertyPicture.find(params[:id])\n\n respond_to do |format|\n if @property_picture.update_attributes(params[:property_picture])\n format.html { redirect_to @property_picture, notice: 'Property picture was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @property_picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @photo.update(photo_params)\n save_to_json\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t@artwork = Artwork.find(params[:id])\n\n\trespond_to do |format|\n\t\tif @artwork.update_attributes(artwork_params)\n\t\t\tif params[:images]\n\t\t\t\tparams[:images].each { |image| \n\t\t\t\t\[email protected](image: image)\n\t\t\t\t}\n\t\t\tend\n\n\t\t\tredirect_to @artwork, notice: \"Artwork submitted successfully\"\n\t\telse\n\t\t\trender 'edit'\n\t\tend\n\tend\nend",
"def update\n respond_to do |format|\n if @apartment.update(apartment_params)\n if params[:images]\n # The magic is here ;)\n params[:images].each { |image|\n if (image!=nil)\n @apartment.pictures.create(image: image)\n \n end\n }\n end\n format.html { redirect_to @apartment, notice: 'La propiedad se actualizo correctamente.' }\n format.json { render :show, status: :ok, location: @apartment }\n else\n format.html { render :edit }\n format.json { render json: @apartment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @item_picture.update(item_picture_params)\n format.html { redirect_to @item_picture, notice: 'Item picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_picture }\n else\n format.html { render :edit }\n format.json { render json: @item_picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @image.update(image_params)\n redirect_to '/images'\n end",
"def update\n \n @album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to album_photo_path(@album,@photo), :notice => 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @picture_upload.update(picture_upload_params)\n format.html { redirect_to @picture_upload, notice: 'Picture upload was successfully updated.' }\n format.json { render :show, status: :ok, location: @picture_upload }\n else\n format.html { render :edit }\n format.json { render json: @picture_upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @picture = Picture.create!(picture_params)\n render json: @picture, status: :created\n end",
"def update\n @image = Image.find(params[:id])\n\n respond_to do |format|\n if @image.update_attributes(params[:image])\n format.html { redirect_to @image, :notice => 'Image was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @image.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ministries_picture.update(ministries_picture_params)\n format.html { redirect_to @ministries_picture, notice: 'Ministries picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @ministries_picture }\n else\n format.html { render :edit }\n format.json { render json: @ministries_picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @image = Image.find(params[:id])\n\n respond_to do |format|\n if @image.update_attributes(params[:image])\n format.html { redirect_to @image, notice: 'Image was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @image = Image.find(params[:id])\n\n respond_to do |format|\n if @image.update_attributes(params[:image])\n format.html { redirect_to @image, notice: 'Image was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @image = Image.find(params[:id])\n\n respond_to do |format|\n if @image.update_attributes(params[:image])\n format.html { redirect_to @image, notice: 'Image was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @image = Image.find(params[:id])\n\n respond_to do |format|\n if @image.update_attributes(params[:image])\n format.html { redirect_to @image, notice: 'Image was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @image = Image.find(params[:id])\n if @image.update(image_params)\n render json: {status: \"success\", data: {image:@image}}, status: :ok\n else\n render json: @comment.errors, status: 404\n end\n end",
"def update\n @photo = Photo.find( params[:id])\n if @photo.update_attributes(params[:photo])\n flash[:notice] = \"Photo updated!\"\n if params[:bucket_id]\n redirect_to bucket_album_photo_path( params[:bucket_id], params[:album_id], @photo )\n elsif params[:album_id]\n redirect_to album_photo_path( params[:album_id], @photo )\n else\n redirect_to @photo\n end\n else\n render :action => :edit\n end\n end",
"def change_picture(id, io)\n post(ROOT_URI + '/a/changepicture', 'stream' => id,\n 'picture' => io)\n end",
"def change_picture(id, io)\n post(ROOT_URI + '/a/changepicture', 'stream' => id,\n 'picture' => io)\n end",
"def update\n respond_to do |format|\n if @pic.update(part_update_params)\n format.html { redirect_to @pic, notice: 'Pic was successfully updated.' }\n format.json { render :show, status: :ok, location: @pic }\n else\n format.html { render :edit }\n format.json { render json: @pic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @image = @album.images.find(params[:id])\n @image.update(image_params)\n redirect_to album_path(@image.album.id)\n end",
"def update\n @image = Image.find(params[:id])\n checkaccountobject(\"images\",@image)\n respond_to do |format|\n if @image.update_attributes(params[:image])\n format.html { redirect_to @image, notice: 'Image was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_picture.update(admin_picture_params)\n format.html { redirect_to @admin_picture, notice: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_picture }\n else\n format.html { render :edit }\n format.json { render json: @admin_picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @photo1 = Photo1.find(params[:id])\n\n respond_to do |format|\n if @photo1.update_attributes(params[:photo1])\n format.html { redirect_to @photo1, notice: 'Photo1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @foto = Foto.find(params[:id])\n\n respond_to do |format|\n if @foto.update_attributes(params[:foto])\n format.html { redirect_to @foto, notice: 'Foto was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @foto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_picture\n @picture = @album.pictures.find(params[:id])\n end",
"def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, :notice => 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action=> \"edit\" }\n format.json { render :json => @photo.errors, :status=> :unprocessable_entity }\n end\n end\n end",
"def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, :notice => 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n # @picture = Picture.find_by_id(params[:id])\n respond_to do |format|\n # binding.pry\n if @share.update(share_params)\n format.html { redirect_to @share, notice: 'Successfully updated.' }\n format.json { render :show, status: :ok, location: @share }\n else\n format.html { render :edit }\n format.json { render json: @share.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @profile_picture = ProfilePicture.find(params[:id])\n\n respond_to do |format|\n if @profile_picture.update_attributes(params[:profile_picture])\n format.html { redirect_to @profile_picture, notice: 'Profile picture was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @profile_picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end",
"def set_picture\n @picture = Picture.find(params[:id])\n end"
] | [
"0.7677843",
"0.7093891",
"0.7019593",
"0.6935083",
"0.693408",
"0.68827313",
"0.68587154",
"0.68570614",
"0.67712915",
"0.6759743",
"0.67408067",
"0.6732044",
"0.67319566",
"0.67319566",
"0.67319566",
"0.67319566",
"0.66940475",
"0.6688948",
"0.6681928",
"0.6645544",
"0.66418326",
"0.66191876",
"0.660763",
"0.65678394",
"0.65310395",
"0.6529694",
"0.6524177",
"0.65020883",
"0.6487801",
"0.6467241",
"0.64630175",
"0.6403341",
"0.6397874",
"0.63893276",
"0.6350455",
"0.6343353",
"0.63429904",
"0.63429904",
"0.63227046",
"0.6303501",
"0.6302832",
"0.62944454",
"0.6294022",
"0.62060237",
"0.62060237",
"0.620489",
"0.620462",
"0.61939955",
"0.61896414",
"0.61878484",
"0.61878484",
"0.61878484",
"0.61878484",
"0.61878484",
"0.61878484",
"0.61878484",
"0.61801785",
"0.6179345",
"0.6165112",
"0.6161825",
"0.6153072",
"0.6152447",
"0.6148126",
"0.6141951",
"0.6141951",
"0.6141951",
"0.6141951",
"0.6131716",
"0.61282766",
"0.61256194",
"0.61256194",
"0.6122093",
"0.61206084",
"0.61149484",
"0.6109912",
"0.61044824",
"0.6102478",
"0.60978246",
"0.60978246",
"0.60978246",
"0.60978246",
"0.6097723",
"0.6096807",
"0.60944957",
"0.6089335",
"0.6087142",
"0.60819197",
"0.60819197",
"0.60819197",
"0.60819197",
"0.60819197",
"0.60819197",
"0.60819197",
"0.60819197",
"0.60819197",
"0.60819197",
"0.60819197",
"0.60819197"
] | 0.68732107 | 8 |
DELETE /pictures/1 DELETE /pictures/1.json | def destroy
@picture = Picture.find(params[:id])
@picture.destroy
render :json => true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @picture = Picture.find(params[:id])\n @picture.destroy\n\n respond_to do |format|\n format.html { redirect_to pictures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture = Picture.find(params[:id])\n @picture.destroy\n\n respond_to do |format|\n format.html { redirect_to pictures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture = Picture.find(params[:id])\n @picture.destroy\n\n respond_to do |format|\n format.html { redirect_to pictures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture = @album.pictures.find(params[:id]) #JRD111115\n @picture.destroy\n respond_to do |format|\n format.html { redirect_to album_pictures_url(@album), notice: 'Picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pict = Picture.find(params[:id])\n @pict.destroy if @pict\n\n respond_to do |format|\n format.html { redirect_to pictures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture = current_user.pictures.find(params[:id])\n @picture.destroy\n\n respond_to do |format|\n format.html { redirect_to pictures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pic = Pic.find(params[:id])\n @pic.destroy\n\n respond_to do |format|\n format.html { redirect_to pics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pic.destroy\n respond_to do |format|\n format.html { redirect_to pics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture = Picture.find(params[:id])\n @picture.destroy\n\n respond_to do |format|\n format.html { redirect_to pictures_url flash: {success: \"Picture was successfully deleted!\"}}\n format.json { head :no_content }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to mypictures_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture.destroy\n\n respond_to do |format|\n format.html { redirect_to pictures_url, notice: 'Picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture.destroy\n respond_to do |format|\n format.html { redirect_to pictures_url, notice: 'Picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture.destroy\n respond_to do |format|\n format.html { redirect_to pictures_url, notice: 'Picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture.destroy\n respond_to do |format|\n format.html { redirect_to pictures_url, notice: 'Picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture.destroy\n respond_to do |format|\n format.html { redirect_to pictures_url, notice: 'Picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture.destroy\n respond_to do |format|\n format.html { redirect_to pictures_url, notice: 'Picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture.destroy\n respond_to do |format|\n format.html { redirect_to pictures_url, notice: 'Picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture.destroy\n\n head :no_content\n end",
"def destroy\n @pic.destroy\n respond_to do |format|\n format.html { redirect_to pics_url, notice: 'Pic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture.destroy\n respond_to do |format|\n format.html { redirect_to album_pictures_path, notice: 'Picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo1 = Photo1.find(params[:id])\n @photo1.destroy\n\n respond_to do |format|\n format.html { redirect_to photo1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pictures_of_cat = PicturesOfCat.find(params[:id])\n @pictures_of_cat.destroy\n\n respond_to do |format|\n format.html { redirect_to pictures_of_cats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture.destroy\n respond_to do |format|\n format.html { redirect_to pictures_url, notice: \"La imagen se destruyó con éxito.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post_pic.destroy\n respond_to do |format|\n format.html { redirect_to post_pics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sample_photo.destroy\n render json: {message: 'Foto Excluida'} , status: :ok\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n render json: {status: \"success\"}, status: :ok\n end",
"def destroy\n @picture = Picture.find(params[:id])\n @picture.destroy\n\n respond_to do |format|\n format.html { redirect_to(pictures_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @picture = Picture.find(params[:id])\n @picture.destroy\n\n respond_to do |format|\n format.html { redirect_to(pictures_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to uploads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@picture = Picture.find(params[:id])\n @picture = @museum.pictures.find(params[:id])\n directory = \"public/data\"\n path = File.join(directory, @picture.name)\n if File.exist?(path)\n File.delete(path) \n end\n @picture.destroy\n\n respond_to do |format|\n #format.html { redirect_to pictures_url }\n format.html { redirect_to museum_pictures_path(@museum) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to uploads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @grm_pic = GrmPic.find(params[:id])\n @grm_pic.destroy\n\n respond_to do |format|\n format.html { redirect_to grm_pics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gallery.pics.each do |pic|\n Cloudinary::Uploader.destroy(pic.public_id.split(\"/\").last.split(\".\")[0] ,@auth) if pic.public_id.present?\n pic.delete\n end\n @gallery.delete\n respond_to do |format|\n format.html { redirect_to galleries_url, notice: 'Gallery was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @photo = Photo.find(params[:id])\r\n @photo.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to photos_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\r\n @photo = Photo.find(params[:id])\r\n @photo.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to photos_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @structure_photo.destroy\n render json: {message: 'Foto Excluida'} , status: :ok\n end",
"def destroy\n @picture = Picture.find(params[:id])\n @activity = @picture.imageable\n @picture.destroy\n\n respond_to do |format|\n format.html { redirect_to activity_pictures_path(@activity) }\n format.json { head :ok }\n end\n end",
"def destroy\n @profile_pic.destroy\n respond_to do |format|\n format.html { redirect_to profile_pics_path(@profile) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to @photo.item }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n \n imagen = @image.filename\n \n #function in manage_images.rb\n remove_image_file(imagen)\n \n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :ok }\n end\n end",
"def delete\n item = FormImage.last\n id = item[:id]\n item.destroy\n render json: {id: id}\n end",
"def destroy\n @photo.photo.destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rock_photo.destroy\n render json: {message: 'Foto Excluida'} , status: :ok\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo.destroy\n\n head :no_content\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to '/home', notice: 'You have deleted the picture' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\tCloudinary::Api.delete_resources([@foto.public_id])\n @foto.destroy\n respond_to do |format|\n format.html { redirect_to @proyecto, notice: 'Foto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture = Picture.find(params[:id])\n @picture.destroy\n\n respond_to do |format|\n format.js\n format.html { redirect_to pictures_url }\n format.json { head :ok }\n end\n \n end",
"def destroy\n @image.destroy\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image.destroy\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image.destroy\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image.destroy\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image.destroy\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image.destroy\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n head :no_content\n end",
"def destroy\n @profile_picture = ProfilePicture.find(params[:id])\n @profile_picture.destroy\n\n respond_to do |format|\n format.html { redirect_to profile_pictures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n\n # Destroy s3 objects\n aws_s3_delete(@photo.key)\n Sebitmin::Application.config.thumbnail_sizes.each do |thumbnail_size|\n aws_s3_delete(@photo[\"thumbnail_key_#{thumbnail_size}\"])\n end\n\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @baby_pic = BabyPic.find(params[:id])\n @baby_pic.destroy\n\n respond_to do |format|\n format.html { redirect_to baby_pics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture = Picture.find(params[:id])\n picture_id = @picture.id\n @picture.image.destroy\n @picture.destroy\n\n respond_to do |format|\n format.js { render :layout => false }\n format.json { render json:{message: 'Файл удален с сервера', id: picture_id}}\n end\n end",
"def destroy\n @photoid = Photoid.find(params[:id])\n @photoid.destroy\n\n respond_to do |format|\n format.html { redirect_to photoids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to @photo.photoable }\n format.json { head :no_content }\n end\n end",
"def destroy\n Image.find(params[:id]).destroy\n respond_to do |format|\n format.html { redirect_to images_url, notice: 'Image was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n File.delete(Rails.root.join(\"app\",'assets','images',@photo.path))\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end",
"def picture_delete\n @memorial = Memorial.find(params[:id])\n p = Picture.find(params[:picture])\n p.destroy\n redirect_to :action => \"show\", :id => @memorial\n end",
"def destroy\n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to(images_url) }\n format.json { head :ok }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n gallery = @photo.gallery\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to gallery_path(gallery) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = @allbum.photos.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to allbum_photos_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n #Finds selected image\n @image = Image.find(params[:id])\n #destroy image\n @image.destroy\n respond_to do |format|\n format.html { redirect_to '/admin' }\n format.json { head :ok }\n end\n end",
"def destroy\n @locweb_thepic.destroy\n respond_to do |format|\n format.html { redirect_to locweb_thepics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_picture.destroy\n respond_to do |format|\n format.html { redirect_to item_pictures_url, notice: 'Item picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n \t@album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :ok }\n end\n end",
"def delete photo_id\n @flickr.photos.delete(photo_id: photo_id)\n end",
"def destroy\n @picture = @album.pictures.find(params[:id])\n @picture.destroy\n flash[:notice] = 'Picture was successfully removed.'\n redirect_to(album_pictures_path(@album)) \n end",
"def destroy\n @private_album_image.destroy\n respond_to do |format|\n format.html { redirect_to private_album_images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foto.destroy\n respond_to do |format|\n format.html { redirect_to fotos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foto = Foto.find(params[:id])\n @foto.destroy\n\n respond_to do |format|\n format.html { redirect_to fotos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @image.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Image was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @img.destroy\n respond_to do |format|\n format.html { redirect_to imgs_url, notice: \"Img was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.7720266",
"0.7720266",
"0.7720266",
"0.77012306",
"0.76928186",
"0.7626824",
"0.76236266",
"0.7621202",
"0.750104",
"0.74616617",
"0.745819",
"0.7438936",
"0.7438936",
"0.7438936",
"0.7438936",
"0.7438936",
"0.7438936",
"0.7437056",
"0.7424971",
"0.74229836",
"0.7419578",
"0.74168015",
"0.7414534",
"0.7400423",
"0.73907954",
"0.73847955",
"0.7370491",
"0.7370491",
"0.73452765",
"0.7321051",
"0.7314203",
"0.7314203",
"0.7314203",
"0.7314203",
"0.7314203",
"0.7314203",
"0.7311973",
"0.7311973",
"0.7311973",
"0.7311973",
"0.7311973",
"0.7306785",
"0.72999406",
"0.728473",
"0.7271963",
"0.72708166",
"0.72708166",
"0.7268663",
"0.7259363",
"0.7255023",
"0.7249774",
"0.7249215",
"0.7249215",
"0.72314227",
"0.7231124",
"0.7230684",
"0.7229887",
"0.7225",
"0.7217008",
"0.7217008",
"0.7217008",
"0.7217008",
"0.7217008",
"0.7217008",
"0.7217008",
"0.72105443",
"0.720706",
"0.72054964",
"0.7197517",
"0.719631",
"0.719631",
"0.719631",
"0.719631",
"0.719631",
"0.719631",
"0.7190257",
"0.71878403",
"0.71846133",
"0.7176669",
"0.7174583",
"0.7163655",
"0.71629816",
"0.71582115",
"0.71577483",
"0.7149859",
"0.71495247",
"0.71385163",
"0.71361613",
"0.7135354",
"0.7130523",
"0.7127937",
"0.71273947",
"0.71264493",
"0.71153283",
"0.7110948",
"0.71049756",
"0.7099107",
"0.70963854",
"0.7090695",
"0.7085404"
] | 0.7794452 | 0 |
At the top of your file, add a method that takes an array and an item as parameters, and returns the array with the item added. | def add_to_array(arr, value)
arr.push(value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_item(array, item)\n\tarray << item\nend",
"def add_to_array(array, item)\n array << item\nend",
"def add_item(array, item)\n\tarray.push(item)\nend",
"def add_to_array(array, item)\n\tarray += [item]\n\tp array\nend",
"def add_to_array!(array, item)\n array << item\nend",
"def add_item(elective_array, item)\n elective_array.push(item)\n puts elective_array\nend",
"def added(array)\nend",
"def add_item(item)\r\n \[email protected](item)\r\n end",
"def << item\n @items << item\n end",
"def add_item(title, price, quantity = 1)\n item = {\n title: title,\n price: price,\n quantity: quantity\n}\n\n\n@items_array << item\n@total += price * quantity\n\n\nend",
"def add_broccoli(array)\n array << \"broccoli\"\n puts array\nend",
"def add_rutabaga_to_array(an_array_param)\n an_array_param << \"rutabaga\"\nend",
"def add_item(electives, item)\n puts electives.push(\"debate club\")\nend",
"def add_value(item)\n array.push(item)\n end",
"def add(item)\n #push item into the array\n @array << item\n view\n end",
"def add_to_array(arr, str) # define a method with an array and a string\n new_array = arr << str # create a new array with the array and add the string\n \n p new_array\n \nend",
"def we_can_add_things(x)\n array = [ 1, 2, 3]\n array.push(x)\nend",
"def add_item(item)\n @get_items << item\n end",
"def add_to_array(arr, a)\r\n\treturn_array = arr\r\n\treturn_array << a\r\nend",
"def add_ay(array)\n array.push(\"ay\")\nend",
"def <<(item)\n @items << item\n end",
"def add_item(new_item)\n grocery_list.push(new_item)\n return grocery_list \nend",
"def push(item); end",
"def push(item)\n end",
"def add_item item\n @items << item\n @@all_items << item\n end",
"def append(array,input)\n array << input\n return array\nend",
"def push(*items)\n items = _ensure_array_is_valid items\n super\n end",
"def addItem(item)\n @items << item\n end",
"def add_to_back(item)\n @array << item\n end",
"def push_elements_into_array(array, new_element)\n array.push new_element\nend",
"def push *items\n @items.concat items\n end",
"def <<(item)\n add!(item)\n end",
"def make_array(item1, item2, item3)\n\tarray = [item1, item2, item3]\n\n\tarray\nend",
"def using_push (array, string)\n return array.push(string)\nend",
"def using_push(array, string)\n array.push(string)\nend",
"def using_push(array, string)\n array.push(string)\nend",
"def using_push(array, string)\n array.push(string)\nend",
"def using_push(array, string)\n array.push(string)\nend",
"def double_array(array)\n # your code here\nend",
"def using_push(array, string)\n array = array.push(string)\n \nend",
"def add_item(grocery_list, new_item_to_add, quanity)\n\tgrocery_list[new_item_to_add] = quanity\n\tp grocery_list\n\nend",
"def using_push(array, string)\n return array.push(string)\nend",
"def add_item(grocery_list, item, quantity=1)\n grocery_list[item] = quantity\n return grocery_list\nend",
"def add_item(grocery_list, item, quantity=1)\r\n grocery_list[item]= quantity\r\n \r\nend",
"def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend",
"def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend",
"def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend",
"def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend",
"def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend",
"def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend",
"def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend",
"def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend",
"def array_method(input)\n\treturn \"thanks for the sweet array!\"\nend",
"def end_arr_add(arr, element)\n # Add `element` to the end of the Array variable `arr` and return `arr`\n arr.push(element)\n return arr\nend",
"def add_item(title, price, quantity = 1)\n @total += price*quantity\n @instance_items << [title, price, quantity]\nend",
"def add(*args); elements.add(*args); end",
"def double_array(array)\n array + array\nend",
"def update_event_list(array)\n array.push(\"cycling\")\nend",
"def get_items\n\t\t@arr\n\tend",
"def add_item(item, grocery_list, quantity = 1)\n grocery_list[item] = quantity\n return grocery_list\nend",
"def add_item(item, grocery_list, quantity = 1)\n grocery_list[item] = quantity\n return grocery_list\nend",
"def add_item(list, name, quantity = 1) \r\n# input: item name and optional quantity\r\n# steps: \r\n# create add method with name and optional quantity arguments\r\n# add name and quantity to hash\r\n list[name] = quantity\r\n# output: print \"your item has been added to the hash\"\r\n return list\r\nend",
"def add_item(list, item, qty = 1)\n list[item] = qty\n return list\nend",
"def add_item(item)\n\t\[email protected](item)\n\tend",
"def add_item(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend",
"def push_elements_into_array(arr, ele)\n arr.push(ele)\n arr\nend",
"def initialize array_of_items\n\tend",
"def add_element_to_end_of_array(array, element)\n array << element \nend",
"def add_item(new_item)\n item = Item.new(new_item)\n items.push(item)\n end",
"def using_push(array, str)\n array.push(str)\nend",
"def using_push(array, str)\n array.push(str)\nend",
"def array_with_two_elements\n [1,2]\nend",
"def add_item(grocery_list, item_name, qty = 1)\r\n\tgrocery_list[item_name] = qty\r\n\treturn grocery_list\r\nend",
"def append(target_array, value_to_append)\n target_array << value_to_append\nend",
"def add_to_array(x, y)\n combined_array = x\n combined_array.push(y)\nend",
"def add_item(groccery_items, item)\n groccery_items[item] = 1\n p groccery_items\nend",
"def make_item_list\n end",
"def add_item(grocery_list, item, qty)\n grocery_list[item] = qty \n grocery_list\nend",
"def using_push(arr, string)\n arr.push(string)\nend",
"def addItem(item)\n @toDoListArray.push(item)\n end",
"def add_new_gift(gifts_array, new_gift)\r\n gifts_array << new_gift\r\nend",
"def add_product(products, new_product)\n products.push(new_product)\nend",
"def array_concat(array_1, array_2)\n # Your code here\n array_1 + array_2 # trying out implicit return\nend",
"def push(element)\n # IMPLEMENT ME!\n end",
"def add_item(grocery_list, item, quantity=1)\n grocery_list[item] = quantity\n grocery_list\nend",
"def mutliplied(array)\nend",
"def add_element_to_end_of_array(array, element)\n array << element\nend",
"def add_item!(list, item, qty=1)\r\n list[item] = qty\r\n list\r\nend",
"def add_item(list, item, quantity)\n #list = item.push\n list[item] = quantity.to_i\n list\nend",
"def add_item(shopping_list, item, quantity=1)\r\n\r\n\tshopping_list[item] = quantity\r\n#\treturn shopping_list\r\nend",
"def add_item(list_item,user_list)\n#user_list is later defined/used to store a new list of information created when create_list method is called.\n#Uses create_list method to format information properly before allowing edits and updates to be done. \n#user_list = create_list(string) \n user_list[list_item] = 1\n user_list\nend",
"def index_arr_add(arr, index, element)\n # Add `element` at position `index` to the Array variable `arr` and return `arr`\n return arr.insert(index, element)\nend",
"def push *items\n @components ||= []\n @components.push items\n self\n end",
"def method2(a, b, c)\n\tx = []\n\tx << a\n\tx << b\n\tx << c\nend",
"def add(item)\n @items << item unless include?(item)\n end",
"def add(*args); end",
"def add_item (list, item, qty)\n list[item]=qty\nend",
"def add_item(list, item, qty = 1)\n list[item] = qty\n\n list\nend",
"def add_item(grocery_list, new_item, new_quant=1)\r\n grocery_list[new_item] = new_quant\r\n p grocery_list\r\nend",
"def add_an_item(grocery_list, new_item, qty = 1)\n grocery_list[new_item] = qty\n grocery_list\nend"
] | [
"0.7831222",
"0.77694875",
"0.7735271",
"0.75432",
"0.75103503",
"0.7368812",
"0.7130133",
"0.7085374",
"0.69466776",
"0.6819663",
"0.68095666",
"0.6808823",
"0.6781232",
"0.6770126",
"0.6708251",
"0.6668714",
"0.66675544",
"0.66139007",
"0.66086584",
"0.6591497",
"0.65496397",
"0.65259266",
"0.64829624",
"0.6462967",
"0.6399442",
"0.6384244",
"0.6375832",
"0.63722795",
"0.6357605",
"0.6315003",
"0.63015926",
"0.6291976",
"0.62636364",
"0.6261386",
"0.62559724",
"0.62559724",
"0.62559724",
"0.62559724",
"0.62386036",
"0.6230703",
"0.6217504",
"0.621547",
"0.6212619",
"0.61979836",
"0.619718",
"0.619718",
"0.619718",
"0.619718",
"0.619718",
"0.619718",
"0.619718",
"0.619718",
"0.6183544",
"0.61796796",
"0.6177268",
"0.6140407",
"0.6137573",
"0.613676",
"0.61360097",
"0.61359495",
"0.61359495",
"0.6133478",
"0.61310333",
"0.61263025",
"0.61256367",
"0.6122723",
"0.61206114",
"0.61019045",
"0.6092236",
"0.6088336",
"0.6088336",
"0.6084344",
"0.60667145",
"0.6066297",
"0.6044064",
"0.6037482",
"0.6028373",
"0.60238236",
"0.6022524",
"0.6021734",
"0.6021472",
"0.60147774",
"0.59731966",
"0.59726954",
"0.59639126",
"0.59586906",
"0.59516144",
"0.5944561",
"0.593947",
"0.59392154",
"0.59347796",
"0.59336895",
"0.5931449",
"0.59311473",
"0.59276646",
"0.59233564",
"0.5922205",
"0.59187216",
"0.5918128",
"0.59156126"
] | 0.6370342 | 28 |
Defines column filter for param. | def filter(param, type:, operation:, column: nil, required: false, format_value: nil)
query_param = param.to_s.underscore
column ||= param.to_s.underscore
op = operations.fetch(operation.to_sym) { raise ArgumentError, "unknown operation #{operation}" }
sql = op.call(column, query_param, type)
raw_filter(param, sql:, required:, format_value:, query_param:, array: op.array)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_orm_filters\n filters = [[]]\n date_format = I18n.t(:\"date.formats.default\", {:locale => I18n.locale })\n self.data_grid.columns.each_with_index do |col, col_index|\n if col.filter and !col.filter_value.blank?\n case col.filter\n when :boolean\n filters[0] << \"#{col.filter_by} = ?\"\n filters << (col.filter_value == '1') ? true : false\n when :auto\n filters[0] << \"#{col.filter_by} = ?\"\n filters << col.filter_value\n when :text\n filters[0] << \"#{col.filter_by} #{ActiveRecord::Base.connection.adapter_name.downcase.to_sym == :postgresql ? 'ILIKE' : 'LIKE'} ?\"\n filters << \"%#{col.filter_value}%\"\n when :number\n filters[0] << \"#{col.filter_by} = ?\"\n filters << col.filter_value.to_i\n when :range\n range = col.filter_value.split(DataGrid.range_separator)\n\n if !range[0].blank? and !range[1].blank?\n begin\n range[0] < 2\n rescue\n range[0] = range[0].to_f\n range[1] = range[1].to_f\n end\n filters[0] << \"#{col.filter_by} >= ? AND #{col.filter_by} <= ?\"\n filters << range[0]\n filters << range[1]\n elsif range[0].blank? and !range[1].blank?\n begin\n range[1] < 2\n rescue\n range[1] = range[1].to_f\n end\n filters[0] << \"#{col.filter_by} <= ?\"\n filters << range[1]\n elsif range[1].blank? and !range[0].blank?\n begin\n range[0] < 2\n rescue\n range[0] = range[0].to_f\n end\n filters[0] << \"#{col.filter_by} >= ?\"\n filters << range[0]\n end\n\n when :date\n range = col.filter_value.split(DataGrid.range_separator)\n\n if !range[0].blank? and !range[1].blank?\n begin\n range[0] < 2\n rescue\n range[0] = DateTime.strptime(range[0], date_format)\n range[1] = DateTime.strptime(range[1], date_format)\n end\n filters[0] << \"#{col.filter_by} >= ? AND #{col.filter_by} <= ?\"\n filters << range[0]\n filters << range[1]\n elsif range[0].blank? and !range[1].blank?\n begin\n range[1] < 2\n rescue\n range[1] = DateTime.strptime(range[1], date_format)\n end\n filters[0] << \"#{col.filter_by} <= ?\"\n filters << range[1]\n elsif range[1].blank? and !range[0].blank?\n begin\n range[0] < 2\n rescue\n range[0] = DateTime.strptime(range[0], date_format)\n end\n filters[0] << \"#{col.filter_by} >= ?\"\n filters << range[0]\n end\n end\n end\n end\n \n filters[0] = filters[0].join(' AND ')\n filters\n end",
"def filter_column(col, expression)\n raise \"Must call autofilter() before filter_column()\" if @filter_count == 0\n # raise \"Incorrect number of arguments to filter_column()\" unless @_ == 2\n\n # Check for a column reference in A1 notation and substitute.\n if col =~ /^\\D/\n # Convert col ref to a cell ref and then to a col number.\n no_use, col = substitute_cellref(col + '1')\n end\n col_first = @filter_area[2]\n col_last = @filter_area[3]\n\n # Reject column if it is outside filter range.\n if (col < col_first or col > col_last)\n raise \"Column '#{col}' outside autofilter() column range \" +\n \"(#{col_first} .. #{col_last})\";\n end\n\n tokens = extract_filter_tokens(expression)\n\n unless (tokens.size == 3 or tokens.size == 7)\n raise \"Incorrect number of tokens in expression '#{expression}'\"\n end\n\n\n tokens = parse_filter_expression(expression, tokens)\n\n @filter_cols[col] = Array.new(tokens)\n @filter_on = 1\n end",
"def raw_filter(param, sql:, query_param: nil, required: false, format_value: nil, array: false)\n param = param.to_sym\n raise ArgumentError, \"filter with param #{param} already defined\" if filters.key?(param)\n\n query_param ||= param.to_s.underscore\n format_value ||= ->(value, _opts) { value }\n filters[param] = Filter.new(param:, sql:, query_param:, required:, format_value:, array:)\n end",
"def make_filter(value, columns_mapped_to=nil)\n {@column_qualified => value}\n end",
"def cell_filtering_params\n params.fetch(:cell_filtering, {})\n end",
"def filter(column, options={}, &block)\n @filters ||= []\n @filters << Filter.new(@params, column, options, &block)\n end",
"def filter(name, options = {})\n name = name.to_s\n options.each { |k,v| options[k] = v.to_s if Symbol === v }\n \n # Adds the new value to the sql_filters hash\n #\n self.sql_filters ||= {}\n self.sql_filters[name] = options\n self.sql_filters[name][:type] ||= :string\n\n if human_name = options.delete(:human_name)\n name.instance_variable_set('@human_name', human_name)\n def name.humanize; @human_name; end\n end\n \n columns << ActiveRecord::ConnectionAdapters::Column.new(\n name,\n sql_filters[name][:default],\n sql_filters[name][:type],\n options.include?(:null) ? options[:null] : true\n )\n \n # raise ArgumentError.new(\"unknown option(s) #{options.inspect}\") unless options.empty?\n end",
"def filter\n params['filter_field'] || '*'\n end",
"def Filter=(arg0)",
"def set_param_column(val)\n define_attr_method :param_column, val\n end",
"def set_param_column(val)\n define_attr_method :param_column, val\n end",
"def filter\n @filter_params.each do |key, val|\n # Strip empty values from the array if the given value is an array.\n val.select!{ |val| !val.to_s.empty? } if val.is_a?(Array)\n\n # Convert key if it starts with a column name.\n key = key.slice(@model_method_name.length + 1, key.length) if key.start_with?(\"#{@model_method_name}_\")\n\n if @force_filter_for && @force_filter_for.include?(key)\n ret = @args[:filter].call(:key => key, :val => val, :query => @query)\n @query = ret if ret\n elsif @model.column_names.include?(key)\n if val.is_a?(Array) && val.empty?\n # Ignore.\n else\n @query = @query.where(key => val)\n end\n elsif match = key.to_s.match(/^(.+)_like$/) and @model.column_names.include?(match[1])\n next if val.blank?\n table = @model.arel_table\n \n val.to_s.strip.split(/\\s+/).each do |str|\n @query = @query.where(table[match[1].to_sym].matches(\"%#{escape(str)}%\"))\n end\n elsif @args[:filter]\n ret = @args[:filter].call(:key => key, :val => val, :query => @query)\n @query = ret if ret\n else\n raise \"Dont know what to do regarding filter with key: '#{key}'.\"\n end\n end\n end",
"def sort_column\n Book.column_names.include?(params[:books_filter_sort]) ? params[:books_filter_sort] : \"average_rating\"\n end",
"def column_display param, column_name\n defined?(param[:searchable][:col]).nil? ? true : param[:searchable][:col].include?(column_name) ? true : false\n end",
"def prepare_data_for_filters\n self.data_grid.columns.each do |col|\n next if col.filter.nil? # if no filter\n\n # Prepare auto filters\n if col.filter == :auto\n self.data_grid.in_data.each do |d|\n if col.sort_by.class == Symbol\n col.filter_data << d.send(col.sort_by)\n else\n # Call lambda\n col.filter_data << col.field.call(d, self.data_grid)\n end\n end\n\n col.filter_data.uniq!\n col.filter_data.sort!\n end\n end\n end",
"def column_filter_conditions_for(table, type)\n values = column_filters[type].join(', ')\n foreign_key = type.singularize.foreign_key\n\n if table == type\n \"\\\\`id\\\\` in (#{ values })\"\n elsif columns_for(table).include?(foreign_key)\n \"\\\\`#{ foreign_key }\\\\` in (#{ values })\"\n end\n end",
"def add_filter_param(param, value)\n @mg_params[filter_param_name.to_sym][param] = value unless @mg_params[filter_param_name.to_sym].key?(param)\n end",
"def csv_filter_params\n params.require(:csv_filter).permit(:name, :csv_attribute_id, :before_value, :after_value, :compare_value, :csv_operator_id)\n end",
"def do_params_filter scope\n filter_params.each do |k,value|\n if value.present?\n if self.class.custom_filter_fields[k].present?\n scope = self.class.custom_filter_fields[k].call scope, value\n elsif resource_class.column_names.include? k\n if resource_class.columns_hash[k].type == :boolean\n if value == '0'\n puts \"Should filter\"\n scope = scope.where(k => [false,nil])\n else\n scope = scope.where(k => true)\n end\n else\n scope = scope.where(k => value)\n end\n elsif resource_class.reflect_on_association(k.to_sym).present?\n klass = resource_class.reflect_on_association(k.to_sym).klass\n scope = do_inner_params_filter klass, value, scope\n else\n Rails.logger.warn(\"No filter is available for field #{k}\")\n end\n end\n end\n scope\n end",
"def prepare_orm_data_for_filters\n self.data_grid.columns.each do |col|\n next if col.filter.nil? # if no filter\n\n # Prepare auto filters\n if col.filter == :auto\n col.filter_data = self.data_grid.data_class.select(\"DISTINCT (#{col.filter_by}) as fc\").to_a.to_a.map(&:fc)\n end\n\n col.filter_data.uniq!\n col.filter_data.sort!\n end\n end",
"def data_grid_filter(data_grid, column)\n hidden_submit_input = '<input type=\"submit\" value=\"\" style=\"width:0px; height: 0px; border: none; padding: 0px; font-size: 0px\">'.html_safe\n output = ''\n col_index = data_grid.columns.index(column)\n case column.filter\n when :boolean\n filter_select_name = \"filter_#{data_grid.name}_#{col_index}\"\n base_url = url_for(data_grid.params.merge(filter_select_name => nil))\n output = select_tag(filter_select_name,\n options_for_select([[I18n.t('data_grid.all_options'), ''], [I18n.t('data_grid.option_true'), '1'], [I18n.t('data_grid.option_false'), '0']], column.filter_value),\n :onchange => \"window.location.href='#{base_url}#{(base_url.include?('?')) ? '&' : '?' }#{filter_select_name}=' + this.value\")\n when :auto\n filter_select_name = \"filter_#{data_grid.name}_#{col_index}\"\n base_url = url_for(data_grid.params.merge(filter_select_name => nil))\n output = select_tag(filter_select_name,\n options_for_select([[I18n.t('data_grid.all_options'), '']] + column.filter_data.map{|fd| [column.auto_filter_hash.nil? ? fd : column.auto_filter_hash[fd.to_s.to_sym], fd]}, column.filter_value),\n :onchange => \"window.location.href='#{base_url}#{(base_url.include?('?')) ? '&' : '?' }#{filter_select_name}=' + this.value\")\n \n when :text\n filter_input_name = \"filter_#{data_grid.name}_#{col_index}\"\n base_url = url_for(data_grid.params.merge(filter_input_name => nil))\n output = form_tag(base_url, :method => 'GET') do\n text_field_tag(filter_input_name, column.filter_value) + \n data_grid_dump_as_hidden_fields(data_grid, [filter_input_name]) + \n hidden_submit_input\n end\n when :number\n filter_input_name = \"filter_#{data_grid.name}_#{col_index}\"\n base_url = url_for(data_grid.params.merge(filter_input_name => nil))\n output = form_tag(base_url, :method => 'GET') do\n text_field_tag(filter_input_name, column.filter_value, :class => 'data_grid_filter_input') + \n data_grid_dump_as_hidden_fields(data_grid, [filter_input_name]) + \n hidden_submit_input\n end\n when :range\n filter_input_name_from = \"filter_#{data_grid.name}_#{col_index}_from\"\n filter_input_name_to = \"filter_#{data_grid.name}_#{col_index}_to\"\n base_url = url_for(data_grid.params.merge(filter_input_name_from => nil, filter_input_name_to => nil))\n output = form_tag(base_url, :method => 'GET') do\n data_grid_dump_as_hidden_fields(data_grid, [filter_input_name_from, filter_input_name_to]) + \n text_field_tag(filter_input_name_from, column.filter_value.to_s.split(DataGrid.range_separator)[0], :class => 'data_grid_filter_input') + \n ' - ' + \n text_field_tag(filter_input_name_to, column.filter_value.to_s.split(DataGrid.range_separator)[1], :class => 'data_grid_filter_input') +\n hidden_submit_input\n end\n \n when :date \n date_format = I18n.t(:\"date.formats.default\", {:locale => I18n.locale })\n filter_input_name_from = \"filter_#{data_grid.name}_#{col_index}_from\"\n filter_input_name_to = \"filter_#{data_grid.name}_#{col_index}_to\"\n form_id = \"filter_#{data_grid.name}_#{col_index}_form\"\n \n base_url = url_for(data_grid.params.merge(filter_input_name_from => nil, filter_input_name_to => nil))\n output = \"<form method='get' action='#{base_url}' id='#{form_id}'>\"\n output << data_grid_dump_as_hidden_fields(data_grid, [filter_input_name_from, filter_input_name_to])\n \n date_picker, datepicker_placeholder_id, trigger_id, dom_id, date_span_id = select_date_datetime_common(\n {:id => \"filter_#{data_grid.name}_#{col_index}_from\", :name => filter_input_name_from}, data_grid.params[filter_input_name_from], form_id)\n\n output << \"#{I18n.t('data_grid.filter_date_from')}: <span id=\\\"#{datepicker_placeholder_id}\\\">#{date_picker}</span>\"\n output << %(<script type=\"text/javascript\">\\n)\n output << %( Calendar.setup\\({\\n)\n output << %( button : \"#{trigger_id}\",\\n )\n output << %( ifFormat : \"#{date_format}\",\\n )\n output << %( inputField : \"#{dom_id}\",\\n )\n output << %( include_blank : true,\\n )\n output << %( singleClick : true,\\n)\n output << %( onClose : function(cal){handleCalendarClose(cal, \"#{dom_id}\", \"#{form_id}\");}\\n)\n output << %( }\\);\\n)\n output << %(</script><br />\\n)\n \n date_picker, datepicker_placeholder_id, trigger_id, dom_id, date_span_id = select_date_datetime_common(\n {:id => \"filter_#{data_grid.name}_#{col_index}_to\", :name => filter_input_name_to}, data_grid.params[filter_input_name_to], form_id)\n\n output << \"#{I18n.t('data_grid.filter_date_to')}: <span id=\\\"#{datepicker_placeholder_id}\\\">#{date_picker}</span>\"\n output << %(<script type=\"text/javascript\">\\n)\n output << %( Calendar.setup\\({\\n)\n output << %( button : \"#{trigger_id}\",\\n )\n output << %( ifFormat : \"#{date_format}\",\\n )\n output << %( inputField : \"#{dom_id}\",\\n )\n output << %( include_blank : true,\\n )\n output << %( singleClick : true,\\n)\n output << %( onClose : function(cal){handleCalendarClose(cal, \"#{dom_id}\", \"#{form_id}\");}\\n)\n output << %( }\\);\\n)\n output << %(</script>\\n)\n \n output << hidden_submit_input\n output << '</form>'\n \n else\n output = ' '\n end\n\n raw output\n end",
"def init_filters\n\n @filters = Hash.new\n\n # set all column filters to the @default_filter\n @headers.each do |column_name|\n @filters[column_name] = @default_filter\n end\n \n end",
"def set_cell_filtering\n @cell_filtering = CellFiltering.find(params[:id])\n end",
"def set_filter(val)\n @filter = val\n build_path_query\n @filter\n end",
"def filter(name, function)\n filters = (self.model.design_doc['filters'] ||= {})\n filters[name.to_s] = function\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def column_params\n params.fetch(:column, {}).permit(:title)\n end",
"def boolean_filter(column, filter)\n val = filter[:value]\n mode = filter[:mode] || 'and'\n\n # In case we decide to allow string values\n # column_name = column.scan(/\\.(.*)/).flatten.last\n # flags_map = send :\"#{column_name}_flags\"\n # val = val.map{ |v| flags_map[v.to_sym] }.compact.reduce{ |v, t| v & t }\n\n decompose = ->(flags) do\n vals = []\n n = 1\n (Math.log2(flags).ceil+1).times do\n vals.push(n) if n & flags > 0\n n = n << 1\n end\n vals\n end\n\n m = ->(v) do\n \"(#{column} & #{v} > 0)\"\n end\n\n if val.kind_of?(Array) && val.all?{|v| v.is_a? String}\n val = SimpleFlaggableColumn.symbols_to_flags(val.map(&:to_sym), Game.send(:\"#{column}_flags\"), false)\n end\n\n if val.kind_of?(Fixnum) and val > 0\n\n if mode == 'xor'\n vals = decompose.call(val)\n if vals.size > 1\n sql = vals.map{ |v, i|\n other = (vals - [v]).map(&m)\n sub_sql = [m.call(v), *other].join(' AND NOT ')\n \"(#{sub_sql})\"\n }.join(' OR ')\n else\n sql = \"(#{column} = #{vals[0]})\"\n end\n elsif mode == 'or'\n sql = m.call(val)\n else\n vals = decompose.call(val)\n sql = vals.map{|v| m.call(v) }.join(' AND ')\n end\n\n sql\n else\n nil\n end\n end",
"def to_param\n \"filter[#{name}]=#{value}\"\n end",
"def filter=(val)\n set_filter(val)\n val\n end",
"def filter_parameters=(_arg0); end",
"def filter_parameters=(_arg0); end",
"def filter_clause\n @filters[filter % @filters.size] unless @filters.size.zero?\n end",
"def apply_filter\n end",
"def param_column?\n column_names.include?(param_column)\n end",
"def param_column?\n column_names.include?(param_column)\n end",
"def similar_list_page_with_filter column, option\n filter_hash = (params[:filter] || {}).dup\n filter_hash[column] = option\n filter_hash.delete column unless option\n similar_list_page :filter => filter_hash\n end",
"def apply_filter(data, filter_model)\n filter_type = filter_model.filter_type\n variable_name = filter_model.variable_name;\n value1 = filter_model.value1\n value2 = filter_model.value2\n\n case filter_type\n when 'equals'\n filter_hash = Hash.new\n filter_hash[variable_name] = value1\n data = data.where(filter_hash)\n\n when 'not_equals'\n filter_hash = Hash.new\n filter_hash[variable_name] = value1\n data = data.where.not(filter_hash)\n\n when 'greater_than'\n data = data.where(\"#{variable_name} > ?\", value1)\n\n when 'greater_than_or_equal'\n data = data.where(\"#{variable_name} >= ?\", value1)\n\n when 'less_than'\n data = data.where(\"#{variable_name} < ?\", value1)\n\n when 'less_than_or_equal'\n data = data.where(\"#{variable_name} <= ?\", value1)\n\n when 'from_to'\n data = data.where(\"#{variable_name} >= ? AND #{variable_name} <= ?\", value1, value2)\n\n else\n data\n end\n end",
"def filter_on=(value)\n @filter_on = value\n end",
"def filtro_particular(conscaso, params_filtro)\n return conscaso\n end",
"def set_filter(opts)\n opts = check_params(opts,[:filters])\n super(opts)\n end",
"def set_filters\n @filters = ''\n @filters.concat(\"status:'Available'\")\n unless @manufacturer_or_publisher.blank?\n @filters.concat(\" AND (manufacturer:'#{@manufacturer_or_publisher}'\")\n @filters.concat(\" OR publisher:'#{@manufacturer_or_publisher}')\")\n end\n @filters.concat(\" AND category:'#{@category}'\") unless @category.blank?\n @filters.concat(\" AND seller_name:'#{@seller_name}'\") unless @seller_name.blank?\n end",
"def process_reaktor_column(rco, attr_name, row)\n begin\n val = Filter.apply_filters(row[attr_name], row, rco.filters)\n rescue Exception\n STDERR.puts \"row: #{row.inspect}\"\n raise\n end\n Log.write_log(rco.table, \"Setting column: #{rco.inspect} value = #{val.inspect}\")\n return [rco.name,val]\nend",
"def column_param_prefix\n @column_param_prefix ||= 'c'\n end",
"def to_scope\r\n\r\n table_name = @model.table_name\r\n\r\n @filtering_attributes.select { |attr|\r\n @filtering_values.key?(attr)\r\n }.reduce(@model.scoped) { |model_scope, attr|\r\n\r\n filtering_value = @filtering_values[attr]\r\n\r\n filtering_column_type = @model.attribute_type(attr)\r\n\r\n column_sql = %'\"#{ table_name }\".\"#{ attr }\"'\r\n\r\n case filtering_column_type\r\n when :string\r\n case filtering_value\r\n when Set\r\n model_scope.where(\"#{ column_sql } IN (?)\", filtering_value)\r\n else\r\n model_scope.where(\"#{ column_sql } LIKE ?\", filtering_value)\r\n end\r\n\r\n when :boolean\r\n model_scope.where(\"#{ column_sql } = ?\", filtering_value)\r\n\r\n when :integer\r\n case filtering_value\r\n when Hash\r\n new_model_scope = model_scope\r\n if filtering_value.key?(:min)\r\n unless filtering_value[:min] == -Float::INFINITY\r\n new_model_scope =\r\n model_scope.where(\"#{ column_sql } >= ?\", filtering_value[:min])\r\n end\r\n end\r\n if filtering_value.key?(:max)\r\n unless filtering_value[:max] == Float::INFINITY\r\n new_model_scope =\r\n model_scope.where(\"#{ column_sql } <= ?\", filtering_value[:max])\r\n end\r\n end\r\n new_model_scope\r\n when Set\r\n model_scope.where(\"#{ column_sql } IN (?)\", filtering_value)\r\n when Range\r\n new_model_scope = model_scope\r\n unless filtering_value.first == -Float::INFINITY\r\n new_model_scope =\r\n model_scope.where(\"#{ column_sql } >= ?\", filtering_value.first)\r\n end\r\n unless filtering_value.last == Float::INFINITY\r\n new_model_scope =\r\n if filtering_value.exclude_end?\r\n model_scope.where(\"#{ column_sql } < ?\", filtering_value.last)\r\n else\r\n model_scope.where(\"#{ column_sql } <= ?\", filtering_value.last)\r\n end\r\n end\r\n new_model_scope\r\n else\r\n model_scope.where(\"#{ column_sql } = ?\", filtering_value)\r\n end\r\n\r\n when :date\r\n case filtering_value\r\n when Hash\r\n new_model_scope = model_scope\r\n if filtering_value.key?(:from)\r\n new_model_scope =\r\n model_scope.where(\"#{ column_sql } >= ?\", filtering_value[:from])\r\n end\r\n if filtering_value.key?(:until)\r\n new_model_scope =\r\n model_scope.where(\"#{ column_sql } <= ?\", filtering_value[:until])\r\n end\r\n new_model_scope\r\n when Set\r\n model_scope.where(\"#{ column_sql } IN (?)\", filtering_value)\r\n when Range\r\n new_model_scope = model_scope\r\n unless filtering_value.first == -Float::INFINITY\r\n new_model_scope =\r\n model_scope.where(\"#{ column_sql } >= ?\", filtering_value.first)\r\n end\r\n unless filtering_value.last == Float::INFINITY\r\n new_model_scope =\r\n if filtering_value.exclude_end?\r\n model_scope.where(\"#{ column_sql } < ?\", filtering_value.last)\r\n else\r\n model_scope.where(\"#{ column_sql } <= ?\", filtering_value.last)\r\n end\r\n end\r\n new_model_scope\r\n else\r\n model_scope.where(\"#{ column_sql } = ?\", filtering_value)\r\n end\r\n else\r\n model_scope\r\n end\r\n }\r\n end",
"def param_filter *args, **kwds, &blk\n if blk\n ParamFilter.with_block( self, *args, **kwds, &blk )\n else\n ParamFilter.with_methods( self, *args, **kwds )\n end\n end",
"def filters=(_arg0); end",
"def filters=(_arg0); end",
"def column_params\n params.require(:column).permit(:name)\n end",
"def sort_col\n params[:sort] || \"name\"\n end",
"def columnIsFiltered?(header)\n return @options[:filteredColumns] &&\n @options[:filteredColumns].is_a?(Array) &&\n @options[:filteredColumns].include?(header)\n end",
"def update\n @filter = Filter.find(params[:id])\n \n where = Hash.new\n columns = []\n params.each do |param, value|\n if (param.include?('with_')) && (!value.nil?)\n where[param] = value\n end \n \n if (param.include?('column_')) && (!value.nil?)\n columns << \"#{value}\"\n end\n end\n\n @filter.where = where \n @filter.columns = \"'#{columns.join(\",\")}'\"\n\n respond_to do |format|\n if @filter.update_attributes(params[:filter])\n format.html { redirect_to(filters_path, :notice => 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @filter.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_param\n send \"#{param_column}=\", to_param if param_column?\n end",
"def set_param\n send \"#{param_column}=\", to_param if param_column?\n end",
"def set_SearchColumn(value)\n set_input(\"SearchColumn\", value)\n end",
"def set_SearchColumn(value)\n set_input(\"SearchColumn\", value)\n end",
"def condition_names_for_column\n [condition_type_name]\n end",
"def column_params\n params.fetch(:column, {}).permit(\n :span_xs, :span_sm, :alignment, :viewport, :pivot, :background_color,\n :gradient_color, :gradient_type, :gradient_direction, :gradient_balance\n )\n end",
"def param_column\n self.class.param_column\n end",
"def param_column\n self.class.param_column\n end",
"def filters\n end",
"def filter_index\n filter\n end",
"def filter(name, value=true)\n name = name.to_sym\n raise NameError, \":#{name} isn't in the defined filters\" unless @model.defined_filters.include? name\n new_filters = @options[:filters] + [[name, value]]\n\n chain_scope filters: new_filters\n end",
"def set_filters\n @filters ||= begin\n filters = []\n filters << { attribute: Gemgento::ProductAttribute.find_by!(code: 'color'), value: params[:color] } unless params[:color].blank?\n filters\n end\n end",
"def global_filter=(_arg0); end",
"def sort_column_param\n params[:sort_column] || 'entry_date'\n end",
"def add_boolean_scopes(col)\n if self.column_names.include?(col.to_s)\n # have to freeze the column name in place. By the time lambda is evaluated,\n # col is long gone.\n politely_add_named_scope :\"#{col}\", lambda { where( :\"#{col}\" => true ) } \n politely_add_named_scope :\"not_#{col}\", lambda { where( :\"#{col}\" => false ) }\n end\n end",
"def filter\n params[:filter] ? params[:filter] : \"active\"\n end",
"def get_combobox_options(params)\n column_name = params[:column]\n CONDITIONS.each { |c| column_name.sub!(/_#{c}$/, \"\") }\n super(:column => column_name)\n end",
"def get_filter_name(field, model = nil)\n field_name = model.present? ? \"#{model.table_name}.#{field}\" : field\n \"#{name}[#{filter_param_name}][#{field_name}]\"\n end",
"def select_column_by_kv h, k, v, column = nil, method_name = :filter_by_kv\n filtered = method(method_name).call h, k, v\n column && filtered.map {|h1| h1[column]} || (!column) && filtered\n end",
"def add_filter\n @filter = true \n end",
"def sort_column_param\n params[:sort_column] || 'application_date'\n end",
"def filter\n @filter = params[:q]\n end",
"def sort_column\n Admin::Coleccion.column_names.include?(params[:sort]) ? params[:sort] : \"nombre\" \n end",
"def apply_attribute_filter(filter, value)\n self.scope = scope.where(filter => value)\n end",
"def set_session_filter(table_name)\r\n if params[:filter] == 'off' # clear all values\r\n session[table_name][:filter] = nil\r\n return\r\n end\r\n\r\n filter_value = if params[:filter_value].nil?\r\n# NIL indicates that no filtering is needed \r\n '#NIL'\r\n else \r\n if params[:filter_value].class == String and params[:filter_value][0] == '@'\r\n# Internal value. Remove leading @ and evaluate expression\r\n expression = DcInternals.get(params[:filter_value])\r\n eval(expression) rescue nil\r\n else\r\n# No filter when empty \r\n params[:filter_value] == '' ? '#NIL' : params[:filter_value] \r\n end\r\n end\r\n# if filter field parameter is omitted then just set filter value\r\n session[table_name][:filter] =\r\n if params[:filter_field].nil?\r\n saved = YAML.load(session[table_name][:filter])\r\n saved['value'] = filter_value\r\n saved.to_yaml\r\n else \r\n# As field defined. Split name and alternative input field\r\n field = if params[:filter_field].match(' as ')\r\n params[:filter_input] = params[:filter_field].split(' as ').last.strip\r\n params[:filter_field].split(' as ').first.strip\r\n else\r\n params[:filter_field]\r\n end\r\n# \r\n {'field' => field, \r\n 'operation' => params[:filter_oper], \r\n 'value' => filter_value,\r\n 'input' => params[:filter_input],\r\n 'table' => table_name }.to_yaml\r\n end\r\n# must be. Otherwise kaminari includes parameter on paging\r\n params[:filter] = nil \r\n params[:filter_id] = nil \r\n params[:filter_oper] = nil \r\n params[:filter_input] = nil \r\n params[:filter_field] = nil \r\nend",
"def add_integer_or_float_scopes(col)\n if self.column_names.include?(col.to_s)\n politely_add_named_scope :\"#{col}_greater_than\", lambda { |amt| where( \"#{col} > ?\", amt ) }\n politely_add_named_scope :\"#{col}_less_than\", lambda { |amt| where( \"#{col} < ?\", amt ) }\n politely_add_named_scope :\"#{col}_in_range\", lambda { |*args|\n if args.first.is_a?(Range)\n where :\"#{col}\" => args.first \n elsif args.length == 2\n where :\"#{col}\" => args.first..args.last \n else\n raise ArgumentError.new(\"Wrong number of arguments.\")\n end\n }\n\n add_order_scopes(col)\n end\n end",
"def sort_column\n # sortable_columns.include?(params[:column]) ? params[:column] : \"name\"\n # if params[:column] == \"postalCode\"\n # logger.info \"##0############### POSTAL ##################\"\n # \"postalCode\"\n # else\n params[:column] ? params[:column] : \"updated_at\"\n # end\n end",
"def parse_filters(params)\n if params['filters'].blank?\n Utilities::Geo::REGEXP_COORD.keys\n else\n params.permit(filters: [])[:filters].map(&:to_sym)\n end\n end",
"def add_boolean_scopes(col)\n if self.column_names.include?(col.to_s)\n politely_add_named_scope :\"#{col}\", { :conditions => { :\"#{col}\" => true } }\n politely_add_named_scope :\"not_#{col}\", { :conditions => { :\"#{col}\" => false } }\n end\n end",
"def add_integer_or_float_scopes(col)\n if self.column_names.include?(col.to_s)\n politely_add_named_scope :\"#{col}_greater_than\", lambda { |amt| { :conditions => [\"#{col} > ?\", amt] } }\n politely_add_named_scope :\"#{col}_less_than\", lambda { |amt| { :conditions => [\"#{col} < ?\", amt] } }\n politely_add_named_scope :\"#{col}_in_range\", lambda { |*args|\n if args.first.is_a?(Range)\n { :conditions => { :\"#{col}\" => args.first } }\n elsif args.length == 2\n { :conditions => { :\"#{col}\" => args.first..args.last } }\n else\n raise ArgumentError.new(\"Wrong number of arguments.\")\n end\n }\n\n add_order_scopes(col)\n end\n end",
"def param_column?\n self.class.param_column?\n end",
"def param_column?\n self.class.param_column?\n end",
"def filter\n @filter ||= filter_class.new default_filter\n end",
"def option_filter_value option\n option = \"#{option}_filter\"\n params[option].present? && params[option] != 'All' && params[option]\n end",
"def filter\n @filter\n end",
"def add_filter(filter_argument = T.unsafe(nil), &filter_proc); end",
"def filter(filtering_params)\n\t\t\tresults = self.where(nil)\n\t\t\tfiltering_params.each do |key, value|\n\t\t\t\tresults = results.public_send(key, value) if value.present?\n\t\t\tend\n\t\t\tresults\n\t\tend",
"def filtering_params(params)\n params.slice(:user, :minprice, :maxprice, :status, :sortby, :pricesort, :datesort)\n end",
"def filter_argument; end",
"def ts_apply_filters\n # TODO: Make filters for Thinking Sphinx\n end",
"def where criteria\n unless(criteria.keys - VALID_FILTERS).empty?\n raise ArgumentError, 'Invalid filter criteria'\n end\n criteria.each{|k,v| criteria[k] = v.to_s}\n @filter.merge! criteria\n self\n end",
"def sort_column\n %w(name email role).include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def sort_column\n %w(name email role).include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def named_filter; end",
"def permitted_filter(params, key)\n params[key] = self[key] if has_key? key\n end",
"def filter_params\n params.require(:filter).permit(:name, :description, :opt_in)\n end",
"def column_range range\n unless range.instance_of? Google::Cloud::Bigtable::ColumnRange\n raise RowFilterError, \"Range type mustbe ColumnRange\"\n end\n @grpc.column_range_filter = range.to_grpc\n self\n end"
] | [
"0.6918216",
"0.66111094",
"0.657951",
"0.65015215",
"0.6492924",
"0.64537555",
"0.63216335",
"0.62943935",
"0.6292374",
"0.62292796",
"0.62292796",
"0.6217071",
"0.6198962",
"0.61800224",
"0.6122546",
"0.6117841",
"0.6110038",
"0.6035985",
"0.60352445",
"0.6014545",
"0.601044",
"0.59011096",
"0.5895453",
"0.5870282",
"0.5840574",
"0.5831153",
"0.5831153",
"0.58116865",
"0.58093524",
"0.5768078",
"0.57538545",
"0.57509923",
"0.57509923",
"0.5748913",
"0.5745131",
"0.57440704",
"0.57440704",
"0.5734642",
"0.5734294",
"0.57278347",
"0.5718303",
"0.5698435",
"0.5683494",
"0.56746185",
"0.5670291",
"0.56673765",
"0.5666747",
"0.56266195",
"0.56266195",
"0.5617484",
"0.56068224",
"0.5578172",
"0.5568101",
"0.5559038",
"0.5559038",
"0.55581677",
"0.55581677",
"0.55547065",
"0.55416495",
"0.5533662",
"0.5533662",
"0.55291617",
"0.55287063",
"0.5519066",
"0.55163217",
"0.550878",
"0.5500165",
"0.5493949",
"0.54896915",
"0.54889596",
"0.54848576",
"0.5481969",
"0.5473464",
"0.5468678",
"0.54659355",
"0.54590267",
"0.5456742",
"0.5442383",
"0.5438422",
"0.54310054",
"0.5429152",
"0.5428365",
"0.5423625",
"0.5418774",
"0.5418774",
"0.540692",
"0.54034024",
"0.54016805",
"0.5394715",
"0.53921765",
"0.536848",
"0.5367284",
"0.53661877",
"0.53661734",
"0.536329",
"0.536329",
"0.536157",
"0.5352893",
"0.5350947",
"0.53476655"
] | 0.6594887 | 2 |
Defines raw filter for param via SQL condition. | def raw_filter(param, sql:, query_param: nil, required: false, format_value: nil, array: false)
param = param.to_sym
raise ArgumentError, "filter with param #{param} already defined" if filters.key?(param)
query_param ||= param.to_s.underscore
format_value ||= ->(value, _opts) { value }
filters[param] = Filter.new(param:, sql:, query_param:, required:, format_value:, array:)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter\n params['filter_field'] || '*'\n end",
"def Filter=(arg0)",
"def filter(param, type:, operation:, column: nil, required: false, format_value: nil)\n query_param = param.to_s.underscore\n column ||= param.to_s.underscore\n op = operations.fetch(operation.to_sym) { raise ArgumentError, \"unknown operation #{operation}\" }\n sql = op.call(column, query_param, type)\n raw_filter(param, sql:, required:, format_value:, query_param:, array: op.array)\n end",
"def filter\n @filter = params[:q]\n end",
"def get_filters_sql\n if self.filters.blank?\n return ''\n else\n conditions = JSON.parse self.filters\n sql_array = []\n conditions.each do |condition|\n if condition['values']\n values = condition['values'].map{|x| \"'#{x}'\"}.join(',')\n sql_array << \" #{condition['name']} in (#{values})\"\n else\n sql_array << \" #{condition['name']} between #{condition['from']} and #{condition['to']}\"\n end\n end\n sql_array.join(' AND ')\n end\n end",
"def filter_clause\n @filters[filter % @filters.size] unless @filters.size.zero?\n end",
"def to_param\n \"filter[#{name}]=#{value}\"\n end",
"def do_params_filter scope\n filter_params.each do |k,value|\n if value.present?\n if self.class.custom_filter_fields[k].present?\n scope = self.class.custom_filter_fields[k].call scope, value\n elsif resource_class.column_names.include? k\n if resource_class.columns_hash[k].type == :boolean\n if value == '0'\n puts \"Should filter\"\n scope = scope.where(k => [false,nil])\n else\n scope = scope.where(k => true)\n end\n else\n scope = scope.where(k => value)\n end\n elsif resource_class.reflect_on_association(k.to_sym).present?\n klass = resource_class.reflect_on_association(k.to_sym).klass\n scope = do_inner_params_filter klass, value, scope\n else\n Rails.logger.warn(\"No filter is available for field #{k}\")\n end\n end\n end\n scope\n end",
"def filters_sql\n if filters.blank?\n ''\n else\n conditions = JSON.parse filters\n sql_array = []\n conditions.each do |condition|\n if condition['values']\n values = condition['values'].map { |x| \"'#{x}'\" }.join(',')\n sql_array << \" #{condition['name']} in (#{values})\"\n else\n sql_array << \" #{condition['name']} between #{condition['from']} and #{condition['to']}\"\n end\n end\n sql_array.join(' AND ')\n end\n end",
"def filter\n @filter_params.each do |key, val|\n # Strip empty values from the array if the given value is an array.\n val.select!{ |val| !val.to_s.empty? } if val.is_a?(Array)\n\n # Convert key if it starts with a column name.\n key = key.slice(@model_method_name.length + 1, key.length) if key.start_with?(\"#{@model_method_name}_\")\n\n if @force_filter_for && @force_filter_for.include?(key)\n ret = @args[:filter].call(:key => key, :val => val, :query => @query)\n @query = ret if ret\n elsif @model.column_names.include?(key)\n if val.is_a?(Array) && val.empty?\n # Ignore.\n else\n @query = @query.where(key => val)\n end\n elsif match = key.to_s.match(/^(.+)_like$/) and @model.column_names.include?(match[1])\n next if val.blank?\n table = @model.arel_table\n \n val.to_s.strip.split(/\\s+/).each do |str|\n @query = @query.where(table[match[1].to_sym].matches(\"%#{escape(str)}%\"))\n end\n elsif @args[:filter]\n ret = @args[:filter].call(:key => key, :val => val, :query => @query)\n @query = ret if ret\n else\n raise \"Dont know what to do regarding filter with key: '#{key}'.\"\n end\n end\n end",
"def filter(*cond, &block)\n clause = (@opts[:having] ? :having : :where)\n cond = cond.first if cond.size == 1\n raise(Error::InvalidFilter, \"Invalid filter specified. Did you mean to supply a block?\") if cond === true || cond === false\n cond = transform_save(cond) if @transform if cond.is_a?(Hash)\n cond = filter_expr(block || cond)\n cond = SQL::BooleanExpression.new(:AND, @opts[clause], cond) if @opts[clause] && !@opts[clause].blank?\n clone(clause => cond)\n end",
"def set_filter(val)\n @filter = val\n build_path_query\n @filter\n end",
"def filter\n params[:filter] ? params[:filter] : \"active\"\n end",
"def filter(filter)\n @query[:q] << \"filter:#{filter}\"\n self\n end",
"def create_filter(filter)\n return nil,nil if filter.nil?\n\n db_adapter = MongoDBConv.new(@current_var, true) #do push 'or'\n\n db_expr,hop_expr = filter.db_conv(@parent, db_adapter) \n end",
"def prepare_orm_filters\n filters = [[]]\n date_format = I18n.t(:\"date.formats.default\", {:locale => I18n.locale })\n self.data_grid.columns.each_with_index do |col, col_index|\n if col.filter and !col.filter_value.blank?\n case col.filter\n when :boolean\n filters[0] << \"#{col.filter_by} = ?\"\n filters << (col.filter_value == '1') ? true : false\n when :auto\n filters[0] << \"#{col.filter_by} = ?\"\n filters << col.filter_value\n when :text\n filters[0] << \"#{col.filter_by} #{ActiveRecord::Base.connection.adapter_name.downcase.to_sym == :postgresql ? 'ILIKE' : 'LIKE'} ?\"\n filters << \"%#{col.filter_value}%\"\n when :number\n filters[0] << \"#{col.filter_by} = ?\"\n filters << col.filter_value.to_i\n when :range\n range = col.filter_value.split(DataGrid.range_separator)\n\n if !range[0].blank? and !range[1].blank?\n begin\n range[0] < 2\n rescue\n range[0] = range[0].to_f\n range[1] = range[1].to_f\n end\n filters[0] << \"#{col.filter_by} >= ? AND #{col.filter_by} <= ?\"\n filters << range[0]\n filters << range[1]\n elsif range[0].blank? and !range[1].blank?\n begin\n range[1] < 2\n rescue\n range[1] = range[1].to_f\n end\n filters[0] << \"#{col.filter_by} <= ?\"\n filters << range[1]\n elsif range[1].blank? and !range[0].blank?\n begin\n range[0] < 2\n rescue\n range[0] = range[0].to_f\n end\n filters[0] << \"#{col.filter_by} >= ?\"\n filters << range[0]\n end\n\n when :date\n range = col.filter_value.split(DataGrid.range_separator)\n\n if !range[0].blank? and !range[1].blank?\n begin\n range[0] < 2\n rescue\n range[0] = DateTime.strptime(range[0], date_format)\n range[1] = DateTime.strptime(range[1], date_format)\n end\n filters[0] << \"#{col.filter_by} >= ? AND #{col.filter_by} <= ?\"\n filters << range[0]\n filters << range[1]\n elsif range[0].blank? and !range[1].blank?\n begin\n range[1] < 2\n rescue\n range[1] = DateTime.strptime(range[1], date_format)\n end\n filters[0] << \"#{col.filter_by} <= ?\"\n filters << range[1]\n elsif range[1].blank? and !range[0].blank?\n begin\n range[0] < 2\n rescue\n range[0] = DateTime.strptime(range[0], date_format)\n end\n filters[0] << \"#{col.filter_by} >= ?\"\n filters << range[0]\n end\n end\n end\n end\n \n filters[0] = filters[0].join(' AND ')\n filters\n end",
"def filter(name, options = {})\n name = name.to_s\n options.each { |k,v| options[k] = v.to_s if Symbol === v }\n \n # Adds the new value to the sql_filters hash\n #\n self.sql_filters ||= {}\n self.sql_filters[name] = options\n self.sql_filters[name][:type] ||= :string\n\n if human_name = options.delete(:human_name)\n name.instance_variable_set('@human_name', human_name)\n def name.humanize; @human_name; end\n end\n \n columns << ActiveRecord::ConnectionAdapters::Column.new(\n name,\n sql_filters[name][:default],\n sql_filters[name][:type],\n options.include?(:null) ? options[:null] : true\n )\n \n # raise ArgumentError.new(\"unknown option(s) #{options.inspect}\") unless options.empty?\n end",
"def _init_sql_where_condition\n last_association_model = @association_chain.target_model\n actual_field = Babik::Table::Field.new(last_association_model, @selected_field).real_field\n @sql_where_condition = Babik::Selection::Operation::Base.factory(\n \"#{target_alias}.#{actual_field}\", @operator, @value\n )\n end",
"def get_filter_sql\n filter_sql = \"( \"\n self.foreach_filter do |filter|\n filter_sql += \"#{filter.get_filter_sql} #{filter.next_condition_as_sql} \"\n end\n filter_sql += \")\"\n return filter_sql\n end",
"def name\n \"\\\"#{filter_name}\\\" = \\\"#{filter_value}\\\"\"\n end",
"def parse_filter(filter_argument = T.unsafe(nil), &filter_proc); end",
"def to_sql\n return nil unless filters.present? and valid?\n filters.map { |n, f| sql_for(n) }.reject(&:blank?).join(' AND ')\n end",
"def apply_attribute_filter(filter, value)\n self.scope = scope.where(filter => value)\n end",
"def filter(name, value=true)\n name = name.to_sym\n raise NameError, \":#{name} isn't in the defined filters\" unless @model.defined_filters.include? name\n new_filters = @options[:filters] + [[name, value]]\n\n chain_scope filters: new_filters\n end",
"def filter_on=(value)\n @filter_on = value\n end",
"def buil_must_query_filter\n query_filter = [{ 'range' => date_range_filter }]\n query_filter | @raw_query\n end",
"def filter\r\n q = self.query\r\n return nil if q.nil?\r\n filter_name = q.ole_methods.detect{|m| m.to_s =~ /Filter\\Z/}\r\n return nil if filter_name.nil?\r\n q.send(filter_name.to_s.to_sym)\r\n end",
"def convert_filter_to_mongo_query(filter) \n filter\n end",
"def apply_filter(data, filter_model)\n filter_type = filter_model.filter_type\n variable_name = filter_model.variable_name;\n value1 = filter_model.value1\n value2 = filter_model.value2\n\n case filter_type\n when 'equals'\n filter_hash = Hash.new\n filter_hash[variable_name] = value1\n data = data.where(filter_hash)\n\n when 'not_equals'\n filter_hash = Hash.new\n filter_hash[variable_name] = value1\n data = data.where.not(filter_hash)\n\n when 'greater_than'\n data = data.where(\"#{variable_name} > ?\", value1)\n\n when 'greater_than_or_equal'\n data = data.where(\"#{variable_name} >= ?\", value1)\n\n when 'less_than'\n data = data.where(\"#{variable_name} < ?\", value1)\n\n when 'less_than_or_equal'\n data = data.where(\"#{variable_name} <= ?\", value1)\n\n when 'from_to'\n data = data.where(\"#{variable_name} >= ? AND #{variable_name} <= ?\", value1, value2)\n\n else\n data\n end\n end",
"def add_filter(filter_argument = T.unsafe(nil), &filter_proc); end",
"def set_filters\n @filters = ''\n @filters.concat(\"status:'Available'\")\n unless @manufacturer_or_publisher.blank?\n @filters.concat(\" AND (manufacturer:'#{@manufacturer_or_publisher}'\")\n @filters.concat(\" OR publisher:'#{@manufacturer_or_publisher}')\")\n end\n @filters.concat(\" AND category:'#{@category}'\") unless @category.blank?\n @filters.concat(\" AND seller_name:'#{@seller_name}'\") unless @seller_name.blank?\n end",
"def apply_filter(relation)\n relation.where(@q.filter.to_sql, *@q.values)\n end",
"def filter\n @filter ||= filter_class.new default_filter\n end",
"def substitute_file_filters(sql)\n sql.scan(/:file_filtering_conditions_for_[a-z_]+/) do |file_filter|\n if file_filter.present?\n resource_name = file_filter.sub(':file_filtering_conditions_for_', '')\n ffcond = file_filtering_conditions resource_name\n sql = sql.sub(file_filter, ffcond)\n end\n end\n sql\n end",
"def filter_parameters=(_arg0); end",
"def filter_parameters=(_arg0); end",
"def query_filter(query)\n if has_filter_params?\n conditions = @build.parse(@filter)\n apply_conditions(query, conditions)\n else\n query\n end\n end",
"def add_filter_param(param, value)\n @mg_params[filter_param_name.to_sym][param] = value unless @mg_params[filter_param_name.to_sym].key?(param)\n end",
"def where(*cond)\n return super if block_given?\n\n filters_per_role = self.cache_get(:filters_per_role) || init_filters([])\n\n Array.wrap(cond).each do |condition|\n filters = case condition\n when Hash\n hash_condition_to_filters(condition)\n when Sequel::SQL::BooleanExpression\n boolean_expression_to_filters(condition)\n else\n raise \"Unsupported condition type: #{condition.class}\"\n end\n\n append_filters(filters_per_role, filters)\n end\n\n dataset = self.from(RoleDataset.build(filters_per_role))\n dataset.cache_set(:filters_per_role, filters_per_role)\n dataset\n end",
"def searchUsing(filter)\n @zqlQuery = filter\n end",
"def search_condition\n if search_support? && params[:q].present?\n clause = search_columns.collect {|f| \"#{model_class.table_name}.#{f} LIKE ?\" }.\n join(\" OR \")\n param = \"%#{params[:q]}%\"\n [\"(#{clause})\"] + [param] * search_columns.size\n end\n end",
"def filter(filter)\n current_widget.filter filter\n end",
"def build_filter filter, fields\n where = [fields.map { |f| \"#{f} like ?\" }.join(\" || \")]\n fields.count.times { |n| where << \"%#{filter}%\" }\n where\n end",
"def where_clause\n \"\"\n end",
"def filter=(val)\n set_filter(val)\n val\n end",
"def apply_filter(query)\n query\n end",
"def apply_filter(query)\n query\n end",
"def attribute_condition(argument)\n case argument\n when nil then \"IS ?\"\n when Array, ActiveRecord::Associations::AssociationCollection then \"IN (?)\"\n when Range then \"BETWEEN ? AND ?\"\n else \"= ?\"\n end\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))\n when :integer\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) = #{value.first.to_i})\"\n else\n sql = \"#{db_table}.#{db_field} = #{value.first.to_i}\"\n end\n when :float\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \")\"\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \"))\"\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})\" if field == \"status_id\"\n when \"><t-\"\n # between today - n days and today\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)\n when \">t-\"\n # >= today - n days\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, nil)\n when \"<t-\"\n # <= today - n days\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n # = n days in past\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \"><t+\"\n # between today and today + n days\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i)\n when \">t+\"\n # >= today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n # <= today + n days\n sql = relative_date_clause(db_table, db_field, nil, value.first.to_i)\n when \"t+\"\n # = today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n # = today\n sql = relative_date_clause(db_table, db_field, 0, 0)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1)\n when \"m\"\n # = this month\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"lm\"\n # = last month\n date = Date.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"y\"\n # = this year\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year)\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def filter_expr(expr)\n case expr\n when Hash\n SQL::BooleanExpression.from_value_pairs(expr)\n when Array\n if String === expr[0]\n filter_expr(expr.shift.gsub(QUESTION_MARK){literal(expr.shift)}.lit)\n else\n SQL::BooleanExpression.from_value_pairs(expr)\n end\n when Proc\n expr.to_sql(self).lit\n when SQL::NumericExpression, SQL::StringExpression\n raise(Error, \"Invalid SQL Expression type: #{expr.inspect}\") \n when Symbol, SQL::Expression\n expr\n when String\n \"(#{expr})\".lit\n else\n raise(Error, 'Invalid filter argument')\n end\n end",
"def filter_expr(*args, &block)\n schema_utility_dataset.literal(schema_utility_dataset.send(:filter_expr, *args, &block))\n end",
"def filter_expr(*args, &block)\n schema_utility_dataset.literal(schema_utility_dataset.send(:filter_expr, *args, &block))\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))\n when :integer\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) = #{value.first.to_i})\"\n else\n sql = \"#{db_table}.#{db_field} = #{value.first.to_i}\"\n end\n when :float\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \")\"\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \"))\"\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})\" if field == \"status_id\"\n when \">t-\"\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)\n when \"<t-\"\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \">t+\"\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i)\n when \"t+\"\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n sql = relative_date_clause(db_table, db_field, 0, 0)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1)\n when \"m\"\n # = this month\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"lm\"\n # = last month\n date = Date.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"y\"\n # = this year\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year)\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def filter_argument; end",
"def get_filter_sql\n return @schema_filter.filter_sql\n end",
"def search filter\n if filter && is_searchable?\n filter = [filter, Chronic.parse(filter).strftime(\"%Y-%m-%d\")] rescue filter\n handle_joins(self.fields, scoped.select(\"DISTINCT(`#{self.table_name}`.`id`), `#{self.table_name}`.*\"))\n .where(build_filter(filter, self.fields))\n else\n scoped\n end\n end",
"def filter\n @filter\n end",
"def create_sql_for_reward_condition condition, tag_string, checkin_time\n case condition\n when RewardCondition::RC_DRINK_TYPE\n filter_condition = \"value NOT IN (#{tag_string})\" #drinks of a certain type\n when RewardCondition::RC_BEFORE_TIME\n filter_condition = \"CAST(value as integer) < #{checkin_time}\" #drinks before a certain time\n when RewardCondition::RC_AFTER_TIME\n filter_condition = \"CAST(value as integer) > #{checkin_time}\" #drinks after a certain time\n end\n \"condition_type = #{condition} AND #{filter_condition}\"\n end",
"def filtro_particular(conscaso, params_filtro)\n return conscaso\n end",
"def global_filter=(_arg0); end",
"def filters=(_arg0); end",
"def filters=(_arg0); end",
"def filter(filtering_params)\n\t\t\tresults = self.where(nil)\n\t\t\tfiltering_params.each do |key, value|\n\t\t\t\tresults = results.public_send(key, value) if value.present?\n\t\t\tend\n\t\t\tresults\n\t\tend",
"def add_filter\n @filter = true \n end",
"def where(condition, *params)\n raise 'Invalid params count in where clause!' unless condition.count('?') == params.count\n\n params.each do |param|\n condition.sub!('?', param.to_s)\n end\n\n conditions = condition.gsub(/\\s+/, ' ').split(/and/i)\n\n conditions.each do |condition|\n attribute, operator, value = condition.split(' ')\n\n raise 'Invalid attribute in where clause!' unless model.attributes.keys.include?(attribute)\n raise 'Invalid operator in where clause!' unless self.class.where_mapping.keys.include?(operator)\n raise 'Parameter in where clause is not an integer!' if !(value =~ /\\A[-+]?[0-9]+\\z/)\n\n method_name = \"#{model.filterable_attributes[attribute]}__#{self.class.where_mapping[operator]}\"\n parameters[method_name] = value\n end\n\n self\n end",
"def apply_filter\n end",
"def filter_expr(*args, &block)\n schema_utility_dataset.literal(schema_utility_dataset.send(:filter_expr, *args, &block))\n end",
"def conditions_clause\n cc = conditions.dup\n cc << filter_clause\n cc.compact.map{|c| @resource.send(:sanitize_sql_for_conditions, c)} * ' AND '\n end",
"def filter_expr(arg=nil, &block)\n if arg.is_a?(Proc) && !block\n block = arg\n arg = nil\n elsif arg.is_a?(String)\n arg = Sequel.lit(arg)\n elsif arg.is_a?(Array)\n if arg.first.is_a?(String)\n arg = Sequel.lit(*arg)\n elsif arg.length > 1\n arg = Sequel.&(*arg)\n end\n end\n schema_utility_dataset.literal(schema_utility_dataset.send(:filter_expr, arg, &block))\n end",
"def make_filter(value, columns_mapped_to=nil)\n {@column_qualified => value}\n end",
"def filter(name, function)\n filters = (self.model.design_doc['filters'] ||= {})\n filters[name.to_s] = function\n end",
"def clean_filter(value)\n value = @filters[value] if value.is_a? Symbol\n ActiveRecord::Type::Boolean.new.cast(value)\n end",
"def filter_params\n params.fetch(:filter, {}).permit(:text, :type)\n end",
"def apply_filters(query)\n query\n end",
"def apply_filter(query, filter, value)\n return [query] if query.blank? || filter.blank? || value.blank?\n return [query] if filter.noop?\n\n klass = filter.klass || query.klass\n column = filter.column\n value = filter.values.call(value) if filter.values.present?\n\n queries = []\n\n if column.present?\n target_column = \"#{klass.table_name}.#{column}\"\n\n if filter.data_type == DateTime\n target_column = \"date_trunc('second', #{target_column})\"\n end\n\n vals = Array(value)\n value = []\n q = []\n\n vals.each do |val|\n if klass.columns_hash[column.to_s] && klass.columns_hash[column.to_s].type == :integer && !(val.to_s.strip =~ /\\A\\d+\\Z/)\n q << '0 = 1'\n else\n q << \"LOWER(#{target_column}::varchar) LIKE LOWER(?)\"\n value << \"%#{val}%\"\n end\n end\n\n queries << \"(#{q.join(' OR ')})\" if q.any?\n elsif filter.query.present?\n query, query_list, value_list = filter.query.call(query, value)\n queries = Array(query_list)\n value = Array(value_list)\n elsif filter.having.present?\n query = query.having(\"LOWER((#{filter.having})::varchar) LIKE ?\", \"%#{Array(value).first}%\")\n end\n\n [query, queries, value]\n end",
"def set_session_filter(table_name)\r\n if params[:filter] == 'off' # clear all values\r\n session[table_name][:filter] = nil\r\n return\r\n end\r\n\r\n filter_value = if params[:filter_value].nil?\r\n# NIL indicates that no filtering is needed \r\n '#NIL'\r\n else \r\n if params[:filter_value].class == String and params[:filter_value][0] == '@'\r\n# Internal value. Remove leading @ and evaluate expression\r\n expression = DcInternals.get(params[:filter_value])\r\n eval(expression) rescue nil\r\n else\r\n# No filter when empty \r\n params[:filter_value] == '' ? '#NIL' : params[:filter_value] \r\n end\r\n end\r\n# if filter field parameter is omitted then just set filter value\r\n session[table_name][:filter] =\r\n if params[:filter_field].nil?\r\n saved = YAML.load(session[table_name][:filter])\r\n saved['value'] = filter_value\r\n saved.to_yaml\r\n else \r\n# As field defined. Split name and alternative input field\r\n field = if params[:filter_field].match(' as ')\r\n params[:filter_input] = params[:filter_field].split(' as ').last.strip\r\n params[:filter_field].split(' as ').first.strip\r\n else\r\n params[:filter_field]\r\n end\r\n# \r\n {'field' => field, \r\n 'operation' => params[:filter_oper], \r\n 'value' => filter_value,\r\n 'input' => params[:filter_input],\r\n 'table' => table_name }.to_yaml\r\n end\r\n# must be. Otherwise kaminari includes parameter on paging\r\n params[:filter] = nil \r\n params[:filter_id] = nil \r\n params[:filter_oper] = nil \r\n params[:filter_input] = nil \r\n params[:filter_field] = nil \r\nend",
"def filter(filter)\n @filters << CGI.escape(filter)\n self\n end",
"def column_filter_conditions_for(table, type)\n values = column_filters[type].join(', ')\n foreign_key = type.singularize.foreign_key\n\n if table == type\n \"\\\\`id\\\\` in (#{ values })\"\n elsif columns_for(table).include?(foreign_key)\n \"\\\\`#{ foreign_key }\\\\` in (#{ values })\"\n end\n end",
"def filter(val)\n raise \"filter requires a String.\" unless val.is_a? String\n @filter = val\n self\n end",
"def query_param(raw_query_str)\n \"query:(query_string:(analyze_wildcard:\" \\\n \"!t,query:'#{escape(raw_query_str)}'))\"\n end",
"def build_condition(argument_type = nil, column, value)\n return nil if value.blank? # Reject blank values (this means we do not want to filter on this column)\n argument_type = @condition_options[:argument_type] if argument_type.nil?\n case argument_type\n when \"string\"\n # We want to represent the condition as a string. Rails does not apply the sanitization for us (it considers the string safe), so we apply sanitization ourselves using Rails' helper methods.\n [\"#{column} = #{AllTypesObject.connection.quote(value)}\"]\n when \"list\"\n # We want to represent the condition as a list (with a string SQL statement and bind values). Rails applies the sanitization for us.\n build_list_condition(column, value)\n when \"array\"\n # We want to represent the condition as an array (with the bind values in an array). Rails applies the sanitization for us.\n # This is very similar to the list argument_type (actually, a list with a string SQL statement and bind values is mapped to an array in Rails), we only need to wrap the result in an array.\n [build_list_condition(column, value)]\n when \"hash\"\n # We want to represent the conditions as a hash. Rails applies the sanitization for us.\n # Placeholder style is ignored for hash arguments (it has no meaning)\n build_hash_condition(column, value)\n else\n raise \"Condition option argument type '#{argument_type}' not supported (it is possible Rails supports this type, but we do not).\"\n end\n end",
"def search_adding_filter(condition,value)\n conditions = params.dup[:conditions] || {}\n\n if PLURAL_FILTERS.include?(condition)\n conditions[condition] ||= []\n conditions[condition] << value\n else\n conditions[condition] = value\n end\n params.except(:quiet, :all, :facet).recursive_merge(:page => nil, :action => :show, :conditions => conditions)\n end",
"def filter_params\n params.require(:filter).permit(:template, :name, :code)\n end",
"def to_json_query_filter\n query_terms = []\n query_terms << process_condition(conditions) \n\n if query_terms.flatten.length != 0\n return \"[?#{query_terms.join(\"][?\")}]\"\n else\n return ''\n end\n \n end",
"def scope_condition\n self.class.send( :sanitize_sql_hash_for_conditions, { :owner_type => owner_type, :owner_id => owner_id } )\n end",
"def option_filter_value option\n option = \"#{option}_filter\"\n params[option].present? && params[option] != 'All' && params[option]\n end",
"def set_filter\n @filter = Filter.friendly.find(params[:id])\n end",
"def filter_callback=(value)\r\n @filter = value\r\n end",
"def raw\n if @filter === true\n 'show distinct_channels'\n elsif @filter.nil?\n 'show channels'\n elsif @filter.is_a?(Fixnum)\n 'show channels %d' % @filter\n elsif @filter.is_a?(String)\n \"show channels like '%s'\" % @filter\n else\n 'show channels'\n end\n end",
"def scaffold_search_add_condition(conditions, record, field) # :doc:\n return unless column = record.column_for_attribute(field)\n if column.klass == String\n if record.send(field).length > 0\n conditions[0] << \"#{record.class.table_name}.#{field} #{record.class.scaffold_auto_complete_search_operator} ?\"\n conditions << \"%#{record.send(field)}%\"\n end\n elsif column.klass == Object\n conditions[0] << \"#{record.class.table_name}.#{field} IS #{record.send(field) ? 'TRUE' : 'FALSE'}\"\n else\n conditions[0] << \"#{record.class.table_name}.#{field} = ?\"\n conditions << record.send(field)\n end\n end",
"def filter\n end",
"def filter(column, options={}, &block)\n @filters ||= []\n @filters << Filter.new(@params, column, options, &block)\n end",
"def crypt_keeper_filter_postgres_log(payload)\n payload.gsub(FILTER) do |_|\n \"#{$~[:operation]}([FILTERED])\"\n end\n end",
"def set_filter\n @filter = Filter.find(params[:id])\n end",
"def set_filter\n @filter = Filter.find(params[:id])\n end",
"def set_filter\n @filter = Filter.find(params[:id])\n end",
"def boolean_filter(column, filter)\n val = filter[:value]\n mode = filter[:mode] || 'and'\n\n # In case we decide to allow string values\n # column_name = column.scan(/\\.(.*)/).flatten.last\n # flags_map = send :\"#{column_name}_flags\"\n # val = val.map{ |v| flags_map[v.to_sym] }.compact.reduce{ |v, t| v & t }\n\n decompose = ->(flags) do\n vals = []\n n = 1\n (Math.log2(flags).ceil+1).times do\n vals.push(n) if n & flags > 0\n n = n << 1\n end\n vals\n end\n\n m = ->(v) do\n \"(#{column} & #{v} > 0)\"\n end\n\n if val.kind_of?(Array) && val.all?{|v| v.is_a? String}\n val = SimpleFlaggableColumn.symbols_to_flags(val.map(&:to_sym), Game.send(:\"#{column}_flags\"), false)\n end\n\n if val.kind_of?(Fixnum) and val > 0\n\n if mode == 'xor'\n vals = decompose.call(val)\n if vals.size > 1\n sql = vals.map{ |v, i|\n other = (vals - [v]).map(&m)\n sub_sql = [m.call(v), *other].join(' AND NOT ')\n \"(#{sub_sql})\"\n }.join(' OR ')\n else\n sql = \"(#{column} = #{vals[0]})\"\n end\n elsif mode == 'or'\n sql = m.call(val)\n else\n vals = decompose.call(val)\n sql = vals.map{|v| m.call(v) }.join(' AND ')\n end\n\n sql\n else\n nil\n end\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quoted_string(val)}'\"}.join(\",\") + \")\"\n when \"!\"\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quoted_string(val)}'\"}.join(\",\") + \"))\"\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n when \"<=\"\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n when \"o\"\n sql = \"#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}\" if field == \"status_id\"\n when \"c\"\n sql = \"#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}\" if field == \"status_id\"\n when \">t-\"\n sql = date_range_clause(db_table, db_field, - value.first.to_i, 0)\n when \"<t-\"\n sql = date_range_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n sql = date_range_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \">t+\"\n sql = date_range_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n sql = date_range_clause(db_table, db_field, 0, value.first.to_i)\n when \"t+\"\n sql = date_range_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n sql = date_range_clause(db_table, db_field, 0, 0)\n when \"w\"\n from = l(:general_first_day_of_week) == '7' ?\n # week starts on sunday\n ((Date.today.cwday == 7) ? Time.now.at_beginning_of_day : Time.now.at_beginning_of_week - 1.day) :\n # week starts on monday (Rails default)\n Time.now.at_beginning_of_week\n sql = \"#{db_table}.#{db_field} BETWEEN '%s' AND '%s'\" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)]\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quoted_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quoted_string(value.first.to_s.downcase)}%'\"\n when \"..\"\n from = nil\n to = nil\n sql = \"\"\n from = Date.parse(value[1])\n to = Date.parse(value[2])\n sql = value_in_date_range(db_table, db_field, from, to)\n end\n return sql\n end"
] | [
"0.68580574",
"0.6649707",
"0.6603387",
"0.6557816",
"0.6487252",
"0.64606726",
"0.63286126",
"0.6320884",
"0.6317552",
"0.6303581",
"0.6302672",
"0.6290166",
"0.62254494",
"0.6222143",
"0.6216791",
"0.62059814",
"0.61531365",
"0.6139491",
"0.61273384",
"0.61079204",
"0.60989815",
"0.6065502",
"0.6032166",
"0.60296845",
"0.602456",
"0.6023618",
"0.6023172",
"0.60141706",
"0.600969",
"0.6008999",
"0.60053766",
"0.60048926",
"0.6001745",
"0.5998981",
"0.5997667",
"0.5997667",
"0.5996574",
"0.5986096",
"0.5979039",
"0.59770346",
"0.5968388",
"0.5961583",
"0.5933232",
"0.5931534",
"0.59222245",
"0.5920203",
"0.5920203",
"0.59180295",
"0.591059",
"0.591059",
"0.59051204",
"0.5901593",
"0.589722",
"0.589722",
"0.58955544",
"0.58892226",
"0.58864594",
"0.5878434",
"0.5874049",
"0.5873152",
"0.58683425",
"0.58603984",
"0.5857994",
"0.5857994",
"0.58517236",
"0.5844966",
"0.5836453",
"0.583613",
"0.5808991",
"0.5792139",
"0.57842916",
"0.5778266",
"0.5763274",
"0.5746958",
"0.5746791",
"0.57461107",
"0.5741789",
"0.573793",
"0.5737252",
"0.57356215",
"0.5729564",
"0.57274073",
"0.5721556",
"0.5717137",
"0.5716338",
"0.57139415",
"0.5702543",
"0.56937355",
"0.56934446",
"0.5685559",
"0.56828296",
"0.5682368",
"0.5681656",
"0.5670116",
"0.56660354",
"0.566341",
"0.566341",
"0.566341",
"0.5663065",
"0.5662831"
] | 0.79207706 | 0 |
Load the contents of a JSON file into Redis Each key in the JSON file becomes a redis key. If the value is a literal then this is added as a redis keyvalue pair. If an array, then a List. If a hash, then a Hash. Nested objects will be flattened. file:: json file path:: optional, path in the json file indicating the subsection to load | def load_json(file, path=nil)
f = File.new( file )
json = JSON.parse( f.read )
if path != nil
json = Siren.query(query, json)
end
counter = 0
#TODO could support proper results, not just hash?
if json != nil
json.each_pair do |key,value|
if value.class() == Array
value.each do |v|
@redis.lpush( key, v )
end
elsif value.class == Hash
value.each_pair do |field, v|
#TODO better handling of nesting?
#E.g. convert hash or array back into JSON?
@redis.hset(key, field, v)
end
else
@redis.set(key, value)
end
counter = counter + 1
end
end
return counter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_load(file_path)\n MultiJson.load(File.read(file_path)).to_smash\n end",
"def load_hash(file_path) \n file=File.read(file_path)\n JSON.parse(file)\n end",
"def load_hash(file_path) \n file=File.read(file_path)\n JSON.parse(file)\n end",
"def load_json(file)\n type = File.basename(file, File.extname(file)).to_sym\n JSON.parse(File.read(file)).each do |allocation, settings|\n next if allocation == \"_\"\n\n settings.reject! { |k, _| k.start_with?(\"_\") }\n host = settings.delete(\"host\")\n host = intern_string(host) if host\n options = if settings.empty?\n EMPTY_HASH\n else\n settings.map { |k, v| [k.to_sym, v.is_a?(String) ? intern_string(v) : v] }.to_h.freeze\n end\n define(type, allocation, host, options)\n end\n end",
"def load_from_file!(file_path)\n raise IOError, \"File #{file_path} not exist\" unless File.exist?(file_path)\n raw_data = IO.read(file_path)\n load_from_json!(raw_data)\n end",
"def load\n @cache = JSON.parse(File.read(file))\n rescue\n @cache = {}\n end",
"def read_and_parse_file(path)\n json = JSON.parse(File.read(path))\n recursive_symbolize_keys!(json)\n end",
"def load_json(filename); end",
"def load_from_file(path)\n return unless File.exist?(path)\n json_data = File.read(path)\n load_raw_json(json_data)\n end",
"def load_data_from_file(default=json_default)\n KiJSONFile.load_json(path, default)\n end",
"def load(file)\n data = File.read(file)\n JSONL.parse(data)\n end",
"def load_list(key, file)\n f = File.new( file )\n counter = process_lines(f) do |redis,line|\n redis.lpush( key , line.chomp)\n end\n return counter \n end",
"def load\n if File.exist?(@file_path)\n\n @_cache = JSON File.open(@file_path, &:read).strip\n else\n $stderr.puts \"#{@file_path} does not exist\"\n end\n end",
"def flat_hash_from_json_file(file_path)\n JSON.parse(File.read(file_path)).path_flatten\n end",
"def load!(file)\n hash = {}\n YAML.load_file(file).each do |k, v|\n hash[Pathname(k)] = v.map{|vv| Pathname(vv) }\n end\n replace(hash)\n end",
"def reload(file=nil)\n @file = file if file\n @h = JSON.parse(IO.read(@file), :symbolize_names => true)\n self\n end",
"def from_json(filename)\n require \"json\" unless defined?(JSON)\n from_hash(JSON.parse(IO.read(filename)))\n end",
"def load_dict(filename)\n if File.exist?(filename)\n f = File.read(filename)\n @hash_dict = JSON.parse(f)\n else\n puts('read error')\n end\n end",
"def load\n sleeper = 0.0\n while File.exist? lock_file\n sleeper += 0.1 if sleeper <= 10.0\n sleep(sleeper.to_i)\n end\n # :symbolize_names does not play nicely with :create_additions\n tmp = JSON.parse(File.read(path),\n {:symbolize_names=>false, :create_additions=>true})\n @data = {}\n tmp.each_pair{ |k,v| self[k] = v }\n end",
"def read_file(path, key)\n file = IO.read(path)\n JSON.parse(file)[key]\n end",
"def populate\n file = File.read(json_file)\n storage = JSON.parse(file, :symbolize_names => true)\n\n @hashes = storage[:hashes]\n convert if @hashes.is_a? Array\n\n @hashes\n end",
"def open_data(file)\n @data = JSON.parse(IO.readlines(file).join)\n end",
"def load_file(file_name)\n File.open(file_name, 'r') do |f|\n f.each_line.collect do |line|\n parse_json(line)\n end\n end\n end",
"def load_file(file_name)\n File.open(file_name, \"r\") do |f|\n f.each_line.collect do |line|\n parse_json(line)\n end\n end\n end",
"def add_json(file)\n new_json = parse_json_file(file)\n store_all_cities(new_json)\n store_all_routes(new_json)\n end",
"def load(file = '.cookies')\n YAML.safe_load_file(file, permitted_classes: [::Symbol, ::Time]).each do |c|\n add(c.delete(:name), c.delete(:value), c)\n end\n end",
"def getHashFromJson(filename)\n File.open( filename, \"r\" ) do |f|\n JSON.load(f)\n end\nend",
"def load_from_file_cache(file)\n puts \"loading stuff from #{file}\"\n File.open(file, 'r') do |input|\n Marshal.load(input.read)\n end\n end",
"def new_from_json_file(path)\n json = ::File.read(path)\n new_from_json_string(json)\n end",
"def load_databag_json(filename)\n File.open(File.expand_path(\"../../data_bags/rubycas/#{filename}\", __FILE__), \"r\") { |f| MultiJson.load(f) }\nend",
"def add_file(path_to_file, options)\n puts \"INSIDE add_file METHOD\"\n puts \"OPTIONS: #{options.inspect}\"\n name = options[:name] || File.basename(path_to_file)\n if options[:type]\n redis_collection = new name, options[:type]\n else\n redis_collection = new name\n end\n \n IO.foreach path_to_file do |line|\n redis_collection << line\n end\n redis_collection\n end",
"def load_from_file(file_path)\n require \"erb\"\n opts = YAML.load(ERB.new(File.read(file_path)).result) || {}\n symbolize_keys(opts)\n end",
"def json(*files, **options, &block) = read(*files, parse: :json, ext: '.json', **options, &block)",
"def initialize(file_name)\n @file = File.read(file_name)\n @json_hash = JSON.parse(@file)\n end",
"def load_data(file_path)\n json_data = JSON.parse(File.read(file_path))\n @processed_favs = json_data.map do |fav|\n fav.transform_keys(&:to_sym) \n end\n\n i = 0\n while i < @processed_favs.length\n\n items = @processed_favs[i][:name]\n @fav_list << items\n\n i += 1\n end\n rescue Errno::ENOENT\n File.open(file_path, 'w+')\n File.write(file_path, [])\n retry\n end",
"def load_json(dir_path, filename)\n file_path = File.join(dir_path, filename)\n JSON.parse(File.read(file_path))\n end",
"def read_from_json\n JSON.parse File.new(@filepath).read\n end",
"def json(file_path)\n raise(format(ERROR_EXT_NOT_JSON, file_path)) unless json?(file_path)\n\n content = read_file(file_path)\n JSON.parse(content)\n end",
"def [](key, file=_root_file)\n with_file(file, key)\n end",
"def read(path)\n @file_data = ::JSON.parse(open(path).read)\n @json = @file_data\n self\n end",
"def load_json(path)\n JSON.parse(File.read(File.expand_path(path))).each do |_env, config|\n config.transform_keys!(&SNAKE_CASE) if config.is_a?(Hash)\n end.tap do |config|\n config.transform_keys!(&SNAKE_CASE)\n end\n end",
"def read_json_file(path)\n JSON.parse(File.open(path){ |f| f.read })\nend",
"def import_file! file\n # if given a file name, try opening it\n if file.instance_of? String\n _file = File.open file\n elsif file.instance_of? File\n _file = file\n else\n raise \"type not recognized: #{file.class.name}\"\n end\n\n puts \"- Iterating over keys in #{_file.inspect}\" if @verbose\n \n # iterate over keys\n YAML::load(_file).each do |env, env_hash|\n env_hash.each do |app, app_hash|\n app_hash.each do |namespace, namespace_hash|\n namespace_hash.each do |identifier, value|\n k = \"#{namespace}:#{identifier}\"\n set! k, value, app, env\n end\n end\n end\n end\n end",
"def load_json(file)\n data = ''\n f = File.open(File.join(Rails.root, 'spec', 'mocks', file)) \n f.each_line do |line|\n data += line\n end\n f.close\n JSON.parse(data)\nend",
"def load_file( file, hash = {})\n fail 'given file is nil' unless file\n hash.merge!( YAML.load_file(file) )\n end",
"def ensure_load_json(file_path, def_val, json_params = {})\n if File.exists?(file_path)\n file_data = File.read(file_path).force_encoding('utf-8')\n if file_data.size >= 2 # '[]'\n JSON.parse(file_data, json_params)\n else\n def_val\n end\n else\n def_val\n end\n end",
"def render_json(file_path, local_variables = {})\n object = load file_path, local_variables\n JSON.pretty_generate object\n end",
"def load_yaml(file)\n @data = YAML.load(File.open(file))\n\n @data[\"people\"].each do |yaml_person|\n person = Person.new(yaml_person[\"fname\"], yaml_person[\"surname\"], yaml_person[\"dob\"])\n\n yaml_person[\"emails\"].each do |e|\n person.add_email(e)\n end\n\n yaml_person[\"phones\"].each do |e|\n person.add_phone(e)\n end\n\n add(person) \n end\n end",
"def json_file_fixture(path)\n return JSON.parse(File.read(file_fixture(path)), symbolize_names: true)\n end",
"def read\n file = File.read(@filename)\n JSON.parse(file)\n end",
"def get_data_from_json_file(filename)\n file_to_parse = File.read(filename)\n data_hash = JSON.parse(file_to_parse)\n return data_hash\nend",
"def load(file)\r\n if file == String # does this work?\r\n @path = file\r\n end\r\n\r\n @reader = Reader.new(file)\r\n load_section self, @reader\r\n @reader.close\r\n end",
"def parse_json(filename)\n\tfile = File.read(filename)\n\tbegin\n \t\tdata_hash = JSON.parse(file)\n\trescue JSON::ParserError\n\t\tfile = nil\n\tend\n\tdata_hash\n end",
"def get_items_from_file()\n if(File.exists?(@filename) && !File.empty?(@filename))\n file = File.read(@filename)\n JSON.parse(file).each do |item|\n movie = Movie.new\n item.each { |key, value| movie.send(\"#{key}=\", value)}\n @items.push(movie)\n end\n end\n end",
"def parse\n file = File.read(@file)\n @data = JSON.parse(file)\n end",
"def aggregate(file)\n read_entries(file) do |data|\n ManageData.aggregate(data, file.file.chomp(File.extname(file.file)))\n end\n file.add_to_redis\n end",
"def load_table (filename)\n\t\t\tnew_table = File.open(filename)\n\t\t\t@file_table = JSON.load(new_table)\n\t\t\tnew_table.close\n\t\tend",
"def load_json(filename)\n begin\n File.open(filename, \"r\" ) do |f|\n JSON.load(f)\n end\n rescue Errno::ENOENT, TypeError => e\n puts \"You must supply a valid filename: #{e.message}\"\n exit\n end\nend",
"def readJson(dataFilePath)\n dataFile = File.new(dataFilePath, \"r\");\n data = JSON.load(dataFile);\n dataFile.close();\n data;\nend",
"def yaml_load(file_path)\n YAML.load(File.read(file_path)).to_smash\n end",
"def keys_from_file(path)\n file_keys = YAML.load_file(path)\n file_keys_shallow = Translate::Keys.to_shallow_hash(file_keys)\n\n keys_shallow = Translate::Keys.to_shallow_hash(keys)\n\n to_save_shallow = keys_shallow.slice(*file_keys_shallow.keys)\n Translate::Keys.to_deep_hash(to_save_shallow)\n end",
"def load_file(config_file)\n return unless File.exists?(config_file)\n\n file_data = YAML.load_file(config_file) || {}\n\n # set up required keys\n file_data['required'] ||= []\n file_data['required'].each do |key|\n required.push(Util.normalize(key))\n end\n\n # load up the environment-specific data\n file_data['environments'] ||= {}\n @data = file_data['environments'][environment] || {}\n end",
"def load_yaml(file)\n require 'yaml'\n tokens = YAML.load_file(file)\n tokens.each do |token, category|\n @db[token] = category\n end\n end",
"def read\n return nil unless File.file?(\"./#{filename}\")\n JSON.parse(IO.read(filename))\n end",
"def load(filename)\n json_string = String.new\n File.open(filename, \"r\") { |f| \n json_string += f.read \n }\n @score = JSON.parse json_string \n end",
"def json_from(json_file)\n JSON.parse(File.read(json_file), symbolize_names: true)\nend",
"def load_collection_from_file(filename, default)\n\n\treturn default unless File.exists?(filename)\n\t\n\tfile = File.new(filename, 'r');\n\tfile_json = file.read;\n\tfile.close;\n\tcollection = JSON.load(file_json);\n\t\n\tlog(\"Loaded #{collection.length} collection item(s) from #{filename}.\");\n\t\n\treturn collection;\nend",
"def load_yaml_data( file )\n yaml_data = {}\n yaml_data.merge!( File.open( file ) { |yf| YAML::load( yf ) } )\n\n return yaml_data\n end",
"def parse json; return JSON.parse File.read json end",
"def parse json; return JSON.parse File.read json end",
"def json_file_fixture(path)\n return JSON.parse(File.read(file_fixture(path)), symbolize_names: true)\nend",
"def load_storage\n YAML.load_file(file_path) || {}\n end",
"def load_json(filename)\n File.open(File.expand_path(\"../support/#{filename}\", __FILE__), \"r\") do |json_file|\n JSON.load(json_file)\n end\nend",
"def getFileContent(file_path)\n file = File.read(file_path)\n data_hash = JSON.parse(file)\n return data_hash\nend",
"def load_from_file(path)\n YAML.load_file(path).each { |n,v| instance_variable_set(n, v) }\n end",
"def read_json_file(filepath)\n file = File.open(filepath)\n file_data = file.read\n return JSON.parse(file_data)\nend",
"def read_jason(file_path)\r\n json_file = File.read(file_path)\r\n data_hash = JSON.parse(json_file)\r\n return data_hash\r\nend",
"def initialize(file = 'cache.yaml')\n @file = file\n @cache = YAML::Store.new(file)\n end",
"def load(key)\n redis_key = prefix(key)\n value = @redis.get(redis_key)\n Marshal.load(value) if value\n end",
"def parse_json(file = nil, symbolize = true)\n return unless file && ::File.exist?(file.to_s)\n begin\n ::JSON.parse(::File.read(file.to_s), symbolize_names: symbolize)\n rescue JSON::ParserError\n return\n end\n end",
"def read_locations_from file\n data_hash = []\n File.readlines(file).each do |line|\n data_hash << JSON.parse(line)\n end\n self.location_hash = data_hash\n self\n end",
"def load_file(file)\n buf = File.read(file)\n\n # parse the document into a Psych tree; we don't load here because we want\n # the file/line info while creating our entities.\n doc = YAML.parse(buf, filename: file)\n\n # Document should be an Array of Hashes\n seq = doc.children.first or return # ignore empty documents\n load_error!('not a yaml sequence (Array)', file, seq) unless seq.sequence?\n\n # Loop through each Hash\n seq.children.each do |map|\n\n # Make sure it's a mapping before we convert it to a ruby Hash\n load_error!('not a yaml mapping (Hash)', file, map) unless map.mapping?\n entity = YAML.send(:symbolize_names!, map.to_ruby)\n\n # Ensure they're not using some unknown keys\n unknown_keys = entity.keys - SUPPORTED_KEYS\n load_error!(\"unknown keys: #{unknown_keys}\", file, map) unless\n unknown_keys.empty?\n\n load_error!(\"id and update are mutually exclusive\", file, map) if\n entity[:id] and entity[:update]\n\n source = \"#{file}:#{map.start_line + 1}\"\n\n create = {}\n create[:id] = entity[:id] if entity.has_key?(:id)\n create[:update] = entity[:update] if entity.has_key?(:update)\n\n # Create an Array of the various base Entities that will be layered into\n # this Entity\n create[:base] = [entity[:base]].flatten.compact\n\n # Construct an Array of component arguments that will be sent to\n # Morrow::EntityManager#create_entity\n entity[:components] ||= []\n load_error!('The `components` field must be an Array; %s' %\n [ entity[:components].inspect ], file, map) unless\n entity[:components].is_a?(Array)\n\n create[:components] = entity[:components].map do |conf|\n case conf\n when Symbol\n conf\n when String\n conf.to_sym\n when Hash\n load_error!(<<~ERROR, file, map) unless conf.size == 1\n Multiple keys found in single component configuration. Note that\n the `components` field is an Array. Perhaps you missed a '-'\n before the next component after this one.\n ERROR\n\n # A Hash is a component with non-default values. The values may be\n # provided as a Hash, an Array (must have all elements), or a scalar\n # (for single field Components)\n comp, config = conf.first\n case config\n when Hash\n config.rekey! { |k| k.to_sym }\n when Array\n # don't make any changes\n else\n # turn this non-array value into an array of a single element\n config = [ config ]\n end\n { comp.to_sym => config }\n else\n load_error!('Unsupported component configuration type: %s' %\n [ conf.inspect ], file, map)\n end\n end\n\n create[:remove] = entity[:remove] || []\n\n # defer the action if we're not able to do it at the moment\n begin\n create_or_update(**create)\n rescue Morrow::UnknownEntity\n defer(source: source, entity: create)\n rescue Exception => ex\n raise Morrow::Error, <<~ERROR.chomp\n error in entity file: #{source}: #{entity.pretty_inspect\n .chomp.gsub(/\\n/, \"\\n\" + ' ' * 16)}\n ERROR\n end\n end\n\n # Attempt to flush any deferred actions now that we've loaded everything in\n # the file.\n flush\n end",
"def openJsonFile(filepath)\n $file = File.open filepath\n $jsonObjectMain = JSON.load $file\n return $jsonObjectMain\nend",
"def load_json( filename, debug = false)\n\traise RuntimeError, \"Missing filename\" if not filename\n\n\tif( File.exists?( filename ) or File.symlink?( filename ) )\t\t\n\t\treturn JSON.load( File.open( filename ) )\n\telse\n\t\traise RuntimeError, \"Could not find \"+filename+\"\\n\"\n\tend\n\nend",
"def scanJsonFile(_jsonFile)\n open(_jsonFile,\"r\"){|strm|\n scanJsonString(strm.read()) ;\n }\n end",
"def load!\n JSON.load(File.read(@name))\n rescue JSON::ParserError => e\n raise LogFile::LoadError, e.message\n end",
"def load_file(file)\n File.open(file, \"r\") { |f| load(f) }\n end",
"def load\n yaml = YAML.load_file(@file_path)\n yaml.each {|k, v| interpolate_setting(yaml, v)}\n settings = OpenStruct.new\n add_hash(settings, yaml)\n\n @lock.synchronize do\n @yaml = yaml\n @settings = settings\n end\n rescue\n puts \"Failed to load file: #{@file_path}\\n#{$!}\"\n end",
"def load_config(file_path)\n file = File.read(File.expand_path(file_path, __FILE__))\n yaml = YAML.load(file)\n \n # set new options\n options.keys.each do |option|\n set_option(option, yaml[option]) if !yaml[option].nil?\n end\n \n # set new settings\n settings.keys.each do |setting|\n set(setting, yaml[setting]) if !yaml[setting].nil?\n end\n end",
"def consider_json_for_inclusion(file_path)\n stage_json(file_path) if json_file_from_target_window?(file_path)\n end",
"def load( filepath )\n unserialize( IO.read( filepath ) )\n end",
"def load(file)\n return false unless File.exists?(file)\n @settings = settings.merge(YAML::load_file(file)).symbolize_keys\n end",
"def parse(file_path)\n settings = YAML.load_file(file_path)\n load(settings[\"client\"])\n end",
"def initialize(file)\n @spec = ::JSON.parse(File.read(file).force_encoding('utf-8'))\n end",
"def load(clear=true, filename = @filename)\n @mutex.synchronize{\n @filename = filename\n\n hash = YAML.load_file( filename )\n self.clear if clear\n self.merge!(hash)\n }\n end",
"def load(json_path_or_hash)\n if(json_path_or_hash.is_a?(String))\n require 'multi_json'\n content = AttributeStruct.hashish.new(MultiJson.load(File.read(json)))\n else\n content = json_path_or_hash\n end\n content.each do |type, hash|\n register(type, hash)\n end\n true\n end",
"def payload_for(filename)\n JSON.parse(get_json(filename), symbolize_names: true)\n end",
"def load_data(filename=nil)\n filename=data_file(filename)\n return unless File.exist?(filename)\n case File.extname(filename).downcase\n when \".yaml\",\".yml\"\n YAML.load(File.open(filename))\n when \".json\"\n JSON.parse(File.read(filename))\n else\n File.read(filename)\n end\n end",
"def shell_registry_loadkey(key, file)\n key = normalize_key(key)\n shell_registry_cmd_result(\"load \\\"#{key}\\\" \\\"#{file}\\\"\")\n end",
"def load(filepath)\n @proxies = YAML.load(File.read(filepath))\n end"
] | [
"0.6992283",
"0.64195734",
"0.64195734",
"0.63779396",
"0.6324285",
"0.6300944",
"0.623934",
"0.6237231",
"0.62318707",
"0.6188736",
"0.61245394",
"0.60220444",
"0.6005296",
"0.5924706",
"0.5919942",
"0.5878331",
"0.5819003",
"0.5785386",
"0.5781708",
"0.57408696",
"0.57370955",
"0.5712482",
"0.56831557",
"0.5679007",
"0.56704426",
"0.5654645",
"0.56183106",
"0.5588318",
"0.55736077",
"0.55590504",
"0.5558346",
"0.5551272",
"0.55148685",
"0.54293114",
"0.54085577",
"0.5399151",
"0.53958476",
"0.5353339",
"0.535312",
"0.53214204",
"0.5301687",
"0.5287439",
"0.5263937",
"0.5255477",
"0.5249788",
"0.52427506",
"0.52383703",
"0.5230841",
"0.522424",
"0.52224374",
"0.5218816",
"0.5213606",
"0.51960623",
"0.5182486",
"0.51658",
"0.5161955",
"0.5143105",
"0.5131975",
"0.51176804",
"0.51121044",
"0.50987136",
"0.50931823",
"0.5078959",
"0.50671875",
"0.5063348",
"0.50575143",
"0.50517905",
"0.5050986",
"0.5038764",
"0.5038764",
"0.5033811",
"0.503257",
"0.50147915",
"0.5012979",
"0.5006391",
"0.50014496",
"0.49939674",
"0.49858257",
"0.49735165",
"0.4973136",
"0.4972847",
"0.49409026",
"0.49332938",
"0.49298105",
"0.49273357",
"0.49239743",
"0.4923093",
"0.49220842",
"0.49121144",
"0.49051127",
"0.48810762",
"0.48786053",
"0.48710924",
"0.4865212",
"0.48591214",
"0.48524955",
"0.4850368",
"0.48464566",
"0.4843948",
"0.48286453"
] | 0.75714713 | 0 |
Load the contents of a file into a Redis list key:: name of the list file:: name of file (string) | def load_list(key, file)
f = File.new( file )
counter = process_lines(f) do |redis,line|
redis.lpush( key , line.chomp)
end
return counter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadlist _file, _append\n send_cmd(\"loadlist #{_file} #{_append}\")\n end",
"def load_cache\n @list = YAML::load_file Settings[:cache_file]\n end",
"def add_file(path_to_file, options)\n puts \"INSIDE add_file METHOD\"\n puts \"OPTIONS: #{options.inspect}\"\n name = options[:name] || File.basename(path_to_file)\n if options[:type]\n redis_collection = new name, options[:type]\n else\n redis_collection = new name\n end\n \n IO.foreach path_to_file do |line|\n redis_collection << line\n end\n redis_collection\n end",
"def load_list filename\n\tlist = []\n\tbegin\n\t\topen filename do |f|\n\t\t\tuntil (line = f.gets).nil?\n\t\t\t\tnext if line.strip.empty?\n\t\t\t\tlist << line.strip\n\t\t\tend\n\t\tend\n\trescue Errno::ENOENT\n\tend\n\tlist\nend",
"def load_from_file_cache(file)\n puts \"loading stuff from #{file}\"\n File.open(file, 'r') do |input|\n Marshal.load(input.read)\n end\n end",
"def read_from_file(filename = \"listsave\")\n\t\tIO.readlines(filename).each do |line|\n\t\t\tadd_task(Task.new(line.chomp))\n\t\tend\n\tend",
"def load\n #p 'loading ...'\n #p @name\n @rarray = Array.new\n begin\n dshash = YAML.load_file('db/'+@name+'.store') \n #p dshash\n #@rkeys = Array.new\n #p 'loading ...'\n dshash.each {|k,v| # converts strings into symbols\n cid = dshash[k][\"id\"]\n next if cid < 1 # do not transform if id < 1 \n #@rkeys << k\n rhash = Hash.new \n v.each {|k2,v2|\n #p k2\n #p v2\n rhash[k2.to_sym] = v2\n }\n @rarray << rhash\n }\n rescue\n p 'no file now' \n self.insert({:id=>0})\n end\n end",
"def load_data_file(data_file)\n # Determine data_file index.\n @keydir.data_files |= [data_file]\n file_id = @keydir.data_files.index data_file\n \n pos = 0\n data_file.each do |entry|\n # Check for existing newer entry in keydir\n if (cur = @keydir[entry.key]).nil? or entry.tstamp >= cur.tstamp\n @keydir[entry.key] = Keydir::Entry.new(\n file_id,\n data_file.pos - pos,\n pos,\n entry.tstamp\n )\n end\n\n pos = data_file.pos\n end\n end",
"def add(key_file); end",
"def load_file(f)\n @list_link = []\n YAML.load_file(f).each { |e|\n link = Link.new e[0], e[1]\n link.exclude = e[2] if e.size > 2\n @list_link << link\n }\n check_possibility\n @list_link_copy = Array.new @list_link\n end",
"def load\n sleeper = 0.0\n while File.exist? lock_file\n sleeper += 0.1 if sleeper <= 10.0\n sleep(sleeper.to_i)\n end\n # :symbolize_names does not play nicely with :create_additions\n tmp = JSON.parse(File.read(path),\n {:symbolize_names=>false, :create_additions=>true})\n @data = {}\n tmp.each_pair{ |k,v| self[k] = v }\n end",
"def add_to_list(list_name, file_name)\n csv = CSV.read(file_name)\n\n csv.each do |entry|\n @r.hmset entry[0], \"id\", entry[0], \"email\", entry[1], \"status\", entry[2]\n @r.sadd(list_name, entry[0]) if entry[2] == \"Active\"\n end\nend",
"def load_queues\n if queue_file? && File.exists?(queue_file)\n @entries = YAML.load(File.new(queue_file).read)\n\n File.unlink(queue_file)\n end\n end",
"def load_data(file_path)\n json_data = JSON.parse(File.read(file_path))\n @processed_favs = json_data.map do |fav|\n fav.transform_keys(&:to_sym) \n end\n\n i = 0\n while i < @processed_favs.length\n\n items = @processed_favs[i][:name]\n @fav_list << items\n\n i += 1\n end\n rescue Errno::ENOENT\n File.open(file_path, 'w+')\n File.write(file_path, [])\n retry\n end",
"def shell_registry_loadkey(key, file)\n key = normalize_key(key)\n shell_registry_cmd_result(\"load \\\"#{key}\\\" \\\"#{file}\\\"\")\n end",
"def parse_list list_path\n list = Hash.new\n #If the file doesn't exist, don't bother right now.\n if !File.exist? list_path\n return list\n end\n\n file = File.new list_path\n file.readlines.each do\n |app|\n bin, uses = app.split /\\s+/\n list[bin] = uses.to_i\n end\n file.close\n\n return list\nend",
"def load_file(file)\n data = {} # Hash keyed on group name. Each hash value to have an array of hosts.\n\n File.open(file).each do |line|\n next if line =~ /^#/\n next if line =~ /^$/\n next if line =~ /^\\s+$/\n line.chomp!\n line.downcase!\n host, group_csv = line.split(/\\s+/)\n groups = group_csv.split(\",\")\n # Add host to each of the specified groups.\n groups.each do |group|\n data[group.to_sym] = [] if data[group.to_sym].nil?\n data[group.to_sym].push(host)\n end\n # Add host to the all group.\n data[:all] = [] if data[:all].nil?\n data[:all].push(host)\n # Add host to all_no_db group unless it is the db.\n data[:all_no_db] = [] if data[:all_no_db].nil?\n data[:all_no_db].push(host) unless groups.include?(\"db\")\n end\n # Sort and uniq the arrays of hosts.\n data.each_key do |k|\n data[k].uniq!\n data[k].sort!\n end\nend",
"def load(name, id, contents)\n if name[id].nil?\n name[id] = []\n end\n name[id] = name[id].push(contents)\n end",
"def load(file); end",
"def create_dict(file)\n # Since wordlist is constant\n if File.file?(file)\n IO.readlines(file, chomp: true)\n else\n puts 'File not found!'\n end\n end",
"def [](key, file=_root_file)\n with_file(file, key)\n end",
"def init_list!\n write! unless File.exist?(path)\n @init_mtime = File.mtime(path)\n content.deep_merge!(\n MultiJson.load(\n File.open(path, \"r\") do |file|\n file.flock(File::LOCK_SH)\n file.read\n end\n )\n )\n end",
"def load_file(file); end",
"def list\n @list ||= PublicSuffix::List::parse(File.new(list_path, \"r:utf-8\"))\n end",
"def file(fname)\n @file_list[fname]\n end",
"def get_file_load_list\n json_file_path = File.join(SDESK_ROOT_PATH, 'configs', 'file_list.json')\n json_data = load_json_file json_file_path\n return [] unless json_data\n\n flist_arr = []\n json_data.each_pair do |dir_name, file_h|\n file_h.each_pair do |fname, queue_id|\n flist_arr << [File.join(dir_name, fname+'.rb'), queue_id]\n end\n end\n flist_arr.sort_by!{|arr| arr.last}\n flist_arr.map(&:first)\n end",
"def record(filename)\n contents = File.read(filename) rescue nil\n files[filename] = contents unless files.has_key? filename\n end",
"def load(key)\n redis_key = prefix(key)\n value = @redis.get(redis_key)\n Marshal.load(value) if value\n end",
"def load!(file)\n hash = {}\n YAML.load_file(file).each do |k, v|\n hash[Pathname(k)] = v.map{|vv| Pathname(vv) }\n end\n replace(hash)\n end",
"def load\n if File.exist?(@file_path)\n\n @_cache = JSON File.open(@file_path, &:read).strip\n else\n $stderr.puts \"#{@file_path} does not exist\"\n end\n end",
"def restore_from_disk\n log(\"Loading Data in...\")\n\n if File.directory?('buckets') then\n entries = Dir.entries(\"buckets\").collect do |f| f unless f.match(\"bucket\").nil? end.compact\n\n entries.each do |e|\n File.open(\"buckets/\" + e) do |f|\n @contents = Marshal.load(f)\n end\n\n buckets[\"#{e.gsub(\".bucket\", \"\")}\"] = @contents\n\n end\n\n end\n\n end",
"def loadAccounts(path)\n users = YAML::load_file(path)\n users.each_pair do |user,pwd|\n @accountList << Account.new(user,pwd)\n end \n end",
"def json_load(file_path)\n MultiJson.load(File.read(file_path)).to_smash\n end",
"def load_from_file(filename,clean)\n\t\tbegin\n\t\t\t@clusters = []\n\t\t\t@items = []\n\t\t\t\n\t\t\traise IOError.new(\"#{filename} not found\") if not File.exists?(filename)\n\t\t\t\n\t\t\tIO.foreach(filename) do |line|\n\t\t\t\tlabel, items = *line.split(\":\",2).map { |x| x.strip }\n\t\t\t\titems = items.split(\" \").map { |x| (x.respond_to?(:to_sym) and not x.to_sym.nil?) ? x.to_sym : x }\n\t\t\t\titems = items - @items if clean\n\t\t\t\tif items.size > 0\n\t\t\t\t\titems.reject! { |x| @items.include?(x) }\n\t\t\t\t\tcluster = Cluster.new(items,label)\n\t\t\t\t\t@items = @items | cluster.items\n\t\t\t\t\[email protected] cluster\n\t\t\t\tend\n\t\t\tend\n\t\trescue IOError\n\t\t\traise $!\n\t\tend\n\tend",
"def load_plist(file)\n NSMutableDictionary.dictionaryWithContentsOfFile(file)\n end",
"def load_index_cache(file)\n @indexes = Marshal.load(File.read(file))\n nil\n end",
"def load_file(filename); end",
"def load_file(filename); end",
"def data\n return [] unless ::File.exist?(@locks_file)\n\n # opening up the file, and creating a shared lock\n handle = ::File.open(@locks_file, 'r')\n handle.flock(::File::LOCK_SH)\n\n # Reading data until the eof\n data = handle.read\n\n # We're all good\n handle.flock(::File::LOCK_UN)\n handle.close\n\n # Unserializing and checking if the resource file contains data for this file\n data = YAML.load(data)\n data || []\n end",
"def get_items_from_file()\n if(File.exists?(@filename) && !File.empty?(@filename))\n file = File.read(@filename)\n JSON.parse(file).each do |item|\n movie = Movie.new\n item.each { |key, value| movie.send(\"#{key}=\", value)}\n @items.push(movie)\n end\n end\n end",
"def read_file_content(file, key)\n @content_as_table = parse(file)\n @headers = @content_as_table.headers if @headers.empty?\n index_of_key = @headers.index(key)\n @content += @content_as_table.sort_by { |a| -a[index_of_key].to_i }\n end",
"def registry_loadkey(key, file)\n if session_has_registry_ext\n meterpreter_registry_loadkey(key, file)\n else\n shell_registry_loadkey(key, file)\n end\n end",
"def add_file_to_distributed_cache(file)\n add_to_distributed_cache(file, \"mapred.cache.files\")\n end",
"def load_from_dir dir\n Dir[File.join(dir,\"*.yml\")].each do |file|\n begin\n var_name = File.basename(file).gsub(/s\\.yml/,'')\n my_count = 0\n File.open(file) do |my_file|\n last_obj = nil\n while line = my_file.gets do\n if line == \"--- \\n\" #uj yaml objekt :)\n if last_obj\n o = YAML.load(last_obj) \n set_obj_val var_name,o.keys[0],o.values[0]\n my_count = my_count + 1\n end\n last_obj = ''\n end\n last_obj = last_obj + line\n end\n o = YAML.load(last_obj)\n set_obj_val var_name,o.keys[0],o.values[0]\n my_count = my_count + 1\n end\n\n try(\"puts \\\"Cache loaded @#{var_name}: #{my_count} instances from disk.\\\"\")\n rescue Exception => e\n puts \"Can not load #{file}.\"\n puts e.message\n end\n end\n end",
"def load_from_dir dir\n Dir[File.join(dir,\"*.yml\")].each do |file|\n begin\n var_name = File.basename(file).gsub(/s\\.yml/,'')\n my_count = 0\n File.open(file) do |my_file|\n last_obj = nil\n while line = my_file.gets do\n if line == \"--- \\n\" #uj yaml objekt :)\n if last_obj\n o = YAML.load(last_obj) \n set_obj_val var_name,o.keys[0],o.values[0]\n my_count = my_count + 1\n end\n last_obj = ''\n end\n last_obj = last_obj + line\n end\n o = YAML.load(last_obj)\n set_obj_val var_name,o.keys[0],o.values[0]\n my_count = my_count + 1\n end\n\n try(\"puts \\\"Cache loaded @#{var_name}: #{my_count} instances from disk.\\\"\")\n rescue Exception => e\n puts \"Can not load #{file}.\"\n puts e.message\n end\n end\n end",
"def load(fname)\n @score.clear\n File.foreach(fname) do |line|\n who, score, time = line.chomp.split(/\\s+/)\n @score[who] = [score.to_i, time]\n end\n end",
"def file_add(file)\n\t\tputs \"Add entries to the local site store from file: #{file}\"\n\t\traise \"File non-exist. Please check your file path and name again: #{file}\" unless File.exist?(file)\n\t\tchanges=Hash.new\n\t\tsites=file_2_list(file)\n\t\tchanges=bulk_add(sites) unless sites.nil? or sites.empty?\n\t\tputs \"Done loading file #{file}. \"\n\t\treturn changes\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend",
"def load_collection_from_file(filename, default)\n\n\treturn default unless File.exists?(filename)\n\t\n\tfile = File.new(filename, 'r');\n\tfile_json = file.read;\n\tfile.close;\n\tcollection = JSON.load(file_json);\n\t\n\tlog(\"Loaded #{collection.length} collection item(s) from #{filename}.\");\n\t\n\treturn collection;\nend",
"def load(file_path); end",
"def load(file_path); end",
"def load_from_file(fname)\n # first load plaintext file into memory\n ary_newdata = ''\n ary_pwdata = @pwdata.split \"\\n\"\n File.open(fname) do |f|\n ary_newdata = f.readlines.reject do |e|\n match = e.match(/([^:]+):[^:]+:[^:]+/)\n tok1 = (match ? match[1] : nil)\n tok1 == nil || ary_pwdata.find { |d| d =~ /^#{tok1}/i }\n end\n end\n # readlines leaves newlines, remove since add_to_safe doesn't expect them\n ary_newdata.map! { |e| e.chomp }\n # encrypt and save new safe contents\n add_to_safe(ary_newdata)\n ary_newdata.size\n end",
"def load_genre_list()\n File.open('./genre_list')\nend",
"def read_multi(names)\n @redis.mget(*names).map{|value| Oj.load(value)}\n end",
"def load(filepath)\n @proxies = YAML.load(File.read(filepath))\n end",
"def file_list(hash)\n\nend",
"def file_list(hash)\n\nend",
"def load(data)\n @monitor.synchronize do\n data.each do |key, value|\n expire!\n store(key, val)\n end\n end\n end",
"def load\n @cache = JSON.parse(File.read(file))\n rescue\n @cache = {}\n end",
"def readList # read the list file and return an array\n array_list = []\n i = 0\n File.open(\"list.txt\").readlines.each do |line|\n array_list[i] = line\n i += 1\n end\n array_list\nend",
"def readToList( filename )\n\treader = CSV::parse(File.open(filename) {|f| f.read} )\n\treturn reader\nend",
"def load(file = '.cookies')\n YAML.safe_load_file(file, permitted_classes: [::Symbol, ::Time]).each do |c|\n add(c.delete(:name), c.delete(:value), c)\n end\n end",
"def list_contents\n list = load_storage\n list.is_a?(Hash) ? list.keys.sort : [list]\n end",
"def read_file(master_list, fileName, sepRegex, reorder)\n\tFile.foreach(\"codetest_files/input_files/\"+fileName) do |x|\n\t\tnewS = x.gsub(/\\n/, \"\").split(sepRegex)\n\t\tnewO = {\n\t\t\t\"LastName\": newS[0],\n\t\t\t\"FirstName\": newS[1],\n\t\t\t\"Gender\": newS[reorder[0]][0] == \"M\" ? \"Male\" : \"Female\",\n\t\t\t\"DOB\": newS[reorder[1]].gsub(/-/, \"/\"),\n\t\t\t\"FavoriteColor\": newS[reorder[2]]\n\t\t}\n\t\t# pushing object into master array\n\t\tmaster_list << newO\n\tend\n\tmaster_list\nend",
"def add( key_file )\n @key_files.push( key_file ).uniq!\n self\n end",
"def add_to_redis_list(captured_content)\n begin\n @redis.rpush(@event_list,captured_content[\"name\"])\n puts @redis.lrange(@event_list, 0, -1 )\n rescue Exception => e\n puts e.message\n end\n end",
"def add_to_list\n return if exists?\n @redis.lpush list, @data\n sadd\n end",
"def loadpath=(list)\n @loadpath = makelist(list)\n end",
"def load( filepath )\n unserialize( IO.read( filepath ) )\n end",
"def load(filename)\n files= filename.include?(',') ? filename.split(',') : [filename]\n @yml = files.inject({}) do |total_merge,file|\n total_merge.merge!(::YAML.load(ERB.new(File.read(\"#{yml_directory}/#{file}\")).result(binding)))\n end\n end",
"def load_hash(file_path) \n file=File.read(file_path)\n JSON.parse(file)\n end",
"def load_hash(file_path) \n file=File.read(file_path)\n JSON.parse(file)\n end",
"def add_list_member(f)\n File.open f, 'r' do |file|\n file.each do |email|\n print email\n RestClient.post(\"https://api:key-#{API_KEY}\" \\\n \"@api.mailgun.net/v3/lists/#{LIST}@#{DOMAIN_NAME}/members\",\n :subscribed => true,\n :address => email.chomp!,\n :upsert => true )\n end\n end\nend",
"def read_keys_file(path)\n return [] unless File.exists?(path)\n File.readlines(path).map! { |l| l.chomp.strip }\n end",
"def load_stopwords_file(file) \n stop_words = {}\n\n # Looping through the file and adding each word to a hash table after chomping them\n File.open(file, \"r\").each_line do |line|\n stop_words[line.chomp] = 1\n end\n\n return stop_words\n\nend",
"def cmd_db_import_ip_list(*args)\n\t\t\treturn unless active?\n\t\t\tif (not (args and args.length == 1))\n\t\t\t\tprint_error(\"Usage: db_import_file_list <iplist.txt>\")\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\tif (not File.readable?(args[0]))\n\t\t\t\tprint_status(\"Could not read the text file\")\n\t\t\t\treturn\n\t\t\tend\n\t\t\tframework.db.import_ip_list_file(:filename => args[0])\n\t\tend",
"def import_file(filename)\n [File.basename(filename).sub(\".yml\", \"\"), YAML.load(File.read(filename.to_s))]\nend",
"def load_all_raw_data_into_redis\n\t$all_stock_list.each do |symbol,name|\n\t\tputs \"#{symbol} start\"\n\t\tyahoo_get_raw_data_from_file(symbol)\n\tend\n\nend",
"def file_load(file)\n\t\tresult = \"\"\n\t\tFile.open(file.to_s, 'r') do |f|\n\t\t\twhile l = f.gets \n\t\t\t\tresult << l\n\t\t\tend\n\t\tend\n\t\tresult\n\tend",
"def load_comics (path)\n comics = {}\n File.foreach(path) do |line|\n name, url = line.split(': ')\n comics[name] = url.to_s.strip\n end\ncomics\nend",
"def hashdump dictfilepath\n @lookup = {}\n IO.foreach(dictfilepath) do |word|\n next unless word.size > 3\n word.chomp!\n @lookup[ word.sort2 ] ||= []\n @lookup[ word.sort2 ] << word\n end\n end",
"def save_cache\n open(Settings[:cache_file], 'w').write @list.to_yaml\n end",
"def fromFile( filename ) \n lines = IO.readlines( filename )\n loadAll( lines )\n end",
"def load_blog_list_from_local\n input = YAML.load(File.read('blogs.yaml'))['blogs']\n\n blogs = []\n input.each do |blog|\n blog_id = calculate_id_for(blog)\n item = {\n '__typename': 'Blog',\n '_version': 1,\n '_lastChangedAt': Time.now.to_i,\n id: blog_id,\n title: blog['title'],\n url: blog['url']\n }\n\n $ddb_client.put_item({\n table_name: BLOGS_TABLE,\n item: item\n })\n\n blogs.push(item)\n end\n\n p \"Added #{blogs.length} blogs\"\n { items: blogs, count: blogs.length }\nend",
"def add_labels(filename)\n labels = Hash.new\n if File.exist? \"./tmp/\"+filename\n result = File.open(\"./tmp/\"+filename,'r') do |f|\n while (line = f.gets) do\n line.chomp!\n a = line.split(\",\")\n labels[a[0]] = a[1].hex\n end\n end\n else\n puts \"missing +#{filename}\"\n end\n return labels\n end",
"def list_post(file_path)\n YAML::load(File.read(file_path));\nend",
"def load_file(path, name)\n data_file = PStore.new(path)\n data = nil\n data_file.transaction do\n data = data_file[name]\n end\n if data == nil\n data = Array.new\n end\n data\nend",
"def load(filename)\n end",
"def load(clear=true, filename = @filename)\n @mutex.synchronize{\n @filename = filename\n\n hash = YAML.load_file( filename )\n self.clear if clear\n self.merge!(hash)\n }\n end",
"def load_data(file)\n return [] unless File.exist?(file)\n @crypto.decrypt(File.open(file, 'rb').read, password: @passphrase).to_s.each_line.to_a\n rescue GPGME::Error::NoData\n []\n end",
"def load_sig_from_file (file, lc=true)\n puts \"Loading data file: #{file}\"\tif @verbose\n\t\t\tdata_store=Hash.new\n\t\t\tf = File.open(file, 'r')\n\t\t\tf.each_line do |line|\n\t\t\t\tputs \"Processing line: #{line}\" if @verbose\n\t\t\t\tline=line.chomp.strip\n\t\t\t\tnext if line.nil?\n\t\t\t\tnext if line.empty?\n\t\t\t\tnext if line =~ /^\\s*#/\n\t\t\t\tline=line.downcase if lc==true\n\t\t\t\tentry=line.split(',')\n\t\t\t\tif data_store.key?(entry[0])\n\t\t\t\t\tnext\n\t\t\t\telse\n\t\t\t\t\tdata_store[entry[0]]=entry[1].strip\n\t\t\t\tend\n\t\t\tend\n\t\t\tf.close\n\t\t\treturn data_store\n\t\trescue => ee\n\t\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\t\t\treturn nil\n \tend",
"def read_hosts_from_file\n if File.exists?(SMOKE_HOSTS_FILE)\n self.hosts = File.read(SMOKE_HOSTS_FILE).split(',')\n end\n end",
"def read_by_filename(filename)\n result = find_by_filename(filename)\n \n if result.count > 1\n result.map! { |r| read(r['_id']) }\n else\n result.blank? ? [] : [read(result.first['_id'])]\n end\n end",
"def load_json(file, path=nil)\n f = File.new( file )\n json = JSON.parse( f.read )\n if path != nil\n json = Siren.query(query, json)\n end\n counter = 0\n #TODO could support proper results, not just hash?\n if json != nil\n json.each_pair do |key,value|\n if value.class() == Array\n value.each do |v|\n @redis.lpush( key, v )\n end \n elsif value.class == Hash\n value.each_pair do |field, v|\n #TODO better handling of nesting?\n #E.g. convert hash or array back into JSON?\n @redis.hset(key, field, v)\n end\n else\n @redis.set(key, value)\n end\n counter = counter + 1 \n end \n end\n return counter\n end",
"def load(key_store_file, password)\n\n end",
"def load_items\n return @items unless YAML.load_file(file)\n\n YAML.load_file(file).each do |key, texts|\n texts.each do |text|\n @items << Item.new(\"#{text} #{key}\") if key.to_s != '@done'\n end\n end\n @items\n end",
"def load_known_hosts_from_file (f_hosts=@hosts_file)\n\t\tputs \"Loading local hosts from file: #{f_hosts} ...\" if @verbose\n\t\tknown_hosts=Hash.new\n\t\t@alias = Hash.new\n\t\tFile.write(f_hosts, \"\") unless File.exist?(f_hosts)\n\t\tf=File.open(f_hosts, 'r')\n\t\tf.each do |line|\n\t\t\tnext unless line =~ /\\d+\\.\\d+\\.\\d+\\.\\d+/\n\t\t\tentry=line.chomp.split(%r{\\t+|\\s+|\\,})\n\t\t\tkey=entry[0].downcase\n\t\t\tvalue=entry[1]\n\t\t\tputs \"Loading key value pair: #{key} - #{value}\" if @verbose\n\t\t\tknown_hosts[key] = Hash.new unless known_hosts.key?(key)\n\t\t\tknown_hosts[key]= value\n\t\t\t# For reverse host lookup\n\t\t\tknown_hosts[value] = Hash.new unless known_hosts.key?(value)\n\t\t\tknown_hosts[value] = key\n\t\t\t# Count the number of alias for the recorded IP\n\t\t\tif @alias.key?(value)\n\t\t\t\t@alias[value]+=1\n\t\t\telse\n\t\t\t\t@alias[value]=1\n\t\t\tend\n\t\tend\n\t\tf.close\n\t\treturn known_hosts\n\t\t#rescue => ee\n\t\t#\tputs \"Exception on method #{__method__}: #{ee}\"\n\t\t#\treturn known_hosts\n\tend",
"def [](key)\n sanitized_key = sanitize_key(key)\n return unless @mongo.exist?(:filename => sanitized_key)\n object = @mongo.get sanitized_key\n data = object.read\n Marshal.load data if data\n end",
"def yaml_load(file_path)\n YAML.load(File.read(file_path)).to_smash\n end",
"def aggregate(file)\n read_entries(file) do |data|\n ManageData.aggregate(data, file.file.chomp(File.extname(file.file)))\n end\n file.add_to_redis\n end",
"def read_taskwarrior_file(file)\n tasks = []\n open(file).each_line do |l|\n l = l.encode('UTF-8', :invalid => :replace, :undef => :replace, :replace => 'X')\n t = l.scan( /\\w+:\".+?\"/ ).collect{|i| \n k, v = i.split(':', 2)\n [k.to_sym, v.gsub(/\\A\"|\"\\Z/,'')] \n } \n t = Hash[t]\n t[:tags] = t[:tags].strip.split(\",\") if t[:tags]\n t[:entry] = t[:entry].to_i\n t[:end] = t[:end].to_i if t[:end]\n tasks << t\n end if File.file? file\n tasks\n end"
] | [
"0.64938444",
"0.63241535",
"0.63234454",
"0.60214484",
"0.59627587",
"0.59255385",
"0.590026",
"0.5876876",
"0.58177805",
"0.5789792",
"0.5767522",
"0.57405245",
"0.57155603",
"0.5713657",
"0.5706526",
"0.56286347",
"0.5605674",
"0.5551865",
"0.554792",
"0.5537724",
"0.553386",
"0.5511205",
"0.55056685",
"0.5504143",
"0.5478001",
"0.5472719",
"0.54409015",
"0.54274565",
"0.54097074",
"0.5391547",
"0.5364941",
"0.53551936",
"0.53456813",
"0.53416365",
"0.533022",
"0.53293777",
"0.5310772",
"0.5310772",
"0.52955854",
"0.52850455",
"0.528038",
"0.5261728",
"0.52602863",
"0.5258053",
"0.5258053",
"0.5251783",
"0.5249889",
"0.52491724",
"0.5247489",
"0.5247489",
"0.52464426",
"0.52427197",
"0.52407384",
"0.5237421",
"0.52371466",
"0.52371466",
"0.5225424",
"0.5217525",
"0.5217239",
"0.52164024",
"0.5210607",
"0.52079713",
"0.52074504",
"0.5193894",
"0.51909786",
"0.5185484",
"0.518336",
"0.5182955",
"0.51758695",
"0.51725924",
"0.51725924",
"0.5158676",
"0.5152401",
"0.51452154",
"0.51444435",
"0.5138281",
"0.51371425",
"0.51351666",
"0.51255757",
"0.5125368",
"0.5125066",
"0.51235545",
"0.5111361",
"0.5109663",
"0.51039916",
"0.51037836",
"0.51036114",
"0.51024044",
"0.5093079",
"0.5090421",
"0.508347",
"0.50833756",
"0.5081237",
"0.5079682",
"0.5077017",
"0.50699264",
"0.50697786",
"0.5063683",
"0.5057445",
"0.50559455"
] | 0.8290899 | 0 |
Process lines io:: IO Object | def process_lines(io)
counter = 0
io.each_line do |line|
yield @redis, line
counter = counter + 1
end
return counter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_lines(io)\n buffer = +''\n while line = io.gets\n buffer << line\n yield line\n end\n buffer\n end",
"def proccess_lines(input)\n CSV.foreach(input, headers: true, header_converters: :symbol) do |row|\n line_parser = LineParser.new(row)\n\n if line_parser.valid?\n output_file << line_parser.to_csv\n elsif !line_parser.empty?\n error_file << line_parser.to_csv\n end\n end\n end",
"def process_lines(input_file)\n for line in input_file\n process_line(line)\n end\n end_of_file\n end",
"def map_lines\n while (inline = input.gets)\n output.puts yield(inline)\n end\n end",
"def stream\n $stdin.each do |line|\n record = recordize(line.chomp)\n next unless record\n process(*record) do |output_record|\n emit output_record\n end\n end\n end",
"def read(_lines)\n raise NotImplementedError\n end",
"def load_data\n self.open if @io.nil?\n @lines = @io.readlines\n @io.rewind\n @lines.delete_if {|line| line.match(/^\\s*$/)}\n @num_lines = @lines.count\n end",
"def read_and_process\n process(read)\n end",
"def input_lines; end",
"def process(io, context = {})\n end",
"def each_input_line\n with_input_io{|io| io.each_line(&Proc.new)}\n end",
"def parse(line)\n @io.rewind\n @io.truncate(0)\n @io << line\n @io.rewind\n @csv.shift\n end",
"def to_io(io) \n to_line_list.each do |line|\n io.write \"#{line}\\n\"\n end\n end",
"def process(io=$stdin)\n io = open(io)\n result = load(io)\n \n if use_close || file\n close(io)\n end\n \n result\n end",
"def read\n @lines.shift\n end",
"def format_io input\n input.each_line do |line|\n output.write format_log_line(line)\n end\n end",
"def process_line line\n if looks_like_json?(line)\n process_line_of_json_in_new_pipe(line)\n else\n process_line_of_tsv_in_this_pipe(line)\n end\n end",
"def readlines(sep=$/) end",
"def readlines(sep=$/) end",
"def each(options = {})\n options = { delimiter: \"\\t\", progress_bar: true }.merge(options)\n \n # Create the progress bar\n if options[:progress_bar]\n `wc -l #{@io.path}` =~ /\\d+/\n pbar = ProgressBar.new(\"Parsing #{Pathname.new(@io.path).basename}\", $~[0].to_i, STDOUT)\n end\n \n @io.each do |raw_line|\n pbar.inc if options[:progress_bar]\n \n # Handle possible issues with line return encodings\n cr_lines = raw_line.strip.split(\"\\r\")\n cr_lines.each do |line|\n # Skip lines that are comments.\n # TODO: This eventually may want to be handled differently since some comments are actually pragmas\n begin\n next if line =~ /^(#|\\s+$)/\n rescue\n # Try to handle for bad character conversion\n line = Iconv.new('UTF-8//IGNORE', 'UTF-8').iconv(line)\n next if line =~ /^(#|\\s+$)/\n end\n \n yield line.split(options[:delimiter]).map(&:strip)\n end\n end\n end",
"def input_handler\n STDIN.read.split(\"\\n\").each do |line|\n process_line(line)\n end\n end",
"def readlines(*rest) end",
"def readlines(*rest) end",
"def readlines(*several_variants)\n #This is a stub, used for indexing\n end",
"def process_externals_lines\n File.open(file_name, \"r\") do |f|\n #File.open(\"./lib/externals/externals_table_data_input_lines.txt\", \"r\") do |f|\n f.each_line do |line|\n puts line.to_textual\n sleep(0.01)\n end\n end\n end",
"def output=(io); end",
"def processed(io, context)\n process(io, context)\n end",
"def read() end",
"def read_io io\n handle_client io\n end",
"def readlines(*args, **kwd); end",
"def handle(data)\n\t\t\t\tprocess_line(data)\n\t\t\tend",
"def parse(lines)\n lines\n .split(\"\\n\")\n .select { |line| line_filter(line) }\n .map { |line| scan_call(scan_line(line)) }\n end",
"def process_input_file \n File.open(@file, 'r') do |f|\n f.each_line do |line|\n parse_line(line)\n end\n end\n end",
"def storlines(cmd, file, &block) # :yield: line\n synchronize do\n voidcmd(\"TYPE A\")\n conn = transfercmd(cmd)\n loop do\n buf = file.gets\n break if buf == nil\n if buf[-2, 2] != CRLF\n buf = buf.chomp + CRLF\n end\n conn.write(buf)\n yield(buf) if block\n end\n conn.close # closes the SSL\n conn.io.close # closes the TCP below it\n voidresp\n end\n end",
"def process(lines, filename=\"stdio\")\n line_number = 1\n lines.each_line do |line|\n Command.process(line, filename, line_number)\n line_number += 1\n increment_progress_bar\n end\n end",
"def read_lines(data)\n blockchain_temp = IO.readlines(data)\n blockchain_temp\n end",
"def lines(source); end",
"def from_org_io(io, **types)\n table_re = /\\A\\s*\\|/\n hrule_re = /\\A\\s*\\|[-+]+/\n rows = []\n table_found = false\n header_found = false\n io.each do |line|\n unless table_found\n # Skip through the file until a table is found\n next unless line.match?(table_re)\n\n unless line.match?(hrule_re)\n line = line.sub(/\\A\\s*\\|/, '').sub(/\\|\\s*\\z/, '')\n rows << line.split('|').map(&:clean)\n end\n table_found = true\n next\n end\n break unless line.match?(table_re)\n\n if !header_found && line =~ hrule_re\n rows << nil\n header_found = true\n next\n elsif header_found && line =~ hrule_re\n # Mark the boundary with a nil\n rows << nil\n elsif !line.match?(table_re)\n # Stop reading at the second hline\n break\n else\n line = line.sub(/\\A\\s*\\|/, '').sub(/\\|\\s*\\z/, '')\n rows << line.split('|').map(&:clean)\n end\n end\n from_array_of_arrays(rows, hlines: true, **types)\n end",
"def read(io)\n begin\n while object = Marshal.load(io)\n type, id, attrs = object\n feed type, id, attrs\n end\n rescue EOFError\n end\n end",
"def serve(io)\n loop do\n data = \"\"\n begin\n while line = io.recv(1)\n break if line == \"\\0\"\n data += line\n end\n rescue\n log \"recv break removal event\"\n remove_dead_socket io #, true\n break\n end\n unless data == \"\"\n log \"#{data}\"\n parse_line(data, io)\n end\n end\n end",
"def each_record(io,&block)\n io.each_line do |line|\n required_line_length = self.class.get_subclass_variable 'width'\n #line = io.readline\n line.chop!\n next if line.length == 0\n difference = required_line_length - line.length\n raise RecordLengthError.new(\n \"length is #{line.length} but should be #{required_line_length}\"\n ) unless(difference == 0)\n yield(create_record(line, io.lineno), line)\n end\n end",
"def readlines(filename, start_pos, num_lines, client)\n arr = IO.readlines(\"File1.txt\")\n for i in 0..num_lines-1\n client.puts arr[i]\n end\nend",
"def read(io)\n game_text = ''\n io.each { | line |\n line.chomp!\n case line\n when /\\[(.*)\\]/ # New games starting (if multi-game file)\n when /^\\s*$/\n else\n game_text << ' '\n game_text << line\n end\n }\n game_text\n end",
"def map_processed_lines(response)\n end",
"def processed_lines\n return [] unless lines.any? { |line| line.streams.any? }\n\n lines.map do |line|\n if exceeds_width?(line)\n line_length = 0\n processed = []\n line.streams.each do |stream|\n next if stream.text.empty?\n\n if (line_length += stream.text.size) >= width\n remainder = width - line_length\n\n processed << Stream.new({\n colour: stream.colour.attributes,\n style: stream.style,\n text: truncate(stream.text, remainder),\n })\n\n else\n processed << stream\n\n end\n end\n\n Line.new({\n colour: line.colour.attributes,\n streams: processed,\n style: line.style,\n })\n\n else\n line\n\n end\n end\n end",
"def each_line\n while line = self.gets do\n yield line\n end\n end",
"def enqueue_lines(fh, numlines)\n vc = 0 # valid count \n lc = 0 # line count\n while line = fh.gets\n vc += 1 if enqueue_url(line)\n lc += 1\n break if numlines and lc >= numlines\n end\n [lc, vc]\n end",
"def lines; end",
"def lines; end",
"def read(io, style)\n in_multiline_comment = false\n io.each do |line| \n @lines += 1\n\n # Process the line to avoid matching comment characters within quoted\n # strings or regular expressions.\n line.gsub!(/\\'.*?\\'/, \"X\") # Single quoted string\n line.gsub!(/[^\\\"]\\\"[^\\\"]+\\\"/, \"X\") # Double quoted string\n if style == :ruby\n line.gsub!(/\\/.*?\\//, \"X\") # Regular expression\n end\n\n patterns = comment_patterns(style)\n \n # In the event where the multiline_end pattern is the same as the \n # multiline_begin pattern, it is necessary to check for the ending\n # pattern first - otherwise we will never detect the ending pattern.\n if in_multiline_comment\n if patterns.include?(:multiline_end_mixed) and \n line =~ patterns[:multiline_end_mixed]\n @comments += 1\n @code += 1\n in_multiline_comment = false\n next\n elsif line =~ patterns[:multiline_end]\n @comments += 1\n in_multiline_comment = false\n next\n end\n end\n \n case line\n when patterns[:multiline_begin]\n in_multiline_comment = true \n if patterns.include?(:multiline_begin_mixed) and \n line =~ patterns[:multiline_begin_mixed]\n @code += 1\n end\n \n if line.sub(patterns[:multiline_begin], \"X\") =~ patterns[:multiline_end]\n in_multiline_comment = false\n end\n @comments += 1\n \n when patterns[:blank_line]\n @blank += 1\n \n when patterns[:single_line_full]\n @comments += 1\n \n when patterns[:single_line_mixed]\n @comments += 1\n @code += 1\n \n else\n if in_multiline_comment\n @comments += 1\n else\n @code += 1\n end # if\n end # case\n end # read\n end",
"def parse_entry(io)\n # Read INSDC or RefSeq entry\n Bio::FlatFile.auto(io).each do |entry|\n @entry = entry\n @features = entry.features\n @source = @features.shift\n parse_sequence\n parse_source\n #parse_genes\n parse_features\n end\n end",
"def process_lit_doc_lines(files_and_header_sizes, generated_file_path)\n files_and_header_sizes.each do |entry|\n entry[:file][:lines].each do |line|\n args = line.split(' ')\n\n File.open(generated_file_path, 'a') { |f| f << \"\\n\" }\n\n # args.shift(2) = remove first 2 entries in array\n case args[1]\n when '@h:'\n args.shift(2)\n header_size = entry[:file][:sizes][:h]\n process_header(args, generated_file_path, header_size)\n when '@r:'\n args.shift(2)\n process_route(args, generated_file_path)\n when '@b-model:'\n args.shift(2)\n process_body_model(args, generated_file_path)\n when '@res-model:'\n args.shift(2)\n process_response_model(args, generated_file_path)\n when '@b-serializer:'\n args.shift(2)\n process_body_serializer(args, generated_file_path)\n when '@res-serializer:'\n args.shift(2)\n process_response_serializer(args, generated_file_path)\n else\n args.shift\n process_markdown(args, generated_file_path)\n end\n end\n end\n end",
"def parse_lines(input, out)\r\n lines = 0\r\n\r\n File.readlines(input).each do |ln|\r\n lines += 1\r\n\r\n # Get line ending\r\n self.ln_ending ||= ln if ln.chomp.empty?\r\n\r\n # Append line to out unless it is an import\r\n out.puts(ln) unless line_import?(ln)\r\n end\r\n lines\r\n rescue SystemCallError => e\r\n Message::Warning.warning_puts(\"Could not load #{input} - #{e}\")\r\n return 0\r\n end",
"def handle_request(client, lines, requests); end",
"def consume_lines(lines)\n log \"Removing commented lines and sorting mentions\"\n\n statements = []\n mentions = []\n lines.each do |l|\n next if l.start_with?('#') # Remove commented lines\n next if l.include?('RT') || l.include?('MT') # Remove soft retweets\n\n if l[0]==('@') || l.match(/\\s@/)\n mentions << NLP.normalize(l)\n else\n statements << NLP.normalize(l)\n end\n end\n\n text = statements.join(\"\\n\").encode('UTF-8', :invalid => :replace)\n mention_text = mentions.join(\"\\n\").encode('UTF-8', :invalid => :replace)\n\n lines = nil; statements = nil; mentions = nil # Allow garbage collection\n\n log \"Tokenizing #{text.count('\\n')} statements and #{mention_text.count('\\n')} mentions\"\n\n mass_tikify(text, @smodel)\n mass_tikify(mention_text, @mmodel)\n\n @keywords.import(NLP.keywords(text).top(2000).map(&:to_s))\n log \"Top keywords: #{@keywords[0]} #{@keywords[1]} #{@keywords[2]}\"\n\n self\n end",
"def consume_lines(lines)\n log \"Removing commented lines\"\n\n statements = []\n lines.each do |l|\n next if l.start_with?(\"#\") # Remove commented lines\n statements << NLP.normalize(l)\n end\n\n text = statements.join(\"\\n\").encode(\"UTF-8\", :invalid => :replace)\n lines = nil; statements = nil # Allow garbage collection\n\n log \"Tokenizing #{text.count(\"\\n\")} statements\"\n\n @sentences = mass_tikify(text)\n\n log \"Ranking keywords\"\n @keywords = NLP.keywords(text).top(200).map(&:to_s)\n log \"Top keywords: #{@keywords[0]} #{@keywords[1]} #{@keywords[2]}\"\n\n self\n end",
"def each\n loop do\n yield read\n end\n end",
"def readlines(eol=$/)\n ary = []\n ary << line while line = self.gets(eol)\n ary\n end",
"def all_by_magic(io); end",
"def process_skipped_lines(lines); end",
"def line_maker\n @lines = File.readlines(path, chomp: true)\n end",
"def each(eol=$/)\n while line = self.gets(eol)\n yield line\n end\n end",
"def do_it_lines\n open(file_name).each {|x| p x; }\n end",
"def readlines(&block)\n loop do\n if @lines.size < 3 && [email protected]?\n @lines << @f.readline\n elsif @lines.size == 0 && @f.eof?\n break\n else\n yield @lines.shift\n end\n end\n end",
"def new_reader\n Thread.new do\n while line = @pipe.gets\n # The output strings must not contain \"\\n\".\n line.chomp!\n case line\n when BEGIN_MARKER\n @inside_output = true\n $stderr.puts 'Found the begin marker.' if $DEBUG\n when END_MARKER\n @inside_output = false\n $stderr.puts 'Found the end marker.' if $DEBUG\n else\n if @inside_output\n @queue_mutex.synchronize { @queue << line }\n $stderr.puts \"<#{line}> added to the queue.\" if $DEBUG\n end\n end\n end\n end # thread\n end",
"def write_line(data); end",
"def output lines\n nil\n end",
"def process_logfile\n # Read each line from the logfile and process it.\n IO.foreach(@logfile) { |line|\n @endpoints.add(LineTokenizer.new(line))\n @loglines += 1\n }\n end",
"def io; end",
"def io; end",
"def io; end",
"def io; end",
"def process_line(_line)\n raise NotImplementedError\n end",
"def process_testcase(line_buffer)\n line_buffer\n end",
"def read_txt\n # Open TXT file\n # f = File.open(self.fichero, \"r\")\n # Use TXT file content\n f = self.fichero\n # Loop thru open file lines\n f.each_line do |line|\n cod_reg = line[0,2]\n if cod_reg == '80'\n # Totals line\n amount = line[36,12]\n self.total_bills = line[22,6].to_i\n self.total_amount = (amount[0,10] + '.' + amount[10,2]).to_d\n elsif cod_reg == '02'\n # Header line\n pdate = line[36,6]\n self.nif = line[10,8]\n self.sufijo = line[18,3]\n self.process_date_time = Date.parse(pdate[4,2] + pdate[2,2] + pdate[0,2]) rescue Date.today\n elsif cod_reg == '01' || cod_reg == '90'\n # First or Last line\n else\n # Invoice charged line: Save in array\n amount = line[36,12]\n self.lista_cobros.push(bill_id: line[76,11].to_i,\n amount: (amount[0,10] + '.' + amount[10,2]).to_d,\n date: line[30,6],\n issuer: line[10,8],\n suffix: line[18,3],\n charge_code: line[21,1],\n charge_bank: line[22,4],\n charge_office: line[26,4],\n charge_id: line[48,6],\n iban_head: line[4,4],\n ccc_bank: line[54,4],\n ccc_office: line[58,4],\n ccc_dc: line[62,2],\n ccc_account_no: line[64,10],\n debit_code: line[74,1],\n cancel_code: line[75,1],\n reference: line[76,13])\n end\n end # f.each_line\n # f.close\n end",
"def read\n @io.rewind\n @io.read\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read(lines)\n\t\t@digitCount = lines[0].length / DIGIT_WIDTH;\n\n\t\t@result = \"\"\t\t\n\t\t(1..@digitCount).each do |digitIndex| \n\t\t\t@result += (Digit.new getDigitString(lines, digitIndex)).asInteger.to_s\n\t\tend\n\t\[email protected]_i\n\tend",
"def receive_line line\n super(line)\n write_output\n end",
"def read_io(io, &block)\n read_memory(io.read, &block)\n end",
"def transform(lines, &block)\n return enum_for(:transform, lines) unless block\n\n @row_index = 0\n @header_valid = false\n @header_best_guess = nil\n @notifier.try(:started)\n\n last_col = last_column_to_transform\n skip_footer_lines(lines, footer_lines).each do |line|\n line.is_a?(Array) ? process_line(line[0..last_col], &block) : process_line(line, &block)\n end\n\n @notifier.try(:finished)\n end",
"def lines\n\t\t\[email protected](Ruvim::API::CR)\n\t\tend",
"def write(io)\n each do |chunk|\n io << chunk\n end\n\n self\n end",
"def process_line(line)\n if @state.include?(:data)\n process_data_line(line)\n elsif @state.include?(:auth_plain_incomplete)\n process_auth_plain_line(line)\n elsif @state.include?(:auth_login_incomplete)\n process_auth_login_line(line)\n else\n process_command_line(line)\n end\n [email protected]?(:quit) # return true unless QUIT is given\n end",
"def read(io, fps, check_parity = true)\n # Initialize new grids for character storage\n @foreground_grid = Grid.new\n @background_grid = Grid.new\n # Initialize state\n @state = State.default\n @captions = []\n @now = Timecode.new(0, fps)\n @data_channel = 0\n\n magic = io.readline.chomp!\n fail InvalidFormatError, 'File does not start with \"' + Scc::FILE_MAGIC + '\"' unless Scc::FILE_MAGIC == magic\n\n io.each_line do |line|\n line.chomp!\n # Skip empty lines between the commands\n next if line.empty?\n\n line_data = LINE_REGEXP.match(line)\n fail InvalidFormatError, \"Invalid line \\\"#{line}\\\"\" if line_data.nil?\n # Parse timecode\n old_time = @now\n timecode = Timecode.new(line_data[:timecode], fps)\n @now = timecode\n fail InvalidFormatError, 'New timecode is behind last time' if @now < old_time\n\n # Parse data words\n parse_data(line_data[:data], check_parity)\n end\n end",
"def each_io\n each_file do |filename|\n io = get filename\n yield filename, io\n end\n end",
"def each_io\n each_file do |filename|\n io = get filename\n yield filename, io\n end\n end",
"def add_items_to_input_stream(*items)\n items.each do |item|\n stdin.puts item\n end\n stdin.rewind\nend",
"def lines\n load_data unless @lines\n @lines\n end"
] | [
"0.6559067",
"0.6375462",
"0.62753123",
"0.626858",
"0.61905915",
"0.615974",
"0.6126743",
"0.606643",
"0.6064732",
"0.6054343",
"0.6046821",
"0.6023971",
"0.6022353",
"0.5922476",
"0.5910147",
"0.58940905",
"0.58763564",
"0.586661",
"0.58659804",
"0.58546996",
"0.5853314",
"0.58491045",
"0.58491045",
"0.5824395",
"0.5823124",
"0.5807328",
"0.57968366",
"0.57937974",
"0.578277",
"0.5774424",
"0.5760057",
"0.57564676",
"0.5723166",
"0.57057583",
"0.56896675",
"0.567612",
"0.56736887",
"0.56598455",
"0.56454974",
"0.5642829",
"0.56286776",
"0.56225586",
"0.55851746",
"0.55806255",
"0.5579272",
"0.5530192",
"0.55131817",
"0.5511414",
"0.5511414",
"0.54983014",
"0.54834723",
"0.5481765",
"0.548134",
"0.54810935",
"0.54791254",
"0.54754776",
"0.5472927",
"0.54581827",
"0.5450934",
"0.5450016",
"0.54040456",
"0.5397628",
"0.53924865",
"0.53863853",
"0.5374639",
"0.5374293",
"0.5372329",
"0.53717446",
"0.5369113",
"0.5369113",
"0.5369113",
"0.5369113",
"0.5364967",
"0.53271955",
"0.5316902",
"0.53048176",
"0.52980995",
"0.52980995",
"0.52980995",
"0.52980995",
"0.52980995",
"0.5291297",
"0.5291297",
"0.5291297",
"0.5291297",
"0.5291297",
"0.5291297",
"0.5291297",
"0.5289818",
"0.5289179",
"0.52883726",
"0.5286917",
"0.52822244",
"0.5279529",
"0.52792376",
"0.5266927",
"0.52640307",
"0.52640307",
"0.52638155",
"0.5260548"
] | 0.6733401 | 0 |
Called on the ratings new page | def return_sub_types
main_type = type_status
if main_type
return self.beer_subtypes.map{|type| {id: type.id, name: type.name}}
else
return types_for_subtype
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @rating_alt = Rating.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rating_alt }\n end\n end",
"def new\n @rating = Rating.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rating }\n end\n end",
"def new\n @rating = Rating.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rating }\n end\n end",
"def new\n @rating = Rating.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rating }\n end\n end",
"def create\n @rating = Rating.new(rating_params)\n\n respond_to do |format|\n if @rating.save\n format.html { redirect_back(fallback_location: presets_path, notice: 'rating was sucessefully added') }\n\n else\n format.html { render :new }\n\n end\n end\n end",
"def create\n @rating_alt = Rating.new(params[:rating_alt])\n\n respond_to do |format|\n if @rating_alt.save\n format.html { redirect_to @rating_alt, notice: 'Rating was successfully created.' }\n format.json { render json: @rating_alt, status: :created, location: @rating_alt }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rating_alt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\r\n\t\t@rating = Rating.new\r\n\t\[email protected]_id = Widget.find_by_id(params[:widget_id]).id\r\n\t\t# verificamos si el usuario ya puntuo el widget\r\n\t\t@rate = Rating.find(:all, :conditions => {:widget_id => @rating.widget_id, :user_id => current_user.id}).first\r\n\t\tif @rate.nil?\r\n\t\t\t@rate = 0\r\n\t\telse\r\n\t\t\t@rate = @rate.rate\r\n\t\tend\r\n\tend",
"def create\n # work around the jquery rating plugin we're using\n if params[:id] and params[:rating].is_a?(String)\n params[:rating] = { :score => params[:rating], :dream_id => params[:id] }\n end\n \n # Slightly ugly, but for now we're letting users overwrite their previous\n # ratings.\n @rating = current_user.ratings.find_or_initialize_by_dream_id(params[:rating])\n @rating.attributes = params[:rating] unless @rating.new_record?\n\n respond_to do |format|\n if @rating.save\n format.html { flash[:notice] = 'Rating was successfully created.'; redirect_to(@rating.dream) }\n format.js { render :text => @rating.dream.ratings.average(:score), :status => :created }\n format.xml { render :xml => @rating, :status => :created, :location => @rating }\n else\n format.html { render :action => \"index\" }\n format.js { render :status => '400 Bad Request' } \n format.xml { render :xml => @rating.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n set_rating\n end",
"def new\n # Not generally used. Most people want to vote via AJAX calls.\n end",
"def rate_new\n @page_title = _('Add_new_rate_to_tariff') +\": \" + @tariff.name\n @page_icon = \"add.png\"\n\n # st - from which letter starts rate's direction (usualy country)\n @st = \"A\"\n @st = params[:st].upcase if params[:st]\n @page = (params[:page] || 1).to_i\n offset = (@page -1) * session[:items_per_page].to_i\n\n @dests, total_records = @tariff.free_destinations_by_st(@st, session[:items_per_page].to_i, offset)\n @total_pages = (total_records.to_f / session[:items_per_page].to_f).ceil\n\n @letter_select_header_id = @tariff.id\n @page_select_header_id = @tariff.id\n end",
"def create\n idea = Idea.find_by_id(params[:idea_id])\n user_rating = UserRating.new(params[:rating])\n user_rating.rating_id = params[:rating_id]\n user_rating.user_id = current_user.id\n\n if user_rating.save\n saved_rating = UserRating.where('rating_id' => params[:rating_id])\n\n if saved_rating.size != 0\n rating = Rating.find_by_id(params[:rating_id])\n average_rating = 0\n\n saved_rating.each do |sr|\n average_rating = average_rating.to_i + sr.value.to_i\n end\n\n if current_user.provider == 'twitter' && current_user.facebook_share\n current_user.twitter.update(\"I've rated an idea on #Idearator ! available on: \" + root_url + \"ideas/\" + idea.id.to_s) rescue Twitter::Error\n end\n\n rating.value = average_rating.to_f / saved_rating.size.to_f\n rating.save\n end\n\n respond_to do |format|\n format.html { redirect_to idea, :notice => 'Your rating has been saved successfully!' }\n format.js\n end\n else\n respond_to do |format|\n format.html { redirect_to idea, :alert => 'Your rating has not been saved, please retry!' }\n format.js\n end\n end\n end",
"def create\n @rating = Rating.new(params[:rating])\n\n respond_to do |format|\n if @rating.save\n format.html { redirect_to @rating, notice: 'Rating was successfully created.' }\n format.json { render json: @rating, status: :created, location: @rating }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @professor = Professor.find(params[:id])\n session[:professor] = @professor\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rating }\n end\n end",
"def new\n @participant_rating = ParticipantRating.new\n\n @participant_rating_old = ParticipantRating.find(:all, :conditions => [ \"participant_id = ?\", @participant.id], :group => 'video_id')\n\n if @participant_rating_old != nil and @participant_rating_old.size >= 4\n redirect_to new_participant_question_set1_path(@participant)\n else \n\n if @participant_rating_old != nil\n @position = @participant_rating_old.size \n else\n @position = 0\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participant_rating }\n end\n end\n end",
"def rate\n if Rating.find(:first, :conditions =>{:user_id => current_user.id, :rateable_id => current_object.id, :rateable_type => current_object.class.to_s})\n #TODO TRANSLATE AND DISPLAY CORRECT MESSAGE IN blank.js\n message = \"Already Rated\"\n else\n current_object.add_rating(Rating.new(:rating => params[:rated].to_i,:user_id => current_user.id))\n current_object.update_attributes(:rates_average => Rating.average(:rating, :conditions =>{:rateable_id => current_object.id, :rateable_type => current_object.class.to_s}).to_i)\n message = \"Rated Successfully\"\n end\n\t\t\t\t# TODO : refresh the rate box ...\n render :text => message\n end",
"def create\n # Check if already exists\n if Rating.find_by(user_id: current_user.id, event_id: params[:event_id])\n update\n else\n @rating = Rating.new(rating_params)\n @rating.event_id = params[:event_id]\n @rating.user_id = current_user.id\n\n respond_to do |format|\n if @rating.save\n format.html { redirect_back fallback_location: root_path }\n else\n format.html { render :new }\n end\n end\n end\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def thumbs_up\n extract = Csvarchive.find(params[:id])\n if extract.contributor_id != current_user\n recommendation = Recommendation.new(:user_id=>current_user.id, :recommendable_id=>extract.id, :recommendable_type=>\"Csvarchive\")\n recommendation.save\n render :update do |page|\n page.replace_html 'recommended', :partial=>\"recommendations/thumbs_down\", :locals=>{:item=>extract}\n page.replace_html 'award', :partial => \"recommendations/awards\", :locals => { :count => extract.recommendations.size }\n end\n end\n end",
"def new\n @create_rating = CreateRating.new\n\n respond_to do |format|\n \n format.html # new.html.erb\n format.xml { render :xml => @create_rating }\n end\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def create\n @rating = Rating.new(params[:rating])\n facebook_id = params[:rating][:user_id]\n @user = User.find_by_facebook_id(facebook_id)\n @rating.user_id = @user.id\n dish = Dish.find(params[:rating][:dish_id]) \n @rating.dish_id = dish.id \n \n respond_to do |format|\n if @rating.save\n if @rating.value == 1\n dish.upvotes += 1\n else\n dish.downvotes += 1\n end\n dish.save\n format.html { redirect_to @rating, notice: 'Rating was successfully created.' }\n format.json { render json: @rating, status: :created, location: @rating }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rating = Plugins::CamaleonCmsRating::Rating.new(\n score: params[:score],\n post_id: params[:post_id],\n rater_id: cama_current_user.try(:id)\n )\n\n head @rating.save ? :ok : :bad_request\n end",
"def post_rating_processing(rating)\n #abstract class... override to provide specific class post rating processing\n end",
"def create\n @rating = Rating.new(rating_params)\n\n respond_to do |format|\n if @rating.save\n @yellow = Yellowpage.find(@rating.post_id)\n @yellow.AveRating = (@yellow.AveRating*(@yellow.totalRatings) + @rating.rate)/(@yellow.totalRatings + 1)\n @yellow.totalRatings += 1\n @yellow.save\n @notification = Notification.create\n @notification.created_by = @yellow.profile_id\n @notification.responded_by = @rating.profile_id\n @notification.post_id = @yellow.id\n @notification.notification_type = 6\n @notification.view_stat = 0\n @notification.message = @current_profile.firstName + \" \" + @current_profile.LastName + \" Rated your Contact\" + \"(contact_id:\" + \") \" + @rating.rate.to_s\n @notification.save\n format.html { redirect_to @yellow, notice: 'Rating was successfully created.' }\n format.json { render :show, status: :created, location: @rating }\n else\n format.html { render :new }\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def rate_post\n render nothing: true\n\n post = Post.find(params[:id])\n\n assert(@post.kind_of?(Post))\n\n if not post.user_ratings.include? current_user.id\n post.user_ratings.push(current_user.id)\n post.save\n else\n redirect_to_back(root_path)\n end\n end",
"def create_ratyrate\n\t\tself.rate(self.rating, self.user, \"rating\", false)\n\tend",
"def user_created_rating _user, rating\n query = rating.query\n\n data = {\n category: 'Ratings',\n action: 'Rated a Query',\n label: query.query_text,\n value: rating.rating,\n bounce: false,\n }\n\n create_event data\n end",
"def new\n @paragraph_rating = ParagraphRating.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @paragraph_rating }\n end\n end",
"def new\n @m_rating = MRating.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @m_rating }\n end\n end",
"def new_rating\n @place = Place.find(params[:id]) \n end",
"def rate\n @article = Article.find(params[:id])\n authorize! :rate, @article\n @article_rating = ArticleRating.new({\n :user_id => current_user.id,\n :article_id => params[:id],\n :rating => params[:rating]\n })\n\n if @article_rating.save\n flash[:notice] = 'Thanks for rating'\n else\n flash[:alert] = \"Could not save your rating. You may have rated this already!\"\n end\n\n redirect_to :back\n end",
"def create\n @create_rating = CreateRating.new(params[:create_rating])\n\n respond_to do |format|\n if @create_rating.save\n format.html { redirect_to(@create_rating, :notice => 'Create rating was successfully created.') }\n format.xml { render :xml => @create_rating, :status => :created, :location => @create_rating }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @create_rating.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @m_rating = MRating.new(params[:m_rating])\n\n respond_to do |format|\n if @m_rating.save\n format.html { redirect_to(@m_rating, :notice => 'M rating was successfully created.') }\n format.xml { render :xml => @m_rating, :status => :created, :location => @m_rating }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @m_rating.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\r\n rating = Rating.create(score: params[:score], comment: params[:comment], rater_id: current_user.id, ratee_id: params[:ratee_id])\r\n\r\n if rating.save\r\n render json: rating\r\n else\r\n render json: { error: \"Rating creating error\" }, status: :unprocessable_entity\r\n end\r\n end",
"def create\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @product = Product.find(params[:product_id])\n @[email protected](rating_params)\n @rating.user_id = @current_user.id\n if @rating.save\n redirect_to @product , notice:'Review was successfully created'\n else\n redirect_to @product , notice:'Review was not created'\n end\n end",
"def rate\n\t\t# retrieve user with specified ID and rate him/her \n @user = User.find(params[:id])\n @user.rate(params[:stars], current_user, params[:dimension])\n\n\t\t# automatically display the new rating\n render :update do |page|\n page.replace_html @user.wrapper_dom_id(params), ratings_for(@user, params.merge(:wrap => false))\n page.visual_effect :highlight, @user.wrapper_dom_id(params)\n end\n end",
"def new\n @school_rating = SchoolRating.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @school_rating }\n end\n end",
"def users_rating\n @rating = Rating.find(params[:id])\n redirect_to skate_spot_path(@skate_spot) unless @rating.user_id == current_user.id\n end",
"def create\n @idea_rating = IdeaRating.new(idea_rating_params)\n\n respond_to do |format|\n if @idea_rating.save\n format.html { redirect_to @idea_rating, notice: (I18n.t :act_create) }\n format.json { render :show, status: :created, location: @idea_rating }\n else\n format.html { render :new }\n format.json { render json: @idea_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rating\r\n\t\t@rating\r\n\tend",
"def create\n @user_vote = UserVote.new(params[:user_vote])\n\n @user_vote.user = current_user\n @user_vote.rating_date = Time.now\n \n\n respond_to do |format|\n format.js { head :ok}\n if @user_vote.save\n format.html { redirect_to(@user_vote.movie, :notice => 'Movie rating was successfully created.') }\n format.xml { render :xml => @user_vote, :status => :created, :location => @user_vote }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_vote.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @campsite = Campsite.find(params[:campsite_id])\n if @campsite.reviews.find_by(user_id:current_user.id).blank?\n @review = @campsite.reviews.create(body:params[:body], user_id:current_user.id, title:params[:title])\n @review.save\n end\n if params[:rating].to_f != 0.0 && @campsite.ratings.find_by(user_id:current_user.id).blank?\n @rating = @campsite.ratings.create(value: params[:rating].to_f, user_id:current_user.id, review_id:@review.id)\n @rating.save\n @campsite.resave_avg_rating\n @campsite.save\n end\n respond_to do |format|\n if @review && @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render action: 'show', status: :created, location: @review }\n else\n format.html { render action: 'new' }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ratings_query\n super\n end",
"def rating\n @rating = @movie.ratings.new(rating_params)\n @rating.user_id = current_user.id\n if @rating.save\n render json: { message: \"Rating Created\", data: @rating }, status: 200\n else\n render json: { message: \"Rating not Created\" }, status: 422\n end\n end",
"def set_rating\n @rating = Rating.find_by_name(params[:id])\n end",
"def create\n @participant_rating = ParticipantRating.new(params[:participant_rating])\n @participant_rating.participant_id = @participant.id\n\n\n respond_to do |format|\n if @participant_rating.save\n format.html { redirect_to(new_participant_question_set1_path(@participant.id))}\n format.json { render json: @participant_rating, status: :created, location: @participant_rating }\n else\n format.html { render action: \"new\" }\n format.json { render json: @participant_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reviews_and_rating = ReviewsAndRating.new(reviews_and_rating_params)\n\n respond_to do |format|\n if @reviews_and_rating.save\n format.html { redirect_to @reviews_and_rating, notice: 'Reviews and rating was successfully created.' }\n format.json { render :show, status: :created, location: @reviews_and_rating }\n else\n format.html { render :new }\n format.json { render json: @reviews_and_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # @user = User.find_or_create_by(user_id: @user.id)\n \n @movie = Movie.find_or_create_by(imdbID: params[:imdbID], poster: params[:poster], title: params[:title])\n @rating = Rating.where(movie_id: @movie.id, user_id: logged_in_user.id).first_or_create do |rating|\n rating.score = rating_params[:score]\n rating.comment = rating_params[:comment]\n end\n render json: @rating\n end",
"def show\n @myRating= Rating.find_by_wine_id_and_user_id(@wine.id,current_user.id);\n @myRating= Rating.new(user_id: current_user.id) if @myRating.nil?\n \n User.all.each do |i|\n if(! @wine.ratings.any?{|r| r.user_id==i.id})\n curr= Rating.find_by_wine_id_and_user_id(params[:wine_id],current_user.id);\n if(curr.nil?)\n curr= Rating.new()\n curr[:wine_id]= params[@wine.id]\n curr[:user_id]= i.id\n end\n \n @wine.ratings.push(curr)\n end\n end\n \n end",
"def index\n @ratings = Rating.all\n end",
"def index\n @ratings = Rating.all\n end",
"def index\n @ratings = Rating.all\n end",
"def create\n @subject = Subject.find_by_id(rating_params[:subject_id])\n @tag = Tag.find_by_id(rating_params[:tag_id])\n\n if @subject.nil? or @tag.nil?\n respond_to do |format|\n format.html { redirect_to action: 'new', notice: 'Subject and Tag cant be null.' }\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n else\n @rating = Rating.where(subject_id: rating_params[:subject_id], tag_id: rating_params[:tag_id]).first ||\n Rating.create(\n name: @subject.safe_name + \"-\" + @tag.safe_name,\n subject_id: rating_params[:subject_id],\n tag_id: rating_params[:tag_id],\n subject_name: @subject.name,\n tag_name: @tag.name)\n \n respond_to do |format|\n if @rating.save\n format.html { redirect_to(:back) }\n format.json { render :show, status: :created, location: @rating }\n else\n format.html { render :new, notice: 'Something went wrong.' }\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n item = Item.find(params[:review][:rateable_id])\n @review = item.reviews.new\n @review.user_id = current_user.id\n @review.rating = params[:review][:rating]\n @review.comment = params[:review][:comment]\n if @review.save\n redirect_to item_path(item)\n else\n flash[:alet] = \"There was a problem creating the review\"\n render :new\n end\n end",
"def add(rating)\n @rating_list[rating.movie_id] = rating\n end",
"def add(rating)\n @rating_list[rating.movie_id] = rating\n end",
"def review\n end",
"def show\n @current_book = Book.find(@book.id)\n @rating = @book.ratings.new\n end",
"def new\n # any registered user can add a location\n unless current_user.is_general_user?\n redirect_to denied_path\n return\n end\n\n @review = Review.new\n logger.info \"review.new params: \" + params.inspect\n if params[:dish_id]\n @dish = Dish.find(params[:dish_id])\n else\n @dish = current_dish\n end\n @review.dish_id = @dish.id\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @review }\n end\n end",
"def set_rating_score\n @rating_score = RatingScore.find(params[:id])\n end",
"def create\n @content_rating = ContentRating.new(content_rating_params)\n\n respond_to do |format|\n if @content_rating.save\n format.html { redirect_to @content_rating, notice: \"Content rating was successfully created.\" }\n format.json { render :show, status: :created, location: @content_rating }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @content_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show_rating(id, numb, ctrl_name, check_rated, val_rate)\n if !logged_in?\n link_to_require_login(numb)\n elsif check_rated\n link_to(numb, \"javascript:;\", :class => \"vtip\", :title => \"#{configatron.str_rated}\")\n else\n link_to numb, { :controller => ctrl_name, :action => \"rate\", :post_id => id, :rating => val_rate }, :remote => true\n end\n end",
"def create\n @place = get_place\n @rating = current_user.ratings.new(rating_params.update(place: @place))\n if @rating.save\n redirect_to @place, notice: \"Merci de votre évaluation.\"\n else\n render :new\n end\n end",
"def show\n @rating = Rating.new\n @rating.beer = @beer\n end",
"def rate\n clas = params[:rating_for_class]\n @rate = clas == \"discussion\" ? Discussion.find(params[:id]) : (clas == 'comment' ? Comment.find(params[:id]) : Picture.find(params[:id]))\n @rate.rate_it(params[:score], current_user)\n respond_to do |format|\n format.js\n end\n end",
"def ratings_count\n ratings.count\n end",
"def rating_id=(rating_id)\n self.rating = Rating.find rating_id\n end",
"def create\n\t@bookmark = Bookmark.find(params[:bookmark_id])\n\t@rating = @bookmark.ratings.build(params[:rating])\n\[email protected] = current_user\n\n\trespond_to do |format|\n\tif @rating.save\n\t\tflash[:success] = \"Thanks for rating dawg!\"\n \tformat.html { redirect_to(@bookmark) }\n else\n\t\tflash[:error] = \"Something went awfully wrong and your rating was not submitted, please try again.\"\n \tformat.html { redirect_to(@bookmark) }\n end #if ends\n\tend #do ends\n\t\nend",
"def create\n @rating_score = RatingScore.new(rating_score_params)\n\n respond_to do |format|\n if @rating_score.save\n format.html { redirect_to @rating_score, notice: 'Rating score was successfully created.' }\n format.json { render :show, status: :created, location: @rating_score }\n else\n format.html { render :new }\n format.json { render json: @rating_score.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.find(params[:book_id])\n @rating = @book.ratings.new(rating_params)\n @rating.customer_id = current_customer.id\n respond_to do |format|\n if current_customer.did_not_rate?(@book.id)\n if @rating.save\n format.html { redirect_to @book, notice: t(:rating_suc_create) }\n format.json { redirect_to @book, status: :created, location: @rating }\n else\n format.html { redirect_to @book, alert: t(:rating_fails_create) }\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to @book, alert: t(:rated_already) }\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rating\n @rating = params[:value]\n @rated_user = params[:rated_user]\n @previous_rating = Rating.find_by rated_user_id: @rated_user, rating_user_id: @current_user.id\n if @previous_rating.blank?\n Rating.create(rated_user_id: @rated_user, rating_user_id: @current_user.id, value: @rating)\n else\n @previous_rating.value = @rating\n @previous_rating.save\n end\n render nothing: true, status: :ok and return\n end",
"def create_rating\n return unless valid?\n @rating_class.create(\n social_entry: @social_entry,\n rateable: @rateable,\n rater: @rater,\n ratee: @ratee,\n rating_type: @rating_type,\n rating_metrics: @rating_metrics\n )\n update_rating_aggregates\n end",
"def rating #Getter\n @rating\n end",
"def create\n @swit_sour = SwitSour.where(:user_id => params[:user_id], :swit_id => params[:swit_id]).first_or_initialize\n @swit_sour.update(:rating => params[:rating])\n\n respond_to do |format|\n if @swit_sour.save\n format.html { redirect_to @swit_sour, notice: 'Swit sour was successfully created.' }\n format.js\n format.json { render :show, status: :created, location: @swit_sour }\n else\n format.html { render :new }\n format.json { render json: @swit_sour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_rating_history\n @rating_history = RatingHistory.find(params[:id])\n end",
"def num_ratings \n 5\n end",
"def rate_comment\n render nothing: true\n comment = Comment.find(params[:id])\n\n if(!comment.user_ratings.include? current_user.id)\n comment.user_ratings.push(current_user.id)\n comment.save\n else\n return redirect_to_back(root_path)\n end\n\n end",
"def create\n @engine_rating = EngineRating.new(engine_rating_params)\n\n respond_to do |format|\n if @engine_rating.save\n format.html { redirect_to @engine_rating, notice: 'Engine rating was successfully created.' }\n format.json { render :show, status: :created, location: @engine_rating }\n else\n format.html { render :new }\n format.json { render json: @engine_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rate\n @album = Album.find(params[:id])\n authorize! :rate, @album\n @album_rating = AlbumRating.new({\n :user_id => current_user.id,\n :album_id => params[:id],\n :rating => params[:rating]\n })\n\n if @album_rating.save\n flash[:notice] = 'Thanks for rating'\n else\n flash[:alert] = \"Could not save your rating. You may have rated this already!\"\n end\n\n redirect_to :back\n end",
"def new\n @team_rating = TeamRating.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team_rating }\n end\n end",
"def rating_params\n params[:rating]\n end",
"def create\n respond_to do |format|\n if logged_in?\n @user = current_user\n @movie = Movie.find_or_create_by(id: params[:movie_id], title: params[:title])\n @rating = Rating.new(user_id: @user.id, movie_id: @movie.id, rating: params[:rating])\n\n if @rating.save\n format.json { render json: @rating }\n else\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n else \n format.json { head :no_content }\n end\n end\n end",
"def show\n movies_search = Movie.search_rating(@movie.name)\n unless(movies_search['total']==0)\n @rating = movies_search['movies'][0]['ratings']['audience_score']\n @poster = movies_search['movies'][0]['posters']['original']\n @movie.poster = @poster\n @movie.save\n end\n end",
"def create\n user_id = current_user.id\n review_id = params[:review_id]\n puts user_id, review_id\n if RateUp.exists?(user_id: user_id, review_id: review_id)\n RateUp.find_by(user_id: user_id, review_id: review_id).delete\n else\n RateDown.find_by(user_id: user_id, review_id: review_id).delete if RateDown.exists?(user_id: user_id, review_id: review_id)\n RateUp.create(user_id: user_id, review_id: review_id)\n end\n @review = Review.find(review_id)\n respond_to do |format|\n format.js { }\n end\n end",
"def create\n @rating = Rating.new\n @rating.user_id = params[:user_id]\n @rating.rate = params[:rate].to_i\n if @answer\n if @answer.user_id == current_user.id\n redirect_to @post, alert: \"You can't rate your own answer.\" and return\n end\n @rating.answer_id = @answer.id\n @answer.rating_score += @rating.rate\n @answer.save\n else\n if @post.user_id == current_user.id\n redirect_to @post, alert: \"You can't rate your own post.\" and return\n end\n @rating.post_id = @post.id\n @post.rating_score += @rating.rate\n @post.save\n end\n\n respond_to do |format|\n if @rating.save\n format.html { redirect_to @post, notice: 'Rating was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { redirect_to @post, alert: 'Rating was NOT successfully created.' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def review; end",
"def create\n @finale_rating = FinaleRating.new(finale_rating_params)\n\n respond_to do |format|\n if @finale_rating.save\n format.html { redirect_to @finale_rating, notice: 'Finale rating was successfully created.' }\n format.json { render :show, status: :created, location: @finale_rating }\n else\n format.html { render :new }\n format.json { render json: @finale_rating.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6557378",
"0.6440427",
"0.6440427",
"0.6440427",
"0.63995826",
"0.6393542",
"0.6364518",
"0.63636035",
"0.63427615",
"0.6242519",
"0.6197882",
"0.618935",
"0.6186078",
"0.6107314",
"0.6106605",
"0.61003184",
"0.6093549",
"0.6075821",
"0.6075821",
"0.6075821",
"0.60682255",
"0.60413027",
"0.60211456",
"0.6020151",
"0.60146207",
"0.6009388",
"0.60048383",
"0.600206",
"0.5982013",
"0.5982013",
"0.5982013",
"0.5982013",
"0.5982013",
"0.5982013",
"0.5982013",
"0.5982013",
"0.5982013",
"0.5982013",
"0.59739697",
"0.59722835",
"0.5897137",
"0.58847207",
"0.5881076",
"0.5867877",
"0.58613753",
"0.58576554",
"0.58480453",
"0.5838157",
"0.58162427",
"0.5792574",
"0.5778032",
"0.57722926",
"0.5752296",
"0.5750076",
"0.5737924",
"0.5732277",
"0.5726062",
"0.57188475",
"0.57100093",
"0.57068413",
"0.57062536",
"0.5703897",
"0.570086",
"0.5692452",
"0.5692452",
"0.5692452",
"0.56811714",
"0.5674497",
"0.5661381",
"0.5661381",
"0.56581694",
"0.565254",
"0.5648356",
"0.56339735",
"0.5629877",
"0.5629199",
"0.5624064",
"0.56128633",
"0.56114733",
"0.56107914",
"0.5609528",
"0.5608116",
"0.5603445",
"0.5585605",
"0.5583283",
"0.557962",
"0.55762225",
"0.55740947",
"0.5574078",
"0.556942",
"0.5562941",
"0.5558644",
"0.5556778",
"0.555426",
"0.5550128",
"0.5543643",
"0.55429506",
"0.554108",
"0.5536926",
"0.55323154",
"0.55291504"
] | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.