query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Returns a list of caption tracks that are associated with a specified video.
def get_captions(video_id) @youtube.list_captions('snippet', video_id) end
[ "def text_tracks\n perform_get(\"/videos/#{get_id}/texttracks\")\n end", "def tracks\n (1..track_count).map do |i|\n Track.new.load_from_movie(self, i)\n end\n end", "def video_list\n videos.map { |video| video.title }\n end", "def find_video_for_track(track)\n query = track[:name] + ' - ' + track[:artist]\n results = @yt_client.videos_by({query: query, video_format: 5, categories: {either: [:music, :entertainment]}})\n results = beat_match_rank(track, results.videos)\n results[0]\n end", "def tracks\n @tracks ||= fetch_collection(:trackKeys, Track)\n end", "def tracks\n ids = track_keys\n return [] if not ids\n return ids.map {|id| Track.get id}\n end", "def tracks\n return @tracks\n end", "def find(id:, video_id:)\n client.execute(method: :get, path: \"/videos/#{video_id}/subtitles/#{id}\")\n end", "def videotracks=(videoTracks)\n self.add_option(key: :tracks, value: videoTracks)\n videoTracks\n end", "def album_tracks(album)\r\n artist_album = RSpotify::Album.search(album).first\r\n artist_album = artist_album.tracks\r\n artist_album.collect do |track| \r\n track.name\r\n end\r\n # #puts artists\r\n\r\n end", "def media_control_tracks\n tracks = []\n\n if @session_description.nil?\n tracks << \"\"\n else\n @session_description.media_sections.each do |media_section|\n media_section[:attributes].each do |a|\n tracks << \"#{@content_base}#{a[:value]}\" if a[:attribute] == \"control\"\n end\n end\n end\n\n tracks\n end", "def tracklist\n tracks = Track.where({\"album_id\" => self.id})\n tracklist = {}\n track_number = 1\n\n tracks.each do |track|\n tracklist[track_number] = track.title\n track_number += 1\n end\n tracklist\n end", "def video_list\n self.video_list = videos.map { |video| video[\"title\"] }\n end", "def get_similar( params )\n xml = LastFM.get( \"track.getSimilar\", params )\n xml.find('similartracks/track').map do |track|\n LastFM::Track.from_xml( track )\n end\n end", "def audio_tracks\n tracks.select { |t| t.audio? }\n end", "def text_tracks\n tracks.select { |t| t.text? }\n end", "def tracks_for_artist_in_collection(artist,extras=nil)\n api.getTracksForArtistInCollection artist,self,extras\n end", "def tracks_for_album_in_collection(album,extras=nil)\n api.getTracksForAlbumInCollection album,self,extras\n end", "def related_tracks\n tracks = Scrobbler::Track.new(self.artist, self.source_id).similar[0..13]\n \n cat_id = ItemCategory.find_by_api_source(\"music-track\").id\n \n items = []\n tracks.each do |track|\n if item = Item.find_by_source_id(/#{track.name}/i, :conditions=>{:category_id => cat_id})\n items << item\n else\n track.load_info\n \n artist = Scrobbler::Artist.new(track.artist.name)\n artist.load_info\n \n # I'd prefer to grab the album image for a track\n #album = Scrobbler::Album.new(track.artist.name, ***track.album.name)\n \n items << Item.new(:name => track.name, :basic_image_url => artist.image_large)\n end\n end\n \n return items\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
e.g. check_is_array(10) => false check_is_array([10,20,30]) => true
def check_is_array(number) if number.class == Array return true else return false end end
[ "def array?(item)\n item.is_a?(Array)\n end", "def check_is_array(parameter)\n\tif parameter.class == Array\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def is_array?\n (self.is_a?(Array) and not self.empty?) ? true : false\n end", "def array?(value)\n value.is_a?(Array)\n end", "def is_int_array(arr)\n arr.is_a?(Array) && arr.all? {|e| e.to_i == e}\nend", "def is_integer_array? array\n\t\treturn array.all? {|a| a.is_a? Integer}\n\tend", "def is_array?\n self.parameter_type.split('[').first == 'Array'\n end", "def is_int_array_alt(arr)\n arr.is_a?(Array) && arr.all? { |e| e.is_a?(Integer) || e.is_a?(Float) && e % 1 == 0}\nend", "def data_has_multiple_entries?\n @data.is_a? Array\n end", "def must_be_an_array(value)\n value.is_a?(Array)\n end", "def boolean_nested_array(array)\n array.each do |slot|\n return true if slot.kind_of?(Array)\n end\n return false\nend", "def test_array?(data)\r\n return data[0, 1] == '['\r\n end", "def multi_array?( obj )\n obj.all? { |el| el.is_a?( Array ) } && obj.is_a?( Array ) rescue false\n end", "def verify_array_of_strings(input_array)\n string_checked_array = input_array.collect {|element| element.is_a?(String)}\n if string_checked_array.count(false) > 0\n return false\n else\n return true\n end\n end", "def validate_array( value )\n\n # Make sure it's an array in the first place.\n\n unless value.is_a? Array\n report( :not_array )\n return\n end\n\n # Enforce array limits.\n\n return unless validate_count( value )\n\n # Now validate array elements. If we detect problems, don't bother with the rest.\n\n value.all?{ |v| validate_value( v ) }\n end", "def expect_array(value, field, subfield)\n return true if value.blank?\n return true if value.is_a?(Array)\n errors.add(field, \"#{subfield} must be an array\")\n false\n end", "def check_array(object)\r\n if object.class != Array\r\n raise Exception.new('Specified object must be an array.')\r\n end\r\n end", "def array?\n return false if error?\n result.is_a?(Array) && result.size > 0 && result.first\n end", "def array?\n true\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: map the filelist to ImageFiles, handling any errors. For now, this just reports errors to STDERR so they can be noted. Returns an Array of ImageFiles.
def to_images image_map = [] self.each do |file| begin image_map << ImageFile.new(file) rescue Exception => e $stderr.puts "WARNING: skipped file - #{e.message}" end end image_map end
[ "def list_image_files\n image_files do |file|\n puts file\n end\n end", "def images\n self.ListImages.first.map { |i| map_image(i) }\n end", "def read_images\n return [] if parsed_contents['images'].nil?\n parsed_contents['images'].map do |img_hash|\n ResourceImage.read(img_hash)\n end\n end", "def find_image_files file_paths\n file_paths.select { |path| path.to_s.match /\\.(png|jpe?g|gif)$/ }\n end", "def files\n array = []\n @list.each do |k,v|\n array += v.filename\n end\n array\n end", "def find_existing_images\n images = []\n Dir.glob(File.join(@flickr_home_dir, '**/*.jpg')).each do |filename|\n images << [filename, File.mtime(filename)]\n end\n images\n end", "def get_images\n\t\trequest = Packet.create_request('stdapi_sys_process_image_get_images')\n\t\timages = []\n\n\t\trequest.add_tlv(TLV_TYPE_HANDLE, process.handle)\n\n\t\tresponse = process.client.send_request(request)\n\n\t\tresponse.each(TLV_TYPE_IMAGE_GROUP) { |i|\n\t\t\timages <<\n\t\t\t\t{\n\t\t\t\t\t'name' => i.get_tlv_value(TLV_TYPE_IMAGE_NAME),\n\t\t\t\t\t'base' => i.get_tlv_value(TLV_TYPE_IMAGE_BASE),\n\t\t\t\t\t'path' => i.get_tlv_value(TLV_TYPE_IMAGE_FILE_PATH)\n\t\t\t\t}\n\t\t}\n\n\t\treturn images\n\tend", "def extract_files(file_ids)\n files = []\n file_ids.each do |f|\n begin\n files << BasicFile.find(f)\n rescue ActiveFedora::ObjectNotFoundError => e\n logger.tagged('CONCEPTUAL_MODEL_MIGRATE') { logger.error e }\n end\n end\n logger.tagged('CONCEPTUAL_MODEL_MIGRATE') { logger.debug \"Files array size = #{files.size}\" }\n files\n end", "def to_a\n @file_list.map{ |file| Pathname.new(file) }\n end", "def images\n r = nil\n Dir.chdir(@originals) do\n r = Dir['*']\n end\n return r\n end", "def files\n file_sets.map{|fs| fs.files }.flatten\n end", "def list_files\n [].tap do |files|\n remote_files do |file|\n files << file\n end\n end\n end", "def files_array(files)\n return [] unless files\n files.is_a?(Array) ? files : pattern_to_filelist(files.to_s)\n end", "def list_images\n available_projects.map { |project| paginated_results(:list_images, :items, project) || [] }.flatten\n end", "def collect_files(dir_list)\n files = Array.new\n dir_list.each do |dir_name|\n files += Dir::glob(\"#{dir_name}/*\")\n end\n files\n end", "def files\n ext_files = mapper.extracted_files || []\n ext_files + [mapper.zip.name.to_s]\n end", "def collect_all\n # TODO refactor using Find\n glob_rule = \"#{@images_dir}/{#{@content_types.join(',')}}/**/[0-9]*.{#{options.filetypes.join(',')}}\"\n\n # Store the paths in an Array[]\n Dir[glob_rule]\n end", "def file_list\n @file_list\n end", "def images\n sources.map { |source| source.image }\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Store +exception_report+ in the exception list. This also indexes the exception into the appropriate exception group.
def store(exception_report) @exceptions << exception_report self.machines << exception_report.machine self.applications << exception_report.application exception_report.id = exceptions.length - 1 exception_groups[exception_report.digest] ||= [] exception_groups[exception_report.digest] << exception_report exception_report.id end
[ "def report(exception_report)\n @exceptions << exception_report\n end", "def store(exception_report)\n report = ExceptionReport.create_from_exception_report(exception_report)\n update_caches(report)\n report.id\n end", "def report(exception_report)\n File.open(filename, 'a') do |file|\n file.puts \"Machine: #{exception_report.machine}\"\n file.puts \"Application: #{exception_report.application}\"\n file.puts \"Timestamp: #{exception_report.timestamp}\"\n file.puts \"Type: #{exception_report.type}\"\n file.puts \"Exception: #{exception_report.exception}\"\n file.puts \"Data: #{YAML.dump(exception_report.data)}\"\n if exception_report.backtrace\n file.puts \"Stack trace:\"\n file.puts exception_report.backtrace.join(\"\\n\")\n end\n file.puts\n end\n end", "def reports_in_group(digest)\n exception_groups[digest]\n end", "def exception_links(exception_report)\n []\n end", "def set_aggregate_failures_exception(exception); end", "def after_create(app, report)\n # Only send an email if it's the first exception of this type\n # we've seen\n send_email(app, report) if app.store.group(report.digest).count == 1\n super(app, report)\n end", "def addException(exceptionString)\n @exceptions << exceptionString\n end", "def add_report(report)\n report = [report] unless report.is_a?(Array)\n\n report.each do |r|\n unless r =~ /^{([^}]*)}(.*)$/\n fail Dav::Exception, 'Reportname must be in clark-notation'\n end\n\n @reports << r\n end\n end", "def report_exception(exception, request_data = nil, person_data = nil, level = nil)\n if person_data\n person_id = person_data[Rollbar.configuration.person_id_method.to_sym]\n return 'ignored' if configuration.ignored_person_ids.include?(person_id)\n end\n\n return 'disabled' unless configuration.enabled\n return 'ignored' if ignored?(exception)\n\n data = exception_data(exception, level ? level : filtered_level(exception))\n\n attach_request_data(data, request_data) if request_data\n data[:person] = person_data if person_data\n\n @last_report = data\n\n payload = build_payload(data)\n schedule_payload(payload)\n log_instance_link(data)\n data\n rescue Exception => e\n report_internal_error(e)\n 'error'\n end", "def exceptions=(value)\n @values['exceptions'] = value\n end", "def last_exception=(exception); end", "def register_exception(e)\n @exceptions << e\n end", "def set_exception(exception); end", "def exceptions=(value)\n @exceptions = value\n end", "def exception_links(exception_report)\n super(exception_report) + [[\"Report to Lighthouse\", \"/lighthouse/report/#{exception_report.id}.html\"]]\n end", "def report(e, other = {})\n if raise_errors?\n squash_context(exception_info(e), other) # surface problems squashing\n raise e\n else\n report!(e, other)\n end\n end", "def save_exception(exception)\n if Maglev.needs_commit\n warn(\"Saving exception to ObjectLog, discarding transaction\")\n end\n Maglev.abort_transaction\n DebuggerLogEntry.create_continuation_labeled(exception.message)\n Maglev.commit_transaction\n end", "def index\n @trace_exceptions = TraceException.all\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a list of exceptions whose digest is +digest+.
def reports_in_group(digest) exception_groups[digest] end
[ "def group(digest)\n ExceptionGroup.where(:digest => digest).first\n end", "def reports_in_group(digest)\n ExceptionReport.where(:digest => digest).order_by(:timestamp.desc)\n end", "def recent\n data = []\n exception_groups.map do |digest, group|\n data << build_group_for_exceptions(group)\n end\n\n data.reverse\n end", "def find_checksum_by_digest(digest)\n checksum = nil\n checksums.each do |cs|\n if cs.digest == digest\n checksum = cs\n break\n end\n end\n checksum\n end", "def extract_sentry_exceptions(event)\n event&.exception&.values || []\n end", "def exception_signatures\n [\n SocketError.new('getaddrinfo: Name or service not known'),\n Errno::ECONNREFUSED.new('Connection refused - connect(2) for \"example.com\" port 443'),\n Errno::ETIMEDOUT.new('Connection timed out - connect(2) for \"example.com\" port 443'),\n Net::OpenTimeout.new('message'),\n Errno::ECONNRESET.new('Connection reset by peer - SSL_connect'),\n Errno::EHOSTUNREACH.new('No route to host - connect(2) for \"example.com\" port 443'),\n Errno::ENETUNREACH.new('Network is unreachable - connect(2) for \"example.com\" port 443')\n ]\n end", "def list_exceptions\n exceptions = @cmd['exceptions']\n return unless exceptions\n\n print_log \"\\nExclusions:\".underline, ' ',\n exceptions.join(', ').yellow, \"\\n\"\n end", "def exceptions\n\t\tselect {|x| x.class == Exception }\n\tend", "def compute_digest(stack_trace)\n md5 = Digest::MD5.new\n\n # 1: extract error class from first line\n cur_stack_trace_line = stack_trace.shift\n error_class = @error_pattern.match(cur_stack_trace_line)\n\n # digest: error classname\n md5.update error_class[1]\n\n # 2: read all stack trace elements until stack trace is empty or we hit the next error\n ste_count = 0\n while not stack_trace.empty?\n cur_stack_trace_line = stack_trace.first\n if cur_stack_trace_line.start_with?(' ') or cur_stack_trace_line.start_with?(\"\\t\")\n # current line starts with a whitespace: is it a stack trace element ?\n stack_element = @stack_element_pattern.match(cur_stack_trace_line)\n if stack_element\n # current line is a stack trace element\n ste_count+=1\n if not is_excluded?(stack_element)\n # digest: STE classname and method\n md5.update stack_element[1]\n # digest: line number (if present)\n if not (stack_element[3].nil? or stack_element[3].empty?)\n md5.update stack_element[3]\n end\n end\n end\n elsif(ste_count > 0)\n # current line doesn't start with a whitespace and we've already read stack trace elements: it looks like the next error in the stack\n break\n end\n # move to next line\n stack_trace.shift\n end\n\n\n # 3: if stack trace not empty, compute digest for next error\n if not stack_trace.empty?\n md5.update compute_digest(stack_trace)\n end\n\n return md5.hexdigest\n end", "def get_image_manifest_by_digest(digest)\n\n token = self.get_auth_token\n\n # https://docs.docker.com/registry/spec/api/#detail\n reg_response = RestClient.get \"https://#{@registry_server}/v2/#{@repository_name}/manifests/#{digest}\", { 'Authorization' => \"Bearer #{token}\" }\n respcode = reg_response.code\n\n if respcode != 200\n raise \"Request to registry failed - response code #{respcode}\"\n end\n\n return reg_response\n\n end", "def validate_digest(digest, options = {})\n options[:digest] = digest\n validate(options)\n end", "def summary_digests\n summary_for_feed[:digests].inject([]) do |r, e|\n r |= e\n end.uniq\n end", "def exceptions\n exceptions = DivaServicesApi.get(\"/algorithms/#{id}/exceptions\").parsed_response\n exceptions.map do |entry|\n DivaServicesApi::ExceptionMessage.new(id, DateTime.parse(entry['date']), entry['errorMessage'])\n end\n end", "def group_exceptions\n rightsMetadata.groups.map {|k, v| k if v == 'exceptions'}.compact\n end", "def step_through_differences(etags, digests)\n differences_agree = []\n etags.zip(digests).each_with_index do |zipped, i|\n next unless i.positive?\n etag, digest = zipped\n if etag != etags[i - 1]\n differences_agree << digest != digests[i - 1]\n elsif digest != digests[i - 1]\n differences_agree << etag != etags[i - 1]\n end\n end\n differences_agree\nend", "def group_exceptions\n groups.map {|k, v| k if v == 'exceptions'}.compact\n end", "def exceptions\n unless defined? @exceptions then\n if @exception_list.empty? then\n @exceptions = nil\n else\n @exceptions = Regexp.union(*@exception_list)\n end\n end\n\n @exceptions\n end", "def failure_exceptions\n @failure_exceptions ||= []\n end", "def digest_paths\n @manifest_index.values\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Empty this exception store. Useful for tests!
def clear @exceptions = [] @exception_groups = {} @machines = Set.new @applications = Set.new end
[ "def clear\n @exceptions = []\n end", "def clear_exceptions\n @exception.clear\n end", "def clear\n `#{store}.clear()`\n end", "def clear!\n event_store.clear\n end", "def clear!\n fail HasUncommittedEvents if aggregates.values.any? { |x| !x.uncommitted_events.empty? }\n\n clear\n end", "def clear\n @throws = []\n end", "def clear!\n key_files.clear\n key_data.clear\n known_identities.clear\n self\n end", "def clear_error\n @exception = nil\n end", "def clear\n\n @db.vanish || raise_error\n end", "def clear()\n @table_throws.clear\n end", "def clear_exception\n <<-CODE\n c->exception = Qnil;\n CODE\n end", "def clear!\n @errors.clear\n end", "def clear\n\n %w[ msgs schedules errors expressions workitems ].each do |type|\n purge_type!(type)\n end\n end", "def clear\n @errors.clear\n end", "def reset_eshelf\n @eshelf = nil\n @eshelf_structure = nil\n @size = nil\n @records = nil\n @basket_id = nil\n end", "def clear_exceptions\n raise \"exceptions already compiled\" if defined? @exceptions\n @exception_list.clear\n nil\n end", "def clear!\n @key_files = []\n @known_identities = nil\n self\n end", "def clear\n\tself.activations.clear\n\tself.agenda.clear\n\tself.default_facts.clear\n\tself.facts.clear\n\tself.rules.clear\n\tself\n end", "def clear\n entries.clear\n self\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find an exception report with the given id.
def find(id) exceptions[id.to_i] end
[ "def find(id)\n ExceptionReport.find(id).to_exception_report\n end", "def get_report(id)\n report = reports.detect { |r| r.id == id }\n raise(UsbException, \"No report with id #{id}\") if report.nil?\n return report\n end", "def find_by_id(id)\n find_one(id)\n rescue RecordNotFound\n nil\n end", "def find(id)\n records.find {|r| r.id == id } || raise('Unknown Record')\n end", "def find_by_id(id)\n id = id.to_i\n\n @id_hash[id]\n end", "def find(id)\r\n find_one do |record|\r\n record.id == id\r\n end\r\n end", "def report(id)\n get(\"reports/#{id}\")\n end", "def find(id)\n @records.find { |record| record.id == id }\n end", "def find_entry(feed_uri, name, id, report=false)\n entries = Feed.read(feed_uri, name, self, report)\n entries.each do |from_feed|\n return from_feed if id == from_feed.child_content('id')\n end\n\n return \"Couldn't find id #{id} in feed #{feed_uri}\"\n end", "def find_entry_by_id(id)\n build_entry_by_id_index\n \n @entries_by_ids[id]\n end", "def get_report(id) path = \"/api/v2/reports/#{id}\"\n get(path, {}, AvaTax::VERSION) end", "def lookup_admin_report(id)\n lookup_report(id, true)\n end", "def report_get id\n call! report_get, id\n end", "def report(id)\n Report.new(get(\"reports/#{id}\"))\n end", "def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end", "def find_issue_by_id(issue_id)\n issue = nil\n begin\n issue = @jira.getIssue(issue_id)\n rescue => e\n puts \"no match for issue #{issue_id} in Jira\"\n end\n issue\n end", "def find_by_friendly_id(id)\n first_by_friendly_id(id) or raise_not_found_exception(id)\n end", "def find(id)\n find!(id)\n rescue CatchNotes::NotFound\n nil\n end", "def find_report(report_name)\n reports_table.rows.select{ |row| row[0].text == report_name}.first\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return recent exceptions grouped by digest.
def recent data = [] exception_groups.map do |digest, group| data << build_group_for_exceptions(group) end data.reverse end
[ "def group(digest)\n ExceptionGroup.where(:digest => digest).first\n end", "def reports_in_group(digest)\n ExceptionReport.where(:digest => digest).order_by(:timestamp.desc)\n end", "def reports_in_group(digest)\n exception_groups[digest]\n end", "def group_exceptions\n groups.map {|k, v| k if v == 'exceptions'}.compact\n end", "def group_exceptions\n rightsMetadata.groups.map {|k, v| k if v == 'exceptions'}.compact\n end", "def extract_sentry_exceptions(event)\n event&.exception&.values || []\n end", "def exceptions\n exceptions = DivaServicesApi.get(\"/algorithms/#{id}/exceptions\").parsed_response\n exceptions.map do |entry|\n DivaServicesApi::ExceptionMessage.new(id, DateTime.parse(entry['date']), entry['errorMessage'])\n end\n end", "def extract_exceptions_from(tree)\n exceptions = tree.delete(:except) || []\n nested_exceptions = {}\n\n tree.each do |key, value|\n next unless value.is_a?(Hash) && !value.empty?\n\n sub_exceptions = extract_exceptions_from(value)\n nested_exceptions[key] = sub_exceptions unless sub_exceptions.empty?\n end\n\n exceptions += [nested_exceptions] unless nested_exceptions.empty?\n exceptions\n end", "def errors_collection \n errors_array.sort_by{|e| e.timestamp }.reverse\n end", "def recently_failed\n joins(:executions)\n .where('executions.success = 0')\n .select('notebooks.*, MAX(executions.updated_at) AS last_failure')\n .group('notebooks.id')\n .order('last_failure DESC')\n end", "def compute_digest(stack_trace)\n md5 = Digest::MD5.new\n\n # 1: extract error class from first line\n cur_stack_trace_line = stack_trace.shift\n error_class = @error_pattern.match(cur_stack_trace_line)\n\n # digest: error classname\n md5.update error_class[1]\n\n # 2: read all stack trace elements until stack trace is empty or we hit the next error\n ste_count = 0\n while not stack_trace.empty?\n cur_stack_trace_line = stack_trace.first\n if cur_stack_trace_line.start_with?(' ') or cur_stack_trace_line.start_with?(\"\\t\")\n # current line starts with a whitespace: is it a stack trace element ?\n stack_element = @stack_element_pattern.match(cur_stack_trace_line)\n if stack_element\n # current line is a stack trace element\n ste_count+=1\n if not is_excluded?(stack_element)\n # digest: STE classname and method\n md5.update stack_element[1]\n # digest: line number (if present)\n if not (stack_element[3].nil? or stack_element[3].empty?)\n md5.update stack_element[3]\n end\n end\n end\n elsif(ste_count > 0)\n # current line doesn't start with a whitespace and we've already read stack trace elements: it looks like the next error in the stack\n break\n end\n # move to next line\n stack_trace.shift\n end\n\n\n # 3: if stack trace not empty, compute digest for next error\n if not stack_trace.empty?\n md5.update compute_digest(stack_trace)\n end\n\n return md5.hexdigest\n end", "def exceptions_raised\n actions_with_exceptions.map { |_operation, formats| formats[:raises].is_a?(Array) ? formats[:raises] : [formats[:raises]] }.flatten\n end", "def summary_digests\n summary_for_feed[:digests].inject([]) do |r, e|\n r |= e\n end.uniq\n end", "def exceptions\n @exceptions ||= key[:exceptions]\n end", "def exceptions\n @values['exceptions']\n end", "def retrieve_failed_events\n options[:start_time] = events_last_synced_at.to_i # Integer timestamp of the last time this rake task ran\n options[:offset] = @offset if @offset.present? # Pass the offset if it is present\n ChargeBee::Event.list(options)\n end", "def failure_exceptions\n @failure_exceptions ||= []\n end", "def step_through_differences(etags, digests)\n differences_agree = []\n etags.zip(digests).each_with_index do |zipped, i|\n next unless i.positive?\n etag, digest = zipped\n if etag != etags[i - 1]\n differences_agree << digest != digests[i - 1]\n elsif digest != digests[i - 1]\n differences_agree << etag != etags[i - 1]\n end\n end\n differences_agree\nend", "def last_exception\n nil\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
must have form or form draft. cannot have both
def belongs_to_form_or_form_draft? return if form.present? ^ form_draft.present? errors.add :base, 'You must specify either a form or form_draft, but not both' end
[ "def valid?(context = nil)\n self.draft, is_draft = false, self.draft\n super\n ensure\n self.draft = is_draft\n end", "def draftable?\n false\n end", "def is_draft\n unless @submission.draft?\n redirect_to @problem\n end\n end", "def draft?\n @draft\n end", "def draft?\n (status == DRAFT)\n end", "def draft?\n !published && !Template.published(family_id).empty?\n end", "def can_update_draft\n redirect_to problem_path(@problem) if @no_new_submission\n end", "def form?\n self.type == :form\n end", "def validation_required?\n return true if from_api?\n return false if draft? || archived_pending_delete? || disabled_for_transition?\n true\n end", "def require_name?\n !draft?\n end", "def is_draft\n return @is_draft\n end", "def manage_draft(model)\n return false unless params[:save_draft]\n\n Rails.logger.debug('save_draft pressed')\n if model.valid?(:draft)\n Rails.logger.debug(' validation passed')\n redirect_to(action: :save_draft)\n else\n render(status: :unprocessable_entity)\n end\n true\n end", "def draft_present?\n return true if draft_present == true && !indicator_is_draft? && !enquiry_indicator?\n\n false\n end", "def has_standard_copy_form?\n is_standard ? false : respond_to?(:standard_copy_form_id) ? !standard_copy_form_id.nil? : forms.any?(&:standard_copy?)\n end", "def is_draft\n return @is_draft\n end", "def draft?\n return !self.published && Template.published(self.family_id).length > 0\n end", "def draft_check\n draft_tutorial = self.draft\n draft_chapters = self.chapters.where({draft: true}).empty?\n draft_steps = self.steps.where({draft: true}).empty?\n\n if draft_tutorial == true || draft_chapters == false || draft_steps == false\n return true\n else\n return false\n end\n end", "def application_form_status\n application_form.is_accepted rescue nil\n\n end", "def form?\n @object.type == :form\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a named route called "root" for matching the root level request.
def root(options = {}) if options.is_a?(Symbol) if source_route = @set.named_routes.routes[options] options = source_route.defaults.merge({ :conditions => source_route.conditions }) end end named_route("root", '', options) end
[ "def root(options = {})\n named_route(\"root\", '', options)\n end", "def root(options = {})\n if options.is_a?(Symbol)\n if source_route = @set.named_routes.routes[options]\n options = source_route.defaults.merge({ :conditions => source_route.conditions })\n end\n end\n named_route(\"root\", '', options)\n end", "def root(handler)\n @routes[''] = handler\n end", "def add_root_route root_route, route_set\n root_route.conditions[:path_info] = root_route.conditions[:path_info].dup\n route_set.set.add_route *root_route\n route_set.named_routes[root_route.name] = root_route\n route_set.routes << root_route\n end", "def root_to reference\n Router.set_root_to reference\n context = Context.collection[reference]\n context.routes[:root]= Route.new('/', context,{ context: reference})\n end", "def root\n get '/'\n end", "def add_root_endpoint(root)\n @mod.instance_variable_set(:@root, root)\n @mod.define_singleton_method(:root) { @root }\n end", "def sitepress_root(controller: DEFAULT_CONTROLLER, action: DEFAULT_ACTION)\n if has_named_route? :root\n Rails.logger.warn \"Sitepress tried to configured the 'root' route, but it was already defined. Check the 'routes.rb' file for a 'root' route or call 'sitepress_pages(root: false)'.\"\n else\n root controller: controller, action: action\n end\n end", "def root; resource :path => '/'; end", "def create_default_route\n Route.default_route_for_app_id(self.id) if self.id.present?\n end", "def root(name=nil)\n @root = name.to_sym if name\n # The first rule in a grammar is the default root.\n @root || rule_names.first\n end", "def default_route\n @default_route ||= '/'\n end", "def root(name=nil)\n @root = name.to_sym if name\n # The first rule in a grammar is the default root.\n @root || rule_names.first\n end", "def named_routes=(_arg0); end", "def root(name=nil)\n if name\n @root = name.to_sym\n else\n # The first rule in a grammar is the default root.\n if instance_variable_defined?(:@root)\n @root\n else\n rule_names.first\n end\n end\n end", "def jjane_root\n\troot :controller => :site, :action => :home_page\n end", "def define_routes; end", "def root; get(\"\"); end", "def static_root=(root)\n expire_index!\n @static_root = root ? Pathname.new(root) : nil\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the relative name of path1 under some path2.
def get_relative_name(path1, path2) path1.start_with?(path2) && path1 != path2 ? path1[path2.length+1..-1] : "" end
[ "def relative_path(path1 = nil, path2)\n path2 = path2 << \"/three20\"\n\n unless path1.nil?\n path1 = File.expand_path(path1)\n @@logger.info \"expanded path1 to: #{path1}\"\n #FileUtils.cd path #File.expand_path(path)\n\n else\n path1 = FileUtils.pwd\n end\n\n @@logger.info \"path1: #{path1} with path2: #{path2}\"\n\n p1 = Pathname.new(path1)\n p2 = Pathname.new(path2)\n relative_path = p2.relative_path_from(p1.parent) # TODO adding .parent seems like a hack\n \n @@logger.info \"the relative path is: #{relative_path}\"\n @@logger.info \"expanded: #{File.expand_path(relative_path)}\"\n end", "def relative_path_from(other)\n Pathname.new(self).relative_path_from(Pathname.new(other)).to_s\n end", "def relative_from_base(path)\n Pathname.new(@from_base).relative_path_from(Pathname.new(path)).to_s\n end", "def resolve_path(ref)\n ref = ref.to_s\n if ref[0,1] == \"/\"\n Pathname(ref[1..-1])\n else\n path.parent + ref\n end\n end", "def shorten2(path)\n p = get(path)\n home = Pa.home2\n\n return p if home.empty?\n\n ret = relative_to2(p, home)\n\n if ret == p\n p\n else\n ret == \".\" ? \"\" : ret\n File.join(\"~\", ret)\n end\n end", "def relative_path_from(start, dest); end", "def rto(a, b)\n\tPathname.new(File.join a, '..', b).cleanpath.to_s\nend", "def relative_path_to(path)\n if nested_namespaces?\n path.relative_path_from(@folder)\n else\n path.basename\n end\n end", "def get_name(path)\n return path[/^.*\\/(.+?)\\/?$/, 1]\n end", "def common_path(other)\n File.common_path([self.to_s, other.to_s]).to_pathname\n end", "def join(base, path)\n (Pathname.new(base) + path).to_s\n end", "def relpath\n File.join(first, last, @id)\n end", "def relative_path(path)\n path.split('/').drop(5).join('/')\nend", "def relative_path_from(start, dest)\n start, dest = Pathname.new(start), Pathname.new(dest)\n start = start.dirname unless start.directory?\n dest.relative_path_from(start).to_s\n end", "def path_diff(path1, path2)\n File.join(path1.split(\"/\") - path2.split(\"/\"))\n end", "def resolve_relative_path(path, base_path)\n p = Pathname(base_path)\n p = p.dirname unless p.extname.empty?\n p += path\n\n p.cleanpath.to_s\n end", "def relative_path(path)\n path = expand(path)\n return nil unless relative?(path)\n \n # if path_root_length > path.length then the first arg\n # returns nil, and an empty string is returned\n path[path_root_length, path.length - path_root_length] || \"\"\n end", "def path_join(base, path)\n return path if path_is_absolute(path)\n base.gsub(/[\\/]+$/, '') + '/' + path.gsub(/^[\\/]+/, '')\n end", "def relative_path (from_str, to_str)\n require 'pathname'\n Pathname.new(to_str).relative_path_from(Pathname.new(from_str)).to_s\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /cyclic_servos/1 GET /cyclic_servos/1.json
def show @cyclic_servo = CyclicServo.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @cyclic_servo } end end
[ "def new\n @cyclic_servo = CyclicServo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cyclic_servo }\n end\n end", "def destroy\n @cyclic_servo = CyclicServo.find(params[:id])\n @cyclic_servo.destroy\n\n respond_to do |format|\n format.html { redirect_to cyclic_servos_url }\n format.json { head :no_content }\n end\n end", "def index\n @servs = Serv.all\n end", "def servers(service_id)\n request :get, \"/services/#{service_id}/servers\"\n end", "def index\n @servings = Serving.all\n end", "def index\n @clientes_servicos = ClientesServico.all\n end", "def index\n @serves = Serve.all\n end", "def service\r\n channels = Channel.where(service: channel_params[:service])\r\n render json: channels\r\n end", "def index\n @cycles = Cycle.where(group_id: params[:group_id])\n\n render json: @cycles\n end", "def create\n @cyclic_servo = CyclicServo.new(params[:cyclic_servo])\n\n respond_to do |format|\n if @cyclic_servo.save\n format.html { redirect_to @cyclic_servo, notice: 'Cyclic servo was successfully created.' }\n format.json { render json: @cyclic_servo, status: :created, location: @cyclic_servo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cyclic_servo.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @servidores = Servidor.all\n end", "def show\n @serv = Serv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @serv }\n end\n end", "def cycle\n TflApi::Client::Cycle.new(self)\n end", "def index\n @conductors = Conductor.all\n render :json => @conductors\n end", "def get_clients_by_devices(args = {}) \n get(\"/clients.json/stats/device\", args)\nend", "def index\n @servants = Servant.all\n end", "def index\n @client_services = ClientService.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @client_services }\n end\n end", "def index\n @convos = Convo.all\n render json: @convos\n end", "def index\n @servicio_de_cinerarios = ServicioDeCinerario.all\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /cyclic_servos/new GET /cyclic_servos/new.json
def new @cyclic_servo = CyclicServo.new respond_to do |format| format.html # new.html.erb format.json { render json: @cyclic_servo } end end
[ "def new\n @serv = Serv.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serv }\n end\n end", "def new\n @server = Server.new\n @creating_new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server }\n\n end\n end", "def new\n @servico = Servico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @servico }\n end\n end", "def create\n @serv = Serv.new(params[:serv])\n if @serv.mother\n @serv.conn.ip=@serv.mother.conn.ip\n @serv.domain=@serv.mother.name\n end\n\n respond_to do |format|\n if @serv.save\n format.html { redirect_to servs_url, notice: t('servs.create.notice') }\n format.json { render json: @serv, status: :created, location: @serv }\n else\n @net_eles = NetEle.all\n format.html { render action: \"new\" }\n format.json { render json: @serv.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @serving = Serving.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serving }\n end\n end", "def create\n @cyclic_servo = CyclicServo.new(params[:cyclic_servo])\n\n respond_to do |format|\n if @cyclic_servo.save\n format.html { redirect_to @cyclic_servo, notice: 'Cyclic servo was successfully created.' }\n format.json { render json: @cyclic_servo, status: :created, location: @cyclic_servo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cyclic_servo.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @server_node = ServerNode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server_node }\n end\n end", "def new\n @service_sermon = Service::Sermon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @service_sermon }\n end\n end", "def new\n @server = Server.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @service }\n end\n end", "def new\n @punto_servicio = PuntoServicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @punto_servicio }\n end\n end", "def create\n @serv = Serv.new(params[:serv])\n\n respond_to do |format|\n if @serv.save\n format.html { redirect_to @serv, notice: 'Serv was successfully created.' }\n format.json { render json: @serv, status: :created, location: @serv }\n else\n format.html { render action: \"new\" }\n format.json { render json: @serv.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @solicitud_servicio = SolicitudServicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @solicitud_servicio }\n end\n end", "def new\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @service }\n end\n end", "def new\n @servicetype = Servicetype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @servicetype }\n end\n end", "def new\n @consecutive = Consecutive.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @consecutive }\n end\n end", "def new\n @server_status = ServerStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server_status }\n end\n end", "def new\n @cycle = Cycle.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cycle }\n end\n end", "def new\n @servqual = Servqual.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @servqual }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /cyclic_servos POST /cyclic_servos.json
def create @cyclic_servo = CyclicServo.new(params[:cyclic_servo]) respond_to do |format| if @cyclic_servo.save format.html { redirect_to @cyclic_servo, notice: 'Cyclic servo was successfully created.' } format.json { render json: @cyclic_servo, status: :created, location: @cyclic_servo } else format.html { render action: "new" } format.json { render json: @cyclic_servo.errors, status: :unprocessable_entity } end end end
[ "def new\n @cyclic_servo = CyclicServo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cyclic_servo }\n end\n end", "def create\n @serv = Serv.new(params[:serv])\n if @serv.mother\n @serv.conn.ip=@serv.mother.conn.ip\n @serv.domain=@serv.mother.name\n end\n\n respond_to do |format|\n if @serv.save\n format.html { redirect_to servs_url, notice: t('servs.create.notice') }\n format.json { render json: @serv, status: :created, location: @serv }\n else\n @net_eles = NetEle.all\n format.html { render action: \"new\" }\n format.json { render json: @serv.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recurso_servidor = RecursoServidor.new(recurso_servidor_params)\n\n respond_to do |format|\n if @recurso_servidor.save\n format.html { redirect_to @recurso_servidor, notice: 'Recurso solicitado com sucesso.' }\n format.json { render :show, status: :created, location: @recurso_servidor }\n else\n format.html { render :new }\n format.json { render json: @recurso_servidor.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @cyclic_servo = CyclicServo.find(params[:id])\n @cyclic_servo.destroy\n\n respond_to do |format|\n format.html { redirect_to cyclic_servos_url }\n format.json { head :no_content }\n end\n end", "def create\n @serv = Serv.new(params[:serv])\n\n respond_to do |format|\n if @serv.save\n format.html { redirect_to @serv, notice: 'Serv was successfully created.' }\n format.json { render json: @serv, status: :created, location: @serv }\n else\n format.html { render action: \"new\" }\n format.json { render json: @serv.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @servicio = Servicio.new(servicio_params)\n respond_to do |format|\n # Creacion de Asientos de Servicio para el Servicio recien creado\n t = @servicio.transaction do\n @servicio.save\n for i in 1..@servicio.unidad.cantAsientos\n AsientoDeServicio.create(nro: i, estado: true, servicio_id: @servicio.id)\n end\n end\n if t\n format.html { redirect_to @servicio, notice: 'Servicio was successfully created.' }\n format.json { render :show, status: :created, location: @servicio }\n else\n format.html { render :new }\n format.json { render json: @servicio.errors, status: :unprocessable_entity }\n end\n end \n end", "def create\n @serv = Serv.new(serv_params)\n\n respond_to do |format|\n if @serv.save\n format.html { redirect_to @serv, notice: 'Serv was successfully created.' }\n format.json { render :show, status: :created, location: @serv }\n else\n format.html { render :new }\n format.json { render json: @serv.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend", "def create\n @servidor = Servidor.new(servidor_params)\n\n respond_to do |format|\n if @servidor.save\n format.html { redirect_to servidores_path, success: 'Servidor cadastrado com sucesso.' }\n format.json { render :show, status: :created, location: @servidor }\n else\n format.html { render :new }\n format.json { render json: @servidor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @servidor = Servidor.new(servidor_params)\n\n respond_to do |format|\n if @servidor.save\n format.html { redirect_to @servidor, notice: 'Servidor was successfully created.' }\n format.json { render :show, status: :created, location: @servidor }\n else\n format.html { render :new }\n format.json { render json: @servidor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @c_serv = CServ.new(c_serv_params)\n\n respond_to do |format|\n if @c_serv.save\n format.html { redirect_to @c_serv, notice: 'C serv was successfully created.' }\n format.json { render :show, status: :created, location: @c_serv }\n else\n format.html { render :new }\n format.json { render json: @c_serv.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @servservice = Servservice.new(servservice_params)\n\n respond_to do |format|\n if @servservice.save\n format.html { redirect_to @servservice, notice: 'Servservice was successfully created.' }\n format.json { render :show, status: :created, location: @servservice }\n else\n format.html { render :new }\n format.json { render json: @servservice.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @clientes_servico = ClientesServico.new(clientes_servico_params)\n\n respond_to do |format|\n if @clientes_servico.save\n format.html { redirect_to @clientes_servico, notice: 'Clientes servico was successfully created.' }\n format.json { render action: 'show', status: :created, location: @clientes_servico }\n else\n format.html { render action: 'new' }\n format.json { render json: @clientes_servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_servers\n # use \"rsc\" tool to get detailed deployment + server view from api 1.6, not supported by right_api_client\n old_deployment = JSON.parse(`rsc -a #{@options[:src]} cm16 show /api/deployments/#{@options[:deployment]} view=full`)\n\n old_deployment['servers'].each do |server|\n @api.account_id = @options[:src]\n name = server['next_instance']['name']\n\n puts \"Creating server: #{name} ...\\n\"\n\n cloud = find_cloud(server['next_instance']['links']['cloud']['href'], name)\n @api.account_id = @options[:src]\n\n ssh_key = choose_ssh_key(cloud)\n @api.account_id = @options[:src]\n\n instance_type = choose_instance_type(cloud)\n old_st_url = server['next_instance']['server_template']['href']\n new_st_url = @server_templates[old_st_url]['new_st_url']\n \n mci = choose_mci(new_st_url)\n @api.account_id = @options[:src]\n\n subnets = choose_subnets(cloud)\n @api.account_id = @options[:src]\n\n security_groups = choose_security_groups(cloud)\n @api.account_id = @options[:src]\n\n inputs_hash = format_inputs(@api.resource(server['next_instance']['href']).show.inputs)\n\n # Create server\n params = {}\n params[:server] = {}\n params[:server][:name] = name\n params[:server][:deployment_href] = @new_deployment\n params[:server][:instance] = {}\n params[:server][:instance][:cloud_href] = cloud\n params[:server][:instance][:server_template_href] = new_st_url\n params[:server][:instance][:ssh_key_href] = ssh_key if ssh_key\n params[:server][:instance][:instance_type_href] = instance_type\n params[:server][:instance][:multi_cloud_image_href] = mci\n params[:server][:instance][:subnet_hrefs] = subnets if subnets\n params[:server][:instance][:security_group_hrefs] = security_groups\n params[:server][:instance][:inputs] = inputs_hash\n @api.account_id = @options[:dst]\n @api.servers.create(params)\n end\nend", "def create_next\n old_cycles = Maintenance::Cycle::CYCLE_TYPES.map { |type| Maintenance::Cycle.current(type) }.select{ |cycle| cycle && cycle.is_over? }\n cycles = []\n for old_cycle in old_cycles\n cycles << Maintenance::Cycle.generate_next_cycle( old_cycle.cycle_type )\n end\n flash[:sticky_messages] = []\n render json: cycles.map{|cycle| {cycle_number: cycle.ordinality_number, cycle_type: cycle.cycle_type_desc, year: cycle.year } }.to_json\n end", "def create\n @observ = Observ.new(observ_params)\n\n respond_to do |format|\n if @observ.save\n format.html { redirect_to @observ, notice: 'Observ was successfully created.' }\n format.json { render action: 'show', status: :created, location: @observ }\n else\n format.html { render action: 'new' }\n format.json { render json: @observ.errors, status: :unprocessable_entity }\n end\n end\n end", "def reserveNode(node_ids,account_name,valid_from,valid_until)\n cert_path = APP_CONFIG['cert_path']\n # resernation_name: we set a random name for every reservation constructing by the name of the slice and a random number ex user1/12341234 \n resernation_name =account_name+ \"/\" + (1000 + Random.rand(10000000)).to_s\n puts resernation_name\n \n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s\n\n node_ids.map!{|r| {uuid: r}}\n\n header = {\"Content-Type\" => \"application/json\"}\n options ={\n name: resernation_name,\n valid_from: valid_from,\n valid_until: valid_until,\n account: \n { \n name: account_name\n },\n components: node_ids\n }\n\n #puts options.to_json \n uri = URI.parse(broker_url+\"/resources/leases\")\n pem = File.read(cert_path)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.cert = OpenSSL::X509::Certificate.new(pem)\n http.key = OpenSSL::PKey::RSA.new(pem)\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Post.new(uri.request_uri, header)\n request.body = options.to_json\n\n response = http.request(request)\n \n res = JSON.parse(response.body)\n \n if response.header.code != '200'\n puts \"Something went wrong\"\n puts response \n puts res[\"exception\"][\"reason\"]\n return res[\"exception\"][\"reason\"]\n else\n return \"OK\"\n end\n \n end", "def create\n @servicio = Servicio.new(params[:servicio])\n\n respond_to do |format|\n if @servicio.save\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully created.' }\n format.json { render :json => @servicio, :status => :created, :location => @servicio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @service_sermon = Service::Sermon.new(params[:service_sermon])\n\n respond_to do |format|\n if @service_sermon.save\n format.html { redirect_to @service_sermon, notice: 'Sermon was successfully created.' }\n format.json { render json: @service_sermon, status: :created, location: @service_sermon }\n else\n format.html { render action: \"new\" }\n format.json { render json: @service_sermon.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /cyclic_servos/1 PUT /cyclic_servos/1.json
def update @cyclic_servo = CyclicServo.find(params[:id]) respond_to do |format| if @cyclic_servo.update_attributes(params[:cyclic_servo]) format.html { redirect_to @cyclic_servo, notice: 'Cyclic servo was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @cyclic_servo.errors, status: :unprocessable_entity } end end end
[ "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def put_clone\n response = self.class.put(\"/service/#{$service_id}/version/#{$service_version}/clone\", { \n headers: {\"Fastly-Key\" => $key} \n })\n end", "def destroy\n @cyclic_servo = CyclicServo.find(params[:id])\n @cyclic_servo.destroy\n\n respond_to do |format|\n format.html { redirect_to cyclic_servos_url }\n format.json { head :no_content }\n end\n end", "def create\n @cyclic_servo = CyclicServo.new(params[:cyclic_servo])\n\n respond_to do |format|\n if @cyclic_servo.save\n format.html { redirect_to @cyclic_servo, notice: 'Cyclic servo was successfully created.' }\n format.json { render json: @cyclic_servo, status: :created, location: @cyclic_servo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cyclic_servo.errors, status: :unprocessable_entity }\n end\n end\n end", "def change_serv(source_serv, dest_serv)\n end", "def update\n @server = compute.get_server(params[:id]).update(:name=>params[:name])\n respond_to do |format|\n format.html { redirect_to servers_path, :notice => 'Server was successfully updated.' }\n format.json { head :ok }\n end\n end", "def modify_server(server_uuid, params)\n data = { \"server\" => params }\n json = JSON.generate data\n response = put \"server/#{server_uuid}\", json\n\n response\n end", "def update\n @serv = Serv.find(params[:id])\n\n respond_to do |format|\n if @serv.update_attributes(params[:serv])\n format.html { redirect_to @serv, notice: 'Serv was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serv.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_aos_version(args = {}) \n put(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def update\n @company_id = company_params[:company_id]\n @reponse = HTTParty.put(\"https://rails-api-ipo.herokuapp.com/api/v1/companies/#{@company_id}.json\",\n :body => {:company_name => company_params[:company_name]}.to_json,\n :headers => { 'Content-Type' => 'application/json' } )\n respond_to do |format|\n format.html { redirect_to '/companies/'+(@reponse['id'].to_s), notice: 'Company was successfully created.' }\n end\n end", "def update\n respond_to do |format|\n if @recurso_servidor.update(recurso_servidor_params)\n format.html { redirect_to @recurso_servidor, notice: 'Recurso servidor was successfully updated.' }\n format.json { render :show, status: :ok, location: @recurso_servidor }\n else\n format.html { render :edit }\n format.json { render json: @recurso_servidor.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @cyclic_servo = CyclicServo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cyclic_servo }\n end\n end", "def put(*a) route 'PUT', *a end", "def update\n respond_to do |format|\n if @servidor.update(servidor_params)\n format.html { redirect_to @servidor, notice: 'Servidor atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @servidor.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, params={}); make_request(:put, host, port, path, params); end", "def update\n respond_to do |format|\n if @serv.update(serv_params)\n format.html { redirect_to @serv, notice: 'Serv was successfully updated.' }\n format.json { render :show, status: :ok, location: @serv }\n else\n format.html { render :edit }\n format.json { render json: @serv.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_mobile_carrier(args = {}) \n put(\"/mobile.json/#{args[:carrierId]}\", args)\nend", "def show\n @cyclic_servo = CyclicServo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cyclic_servo }\n end\n end", "def create\n @serv = Serv.new(params[:serv])\n if @serv.mother\n @serv.conn.ip=@serv.mother.conn.ip\n @serv.domain=@serv.mother.name\n end\n\n respond_to do |format|\n if @serv.save\n format.html { redirect_to servs_url, notice: t('servs.create.notice') }\n format.json { render json: @serv, status: :created, location: @serv }\n else\n @net_eles = NetEle.all\n format.html { render action: \"new\" }\n format.json { render json: @serv.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /cyclic_servos/1 DELETE /cyclic_servos/1.json
def destroy @cyclic_servo = CyclicServo.find(params[:id]) @cyclic_servo.destroy respond_to do |format| format.html { redirect_to cyclic_servos_url } format.json { head :no_content } end end
[ "def destroy\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n @server.send_delete\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end", "def destroy\n @recurso_servidor.destroy\n respond_to do |format|\n format.html { redirect_to recurso_servidors_url, notice: 'Recurso servidor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @serv = Serv.find(params[:id])\n @serv.destroy\n\n respond_to do |format|\n format.html { redirect_to servs_url, notice: t('servs.delete.notice') }\n format.json { head :no_content }\n end\n end", "def destroy\n @serv = Serv.find(params[:id])\n if @serv.mngbl\n #Remueve el MR a través de una llamada al webservice del núcleo\n http = Net::HTTP.new(\"192.168.119.163\",9999)\n post_params = {'ip' => @serv.conn.ip, 'port' => @serv.conn.port}\n request = Net::HTTP::Delete.new(\"/mbs/#{@serv.domain}/#{@serv.name}\")\n request.set_form_data(post_params)\n begin\n response = http.request(request)\n rescue Errno::ECONNREFUSED\n end\n end\n @serv.destroy\n\n respond_to do |format|\n format.html { redirect_to servs_url, notice: t('servs.delete.notice') }\n format.json { head :no_content }\n end\n end", "def destroy\n http_api.delete(\"clients/#{@name}\")\n end", "def destroy\n @serv = Serv.find(params[:id])\n @serv.destroy\n\n respond_to do |format|\n format.html { redirect_to servs_url }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @clientes_servico.destroy\n respond_to do |format|\n format.html { redirect_to clientes_servicos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @servico = Servico.find(params[:id])\n @servico.destroy\n\n respond_to do |format|\n format.html { redirect_to servicos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n define_path\n ServerFileOperation.delete(@client.home_directory,@public_path)\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(clients_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @complex_graph = ComplexGraph.find(params[:id])\n @complex_graph.destroy\n\n respond_to do |format|\n format.html { redirect_to url_for(:controller=>:service, :action => :index) }\n format.json { head :no_content }\n end\n end", "def destroy\n @c_serv.destroy\n respond_to do |format|\n format.html { redirect_to c_servs_url, notice: 'C serv was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n render json: @api_v1_client if @api_v1_client.destroy\n end", "def destroy\n @servidor.destroy\n respond_to do |format|\n format.html { redirect_to servidores_path, notice: 'Servidor excluído com sucesso!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_service = ClientService.find(params[:id])\n @client_service.destroy\n\n respond_to do |format|\n format.html { redirect_to client_services_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @servicio = Servicio.find(params[:id])\n @servicio.destroy\n\n respond_to do |format|\n format.html { redirect_to servicios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @observ.destroy\n respond_to do |format|\n format.html { redirect_to observs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @server = compute.get_server(params[:id])\n @server.delete!\n\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end", "def destroy\n @service_sermon = Service::Sermon.find(params[:id])\n @service_sermon.destroy\n\n respond_to do |format|\n format.html { redirect_to service_sermons_url }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1]. Brute force solution: Time O(n2), Space O(1)
def solution(nums, target) nums.each.with_index do |n, i| j = i + 1 while (j <= nums.size-1) return [i,j] if target == (n + nums[j]) j += 1 end end -1 end
[ "def solve(nums, target)\n nums.each_with_index do |e, i|\n nums.each_with_index do |e_, i_|\n return [i, i_] if ((e + e_ == target) && (i != i_))\n end\n end\nend", "def best_sum(target, array, memo={})\n return memo[target] if memo.include? (target)\n return [] if target == 0\n return nil if target < 0\n\n shortResult = nil\n\n array.each do |num|\n remainder = target - num\n\n remainderResult = can_sum(remainder, array, memo)\n\n if remainderResult != nil\n combination = [*remainderResult, num]\n\n if shortResult == nil || combination.length < shortResult.length\n shortResult = combination\n memo[target] = shortResult\n end\n end\n end\n shortResult\nend", "def find_prefix_solution(numbers, target_sum)\n return nil if numbers.size < 2\n\n sum_so_far = numbers[0]\n numbers[1..].each do |x|\n sum_so_far += x\n return x + numbers[0] if sum_so_far == target_sum\n end\n\n nil\nend", "def two_sum(nums, target)\n sorted_nums = nums.sort\n\n last_index = sorted_nums.size - 1\n first_index = 0\n\n while true do\n if sorted_nums[last_index] + sorted_nums[first_index] > target\n last_index -= 1\n\n next\n end\n\n smaller_have_to_be = target - sorted_nums[last_index]\n\n while true do\n if sorted_nums[first_index] < smaller_have_to_be\n first_index += 1\n\n next\n end\n\n break\n end\n\n if sorted_nums[first_index] != smaller_have_to_be\n last_index -= 1\n next\n end\n\n break\n end\n\n # Find correct indexes ( because that indexs in sorted array )\n\n result = []\n nums.each_with_index do |number, index|\n if [sorted_nums[first_index], sorted_nums[last_index]].include?(number)\n result.push(index)\n end\n end\n\n result\nend", "def two_sum(numbers, target)\n\n numbers.each_with_index do |num, index|\n \n looking_for = target - num\n answer_2 = binary_search(numbers, index + 1, numbers.length - 1, looking_for)\n if !!answer_2\n return [index + 1, answer_2 + 1] \n end\n end\nend", "def find_target_sum_ways(nums, s)\n return calculate(nums, 0, 0, s, cache={})\nend", "def combination_sum(candidates, target, results = [], solution = [], start = 0)\n return results << solution.clone if target == 0\n\n candidates.each_with_index do |num, idx|\n next if target < 0\n\n solution << num\n\n combination_sum(candidates[idx..-1], target - num, results, solution, idx)\n\n solution.pop\n end\n results\nend", "def combination_sum(nums, target)\n combinations = []\n combination_sum_helper(nums, target, [], combinations, 0)\n combinations\nend", "def two_sum(numbers, target)\n index1 = 0\n index2 = index1 + 1\n \n loop do\n break if numbers[index1] == nil\n loop do\n break if numbers[index2] == nil\n if numbers[index1] + numbers[index2] == target\n return [index1, index2]\n else \n index2 += 1\n end\n end\n index1 += 1\n index2 = index1 + 1\n end\n \nend", "def pair_sum(arr, target)\n # basic approach is nested loops scanning each element checking if its == to target\n result = []\n i = 0\n j = i + 1\n while i < arr.length\n while j < arr.length\n p i, j\n if i != j && arr[i] + arr[j] == target\n result << [i, j]\n end\n j += 1\n end\n i += 1\n j = i + 1\n end\n result\nend", "def combination_sum(candidates, target)\n r = []\n candidates.sort!\n #candidates = candidates.reverse\n loop = lambda do |i, target, combs|\n if target.zero?\n r << combs\n return\n end\n return if target < 0\n\n i.upto(candidates.size - 1) do |j|\n c = candidates[j]\n next if j > i && candidates[j-1] == c\n break if target < c\n loop.call(j + 1, target - c, combs + [c])\n end\n end\n loop.call(0, target, [])\n r\nend", "def four_sum(nums, target)\n nums.sort!\n res = []\n\n (0...nums.length - 3).each do |i|\n if i == 0 || nums[i] != nums[i - 1]\n (i + 1...nums.length - 2).each do |j|\n if j == i + 1 || nums[j] != nums[j - 1]\n low = j + 1\n high = nums.length - 1\n\n while low < high\n if nums[i] + nums[j] + nums[low] + nums[high] == target\n res << [nums[i], nums[j], nums[low], nums[high]]\n low += 1\n high -= 1\n\n low += 1 while nums[low] == nums[low - 1]\n high -= 1 while nums[high] == nums[high + 1]\n elsif nums[i] + nums[j] + nums[low] + nums[high] > target\n high -= 1\n else\n low += 1\n end\n end\n end\n end\n end\n end\n \n res\nend", "def pair_sum(target)\n set = []\n (0...length).each do |i|\n (i + 1...length).each do |j|\n set << [i, j] if self[i] + self[j] == target\n end\n end\n set\n end", "def two_sum_binary(numbers, target)\n numbers.each_with_index do |num, i|\n j = binary_search(numbers, target - num, i+1)\n\n # +1 because we do both index1 and index2 are not zero-based\n return [i+1, j+1] unless j == -1\n end\n\n raise ArgumentError.new(\"No two sum solution\")\nend", "def two_sum(array, target)\n\n !!array.uniq.combination(2).detect { |a, b| a + b == target }\nend", "def pair_sum(arr, target)\n\n pairs = []\n arr.each_with_index do |num1, idx1|\n arr.each_with_index do |num2, idx2|\n pairs << [num1, num2] if num1 + num2 == target && idx1 != idx2\n end\n end\n pairs\nend", "def contiguous_sum_smart(candidates, target) \n # Prefix sums (i, j) = (offset, size - 1) \n offset, size = 0, 0\n \n catch :Done do\n sum = 0\n (0...candidates.size).each do |i|\n sum = candidates[i]\n (i + 1...candidates.size).each do |j| \n sum += candidates[j]\n if sum == target\n offset, size = i, j - i + 1\n throw :Done\n end\n end\n end\n end\n \n candidates[offset...offset + size]\nend", "def two_sum2(numbers, target)\n len = numbers.length\n my_hash = {}\n\n i = 0\n while i < len\n num2 = numbers[i]\n num1 = target - num2\n\n if my_hash[num2] # A match is found since num1 + num2 = target\n index1 = numbers.index(num1) + 1\n index2 = i + 1\n puts \"index1=#{index1}, index2=#{index2}\"\n return\n else\n my_hash[num1] = num2\n end\n i += 1\n end\nend", "def find_duplicate(nums)\n result = 0\n nums.each_with_index do |num, index|\n result ^= num ^ index\n end\n result\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Dump data from Hastur. The query is based on the Sinatra params. Where appropriate, values can be commaseparated lists. But little or no postoperation or formatting is done on the results. Params can include the following:
def dump_from_hastur(params) types = type_list_from_string(params[:type]) uuids = uuid_or_hostname_to_uuids params[:uuid].split(',') names = params[:name] ? params[:name].split(',') : [] labels = params[:label] ? CGI::unescape(params[:label]).split(',') : [] return {} if types.empty? unless types.all? { |t| TYPES[:all].include?(t) } hastur_error! "Invalid type(s): '#{types}', not all included in #{TYPES[:all].join(", ")}", 404 end # Some message types are day bucketed and are only expected once a day, like registrations, # heartbeats, and ohai information. These should default to getting one day of data. if types & DEFAULT_DAY_BUCKET == types default_span = :one_day else default_span = :five_minutes end start_ts, end_ts = get_start_end default_span name_option_list = build_name_option_list names # query cassandra values = Hastur.time "hastur.rest.db.query_time" do name_option_list.map do |options| dump = Hastur::Cassandra.dump(cass_client, uuids, types, start_ts, end_ts, options.merge(:cass_query_size => 100)) dump.map { |item| item[2] } end.flatten end values end
[ "def query_hastur(params)\n kind = params[:kind]\n types = type_list_from_string(params[:type])\n uuids = uuid_or_hostname_to_uuids params[:uuid].split(',')\n names = params[:name] ? params[:name].split(',') : []\n labels = params[:label] ? params[:label].split(',') : []\n\n unless FORMATS.include? kind\n hastur_error! \"Illegal output option: #{kind.inspect}\", 404\n end\n\n unless types.any? { |t| TYPES[:all].include?(t) }\n hastur_error! \"Invalid type(s): '#{types}'\", 404\n end\n\n # Some message types are day bucketed and are only expected once a day, like registrations,\n # heartbeats, and ohai information. These should default to getting one day of data.\n if types & DEFAULT_DAY_BUCKET == types\n default_span = :one_day\n else\n default_span = :five_minutes\n end\n\n start_ts, end_ts = get_start_end default_span\n name_option_list = build_name_option_list names\n\n # query cassandra\n values = Hastur.time \"hastur.rest.db.query_time\" do\n name_option_list.map do |options|\n Hastur::Cassandra.get(cass_client, uuids, types, start_ts, end_ts, options)\n end\n end\n\n if FORMATS.include? kind\n output = sort_series_keys(flatten_rows(values))\n\n if kind == \"message\"\n output = deserialize_json_messages(output)\n end\n else\n hastur_error! \"Unsupported data type: #{kind.inspect}!\", 404\n end\n\n # Some queries go directly to a Cassandra range scan, which only matches prefixes\n # so a second pass is required to reduce the data down to only what was requested\n # for infix wildcards.\n if names.select {|n| n.include?('*') }.any?\n filter_out_unwanted_names output, names\n end\n\n if params[:fun]\n output = apply_functions(params[:fun], output)\n end\n\n output\n end", "def query_formatter(hash)\n params_str = []\n \n hash.each do |key, value|\n params_str << key.to_s + \"=\" + value.to_s\n end\n\n yield params_str\n end", "def make_query_param_json(query_params)\n common_ops = [\n ['is', '='],\n ['is not', '<>'],\n ['greater than', '>'],\n ['less than', '<'],\n ['greater than or equal to', '>='],\n ['less than or equal to', '<='],\n ['is blank', 'is_null'],\n ['is NOT blank', 'not_null']\n ]\n text_ops = [\n %w[starts with starts_with],\n %w[ends with ends_with],\n %w[contains contains]\n ]\n date_ops = [\n %w[between between]\n ]\n # ar = []\n qp_hash = {}\n query_params.each do |query_param|\n hs = { column: query_param.column, caption: query_param.caption,\n default_value: query_param.default_value, data_type: query_param.data_type,\n control_type: query_param.control_type }\n if query_param.control_type == :list\n hs[:operator] = common_ops\n hs[:list_values] = if query_param.includes_list_options?\n query_param.build_list.list_values\n else\n query_param.build_list { |sql| db_connection[sql].all.map(&:values) }.list_values\n end\n elsif query_param.control_type == :daterange\n hs[:operator] = date_ops + common_ops\n else\n hs[:operator] = common_ops + text_ops\n end\n # ar << hs\n qp_hash[query_param.column] = hs\n end\n # ar.to_json\n qp_hash.to_json\n end", "def sorted_query(cgi_escaping = true)\n q = ''\n sorted_parameters(cgi_escaping).each_pair do|k,v|\n if v.is_a?(Enumerable)\n v.each do|v2|\n q << '&' unless q == ''\n q << k + '[]=' + (cgi_escaping ? CGI.escape(v2) : v2)\n end\n else\n q << '&' unless q == ''\n q << k + '=' + (cgi_escaping && v ? CGI.escape(v) : v.to_s)\n end\n end\n q\n end", "def body\n { 'query' => query, 'variables' => variables }\n end", "def query_params\n validate_params!\n \n qargs = {\n Ebay::Search::Api::OPERATION_NAME[:key] => Ebay::Search::Api::OPERATION_NAME[:value],\n Ebay::Search::Api::SERVICE_VERSION[:key] => Ebay::Search::Api::SERVICE_VERSION[:value],\n Ebay::Search::Api::SECURITY_APPNAME[:key] => self.app_name,\n Ebay::Search::Api::GLOBAL_ID[:key] => self.global_id,\n Ebay::Search::Api::RESPONSE_DATA_FORMAT[:key] => Ebay::Search::Api::RESPONSE_DATA_FORMAT[:value],\n Ebay::Search::Api::PER_PAGE[:key] => self.per_page,\n Ebay::Search::Api::KEYWORDS[:key] => self.keywords\n }\n \n query_formatter(qargs) do |params|\n params.join(\"&\")\n end\n end", "def to_s\n parts = @query_hash.sort.inject([]) do |arr, (key,value)|\n if value.kind_of?(Array)\n value.each do |nested|\n arr << \"%s=%s\" % [key, nested]\n end\n else\n arr << \"%s=%s\" % [key, value]\n end\n arr\n end\n parts.join('&')\n end", "def pp_data(db, table, data = nil)\n if data == nil\n data = view_table(db, table)\n end\n pp_string = ''\n\n data.each do |entry|\n entry.each do |id, val| \n if id.is_a? String\n pp_string += \"#{id}: #{val}\\t| \" \n end \n end\n pp_string += \"\\n\"\n end\n pp_string\nend", "def make_query_param_json(query_params, connection = DB)\n qp_hash = {}\n query_params.each do |query_param|\n hs = { column: query_param.column, caption: query_param.caption,\n default_value: query_param.default_value, data_type: query_param.data_type,\n control_type: query_param.control_type }\n hs[:list_values] = build_list_values(query_param, connection) if query_param.control_type == :list\n hs[:operator] = build_operators(query_param.control_type)\n qp_hash[query_param.column] = hs\n end\n qp_hash.to_json\n end", "def query(query=nil, options={})\n \n \n if logger.debug?\n logger.debug(\"query recieved :\")\n query.to_s.split(\"\\n\").each do |line|\n logger.debug(line)\n end\n logger.debug(\"options recieved : \")\n options.keys.each do |key|\n logger.debug(\"#{key} : #{options[key]}\")\n end\n end\n \n #set column headers\n column_header = false\n if options.has_key? :column_headers and options[:column_headers]\n column_headers = true\n end\n \n #set user\n user = nil\n if options.has_key? :user and options[:user] != nil and not options[:user].empty?\n user = options[:user]\n end\n \n #set limit\n limit = nil\n if options.has_key? :limit and options[:limit] != nil and options[:limit].to_i > 0\n limit = options[:limit].to_i\n end\n \n #set localtime \n localtime = nil\n if options.has_key? :local_time and options[:local_time] != nil and not options[:local_time].to_i\n localtime = options[:local_time].to_i\n end\n \n #set output\n output = nil\n if options.has_key? :output and options[:output] != nil and not options[:output].empty?\n if ['json','python'].include?(options[:output])\n output = options[:output]\n else\n raise RequestException.new(\"Output must be one of #{['json','python'].join(', ')}\")\n end\n end\n \n columns=[]\n if column_headers and query.has_stats\n columns = query.get_columns_name\n end\n \n #if socket is generated and query exists\n if query != nil and query.is_a? Nagios::MkLiveStatus::Query and query.to_s.upcase.start_with?(\"GET \")\n \n strQuery = \"#{query}\"\n #the endline must be empty\n if not strQuery.end_with?(\"\\n\")\n strQuery << \"\\n\"\n end\n \n #set user if needed\n if user != nil and not user.empty? and strQuery.match(/^GET\\s+(hosts|hostgroups|services|servicegroup|log)\\s*$/)\n strQuery << \"AuthUser: #{user}\\n\"\n end\n \n if localtime != nil\n strQuery << \"LocalTime: #{localtime}\\n\"\n end\n \n # set columns headers\n if column_headers\n strQuery << \"ColumnHeaders: on\\n\"\n end\n \n # set the limit\n if limit\n strQuery << \"Limit: #{limit}\"\n end\n \n #set the output format\n if output\n strQuery << \"OutputFormat: #{output}\"\n end\n \n logger.info(\"\")\n logger.info(\"---\")\n strQuery.split(\"\\n\").each do |line|\n logger.info(line)\n end\n logger.info(\"---\")\n \n #get error message if some are given\n strQuery << \"ResponseHeader: fixed16\\n\"\n \n socket = open_socket()\n \n logger.debug(\"querying ...\")\n # query the socket\n socket.puts strQuery\n \n logger.debug(\"closing socket.\")\n # close the socket\n socket.shutdown(Socket::SHUT_WR)\n logger.debug(\"socket closed.\")\n \n # check data reception\n recieving = socket.recv(16)\n check_receiving_error recieving\n \n logger.debug(\"Reading results.\")\n # get all the line of the socket\n response = socket.gets(nil)\n \n # if columns header are required but stats are defined > no column. So we put ours\n if columns.length > 0\n logger.debug(\"Adding columns\")\n response = columns.join(\";\")+\"\\n\"+response\n end\n \n \n \n if response\n response.force_encoding(\"UTF-8\")\n logger.info(\"Results :\")\n response.split(\"\\n\").each do |line|\n logger.info(line)\n end\n else\n logger.info(\"No results.\")\n end\n \n return response\n \n end\n \n end", "def format_params(params)\n \n # this is just used for multi_index search\n params[:indexes] ||= ['documents', 'people', 'topics', 'places' ]\n \n \n # return loaded models?\n params[:load] ||= true\n \n # will_paginate settings\n params[:page] ||= 1\n params[:per_page] ||= 25\n params[:offset] = ( ( params[:page].to_i - 1) * params[:per_page].to_i)\n\n # sort by\n params[:sort_by], params[:order_by] = params[:sort].split(\":\") if params[:sort]\n params[:order_by] = \"desc\" unless params[:order_by] == \"asc\"\n\n # facet filters and query\n params[:facet] ||= []\n params[:facet].compact!\n\n params[:request_query] = params[:q] ? params[:q].compact : \"*\"\n \n # facet filtering/limits\n params[:facet_filters] = params[:facet].collect do |f|\n facet, value = f.split(\":\")\n lambda { |boolean| boolean.must { term facet.to_sym, value } }\n end\n \n # facets to be returned\n params[:request_facets] ||= self.facets\n params[:facet_query] = {} \n params[:request_facets].each { |f| params[:facet_query][f] = params[:\"#{f}_page\"] ? ( ( params[:\"#{f}_page\"].to_i * 10 ) + 1 ) : 11 }\n \n return params\n end", "def generate_query\n \n # set up for the loop\n @query_string = @base\n @query_string += @wrapped_values[:format] + @wrapped_values[:query_string] + @wrapped_values[:rank] + @wrapped_values[:api_key]\n \n end", "def hbparams(*params)\n if params.empty?\n nil\n else\n values = translate_values(params.select { |p| p.is_a?(String) })\n hash = translate_hash(params.last.is_a?(Hash) ? params.last : {})\n\n [values, hash].compact.join(' ')\n end\n end", "def format_hash_as_query_string(query_params)\n # replace Ruby => assignment operators with JSON standard colons (:)\n sanitized_params = query_params.to_s.gsub(/=>/, ':')\n CGI.escape(sanitized_params)\n end", "def dump\n if params[:id].present?\n\n if params[:walker_id].present?\n @events = Event.where(:race_id => params[:id], :walker_id => params[:walker_id]).order(:id)\n else\n @events = Event.where(:race_id => params[:id]).order(:id)\n end\n\n else\n # @events = Event.order(:id)\n redirect_to :controller => \"pages\", :action => \"unauthorized\"\n end\n end", "def dump_results\n end", "def dump\n result = \"\"\n result += \"#{id}: from => #{user&.login}, \"\n result += \"to => #{to_user&.login}, flavor => #{flavor}, \"\n result += \"queued => #{queued}\\n\"\n queued_email_integers.each { |i| result += \"\\t#{i.key} => #{i.value}\\n\" }\n queued_email_strings.each { |i| result += \"\\t#{i.key} => #{i.value}\\n\" }\n result += \"\\tNote: #{queued_email_note.value}\\n\" if queued_email_note\n result\n end", "def saveQuery(params)\n filters = params.select { |key, value| key.to_s.match(/filter\\d+/) }\n comparators = params.select { |key, value| key.to_s.match(/comparator\\d+/) }\n filterValues = params.select { |key, value| key.to_s.match(/filterValue\\d+/) }\n attributes = params.select { |key, value| key.to_s.match(/attribute\\d+/) }\n \n @query = Query.create({:name => params[\"saveName\"]})\n \n i = 0\n filters.each do |filter|\n filterRecord = Filter.create(:field => filters[\"filter\" + i.to_s], :comparator => comparators[\"comparator\" + i.to_s], :value => filterValues[\"filterValue\" + i.to_s])\n @query.filters << filterRecord\n i = i + 1\n end\n \n i = 0\n attributes.each do |attribute|\n headerRecord = Header.create(:field => attributes[\"attribute\" + i.to_s])\n @query.headers << headerRecord\n i = i + 1\n end\n \n @query.save\n flash[:query] = @query\n redirect_to site_studentFilterSelection_path\n end", "def prepare_export_statements\n #node\n @export_node_tag = @db.prepare(\"select k, v from tag where id in (select tag from node_tag where id = ?)\")\n @export_node = @db.prepare(\"select id, lat, lon from node where id = ?\")\n @export_node_at =\n @db.prepare(\"select id, lat, lon from node where (lon > ? and lon < ?) and (lat > ? and lat < ?)\")\n #way\n @export_way = @db.prepare(\"select node from way where id = ? order by position\")\n @export_way_tag = @db.prepare(\"select k, v from tag where id in (select tag from way_tag where id = ?)\")\n #relation\n @export_node_relation = @db.prepare(\"select node, role from node_relation where id = ?\")\n @export_way_relation = @db.prepare(\"select way, role from way_relation where id = ?\")\n @export_relation_tag = @db.prepare(\"select k, v from tag where id in (select tag from relation_tag where id = ?)\")\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Take a list of nodes, where the names may be UUIDs or network names and return a list of just UUIDs. Hostnames that cannot be resolved are dropped from the list.
def uuid_or_hostname_to_uuids(nodes) # avoid the Cassandra lookup if all the nodes are already UUIDs return nodes unless nodes.reject { |node| Hastur::Util.valid_uuid?(node) }.any? # node registration is daily, bucket the lookup on day boundary if unspecified day_start_ts, day_end_ts = get_start_end :one_day # You know, this could be sped up a *lot* by caching. Just sayin'. uuid_lookup = Hastur::Cassandra.lookup_by_key(cass_client, "host-uuid", day_start_ts, day_end_ts) nodes.flatten.map do |maybe_uuid| if Hastur::Util.valid_uuid?(maybe_uuid) maybe_uuid else uuid_lookup[maybe_uuid] end end.compact end
[ "def uuid_or_hostname_to_uuids(nodes)\n # avoid the Cassandra lookup if all the nodes are already UUIDs\n return nodes unless nodes.reject { |node| Hastur::Util.valid_uuid?(node) }.any?\n\n # node registration is daily, bucket the lookup on day boundary if unspecified\n day_start_ts, day_end_ts = get_start_end :one_day\n\n uuid_lookup = Hastur::Cassandra.lookup_by_key(cass_client, \"host-uuid\", day_start_ts, day_end_ts)\n\n nodes.flatten.map do |maybe_uuid|\n if Hastur::Util.valid_uuid?(maybe_uuid)\n maybe_uuid\n else\n uuid_lookup[maybe_uuid]\n end\n end.compact\n end", "def unique_scanned_hosts\n hosts = []\n scanned_hosts = self.show_scanned_hosts\n scanned_hosts.each do |sh|\n sh.hosts.split(\", \").each do |host|\n if host.scan(\"0/24\").empty?\n hosts << host.gsub(/\\s+/, \"\")\n else\n host = host.gsub(/\\s+/, \"\").gsub(\"0/24\", \"\")\n (0..255).each do |last_digit|\n tmp_host = \"#{host}#{last_digit}\" \n hosts << tmp_host\n end\n end\n end\n end\n return hosts.uniq.sort\n end", "def nodes_selectors_from_nodes_list(nodes_list_name)\n platform_info[:nodes_lists][nodes_list_name]\n end", "def instances_names_list\n return [] unless configured?\n\n aws_instances_ids = instances_list || []\n aws_instances_ids.map { |instance| instance[:node_name] }\n end", "def nodes_from_list(nodes_list, ignore_unknowns: false)\n select_nodes(@nodes_list_platform[nodes_list].nodes_selectors_from_nodes_list(nodes_list), ignore_unknowns: ignore_unknowns)\n end", "def fetch_nodes(nodes, dns_cache)\n ret = []\n nodes.each_with_index do |item, index|\n ip, port = item\n host = dns_cache.fetch(ip) {\n |missing_ip|\n host = Resolv.getname(missing_ip)\n dns_cache[ip] = host\n host\n }\n name = \"#{host}:#{port}\"\n role = index == 0 ? 'master' : 'slave'\n node = {\n :host => host, :port => port,\n :name => name, :ip => ip,\n :role => role\n }\n ret << node\n end\n ret\n end", "def connectable_nodes_from(nodes)\n @nodes_handler.prefetch_metadata_of nodes, :host_ip\n nodes.select { |node| @nodes_handler.get_host_ip_of(node) }\n end", "def find_orphan_nodes( exceptions = [] )\n orphan_nodes = []\n \n Node.all.each do |node|\n next if exceptions.include?(node.name) or node.node_groups.size != 0\n orphan_nodes << node.name\n end\n \n return orphan_nodes\n end", "def all_names(hostname)\n ret = []\n\n if hostname.local == hostname.fqdn\n ret << hostname.fqdn\n else\n ret << hostname.fqdn << hostname.local\n end\n\n ret\n end", "def uuids_for_hostnames(cass_client, hostnames, start_ts, end_ts)\n lookup = Hastur::Cassandra.lookup_by_key(cass_client, \"host-uuid\", start_ts, end_ts)\n\n # just rely on the lookup table and sink most of the logic there in a scheduled job\n out = {}\n hostnames.each do |host|\n out[host] = lookup[host]\n end\n\n out\n end", "def node_names\n @cluster.nodes.map(&:name)\n end", "def update_node_list(hosts)\n new_nodes = hosts.map do |host|\n if !host.respond_to?(:split)\n warn \"Could not parse host #{host.inspect}.\"\n next\n end\n\n host, port = host.split(':')\n [host, port ? port.to_i : Connection::DEFAULT_PORT]\n end\n\n # Replace the list of seed nodes with the canonical list.\n @nodes = new_nodes.clone\n\n @nodes_to_try = new_nodes - @nodes_tried\n end", "def get_node_names\n Chef::Node.list.keys\n end", "def instance_id_list(nodes)\n Array(nodes).map { |n| n.options[:aws_instance_id] }\n end", "def get_node_names\n l = Chef::Node.list\n nl.keys\n end", "def get_aliases(hostname)\n headers = { Authorization: \"Bearer #{@token}\", 'Content-Type': 'application/json' }\n response = HTTParty.get(\"https://#{NETDB_SERVER}/nodes/#{hostname.fully_qualify}\",\n :headers => headers)\n if response.code != 200\n raise \"no node found for #{hostname}\"\n end\n\n # Parse through the response to find any aliases, and make sure that this is\n # the main hostname.\n node_json = JSON.parse(response.body)\n aliases = []\n node_json['names'].each do |n|\n if n['name'] != hostname\n raise \"#{hostname} is an alias for #{n['name']}. Please rerun with hostname #{n['name']}.\"\n elsif n.key?('aliases')\n aliases = (aliases + n['aliases'])\n end\n end\n\n aliases\nend", "def children_nodes(nodes_list)\n children_nodes_list = []\n nodes_list.each do |node_name|\n children_nodes_list.concat(@nodes_graph[node_name][:connections].keys + @nodes_graph[node_name][:includes])\n end\n children_nodes_list.uniq!\n new_children_nodes = children_nodes_list - nodes_list\n if new_children_nodes.empty?\n children_nodes_list\n else\n children_nodes(children_nodes_list)\n end\n end", "def host_aliases\n @fragments.map(&:host_aliases).flatten.uniq + [name]\n end", "def node_list\n nodes = []\n nodes += config['hosts'] if config['hosts']\n nodes += config['passives'] if config['passives']\n nodes += [\"#{@host}:#{@port}\"] if @client.mongos?\n nodes\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
deserialize JSON messages in the return hash so the enduser can deserialize in one pass
def deserialize_json_messages(data) output = {} data.each do |uuid, name_series| if special_name?(uuid) output[uuid] = data[uuid] next end output[uuid] = {} name_series.each do |name, series| output[uuid][name] = {} series.each do |ts, value| if value.kind_of?(Java::byte[]) value = String.from_java_bytes(value) end # MultiJson gets really upset if you ask it to decode a ruby Hash that ends up # being stringified - TODO(al,2012-06-21) figure out why hashes are appearing in this data # Hashes are appearing in this data when you request *both* a rollup and normal data # together. The right answer is probably not to do that (i.e. change the API). unless value.kind_of? String logger.debug "BUG: Got a ruby #{value.class} where a JSON string was expected: #{value.inspect}" next end begin output[uuid][name][ts] = MultiJson.load value rescue Exception => e hastur_error! "JSON parsing failed for stored message: #{value.inspect} #{e.inspect}", 501 end end end end output end
[ "def deserialize_json_messages(data)\n output = {}\n data.each do |uuid, name_series|\n output[uuid] = {}\n name_series.each do |name, series|\n output[uuid][name] = {}\n series.each do |ts, value|\n # MultiJson gets really upset if you ask it to decode a ruby Hash that ends up\n # being stringified - TODO(al,2012-06-21) figure out why hashes are appearing in this data\n unless value.kind_of? String\n logger.debug \"BUG: Got a ruby hash where a JSON string was expected.\"\n next\n end\n\n begin\n output[uuid][name][ts] = MultiJson.load value\n rescue Exception => e\n hastur_error! \"JSON parsing failed for stored message: #{value.inspect} #{e.inspect}\", 501\n end\n end\n end\n end\n output\n end", "def convert_to_messages(response)\n json = JSON.parse(response.content)\n end", "def decode\n MultiJson.load @payload, :symbolize_keys => true\n end", "def deserialize(message, _stream)\n ::JSON.parse(message)\n end", "def as_json(_args = {})\n messages.to_hash\n end", "def unpack(message)\n payload = super\n if(self.is_a?(Jackal::Cfn::Resource))\n begin\n if(payload['Message'])\n payload = MultiJson.load(payload['Message']).to_smash\n payload = transform_parameters(payload)\n payload[:origin_type] = message[:message].get('Body', 'Type')\n payload[:origin_subject] = message[:message].get('Body', 'Subject')\n payload[:request_type] = snakecase(payload[:request_type])\n payload\n else\n payload.to_smash.fetch('Attributes', 'Body', payload.to_smash.fetch('Body', payload.to_smash))\n end\n rescue MultiJson::ParseError\n # Not our expected format so return empty payload\n Smash.new\n end\n else\n payload.to_smash.fetch('Attributes', 'Body', payload.to_smash.fetch('Body', payload.to_smash))\n end\n end", "def parse_json(msg)\n return JSON.parse(msg.value) rescue JSON::ParserError\n STDERR.puts \"Skipped unparseable message at #{msg.offset}\"\n return nil\n end", "def response_message\n parsed_response['message']\nend", "def parse_message(msg)\n hash = json_to_message(msg)\n if (retval = check_message_attr(hash)) < 0\n error(\"attribute error with errno #{retval}\")\n end\n return hash\n end", "def json_to_message(json)\n unless json.kind_of?(String)\n error(\"invalid type of json. #{json.class.name}\")\n return nil\n end\n if json == \"\"\n error(\"empty json.\")\n return nil\n end\n begin\n hash = JSON.parse(json, :symbolize_names => true)\n rescue Exception => e\n error(\"JSON.parse failed. #{e.message}\")\n error(e.backtrace)\n raise e\n end\n return hash\n end", "def deserialize(json_string)\n return JSON.parse(json_string)\nend", "def deserialize!\n each(&:payload)\n end", "def parsed_body\n hash = JSON.parse(@body)\n Hashie::Mash.new hash\n rescue\n {}\n end", "def decode_message(message_body)\n JSON.parse(Base64.decode64(message_body))\n end", "def deserialize(arguments); end", "def deserialize_json_body( txn )\n\t\trval = JSON.load( txn )\n\t\tif rval.is_a?( Hash ) && rval.keys == [ SPECIAL_JSON_KEY ]\n\t\t\treturn rval[ SPECIAL_JSON_KEY ]\n\t\telse\n\t\t\treturn rval\n\t\tend\n\tend", "def response_parser(response_content)\n Hashie::Mash.new(JSON(response_content))\n end", "def decode(payload)\n MultiJson.decode(payload)\n end", "def decode(job)\n JSON.parse(job)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Modify the output hash inplace, deleting any name keys that don't match what the user requested.
def filter_out_unwanted_names(output, names) names.each do |match| output.keys.each do |uuid| next if special_name?(uuid) output[uuid].keys.each do |name| unless name_matches?(name, match) output[uuid].delete name end end end end end
[ "def filter_out_unwanted_names(output, names)\n names.each do |match|\n output.keys.each do |uuid|\n output[uuid].keys.each do |name|\n unless name_matches?(name, match)\n output[uuid].delete name\n end\n end\n end\n end\n end", "def clean_mem_hash(hash)\n hash.except(:org, :primary)\n end", "def _process_hashed(hashed)\n hashed.each_pair do |key, value|\n if value.equal?(Utils::DeletedMarker)\n hashed.delete(key)\n elsif Utils.hashable?(value)\n _process_hashed(value.to_hash).freeze\n end\n end\n\n hashed\n end", "def re_hash(ret, hash)\n if ret!=nil\n ret = \"$\" + ret\n key_point = ret.index(\"!\")\n if key_point\n mykey = ret[1, key_point-1]\n unwanted_key = ret[0, key_point+1]\n ret = ret.gsub!(unwanted_key, \"\")\n ret = \"$\" + ret\n value_point = ret.index(\"!\")\n if value_point\n myvalue = ret[1, value_point-1]\n unwanted_value = ret[0, value_point+1]\n hash.store(mykey, myvalue)\n ret = ret.gsub!(unwanted_value, \"\")\n else\n myvalue = ret.gsub!(\"$\", \"\")\n hash.store(mykey, myvalue)\n ret = nil\n end\n re_hash(ret, hash)\n end\n end\n end", "def unaltered(hash)\n hash\n end", "def delete_manifest_keys!(input_hash)\n MANIFEST_KEYS.each do |key|\n input_hash.delete key\n end\n end", "def reset_hash\n warn(\"Resetting hermit database... all hermit location is now kaput\")\n @hermithash = @resethash\n save_hash\n end", "def rehash() end", "def change_name_to_certname(hash)\n hash['certname'] = hash.delete('name')\n\n hash\n end", "def replace_aliases_with_original_keys(hash)\n # DISCUSS: Better way to check for alias presence in `hash`\n return hash unless (hash.keys & @aliases.values).any?\n\n _hash = hash.dup\n\n @aliases.each do |original_key, _alias|\n _hash[original_key] = _hash.delete(_alias) if _hash.key?(_alias)\n end\n\n return _hash\n end", "def hash_flush_out(hash, pre=\"\", post=\"\") \n hash.map do |k,v|\n if o = handle_actions(k,v)\n o\n else\n key = to_chef_key(k)\n res = to_option_string(v)\n (key.nil? || res.nil?) ? nil : \"#{pre}#{key} #{res}#{post}\"\n end\n end\n end", "def prune_hash\n @mutex.synchronize do\n remove.times do\n @hash.delete(keys.shift)\n end\n end\n end", "def clean_unwanted_keys(hash)\r\n ignored_keys = [:only_path, :use_route]\r\n hash.dup.delete_if{|key,value| ignored_keys.include?(key)}\r\n end", "def whitelist_redact_hash redact_hash\n \t digest_hash = {}\n \t \n \t \tredact_hash.each do |key,how|\n \t \t if (how.to_sym == :digest)\n \t \t digest_hash[digest_key(key)] = :keep\n \t \t end\n \t \tend\n \t \t\n \t \tdigest_hash.merge redact_hash\n\t end", "def clean_unwanted_keys(hash)\r\n ignored_keys = [:only_path, :use_route]\r\n hash.dup.delete_if{|key,value| ignored_keys.include?(key)}\r\n end", "def without_private_entries\n hash = dup\n hash.delete_if { |k, _v| k =~ /__.*__/ }\n convert_hash(hash)\n end", "def normalize_hash( hash )\n\t\t\thash = hash.dup\n\t\t\thash.keys.each do |key|\n\t\t\t\tnkey = normalize_key( key )\n\t\t\t\thash[ nkey ] = hash.delete( key ) if key != nkey\n\t\t\tend\n\n\t\t\treturn hash\n\t\tend", "def deleted\n\t\thash = {}\n\t\t@old_hash.each do |k,v|\n\t\t\thash.store(k,v) unless @new_hash.key?(k)\n\t\tend\n\t\thash\n\tend", "def rehash\n buckets.compact.each do |key, value|\n insert(key, value)\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Do an intersection between sets of param values (UUIDs, types, etc) and/or :all, meaning "all possible values."
def intersect_params(lists) return [] if lists.empty? lists = lists.select { |l| l != :all } return :all if lists.empty? lists.inject(:"&") end
[ "def intersect_all(select)\n add_set_op('intersect all', select)\n end", "def all_and(*args)\n Term.get AndTerm, *args\n end", "def includes_all? *args\n args.all? { |arg| include? arg }\n end", "def supports_intersect_except_all?\n false\n end", "def all?(options, check_params)\n options[:all] &&\n check_params.map { |p| params[p] }.compact.empty?\n end", "def any_of_match(*args)\n qs = []\n args.each do |hash|\n qs << any_match_(hash)\n end\n self.where(qs.reduce(:or))\n end", "def intersect_all(*queries, &block)\n intersect(*queries, all: true, &block)\n end", "def select_common_params(from:)\n return from if @common_params.empty?\n from.select { |k, v| valid_common_param?(k) }\n end", "def all_of(*matchers); end", "def all_of(*constraints)\n Parametrized::Constraint::AllOf.new(constraints)\n end", "def all_args_are_valid(param_a,param_b,param_c)\n param_a != 0 and [param_a,param_b,param_c].all?\nend", "def all_of(*args)\n clone.tap do |crit|\n unless args.empty?\n criterion = @selector[\"$and\"] || []\n converted = BSON::ObjectId.convert(klass, args.flatten)\n expanded = converted.collect { |hash| hash.expand_complex_criteria }\n crit.selector[\"$and\"] = criterion.concat(expanded)\n end\n end\n end", "def intersect\n use(:__intersect__)\n end", "def intersect\n use(:__intersect__)\n end", "def any_of(*types)\n XMLRPCUnion.new(*types)\n end", "def all_of(&block)\n conjunction = @scope.add_conjunction\n Util.instance_eval_or_call(Scope.new(conjunction, @setup), &block)\n conjunction\n end", "def all_or_blank?( args )#:nodoc:\n args.blank? || args.any?{|a| a.to_s == 'all' }\n end", "def any_of(*matchers); end", "def all?\n type == Resource::ALL && id == Resource::ALL\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parse a Hasturretrievalformat label param into a set of "must" and "must not" label values.
def parse_labels(label_param) labels = CGI::unescape(label_param).split(',') must = {} must_not = {} labels.each do |lv| label, value = lv.split ':', 2 if label.start_with? '!' must_not[label[1..-1]] = "*" else must[label] = value || "" end end [ must, must_not ] end
[ "def check_label(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CheckLabel'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :label_name\n\t\t\targs[:query]['LabelName'] = optional[:label_name]\n\t\tend\n\t\tif optional.key? :label_series\n\t\t\targs[:query]['LabelSeries'] = optional[:label_series]\n\t\tend\n\t\tif optional.key? :p_k\n\t\t\targs[:query]['PK'] = optional[:p_k]\n\t\tend\n\t\tself.run(args)\n\tend", "def extract_param_set(label)\n extract_string(label, :expr_place, :expr)\n end", "def find_labels\n @input.each_with_index do |line, i|\n if line.label?(i)\n label = line.split(\":\")[0]\n if !@labels.include?(label)\n @labels[label] = [*@instructions.each_with_index].search{|x, _| x >= i}.last\n else\n Error::message(7, i+1, line) \n end\n end\n end\n end", "def validate_labels\n end", "def sanitize_label(label); end", "def load_requires(filter)\n text_requires = \"fileinto reject envelope encoded-character vacation \"\n text_requires += \"subaddress comparator-i;ascii-numeric relational regex \"\n text_requires += \"imap4flags copy include variables body enotify environment mailbox date\"\n text_requires.split(\" \").each do |search|\n if filter.to_s.index(search)\n add_require(search)\n end\n end\n end", "def label= str\n if lbl = normalize_label(str)\n super lbl\n else\n raise Poloxy::Error,\n \"Invalid label specified! #{str} . Allowed pattern is '([a-z\\d_-]+)'\"\n end\n end", "def is_label?(tok)\n #a label is defined as: 1st character = letter, followed by upto 10 chars/digits, followed by \":\"\n return tok.chop if ( (tok =~ /[A-Z_a-z]\\w{0,10}:$/) == 0) and tok[-1] == 58\n return nil\n end", "def handle_label(f)\n opts[:label] = humanize(field) unless opts.has_key?(:label)\n opts[:label] = [opts[:label], form._tag(:abbr, {:title=>'required'}, '*')] if opts[:label] && opts[:required] && obj.forme_use_required_abbr?\n end", "def label_options\n\t\tlabel_opt = @options[:label]\n\t\t# don't do anything if this field shouldn't have a label\n\t\treturn if label_opt == false\n\n\t\t# tell it if it's required so it can add an aterisk\n\t\tdefaults = {'required' => @required}\n\t\t# get the label key\n\t\tif label_opt.is_a?(Symbol) || label_opt.is_a?(String)\n\t\t\t# the option is the key\n\t\t\tdefaults['key'] = label_opt\n\t\telsif label_opt.is_a?(Hash)\n\t\t\t# merge the given options\n\t\t\tdefaults.merge!(label_opt)\n\t\tend\n\n\t\tdefaults\n\tend", "def has_label?(label_set, label)\n label_set && label_set.split(Run::IN_Separator).map(&:strip).include?(label)\n end", "def parse_for_edge_label\n return unless label =~ /^\\(([^\\)]+)\\)(.*)$/m\n\n edge_options[:xlabel] = $LAST_MATCH_INFO[1]\n @label = $LAST_MATCH_INFO[2].strip\n end", "def parse_label\n tok = match(:idt)\n ret = Label.new(name: tok.val)\n @labels << ret\n ret\n end", "def parse_commit(labels, commit)\n regex = /!(?<label>#{labels.join('|')})(?<entry>[\\s\\S]*)\\z/\n matches = commit.match(regex)\n [matches[:label], matches[:entry].strip] if matches\nend", "def required_label_text; end", "def valid_parameter_for_conditional_formatting\n %i[\n type\n format\n criteria\n value\n minimum\n maximum\n stop_if_true\n min_type\n mid_type\n max_type\n min_value\n mid_value\n max_value\n min_color\n mid_color\n max_color\n bar_color\n bar_negative_color\n bar_negative_color_same\n bar_solid\n bar_border_color\n bar_negative_border_color\n bar_negative_border_color_same\n bar_no_border\n bar_direction\n bar_axis_position\n bar_axis_color\n bar_only\n icon_style\n reverse_icons\n icons_only\n icons\n data_bar_2010\n ]\n end", "def valid_parameter_for_conditional_formatting\n [\n :type,\n :format,\n :criteria,\n :value,\n :minimum,\n :maximum,\n :min_type,\n :mid_type,\n :max_type,\n :min_value,\n :mid_value,\n :max_value,\n :min_color,\n :mid_color,\n :max_color,\n :bar_color\n ]\n end", "def validates_as_hostname_label(*attrs)\n options = ValidatesAsHostnameLabel.default_options.merge(attrs.extract_options!)\n\n format, characters = 'a-z0-9\\-', %w(alphanumeric hyphen)\n format << '_' and characters << 'underscore' if options.delete(:allow_underscores)\n\n I18n.with_options :scope => 'validates_as_hostname_label' do |i18n|\n validates_presence_of *attrs + [options] unless options.delete(:allow_blank) || options.delete(:allow_nil)\n\n validates_exclusion_of *attrs + [{\n :in => options.delete(:reserved),\n :message => i18n.t('reserved', :default => 'is reserved'),\n :allow_blank => true\n }.merge(options)]\n\n validates_format_of *attrs + [{\n :with => /\\A[#{format}]*\\z/i,\n :message => i18n.t('invalid_format', :default => \"may only contain #{characters.to_sentence} characters\"),\n :allow_blank => true\n }.merge(options)]\n\n validates_format_of *attrs + [{\n :with => /\\A[^-_].*[^-_]\\z/i,\n :message => i18n.t('invalid_prefix_or_suffix', :default => 'may not start or end with a hyphen or underscore'),\n :allow_blank => true\n }.merge(options)]\n\n validates_length_of *attrs + [{\n :in => 1..63,\n :message => i18n.t('invalid_length', :default => 'must be between 1 and 63 characters long'),\n :allow_blank => true\n }.merge(options)]\n end\n end", "def clean_label(label)\n clean_value(label).gsub /:\\Z/, ''\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This is used to clean data from lookup_label_stat_names of entries not matching a restricted set of uuids, types or message names.
def clean_nonmatching_lookup(data, must, uuids, types, msg_names) # Clean out non-matching label values data.each do |lname, lvalue_hash| lvalue_hash.keys.each do |lvalue| unless lvalue == must[lname] || name_matches?(lvalue, must[lname]) lvalue_hash.delete(lvalue) end end end # Clean out non-matching types unless types == :all data.each do |lname, lvalue_hash| lvalue_hash.each do |lvalue, type_hash| type_hash.keys.each do |type| unless types.include? type type_hash.delete(type) end end end end end # Clean out non-matching msg names unless msg_names == :all data.each do |lname, lvalue_hash| lvalue_hash.each do |lvalue, type_hash| type_hash.each do |type, msg_name_hash| msg_name_hash.keys.each do |msg_name| if msg_names.include?(msg_name) msg_name_hash[msg_name] &= uuids # Filter non-matching UUIDs else msg_name_hash.delete msg_name end end end end end end data end
[ "def sanitize_names\n self.name = name.gsub(/[^a-zA-Z0-9]/, '_')\n self.label_format = label_format.gsub(/[^a-zA-Z0-9]/, '_')\n end", "def sanitize_label(label); end", "def process_removing_labels\n unless labels_to_remove.empty?\n (labels_to_remove & issue_labels).each {|label| unlabel_issue(label)}\n end\n end", "def normal_labels\n\t imap_xlist.reject { |label|\n\t\tlabel.attr.include?(:Noselect) or label.attr.any? { |flag| gmail_label_types.include?(flag) }\n\t }.map { |label|\n\t\tlabel.name\n\t }\n end", "def sanitize_group_names\n group_names.map! { |name| name.gsub(NAME_SANITIZER, '').downcase }.reject!(&:blank?)\n end", "def filter_out_unwanted_names(output, names)\n names.each do |match|\n output.keys.each do |uuid|\n next if special_name?(uuid)\n\n output[uuid].keys.each do |name|\n unless name_matches?(name, match)\n output[uuid].delete name\n end\n end\n end\n end\n end", "def filter_out_unwanted_names(output, names)\n names.each do |match|\n output.keys.each do |uuid|\n output[uuid].keys.each do |name|\n unless name_matches?(name, match)\n output[uuid].delete name\n end\n end\n end\n end\n end", "def check_label_names\n return if labels.nil? || label_template.nil?\n\n # extract the label names for the label template\n expected_labels = label_template.labels.pluck(:name)\n\n # pull out the label names that are received in the request\n received_labels = labels.pluck('label_name').uniq\n\n return if labels_match(expected_labels, received_labels)\n\n errors.add(:label_name, 'does not match label template label names')\n end", "def sanitize_label(label)\n label.to_s.gsub(LABEL_SANITIZER, '_').downcase[0...63]\n end", "def clean_label(label)\n clean_value(label).gsub /:\\Z/, ''\n end", "def sanitize_mods_name_label(label)\n label.sub(/:$/, '')\n end", "def warning_labels\n our_labels = [\"ofx-incomplete\", \"ofx-osx\", \"ofx-win\", \"ofx-linux\"]\n relevant_labels = []\n if issues\n issues.select{|issue| issue[\"state\"] == \"open\" }.each do |issue|\n our_labels.each do |l|\n if Regexp.new(l) =~ issue[\"title\"]\n relevant_labels << l\n end\n end\n end\n end\n relevant_labels\n end", "def sanitize_mods_name_label(label)\n label.sub(/:$/, '')\n end", "def massage_invalid_disability_names\n disabilities = form_data['disabilities']\n invalid_characters = %r{[^a-zA-Z0-9\\\\\\-'.,/() ]}\n\n disabilities.map do |disability|\n name = disability['name']\n name = truncate_disability_name(name: name) if name.length > 255\n name = sanitize_disablity_name(name: name, regex: invalid_characters) if name.match?(invalid_characters)\n disability['name'] = name\n\n disability\n end\n end", "def tag_labels\n metadata\n .reject { |k| RSPEC_IGNORED_METADATA.include?(k) || special_metadata_tag?(k) }\n .filter_map { |k, v| custom_label(k, v) }\n end", "def sanitize_label(label)\n label.gsub(%r![^a-z0-9_\\-.]!i, \"\")\n end", "def massage_invalid_disability_names\n disabilities = form_data['disabilities']\n invalid_characters = %r{[^a-zA-Z0-9\\\\\\-'.,/() ]}\n\n disabilities.map do |disability|\n name = disability['name']\n name = truncate_disability_name(name:) if name.length > 255\n name = sanitize_disablity_name(name:, regex: invalid_characters) if name.match?(invalid_characters)\n name = strip_disablity_name(name:)\n disability['name'] = name\n\n disability\n end\n end", "def sanitize_entries\n unless event_name.blank?\n self.event_name = I18n.transliterate(event_name.to_s.downcase.strip).to_s.downcase.strip\n end\n unless team_first.blank?\n self.team_first = I18n.transliterate(team_first.to_s.downcase.strip).to_s.downcase.strip.gsub(' ', '')\n end\n unless team_second.blank?\n self.team_second = I18n.transliterate(team_second.to_s.downcase.strip).to_s.downcase.strip.gsub(' ', '')\n end\n end", "def rejected_headings(original_headings)\n rejected = original_headings.select do |heading|\n (heading[:value].split(' -- ').map(&:downcase) & REMAP_SEGMENTS).any?\n end\n\n rejected.map { |s| s[:value] }\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /dolls/1 GET /dolls/1.json
def show @doll = Doll.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @doll } end end
[ "def public_doodles\n @doodles = Doodle.all\n json_response(@doodles)\n end", "def public_doodles_by_category\n @category = Category.find(params[:category_id])\n json_response(@category.doodles)\n end", "def index\n @dolgnosts = Dolgnost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dolgnosts }\n end\n end", "def doodles_by_tag\n\n\t \t@tag = Tag.where(\"name = ?\", params[:tag_name]).first\n\n\t \t@doodles = Doodle.joins(:tag).where(:tags => {:name => @tag.name})\n\n\n\t\t\t# render json: { message: @doodles}, status: :ok \t \n\t\t\trespond_with :api, @doodles\t\n\n\t\t\trescue\n\t @error = ErrorMessage.new(\"Could not find that resource. Are you using the right resource identification\", \"The requested item was not found!\" )\n\t respond_with @error, status: :not_found\n\t end", "def index\n @ladders = Ladder.all\n\n render json: @ladders\n end", "def private_doodles\n @doodles = current_user.doodles\n json_response(@doodles)\n end", "def index\n @lugars = Lugar.all\n\n render json: @lugars\n end", "def dropletList()\n http, req = initReq(\"droplets/\")\n JSON.parse(http.request(req).body)\nend", "def index\n @lophs = Loph.all\n respond_to do |format|\n format.html\n format.json { render json: @lophs}\n end\n end", "def index\n @laws = Law.ordered_roots\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laws }\n end\n end", "def index\n @dioceses = Diocese.all\n\n render json: @dioceses\n end", "def show\n @ridol = Ridol.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ridol }\n end\n end", "def index\n respond_to do |format|\n format.html {}\n format.json {\n render json: @ladders, root: false\n }\n end\n end", "def index\n @drops = Drop.all\n\n render json: @drops\n end", "def index\n @leaverolls = Leaveroll.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leaverolls }\n end\n end", "def index\n @dolars = Dolar.all\n end", "def show\n @lbd = Lbd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lbd }\n end\n end", "def show\n @dolgnost = Dolgnost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dolgnost }\n end\n end", "def index\n @dinos = Dino.where(query_params)\n render json: @dinos\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /dolls/new GET /dolls/new.json
def new @doll = Doll.new respond_to do |format| format.html # new.html.erb format.json { render json: @doll } end end
[ "def new\n @page = 'newdoll'\n @doll = current_user.dolls.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @doll }\n end\n end", "def new\n @lop = Lop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lop }\n end\n end", "def new\n @ridol = Ridol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ridol }\n end\n end", "def new\n @dolgnost = Dolgnost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dolgnost }\n end\n end", "def new\n @lid = Lid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lid }\n end\n end", "def new\n @dop = Dop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dop }\n end\n end", "def new\n @lot = Lot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lot }\n end\n end", "def new\n @lodge = Lodge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lodge }\n end\n end", "def new\n @depot = Depot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @depot }\n end\n end", "def new\n\tadd_breadcrumb \"Nuevo libro\", :new_libro_path\n @libro = Libro.new\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @libro }\n end\n end", "def new\n @lbd = Lbd.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lbd }\n end\n end", "def new\n @dell = Dell.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dell }\n end\n end", "def new\n @loco = Loco.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loco }\n end\n end", "def new\n @lt = Lt.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lt }\n end\n end", "def new\n @lipid = Lipid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lipid }\n end\n end", "def new\n @curpg = :admintools\n @dropreason = Dropreason.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dropreason }\n end\n end", "def new\n @modull = Modull.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @modull }\n end\n end", "def new\n @loteo = Loteo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loteo }\n end\n end", "def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /dolls POST /dolls.json
def create @doll = Doll.new(params[:doll]) respond_to do |format| if @doll.save format.html { redirect_to @doll, notice: 'Doll was successfully created.' } format.json { render json: @doll, status: :created, location: @doll } else format.html { render action: "new" } format.json { render json: @doll.errors, status: :unprocessable_entity } end end end
[ "def create\n @doll = current_user.dolls.new(params[:doll])\n\n respond_to do |format|\n if @doll.save\n format.html { redirect_to @doll, notice: 'Doll was successfully created.' }\n format.json { render json: @doll, status: :created, location: @doll }\n else\n format.html { render action: \"new\" }\n format.json { render json: @doll.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dolar = Dolar.new(dolar_params)\n\n respond_to do |format|\n if @dolar.save\n format.html { redirect_to @dolar, notice: 'Dolar was successfully created.' }\n format.json { render :show, status: :created, location: @dolar }\n else\n format.html { render :new }\n format.json { render json: @dolar.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n request = RestClient.post File.join(API_SERVER,\"rest-api/departments\"), { \n 'name' => params['department']['name'], \n 'description' => params['department']['description'] }.to_json, :content_type => :json, :accept => :json\n redirect_to :action => :index\n end", "def create\n @ladder = Ladder.new(ladder_params)\n\n if @ladder.save\n render json: @ladder, status: :created, location: @ladder\n else\n render json: @ladder.errors, status: :unprocessable_entity\n end\n end", "def create\n @dolgnost = Dolgnost.new(params[:dolgnost])\n\n respond_to do |format|\n if @dolgnost.save\n format.html { redirect_to @dolgnost, notice: 'Dolgnost was successfully created.' }\n format.json { render json: @dolgnost, status: :created, location: @dolgnost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dolgnost.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @page = 'newdoll'\n @doll = current_user.dolls.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @doll }\n end\n end", "def create_allele(a)\n allele_data = request(\n :url => \"alleles.json\",\n :method => \"post\",\n :payload => { :allele => a }.to_json\n )\n allele = JSON.parse(allele_data)[\"allele\"]\n return allele\nend", "def create\n @lizd = Lizd.new(lizd_params)\n\n respond_to do |format|\n if @lizd.save\n format.html { redirect_to @lizd, notice: 'Lizd was successfully created.' }\n format.json { render action: 'show', status: :created, location: @lizd }\n else\n format.html { render action: 'new' }\n format.json { render json: @lizd.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @loceod = Loceod.new(loceod_params)\n\n respond_to do |format|\n if @loceod.save\n format.html { redirect_to @loceod, notice: 'Loceod was successfully created.' }\n format.json { render :show, status: :created, location: @loceod }\n else\n format.html { render :new }\n format.json { render json: @loceod.errors, status: :unprocessable_entity }\n end\n end\n end", "def public_doodles\n @doodles = Doodle.all\n json_response(@doodles)\n end", "def create\n @lodging = Lodging.new(lodging_params)\n\n respond_to do |format|\n if @lodging.save\n format.html { redirect_to @lodging, notice: 'Lodging was successfully created.' }\n format.json { render :show, status: :created, location: @lodging }\n else\n format.html { render :new }\n format.json { render json: @lodging.errors, status: :unprocessable_entity }\n end\n end\n end", "def dropletList()\n http, req = initReq(\"droplets/\")\n JSON.parse(http.request(req).body)\nend", "def create\n @lol = Lol.new(lol_params)\n\n respond_to do |format|\n if @lol.save\n format.html { redirect_to @lol, notice: 'Lol was successfully created.' }\n format.json { render :show, status: :created, location: @lol }\n else\n format.html { render :new }\n format.json { render json: @lol.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @curpg = :admintools\n @dropreason = Dropreason.new(params[:dropreason])\n\n respond_to do |format|\n if @dropreason.save\n format.html { redirect_to :action => \"index\" }\n format.json { render json: @dropreason, status: :created, location: @dropreason }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dropreason.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lbd = Lbd.new(params[:lbd])\n\n respond_to do |format|\n if @lbd.save\n format.html { redirect_to :action => 'index' }\n format.json { render json: @lbd, status: :created, location: @lbd }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lbd.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ridol = Ridol.new(params[:ridol])\n\n respond_to do |format|\n if @ridol.save\n format.html { redirect_to @ridol, :notice => 'Ridol was successfully created.' }\n format.json { render json: @ridol, :status => :created, location: @ridol }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ridol.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @lesuur = Lesuur.new(params[:lesuur])\n @dags = Dag.all\n respond_to do |format|\n if @lesuur.save\n format.html { redirect_to dags_path, notice: 'Lesuur werd succesvol aangemaakt.' }\n format.json { render json: @lesuur, status: :created, location: @lesuur }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lesuur.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @drop = Drop.new(drop_params)\n\n if @drop.save\n render json: @drop, status: :created, location: @drop\n else\n render json: @drop.errors, status: :unprocessable_entity\n end\n end", "def save\n # post to API\n url = 'https://petapi-1.herokuapp.com/addPet'\n response = RestClient.post( url, { name: params[:name], type: params[:type], breed: params[:breed], location: params[:location], latitude: params[:latitude], longitude: params[:longitude] })\n\n # if we get an ok response, redirect to main list page\n if response.code <= 200\n # redirect to main page\n redirect_to '/'\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /dolls/1 DELETE /dolls/1.json
def destroy @doll = Doll.find(params[:id]) @doll.destroy respond_to do |format| format.html { redirect_to dolls_url } format.json { head :no_content } end end
[ "def destroy\n @doll = current_user.dolls.find(params[:id])\n @doll.destroy\n\n respond_to do |format|\n format.html { redirect_to dolls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n request = RestClient.delete File.join(API_SERVER,\"rest-api/departments\",params['id'])\n redirect_to :action => :index\t\n end", "def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @dodo.destroy\n respond_to do |format|\n format.html { redirect_to dodos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n\n head :no_content\n end", "def destroy\n @lob.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lop = Lop.find(params[:id])\n @lop.destroy\n\n respond_to do |format|\n format.html { redirect_to lops_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cephalopod.destroy\n respond_to do |format|\n format.html { redirect_to cephalopods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @loco = Loco.find(params[:id])\n @loco.destroy\n\n respond_to do |format|\n format.html { redirect_to locos_url }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @dell = Dell.find(params[:id])\n @dell.destroy\n\n respond_to do |format|\n format.html { redirect_to dells_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dragon = Dragon.find(params[:id])\n @dragon.destroy\n\n respond_to do |format|\n format.html { redirect_to dragons_url }\n format.json { head :ok }\n end\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @rond = Rond.find(params[:id])\n @rond.destroy\n\n respond_to do |format|\n format.html { redirect_to ronds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lixodone.destroy\n respond_to do |format|\n format.html { redirect_to lixodones_url, notice: 'Lixodone was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ridol = Ridol.find(params[:id])\n @ridol.destroy\n\n respond_to do |format|\n format.html { redirect_to ridols_url }\n format.json { head :ok }\n end\n end", "def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @drumy = Drumy.find(params[:id])\n @drumy.destroy\n\n respond_to do |format|\n format.html { redirect_to drumies_url }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
p average_of_three(5, 6, 8) a word is special if it starts with "c" OR has an even number of letters, but NOT both Write a method special_word? that takes in a string and returns true if the word is special
def special_word?(str) return (str[0].downcase == 'c') ^ (str.length.even?) end
[ "def special_word?(str)\n if str[0] == 'c' && str.length % 2 == 0\n return false\n elsif str[0] == 'c' || str.length % 2 == 0\n return true\n end\n return false\nend", "def test_case_3\n terms = @gh.all_words.with_word_length(6).begins_with('e').char_count_less_than('e', 2).does_not_contain('y')\n assert(terms.all? { |term| term.size == 6 && term.match(/\\Ae[^ey]{5}\\z/) })\n end", "def letter_in_word?(letter)\n end", "def words_that_contain(letter)\n letter_count(letter)\n end", "def contains_special(string)\n if string.include?(\"!\") || string.include?(\"#\") || string.include?(\"$\")\n true\n else\n false\n end\nend", "def get_score_for_word(word)\n word.length >= 3 ? word.length : 0\n end", "def filter_invalid_word(word)\n # Define a string which includes all valid letter\n letters = \"abcdefghijklmnopqrstuvwxyz\"\n # Define return variable and give a default value\n valid = true\n # transfer the word to lowercase and take out off \\r\\n\n word = word.chomp.downcase\n # set return value as false if the length of word not exactly equal 5\n if (word.split(//).size != 5)\n valid = false\n end\n # loop each word\n word.split(//).each do |letter|\n # If the letter occurs more than once in the word, set return value to false\n if (word.count(letter.to_s)) > 1 \n valid = false\n end\n # If the letter does not included in valid letter, set return value to false\n if (letters.include?(letter) == false) \n valid = false\n end\n end\n # return a bool value to method\n return valid\n end", "def garbage(w)\n acronym = w =~ ACRONYM\n\n # More than 30 bytes in length.\n (w.length > 30) ||\n\n # If there are three or more identical characters in a row in the string.\n (w =~ REPEAT) ||\n\n # More punctuation than alpha numerics.\n (!acronym && (w.scan(ALNUM).length < w.scan(PUNCT).length)) ||\n\n # Ignoring the first and last characters in the string, if there are three or\n # more different punctuation characters in the string.\n (w[1...-1].scan(PUNCT).uniq.length >= 3) ||\n\n # Four or more consecutive vowels, or five or more consecutive consonants.\n ((w =~ VOWEL_5) || (w =~ CONSONANT_5)) ||\n\n # Number of uppercase letters greater than lowercase letters, but the word is\n # not all uppercase + punctuation.\n (!acronym && (w.scan(UPPER).length > w.scan(LOWER).length)) ||\n\n # Single letters that are not A or I.\n (w.length == 1 && (w =~ ALL_ALPHA) && (w !~ SINGLETONS)) ||\n\n # All characters are alphabetic and there are 8 times more vowels than\n # consonants, or 8 times more consonants than vowels.\n (!acronym && (w.length > 2 && (w =~ ALL_ALPHA)) &&\n (((vows = w.scan(VOWEL).length) > (cons = w.scan(CONSONANT).length) * 8) ||\n (cons > vows * 8)))\nend", "def classify_word\n n = @mystery_word.chars.to_a.uniq.length # Num. unique chars in mystery_word\n #if there are less than five unique letters and the word includes the most commonly guessed letters, it's classified as 'easy'\n if n < 5 && @mystery_word =~ /[aerstln]/\n return @difficulty = \"easy\"\n #if all of the letters in the word are unique, and the word includes the least commonly guessed letters, it's classified as 'hard'\n elsif n == @mystery_word.length && @mystery_word =~ /[qjkwvxz]/\n return @difficulty = \"hard\"\n else\n return @difficulty = \"medium\"\n end\n puts \"That is a(n) #{@difficulty} level word.\"\n end", "def extra_letter( dict_word, word )\n\n\tnum = word.length - 1\n\n\t# Remove a letter from the test word to see if a match results\n\tnum.times do |i|\n\n\t\ttest_word = word[0, i+1] + word[i+2, num]\n\n\t\t# Match made\n\t\treturn true if @dictionary[test_word]\t\n\tend\n\n\t# No match found\n\treturn false\nend", "def valid_word?(word, inner_letter, outer_letters)\n word.include?(inner_letter) && word.chars.uniq.all? {|l| @all_letters.chars.include?(l) }\n end", "def valid_Word(_word)\n\tif _word.strip.empty? # check for empty string\n\t\tputs \"Bye!\"\n\t\treturn false\n\telse\t\t\t# string is not empty, score may be calculated\n return true\n end\nend", "def test_case_1\n terms = @gh.all_words.with_word_length(5).begins_with('e').does_not_contain('x')\n assert(terms.all? { |term| term.size == 5 && term.match(/\\Ae[^x]{4}\\z/) })\n end", "def validate_word(word, letter, input, saved_input)\n\n # if input less than 2 chars\n if input.length < 2\n puts \"Too short. Need at least 2 characters.\".colorize(:red)\n\n # if word is not found from online dictionary\n elsif !word\n puts \"Invalid entry.\".colorize(:red)\n\n # if input not matched to word\n elsif letter.length > 0 \n puts \"Letter(s) not found or more than in word.\".colorize(:red)\n \n # if input is repeated\n elsif saved_input[input] > 1\n puts \"Word has been used.\".colorize(:red)\n \n # validate word\n else\n puts \"Valid word.\".colorize(:blue)\n return true\n end\nend", "def test_score_a_word_having_multiple_different_tiles\n\t\t\"LEWIS\".each_char { |x| @word.append x.to_sym }\n\t\tassert_equal 8, @word.score\n\tend", "def is_all_this_letter?(word, character)\n a = is_all_as?(word)\n\n end", "def does_not_contain_special(string)\n if string.include?(\"!\") || string.include?(\"#\") || string.include?(\"$\")\n false\n else\n true\n end\nend", "def important?(word)\n\nend", "def validate_word(word)\n\n # Remove the spaces from the ends of the words and chop it into characters\n chars = word.chomp.split('')\n invalid = false\n\n # Check if the word or input is 5 characters, Reject it if its not\n if chars.length != 5\n invalid = true\n end\n\n # See if the character appears in the word more than once, otherwise use regex`s to test for numbers and characters\n # The first regex uses the shorthand \\W which looks for anything that is NOT [0-9a-zA-Z_] as a quick way to wittle\n # out characters such as !@. The second looks for anything that IS a number. the match method is used to check if\n # your character matches any of the regex conditions.\n # It is worth noting these checks will always be run UNLESS invalid has already been flipped to true.\n # If any of these evaluate, flip invalid to true\n chars.each do |char|\n unless invalid\n invalid = true if word.count(char) > 1 || char.match(/\\W/) || char.match(/[0-9]/)\n end\n end\n\n #return wether the word is valid or not the word is valid\n return invalid\n\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns available floormap names. If timestamp is given, only files newer than the given time are returned.
def floormap_names(timestamp = nil) names = [] basenames = Dir.entries(FLOORMAP_DIR) basenames.each do |basename| filename = File.join(FLOORMAP_DIR, basename) if File.file?(filename) && (timestamp == nil || File.mtime(filename) > timestamp) names << basename end end names end
[ "def filter_by_time( fileList, hours=12 )\n\tarr = []\n\tolderarr = []\n\n\tfileList.each { |f|\n\t\tif (Time.now - (hours*60*60)).gmtime.strftime(\"%Y%m%d%H%M\") < f[/[0-9]{12}.yaml/]\n\t\t\tarr.push(f)\n\t\telse \n\t\t\tolderarr.push(f)\n\t\tend # if (Time.now - (hours*60*60)).gmtime.strftime(\"%Y%m%d%H%M\") < f[/[0-9]{12}.yaml/]\n\t} #fileList.each { |f|\n\n\tarr2 = arr.sort { |x,y| y <=> x } # reverse sort puts present on top of past, though this means hostnames are backwards as well. \n\n\treturn arr2,olderarr\n\nend", "def files\n Dir.glob(\"#{File.expand_path(path)}/*\").map do |filename|\n begin\n [File.mtime(filename), filename]\n rescue Errno::ENOENT\n nil\n end\n end.compact.sort.reverse.map { |mtime, filename| filename }\n end", "def file_names_mtimes\n group_by_resolution.each_with_object({}) do |images, hash|\n name = filename(images.values.first)\n mtime = images.values.map do |image|\n File.mtime('public/' + image)\n end.min\n\n hash[name] = mtime\n end\n end", "def recent_specs(touched_since)\n recent_specs = FileList['app/**/*'].map do |path|\n\n if File.mtime(path) > touched_since\n spec = File.join('spec', File.dirname(path).split(\"/\")[1..-1].join('/'),\n \"#{File.basename(path, \".*\")}_spec.rb\")\n spec if File.exists?(spec)\n end\n end.compact\n\n recent_specs += FileList['spec/**/*_spec.rb'].select do |path| \n File.mtime(path) > touched_since \n end.uniq\nend", "def recent_specs(touched_since)\n recent_specs = FileList['app/**/*'].map do |path|\n\n if File.mtime(path) > touched_since\n spec = File.join('spec', File.dirname(path).split(\"/\")[1..-1].join('/'),\n \"#{File.basename(path, \".*\")}_spec.rb\")\n spec if File.exists?(spec)\n end\n end.compact\n\n recent_specs += FileList['spec/**/*_spec.rb'].select do |path|\n File.mtime(path) > touched_since\n end\n recent_specs.uniq\nend", "def changed_files_since(root, time, prunes = [ ])\n prunes = prunes.map { |p| File.expand_path(p) }\n \n root = File.expand_path(root)\n key = key_for(root, prunes)\n data = @roots[key]\n \n unless data && data[:up_to_date]\n new_mtimes = { }\n start_time = Time.now\n if @filesystem_impl.exist?(root)\n @filesystem_impl.find(root) do |path|\n if prunes.detect { |p| File.expand_path(path)[0..(p.length - 1)] == p }\n @filesystem_impl.prune\n else\n new_mtimes[path] = @filesystem_impl.mtime(path)\n end\n end\n end\n end_time = Time.now\n \n # Deleted files -- if we don't have a new mtime for it, it doesn't exist;\n # we then say it was modified now, the first time we noticed it was gone.\n if data\n data.keys.each { |path| new_mtimes[path] ||= start_time }\n end\n \n data = new_mtimes\n @roots[key] = data\n @roots[key][:up_to_date] = true\n end\n \n file_list = data.keys - [ :up_to_date ]\n if time\n time = Time.at(time.to_i)\n file_list = file_list.select { |path| data[path] >= time }\n end\n \n file_list\n end", "def newer_than_timestamp(timestamp)\n non_future_partitions.select do |p|\n timestamp <= p.timestamp\n end\n end", "def last_files x = 50\n # Tous les fichiers séances (Array of file names)\n # \n return [] if all_days.empty?\n oldest_date = Date.strptime(all_days.first, '%y%m%d')\n # Only the lasts x\n lejour, choosed_files, fold = Date.today, [], @roadmap.folder_seances\n while choosed_files.count < x && lejour >= oldest_date\n day = lejour.strftime(\"%y%m%d\") \n nfile = \"#{day}.msh\"\n choosed_files << File.join(fold, nfile) if all_days.include?( day )\n lejour -= 1\n end\n \n choosed_files\n end", "def find_caches\n Dir.glob(File.join(@root, '**/*.cache')).reduce([]) { |stats, filename|\n stat = safe_stat(filename)\n # stat maybe nil if file was removed between the time we called\n # dir.glob and the next stat\n stats << [filename, stat] if stat\n stats\n }.sort_by { |_, stat| stat.mtime.to_i }\n end", "def recent_specs(touched_since)\n recent_specs = []\n recent_specs += Dir['spec/**/*_spec.rb'].select do |path|\n File.mtime(path) > touched_since\n end\nend", "def read_timestamps\n FFMpeg.log.inject([]) do |array, log|\n array << (log[1] =~ /time=([\\w|\\.]+ )/ && [log[0], $1.to_f] || nil)\n end.compact\n end", "def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)\n FileList[source_pattern].map do |path|\n if File.mtime(path) > touched_since\n test = \"#{test_path}/#{File.basename(path, '.rb')}_test.rb\"\n test if File.exists?(test)\n end\n end.compact\nend", "def get_backup_dirs(prefix, backup_location, backup_timestamp)\n input_time = DateTime.strptime(backup_timestamp,\"%Y_%m_%d_%H_%M_%S\" )\n Chef::Log.info(\"backup_timestamp : #{input_time}\")\n backup_names = []\n Dir.foreach(backup_location) do |backup_dir|\n if backup_dir.start_with?(prefix)\n # Ex. Backup dir name syntax 'snapshot.sams_list1_shard1_replica0_20171116_003001'\n # extract timestamp suffix from the dir name & parse to date object\n stored_backup_date_time = DateTime.strptime(backup_dir.split(//).last(19).join(\"\").to_s,\"%Y_%m_%d_%H_%M_%S\" )\n Chef::Log.info(\"stored_backup_date_time : #{stored_backup_date_time}\")\n diff_in_minutes = (((input_time - stored_backup_date_time)*24*60*60).to_i)/ 60\n Chef::Log.info(\"diff_in_minutes : #{diff_in_minutes}\")\n if diff_in_minutes.to_i <= 10 && diff_in_minutes.to_i >= -10\n backup_names.push backup_dir\n end\n end\n end\n return backup_names\n end", "def find_files\n ret = []\n directory.children.each do |f|\n begin\n time = Time.strptime(f.basename.to_s, pattern)\n ret << File.new(f, (Date.today - time.to_date).to_i)\n rescue ArgumentError\n end\n end\n ret.sort_by(&:age)\n end", "def recent_files\n # print -rl -- **/*(Dom[1,10])\n @title = 'Recent files'\n # zsh D DOT_GLOB, show dot files\n # zsh om order on modification time\n @files = `zsh -c 'print -rl -- **/*(Dom[1,15])'`.split(\"\\n\").reject { |f| f[0] == '.' }\nend", "def find_existing_images\n images = []\n Dir.glob(File.join(@flickr_home_dir, '**/*.jpg')).each do |filename|\n images << [filename, File.mtime(filename)]\n end\n images\n end", "def enum_recent_mounts(base_key)\n recent_mounts = []\n partial_path = base_key + \"\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Explorer\"\n full_path = \"#{partial_path}\\\\Map Network Drive MRU\"\n explorer_keys = registry_enumkeys(partial_path) || ''\n if explorer_keys.include?(\"Map Network Drive MRU\")\n vals_found = registry_enumvals(full_path)\n if vals_found\n registry_enumvals(full_path).each do |k|\n if not k =~ /MRUList/\n recent_mounts << registry_getvaldata(full_path,k)\n end\n end\n end\n end\n return recent_mounts\n end", "def enum_recent_mounts(base_key)\n\trecent_mounts = []\n\tpartial_path = base_key + '\\Software\\\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n\tfull_path = \"#{partial_path}\\\\Map Network Drive MRU\"\n\texplorer_keys = registry_enumkeys(partial_path)\n\tif explorer_keys.include?(\"Map Network Drive MRU\")\n\t\tregistry_enumvals(full_path).each do |k|\n\t\t\tif not k =~ /MRUList/\n\t\t\t\trecent_mounts << registry_getvaldata(full_path,k)\n\t\t\tend\n\t\tend\n\tend\n\treturn recent_mounts\nend", "def snapshot_filesystem\n mtimes = {}\n\n files = @files.map { |file| Dir[file] }.flatten.uniq\n\n files.each do |file|\n if File.exists? file\n mtimes[file] = File.stat(file).mtime\n end\n end\n\n mtimes\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns structural floormap data (binary content + metadata) for the given id.
def floormap_data(id) contents = File.open(File.join(FLOORMAP_DIR, id), 'rb').read fileinfo = Hash.new fileinfo['id'] = id fileinfo['contents'] = Base64.encode64(contents) ending = id.split('.')[-1] fileinfo['type'] = MIME_TYPE_FOR_ENDING[ending] || ('image/' + ending) fileinfo end
[ "def retrieve_field_data(id, fields = nil)\n doc = reader[id]\n field_data = { :id => doc[:id] }\n fields.each do |f|\n field_data[f] = doc[f]\n end if fields\n return field_data\n end", "def get_fundamental_by_id(id, opts = {})\n data, _status_code, _headers = get_fundamental_by_id_with_http_info(id, opts)\n return data\n end", "def get_object(id)\n path = object_path(id)\n \n if File.exists?(path)\n buf = open(path, \"rb\") { |f| f.read }\n\n raise if not legacy_loose_object?(buf)\n \n header, content = Zlib::Inflate.inflate(buf).split(/\\0/, 2)\n type, size = header.split(/ /, 2)\n else\n content, type = get_object_from_pack(id)\n end\n \n return content, type\n end", "def data_element(id)\n DataElement.find(@server, id: id, context: {\n all: lambda { data_elements },\n any: lambda { data_elements.first },\n new: lambda { DataElement.fake(property: self) },\n })\n end", "def get_metadata\n layer_id = params['id']\n fgdc = get_layer(layer_id)['FgdcText']\n respond_to do |format|\n format.xml { \n send_data fgdc, :filename => \"#{layer_id}.fgdc.xml\", :type => :xml\n }\n format.html {\n render :text => transform_fgdc_to_html(layer_id)\n }\n end\n end", "def get_complex_by_id(id)\n get_json(\"/json/complex/#{id}\")\n end", "def read id, &block\n fn = _data_path(id)\n if block_given?\n File.open(fn, 'r', &block)\n else\n File.read(fn)\n end\n end", "def fetch_data\n return @data if @data[\"/type/reflect/any_master\"]\n @data = Ken.session.mqlread(FETCH_DATA_QUERY.merge!(:id => id))\n end", "def retrieve_from_pulfa(id)\n conn = Faraday.new(url: \"https://findingaids.princeton.edu/collections/\")\n response = conn.get(\"#{id.tr('_', '/')}.xml\", scope: \"record\")\n response.body.force_encoding(\"UTF-8\")\n end", "def find_metadata_by_id (id, id_type: 'uuid', return_description: true)\r\n\r\n # loop through the metadata structure\r\n $isaac_metadata_auxiliary.each_value do |value|\r\n\r\n # check to see if the passed id matches the specified id in the metadata\r\n if id_type == 'uuid' && value['uuids'] && value['uuids'].first[:uuid] == id\r\n found = true\r\n elsif id_type == 'sequence' && value['uuids'] && value['uuids'].first[:translation]['value'].to_s == id.to_s\r\n found = true\r\n end\r\n\r\n # if this value was a match, return the specified object\r\n if found && return_description\r\n return value['fsn']\r\n elsif found\r\n return value\r\n end\r\n end\r\n\r\n # if nothing was found return an empty string\r\n return ''\r\n end", "def get_datastream_md(druid, ds_id)\n begin\n url = URI.parse(@fedora_url + '/objects/' + druid + '/datastreams/' + ds_id)\n req = Net::HTTP::Get.new(url.request_uri)\n req.basic_auth FEDORA_USER, FEDORA_PASS\n res = DorService.get_https_connection(url).start {|http| http.request(req) } \n case res\n when Net::HTTPSuccess\n return res.body\n else\n LyberCore::Log.error(\"Datastream \" + ds_id + \" not found for \" + druid)\n return nil\n end\n end \n end", "def get(id)\n\t\t\traise FileStoreException, \"No ID given\" if id.nil? or id == ''\n\t\t\traise FileStoreException, \"No file for ID #{id} found\" if not @meta_manager.has_id?(id)\n\t\t\t\n\t\t\tmd = @meta_manager.get_data(id)\n\t\t\tpath = md[:path]\n\n\t\t\traise FileStoreException, \"No valid meta data found for ID #{id}\" if md.nil? or not File.exists?(path)\n\t\t\t\n\t\t\tinform ObserverAction.new(:type => ObserverAction::TYPE_STORE_GET, \n :objects => [id], :msg => \"Returning file from file store\") if self.is_a?(ObservedSubject)\n\t\t\t\n\t\t\treturn { :path => File.new(path), :data => md }\n\t\tend", "def get_feature_by_id(feature_id)\n @geojson_file[:features].each do |f|\n if f[:properties] && f[:properties][:id] == feature_id\n # merge site origin properties\n f = merge_site_properties(f)\n # rubocop:disable Style/GuardClause\n if f[:properties][:type] == 'Building'\n # rubocop:enable Style/GuardClause\n return URBANopt::GeoJSON::Building.new(f)\n elsif f[:properties] && f[:properties][:type] == 'District System'\n return URBANopt::GeoJSON::DistrictSystem.new(f)\n end\n end\n end\n return nil\n end", "def get(id)\n\t\t\t\turl = \"api/v2/features/#{id}\"\n\t\t\t\tget_object(:get, \"feature\", url)\n\t\t\tend", "def get_gist_content(id)\n\t\t\tself.class.get(\"/gists/#{id}\", :headers => @headers)\n\t\t\tresponse[\"files\"].first[1][\"content\"]\n\t\tend", "def fetch_motif_by_id(id)\n # separate stable ID and version number\n base_id, version = Bio::Jaspar.split_jaspar_id(id)\n\n unless version\n # if ID contains no version portion, fetch the latest version\n version = _fetch_latest_version(base_id)\n end\n\n # fetch internal JASPAR matrix ID - also a check for validity\n int_id = nil\n if version\n int_id = _fetch_internal_id(base_id, version)\n end\n\n # fetch JASPAR motif using internal ID\n motif = nil\n if int_id\n motif = _fetch_motif_by_internal_id(int_id)\n end\n\n return motif\n end", "def find_rendered( id )\n begin\n ( Regulate.repo.tree / File.join( id , 'rendered.html' ) ).data\n rescue\n nil\n end\n end", "def get(id)\n attrs = fetch(id)\n attrs ? new(attrs) : nil\n end", "def [](id)\n return { :text => \"\", :sound => \"\", :sound_length => 0.0, :volume_variance => 0, :pitch_variance => 0} if id == 0xffffffff\n\n return @cache[id] if @cache[id]\n\n raise ArgumentError, \"No such string ID: #{id.inspect} (size: #{@size})\" if id > (self.size-1) || id < 0\n seek_to = HEADER_SIZE + (id) * DATA_ELEMENT_SIZE\n @io.seek(seek_to)\n data = @io.e_read(DATA_ELEMENT_SIZE, \"tlk entry = #{id}\")\n\n flags, sound_resref, v_variance, p_variance, offset,\n size, sound_length = data.unpack(\"I A16 I I I I f\")\n flags = flags.to_i\n\n @io.seek(@entries_offset + offset)\n text = @io.e_read(size, \"tlk entry = #{id}, offset = #{@entries_offset + offset}\")\n\n text = flags & 0x1 > 0 ? text : \"\"\n sound = flags & 0x2 > 0 ? sound_resref : \"\"\n sound_length = flags & 0x4 > 0 ? sound_length.to_f : 0.0\n\n @cache[id] = {\n :text => text, :sound => sound, :sound_length => sound_length,\n :volume_variance => v_variance, :pitch_variance => p_variance\n }\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an array of floormap data structures for the given floormap names.
def floormap_data_collection(names) floormaps = [] names.each do |name| floormaps << floormap_data(name) end floormaps end
[ "def map_by_name(arr)\n return arr.map { |ele| ele[\"name\"] }\nend", "def maps()\n @map=Array.new()\n @map.push(Array.new())\n x=0\n y=0\n Dir.foreach(\"./mapsDebut\") do |fichier|\n if fichier!=\"..\" && fichier!=\".\"\n @map[x].push(fichier)\n y+=1\n if y==7\n y=0\n x+=1\n @map.push(Array.new())\n end\n end\n end\n end", "def create_color_arr(fg_map, bg_map)\n fg_arr = color_map_to_arr(fg_map)\n bg_arr = color_map_to_arr(bg_map)\n\n color_arr = []\n fg_arr.each_index do |y|\n temp_row = []\n fg_arr[y].each_index do |x|\n temp_row << [fg_arr[y][x], bg_arr[y][x]]\n end\n color_arr << temp_row\n end\n\n return color_arr\n end", "def build_maps(fog)\n if fog.respond_to?(:images) && fog.respond_to?(:flavors)\n @image_map = fog.images.reduce({}) do |c,e|\n name, ver = map_image_id(e)\n c[name] ||= []\n c[name] << ver\n c\n end\n @flavor_map = fog.flavors.reduce({}) do |c,e|\n c.merge({e.id => { ram: e.ram, disk: e.disk }})\n end\n else\n @image_map = {}\n @flavor_map = {}\n end\n end", "def create_mf_array(males, females)\n Array.new(males, 'M').concat( Array.new(females, 'F') ) \n end", "def pmmap_grouped(data)\n pmmap_grouped = ['rss', 'size', 'pss', 'shared_clean', \n 'shared_dirty', 'private_clean', 'private_dirty', \n 'referenced', 'anonymous', 'swap']\n os_list = []\n data.each do |k, v|\n os = OpenStruct.new\n os.path = k\n pmmap_grouped.each_index {|i| os[pmmap_grouped[i]] = v[i]}\n os_list.push(os)\n end\n os_list\n end", "def slide_map\n result = {}\n ft_filenames.each do |ft_filename|\n name = ft_filename.split(\"/\").last().gsub(/\\.ft$/,\"\")\n result[name] = { :forward => nil, :reverse => nil }\n File.open(ft_filename) do |ft_file|\n ft_file.each_line do |line|\n comps = line.split(\"\\t\")\n slidenum = comps[0].split('.')[0]\n if (comps[1] == 'f') then\n result[name][:forward] = slidenum\n elsif (comps[1] == 'r') then\n result[name][:reverse] = slidenum\n end\n end\n end\n end\n result\n end", "def get_image_names_array( design_template )\n images = get_images_array( design_template )\n names = []\n images.each { |i|\n names << i[ 'name' ]\n }\n names\n end", "def get_m_x_y_array_of_arrays\n get_m_n_value_from_bitmap_file[:file_contents].map do |file_content|\n file_content.split('')\n end\n end", "def figures_a\n figs = []\n 8.times do |row|\n figs << []\n 8.times do |col|\n figs[row] << self.fields[row][col].figure\n end\n end\n return figs\n end", "def get_fat_archs\n archs = []\n\n header.nfat_arch.times do |i|\n fields = @raw_data[8 + (FatArch.bytesize * i), FatArch.bytesize].unpack(\"N5\")\n archs << FatArch.new(*fields)\n end\n\n archs\n end", "def floormap_names(timestamp = nil)\n names = []\n basenames = Dir.entries(FLOORMAP_DIR)\n basenames.each do |basename|\n filename = File.join(FLOORMAP_DIR, basename)\n if File.file?(filename) && (timestamp == nil || File.mtime(filename) > timestamp)\n names << basename\n end\n end\n names\nend", "def names\n Array(name)\n end", "def collect_names(entries)\n names = entries.collect do |entry_class|\n entry = entry_class.new(coordinates)\n entry.name if entry.included?\n end\n names.compact\n end", "def channels_from names\n names.map{|x| Wires::Channel[x]}\n end", "def build_flavor_maps\n self.class.const_set(:FLAVOR_LIST, [\n {id: 1, mem: 256, hdd: 10},\n {id: 2, mem: 512, hdd: 20},\n {id: 3, mem: 1024, hdd: 40},\n {id: 4, mem: 2048, hdd: 80},\n {id: 5, mem: 4096, hdd: 160},\n {id: 6, mem: 8192, hdd: 320},\n {id: 7, mem: 15872, hdd: 620},\n {id: 8, mem: 30720, hdd: 1200}\n ].reduce({}) {|list, flavor| list[flavor[:id]] = flavor; list })\n end", "def create_pixel_array\n\t\t@pixel_array = []\n\t\t@master.each_pixel do |pixel, c, r| \n\t\t @pixel_array << {:red => pixel.red, :green => pixel.green, :blue => pixel.blue} \n\t\tend\n\tend", "def _map_bootloaders(*names)\n conditions = Hash === names.last ? names.pop : {}\n names.flatten.map do |name|\n if _bootloaders[name].run?(conditions)\n r = []\n r << _map_bootloaders(_bootloader_map[name][:before])\n r << name\n r << _map_bootloaders(_bootloader_map[name][:after])\n end\n end.flatten.compact\n end", "def build_flavor_maps\n self.class.const_set(:FLAVOR_LIST, [\n {id: 2, mem: 512, hdd: 20},\n {id: 3, mem: 1024, hdd: 40},\n {id: 4, mem: 2048, hdd: 80},\n {id: 5, mem: 4096, hdd: 160},\n {id: 6, mem: 8192, hdd: 320},\n {id: 7, mem: 15872, hdd: 620},\n {id: 8, mem: 30720, hdd: 1200},\n {id: \"performance1-1\", mem: 1024, hdd: 20},\n {id: \"performance1-2\", mem: 2048, hdd: 60},\n {id: \"performance1-4\", mem: 4096, hdd: 80},\n {id: \"performance1-8\", mem: 8192, hdd: 120},\n {id: \"performance2-15\", mem: 15360, hdd: 190},\n {id: \"performance2-30\", mem: 30720, hdd: 340},\n {id: \"performance2-60\", mem: 61440, hdd: 640},\n {id: \"performance2-90\", mem: 92160, hdd: 940},\n {id: \"performance2-120\", mem: 122880, hdd: 1240}\n ].reduce({}) {|list, flavor| list[flavor[:id]] = flavor; list })\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the index of the interval enclosing today's date
def today_interval_index @today_interval_index ||= begin # time period is strictly in the past if to_date && to_date < Time.zone.today nil # time period is strictly in the future OR # time period is infinite OR # time period has to_date in the future but no from_date boundary OR # time period has from_date in the past but not to_date boundary elsif (from_date && from_date > Time.zone.today) || !from_date || !to_date 0 # time period encloses today, with from_date and to_date boundaries else interval_end_dates.index do |interval_end| Time.zone.today <= interval_end end end end end
[ "def get_index_of_cur_day\n\treturn $index_of_cur_day\nend", "def get_interval(date)\n ((date - start + 1.hours) / interval.days).floor\n end", "def incre_index_for_cur_day\n\t$index_of_cur_day = (get_index_of_cur_day + 1).modulo($num_days_per_wk)\nend", "def date_index(date)\n dates.find_index(date)\n end", "def interval\n (Date.current - limit.days) .. Date.tomorrow\n end", "def day\n (game.periods.index(self) / 2) + 1\n end", "def current_interval_id\n get_interval_id(Time.now)\n end", "def to_index(time)\n # time = Time.parse(date_time)\n day = time.to_date\n midnight = time.midnight\n\n @day = day if @day.nil?\n raise \"Attempting to save multiple days in a single DaySchedule.\" unless @day == day\n\n index = ((time - midnight) / 60 / 15 - 32).to_i\n return index < 0 ? 0 : index\n end", "def date idx\n _date at(idx)\n end", "def dates_interval\n (Date.parse(@date) - 2..Date.parse(@date) + 2)\n end", "def get_period_offset(i)\n (i * self.interval).days\n end", "def startOfDay\n Time.now.getutc.beginning_of_day.to_i\n end", "def days_to_begins\n ((begins.to_time - Date.today.to_time) / 3600 / 24).to_i\n end", "def get_cur_day\n\treturn $cur_day.to_i\nend", "def indexToDate(index)\n return @startDate + index\nend", "def today\n time = Time.now.in_time_zone(tz)\n time.beginning_of_day..(time.end_of_day + 1)\n end", "def days_left\n (date - Date.today)\n end", "def current_interval_id\n get_interval_id(time_to_redis(Time.now))\n end", "def day_to_index(day_num)\n check_pre((\n (day_num.int?)\n ))\n\n return day_num - 1\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /customer_leads GET /customer_leads.json
def index @customer_leads = CustomerLead.all end
[ "def get_user_campaign_leads username, password, campaign_id, options = {}\n do_request 'get_user_campaign_leads', options.merge(username: username, password: password,\n campaign_id: campaign_id)\n end", "def get_user_leads username, password, options = {}\n do_request 'get_user_leads', options.merge(username: username, password: password)\n end", "def index\n @leads = Lead.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leads }\n end\n end", "def show\n @customer_ledger = CustomerLedger.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer_ledger }\n end\n end", "def getLeads\n\n\t\tlead_class=@client.materialize(\"Lead\")\n\t\tleads=Lead.all\n\t\treturn leads\n\tend", "def get_leads_by_owner_id\n request_params = Leads::GetLeadsByOwnerIdRequestParams.new(request.message)\n request_params.validate!\n service = Leads::GetLeadsByOwnerIdService.new(request_params, nil)\n service.run!\n presenter = Leads::LeadsPresenter.new(service.result)\n presenter.generate_response\n end", "def show\n @leads_b = LeadsB.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leads_b }\n end\n end", "def customer_list\n perform_get_request('/customer/list')\n end", "def index\n @leads = @leads.find(:all, :include => [:contact, :agent])\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @leads }\n end\n end", "def create\n @customer_lead = CustomerLead.new(customer_lead_params)\n\n respond_to do |format|\n if @customer_lead.save\n format.html { redirect_to admin_customers_customer_leads_url, notice: 'Customer lead was successfully created.' }\n format.json { render action: 'show', status: :created, location: @customer_lead }\n else\n format.html { render action: 'new' }\n format.json { render json: @customer_lead.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @leads_a = LeadsA.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leads_a }\n end\n end", "def debts(customer, params = {})\n id = customer.is_a?(Model::Customer) ? customer.gid : customer\n response = @connection.get(\"customers/#{id}/debts\", params)\n raise InvisibleCollector::NotFound.from_json(response.body) if response.status == 404\n\n if handles.key?(response.status)\n handles[response.status].call response\n else\n debts = JSON.parse(response.body).map { |j| Model::Debt.new(j.deep_transform_keys(&:underscore)) }\n Response.new(response, debts)\n end\n end", "def leadsforce\n if current_user\n @leadsforce = @client.getAllLeads\n end\n end", "def index\n @ladders = Ladder.all\n\n render json: @ladders\n end", "def index\n @buyer_referral_leads = Buyer::ReferralLead.all\n end", "def new\n @customer_ledger = CustomerLedger.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer_ledger }\n end\n end", "def create\n @customer_lead = CustomerLead.new(customer_lead_params)\n\n respond_to do |format|\n if @customer_lead.save\n format.html { redirect_to @customer_lead, notice: 'Customer lead was successfully created.' }\n format.json { render action: 'show', status: :created, location: @customer_lead }\n else\n format.html { render action: 'new' }\n format.json { render json: @customer_lead.errors, status: :unprocessable_entity }\n end\n end\n end", "def accounts(customer_id)\n self.class.get(\"/customers/#{customer_id}/accounts\", @options)\n end", "def all(params = {})\n @client.make_request(:get, 'referral_customers', MODEL_CLASS, params)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /customer_leads POST /customer_leads.json
def create @customer_lead = CustomerLead.new(customer_lead_params) respond_to do |format| if @customer_lead.save format.html { redirect_to @customer_lead, notice: 'Customer lead was successfully created.' } format.json { render action: 'show', status: :created, location: @customer_lead } else format.html { render action: 'new' } format.json { render json: @customer_lead.errors, status: :unprocessable_entity } end end end
[ "def create\n @customer_lead = CustomerLead.new(customer_lead_params)\n\n respond_to do |format|\n if @customer_lead.save\n format.html { redirect_to admin_customers_customer_leads_url, notice: 'Customer lead was successfully created.' }\n format.json { render action: 'show', status: :created, location: @customer_lead }\n else\n format.html { render action: 'new' }\n format.json { render json: @customer_lead.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer_ledger = CustomerLedger.new(params[:customer_ledger])\n\n respond_to do |format|\n if @customer_ledger.save\n format.html { redirect_to @customer_ledger, notice: 'Customer ledger was successfully created.' }\n format.json { render json: @customer_ledger, status: :created, location: @customer_ledger }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer_ledger.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lead = current_user.leads.build(params[:lead])\n\n respond_to do |format|\n if @lead.save\n format.html { redirect_to @lead, :notice => 'Lead was successfully created.' }\n format.json { render :json => @lead, :status => :created, :location => @lead }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @lead.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @customer_leads = CustomerLead.all\n end", "def create\n \n @lead = Lead.new(lead_params)\n respond_to do |format|\n \n if @lead.save\n format.html { redirect_to @lead, notice: 'Lead was successfully created.' }\n format.json { render :show, status: :created, location: @lead }\n else\n format.html { render :new }\n format.json { render json: @lead.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lead = @company.leads.new(safe_params)\n\n respond_to do |format|\n if @lead.save\n format.html { redirect_to [@company, @lead], notice: 'Lead was successfully created.' }\n format.json { render :show, status: :created, location: @lead }\n else\n format.html { render :new }\n format.json { render json: @lead.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(lead)\n validate_type!(lead)\n\n attributes = sanitize(lead)\n _, _, root = @client.post(\"/leads\", attributes)\n\n Lead.new(root[:data])\n end", "def create\n @leads_b = LeadsB.new(params[:leads_b])\n\n respond_to do |format|\n if @leads_b.save\n format.html { redirect_to @leads_b, notice: 'Leads b was successfully created.' }\n format.json { render json: @leads_b, status: :created, location: @leads_b }\n else\n format.html { render action: \"new\" }\n format.json { render json: @leads_b.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @leads_a = LeadsA.new(params[:leads_a])\n\n respond_to do |format|\n if @leads_a.save\n format.html { redirect_to @leads_a, notice: 'Leads a was successfully created.' }\n format.json { render json: @leads_a, status: :created, location: @leads_a }\n else\n format.html { render action: \"new\" }\n format.json { render json: @leads_a.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @leads2 = Leads2.new(leads2_params)\n\n respond_to do |format|\n if @leads2.save\n format.html { redirect_to @leads2, notice: 'Lead was successfully created.' }\n format.json { render action: 'show', status: :created, location: @leads2 }\n else\n format.html { render action: 'new' }\n format.json { render json: @leads2.errors, status: :unprocessable_entity }\n end\n end\n end", "def salesforce\n if current_user\n\n @params = params[:lead_id]\n @totalImported = 0\n\n if @params != nil\n @params.each do |p|\n lead = Lead.find_by(id: p)\n payload = {\n :name => lead.name,\n :middleName => \"\",\n :lastName => lead.last_name,\n :status => \"New\",\n :company => lead.company,\n :email => lead.email,\n :website => lead.website,\n :phone => lead.phone,\n :jobTitle => lead.job_title\n }\n newLead = @client.create(payload)\n @totalImported += 1\n end\n end\n\n @leads = @client.getAllLeads\n end\n end", "def create\n @buyer_referral_lead = Buyer::ReferralLead.new(buyer_referral_lead_params)\n\n respond_to do |format|\n if @buyer_referral_lead.save\n format.html { redirect_to @buyer_referral_lead, notice: 'Referral lead was successfully created.' }\n format.json { render :show, status: :created, location: @buyer_referral_lead }\n else\n format.html { render :new }\n format.json { render json: @buyer_referral_lead.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(params = {})\n @client.make_request(:post, 'referral_customers', MODEL_CLASS, { user: params })\n end", "def get_user_campaign_leads username, password, campaign_id, options = {}\n do_request 'get_user_campaign_leads', options.merge(username: username, password: password,\n campaign_id: campaign_id)\n end", "def create\n params.require(:customer_id)\n\n customer = Customer.find_by(id: params[:customer_id])\n render json: 'Customer ID not found.', status: :not_acceptable and return if customer.nil?\n\n referral = Referral.create do |r|\n r.customer = customer\n end\n\n if referral.save\n render json: build_sign_up_link(referral.key), status: :created\n else\n render json: 'There was a problem with the referral creation.', status: :bad_request\n end\n end", "def new\n @leads_b = LeadsB.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @leads_b }\n end\n end", "def create\n @lead = Lead.new(params[:lead])\n\n respond_to do |format|\n if @lead.save\n flash[:notice] = 'Lead was successfully created.'\n format.html { redirect_to(@lead) }\n format.xml { render :xml => @lead, :status => :created, :location => @lead }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lead.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @residential_lead = ResidentialLead.new(residential_lead_params)\n\n respond_to do |format|\n if @residential_lead.save\n format.html { redirect_to @residential_lead, notice: 'Residential lead was successfully created.' }\n format.json { render :show, status: :created, location: @residential_lead }\n else\n format.html { render :new }\n format.json { render json: @residential_lead.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @retailer_ledger = RetailerLedger.new(params[:retailer_ledger])\n\n respond_to do |format|\n if @retailer_ledger.save\n format.html { redirect_to @retailer_ledger, notice: 'Retailer ledger was successfully created.' }\n format.json { render json: @retailer_ledger, status: :created, location: @retailer_ledger }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retailer_ledger.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /customer_leads/1 PATCH/PUT /customer_leads/1.json
def update respond_to do |format| if @customer_lead.update(customer_lead_params) format.html { redirect_to @customer_lead, notice: 'Customer lead was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @customer_lead.errors, status: :unprocessable_entity } end end end
[ "def update\n respond_to do |format|\n if @customer_lead.update(customer_lead_params)\n format.html { redirect_to action: 'show', notice: 'Customer lead was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @customer_lead.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer_ledger = CustomerLedger.find(params[:id])\n\n respond_to do |format|\n if @customer_ledger.update_attributes(params[:customer_ledger])\n format.html { redirect_to @customer_ledger, notice: 'Customer ledger was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer_ledger.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lead = current_user.leads.find(params[:id])\n\n respond_to do |format|\n if @lead.update_attributes(params[:lead])\n format.html { redirect_to @lead, :notice => 'Lead was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @lead.errors, :status => :unprocessable_entity }\n end\n end\n end", "def change_lead(lead, lead_hash)\n lead_hash = auth_token_hash.merge({:lead => lead_hash})\n put_with_body(\"/leads/#{lead}\", :body => lead_hash.to_json, :headers => {'Content-Type' => 'application/json'})\n end", "def update\n @leads_a = LeadsA.find(params[:id])\n\n respond_to do |format|\n if @leads_a.update_attributes(params[:leads_a])\n format.html { redirect_to @leads_a, notice: 'Leads a was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @leads_a.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lead = Lead.find(params[:id])\n\n respond_to do |format|\n if @lead.update_attributes(params[:lead])\n format.html { redirect_to @lead, notice: 'Lead was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lead.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @leads_b = LeadsB.find(params[:id])\n\n respond_to do |format|\n if @leads_b.update_attributes(params[:leads_b])\n format.html { redirect_to @leads_b, notice: 'Leads b was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @leads_b.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lead_contact = LeadContact.find(params[:id])\n\n respond_to do |format|\n if @lead_contact.update_attributes(params[:lead_contact])\n format.html { redirect_to @lead_contact.lead, notice: 'Lead contact was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lead_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @leads2.update(leads2_params)\n format.html { redirect_to @leads2, notice: 'Lead was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @leads2.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lead = Lead.find(params[:id])\n\n respond_to do |format|\n if @lead.update_attributes(params[:lead])\n flash[:notice] = 'Lead was successfully updated.'\n format.html { redirect_to(@lead) }\n format.xml { head :ok }\n format.json { render :json => @lead }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lead.errors, :status => :unprocessable_entity }\n format.json { render :json => @lead.errors }\n end\n end\n end", "def update\n @lead = Salesforce::Lead.find(params[:id])\n # if params[\"salesforce_lead\"] && params[\"salesforce_lead\"].class == Hash\n params[\"salesforce_lead\"].each do |key, value|\n method = key + \"=\"\n @lead.send method, value\n end\n # end\n # @lead = Salesforce::Lead.new(params[:salesforce_lead])\n \n respond_to do |format|\n # if @lead.update_attributes(params[:lead])\n if @lead.save\n format.html { redirect_to(@lead, :notice => 'Salesforce::Lead was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lead.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lead_detail = LeadDetail.find(params[:id])\n\n respond_to do |format|\n if @lead_detail.update_attributes(params[:lead_detail])\n format.html { redirect_to @lead_detail, notice: 'Lead detail was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lead_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer_bill = CustomerBill.find(params[:id])\n\n respond_to do |format|\n if @customer_bill.update_attributes(params[:customer_bill])\n format.html { redirect_to @customer_bill, notice: 'Customer bill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer_bill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @offer_customer = OfferCustomer.find(params[:id])\n\n respond_to do |format|\n if @offer_customer.update_attributes(params[:offer_customer])\n format.html { redirect_to @offer_customer, notice: 'Offer customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @offer_customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @buyer_referral_lead.update(buyer_referral_lead_params)\n format.html { redirect_to @buyer_referral_lead, notice: 'Referral lead was successfully updated.' }\n format.json { render :show, status: :ok, location: @buyer_referral_lead }\n else\n format.html { render :edit }\n format.json { render json: @buyer_referral_lead.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @residential_lead.update(residential_lead_params)\n format.html { redirect_to @residential_lead, notice: 'Residential lead was successfully updated.' }\n format.json { render :show, status: :ok, location: @residential_lead }\n else\n format.html { render :edit }\n format.json { render json: @residential_lead.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lead.update_attributes(params[:lead])\n format.html { redirect_to(@lead, :notice => 'Lead was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lead.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @referring_agency = ReferringAgency.find(params[:id])\n\n respond_to do |format|\n if @referring_agency.update_attributes(params[:referring_agency])\n format.html { redirect_to @referring_agency, notice: 'Referring agency was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @referring_agency.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer_relationship.update(customer_relationship_params)\n format.html { redirect_to @business_model_canvase, notice: 'Customer relationship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @customer_relationship.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /customer_leads/1 DELETE /customer_leads/1.json
def destroy @customer_lead.destroy respond_to do |format| format.html { redirect_to customer_leads_url } format.json { head :no_content } end end
[ "def destroy\n @customer_ledger = CustomerLedger.find(params[:id])\n @customer_ledger.destroy\n\n respond_to do |format|\n format.html { redirect_to customer_ledgers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lead = Lead.find(params[:id])\n @lead.delete\n\n respond_to do |format|\n format.html { redirect_to leads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lead = Lead.find(params[:id])\n @lead.destroy\n\n respond_to do |format|\n format.html { redirect_to leads_url }\n format.json { head :ok }\n end\n end", "def destroy\n @lead = Lead.find(params[:id])\n @lead.destroy\n\n respond_to do |format|\n format.html { redirect_to leads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lead.destroy\n respond_to do |format|\n format.html { redirect_to company_leads_url(@company), notice: 'Lead was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @leads_b = LeadsB.find(params[:id])\n @leads_b.destroy\n\n respond_to do |format|\n format.html { redirect_to leads_bs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @leads2.destroy\n respond_to do |format|\n format.html { redirect_to leads2s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lead = Salesforce::Lead.find(params[:id])\n @lead.destroy\n\n respond_to do |format|\n format.html { redirect_to(salesforce_leads_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @buyer_referral_lead.destroy\n respond_to do |format|\n format.html { redirect_to buyer_referral_leads_url, notice: 'Referral lead was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @agency_client = AgencyClient.find(params[:id])\n @agency_client.destroy\n\n respond_to do |format|\n format.html { redirect_to agency_clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reach_out_to_customer.destroy\n respond_to do |format|\n format.html { redirect_to reach_out_to_customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @referring_agency = ReferringAgency.find(params[:id])\n @referring_agency.destroy\n\n respond_to do |format|\n format.html { redirect_to referring_agencies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lead = Lead.find(params[:id])\n @lead.destroy\n\n respond_to do |format|\n format.html { redirect_to(leads_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lead.destroy\n\n respond_to do |format|\n format.html { redirect_to(leads_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lead_detail = LeadDetail.find(params[:id])\n @lead_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to lead_details_url }\n format.json { head :ok }\n end\n end", "def destroy\n @leads_a = LeadsA.find(params[:id])\n @leads_a.destroy\n\n respond_to do |format|\n format.html { redirect_to leads_as_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer_bill = CustomerBill.find(params[:id])\n @customer_bill.destroy\n\n respond_to do |format|\n format.html { redirect_to customer_bills_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lead_contact = LeadContact.find(params[:id])\n @lead_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to lead_contacts_url }\n format.json { head :ok }\n end\n end", "def destroy\n @email_lead.destroy\n respond_to do |format|\n format.html { redirect_to email_leads_url }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Indicate whether the record is associated with an uploaded file.
def file_valid? record.present? && record.file_attacher.file.present? end
[ "def has_upload?\n @record.uploaded_file && File.exist?(@record.uploaded_file.path)\n end", "def uploaded?(uploaded_file)\n uploaded_file.storage_key == storage_key.to_s\n end", "def file_uploaded?\n\t\t\treturn request_status == REQUEST_STATUS['file_uploaded']\n\t\tend", "def attached_file_valid?\n make_file_record(file_data).blank? || super\n end", "def has_a_file_attribute?\n attributes.each do |attribute|\n return true if attribute.type == :file\n end\n return false\n end", "def stored?(file = self.file)\n uploaded?(file, store_key)\n end", "def can_upload?\n klass.model_class && mime_types && mime_types.keys.include?(file_mime_type)\n end", "def raw_file_okay?\n File.exists? uploaded_file_path\n end", "def uploaded?(file, storage_key)\n file&.storage_key == storage_key\n end", "def file_allowed?\n @file_allowed\n end", "def can_upload?\n self.assigned? || self.error?\n end", "def is_uploaded_file?(param)\n if param.respond_to?(:has_key?)\n [:filename, :type, :name, :tempfile, :head].each do |k|\n return false if !param.has_key?(k)\n end\n\n return true\n else\n return false\n end\n end", "def file_required?\n @file_required\n end", "def file_set?(resource)\n resource.respond_to?(:file_metadata) && !resource.respond_to?(:member_ids)\n end", "def has_multipart?(obj); end", "def file?\n @tag == :file\n end", "def file_entity?\n code == FILE_ENTITY_CODE\n end", "def uploaded?\n upload_status == 'uploaded' if video?\n end", "def attachment?(file_name)\n frm.link(:text=>file_name).exist?\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Indicate whether the EMMA metadata associated with the record is valid.
def metadata_valid? record.present? && record.valid? end
[ "def valid_v3_metadata?\n return false unless record.respond_to?(:manifest_metadata)\n metadata = record.manifest_metadata\n valid_v3_metadata_structure?(metadata) && valid_metadata_content?(metadata)\n end", "def valid?\n metadata && id && name rescue false\n end", "def has_valid_metadata?\n meta = scm_connection.metadata(full_name)\n if meta.blank? || meta.kind_of?(ErrorExchange)\n spin_log('[ERROR] Error parsing metadata')\n else\n spin_log('[OK] The Spin metadata is correct')\n return true\n end\n false\n end", "def valid?\n @errors = new_errors\n @heading.attributes.each { |attribute|\n unless @object.persisted?\n next if attribute.domain.is_a?(Orel::Domains::Serial)\n end\n\n # TODO: implement domain specific validations\n value = @attributes[attribute.name]\n if value.nil?\n @errors.add(attribute.name, \"cannot be blank\")\n end\n }\n @errors.size == 0\n end", "def valid?\n OGP_REQUIRED_FIELDS.all? { |k| metadata[k].present? }\n end", "def has_valid_metadata?\n @row_count = 0\n all_valid = true\n metadata_file_path = FileLocations.metadata_file_path(@source_dir)\n ::CSV.foreach(metadata_file_path, headers: true).each do |csv_row|\n next if csv_row.blank?\n # Each row of metadata listed in DESCRIPTION.csv should be valid\n row = strip_csv_row(csv_row)\n @row_count += 1\n all_valid = all_valid && has_valid_metadata_row?(row, @row_count)\n end\n # Should have 1 or more rows\n unless @row_count > 0\n @errors << \"Metadata file #{metadata_file_path} has no rows\"\n all_valid = false\n end\n all_valid\n end", "def valid?\n @specification.check_tag(self) && @attributes.all? { | _k, v | v.valid? }\n end", "def metadata?\n !(metadata.nil? || metadata.empty?)\n end", "def metadata?\n !@metadata.nil? && !@metadata.empty?\n end", "def valid_meta_section?\n meta = @parsed_response.dig('meta')\n return set_failure_message(FailureMessages::MISSING_META) unless meta.is_a?(Hash)\n true\n end", "def metadata?\n !!@metadata\n end", "def camera_data_valid?\n @camera_data[:start_frame] && @camera_data[:end_frame] ? true : false\n end", "def errors?\n attr_plain, attr_id = builder.assoc_and_id_attr(attr)\n object.errors.key?(attr_plain.to_sym) ||\n object.errors.key?(attr_id.to_sym)\n end", "def materials_data_valid?\n @materials_data.size > 0\n end", "def reliable_match?(record_metadata)\n return true unless (@record_id.nil? or @record_id.empty?)\n return true unless (@issn.nil? or @issn.empty?) and (@isbn.nil? or @isbn.empty?)\n return false if (record_metadata.nil? or record_metadata.empty? or record_metadata[:title].nil? or record_metadata[:title].empty?)\n # Titles must be equal\n return false unless record_metadata[:title].to_s.downcase.eql?(@title.downcase)\n # Author must be equal\n return false unless record_metadata[:author].to_s.downcase.eql?(@author.downcase)\n return true\n end", "def valid?\n return @valid ||= !malformed? && FiveD::AccessToken.calc_signature(@token) == @signature && !in_future?\n end", "def attributes_valid?\n invalid_attributes.empty?\n end", "def isValid\n # check that the amino acid is complete\n nonHydrogenAtoms = self.atoms.select{|atom| atom.atom != \"H\"}\n if (nonHydrogenAtoms.size == AMINO_ACID_SIZES[self.resname])\n @isvalid = true\n end\n puts \"ISVALID : #{self.isvalid} #{nonHydrogenAtoms.size} \"\n end", "def valid?\n validation_errors.clear\n validation_errors.concat(\n JSON::Validator.fully_validate(self.class.schema, data)\n )\n validation_errors.empty?\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Upload file via Shrine and update failed/succeeded arrays.
def wf_upload_file(*event_args) __debug_items(binding) opt = event_args.extract_options!.presence || event_args.first || {} opt[:meth] ||= calling_method # The return from Shrine will be the results of the workflow step. stat, _hdrs, body = self.results = upload_file(**opt) # Update status arrays accordingly. data = nil if stat.nil? self.failures << 'missing env data' elsif stat != 200 self.failures << 'invalid file' elsif !record self.succeeded << 'no record' # TODO: should this be a failure? elsif (data = json_parse(body.first)&.except(:emma_data)&.to_json) self.succeeded << record.id else self.failures << 'invalid file_data' end # Ensure that the record is updated now instead of waiting for the file # data to be returned when the form is submitted in case the submission is # canceled and the uploaded file needs to be removed from storage. record.update_column(record.file_data_column, data) if data end
[ "def call\n uploaded_file = shrine_class.uploaded_file(storage: upload_storage, id: upload_location)\n uploaded_file.open(**upload_open_options)\n uploaded_file\n rescue Shrine::FileNotFound\n end", "def upload\n end", "def upload\n __log_activity\n __debug_route\n __debug_request\n prm = current_params.dup\n ids = prm.extract!(*model_options.identifier_keys)\n id = ids[:id].presence || ids.values.compact.first\n fd = true?(request.headers['X-Update-FileData-Only'])\n stat, hdrs, body = upload_file(**prm, id: id, update_time: !fd)\n self.status = stat if stat.present?\n self.headers.merge!(hdrs) if hdrs.present?\n self.response_body = body if body.present?\n rescue Record::SubmitError => error\n post_response(:conflict, error, xhr: true)\n rescue => error\n post_response(error, xhr: true)\n end", "def check_existence_upload_file_and_wait data_dir,file_name,content_type,cbrain_type,cbrain_data_provider_id\n\n absolute_file_name = File.join(data_dir,file_name)\n raise \"!! File does not exist: #{absolute_file_name}\" unless File.exist?(absolute_file_name)\n userfiles = index_userfiles({:data_provider_id => cbrain_data_provider_id, :name => file_name})\n # Redo the call a second time, just in case (see API bug #5)\n userfiles = index_userfiles({:data_provider_id => cbrain_data_provider_id, :name=>file_name})\n if userfiles.size > 1\n puts \"!! Found the following file ids with name #{file_name} on data provider #{cbrain_data_provider_id}:\"\n userfiles.each do |f|\n puts \"!! #{f[:id]}\"\n end\n raise \"!! Found more than 1 file with name #{file_name} on data provider #{cbrain_data_provider_id}\" \n end\n \n if !userfiles.empty? # file exists\n return userfiles[0][:id] if @overwrite_none # file exists and no file must be overwritten: do nothing. \n overwrite = @overwrite_all ? true : ask_overwrite(userfiles[0][:name],userfiles[0][:id])\n return userfiles[0][:id] if !overwrite # file exists and file mustn't be overwritten: do nothing.\n puts \"-- Deleting file #{userfiles[0][:name]} with id #{userfiles[0][:id]}...\" # delete file and fall into the \"file doesn't exist case\"\n delete_userfiles(userfiles[0][:id])\n end\n\n # File doesn't exist: upload it\n puts \"++ Uploading file #{file_name} (#{File.size(absolute_file_name)} bytes)...\"\n params = { :data_provider_id => cbrain_data_provider_id,\n :archive => \"save\",\n :file_type => cbrain_type,\n \"userfile[group_id]\" => 1, # everyone\n \"userfile[group_writable]\" => false,\n }\n \n response = create_userfile(\n absolute_file_name,\n content_type,\n params)\n puts \"#{response}\" if !response.nil? && !response==\"\"\n\n # Check that the file is in CBRAIN and wait for the synchronization status to be \"InSync\"\n userfiles = index_userfiles({:data_provider_id => cbrain_data_provider_id, :name=>file_name})\n # Redo the call a second time, just in case (see API bug #5)\n userfiles = index_userfiles({:data_provider_id => cbrain_data_provider_id, :name=>file_name})\n raise \"!! Cannot find file with name #{file_name} on data provider #{cbrain_data_provider_id}\" if userfiles.empty?\n raise \"!! Found more than 1 file with name #{file_name} on data provider #{cbrain_data_provider_id}\" if userfiles.size > 1\n print \".. Waiting for file #{file_name} to be synchronized\"\n begin\n sleep 1\n userfile_info = show_userfile(userfiles[0][:id])\n if userfile_info.blank? or userfile_info[:remote_sync_status].blank? or userfile_info[:remote_sync_status].empty?\n print \"x\"\n next\n end\n status = userfile_info[:remote_sync_status][0][:status]\n print \".\"\n end while status != \"InSync\"\n puts \"\"\n \n return userfiles[0][:id]\n end", "def upload_rexe(path, payload)\n vprint_status(\"Uploading #{path}\")\n\n if file? path\n fail_with(Failure::Unknown, \"File #{path} already exists... Exiting\")\n end\n\n begin\n write_file(path, payload)\n rescue => e\n fail_with(Failure::Unknown, \"Could not upload to #{path}\")\n end\n\n print_good(\"Successfully Uploaded remote executable to #{path}\")\n end", "def start_upload\n no_error = true # This is the value we expect from each of the following methods\n\n # Upload inspection\n no_error = upload_inspection\n\n # Upload inspection items\n no_error = upload_inspection_items if no_error\n\n # Upload inspection item photos\n no_error = upload_inspection_item_photo_to_remote if no_error\n\n no_error = upload_inspection_item_photos if no_error\n\n # Finalize inspection\n finalize_inspection if no_error\n end", "def upload\n return if current_pstore.nil?\n fichier_synchro.upload\n flash \"PStore uploadé\"\n end", "def upload_unit_test_report\n if params[:token] == Token::AUTO_TEST_TOKEN\n file_save_status = @version.save_utr_file(params[:file]) # if @version.unit_test?\n if file_save_status\n @version.update_column(:has_unit_test_report, true)\n render :text => \"File saved!\"\n else\n render_error :status => 500, :message => \"Request failed!\"\n end\n else\n render_error :status => 422, :message => \"Invalid authenticity token.\"\n end\n end", "def transfer!\n package.filenames.each do |filename|\n src = File.join(Config.tmp_path, filename)\n dest = File.join('/', remote_path, filename)\n Logger.info \"Storing '#{ dest }'...\"\n\n File.open(src, 'r') do |file|\n @uploader = ChunkedUploader.new(client, file)\n with_retries do\n @uploader.upload(1024**2 * chunk_size)\n end\n end\n\n with_retries do\n @uploader.finish(dest)\n end\n end\n rescue => err\n raise Error.wrap(err, \"Upload Failed!\")\n end", "def upload_file_for_episode(pending_upload)\n \n c = Curl::Easy.new(pending_upload[:upload].url) \n c.multipart_form_post = true\n \n fields = []\n pending_upload[:upload].params.each_pair do |key, value|\n fields << Curl::PostField.content(key, value)\n end\n \n fields << Curl::PostField.file(\"file\", pending_upload[:filepath])\n \n begin\n c.http_post(*fields)\n raise ::Episodic::Platform::FileUploadFailed.new(\"Status #{c.response_code} returned from file upload request\") if c.response_code > 399\n return true\n rescue Curl::Err::CurlError => e\n raise ::Episodic::Platform::FileUploadFailed.new(e.message)\n end\n end", "def perform_study_file_upload(filename, study_file_params, study_id)\n file_upload = Rack::Test::UploadedFile.new(Rails.root.join('test', 'test_data', filename))\n study_file_params[:study_file].merge!(upload: file_upload)\n patch \"/single_cell/studies/#{study_id}/upload\", params: study_file_params, headers: {'Content-Type' => 'multipart/form-data'}\nend", "def push_file(path, data)\n begin\n @upload_retries ||= 0\n response = post(path, data)\n return response if response\n rescue StandardError => se\n # Decide if we should fail based on number of retries\n if @upload_retries < 3\n if path.include? 'remove'\n raise 'could not delete file'\n else\n raise 'could not upload file'\n end\n else\n return se\n end\n end\n rescue => e\n @upload_retries += 1\n sleep 2\n retry\n ensure\n # verify that this is only called if the retry is not triggered\n @upload_retries = nil\n end", "def upload_to_scribd\n if scribdable? and self.scribd_id.blank?\n with_file_path do |file_path|\n if resource = scribd_login.upload(:file => \"#{file_path}\",\n :access => access_level)\n logger.info \"[Scribd_fu] #{Time.now.rfc2822}: Object #{id} successfully uploaded for conversion to iPaper.\"\n\n self.scribd_id = resource.doc_id\n self.scribd_access_key = resource.access_key\n\n save\n else\n logger.info \"[Scribd_fu] #{Time.now.rfc2822}: Object #{id} upload failed!\"\n end\n end\n end\n end", "def upload(app_name, binary_path, platform)\n binary_type = binary_type_from_path(binary_path)\n\n UI.message(\"⌛ Uploading the #{binary_type}.\")\n operation_name = upload_binary(app_name, binary_path, platform)\n\n upload_status_response = get_upload_status(operation_name)\n MAX_POLLING_RETRIES.times do\n if upload_status_response.success?\n if upload_status_response.release_updated?\n UI.success(\"✅ Uploaded #{binary_type} successfully; updated provisioning profile of existing release #{upload_status_response.release_version}.\")\n break\n elsif upload_status_response.release_unmodified?\n UI.success(\"✅ The same #{binary_type} was found in release #{upload_status_response.release_version} with no changes, skipping.\")\n break\n else\n UI.success(\"✅ Uploaded #{binary_type} successfully and created release #{upload_status_response.release_version}.\")\n end\n break\n elsif upload_status_response.in_progress?\n sleep(POLLING_INTERVAL_SECONDS)\n upload_status_response = get_upload_status(operation_name)\n else\n if !upload_status_response.error_message.nil?\n UI.user_error!(\"#{ErrorMessage.upload_binary_error(binary_type)}: #{upload_status_response.error_message}\")\n else\n UI.user_error!(ErrorMessage.upload_binary_error(binary_type))\n end\n end\n end\n unless upload_status_response.success?\n UI.crash!(\"It took longer than expected to process your #{binary_type}, please try again.\")\n end\n\n upload_status_response.release_name\n end", "def upload\n secure_silence_logs do\n return bad_request unless params[:file] && params[:title] && current_account\n is_file = params[:file].respond_to?(:path)\n if !is_file && !(URI.parse(params[:file]) rescue nil)\n return bad_request(:error => \"The 'file' parameter must be the contents of a file or a URL.\")\n end\n \n if params[:file_hash] && Document.accessible(current_account, current_organization).exists?(:file_hash=>params[:file_hash])\n return conflict(:error => \"This file is a duplicate of an existing one you have access to.\")\n end\n params[:url] = params[:file] unless is_file\n @response = Document.upload(params, current_account, current_organization).canonical\n render_cross_origin_json\n end\n end", "def upload_to_scribd\n ScribdFu::upload(self, file_path) if scribdable?\n end", "def create\n RawFile.transaction do\n @raw_file = RawFile.new(params[:raw_file])\n\n @raw_file.uploaded_file = params[:raw_file][:file]\n\n @raw_file.status = 'SENT'\n\n respond_to do |format|\n if @raw_file.save\n format.html { redirect_to @raw_file, :notice => 'File was successfully created.' }\n format.json { render :json => @raw_file, :status => :created, :location => @raw_file }\n else\n format.html { render \"new\", :locals => { :raw_file => @raw_file } }\n format.json { render :json => @raw_file.errors, :status => :unprocessable_entity }\n end\n end\n end\n end", "def upload\n # @resource.clean_uploads # might want this back cleans database to match existing files on file system\n @file = FileUpload.new(resource_id: resource.id) # this is apparantly needed for the upload control\n @uploads = resource.latest_file_states\n render 'upload_manifest' if resource.upload_type == :manifest\n end", "def transfer!\n package.filenames.each do |filename|\n src = File.join(Config.tmp_path, filename)\n dest = File.join(remote_path, filename)\n Logger.info \"Storing '#{dest}'...\"\n\n uploader = nil\n File.open(src, \"r\") do |file|\n uploader = connection.get_chunked_uploader(file, file.stat.size)\n while uploader.offset < uploader.total_size\n with_retries do\n uploader.upload(1024**2 * chunk_size)\n end\n end\n end\n\n with_retries do\n uploader.finish(dest)\n end\n end\n rescue => err\n raise Error.wrap(err, \"Upload Failed!\")\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
When the workflow state of the record is :unretrieved, check the AWS S3 bucket to determine whether the submission has finally been picked up by the member repository and removed from the queue. If so, then advance the workflow state.
def wf_check_retrieved sid = record.submission_id data = aws_api.list_records(record).values_at(sid).flatten # Advance workflow state if the test passes. done = data.blank? advance! if done # Return status. sub = "submission #{sid.inspect}" repo = Upload.repository_name(record) if done "#{repo} is now processing #{sub}" else "#{sub} has not yet been retrieved by #{repo}" end end
[ "def on_purged_entry(state, event, *event_args)\n super\n\n __debug_sim('The submission entry is being purged.')\n\n __debug_sim('Shrine cache item is being removed from AWS S3.')\n # TODO: remove Shrine cache item from AWS S3.\n\n __debug_sim('Database entry is being removed.')\n # TODO: delete 'upload' table record, OR mark as purged:\n #set_workflow_phase(:purge) # TODO: what record?\n\n halt\n self\n end", "def on_purged_entry(state, event, *event_args)\n super\n\n __debug_sim('The submission entry is being purged.')\n\n __debug_sim('Shrine cache item is being removed from AWS S3.')\n # TODO: remove Shrine cache item from AWS S3.\n\n __debug_sim('Database entry is being removed.')\n # TODO: delete 'upload' table record, OR mark as purged:\n set_workflow_phase(:purge)\n\n halt\n self\n end", "def on_unretrieved_entry(state, event, *event_args)\n super\n\n if simulating\n\n task = RetrievalTask\n\n unless event == :timeout\n __debug_sim(\"Start #{task} to check for the submission.\")\n task.start\n end\n\n if task.check\n __debug_sim(\"The #{task} is checking...\")\n timeout! # NOTE: => :unretrieved\n\n elsif task.success\n __debug_sim(\"The #{task} has detected the submission.\")\n advance! # NOTE: => :retrieved\n\n else\n __debug_sim(\"The #{task} still has NOT detected the submission.\")\n __debug_sim('SYSTEM notifies the user of submission status.')\n __debug_sim('SYSTEM notifies an agent of the member repository.')\n if task.restart\n __debug_sim(\"The #{task} is restarting.\")\n timeout! # NOTE: => :unretrieved\n else\n __debug_sim(\"The #{task} is terminated.\")\n fail! # NOTE: => :failed\n end\n end\n\n end\n\n unless simulating\n advance! # NOTE: => :retrieved\n end\n\n self\n end", "def skip\n param 'state' => Patriot::JobStore::JobState::SUCCEEDED\n end", "def failed!\n sync_record.successful = false\n skip_purge!\n end", "def abort\n !!client.bucket_abort_multipart(upload_id, key)\n end", "def step_unschedule\n\n loop do\n\n break if @unschedule_queue.empty?\n\n do_unschedule(@unschedule_queue.pop)\n end\n end", "def unsubmit(_ = nil)\n # Skip the state validation in answers.\n @unsubmitting = true\n\n unsubmit_latest_answers\n self.points_awarded = nil\n end", "def reap\n if stateinfo['status'] == 'finished'\n File.unlink(state_file)\n 'success'\n else\n 'failed'\n end\n end", "def successful_upload_attempt(destination_path)\r\n # Loop through each active upload for the destination folder url\r\n if @upload_queue.has_key?(destination_path)\r\n # Loop through each file for this destination folder\r\n @upload_queue[destination_path].each_pair do |source_file_path, value|\r\n # If the file was actively being uploaded then remove it\r\n if @upload_queue[destination_path][source_file_path]['active']\r\n remove_source_from_queue(destination_path, source_file_path)\r\n end\r\n end \r\n end\r\n end", "def dequeue_proposal_no_lock(bc, inst)\n logger.debug(\"dequeue_proposal_no_lock: enter for #{bc}:#{inst}\")\n begin\n # Find the proposal to delete, get its elements (nodes)\n item = ProposalQueue.find_by(barclamp: bc, name: inst)\n\n if item\n logger.debug(\"dequeue_proposal_no_lock: found queued item for #{bc}:#{inst}; removing\")\n\n elements = item.properties[\"elements\"]\n item.destroy\n\n # Remove the pending roles for the current proposal from the node records.\n remove_pending_elements(bc, inst, elements) if elements\n else\n logger.debug(\"dequeue_proposal_no_lock: item for #{bc}:#{inst} not in the queue\")\n end\n\n # Mark the proposal as not in the queue\n prop = Proposal.where(barclamp: bc, name: inst).first\n unless prop.nil?\n prop[\"deployment\"][bc][\"crowbar-queued\"] = false\n prop.save\n end\n rescue StandardError => e\n logger.error(\"Error dequeuing proposal for #{bc}:#{inst}: #{e.message} #{e.backtrace.join(\"\\n\")}\")\n logger.debug(\"dequeue proposal_no_lock: exit for #{bc}:#{inst}: error\")\n return false\n end\n logger.debug(\"dequeue proposal_no_lock: exit for #{bc}:#{inst}\")\n true\n end", "def set_retrieved!\n update!(last_step_completed: :retrieved)\n ::Client::Repl::BagUnpackJob.perform_later(self, staging_location)\n end", "def on_removed_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[remove_emma_items: #{submission.emma_item}]\")\n emma_items = submission.emma_item\n else\n emma_items = true\n end\n\n # Determine whether this is destined for a member repository.\n unless simulating\n emma_items = Upload.emma_native?(record) if record\n end\n\n ok = nil\n\n if simulating\n if emma_items\n # From UploadController#destroy:\n # @succeeded, @failed = bulk_upload_remove(items)\n __debug_sim('CODE') do\n args = \"items=#{submission.items.inspect}\"\n opt = 'index: false'\n \"@succeeded, @failed = bulk_upload_remove(#{args}, #{opt})\"\n end\n self.succeeded += submission.items\n ok = ready?\n else\n ok = true # TODO: Simulate member repository delete request?\n end\n end\n\n unless simulating\n wf_remove_items(*event_args)\n ok = ready?\n end\n\n # TODO: simulation - remove\n __debug_sim do\n if !emma_items; 'Generating removal request for member repository items.'\n elsif !ok; 'The EMMA-native items NOT removed due to failure(s).'\n else; 'The EMMA-native items were removed.'; end\n end\n\n # Automatically transition to the next state based on submission status.\n if ok\n advance! # NOTE: => :staging\n else\n fail! # NOTE: => :failed\n end\n self\n end", "def undone!\n self.done = false\n end", "def failed!\n @resultant = :\"#u\"\n\n # Remove all items until most recent backtrack point.\n until move_queue.empty? ||\n (last_move.kind_of?(Bookmark) && last_move.kind == :bt_point)\n dequeue_item\n end\n end", "def erase_job_if_not_needed\n self.job = nil if not job_required?\n end", "def unfetch(track_provider)\n if @queue[0] && @queue[1] && @queue[1].owner == track_provider\n Trace.ppq(\"player unfetched by #{track_provider.class.name}\".red)\n @queue.slice!(1, PREFETCH_SIZE) # Remove all entries after the first one\n debug_queue if Cfg.trace_gstqueue\n end\n end", "def perform\n page_ref.ensure_attributes\n # Do we really want to fail/relaunch if the PageRef fails? Shouldn't that depend on the results?\n=begin\n if page_ref.bad?\n err_msg = \"Page at '#{page_ref.url}' can't be gleaned: PageRef ##{page_ref.id} sez:\\n#{page_ref.error_message}\"\n errors.add :url, err_msg\n raise err_msg if page_ref.dj # PageRef is ready to try again => so should we be, so restart via Delayed::Job\n end\n=end\n super if defined?(super)\n end", "def process_queue_item #:nodoc:\n return false if @queue.empty?\n\n # Even though we just asked if the queue was empty, it\n # still could have had an item which by this statement\n # is now gone. For this reason we pass true to Queue#deq\n # because we will sleep indefinitely if it is empty.\n promise = @queue.deq(true)\n stat :dequeued, item_id: promise.object_id\n promise.work\n return true\n\n rescue ThreadError # this means the queue is empty\n false\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
When the workflow state of the record is :indexing, check to determine whether index has finally received the update from the member repository. If so then advance the workflow state.
def wf_check_indexed sid = record.submission_id rid = record.emma_metadata[:emma_recordId] data = ingest_api.get_records(rid) # Advance workflow state if the test passes. done = data.present? advance! if done # Return status. sub = "submission #{sid.inspect}" sub = "#{Upload.repository_name(record)} #{sub}" unless record.emma_native? if done "the index service is now processing #{sub}" else "#{sub} has not yet been included in the index" end end
[ "def wf_index_update(*_event_args)\n __debug_items(binding)\n if succeeded.blank?\n self.failures << \"#{__method__}: NO ENTRIES - INTERNAL WORKFLOW ERROR\"\n elsif DEFER_INDEXING\n s, f, _ = bulk_update_in_index(*succeeded)\n self.succeeded = s\n self.failures += f\n end\n end", "def on_indexed_entry(state, event, *event_args)\n super\n wf_set_records_state\n\n __debug_sim('SYSTEM notifies the user that the submission is complete.')\n\n advance! # NOTE: => :completed\n self\n end", "def index(index, instance = nil)\n return true if skip?(instance)\n ThinkingSphinx::Deltas::SidekiqDelta::DeltaJob.perform_async(index.name) unless self.class.locked?(index.name)\n # if instance\n # model.core_index_names.each do |core|\n # FlagAsDeletedSet.add(core, instance.sphinx_document_id)\n # end\n # end\n true\n end", "def after_commit_update_work_index_if_needed\n return unless (\n self.saved_change_to_attribute?(:ohms_xml_text) ||\n self.saved_change_to_attribute?(:searchable_transcript_source)\n )\n return unless work && Kithe::Indexable.auto_callbacks?(work)\n\n work.update_index\n end", "def on_retrieved_entry(state, event, *event_args)\n super\n\n __debug_sim('The submission has been received by the member repository.')\n __debug_sim('SYSTEM ensures the staging area is consistent.')\n\n advance! # NOTE: => :indexing\n self\n end", "def search_index_update_touch\n return true if ignore_search_indexing?(:update)\n\n # start background job to transfer data to search index\n return true if !SearchIndexBackend.enabled?\n\n SearchIndexJob.perform_later(self.class.to_s, id)\n true\n end", "def update_needs_index?\n ENABLE_SOLR_UPDATES\n end", "def on_indexed_entry(state, event, *event_args)\n super\n\n __debug_sim('SYSTEM notifies the user that the submission is complete.')\n\n advance! # NOTE: => :completed\n self\n end", "def update_index\n return if skip_indexing?\n if self.class.update_index_policy == :immediate_with_refresh\n local_index_in_elastic_search(:refresh => true)\n elsif self.class.update_index_policy == :enqueue\n Resque.enqueue(DistributedIndexing::ReIndexDocuments, self.class.to_s, [self.id])\n else\n local_index_in_elastic_search\n end\n end", "def reindex\n return unless search_data.keys.detect { |key| send(\"#{key}_changed?\") }\n Rails.logger.debug \"User #{id} is gonna be re-indexed\"\n super\n end", "def update_index(*args)\n\n # This fixes bug https://github.com/sciencehistory/chf-sufia/issues/428 .\n # It updates the display_label property for each inscription associated with this work\n # before said display_label is indexed into SOLR's 'inscription_tesim' field.\n # That field, in turn, is what is shown on the individual work display page\n # as the inscription[s].\n self.inscription.map(&:compose_label)\n # end fix\n\n super.tap do\n if self.changes.keys.include?(\"representative_id\") ||\n self.previous_changes.keys.include?(\"representative_id\") ||\n (self.changes.blank? && self.previous_changes.blank?)\n GenericWork.where(GenericWork.reflections[:representative_id].solr_key => self.id).each do |parent_work|\n parent_work.update_index\n end\n end\n end\n end", "def should_be_in_index?\n # TODO, add a record should_index? method like searchkick\n # https://github.com/ankane/searchkick/blob/5d921bc3da69d6105cbc682ea3df6dce389b47dc/lib/searchkick/record_indexer.rb#L44\n !record.destroyed? && record.persisted?\n end", "def check_index_walk\n if first['index_walk']\n @cost = limit\n add_message(\"index_walk\")\n end\n end", "def should_reindex_parent_after_save?(indexed_attributes: [:transcription, :english_translation])\n if parent.nil?\n return false\n elsif self.destroyed?\n # if we were destroyed with indexed_attributes present, parent needs to be re-indexed\n # to remove us from index.\n indexed_attributes.any? { |attr| self.send(attr).present? }\n elsif self.saved_change_to_published?\n # if published status changed, we have to reindex if and only if we HAVE any indexed attributes,\n # to include them in index.\n indexed_attributes.any? { |attr| self.send(attr).present? }\n else\n # an ordinary save (including create), did any attributes of interest CHANGE? (Including removal)\n # then we need to reindex parent to get them updated in index.\n indexed_attributes.any? { |attr| self.saved_change_to_attribute(attr).present? }\n end\n end", "def wf_check_retrieved\n sid = record.submission_id\n data = aws_api.list_records(record).values_at(sid).flatten\n\n # Advance workflow state if the test passes.\n done = data.blank?\n advance! if done\n\n # Return status.\n sub = \"submission #{sid.inspect}\"\n repo = Upload.repository_name(record)\n if done\n \"#{repo} is now processing #{sub}\"\n else\n \"#{sub} has not yet been retrieved by #{repo}\"\n end\n end", "def is_indexed?\n props['precommit'].include?(SEARCH_PRECOMMIT_HOOK)\n end", "def before_update\n\t\tif self.is_index == true\n\t\t\tpage = Page.find(:first, :conditions => [\"is_index = ?\",1])\n\t\t\tpage.update_attributes(:is_index => 0) if page\n\t\tend\n\tend", "def index(model, instance = nil)\n return true if skip? instance\n\n self.class.enqueue(\n FlyingSphinx::IndexRequest.new(model.delta_index_names, true),\n delayed_job_priority\n )\n\n self.class.enqueue_without_duplicates_check(\n FlyingSphinx::FlagAsDeletedJob.new(\n model.core_index_names, instance.sphinx_document_id\n ),\n delayed_job_priority\n ) if instance\n\n true\n end", "def update_needs_index?\n ActiveFedora.enable_solr_updates?\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Upon entering the :scheduling state: The submission is being scheduled for review.
def on_scheduling_entry(state, event, *event_args) super # TODO: simulation - remove if simulating __debug_sim("[auto_review: #{submission.auto_review}]") auto_review = submission.auto_review else auto_review = false end # Determine whether the system should perform an automated review. unless simulating auto_review = record.auto_reviewable? end # TODO: simulation - remove if auto_review __debug_sim('SYSTEM will perform an automated review.') else __debug_sim('SYSTEM will determine a pool of reviewer(s).') end # Automatically transition to the next state based on submission status. if auto_review assign! # NOTE: => :assigned else advance! # NOTE: => :assigning end self end
[ "def on_reviewing_entry(state, event, *event_args)\n super\n\n if !simulating || !submission.auto_review\n __debug_sim('[auto_review: false]') if simulating\n __debug_sim('Waiting for reviewer evaluation.')\n __debug_sim('REVIEWER must `approve!` or `reject!` to advance...')\n\n elsif submission.auto_approve # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_approve: true]')\n __debug_sim('SYSTEM review approves the submission.')\n\n approve! # NOTE: => :approved\n\n elsif submission.auto_reject # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_reject: true]')\n __debug_sim('SYSTEM review rejects the submission.')\n\n reject! # NOTE: => :rejected\n\n else # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_approve: false]')\n __debug_sim('[auto_reject: false]')\n __debug_sim('SYSTEM must `approve!` or `reject!` to advance...')\n\n end\n\n self\n end", "def on_submitted_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[no_review: #{submission.no_review}]\")\n must_review = !submission.no_review\n else\n must_review = true\n end\n\n # Determine whether the item needs to be reviewed.\n unless simulating\n must_review = record.review_required? if record\n end\n\n # TODO: simulation - remove\n if must_review\n __debug_sim('This item requires review.')\n else\n __debug_sim('This item can be submitted without review.')\n end\n\n # Automatically transition to the next state based on submission status.\n if must_review\n schedule! # NOTE: => :scheduling\n else\n advance! # NOTE: => :staging\n end\n self\n end", "def on_assigned_entry(state, event, *event_args)\n super\n\n # Determine whether the system should perform an automated review.\n auto_review = false # TODO: auto-review?\n\n # Determine whether the system should perform an automated review.\n if simulating\n __debug_sim(\"[auto_review: #{submission.auto_review}]\")\n auto_review = submission.auto_review # TODO: remove\n end\n\n # Determine whether the system should perform an automated review.\n unless simulating\n auto_review = record.auto_reviewable? if record\n end\n\n # TODO: simulation - remove\n if auto_review\n __debug_sim('SYSTEM is performing an automated review.')\n else\n __debug_sim('Waiting for reviewer to begin review.')\n __debug_sim('REVIEWER must `review!` to advance...')\n end\n\n # If the submission is to be reviewed by a human then it remains in this\n # state until a review claims it (i.e. starts a review).\n review! if auto_review # NOTE: => :reviewing\n\n self\n end", "def scheduled?\n @current_state == Psc::ScheduledActivity::SCHEDULED\n end", "def closed_submission_status\n 'Closed for Review'\n end", "def on_assigning_entry(state, event, *event_args)\n super\n\n # Determine availability of appropriate reviewer(s).\n if simulating\n __debug_sim(\"[no_reviewers: #{submission.no_reviewers}]\")\n can_proceed = !submission.no_reviewers\n else\n can_proceed = true\n end\n\n # TODO: simulation - remove\n if can_proceed\n __debug_sim('SYSTEM notifies the pool of available reviewer(s).')\n else\n __debug_sim('SYSTEM determined there are no reviewers available.')\n end\n\n # Automatically transition to the next state based on submission status.\n if can_proceed\n advance! # NOTE: => :assigned\n else\n hold! # NOTE: => :holding\n end\n self\n end", "def assignment_submitted\n\t\t\t\tif !@hit_id.nil? && !@assignment_id.nil?\n\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] AssignmentSubmitted\"\n\n\t\t\t\t\t# Look up the HIT\n\t\t\t\t\t@hit = RTurk::Hit.find(@hit_id)\n\n\t\t\t\t\t# Parse the JSON stored in annotation\n\t\t\t\t\tbegin\n\t\t\t\t\t\tannotation = JSON.parse(@hit.annotation)\n\t\t\t\t\trescue JSON::ParserError\n\t\t\t\t\t\tannotation = {}\n\t\t\t\t\tend\n\n\t\t\t\t\tretries = 0\n\n\t\t\t\t\tbegin\n\t\t\t\t\t\t# Get the item we're operating on.\n\t\t\t\t\t\titem = ::DataObject.get(annotation[\"item_id\"])\n\t\t\t\t\t\titem.turk_events ||= {}\n\t\t\t\t\t\titem.turk_events[\"assignment_submitted\"] ||= {}\n\n\t\t\t\t\t\t# Check if we have already worked on this item.\n\t\t\t\t\t\tif !item.turk_events[\"assignment_submitted\"][@assignment_id].nil?\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] Not processing - event already processed for Assignment ID #{@assignment_id}\"\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# Mark event as processed.\n\t\t\t\t\t\titem.turk_events[\"assignment_submitted\"][@assignment_id] = Time.new.getutc.iso8601\n\t\t\t\t\t\titem.save\n\t\t\t\t\trescue RestClient::Conflict\n\t\t\t\t\t\t# We had a conflict. See assignment accepted for explanation.\n\n\t\t\t\t\t\tif retries < 10\n\t\t\t\t\t\t\tretries += 1\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - retry #{retries}\"\n\t\t\t\t\t\t\tretry\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - giving up\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def confirm_reschedule\n reschedule = ApptRescheduler.new(@appt.id, params).format_new_time\n if reschedule[:success] == true\n @new_start_time = reschedule[:new_start_time]\n @new_slot_id = reschedule[:new_slot_id]\n end\n render layout: '../dashboard/student/home/confirm_reschedule'\n end", "def on_modified_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[edit_no_review: #{submission.no_review}]\")\n must_review = !submission.no_review\n else\n must_review = true\n end\n\n # Determine whether the item needs to be reviewed.\n unless simulating\n must_review = record.review_required? if record\n end\n\n # TODO: simulation - remove\n if must_review\n __debug_sim('This item requires review.')\n else\n __debug_sim('This item can be submitted without review.')\n end\n\n # Automatically transition to the next state based on submission status.\n if must_review\n schedule! # NOTE: => :scheduling\n else\n advance! # NOTE: => :staging\n end\n self\n end", "def update_scheduled_status\n self._scheduled = !self.user_id.blank? && !self.milestone_id.blank? && !self.priority.blank?\n true\n end", "def check_submission_time\r\n\r\n @last_change = newest_change\r\n @output.puts \"Latest change: #{@last_change.strftime(\"%a %b %d %Y %I:%M%p\")}\"\r\n if @config[\"due\"]\r\n due = DateTime.parse( @config[\"due\"] )\r\n @output.puts \"Submitted #{@last_change <= due ? \"ON TIME\".green : \"LATE\".red}\"\r\n end\r\n end", "def submitted?\n assignment_status_match?('Submitted')\n end", "def submit!\n if requires_approval?\n @staff_template = EmailTemplate.find_by_name(APPROVAL_REQUEST_EMAIL_TEMPLATE)\n @student_template = EmailTemplate.find_by_name(AWAITING_APPROVAL_EMAIL_TEMPLATE)\n else\n @staff_template = EmailTemplate.find_by_name(NO_APPROVAL_NEEDED_STAFF_EMAIL_TEMPLATE)\n @student_template = EmailTemplate.find_by_name(NO_APPROVAL_NEEDED_EMAIL_TEMPLATE)\n end \n send_staff_email!(@staff_template) if @staff_template && !staff?\n send_student_email!(@student_template) if @student_template\n \n self.update_attribute(:submitted, true)\n end", "def schedule_next_review\n self.next.save! if just_reviewed?\n end", "def review_requested?\n github_event == 'review_requested'\n end", "def submitForApproval(period=nil, comment='', name=@username)\n if period.nil? then\n # First day of work week\n cur = currentApprovalStatus(nil, name)\n period = cur.access 'period.dateFrom'\n end\n verbose \"Submitting timesheet for #{period}\"\n post('timesheet-approval/', {\n :user=>{\n :name=>name,\n },\n :period=>{\n :dateFrom=>period,\n },\n :action=>{\n :name=>:submit,\n :comment=>comment,\n }\n }) unless $cfg['tool.dry']\n end", "def is_scheduling_enabled\n return @is_scheduling_enabled\n end", "def scheduled?(resource)\n self.ignoreschedules or resource.scheduled?\n end", "def submit_now\n self.submitted = DateTime.now\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Upon entering the :assigning state: The submission is being assigned for review.
def on_assigning_entry(state, event, *event_args) super # Determine availability of appropriate reviewer(s). if simulating __debug_sim("[no_reviewers: #{submission.no_reviewers}]") can_proceed = !submission.no_reviewers else can_proceed = true end # TODO: simulation - remove if can_proceed __debug_sim('SYSTEM notifies the pool of available reviewer(s).') else __debug_sim('SYSTEM determined there are no reviewers available.') end # Automatically transition to the next state based on submission status. if can_proceed advance! # NOTE: => :assigned else hold! # NOTE: => :holding end self end
[ "def review\n return access_denied unless @course.has_teacher(current_user) || @submission.group.has_reviewer?(current_user) || (@exercise.collaborative_mode == 'review' && (@course_instance.has_student(current_user) || @course_instance.has_assistant(current_user)))\n\n review = @submission.assign_to(current_user)\n\n redirect_to edit_review_path(review)\n log \"create_review #{@submission.id},#{@exercise.id}\"\n end", "def on_assigned_entry(state, event, *event_args)\n super\n\n # Determine whether the system should perform an automated review.\n auto_review = false # TODO: auto-review?\n\n # Determine whether the system should perform an automated review.\n if simulating\n __debug_sim(\"[auto_review: #{submission.auto_review}]\")\n auto_review = submission.auto_review # TODO: remove\n end\n\n # Determine whether the system should perform an automated review.\n unless simulating\n auto_review = record.auto_reviewable? if record\n end\n\n # TODO: simulation - remove\n if auto_review\n __debug_sim('SYSTEM is performing an automated review.')\n else\n __debug_sim('Waiting for reviewer to begin review.')\n __debug_sim('REVIEWER must `review!` to advance...')\n end\n\n # If the submission is to be reviewed by a human then it remains in this\n # state until a review claims it (i.e. starts a review).\n review! if auto_review # NOTE: => :reviewing\n\n self\n end", "def assign_to(user)\n user = User.find(user) unless user.is_a?(User)\n options = {:user => user, :submission => self}\n \n if ['annotation', 'exam'].include?(self.exercise.review_mode) && self.annotatable?\n review = AnnotationAssessment.new(options)\n else\n review = Review.new(options)\n end\n \n review.save\n\n return review\n end", "def assignment_submitted\n\t\t\t\tif !@hit_id.nil? && !@assignment_id.nil?\n\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] AssignmentSubmitted\"\n\n\t\t\t\t\t# Look up the HIT\n\t\t\t\t\t@hit = RTurk::Hit.find(@hit_id)\n\n\t\t\t\t\t# Parse the JSON stored in annotation\n\t\t\t\t\tbegin\n\t\t\t\t\t\tannotation = JSON.parse(@hit.annotation)\n\t\t\t\t\trescue JSON::ParserError\n\t\t\t\t\t\tannotation = {}\n\t\t\t\t\tend\n\n\t\t\t\t\tretries = 0\n\n\t\t\t\t\tbegin\n\t\t\t\t\t\t# Get the item we're operating on.\n\t\t\t\t\t\titem = ::DataObject.get(annotation[\"item_id\"])\n\t\t\t\t\t\titem.turk_events ||= {}\n\t\t\t\t\t\titem.turk_events[\"assignment_submitted\"] ||= {}\n\n\t\t\t\t\t\t# Check if we have already worked on this item.\n\t\t\t\t\t\tif !item.turk_events[\"assignment_submitted\"][@assignment_id].nil?\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] Not processing - event already processed for Assignment ID #{@assignment_id}\"\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# Mark event as processed.\n\t\t\t\t\t\titem.turk_events[\"assignment_submitted\"][@assignment_id] = Time.new.getutc.iso8601\n\t\t\t\t\t\titem.save\n\t\t\t\t\trescue RestClient::Conflict\n\t\t\t\t\t\t# We had a conflict. See assignment accepted for explanation.\n\n\t\t\t\t\t\tif retries < 10\n\t\t\t\t\t\t\tretries += 1\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - retry #{retries}\"\n\t\t\t\t\t\t\tretry\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - giving up\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def on_reviewing_entry(state, event, *event_args)\n super\n\n if !simulating || !submission.auto_review\n __debug_sim('[auto_review: false]') if simulating\n __debug_sim('Waiting for reviewer evaluation.')\n __debug_sim('REVIEWER must `approve!` or `reject!` to advance...')\n\n elsif submission.auto_approve # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_approve: true]')\n __debug_sim('SYSTEM review approves the submission.')\n\n approve! # NOTE: => :approved\n\n elsif submission.auto_reject # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_reject: true]')\n __debug_sim('SYSTEM review rejects the submission.')\n\n reject! # NOTE: => :rejected\n\n else # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_approve: false]')\n __debug_sim('[auto_reject: false]')\n __debug_sim('SYSTEM must `approve!` or `reject!` to advance...')\n\n end\n\n self\n end", "def on_scheduling_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[auto_review: #{submission.auto_review}]\")\n auto_review = submission.auto_review\n else\n auto_review = false\n end\n\n # Determine whether the system should perform an automated review.\n unless simulating\n auto_review = record.auto_reviewable?\n end\n\n # TODO: simulation - remove\n if auto_review\n __debug_sim('SYSTEM will perform an automated review.')\n else\n __debug_sim('SYSTEM will determine a pool of reviewer(s).')\n end\n\n # Automatically transition to the next state based on submission status.\n if auto_review\n assign! # NOTE: => :assigned\n else\n advance! # NOTE: => :assigning\n end\n self\n end", "def assignment_accepted\n\t\t\t\tif !@hit_id.nil? && !@assignment_id.nil?\n\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] AssignmentAccepted\"\n\n\t\t\t\t\t# Look up the HIT\n\t\t\t\t\t@hit = RTurk::Hit.find(@hit_id)\n\n\t\t\t\t\t# Parse the JSON stored in annotation\n\t\t\t\t\tbegin\n\t\t\t\t\t\tannotation = JSON.parse(@hit.annotation)\n\t\t\t\t\trescue JSON::ParserError\n\t\t\t\t\t\tannotation = {}\n\t\t\t\t\tend\n\n\t\t\t\t\tretries = 0\n\n\t\t\t\t\tbegin\n\t\t\t\t\t\t# Get the item we're operating on.\n\t\t\t\t\t\titem = ::DataObject.get(annotation[\"item_id\"])\n\t\t\t\t\t\titem.turk_events ||= {}\n\t\t\t\t\t\titem.turk_events[\"assignment_accepted\"] ||= {}\n\n\t\t\t\t\t\t# Check if we have already worked on this item.\n\t\t\t\t\t\tif !item.turk_events[\"assignment_accepted\"][@assignment_id].nil?\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] Not processing - event already processed for Assignment ID #{@assignment_id}\"\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# Mark event as processed.\n\t\t\t\t\t\titem.turk_events[\"assignment_accepted\"][@assignment_id] = Time.new.getutc.iso8601\n\t\t\t\t\t\titem.save\n\t\t\t\t\trescue RestClient::Conflict\n\t\t\t\t\t\t# We had a conflict when saving the item. Let's retry until we are able to save without a conflict.\n\t\t\t\t\t\t# This could cause an infinite loop, so we don't retry after a certain number of retries.\n\n\t\t\t\t\t\tif retries < 10\n\t\t\t\t\t\t\tretries += 1\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - retry #{retries}\"\n\t\t\t\t\t\t\tretry\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - giving up\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def submitted?\n assignment_status_match?('Submitted')\n end", "def on_submitted_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[no_review: #{submission.no_review}]\")\n must_review = !submission.no_review\n else\n must_review = true\n end\n\n # Determine whether the item needs to be reviewed.\n unless simulating\n must_review = record.review_required? if record\n end\n\n # TODO: simulation - remove\n if must_review\n __debug_sim('This item requires review.')\n else\n __debug_sim('This item can be submitted without review.')\n end\n\n # Automatically transition to the next state based on submission status.\n if must_review\n schedule! # NOTE: => :scheduling\n else\n advance! # NOTE: => :staging\n end\n self\n end", "def approved?\n assignment_status_match?('Approved')\n end", "def ready_for_submission?\n self.all_reviewers_assigned? && \n self.all_manager_reviewers_assigned? &&\n self.design_data_filled_in?\n end", "def on_assigned_exit(state, event, *event_args)\n super\n\n unless event == :review\n changed = 'withdrawn'\n changed += ' pending edits' unless event == :cancel\n __debug_sim(\"Reviewer(s) notified the submission was #{changed}.\")\n end\n\n self\n end", "def is_assigned\n return @is_assigned\n end", "def approve\n update_attribute :needs_review, false\n end", "def has_peer_review_assignment?\n !pr_assignment.nil?\n end", "def update_review_assignments\n\n design_review_id = params[:id]\n new_reviewers = params[:user]\n design_review = DesignReview.find(design_review_id)\n designer = User.find(design_review.designer_id)\n flash_msg = ''\n\n if new_reviewers\n # Reassign the review to the new reviewer\n new_reviewers.each { |role_name, user_id|\n next if user_id == '' || user_id == '0'\n role = Role.find_by_name(role_name)\n design_review_result = DesignReviewResult.find(\n :first,\n :conditions => \"design_review_id='#{design_review_id}' and \" +\n \"reviewer_id='#{@logged_in_user.id}' and \" +\n \"role_id='#{role.id}'\")\n\n if design_review_result\n is_reviewer = @logged_in_user.id == design_review_result.reviewer_id\n design_review_result.reviewer_id = user_id\n design_review_result.save\n peer = User.find(user_id)\n new_reviewer = peer.name\n\n design_review.record_update(role.display_name,\n @logged_in_user.name,\n peer.name,\n @logged_in_user)\n \n if flash_msg == ''\n flash_msg = \"#{new_reviewer} is assigned to the #{role.display_name} review\"\n else\n flash_msg += \" and #{new_reviewer} is assigned to the #{role.display_name} review\"\n end\n\n if is_reviewer\n Mailer::reassign_design_review_to_peer(\n @logged_in_user, peer, designer, design_review, role).deliver\n end\n end\n }\n end\n\n # Check to see if any \"assign_to_self\" box is check.\n params.each { |key, value|\n\n next if not key.include?(\"assign_to_self\")\n next if value[@logged_in_user.id.to_s] == 'no'\n\n role = Role.find(key.split('_')[1])\n design_review_result = DesignReviewResult.find(:first,\n :conditions => \"design_review_id='#{design_review_id}' and\" +\n \" role_id='#{role.id}'\")\n\n if design_review_result\n peer = User.find(design_review_result.reviewer_id)\n design_review_result.reviewer_id = @logged_in_user.id\n design_review_result.save\n \n design_review.record_update(role.display_name,\n peer.name,\n @logged_in_user.name,\n @logged_in_user)\n\n new_reviewer = @logged_in_user.name\n if flash_msg == ''\n flash_msg = \"You are assigned to the #{role.display_name} review\"\n else\n flash_msg += \" and you are assigned to the #{role.display_name} review\"\n end\n\n DesignReviewMailer::reassign_design_review_from_peer(\n @logged_in_user, peer, designer, design_review, role).deliver\n end\n\n }\n\n if flash_msg != ''\n flash['notice'] = flash_msg + ' - mail was sent'\n else\n flash['notice'] = 'Nothing selected - no assignments were made'\n end\n\n redirect_to(:action => :view, :id => design_review_id)\n\nend", "def start_self_review\n user_id = params[:reviewer_userid]\n assignment = Assignment.find(params[:assignment_id])\n team = Team.find_team_for_assignment_and_user(assignment.id, user_id).first\n begin\n # ACS Removed the if condition(and corresponding else) which differentiate assignments as team and individual assignments\n # to treat all assignments as team assignments\n if SelfReviewResponseMap.where(reviewee_id: team.id, reviewer_id: params[:reviewer_id]).first.nil?\n SelfReviewResponseMap.create(reviewee_id: team.id,\n reviewer_id: params[:reviewer_id],\n reviewed_object_id: assignment.id)\n else\n raise 'Self review already assigned!'\n end\n redirect_to controller: 'submitted_content', action: 'edit', id: params[:reviewer_id]\n rescue StandardError => e\n redirect_to controller: 'submitted_content', action: 'edit', id: params[:reviewer_id], msg: e.message\n end\n end", "def is_assigned=(value)\n @is_assigned = value\n end", "def assign\n verify_post_request\n require_parameters :issue\n\n result = Internal.issues.assign(params[:issue], params[:assignee])\n render_result_issue(result)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Upon entering the :holding state: The system is waiting for a reviewer (or the review process is paused). The submission will remain in this state until the reviewer's action causes the state to advance.
def on_holding_entry(state, event, *event_args) super if simulating task = ReviewerTask if event == :hold __debug_sim("Start #{task} to check for an available reviewer.") task.start end if task.check __debug_sim("The #{task} is checking...") timeout! # NOTE: => :holding elsif task.success __debug_sim("The #{task} has found a reviewer.") advance! # NOTE: => :assigning else __debug_sim("The #{task} still has NOT found a reviewer.") __debug_sim('SYSTEM notifies the user of submission status.') __debug_sim('SYSTEM notifies administrator of possible problem.') if task.restart __debug_sim("The #{task} is restarting.") timeout! # NOTE: => :holding else __debug_sim("The #{task} is terminated.") fail! # NOTE: => :failed end end end self end
[ "def on_assigning_entry(state, event, *event_args)\n super\n\n # Determine availability of appropriate reviewer(s).\n if simulating\n __debug_sim(\"[no_reviewers: #{submission.no_reviewers}]\")\n can_proceed = !submission.no_reviewers\n else\n can_proceed = true\n end\n\n # TODO: simulation - remove\n if can_proceed\n __debug_sim('SYSTEM notifies the pool of available reviewer(s).')\n else\n __debug_sim('SYSTEM determined there are no reviewers available.')\n end\n\n # Automatically transition to the next state based on submission status.\n if can_proceed\n advance! # NOTE: => :assigned\n else\n hold! # NOTE: => :holding\n end\n self\n end", "def on_submitted_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[no_review: #{submission.no_review}]\")\n must_review = !submission.no_review\n else\n must_review = true\n end\n\n # Determine whether the item needs to be reviewed.\n unless simulating\n must_review = record.review_required? if record\n end\n\n # TODO: simulation - remove\n if must_review\n __debug_sim('This item requires review.')\n else\n __debug_sim('This item can be submitted without review.')\n end\n\n # Automatically transition to the next state based on submission status.\n if must_review\n schedule! # NOTE: => :scheduling\n else\n advance! # NOTE: => :staging\n end\n self\n end", "def on_assigned_exit(state, event, *event_args)\n super\n\n unless event == :review\n changed = 'withdrawn'\n changed += ' pending edits' unless event == :cancel\n __debug_sim(\"Reviewer(s) notified the submission was #{changed}.\")\n end\n\n self\n end", "def on_reviewing_entry(state, event, *event_args)\n super\n\n if !simulating || !submission.auto_review\n __debug_sim('[auto_review: false]') if simulating\n __debug_sim('Waiting for reviewer evaluation.')\n __debug_sim('REVIEWER must `approve!` or `reject!` to advance...')\n\n elsif submission.auto_approve # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_approve: true]')\n __debug_sim('SYSTEM review approves the submission.')\n\n approve! # NOTE: => :approved\n\n elsif submission.auto_reject # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_reject: true]')\n __debug_sim('SYSTEM review rejects the submission.')\n\n reject! # NOTE: => :rejected\n\n else # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_approve: false]')\n __debug_sim('[auto_reject: false]')\n __debug_sim('SYSTEM must `approve!` or `reject!` to advance...')\n\n end\n\n self\n end", "def on_assigned_entry(state, event, *event_args)\n super\n\n # Determine whether the system should perform an automated review.\n auto_review = false # TODO: auto-review?\n\n # Determine whether the system should perform an automated review.\n if simulating\n __debug_sim(\"[auto_review: #{submission.auto_review}]\")\n auto_review = submission.auto_review # TODO: remove\n end\n\n # Determine whether the system should perform an automated review.\n unless simulating\n auto_review = record.auto_reviewable? if record\n end\n\n # TODO: simulation - remove\n if auto_review\n __debug_sim('SYSTEM is performing an automated review.')\n else\n __debug_sim('Waiting for reviewer to begin review.')\n __debug_sim('REVIEWER must `review!` to advance...')\n end\n\n # If the submission is to be reviewed by a human then it remains in this\n # state until a review claims it (i.e. starts a review).\n review! if auto_review # NOTE: => :reviewing\n\n self\n end", "def releasable?; review_state? :ready; end", "def on_scheduling_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[auto_review: #{submission.auto_review}]\")\n auto_review = submission.auto_review\n else\n auto_review = false\n end\n\n # Determine whether the system should perform an automated review.\n unless simulating\n auto_review = record.auto_reviewable?\n end\n\n # TODO: simulation - remove\n if auto_review\n __debug_sim('SYSTEM will perform an automated review.')\n else\n __debug_sim('SYSTEM will determine a pool of reviewer(s).')\n end\n\n # Automatically transition to the next state based on submission status.\n if auto_review\n assign! # NOTE: => :assigned\n else\n advance! # NOTE: => :assigning\n end\n self\n end", "def review_locked?\n (self.review_type.name == \"Final\" && \n (!(self.design.audit.skip? || self.design.audit.auditor_complete?) ||\n !self.design.work_assignments_complete?))\n end", "def place_on_hold(current_time = Time.now)\n self.review_status = ReviewStatus.find(:first, \n :conditions => \"name='Review On-Hold'\")\n self.placed_on_hold_on = current_time\n self.save\n end", "def object_lock_legal_hold_status; end", "def put_on_hold\n self.status = ON_HOLD\n end", "def on_modified_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[edit_no_review: #{submission.no_review}]\")\n must_review = !submission.no_review\n else\n must_review = true\n end\n\n # Determine whether the item needs to be reviewed.\n unless simulating\n must_review = record.review_required? if record\n end\n\n # TODO: simulation - remove\n if must_review\n __debug_sim('This item requires review.')\n else\n __debug_sim('This item can be submitted without review.')\n end\n\n # Automatically transition to the next state based on submission status.\n if must_review\n schedule! # NOTE: => :scheduling\n else\n advance! # NOTE: => :staging\n end\n self\n end", "def review(*)\n super.tap do\n __debug_sim('REVIEWER initiates review of the submission.')\n end\n end", "def waiting=(_); end", "def cancel_hold\n if self.status == 'Held'\n create_delivery('HoldCancelled', :details => \"The hold on this validation has been removed without action.\")\n end\n end", "def can_hold?\n !on_hold? and _workflow.can_hold?(self)\n end", "def check_for_released\n if released_to_students && marking_state_changed?(to: Result::MARKING_STATES[:incomplete])\n errors.add(:base, I18n.t('results.marks_released'))\n throw(:abort)\n end\n true\n end", "def check_rating_run\n raise Error.new(\"rating run is not in waiting state\") unless @rating_run.status == \"waiting\"\n rivals = @rating_run.rivals\n raise Error.new(\"there are other unfinished runs (#{rivals.map(&:id).join(', ')})\") if rivals.count != 0\n end", "def update_for_awaiting_decisions\n if awaiting_decisions? && all_selections_have_college_offers?\n if all_selections_rejected?\n self.status = :all_rejected\n # We mark courses as skipped, meaning that a student choice was not asked for.\n CourseSelection.update_all_student_choices self, :skipped\n else\n # Waiting for student.\n self.status = :awaiting_replies\n self.replies_due = calculate_replies_due # Store the final replies due date.\n end\n\n self.save! validate: false\n\n StudentMailer.decisions_made(student, self).deliver_later\n StudentMessenger.new.decisions_made(student, self)\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Upon entering the :assigned state: The submission has been assigned for review.
def on_assigned_entry(state, event, *event_args) super # Determine whether the system should perform an automated review. auto_review = false # TODO: auto-review? # Determine whether the system should perform an automated review. if simulating __debug_sim("[auto_review: #{submission.auto_review}]") auto_review = submission.auto_review # TODO: remove end # Determine whether the system should perform an automated review. unless simulating auto_review = record.auto_reviewable? if record end # TODO: simulation - remove if auto_review __debug_sim('SYSTEM is performing an automated review.') else __debug_sim('Waiting for reviewer to begin review.') __debug_sim('REVIEWER must `review!` to advance...') end # If the submission is to be reviewed by a human then it remains in this # state until a review claims it (i.e. starts a review). review! if auto_review # NOTE: => :reviewing self end
[ "def on_assigning_entry(state, event, *event_args)\n super\n\n # Determine availability of appropriate reviewer(s).\n if simulating\n __debug_sim(\"[no_reviewers: #{submission.no_reviewers}]\")\n can_proceed = !submission.no_reviewers\n else\n can_proceed = true\n end\n\n # TODO: simulation - remove\n if can_proceed\n __debug_sim('SYSTEM notifies the pool of available reviewer(s).')\n else\n __debug_sim('SYSTEM determined there are no reviewers available.')\n end\n\n # Automatically transition to the next state based on submission status.\n if can_proceed\n advance! # NOTE: => :assigned\n else\n hold! # NOTE: => :holding\n end\n self\n end", "def is_assigned\n return @is_assigned\n end", "def review\n return access_denied unless @course.has_teacher(current_user) || @submission.group.has_reviewer?(current_user) || (@exercise.collaborative_mode == 'review' && (@course_instance.has_student(current_user) || @course_instance.has_assistant(current_user)))\n\n review = @submission.assign_to(current_user)\n\n redirect_to edit_review_path(review)\n log \"create_review #{@submission.id},#{@exercise.id}\"\n end", "def submitted?\n assignment_status_match?('Submitted')\n end", "def assignment_submitted\n\t\t\t\tif !@hit_id.nil? && !@assignment_id.nil?\n\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] AssignmentSubmitted\"\n\n\t\t\t\t\t# Look up the HIT\n\t\t\t\t\t@hit = RTurk::Hit.find(@hit_id)\n\n\t\t\t\t\t# Parse the JSON stored in annotation\n\t\t\t\t\tbegin\n\t\t\t\t\t\tannotation = JSON.parse(@hit.annotation)\n\t\t\t\t\trescue JSON::ParserError\n\t\t\t\t\t\tannotation = {}\n\t\t\t\t\tend\n\n\t\t\t\t\tretries = 0\n\n\t\t\t\t\tbegin\n\t\t\t\t\t\t# Get the item we're operating on.\n\t\t\t\t\t\titem = ::DataObject.get(annotation[\"item_id\"])\n\t\t\t\t\t\titem.turk_events ||= {}\n\t\t\t\t\t\titem.turk_events[\"assignment_submitted\"] ||= {}\n\n\t\t\t\t\t\t# Check if we have already worked on this item.\n\t\t\t\t\t\tif !item.turk_events[\"assignment_submitted\"][@assignment_id].nil?\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] Not processing - event already processed for Assignment ID #{@assignment_id}\"\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# Mark event as processed.\n\t\t\t\t\t\titem.turk_events[\"assignment_submitted\"][@assignment_id] = Time.new.getutc.iso8601\n\t\t\t\t\t\titem.save\n\t\t\t\t\trescue RestClient::Conflict\n\t\t\t\t\t\t# We had a conflict. See assignment accepted for explanation.\n\n\t\t\t\t\t\tif retries < 10\n\t\t\t\t\t\t\tretries += 1\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - retry #{retries}\"\n\t\t\t\t\t\t\tretry\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - giving up\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def assignment_accepted\n\t\t\t\tif !@hit_id.nil? && !@assignment_id.nil?\n\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] AssignmentAccepted\"\n\n\t\t\t\t\t# Look up the HIT\n\t\t\t\t\t@hit = RTurk::Hit.find(@hit_id)\n\n\t\t\t\t\t# Parse the JSON stored in annotation\n\t\t\t\t\tbegin\n\t\t\t\t\t\tannotation = JSON.parse(@hit.annotation)\n\t\t\t\t\trescue JSON::ParserError\n\t\t\t\t\t\tannotation = {}\n\t\t\t\t\tend\n\n\t\t\t\t\tretries = 0\n\n\t\t\t\t\tbegin\n\t\t\t\t\t\t# Get the item we're operating on.\n\t\t\t\t\t\titem = ::DataObject.get(annotation[\"item_id\"])\n\t\t\t\t\t\titem.turk_events ||= {}\n\t\t\t\t\t\titem.turk_events[\"assignment_accepted\"] ||= {}\n\n\t\t\t\t\t\t# Check if we have already worked on this item.\n\t\t\t\t\t\tif !item.turk_events[\"assignment_accepted\"][@assignment_id].nil?\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] Not processing - event already processed for Assignment ID #{@assignment_id}\"\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# Mark event as processed.\n\t\t\t\t\t\titem.turk_events[\"assignment_accepted\"][@assignment_id] = Time.new.getutc.iso8601\n\t\t\t\t\t\titem.save\n\t\t\t\t\trescue RestClient::Conflict\n\t\t\t\t\t\t# We had a conflict when saving the item. Let's retry until we are able to save without a conflict.\n\t\t\t\t\t\t# This could cause an infinite loop, so we don't retry after a certain number of retries.\n\n\t\t\t\t\t\tif retries < 10\n\t\t\t\t\t\t\tretries += 1\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - retry #{retries}\"\n\t\t\t\t\t\t\tretry\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - giving up\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def is_assigned=(value)\n @is_assigned = value\n end", "def approved?\n assignment_status_match?('Approved')\n end", "def ready_for_submission?\n self.all_reviewers_assigned? && \n self.all_manager_reviewers_assigned? &&\n self.design_data_filled_in?\n end", "def on_assigned_exit(state, event, *event_args)\n super\n\n unless event == :review\n changed = 'withdrawn'\n changed += ' pending edits' unless event == :cancel\n __debug_sim(\"Reviewer(s) notified the submission was #{changed}.\")\n end\n\n self\n end", "def view_submission\n\t\tmapping = ReviewMapping.find(params[:mapping_id])\n\t\t@student_a = mapping.user\n\t\t@review_assignment = mapping.review_assignment\n\t\t@student_b = mapping.other_user\n\t\t@answers = ReviewAnswer.find_all_by_user_id_and_other_id(@student_a.id, @student_b.id)\n\t\t@answers = @answers.reject{|x| x.review_question.review_assignment.id != @review_assignment.id}\n\t\t\n\t\tfaculty_review = FacultyReview.find_by_review_mapping_id(mapping.id)\n\t\t@faculty_review_content = \"Review Acceptable.\"\n\t\t@faculty_review_content = faculty_review.content unless faculty_review.nil?\n\t\t\n\t\t@mapping_id = mapping.id\n\tend", "def closed_submission_status\n 'Closed for Review'\n end", "def reviewed?\n @status == :reviewed\n end", "def nessie_assigns_submitted(site)\n site_statistics(analytics(site)['assignmentsSubmitted']).merge!({:type => 'Assignments Submitted'})\n end", "def on_reviewing_entry(state, event, *event_args)\n super\n\n if !simulating || !submission.auto_review\n __debug_sim('[auto_review: false]') if simulating\n __debug_sim('Waiting for reviewer evaluation.')\n __debug_sim('REVIEWER must `approve!` or `reject!` to advance...')\n\n elsif submission.auto_approve # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_approve: true]')\n __debug_sim('SYSTEM review approves the submission.')\n\n approve! # NOTE: => :approved\n\n elsif submission.auto_reject # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_reject: true]')\n __debug_sim('SYSTEM review rejects the submission.')\n\n reject! # NOTE: => :rejected\n\n else # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_approve: false]')\n __debug_sim('[auto_reject: false]')\n __debug_sim('SYSTEM must `approve!` or `reject!` to advance...')\n\n end\n\n self\n end", "def assign_to(user)\n user = User.find(user) unless user.is_a?(User)\n options = {:user => user, :submission => self}\n \n if ['annotation', 'exam'].include?(self.exercise.review_mode) && self.annotatable?\n review = AnnotationAssessment.new(options)\n else\n review = Review.new(options)\n end\n \n review.save\n\n return review\n end", "def review_locked?\n (self.review_type.name == \"Final\" && \n (!(self.design.audit.skip? || self.design.audit.auditor_complete?) ||\n !self.design.work_assignments_complete?))\n end", "def review_allowed?(assignment, reviewer)\n @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)\n assignment.num_reviews_allowed > @review_mappings.size\n end", "def start_self_review\n user_id = params[:reviewer_userid]\n assignment = Assignment.find(params[:assignment_id])\n team = Team.find_team_for_assignment_and_user(assignment.id, user_id).first\n begin\n # ACS Removed the if condition(and corresponding else) which differentiate assignments as team and individual assignments\n # to treat all assignments as team assignments\n if SelfReviewResponseMap.where(reviewee_id: team.id, reviewer_id: params[:reviewer_id]).first.nil?\n SelfReviewResponseMap.create(reviewee_id: team.id,\n reviewer_id: params[:reviewer_id],\n reviewed_object_id: assignment.id)\n else\n raise 'Self review already assigned!'\n end\n redirect_to controller: 'submitted_content', action: 'edit', id: params[:reviewer_id]\n rescue StandardError => e\n redirect_to controller: 'submitted_content', action: 'edit', id: params[:reviewer_id], msg: e.message\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
When leaving the :assigned state: The submission was assigned for review.
def on_assigned_exit(state, event, *event_args) super unless event == :review changed = 'withdrawn' changed += ' pending edits' unless event == :cancel __debug_sim("Reviewer(s) notified the submission was #{changed}.") end self end
[ "def on_assigning_entry(state, event, *event_args)\n super\n\n # Determine availability of appropriate reviewer(s).\n if simulating\n __debug_sim(\"[no_reviewers: #{submission.no_reviewers}]\")\n can_proceed = !submission.no_reviewers\n else\n can_proceed = true\n end\n\n # TODO: simulation - remove\n if can_proceed\n __debug_sim('SYSTEM notifies the pool of available reviewer(s).')\n else\n __debug_sim('SYSTEM determined there are no reviewers available.')\n end\n\n # Automatically transition to the next state based on submission status.\n if can_proceed\n advance! # NOTE: => :assigned\n else\n hold! # NOTE: => :holding\n end\n self\n end", "def on_assigned_entry(state, event, *event_args)\n super\n\n # Determine whether the system should perform an automated review.\n auto_review = false # TODO: auto-review?\n\n # Determine whether the system should perform an automated review.\n if simulating\n __debug_sim(\"[auto_review: #{submission.auto_review}]\")\n auto_review = submission.auto_review # TODO: remove\n end\n\n # Determine whether the system should perform an automated review.\n unless simulating\n auto_review = record.auto_reviewable? if record\n end\n\n # TODO: simulation - remove\n if auto_review\n __debug_sim('SYSTEM is performing an automated review.')\n else\n __debug_sim('Waiting for reviewer to begin review.')\n __debug_sim('REVIEWER must `review!` to advance...')\n end\n\n # If the submission is to be reviewed by a human then it remains in this\n # state until a review claims it (i.e. starts a review).\n review! if auto_review # NOTE: => :reviewing\n\n self\n end", "def assignment_submitted\n\t\t\t\tif !@hit_id.nil? && !@assignment_id.nil?\n\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] AssignmentSubmitted\"\n\n\t\t\t\t\t# Look up the HIT\n\t\t\t\t\t@hit = RTurk::Hit.find(@hit_id)\n\n\t\t\t\t\t# Parse the JSON stored in annotation\n\t\t\t\t\tbegin\n\t\t\t\t\t\tannotation = JSON.parse(@hit.annotation)\n\t\t\t\t\trescue JSON::ParserError\n\t\t\t\t\t\tannotation = {}\n\t\t\t\t\tend\n\n\t\t\t\t\tretries = 0\n\n\t\t\t\t\tbegin\n\t\t\t\t\t\t# Get the item we're operating on.\n\t\t\t\t\t\titem = ::DataObject.get(annotation[\"item_id\"])\n\t\t\t\t\t\titem.turk_events ||= {}\n\t\t\t\t\t\titem.turk_events[\"assignment_submitted\"] ||= {}\n\n\t\t\t\t\t\t# Check if we have already worked on this item.\n\t\t\t\t\t\tif !item.turk_events[\"assignment_submitted\"][@assignment_id].nil?\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] Not processing - event already processed for Assignment ID #{@assignment_id}\"\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# Mark event as processed.\n\t\t\t\t\t\titem.turk_events[\"assignment_submitted\"][@assignment_id] = Time.new.getutc.iso8601\n\t\t\t\t\t\titem.save\n\t\t\t\t\trescue RestClient::Conflict\n\t\t\t\t\t\t# We had a conflict. See assignment accepted for explanation.\n\n\t\t\t\t\t\tif retries < 10\n\t\t\t\t\t\t\tretries += 1\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - retry #{retries}\"\n\t\t\t\t\t\t\tretry\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - giving up\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def closed_submission_status\n 'Closed for Review'\n end", "def review\n return access_denied unless @course.has_teacher(current_user) || @submission.group.has_reviewer?(current_user) || (@exercise.collaborative_mode == 'review' && (@course_instance.has_student(current_user) || @course_instance.has_assistant(current_user)))\n\n review = @submission.assign_to(current_user)\n\n redirect_to edit_review_path(review)\n log \"create_review #{@submission.id},#{@exercise.id}\"\n end", "def assignment_accepted\n\t\t\t\tif !@hit_id.nil? && !@assignment_id.nil?\n\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] AssignmentAccepted\"\n\n\t\t\t\t\t# Look up the HIT\n\t\t\t\t\t@hit = RTurk::Hit.find(@hit_id)\n\n\t\t\t\t\t# Parse the JSON stored in annotation\n\t\t\t\t\tbegin\n\t\t\t\t\t\tannotation = JSON.parse(@hit.annotation)\n\t\t\t\t\trescue JSON::ParserError\n\t\t\t\t\t\tannotation = {}\n\t\t\t\t\tend\n\n\t\t\t\t\tretries = 0\n\n\t\t\t\t\tbegin\n\t\t\t\t\t\t# Get the item we're operating on.\n\t\t\t\t\t\titem = ::DataObject.get(annotation[\"item_id\"])\n\t\t\t\t\t\titem.turk_events ||= {}\n\t\t\t\t\t\titem.turk_events[\"assignment_accepted\"] ||= {}\n\n\t\t\t\t\t\t# Check if we have already worked on this item.\n\t\t\t\t\t\tif !item.turk_events[\"assignment_accepted\"][@assignment_id].nil?\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] Not processing - event already processed for Assignment ID #{@assignment_id}\"\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# Mark event as processed.\n\t\t\t\t\t\titem.turk_events[\"assignment_accepted\"][@assignment_id] = Time.new.getutc.iso8601\n\t\t\t\t\t\titem.save\n\t\t\t\t\trescue RestClient::Conflict\n\t\t\t\t\t\t# We had a conflict when saving the item. Let's retry until we are able to save without a conflict.\n\t\t\t\t\t\t# This could cause an infinite loop, so we don't retry after a certain number of retries.\n\n\t\t\t\t\t\tif retries < 10\n\t\t\t\t\t\t\tretries += 1\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - retry #{retries}\"\n\t\t\t\t\t\t\tretry\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tputs \"[MacroDeck::TurkEventProcessor] 409 Conflict while saving - giving up\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def submitted?\n assignment_status_match?('Submitted')\n end", "def is_assigned\n return @is_assigned\n end", "def on_submitted_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[no_review: #{submission.no_review}]\")\n must_review = !submission.no_review\n else\n must_review = true\n end\n\n # Determine whether the item needs to be reviewed.\n unless simulating\n must_review = record.review_required? if record\n end\n\n # TODO: simulation - remove\n if must_review\n __debug_sim('This item requires review.')\n else\n __debug_sim('This item can be submitted without review.')\n end\n\n # Automatically transition to the next state based on submission status.\n if must_review\n schedule! # NOTE: => :scheduling\n else\n advance! # NOTE: => :staging\n end\n self\n end", "def status!(as_seen_by)\n if grade_type == NORMAL\n if submission_status == :submitted\n latest_submission.final_score as_seen_by\n else # :not_yet_submitted, :not_submitted\n submission_status\n end\n else # ZEROED, EXCUSED\n AssessmentUserDatum.grade_type_to_sym grade_type\n end\n end", "def is_assigned=(value)\n @is_assigned = value\n end", "def on_reviewing_entry(state, event, *event_args)\n super\n\n if !simulating || !submission.auto_review\n __debug_sim('[auto_review: false]') if simulating\n __debug_sim('Waiting for reviewer evaluation.')\n __debug_sim('REVIEWER must `approve!` or `reject!` to advance...')\n\n elsif submission.auto_approve # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_approve: true]')\n __debug_sim('SYSTEM review approves the submission.')\n\n approve! # NOTE: => :approved\n\n elsif submission.auto_reject # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_reject: true]')\n __debug_sim('SYSTEM review rejects the submission.')\n\n reject! # NOTE: => :rejected\n\n else # TODO: remove\n __debug_sim('[auto_review: true]')\n __debug_sim('[auto_approve: false]')\n __debug_sim('[auto_reject: false]')\n __debug_sim('SYSTEM must `approve!` or `reject!` to advance...')\n\n end\n\n self\n end", "def on_scheduling_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[auto_review: #{submission.auto_review}]\")\n auto_review = submission.auto_review\n else\n auto_review = false\n end\n\n # Determine whether the system should perform an automated review.\n unless simulating\n auto_review = record.auto_reviewable?\n end\n\n # TODO: simulation - remove\n if auto_review\n __debug_sim('SYSTEM will perform an automated review.')\n else\n __debug_sim('SYSTEM will determine a pool of reviewer(s).')\n end\n\n # Automatically transition to the next state based on submission status.\n if auto_review\n assign! # NOTE: => :assigned\n else\n advance! # NOTE: => :assigning\n end\n self\n end", "def submission_moved(submission)\n setup_email(submission.user)\n subject 'Edison Nation - The status of your submission has changed'\n body :submission => submission\n end", "def reset_assignee\r\n assigned_status = IssueStatus.find_by_name('assigned')\r\n status = self.status_id\r\n if status == assigned_status.id\r\n assignee = self.assigned_to_id\r\n check_assignee = Group.find(assignee) rescue nil\r\n if check_assignee.present?\r\n self.assigned_to_id = \"\"\r\n end\r\n end\r\n end", "def review_locked?\n (self.review_type.name == \"Final\" && \n (!(self.design.audit.skip? || self.design.audit.auditor_complete?) ||\n !self.design.work_assignments_complete?))\n end", "def reset_reviewed\n if copy_changed? && !approved_changed?\n if copy_change[0] != copy_change[1]\n self.reviewer_id = nil\n self.approved = nil\n end\n end\n return true\n end", "def nessie_assigns_submitted(site)\n site_statistics(analytics(site)['assignmentsSubmitted']).merge!({:type => 'Assignments Submitted'})\n end", "def move_incident_to_in_review_if_necessary!\n @incident.in_review! if @incident.approved?\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Upon entering the :reviewing state: The submission is under review.
def on_reviewing_entry(state, event, *event_args) super if !simulating || !submission.auto_review __debug_sim('[auto_review: false]') if simulating __debug_sim('Waiting for reviewer evaluation.') __debug_sim('REVIEWER must `approve!` or `reject!` to advance...') elsif submission.auto_approve # TODO: remove __debug_sim('[auto_review: true]') __debug_sim('[auto_approve: true]') __debug_sim('SYSTEM review approves the submission.') approve! # NOTE: => :approved elsif submission.auto_reject # TODO: remove __debug_sim('[auto_review: true]') __debug_sim('[auto_reject: true]') __debug_sim('SYSTEM review rejects the submission.') reject! # NOTE: => :rejected else # TODO: remove __debug_sim('[auto_review: true]') __debug_sim('[auto_approve: false]') __debug_sim('[auto_reject: false]') __debug_sim('SYSTEM must `approve!` or `reject!` to advance...') end self end
[ "def reviewed?\n @status == :reviewed\n end", "def review\n return access_denied unless @course.has_teacher(current_user) || @submission.group.has_reviewer?(current_user) || (@exercise.collaborative_mode == 'review' && (@course_instance.has_student(current_user) || @course_instance.has_assistant(current_user)))\n\n review = @submission.assign_to(current_user)\n\n redirect_to edit_review_path(review)\n log \"create_review #{@submission.id},#{@exercise.id}\"\n end", "def releasable?; review_state? :ready; end", "def just_reviewed?\n reviewed? and reviewed_changed?\n end", "def approve\n update_attribute :needs_review, false\n end", "def move_incident_to_in_review_if_necessary!\n @incident.in_review! if @incident.approved?\n end", "def on_submitted_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[no_review: #{submission.no_review}]\")\n must_review = !submission.no_review\n else\n must_review = true\n end\n\n # Determine whether the item needs to be reviewed.\n unless simulating\n must_review = record.review_required? if record\n end\n\n # TODO: simulation - remove\n if must_review\n __debug_sim('This item requires review.')\n else\n __debug_sim('This item can be submitted without review.')\n end\n\n # Automatically transition to the next state based on submission status.\n if must_review\n schedule! # NOTE: => :scheduling\n else\n advance! # NOTE: => :staging\n end\n self\n end", "def review(*)\n super.tap do\n __debug_sim('REVIEWER initiates review of the submission.')\n end\n end", "def review_requested?\n github_event == 'review_requested'\n end", "def post_review?(next_review, user)\n\n (next_review && \n !self.review_locked? && \n next_review.designer_id == user.id &&\n next_review.review_type_id == next_review.design.phase_id)\n\n end", "def reviewed?\n !application_review_decision_type.nil?\n end", "def on_assigned_entry(state, event, *event_args)\n super\n\n # Determine whether the system should perform an automated review.\n auto_review = false # TODO: auto-review?\n\n # Determine whether the system should perform an automated review.\n if simulating\n __debug_sim(\"[auto_review: #{submission.auto_review}]\")\n auto_review = submission.auto_review # TODO: remove\n end\n\n # Determine whether the system should perform an automated review.\n unless simulating\n auto_review = record.auto_reviewable? if record\n end\n\n # TODO: simulation - remove\n if auto_review\n __debug_sim('SYSTEM is performing an automated review.')\n else\n __debug_sim('Waiting for reviewer to begin review.')\n __debug_sim('REVIEWER must `review!` to advance...')\n end\n\n # If the submission is to be reviewed by a human then it remains in this\n # state until a review claims it (i.e. starts a review).\n review! if auto_review # NOTE: => :reviewing\n\n self\n end", "def in_review?\n self.review_status_id == ReviewStatus.find(:first,\n :conditions => \"name='In Review'\").id\n end", "def review\n # record a payment exemption if there is one, before submission\n @resource&.identifier&.record_payment\n end", "def review_required?\n DEFAULT_REVIEW_REQUIRED # TODO: review_required?\n end", "def review_locked?\n (self.review_type.name == \"Final\" && \n (!(self.design.audit.skip? || self.design.audit.auditor_complete?) ||\n !self.design.work_assignments_complete?))\n end", "def no_review_yet\n if current_user.review_for(@course)\n flash[:danger] = \"You can only post one review per course.\"\n redirect_to @course\n end\n end", "def review_requested?\n payload_type == 'review_requested'\n end", "def record_review_status\n # This load will come from the cache (the per-request cache that rails maintains)\n r = self.id ? Review.find(self.id) : nil\n @should_count_before_save = r ? r.should_count_towards_review_count? : should_count_towards_review_count?\n return true\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Upon entering the :staging state: The submission request (submitted file plus generated request form) has been added to the staging area.
def on_staging_entry(state, event, *event_args) super # Determine whether this is destined for a member repository. if simulating __debug_sim("[emma_items: #{submission.emma_item}]") emma_items = submission.emma_item else emma_items = emma_item?(record) end unless simulating wf_finalize_submission(*event_args) end # TODO: simulation - remove if emma_items __debug_sim('SYSTEM determines this is an EMMA-native submission.') else __debug_sim('SYSTEM moves the submission into the repo staging area.') end # Automatically transition to the next state based on submission status. if emma_items index! # NOTE: => :indexing else advance! # NOTE: => :unretrieved end self end
[ "def stage(trace)\n ::Instana.logger.debug(\"Staging incomplete trace id: #{trace.id}\")\n @staging_queue.add(trace)\n end", "def offload_staging!(form_hash, tmpdir)\n if form_hash['upload']\n upload_form = replace_form_field(\n form_hash.delete('upload'),\n 'droplet',\n tmpdir\n ).except('droplet_name')\n form_hash.update(upload_form)\n end\n end", "def staging\n # TODO: mutex\n @staging_index ||= StageIndex.read(self)\n end", "def commit_staging\n @app = App.find_by_name!(params[:app_id])\n @deployment = @app.deployments.find(params[:id])\n begin\n logger.error '##############################hello there.'\n logger.error '##############################hello there.'\n logger.info '##############################hello there.'\n logger.info '##############################hello there.'\n logger.info '##############################hello there.'\n\n logger.info '##############################hello there.<>'\n new_deployment = @deployment.commit_staging!\n logger.info '##############################hello there.</>'\n logger.info \"##############################hello there. #{new_deployment}\"\n logger.info '##############################hello there.'\n render :xml => {:new_deployment_id => new_deployment.id}.to_xml(:root => :deployment)\n rescue => e\n logger.error e\n end\n end", "def staging\n environment(:staging)\n end", "def record_stage\n session[:bulk_upload_stage] = params[:action]\n end", "def stage\n staged_dir = OSC::Machete::JobDir.new(staging_target_dir).new_jobdir\n FileUtils.mkdir_p staged_dir\n FileUtils.cp_r staging_template_dir.to_s + \"/.\", staged_dir\n\n staged_dir\n end", "def staging\n if Rails.env.staging?\n head :ok\n else\n head :internal_server_error\n end\n end", "def on_retrieved_entry(state, event, *event_args)\n super\n\n __debug_sim('The submission has been received by the member repository.')\n __debug_sim('SYSTEM ensures the staging area is consistent.')\n\n advance! # NOTE: => :indexing\n self\n end", "def staging=(idx)\n # TODO: mutex\n @staging_index = idx\n end", "def health_with_staging_environment_setup\n\n\tENV[Constants::ENVIRONMENT_VAR_FOR_STAGING] = '1'\n render plain: 'OK'\n end", "def staging?\n environment == :staging\n end", "def process_staged\n @staging_lock.synchronize {\n if @staging_queue.size > 0\n @staging_queue.delete_if do |t|\n if t.complete?\n ::Instana.logger.debug(\"Moving staged complete trace to main queue: #{t.id}\")\n add(t)\n true\n elsif t.discard?\n ::Instana.logger.debug(\"Discarding trace with uncompleted async spans over 5 mins old. id: #{t.id}\")\n true\n else\n false\n end\n end\n end\n }\n end", "def staging?\n @staging_index != nil\n end", "def setup_staging\n template 'config/environments/production.rb.tt', 'config/environments/staging.rb'\n # Enable displaying error messages in staging\n replace_string_in_file('config/environments/staging.rb',\n '^[\\s]*?(config.consider_all_requests_local)[\\s]*= false[\\s]?$',\n ' config.consider_all_requests_local = true')\n # create a webpacker staging environment\n return if options[:skip_javascript]\n\n dup_file('config/webpack/production.js', 'config/webpack/staging.js')\n webpacker_str = <<~STAGING\n staging:\n <<: *default\n # Production depends on precompilation of packs prior to booting for performance.\n compile: false\n # Extract and emit a css file\n extract_css: true\n # Cache manifest.json for performance\n cache_manifest: true\n STAGING\n append_to_file('config/webpacker.yml', \"\\n#{webpacker_str}\")\n end", "def commit_stage\n @stage_monitor.synchronize do\n @service_stages << @current_stage unless @current_stage.empty?\n @stage_counter ||= 0\n @stage_counter += 1\n @current_stage = []\n end\n end", "def stage(_stage=nil)\n unless (_stage)\n _stage = ENV['FIELDS_STAGE'] || \"#{ENV['USER']}-forgot-fields-stage\"\n end\n ENV['FIELDS_STAGE'] = _stage\n _stage\n end", "def on_submitted_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[no_review: #{submission.no_review}]\")\n must_review = !submission.no_review\n else\n must_review = true\n end\n\n # Determine whether the item needs to be reviewed.\n unless simulating\n must_review = record.review_required? if record\n end\n\n # TODO: simulation - remove\n if must_review\n __debug_sim('This item requires review.')\n else\n __debug_sim('This item can be submitted without review.')\n end\n\n # Automatically transition to the next state based on submission status.\n if must_review\n schedule! # NOTE: => :scheduling\n else\n advance! # NOTE: => :staging\n end\n self\n end", "def request_processing!(request)\n request.update!(state: OrgActionRequest::State::PROCESSING)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Upon entering the :retrieved state: The submission request has been retrieved by the member repository and removed from the staging area.
def on_retrieved_entry(state, event, *event_args) super __debug_sim('The submission has been received by the member repository.') __debug_sim('SYSTEM ensures the staging area is consistent.') advance! # NOTE: => :indexing self end
[ "def set_retrieved!\n update!(last_step_completed: :retrieved)\n ::Client::Repl::BagUnpackJob.perform_later(self, staging_location)\n end", "def on_purged_entry(state, event, *event_args)\n super\n\n __debug_sim('The submission entry is being purged.')\n\n __debug_sim('Shrine cache item is being removed from AWS S3.')\n # TODO: remove Shrine cache item from AWS S3.\n\n __debug_sim('Database entry is being removed.')\n # TODO: delete 'upload' table record, OR mark as purged:\n #set_workflow_phase(:purge) # TODO: what record?\n\n halt\n self\n end", "def on_purged_entry(state, event, *event_args)\n super\n\n __debug_sim('The submission entry is being purged.')\n\n __debug_sim('Shrine cache item is being removed from AWS S3.')\n # TODO: remove Shrine cache item from AWS S3.\n\n __debug_sim('Database entry is being removed.')\n # TODO: delete 'upload' table record, OR mark as purged:\n set_workflow_phase(:purge)\n\n halt\n self\n end", "def wf_check_retrieved\n sid = record.submission_id\n data = aws_api.list_records(record).values_at(sid).flatten\n\n # Advance workflow state if the test passes.\n done = data.blank?\n advance! if done\n\n # Return status.\n sub = \"submission #{sid.inspect}\"\n repo = Upload.repository_name(record)\n if done\n \"#{repo} is now processing #{sub}\"\n else\n \"#{sub} has not yet been retrieved by #{repo}\"\n end\n end", "def on_removed_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[remove_emma_items: #{submission.emma_item}]\")\n emma_items = submission.emma_item\n else\n emma_items = true\n end\n\n # Determine whether this is destined for a member repository.\n unless simulating\n emma_items = Upload.emma_native?(record) if record\n end\n\n ok = nil\n\n if simulating\n if emma_items\n # From UploadController#destroy:\n # @succeeded, @failed = bulk_upload_remove(items)\n __debug_sim('CODE') do\n args = \"items=#{submission.items.inspect}\"\n opt = 'index: false'\n \"@succeeded, @failed = bulk_upload_remove(#{args}, #{opt})\"\n end\n self.succeeded += submission.items\n ok = ready?\n else\n ok = true # TODO: Simulate member repository delete request?\n end\n end\n\n unless simulating\n wf_remove_items(*event_args)\n ok = ready?\n end\n\n # TODO: simulation - remove\n __debug_sim do\n if !emma_items; 'Generating removal request for member repository items.'\n elsif !ok; 'The EMMA-native items NOT removed due to failure(s).'\n else; 'The EMMA-native items were removed.'; end\n end\n\n # Automatically transition to the next state based on submission status.\n if ok\n advance! # NOTE: => :staging\n else\n fail! # NOTE: => :failed\n end\n self\n end", "def on_removing_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n # From UploadController#delete:\n # ids = Upload.expand_ids(@item_id)\n __debug_sim('CODE') do\n args = \"id=#{submission.id.inspect}\"\n \"@items = Upload.expand_ids(#{args})\"\n end\n submission.items << submission.id\n end\n\n unless simulating\n wf_list_items(*event_args)\n end\n\n # TODO: simulation - remove\n __debug_sim('System shows the list of item(s) to be removed.')\n if submission&.auto_cancel\n __debug_sim('[auto_remove_cancel: true]')\n __debug_sim('USER decides not to delete item(s).')\n cancel! # NOTE: => :canceled\n elsif submission&.auto_submit\n __debug_sim('[auto_remove_submit: true]')\n __debug_sim('USER confirms the intent to delete item(s).')\n submit! # NOTE: => :removed\n else\n __debug_sim('USER must `cancel!` or `submit!` to advance...')\n end\n\n self\n end", "def relinquishes!(submission)\n return false if submission.profile != self\n return nil if submission.owner.nil?\n submission.profile = submission.owner\n submission.save\n notification = notifications.where(notifyable_type: 'Submission', notifyable_id: submission.id).first\n notification.destroy if notification\n end", "def unsubmit_submission(assessment, submissions, question, unsubmitter)\n User.with_stamper(unsubmitter) do\n Course::Assessment::Submission.transaction do\n creator_ids = []\n submissions.each do |submission|\n submission.update!('unmark' => 'true') if submission.graded?\n submission.update!('unsubmit' => 'true') unless submission.attempting?\n creator_ids << submission.creator_id\n end\n\n Course::Assessment::Submission::MonitoringService.continue_listening_from(assessment, creator_ids)\n\n question&.answers&.destroy_all\n end\n end\n end", "def unsubmit(_ = nil)\n # Skip the state validation in answers.\n @unsubmitting = true\n\n recreate_current_answers\n answers.reload\n\n self.points_awarded = nil\n self.draft_points_awarded = nil\n self.awarded_at = nil\n self.awarder = nil\n self.submitted_at = nil\n self.publisher = nil\n self.published_at = nil\n end", "def on_staging_entry(state, event, *event_args)\n super\n\n # Determine whether this is destined for a member repository.\n if simulating\n __debug_sim(\"[emma_items: #{submission.emma_item}]\")\n emma_items = submission.emma_item\n else\n emma_items = emma_item?(record)\n end\n\n unless simulating\n wf_finalize_submission(*event_args)\n end\n\n # TODO: simulation - remove\n if emma_items\n __debug_sim('SYSTEM determines this is an EMMA-native submission.')\n else\n __debug_sim('SYSTEM moves the submission into the repo staging area.')\n end\n\n # Automatically transition to the next state based on submission status.\n if emma_items\n index! # NOTE: => :indexing\n else\n advance! # NOTE: => :unretrieved\n end\n self\n end", "def on_submitted_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[no_review: #{submission.no_review}]\")\n must_review = !submission.no_review\n else\n must_review = true\n end\n\n # Determine whether the item needs to be reviewed.\n unless simulating\n must_review = record.review_required? if record\n end\n\n # TODO: simulation - remove\n if must_review\n __debug_sim('This item requires review.')\n else\n __debug_sim('This item can be submitted without review.')\n end\n\n # Automatically transition to the next state based on submission status.\n if must_review\n schedule! # NOTE: => :scheduling\n else\n advance! # NOTE: => :staging\n end\n self\n end", "def request_delivered\n @request = Request_Sample.find(params[:request])\n @request.destroy\n respond_to do |format|\n format.html { redirect_to profiles_path(current_trader.id)}\n format.json { head :no_content }\n end\n end", "def unsubmit(_ = nil)\n # Skip the state validation in answers.\n @unsubmitting = true\n\n unsubmit_latest_answers\n self.points_awarded = nil\n end", "def on_assigned_exit(state, event, *event_args)\n super\n\n unless event == :review\n changed = 'withdrawn'\n changed += ' pending edits' unless event == :cancel\n __debug_sim(\"Reviewer(s) notified the submission was #{changed}.\")\n end\n\n self\n end", "def unsubmit(_ = nil)\n # Skip the state validation in answers.\n @unsubmitting = true\n\n unsubmit_current_answers\n self.points_awarded = nil\n self.draft_points_awarded = nil\n self.awarded_at = nil\n self.awarder = nil\n self.submitted_at = nil\n self.publisher = nil\n self.published_at = nil\n end", "def employer_show_remove\n authorize @job\n @removed_job_candidates = JobCandidate.includes(:candidate).where(:job_id => params[:id], :status => JobCandidate.statuses[:deleted]).page(params[:page])\n end", "def submission_moved(submission)\n setup_email(submission.user)\n subject 'Edison Nation - The status of your submission has changed'\n body :submission => submission\n end", "def resubmit \n#--{{{\n init_logging\n resubmitter = ReSubmitter::new self\n resubmitter.resubmit\n#--}}}\n end", "def unpublish_self\n if self.submitted?\n self.deleted!\n save\n end\n if self.revisions.present?\n self.revisions.each do |event|\n if event.submitted?\n event.deleted!\n event.save\n end\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Upon entering the :indexed state: The submission is complete and present in the EMMA Unified Index.
def on_indexed_entry(state, event, *event_args) super __debug_sim('SYSTEM notifies the user that the submission is complete.') advance! # NOTE: => :completed self end
[ "def on_indexed_entry(state, event, *event_args)\n super\n wf_set_records_state\n\n __debug_sim('SYSTEM notifies the user that the submission is complete.')\n\n advance! # NOTE: => :completed\n self\n end", "def wf_check_indexed\n sid = record.submission_id\n rid = record.emma_metadata[:emma_recordId]\n data = ingest_api.get_records(rid)\n\n # Advance workflow state if the test passes.\n done = data.present?\n advance! if done\n\n # Return status.\n sub = \"submission #{sid.inspect}\"\n sub = \"#{Upload.repository_name(record)} #{sub}\" unless record.emma_native?\n if done\n \"the index service is now processing #{sub}\"\n else\n \"#{sub} has not yet been included in the index\"\n end\n end", "def on_retrieved_entry(state, event, *event_args)\n super\n\n __debug_sim('The submission has been received by the member repository.')\n __debug_sim('SYSTEM ensures the staging area is consistent.')\n\n advance! # NOTE: => :indexing\n self\n end", "def complete\n raise \"Item is not in a submitting state.\" unless @item.submitting?\n begin\n raise \"Item has no attached files\" if @item.bitstreams.count < 1\n # Normally at the end of the updating process, UpdateItemCommand would\n # add an event of Type::UPDATE with a `before_changes` property\n # containing the current (as in, at this very point) state of the item.\n # But several changes have been made to the item through the submission\n # form, outside of any other UpdateItemCommands, since it was created.\n # So we provide the item's state immediately after the last create event\n # in order to capture those.\n after_create_state = @item.events.\n where(event_type: Event::Type::CREATE).\n limit(1).\n first&.\n after_changes\n UpdateItemCommand.new(item: @item,\n user: current_user,\n description: \"Completed the submission process.\",\n before_changes: after_create_state).execute do\n build_embargo\n @item.complete_submission\n @item.save!\n RefreshOpensearchJob.perform_later\n end\n rescue => e\n flash['error'] = \"#{e}\"\n redirect_to edit_submission_path(@item)\n else\n if @item.primary_collection&.submissions_reviewed\n redirect_to submission_status_path(@item)\n else\n flash['success'] = \"Your submission is complete! \"\\\n \"Your submitted item appears below.\"\n redirect_to @item\n end\n end\n end", "def index\n @incompletes = Incomplete.all\n end", "def finish!\n send_results()\n self.current_question_index = nil\n save()\n end", "def wf_index_update(*_event_args)\n __debug_items(binding)\n if succeeded.blank?\n self.failures << \"#{__method__}: NO ENTRIES - INTERNAL WORKFLOW ERROR\"\n elsif DEFER_INDEXING\n s, f, _ = bulk_update_in_index(*succeeded)\n self.succeeded = s\n self.failures += f\n end\n end", "def enter_completed; end", "def complete\n writer.close if writer.respond_to?(:close)\n run_after_processing_steps\n\n # after an indexer has been completed, it is not really usable anymore,\n # as the writer has been closed.\n @completed = true\n end", "def update\n @index_new.update_attributes!(index_new_params)\n render_success_format('Entrada actualizada',@index_new,true)\n rescue Exception => e\n render_default_error e, 401\n\n end", "def complete_item\n \t@completed_status = true\n end", "def index_archive(indexName)\n id = indexName\n values = {\"id\" => id, \"name\" => id, \"state\" => \"pending\", \"stateTs\" => Time.now.getutc}\n r = @esarchived.set_by_id(id, values)\n\n # close the index\n Kelastic.close_index(indexName)\n\n # todo, do real archiving..\n return r[\"ok\"]\n end", "def update_index(index)\n if index.status == :invalid\n index.mutex.synchronize do\n @logger.info(\"INDEX MGMT\") { \"Updating index #{index.name}\" }\n index.status = :updating\n begin\n @elasticsearch.clear_index index.name\n index_documents index\n @elasticsearch.refresh_index index.name\n index.status = :valid\n @logger.info(\"INDEX MGMT\") { \"Index #{index.name} is up-to-date\" }\n rescue StandardError => e\n index.status = :invalid\n @logger.error(\"INDEX MGMT\") { \"Failed to update index #{index.name}.\" }\n @logger.error(\"INDEX MGMT\") { e.full_message }\n end\n end\n end\n index\n end", "def mark_complete\n\t\t@completed_status = true\n\tend", "def index\n @completed_verifications = CompletedVerification.all\n end", "def email_on_complete\n count = options['email_me']\n return unless count && count > 0\n if Document.owned_by(document.account).pending.count == 0\n LifecycleMailer.documents_finished_processing(document.account, count).deliver_now\n end\n end", "def completed?\n @assessment.status == :complete\n end", "def log_complete\n @notifier.log \"#{identifier}: Completed with #{query_got_hash.to_s}\", level: :collect\n end", "def update\n @enquiry.done!\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Upon entering the :failed state: The system is terminating the workflow.
def on_failed_entry(state, event, *event_args) super __debug_sim("[prev_state == #{prev_state.inspect}]") __debug_sim('SYSTEM has terminated the workflow.') __debug_sim('Associated data will persist until this entry is pruned.') self end
[ "def handle_fail_workflow_execution_failed(event)\n handle_closing_failure\n end", "def on_failed_entry(state, event, *event_args)\n super\n wf_set_records_state\n\n __debug_sim(\"[prev_state == #{prev_state.inspect}]\")\n __debug_sim('SYSTEM has terminated the workflow.')\n __debug_sim('Associated data will persist until this entry is pruned.')\n\n self\n end", "def handle_complete_workflow_execution_failed(event)\n handle_closing_failure\n end", "def handle_continue_as_new_workflow_execution_failed(event)\n handle_closing_failure\n end", "def handle_cancel_workflow_execution_failed(event)\n handle_closing_failure\n end", "def fail!\n return if state == 'FAILED'\n JobTracker.transaction do\n update_attribute(:state, 'FAILED')\n Delayed::Job.destroy_failed_jobs ? delayed_jobs.each(&:destroy) : delayed_jobs.each do |dj|\n dj.update_attribute(:failed_at, Time.now)\n end\n end\n end", "def on_workflow_cancel\n restore_status\n end", "def handle_child_workflow_execution_terminated(event)\n handle_event(event,\n {:id_methods => [:workflow_execution, :workflow_id],\n :consume_symbol => :handle_completion_event,\n :decision_helper_scheduled => :scheduled_external_workflows,\n :handle_open_request => lambda do |event, open_request|\n exception = ChildWorkflowTerminatedException.new(event.id, open_request.description, nil)\n open_request.completion_handle.fail(exception)\n end\n })\n end", "def failure!\n state.failure!\n end", "def abort(reason)\n puts \"Test failed: #{reason}\"\n if EventMachine.reactor_running?\n EventMachine.stop()\n end\n exit(FAILURE_EXIT_STATUS)\n end", "def aborted!\n self.update_attribute(:status, States::ABORTED)\n end", "def enter_failed; end", "def handle_signal_external_workflow_execution_failed(event)\n handle_event(event, {\n :id_methods => [:control],\n :consume_symbol => :handle_completion_event,\n :decision_helper_scheduled => :scheduled_signals,\n :handle_open_request => lambda do |event, open_request|\n workflow_execution = AWS::Flow::MinimalWorkflowExecution.new(\"\",event.attributes.workflow_id, event.attributes.run_id)\n failure = SignalExternalWorkflowException(event.id, workflow_execution, event.attributes.cause)\n open_request.completion_handle.fail(failure)\n end\n })\n end", "def on_failure( channel )\n if @state == :pty || @state == :shell\n @state = :closed\n end\n end", "def terminate_early\n\t\t@pb.set_subject \"[!Early Termination!] 0\"\n\t\t@pb.add_line \"Failed to obtain default predictions.\"\n\tend", "def fail!\n puts \"Job with attributes #{@attributes.inspect} failed!\"\n if Delayed::Worker.destroy_failed_jobs\n destroy\n else\n update_attributes(failed_at: Time.now.utc)\n end\n end", "def handle_child_workflow_execution_failed(event)\n handle_event(event,\n {:id_methods => [:workflow_execution, :workflow_id],\n :consume_symbol => :handle_completion_event,\n :decision_helper_scheduled => :scheduled_external_workflows,\n :handle_open_request => lambda do |event, open_request|\n attributes = event.attributes\n reason = attributes[:reason] if attributes.keys.include? :reason\n reason ||= \"The activity which failed did not provide a reason\"\n details = attributes[:details] if attributes.keys.include? :details\n details ||= \"The activity which failed did not provide details\"\n # workflow_id = @decision_helper.child_initiated_event_id_to_workflow_id[event.attributes.initiated_event_id]\n # @decision_helper.scheduled_external_workflows[workflow_id]\n failure = ChildWorkflowFailedException.new(event.id, event.attributes[:workflow_execution], event.attributes.workflow_type, reason, details )\n open_request.completion_handle.fail(failure)\n end\n }\n )\n end", "def halt\n StepResult.new(false)\n end", "def signal_failure\n __send_signal(:failure)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Upon entering the :resuming state: Pseudostate indicating the previous workflow state.
def on_resuming_entry(state, event, *event_args) super persist_workflow_state(prev_state) __debug_entry(current_state) self end
[ "def manual_resume_state\n super\n end", "def resume\n @state = :running\n end", "def resume\n\t\t@state = STATE_ONLINE\n\tend", "def resume; end", "def return_to_previous_state\n @update_callback = nil\n @direction = @prelock_direction if @prelock_direction > 0\n @prelock_direction = 0\n @pattern = 0\n if @surfing\n enter_in_surfing_state\n elsif $game_switches[::Yuki::Sw::EV_Bicycle]\n enter_in_cycling_state\n elsif $game_switches[::Yuki::Sw::EV_AccroBike]\n enter_in_acro_bike_state\n else\n enter_in_walking_state\n end\n end", "def on_workflow_cancel\n restore_status\n end", "def resume\n\t\tunless self.status == \"--paused--\"\n\t\t\traise \"timer is not paused. \\ntimer_status: \" + self.status \n\t\tend\n\t\tself.pos = DateTime.now\n\t\tself.status = \"--running--\"\n\n\t\tif self.save\n\t\t\treturn true\n\t\tend\n\t\treturn false\n\tend", "def reactivate(*args)\n @state.activate(*args)\n resume\n end", "def current_state\n if self.steps.where(state: 'reproved').exists?\n 'reproved'\n elsif self.steps.pluck(:state).uniq == ['approved']\n 'approved'\n else\n 'waiting'\n end\n end", "def resume\n if(@paused)\n @paused = false\n reset\n end\n current_self\n end", "def resume!\n raise Burstflow::Job::InternalError.new(self, \"Can't resume: already resumed\") if resumed?\n raise Burstflow::Job::InternalError.new(self, \"Can't resume: not suspended\") unless suspended?\n\n self.resumed_at = current_timestamp\n end", "def set_in_progress\n if self.status == \"Neu\"\n self.status = \"In Bearbeitung\"\n logger.info(\"Transitioning current claim from 'New' to 'In Progress'.\")\n end\n end", "def translate_state_from(workflow)\n return super if workflow.class == self.class\n final_state if workflow.final_state?\n end", "def state\n s = self[:saved_state].to_sym\n if s == :running\n stop ? :cancelling : :running\n else\n s\n end\n end", "def resume\n if @status == :paused\n @status = :playing\n DhunExt.resume\n notify mp3_tag(@current),:sticky => false\n return true\n end\n return false\n end", "def reminder_state\n state\n end", "def restore(memento)\n @state = memento.state\n puts \"Originator: My state has changed to: #{@state}\"\n end", "def resume\n process_status = status\n if process_status == 'stopped'\n return status if Process.kill('CONT', @proc_attrs[:pid].to_i)\n end\n process_status\n rescue Errno::EPERM\n return 'non-privilaged operation'\n end", "def restore(memento)\r\n @state = memento.state\r\n puts \"Originator: My state has changed to: #{@state}\"\r\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Upon entering the :purged state: All data associated with the submission is being eliminated.
def on_purged_entry(state, event, *event_args) super __debug_sim('The submission entry is being purged.') __debug_sim('Shrine cache item is being removed from AWS S3.') # TODO: remove Shrine cache item from AWS S3. __debug_sim('Database entry is being removed.') # TODO: delete 'upload' table record, OR mark as purged: set_workflow_phase(:purge) halt self end
[ "def on_purged_entry(state, event, *event_args)\n super\n\n __debug_sim('The submission entry is being purged.')\n\n __debug_sim('Shrine cache item is being removed from AWS S3.')\n # TODO: remove Shrine cache item from AWS S3.\n\n __debug_sim('Database entry is being removed.')\n # TODO: delete 'upload' table record, OR mark as purged:\n #set_workflow_phase(:purge) # TODO: what record?\n\n halt\n self\n end", "def purging\n @purging = true\n end", "def unsubmit(_ = nil)\n # Skip the state validation in answers.\n @unsubmitting = true\n\n recreate_current_answers\n answers.reload\n\n self.points_awarded = nil\n self.draft_points_awarded = nil\n self.awarded_at = nil\n self.awarder = nil\n self.submitted_at = nil\n self.publisher = nil\n self.published_at = nil\n end", "def unsubmit(_ = nil)\n # Skip the state validation in answers.\n @unsubmitting = true\n\n unsubmit_current_answers\n self.points_awarded = nil\n self.draft_points_awarded = nil\n self.awarded_at = nil\n self.awarder = nil\n self.submitted_at = nil\n self.publisher = nil\n self.published_at = nil\n end", "def on_removing_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n # From UploadController#delete:\n # ids = Upload.expand_ids(@item_id)\n __debug_sim('CODE') do\n args = \"id=#{submission.id.inspect}\"\n \"@items = Upload.expand_ids(#{args})\"\n end\n submission.items << submission.id\n end\n\n unless simulating\n wf_list_items(*event_args)\n end\n\n # TODO: simulation - remove\n __debug_sim('System shows the list of item(s) to be removed.')\n if submission&.auto_cancel\n __debug_sim('[auto_remove_cancel: true]')\n __debug_sim('USER decides not to delete item(s).')\n cancel! # NOTE: => :canceled\n elsif submission&.auto_submit\n __debug_sim('[auto_remove_submit: true]')\n __debug_sim('USER confirms the intent to delete item(s).')\n submit! # NOTE: => :removed\n else\n __debug_sim('USER must `cancel!` or `submit!` to advance...')\n end\n\n self\n end", "def unsubmit(_ = nil)\n # Skip the state validation in answers.\n @unsubmitting = true\n\n unsubmit_latest_answers\n self.points_awarded = nil\n end", "def clean_trash\n return unless self.active? == false and self.rank === MemberRank.find_by_name('Declined Applicant')\n\n # Don't care about what they want\n self.wishlists.destroy_all\n\n # Don't care about the achievements they mooched from us\n self.completed_achievements.destroy_all\n end", "def on_removed_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n __debug_sim(\"[remove_emma_items: #{submission.emma_item}]\")\n emma_items = submission.emma_item\n else\n emma_items = true\n end\n\n # Determine whether this is destined for a member repository.\n unless simulating\n emma_items = Upload.emma_native?(record) if record\n end\n\n ok = nil\n\n if simulating\n if emma_items\n # From UploadController#destroy:\n # @succeeded, @failed = bulk_upload_remove(items)\n __debug_sim('CODE') do\n args = \"items=#{submission.items.inspect}\"\n opt = 'index: false'\n \"@succeeded, @failed = bulk_upload_remove(#{args}, #{opt})\"\n end\n self.succeeded += submission.items\n ok = ready?\n else\n ok = true # TODO: Simulate member repository delete request?\n end\n end\n\n unless simulating\n wf_remove_items(*event_args)\n ok = ready?\n end\n\n # TODO: simulation - remove\n __debug_sim do\n if !emma_items; 'Generating removal request for member repository items.'\n elsif !ok; 'The EMMA-native items NOT removed due to failure(s).'\n else; 'The EMMA-native items were removed.'; end\n end\n\n # Automatically transition to the next state based on submission status.\n if ok\n advance! # NOTE: => :staging\n else\n fail! # NOTE: => :failed\n end\n self\n end", "def unsubmit_submission(assessment, submissions, question, unsubmitter)\n User.with_stamper(unsubmitter) do\n Course::Assessment::Submission.transaction do\n creator_ids = []\n submissions.each do |submission|\n submission.update!('unmark' => 'true') if submission.graded?\n submission.update!('unsubmit' => 'true') unless submission.attempting?\n creator_ids << submission.creator_id\n end\n\n Course::Assessment::Submission::MonitoringService.continue_listening_from(assessment, creator_ids)\n\n question&.answers&.destroy_all\n end\n end\n end", "def remove_hold\n request = {\n method: :put,\n url: \"#{endpoint_url(group_id)}/unhold\",\n body: body,\n headers: headers,\n query: query,\n }\n\n submit request\n end", "def unpublish_self\n if self.submitted?\n self.deleted!\n save\n end\n if self.revisions.present?\n self.revisions.each do |event|\n if event.submitted?\n event.deleted!\n event.save\n end\n end\n end\n end", "def mark_progresses_for_removal\n self.progresses.each do |p|\n if p.due_date.blank? && p.accuracy.to_i <= 0\n p.mark_for_destruction\n end\n end\n end", "def purge_unused\n end", "def relinquishes!(submission)\n return false if submission.profile != self\n return nil if submission.owner.nil?\n submission.profile = submission.owner\n submission.save\n notification = notifications.where(notifyable_type: 'Submission', notifyable_id: submission.id).first\n notification.destroy if notification\n end", "def discard_saved_state\n end", "def unsubmit_all_assignments\n @assignment = Assignment.find(params[:id])\n submissions = @assignment.submissions\n submissions.each do |submission|\n submission.submitted = false\n submission.save\n submission.remove_saved_runs\n end\n redirect_to @assignment\n end", "def when_removed\n WebMoney::Ext::Client.get_user_purses_balance(self.account_identifier).pursesBalances.each do |purse|\n WebMoney::Ext::Client.remove_purse(self.account_identifier, purse.purse.to_i)\n end\n end", "def reject!\n return false if self.approved == true\n self.destroy\n end", "def declines!(submission)\n collaboration = collaborations.where(submission: submission).first\n # Remove the associated notification.\n notifications.where(notifyable_type: 'Collaboration', notifyable_id: collaboration.id).first.destroy\n collaboration.destroy\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the current state of the workflow item.
def persist_workflow_state(new_value) set_workflow_state(new_value) || super end
[ "def set_workflow_state(new_value, rec = nil)\n (rec || record)&.set_state(new_value, workflow_column)&.to_s\n end", "def persist_workflow_state(new_value)\n update_attribute self.class.workflow_column, new_value\n end", "def set_state index, value\n\t\t\t\tcheck_block index\n\t\t\t\t@bsc_blocks[index].state = value\n\t\t\tend", "def workflow=(value)\n @workflow = value\n end", "def set_workflow(workflow)\n\n @workflow = workflow\n\n end", "def assign_state(state)\n @state = state\n end", "def set_workflow_current_step(workflow_step_data)\n @workflow_current_step = CompanyApi::Response::Entity::WorkflowCurrentStep.new(workflow_step_data)\n end", "def persist_workflow_state(new_value)\n self.write_attribute(self.class.workflow_column, new_value.to_s)\n self.save!\n end", "def persist_workflow_state(new_value)\n # Rails 3.1 or newer\n update_column self.class.workflow_column, new_value\n end", "def state=(s)\n @tasks.each_value do |task|\n task.state = s\n end\n end", "def write_initial_state\n write_attribute self.class.workflow_column, current_state.to_s\n end", "def set_state(state, actor = nil)\n write_attribute(:state, Fl::Framework::List::ListItem.state_to_db(state))\n write_attribute(:state_updated_at, Time.new)\n\n self.state_updated_by = (actor.nil?) ? self.owner : actor\n\n # setting the state will cause the update time on the list to be bumped\n\n @bump_list_update_time = true\n end", "def current_state=(value)\n value = infer_current_state(value)\n return unless value\n \n raise ArgumentError, \"Can only set the state to an available state, not #{value}\" unless\n graph_states.include?(value)\n \n @repository << @current_state if @current_state\n @current_state = value\n end", "def state\n @state_wrapper ||= ActionItemInternal::ActionItemStateWrapper.new(@item)\n end", "def current_state=(new_state)\n self[:current_state] = FFILib::ReaderStateQuery.pack_state new_state\n end", "def wf_set_records_state(*items, state: nil)\n items = succeeded if items.blank?\n items.each do |item|\n next unless item.is_a?(Upload)\n state ||= current_state\n item.set_phase(workflow_phase)\n item.set_state(state, workflow_column)\n end\n end", "def set_state(index, state)\n @states[index] = state\n end", "def write_initial_state\n write_attribute self.class.workflow_column, current_state.to_s unless send(:\"#{self.class.workflow_column}?\")\n end", "def start_state= x\n @start_state = x\n if x\n @start_state.stateMachine = self\n @states.each do | s |\n s.state_type = nil if s.start_state?\n end\n x.state_type = :start\n end\n x\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the current realtime value of the record's workflow phase.
def get_workflow_phase(rec = nil) (rec || record)&.get_phase end
[ "def step_value\n current_step.value\n end", "def value\n\t\treturn self.current_value\n\tend", "def current_value\n return @current_value\n end", "def current_mediation_phase\n current_mediator.try(:aasm_current_state)\n end", "def get_workflow\n return @workflow\n end", "def get_workflow_state(rec = nil)\n (rec || record)&.get_state(workflow_column)&.to_s\n end", "def current_workflow_status\r\n return self.workflow_status\r\n end", "def current_phase()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.Timer_current_phase(@handle.ptr)\n result\n end", "def current_value; end", "def processed_value\n @value\n end", "def workflow\n return @workflow\n end", "def get_sensor_value()\n raw = get_raw_value()\n current = raw_to_current(raw)\n Rails.logger.debug(\"Current value = #{current}\")\n current\n end", "def value\n return self.stock_live_info.value_now\n end", "def workflow_execution\n @task.workflow_execution\n end", "def last_evaluated_value\n value = \"expert\"\n puts value\n return value\nend", "def get_record_timing\n @timing\n end", "def model_value\n current_reference_descriptor.extracted_value\n end", "def phase\n @phase\n end", "def get\n @value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the current realtime value of the record's workflow phase.
def set_workflow_phase(new_value = nil, rec = nil) (rec || record)&.set_phase(new_value) end
[ "def set_workflow_state(new_value, rec = nil)\n (rec || record)&.set_state(new_value, workflow_column)&.to_s\n end", "def persist_workflow_state(new_value)\n set_workflow_state(new_value) || super\n end", "def persist_workflow_state(new_value)\n update_attribute self.class.workflow_column, new_value\n end", "def workflow=(value)\n @workflow = value\n end", "def persist_workflow_state(new_value)\n # Rails 3.1 or newer\n update_column self.class.workflow_column, new_value\n end", "def persist_workflow_state(new_value)\n self.write_attribute(self.class.workflow_column, new_value.to_s)\n self.save!\n end", "def []=(key,value)\n raise Wfe::Exception.new(\"workflow context hash accessed outside of execution scope\") unless ! @wf.nil?\n @wf.run_time_ctx[key] = value\n @wf.save\n end", "def set_workflow_current_step(workflow_step_data)\n @workflow_current_step = CompanyApi::Response::Entity::WorkflowCurrentStep.new(workflow_step_data)\n end", "def set_value= val\n @value = val\n @evaluated = true\n end", "def value=(value)\n @literal_value = format_source(value)\n @value = format_source(value)\n\n @steps = []\n value\n end", "def phase=(value)\n @phase = value\n end", "def set_CurrentValue(value)\n set_input(\"CurrentValue\", value)\n end", "def set_PotentialStage(value)\n set_input(\"PotentialStage\", value)\n end", "def current_step=(value)\n @current_step = value\n end", "def set_step_result(result)\n @current_step.result = result\n end", "def set_workflow(workflow)\n\n @workflow = workflow\n\n end", "def current_value=(value)\n @current_value = value\n end", "def value=(value)\n @literal_value ||= format_source(value)\n @value = format_source(value)\n\n @steps = []\n end", "def assign_current_step\n resource.current_step = step.to_sym\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the current realtime value of the appropriate workflow state field.
def get_workflow_state(rec = nil) (rec || record)&.get_state(workflow_column)&.to_s end
[ "def state_value\n data.state_value\n end", "def current_workflow_status\r\n return self.workflow_status\r\n end", "def value\n\t\treturn self.current_value\n\tend", "def current_value\n return @current_value\n end", "def current_state\n if self.steps.where(state: 'reproved').exists?\n 'reproved'\n elsif self.steps.pluck(:state).uniq == ['approved']\n 'approved'\n else\n 'waiting'\n end\n end", "def translate_state_from(workflow)\n workflow.current_state\n end", "def translated_state_for(resource)\n state_value = related_workflow(resource).translate_state_from(changed_workflow)\n state_value.to_s\n end", "def state\r\n\t\tcase self.workflow_state.to_sym\r\n\t\t\twhen :checking then 'checking'\r\n\t\t\twhen :converting then I18n.t(:media_work_converting)\r\n\t\t\twhen :ready then I18n.t(:media_work_ready)\r\n\t\t\twhen :error then I18n.t(:media_work_error)\r\n\t\t\twhen :invalid then 'invalid'\r\n\t\tend\r\n\tend", "def state\n return @state\n end", "def current_value; end", "def get_workflow\n return @workflow\n end", "def workflow\n return @workflow\n end", "def workflow_state(workflow_id:)\n get(url: \"#{@url}workflows/#{workflow_id}/state\")\n end", "def reminder_state\n state\n end", "def current_value\n return custom_value if dirty?\n\n default_value\n end", "def workflow\n if @workflow == \"\"\n @workflow = @server.get_run_attribute(@uuid, @links[:workflow])\n end\n @workflow\n end", "def value\n @event_status\n end", "def step_value\n current_step.value\n end", "def get_sensor_value()\n raw = get_raw_value()\n current = raw_to_current(raw)\n Rails.logger.debug(\"Current value = #{current}\")\n current\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the current realtime value of the appropriate workflow state field.
def set_workflow_state(new_value, rec = nil) (rec || record)&.set_state(new_value, workflow_column)&.to_s end
[ "def persist_workflow_state(new_value)\n set_workflow_state(new_value) || super\n end", "def persist_workflow_state(new_value)\n update_attribute self.class.workflow_column, new_value\n end", "def persist_workflow_state(new_value)\n # Rails 3.1 or newer\n update_column self.class.workflow_column, new_value\n end", "def workflow=(value)\n @workflow = value\n end", "def persist_workflow_state(new_value)\n self.write_attribute(self.class.workflow_column, new_value.to_s)\n self.save!\n end", "def set_workflow_current_step(workflow_step_data)\n @workflow_current_step = CompanyApi::Response::Entity::WorkflowCurrentStep.new(workflow_step_data)\n end", "def set_CurrentValue(value)\n set_input(\"CurrentValue\", value)\n end", "def set_Current(value)\n set_input(\"Current\", value)\n end", "def write_initial_state\n write_attribute self.class.workflow_column, current_state.to_s\n end", "def set_workflow_phase(new_value = nil, rec = nil)\n (rec || record)&.set_phase(new_value)\n end", "def set_workflow(workflow)\n\n @workflow = workflow\n\n end", "def set_CurrentStatus(value)\n set_input(\"CurrentStatus\", value)\n end", "def state=(s)\n @tasks.each_value do |task|\n task.state = s\n end\n end", "def set_approval_state(state)\n return unless self.class.approvable_field\n send(\"#{self.class.approvable_field}=\".to_sym, state)\n end", "def current_value=(value)\n @current_value = value\n end", "def set_state( key, val )\r\n\t\t@parent_node.parent_fsa.state[key]=val\r\n\tend", "def set_state index, value\n\t\t\t\tcheck_block index\n\t\t\t\t@bsc_blocks[index].state = value\n\t\t\tend", "def set_state(state)\n request = Http.put(\"#{@@apiserver}/machine/#{self.identifier}\", { \"state\" => state })\n logger.info \"#{Time.now} #{self.identifier}: setting state of VM to #{state}\"\n\n end", "def write_initial_state\n write_attribute self.class.workflow_column, current_state.to_s unless send(:\"#{self.class.workflow_column}?\")\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns [boolean check_result, string details] check_result is true if and only if: the system is reachable AND we have the required authentication information AND we successfully connected using the authentication details is a UI friendly message By default, the authentication's status is updated by the validation_successful or validation_failed callbacks. An optional :save => false can be passed to bypass these callbacks. TODO: :valid, :incomplete, and friends shouldn't be littered in here and authentication
def authentication_check(*args) options = args.last.kind_of?(Hash) ? args.last : {} save = options.fetch(:save, true) auth = authentication_best_fit(args.first) type = args.first || auth.try(:authtype) status, details = authentication_check_no_validation(type, options) if auth && save status == :valid ? auth.validation_successful : auth.validation_failed(status, details) end return status == :valid, details.truncate(20_000) end
[ "def authok?\n @authok\n end", "def authentication_successful?\n @user.present?\n end", "def check\n refresh\n primary_status = self.primary_status\n secondary_status = self.secondary_status\n mark_message \"Connected to #{session.cluster.nodes.count} nodes in mongodb replica set '#{primary_status['set']}'\"\n rescue ConnectionFailed => e\n mark_failure\n mark_message \"Error: '#{e}'\"\n end", "def check\n status, body = perform_request\n raise(StatusFailed, body) unless status == 200 && body['status'].values.all? { |v| v == 'operational' }\n\n mark_message('Monitoring check successful')\n rescue StandardError => e\n mark_message(\"Error: '#{e}'\")\n mark_failure\n end", "def active_for_authentication?\n\t\t\t#puts \"came to active for authentication,\"\n\t\t\t#puts \"the status of additional login param is:\"\n\t\t\t#puts additional_login_param_status.to_s\n\t\t\t##if additional_login_param is confirmed and \n\t\t\tif additional_login_param_status == 2\n\t\t\t\t\n\t\t\t\ttrue\n\t\t\telse\n\t\t\t\t\n\t\t\t\tsuper\n\t\t\tend\n\t\tend", "def user_details?\n !!(@username && @password)\n end", "def check\r\n\r\n @uri = target_uri\r\n user = datastore['USERNAME']\r\n pass = datastore['PASSWORD']\r\n\r\n # login\r\n print_status(\"#{peer} - Authenticating as '#{user}'\")\r\n res = login(user, pass)\r\n if res and res.code == 302 and res.headers['location'] !~ /authfailed/\r\n print_good(\"#{peer} - Authenticated successfully as '#{user}'\")\r\n # check access to the console\r\n print_status(\"#{peer} - Checking access to the script console\")\r\n get_nonce\r\n if @nonce.nil?\r\n return Exploit::CheckCode::Detected\r\n else\r\n return Exploit::CheckCode::Vulnerable\r\n end\r\n elsif res.headers.include?('X-Jenkins') or res.headers['location'] =~ /authfailed/\r\n print_error(\"#{peer} - Authentication failed\")\r\n return Exploit::CheckCode::Detected\r\n else\r\n return Exploit::CheckCode::Safe\r\n end\r\n\r\n end", "def authentication_successful?\n !!@current_user\n end", "def check_auth\n\t\tputs \"CHECKING AUTH STATUS\"\n\n\t\tapi_key = ApiKey.find_by_access_token(params[:access_token])\n\t\tusr = User.find(api_key.user_id)\n\t\t#puts \"CHECKING AUTH FOR USER: #{usr}\"\n\t\trole = usr.role\n\t\tputs \"ROLE: #{role}\"\n\t\tmsg = \"SUCCESS\"\n\n\t\trespond_to do |format|\n \t\tformat.json { render :json => { :msg => msg, :role => role } } \t\t\n \t\tend\n\tend", "def check\n @host.continue = self\n result = true\n @missions.each do | mission |\n input = mission.check\n result = handle_responses(input)\n end\n \n return result\n end", "def authentication_successful?\n auth_headers.present? && \n auth_headers[:authentication_token].present? && \n @traveler.present?\n end", "def perform_remote_check\n # Get remote session info\n url = Maestrano::SSO[self.preset].session_check_url(self.uid, self.session_token)\n begin\n response = RestClient.get(url)\n response = JSON.parse(response)\n rescue Exception => e\n response = {}\n end\n\n # Process response\n if response['valid'] && response['recheck']\n self.recheck = Time.iso8601(response['recheck'])\n return true\n end\n\n return false\n end", "def authenticate\n if auth_needed?\n http = Net::HTTP.new(config.server_host, config.server_port)\n http.use_ssl = true if config.server_port == 443\n response = http.get(auth_validate_path)\n @payload = XML.parse(response.body)\n payload.valid?\n else\n false\n end\n end", "def check\n if needs_alert?\n warn_alert\n send_alert\n false\n else\n info_passed\n true\n end\n end", "def check_availability!\n Connector.check_availability!(@user, @provider_name)\n end", "def otp_validate?\n self.otp_activation_status\n end", "def check_auth\n if current_user\n return_data = {:username => current_user.username_forum,\n :email => current_user.email,\n :admin => current_user.is_admin?,\n :authenticated => true\n }\n else\n return_data = {:authenticated => false}\n end\n #logger.debug return_data\n\n render json: return_data\n return\n end", "def Authenticate\n response = @event_getter.ByAccountID({\"AccountID\" => @account_id,\n \"Username\" => @username,\n \"Password\" => @password})\n if response.byAccountIDResult == 'The credentials you supplied are not valid.'\n return false\n else\n return true\n end\n end", "def check\n response = self.class.get(\"/acpin/#{@pin}/check\")\n response.parsed_response\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Change the password as a queued task and return the task id. The userid, current password and new password are mandatory. The auth type is optional and defaults to 'default'.
def change_password_queue(userid, current_password, new_password, auth_type = :default) task_opts = { :action => "Changing the password for Physical Provider named '#{name}'", :userid => userid } queue_opts = { :class_name => self.class.name, :instance_id => id, :method_name => 'change_password', :role => 'ems_operations', :queue_name => queue_name_for_ems_operations, :zone => my_zone, :args => [current_password, new_password, auth_type] } MiqTask.generic_action_with_callback(task_opts, queue_opts) end
[ "def change_password!(password)\n json = JSON.generate(:changePassword => { :adminPass => password })\n @compute.connection.req('POST', \"/servers/#{@id}/action\", :data => json)\n @adminPass = password\n end", "def update_password(mailbox_name, password)\n Mailgun.submit :put, mailbox_url(mailbox_name), :password => password\n end", "def change_temp_password\n\tend", "def cmdAuthIdPassword\n params = {\n \"auth_id_password\" => \"\",\n \"id_player\" => @config[\"id\"],\n \"password\" => @config[\"password\"],\n \"app_version\" => @config[\"version\"],\n }\n response = @client.request(params, @sid, true, false)\n @syncSeq = 0\n serializer = Serializer.new(response)\n return serializer.parseAuthIdPassword\n end", "def set_password\n is_new_session = @request[\"session\"][\"new\"]\n if is_new_session\n message = \"To reset your password, you must first tell me the current password.\"\n build_response( message,\n {\"intent\" => \"AskPassword\", \"tries\" => 1, \"original_intent\" => \"SetPassword\"},\n false\n )\n else\n new_password = @request[\"request\"][\"intent\"][\"slots\"][\"number_sequence\"][\"value\"]\n if @request[\"session\"][\"attributes\"][\"confirm\"]\n # Check old password\n if @request[\"session\"][\"attributes\"][\"new_password\"] == new_password\n query_database( \"UPDATE #{ALEXA_INFORMATION} SET password=#{new_password}\" )\n build_response( \"The password has been changed!\" )\n else\n build_response( \"The password confirmation was invalid. Restart the process to try again.\" )\n end\n else\n # Confirm the password once\n build_response( \"Please confirm the password\",\n {\"intent\" => \"SetPassword\", \"new_password\" => new_password, \"confirm\" => true},\n false)\n end\n end\n end", "def set_temp_pass(token_id, pass)\n res = @client.call(:set_temporary_password,\n message: {\n 'vip:TokenId': token_id,\n 'vip:TemporaryPassword': pass\n },\n attributes: {\n 'Version': '3.1',\n 'Id': Utilities.get_request_id('set_temp_pass')\n }\n ).body\n\n get_return_hash(res[:set_temporary_password_response])\n end", "def change_password(change_password_id, request)\n startAnonymous.uri('/api/user/change-password')\n .url_segment(change_password_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end", "def reset_password\n set :password, Proc.new {\n Capistrano::CLI.password_prompt(\"Password (for user: #{user}): \")\n } \n end", "def set_password(new_password)\r\n update(Password: new_password)\r\n end", "def set_password(new_password)\n UserPassword.new(:id => id, :new_password => new_password).post\n end", "def update_password(pass)\n self.password_confirmation = pass\n self.password = pass\n end", "def set_temp_password() \n\t\t#Generate new password\n\t\tpassword = User.generate_password()\n\t\t\n\t\tsalt = self.salt\n\t\tenc_password = Digest::SHA1.hexdigest(salt+password)\n\t\t\n\t\tself.temp_password = enc_password\n\t\tself.save\n\t\t\n\t\t#Ignore temp password if user is already logged in\n\t\tself.temp_password = nil\n\t\t\n\t\t#Notify user\n\t\tAppMailer.temporary_password_created(self, password).deliver\n\tend", "def password=(new_password)\n if credential = self.password_credential\n credential.password = new_password\n else\n credentials << Credentials::Password.new(password: new_password)\n end\n new_password\n end", "def change_password\n self.dummy_password = false if password_digest_changed?\n end", "def reset_ftp_password\n requires :identity\n data = service.reset_ftp_password_account(identity)\n merge_attributes(data)\n library_ftp_password\n end", "def change_password(id, password)\n response = request(:post, \"/virtual_machines/#{id}/reset_password.json\", :query => { :new_password => password })\n response['virtual_machine']\n end", "def update_password\n enc_password = Authentication::Encryptor.digest(password)\n account = Authentication::Account.reset_token_account(reset_password_token)\n account.encrypted_password = enc_password\n account.reset_password_token, account.reset_password_expires_at = nil, nil\n account.save!\n {'success' => true}\n end", "def change_password\n print 'New password: '\n new_password = $stdin.noecho(&:gets).chomp\n puts '*' * new_password.length\n\n print 'Repeat new password: '\n verify_new_password = $stdin.noecho(&:gets).chomp\n puts '*' * verify_new_password.length\n\n raise 'Passwords do not match' if new_password != verify_new_password\n\n @connection.change_password new_password\n\n nil\n end", "def crypt_password\n # EmailNotify.send_user_create_notification self\n self[:password] =\n password_hash(password(true))\n @password = nil\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new instance of an AppNews news item with the given data [+app_id+] The unique Steam Application ID of the game (e.g. +440+ for Team Fortress 2). See for all application IDs [+news_data+] The news data extracted from JSON
def initialize(app_id, news_data) @app_id = app_id @author = news_data[:author] @contents = news_data[:contents].strip @data = Time.at(news_data[:date]) @external = news_data[:is_external_url] @feed_label = news_data[:feedlabel] @feed_name = news_data[:feedname] @gid = news_data[:gid] @title = news_data[:title] @url = news_data[:url] end
[ "def initialize(app_id, news_data)\n @app_id = app_id\n @author = news_data[:author]\n @contents = news_data[:contents].strip\n @data = Time.at(news_data[:date])\n @external = news_data[:is_external_url]\n @feed_label = news_data[:feedlabel]\n @feed_name = news_data[:feedname]\n @gid = news_data[:gid]\n @title = news_data[:title]\n @url = news_data[:url]\n end", "def create_news_item(org_unit_id, news_item_data, attachments = [])\n # POST /d2l/api/le/(version)/(orgUnitId)/news/\n path = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/news/\"\n json =\n {\n \"Title\" => \"Placeholder_title\",\n \"Body\" =>\n { # Composite: RichText\n \"Text\" => \"plaintext_text_here\",\n \"HTML\" => nil # OR the HTML_Formatted_version_of_text\n },\n \"StartDate\" => \"UTCDateTime\",\n \"EndDate\" => nil, # nil or UTCDateTime -- e.g. 2017-03-28T18:54:56.000Z\n \"IsGlobal\" => false,\n \"IsPublished\" => false, # sets it as a draft\n \"ShowOnlyInCourseOfferings\" => false\n }.merge!(news_item_data)\n files = attachments\n method = \"POST\"\n ap json\n ap _news_upload(path, json, files, method)\n # RETURNS a NewsItem JSON data block\nend", "def new(data = {})\n Feed::Activity.new(feed, data)\n end", "def create_news_feed_item!(attributes = {})\n self.force_news_feed = true\n self.news_feed_item_attributes = attributes\n save!\n end", "def update_news_item(org_unit_id, news_item_id, news_item_data)\n # Example of News.NewsItemData JSON Data Block:\n # {\"Title\" => \"string\",\n # \"Body\" => {'Content' => \"content\", \"Type\" => \"type\"} # RichTextInput -- e.g. {'Content'=>'x', 'Type'=>'y'}\n # \"StartDate\": \"<string:UTCDateTime>\",\n # \"EndDate\": \"<string:UTCDateTime>\", # or nil\n # \"IsGlobal\": false,\n # \"IsPublished\": false,\n # \"ShowOnlyInCourseOfferings\": false}\n # PUT /d2l/api/le/(version)/(orgUnitId)/news/(newsItemId)\nend", "def create\n respond_to do |format|\n if @news_item.save\n format.html { redirect_to @news_item, :notice => 'News item was successfully created.' }\n format.json { render :json => @news_item, :status => :created, :location => @news_item }\n else\n format.html { render action: 'new' }\n format.json { render :json => @news_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @news_message = NewsMessage.new(news_message_params)\n @news_message.game = current_game\n if @news_message.title.nil?\n @news_message.title = \"AP Reports:\"\n end\n @current_round = current_game.round\n if params[:post_online]\n # client = Tweet.generate_client\n # client.update(\"AP: #{@news_message.content}\")\n end\n\n respond_to do |format|\n if @news_message.save\n current_game.news_messages.push(@news_message)\n format.html { redirect_to @news_message, notice: 'News message was successfully created.' }\n format.json { render :show, status: :created, location: @news_message }\n else\n format.html { render :new }\n format.json { render json: @news_message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @newsitem = Newsitem.new(newsitem_params)\n\n respond_to do |format|\n if @newsitem.save\n format.html { redirect_to @newsitem, notice: 'Newsitem was successfully created.' }\n format.json { render :show, status: :created, location: @newsitem }\n else\n format.html { render :new }\n format.json { render json: @newsitem.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate_news_item\n news_step_id = self.id\n news_title = self.name\n if self.project.title.downcase.include? \"website\"\n news_type = \"website\"\n else\n news_type = \"mobile\"\n end\n News.create(:title => news_title, :step_id => news_step_id, :news_type => news_type)\n end", "def create\n @news = New.new(news_params)\n\n if @news.save\n render json: @news, status: :created\n else\n render json: @news.errors, status: :unprocessable_entity\n end\n end", "def new\n @newsitem = Newsitem.new\n\n @newsitem = current_user.newsitems.build()\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newsitem }\n end\n end", "def create\n @news_item = NewsItem.new(params[:news_item])\n\n respond_to do |format|\n if @news_item.save\n flash[:notice] = 'News item was successfully created.'\n format.html { redirect_to(news_path(@news_item)) }\n format.xml { render :xml => @news_item, :status => :created, :location => @news_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @newsfeeds = Newsfeed.new(params[:id])\n\n respond_to do |format|\n if @newsfeeds.save\n format.html { redirect_to @newsfeeds, notice: 'Newsfeed was successfully created.' }\n format.json { render json: @newsfeeds, status: :created, location: @newsfeeds }\n else\n format.html { render action: \"new\" }\n format.json { render json: @newsfeeds.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news_item = NewsItem.new(params[:news_item])\n\n respond_to do |format|\n if @news_item.save\n flash[:notice] = 'NewsItem was successfully created.'\n format.html { redirect_to(@news_item) }\n format.xml { render :xml => @news_item, :status => :created, :location => @news_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def insert_news_if_necessary(url)\n latest_date = latest_news_date(Feed.id_from_url(url))\n latest_date = Setting.keep_news_time if latest_date.zero?\n\n channel = Arss::FeedParser.parse_uri(url).feed['channel']\n return unless channel.has_key? 'items'\n\n channel['items'].each do |item|\n if Setting.get_delete_after_days.nonzero?\n next if (item['pubDate'] <= latest_date or item['pubDate'] < Setting.keep_news_time)\n end\n\n create(:user_id => User.current_user_id, :feed_id => Feed.id_from_url(url),\n :title => item['title'], :description => item['description'],\n :url => item['link'], :read => 0, :date => item['pubDate'])\n end\n end", "def create\n @discourse_news_item = DiscourseNewsItem.new(discourse_news_item_params)\n\n respond_to do |format|\n if @discourse_news_item.save\n format.html { redirect_to @discourse_news_item, notice: 'Discourse news item was successfully created.' }\n format.json { render :show, status: :created, location: @discourse_news_item }\n else\n format.html { render :new }\n format.json { render json: @discourse_news_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news_feed = NewsFeed.new(params[:news_feed])\n\n respond_to do |format|\n if @news_feed.save\n format.html { redirect_to @news_feed, notice: 'News feed was successfully created.' }\n format.json { render json: @news_feed, status: :created, location: @news_feed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news_feed.errors, status: :unprocessable_entity }\n end\n end\n end", "def publish_draft_news_item(org_unit_id, news_item_id)\n path = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/news/#{news_item_id}/publish\"\n _post(path, {})\nend", "def create\n @news_item = NewsItem.new(news_item_params)\n\n respond_to do |format|\n if @news_item.save\n format.html { redirect_to [:admin, @news_item], notice: 'News item was successfully created.' }\n format.json { render :show, status: :created, location: @news_item }\n else\n format.html { render :new }\n format.json { render json: @news_item.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /cup_usages GET /cup_usages.json
def index @cup_usages = CupUsage.all respond_to do |format| format.html # index.html.erb format.json { render json: @cup_usages } end end
[ "def show\n @cup_usage = CupUsage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cup_usage }\n end\n end", "def get_usage(usage_type)\n return @api.do_request(\"GET\", get_base_api_path() + \"/usage/#{usage_type}\")\n end", "def index\n @usages = get_usages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usages }\n end\n end", "def usage(opts)\n url = '/stats/usage'\n url += '_by_month' if opts.delete(:by_month)\n url += '_by_service' if opts.delete(:by_service)\n client.get_stats(url, opts)\n end", "def get_usage(opts = {})\n data, _status_code, _headers = get_usage_with_http_info(opts)\n data\n end", "def new\n @cup_usage = CupUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cup_usage }\n end\n end", "def show_usage\n @file_sizes = @institution.file_stats\n @unit_count = @institution.units.\n where(buried: false).\n count\n @collection_count = Collection.\n where(institution: @institution).\n where(buried: false).\n count\n @item_count = Item.\n where(institution: @institution).\n where.not(stage: Item::Stages::BURIED).\n count\n @user_count = @institution.users.count\n render partial: \"show_usage_tab\"\n end", "def destroy\n @cup_usage = CupUsage.find(params[:id])\n @cup_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to cup_usages_url }\n format.json { head :no_content }\n end\n end", "def create\n @cup_usage = CupUsage.new(params[:cup_usage])\n @cup_usage.user_id = current_user.id\n\n respond_to do |format|\n if @cup_usage.save\n format.html { redirect_to dashboard_path(user_id: current_user.id), notice: 'Cup usage was successfully created.' }\n format.json { render json: @cup_usage, status: :created, location: @cup_usage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cup_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @app_usages = AppUsage.all\n end", "def key_usage\n response = http_client.get('api/v1/key-usage').body\n CredHubble::Resources::KeyUsage.from_json(response)\n end", "def index\n @customer_usages = CustomerUsage.all\n end", "def update\n @cup_usage = CupUsage.find(params[:id])\n\n respond_to do |format|\n if @cup_usage.update_attributes(params[:cup_usage])\n format.html { redirect_to @cup_usage, notice: 'Cup usage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cup_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_asset_usage(options)\n @client.raw('get', '/content/assets/usage', options)\n end", "def account_usage(uid)\n usage_hash = @client.user_usage(\"#{uid}\")\n Rails.logger.debug '> Radosgw: Account usage'\n usage_hash\n end", "def usages\n @usages\n end", "def show\n @coupon_usage = CouponUsage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @coupon_usage }\n end\n end", "def usage\n Zapi::Models::Usage.new\n end", "def getUsage(type, qty)\n req = DaemonGetUsageRequest.new(type, qty)\n rc = nil\n sendAndRecv(req){ |resp|\n rc = resp.buckets\n }\n rc\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /cup_usages/1 GET /cup_usages/1.json
def show @cup_usage = CupUsage.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @cup_usage } end end
[ "def index\n @cup_usages = CupUsage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cup_usages }\n end\n end", "def get_usage(usage_type)\n return @api.do_request(\"GET\", get_base_api_path() + \"/usage/#{usage_type}\")\n end", "def new\n @cup_usage = CupUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cup_usage }\n end\n end", "def index\n @usages = get_usages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usages }\n end\n end", "def create\n @cup_usage = CupUsage.new(params[:cup_usage])\n @cup_usage.user_id = current_user.id\n\n respond_to do |format|\n if @cup_usage.save\n format.html { redirect_to dashboard_path(user_id: current_user.id), notice: 'Cup usage was successfully created.' }\n format.json { render json: @cup_usage, status: :created, location: @cup_usage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cup_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_usage(opts = {})\n data, _status_code, _headers = get_usage_with_http_info(opts)\n data\n end", "def usage(opts)\n url = '/stats/usage'\n url += '_by_month' if opts.delete(:by_month)\n url += '_by_service' if opts.delete(:by_service)\n client.get_stats(url, opts)\n end", "def destroy\n @cup_usage = CupUsage.find(params[:id])\n @cup_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to cup_usages_url }\n format.json { head :no_content }\n end\n end", "def update\n @cup_usage = CupUsage.find(params[:id])\n\n respond_to do |format|\n if @cup_usage.update_attributes(params[:cup_usage])\n format.html { redirect_to @cup_usage, notice: 'Cup usage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cup_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @coupon_usage = CouponUsage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @coupon_usage }\n end\n end", "def show_usage\n @file_sizes = @institution.file_stats\n @unit_count = @institution.units.\n where(buried: false).\n count\n @collection_count = Collection.\n where(institution: @institution).\n where(buried: false).\n count\n @item_count = Item.\n where(institution: @institution).\n where.not(stage: Item::Stages::BURIED).\n count\n @user_count = @institution.users.count\n render partial: \"show_usage_tab\"\n end", "def key_usage\n response = http_client.get('api/v1/key-usage').body\n CredHubble::Resources::KeyUsage.from_json(response)\n end", "def usage\n Zapi::Models::Usage.new\n end", "def show\n @bw_usage_cach = BwUsageCache.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bw_usage_cach }\n end\n end", "def index\n @app_usages = AppUsage.all\n end", "def usage\r\n UsageController.instance\r\n end", "def index\n @customer_usages = CustomerUsage.all\n end", "def show\n @risp_service_usage = RispServiceUsage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @risp_service_usage }\n end\n end", "def show\n render json: @upc_description\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /cup_usages/new GET /cup_usages/new.json
def new @cup_usage = CupUsage.new respond_to do |format| format.html # new.html.erb format.json { render json: @cup_usage } end end
[ "def create\n @cup_usage = CupUsage.new(params[:cup_usage])\n @cup_usage.user_id = current_user.id\n\n respond_to do |format|\n if @cup_usage.save\n format.html { redirect_to dashboard_path(user_id: current_user.id), notice: 'Cup usage was successfully created.' }\n format.json { render json: @cup_usage, status: :created, location: @cup_usage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cup_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @usage = Usage.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usage }\n end\n end", "def new\n @usage = Usage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usage }\n end\n end", "def new\n @usage_tracking = UsageTracking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usage_tracking }\n end\n end", "def create\n @usage = Usage.new(params[:usage])\n\n respond_to do |format|\n if @usage.save\n format.html { redirect_to @usage, notice: 'Usage was successfully created.' }\n format.json { render json: @usage, status: :created, location: @usage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @coupon_usage = CouponUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @coupon_usage}\n end\n end", "def create\n @usage = Usage.new(usage_params)\n\n respond_to do |format|\n if @usage.save\n format.html { redirect_to @usage, notice: 'Usage was successfully created.' }\n format.json { render action: 'show', status: :created, location: @usage }\n else\n format.html { render action: 'new' }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_rest\n @v1_item_usage = V1ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @v1_item_usage }\n end\n end", "def new\n @cup = Cup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @cup }\n end\n end", "def new\n @analytics_usage = AnalyticsUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @analytics_usage }\n end\n end", "def new\n @usage = Usage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usage }\n end\n end", "def new\n @risp_service_usage = RispServiceUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @risp_service_usage }\n end\n end", "def new_rest\n @v1_page_usage = V1PageUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @v1_page_usage }\n end\n end", "def new\n @squishee_cup = SquisheeCup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @squishee_cup }\n end\n end", "def create\n @usage = Usage.new(params[:usage])\n\n respond_to do |format|\n if @usage.save\n flash[:notice] = 'Usage was successfully created.'\n format.html { redirect_to(@usage) }\n format.xml { render :xml => @usage, :status => :created, :location => @usage }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @usage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @uset = Uset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @uset }\n end\n end", "def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end", "def new\n @breadcrumb = 'create'\n @use = Use.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @use }\n end\n end", "def new\n @cuotum = Cuotum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cuotum }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /cup_usages POST /cup_usages.json
def create @cup_usage = CupUsage.new(params[:cup_usage]) @cup_usage.user_id = current_user.id respond_to do |format| if @cup_usage.save format.html { redirect_to dashboard_path(user_id: current_user.id), notice: 'Cup usage was successfully created.' } format.json { render json: @cup_usage, status: :created, location: @cup_usage } else format.html { render action: "new" } format.json { render json: @cup_usage.errors, status: :unprocessable_entity } end end end
[ "def new\n @cup_usage = CupUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cup_usage }\n end\n end", "def create\n @usage = Usage.new(params[:usage])\n\n respond_to do |format|\n if @usage.save\n format.html { redirect_to @usage, notice: 'Usage was successfully created.' }\n format.json { render json: @usage, status: :created, location: @usage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @cup_usages = CupUsage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cup_usages }\n end\n end", "def create\n @usage = Usage.new(usage_params)\n\n respond_to do |format|\n if @usage.save\n format.html { redirect_to @usage, notice: 'Usage was successfully created.' }\n format.json { render action: 'show', status: :created, location: @usage }\n else\n format.html { render action: 'new' }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cup_usage = CupUsage.find(params[:id])\n\n respond_to do |format|\n if @cup_usage.update_attributes(params[:cup_usage])\n format.html { redirect_to @cup_usage, notice: 'Cup usage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cup_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @cup_usage = CupUsage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cup_usage }\n end\n end", "def destroy\n @cup_usage = CupUsage.find(params[:id])\n @cup_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to cup_usages_url }\n format.json { head :no_content }\n end\n end", "def create\n @app_usage = AppUsage.new(app_usage_params)\n\n respond_to do |format|\n if @app_usage.save\n format.html { redirect_to @app_usage, notice: 'App usage was successfully created.' }\n format.json { render :show, status: :created, location: @app_usage }\n else\n format.html { render :new }\n format.json { render json: @app_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer_usage = CustomerUsage.new(customer_usage_params)\n\n respond_to do |format|\n if @customer_usage.save\n format.html { redirect_to @customer_usage, notice: 'Customer usage was successfully created.' }\n format.json { render action: 'show', status: :created, location: @customer_usage }\n else\n format.html { render action: 'new' }\n format.json { render json: @customer_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @coupon_usage = CouponUsage.new(params[:coupon_usage])\n\n respond_to do |format|\n if @coupon_usage.save\n format.html { redirect_to @coupon_usage, notice: \"Coupon usage was successfully created.\" }\n format.json { render json: @coupon_usage, status: :created, location: @coupon_usage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @coupon_usage.errors, status: :unprocessable_entry }\n end\n end\n end", "def create\n @usage = Usage.new(params[:usage])\n\n respond_to do |format|\n if @usage.save\n flash[:notice] = 'Usage was successfully created.'\n format.html { redirect_to(@usage) }\n format.xml { render :xml => @usage, :status => :created, :location => @usage }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @usage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @analytics_usage = AnalyticsUsage.new(params[:analytics_usage])\n\n respond_to do |format|\n if @analytics_usage.save\n format.html { redirect_to @analytics_usage, notice: 'Analytics usage was successfully created.' }\n format.json { render json: @analytics_usage, status: :created, location: @analytics_usage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @analytics_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n record_users(\"#{Date.today}\"+\":\"+\"#{current_user.id}\") if current_user\n message_ids = []\n string = request.body.read\n device_id = request.headers['device_id']\n usages = ActiveSupport::JSON.decode(string)\n if !usages.empty?\n begin\n usages.each do |usage|\n if usage['user_id'].nil?\n usage['deviceid'] = device_id\n end\n id = usage['_id']\n usage.delete('_id')\n @usage = Usage.new(usage)\n @find_usage = Usage.find_by_uri_and_user_id(usage['uri'],usage['user_id'])\n if @find_usage\n @find_usage.update_attributes(usage.delete('_id'))\n message_ids << id\n else\n if @usage.save\n message_ids << id\n else\n logger.info \"---- usage-token failed to save\"\n end\n end\n #respond_to do |format|\n # if @find_usage\n # if @find_usage.update_attributes(usage)\n # format.html { redirect_to @find_usage, notice: 'usage was successfully updated.' }\n # format.json { head :ok }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @find_usage.errors, status: :unprocessable_entity }\n # end\n # else\n # if @usage.save\n # format.html { redirect_to @usage, notice: 'usage was successfully created.' }\n # format.json { head :ok }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @usage.errors, status: :unprocessable_entity }\n # end\n # end\n #end\n end\n rescue Exception => e\n logger.info \"Exception in creating usage #{e}\"\n @error = \"#{e.message} \"#for #{e.try(:record).try(:class).try(:name)}\"\n record_errors(@errors)\n end\n end\n respond_to do |format|\n format.json {render json: message_ids}\n end\n end", "def index\n @usages = get_usages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usages }\n end\n end", "def create\n @sausage = Sausage.new(sausage_params)\n\n respond_to do |format|\n if @sausage.save\n format.html { redirect_to @sausage, notice: 'Sausage was successfully created.' }\n format.json { render :show, status: :created, location: @sausage }\n else\n format.html { render :new }\n format.json { render json: @sausage.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_usage(usage_type)\n return @api.do_request(\"GET\", get_base_api_path() + \"/usage/#{usage_type}\")\n end", "def usage(opts)\n url = '/stats/usage'\n url += '_by_month' if opts.delete(:by_month)\n url += '_by_service' if opts.delete(:by_service)\n client.get_stats(url, opts)\n end", "def create\n @upc = Upc.new(upc_params)\n\n respond_to do |format|\n if @upc.save\n format.html { redirect_to @upc, notice: 'Upc was successfully created.' }\n format.json { render :show, status: :created, location: @upc }\n else\n format.html { render :new }\n format.json { render json: @upc.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_usage(opts = {})\n data, _status_code, _headers = get_usage_with_http_info(opts)\n data\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /cup_usages/1 PUT /cup_usages/1.json
def update @cup_usage = CupUsage.find(params[:id]) respond_to do |format| if @cup_usage.update_attributes(params[:cup_usage]) format.html { redirect_to @cup_usage, notice: 'Cup usage was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @cup_usage.errors, status: :unprocessable_entity } end end end
[ "def create\n @cup_usage = CupUsage.new(params[:cup_usage])\n @cup_usage.user_id = current_user.id\n\n respond_to do |format|\n if @cup_usage.save\n format.html { redirect_to dashboard_path(user_id: current_user.id), notice: 'Cup usage was successfully created.' }\n format.json { render json: @cup_usage, status: :created, location: @cup_usage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cup_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @usage.update(usage_params)\n format.html { redirect_to @usage, notice: 'Usage was successfully updated.' }\n format.json { render :show, status: :ok, location: @usage }\n else\n format.html { render :edit }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @cup_usage = CupUsage.find(params[:id])\n @cup_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to cup_usages_url }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @usage.update(usage_params)\n format.html { redirect_to @usage, notice: 'Usage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @usage = Usage.find(params[:id])\n\n respond_to do |format|\n if @usage.update_attributes(params[:usage])\n format.html { redirect_to @usage, notice: 'usage was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pc_usage.update(pc_usage_params)\n format.html { redirect_to root_path, notice: 'Pc usage was successfully updated.' }\n format.json { render :show, status: :ok, location: @pc_usage }\n else\n format.html { render :edit }\n format.json { render json: @pc_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @usage = Usage.find(params[:id])\n\n respond_to do |format|\n if @usage.update_attributes(params[:usage])\n format.html { redirect_to @usage, notice: 'Usage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @cup_usage = CupUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cup_usage }\n end\n end", "def show\n @cup_usage = CupUsage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cup_usage }\n end\n end", "def update\n @coupon_usage = CouponUsage.find(params[:id])\n\n respond_to do |format|\n if @coupon_usage.update_attributes(params[:coupon_usage])\n format.html { redirect_to @coupon_usage, notice: \"Coupon usage was successfully updated.\"}\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @coupon_usage.errors, status: \"unprocessable_entry\" }\n end\n end\n end", "def update\n respond_to do |format|\n if @app_usage.update(app_usage_params)\n format.html { redirect_to @app_usage, notice: 'App usage was successfully updated.' }\n format.json { render :show, status: :ok, location: @app_usage }\n else\n format.html { render :edit }\n format.json { render json: @app_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer_usage.update(customer_usage_params)\n format.html { redirect_to @customer_usage, notice: 'Customer usage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @customer_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @analytics_usage = AnalyticsUsage.find(params[:id])\n\n respond_to do |format|\n if @analytics_usage.update_attributes(params[:analytics_usage])\n format.html { redirect_to @analytics_usage, notice: 'Analytics usage was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @analytics_usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @usage = Usage.find(params[:id])\n\n respond_to do |format|\n if @usage.update_attributes(params[:usage])\n flash[:notice] = 'Usage was successfully updated.'\n format.html { redirect_to(@usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @usage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @usage = Usage.new(params[:usage])\n\n respond_to do |format|\n if @usage.save\n format.html { redirect_to @usage, notice: 'Usage was successfully created.' }\n format.json { render json: @usage, status: :created, location: @usage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @v1_item_usage = V1ItemUsage.find(params[:id])\n\n respond_to do |format|\n if @v1_item_usage.update_attributes(params[:v1_item_usage])\n flash[:notice] = 'V1ItemUsage was successfully updated.'\n format.html { redirect_to(@v1_item_usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @v1_item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n logger.debug(\"Update of #{params[:id]}\")\n use_count = application_user.use_counters.find_or_create_by_name(params[:name])\n use_count.count = params[:count].to_i\n if use_count.save\n render :json => 'done'\n else\n render :json => 'failed', :status => 500\n end\n end", "def update\n respond_to do |format|\n if @sausage.update(sausage_params)\n format.html { redirect_to @sausage, notice: 'Sausage was successfully updated.' }\n format.json { render :show, status: :ok, location: @sausage }\n else\n format.html { render :edit }\n format.json { render json: @sausage.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @cup_usages = CupUsage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cup_usages }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /cup_usages/1 DELETE /cup_usages/1.json
def destroy @cup_usage = CupUsage.find(params[:id]) @cup_usage.destroy respond_to do |format| format.html { redirect_to cup_usages_url } format.json { head :no_content } end end
[ "def destroy\n @usage.destroy\n respond_to do |format|\n format.html { redirect_to usages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @usage = Usage.find(params[:id])\n @usage.destroy\n\n respond_to do |format|\n format.html { redirect_to usages_url }\n format.json { head :ok }\n end\n end", "def destroy_rest\n @v1_item_usage = V1ItemUsage.find(params[:id])\n @v1_item_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(v1_item_usages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @usage = Usage.find(params[:id])\n @usage.destroy\n\n respond_to do |format|\n format.html { redirect_to usages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pc_usage.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Pc usage was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer_usage.destroy\n respond_to do |format|\n format.html { redirect_to customer_usages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @analytics_usage = AnalyticsUsage.find(params[:id])\n @analytics_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to analytics_usages_url }\n format.json { head :ok }\n end\n end", "def destroy_rest\n @v1_page_usage = V1PageUsage.find(params[:id])\n @v1_page_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(v1_page_usages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @app_usage.destroy\n respond_to do |format|\n format.html { redirect_to app_usages_url, notice: 'App usage was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy_rest\n @item_usage = ItemUsage.find(params[:id])\n @item_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(item_usages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @usage = Usage.find(params[:id])\n @usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(usages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @inden_usage.destroy\n respond_to do |format|\n format.html { redirect_to inden_usages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @coupon_usage = CouponUsage.find(params[:id])\n @coupon_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to coupon_usages_url }\n format.json { head :ok }\n end\n end", "def destroy\n @hq_rsrc_usage = HqRsrcUsage.find(params[:id])\n @hq_rsrc_usage.destroy\n \n respond_to do |format|\n format.html { redirect_to(hq_rsrc_usages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @risp_service_usage = RispServiceUsage.find(params[:id])\n @risp_service_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to risp_service_usages_url }\n format.json { head :no_content }\n end\n end", "def destroy_rest\n @page_usage = PageUsage.find(params[:id])\n @page_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_usages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @bw_usage_cach = BwUsageCache.find(params[:id])\n @bw_usage_cach.destroy\n\n respond_to do |format|\n format.html { redirect_to bw_usage_caches_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @usage_record.destroy\n respond_to do |format|\n format.html { redirect_to @project }\n format.json { head :no_content }\n end\n end", "def destroy\n @usage_type.destroy\n respond_to do |format|\n format.html { redirect_to usage_types_url }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /simpletexts GET /simpletexts.xml
def index @simpletexts = Simpletext.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @simpletexts } end end
[ "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @simpletext }\n end\n end", "def index\n @page_texts = PageText.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @page_texts }\n end\n end", "def index\n @text_contents = TextContent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @text_contents }\n end\n end", "def new\n @simpletext = Simpletext.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @simpletext }\n end\n end", "def index\n @texts = Text.all\n render json: @texts, status: 200\n end", "def text(params, options = {})\n path = \"#{base_uri(params)}/text\"\n request(path, options).if_404_raise(Neutrino::Gateway::Exceptions::PatientDocumentTextNotFoundError)\n .to_s\n end", "def index\n @text_reflections = TextReflection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @text_reflections }\n end\n end", "def index\n @tagged_texts = TaggedText.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tagged_texts }\n end\n end", "def show\n @text_content = TextContent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @text_content }\n end\n end", "def show\n @story_text = StoryText.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @story_text }\n end\n end", "def index\n @request_texts = RequestText.all\n end", "def show\n @text_topic = TextTopic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @text_topic }\n end\n end", "def show\n @sentence = Sentence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sentence }\n end\n end", "def show\n @sushi_text = SushiText.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sushi_text }\n end\n end", "def show\n @text_reflection = TextReflection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @text_reflection }\n end\n end", "def index\n @txts = Txt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @txts }\n end\n end", "def index\n @texts = Text.all\n render json: @texts\n end", "def show\n @incoming_text = IncomingText.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @incoming_text }\n end\n end", "def index\n @copy_texts = CopyText.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @copy_texts }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /simpletexts/1 GET /simpletexts/1.xml
def show respond_to do |format| format.html # show.html.erb format.xml { render :xml => @simpletext } end end
[ "def index\n @simpletexts = Simpletext.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @simpletexts }\n end\n end", "def index\n @text_contents = TextContent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @text_contents }\n end\n end", "def new\n @simpletext = Simpletext.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @simpletext }\n end\n end", "def index\n @page_texts = PageText.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @page_texts }\n end\n end", "def show\n @text_content = TextContent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @text_content }\n end\n end", "def show\n @story_text = StoryText.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @story_text }\n end\n end", "def show\n @sushi_text = SushiText.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sushi_text }\n end\n end", "def show\n @text_topic = TextTopic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @text_topic }\n end\n end", "def show\n @text_reflection = TextReflection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @text_reflection }\n end\n end", "def index\n @text_reflections = TextReflection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @text_reflections }\n end\n end", "def show\n @sentence = Sentence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sentence }\n end\n end", "def show\n @incoming_text = IncomingText.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @incoming_text }\n end\n end", "def index\n @copy_texts = CopyText.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @copy_texts }\n end\n end", "def show\n @page_text = PageText.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @page_text }\n end\n end", "def index\n @tagged_texts = TaggedText.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tagged_texts }\n end\n end", "def show\n @text_element = TextElement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @text_element }\n end\n end", "def text(params, options = {})\n path = \"#{base_uri(params)}/text\"\n request(path, options).if_404_raise(Neutrino::Gateway::Exceptions::PatientDocumentTextNotFoundError)\n .to_s\n end", "def create\n @simpletext = Simpletext.new(params[:simpletext])\n\n respond_to do |format|\n if @simpletext.save\n flash[:notice] = 'Simpletext was successfully created.'\n format.html { redirect_to(@simpletext) }\n format.xml { render :xml => @simpletext, :status => :created, :location => @simpletext }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @simpletext.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @txts = Txt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @txts }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /simpletexts/new GET /simpletexts/new.xml
def new @simpletext = Simpletext.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @simpletext } end end
[ "def new\n @text = Text.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @text }\n end\n end", "def new\n @plain_text = PlainText.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @plain_text }\n end\n end", "def new\n @text_content = TextContent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @text_content }\n end\n end", "def new\n @template_text = TemplateText.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @template_text }\n end\n end", "def new\n @text_topic = TextTopic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @text_topic }\n end\n end", "def new\n @incoming_text = IncomingText.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @incoming_text }\n end\n end", "def new\n @page_text = PageText.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_text }\n end\n end", "def new\n @textfile = Textfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @textfile }\n end\n end", "def new\n @text_reflection = TextReflection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @text_reflection }\n end\n end", "def new\n @sentence = Sentence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sentence }\n end\n end", "def new\n @story_text = StoryText.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @story_text }\n end\n end", "def new\n @text_element = TextElement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @text_element }\n end\n end", "def create\n @simpletext = Simpletext.new(params[:simpletext])\n\n respond_to do |format|\n if @simpletext.save\n flash[:notice] = 'Simpletext was successfully created.'\n format.html { redirect_to(@simpletext) }\n format.xml { render :xml => @simpletext, :status => :created, :location => @simpletext }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @simpletext.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @textpage = Textpage.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def new\n @tagged_text = TaggedText.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tagged_text }\n end\n end", "def new\n @text = Text.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @text }\n end\n end", "def new\n @newstuff = Newstuff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newstuff }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @noun = Noun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @noun }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /simpletexts POST /simpletexts.xml
def create @simpletext = Simpletext.new(params[:simpletext]) respond_to do |format| if @simpletext.save flash[:notice] = 'Simpletext was successfully created.' format.html { redirect_to(@simpletext) } format.xml { render :xml => @simpletext, :status => :created, :location => @simpletext } else format.html { render :action => "new" } format.xml { render :xml => @simpletext.errors, :status => :unprocessable_entity } end end end
[ "def new\n @simpletext = Simpletext.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @simpletext }\n end\n end", "def post_text(text)\n post_message({ :text => text }) if text\n end", "def create\n @sushi_text = SushiText.new(params[:sushi_text])\n\n respond_to do |format|\n if @sushi_text.save\n flash[:notice] = 'SushiText was successfully created.'\n format.html { redirect_to(@sushi_text) }\n format.xml { render :xml => @sushi_text, :status => :created, :location => @sushi_text }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sushi_text.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @survey_text = SurveyText.new(params[:survey_text])\n\n respond_to do |format|\n if @survey_text.save\n format.html { redirect_to @survey_text, notice: 'Survey text was successfully created.' }\n format.json { render json: @survey_text, status: :created, location: @survey_text }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey_text.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @text_element = TextElement.new(params[:text_element])\n\n respond_to do |format|\n if @text_element.save\n flash[:notice] = 'TextElement was successfully created.'\n format.html { redirect_to([:admin,@text_element]) }\n format.xml { render :xml => @text_element, :status => :created, :location => @text_element }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @text_element.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @text_topic = TextTopic.new(params[:text_topic])\n\n respond_to do |format|\n if @text_topic.save\n format.html { redirect_to(@text_topic, :notice => 'Text topic was successfully created.') }\n format.xml { render :xml => @text_topic, :status => :created, :location => @text_topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @text_topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @text = Text.new(text_params)\n\n respond_to do |format|\n if @text.save\n format.html { redirect_to @text, notice: 'Text was successfully created.' }\n format.json { render :show, status: :created, location: @text }\n else\n format.html { render :new }\n format.json { render json: @text.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @simpletexts = Simpletext.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @simpletexts }\n end\n end", "def create\n @static_text = StaticText.new(static_text_params)\n\n respond_to do |format|\n if @static_text.save\n format.html { redirect_to @static_text, notice: 'Static text was successfully created.' }\n format.json { render :show, status: :created, location: @static_text }\n else\n format.html { render :new }\n format.json { render json: @static_text.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @story_text = StoryText.new(params[:story_text])\n\n respond_to do |format|\n if @story_text.save\n flash[:notice] = 'StoryText was successfully created.'\n format.html { redirect_to(@story_text) }\n format.xml { render :xml => @story_text, :status => :created, :location => @story_text }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @story_text.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @simpletext.update_attributes(params[:simpletext])\n flash[:notice] = 'Simpletext 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 => @simpletext.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @text = current_user.texts.build(text_params)\n\n respond_to do |format|\n if @text.save\n format.html { redirect_to @text, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @text }\n else\n format.html { render :new }\n format.json { render json: @text.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @page_text = PageText.new(params[:page_text])\n\n respond_to do |format|\n if @page_text.save\n flash[:notice] = 'PageText was successfully created.'\n format.html { redirect_to(@page_text) }\n format.xml { render :xml => @page_text, :status => :created, :location => @page_text }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @page_text.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @add_text = AddText.new(add_text_params)\n\n respond_to do |format|\n if @add_text.save\n format.html { redirect_to @add_text, notice: 'Add text was successfully created.' }\n format.json { render :show, status: :created, location: @add_text }\n else\n format.html { render :new }\n format.json { render json: @add_text.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @text = Text.new(text_params)\n if @text.save!\n render json: @text\n else\n flash.now[:errors] = @text.errors.full_messages\n render json: @text\n end\n end", "def create\n @textdesc = Textdesc.new(params[:textdesc])\n\n respond_to do |format|\n if @textdesc.save\n format.html { redirect_to @textdesc, notice: 'Textdesc was successfully created.' }\n format.json { render json: @textdesc, status: :created, location: @textdesc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @textdesc.errors, status: :unprocessable_entity }\n end\n end\n end", "def POST; end", "def create\n api = Clickatell::API.authenticate(ENV['API_ID'], ENV['API_USER_NAME'], ENV['API_PASSWORD'])\n @sms_text = SmsText.new(sms_text_params)\n recipient = @sms_text.recipient\n sms_message = @sms_text.sms_message\n api.send_message(recipient, sms_message)\n respond_to do |format|\n if @sms_text.save\n format.html { redirect_to @sms_text, notice: 'Sms text was successfully created.' }\n format.json { render json: @sms_text, status: :created, location: @sms_text }\n else\n format.html { render :new }\n format.json { render json: @sms_text.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @template_text = TemplateText.new(params[:template_text])\n\n respond_to do |format|\n if @template_text.save\n format.html { redirect_to(@template_text, :notice => 'Texto criado com sucesso.') }\n format.xml { render :xml => @template_text, :status => :created, :location => @template_text }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @template_text.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /simpletexts/1 PUT /simpletexts/1.xml
def update respond_to do |format| if @simpletext.update_attributes(params[:simpletext]) flash[:notice] = 'Simpletext was successfully updated.' format.html { redirect_to :back } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @simpletext.errors, :status => :unprocessable_entity } end end end
[ "def update_text(id, data)\n put \"texts/#{id}\", data\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end", "def put_text_request(path, body)\n put(path) do |req|\n req.headers['Content-Type'] = 'text/plain'\n req.body = body\n end\n end", "def update\n respond_to do |format|\n if @text.update_attributes(params[:text])\n format.html { redirect_to @text, flash: {success: t(\"texts.updated\")} }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @text.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @texto = Texto.find(params[:id])\n\n respond_to do |format|\n if @texto.update_attributes(params[:texto])\n format.html { redirect_to(@texto, :notice => 'Texto was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @texto.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @textfile = Textfile.find(params[:id])\n @textfile.needs_fs_update = true\n @textfile.modified_at = Time.now\n\n respond_to do |format|\n if @textfile.update_attributes(params[:textfile])\n flash[:notice] = 'Textfile was successfully updated.'\n format.html { redirect_to(@textfile) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @textfile.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @incoming_text = IncomingText.find(params[:id])\n\n respond_to do |format|\n if @incoming_text.update_attributes(params[:incoming_text])\n format.html { redirect_to(@incoming_text, :notice => 'Incoming text was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @incoming_text.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @survey_text = SurveyText.find(params[:id])\n\n respond_to do |format|\n if @survey_text.update_attributes(params[:survey_text])\n filename = \"surveys/survey_#{@survey_text.title}_#{Time.now().to_i}.rb\"\n File.open(filename, 'w') {|f| f.write(@survey_text.body) }\n Surveyor::Parser.parse_file(filename)\n #puts \"SYSTEM TASKS***********************************#{`bundle exec rake surveyor FILE=#{filename}`}\"\n format.html { redirect_to @survey_text, notice: 'Survey text was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey_text.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sushi_text = SushiText.find(params[:id])\n\n respond_to do |format|\n if @sushi_text.update_attributes(params[:sushi_text])\n flash[:notice] = 'SushiText was successfully updated.'\n format.html { redirect_to(@sushi_text) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sushi_text.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @text_topic = TextTopic.find(params[:id])\n\n respond_to do |format|\n if @text_topic.update_attributes(params[:text_topic])\n format.html { redirect_to(@text_topic, :notice => 'Text topic was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @text_topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @text_element = TextElement.find(params[:id])\n\n respond_to do |format|\n if @text_element.update_attributes(params[:text_element])\n flash[:notice] = 'TextElement was successfully updated.'\n format.html { redirect_to([:admin,@text_element]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @text_element.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @texto = Texto.find(params[:id])\n\n respond_to do |format|\n if @texto.update_attributes(params[:texto])\n format.html { redirect_to @texto, notice: 'texto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @texto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @story_text = StoryText.find(params[:id])\n\n respond_to do |format|\n if @story_text.update_attributes(params[:story_text])\n flash[:notice] = 'StoryText was successfully updated.'\n format.html { redirect_to(@story_text) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @story_text.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put_entry(id,summary)\n xml = <<DATA\n <entry xmlns=\"http://purl.org/atom/ns#\">\n <summary type=\"text/plain\"></summary>\n </entry>\nDATA\n\n doc = REXML::Document.new(xml)\n doc.elements['/entry/summary'].add_text(summary)\n\n # REXML -> String\n data=String.new\n doc.write(data)\n\n #make request\n path=\"/atom/edit/#{id}\"\n req=Net::HTTP::Put.new(path)\n req['Accept']= 'application/x.atom+xml,application/xml,text/xml,*/*',\n req['X-WSSE']= @credential_string\n\n #YHAAAA!!!\n res = @http.request(req,data)\n return res\n end", "def update\n respond_to do |format|\n if @api_v1_custom_text.update(api_v1_custom_text_params)\n format.html { redirect_to @api_v1_custom_text, notice: 'Custom text was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_custom_text }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_custom_text.errors, status: :unprocessable_entity }\n end\n end\n end", "def put *args\n make_request :put, *args\n end", "def update\n @template_text = TemplateText.find(params[:id])\n\n respond_to do |format|\n if @template_text.update_attributes(params[:template_text])\n format.html { redirect_to(@template_text, :notice => 'Texto atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @template_text.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @textdesc = Textdesc.find(params[:id])\n\n respond_to do |format|\n if @textdesc.update_attributes(params[:textdesc])\n format.html { redirect_to @textdesc, notice: 'Textdesc was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @textdesc.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /simpletexts/1 DELETE /simpletexts/1.xml
def destroy @simpletext.destroy respond_to do |format| format.html { redirect_to(simpletexts_url) } format.xml { head :ok } end end
[ "def destroy\n @text_element = TextElement.find(params[:id])\n @text_element.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_text_elements_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sushi_text = SushiText.find(params[:id])\n @sushi_text.destroy\n\n respond_to do |format|\n format.html { redirect_to(sushi_texts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @textfile = Textfile.find(params[:id])\n @textfile.destroy\n\n respond_to do |format|\n format.html { redirect_to(textfiles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @text_content = TextContent.find(params[:id])\n @text_content.destroy\n\n respond_to do |format|\n format.html { redirect_to(text_contents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @texto = Texto.find(params[:id])\n @texto.destroy\n\n respond_to do |format|\n format.html { redirect_to(textos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @template_text = TemplateText.find(params[:id])\n @template_text.destroy\n\n respond_to do |format|\n format.html { redirect_to(template_texts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @incoming_text = IncomingText.find(params[:id])\n @incoming_text.destroy\n\n respond_to do |format|\n format.html { redirect_to(incoming_texts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sentence = Sentence.find(params[:id])\n @sentence.destroy\n\n respond_to do |format|\n format.html { redirect_to(sentences_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sitetext = Sitetext.find(params[:id])\n @sitetext.destroy\n\n respond_to do |format|\n format.html { redirect_to(sitetexts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page_text = PageText.find(params[:id])\n @page_text.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_texts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @story_text = StoryText.find(params[:id])\n @story_text.destroy\n\n respond_to do |format|\n format.html { redirect_to(story_texts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @text_reflection = TextReflection.find(params[:id])\n @text_reflection.destroy\n\n respond_to do |format|\n format.html { redirect_to(text_reflections_url) }\n format.xml { head :ok }\n end\n end", "def delete_text name\n unless @doc.root.elements[\"Texts/Text[@name='#{File.basename(name)}']\"] == nil\n @doc.root.elements.delete(\"Texts/Text[@name='#{File.basename(name)}']\")\n save\n else\n puts \"The text is not in the project\"\n end\n end", "def destroy\n @tagged_text = TaggedText.find(params[:id])\n @tagged_text.destroy\n\n respond_to do |format|\n format.html { redirect_to(tagged_texts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @text = Text.find(params[:id])\n @text.destroy\n\n respond_to do |format|\n format.html { redirect_to texts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @text_topic = TextTopic.find(params[:id])\n @text_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(text_topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n path = 'public/uploads/batale/text/image/' + @batale_text.id\n FileUtils.remove_dir(path) unless Dir.glob(path).empty? # Remove imagem associada ao texto, caso exista\n @batale_text.destroy\n respond_to do |format|\n format.html { redirect_to batale_texts_url, notice: 'Texto deletado com sucesso.' }\n format.json { head :no_content }\n end\n end", "def delete_text path\n element = @doc.root.elements[\"Texts/Text[@name='#{File.basename(path)}']\"]\n if element == nil\n puts \"The text is not in the project\"\n return false\n elsif element.attributes[\"p\"] == \"true\"\n puts \"Can't delete the prince text\"\n return false\n elsif \n @doc.root.elements.delete(\"Texts/Text[@name='#{File.basename(path)}']\")\n puts \"Deleted #{path} from the project\"\n save\n return true\n end\n end", "def delete_document index, id\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Delete.new(uri)\n run(uri, req)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
input string; lowercase, alphabetic chars only, no spaces output int; the highest value substring rules consonants are any letters of the alphabet except 'aeiou' split the given str on any vowels
def solve(str) str.split(/[aeiou]/).map! do |substring| substring.bytes.map { |value| value - 96 }.reduce(&:+) end.reject { |value| value == nil }.max end
[ "def solve(str)\n vowels = ['a','e','i','o','u'];\n alphabet = {\n :a => 1,\n :b => 2,\n :c => 3,\n :d => 4,\n :e => 5,\n :f => 6,\n :g => 7,\n :h => 8,\n :i => 9,\n :j => 10,\n :k => 11,\n :l => 12,\n :m => 13,\n :n => 14,\n :o => 15,\n :p => 16,\n :q => 17,\n :r => 18,\n :s => 19,\n :t => 20,\n :u => 21,\n :v => 22,\n :w => 23,\n :x => 24,\n :y => 25,\n :z => 26\n };\n\n max_substring_value = 0;\n current_substring_value = 0;\n\n str.chars.each do |c|\n unless vowels.include?(c)\n current_substring_value += alphabet[:\"#{c}\"];\n else\n if current_substring_value > max_substring_value\n max_substring_value = current_substring_value;\n end\n current_substring_value = 0;\n end\n end\n\n max_substring_value\nend", "def solve(s)\n alphabet = ('a'..'z').to_a\n s.gsub(/[aeiou]/, ' ').split.map { |l| l.chars.map { |i| alphabet.index(i) + 1 }.sum }.max\nend", "def solve(string)\n vowels = 'aeiou'\n string_of_chars = string.chars\n \n count = 0\n counted = []\n \n string_of_chars.each do |char|\n if vowels.include?(char)\n count += 1\n else\n count = 0\n end\n counted << [count]\n end\n counted.max.first\n end", "def getCount(inputStr)\n vowels = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n count = 0\n \n letters = inputStr.split(\"\")\n letters.each { |letter|\n if vowels.include?(letter)\n count += 1\n end\n }\n count\nend", "def solve(s)\n s.split(/[a,e,i,o,u]/).map! {|substring| substring.chars.map{ |c| c.ord-96 }.reduce(:+) }.compact.max\n end", "def vowelCount(str)\n\tcount = 0\n\tstr = str.split('').each{|x| count += 1 if(%(a e i o u).include?(x))}\n\treturn count\nend", "def custom_count(string, substring)\n count = 0\n letters = string.chars\n substring_letters = substring.chars\n substring_letters.each do |target|\n letters.each do |letter|\n if target == letter\n count += 1\n end\n end\n end\n return count\nend", "def max_consonant_value(s)\n s.scan(/[^aeiou]+/).map {|ss| ss.sum - (ss.size * 96)}.max\nend", "def string_sum(string)\n letters = ('a'..'z').to_a\n sum = 0\n string.split(\"\").each{|x| sum += letters.index(x) + 1}\n sum \nend", "def solve(s)\n letters = s.split(/[aeiou]/)\n alphabet = ('a'..'z')\n letters_and_numbers = Hash.new\n \n alphabet.each_with_index do |letter, index|\n letters_and_numbers[letter] = index + 1\n end\n \n letters.map! do |letter|\n if letter.length.eql?(1)\n letters_and_numbers[letter.downcase]\n else\n letter.chars.map do |split_letter|\n letters_and_numbers[split_letter]\n end.sum\n end\n end\n \n letters.sort.pop\n \nend", "def most_common_vowel(string)\n vowels = \"aeiou\"\n result_hash = Hash.new(0)\n string.chars.each do |letter|\n if vowels.include?(letter.downcase)\n result_hash[letter] += 1\n end\n end\n max_count_vowel = result_hash.values.max\n vowels.chars.each do |letter|\n return letter if result_hash[letter] == max_count_vowel\n end\nend", "def string_sum(string)\n sum = 0\n alphabets = (\"a\"..\"z\").to_a\n string.chars.each do |ch|\n sum += alphabets.index(ch) + 1\n end\n sum\nend", "def vowel_recognition(s)\n (0...s.size).map {|i| s[i] =~ /[aeiou]/i ? (s.size - i) * (i + 1) : 0}.sum\nend", "def getCount(inputStr)\n arr = inputStr.split('')\n sum = 0\n vowel = ['a','o','u','i','e']\n vowel.map{|x| arr.count(x)}\n\n end", "def vowel_count(str)\r\n\r\nend", "def zaehle(teil_string)\r\n i = 0\r\n e = 0\r\n while i != @string.length() \r\n if @string[0+i...(teil_string.length+i)].include?(teil_string) \r\n e += 1\r\n end\r\n i += 1\r\n end\r\n return e\r\n end", "def most_common_vowel(string)\n vowels_hash = Hash.new(0)\n vowels = \"aeiou\"\n string.chars { |char| vowels_hash[char] +=1 if vowels.include?(char) }\n max = vowels_hash.values.max\n vowels = vowels_hash.sort_by {|k,v| k}.flatten\n (0...vowels.length).each do |i|\n \treturn vowels[i- 1] if vowels[i] == max\n end\nend", "def custom_count(string, search_characters)\n total_chars = 0\n #\n search_characters.each_char do |sc|\n # split the string and review letter & sc\n letters = string.each_char { |letter| letter == sc ? total_chars += 1 : next }\n\n end # end of do (search chars)\n\n total_chars\nend", "def solution(s)\n return 0 if s.empty?\n t = 0\n ('A'..'Z').to_a.each do |c|\n t += s.count(c)\n end\n t + 1\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the local path in a config file. ==== Input [path : String : ''] Typically the name of a file, but it could be a path itself. ==== Output [String] A value that is the local path as specified in a config file. ==== Examples local_path => /good/local/path local_path 'blah' => /good/local/blah/path local_path '/blah' => /good/local/blah/path
def local_path(path = '') "/good/local#{get_file_path(path)}/path" end
[ "def local_path\n @local_path\n end", "def to_local(path)\n local_abs_paths = []\n path.to_s.split(/\\s+/).each do |p|\n if p =~ /^#{remote}/\n p.sub!(/^#{remote}/, '')\n p.slice!(0) if p =~ /^\\//\n p = \"#{local}/#{p}\"\n else\n if Pathname.new(p).absolute?\n # No action required\n else\n p = \"#{local}/#{p}\"\n end\n end\n local_abs_paths << p\n end\n local_abs_paths\n end", "def file_path\n @local_path\n end", "def relative_path\n @local_path.relative_path_from(@platform.local_path)\n end", "def remote_path(local_path)\n relative = relativize(local_path)\n return if !relative\n sanitized = relative.gsub(/[^a-zA-Z0-9\\-_\\.\\/]/, '-')\n \"#{@remote_dir}#{sanitized}\"\n end", "def config_path\n @config_path ||= local_config_path\n end", "def local_config_file\n @local_config_file ||= ConfigFile.new(local_config_path, @section)\n end", "def remote_path(path = '')\n \"/good/remote#{get_file_path(path)}/path\"\n end", "def is_local_path(path)\n (path =~ /^.:(\\/|\\\\)/)\nend", "def local_path_for_file(file)\n return file.path if file.respond_to?(:path)\n return file.content.path if file.content.respond_to?(:path)\n\n Tempfile.open('') do |t|\n t.binmode\n write_to_temp_file(file, t)\n t.close\n t.path\n end\n end", "def local_source_path\n # normalize path\n Pathname.new(\"#{clone_root_path}/#{src_subpath}\").cleanpath\n end", "def relativize(local_path)\n local_path[@local_dir.size..-1]\n end", "def get_sync_data_file(local_path)\n\n # location of our sync data\n sync_data_path = local_path + \"/\" + SYNC_DATA_FILE\n\n return sync_data_path\n end", "def subauthorities_path\n if config[:local_path].starts_with?(File::Separator)\n config[:local_path]\n else\n Rails.root.join(config[:local_path]).to_s # TODO: Rails.root.join returns class Pathname, which may be ok. Added to_s because of failing regression test.\n end\n end", "def local?\n @attributes[:local_path_to_file] && File.exist?(@attributes[:local_path_to_file])\n end", "def local?\n @attributes.has_key?(:local_path_to_file) && File.exist?(@attributes[:local_path_to_file])\n end", "def getFsPath(path)\n if path.kind_of? Array\n if path.length == 0\n localPath = @cwd.dup\n else\n localPath = normalizePath(path[0].dup)\n end\n else\n localPath = normalizePath(path.dup)\n end\n\n dl = localPath.slice!(0..1).upcase\n raise MiqException::MiqVmMountError, \"Unknown drive letter - #{dl}\" unless (fs = @driveToFS[dl])\n return fs, localPath\n end", "def get_path_inside_project(file_path)\n file_path.gsub(%r{/#{local_source_path}}, @name)\n end", "def local_path?(key)\n key.to_s.split('_').last == 'path' && !key.to_s.include?('remote')\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Black magic. This is used for the following purposes: To return elements from the ITEMS hash. To return messages (from the ITEMS hash), possibly with string substitutions. ==== Input [method : Symbol] The method that was called. [args : Array] Any arguments that were passed in. [&block : Block] A block, if specified. ==== Output [Any] It depends on the method.
def method_missing(method, *args, &block) # Check if the method is a key in the ITEMS hash. if ITEMS.has_key? method # Initialize the variable that will hold the return value. value = nil if args.nil? or args.count == 0 # If no arguments have been specified, return the element as is. value = ITEMS[method] elsif ITEMS[method][args[0]].is_a?(String) && ITEMS[method][args[0]].index('%s') # The first parameter is the message. msg = args.shift if args.count == 0 # If no arguments are left, return the message. value = ITEMS[method][msg] else # Use any remaining arguments to make substitutions. value = ITEMS[method][msg] % args end else # All other methods - which are expected to have one parameter. # Get the element to return. item = args[0].to_sym # Return the indicated element. value = ITEMS[method][item] # Dynamically add configuration files. if value.nil? and [:dest, :function].index(method) value = item.to_s end end # Strip all trailing line feeds from strings. value.gsub!(/\n*\z/, '') if value.is_a?(String) return value else super end end
[ "def assert_instance_method(method, content)\n assert content =~ /def #{method}(\\(.+\\))?(.*?)\\n end/m, \"Expected to have method #{method}\"\n yield $2.strip if block_given?\n end", "def method_tuple(method)\n if method.respond_to?(:parameters) # Ruby 1.9.2+\n # See http://ruby.runpaint.org/methods#method-objects-parameters\n args = method.parameters.inject([]) do |arr, (type, name)|\n name ||= (type == :block ? 'block' : \"arg#{arr.size + 1}\")\n arr << case type\n when :req then name.to_s\n when :opt, :rest then \"*#{name}\"\n when :block then \"&#{name}\"\n else '?'\n end\n end\n else # See http://ruby-doc.org/core/classes/Method.html#M001902\n args = (1..method.arity.abs).map { |i| \"arg#{i}\" }\n args[-1] = \"*#{args[-1]}\" if method.arity < 0\n end\n\n # method.to_s formats to handle:\n #\n # #<Method: Fixnum#zero?>\n # #<Method: Fixnum(Integer)#years>\n # #<Method: User(#<Module:0x00000103207c00>)#_username>\n # #<Method: User(id: integer, username: string).table_name>\n # #<Method: User(id: integer, username: string)(ActiveRecord::Base).current>\n # #<UnboundMethod: Hello#world>\n #\n if method.to_s =~ /(Unbound)*Method: (.*)[#\\.]/\n unbound, klass = $1 && '(unbound)', $2\n if klass && klass =~ /(\\(\\w+:\\s.*?\\))/ # Is this ActiveRecord-style class?\n klass.sub!($1, '') # Yes, strip the fields leaving class name only.\n end\n owner = \"#{klass}#{unbound}\".gsub('(', ' (')\n end\n\n [ method.name.to_s, \"(#{args.join(', ')})\", owner.to_s ]\n end", "def scrape_callseqs(method)\n callseqs = []\n \n method.css('.method-heading').css('.method-callseq').each do |callseq|\n callseqs << callseq.text\n end\n \n if callseqs.empty?\n method.css('.method-heading').each do |heading|\n name = heading.css('.method-name').text\n args = heading.css('.method-args').text\n \n callseqs << name + args\n end\n end\n \n callseqs\nend", "def method_call(method)\n\n\n\n # 197:7: called_method_name[method] '(' ( arguments[method] )? ')' ';'\n called_method_name(method)\n\n match(:LEFT_PARENTESIS)\n # 197:38: ( arguments[method] )?\n alt27 = 2\n # 197:38: ( arguments[method] )?\n look_ahead27_0 = look_ahead(1)\n\n if look_ahead27_0 == :IDENTIFIER || look_ahead27_0 == :NUMBER || (TOKENS[look_ahead27_0] >= 25 && TOKENS[look_ahead27_0] <= 26) || look_ahead27_0 == :ECOMMERCIAL || (TOKENS[look_ahead27_0] >= 31 && TOKENS[look_ahead27_0] <= 32) || (TOKENS[look_ahead27_0] >= 35 && TOKENS[look_ahead27_0] <= 46) || (TOKENS[look_ahead27_0] >= 48 && TOKENS[look_ahead27_0] <= 49) || look_ahead27_0 == :T58 \n alt27 = 1\n end\n case alt27\n when 1\n # 197:38: arguments[method]\n arguments(method)\n\n end\n match(:RIGHT_PARENTESIS)\n match(:SEMICOLON)\n\n\n\n end", "def assert_instance_method(method, content)\n assert content =~ /(\\s+)def #{method}(\\(.+\\))?(.*?)\\n\\1end/m, \"Expected to have method #{method}\"\n assert_nothing_raised { yield $3.strip } if block_given?\n end", "def method_tuple(method)\n if method.respond_to?(:parameters) # Ruby 1.9.2+\n # See http://ruby.runpaint.org/methods#method-objects-parameters\n args = method.parameters.inject([]) do |arr, (type, name)|\n name ||= (type == :block ? 'block' : \"arg#{arr.size + 1}\")\n arr << case type\n when :req then name.to_s\n when :opt, :rest then \"*#{name}\"\n when :block then \"&#{name}\"\n else '?'\n end\n end\n else # See http://ruby-doc.org/core/classes/Method.html#M001902\n args = (1..method.arity.abs).map { |i| \"arg#{i}\" }\n args[-1] = \"*#{args[-1]}\" if method.arity < 0\n end\n\n if method.to_s =~ /(Unbound)*Method: (.*?)[#\\.]/\n owner = \"#{$2}#{$1 ? '(unbound)' : ''}\".gsub('(', ' (')\n end\n\n [ method.name.to_s, \"(#{args.join(', ')})\", owner.to_s ]\n end", "def normalize_method_args(method, args); end", "def filter_call(method, args)\n case method\n when :filter_in, :init\n retval = args\n @filters.each do |v|\n retval = v.send(method,retval)\n end\n when :filter_out\n retval = args\n @filters.reverse_each do |v|\n retval = v.send(method,retval)\n end\n else\n log.error \"(#{self.object_id}) ProtocolStack#filter_call unknown method '#{method}',a:#{args.inspect},r:#{retval.inspect}\"\n end\n retval\n end", "def method_shark es, method_name\n es.select {|e| e.method_name == method_name }\n .map {|e| \"\\n\\n\\n#{e.date}\\n\\n#{e.method_body}\" }\nend", "def stub_method(method, &block)\n case method\n when Symbol\n NotAMock::CallRecorder.instance.untrack_method(self, method)\n NotAMock::Stubber.instance.unstub_method(self, method)\n NotAMock::Stubber.instance.stub_method(self, method, &block)\n NotAMock::CallRecorder.instance.track_method(self, method)\n when Hash\n stub_methods(method)\n else\n raise ArgumentError\n end\n end", "def yields(method, node, exp)\n ret = []\n out = node.send(method) do |*args|\n ret << args\n end\n assert_same(exp, out)\n return ret\n end", "def block_it(method = 'piGENE')\n top = Bio::Sequence::NA.new('CACC') # top_strand_shrna_overhang\n bot = Bio::Sequence::NA.new('AAAA') # bottom_strand_shrna_overhang\n fwd = @pair.sense\n rev = @pair.sense.complement\n\n case method\n when 'BLOCK-iT'\n # From BLOCK-iT's manual\n loop_fwd = Bio::Sequence::NA.new('CGAA')\n loop_rev = loop_fwd.complement\n when 'piGENE'\n # From piGENE document\n loop_fwd = Bio::Sequence::NA.new('GTGTGCTGTCC')\n loop_rev = loop_fwd.complement\n else\n raise NotImplementedError\n end\n\n if /^G/i =~ fwd\n @top_strand = top + fwd + loop_fwd + rev\n @bottom_strand = bot + fwd + loop_rev + rev\n else\n @top_strand = top + 'G' + fwd + loop_fwd + rev\n @bottom_strand = bot + fwd + loop_rev + rev + 'C'\n end\n end", "def extract_key_from_method(method, password = nil)\n extract_key(@instance.send(method), password)\n end", "def quiet(*method_keys); end", "def flexmock_invoke_original(method, args)\n method_proc = @method_definitions[method]\n method_proc.call(*args)\n end", "def extract_method_details; end", "def ruby_method\n @ruby_method ||= @message.gsub(/^\\<\\@#{@client.self.id}\\>:? ?(please explain)*?/, \"\")\n end", "def parse_interface(yard_method)\n args, block = [], {}\n image, returns = yard_method.signature.split(/[=-]\\>/)\n image = image.strip\n if i = image.index(/\\)\\s*\\{/)\n block['image'] = image[i+1..-1].strip\n image = image[0..i].strip\n end\n image = image.sub(/^def\\s*/, '')\n image = image.sub(/^self\\./, '')\n image = image.sub('( )','()')\n\n yard_method.parameters.each do |n,v|\n n = n.to_s\n case n\n when /^\\&/\n block['name'] = n\n else\n args << (v ? {'name'=>n,'default'=>v} : {'name'=>n})\n end\n end\n\n result = {}\n result['signature'] = image\n result['arguments'] = args\n #result['parameters'] = params\n result['block'] = block unless block.empty?\n result['returns'] = returns.strip if returns\n result\n end", "def display_method_info(method)\n page do\n @formatter.draw_line(method.full_name)\n display_params(method)\n\n @formatter.draw_line\n display_flow(method.comment)\n\n if method.aliases and not method.aliases.empty? then\n @formatter.blankline\n aka = \"(also known as #{method.aliases.map { |a| a.name }.join(', ')})\"\n @formatter.wrap aka\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the remote path in a config file. ==== Input [path : String : ''] Typically the name of a file, but it could be a path itself. ==== Output [String] A value that is the remote path as specified in a config file. ==== Examples remote_path => /good/remote/path remote_path 'blah' => /good/remote/blah/path remote_path '/blah' => /good/remote/blah/path
def remote_path(path = '') "/good/remote#{get_file_path(path)}/path" end
[ "def remote_path\n source || URL\n end", "def remote_path(local_path)\n relative = relativize(local_path)\n return if !relative\n sanitized = relative.gsub(/[^a-zA-Z0-9\\-_\\.\\/]/, '-')\n \"#{@remote_dir}#{sanitized}\"\n end", "def get_git_url_for_directory(dir_path)\n logger.debug \"trying to find git remote for: #{dir_path}\"\n conf = nil\n Dir.chdir(dir_path) do\n begin\n conf = `git config --local -l`\n rescue\n conf = nil\n end\n end\n return nil if conf.nil?\n conf.split(\"\\n\").each do |line|\n return Regexp.last_match(1) if line =~ /^remote\\.[^\\.]+\\.url=(.+)/\n end\n nil\n end", "def config_path\n @config_path ||= local_config_path\n end", "def remote_path\n ftp_server.url + '/' +full_path\n end", "def remoteFind( path, hash )\n\t\t\tconnect unless @connection\n\t\t\tc = @connection\n\n\t\t\tc.nlst(path).each do |item|\n\t\t\t\tnext if @ignore.include?( File.basename(item) )\n\n\t\t\t\t# To prevent looping & redundancy\n\t\t\t\tnext if [\".\", \"..\", File.join(path, \".\"), File.join(path, \"..\")].include?(item)\n\t\t\t\titem = File.join(path, item) if !item.include?(path)\n\n\t\t\t\t# Net::FTP will throw an FTPPermError\n\t\t\t\t# if trying to mtime a directory.\n\t\t\t\tbegin\n\t\t\t\t\thash[item] = c.mtime(item).to_i\n\t\t\t\trescue Net::FTPPermError\n\t\t\t\t\thash[item] = \"n/a\"\n\t\t\t\tend\n\n\t\t\t\t# So far I have not been able to find\n\t\t\t\t# any reliable equivalent of File.directory?\n\t\t\t\t# for remote files.\n\t\t\t\t# However, there's a heuristic we can use.\n\t\t\t\t# c.nlst(item).length > 1 means it's a directory,\n\t\t\t\t# since it will include at the very least \"item/.\"\n\t\t\t\t# and \"item/..\" (i.e. have a length of 2). If it's\n\t\t\t\t# a file, only the file itself will be included.\n\t\t\t\tif c.nlst(item).length > 1\n\t\t\t\t\tremoteFind( item, hash )\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn hash\n\t\tend", "def remote_origin_url path\n unless is_working_dir path\n raise NotGitRepo.new \"Not a Git repo: #{path}\"\n end\n\n %x{git --git-dir=#{path}/.git config --get remote.origin.url}\n end", "def server_path(file_path)\n target_path = Chef::ChefFS::PathUtils.realest_path(file_path, @cwd)\n\n # Check all object paths (cookbooks_dir, data_bags_dir, etc.)\n # These are either manually specified by the user or autogenerated relative\n # to chef_repo_path.\n object_paths.each_pair do |name, paths|\n paths.each do |path|\n object_abs_path = Chef::ChefFS::PathUtils.realest_path(path, @cwd)\n if relative_path = PathUtils.descendant_path(target_path, object_abs_path)\n return Chef::ChefFS::PathUtils.join(\"/#{name}\", relative_path)\n end\n end\n end\n\n # Check chef_repo_path\n Array(@chef_config[:chef_repo_path]).flatten.each do |chef_repo_path|\n # We're using realest_path here but we really don't need to - we can just expand the\n # path and use realpath because a repo_path if provided *must* exist.\n realest_chef_repo_path = Chef::ChefFS::PathUtils.realest_path(chef_repo_path, @cwd)\n if Chef::ChefFS::PathUtils.os_path_eq?(target_path, realest_chef_repo_path)\n return \"/\"\n end\n end\n\n nil\n end", "def remote_base\n @remote_base ||= [path, directory.split('/').last].select { |part|\n part && part.strip.length > 0\n }.join('/')\n end", "def custom_config_path\n argv.each_with_index do |arg, index|\n if arg == \"--config-path\" || arg == \"-c\"\n next_arg = argv[index + 1]\n raise ConfigPathNotProvided.new if next_arg.nil?\n raise ConfigPathInvalid.new(next_arg) unless File.file?(next_arg) && File.readable?(next_arg)\n\n return next_arg\n end\n end\n nil\n end", "def extract_path_from_config(config, key, root)\n value = config.delete(\"config.#{key}\") { DEFAULTS[key] }\n value.is_a?(String) ? root + value : value\n end", "def remote_path\n return \"https://forgeapi.puppetlabs.com/v3/files/#{@name}-#{@version}.tar.gz\"\n end", "def url_of_git_repo(remote_name)\n `git config remote.#{remote_name}.url`.strip\n end", "def to_local(path)\n local_abs_paths = []\n path.to_s.split(/\\s+/).each do |p|\n if p =~ /^#{remote}/\n p.sub!(/^#{remote}/, '')\n p.slice!(0) if p =~ /^\\//\n p = \"#{local}/#{p}\"\n else\n if Pathname.new(p).absolute?\n # No action required\n else\n p = \"#{local}/#{p}\"\n end\n end\n local_abs_paths << p\n end\n local_abs_paths\n end", "def scp_path(path)\n case determine_ssh_server\n when :bitvise\n # swap out separators\n network_path = path.gsub('\\\\', scp_separator)\n # pull off drive prefix since base BitVise dir is '/'\n network_path.gsub('C:', '')\n when :openssh\n path\n else\n raise ArgumentError(\"windows/file.rb:scp_path: ssh server not recognized: '#{determine_ssh_server}'\")\n end\n end", "def scp_path(path)\n path\n end", "def find_config_path\n path = Pathname(Pathname.pwd).ascend{|d| h=d+config_filename; break h if h.file?}\n end", "def getConfigPath\n if @conf[:config_name].index('/')\n return @conf[:config_name] if File.file?(@conf[:config_name])\n else \n @conf[:config_dirs].each {|i|\n r = Pathname.new(i) + @conf[:config_name]\n return r if File.file?(r)\n }\n end\n\n CliUtils.warnx \"no config file '#{@conf[:config_name]}' found\" if @conf[:verbose] >= 2\n return nil\n end", "def remote\n grit.config[\"branch.#{branch}.remote\"] || 'origin'\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /agent_types GET /agent_types.json
def index @agent_types = AgentType.all end
[ "def index\n @reagent_types = ReagentType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reagent_types }\n end\n end", "def retrieve_entity_types()\n start.uri('/api/entity/type')\n .get()\n .go()\n end", "def agent_types\n UserAgents::AGENT_TYPES.keys.map(&:to_s)\n end", "def types\n types = JSON.parse(connection.get(\"/Contact/Types\").body )\n end", "def types\n @client.make_request :get, reports_path\n end", "def show\n @agent_type = AgentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agent_type }\n end\n end", "def types\n get(\"/project/types\")[\"types\"]\n end", "def get_lesson_types\n get \"lessonTypes.json\"\n end", "def goal_types\n @client.request_cmd(\n {\n 'goal_types_get_list' => 1,\n 'app_version' => @version\n }\n )\n end", "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def index\n @user_agents = UserAgent.all\n\n render json: @user_agents\n end", "def ride_types(args = {})\n make_request(\n http_method: :get,\n endpoint: path_for(:ride_types),\n access_token: args.delete(:access_token),\n options: { query: args }\n )\n end", "def index\n @resource_types = ResourceType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end", "def types\n data = {\n 'sale_agent_role' => SaleAgent::ROLE_TYPES,\n 'transaction_type' => Entry::TYPES_TRANSACTION,\n 'author_role' => EntryAuthor::TYPES_ROLES,\n 'artist_role' => EntryArtist::TYPES_ROLES,\n 'currency' => Sale::CURRENCY_TYPES,\n 'sold' => Sale::SOLD_TYPES,\n 'material' => EntryMaterial::MATERIAL_TYPES,\n 'alt_size' => Entry::ALT_SIZE_TYPES,\n 'acquisition_method' => Provenance::ACQUISITION_METHOD_TYPES\n }\n render json: data\n end", "def cmdGoalTypesGetList\n params = {\n \"goal_types_get_list\" => 1,\n \"app_version\" => @config[\"version\"],\n }\n response = @client.request(params, @sid, true, false)\n serializer = Serializer.new(response)\n return serializer.parseGoalsTypes\n end", "def order_types\n url = \"#{@url}reference/order-types\"\n make_request(url)\n end", "def land_types(format: \"json\", pretty: false)\n request_catalogue(\"/catalog/land-types\", format, pretty)\n end", "def index\n @vehicle_types = VehicleType.all\n\n render json: @vehicle_types\n end", "def index\n @armor_types = ArmorType.all\n\n render json: @armor_types\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /agent_types POST /agent_types.json
def create @agent_type = AgentType.new(agent_type_params) respond_to do |format| if @agent_type.save format.html { redirect_to @agent_type, notice: 'Agent type was successfully created.' } format.json { render :show, status: :created, location: @agent_type } else format.html { render :new } format.json { render json: @agent_type.errors, status: :unprocessable_entity } end end end
[ "def create\n @agent_type = AgentType.new(params[:agent_type])\n\n respond_to do |format|\n if @agent_type.save\n format.html { redirect_to @agent_type, notice: 'Agent type was successfully created.' }\n format.json { render json: @agent_type, status: :created, location: @agent_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agent_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_agent_via_api(agent_type, opts = {})\n case agent_type\n when :person\n agent_json = if opts[:create_subrecords]\n build(:json_agent_person_full_subrec)\n else\n build(:json_agent_person)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/people\")\n when :corporate_entity\n agent_json = if opts[:create_subrecords]\n build(:json_agent_corporate_entity_full_subrec)\n else\n build(:json_agent_corporate_entity)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/corporate_entities\")\n when :family\n agent_json = if opts[:create_subrecords]\n build(:json_agent_family_full_subrec)\n else\n build(:json_agent_familly)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/families\")\n when :software\n agent_json = if opts[:create_subrecords]\n build(:json_agent_software_full_subrec)\n else\n build(:json_agent_software)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/software\")\n end\n\n response = JSONModel::HTTP.post_json(url, agent_json.to_json)\n json_response = ASUtils.json_parse(response.body)\n\n if json_response['status'] == 'Created'\n json_response['id']\n else\n -1\n end\nrescue StandardError => e\n -1\nend", "def create_agent_via_api(agent_type, opts = {})\n\tcase agent_type\n\twhen :person\n\t\tagent_json = opts[:create_subrecords] ? \n\t\t\tbuild(:json_agent_person_full_subrec) : \n\t\t\tbuild(:json_agent_person)\n\t\turl = URI(\"#{JSONModel::HTTP.backend_url}/agents/people\")\n\twhen :corporate_entity\n\t agent_json = opts[:create_subrecords] ? \n\t\t\tbuild(:json_agent_corporate_entity_full_subrec) : \n\t\t\tbuild(:json_agent_corporate_entity)\n\t\turl = URI(\"#{JSONModel::HTTP.backend_url}/agents/corporate_entities\")\n\twhen :family\n\t\tagent_json = opts[:create_subrecords] ? \n\t\t\tbuild(:json_agent_family_full_subrec) : \n\t\t\tbuild(:json_agent_familly)\n\t\turl = URI(\"#{JSONModel::HTTP.backend_url}/agents/families\")\n\twhen :software\n agent_json = opts[:create_subrecords] ? \n\t\t\tbuild(:json_agent_software_full_subrec) : \n\t\t\tbuild(:json_agent_software)\n\t\turl = URI(\"#{JSONModel::HTTP.backend_url}/agents/software\")\n\tend\n\n response = JSONModel::HTTP.post_json(url, agent_json.to_json)\n json_response = ASUtils.json_parse(response.body)\n\n if json_response[\"status\"] == \"Created\"\n return json_response[\"id\"]\n else\n return -1\n\tend\nrescue => e\n\treturn -1\nend", "def create\n @reagent_type = ReagentType.new(params[:reagent_type])\n\n respond_to do |format|\n if @reagent_type.save\n format.html { redirect_to @reagent_type, notice: 'Reagent type was successfully created.' }\n format.json { render json: @reagent_type, status: :created, location: @reagent_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reagent_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @agent_types = AgentType.all\n end", "def agent_types\n UserAgents::AGENT_TYPES.keys.map(&:to_s)\n end", "def create\n @agent_relationship_type = AgentRelationshipType.new(agent_relationship_type_params)\n\n respond_to do |format|\n if @agent_relationship_type.save\n format.html { redirect_to @agent_relationship_type, notice: t('controller.successfully_created', model: t('activerecord.models.agent_relationship_type')) }\n format.json { render json: @agent_relationship_type, status: :created, location: @agent_relationship_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agent_relationship_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @agent_type = AgentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agent_type }\n end\n end", "def create\n @agent = Agent.new(agent_params)\n\n respond_to do |format|\n if @agent.save\n case\n when @work\n @agent.works << @work\n when @manifestation\n @agent.manifestations << @manifestation\n when @item\n @agent.items << @item\n end\n format.html { redirect_to @agent, notice: t('controller.successfully_created', model: t('activerecord.models.agent')) }\n format.json { render json: @agent, status: :created, location: @agent }\n else\n prepare_options\n format.html { render action: \"new\" }\n format.json { render json: @agent.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @agency_type = AgencyType.new(params[:agency_type])\n\n respond_to do |format|\n if @agency_type.save\n format.html { redirect_to @agency_type, notice: 'Agency type was successfully created.' }\n format.json { render json: @agency_type, status: :created, location: @agency_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agency_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_entity_type(entity_type_id, request)\n start.uri('/api/entity/type')\n .url_segment(entity_type_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end", "def index\n @reagent_types = ReagentType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reagent_types }\n end\n end", "def meta_types\n request('meta_types').map { |ent| MetaType.create(ent) }\n end", "def create\n @agent = current_user.agents.new(agent_params)\n\n respond_to do |format|\n if @agent.save\n format.html { redirect_to @agent, notice: 'Agent was successfully created.' }\n format.json { render action: 'show', status: :created, location: @agent }\n else\n format.html { render action: 'new' }\n format.json { render json: @agent.errors, status: :unprocessable_entity }\n end\n end\n end", "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def create\n @user_agent = UserAgent.new(user_agent_params)\n\n if @user_agent.save\n render json: @user_agent, status: :created, location: @user_agent\n else\n render json: @user_agent.errors, status: :unprocessable_entity\n end\n end", "def create_types\n\t\t[]\n\tend", "def create\n @agent = Agent.new(agent_params)\n\n respond_to do |format|\n if @agent.save\n format.html { redirect_to agents_path: :index, notice: 'Agent was successfully created.' }\n format.json { render :show, status: :created, location: @agent }\n else\n format.html { render :new }\n format.json { render json: @agent.errors, status: :unprocessable_entity }\n end\n end\n end", "def types\n data = {\n 'sale_agent_role' => SaleAgent::ROLE_TYPES,\n 'transaction_type' => Entry::TYPES_TRANSACTION,\n 'author_role' => EntryAuthor::TYPES_ROLES,\n 'artist_role' => EntryArtist::TYPES_ROLES,\n 'currency' => Sale::CURRENCY_TYPES,\n 'sold' => Sale::SOLD_TYPES,\n 'material' => EntryMaterial::MATERIAL_TYPES,\n 'alt_size' => Entry::ALT_SIZE_TYPES,\n 'acquisition_method' => Provenance::ACQUISITION_METHOD_TYPES\n }\n render json: data\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /agent_types/1 PATCH/PUT /agent_types/1.json
def update respond_to do |format| if @agent_type.update(agent_type_params) format.html { redirect_to @agent_type, notice: 'Agent type was successfully updated.' } format.json { render :show, status: :ok, location: @agent_type } else format.html { render :edit } format.json { render json: @agent_type.errors, status: :unprocessable_entity } end end end
[ "def update\n @agent_type = AgentType.find(params[:id])\n\n respond_to do |format|\n if @agent_type.update_attributes(params[:agent_type])\n format.html { redirect_to @agent_type, notice: 'Agent type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @agent_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch_entity_type(entity_type_id, request)\n start.uri('/api/entity/type')\n .url_segment(entity_type_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .patch()\n .go()\n end", "def update\n @reagent_type = ReagentType.find(params[:id])\n\n respond_to do |format|\n if @reagent_type.update_attributes(params[:reagent_type])\n format.html { redirect_to @reagent_type, notice: 'Reagent type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reagent_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_entity_type(entity_type_id, request)\n start.uri('/api/entity/type')\n .url_segment(entity_type_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .put()\n .go()\n end", "def update\n @agency_type = AgencyType.find(params[:id])\n\n respond_to do |format|\n if @agency_type.update_attributes(params[:agency_type])\n format.html { redirect_to @agency_type, notice: 'Agency type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @agency_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @verb_type = VerbType.find(params[:id])\n\n respond_to do |format|\n if @verb_type.update_attributes(params[:verb_type])\n format.html { redirect_to @verb_type, notice: 'Verb type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @verb_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n json_update(factType,factType_params, FactType)\n end", "def update\n @custom_agent = CustomAgent.find(params[:id])\n\n respond_to do |format|\n if @custom_agent.update_attributes(params[:custom_agent])\n format.html { redirect_to @custom_agent, notice: 'Custom agent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @custom_agent.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @incident_type.update(incident_type_params)\n format.html { redirect_to admin_incident_types_path, notice: 'Incident type was successfully updated.' }\n format.json { render :show, status: :ok, location: @incident_type }\n else\n format.html { render :edit }\n format.json { render json: @incident_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @agent = Agent.find(params[:id])\n\n respond_to do |format|\n if @agent.update_attributes(params[:agent])\n format.html { redirect_to @agent, notice: 'Agent was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @agent.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client_type = ClientType.find(params[:id])\n\n respond_to do |format|\n if @client_type.update_attributes(params[:client_type])\n format.html { redirect_to @client_type, notice: 'Client type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @agent = @business.agents.find(params[:id])\n\n respond_to do |format|\n if @agent.update_attributes(agent_params || {})\n format.html { redirect_to business_agent_path(@business, @agent), notice: 'Agent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @agent.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @request_type = RequestType.find(params[:id])\n\n respond_to do |format|\n if @request_type.update_attributes(params[:request_type])\n format.html { redirect_to @request_type, notice: 'Request type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @request_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_admin_type.update(api_v1_admin_type_params)\n format.html { redirect_to @api_v1_admin_type, notice: 'Admin type was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_admin_type }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_admin_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @clienttype = Clienttype.find(params[:id])\n\n respond_to do |format|\n if @clienttype.update_attributes(params[:clienttype])\n format.html { redirect_to @clienttype }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clienttype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tracing_type.update(tracing_type_params)\n format.html { redirect_to @tracing_type, notice: 'Tracing type was successfully updated.' }\n format.json { render :show, status: :ok, location: @tracing_type }\n else\n format.html { render :edit }\n format.json { render json: @tracing_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @vehicle_type.update(vehicle_type_params)\n render json: @vehicle_type\n # 'vehicle_type was successfully updated.'\n else\n render json: @vehicle_type.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @client_type.update(client_type_params)\n format.html { redirect_to @client_type, notice: 'Client type was successfully updated.' }\n format.json { render :show, status: :ok, location: @client_type }\n else\n format.html { render :edit }\n format.json { render json: @client_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @incident_type = IncidentType.find(params[:id])\n\n respond_to do |format|\n if @incident_type.update_attributes(params[:incident_type])\n format.html { redirect_to @incident_type, notice: 'Incident type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @incident_type.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /agent_types/1 DELETE /agent_types/1.json
def destroy @agent_type.destroy respond_to do |format| format.html { redirect_to agent_types_url, notice: 'Agent type was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @agent_type = AgentType.find(params[:id])\n @agent_type.destroy\n\n respond_to do |format|\n format.html { redirect_to agent_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reagent_type = ReagentType.find(params[:id])\n @reagent_type.destroy\n\n respond_to do |format|\n format.html { redirect_to reagent_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @agency_type = AgencyType.find(params[:id])\n @agency_type.destroy\n\n respond_to do |format|\n format.html { redirect_to agency_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @agent_relationship_type.destroy\n\n respond_to do |format|\n format.html { redirect_to agent_relationship_types_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.agent_relationship_type')) }\n format.json { head :no_content }\n end\n end", "def destroy\n @agent.destroy\n respond_to do |format|\n format.html { redirect_to agents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @verb_type = VerbType.find(params[:id])\n @verb_type.destroy\n\n respond_to do |format|\n format.html { redirect_to verb_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @agent = Agent.find(params[:id])\n @agent.destroy\n\n respond_to do |format|\n format.html { redirect_to agents_url }\n format.json { head :ok }\n end\n end", "def destroy\n @client_type = ClientType.find(params[:id])\n @client_type.destroy\n\n respond_to do |format|\n format.html { redirect_to client_types_url }\n format.json { head :no_content }\n end\n end", "def delete_agent id\n\t\t\t\t\tbegin\n\t\t\t\t\t\t( @connection.delete AGENTS, id ).code\n\t\t\t\t\trescue Freshdesk::Api::ServerError\n\t\t\t\t\t\t200\n\t\t\t\t\tend\n\t\t\t\tend", "def destroy\n @agent_status = AgentStatus.find(params[:id])\n @agent_status.destroy\n\n respond_to do |format|\n format.html { redirect_to agent_statuses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @clienttype = Clienttype.find(params[:id])\n @clienttype.destroy\n\n respond_to do |format|\n format.html { redirect_to clienttypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @advertiser_type = AdvertiserType.find(params[:id])\n @advertiser_type.destroy\n\n respond_to do |format|\n format.html { redirect_to advertiser_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @hero_type.destroy\n respond_to do |format|\n format.html { redirect_to hero_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @incident_type = IncidentType.find(params[:id])\n @incident_type.destroy\n\n respond_to do |format|\n format.html { redirect_to incident_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @agente = Agente.find(params[:id])\n @agente.destroy\n\n respond_to do |format|\n format.html { redirect_to agenti_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @agent = @business.agents.find(params[:id])\n @agent.destroy\n\n respond_to do |format|\n format.html { redirect_to business_agents_url(@business) }\n format.json { head :no_content }\n end\n end", "def destroy\n @custom_agent = CustomAgent.find(params[:id])\n @custom_agent.destroy\n\n respond_to do |format|\n format.html { redirect_to custom_agents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ad_type = AdType.find(params[:id])\n @ad_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ad_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_admin_type.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_admin_types_url, notice: 'Admin type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a paragaph of ipsum text built from the phrase dictionary.
def build_paragraph @dictionary = Dictionary.new sentence_count.times.collect { build_sentence }.join(" ") end
[ "def paragraphs(\n word_count: rand(DEFAULT_WORD_COUNT_RANGE),\n sentence_count: rand(DEFAULT_SENTENCE_COUNT_RANGE),\n paragraph_count: rand(DEFAULT_PARAGRAPH_COUNT_RANGE),\n fillers: dictionnary.fillers,\n seperator: DEFAULT_PARAGRAPH_SEPARATOR\n )\n paragraph_count = 0 if paragraph_count.negative?\n paragraphs = []\n paragraph_count.times do\n p = paragraph(word_count: word_count, sentence_count: sentence_count, fillers: fillers)\n paragraphs << p unless p.empty?\n end\n paragraphs.join(seperator)\n end", "def paragraph(\n word_count: rand(DEFAULT_WORD_COUNT_RANGE),\n sentence_count: rand(DEFAULT_SENTENCE_COUNT_RANGE),\n fillers: dictionnary.fillers\n )\n sentence_count = 0 if sentence_count.negative?\n paragraph = []\n sentence_count.times do\n s = sentence(word_count: word_count, fillers: fillers)\n paragraph << s unless s.empty?\n end\n paragraph.join(' ')\n end", "def excerpt(text, phrase, *args)\n options = extract_options_from_args!(args) || {}\n unless args.empty?\n options[:radius] = args[0] || 100\n options[:omission] = args[1] || \"...\"\n end\n options.reverse_merge!(:radius => 100, :omission => \"...\")\n\n if text && phrase\n phrase = Regexp.escape(phrase)\n\n if found_pos = text =~ /(#{phrase})/i\n start_pos = [ found_pos - options[:radius], 0 ].max\n end_pos = [ [ found_pos + phrase.length + options[:radius] - 1, 0].max, text.length ].min\n\n prefix = start_pos > 0 ? options[:omission] : \"\"\n postfix = end_pos < text.length - 1 ? options[:omission] : \"\"\n\n prefix + text[start_pos..end_pos].strip + postfix\n else\n nil\n end\n end\n end", "def prepare_phrases\n text_array, prepared = @text.split, []\n 3.times do |time|\n prepared << random_phrase(text_array)\n end\n prepared\n end", "def phrases(query)\n parts = keywords(query)\n parts_size = parts.size\n\n [*0..parts_size]\n .combination(2)\n .map { |(a, b)| parts[a...parts_size - (b - a - 1)].join(' ') }\n end", "def phrases; end", "def paragraph(options={})\n count = rand_count options[:sentences] || (5..15)\n\n count.times.collect do |i|\n op = options.clone\n op.delete :punctuation unless i==count-1\n op.delete :first_word unless i==0\n sentence op\n end.join(\" \")\n end", "def paragraph\n ((1..(rand(3)+2)).map{sentence}).join(\" \")\n end", "def get_paragraph\n wo = self.words_from_markov_data\n\n self.paragraph_from_words(wo).strip\n end", "def get_sample_phrase_1\r\n \"the cat in the hat\"\r\n end", "def mathphrase\n p length = (1..20).to_a.sample\n sentence_array = []\n length.times do\n sentence_array << NUMBERS.sample\n sentence_array << OPERATORS.sample\n end\n sentence_array << NUMBERS.sample\n sentence_array.join(\" \").gsub(\"divided\", \"divided by\")\nend", "def paragraph(text)\n return if text.blank?\n\n create_opinion(\n (@last_position + 1 - @num_sections).to_s,\n text,\n Decidim::Opinions::ParticipatoryTextSection::LEVELS[:article]\n )\n\n text\n end", "def paragraphs(options={})\n count = rand_count options[:paragraphs] || (3..5)\n join_str = options[:join]\n\n res = count.times.collect do |i|\n op = options.clone\n op.delete :punctuation unless i==count-1\n op.delete :first_word unless i==0\n paragraph op\n end\n\n join_str!=false ? res.join(join_str || \"\\n\\n\") : res\n end", "def phrases\n quote = [' Let the dance begin.', ' Human or AI?', \" Let's dance.\"]\n quote[Random.rand(0...quote.length)]\n end", "def create_phrase\n @phrase_text = add_text(base_x, base_y, 0, 16, @phrase)\n end", "def html_paragraphs(text)\n h(text).split(/\\n\\s*\\n/).collect { |para| \"<p>#{para}</p>\" }.join(\"\\n\")\n end", "def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3)\n sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')\n end", "def sandwich(sentences: 3, repeat: 1)\n text_block = []\n text_block << heading\n repeat.times do\n text_block << paragraph(sentence_count: sentences)\n text_block << random(exclude: %i[script link])\n end\n text_block.join(\"\\n\")\n end", "def lorem count=1\n res = []\n count.times { res << Lipsum.paragraph }\n \"<p>#{res.join(\"</p>\\n<p>\")}</p>\".html_safe\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Capitalizes the first word of a sentence, but leaves all other capitalization untouched.
def capitalize_sentence(sentence) sentence.slice(0,1).capitalize + sentence.slice(1..-1) end
[ "def capitalise_first_word\n @title = @title.slice(0,1).upcase + @title.slice(1..-1)\n end", "def capitalize_sentence text\n words = text.split(\" \").map { |word| word.capitalize }\n words.join(\" \")\n end", "def capitalize(sentence)\n sentence.split.map do |word|\n word[0].upcase + word[1..-1]\n end.join(' ')\nend", "def titleize(sentence)\n\tret = \"\"\n\twords = sentence.split(\" \")\n\n\t#These are the words NOT to be capitalized if they are not the first word\n\t#The test case includes over as a little_word\n\tlittle_words = [\"a\", \"an\", \"and\", \"the\", \"over\"]\n\n\twords.each_with_index do |word, i|\n\t\tif(i > 0)\n\t\t\tif(little_words.include?(word))\n\t\t\t\tret << word + \" \"\n\t\t\telse\n\t\t\t\tret << word.capitalize + \" \"\n\t\t\tend\n\t\telse\n\t\t\t#capitalize the first word, regardless of if it is a little_word\n\t\t\tret << word.capitalize + \" \"\n\t\tend\n\tend\n\n\tret[0..-2]\nend", "def capitalize_most_words\n \tself.split.collect{ |w| words_to_skip_capitalization_of.include?(w.downcase) ? w : w.capitalize_first }.join(\" \").capitalize_first\n end", "def uncapitalize\n (self.length > 0) ? (self[0, 1].downcase + self[1..-1]) : \"\"\n end", "def word_cap(sentence)\n words = sentence.split(' ')\n capitalized_words = []\n words.each do |word|\n capitalized_words << word.capitalize\n end\n capitalized_words.join(' ')\nend", "def capitalize() end", "def capitalize(word)\n word[0, 1].upcase + word[1 .. -1]\n end", "def capitalize str=''\n str.sub(/(>(.))|(^\\w)/){|s| s.upcase }\n end", "def capitalize!\n modify = nil\n first = self[0].chr\n if islower first then\n self[0] = toupper first\n modify = self\n end\n\n 1.upto(self.length - 1) do |i|\n cur = self[i].chr\n if isupper cur then\n self[i] = tolower cur\n modify = self\n end\n end\n\n return modify\n end", "def ucfirst\n self.sub(/^(\\w)/) { |s| s.capitalize }\n end", "def capitalize!() end", "def titleize_a_string(string)\nsentence = string.capitalize!.split(' ')\n words_not_to_capitalize = ['a', 'and', 'the']\n\n sentence.each do |word|\n word.capitalize! unless words_not_to_capitalize.include?(word)\n end.join(' ')\n\nend", "def capitalize(input); end", "def getCapitalizedFirst(str)\n newStr = String.new\n newStr += str[0, 1].capitalize\n\n if (str.length > 1)\n newStr += str[1..str.length - 1]\n end\n\n return(newStr)\n end", "def titleize(sentence)\n\twords = sentence.split\n\t# shorties = %w{and over the}\n\t# adding words for use in later book exercise\n\tshorties = %w{and over the a an to in of}\n\twords.each_with_index do |word, index|\n\t\t(index == 0 || !shorties.include?(word)) ? word.capitalize! : word\n\tend\n\twords.join(\" \")\nend", "def capitalize_each_word(phrase)\n phrase.downcase!\n phrase = phrase.split(\" \")\n idx = 0\n while idx < phrase.length\n phrase[idx].capitalize!\n idx+=1\n end\n phrase.join(\" \")\nend", "def capitalise_after_period\n\t\t@title = @title.gsub(/(\\.(\\s+)([a-z]))/) {|word| word.upcase }\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Inserts a comma into a word array.
def insert_comma_into_words(words) comma_index = rand(MIN_WORDS_BEFORE_COMMA..(words.length - MIN_WORDS_AFTER_COMMA - 1)) words[comma_index] += "," words end
[ "def shift_comma!\n gsub!(/,(?!\\d)/o, ' , '.freeze)\n gsub!(/(?<=\\D),(?=\\S+)/, ' , '.freeze)\n end", "def on_comma(value); end", "def comma\n self << ','\n end", "def oxford_comma(array)\n case array.length \nwhen 1\n \"#{array[0]}\"\nwhen 2\n array[0..1].join(\" and \")\nelse \n array[0...-1].join(\", \") << \", and #{array[-1]}\"\nend \nend", "def oxford_comma(array)\n case array.size\n when 0\n \"\"\n when 1\n array.first\n when 2\n array.join(' and ')\n else\n [array[0..-2].join(', '), array.last].join(', and ')\n end\nend", "def space_around_comma!\n substitute!(/[[:space:]]*,[[:space:]]*/, ',\n ')\n end", "def oxford_comma(array)\n if array.length == 1\n array.join\n elsif array.length == 2\n array.join(\" and \")\n else\n tempvar = array.pop\n returnvar = array.join(\", \") + \", and \" + tempvar\n returnvar\n end\nend", "def do_comma s; a = mega_pop(s); String == a.class ? s[:output] << \"#{a}\" : s[:output] << \"#{a.chr}\" end", "def oxford_comma(array)\n if array.size <= 1\n array.join \n elsif array.size == 2\n array.join(\" and \")\n else\n array[-1] = \"and #{array[-1]}\"\n array.join(\", \")\n end\nend", "def comma(str, *phrases)\n _concat([\", \", str])\n _inspect(phrases)\n end", "def update_comma_tags(input)\n return if self.id.nil? # Disable if not saved\n\n Tag.where(:listing => self.id).delete_all\n if input.include?(', ') then\n input.split(', ').each do |tag|\n self.insert_tag(tag)\n end\n else\n self.insert_tag(input)\n end\n\n end", "def comma\n match(Token.new(:symbol, ','))\n end", "def comma_breakable; end", "def separate_comma (num)\n\n word = num.to_s\n word = word.split(//).reverse\n \n new_word = []\n \n word.each_slice(3) do |letter|\n new_word.push(letter)\n new_word.push(',') \n end\n\n new_word.flatten.reverse.join(' ') \n p new_word[1..-1]\nend", "def encode_array(arr)\n arr.join ','\n end", "def format_words(words)\n return \"\" if words.empty?\n return words.join if words.size <= 1\n words = words.join(\" \").split()\n ending = words.slice!(-2, 2).join(' and ')\n words.push(ending).join(', ')\nend", "def format_comma_and(array)\n case array.size\n when 0 then ''\n when 1 then array[0]\n when 2 then \"#{array[0]} and #{array[1]}\"\n else \"#{array[0]}, #{format_comma_and(array[1..-1])}\"\n end\nend", "def oxford_comma_list(strings)\n if strings.size == 0\n \"\"\n elsif strings.size == 1\n strings.first\n else\n strings[0...-1].join(\", \") + (strings.size > 2 ? \",\" : \"\") +\n \" & \"+ strings.last\n end\n end", "def comma(str)\n \"#{str.to_s},\"\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determine the number of paragraphs. Count should be a number greater than or equal to one, no more than PARAGRAPH_COUNT_MAX.
def paragraph_count(count) count.to_i < 1 ? PARAGRAPH_COUNT_DEFAULT : [count.to_i, PARAGRAPH_COUNT_MAX].min end
[ "def num_paragraphs\r\n paragraphs.length\r\n end", "def num_paragraphs\n @paragraphs.length\n end", "def num_paragraphs\n @paragraphs.length\n end", "def paragraph_counter\n # Separate pharagraphs \n paras = @text.split(\"\\n\", -1)\n paras.count.times do |i|\n # Removes new line characters\n paras[i] = paras[i].gsub(\"\\n\", \"\")\n end\n @paragraph = paras\n return @paragraph.count\n end", "def paragraph_count\n ng_xml.css(\"fits > metadata > document > paragraphCount\").map(&:text)\n end", "def paragraphs(\n word_count: rand(DEFAULT_WORD_COUNT_RANGE),\n sentence_count: rand(DEFAULT_SENTENCE_COUNT_RANGE),\n paragraph_count: rand(DEFAULT_PARAGRAPH_COUNT_RANGE),\n fillers: dictionnary.fillers,\n seperator: DEFAULT_PARAGRAPH_SEPARATOR\n )\n paragraph_count = 0 if paragraph_count.negative?\n paragraphs = []\n paragraph_count.times do\n p = paragraph(word_count: word_count, sentence_count: sentence_count, fillers: fillers)\n paragraphs << p unless p.empty?\n end\n paragraphs.join(seperator)\n end", "def paragraph_count(all_lines_from_file)\n all_lines_from_file.split(/\\n\\n/).length\nend", "def table_count_paragraph(paragraph)\n counter = 0\n paragraph.nonempty_runs.each do |run|\n next if run.is_a?(OoxmlParser::DocxFormula)\n counter += table_count_in_graphic_data(run)\n counter += table_count_in_element_list(run.shape)\n end\n counter\n end", "def page_count(n, p)\n p / 2 < ((n + 1) % 2 + n - p) / 2 ? p / 2 : ((n + 1) % 2 + n - p) / 2\n end", "def output_paragraphs\n if @number <= self.class.total_included_paragraphs\n PARAGRAPHS[0, @number].join(\"\\n\\n\")\n else\n repeat = (@number / self.class.total_included_paragraphs.to_f).ceil\n (PARAGRAPHS * repeat)[0, @number].join(\"\\n\\n\")\n end\n end", "def pages\n page_count = 0\n\n # If the document is not rendered yet\n if @pdf.page_count == 0\n sandbox do\n render\n page_count = @pdf.page_count\n end\n else\n page_count = @pdf.page_count\n end\n\n return page_count\n end", "def page_count\n return 1 unless previewable? && !viewable_image?\n\n self.class.check_pdftoppm_exists!\n\n Rails.cache.fetch(cache_key(:page_count)) do\n IO.popen [SecureView::Config.pdfinfo_path, path] do |res|\n page_res = res.read.scan(/^Pages: \\s*(\\d+)/)\n return nil unless page_res.first&.first\n\n return page_res.first.first.to_i\n end\n end\n end", "def page_count\n return 1 unless previewable? && !viewable_image?\n\n self.class.check_pdftoppm_exists!\n\n Rails.cache.fetch(cache_key(:page_count)) do\n IO.popen [SecureView::Config.pdfinfo_path, path] do |res|\n page_res = res.read.scan(/^Pages: \\s*(\\d+)/)\n return unless page_res.first&.first\n\n return page_res.first.first.to_i\n end\n end\n end", "def count\n @text_blocks.count\n end", "def count\n @document.page_count\n end", "def number_of_slides(doc)\n count = 0\n doc.css(\"div.ep-nav ul li\").each do |i|\n count += 1\n end\n return count\n end", "def count_sentences\n self.split.count do |num|\n num.end_with?(\".\", \"?\", \"!\")\n # binding.pry\n end\n end", "def words_per_page\n @text.split.size / pages_count\n end", "def pages_count\n instance_read(:pages_count)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin Using the multiply method from the "Multiplying Two Numbers" problem, write a method that computes the square of its argument (the square is the result of multiplying a number by itself). Example: square(5) == 25 square(8) == 64 Further Exploration What if we wanted generalize this method to a "power to the n" type method: cubed, to the 4th power, to the 5th, etc. How would we go about doing so while still using the multiply method? =end
def square(num) multiply(num, num) end
[ "def square(number)\r\n multiply(number, number)\r\nend", "def square(a)\n multiply(a, a)\nend", "def square_num(num)\n return num*num\nend", "def square\n self * self\n end", "def square(term)\n return term * term\nend", "def square_numb(numb)\n return numb**2\nend", "def square(term1)\n return term1.to_i ** 2\nend", "def square_number(number)\n puts \"The result of squaring #{number} is #{number ** 2} \"\nend", "def power(num_one, num_two)\n return num_one ** num_two\nend", "def power(number1, number2)\n return number1 ** number2\nend", "def product(num1, num2)\n num1 * num2\nend", "def multiply\n\t22*44\nend", "def multiplyNumber2(number)\n p number *2\n end", "def multiply(a, b)\n if b == 0\n return 0\n elsif a == 0\n return 0\n elsif b == 1\n return a\n elsif a == 1\n return b\n else\n b = b - 1\n prod = a + multiply(a, b)\n return prod\n end\nend", "def calculate_product(num1, num2)\n num1 * num2\nend", "def magical_well(a, b, n)\n answer = 0\n n.times do\n answer += (a * b)\n a += 1\n b += 1\n end\n answer\nend", "def multiply(array, num_two)\n array * num_two\nend", "def calculate_product(a,b)\n a*b\nend", "def multiply\n 22*44\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Enables a given feature id
def enable_feature(feature_id) Request.request('POST',{'id': feature_id}, "apps/#{self.app_key}/features" ) end
[ "def user_enable_feature(user_id, feature)\n @tropo_client.post(\"users/#{user_id}/features\", { :feature => feature })\n end", "def enable(id)\n change_status id, true\n end", "def enable(id)\n change_status id, true\n end", "def enable(feature)\n create_or_update_feature_flags(feature.to_sym => true)\n end", "def enable(community_id:, person_id: nil, features:)\n if features.blank?\n return Result::Error.new(\"You must specify one or more flags in #{@feature_flag_store.known_flags} to enable.\")\n end\n\n Result::Success.new(@feature_flag_store.enable(community_id, person_id, features))\n end", "def enable_feature(feature_name)\n feature(feature_name, true)\n end", "def enable_feature!(name)\n unless feature_enabled?(name)\n self.features_plans.create :feature => service.features.find_by_system_name!(name.to_s)\n end\n end", "def enable(name, *args)\n feature(name).enable(*args)\n end", "def enable_feature_for(plugin, *raw_features)\n PluginList.find_plugin! plugin\n _resolve_features(plugin, raw_features).each do |feature|\n f = self.features[plugin][feature]\n next if f.enabled?\n f.enable\n end\n end", "def set_feature!(name, enabled)\n if enabled\n enable_feature!(name)\n else\n disable_feature!(name)\n end\n end", "def enable(feature, gate, thing)\n case gate.data_type\n when :boolean, :integer\n @client.put key(feature, gate), thing.value.to_s\n when :set\n @client.put set_member_key(feature, gate, thing), '1'\n else\n unsupported_data_type gate.data_type\n end\n\n true\n end", "def enable\n feature_name = shift_argument\n error \"Usage: heroku features:enable FEATURE\\nMust specify FEATURE to enable.\" unless feature_name\n validate_arguments!\n\n feature = api.get_features.body.detect { |f| f[\"name\"] == feature_name }\n message = \"Enabling #{feature_name} \"\n\n error \"No such feature: #{feature_name}\" unless feature\n\n if feature[\"kind\"] == \"user\"\n message += \"for #{Heroku::Auth.user}\"\n else\n error \"Must specify an app\" unless app\n message += \"for #{app}\"\n end\n\n feature_data = action(message) do\n api.post_feature(feature_name, app).body\n end\n\n display \"For more information see: #{feature_data[\"docs\"]}\" if feature_data[\"docs\"]\n end", "def enable_features(feature_names)\n self.enabled_features = feature_names\n end", "def enable\n feature_name = shift_argument\n error \"Usage: heroku labs:enable FEATURE\\nMust specify FEATURE to enable.\" unless feature_name\n validate_arguments!\n\n feature = api.get_features.body.detect { |f| f[\"name\"] == feature_name }\n message = \"Enabling #{feature_name} \"\n\n error \"No such feature: #{feature_name}\" unless feature\n\n if feature[\"kind\"] == \"user\"\n message += \"for #{Heroku::Auth.user}\"\n else\n error \"Must specify an app\" unless app\n message += \"for #{app}\"\n end\n\n feature_data = action(message) do\n api.post_feature(feature_name, app).body\n end\n\n display \"WARNING: This feature is experimental and may change or be removed without notice.\"\n display \"For more information see: #{feature_data[\"docs\"]}\" if feature_data[\"docs\"]\n end", "def set_FeatureID(value)\n set_input(\"FeatureID\", value)\n end", "def enable\n\t\t@attribute = Attribute.find(params[:id])\n\t\t\n\t\trespond_to do |format|\n\t\t\tif @attribute.update_attribute(:enabled, true)\n\t\t\t\tformat.html { redirect_to attributes_url, notice: \"Attribute Enabled\" }\n\t\t\t\tformat.json\t{ head :ok }\n\t\t\telse\n\t\t\t\tformat.html { redirect_to attributes_url, notice: \"There was an error enabling this Attribute\" }\n\t\t\t\tformat.json\t{ render json: @attribute.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\t\t\n\tend", "def enable(thing)\n toggle.enable(thing)\n end", "def enable(feature, gate, thing)\n case gate.data_type\n when :boolean, :integer\n update feature.key, gate.key, thing.value.to_s\n when :set\n update feature.key, to_field(gate, thing), thing.value.to_s\n else\n unsupported_data_type gate.data_type\n end\n\n true\n end", "def enable\n if feature_name = args.shift\n feature_name = feature_name.downcase.strip\n else\n error(\"Usage: heroku labs:enable FEATURE\")\n end\n message = \"Enabling #{feature_name}\"\n message += \" for #{app}\" if app\n action(message) do\n heroku.enable_feature(app, feature_name)\n end\n display \"WARNING: This feature is experimental and may change or be removed without notice.\"\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Disables a given feature id
def disable_feature(feature_id) Request.request('DELETE', '', "apps/#{self.app_key}/features/#{feature_id}") end
[ "def user_disable_feature(user_id, feature_number)\n @tropo_client.delete(\"users/#{user_id}/features/#{feature_number}\")\n end", "def disable(feature)\n create_or_update_feature_flags(feature.to_sym => false)\n end", "def disable(id)\n change_status id, false\n end", "def disable(feature)\n set(feature, false)\n end", "def disable(community_id:, person_id: nil, features:)\n if features.blank?\n return Result::Error.new(\"You must specify one or more flags in #{@feature_flag_store.known_flags} to disable.\")\n end\n\n Result::Success.new(@feature_flag_store.disable(community_id, person_id, features))\n end", "def disable(name, *args)\n feature(name).disable(*args)\n end", "def disable(thing)\n toggle.disable(thing)\n end", "def disable\n feature_name = shift_argument\n error \"Usage: heroku labs:disable FEATURE\\nMust specify FEATURE to disable.\" unless feature_name\n validate_arguments!\n\n feature = api.get_features(app).body.detect { |f| f[\"name\"] == feature_name }\n message = \"Disabling #{feature_name} \"\n\n error \"No such feature: #{feature_name}\" unless feature\n\n if feature[\"kind\"] == \"user\"\n message += \"for #{Heroku::Auth.user}\"\n else\n error \"Must specify an app\" unless app\n message += \"for #{app}\"\n end\n\n action message do\n api.delete_feature feature_name, app\n end\n end", "def disable(feature, gate, thing)\n case gate.data_type\n when :boolean\n @client.delete build_path(feature), recurse: true\n when :integer\n @client.put key(feature, gate), thing.value.to_s\n when :set\n @client.delete set_member_key(feature, gate, thing)\n else\n unsupported_data_type gate.data_type\n end\n\n true\n end", "def disable\n feature_name = shift_argument\n error \"Usage: heroku features:disable FEATURE\\nMust specify FEATURE to disable.\" unless feature_name\n validate_arguments!\n\n feature = api.get_features(app).body.detect { |f| f[\"name\"] == feature_name }\n message = \"Disabling #{feature_name} \"\n\n error \"No such feature: #{feature_name}\" unless feature\n\n if feature[\"kind\"] == \"user\"\n message += \"for #{Heroku::Auth.user}\"\n else\n error \"Must specify an app\" unless app\n message += \"for #{app}\"\n end\n\n action message do\n api.delete_feature feature_name, app\n end\n end", "def disable\n if feature_name = args.shift\n feature_name = feature_name.downcase.strip\n else\n error(\"Usage: heroku labs:disable FEATURE\")\n end\n message = \"Disabling #{feature_name}\"\n message += \" for #{app}\" if app\n action(message) do\n heroku.disable_feature(app, feature_name)\n end\n end", "def disable(feature, gate, thing)\n case gate.data_type\n when :boolean\n delete feature.key\n when :integer\n update feature.key, gate.key, thing.value.to_s\n when :set\n delete feature.key, to_field(gate, thing)\n else\n unsupported_data_type gate.data_type\n end\n\n true\n end", "def disable(*features)\n @disabled_features.concat features.flatten\n end", "def disableChecker(id)\n @availableCheckers.collect {|x| x.enabled = false if x.id == id} \n end", "def disable(capability)\n check_pid\n @caps[:effective].delete(capability)\n save\n end", "def disable\n disable_features :all\n end", "def disable\n\t\t@attribute = Attribute.find(params[:id])\n\t\t\n\t\trespond_to do |format|\n\t\t\tif @attribute.update_attribute(:enabled, false)\n\t\t\t\tformat.html { redirect_to attributes_url, notice: \"Attribute Disabled\" }\n\t\t\t\tformat.json\t{ head :ok }\n\t\t\telse\n\t\t\t\tformat.html { redirect_to attributes_url, notice: \"There was an error disabling this Attribute\" }\n\t\t\t\tformat.json\t{ render json: @attribute.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\t\t\n\tend", "def disable(serverid, backend = nil)\n if server_instances.has_key?(serverid)\n server = server_instances[serverid]\n server.disable(backend)\n else\n raise \"InvalidServerId\"\n end\n end", "def disable!\n set_enabled!(false)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Type is :read, :write or :read_write
def has_access?(type) case type when :read read_write.include? 'r' when :write read_write.include? 'w' when :read_write, :write_read read_write == 'rw' end end
[ "def readwrite(*fields)\n readable(*fields)\n writable(*fields)\n allow(*fields)\n nil\n end", "def allows_write?\n [\"ADMIN\", \"WRITE\"].include?(self.mode)\n end", "def current_operation\n if %w[create update destroy].include?(action_name)\n :write\n else\n :read\n end\n end", "def writeable?\n return @access_mode == Pho::READ_WRITE\n end", "def read_method=(val)\n @read_method = val if %w(:flock :normal).include?(val)\n end", "def readwrite(*fields)\n readable(*fields)\n writable(*fields)\n nil\n end", "def read?\n self.status == 'read'\n end", "def read_write?(name, tag)\n !readonly?(name, tag)\n end", "def writable?() end", "def read?\n (status == READ)\n end", "def other_writable?(mode)\n mode & 00002 == 00002\n end", "def writeable?\n flags.include? FLAG_WRITE\n end", "def read!\n self.update_attribute(:status, READ)\n end", "def user_writable?(mode)\n mode & 00200 == 00200\n end", "def new_model_access\n self.new_model? ? :read_write : :read\n end", "def define_read_field_method(field_type)\n define_method field_type do\n self[field_type]\n end\n end", "def type\n case super\n when 'get' then :get\n when 'set' then :set\n when 'result' then :result\n when 'error' then :error\n else nil\n end\n end", "def rw\n [read? && \"R\", write? && \"W\"].compact.join\n end", "def to_r_or_w(action)\n case action\n when :list then :r\n when :read then :r\n when :create then :w\n when :update then :w\n when :delete then :w\n else raise \"Unexpected action : #{action.inspect}\"\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Step through every SVG file in the app/assets/images/icons directory in the rails app. We only look at toplevel "g" elements, and strip their interfering attributes.
def process_icons icons_dir = Rails.root.join('app', 'assets', 'images', 'icons') tmpl = File.read(File.expand_path("./templates/icon.svg.erb", __dir__)) Dir.glob("#{icons_dir}/*.svg").each do |file| icon_name = File.basename(file, '.svg') doc = Nokogiri::XML(File.read(file)) icon_content = strip_attrs(doc).css('svg > g').to_s @svg_content += ERB.new(tmpl).result(binding) end end
[ "def clear_svgs(dirPath)\n Dir.open(dirPath).each do |filename|\n # skip directory entries\n next if File.directory? filename\n # skip non svg entries\n next if !filename.include? \"svg\"\n # remove all files in xcode that match the svg file in the assets directory\n $project.files.each do |file|\n if file.name == filename\n file.remove_from_project\n end\n end\n end\nend", "def svg!\n attr = ->(node) { ['src', 'data'].find {|k| node[k]} }\n @doc.css('img,iframe,embed,object[type=\"image/svg+xml\"]').select do |node|\n src = attr.call node\n Transformer.local_img?(node, ['src', 'data']) && MiniMime.lookup_by_filename(node[src])&.content_type == 'image/svg+xml'\n end.each do |node|\n src = attr.call node\n node[src] = \"data:image/svg+xml;base64,#{Base64.strict_encode64(File.read node[src])}\"\n end\n end", "def wrap_icons\n tmpl = File.read(File.expand_path('./templates/icon_wrapper.svg.erb', __dir__))\n @icons_sprite = ERB.new(tmpl).result(binding)\n end", "def extract_svg(svg_font, output_dir)\n doc = Nokogiri::XML(open(svg_font)).remove_namespaces!\n\n doc.xpath('//glyph').each_with_index do |glyph, i|\n file_name = glyph.attr('glyph-name') || format('%04d', i)\n full_path = File.join(output_dir, \"#{file_name}.svg\")\n puts \"Extracting #{file_name}...\"\n write_file_from_glyph(Hash[glyph.to_a], full_path)\n end\nend", "def material_icon_svg\n @@material_icon_svg.reset\n end", "def trumbowyg_icons\n send_file \"#{LatoView::Engine.root}/app/assets/images/lato_view/vendor/trumbowyg_icons.svg\", type: 'image/svg+xml'\n end", "def linkify_avatar_in_svg(svg_file_name, g, avatar_dir)\n avatar_map = build_avatar_map(g)\n svg_file = File.new(svg_file_name)\n lines = svg_file.readlines\n svg_file.close\n\n lines.each do |line|\n if line.index(\"<image\") == 0\n uid = Frienda::Helper.extract_uid(line)\n avatar_url = avatar_map[uid]\n avatar_local_file = File.join(File.expand_path(avatar_dir), \"#{uid}.#{avatar_url[-3, 3]}\")\n line.sub!(avatar_local_file, avatar_url)\n LOGGER.debug \"Substitue #{avatar_local_file} with #{avatar_url} in SVG file.\"\n end\n end\n\n File.open(svg_file.path, 'w') do |file|\n lines.each {|line| file.write(line)}\n end\n\n system \"java -Xmx#{CONFIG['max_memory']} -jar lib/jar/batik-rasterizer.jar report/#{File.basename(svg_file.path)}\" if CONFIG['generate_complex_png']\nend", "def strip_images(node)\n node.css('img').each do |img|\n match = ASSET_IMAGE_SRC_REGEX.match(img['src'])\n\n insert_tag(HANDLEBARS_TEMPLATE_ASSET_IMAGE % match[1].to_i) if match\n img.remove\n end\n\n node\n end", "def images\n embedded_images = Set.new\n\n defs = dom.create_element(\"def\")\n\n # assuming the images are the correct size, declare their size\n dom.css(\"image\").each do |img|\n file_name = img.attributes[\"href\"].value\n id = file_name.split(\".\").first.split(\"/\").last\n if file_name =~ /\\.svg$/ && ! embedded_images.include?(file_name)\n src = parse_dom(File.read(file_name)).at(\"svg\")\n g = dom.create_element(\"g\", id: id,\n width: src[\"width\"], height: src[\"height\"])\n defs.add_child(g)\n src.children.each do |child|\n g.add_child(child.clone)\n end\n embedded_images << file_name\n end\n\n img.name=\"use\"\n img.attributes[\"href\"].value=\"##{id}\"\n #img.attributes[\"width\"].remove\n #img.attributes[\"height\"].remove\n #img.attributes[\"preserveAspectRatio\"].remove\n end\n defs\n end", "def remove_app_icon_assets(latest_release_pkg_path)\n FileUtils.rm_r(Dir.glob(\"#{app_icon_asset_path(latest_release_pkg_path)}/*.png\"))\nend", "def link_svgs(dirPath, assets)\n Dir.open(dirPath).each do |filename|\n # skip directory entries\n next if File.directory? filename\n # skip non svg entries\n next if !filename.include? \"svg\"\n \n # add svg relative to .xcodeproj\n file = $SVG_group.new_file('../assets/'+assets+'/'+filename)\n # get ref to the main build target\n main_target = $project.targets.first\n # add to build target\n main_target.add_file_references([file])\n # add the svg file into the resources build phase, the svgs are not included in the app bundle without this\n main_target.resources_build_phase.add_file_reference(file)\n end\nend", "def augment_svg(svg_file, svg_out, add_fragment_index: false)\n def get_classes(element)\n attr = element.attribute('class')\n if attr\n Set.new(attr.value.split(/\\s+/))\n else\n Set.new([])\n end\n end\n\n def set_classes(element, collection)\n if collection.empty?\n element.remove_attribute('class')\n else\n element['class'] = collection.to_a.join(\" \")\n end\n element['class']\n end\n\n def add_class(element, class_name)\n classes = get_classes(element)\n classes.add(class_name)\n set_classes(element, classes)\n end\n\n def remove_class(element, class_name)\n classes = get_classes(element)\n classes.delete(class_name)\n set_classes(element, classes)\n end\n\n def add_fragment(element)\n add_class(element, 'fragment')\n end\n\n def remove_fragment(g)\n remove_class(g, 'fragment')\n g.remove_attribute('data-fragment-index')\n end\n\n image = File.open(svg_file) { |f| Nokogiri::XML(f) }\n image.remove_namespaces!\n layers = image.xpath(\"//g[@id]\")\n\n if layers.length == 0\n # Nothing to do\n elsif layers.length == 1\n # There's only one layer. No sense causing incremental display.\n # Remove any existing fragments.\n puts \"Image #{svg_file} is a single-layer image. No animation.\"\n g = layers[0]\n remove_fragment(g)\n else\n layers.each_with_index do |g, i|\n # Don't mark the first layer; that should show up when the slide\n # shows up.\n if i == 0\n remove_fragment(g)\n else\n add_fragment(g)\n\n if add_fragment_index\n g['data-fragment-index'] = i.to_s\n end\n end\n\n id = g.attribute('id')\n if id.value.include?('one-time')\n add_class(g, 'current-visible')\n end\n end\n end\n\n #%w{x y viewBox height width}.each { |attr| image.root.delete(attr) }\n %w{x y height width}.each { |attr| image.root.delete(attr) }\n File.open svg_out, \"w\" do |f|\n # Skip to the SVG element, in case there's a processing instruction or\n # doctype. They're not necessary, since we're embedding.\n f.write(image.at_xpath('//svg').to_xml)\n end\n\nend", "def embedded_svg(filename, options = {})\n # assets = Rails.application.assets\n # file = assets.find_asset(filename).source.force_encoding(\"UTF-8\")\n File.open(\"app/assets/images/#{filename}\", 'rb') do |file|\n doc = Nokogiri::HTML::DocumentFragment.parse file\n svg = doc.at_css \"svg\"\n if options[:class].present?\n svg[\"class\"] = options[:class]\n end\n raw doc\n end\n end", "def svg\n browser.first(:xpath, \"//*[local-name() = 'svg']\")\n end", "def index\n @svg_images = SvgImage.all\n end", "def libguides_icons(document)\n icons = []\n\n raw_icons = []\n raw_icons = document['icons_tesim'].first.split(\"\\n\").reject!(&:blank?) unless document['icons_tesim'].blank?\n\n raw_icons.each_slice(7) do |raw|\n raw = raw.map(&:strip)\n icon = { id: raw[0], site_id: raw[1], file: raw[2], description: raw[3], url: raw[4] }\n icons << icon\n end\n\n icons\n end", "def show_svg(path)\n File.open(\"app/assets/images/svg_img/#{path}\", \"rb\") do |file|\n raw file.read\n end\n end", "def removeGif(file)\n \n doc = Nokogiri::HTML(open(file))\n doc.search(\"//a[@href='http://www.avantstar.com']\").each {|g| g.remove }\n \n doc.search(\"//img\").each {|j| puts j }\n \n \n output = File.open(file,'w')\n output << doc.to_xml\n output.close\n \n end", "def fix_indentation\n @icons_sprite = Nokogiri::XML(@icons_sprite, &:noblanks).to_xml\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Wrap our SVG icon markup in one SVG/XML document.
def wrap_icons tmpl = File.read(File.expand_path('./templates/icon_wrapper.svg.erb', __dir__)) @icons_sprite = ERB.new(tmpl).result(binding) end
[ "def svg_icon(icon, options = {})\n content_tag :svg, class: \"icon icon--#{icon} #{options[:class]}\", viewBox: \"0 0 100 100\" do\n content_tag :use, \"xlink:href\": \"##{icon}\" do\n end\n end\n end", "def svg!\n attr = ->(node) { ['src', 'data'].find {|k| node[k]} }\n @doc.css('img,iframe,embed,object[type=\"image/svg+xml\"]').select do |node|\n src = attr.call node\n Transformer.local_img?(node, ['src', 'data']) && MiniMime.lookup_by_filename(node[src])&.content_type == 'image/svg+xml'\n end.each do |node|\n src = attr.call node\n node[src] = \"data:image/svg+xml;base64,#{Base64.strict_encode64(File.read node[src])}\"\n end\n end", "def svg_symbol!\n svg = svg_shape\n\n # Replace <svg> with <symbol id=...>.\n svg.sub! '<svg ', %Q|<symbol preserveAspectRatio=\"none\" id=\"#{svg_symbol_id}\" |\n svg.sub! '</svg>', '</symbol>'\n \n svg\n end", "def process_icons\n icons_dir = Rails.root.join('app', 'assets', 'images', 'icons')\n tmpl = File.read(File.expand_path(\"./templates/icon.svg.erb\", __dir__))\n Dir.glob(\"#{icons_dir}/*.svg\").each do |file|\n icon_name = File.basename(file, '.svg')\n doc = Nokogiri::XML(File.read(file))\n icon_content = strip_attrs(doc).css('svg > g').to_s\n @svg_content += ERB.new(tmpl).result(binding)\n end\n end", "def octicon(name, options)\n content_tag :svg, options do\n content_tag :use, '', 'xlink:href' => \"#icon-#{name}\"\n end\n end", "def etail\n puts '</svg>'\nend", "def add_elements\n Nokogiri::XML::Builder.with(@doc.at('svg')) do |xml|\n yield xml\n end\n end", "def icon(icon, options = {})\n file = File.read(\"node_modules/bootstrap-icons/icons/#{icon}.svg\")\n doc = Nokogiri::HTML::DocumentFragment.parse file\n svg = doc.at_css('svg')\n\n # Add any of Bootstrap's classes, if provided.\n svg['class'] += ' ' + options[:class] if options[:class].present?\n\n doc.to_html.html_safe\n end", "def hack doc\n doc.css('button svg').first.replace('<i class=\"material-icons\">menu</i>')\n doc\n end", "def render\n output = \"\"\n xml = Builder::XmlMarkup.new(:target => output, :indent => @options[:indent])\n\n # Output headers unless we specified otherwise\n xml.instruct!\n xml.declare! :DOCTYPE, :svg, :PUBLIC, \"-//W3C//DTD SVG 1.1//EN\", \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"\n\n xml.svg(:viewBox => \"0 0 #{@options[:viewbox][:width]} #{@options[:viewbox][:height]}\",\n :width => @options[:width], :height => @options[:height],\n :xmlns => 'http://www.w3.org/2000/svg', :version => '1.1') do |xml|\n\n xml.g(:fill => 'black', :stroke => 'black', 'stroke-width' => '2',\n 'font-family' => 'Helvetica, Arial, sans-serif', 'font-size' => '10px', 'font-weight' => 'medium') do |xml|\n\n # Outline\n xml.rect(:x => @options[:margin][:left], :y => @options[:margin][:top],\n :width => graph_width,\n :height => graph_height,\n :fill => 'lightgray')\n\n xml.g 'stroke-width' => '1' do |xml|\n\n # Title\n xml.text(@options[:title], 'font-size' => '24px', :x => (@options[:viewbox][:width] / 2.0).round, :y => (@options[:subtitle] ? 24 : 32), 'text-anchor' => 'middle') if @options[:title]\n xml.text(@options[:subtitle], 'font-size' => '18px', :x => (@options[:viewbox][:width] / 2.0).round, :y => 34, 'text-anchor' => 'middle') if @options[:subtitle]\n\n # Lines\n xml.g 'font-size' => '10px' do |xml|\n line_x1 = @options[:margin][:left] + 1\n line_x2 = @options[:viewbox][:width] - @options[:margin][:right] - 1\n\n text_x = @options[:margin][:left] - 5\n\n xml.text 0, :x => text_x, :y => (@options[:viewbox][:height] - @options[:margin][:bottom] + 4), 'stroke-width' => 0.5, 'text-anchor' => 'end'\n\n 1.upto((max / division) - 1) do |line_number|\n y = (@options[:margin][:top] + (line_number * dy)).round\n xml.line :x1 => line_x1, :y1 => y, :x2 => line_x2, :y2 => y, :stroke => '#666666'\n xml.text max - line_number * division, :x => text_x, :y => y + 4, 'stroke-width' => 0.5, 'text-anchor' => 'end'\n\n # Smaller Line\n xml.line(:x1 => line_x1, :y1 => y + (0.5 * dy), :x2 => line_x2, :y2 => y + (0.5 * dy), :stroke => '#999999') if max < 55\n end\n\n xml.text max, :x => text_x, :y => @options[:margin][:top] + 4, 'stroke-width' => 0.5, 'text-anchor' => 'end'\n # Smaller Line\n xml.line(:x1 => line_x1, :y1 => @options[:margin][:top] + (0.5 * dy), :x2 => line_x2, :y2 => @options[:margin][:top] + (0.5 * dy), :stroke => '#999999') if max < 55\n end\n\n # Labels\n xml.g 'text-anchor' => 'end', 'font-size' => '12px', 'stroke-width' => 0.3 do |xml|\n @labels.each_with_index do |label, index|\n x = (@options[:margin][:left] + (dx * index) + (dx / 2.0)).round\n y = @options[:viewbox][:height] - @options[:margin][:bottom] + 15\n xml.text label, :x => x, :y => y, :transform => \"rotate(-45 #{x} #{y})\"\n end\n end\n\n # Bars\n xml.g 'font-size' => '10px', 'stroke-width' => 0.3 do |xml|\n last_spot = []\n\n @data.each_with_index do |data, data_index|\n data = Array(data)\n width = dx - @options[:padding]\n bar_width = (width / Float(data.size)).round\n\n x = (@options[:margin][:left] + (dx * data_index)).round\n\n # Rectangles\n data.each_with_index do |number, number_index|\n color = if @colors.respond_to? :call\n @colors.call(data_index, number_index, @data.size, data.size)\n elsif @colors.class == Array\n first = @colors[data_index % (@colors.size)]\n\n if first.class == Array\n first[number_index % (first.size)]\n else\n first\n end\n else\n @colors\n end\n\n height = ((dy / division) * number).round\n\n bar_x = (x + ((dx - width) / 2.0) + (number_index * bar_width)).round\n bar_y = @options[:viewbox][:height] - @options[:margin][:bottom] - height\n\n\n case @options[:type]\n when :bar then\n xml.rect :fill => color, :stroke => color, 'stroke-width' => 0, :x => bar_x, :width => bar_width, :y => bar_y, :height => height - 1\n when :line then\n if last_spot[number_index]\n xml.line(:x1 => last_spot[number_index][:x], :y1 => last_spot[number_index][:y], :x2 => bar_x, :y2 => bar_y,\n :fill => color, :stroke => color, 'stroke-width' => 2.0)\n end\n xml.circle :cx => bar_x, :cy => bar_y, :fill => color, :stroke => color, :r => bar_width * 1.5\n end\n\n last_spot[number_index] = { :x => bar_x, :y => bar_y }\n end\n end\n\n @data.each_with_index do |data, data_index|\n data = Array(data)\n width = dx - @options[:padding]\n bar_width = (width / Float(data.size)).round\n\n x = (@options[:margin][:left] + (dx * data_index)).round\n\n # Text\n if @options[:bar_text] != :none\n last_bar_height = false\n data.each_with_index do |number, number_index|\n percent_total = data.inject(0) { |total, percent_number| total + percent_number }\n\n if number > 0\n height = ((dy / division) * number).round\n\n bar_x = (x + ((dx - width) / 2.0) + (number_index * bar_width)).round\n text_x = (bar_x + (bar_width / 2.0)).round\n\n bar_y = @options[:viewbox][:height] - @options[:margin][:bottom] - height\n text_y = bar_y - 3\n\n if last_bar_height && (last_bar_height - height).abs < 14\n text_y -= (14 - (height - last_bar_height))\n last_bar_height = false\n else\n last_bar_height = height\n end\n\n label = case @options[:bar_text]\n when :number then number\n when :percent then (100.0 * Float(number) / Float(percent_total)).round.to_s + \"%\"\n end\n\n xml.text label, :x => text_x, :y => text_y, 'text-anchor' => 'middle'\n else\n last_bar_height = false\n end\n end\n end\n end\n end\n\n # Legend\n if @legend\n if @options[:legend] == :right\n legend_x = @options[:viewbox][:width] - (3 * @options[:margin][:right])\n else\n legend_x = (@options[:margin][:left] * 1.5).round\n end\n legend_y = (@options[:margin][:top] / 2) + @options[:margin][:top]\n xml.rect :fill => '#ffffff', :stroke => '#000000', 'stroke-width' => 2, :x => legend_x, :y => legend_y, :width => (2.5 * @options[:margin][:right]), :height => (@legend.size * 15) + 16\n\n @legend.sort.each_with_index do |data, index|\n color, label = data\n xml.rect :fill => color, :stroke => color, 'stroke-width' => 0, :x => legend_x + 10, :y => legend_y + 10 + (index * 15), :width => 35, :height => 10\n xml.text label, :x => legend_x + 55, :y => legend_y + 18 + (index * 15), 'text-anchor' => 'left'\n end\n end\n\n # Yield in case they want to do some custom drawing and have a block ready\n yield(xml, @options) if block_given?\n\n end\n end\n end\n\n output\n end", "def embedded_svg(symbol_name, options = {})\n content_tag(:svg, content_tag(:use, \"\", 'xlink:href' => \"\\##{symbol_name}\", :class => options[:xlink_class]), :class => options[:class])\n end", "def embedded_svg(filename, options = {})\n doc = Nokogiri::HTML::DocumentFragment.parse(File.read(Rails.root.join('app', 'assets', 'images', filename)))\n if options[:class].present?\n doc.at_css('svg')['class'] = \"svg svg--#{File.basename(filename, '.*').parameterize} #{options[:class]}\"\n else\n doc.at_css('svg')['class'] = \"svg svg--#{File.basename(filename, '.*').parameterize}\"\n end\n raw doc\n end", "def write_sprite\n dest = Rails.root.join('app', 'assets', 'images', 'icons.svg')\n template 'icons_sprite.svg.erb', dest, force: true\n end", "def embed_svg(filename, additional_class = nil)\n\n svg = File.open(Rails.root.to_s + '/app/assets/images/' + filename) { |f| Nokogiri::XML f }\n\n unless additional_class.nil?\n svg.root['class'] = additional_class\n end\n\n svg.to_html.html_safe\n\n end", "def svg\n # Only recompile the SVG if it doesn't already exist\n unless File.exist? self.svg_name\n File.open(\"#{@name}.tex\", 'w') { |f| f.write document }\n # TODO Catch pdflatex errors\n system \"lib/latex2svg #{@name}\"\n end\n # Unless latex2svg was successful, use a placeholder SVG\n copy_placeholder unless File.exist? self.svg_name\n return File.read self.svg_name\n end", "def embed_svg(svg:)\n t = Tempfile.new(['embed','.svg'])\n t.write svg\n t.close\n t.path\n end", "def with_svg(doc)\n doc = Nokogiri::XML::Document.parse(\n doc.to_html(encoding: \"UTF-8\"), nil, \"UTF-8\"\n )\n svg = doc.at_css \"svg\"\n yield svg if svg && block_given?\n doc\n end", "def svg(s)\n convert(s, mime: 'image/svg+xml')\n end", "def svg\n template = '<circle cx=\"%cx%\" cy=\"%cy%\" r=\"%r%\"/>'\n return template.subreplace( {\"%cx%\" => cx,\n\t\t\t\t \"%cy%\" => cy,\n\t\t\t\t \"%r%\" => radius} )\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fix indentation in sprite markup.
def fix_indentation @icons_sprite = Nokogiri::XML(@icons_sprite, &:noblanks).to_xml end
[ "def relative_indent; end", "def spacing_stack; end", "def correct_indentation(node); end", "def reset_indent; end", "def indentation; end", "def relativeIndent; end", "def save_indent(match); end", "def indent(distance); end", "def unexpected_indent_offset; end", "def unindent\n @__indent__ ||= 0\n @__indent__ -= indentation\n end", "def reindent(lines, node, corrector); end", "def write_white_space\r\n #@file.write String.new.rjust(@indentation)\r\n @file.write(' ' * @indentation)\r\n end", "def unindent(txt, n = 2)\n txt.gsub /^[ ]{#{n}}/, ''\n end", "def indentation(depth)\n \" \" * 4 * depth\nend", "def codeblock_linefeed_with_indent(text, offset)\n text.gsub(/```(.+)```/) { \"\\n\\n#{indent(offset+1)}```#{$1.gsub('<br />', \"\\n#{indent(offset+1)}\")}```\" }\n end", "def unindent(txt, n = 2)\n txt.gsub /^[ ]{#{n}}/, ''\n end", "def matched_indent; end", "def insert_indentation(line, indentation)\n line ? \" \" * indentation + line.to_s : \"\"\n end", "def undent\n @indent_level > 0 ? @indent_level -= 1 : @indent_level = 0\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Write the sprite to file in the Rails app (app/assets/images/icons.svg).
def write_sprite dest = Rails.root.join('app', 'assets', 'images', 'icons.svg') template 'icons_sprite.svg.erb', dest, force: true end
[ "def path_to_sprite(name)\n path_to_file @sprites_path + \"#{name}.png\"\n end", "def save_svg(filename)\n File.open(\"#{filename}.svg\", 'w') { |f| f.write(to_svg) }\n end", "def export_png(icon_size = 200)\n @glyphs.glob('*.svg').map do |p|\n # puts p.dirname.inspect.yellow\n # puts p.basename.inspect.red\n # puts p.basename('.svg').inspect.yellow\n png_file = @root.join('tmp', 'png', p.basename('.svg').to_s + '.png')\n command(\"convert -background none -size #{icon_size}x#{icon_size} #{p} #{png_file}\")\n end\n end", "def sprite(id, width, height)\n \"<svg viewBox='0 0 #{width} #{height}' class='icon #{id}'>\" +\n \" <use xlink:href='/assets/images/sprite.min.svg##{id}'></use>\" +\n \"</svg>\"\n end", "def save_png(filename)\n to_png.save(filename)\n end", "def create_svg\n @project = Project.find params[:id]\n filename = params[:filename].squish.downcase.tr(\" \",\"_\") + '.svg'\n file = File.open(File.join(@project.path, filename), 'w+') {|f| f.write(params[:sketch]) }\n if file\n commit @project.path, filename, Base64.decode64(params[:sketch]), \"Create #{filename}\"\n flash[:notice] = \"Your new image was added successfully! How sparkly!\"\n else\n flash[:alert] = \"Your new image didn't get saved! How sad :(\"\n end\n redirect_to url_for(@project)\n end", "def to_file\n a = []\n\n @sprites.product(@palettes).each do |pair|\n a << pair.first.to_canvas(pair.last)\n end\n\n combine_canvas(a).to_datastream\n end", "def write_png(file)\n @canvas.target.write_to_png(file)\nend", "def write( path )\n base_image.write( path )\n end", "def write(file_name = 'graph.png')\n to_image.write(file_name)\n end", "def write(filename=\"graph.png\")\n draw()\n @base_image.write(filename)\n end", "def wrap_icons\n tmpl = File.read(File.expand_path('./templates/icon_wrapper.svg.erb', __dir__))\n @icons_sprite = ERB.new(tmpl).result(binding)\n end", "def copy_icon_file\n FileUtils.cp spec.icon, icon_file\n end", "def save_file(name)\n #first save SVG\n name += \".svg\" unless name.match(/svg$/)\n File.open(name, \"w\") do |file|\n file.write build\n end\n \n #convert to JPG and delete the SVG doc\n if(name.match(/jpg|png/))\n #puts \"converting...\"\n system(\"nice -n #{@priority} #{@myconvert} -quality 95 #{name} #{name.sub('.svg','')}\")\n #system(\"rm #{name}\") \n end\nend", "def save_badge(badge, metric)\n # make sure directory exists\n dirname = File.dirname(image_dir)\n unless File.directory?(image_dir)\n FileUtils.mkdir_p(image_dir)\n end\n\n # wirte file\n File.write(\"#{image_dir}/#{metric}.svg\", badge)\n\n # compute url\n url = \"#{ci_project_url}/-/jobs/#{ci_job_id}/artifacts/raw/#{image_dir}/#{metric}.svg?inline=false\"\n end", "def set_dmg_icon\n execute <<-EOH.gsub(/^ {8}/, '')\n # Convert the png to an icon\n sips -i \"#{resource_path('icon.png')}\"\n\n # Extract the icon into its own resource\n DeRez -only icns \"#{resource_path('icon.png')}\" > tmp.rsrc\n\n # Append the icon reosurce to the DMG\n Rez -append tmp.rsrc -o \"#{final_dmg}\"\n\n # Source the icon\n SetFile -a C \"#{final_dmg}\"\n EOH\n end", "def png symbol\n file = File.join(OUT, filename(symbol))\n unless File.exists?(file+'.png')\n create symbol\n end\n file\n end", "def write_image(image, write_path, size_type)\n size = find_size size_type\n image.resize_to_fill!(size[0], size[1]) if size_type\n image.format = \"PNG\" if image.format == \"SVG\"\n write_path.gsub!(/.svg/i, \".png\")\n image.write write_path\n end", "def save\n return false if @sources.empty?\n\n @save_path.dirname.mkpath\n\n unless @save_path.dirname.writable?\n raise Polymer::TargetNotWritable, <<-ERROR\n Polymer can't save the #{@name} sprite in\n `#{@save_path.dirname.to_s}' as it isn't writable.\n ERROR\n end\n\n width, height = @sources.inject([1, 0]) do |dimensions, source|\n # Determine the width of the sprite by finding the widest source.\n source_width = source.image.width\n dimensions[0] = source_width if source_width > dimensions[0]\n\n # Determine the height of the sprite by summing the height of each\n # source.\n dimensions[1] += source.image.height\n\n dimensions\n end\n\n if @padding and @padding > 0\n # Adjust the height to account for padding.\n height += (@sources.length - 1) * @padding\n end\n\n canvas = ChunkyPNG::Canvas.new(width, height)\n\n # Add each source to the canvas.\n @sources.each do |source|\n canvas.compose!(source.image, 0, position_of(source))\n end\n\n canvas.save(@save_path, :best_compression)\n\n true\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
An indicator used for the json type, so that the search engine can now how to convert the types.
def json_type_indicator(value) case value when Integer 'i' when true, false 'b' when nil 'n' end end
[ "def json_type_show(obj)\n if obj.is_a? Hash\n if obj['type']\n obj['type']\n elsif json_nested_attributes(obj) && !json_xof(obj)\n 'object'\n else\n json_xof(obj) \n end\n end \n end", "def simplified_type(field_type)\n if field_type == 'jsonb'\n :json\n else\n super\n end\n end", "def nonregular_type; end", "def type\n self.class.config[:type] || :undefined_jsonapi_type\n end", "def desired_type; end", "def type\n return :annotation unless self[:type]\n self[:type].downcase.to_sym\n end", "def additional_types; end", "def type\n case attributes['type']\n when 'boolean' then :boolean\n when 'fixed' then :fixed\n when 'hidden' then :hidden\n when 'jid-multi' then :jid_multi\n when 'jid-single' then :jid_single\n when 'list-multi' then :list_multi\n when 'list-single' then :list_single\n when 'text-multi' then :text_multi\n when 'text-private' then :text_private\n when 'text-single' then :text_single\n else nil\n end\n end", "def json?(type)\n format_type(type) == :json\n end", "def types\n data = {\n 'sale_agent_role' => SaleAgent::ROLE_TYPES,\n 'transaction_type' => Entry::TYPES_TRANSACTION,\n 'author_role' => EntryAuthor::TYPES_ROLES,\n 'artist_role' => EntryArtist::TYPES_ROLES,\n 'currency' => Sale::CURRENCY_TYPES,\n 'sold' => Sale::SOLD_TYPES,\n 'material' => EntryMaterial::MATERIAL_TYPES,\n 'alt_size' => Entry::ALT_SIZE_TYPES,\n 'acquisition_method' => Provenance::ACQUISITION_METHOD_TYPES\n }\n render json: data\n end", "def type\n return @artist_data[\"type\"]\n end", "def supports_json?; end", "def describe_type_expectation\n\t\t\treturn \"a JSON collection (Array of Objects)\"\n\t\tend", "def data_type(*) end", "def data_type\n raw_response[6]\n end", "def indicator_type_name\n I18n.t(\"shared.external_indicators.indicator_types.#{INDICATOR_TYPES.keys[INDICATOR_TYPES.values.index(self.indicator_type)]}\")\n end", "def type(data)\n if data.is_a? Numeric\n 'numeric'\n elsif data.is_a? String\n 'text'\n else\n data.class.to_s.downcase\n end\n end", "def schema_column_type(db_type)\n case db_type\n when 'json'\n :json\n when 'jsonb'\n :jsonb\n else\n super\n end\n end", "def value_types; end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
exercise question 2 write method that takes a string as argument. Method should return a new, allcaps version of the string, but only if the string is longer than 10 characters cute try but not quite: print "Enter a string: " user_input = gets.chomp test 1: is string longer than 10 characters?" if user_input.length < 10 puts "need a longer string, chief." else puts user_input.upcase! end attempt 2, paying closer attention to the directions this time
def allcaps(user_string) if user_string.length > 10 puts user_string.upcase! else puts "less than 10 characters." end end
[ "def all_caps(string)\n if string.length > 10 then\n string.upcase\n else\n string\n end\nend", "def allcaps(string)\n if string.length > 10\n string.upcase\n else\n string\n end\nend", "def all_caps(string)\n if string.length >= 10\n return string.upcase\n end\nend", "def all_caps(string)\n return string.upcase if string.length > 10\n string\nend", "def i_hate_steve\n puts \"Hello - what is your name?\"\n user_name = gets.chomp\n return \"#{user_name.upcase}!!!!!\" if user_name[0].upcase == \"S\"\n return \"Hi, #{user_name.capitalize}\"\nend", "def caps(words)\n words.length > 10 ? words.upcase : words \nend", "def capitalize(input); end", "def all_caps\n caps = \"This string is going to be all caps using the .upcase action!\\n\"\n puts caps.upcase\nend", "def make_caps(string)\n string.upcase\nend", "def check_characters(user_input)\n\tif user_input == user_input.upcase\n\t\tputs \"You are shouting\"\n\telsif user_input =~ /[A-Z]/\n\t\tputs \"You are neutral\"\n\telse\n\t\tputs \"I love Ruby\"\n\tend\nend", "def test_to_capitalize_every_other_character_with_even_id_length\nresult = capitalize_every_other(\"landon\")\nassert_equal(\"LaNdOn\", result)\nend", "def all_caps_if_proper_noun(string)\n sentence = string.split(\" \") #turns string into array\n new_sentence = sentence.map do |word|\n if word[0] === word[0].upcase #if first letter of word is uppercase...\n then word = word.upcase #then make that whole word uppercase...\n else word = word #else, keep the word as it is\n end\n end\n new_sentence_string = new_sentence.join(\" \") #turn array into a string\n return new_sentence_string\n end", "def uppercase(str)\n # ...\nend", "def uppercase? (string)\n string.upcase == string ? true : false\nend", "def uppercase(input)\n input.upcase\n end", "def input\n word = gets.chomp.downcase\n until word.length >= 2\n print \"ERROR! Please enter a word that is at least 2 letters in \"\n print \"length: \"\n word = gets.chomp.downcase\n end\n return word\nend", "def user_input\n puts \"please enter a word to see if it is a polindrome\"\nend", "def upper?(password)\n password.gsub(/[A-Z]/, '') != password\nend", "def staggered_case(string)\n new_str = \"\"\n to_cap = true\n string.chars.each do |char|\n if char =~ /[A-Za-z]/ && to_cap\n new_str << char.upcase\n to_cap = !to_cap\n elsif char =~ /[A-Za-z]/ && (!to_cap)\n new_str << char.downcase\n to_cap = !to_cap\n else\n new_str << char\n end\n end\n \n new_str\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
define the navigation structure in this file example structure: def structure [ item('Top Nav Item 1', subitems: [ item('Top Nav Dropdown Item 1', class: 'customclass', path: some_named_route_path), item('Top Nav Dropdown Item 2', subitems: [ item('Side Nav Item 1', subitems: [ item('Side Nav Nested Item', path: some_named_route_path) ]), item('Side Nav Item 1', path: some_named_route_path) ]), ]), item('Pages', subitems: [ item('Home', path: fae.edit_content_block_path('home')), item('About Us', path: fae.edit_content_block_path('about_us')) ]) ] end
def structure [ item('Thought Categories', path: admin_thought_categories_path), item('Thoughts', path: admin_thoughts_path), item('Team Members', path: admin_team_members_path), item('Services', path: admin_services_path), item('Messages', path: admin_messages_path), # scaffold inject marker item('Pages', subitems: [ item('All', path: fae.pages_path), item('Home', path: fae.edit_content_block_path('home')), item('About Us', path: fae.edit_content_block_path('about_us')), item('What We Do', path: fae.edit_content_block_path('what_we_do')), item('Contact Us', path: fae.edit_content_block_path('contact_us')) ]) ] end
[ "def structure\n @structure = [\n item('Events', path: admin_events_path),\n item('News Items', path: admin_news_items_path),\n item('Public Notices', path: admin_public_notices_path),\n item('Quick Links', path: admin_quick_links_path),\n item('Places', path: admin_places_path),\n item('Roles', path: admin_roles_path)\n ]\n add_organization_nav_links\n add_pages_nav_links\n @structure\n end", "def structure\n [\n item('Manage', subitems: [\n item('Addresses', path: admin_addresses_path),\n item('Clients', path: admin_clients_path),\n item('Discounts', path: admin_discounts_path),\n item('Suppliers', path: admin_suppliers_path),\n item('Services', path: admin_services_path),\n item('Products', path: admin_products_path),\n item('Sells', path: admin_sells_path),\n item('Schedule Service', path: admin_schedule_services_path),\n ]),\n item('Marketing', subitems: [\n item('Campaigns', path: admin_campaigns_path)\n ]),\n item('+ Sell', path: '/admin/sells/new')\n ]\n end", "def nav_items\n [\n {\n url: root_path,\n title: \"Home\"\n },\n {\n url: about_me_path,\n title: \"About Me\"\n },\n {\n url: contact_path,\n title: \"Contact\"\n },\n {\n url: tech_news_path,\n title: \"Rails News\"\n },\n {\n url: blogs_path,\n title: \"Blog\"\n },\n {\n url: portfolios_path,\n title: \"Portfolio\"\n }\n ]\n end", "def bootstrap_nav(*args, &block)\n levels = { :primary => 1, :secondary => 2, :tertiary => 3 }\n options = args.extract_options!\n level = levels[options[:level]] || (options[:level] || 1).to_i\n\n\n # If there are no arguments, use the current page\n args.unshift page if args.empty? && !page.nil?\n \n current_page = page\n \n contents = \"\".tap do |str|\n\n page = current_page # TODO: Can't call page within tap, so we've passed it as a variable. Can we do this better?\n\n # Opening HTML for Twitter Bootstrap Navigation\n if level == 1\n str << '<ul class=\"nav\">'\n else\n str << '<ul class=\"dropdown-menu\">'\n end\n \n pages = args.map do |arg|\n if arg.root?\n arg.children.first\n else \n case arg\n when Breeze::Content::NavigationItem then arg\n else Breeze::Content::NavigationItem.where(:permalink => arg.to_s).first\n end\n end\n end.flatten.compact\n \n ancestry = pages.first ? pages.first.self_and_ancestors.to_a : [ page ]\n\n # If page is undefined, there's no active page\n # This is used for example on the Breeze Commerce Cart and Checkout pages\n # In the longer term, this should be removed, in favour of making the cart a proper page, with checkout as a view\n page ||= nil\n \n active = page ? (page.root? ? [page] : ancestry.dup) : []\n ancestry << ancestry.last.children.first if ancestry.last\n ancestry.compact!\n \n if level <= ancestry.length && ancestry[level].present?\n siblings = ancestry[level].self_and_siblings.to_a.select(&:show_in_navigation?) \n # siblings = page.self_and_siblings.to_a.select(&:show_in_navigation?) \n siblings.unshift ancestry[level - 1] if options[:home] || (level == 1 && options[:home] != false)\n siblings.each_with_index do |p, i|\n page_title = if (options[:home] && options[:home] != true) && (p.level < level || p.root?)\n options[:home]\n case options[:home]\n when true then p.title\n when Symbol then p.send options[:home]\n when Proc then options[:home].call(p)\n else options[:home].to_s\n end\n else\n p.title\n end\n page_title = p.title if page_title.blank?\n \n link_options = ({}).tap do |o|\n o[:class] = [ p.root? ? \"home\" : p.slug ].tap do |classes|\n classes << \"active\" if p == page || (active.index(p).to_i > 0 && p.level == level)\n classes << \"first\" if i == 0\n classes << \"last\" if i == siblings.length - 1\n end.join(\" \")\n end\n \n link = if block_given?\n capture p, link_options, &block\n else\n permalink = p.class.name == \"Breeze::Content::Placeholder\" ? 'javascript:void(0)' : p.permalink\n link_to content_tag(:span, \"#{page_title}\".html_safe), permalink, link_options\n end\n \n recurse = case options[:recurse]\n when true then 3\n when :active then ancestry.include?(p) ? 1 : 0\n when Numeric, /^\\d+$/ then options[:recurse].to_i\n else 0\n end\n \n if recurse > 0 && p.level == level && !p.root?\n unless (child = p.children.first).nil?\n link << bootstrap_nav(child, options.merge(:level => level + 1, :recurse => recurse - 1), &block)\n end\n end\n \n # if options[:full] && p.children\n # p.children.each do |child|\n # link << navigation_bootstrap(child, options.merge(:full => true), &block)\n # end\n # end\n\n li_options = ({}).tap do |o|\n o[:class] = [ p.root? ? \"home\" : p.slug ].tap do |classes|\n classes << \"active\" if p == page || (active.index(p).to_i > 0 && p.level == level)\n classes << \"first\" if i == 0\n classes << \"last\" if i == siblings.length - 1\n classes << \"dropdown\" if p.children.length > 0\n classes << 'level-' + level.to_s\n end.join(\" \")\n end\n \n str << content_tag(:li, link.html_safe, li_options)\n end\n end\n \n # Opening HTML for Twitter Bootstrap Navigation\n str << '</ul>'\n \n end\n # content_tag :div, contents.html_safe, options.except(:level, :recurse).reverse_merge(:class => \"#{levels.invert[level] || \"level-#{level}\"} navigation\")\n contents.html_safe\n \n end", "def navigation_list\n w.partial(\"navigation_list\", \n :locals => { :current_level => \"1\" })\n end", "def nav(content = nil, options = {}, html_options = nil, &block)\n @items << UiBibz::Ui::Core::Component.new(Nav.new(content, options).tap(&block).render, {}, html_options)\n end", "def nav_items\n [\n {url: root_path,\n title: 'Home'},\n {url: pages_about_path,\n title: 'About'},\n {url: pages_contact_path,\n title: 'Contact Me'},\n {url: blogs_path,\n title: 'Blogs'},\n {url: portfolios_path,\n title: 'Portfolio' \n }\n ]\n end", "def navigation_item(title, path_helper,options ={})\n nav_item = AppKit::NavigationItem.new\n nav_item.title = title\n nav_item.path_helper = path_helper\n nav_item.icon = options[:icon]\n nav_item.position = options[:position] || :left\n nav_item.controller = options[:controller]\n navigation_items << nav_item\n end", "def buildNavigation(navHash, parentItemKey = '')\n if (navHash == nil && navHash.empty?)\n #puts \"Empty hash \"\n return\n end\n\n\n navHash.each do |pageId, pageData|\n\n itemKey = $CfeUtils.removeUnvantedChars(pageId)\n\n $leftNavigation[itemKey] ||= {}\n\n if (pageData.has_key?('alias') && !pageData['alias'].empty?)\n $breadcrumbsNavigation[itemKey] ||= {}\n $breadcrumbsNavigation[itemKey]['title'] = pageData['title']\n $breadcrumbsNavigation[itemKey]['alias'] = pageData['alias']\n else\n puts \"--------------------------------------------------------\"\n puts \"WARNING: Page: \" + k + \". Full path: \" + itemKey + \" doesn't have right meta tags\"\n puts \"--------------------------------------------------------\"\n end\n\n\n $leftNavigation[itemKey] ||= {}\n $leftNavigation[itemKey]['childrens'] ||= {}\n\n if (parentItemKey != '')\n # we need pages which are in the same lavel as current,\n # best way to do this is to get parent level page children\n $leftNavigation[itemKey]['uncles'] ||= {}\n\n if (!$leftNavigation[parentItemKey].empty?)\n $leftNavigation[itemKey]['uncles'] = $leftNavigation[parentItemKey]['childrens']\n end\n\n\n # also for pages with level 2+ we need information about parents\n $leftNavigation[itemKey]['parents'] ||= {}\n $leftNavigation[itemKey]['parents'] = $leftNavigation[parentItemKey]['uncles']\n\n\n end\n\n\n # current page properties\n $leftNavigation[itemKey]['alias'] = pageData['alias']\n $leftNavigation[itemKey]['title'] = pageData['title']\n $leftNavigation[itemKey]['level'] = pageData['level']\n $leftNavigation[itemKey]['parent_page'] = parentItemKey\n\n\n\n if (!pageData.empty? && !pageData.has_key?('childrens'))\n # for the 3-rd and 4-th level pages we must set their parent reference\n if (pageData['level'] == (CONST_MaxSubLevels - 2) || pageData['level'] == (CONST_MaxSubLevels - 1))\n $leftNavigation[itemKey]['parentReference'] ||= {}\n $leftNavigation[itemKey]['parentReference']['parentKey'] = parentItemKey\n $leftNavigation[itemKey]['parentReference']['parentData'] ||= {}\n $leftNavigation[itemKey]['parentReference']['parentData'][parentItemKey] = $leftNavigation[parentItemKey]\n end\n\n next\n end\n\n\n # level 1\n pageData['childrens'].each do |pageKey, pages|\n pageKey = $CfeUtils.removeUnvantedChars(pageKey)\n $leftNavigation[itemKey]['childrens'][pageKey] ||= {}\n $leftNavigation[itemKey]['childrens'][pageKey]['alias'] = pages['alias']\n $leftNavigation[itemKey]['childrens'][pageKey]['title'] = pages['title']\n $leftNavigation[itemKey]['childrens'][pageKey]['level'] = pages['level']\n $leftNavigation[itemKey]['childrens'][pageKey]['parent_page'] = itemKey\n end\n\n #recursively call for all 2 level pages\n buildNavigation(pageData['childrens'], itemKey)\n end\n end", "def navigation(options = {})\n options.reverse_merge!( page: @page, depth: 1 )\n page = options[:page]\n children = page.home? ? page.navigable_children : page.parent.navigable_children\n html = (is_home_and_shown_in_nav?(page) ? nav_link(Page.home) : '').html_safe\n html << list_items(children, options[:depth])\n content_tag(:ul, html, options.slice(:id, :class))\n end", "def build\n yield self if block_given?\n @item_builders.each { |b| @nav.items << b.item }\n @nav\n end", "def buildNavigation(navHash, parentSection='')\n if (navHash != nil && !navHash.empty?)\n navHash.each do |k, arr|\n\n itemKey = $CfeUtils.removeUnvantedChars(k)\n \n $leftNavigation[itemKey] ||= {}\n \n if (arr.has_key?('own_url') && !arr['own_url'].empty?)\n $breadcrumbsNavigation[itemKey] ||= {}\n $breadcrumbsNavigation[itemKey]['title'] = arr['own_url']['title']\n $breadcrumbsNavigation[itemKey]['alias'] = arr['own_url']['alias']\n else\n puts \"--------------------------------------------------------\"\n puts \"WARNING: Page: \" + k + \". Full path: \" + itemKey + \" doesn't have right meta tags\" \n puts \"--------------------------------------------------------\"\n end\n \n $leftNavigation[itemKey]['level1'] ||= {}\n \n navHash.each do |pageKey, pages|\n # create first level pages\n $leftNavigation[itemKey]['level1'][pageKey] ||= {}\n $leftNavigation[itemKey]['level1'][pageKey]['alias'] = pages['own_url']['alias']\n $leftNavigation[itemKey]['level1'][pageKey]['title'] = pages['own_url']['title']\n \n # check if page has children\n if ( pageKey == k && arr.has_key?('childrens') && !arr['childrens'].empty?)\n $leftNavigation[itemKey]['level1'][pageKey]['childrens'] ||= {}\n pages['childrens'].each do |level2Key, level2Pages|\n $leftNavigation[itemKey]['level1'][pageKey]['childrens'][level2Key] ||= {}\n $leftNavigation[itemKey]['level1'][pageKey]['childrens'][level2Key]['alias'] = level2Pages['own_url']['alias']\n $leftNavigation[itemKey]['level1'][pageKey]['childrens'][level2Key]['title'] = level2Pages['own_url']['title']\n end \n buildNavigation(pages['childrens'], itemKey) \n \n else \n # if this is last level page - we will show his parent as first level, and this page as children\n # we set level0 as parent array, and remove leve1, because we don't need it anymore\n if (parentSection != '' && pageKey == k) \n $leftNavigation[itemKey]['level0'] ||= {}\n $leftNavigation[itemKey]['level0'] = $leftNavigation[parentSection]['level1']\n $leftNavigation[itemKey].delete('level1')\n break;\n end\n end\n end #navhash pages loop \n end \n end #navhash arr loop \n end", "def navigation_menu_contents\n [\n {:name => :events, :active_when => [:events, :event_participants]},\n {:name => :participants, :active_when => [:participants]},\n :users,\n {:name => :counties, :active_when => [:counties, :municipalities, :settlements]},\n :event_types, :languages, :roles, :accounts\n ]\n end", "def nav(opts = {}, &block)\n opts[:class] = (opts[:class] || '') << \" nav-#{@type}\"\n opts[:data] = (opts[:data] || {}).merge(toggle: 'tab')\n opts[:child] = {\n data: {\n toggle: 'tab'\n }\n }\n\n Nav.new(@template, opts, &block)\n end", "def set_submenu *args\r\n case parse_item(args[0], 'name')\r\n when 'Invoices'; render partial: 'shared/navbar_invoices', locals: { active: parse_item(args[0], 'action') || 'sent' }\r\n when 'Categories'; render 'shared/navbar_categories'\r\n when 'Pixis'; render partial: 'shared/navbar_pixis', locals: { loc_name: @loc_name, rFlg: show_recent?, statusFlg: false }\r\n when 'Pixi'; render 'shared/navbar_show_pixi'\r\n when 'My Pixis'; render 'shared/navbar_mypixis'\r\n when 'My Accounts', 'Manage Accounts'; render 'shared/navbar_accounts'\r\n when 'Pending Orders'; render 'shared/navbar_pending'\r\n when 'Messages'; render 'shared/navbar_conversations'\r\n when 'Home'; render 'shared/navbar_home', locals: { loc_name: @loc_name }\r\n when 'PixiPosts'; render 'shared/navbar_pixi_post'\r\n when 'My PixiPosts'; render 'shared/navbar_pixi_post'\r\n when 'Inquiries'; render 'shared/navbar_inquiry'\r\n when 'Users'; render 'shared/navbar_users'\r\n when 'Sites'; render 'shared/navbar_sites'\r\n when 'Manage Pixis'; render 'shared/navbar_manage_pixis'\r\n when 'My Sellers', 'Manage Followers', 'My Followers'; render 'shared/navbar_sellers'\r\n when 'Manage Sites'; render 'shared/navbar_sites'\r\n else render 'shared/navbar_main'\r\n end\r\n end", "def nav_item(type, version=nil)\n label = case type\n when :api\n \"API #{version}\"\n when :feed\n \"Feed #{version}\"\n else\n \"#{type.capitalize}\" + (version.nil? ? '' : \" #{version.capitalize}\")\n end\n path = \"/#{type}/\" + (version.nil? ? '' : \"#{version}/\")\n classes = [type, version] == current_type_version ? 'current' : ''\n # build list item\n %(<li><a href=\"#{path}\" class=\"#{classes}\">#{label}</a></li>)\n end", "def add_sub_nav(options = {}, &block)\n add_item(Navbar, options, &block)\n end", "def navigation(start=1, descendants=1, breadcrumb=false)\n setup\n reset(start, descendants, breadcrumb)\n nav = unordered_list(navigation_origin)\n reset\n return nav\n end", "def build_items(item, limit, index, hierarchical = false, root_path = \"\")\n return \"\" if index > limit || !item.children.present?\n\n html = \"<ul class='#{index == 1 ? \"menu\" : \"sub-menu\"}'>\"\n item.children.order_default.each do |i|\n if i.visible && i.active\n html << \"<li class='#{\"menu-item-has-children\" if i.children.present?} #{\"active\" if i.slug == params[:menu_id] || i.slug == request.original_fullpath.match(/(\\D+\\/{1}|\\D+)/)[0].gsub('/', '')}'>\"\n\n if i.external_link.blank?\n if hierarchical\n html << \"<a href='#{root_path}/#{i.slug}'>#{i.name}</a>\"\n else\n html << \"<a href='/#{i.slug}'>#{i.name}</a>\"\n end\n else\n html << \"<a href='#{i.external_link}' rel='#{(i.follow || i.follow.nil?) ? \"follow\" : \"nofollow\"}' target='#{i.target.blank? ? '_self' : i.target}'>#{i.name}</a>\"\n end\n\n html << build_items(i, limit, index + 1, hierarchical, root_path + \"/#{i.slug}\")\n html << \"</li>\"\n end\n end\n html << \"</ul>\"\n html.html_safe\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /retailers GET /retailers.json
def index @retailers = Retailer.page(params[:page] || 1).per(10) end
[ "def index\n @retailers = Retailer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @retailers }\n end\n end", "def index\n respond_with(@collection) do |format|\n format.html # index.html.erb\n format.json { render json: @retailers }\n end\n end", "def show\n @retailer = Retailer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retailer }\n end\n end", "def index\n @admin_retailers = Admin::Retailer.all\n end", "def index\n @retailer_profiles = RetailerProfile.all\n end", "def index\n @game_retailers = GameRetailer.order(\"name ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @game_retailers }\n end\n end", "def riders\n @current_tab = \"Meetings\"\n \n sess = Patron::Session.new\n sess.base_url = \"http://online.equipe.com/\"\n #http://online.equipe.com/api/v1/meetings.json\n response = sess.get \"api/v1/meetings/\" + params[:id].to_s + \"/riders.json\"\n @meetings = JSON.parse response.body\n \n \n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @meetings }\n end\n \n end", "def index\n @racers = Racer.all\n\n render json: @racers\n end", "def list\n http.get(\"/takers\") do |response|\n respond_with_collection(response)\n end\n end", "def new\n @retailer = Retailer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retailer }\n end\n end", "def new\n @retailer = Retailer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @retailer }\n end\n end", "def index\n @recruiters = Recruiter.all\n\n render json: @recruiters\n end", "def new\n @retailer = Retailer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retailer}\n end\n end", "def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners }\n end\n end", "def index\n @recitators = Recitator.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recitators }\n end\n end", "def beers_list\n \t@url = 'https://api.punkapi.com/v2/beers' \t\t\n \tresponse = RestClient.get beer_url\n \tjson_response = JSON.parse response.body\n\n \tcreate_list = ::Beers::Create.call(\n \t\tuser: @current_user,\n \t\tbeers_data: json_response\n \t)\n \t\n \trender json: create_list.beers, adapter: :json_api, each_serializer: BeerSerializer\n end", "def list\n # This method is funky. That is all\n result = server.perform_request('listresellers', :key => 'reseller')\n result[:success] = true\n result[:params] = {:resellers => result.delete(:params)}\n result\n end", "def index\n @recruiters = Recruiter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recruiters }\n end\n end", "def index\n @recruiters = Recruiter.all\n render_json_serializer(@recruiters)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Deletes a cassette based on a name. Required because VCR complains that a cassette already exists when trying to overwrite, even in +record: :none+ mode.
def delete_old_cassette!(name) @vcr_library_dir ||= Pathname.new(::VCR.configuration.cassette_library_dir) cassette_path = @vcr_library_dir.join("#{name}.yml") if File.exist?(cassette_path) File.delete(cassette_path) true else false end end
[ "def delete(name)\n path = \"/projects/#{project.name}/resources/#{name}\"\n\n !!client.delete(path)\n end", "def delete(name)\n File.delete(path(name))\n end", "def delete_credential_by_name(name)\n template = Addressable::Template.new('/api/v1/data{?query*}')\n\n query_args = { name: name }\n path = template.expand(query: query_args).to_s\n\n http_client.delete(path).success?\n end", "def destroy(v_asset)\n File.delete(v_asset.path)\n end", "def delete\n asset.destroy\n\n OK\n end", "def delete_name name\n @statements[:delete_name].execute! NamesTable, name\n end", "def delete(name)\n @driver.deleteRule([name])\n end", "def delete_vcl(name)\n hash = fetcher.client.delete(\"#{Version.put_path(self)}/vcl/#{name}\")\n hash.nil? ? nil : hash\n end", "def delete(name)\n if not @objects.key?(name)\n return\n end\n\n obj, dtor = @objects[name]\n @objects.delete(name)\n destroy(obj, dtor)\n end", "def delete(name)\n id = name_to_id(name)\n puts \"Deleting card with ID #{id}.\"\n self.class.delete(\"/cards/#{id}.xml\")\n end", "def delete(name)\n existing_tag = one.delete(name)\n existing_tag && new(existing_tag) || nil\n end", "def delete(name)\r\n id = name_to_id(name)\r\n self.class.delete(\"/cards/#{id}.xml\")\r\n end", "def destroy\n @cassette.destroy\n respond_to do |format|\n format.html { redirect_to cassettes_url, notice: 'Cassette was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_record(asset)\n post(\"metadata.delete\", self.class.xml_doc.request { |r|\n r.uuid asset.uuid\n }) rescue nil # Geonetwork 500's if the record doesn't exist...\n end", "def delete_asset(id)\n @client.raw('delete', \"/content/assets/#{id}\")\n end", "def del(name)\n data.delete(name)\n end", "def delete_trail(trail_name)\r\n @cloudtrail.delete_trail({ name: trail_name })\r\n end", "def remove_object(name)\n @objects.delete Fog::Rackspace.escape(name)\n end", "def delete(asset_id)\n Deleter.new(self).delete(asset_id)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=> Filters out the results that the user has already guessed on
def exclude_user_guessed(user) photo_set.search() end
[ "def missed_guesses\n guesses - secret\n end", "def misses()\r\n\t\treturn @bad_guesses\r\n\tend", "def guessed_wrong_letter()\n if $hidden_word_arr.exclude?($input)\n $guessed.append($input)\n end\n end", "def bad_guesses\n\t\tif @guesses_left < 6\n\t\t\tprint \"Bad guesses (only #{@guesses_left} left!): \"\n\t\t\t@letters_guessed.split(\"\").each{|letter|\n\t\t\t\tif !@my_word.include? letter\n\t\t\t\t\tprint letter\n\t\t\t\tend\n\t\t\t}\n\t\t\tputs \"\"\n\t\tend\n\tend", "def wrong_guesses\n\t @wrong_guesses\n end", "def use_guess\n @guesses -= 1\n end", "def letter_guessed(user_guess)\n\t\tif @guessed_letters.length == 0\n\t\t\t@guessed_letters << user_guess\n\t\telse \n\t\t\tif @guessed_letters.include?(user_guess)\n\t\t\t\tputs \"--You already guessed that letter! Try again!--\"\n\t\t\t\t@guess_count -= 1\n\t\t\telse\n\t\t\t\t@guessed_letters << user_guess\n\t\t\tend\n\t\tend\n\tend", "def check_guess\n @already_guessed.push(@guess)\n if @secret_word.include?(@guess)\n @secret_word.split(\"\").each_with_index do |letter, index|\n if letter == @guess\n @blanks[index] = letter\n end\n end\n else\n @guesses_left -= 1\n @missed_letters.push(@guess)\n end\n @blanks\n end", "def scorers\r\n guesses.select { |g| g.score > 0 }\r\n end", "def check_guess(letter_guessed)\r\n letter_guessed.downcase\r\n @users_word.split('').each_with_index do|user_letter, hidden_letter|\r\n if letter_guessed == user_letter\r\n @hidden_word[hidden_letter] = letter_guessed\r\n p @hidden_word\r\n end\r\n if !@users_word.include?(letter_guessed)\r\n puts \"#{letter_guessed} is not in the word. Try again.\"\r\n end\r\n end\r\n end", "def guess_unused?(guess)\r\n @used_guesses.include?(guess) && @used_guesses.length > 0 ? (puts \"You have used that guess. Please try again!\") : @used_guesses.push(guess)\r\n end", "def give_feedback\n print 'Matches: '\n puts 'Black ' * @secret.exact_matches(last_guess) + \\\n 'White ' * @secret.near_matches(last_guess)\n end", "def show_guesses\n puts \"Guesses: #{guesses.join(\" \")}\\n\" unless turns == 12\n end", "def incorrect_guesses\n @guesses - @word_characters\n end", "def show_wrongly_guessed(wrongly_guessed)\n guesses = ''\n wrongly_guessed.each {|guess| guesses += \"#{guess}, \"}\n guesses = validate_guesses(guesses)\n puts(\"Guessed so far: #{guesses}\")\n end", "def guesses\n @guessed_letters.clone\n end", "def allowed_guesses\n blanks = @given_phrase.count(\"*\")\n if blanks <= 10\n @wrong_guesses = 3\n elsif (blanks >= 11) && (blanks <= 20)\n @wrong_guesses = 5\n else \n @wrong_guesses = 8\n end\n puts \"You are allowed #{@wrong_guesses} wrong guesses.\"\n @wrong_guesses\n end", "def\tget_guesses\n\n \t#While the user hasn't made 6 bad guesses (head, torso, arms, legs) in a row, get the next guess\n \tif @letters_remain\n \t\tare_there_any_letters_left?\n\t \twhile @bad_guesses < MAX_BAD_GUESSES && @letters_remain\n\t \t\tputs\n\t \t\tthis_letter = ask_for_a_guess\n\t \t\tdoes_it_match?(this_letter) \n\t end #while\n\tend #if\n\t@this_turn += 1\nend", "def handle_guess guess\n if @secret_word.include? guess\n @secret_word.length.times do |index|\n if @secret_word[index] == guess\n @guesses[index] = guess\n end\n end\n puts \"Correct guess!\"\n else\n @incorrect_guesses << guess\n puts \"Incorrect guess :(\"\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }