query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
sequencelengths
0
101
negative_scores
sequencelengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Find a string in text input Finds all occurrences of the input string in the input content, and returns the matches
def edit_text_find_simple_with_http_info(request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_find_simple ...' end # verify the required parameter 'request' is set if @api_client.config.client_side_validation && request.nil? fail ArgumentError, "Missing the required parameter 'request' when calling EditTextApi.edit_text_find_simple" end # resource path local_var_path = '/convert/edit/text/find/string' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(request) auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'FindStringSimpleResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_find_simple\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match_text text\n @lookups.each do |rx_curr|\n return true if text =~ rx_curr\n end\n false\n end", "def partial_matches_for(input_string)\n # [\"aardvark\", \"apple\"]\n @word_list.select do |word|\n word.start_with?(input_string)\n end\n end", "def textmatch(text, terms)\n terms.all? { |term| text =~ /#{term}/i }\nend", "def search_words\n begin\n regex = Regexp.new(@pattern)\n rescue RegexpError => msg\n error_msg(msg)\n rescue NameError => msg\n error_msg(msg)\n end\n @results = DICT.select do |word|\n regex =~ word\n end\n @num_results = @results.length\n format_results\n display_results\n end", "def exact_matches(search_word, string)\n regexp = Regexp.new(Regexp.escape(search_word), \"i\")\n return (string.scan(regexp) || []).length\n end", "def find(string)\n string = string.split(//).join(\".*?\")\n pattern = \"/#{string}/i\"\n\n results = self.cache.grep /#{string}/i\n\n return results\n end", "def matches(input)\n (0...input.length).reduce([]) do |memo, offset|\n memo + matches_at_offset(input, offset)\n end\n end", "def matches(str)\n each_match(str).to_a\n end", "def find(input)\n end", "def search(word)\n \n end", "def find(t)\n text = t\n text.downcase! unless @case_sensitive\n text.gsub!(/\\s+/,' ') # Get rid of multiple spaces.\n @state = 0\n index = 0\n text.each_char do |char|\n # Incrementing now so that I can announce index - @length.\n index += 1\n @state = step(@state,char)\n if @state == @length # Yay, we've got ourselves a match!\n puts \"Match found for #{@word[1,@length]} at #{index - @length}\"\n @state = 0\n end\n end\n end", "def search(str)\n return [] if str.to_s.empty?\n \n words = str.downcase.split(' ')\n pattern = Regexp.new(words.join('|'))\n matches = []\n\n pages.each do |page|\n if page.title.downcase =~ pattern\n matches << [page, []]\n \n elsif page.body.downcase =~ pattern\n matches << [page, highlight(page.html, words)]\n end\n end\n\n matches\n end", "def find_reg_ex_matches( reg_ex )\n match_set = Set.new\n @words_set.to_a.each do |word|\n match_set.add word if word.downcase.match(reg_ex)\n end\n match_set\n end", "def search_values_in_quotes\n search_string.scan(REGEX_WORD_IN_QUOTES)\n end", "def search(string)\n raise 'The library is not open!' unless @open\n myStr = string\n count = 0\n pattern = Regexp.new(myStr, 'i')\n unless myStr.length >= 4\n puts 'Search string must contain at least four characters'\n else\n books_available.each_with_index do |line, index|\n tempString = line.to_s\n if tempString =~ pattern\n puts line\n temp_object = books_available.at(index)\n book_ids << temp_object.get_id\n count = count + 1\n end\n end\n\n if count == 0\n puts 'No books found'\n end\n\n end\n\n end", "def matches( input )\n matches = Array.new\n\n input.shorter.each_with_index do |char, idx|\n input.window_range( idx ).each do |widx|\n if input.longer[widx] == char then\n matches << widx\n break\n end\n end\n end\n\n return matches\n end", "def pattern_matching(pattern, genome)\n # Pattern Matching Problem: Find all occurrences of a pattern in a string.\n # Input: Two strings, Pattern and Genome.\n # Output: All starting positions where Pattern appears as a substring of Genome.\n\n # Sample Input:\n # ATAT\n # GATATATGCATATACTT\n\n # Sample Output:\n # 1 3 9\n\n match_indexes = []\n search_start_pos = 0\n while index = genome.index(pattern, search_start_pos)\n match_indexes << index\n # puts index\n search_start_pos = index + 1\n end\n return match_indexes\n end", "def search\n\t\terror_message = nil\n\t\tresults = []\n\t\tloop do\n\t\t\t# system \"clear\"\n\t\t\tputs error_message || \"Please enter how you'd like to search.\".green\n\t\t\tputs \"1) Exact Match\\n2) Partial Match\\n3) Begins With...\\n4) Ends With...\\n\"\n\t\t\tprint \">\".blink.cyan\n\t\t\tinput = gets.chomp.to_i\n\t\t\tif input.is_a?(Fixnum) && input >= 1 && input <= 4\n\t\t\t\tresults = @dictionary_analyzer.search(input, @dictionary)\n\t\t\t\tbreak\n\t\t\telse\n\t\t\t\terror_message = \"Sorry, invalid input. Please choose 1,2,3 or 4.\"\n\t\t\t\tredo\n\t\t\tend\t\n\t\tend\n\n\t\t# Now that we have the results let's do something\n\t\t# with them. Unless there aren't any.\n\t\tif results.count == 0\n\t\t\tputs \"Sorry, no words were found that match that string.\"\n\t\telse\n\t\t\tfound_match(results)\n\t\tend\n\tend", "def search(term)\n # pattern = Regexp.new(pattern, case_insensitive=true)\n # pattern = Regexp.new(pattern, Regexp::EXTENDED | Regexp::IGNORECASE)\n # pattern = Regexp.new(pattern)\n pattern = Regexp.new(term)\n select do |tweet|\n tweet.full_text =~ pattern\n end\n end", "def search_text(query, text)\n text = pattern(text)\n query.where { title.ilike(text) | description.ilike(text) }\n end", "def match(input)\n input \n end", "def search_in(label, string)\n if !LABELS.include? label.to_sym\n raise ArgumentError, \"Unknown key: #{label}\"\n end\n\n find_all do |entry|\n text = entry.send(label).str\n text.match(/#{string}/i)\n end\n end", "def word_finder (arr, str)\n arr.select do |value|\n value.include? str\n end\nend", "def findWord(query, array_of_strings)\n\t#array_of_strings.select {|str| str.match(query) }\n #array_of_strings.any? {|i| i[query] }\n array_of_strings.reject {|x| x.match (/#{query}/) }\nend", "def my_array_finding_method(source, thing_to_find)\n match_words = []\n source.each do |word| \n for i in 0...word.to_s.length\n if thing_to_find === word[i]\n match_words.push(word)\n break\n end\n end\n end\n return match_words\nend", "def matches(s, re)\n start_at = 0\n matches = []\n while(m = s.match(re, start_at))\n matches.push(m)\n start_at = m.end(0)\n end\n matches\n end", "def match(text)\n shift = 0\n result = []\n\n # Try to take previous element from cache, if .test() called before\n if (@__index__ >= 0 && @__text_cache__ == text)\n result.push(Match.createMatch(self, shift))\n shift = @__last_index__\n end\n\n # Cut head if cache was used\n tail = shift ? text.slice(shift..-1) : text\n\n # Scan string until end reached\n while (self.test(tail))\n result.push(Match.createMatch(self, shift))\n\n tail = tail.slice(@__last_index__..-1)\n shift += @__last_index__\n end\n\n if (result.length)\n return result\n end\n\n return nil\n end", "def match_text_exact(match_string, reject = false)\n text = match_string.downcase || \"\"\n proc = Proc.new { |entry|\n title, summary, content = cleaned_content(entry)\n title.include?(text) ||\n summary.include?(text) ||\n content.include?(text)\n }\n reject ? self.entries.reject(&proc) : self.entries.find_all(&proc)\n end", "def search_text(text)\n sets = @schemes.map do |scheme|\n scheme.find_all(text).uniq\n end\n sets.flatten.uniq\n end", "def search_note(string)\n logger.info 'Searching for a string within a note'\n search string\n end", "def brute_force_matches string, pattern\n i = 0\n pos = []\n while i + pattern.length - 1 < string.length\n pos << i if string[i..(i + pattern.length - 1)] == pattern\n i += 1\n end\n pos\nend", "def my_array_finding_method(source, thing_to_find)\n result = [] # result is the output array\n source.each do |word|\n word_array = word.to_s.split(//) # This creates an array of charaters of 'word'\n if word_array.include?(thing_to_find)\n result.push(word)\n end\n end\n return result\nend", "def include?(searchstring, substring)\n\nend", "def my_array_finding_method(source, thing_to_find)\n result = source.select{ |word| word.to_s.include? (thing_to_find) }\n result\nend", "def my_array_finding_method(source, thing_to_find)\n source.select { |word| word.to_s.include? thing_to_find}\nend", "def match(input); end", "def my_array_finding_method(source, thing_to_find)\n source.select { |word| word.to_s.include? thing_to_find }\nend", "def match(keyword); end", "def my_array_finding_method(source, thing_to_find)\n # final_array = []\n # source.each do |word|\n # if word.class == thing_to_find.class && word.include?(thing_to_find) == true\n # final_array << word\n # end\n # end\n # return final_array\n ###### refactor\n return source.grep(/#{ thing_to_find }/)\nend", "def brute_search string, pattern\n pattern_length = pattern.length\n for string_index in (0... string.length)\n match_count = 0\n loop do\n # if a non-match is found, then break.\n break if string[string_index + match_count] != pattern[match_count]\n # if it wasn't a non-match, it must be a match!\n match_count += 1\n # if match_count reaches the length of the pattern, you've found your pattern!\n # return the index in string where the pattern begins\n return string_index if match_count == pattern_length\n end\n end\n return \"not found\"\nend", "def brute_search string, pattern\n pattern_length = pattern.length\n for string_index in (0... string.length)\n match_count = 0\n loop do\n # if a non-match is found, then break.\n break if string[string_index + match_count] != pattern[match_count]\n # if it wasn't a non-match, it must be a match!\n match_count += 1\n # if match_count reaches the length of the pattern, you've found your pattern!\n # return the index in string where the pattern begins\n return string_index if match_count == pattern_length\n end\n end\n return \"not found\"\nend", "def matches(s, re)\r\n start_at = 0\r\n matches = [ ]\r\n while(m = s.match(re, start_at))\r\n matches.push(m)\r\n start_at = m.end(0)\r\n end\r\n return matches\r\n end", "def search(word)\r\n \r\n end", "def found_match(str)\n\tif dictionary.include?(str) # returns true if found in the dictionary\n\t\treturn str # don't stop the recursion, but return the word ?\n\tend\n\tfalse\nend", "def bruteForceStringSearch(text,pattern)\n\treturn nil if pattern.nil? or text.nil?\n\tn = text.length\n\tm = pattern.length\n\t0.upto(n-m) do |i|\n\t\tj = 0\n\t\twhile (j < m) and text[i+j] == pattern[j] do\n\t\t\tj += 1\n\t\tend\n\t\treturn i if j==m\n\tend\n\treturn nil\nend", "def search(pattern)\n entries.grep(Regexp.new(pattern))\n end", "def check_for (array, thing_to_find )\n array.select { |word| word.include? thing_to_find }\n end", "def find_a(array)\n array.find_all do |words|\n words.start_with?(\"a\")\n end\nend", "def find_contact(input)\n # binding.pry\n index_result = []\n matches = Contact.all.each_with_index do |one_contact, index|\n if one_contact.name.to_s =~ /#{Regexp.quote(input)}/i \n index_result << index\n end\n end\n puts \"Here's a list of contacts matching your search: \"\n puts \"================================\"\n index_result.each do |index|\n puts \"Name: #{Contact.find(index).name}\"\n puts \"Email: #{Contact.find(index).email}\"\n puts Contact.find(n).phone_hash.to_yaml\n puts \"================================\"\n end\n end", "def match(string)\n result = @trie[string]\n return nil unless result\n result.each do |pattern, block|\n match = pattern.match(string)\n block.call(match) if match\n end\n end", "def linear_search(input)\n \n search_name = input.downcase.split(' ')\n search_name.each do |name_el|\n \n entries.each do |entry|\n \n name_array = entry.name.downcase.split(' ')\n \n if name_array.include?(name_el)\n return entry\n end\n end\n end\n return nil\n end", "def text_search (string,text)\n\tif !$browser.text.include? string \n\t\tputs \"Error: #{text} not found\"\n\tend\nend", "def fuzzy_match( input, match_against )\n [*match_against].each_with_index do |targ, idx|\n if input =~ /^#{targ}$/i\n return idx\n elsif input.slice(0..5) =~ /^#{targ.slice(0..5)}/i\n return idx\n end\n end\n return nil\n\n end", "def search_str(to, po)\n # final value\n s_val = []\n\n # convert into array\n t_arr = to.split('')\n p_arr = po.split('')\n\n # get the count of lookup array\n t_len = t_arr.count - 1\n p_len = p_arr.count - 1\n nxt_ctr = 0 # counter\n\n # loop at t array\n t_arr.each_with_index do |_v, i|\n # break if the counter reached the last element\n break if p_len == t_len\n\n # Compare the set of values in an array with the p array\n s_val << i if t_arr[nxt_ctr..p_len] == p_arr\n\n # Increment the next counter set\n nxt_ctr += 1\n p_len += 1\n end\n s_val\nend", "def textField(textField, completions:somecompletions, forPartialWordRange:partialWordRange, indexOfSelectedItem:theIndexOfSelectedItem)\n matches = Entry.where(:title).contains(textField.stringValue,NSCaseInsensitivePredicateOption).map(&:title).uniq\n matches\n end", "def search_non_note(string)\n logger.info \"Searching for '#{string}'\"\n search string\n end", "def search(word, list)\n\tlist.each do |item|\n\t\tif item == word\n\t\t\tp \" '#{item}' was found\" \n\t\tend\n\tend\nend", "def findi(words)\n puts words.scan(/i/i).count\nend", "def find_bigrams(str, bigrams)\n bigrams.select { |bigram| str.include?(bigram)}\nend", "def rabinKarpStringSearch(text, pattern)\n return nil if pattern.nil? or text.nil?\n n = text.length\n m = pattern.length\n\n patternHash = hash_of(pattern)\n textHash = hash_of(text[0,m]) \n\n 0.upto(n-m) do |i|\n if textHash == patternHash\n if text[i..i+m-1] == pattern\n return i\n end\n end\n \n textHash = hash_of(text[i+1..i+m])\n end\n \n nil\nend", "def match_string( tree, string )\n # puts \"Checking for `#{string}` in tree (#{tree}).\"\n\n if tree.empty?\n # puts \"Tree is empty, returning empty\"\n return [ ]\n\n elsif string.empty?\n # puts \"No search string, returning empty\"\n return [ ]\n\n else\n matches = [ ]\n\n tree.each do |key,val|\n # puts \"Checking for `#{string}` in `#{key}` branch.\"\n\n simdex = string.simdex(key)\n\n if 0 < simdex\n if string == key\n # puts \"Matched full word! #{string} is #{key}\"\n # matches = collect_keys(val, key).unshift(key)\n return collect_keys(val, key).unshift(key)\n # puts \"Got matches: #{matches}\"\n\n else\n leaf = string.leaf(simdex)\n # puts \"Got leaf #{leaf}\"\n\n check = match_string(val, leaf)\n # puts \"Got check: #{check}\"\n\n if !check.empty?\n # matches = (check.map { |m| key + m })\n return check.map { |m| key + m }\n # puts \"New matches: #{matches}\"\n end\n end\n\n # break\n\n else\n check = match_string(val, string)\n\n if !check.empty?\n matches += check\n end\n end\n end\n\n # if matches.empty?\n # # puts \"No matches (#{string})\"\n # else\n # # puts \"Returning matches (#{string}): #{matches}\"\n # end\n\n return matches\n end\n end", "def check_in(word)\n if /lab/ =~ word\n puts word\n else\n puts \"No match\"\n end\nend", "def check_in(word)\n if /lab/ =~ word\n puts word\n else\n puts \"No match\"\n end\nend", "def check_in(word)\n if /lab/ =~ word\n puts word\n else\n puts \"No match\"\n end\nend", "def find(input)\r\n if include?(input)\r\n Hash[input, (@@words[input])]\r\n elsif keywords.any? {|key| key.start_with?(input)}\r\n @@words.select {|key, value| key.start_with?(input)}\r\n else\r\n Hash.new\r\n end \r\nend", "def search(plaintext)\n call(:search, :plaintext => plaintext)[:search_response][:return]\n end", "def search_full(pattern, succptr, getstr)\n _scan(pattern, succptr, getstr)\n end", "def match(array)\n array.find_all do |word|\n # split word into arry of letters\n if word.split(\"\").sort == @word.sort\n word\n end\n end\n end", "def match(text)\n if match = @regexp.match(text)\n @matched_text = match.to_s\n [match.to_s, @name]\n else\n nil\n end\n end", "def article_match? (query, article_title)\n found = false\n return true if query.empty?\n temp_article = article_title.downcase\n query.each do |kw|\n pattern = Regexp.new /.*#{kw.downcase}.*/\n found = true if temp_article =~ pattern\n end\n found\nend", "def search_helper *args\n matches = []\n @script_executor.search(*args) { |match|\n matches << match\n }\n matches\nend", "def custom_count(string, search_characters)\n str = string.chars\n searched = search_characters.chars\n p str\n p searched\n count = 0\n str.each do |item|\n if searched.include?(item)\n count = count + 1\n end\n end\n count\nend", "def search_search(exploits_array, query)\n search_results=[]\n exploits_array.each do |line|\n line = line.unpack('C*').pack('U*') if !line.valid_encoding?\n if query == 'nil'\n search_results << line\n else\n search_results << line if line =~ /#{query}/i\n end\n end\n return search_results\nend", "def searchABatch(directory, extension, searchString)\n return Dir.entries(directory).select{|file| File.open(file, \"r\").include?(searchString)}\nend", "def contains_text(str)\n text.index(str)\n end", "def match(str)\n d, m = str.split(\" \")\n _match(d, m) \n end", "def find(prepostion)\n\t\tpartial_search_kb = string_to_internal(preposition)\n\t\tpartial_search_kb.each do |sentence|\n\t\t\tind = @kb.index(sentence)\n\t\tend\n\t\treturn ind\n\tend", "def matchanywhere(rgx, text)\n if rgx[0] == '^'\n return matchhere(rgx[1..-1], text)\n elsif matchhere(rgx, text)\n return true\n elsif text.nil? && !rgx.nil?\n return false\n else\n return matchanywhere(rgx, text[1..-1])\n end\nend", "def word_pattern(pattern, input)\n \nend", "def find_ocurrences(text, first, second)\n text = text.split(' ')\n \n word_output = []\n \n text.each_with_index do |word, index|\n next if index == 0 || index == 1\n \n word_output << word if text[index - 1] == second && text[index - 2] == first\n end\n \n word_output\nend", "def search(list)\n count = 0\n list.each_line do |string|\n count += 1 if is_a_nice_string?(string)\n end\n count\nend", "def search_substr( fullText, searchText, allowOverlap = true )\n if searchText == ''\n 0\n else\n fullText.scan(allowOverlap ? Regexp.new(\"(?=(#{searchText}))\") : searchText).size\n end\nend", "def find_matches(bucket, word)\n\t\tmatches = bucket.map do |exp, match|\n\t\t\tword =~ exp ? match : nil\n\t\tend\n\t\tmatches.compact\n\tend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def match_in_string?(string, regex)\n string.match(regex).class == MatchData\nend", "def check_for_matches(input)\n @matched = false\n secret_word_array = @secret_word.split(\"\")\n\n secret_word_array.each_with_index do |char, idx|\n if char == input || char == input.upcase\n @matched_letters.insert(idx, char).slice!(idx+1)\n @matched = true\n end\n end\n\n if !@matched\n @guesses_left -= 1\n @misses += \", \" unless @misses == \"\"\n @misses += input\n end\n end", "def match(*strings)\n result = []\n @tags.each do |tag|\n strings.each do |string|\n if string.downcase =~ /#{tag.downcase}/\n strings.delete string\n result << tag\n break\n end\n end\n end\n return result\n end", "def all_alpha_matches(input)\n where(alpha: sort_letters(input)).pluck :text\n end", "def matches (string, pattern)\n if string . length == 0 || pattern . length == 0\n return 0\n end\n\n count = matches string [1 .. -1], pattern\n\n if string [0] == pattern [0]\n if pattern . length == 1\n count += 1\n else\n count += matches string [1 .. -1], pattern [1 .. -1]\n end\n end\n\n return count\nend", "def alpha_search(str)\r\n\r\nend" ]
[ "0.68036395", "0.6795913", "0.67817473", "0.67779964", "0.67151433", "0.6652563", "0.6601666", "0.65592533", "0.6536796", "0.6494622", "0.64858484", "0.6435211", "0.6286359", "0.62684727", "0.625438", "0.62385225", "0.62101394", "0.62021774", "0.6197026", "0.6191484", "0.61857665", "0.6176195", "0.6162423", "0.61596686", "0.61588895", "0.61509293", "0.6135211", "0.6129049", "0.6128614", "0.61249727", "0.61019206", "0.6090966", "0.6055051", "0.60489583", "0.6020805", "0.6013889", "0.60108906", "0.59931785", "0.5986304", "0.5984347", "0.5984347", "0.59530395", "0.59517586", "0.5938692", "0.5936688", "0.59274846", "0.59229094", "0.5902286", "0.5884282", "0.5880557", "0.58775306", "0.58713996", "0.58631396", "0.58624184", "0.58550143", "0.5853487", "0.58525324", "0.58198345", "0.5819184", "0.5815157", "0.5814918", "0.5809757", "0.5809757", "0.5809757", "0.5806456", "0.5805809", "0.5800005", "0.5765715", "0.5765593", "0.5764866", "0.57505935", "0.5742885", "0.5742184", "0.5740217", "0.57342243", "0.573201", "0.57308686", "0.57305217", "0.5728626", "0.57280695", "0.5702954", "0.56957376", "0.5695454", "0.5692202", "0.5692202", "0.5692202", "0.5692202", "0.5692202", "0.5692202", "0.5692202", "0.5692202", "0.5692202", "0.5692202", "0.5692202", "0.5692202", "0.5692202", "0.5690693", "0.5688165", "0.56848633", "0.5680803", "0.56777036" ]
0.0
-1
Remove whitespace from text string Removes all whitespace from text, leaving behind only nonwhitespace characters. Whitespace includes newlines, spaces and other whitespace characters.
def edit_text_remove_all_whitespace(request, opts = {}) data, _status_code, _headers = edit_text_remove_all_whitespace_with_http_info(request, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_whitespace(text)\n text.to_s.gsub(/[[:space:]]+/, ' ').strip\n end", "def trimmed_whitespace(text)\n text.gsub(/[\\t\\n\\f\\r ]+/ium, ' ')\n end", "def strip_all_spaces(text)\n text&&text.gsub(/&nbsp;|\\xC2\\xA0|\\xA0/, ' ').strip\n end", "def sanitize text\n [' ', '\\r\\n', \"\\r\\n\", \"\\n\", \"\\r\", \"\\t\", / ^/, / $+/, /^  /, /^ /].each { |text_to_remove|\n text.gsub!(text_to_remove,'')\n }\n return text\n end", "def clean(str)\n return nil unless str\n str.gsub(/\\p{Space}/, ' ').strip.squeeze(' ')\n end", "def whitespace_fixup(text)\n text.andand.gsub(/\\r/, \"\")\n end", "def cleanup(text)\n text.gsub(/[^a-z]/i,\" \").squeeze(\" \")\nend", "def squash(text)\n return text.scrub.gsub(/[[:space:]]+/, ' ').strip\nend", "def whitespace_fixup(text)\n text.andand.gsub(/\\r/, \"\")\n end", "def cleanup(string)\n string.gsub!(/\\W/, ' ').squeeze(' ')\nend", "def remove_whitespace\n # NOTE: According to the docs, \\s only matches [ \\t\\r\\n\\f], i.e. it does not\n # match e.g. non-breaking space (&nbsp). The POSIX character class\n # [[:space:]] does match non-breaking space. This is relevant because\n # in Heroku, space in ENV variables might be translated as &nbsp.\n # DOC: http://ruby-doc.org/core-2.5.1/Regexp.html#class-Regexp-label-Character+Classes\n # SOURCE: http://stackoverflow.com/a/13288542\n gsub(/[[:space:]]/, '')\n end", "def cleanup(txt)\n txt.gsub(/[^a-z]/i, ' ').squeeze(' ')\nend", "def cleanup(str)\n str.gsub(/\\W/, ' ').squeeze(' ')\nend", "def clean_up_spaces(string)\n string.gsub(\"\\n\", ' ').gsub(/[[:space:]]+/, ' ').strip if string.is_a? String\n end", "def cleanup(str)\n str.gsub!(/[^0-9a-z ]/i, ' ')\n str.gsub!(/\\s+/, ' ')\nend", "def dewhitespace\n gsub(/\\s+/,' ').strip\n end", "def strip(s)\n s.gsub(/^\\s+/, '').gsub(/\\s+$/, '')\n end", "def pre_proccess(text)\n text.to_s.strip.gsub(/[[:space:]]+/, ' ').gsub(/\\s{2,}/, ' ')\n end", "def cleanup(string)\n string.gsub!(/\\W+/, ' ')\nend", "def cleanup(str)\r\n str.gsub!(/[^a-z]/, ' ').squeeze(' ')\r\nend", "def admin_strip_text(str)\n\t\tstr.gsub(/\\t|\\n/,'')\n\t\tstr.strip\n\tend", "def clean text\n text.gsub(/(\\n|\\t|\\r)/, ' ').gsub(/>\\s*</, '><').squeeze(' ')\n end", "def clean_string s\n s.gsub(/\\s/, \"\")\n end", "def cleanup(string)\n string.gsub!(/[^a-zA-Z]/, ' ').squeeze(' ')\nend", "def cleanup(str)\n str.gsub(/\\W+/, ' ')\nend", "def clear_text(text)\n text = text.tr(\"\\n\", \" \")\n text.gsub(/[^0-9A-Za-z. ]/, '')\n end", "def cleanup(str)\n str.gsub(/\\W+/,' ')\nend", "def remove_whitespaces(myString)\n\treturn myString.gsub(/\\s+/, \"\")\nend", "def cleanup(string)\n string.gsub(/[^a-z]/i, ' ').squeeze(' ')\nend", "def cleanup(string)\n string.gsub(/[^a-z0-9]/, \" \").gsub(/\\s+/, \" \")\n # string.gsub(/[^a-z]/, ' ').squeeze(' ')\nend", "def cleanup(string)\n string.gsub(/[^a-z]/, ' ').squeeze(' ')\nend", "def regex_strip(string)\n return string.gsub(/[^\\p{L}\\p{N}]/u, \" \")\n end", "def cleanup(str)\n str.gsub(/([^a-z])/, ' ').squeeze(' ')\nend", "def cleanup(str)\n str.gsub(/[^a-z]/,\" \").squeeze(\" \")\nend", "def cleanup(string)\n string.gsub(/[\\W\\d]/, ' ').gsub(/\\s+/, ' ')\nend", "def clean_text(string)\n if string\n string.chomp!\n string.gsub!(/\\t+|\\(.+?\\)\\s*/,'')\n string.gsub!(/‘|’|„|“/, \"'\")\n string.squeeze!(\"?|!\")\n string.gsub!(/!\\?|\\?!/, \"?\")\n string.gsub!(/…|!|\\.\\.\\./, \".\") # Used the three marks to keep the count clean\n string.gsub!(/(Na)(ja)/i, '\\1 \\2')\n string.squeeze(\" \").strip\n else\n \"\"\n end\n end", "def cleanup(string)\n string.gsub(/[^a-z]/i, \" \").squeeze(' ')\nend", "def cleanup(string)\n string = string.gsub(/[^a-z]/i, ' ')\n until !string.include?(' ')\n string.gsub!(' ', ' ')\n end\n string\nend", "def white_out(str)\n str.delete(\" \\n\\t\")\nend", "def compact_whitespace s\n s.gsub(/\\s+/, ' ').gsub(/>\\s</, '><').strip\n end", "def cleanup2(string)\n string.gsub(/[^a-z]/i, ' ').squeeze\nend", "def cleanup(string)\n\ts = string.gsub(/[^0-9a-z]/i, ' ')\n\ts.squeeze(\" \")\nend", "def trim_all_whitespace(text)\n text.to_a.map do |line|\n left_spacing(line) + line.squeeze(\" \").squeeze(\" \").lstrip #the 2. is a tab\n end.join\n end", "def cleanup(str)\nstr.gsub!(/[^0-9A-Za-z]/, \" \").squeeze(\" \")\n\nend", "def trim(string)\n string.sub(/^[  ]+/, '').sub(/[  ]+$/, '')\n end", "def cleanup string\n string.gsub(/\\W|\\d/, ' ').gsub(/\\ (?=\\ )/, '')\nend", "def clean_whitespace(a)\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\nend", "def clean_whitespace(a)\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\nend", "def strip_trailing_whitespace(text)\n text.split(\"\\n\").collect(&:strip).join(\"\\n\")\n end", "def cleanup(str)\n # str.gsub!(/[^a-z]/, ' ').squeeze(' ')\n str.tr_s(' -/:-@[-`{-~', ' ')\nend", "def clean_whitespace(a)\n\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\n\nend", "def clean_whitespace(a)\n\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\n\nend", "def strip_whitespace!\n replace(self.strip_whitespace)\n end", "def normalize_whitespace(input)\n input.to_s.gsub(%r!\\s+!, \" \").tap(&:strip!)\n end", "def clean_text(text)\n text.gsub!(/\\r\\n/, '')\n text.gsub!(/\\r/, '')\n text\n end", "def cleanup(sentence)\n sentence.gsub(/[^a-z]+/i, ' ')\nend", "def cleanup(str)\n str.gsub!(/[^a-z]+/i, ' ') if str.match(/[^a-z]+/i)\n str\nend", "def strip_leading_whitespace(text)\n return text if text.empty?\n leading_spaces = text.lines.first[/^(\\s+)/, 1]\n text.gsub(/^#{leading_spaces}/, '')\n end", "def cleanup(string)\n string.gsub(/[^A-Za-z0-9]/, \" \").squeeze\nend", "def remove_nonprinting_chars(text)\n return text if text.blank?\n\n text.chars.map { |char| rejected_char?(char) ? ' ' : char }.join\n end", "def clean_html_string(string)\n string.\n inner_text.\n gsub(/\\s+/, \" \").\n strip\n end", "def cleanup(input)\n input.gsub(/[^a-zA-Z]/, ' ').squeeze(' ')\nend", "def cleanup(string)\n string.gsub!(/[^a-z]/i, \" \") #/i makes it case insensitive\n\n loop do\n string.gsub!(\" \", \" \")\n break if !string.include?(\" \")\n end\n string\nend", "def cleanup(str)\n str.gsub(/[^a-zA-Z]+/, ' ')\nend", "def normalize_spacing(text)\n text\n .delete(REMOVED_CHARACTERS)\n .tr(SQUEEZED_SPACES, ' ')\n .squeeze(' ')\n .sub(LEADING_SPACES, '')\n .sub(TRAILING_SPACES, '')\n .tr(NON_BREAKING_SPACE, ' ')\n end", "def normalize( text )\n text.gsub(/\\s/,'').gsub(/[[:punct:]]/, '').gsub(/\\p{S}/,'').downcase\nend", "def cleanup str\n str2 = str.gsub(/[^A-Za-z]/, ' ')\n str3 = str2.gsub(/[ ]{2,}/, ' ')\nend", "def cleanup(str)\n clean = str.chars.map do |char|\n ('a'..'z').include?(char) ? char : ' '\n end\n clean.join.squeeze(' ')\nend", "def remove_whitespace( answer_string )\n if @whitespace.nil?\n answer_string\n elsif [:strip, :chomp].include?(@whitespace)\n answer_string.send(@whitespace)\n elsif @whitespace == :collapse\n answer_string.gsub(/\\s+/, \" \")\n elsif [:strip_and_collapse, :chomp_and_collapse].include?(@whitespace)\n result = answer_string.send(@whitespace.to_s[/^[a-z]+/])\n result.gsub(/\\s+/, \" \")\n elsif @whitespace == :remove\n answer_string.gsub(/\\s+/, \"\")\n else\n answer_string\n end\n end", "def no_space(x)\n x.gsub(\" \", \"\")\nend", "def cleanup(string)\n characters = string.chars\n characters.each_with_index do |char, index|\n if !('a'..'z').include?(char.downcase)\n if characters[index - 1] == ' '\n characters[index - 1] = ''\n characters[index] = ' '\n else\n characters[index] = ' '\n end\n end\n end\n characters.join\nend", "def condense_spaces(str)\n str.gsub(/\\s+/, \" \")\n end", "def cleanup(string)\n letters = %w(a b c d e f g h i j k l m n o p q r s t u w v x y z\n A B C D E F G H I J K L M N O P Q R S T U W V X Y Z )\n index = 0\n loop do\n string[index] = ' ' unless letters.include?(string[index])\n index += 1\n break if index == string.size\n end\n string.squeeze(' ')\nend", "def cleanup(text)\n text && text.gsub(\"\\t\", ' ').dedent\n end", "def normalize_whitespace(string)\n # in most cases there is nothing to do, then leave immediately\n return string unless string.match(/\\s\"\\s/)\n\n scanner = StringScanner.new(string)\n reset_direct_speech_status\n string_with_normalized_whitespace(scanner)\n end", "def strip_space!\n replace self.gsub(/:\\s*/, \":\").gsub(/\\n/, \"\").gsub(/\\s+/, \" \").gsub(/(\\/\\*).*?(\\*\\/)/, \"\")\n end", "def trim_whitespace; end", "def strip(s)\n Sanitize.clean(s)\n end", "def cleanup(str)\r\n str.chars.map {|char| char.match(/[A-Za-z0-9]/) ? char : ' ' }.join.squeeze(\" \")\r\nend", "def sanitize_text(text)\n text = unescape_text(text)\n text = extract_text(text) if aruba.config.remove_ansi_escape_sequences\n\n text.chomp\n end", "def clean_ws(s)\n Util.clean_ws(s)\n end", "def clean( input )\n input.gsub( %r/\\s+/, '' )\n end", "def unindent(text)\n text.strip.gsub(/^\\s+/, \"\")\n end", "def cleanup(str)\n char_clean = []\n str.chars.each do |char|\n if /[a-z]/.match(char)\n char_clean << char\n else\n char_clean << ' ' unless char_clean[-1] == ' '\n end\n end\n char_clean.join\nend", "def cleanup(text)\n text.gsub(/[^a-z]/i, '')\nend", "def strip\n lambda do |rec, acc|\n acc.collect! do |v|\n # unicode whitespace class aware\n v.sub(/\\A[[:space:]]+/,'').sub(/[[:space:]]+\\Z/, '')\n end\n end\n end", "def remove_leading_and_trailing_whitespace(text)\n pre_blocks = text.split(DO_NOT_TOUCH_WHITESPACE)\n\n output = []\n pre_blocks.each.with_index do |block, index|\n if index % 2 == 0\n output << block.gsub(/[ \\t]*\\n[ \\t]*/im, \"\\n\").gsub(/ *\\t */im, \"\\t\")\n else\n output << block\n end\n end\n\n output.join\n end", "def strip_squeeze\n strip.squeeze(\" \")\n end", "def cleanup_noregexp str\n str2 = ''\n str.chars.each do |chr|\n case chr.downcase\n when ('a'..'z')\n str2 << chr\n else\n str2 << ' '\n end\n end\n str2.squeeze(' ')\nend", "def cleanup_string(string, strip: true)\n return \"\" if string.nil?\n raise ArgumentError, \"Expected a string or an object that implements #to_str\" unless string.respond_to?(:to_str)\n\n s = strip_tags(string.to_str)\n s = s.dup if s.frozen?\n s.gsub!(/\\s+/, \" \")\n s.strip! if strip\n\n s\n end", "def cleanup(str)\n\tnew_str = str.gsub(/[^a-z]/i, ' ').split.join(' ')\n\t\" #{new_str} \"\nend", "def normalize_whitespace(input); end", "def strip(string)\n while string[-1] == \" \" || string[-1] == \"\\n\" || string[-1] == \"\\t\"\n string[-1] = \"\"\n end\n while string[0] == \" \" || string[0] == \"\\n\" || string[0] == \"\\t\"\n string[0] = \"\"\n end\n return string\nend", "def cleanup(str)\n str.chars.map { |char| ('a'..'z').include?(char.downcase) ? char : ' ' }.join.squeeze(' ')\nend", "def no_space(x)\n # code go here\n x.gsub(' ', '')\nend", "def clean_content(content)\n content.gsub(/[^a-zA-Z ]/, '').squeeze(' ').downcase.strip\n end", "def cleanup(string)\n i = 0\n final = ''\n while i < string.length\n final << (('a'..'z').cover?(string[i]) ? string[i] : ' ')\n i += 1\n end\n final.squeeze(' ')\nend", "def strip_tags_nbsp(text)\n if text.present?\n strip_tags(text.gsub('&nbsp;', ' '))\n end\n end", "def clean_string(string)\n string.gsub(/\\W+/, '')\nend", "def cleanup(str)\n new_string = []\n characters = ['-', \"'\", '+', '*', '&', '?']\n str.chars.each do |c|\n characters.include?(c) ? new_string << ' ' : new_string << c\n end\n new_string.join.squeeze\nend" ]
[ "0.81326824", "0.80019504", "0.76887697", "0.76572776", "0.75752884", "0.757346", "0.7497051", "0.74809724", "0.7444948", "0.74003035", "0.7357382", "0.7331862", "0.73272204", "0.73223364", "0.73080677", "0.7296706", "0.7286191", "0.72791386", "0.7262048", "0.725166", "0.7229612", "0.72207856", "0.72188306", "0.7215364", "0.72116834", "0.71997285", "0.7194891", "0.7188525", "0.71816003", "0.71769726", "0.7169505", "0.715123", "0.7117207", "0.71087056", "0.7103694", "0.70950633", "0.70797133", "0.70747894", "0.7015231", "0.699895", "0.69885767", "0.69440395", "0.6935537", "0.69354975", "0.6915514", "0.69134", "0.69041896", "0.69041896", "0.69036394", "0.6895953", "0.68826956", "0.68826956", "0.6879251", "0.6867463", "0.6846993", "0.6843047", "0.6838626", "0.68307406", "0.68243533", "0.68132114", "0.6812604", "0.68112355", "0.6801239", "0.67986405", "0.6793454", "0.67869645", "0.67716587", "0.67621917", "0.6751039", "0.6746441", "0.6725188", "0.6688672", "0.6676151", "0.6657974", "0.6656669", "0.66516596", "0.6632439", "0.66237456", "0.66237324", "0.6612291", "0.66111857", "0.6609933", "0.66093236", "0.660854", "0.6560098", "0.65422964", "0.65344274", "0.65074885", "0.64894724", "0.6486584", "0.64821297", "0.6458803", "0.64586496", "0.6446932", "0.64438903", "0.6441518", "0.640962", "0.6389723", "0.6387667", "0.638272" ]
0.6582775
84
Remove whitespace from text string Removes all whitespace from text, leaving behind only nonwhitespace characters. Whitespace includes newlines, spaces and other whitespace characters.
def edit_text_remove_all_whitespace_with_http_info(request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_remove_all_whitespace ...' end # verify the required parameter 'request' is set if @api_client.config.client_side_validation && request.nil? fail ArgumentError, "Missing the required parameter 'request' when calling EditTextApi.edit_text_remove_all_whitespace" end # resource path local_var_path = '/convert/edit/text/remove/whitespace/all' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(request) auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'RemoveWhitespaceFromTextResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_remove_all_whitespace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_whitespace(text)\n text.to_s.gsub(/[[:space:]]+/, ' ').strip\n end", "def trimmed_whitespace(text)\n text.gsub(/[\\t\\n\\f\\r ]+/ium, ' ')\n end", "def strip_all_spaces(text)\n text&&text.gsub(/&nbsp;|\\xC2\\xA0|\\xA0/, ' ').strip\n end", "def sanitize text\n [' ', '\\r\\n', \"\\r\\n\", \"\\n\", \"\\r\", \"\\t\", / ^/, / $+/, /^  /, /^ /].each { |text_to_remove|\n text.gsub!(text_to_remove,'')\n }\n return text\n end", "def clean(str)\n return nil unless str\n str.gsub(/\\p{Space}/, ' ').strip.squeeze(' ')\n end", "def whitespace_fixup(text)\n text.andand.gsub(/\\r/, \"\")\n end", "def cleanup(text)\n text.gsub(/[^a-z]/i,\" \").squeeze(\" \")\nend", "def squash(text)\n return text.scrub.gsub(/[[:space:]]+/, ' ').strip\nend", "def whitespace_fixup(text)\n text.andand.gsub(/\\r/, \"\")\n end", "def cleanup(string)\n string.gsub!(/\\W/, ' ').squeeze(' ')\nend", "def remove_whitespace\n # NOTE: According to the docs, \\s only matches [ \\t\\r\\n\\f], i.e. it does not\n # match e.g. non-breaking space (&nbsp). The POSIX character class\n # [[:space:]] does match non-breaking space. This is relevant because\n # in Heroku, space in ENV variables might be translated as &nbsp.\n # DOC: http://ruby-doc.org/core-2.5.1/Regexp.html#class-Regexp-label-Character+Classes\n # SOURCE: http://stackoverflow.com/a/13288542\n gsub(/[[:space:]]/, '')\n end", "def cleanup(txt)\n txt.gsub(/[^a-z]/i, ' ').squeeze(' ')\nend", "def cleanup(str)\n str.gsub(/\\W/, ' ').squeeze(' ')\nend", "def clean_up_spaces(string)\n string.gsub(\"\\n\", ' ').gsub(/[[:space:]]+/, ' ').strip if string.is_a? String\n end", "def cleanup(str)\n str.gsub!(/[^0-9a-z ]/i, ' ')\n str.gsub!(/\\s+/, ' ')\nend", "def dewhitespace\n gsub(/\\s+/,' ').strip\n end", "def strip(s)\n s.gsub(/^\\s+/, '').gsub(/\\s+$/, '')\n end", "def pre_proccess(text)\n text.to_s.strip.gsub(/[[:space:]]+/, ' ').gsub(/\\s{2,}/, ' ')\n end", "def cleanup(string)\n string.gsub!(/\\W+/, ' ')\nend", "def cleanup(str)\r\n str.gsub!(/[^a-z]/, ' ').squeeze(' ')\r\nend", "def admin_strip_text(str)\n\t\tstr.gsub(/\\t|\\n/,'')\n\t\tstr.strip\n\tend", "def clean text\n text.gsub(/(\\n|\\t|\\r)/, ' ').gsub(/>\\s*</, '><').squeeze(' ')\n end", "def clean_string s\n s.gsub(/\\s/, \"\")\n end", "def cleanup(string)\n string.gsub!(/[^a-zA-Z]/, ' ').squeeze(' ')\nend", "def cleanup(str)\n str.gsub(/\\W+/, ' ')\nend", "def clear_text(text)\n text = text.tr(\"\\n\", \" \")\n text.gsub(/[^0-9A-Za-z. ]/, '')\n end", "def cleanup(str)\n str.gsub(/\\W+/,' ')\nend", "def remove_whitespaces(myString)\n\treturn myString.gsub(/\\s+/, \"\")\nend", "def cleanup(string)\n string.gsub(/[^a-z]/i, ' ').squeeze(' ')\nend", "def cleanup(string)\n string.gsub(/[^a-z0-9]/, \" \").gsub(/\\s+/, \" \")\n # string.gsub(/[^a-z]/, ' ').squeeze(' ')\nend", "def cleanup(string)\n string.gsub(/[^a-z]/, ' ').squeeze(' ')\nend", "def regex_strip(string)\n return string.gsub(/[^\\p{L}\\p{N}]/u, \" \")\n end", "def cleanup(str)\n str.gsub(/([^a-z])/, ' ').squeeze(' ')\nend", "def cleanup(str)\n str.gsub(/[^a-z]/,\" \").squeeze(\" \")\nend", "def cleanup(string)\n string.gsub(/[\\W\\d]/, ' ').gsub(/\\s+/, ' ')\nend", "def clean_text(string)\n if string\n string.chomp!\n string.gsub!(/\\t+|\\(.+?\\)\\s*/,'')\n string.gsub!(/‘|’|„|“/, \"'\")\n string.squeeze!(\"?|!\")\n string.gsub!(/!\\?|\\?!/, \"?\")\n string.gsub!(/…|!|\\.\\.\\./, \".\") # Used the three marks to keep the count clean\n string.gsub!(/(Na)(ja)/i, '\\1 \\2')\n string.squeeze(\" \").strip\n else\n \"\"\n end\n end", "def cleanup(string)\n string.gsub(/[^a-z]/i, \" \").squeeze(' ')\nend", "def cleanup(string)\n string = string.gsub(/[^a-z]/i, ' ')\n until !string.include?(' ')\n string.gsub!(' ', ' ')\n end\n string\nend", "def white_out(str)\n str.delete(\" \\n\\t\")\nend", "def compact_whitespace s\n s.gsub(/\\s+/, ' ').gsub(/>\\s</, '><').strip\n end", "def cleanup2(string)\n string.gsub(/[^a-z]/i, ' ').squeeze\nend", "def cleanup(string)\n\ts = string.gsub(/[^0-9a-z]/i, ' ')\n\ts.squeeze(\" \")\nend", "def trim_all_whitespace(text)\n text.to_a.map do |line|\n left_spacing(line) + line.squeeze(\" \").squeeze(\" \").lstrip #the 2. is a tab\n end.join\n end", "def cleanup(str)\nstr.gsub!(/[^0-9A-Za-z]/, \" \").squeeze(\" \")\n\nend", "def trim(string)\n string.sub(/^[  ]+/, '').sub(/[  ]+$/, '')\n end", "def cleanup string\n string.gsub(/\\W|\\d/, ' ').gsub(/\\ (?=\\ )/, '')\nend", "def clean_whitespace(a)\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\nend", "def clean_whitespace(a)\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\nend", "def strip_trailing_whitespace(text)\n text.split(\"\\n\").collect(&:strip).join(\"\\n\")\n end", "def cleanup(str)\n # str.gsub!(/[^a-z]/, ' ').squeeze(' ')\n str.tr_s(' -/:-@[-`{-~', ' ')\nend", "def clean_whitespace(a)\n\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\n\nend", "def clean_whitespace(a)\n\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\n\nend", "def strip_whitespace!\n replace(self.strip_whitespace)\n end", "def normalize_whitespace(input)\n input.to_s.gsub(%r!\\s+!, \" \").tap(&:strip!)\n end", "def clean_text(text)\n text.gsub!(/\\r\\n/, '')\n text.gsub!(/\\r/, '')\n text\n end", "def cleanup(sentence)\n sentence.gsub(/[^a-z]+/i, ' ')\nend", "def cleanup(str)\n str.gsub!(/[^a-z]+/i, ' ') if str.match(/[^a-z]+/i)\n str\nend", "def strip_leading_whitespace(text)\n return text if text.empty?\n leading_spaces = text.lines.first[/^(\\s+)/, 1]\n text.gsub(/^#{leading_spaces}/, '')\n end", "def cleanup(string)\n string.gsub(/[^A-Za-z0-9]/, \" \").squeeze\nend", "def clean_html_string(string)\n string.\n inner_text.\n gsub(/\\s+/, \" \").\n strip\n end", "def remove_nonprinting_chars(text)\n return text if text.blank?\n\n text.chars.map { |char| rejected_char?(char) ? ' ' : char }.join\n end", "def cleanup(input)\n input.gsub(/[^a-zA-Z]/, ' ').squeeze(' ')\nend", "def cleanup(string)\n string.gsub!(/[^a-z]/i, \" \") #/i makes it case insensitive\n\n loop do\n string.gsub!(\" \", \" \")\n break if !string.include?(\" \")\n end\n string\nend", "def cleanup(str)\n str.gsub(/[^a-zA-Z]+/, ' ')\nend", "def normalize_spacing(text)\n text\n .delete(REMOVED_CHARACTERS)\n .tr(SQUEEZED_SPACES, ' ')\n .squeeze(' ')\n .sub(LEADING_SPACES, '')\n .sub(TRAILING_SPACES, '')\n .tr(NON_BREAKING_SPACE, ' ')\n end", "def normalize( text )\n text.gsub(/\\s/,'').gsub(/[[:punct:]]/, '').gsub(/\\p{S}/,'').downcase\nend", "def cleanup str\n str2 = str.gsub(/[^A-Za-z]/, ' ')\n str3 = str2.gsub(/[ ]{2,}/, ' ')\nend", "def cleanup(str)\n clean = str.chars.map do |char|\n ('a'..'z').include?(char) ? char : ' '\n end\n clean.join.squeeze(' ')\nend", "def remove_whitespace( answer_string )\n if @whitespace.nil?\n answer_string\n elsif [:strip, :chomp].include?(@whitespace)\n answer_string.send(@whitespace)\n elsif @whitespace == :collapse\n answer_string.gsub(/\\s+/, \" \")\n elsif [:strip_and_collapse, :chomp_and_collapse].include?(@whitespace)\n result = answer_string.send(@whitespace.to_s[/^[a-z]+/])\n result.gsub(/\\s+/, \" \")\n elsif @whitespace == :remove\n answer_string.gsub(/\\s+/, \"\")\n else\n answer_string\n end\n end", "def no_space(x)\n x.gsub(\" \", \"\")\nend", "def cleanup(string)\n characters = string.chars\n characters.each_with_index do |char, index|\n if !('a'..'z').include?(char.downcase)\n if characters[index - 1] == ' '\n characters[index - 1] = ''\n characters[index] = ' '\n else\n characters[index] = ' '\n end\n end\n end\n characters.join\nend", "def condense_spaces(str)\n str.gsub(/\\s+/, \" \")\n end", "def cleanup(string)\n letters = %w(a b c d e f g h i j k l m n o p q r s t u w v x y z\n A B C D E F G H I J K L M N O P Q R S T U W V X Y Z )\n index = 0\n loop do\n string[index] = ' ' unless letters.include?(string[index])\n index += 1\n break if index == string.size\n end\n string.squeeze(' ')\nend", "def normalize_whitespace(string)\n # in most cases there is nothing to do, then leave immediately\n return string unless string.match(/\\s\"\\s/)\n\n scanner = StringScanner.new(string)\n reset_direct_speech_status\n string_with_normalized_whitespace(scanner)\n end", "def cleanup(text)\n text && text.gsub(\"\\t\", ' ').dedent\n end", "def strip_space!\n replace self.gsub(/:\\s*/, \":\").gsub(/\\n/, \"\").gsub(/\\s+/, \" \").gsub(/(\\/\\*).*?(\\*\\/)/, \"\")\n end", "def trim_whitespace; end", "def cleanup(str)\r\n str.chars.map {|char| char.match(/[A-Za-z0-9]/) ? char : ' ' }.join.squeeze(\" \")\r\nend", "def strip(s)\n Sanitize.clean(s)\n end", "def sanitize_text(text)\n text = unescape_text(text)\n text = extract_text(text) if aruba.config.remove_ansi_escape_sequences\n\n text.chomp\n end", "def clean_ws(s)\n Util.clean_ws(s)\n end", "def clean( input )\n input.gsub( %r/\\s+/, '' )\n end", "def unindent(text)\n text.strip.gsub(/^\\s+/, \"\")\n end", "def cleanup(str)\n char_clean = []\n str.chars.each do |char|\n if /[a-z]/.match(char)\n char_clean << char\n else\n char_clean << ' ' unless char_clean[-1] == ' '\n end\n end\n char_clean.join\nend", "def edit_text_remove_all_whitespace(request, opts = {})\n data, _status_code, _headers = edit_text_remove_all_whitespace_with_http_info(request, opts)\n data\n end", "def cleanup(text)\n text.gsub(/[^a-z]/i, '')\nend", "def strip\n lambda do |rec, acc|\n acc.collect! do |v|\n # unicode whitespace class aware\n v.sub(/\\A[[:space:]]+/,'').sub(/[[:space:]]+\\Z/, '')\n end\n end\n end", "def remove_leading_and_trailing_whitespace(text)\n pre_blocks = text.split(DO_NOT_TOUCH_WHITESPACE)\n\n output = []\n pre_blocks.each.with_index do |block, index|\n if index % 2 == 0\n output << block.gsub(/[ \\t]*\\n[ \\t]*/im, \"\\n\").gsub(/ *\\t */im, \"\\t\")\n else\n output << block\n end\n end\n\n output.join\n end", "def strip_squeeze\n strip.squeeze(\" \")\n end", "def cleanup_noregexp str\n str2 = ''\n str.chars.each do |chr|\n case chr.downcase\n when ('a'..'z')\n str2 << chr\n else\n str2 << ' '\n end\n end\n str2.squeeze(' ')\nend", "def cleanup_string(string, strip: true)\n return \"\" if string.nil?\n raise ArgumentError, \"Expected a string or an object that implements #to_str\" unless string.respond_to?(:to_str)\n\n s = strip_tags(string.to_str)\n s = s.dup if s.frozen?\n s.gsub!(/\\s+/, \" \")\n s.strip! if strip\n\n s\n end", "def cleanup(str)\n\tnew_str = str.gsub(/[^a-z]/i, ' ').split.join(' ')\n\t\" #{new_str} \"\nend", "def normalize_whitespace(input); end", "def strip(string)\n while string[-1] == \" \" || string[-1] == \"\\n\" || string[-1] == \"\\t\"\n string[-1] = \"\"\n end\n while string[0] == \" \" || string[0] == \"\\n\" || string[0] == \"\\t\"\n string[0] = \"\"\n end\n return string\nend", "def cleanup(str)\n str.chars.map { |char| ('a'..'z').include?(char.downcase) ? char : ' ' }.join.squeeze(' ')\nend", "def no_space(x)\n # code go here\n x.gsub(' ', '')\nend", "def clean_content(content)\n content.gsub(/[^a-zA-Z ]/, '').squeeze(' ').downcase.strip\n end", "def cleanup(string)\n i = 0\n final = ''\n while i < string.length\n final << (('a'..'z').cover?(string[i]) ? string[i] : ' ')\n i += 1\n end\n final.squeeze(' ')\nend", "def strip_tags_nbsp(text)\n if text.present?\n strip_tags(text.gsub('&nbsp;', ' '))\n end\n end", "def clean_string(string)\n string.gsub(/\\W+/, '')\nend", "def cleanup(str)\n new_string = []\n characters = ['-', \"'\", '+', '*', '&', '?']\n str.chars.each do |c|\n characters.include?(c) ? new_string << ' ' : new_string << c\n end\n new_string.join.squeeze\nend" ]
[ "0.81326866", "0.8002261", "0.76887006", "0.76567113", "0.7575633", "0.7572814", "0.74958056", "0.74804974", "0.74444455", "0.73995566", "0.7356686", "0.7330323", "0.73262304", "0.7323826", "0.73082674", "0.7296096", "0.72854424", "0.7279162", "0.72619355", "0.7251063", "0.72304094", "0.7219454", "0.7219262", "0.72149354", "0.72114867", "0.7198488", "0.7194641", "0.7189453", "0.7181138", "0.71768683", "0.716893", "0.7152052", "0.71164167", "0.71080965", "0.7103553", "0.70956445", "0.707937", "0.70746917", "0.7015507", "0.69986993", "0.6987621", "0.69445306", "0.6935539", "0.6934949", "0.6916539", "0.69130754", "0.69034576", "0.69034576", "0.690231", "0.689543", "0.6881989", "0.6881989", "0.68783295", "0.68672055", "0.6845742", "0.6842672", "0.68386674", "0.68306464", "0.6823927", "0.6813433", "0.6812601", "0.68099254", "0.68012196", "0.6798688", "0.67928904", "0.6787142", "0.6771368", "0.67621726", "0.6750857", "0.67468745", "0.6725293", "0.6690657", "0.6676611", "0.66588926", "0.6656685", "0.6650235", "0.6632458", "0.66234773", "0.6623475", "0.66118693", "0.66106784", "0.66091776", "0.6608907", "0.660849", "0.6582275", "0.655905", "0.65403926", "0.6534663", "0.6506469", "0.64882946", "0.6487038", "0.6482735", "0.6459377", "0.6458927", "0.64463633", "0.6444101", "0.6439815", "0.64099985", "0.63900214", "0.63877636", "0.6382535" ]
0.0
-1
Remove HTML from text string Removes HTML from text, leaving behind only text. Formatted text will become plain text. Important for protecting against HTML and CrossSiteScripting attacks.
def edit_text_remove_html(request, opts = {}) data, _status_code, _headers = edit_text_remove_html_with_http_info(request, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_html(string=\"\")\n begin\n string = strip_tags(string)\n string = string.gsub(/<\\/?[^>]*>/, \"\")\n string = string.gsub(/\\&+\\w*\\;/, \" \") # replace &nbsp; with a space\n string.html_safe\n rescue\n raw(\"<!-- error stripping html from: #{string} -->\")\n end\n end", "def strip_html_tags(text)\n return text.gsub!(/(<[^>]*>)|\\n|\\t/s) {\" \"}\n end", "def strip_html(string=\"\")\n begin\n string = string.gsub(/<\\/?[^>]*>/, \"\")\n string = string.gsub(/\\&+\\w*\\;/, \" \") # replace &nbsp; with a space\n string.html_safe\n rescue\n raw(\"<!-- error stripping html from: #{string} -->\")\n end\n end", "def strip_html(string=\"\")\n begin\n string = string.gsub(/<\\/?[^>]*>/, \"\")\n string = string.gsub(/\\&+\\w*\\;/, \" \") # replace &nbsp; with a space\n string.html_safe\n rescue\n raw(\"<!-- error stripping html from: #{string} -->\")\n end\n end", "def strip_html(text)\n unless text.nil?\n strip_tags(text)\n end\n end", "def strip_html(str)\n str.gsub HTML_TAG, \"\" if str\n end", "def sanitize_text(text)\n doc = Nokogiri::HTML.fragment(text)\n UNSUPPORTED_HTML_TAGS.each do |tag|\n doc.search(tag).each(&:remove)\n end\n doc.inner_html\n end", "def strip_html(string)\n # FIXME will need something more sophisticated than this, because it sucks\n string.gsub(/<[^>]*(>+|\\s*\\z)/m, '').strip\n end", "def clean_html_string(string)\n string.\n inner_text.\n gsub(/\\s+/, \" \").\n strip\n end", "def strip_html(text)\n Nokogiri::HTML.fragment(text).content\n end", "def strip_html\n gsub(HTML_TAG_PATTERN, \"\")\n end", "def strip_tags(html)\n return html if html.blank?\n if html.index(\"<\")\n text = \"\"\n tokenizer = ::HTML::Tokenizer.new(html)\n while token = tokenizer.next\n node = ::HTML::Node.parse(nil, 0, 0, token, false)\n # result is only the content of any Text nodes\n text << node.to_s if node.class == ::HTML::Text\n end\n # strip any comments, and if they have a newline at the end (ie. line with\n # only a comment) strip that too\n text.gsub(/<!--(.*?)-->[\\n]?/m, \"\")\n else\n html # already plain text\n end\n end", "def strip_html( html )\n html.gsub(/<\\/?[^>]*>/, '')\n end", "def strip_html(text)\n @name =\n # Remove HTML from the text\n Sanitize.clean(text).\n # Replace newlines with a space\n gsub(/\\n|\\r/, ' ').\n # Replaces runs of spaces by a single space\n squeeze(' ').\n # Remove leading and trailing whitespace\n strip\nend", "def plain_text(text)\n strip_tags(markdown.render(text.to_s)).strip\n end", "def clean_up_text\n text.gsub!(/<br/, \"\\n<br\")\n text.gsub!(/<p/, \"\\n<p\")\n text.gsub!(/<\\/?span(.*?)?>/, '')\n text.gsub!(/<\\/?div(.*?)?>/, '')\n end", "def strip_html(str,allow=['dm','dl'])\n str = str.strip || ''\n allow_arr = allow.join('|') << '|\\/'\n str.gsub(/<(\\/|\\s)*[^(#{allow_arr})][^>]*>/,'').strip\n end", "def text_only(html)\n Nokogiri::HTML.parse(html).text.gsub(/\\A\\p{Space}+|\\p{Space}+\\z/, '')\n .strip\n end", "def strip_tags(html); end", "def strip_tags(html); end", "def strip_tags(html); end", "def strip_tags(html)\n # First we need to get rid of any embedded code.\n html = strip_embedded(html)\n\n # Remove comments\n html = html.gsub(/<!--.*?--\\s*>/m, \"\\xEF\\xBF\\xBC\")\n\n # SGML Declarations\n html = html.gsub(/<!.*?>/m, \"\\xEF\\xBF\\xBC\")\n\n # Remove script and css blocks\n html = html.gsub(/<script.*?>.*?<\\/script>/m, \"\\xEF\\xBF\\xBC\")\n html = html.gsub(/<style.*?>.*?<\\/style>/m, \"\\xEF\\xBF\\xBC\")\n\n # Strip html tags\n html = html.gsub(/<\\/? # opening tag with optional slash\n (\n [^<>\"'] | # match anything unquoted\n \".*?\" | # match double quotes…\n '.*?' # and single ones\n )* # any combination of the three\n > # close tag\n /xm, \"\\xEF\\xBF\\xBC\") # placeholder\n\n # Handle placeholders\n html = html.gsub(/^[ \\t]*\\xEF\\xBF\\xBC[ \\t]*(\\n|\\r|\\r\\n)/xm, '') # Remove lines with only tags\n html = html.gsub(/\\xEF\\xBF\\xBC/xm, '') # Remove other placeholders\n return html\nend", "def html_remove\n gsub(/<\\/?[^>]+>/, '')\n end", "def get_text_contents(html_string)\n\t# Remove HTML and scripts\n\thtml_regex = /<head>.*?<\\/head>|<script>.*?<\\/script>|<noscript>.*?<\\/noscript>/m\n\ttext_string = html_string.gsub(html_regex,\"\")\n\n\t# Remove tags\n\ttag_regex = /<[^<>]*?>/m\n\ttext_string.gsub!(tag_regex,\"\")\n\n\t# Replace multiple spaces with one\n\ttext_string.gsub!(/\\s{2,}/m,\" \")\n\n\t# Remove STX\n\ttext_string.gsub!(/\\^B/,\"\")\n\n\treturn text_string\nend", "def mark_text(str)\n\t str = clean_html(str)\n\t \n\t return str\n end", "def parse_text(text)\n ## Strip html\n Sanitize::clean!(text, :remove_contents => ['script','style'])\n text.gsub!(/[\\n\\t]+/, ' ')\n text\n end", "def sanitize text\n [' ', '\\r\\n', \"\\r\\n\", \"\\n\", \"\\r\", \"\\t\", / ^/, / $+/, /^  /, /^ /].each { |text_to_remove|\n text.gsub!(text_to_remove,'')\n }\n return text\n end", "def clean_text(text)\n text = strip_html_quote_entities(text)\n text = Helper::Text.strip_html_tags(text)\n text = strip_copyright_text(text)\n text.strip!\n text = Helper::Text.clean_verse_start(text)\n text = Helper::Text.clean_verse_end(text)\n end", "def strip_html (s)\ns.gsub(/<[^>]*(>+|\\s*\\z)/m, '');\nend", "def normalize_text(content)\n replaced_content = content.gsub(/\\n|<br>|&nbsp;/) do |match|\n case match\n when \"\\n\", \"&nbsp;\"\n \"\"\n when \"<br>\"\n \"\\n\"\n end\n end.sub(/\\s*(---|‐‐‐|―――)\\s*\\z/, \"\")\n strip_html(replaced_content)\n end", "def clean text\n text.gsub(/(\\n|\\t|\\r)/, ' ').gsub(/>\\s*</, '><').squeeze(' ')\n end", "def html_to_text(text)\n return nil if text.nil? || text.empty?\n text.gsub! /<br( \\/)?>/i, \"\\n\"\n\n string = Nokogiri::HTML.parse(text.to_s).css('body').text\n string.gsub! /[[:blank:]]/, ' '\n string = string.split(\"\\n\").collect{ |line| line.strip }.join(\"\\n\")\n string.gsub! /(\\n{1,})\\n/ do |match|; $1; end # convert x\\n to (x-1)\\n\n string.strip!\n string\n end", "def clean_html(str)\n\t str = str.gsub(/<script(.*)>(.*)<\\/script>/i, \"\")\n\t str = str.gsub(/<frame(.*)>(.*)<\\/frame>/i, \"\")\n\t str = str.gsub(/<iframe(.*)>(.*)<\\/iframe>/i, \"\")\n\t\n\t return str\n end", "def strip_bbcode(string); end", "def strip_html_tags!\n @raw.gsub!(/<[^>]+?>/, ' ')\n end", "def strip_and_convert(str)\n CGI.unescapeHTML(strip_tags(str))\n end", "def cleanText(txt)\r\n clean = txt.gsub(\"<\", \"&lt;\")\r\n clean.gsub!(\">\", \"&gt;\")\r\n\r\n puts \"cleaned text: #{txt} -> #{clean}\" if $DEBUG\r\n clean\r\n\r\n end", "def sanitize(text)\n text.gsub('<', '&lt;').gsub('>', '&gt;')\n end", "def strip_tags(html)\n html.gsub(/<\\/?[^>]*>/, \"\") if html\n end", "def strip_tags(html)\n Sanitize.clean(html.strip).strip\n end", "def strip_tags(html)\n Sanitize.clean(html.strip).strip\n end", "def sanitize(text)\n return nil if text.nil? || text.empty?\n string = text.to_s # ensure we have a string\n\n doc = Nokogiri::HTML.parse(text)\n\n doc.xpath('//@style').remove\n doc.xpath('//@class').remove\n doc.xpath('//@id').remove\n doc.xpath('//@font-size').remove\n doc.xpath('//@color').remove\n doc.xpath('//@size').remove\n doc.xpath('//@face').remove\n doc.xpath('//@bgcolor').remove\n doc.xpath('//comment()').remove\n\n # remove \"bad\" elements\n doc.css('script, link, img, style').each { |node| node.remove }\n\n # convert all <div>s to <p>s\n doc.css('div').each do |div|\n node = doc.create_element 'p'\n node.inner_html = div.inner_html\n div.replace(node)\n end\n\n # remove <font> and <span> tags, but preserve their content\n doc.css('font, span').each do |node|\n node.swap(node.children)\n end\n\n # removing tags leaves dangling text nodes that should really be merged, so let's\n # re-build the document\n doc = Nokogiri::HTML.parse(doc.to_s)\n\n # wrap orphaned text nodes in <p> tags\n doc.css('html body').children.each do |orphan|\n if orphan.class == Nokogiri::XML::Text && !orphan.text.strip.gsub(Envelope::Message::ALL_SPACES, '').empty?\n node = doc.create_element 'p'\n node.inner_html = orphan.text\n orphan.replace(node)\n end\n end\n\n # remove all <p><br><p>\n doc.css('p br').each do |node|\n node.remove\n end\n\n # convert all new lines to br and trim content\n doc.css('p').each do |node|\n node.inner_html = node.inner_html.gsub(\"\\n\", '<br>').strip\n end\n\n # remove empty tags\n doc.css('html body > *').each do |node|\n unless %w(br p).include?(node.name)\n node.remove if node.inner_html.gsub(Envelope::Message::ALL_SPACES, '').empty?\n end\n end\n\n doc.css('html body > *').to_s.gsub(/[\\n\\t]+?/, '')\n end", "def simple_format_no_tags(text, _html_options = {}, options = {})\n text = '' if text.nil?\n text = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n text = sanitize(text) unless options[:sanitize] == false\n text = text.to_str\n text.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n # text.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n text.html_safe\n end", "def safe_text text\n return \"\" if text.nil?\n \n markdown_content_type = \"# Content-Type: text/markdown\"\n starts_with_markdown = text.strip.start_with? markdown_content_type\n if (not /<(a |img |ol|ul|li|h[1-6]|p|div|span)[^<]*>/.match(text)) && !starts_with_markdown\n return \"<blockquote>\" + CGI::escape_html(text).gsub(\"\\n\",\"<br />\\n\") + \"</blockquote>\"\n end\n\n if BMF::Settings.instance.display_sanitized_html != 'yes'\n return \"<blockquote>\" + CGI::escape_html(text).gsub(\"\\n\", \"<br />\\n\") + \"</blockqoute>\"\n end\n\n if text.strip.start_with? markdown_content_type\n text = RDiscount.new(text.sub(markdown_content_type, \"\")).to_html\n end\n\n safe_html(text)\n \n end", "def html_text( text_node )\n self.remove_leading_and_trailing_whitespace( text_node )\n end", "def htmlClean(html)\n html\nend", "def conv_html(txt)\n txt.\n gsub(/&gt;/, '>').\n gsub(/&lt;/, '<').\n gsub(/&quot;/, '\"').\n gsub(/&amp;/, '&')\n \n end", "def remove_paragraph_tags mytext\n mytext.sub!(/^<p>\\s*<\\/p>/,\"\")\n mytext.sub!(/(<br>)*<p>\\s*<\\/p>$/,\"\")\n mytext.sub!(/^<p>/,'')\n mytext.sub!(/<\\/p>?/,'')\n return mytext\n end", "def wp_strip_all_tags(string, remove_breaks = false)\n string = string.gsub(/<(script|style)[^>]*?>.*?<\\/\\\\1>/, '')\n string = strip_tags(string)\n\n if remove_breaks\n string = string.gsub(/[\\r\\n\\t ]+/, ' ')\n end\n string.strip\n end", "def ensure_no_tags(str)\n return str unless str.html_safe?\n \n str = str.to_str # get it out of HTMLSafeBuffer, which messes things up\n str = strip_tags(str) \n\n str = HTMLEntities.new.decode(str)\n\n return str\n end", "def clean_text(text)\n text.gsub!(/\\r\\n/, '')\n text.gsub!(/\\r/, '')\n text\n end", "def text\n html.gsub(REGEX_TAGS, \"\")\n end", "def html_text(str)\n str.gsub(/[&<>]/) {|ch| HTML_TEXT_ESCAPE_HASH[ch] }\n end", "def strip_bbcode(text)\n text.gsub!(\"[code]\", \"\")\n text.gsub!(\"[/code]\", \"\")\n text.gsub!(\"8\", \"&#56;\") \n text.gsub!(\"[\", \"&#91;\")\n text.gsub!(\"]\", \"&#93;\")\n text.gsub!(\".\", \"&#46;\")\n text.gsub!(\":\", \"&#58;\")\n text.gsub!(\";)\", \"&#59;&#41;\")\n \n return text \n end", "def simple_format_no_tags(text, html_options = {}, options = {})\n\t\ttext = '' if text.nil?\n\t\ttext = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n\t\ttext = sanitize(text) unless options[:sanitize] == false\n\t\ttext = text.to_str\n\t\ttext.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n#\t\ttext.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n\t\ttext.html_safe\n\tend", "def simple_format_no_tags(text, html_options = {}, options = {})\n\t\ttext = '' if text.nil?\n\t\ttext = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n\t\ttext = sanitize(text) unless options[:sanitize] == false\n\t\ttext = text.to_str\n\t\ttext.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n#\t\ttext.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n\t\ttext.html_safe\n\tend", "def simple_format_no_tags(text, html_options = {}, options = {})\n\t\ttext = '' if text.nil?\n\t\ttext = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n\t\ttext = sanitize(text) unless options[:sanitize] == false\n\t\ttext = text.to_str\n\t\ttext.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n#\t\ttext.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n\t\ttext.html_safe\n\tend", "def simple_format_no_tags(text, html_options = {}, options = {})\n\t\ttext = '' if text.nil?\n\t\ttext = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n\t\ttext = sanitize(text) unless options[:sanitize] == false\n\t\ttext = text.to_str\n\t\ttext.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n#\t\ttext.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n\t\ttext.html_safe\n\tend", "def strip_tags(str)\n str.gsub(/\\</, \"&lt;\").gsub(/\\>/, \"&gt;\").gsub(/\\&/, \"&amp;\")\n end", "def clean_html(html)\n Sanitize.clean(html) rescue html\n end", "def plain_text\n text ? text.gsub(/<[^>]+>/,' ').squeeze(' ').strip : nil\n end", "def html2text(html)\n html ||= \"\" # ensure string is non-nil\n text = html.\n gsub(/(&nbsp;|\\n|\\s)+/im, ' ').squeeze(' ').strip.\n gsub(/<([^\\s]+)[^>]*(src|href)=\\s*(.?)([^>\\s]*)\\3[^>]*>\\4<\\/\\1>/i, '\\4')\n\n linkregex = /<[^>]*(src|href)=\\s*(.?)([^>\\s]*)\\2[^>]*>\\s*/i\n while linkregex.match(text)\n text.sub!(linkregex, \"\")\n end\n \n text = CGI.unescapeHTML(\n text.\n gsub(/<(script|style)[^>]*>.*<\\/\\1>/im, '').\n gsub(/<!--.*-->/m, '').\n gsub(/<hr(| [^>]*)>/i, \"___\\n\").\n gsub(/<li(| [^>]*)>/i, \"\\n* \").\n gsub(/<blockquote(| [^>]*)>/i, '> ').\n gsub(/<(br)(| [^>]*)>/i, \"\\n\").\n gsub(/<(\\/h[\\d]+|p)(| [^>]*)>/i, \"\\n\\n\").\n gsub(/<[^>]*>/, '')\n ).lstrip.gsub(/\\n[ ]+/, \"\\n\") + \"\\n\"\n\n converted = []\n text.split(//).collect { |c| converted << ( c[0] > 127 ? \"&##{c[0]};\" : c ) }\n converted.join('')\n end", "def strip_tags string\n string.gsub(/<\\/?[^>]*>/, \"\")\nend", "def nice_html_to_text(html_text)\n doc = Hpricot(html_text)\n doc.search(\"//text()\").text\n end", "def strip_html(param_string)\n param_string.gsub!('<', '&lt;')\n param_string.gsub!('>', '&gt;')\n param_string.gsub(/\\\"/,\"&quot;\")\n return param_string\n end", "def clean_string(string)\n string = string.gsub(/\\r|\\n/,'').sub(/^ */,'').sub(/\\s*$/,'').gsub(/ +/,' ')\n coder = HTMLEntities.new()\n string = coder.decode(string) # Remove html entities\n return string\n end", "def strip_tags(html)\n strip(Sanitize.clean(html, :elements => [], :attributes => []))\n end", "def rm_html_entities(str)\n str.gsub(/&\\w+;/, \"\")\n end", "def strip_html(allow)\n str = self.strip || ''\n allow_arr = allow.join('|')\n str = str.gsub(/<\\s*/,'<')\n str = str.gsub(/<\\/\\s*/,'</')\n # First part of | prevents matches of </allowed. Second case prevents matches of <allowed\n # and keeps the / chacter from matching the ?! allowed.\n str.gsub(/<(\\/(?!(#{allow_arr}))|(?!(\\/|#{allow_arr})))[^>]*?>/mi,'')\n end", "def sanitize(text)\n sanitized_text = text.dup\n\n # Strip URLs\n sanitized_text.gsub!(URL_REGEX, '')\n\n # Strip @mention style tokens\n sanitized_text.gsub!(MENTION_REGEX, '')\n\n sanitized_text\n end", "def sanitize(html)\n HTML5::HTMLParser.\n parse_fragment(html, :tokenizer => HTML5::HTMLSanitizer, :encoding => 'utf-8').\n to_s\n end", "def sanitize(html)\n HTML5::HTMLParser.\n parse_fragment(html, :tokenizer => HTML5::HTMLSanitizer, :encoding => 'utf-8').\n to_s\n end", "def strip_html_quote_entities(text)\n text.gsub(/&.dquo;/, '')\n end", "def normalise_html(html)\n Nokogiri::HTML5.fragment(html).to_s.gsub(\"\\n\", \"\")\n end", "def as_text\n return self if self.blank?\n mytext = self.gsub(/<p>(.*?)<\\/p>/mi,'\\1'+\"\\n\\n\")\n mytext = mytext.gsub(/<br(.*?)>/mi,\"\\n\") \n mytext = mytext.gsub(/<p(.*?)>/mi,\"\\n\\n\") \n mytext = mytext.gsub(/<\\/p>/mi,\"\") \n mytext = mytext.gsub(/<div(.*?)>/mi, \"\")\n mytext = mytext.gsub(/<\\/div>/mi,\"\") \n # Go ahead and strip all the other html tags as well\n mytext = mytext.gsub(/<\\/?[^>]*>/, \"\")\n CGI.unescapeHTML(mytext).strip\n end", "def clean_html(options={:url => nil})\n use_http_get = true\n call_api('clean-html', options, use_http_get)\n end", "def filter_text(text)\n text = text.to_s\n text.gsub('&', '&amp;')\n text.gsub('\\'', '&#039;')\n text.gsub('\"', '&quot;')\n text.gsub('<', '&lt;')\n text.gsub('>', '&gt;')\n text\n end", "def rm_single_tags(str)\n str.gsub(/<[^<>]*\\/>/, \"\")\n end", "def unescapeHTML(string)\n\tstr = string.dup\n\tstr.gsub!(/&(.*?);/n) {\n\t\tmatch = $1.dup\n\t\tcase match\n\t\t\twhen /\\Aamp\\z/ni then '&'\n\t\t\twhen /\\Aquot\\z/ni then '\"'\n\t\t\twhen /\\Agt\\z/ni then '>'\n\t\t\twhen /\\Alt\\z/ni then '<'\n\t\t\twhen /\\A#(\\d+)\\z/n then Integer($1).chr\n\t\t\twhen /\\A#x([09af]+)\\\n\t\t\tz/ni then $1.hex.chr\n\t\tend\n\t\t}\n\tstr\nend", "def sanitize_html(content)\n require 'cgi'\n CGI.escapeHTML(content)\n end", "def removeTag(text,tag)\n return 0 unless text\n text=text.to_s\n text=text.gsub(\"<\"+tag+\">\", \"\")\n text=text.gsub(\"</\"+tag+\">\", \"\")\n \n return text.to_s\nend", "def unescape_html(str)\n str.gsub(/&(.*?);/n) do\n match = $1.dup\n case match\n when /\\Aamp\\z/ni then '&'\n when /\\Aquot\\z/ni then '\"'\n when /\\Agt\\z/ni then '>'\n when /\\Alt\\z/ni then '<'\n when /\\A#0*(\\d+)\\z/n then\n if Integer($1) < 256\n Integer($1).chr\n else\n if Integer($1) < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)\n [Integer($1)].pack(\"U\")\n else\n \"&##{$1};\"\n end\n end\n when /\\A#x([0-9a-f]+)\\z/ni then\n if $1.hex < 256\n $1.hex.chr\n else\n if $1.hex < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)\n [$1.hex].pack(\"U\")\n else\n \"&#x#{$1};\"\n end\n end\n else\n \"&#{match};\"\n end\n end\n end", "def strip_tags(string)\n if defined?(Loofah)\n # Instead of strip_tags we will use Loofah to strip tags from now on\n Loofah.fragment(string).text(encode_special_chars: false)\n else\n helpers.strip_tags(string)\n end\n end", "def clean_body(text)\n text = strip_bad_chars(text)\n text.gsub!(/(\\r)?\\n/, \"\");\n text.gsub!(/\\s+/, ' ');\n\n # clean start and end whitespace\n text = text.strip;\n return text\nend", "def clean_text(string)\n if string\n string.chomp!\n string.gsub!(/\\t+|\\(.+?\\)\\s*/,'')\n string.gsub!(/‘|’|„|“/, \"'\")\n string.squeeze!(\"?|!\")\n string.gsub!(/!\\?|\\?!/, \"?\")\n string.gsub!(/…|!|\\.\\.\\./, \".\") # Used the three marks to keep the count clean\n string.gsub!(/(Na)(ja)/i, '\\1 \\2')\n string.squeeze(\" \").strip\n else\n \"\"\n end\n end", "def html2text(html)\n\n result = ''\n begin\n web_doc = Hpricot(html)\n web_doc.search(\"//comment()\").remove\n web_doc.search(\"script\").remove\n web_doc.search(\"style\").remove\n web_doc.search(\"noscript\").remove\n web_doc.search(\"object\").remove\n web_doc.search(\"embed\").remove\n web_doc.search(\"head\").remove\n\n web_doc.traverse_text do |e| \n\n begin\n if e.content\n result += e.content+\"\\n\"\n end\n rescue\n # ignore errors\n end\n end\n rescue Exception => e\n # ignore errors\n warn \"html2text() - Exception '#{e.message}' trying to parse '#{html}'\"\n end\n\n if result == ''\n # Use a simple regular-expression approach to remove all tags\n result = html.gsub(/<[^>]*>/, '')\n end\n\n coder = HTMLEntities.new\n result = coder.decode(result)\n\n result.gsub!(/\\n[\\r\\n \\t]*/, \"\\n\")\n\n result\nend", "def sanitize_text(text)\n text = unescape_text(text)\n text = extract_text(text) if aruba.config.remove_ansi_escape_sequences\n\n text.chomp\n end", "def create_cleared_text(s)\n s.gsub(/[RMQ]T @[a-zA-Z0-9_]+:.*/, '')\n .gsub(/\\. ?(@[a-zA-Z0-9_]+ )+/, '')\n .gsub(/@[a-zA-Z0-9_]+/, '')\n .gsub(%r[(https?|ftp)(:\\/\\/[-_.!~*\\'()a-zA-Z0-9;\\/?:\\@&=+\\$,%#]+)], '')\n .gsub(/#.+([  、。]|$)/, '')\n .strip\n end", "def unescapeHTML(string)\n str = string.dup\n str.gsub!(/&(.*?);/n) {\n match = $1.dup\n case match\n when /\\Aamp\\z/ni then '&'\n when /\\Aquot\\z/ni then '\"'\n when /\\Agt\\z/ni then '>'\n when /\\Alt\\z/ni then '<'\n when /\\A#(\\d+)\\z/n then Integer($1).chr\n when /\\A#x([0-9a-f]+)\\z/ni then $1.hex.chr\n end\n }\n str\nend", "def stripped(string, options = {})\n string ? Vidibus::Textile.new(string).to_text(options) : \"\"\n end", "def text2html(text)\n return nl2br(escape_xml(text.to_s).gsub(/ /, ' &nbsp;'))\n end", "def strip_style_tag (s)\ns.gsub(/<style.*<\\/style>/i, '');\nend", "def clear_text(text)\n text = text.tr(\"\\n\", \" \")\n text.gsub(/[^0-9A-Za-z. ]/, '')\n end", "def sanitize(html, options = {})\n msclean(html, options)\n end", "def strip_doctype_html(input)\n input.to_s.gsub(Regexp.new(DOCTYPE_HTML), NOTHING)\n end", "def strip_html_from_description\n self.description = ActionView::Base.full_sanitizer.sanitize(description)\n end", "def sanitize!(html, options = {})\n msclean!(html, options)\n end", "def sanitize(text)\n text.squeeze\n text.capitalize!\n text.gsub!('&', '&amp;')\n text.gsub!('<', '&lt;')\n text.gsub!('>', '&gt;')\n return text\nend", "def scrub_text(text)\n TEXT_GSUBS.inject(text) { |memo, sub| memo = memo.gsub(*sub) }\n end", "def stripsub(text)\n return (text.strip).gsub(\"'\",\"''\").gsub(\"’\", \"''\")\n end" ]
[ "0.7924629", "0.7910312", "0.7887182", "0.7887182", "0.78210896", "0.77246463", "0.7661887", "0.7532948", "0.74416566", "0.7440146", "0.7242279", "0.72368854", "0.7067145", "0.70537746", "0.705334", "0.70479095", "0.7041641", "0.6996081", "0.6968631", "0.6968631", "0.6968631", "0.6956946", "0.69283855", "0.6918119", "0.68912894", "0.6886582", "0.6854076", "0.6847214", "0.6801623", "0.6705647", "0.669329", "0.66786224", "0.66580194", "0.66565996", "0.6642032", "0.662773", "0.6624272", "0.6623007", "0.66151595", "0.6614432", "0.6614432", "0.6606404", "0.6581551", "0.6574822", "0.6571817", "0.6559976", "0.6559482", "0.65396863", "0.65161484", "0.6499224", "0.6498088", "0.64678156", "0.6464707", "0.64638567", "0.6448368", "0.6448368", "0.6448368", "0.6448368", "0.64454067", "0.64360297", "0.6417983", "0.6415647", "0.64033103", "0.6396251", "0.63896537", "0.63723546", "0.6364106", "0.636197", "0.6345261", "0.6310076", "0.63039845", "0.63039845", "0.62999785", "0.62953055", "0.62914157", "0.6254927", "0.62411195", "0.62158245", "0.6189512", "0.615358", "0.6121516", "0.61208445", "0.61023086", "0.6102216", "0.608795", "0.6060742", "0.6053419", "0.60468036", "0.6044646", "0.6039079", "0.6029855", "0.602697", "0.60230297", "0.6020928", "0.6014801", "0.60104704", "0.5999964", "0.59972507", "0.5995744", "0.59862393" ]
0.69984794
17
Remove HTML from text string Removes HTML from text, leaving behind only text. Formatted text will become plain text. Important for protecting against HTML and CrossSiteScripting attacks.
def edit_text_remove_html_with_http_info(request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_remove_html ...' end # verify the required parameter 'request' is set if @api_client.config.client_side_validation && request.nil? fail ArgumentError, "Missing the required parameter 'request' when calling EditTextApi.edit_text_remove_html" end # resource path local_var_path = '/convert/edit/text/remove/html' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(request) auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'RemoveHtmlFromTextResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_remove_html\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_html(string=\"\")\n begin\n string = strip_tags(string)\n string = string.gsub(/<\\/?[^>]*>/, \"\")\n string = string.gsub(/\\&+\\w*\\;/, \" \") # replace &nbsp; with a space\n string.html_safe\n rescue\n raw(\"<!-- error stripping html from: #{string} -->\")\n end\n end", "def strip_html_tags(text)\n return text.gsub!(/(<[^>]*>)|\\n|\\t/s) {\" \"}\n end", "def strip_html(string=\"\")\n begin\n string = string.gsub(/<\\/?[^>]*>/, \"\")\n string = string.gsub(/\\&+\\w*\\;/, \" \") # replace &nbsp; with a space\n string.html_safe\n rescue\n raw(\"<!-- error stripping html from: #{string} -->\")\n end\n end", "def strip_html(string=\"\")\n begin\n string = string.gsub(/<\\/?[^>]*>/, \"\")\n string = string.gsub(/\\&+\\w*\\;/, \" \") # replace &nbsp; with a space\n string.html_safe\n rescue\n raw(\"<!-- error stripping html from: #{string} -->\")\n end\n end", "def strip_html(text)\n unless text.nil?\n strip_tags(text)\n end\n end", "def strip_html(str)\n str.gsub HTML_TAG, \"\" if str\n end", "def sanitize_text(text)\n doc = Nokogiri::HTML.fragment(text)\n UNSUPPORTED_HTML_TAGS.each do |tag|\n doc.search(tag).each(&:remove)\n end\n doc.inner_html\n end", "def strip_html(string)\n # FIXME will need something more sophisticated than this, because it sucks\n string.gsub(/<[^>]*(>+|\\s*\\z)/m, '').strip\n end", "def clean_html_string(string)\n string.\n inner_text.\n gsub(/\\s+/, \" \").\n strip\n end", "def strip_html(text)\n Nokogiri::HTML.fragment(text).content\n end", "def strip_html\n gsub(HTML_TAG_PATTERN, \"\")\n end", "def strip_tags(html)\n return html if html.blank?\n if html.index(\"<\")\n text = \"\"\n tokenizer = ::HTML::Tokenizer.new(html)\n while token = tokenizer.next\n node = ::HTML::Node.parse(nil, 0, 0, token, false)\n # result is only the content of any Text nodes\n text << node.to_s if node.class == ::HTML::Text\n end\n # strip any comments, and if they have a newline at the end (ie. line with\n # only a comment) strip that too\n text.gsub(/<!--(.*?)-->[\\n]?/m, \"\")\n else\n html # already plain text\n end\n end", "def strip_html( html )\n html.gsub(/<\\/?[^>]*>/, '')\n end", "def strip_html(text)\n @name =\n # Remove HTML from the text\n Sanitize.clean(text).\n # Replace newlines with a space\n gsub(/\\n|\\r/, ' ').\n # Replaces runs of spaces by a single space\n squeeze(' ').\n # Remove leading and trailing whitespace\n strip\nend", "def plain_text(text)\n strip_tags(markdown.render(text.to_s)).strip\n end", "def clean_up_text\n text.gsub!(/<br/, \"\\n<br\")\n text.gsub!(/<p/, \"\\n<p\")\n text.gsub!(/<\\/?span(.*?)?>/, '')\n text.gsub!(/<\\/?div(.*?)?>/, '')\n end", "def strip_html(str,allow=['dm','dl'])\n str = str.strip || ''\n allow_arr = allow.join('|') << '|\\/'\n str.gsub(/<(\\/|\\s)*[^(#{allow_arr})][^>]*>/,'').strip\n end", "def edit_text_remove_html(request, opts = {})\n data, _status_code, _headers = edit_text_remove_html_with_http_info(request, opts)\n data\n end", "def text_only(html)\n Nokogiri::HTML.parse(html).text.gsub(/\\A\\p{Space}+|\\p{Space}+\\z/, '')\n .strip\n end", "def strip_tags(html); end", "def strip_tags(html); end", "def strip_tags(html); end", "def strip_tags(html)\n # First we need to get rid of any embedded code.\n html = strip_embedded(html)\n\n # Remove comments\n html = html.gsub(/<!--.*?--\\s*>/m, \"\\xEF\\xBF\\xBC\")\n\n # SGML Declarations\n html = html.gsub(/<!.*?>/m, \"\\xEF\\xBF\\xBC\")\n\n # Remove script and css blocks\n html = html.gsub(/<script.*?>.*?<\\/script>/m, \"\\xEF\\xBF\\xBC\")\n html = html.gsub(/<style.*?>.*?<\\/style>/m, \"\\xEF\\xBF\\xBC\")\n\n # Strip html tags\n html = html.gsub(/<\\/? # opening tag with optional slash\n (\n [^<>\"'] | # match anything unquoted\n \".*?\" | # match double quotes…\n '.*?' # and single ones\n )* # any combination of the three\n > # close tag\n /xm, \"\\xEF\\xBF\\xBC\") # placeholder\n\n # Handle placeholders\n html = html.gsub(/^[ \\t]*\\xEF\\xBF\\xBC[ \\t]*(\\n|\\r|\\r\\n)/xm, '') # Remove lines with only tags\n html = html.gsub(/\\xEF\\xBF\\xBC/xm, '') # Remove other placeholders\n return html\nend", "def html_remove\n gsub(/<\\/?[^>]+>/, '')\n end", "def get_text_contents(html_string)\n\t# Remove HTML and scripts\n\thtml_regex = /<head>.*?<\\/head>|<script>.*?<\\/script>|<noscript>.*?<\\/noscript>/m\n\ttext_string = html_string.gsub(html_regex,\"\")\n\n\t# Remove tags\n\ttag_regex = /<[^<>]*?>/m\n\ttext_string.gsub!(tag_regex,\"\")\n\n\t# Replace multiple spaces with one\n\ttext_string.gsub!(/\\s{2,}/m,\" \")\n\n\t# Remove STX\n\ttext_string.gsub!(/\\^B/,\"\")\n\n\treturn text_string\nend", "def mark_text(str)\n\t str = clean_html(str)\n\t \n\t return str\n end", "def parse_text(text)\n ## Strip html\n Sanitize::clean!(text, :remove_contents => ['script','style'])\n text.gsub!(/[\\n\\t]+/, ' ')\n text\n end", "def sanitize text\n [' ', '\\r\\n', \"\\r\\n\", \"\\n\", \"\\r\", \"\\t\", / ^/, / $+/, /^  /, /^ /].each { |text_to_remove|\n text.gsub!(text_to_remove,'')\n }\n return text\n end", "def clean_text(text)\n text = strip_html_quote_entities(text)\n text = Helper::Text.strip_html_tags(text)\n text = strip_copyright_text(text)\n text.strip!\n text = Helper::Text.clean_verse_start(text)\n text = Helper::Text.clean_verse_end(text)\n end", "def strip_html (s)\ns.gsub(/<[^>]*(>+|\\s*\\z)/m, '');\nend", "def normalize_text(content)\n replaced_content = content.gsub(/\\n|<br>|&nbsp;/) do |match|\n case match\n when \"\\n\", \"&nbsp;\"\n \"\"\n when \"<br>\"\n \"\\n\"\n end\n end.sub(/\\s*(---|‐‐‐|―――)\\s*\\z/, \"\")\n strip_html(replaced_content)\n end", "def clean text\n text.gsub(/(\\n|\\t|\\r)/, ' ').gsub(/>\\s*</, '><').squeeze(' ')\n end", "def html_to_text(text)\n return nil if text.nil? || text.empty?\n text.gsub! /<br( \\/)?>/i, \"\\n\"\n\n string = Nokogiri::HTML.parse(text.to_s).css('body').text\n string.gsub! /[[:blank:]]/, ' '\n string = string.split(\"\\n\").collect{ |line| line.strip }.join(\"\\n\")\n string.gsub! /(\\n{1,})\\n/ do |match|; $1; end # convert x\\n to (x-1)\\n\n string.strip!\n string\n end", "def clean_html(str)\n\t str = str.gsub(/<script(.*)>(.*)<\\/script>/i, \"\")\n\t str = str.gsub(/<frame(.*)>(.*)<\\/frame>/i, \"\")\n\t str = str.gsub(/<iframe(.*)>(.*)<\\/iframe>/i, \"\")\n\t\n\t return str\n end", "def strip_bbcode(string); end", "def strip_html_tags!\n @raw.gsub!(/<[^>]+?>/, ' ')\n end", "def strip_and_convert(str)\n CGI.unescapeHTML(strip_tags(str))\n end", "def cleanText(txt)\r\n clean = txt.gsub(\"<\", \"&lt;\")\r\n clean.gsub!(\">\", \"&gt;\")\r\n\r\n puts \"cleaned text: #{txt} -> #{clean}\" if $DEBUG\r\n clean\r\n\r\n end", "def sanitize(text)\n text.gsub('<', '&lt;').gsub('>', '&gt;')\n end", "def strip_tags(html)\n html.gsub(/<\\/?[^>]*>/, \"\") if html\n end", "def strip_tags(html)\n Sanitize.clean(html.strip).strip\n end", "def strip_tags(html)\n Sanitize.clean(html.strip).strip\n end", "def sanitize(text)\n return nil if text.nil? || text.empty?\n string = text.to_s # ensure we have a string\n\n doc = Nokogiri::HTML.parse(text)\n\n doc.xpath('//@style').remove\n doc.xpath('//@class').remove\n doc.xpath('//@id').remove\n doc.xpath('//@font-size').remove\n doc.xpath('//@color').remove\n doc.xpath('//@size').remove\n doc.xpath('//@face').remove\n doc.xpath('//@bgcolor').remove\n doc.xpath('//comment()').remove\n\n # remove \"bad\" elements\n doc.css('script, link, img, style').each { |node| node.remove }\n\n # convert all <div>s to <p>s\n doc.css('div').each do |div|\n node = doc.create_element 'p'\n node.inner_html = div.inner_html\n div.replace(node)\n end\n\n # remove <font> and <span> tags, but preserve their content\n doc.css('font, span').each do |node|\n node.swap(node.children)\n end\n\n # removing tags leaves dangling text nodes that should really be merged, so let's\n # re-build the document\n doc = Nokogiri::HTML.parse(doc.to_s)\n\n # wrap orphaned text nodes in <p> tags\n doc.css('html body').children.each do |orphan|\n if orphan.class == Nokogiri::XML::Text && !orphan.text.strip.gsub(Envelope::Message::ALL_SPACES, '').empty?\n node = doc.create_element 'p'\n node.inner_html = orphan.text\n orphan.replace(node)\n end\n end\n\n # remove all <p><br><p>\n doc.css('p br').each do |node|\n node.remove\n end\n\n # convert all new lines to br and trim content\n doc.css('p').each do |node|\n node.inner_html = node.inner_html.gsub(\"\\n\", '<br>').strip\n end\n\n # remove empty tags\n doc.css('html body > *').each do |node|\n unless %w(br p).include?(node.name)\n node.remove if node.inner_html.gsub(Envelope::Message::ALL_SPACES, '').empty?\n end\n end\n\n doc.css('html body > *').to_s.gsub(/[\\n\\t]+?/, '')\n end", "def simple_format_no_tags(text, _html_options = {}, options = {})\n text = '' if text.nil?\n text = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n text = sanitize(text) unless options[:sanitize] == false\n text = text.to_str\n text.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n # text.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n text.html_safe\n end", "def safe_text text\n return \"\" if text.nil?\n \n markdown_content_type = \"# Content-Type: text/markdown\"\n starts_with_markdown = text.strip.start_with? markdown_content_type\n if (not /<(a |img |ol|ul|li|h[1-6]|p|div|span)[^<]*>/.match(text)) && !starts_with_markdown\n return \"<blockquote>\" + CGI::escape_html(text).gsub(\"\\n\",\"<br />\\n\") + \"</blockquote>\"\n end\n\n if BMF::Settings.instance.display_sanitized_html != 'yes'\n return \"<blockquote>\" + CGI::escape_html(text).gsub(\"\\n\", \"<br />\\n\") + \"</blockqoute>\"\n end\n\n if text.strip.start_with? markdown_content_type\n text = RDiscount.new(text.sub(markdown_content_type, \"\")).to_html\n end\n\n safe_html(text)\n \n end", "def html_text( text_node )\n self.remove_leading_and_trailing_whitespace( text_node )\n end", "def htmlClean(html)\n html\nend", "def conv_html(txt)\n txt.\n gsub(/&gt;/, '>').\n gsub(/&lt;/, '<').\n gsub(/&quot;/, '\"').\n gsub(/&amp;/, '&')\n \n end", "def remove_paragraph_tags mytext\n mytext.sub!(/^<p>\\s*<\\/p>/,\"\")\n mytext.sub!(/(<br>)*<p>\\s*<\\/p>$/,\"\")\n mytext.sub!(/^<p>/,'')\n mytext.sub!(/<\\/p>?/,'')\n return mytext\n end", "def wp_strip_all_tags(string, remove_breaks = false)\n string = string.gsub(/<(script|style)[^>]*?>.*?<\\/\\\\1>/, '')\n string = strip_tags(string)\n\n if remove_breaks\n string = string.gsub(/[\\r\\n\\t ]+/, ' ')\n end\n string.strip\n end", "def ensure_no_tags(str)\n return str unless str.html_safe?\n \n str = str.to_str # get it out of HTMLSafeBuffer, which messes things up\n str = strip_tags(str) \n\n str = HTMLEntities.new.decode(str)\n\n return str\n end", "def clean_text(text)\n text.gsub!(/\\r\\n/, '')\n text.gsub!(/\\r/, '')\n text\n end", "def text\n html.gsub(REGEX_TAGS, \"\")\n end", "def html_text(str)\n str.gsub(/[&<>]/) {|ch| HTML_TEXT_ESCAPE_HASH[ch] }\n end", "def strip_bbcode(text)\n text.gsub!(\"[code]\", \"\")\n text.gsub!(\"[/code]\", \"\")\n text.gsub!(\"8\", \"&#56;\") \n text.gsub!(\"[\", \"&#91;\")\n text.gsub!(\"]\", \"&#93;\")\n text.gsub!(\".\", \"&#46;\")\n text.gsub!(\":\", \"&#58;\")\n text.gsub!(\";)\", \"&#59;&#41;\")\n \n return text \n end", "def simple_format_no_tags(text, html_options = {}, options = {})\n\t\ttext = '' if text.nil?\n\t\ttext = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n\t\ttext = sanitize(text) unless options[:sanitize] == false\n\t\ttext = text.to_str\n\t\ttext.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n#\t\ttext.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n\t\ttext.html_safe\n\tend", "def simple_format_no_tags(text, html_options = {}, options = {})\n\t\ttext = '' if text.nil?\n\t\ttext = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n\t\ttext = sanitize(text) unless options[:sanitize] == false\n\t\ttext = text.to_str\n\t\ttext.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n#\t\ttext.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n\t\ttext.html_safe\n\tend", "def simple_format_no_tags(text, html_options = {}, options = {})\n\t\ttext = '' if text.nil?\n\t\ttext = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n\t\ttext = sanitize(text) unless options[:sanitize] == false\n\t\ttext = text.to_str\n\t\ttext.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n#\t\ttext.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n\t\ttext.html_safe\n\tend", "def simple_format_no_tags(text, html_options = {}, options = {})\n\t\ttext = '' if text.nil?\n\t\ttext = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n\t\ttext = sanitize(text) unless options[:sanitize] == false\n\t\ttext = text.to_str\n\t\ttext.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n#\t\ttext.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n\t\ttext.html_safe\n\tend", "def strip_tags(str)\n str.gsub(/\\</, \"&lt;\").gsub(/\\>/, \"&gt;\").gsub(/\\&/, \"&amp;\")\n end", "def clean_html(html)\n Sanitize.clean(html) rescue html\n end", "def plain_text\n text ? text.gsub(/<[^>]+>/,' ').squeeze(' ').strip : nil\n end", "def html2text(html)\n html ||= \"\" # ensure string is non-nil\n text = html.\n gsub(/(&nbsp;|\\n|\\s)+/im, ' ').squeeze(' ').strip.\n gsub(/<([^\\s]+)[^>]*(src|href)=\\s*(.?)([^>\\s]*)\\3[^>]*>\\4<\\/\\1>/i, '\\4')\n\n linkregex = /<[^>]*(src|href)=\\s*(.?)([^>\\s]*)\\2[^>]*>\\s*/i\n while linkregex.match(text)\n text.sub!(linkregex, \"\")\n end\n \n text = CGI.unescapeHTML(\n text.\n gsub(/<(script|style)[^>]*>.*<\\/\\1>/im, '').\n gsub(/<!--.*-->/m, '').\n gsub(/<hr(| [^>]*)>/i, \"___\\n\").\n gsub(/<li(| [^>]*)>/i, \"\\n* \").\n gsub(/<blockquote(| [^>]*)>/i, '> ').\n gsub(/<(br)(| [^>]*)>/i, \"\\n\").\n gsub(/<(\\/h[\\d]+|p)(| [^>]*)>/i, \"\\n\\n\").\n gsub(/<[^>]*>/, '')\n ).lstrip.gsub(/\\n[ ]+/, \"\\n\") + \"\\n\"\n\n converted = []\n text.split(//).collect { |c| converted << ( c[0] > 127 ? \"&##{c[0]};\" : c ) }\n converted.join('')\n end", "def strip_tags string\n string.gsub(/<\\/?[^>]*>/, \"\")\nend", "def nice_html_to_text(html_text)\n doc = Hpricot(html_text)\n doc.search(\"//text()\").text\n end", "def strip_html(param_string)\n param_string.gsub!('<', '&lt;')\n param_string.gsub!('>', '&gt;')\n param_string.gsub(/\\\"/,\"&quot;\")\n return param_string\n end", "def clean_string(string)\n string = string.gsub(/\\r|\\n/,'').sub(/^ */,'').sub(/\\s*$/,'').gsub(/ +/,' ')\n coder = HTMLEntities.new()\n string = coder.decode(string) # Remove html entities\n return string\n end", "def strip_tags(html)\n strip(Sanitize.clean(html, :elements => [], :attributes => []))\n end", "def rm_html_entities(str)\n str.gsub(/&\\w+;/, \"\")\n end", "def strip_html(allow)\n str = self.strip || ''\n allow_arr = allow.join('|')\n str = str.gsub(/<\\s*/,'<')\n str = str.gsub(/<\\/\\s*/,'</')\n # First part of | prevents matches of </allowed. Second case prevents matches of <allowed\n # and keeps the / chacter from matching the ?! allowed.\n str.gsub(/<(\\/(?!(#{allow_arr}))|(?!(\\/|#{allow_arr})))[^>]*?>/mi,'')\n end", "def sanitize(text)\n sanitized_text = text.dup\n\n # Strip URLs\n sanitized_text.gsub!(URL_REGEX, '')\n\n # Strip @mention style tokens\n sanitized_text.gsub!(MENTION_REGEX, '')\n\n sanitized_text\n end", "def sanitize(html)\n HTML5::HTMLParser.\n parse_fragment(html, :tokenizer => HTML5::HTMLSanitizer, :encoding => 'utf-8').\n to_s\n end", "def sanitize(html)\n HTML5::HTMLParser.\n parse_fragment(html, :tokenizer => HTML5::HTMLSanitizer, :encoding => 'utf-8').\n to_s\n end", "def strip_html_quote_entities(text)\n text.gsub(/&.dquo;/, '')\n end", "def normalise_html(html)\n Nokogiri::HTML5.fragment(html).to_s.gsub(\"\\n\", \"\")\n end", "def as_text\n return self if self.blank?\n mytext = self.gsub(/<p>(.*?)<\\/p>/mi,'\\1'+\"\\n\\n\")\n mytext = mytext.gsub(/<br(.*?)>/mi,\"\\n\") \n mytext = mytext.gsub(/<p(.*?)>/mi,\"\\n\\n\") \n mytext = mytext.gsub(/<\\/p>/mi,\"\") \n mytext = mytext.gsub(/<div(.*?)>/mi, \"\")\n mytext = mytext.gsub(/<\\/div>/mi,\"\") \n # Go ahead and strip all the other html tags as well\n mytext = mytext.gsub(/<\\/?[^>]*>/, \"\")\n CGI.unescapeHTML(mytext).strip\n end", "def clean_html(options={:url => nil})\n use_http_get = true\n call_api('clean-html', options, use_http_get)\n end", "def filter_text(text)\n text = text.to_s\n text.gsub('&', '&amp;')\n text.gsub('\\'', '&#039;')\n text.gsub('\"', '&quot;')\n text.gsub('<', '&lt;')\n text.gsub('>', '&gt;')\n text\n end", "def rm_single_tags(str)\n str.gsub(/<[^<>]*\\/>/, \"\")\n end", "def unescapeHTML(string)\n\tstr = string.dup\n\tstr.gsub!(/&(.*?);/n) {\n\t\tmatch = $1.dup\n\t\tcase match\n\t\t\twhen /\\Aamp\\z/ni then '&'\n\t\t\twhen /\\Aquot\\z/ni then '\"'\n\t\t\twhen /\\Agt\\z/ni then '>'\n\t\t\twhen /\\Alt\\z/ni then '<'\n\t\t\twhen /\\A#(\\d+)\\z/n then Integer($1).chr\n\t\t\twhen /\\A#x([09af]+)\\\n\t\t\tz/ni then $1.hex.chr\n\t\tend\n\t\t}\n\tstr\nend", "def sanitize_html(content)\n require 'cgi'\n CGI.escapeHTML(content)\n end", "def removeTag(text,tag)\n return 0 unless text\n text=text.to_s\n text=text.gsub(\"<\"+tag+\">\", \"\")\n text=text.gsub(\"</\"+tag+\">\", \"\")\n \n return text.to_s\nend", "def unescape_html(str)\n str.gsub(/&(.*?);/n) do\n match = $1.dup\n case match\n when /\\Aamp\\z/ni then '&'\n when /\\Aquot\\z/ni then '\"'\n when /\\Agt\\z/ni then '>'\n when /\\Alt\\z/ni then '<'\n when /\\A#0*(\\d+)\\z/n then\n if Integer($1) < 256\n Integer($1).chr\n else\n if Integer($1) < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)\n [Integer($1)].pack(\"U\")\n else\n \"&##{$1};\"\n end\n end\n when /\\A#x([0-9a-f]+)\\z/ni then\n if $1.hex < 256\n $1.hex.chr\n else\n if $1.hex < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)\n [$1.hex].pack(\"U\")\n else\n \"&#x#{$1};\"\n end\n end\n else\n \"&#{match};\"\n end\n end\n end", "def strip_tags(string)\n if defined?(Loofah)\n # Instead of strip_tags we will use Loofah to strip tags from now on\n Loofah.fragment(string).text(encode_special_chars: false)\n else\n helpers.strip_tags(string)\n end\n end", "def clean_body(text)\n text = strip_bad_chars(text)\n text.gsub!(/(\\r)?\\n/, \"\");\n text.gsub!(/\\s+/, ' ');\n\n # clean start and end whitespace\n text = text.strip;\n return text\nend", "def clean_text(string)\n if string\n string.chomp!\n string.gsub!(/\\t+|\\(.+?\\)\\s*/,'')\n string.gsub!(/‘|’|„|“/, \"'\")\n string.squeeze!(\"?|!\")\n string.gsub!(/!\\?|\\?!/, \"?\")\n string.gsub!(/…|!|\\.\\.\\./, \".\") # Used the three marks to keep the count clean\n string.gsub!(/(Na)(ja)/i, '\\1 \\2')\n string.squeeze(\" \").strip\n else\n \"\"\n end\n end", "def html2text(html)\n\n result = ''\n begin\n web_doc = Hpricot(html)\n web_doc.search(\"//comment()\").remove\n web_doc.search(\"script\").remove\n web_doc.search(\"style\").remove\n web_doc.search(\"noscript\").remove\n web_doc.search(\"object\").remove\n web_doc.search(\"embed\").remove\n web_doc.search(\"head\").remove\n\n web_doc.traverse_text do |e| \n\n begin\n if e.content\n result += e.content+\"\\n\"\n end\n rescue\n # ignore errors\n end\n end\n rescue Exception => e\n # ignore errors\n warn \"html2text() - Exception '#{e.message}' trying to parse '#{html}'\"\n end\n\n if result == ''\n # Use a simple regular-expression approach to remove all tags\n result = html.gsub(/<[^>]*>/, '')\n end\n\n coder = HTMLEntities.new\n result = coder.decode(result)\n\n result.gsub!(/\\n[\\r\\n \\t]*/, \"\\n\")\n\n result\nend", "def sanitize_text(text)\n text = unescape_text(text)\n text = extract_text(text) if aruba.config.remove_ansi_escape_sequences\n\n text.chomp\n end", "def create_cleared_text(s)\n s.gsub(/[RMQ]T @[a-zA-Z0-9_]+:.*/, '')\n .gsub(/\\. ?(@[a-zA-Z0-9_]+ )+/, '')\n .gsub(/@[a-zA-Z0-9_]+/, '')\n .gsub(%r[(https?|ftp)(:\\/\\/[-_.!~*\\'()a-zA-Z0-9;\\/?:\\@&=+\\$,%#]+)], '')\n .gsub(/#.+([  、。]|$)/, '')\n .strip\n end", "def unescapeHTML(string)\n str = string.dup\n str.gsub!(/&(.*?);/n) {\n match = $1.dup\n case match\n when /\\Aamp\\z/ni then '&'\n when /\\Aquot\\z/ni then '\"'\n when /\\Agt\\z/ni then '>'\n when /\\Alt\\z/ni then '<'\n when /\\A#(\\d+)\\z/n then Integer($1).chr\n when /\\A#x([0-9a-f]+)\\z/ni then $1.hex.chr\n end\n }\n str\nend", "def stripped(string, options = {})\n string ? Vidibus::Textile.new(string).to_text(options) : \"\"\n end", "def text2html(text)\n return nl2br(escape_xml(text.to_s).gsub(/ /, ' &nbsp;'))\n end", "def strip_style_tag (s)\ns.gsub(/<style.*<\\/style>/i, '');\nend", "def clear_text(text)\n text = text.tr(\"\\n\", \" \")\n text.gsub(/[^0-9A-Za-z. ]/, '')\n end", "def sanitize(html, options = {})\n msclean(html, options)\n end", "def strip_doctype_html(input)\n input.to_s.gsub(Regexp.new(DOCTYPE_HTML), NOTHING)\n end", "def strip_html_from_description\n self.description = ActionView::Base.full_sanitizer.sanitize(description)\n end", "def sanitize!(html, options = {})\n msclean!(html, options)\n end", "def sanitize(text)\n text.squeeze\n text.capitalize!\n text.gsub!('&', '&amp;')\n text.gsub!('<', '&lt;')\n text.gsub!('>', '&gt;')\n return text\nend", "def scrub_text(text)\n TEXT_GSUBS.inject(text) { |memo, sub| memo = memo.gsub(*sub) }\n end", "def stripsub(text)\n return (text.strip).gsub(\"'\",\"''\").gsub(\"’\", \"''\")\n end" ]
[ "0.7926463", "0.79096335", "0.7888792", "0.7888792", "0.7820859", "0.7726107", "0.76613516", "0.75348973", "0.7444003", "0.74397993", "0.7242551", "0.7237054", "0.706811", "0.7054293", "0.70524216", "0.7047737", "0.7043161", "0.6997918", "0.6995465", "0.6969951", "0.6969951", "0.6969951", "0.69575745", "0.6929662", "0.6918936", "0.68914133", "0.688569", "0.6853419", "0.68470126", "0.68033105", "0.6706145", "0.66931504", "0.66776645", "0.66588426", "0.6658376", "0.6642532", "0.66300184", "0.6624449", "0.66227895", "0.66161203", "0.6615797", "0.6615797", "0.66061723", "0.65824705", "0.6574092", "0.65718544", "0.6561067", "0.655877", "0.6540133", "0.6518", "0.6500987", "0.6497417", "0.64672494", "0.6464393", "0.64638263", "0.64492464", "0.64492464", "0.64492464", "0.64492464", "0.6447711", "0.6436815", "0.64181674", "0.64155895", "0.64060426", "0.6395205", "0.63911945", "0.6375173", "0.63651496", "0.63632315", "0.6345694", "0.63094634", "0.63051975", "0.63051975", "0.62993735", "0.6296897", "0.62916464", "0.62550664", "0.6240531", "0.6218618", "0.6191761", "0.6153839", "0.61231023", "0.6122127", "0.6105391", "0.610229", "0.6089408", "0.60606825", "0.60521907", "0.6047353", "0.60468084", "0.604163", "0.6028956", "0.6028386", "0.60221237", "0.6021801", "0.6015835", "0.6011658", "0.600068", "0.59977853", "0.59950185", "0.5986392" ]
0.0
-1
Replace a string in text with a regex regular expression string Replaces all occurrences of the input regular expression regex string in the input content, and returns the result
def edit_text_replace_regex(request, opts = {}) data, _status_code, _headers = edit_text_replace_regex_with_http_info(request, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def regex_replace(string, search, replace)\n return string.gsub(/#{search}/m, replace)\n end", "def modify_text(book_text, string_values)\n string_values.each do |search_string, change_string|\n regex = %r[#{search_string}]\n book_text = book_text.gsub(regex, change_string)\n end\n\n return book_text\nend", "def transform(text)\n\t\t\[email protected] do |rule|\n\t\t\t\tif rule.replace.is_a?(String)\n\t\t\t\t\ttext = text.gsub(rule.pattern, rule.replace)\n\t\t\t\telse\n\t\t\t\t\ttext = text.gsub(rule.pattern) {rule.replace.call($~)}\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn text\n\t\tend", "def rewrite!(content)\n return content unless match?\n \n content.gsub(/#{pattern}/, replacement)\n end", "def regex_replace_first(input, regex, replacement = NOTHING)\n input.to_s.sub(Regexp.new(regex), replacement.to_s)\n end", "def replace regex, options\n required_options options, [:with, :in]\n add \"sed -i 's/#{regex}/#{options[:with].to_s.gsub('/', '\\/').gsub(\"\\n\", \"\\\\n\")}/' #{options[:in]}\", check_string(options[:with], options[:in])\n end", "def sub_replacements text\n if REPLACEABLE_TEXT_RX.match? text\n # NOTE interpolation is faster than String#dup\n text = text.to_s\n REPLACEMENTS.each do |pattern, replacement, restore|\n # NOTE Using gsub! as optimization\n text.gsub!(pattern) { do_replacement $LAST_MATCH_INFO, replacement, restore }\n end\n end\n text\n end", "def gsub(text, regexp, with)\n total = 0\n Undo.record text do |record|\n text.index('1.0').upto(text.index('end')) do |index|\n lineend = index.lineend\n line = text.get(index, lineend)\n\n if line.gsub!(regexp, with)\n record.replace(index, lineend, line)\n total += 1\n end\n end\n end\n\n text.message \"Performed gsub on #{total} lines\"\n end", "def replace!(regexp, string)\n unless base.options[:pretend]\n content = File.read(destination)\n content.gsub!(regexp, string)\n File.open(destination, 'wb') { |file| file.write(content) }\n end\n end", "def replace(input_field, regex, into_field, replacement, options = {})\n output = options[:output] || all_fields # Overrides Cascading default\n\n input_field = fields(input_field)\n raise \"input_field must declare exactly one field, was '#{input_field}'\" unless input_field.size == 1\n into_field = fields(into_field)\n raise \"into_field must declare exactly one field, was '#{into_field}'\" unless into_field.size == 1\n\n parameters = [into_field, regex.to_s, replacement.to_s, options[:replace_all]].compact\n each(\n input_field,\n :function => Java::CascadingOperationRegex::RegexReplace.new(*parameters),\n :output => output\n )\n end", "def new_regex(old_unescaped_content, new_unescaped_content, old_regex_string)\r\n\t\t#STDERR.puts \"\"\r\n\t\t#STDERR.puts \"OldRegex\" + old_regex_string\r\n\t\t#content already content unescaped, so it only te\\:st is alreadt te:st\r\n\t\t\r\n\t\t#escape content\r\n\t\t#STDERR.puts SnortRuleContent.escape(old_unescaped_content)\r\n\t\told_escaped_content = content_escape(Regexp.escape(old_unescaped_content))\r\n\t\tnew_escaped_content = content_escape(Regexp.escape(new_unescaped_content))\r\n\t\t#STDERR.puts \"OldEC:\" + old_escaped_content\r\n\t\t#STDERR.puts \"NewEC:\" + new_escaped_content\r\n\t\r\n\t\t#fix up incorrect escape of hyphen\r\n\t\twhile(old_escaped_content.sub(\"\\\\-\",\"-\") != old_escaped_content)\r\n\t\t\told_escaped_content = old_escaped_content.sub(\"\\\\-\",\"-\") \r\n\t\tend\r\n\t\twhile(new_escaped_content.sub(\"\\\\-\",\"-\") != new_escaped_content)\r\n\t\t\tnew_escaped_content = new_escaped_content.sub(\"\\\\-\",\"-\") \r\n\t\tend\r\n\r\n\t\t#replace all occurences of old_escaped_content with new_escaped_content in old_regex_string\r\n\t\twhile(old_regex_string.sub(old_escaped_content,new_escaped_content) !=old_regex_string)\r\n\t\t\told_regex_string = old_regex_string.sub(old_escaped_content,new_escaped_content) \r\n\t\tend\r\n\t\tnew_regex_string = old_regex_string\r\n\t\t#STDERR.puts \"NewRegex\" + new_regex_string\r\n\t\treturn new_regex_string\r\n\tend", "def replace!(regexp, string, force)\n return if base.options[:pretend]\n content = File.binread(destination)\n if force || !content.include?(replacement)\n content.gsub!(regexp, string)\n File.open(destination, \"wb\") { |file| file.write(content) }\n end\n end", "def replace pattern, substitute\n if pattern.is_a? Regexp\n ArelExtensions::Nodes::RegexpReplace.new self, pattern, substitute\n else\n ArelExtensions::Nodes::Replace.new self, pattern, substitute\n end\n end", "def gsub(pattern, replace)\n lambda do |rec, acc|\n acc.collect! { |v| v.gsub(pattern, replace) }\n end\n end", "def as_regex\n Regexp.new('/' + split.map do |element|\n replace element\n end.join('/'))\n end", "def replace_encoded(str, regex)\n str.scan(regex).each do |x|\n str = str.sub(\"#{x[0]}[#{x[1]}]\", x[1] * x[0].to_i)\n end\n str\nend", "def gsub(regex, replacement)\n __gsub_perform_substitution(regex, replacement)[0]\n end", "def gsub(regex, &block)\n return StringGsubEnumerator.new(self, :gsub, regex) unless block\n __gsub_perform_block_substitution(regex, &block)\n end", "def replace_string_inside_node!(search_string_or_regex, replace_string, xn)\n if xn.text? && '' != xn.text && !xn.text.nil?\n xn.content = xn.text.gsub(search_string_or_regex, replace_string)\n else\n xn.children.each { |child_xn|\n replace_string_inside_node!(search_string_or_regex, replace_string, child_xn)\n }\n end\n end", "def replace(content)\n \n # pre-structuring\n content.gsub!( /^(\\w.*)\\n(\\w.*)/ ) { \"#{$1} #{$2}\" } # remove single line breaks between text in order to avoid false paragraph markup\n content.gsub!( /<!--/ ) { \"--\" } # replace opening html commentaries\n content.gsub!( /-->/ ) { \"--\" } # replace closing html commentaries\n \n # templates\n content.gsub!( /\\{\\{Zitat\\|(.*)\\|.*\\}\\}\\s*$\\n/ ) { \"\\{p\\}\\\"#{$1}\\\"\\{/p\\}\\n\" } # citation\n content.gsub!( /\\{\\{.*(Finale Version).*\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1}</font>{/status}<br>\" } # final version\n content.gsub!( /\\{\\{Vorlage:(Dokument.*)\\n*(.*)\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1} #{$2}</font>{/status}<br>\" } # document status\n content.gsub!( /\\{\\{.*\\}\\} *$/ ) { '' } # remove single line templates\n content.gsub!( /\\{\\{.*\\n?.*\\}\\} *$/ ) { '' } # remove all remaining templates\n \n # tags\n content.gsub!( /<nowiki>(.*?)<\\/nowiki>/ ) { \"<pre>#{$1}</pre>\" }\n content.gsub!( /^ +(.*)/ ) { \"<pre>#{$1}</pre>\" }\n\n # special markup of qualidative data analysis\n content = content + \"\\n\\n{!end}\"\n \n # categories\n content.gsub!( /\\[\\[Kategorie:(.*?)\\]\\]/i ) { \"{category}<font color=\\\"#FF0000\\\">Kategorie:#{$1}</font>{/category}<br>\" }\n \n # images\n content.gsub!( /\\[\\[Bild:(.*?)\\]\\]/i ) { \"{image}Bild:#{$1.gsub!(/.*\\|/,'')}{/image}<br>\"} # Bild:lpscreen.jpg|thumb|Bereichseite des Landesportals\n\n # bold\n content.gsub!(/'''(.*?)'''/) {\"<strong>#{$1}</strong>\"}\n content.gsub!(/'''(.*?)$/) {\"<strong>#{$1}</strong>\"}\n\n # italics\n content.gsub!(/''(.*?)''/) {\"<em>#{$1}</em>\"}\n content.gsub!(/''(.*?)$/) {\"<em>#{$1}</em>\"}\n\n # headings\n 6.downto(1) { |i| content.gsub!( /^={#{i}}(.*?)={#{i}} *$/ ) { \"<h#{i}>\\{h>#{i}\\}#{$1}\\{/h>#{i}\\}</h#{i}>\" } }\n \n # links, internal\n content.gsub!( /\\[\\[([^\\[\\n]*?)\\| *(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[\\[(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n\n # links, external\n content.gsub!( /\\[([^\\[\\n]*?)\\| *(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n \n # lists\n content.gsub!(/^:+/,'') # remove forced indenting\n content.gsub!( /^((?:\\*.*\\n+)+)/ ) { \"\\{l>ul\\}<ul>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^\\*/,'')}</li>\\n\" }.join}</ul>\\{/l>ul\\}<br>\\n\" } # first level ul\n content.gsub!( /^((?:#.*\\n+)+)/ ) { \"\\{l>ol\\}<ol>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^#/,'')}</li>\\n\" }.join}</ol>\\{/l>ol\\}<br>\\n\" } # first level ol\n content.gsub!( /<li>\\s*<\\/li>\\n/ ) { '' } # remove empty list entries (this may occur if first-level wiki-lists are entered with \\n\\n; they look like a single list when, in fact, they are but multiple single lists)\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # second level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # second level ol\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # third level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # third level ol\n\n # tables\n # the table conversion barely works, cf. http://johbuc6.coconia.net/doku.php/mediawiki2html_machine/code?DokuWiki=7c542b97df2bc0f82fec0f4875265a20 for an implementation in PHP\n content.gsub!( /^\\{\\|(.*)/ ) { \"\\{table\\}\\n<table #{$1}>\" }\n content.gsub!( /\\|\\}/ ) { \"</table>\\n\\{/table\\}\" }\n content.gsub!( /^\\|-(.*)/ ) { \"<tr>#{$1}\" }\n content.gsub!( /^!(.*?)\\|(.*)/ ) { \"<th #{$1}>#{$2}</th>\" } # table header with piped markup\n content.gsub!( /^!(.*)/ ) { \"<th>#{$1}</th>\" } # table header without piped markup\n content.gsub!( /^\\|(.*?)\\|(.*)/ ) { \"<td #{$1}>#{$2}\" } # table data with piped markup\n content.gsub!( /^\\|(.*)/ ) { \"<td>#{$1}\" } # table data without piped markup\n \n # line breaks\n content.gsub!( /(^(?:\\w|<strong|<em|<a|\\\").*)\\n\\s*\\n/ ) {\"<p>\\{p\\}#{$1}\\{/p\\}</p>\\n\"}\n \n # special markup of qualidative data analysis\n content.gsub!( /(\\{id\\}.*\\{\\/title\\})/ ) { \"<p><strong><em>#{$1.gsub(/_/,' ')}</em></strong></p>\" }\n \n# //$html = nl2br($html);\n# \t// line breaks\n# \t$html = preg_replace('/[\\n\\r]{4}/',\"<br/><br/>\",$html);\n# \t$html = preg_replace('/[\\n\\r]{2}/',\"<br/>\",$html);\n\n# \t$html = preg_replace('/[>]<br\\/>[<]/',\"><\",$html);\n \n# // allowed tags\n# \t$html = preg_replace('/&lt;(\\/?)(small|sup|sub|u)&gt;/','<${1}${2}>',$html);\n#\n# \t$html = preg_replace('/\\n*&lt;br *\\/?&gt;\\n*/',\"\\n\",$html);\n# \t$html = preg_replace('/&lt;(\\/?)(math|pre|code|nowiki)&gt;/','<${1}pre>',$html);\n# \t$html = preg_replace('/&lt;!--/','<!--',$html);\n# \t$html = preg_replace('/--&gt;/',' -->',$html);\n# \n return content\n\nend", "def sub(pattern, replacement)\n replacement = Maglev::Type.coerce_to(replacement, String, :to_str)\n regex = self.__get_pattern(pattern, true)\n\n # If pattern is a string, then do NOT interpret regex special characters.\n # stores into caller's $~\n if (match = regex.__match_vcglobals(self, 0x30))\n __replace_match_with(match, replacement)\n else\n dup\n end\n # r.taint if replacement.tainted? || self.tainted?\n end", "def gsub_file(path, regexp, *args, &block)\n #path = destination_path(relative_destination)\n content = File.read(path)\n check_for = args.first || yield('')\n regex = Regexp.new(regexp.source + Regexp.escape(check_for))\n return if content =~ regex # if we can match the text and its leadin regex, don't add again\n content = content.gsub(regexp, *args, &block)\n File.open(path, 'wb') { |file| file.write(content) }\n end", "def scrub_text(text)\n TEXT_GSUBS.inject(text) { |memo, sub| memo = memo.gsub(*sub) }\n end", "def recursive_gsub(search_txt, txt_to_replace)\n res = self\n res = res.gsub(search_txt, txt_to_replace).recursive_gsub(search_txt, txt_to_replace) if res.include?(search_txt)\n res\n end", "def replace_string_in_file(filename, regex, replacement = '')\n content = File.read(filename).gsub(/#{regex}$/i, replacement)\n File.open(filename, 'wb') { |file| file.write(content) }\n end", "def apply!(str)\n str.gsub! regexp, ''\n end", "def replace!(destination, regexp, string)\n content = File.binread(destination)\n content.gsub!(regexp, string)\n File.open(destination, 'wb') { |file| file.write(content) }\nend", "def replace_placeholders(text)\n matches = text.scan(/\\{([a-z_]+)\\}/).flatten\n\n return text unless matches.any?\n\n replaced = text.dup\n\n matches.each do |match|\n value = @filing_history.description_values.dig(match.to_sym)\n replaced.sub!(/{#{match}}/, value)\n end\n\n replaced\n end", "def replace_word_in_text(text, orignal_word, replaced_word)\n regex = %r[\\b#{orignal_word}\\b]\n text.gsub(regex, replaced_word)\nend", "def replace_all(source_text, replacement)\n case\n # For simple cases we just replace runs to try and keep formatting/layout of source\n when replacement.is_a?(String)\n @main_doc.replace_all_with_text(source_text, replacement)\n when (replacement.is_a?(Magick::Image) or replacement.is_a?(Magick::ImageList))\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n runs.each { |r| r.replace_with_run_fragment(create_image_run_fragment(replacement)) }\n when replacement.is_a?(Hash)\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n runs.each { |r| r.replace_with_body_fragments(create_body_fragments(replacement, {:create_table => true})) }\n when replacement.is_a?(Nokogiri::XML::Element)\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n if replacement.name == \"w:tbl\"\n runs.each { |r| r.replace_with_body_fragments(create_body_fragments(replacement)) }\n else\n runs.each { |r| r.replace_with_run_fragment(create_body_fragments(replacement)) }\n end\n else\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n runs.each { |r| r.replace_with_body_fragments(create_body_fragments(replacement)) }\n end\n end", "def escape(text)\n replacements.inject(text.to_s) do |corpus, (pattern, replacement)|\n corpus.gsub(pattern, replacement)\n end\n end", "def gsub(pattern, replacement = nil, &blk)\n if block_given?\n @string.gsub(pattern, &blk)\n else\n @string.gsub(pattern, replacement)\n end\n end", "def gsub(pattern, replacement = nil, &blk)\n if block_given?\n @string.gsub(pattern, &blk)\n else\n @string.gsub(pattern, replacement)\n end\n end", "def apply_replacements(word)\n @replacements.each do |pattern, target|\n word.gsub!(pattern, target)\n end\n \n word\n end", "def escape_re(str)\n str.gsub(@re_chars) {|c| @re_esc + c}\n end", "def gsub(value, context, parameters)\n # Try to find a full replacement match - if found, return the actual value of that reference.\n return get_reference_value($1, context, parameters) if value.match(REPLACE_REGEX)\n # No full match, substitute all references with their string representations\n value.gsub(INTERPOLATE_REGEX) { get_reference_value($1, context, parameters) }\n end", "def gsub!(*args, &block)\n str = self.gsub(*args, &block)\n if str != self\n self.replace(str)\n self\n else\n nil\n end\n end", "def gsub(pat, rep)\n inject(self.class.new) { |res, fn| res << fn.gsub(pat, rep) }\n end", "def post_process_text(s) \n # extract math\n math, arrays = [], []\n s.scan(/\\$([^$]+)\\$/) {|m| math << m } # $$\n s.scan(/\\\\\\[([^$]+)\\\\\\]/) {|m| arrays << m } # \\[ \\]\n # citations\n s = replace_citations(s)\n # listings, algorithms, tables\n s = replace_listings(s)\n # custom \n s = replace_custom_refs(s)\n # texttt\n s = replace_texttt(s)\n # emph\n s = replace_emph(s)\n # textbf\n s = replace_bf(s)\n # urls\n s = replace_urls(s)\n # footnotes\n s = replace_footnotes(s)\n # paragrams\n s = replace_paragraphs(s)\n # chapter refs\n s = replace_chapter_refs(s)\n # section refs\n s = remove_section_refs(s)\n # replace markboth with nothing\n s = replace_markboth(s)\n # remove hypenation suggestions\n s = remove_hyph_suggestions(s)\n # umlats etc\n s = character_processing(s)\n # replace \\% with %\n s = s.gsub(\"\\\\%\", \"\\%\")\n # replace \"\\ \" with a space\n s = s.gsub(\"\\\\ \", \" \")\n # replace \\\" and \\' with nothing\n s = s.gsub(\"\\\\\\\"\", \"\")\n s = s.gsub(\"\\\\\\'\", \"\")\n # replace ~ with space\n s = s.gsub(\"~\", \" \")\n # replace \\$ with $ (testing algorithms)\n s = s.gsub(\"\\\\$\", \"$\")\n # replace \\_ with _ (testing algorithms)\n s = s.gsub(\"\\\\_\", \"_\") \n # replace \\# with # (appendix)\n s = s.gsub(\"\\\\#\", \"#\")\n # replace \\{ with { (appendix)\n s = s.gsub(\"\\\\{\", \"{\")\n # replace \\} with } (appendix)\n s = s.gsub(\"\\\\}\", \"}\") \n # replace \\\\ with <br /> (appendix, de)\n s = s.gsub(\"\\\\\\\\\", \"<br />\") \n # replace \\Latex with LaTex\n s = s.gsub(\"\\\\LaTeX\", \"LaTex\") \n # replace \\copyright with html copyright\n s = s.gsub(\"\\\\copyright\", \"&copy;\")\n # replace \\mybookdate\\ with publication date 2011\n s = s.gsub(\"\\\\mybookdate\", DATE)\n # replace \\mybookauthor with the author ame\n s = s.gsub(\"\\\\mybookauthor\", \"Jason Brownlee\")\n # replace \\mybooktitle with the book title\n s = s.gsub(\"\\\\mybooktitle\", TITLE)\n # replace \\mybooksubtitle with the book subtitle\n s = s.gsub(\"\\\\mybooksubtitle\", SUBTITLE)\n # finally switch ` for ' (late in the subs)\n s = s.gsub(\"`\", \"'\")\n \n # put the math back\n if !math.empty?\n index = 0\n s = s.gsub(/\\$([^$]+)\\$/) do |m|\n index += 1\n \"$#{math[index - 1]}$\"\n end\n end \n if !arrays.empty?\n index = 0\n s = s.gsub(/\\\\\\[([^$]+)\\\\\\]/) do |m|\n index += 1\n \"\\\\[#{arrays[index - 1]}\\\\]\"\n end\n end\n return s\nend", "def process_text text\n newtext = text.gsub(/if/, 'IF')\n\n 30.times { |i|\n newtext.gsub!(/for/, 'FOR')\n newtext.gsub!(/while/, 'WHILE')\n newtext.gsub!(/switch/, 'SWITCH')\n newtext.gsub!(/case/, 'CASE')\n newtext.gsub!(/goto/, 'GOTO')\n newtext.gsub!(/struct/, 'STRUCT')\n newtext.gsub!(/int/, 'INT')\n newtext.gsub!(/char/, 'CHAR')\n newtext.gsub!(/return/, 'RETURN')\n }\n\n return newtext\nend", "def gsub(*)\n self\n end", "def sub(text, regexp, with)\n linestart = text.index('insert linestart')\n lineend = linestart.lineend\n line = text.get(linestart, lineend)\n\n text.replace(linestart, lineend, line) if line.sub!(regexp, with)\n end", "def replace_contents!(pattern, replace_with)\n\t\twrite contents.gsub(pattern, replace_with)\n\tend", "def replace_contents!(pattern, replace_with)\n\t\twrite contents.gsub(pattern, replace_with)\n\tend", "def substText(text,bodyStack)\n if(text.kind_of?(Text)) \n rawtext = text.string ;\n elsif(text.kind_of?(Attribute))\n rawtext = text.value ;\n elsif(text.kind_of?(String))\n rawtext = text ;\n else\n return ;\n end\n\n result = rawtext.clone() ;\n\n# result.gsub!(ArgFormat) {|dat| \n# getSubstText($1,bodyStack,dat) ;\n# }\n substTextBody(result,bodyStack) ;\n\n return result ;\n end", "def gsub_file(path, regexp, *args, &block)\n content = File.read(path).gsub(regexp, *args, &block)\n File.open(path, 'wb') { |file| file.write(content) }\nend", "def pattern2regex(pattern); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def format!\n substitutions.each { |s| sub_string.gsub!(match(s), replace(s)) }\n sub_string\n end", "def gsub!(pat, rep)\n each_with_index { |fn, i| self[i] = fn.gsub(pat,rep) }\n self\n end", "def mreplace regexp, &block\n matches = []\n offset = 0\n while self[offset..-1] =~ regexp\n matches << [offset, $~]\n offset += $~.end($~.size - 1)\n end\n raise 'unmatched' if matches.empty?\n\n matches.reverse.each do |offset, match|\n slice = self[offset...-1]\n send = (1...match.size).map {|i| slice[match.begin(i)...match.end(i)]}\n if send.length == 1\n recv = block.call(send.first)\n self[offset+match.begin(1)...offset+match.end(1)] = recv\n else\n recv = block.call(*send)\n next unless recv\n (1...match.size).map {|i| [match.begin(i), match.end(i), i-1]}.sort.\n reverse.each do |start, fin, i|\n self[offset+start...offset+fin] = recv[i]\n end\n end\n end\n self\n end", "def edit_text_replace_regex_with_http_info(request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_replace_regex ...'\n end\n # verify the required parameter 'request' is set\n if @api_client.config.client_side_validation && request.nil?\n fail ArgumentError, \"Missing the required parameter 'request' when calling EditTextApi.edit_text_replace_regex\"\n end\n # resource path\n local_var_path = '/convert/edit/text/replace/regex'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(request)\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ReplaceStringRegexResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EditTextApi#edit_text_replace_regex\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def url_replace(url)\n URL_SUBSTITUTION.each do |pattern, replacement|\n if url.match(pattern)\n return url.gsub(Regexp.new(\".*#{pattern}.*\",\"uxim\"), replacement)\n end\n end\n return \"[url]\"\n end", "def replace(line)\n return line if line !~ /\\{\\{Gc/\n return line if line =~ /link=none/ || line =~ /dis=false/ || line =~ /dis=true/\n return line.gsub!(/\\{\\{[Gg]c|mod=(\\S+)\\|/, '{{Gc|mod=\\1|dis=false|')\nend", "def prepare_for_regexp(output_str)\n split_lines(output_str).map do |str|\n Regexp.new(Regexp.escape(str), Regexp::EXTENDED)\n end\n end", "def replace_placeholders(string, placeholder_regex, &block)\n string.gsub(/%{(#{placeholder_regex})}/) do |arg|\n yield($~[1]) || arg\n end\n end", "def make_regexp\n @intent = self.intent\n regexp = self.pattern.dup.downcase\n words = regexp.split(\" \")\n words.each do |word|\n if word.include? '/'\n regexp = regexp.gsub(word,\"(#{word})\")\n\n end\n\n end\n regexp = regexp.gsub('/',\"|\")\n regexp = regexp.gsub('^ ','.{0,60}').gsub(' ^','.{0,60}').gsub(' *','.{1,60}').gsub('* ','.{1,60}').gsub('^','.{1,60}').gsub(' [','.{0,60}[')\n regexp = regexp.gsub(' .{0,60}','.{0,60}')\n regexp = regexp.gsub(' .{1,60}','.{1,60}')\n regexp = '.{0,60}' + regexp + '.{0,60}'\n self.regexp = regexp\n chunks = self.pattern.split(' ')\n chunks.each do |ch|\n result= Regexp.new(/\\[.{0,12}\\]/) =~ ch\n if(result==0)\n set = WordSet.find_by_keyword(ch[1..-2])\n str = '(' + set.words.join('|') + ')'\n regexp = self.regexp.gsub(ch,str)\n self.regexp = regexp\n end\n end\n self.save\n end", "def gsub_functions(text)\n\tlast_function_end = 0\n\n\tresult = text\n\tadjust = 0\n\n\tscan_ignore_comments(/((\\w+)::)?(\\w+)\\s*\\(([^\\)]*?)\\)\\s*\\{/m, text) do |match|\n\t\toffset = match.pre_match.length\n\n\t\tif offset > last_function_end\n\t\t\tclass_name = match[2]\n\t\t\tname = match[3]\n\t\t\tend_offset = find_block_end(text, offset) + 1\n\n\t\t\tblock = text[offset, end_offset - offset]\n\n\t\t\t# Get replacement text.\n\n\t\t\treplacement = yield class_name, name, block\n\n\t\t\t# Substitute old text for new text:\n\n\t\t\tbefore_text = result[0, offset + adjust]\n\t\t\tafter_text = result[end_offset + adjust,\n\t\t\t result.length]\n\t\t\tresult = before_text + replacement + after_text\n\t\t\tadjust += replacement.length - block.length\n\n\t\t\t# Save end position of function so that we won't\n\t\t\t# change anything in this block again.\n\n\t\t\tlast_function_end = end_offset\n\t\tend\n\tend\n\n\tresult\nend", "def search_match(regex, replace, command, method)\n\n #convert regex to a Regexp object (if not already is one) and store it in exp.\n exp = Regexp.new(regex)\n\n #loop through contents and do the appropriate operation depending on 'command' and 'method'\n new_contents = []\n\n contents.each do |line|\n if line.match(exp)\n self.file_edited = true\n case\n when command == 'r'\n new_contents << ((method == 1) ? replace : line.gsub!(exp, replace))\n when command == 'd'\n if method == 2\n new_contents << line.gsub!(exp, \"\")\n end\n when command == 'i'\n new_contents << line\n new_contents << replace unless method == 2\n end\n else\n new_contents << line\n end\n end\n if command == 'i' && method == 2 && ! file_edited\n new_contents << replace\n self.file_edited = true\n end\n\n self.contents = new_contents\n end", "def justLikeSed(file, text_to_replace, text_to_put_in_place)\n text = File.read(file)\n File.open(file, 'w+'){|f| f << text.gsub(text_to_replace, text_to_put_in_place)}\n end", "def gsub!(pat, rep)\n each_with_index { |fn, i| self[i] = fn.gsub(pat,rep) }\n self\n end", "def escape input, regexp, map\n input.gsub(regexp) { | char | map[char] || char }\n end", "def replace_text_nodes_matching(pattern)\n return doc if project.nil?\n\n search_text_nodes(doc).each do |node|\n content = node.to_html\n\n next unless content.match(pattern)\n next if ignored_ancestry?(node)\n\n html = yield content\n\n next if html == content\n\n node.replace(html)\n end\n\n doc\n end", "def replace_contents!(pattern, with_text)\n entries.each do |entry|\n entry.replace_contents!(pattern, with_text) unless entry.dir?\n end\n end", "def rsub(pattern, replacement)\n if i = rindex(pattern) # rubocop:disable Lint/AssignmentInCondition\n s = @string.dup\n s[i] = replacement\n self.class.new s\n else\n self\n end\n end", "def replace_text(text)\n @txt .set_editable(true) # .freeze\n @txt .buffer .set_text(\"\")\n# hdr, value = text .split(\"\\n\\n\", 2)\n# hdr .to_s .each_line{|line|\n# case line\n# when /^Subject:/ ;color = BLUE\n# when /^X-SC-Subject:/ ;color = BLUE\n# when /^From:/ ;color = PURPLE\n# #when /^To:|Cc:/ ;color = ORANGE\n# #when /^Date:/ ;color = GREEN\n# when /^X-SC-(Time|Day):/ ;color = RED\n# else ;color = BLACK\n# end\n# @txt .insert(nil, color, nil, line) if line != ''\n# }\n# @txt .insert(nil, RED, WHITE, hdr .to_s)\n# @txt .insert(nil, BLACK, nil, \"\\n\\n\" + value .to_s)\n\n @txt .buffer .insert(@txt.buffer.start_iter, MhcKconv::todisp(text))\n @txt .set_editable(@text_editable) #.thaw\n end", "def modify_content(source, content, replace_value)\n file = File.read(source)\n replace = file.gsub(/#{content}/, replace_value)\n File.open(source, \"w\"){|f|\n f.puts replace \n }\n end", "def gsubs(replacements)\n str = self.dup\n replacements.each do |r|\n str = str.gsub(r[0],r[1])\n end\n str\n end", "def sub!(pattern, replacement = T.unsafe(nil), &block); end", "def gsub!(pat, rep)\n each_with_index { |fn, i| self[i] = fn.gsub(pat, rep) }\n self\n end", "def replace(ast, pattern, &replacement)\n buffer = Parser::Source::Buffer.new('replacement')\n buffer.source = ast.loc.expression.source\n to_replace = search(ast, pattern)\n types = to_replace.grep(Parser::AST::Node).map(&:type).uniq\n rewriter = Rewriter.new\n rewriter.buffer = buffer\n rewriter.search = pattern\n rewriter.replacement = replacement\n rewriter.replace_on(*types)\n rewriter.rewrite(buffer, ast)\n end", "def initialize find, replace\n @regexp = Regexp.new(\"^#{find}$\")\n @replace = replace\n end", "def search_file_replace(regex, replace)\n search_match(regex, replace, 'r', 2)\n end", "def sed_hack_on_file(file_name, match_regex, replace_with)\n original_content = File.read(file_name)\n new_content = original_content.gsub(match_regex, replace_with)\n if new_content != original_content\n File.open(file_name, 'w') { |file| file.write(new_content) }\n else\n puts \"No change to file during sed hackery...\"\n end\nend", "def sub!(pattern, replacement)\n regex = self.__get_pattern(pattern, true)\n # stores into caller's $~\n if match = regex.__match_vcglobals(self, 0x30)\n replace(__replace_match_with(match, replacement))\n # self.taint if replacement.tainted?\n self\n else\n nil\n end\n end", "def match_string_to_regexp(str)\n #str = str.split(/(\\(\\(.*?\\)\\))(?!\\))/).map{ |x|\n # x =~ /\\A\\(\\((.*)\\)\\)\\Z/ ? $1 : Regexp.escape(x)\n #}.join\n #str = str.gsub(/\\\\\\s+/, '\\s+')\n #Regexp.new(str, Regexp::IGNORECASE)\n\n #str = str.split(/([#$]\\(.*?\\))/).map{ |x|\n # x =~ /\\A[#$]\\((.*)\\)\\Z/ ? ($1.start_with?('#') ? \"(#{$1})\" : $1 ) : Regexp.escape(x)\n #}.join\n #str = str.gsub(/\\\\\\s+/, '\\s+')\n #Regexp.new(str, Regexp::IGNORECASE)\n\n$stderr.puts \"HERE!!!!!!\"\n\n str = str.split(PATTERN).map{ |x|\n case x\n when /\\A\\(\\((.*)\\)\\)\\Z/\n $1\n when /\\A[#$]\\((.*)\\)\\Z/\n $1.start_with?('#') ? \"(#{$1})\" : $1\n else\n Regexp.escape(x)\n end\n }.join\n\n str = str.gsub(/\\\\\\s+/, '\\s+')\n\n Regexp.new(str, Regexp::IGNORECASE)\n\n #rexps = []\n #str = str.gsub(/\\(\\((.*?)\\)\\)/) do |m|\n # rexps << '(' + $1 + ')'\n # \"\\0\"\n #end\n #str = Regexp.escape(str)\n #rexps.each do |r|\n # str = str.sub(\"\\0\", r)\n #end\n #str = str.gsub(/(\\\\\\ )+/, '\\s+')\n #Regexp.new(str, Regexp::IGNORECASE)\n end", "def pig_it(text)\n text.gsub(/\\b([a-z0-9]?)([a-z0-9]+)\\b/i, '\\2\\1ay')\n # text.gsub(/\\b([a-z0-9])([a-z0-9]+)*\\b/i, '\\2\\1ay')\n # text.gsub(/([a-z0-9])([a-z0-9]+)*/i, '\\2\\1ay')\nend", "def replace_pattern\n id = Readline.readline(\"ID of task to perform replace: \").to_i\n old_pattern = Readline.readline('replace : ').chomp\n new_pattern = Readline.readline('with : ').chomp\n ok = ReplacePattern.new(id, old_pattern, new_pattern).execute\n puts \"No such task\" if !ok\n end", "def subs(input, the_story)\n subbed = the_story.gsub(\"lion\", input).gsub(\"r\", \"rrr\")\n return subbed\nend", "def regex(pattern)\n Regexp.new pattern.regex\n end", "def format_text(text)\n # Reflow\n reformatted = text.gsub(/\\s*\\n\\s*\\n+/, '$#$').gsub(/\\s*\\n\\s*/, ' ').gsub('$#$', \"\\n\\n\")\n return reformatted\n end", "def build_regex(string, params = nil)\n result = build_regex_str(string, params)\n Regexp.new \"^#{result}$\"\n end", "def filter_text(text)\n text = text.to_s\n text.gsub('&', '&amp;')\n text.gsub('\\'', '&#039;')\n text.gsub('\"', '&quot;')\n text.gsub('<', '&lt;')\n text.gsub('>', '&gt;')\n text\n end", "def regex\n Regexp.new(@str)\n end", "def sanitize_regexp(value)\n original = value.dup\n\n SANITIZE_REGEXP.each do |pattern, replacement|\n value.gsub!(pattern, replacement)\n end\n\n value2 = ''\n group_index = 0\n value.scan(/((?:[^\\\\(]+|\\\\[^\\d])+)|(\\\\\\d+)|(\\(\\??)/m) do |content, backref, capture|\n value2 << if capture == '('\n \"(?<_#{group_index += 1}>\"\n elsif backref\n \"\\\\k<_#{backref[/\\d+/]}>\"\n else\n (content || capture)\n end\n end\n\n Regexp.new(value2)\n rescue RegexpError => ex\n if ex.message =~ /^invalid multibyte escape:/\n begin\n /#{value2.force_encoding(Encoding::BINARY)}/n\n rescue RegexpError => ex\n error(ex, original, value2)\n end\n else\n error(ex, original, value2)\n end\n end", "def tex_escape(text)\n replacements = {\n '&' => '\\&',\n '%' => '\\%',\n '$' => '\\$',\n '#' => '\\#',\n '_' => '\\_',\n '{' => '\\{',\n '}' => '\\}',\n '~' => '\\textasciitilde{}',\n '^' => '\\^{}',\n '\\\\' => '\\textbackslash{}',\n '<' => '\\textless',\n '>' => '\\textgreater',\n }\n\n replacements.each do |search, escaped_replacement|\n text = text.gsub(search, escaped_replacement)\n end\n\n text\n end", "def on_call_translate(context, input, find, replace)\n input_str = on_call_string(context, input)\n find_chars = on_call_string(context, find).chars.to_a\n replace_chars = on_call_string(context, replace).chars.to_a\n replaced = input_str\n\n find_chars.each_with_index do |char, index|\n replace_with = replace_chars[index] ? replace_chars[index] : ''\n replaced = replaced.gsub(char, replace_with)\n end\n\n return replaced\n end", "def clean_latex(s)\n # Clean &\n s = s.gsub(/(?<!\\\\)\\&(?!\\\\)/, '\\\\\\&')\n\n # Clean $\n s = s.gsub(/(?<!\\\\)\\$(?!\\\\)/, '\\\\\\$')\n\n # Clean %\n s = s.gsub(/(?<!\\\\)%(?!\\\\)/, '\\\\\\%')\n\n # # Clean ~\n s = s.gsub(/\\~/, '\\\\\\textasciitilde')\n\n # # Clean >\n s = s.gsub(/\\>/, '\\\\\\textgreater')\n\n # # Clean <\n s = s.gsub(/\\</, '\\\\\\textless')\n\n s\nend", "def replace_dashes_with_hyphens(text)\t\t\t\n\ttext.gsub!(/(?<=[a-zA-Z])-(?=[a-zA-Z])/,'\\hyp ')\n\t\n\ttext.scan(/\\*\\*(.*?)\\*\\*/).each do |match|\n\t\tdamaged = match[0]\n\t\trepaired = damaged.gsub('\\hyp ','-')\n\t\ttext.gsub!(damaged,repaired)\n\tend\t\n\n\ttext.scan(/\\[\\[(.*?)\\]\\]/).each do |match|\n\t\tdamaged = match[0]\n\t\trepaired = damaged.gsub('\\hyp ','-')\n\t\ttext.gsub!(damaged,repaired)\n\tend\n\t\n\ttext.scan(/cite{(.*?)}/).each do |match|\n\t\tdamaged = match[0]\n\t\trepaired = damaged.gsub('\\hyp ','-')\n\t\ttext.gsub!(damaged,repaired)\n\tend\t\n\n\ttext\nend", "def beautify(txt)\n #txt.gsub!(/\\*(.*)\\*/, \"<span style=\\\"font-weight: bold;\\\">\\\\1</span>\")\n #txt.gsub!(/\\/(.*)\\//, \"<em>\\\\1</em>\") # Italic\n #txt.gsub!(/\\_(.*)\\_/, \"<span style=\\\"font-decoration: underline;\\\">\\\\1</span>\")\n #txt.gsub!(/\\-(.*)\\-/, \"<span style=\\\"font-decoration: line-through;\\\">\\\\1</span>\")\n # <span style=\"font-size: large;\">ok?</span>\n # <span style=\"color: #FF0000;\">ok?</span>\n txt\n end", "def update_query(find_text, replace_text, table, field)\n return \"UPDATE #{table} SET #{field} = REPLACE(#{field}, '#{find_text}', '#{replace_text}')\"\n end", "def replace_in_file(file, pattern, replacement)\n str = File.read(file)\n str.gsub!(pattern, replacement)\n File.open(file, \"w\") { |f| f.write(str) }\nend", "def regex(**mapping)\n render(STANDARD, REGEX, **mapping)\n end" ]
[ "0.72141683", "0.70457387", "0.6969422", "0.6736167", "0.6681672", "0.6660193", "0.651932", "0.64290744", "0.6422861", "0.6416157", "0.6298413", "0.6285974", "0.6206541", "0.6196962", "0.6154058", "0.61505824", "0.6142467", "0.61248857", "0.61047447", "0.6096712", "0.60720056", "0.6029132", "0.5976391", "0.5975728", "0.5971261", "0.59323514", "0.5922166", "0.58888686", "0.58873194", "0.5869257", "0.58572435", "0.583553", "0.583553", "0.58177525", "0.5801758", "0.5797182", "0.5781005", "0.5747929", "0.5718348", "0.5717508", "0.57174975", "0.57095104", "0.56955737", "0.56955737", "0.5694391", "0.56854177", "0.56500167", "0.56497943", "0.56497943", "0.56497943", "0.56497943", "0.56497943", "0.56497943", "0.56497943", "0.56497943", "0.5637169", "0.5625364", "0.55857396", "0.55702513", "0.55664504", "0.5555336", "0.5539864", "0.55176234", "0.5506879", "0.550367", "0.5490922", "0.5487373", "0.5454803", "0.54337597", "0.543168", "0.54273266", "0.5417813", "0.5406825", "0.5402963", "0.54011506", "0.5401066", "0.539668", "0.5368423", "0.53597784", "0.53551424", "0.5323294", "0.5323021", "0.5317767", "0.5301389", "0.52853405", "0.5278054", "0.52615327", "0.5260346", "0.52561986", "0.52525926", "0.52417165", "0.52351695", "0.52349544", "0.5211284", "0.5203654", "0.5202984", "0.5189248", "0.5187859", "0.5181849", "0.5166093" ]
0.6726202
4
Replace a string in text with a regex regular expression string Replaces all occurrences of the input regular expression regex string in the input content, and returns the result
def edit_text_replace_regex_with_http_info(request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_replace_regex ...' end # verify the required parameter 'request' is set if @api_client.config.client_side_validation && request.nil? fail ArgumentError, "Missing the required parameter 'request' when calling EditTextApi.edit_text_replace_regex" end # resource path local_var_path = '/convert/edit/text/replace/regex' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(request) auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ReplaceStringRegexResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_replace_regex\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def regex_replace(string, search, replace)\n return string.gsub(/#{search}/m, replace)\n end", "def modify_text(book_text, string_values)\n string_values.each do |search_string, change_string|\n regex = %r[#{search_string}]\n book_text = book_text.gsub(regex, change_string)\n end\n\n return book_text\nend", "def transform(text)\n\t\t\[email protected] do |rule|\n\t\t\t\tif rule.replace.is_a?(String)\n\t\t\t\t\ttext = text.gsub(rule.pattern, rule.replace)\n\t\t\t\telse\n\t\t\t\t\ttext = text.gsub(rule.pattern) {rule.replace.call($~)}\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn text\n\t\tend", "def rewrite!(content)\n return content unless match?\n \n content.gsub(/#{pattern}/, replacement)\n end", "def edit_text_replace_regex(request, opts = {})\n data, _status_code, _headers = edit_text_replace_regex_with_http_info(request, opts)\n data\n end", "def regex_replace_first(input, regex, replacement = NOTHING)\n input.to_s.sub(Regexp.new(regex), replacement.to_s)\n end", "def replace regex, options\n required_options options, [:with, :in]\n add \"sed -i 's/#{regex}/#{options[:with].to_s.gsub('/', '\\/').gsub(\"\\n\", \"\\\\n\")}/' #{options[:in]}\", check_string(options[:with], options[:in])\n end", "def sub_replacements text\n if REPLACEABLE_TEXT_RX.match? text\n # NOTE interpolation is faster than String#dup\n text = text.to_s\n REPLACEMENTS.each do |pattern, replacement, restore|\n # NOTE Using gsub! as optimization\n text.gsub!(pattern) { do_replacement $LAST_MATCH_INFO, replacement, restore }\n end\n end\n text\n end", "def gsub(text, regexp, with)\n total = 0\n Undo.record text do |record|\n text.index('1.0').upto(text.index('end')) do |index|\n lineend = index.lineend\n line = text.get(index, lineend)\n\n if line.gsub!(regexp, with)\n record.replace(index, lineend, line)\n total += 1\n end\n end\n end\n\n text.message \"Performed gsub on #{total} lines\"\n end", "def replace!(regexp, string)\n unless base.options[:pretend]\n content = File.read(destination)\n content.gsub!(regexp, string)\n File.open(destination, 'wb') { |file| file.write(content) }\n end\n end", "def replace(input_field, regex, into_field, replacement, options = {})\n output = options[:output] || all_fields # Overrides Cascading default\n\n input_field = fields(input_field)\n raise \"input_field must declare exactly one field, was '#{input_field}'\" unless input_field.size == 1\n into_field = fields(into_field)\n raise \"into_field must declare exactly one field, was '#{into_field}'\" unless into_field.size == 1\n\n parameters = [into_field, regex.to_s, replacement.to_s, options[:replace_all]].compact\n each(\n input_field,\n :function => Java::CascadingOperationRegex::RegexReplace.new(*parameters),\n :output => output\n )\n end", "def new_regex(old_unescaped_content, new_unescaped_content, old_regex_string)\r\n\t\t#STDERR.puts \"\"\r\n\t\t#STDERR.puts \"OldRegex\" + old_regex_string\r\n\t\t#content already content unescaped, so it only te\\:st is alreadt te:st\r\n\t\t\r\n\t\t#escape content\r\n\t\t#STDERR.puts SnortRuleContent.escape(old_unescaped_content)\r\n\t\told_escaped_content = content_escape(Regexp.escape(old_unescaped_content))\r\n\t\tnew_escaped_content = content_escape(Regexp.escape(new_unescaped_content))\r\n\t\t#STDERR.puts \"OldEC:\" + old_escaped_content\r\n\t\t#STDERR.puts \"NewEC:\" + new_escaped_content\r\n\t\r\n\t\t#fix up incorrect escape of hyphen\r\n\t\twhile(old_escaped_content.sub(\"\\\\-\",\"-\") != old_escaped_content)\r\n\t\t\told_escaped_content = old_escaped_content.sub(\"\\\\-\",\"-\") \r\n\t\tend\r\n\t\twhile(new_escaped_content.sub(\"\\\\-\",\"-\") != new_escaped_content)\r\n\t\t\tnew_escaped_content = new_escaped_content.sub(\"\\\\-\",\"-\") \r\n\t\tend\r\n\r\n\t\t#replace all occurences of old_escaped_content with new_escaped_content in old_regex_string\r\n\t\twhile(old_regex_string.sub(old_escaped_content,new_escaped_content) !=old_regex_string)\r\n\t\t\told_regex_string = old_regex_string.sub(old_escaped_content,new_escaped_content) \r\n\t\tend\r\n\t\tnew_regex_string = old_regex_string\r\n\t\t#STDERR.puts \"NewRegex\" + new_regex_string\r\n\t\treturn new_regex_string\r\n\tend", "def replace!(regexp, string, force)\n return if base.options[:pretend]\n content = File.binread(destination)\n if force || !content.include?(replacement)\n content.gsub!(regexp, string)\n File.open(destination, \"wb\") { |file| file.write(content) }\n end\n end", "def replace pattern, substitute\n if pattern.is_a? Regexp\n ArelExtensions::Nodes::RegexpReplace.new self, pattern, substitute\n else\n ArelExtensions::Nodes::Replace.new self, pattern, substitute\n end\n end", "def gsub(pattern, replace)\n lambda do |rec, acc|\n acc.collect! { |v| v.gsub(pattern, replace) }\n end\n end", "def as_regex\n Regexp.new('/' + split.map do |element|\n replace element\n end.join('/'))\n end", "def replace_encoded(str, regex)\n str.scan(regex).each do |x|\n str = str.sub(\"#{x[0]}[#{x[1]}]\", x[1] * x[0].to_i)\n end\n str\nend", "def gsub(regex, replacement)\n __gsub_perform_substitution(regex, replacement)[0]\n end", "def gsub(regex, &block)\n return StringGsubEnumerator.new(self, :gsub, regex) unless block\n __gsub_perform_block_substitution(regex, &block)\n end", "def replace_string_inside_node!(search_string_or_regex, replace_string, xn)\n if xn.text? && '' != xn.text && !xn.text.nil?\n xn.content = xn.text.gsub(search_string_or_regex, replace_string)\n else\n xn.children.each { |child_xn|\n replace_string_inside_node!(search_string_or_regex, replace_string, child_xn)\n }\n end\n end", "def replace(content)\n \n # pre-structuring\n content.gsub!( /^(\\w.*)\\n(\\w.*)/ ) { \"#{$1} #{$2}\" } # remove single line breaks between text in order to avoid false paragraph markup\n content.gsub!( /<!--/ ) { \"--\" } # replace opening html commentaries\n content.gsub!( /-->/ ) { \"--\" } # replace closing html commentaries\n \n # templates\n content.gsub!( /\\{\\{Zitat\\|(.*)\\|.*\\}\\}\\s*$\\n/ ) { \"\\{p\\}\\\"#{$1}\\\"\\{/p\\}\\n\" } # citation\n content.gsub!( /\\{\\{.*(Finale Version).*\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1}</font>{/status}<br>\" } # final version\n content.gsub!( /\\{\\{Vorlage:(Dokument.*)\\n*(.*)\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1} #{$2}</font>{/status}<br>\" } # document status\n content.gsub!( /\\{\\{.*\\}\\} *$/ ) { '' } # remove single line templates\n content.gsub!( /\\{\\{.*\\n?.*\\}\\} *$/ ) { '' } # remove all remaining templates\n \n # tags\n content.gsub!( /<nowiki>(.*?)<\\/nowiki>/ ) { \"<pre>#{$1}</pre>\" }\n content.gsub!( /^ +(.*)/ ) { \"<pre>#{$1}</pre>\" }\n\n # special markup of qualidative data analysis\n content = content + \"\\n\\n{!end}\"\n \n # categories\n content.gsub!( /\\[\\[Kategorie:(.*?)\\]\\]/i ) { \"{category}<font color=\\\"#FF0000\\\">Kategorie:#{$1}</font>{/category}<br>\" }\n \n # images\n content.gsub!( /\\[\\[Bild:(.*?)\\]\\]/i ) { \"{image}Bild:#{$1.gsub!(/.*\\|/,'')}{/image}<br>\"} # Bild:lpscreen.jpg|thumb|Bereichseite des Landesportals\n\n # bold\n content.gsub!(/'''(.*?)'''/) {\"<strong>#{$1}</strong>\"}\n content.gsub!(/'''(.*?)$/) {\"<strong>#{$1}</strong>\"}\n\n # italics\n content.gsub!(/''(.*?)''/) {\"<em>#{$1}</em>\"}\n content.gsub!(/''(.*?)$/) {\"<em>#{$1}</em>\"}\n\n # headings\n 6.downto(1) { |i| content.gsub!( /^={#{i}}(.*?)={#{i}} *$/ ) { \"<h#{i}>\\{h>#{i}\\}#{$1}\\{/h>#{i}\\}</h#{i}>\" } }\n \n # links, internal\n content.gsub!( /\\[\\[([^\\[\\n]*?)\\| *(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[\\[(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n\n # links, external\n content.gsub!( /\\[([^\\[\\n]*?)\\| *(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n \n # lists\n content.gsub!(/^:+/,'') # remove forced indenting\n content.gsub!( /^((?:\\*.*\\n+)+)/ ) { \"\\{l>ul\\}<ul>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^\\*/,'')}</li>\\n\" }.join}</ul>\\{/l>ul\\}<br>\\n\" } # first level ul\n content.gsub!( /^((?:#.*\\n+)+)/ ) { \"\\{l>ol\\}<ol>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^#/,'')}</li>\\n\" }.join}</ol>\\{/l>ol\\}<br>\\n\" } # first level ol\n content.gsub!( /<li>\\s*<\\/li>\\n/ ) { '' } # remove empty list entries (this may occur if first-level wiki-lists are entered with \\n\\n; they look like a single list when, in fact, they are but multiple single lists)\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # second level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # second level ol\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # third level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # third level ol\n\n # tables\n # the table conversion barely works, cf. http://johbuc6.coconia.net/doku.php/mediawiki2html_machine/code?DokuWiki=7c542b97df2bc0f82fec0f4875265a20 for an implementation in PHP\n content.gsub!( /^\\{\\|(.*)/ ) { \"\\{table\\}\\n<table #{$1}>\" }\n content.gsub!( /\\|\\}/ ) { \"</table>\\n\\{/table\\}\" }\n content.gsub!( /^\\|-(.*)/ ) { \"<tr>#{$1}\" }\n content.gsub!( /^!(.*?)\\|(.*)/ ) { \"<th #{$1}>#{$2}</th>\" } # table header with piped markup\n content.gsub!( /^!(.*)/ ) { \"<th>#{$1}</th>\" } # table header without piped markup\n content.gsub!( /^\\|(.*?)\\|(.*)/ ) { \"<td #{$1}>#{$2}\" } # table data with piped markup\n content.gsub!( /^\\|(.*)/ ) { \"<td>#{$1}\" } # table data without piped markup\n \n # line breaks\n content.gsub!( /(^(?:\\w|<strong|<em|<a|\\\").*)\\n\\s*\\n/ ) {\"<p>\\{p\\}#{$1}\\{/p\\}</p>\\n\"}\n \n # special markup of qualidative data analysis\n content.gsub!( /(\\{id\\}.*\\{\\/title\\})/ ) { \"<p><strong><em>#{$1.gsub(/_/,' ')}</em></strong></p>\" }\n \n# //$html = nl2br($html);\n# \t// line breaks\n# \t$html = preg_replace('/[\\n\\r]{4}/',\"<br/><br/>\",$html);\n# \t$html = preg_replace('/[\\n\\r]{2}/',\"<br/>\",$html);\n\n# \t$html = preg_replace('/[>]<br\\/>[<]/',\"><\",$html);\n \n# // allowed tags\n# \t$html = preg_replace('/&lt;(\\/?)(small|sup|sub|u)&gt;/','<${1}${2}>',$html);\n#\n# \t$html = preg_replace('/\\n*&lt;br *\\/?&gt;\\n*/',\"\\n\",$html);\n# \t$html = preg_replace('/&lt;(\\/?)(math|pre|code|nowiki)&gt;/','<${1}pre>',$html);\n# \t$html = preg_replace('/&lt;!--/','<!--',$html);\n# \t$html = preg_replace('/--&gt;/',' -->',$html);\n# \n return content\n\nend", "def sub(pattern, replacement)\n replacement = Maglev::Type.coerce_to(replacement, String, :to_str)\n regex = self.__get_pattern(pattern, true)\n\n # If pattern is a string, then do NOT interpret regex special characters.\n # stores into caller's $~\n if (match = regex.__match_vcglobals(self, 0x30))\n __replace_match_with(match, replacement)\n else\n dup\n end\n # r.taint if replacement.tainted? || self.tainted?\n end", "def gsub_file(path, regexp, *args, &block)\n #path = destination_path(relative_destination)\n content = File.read(path)\n check_for = args.first || yield('')\n regex = Regexp.new(regexp.source + Regexp.escape(check_for))\n return if content =~ regex # if we can match the text and its leadin regex, don't add again\n content = content.gsub(regexp, *args, &block)\n File.open(path, 'wb') { |file| file.write(content) }\n end", "def recursive_gsub(search_txt, txt_to_replace)\n res = self\n res = res.gsub(search_txt, txt_to_replace).recursive_gsub(search_txt, txt_to_replace) if res.include?(search_txt)\n res\n end", "def scrub_text(text)\n TEXT_GSUBS.inject(text) { |memo, sub| memo = memo.gsub(*sub) }\n end", "def replace_string_in_file(filename, regex, replacement = '')\n content = File.read(filename).gsub(/#{regex}$/i, replacement)\n File.open(filename, 'wb') { |file| file.write(content) }\n end", "def apply!(str)\n str.gsub! regexp, ''\n end", "def replace!(destination, regexp, string)\n content = File.binread(destination)\n content.gsub!(regexp, string)\n File.open(destination, 'wb') { |file| file.write(content) }\nend", "def replace_placeholders(text)\n matches = text.scan(/\\{([a-z_]+)\\}/).flatten\n\n return text unless matches.any?\n\n replaced = text.dup\n\n matches.each do |match|\n value = @filing_history.description_values.dig(match.to_sym)\n replaced.sub!(/{#{match}}/, value)\n end\n\n replaced\n end", "def replace_word_in_text(text, orignal_word, replaced_word)\n regex = %r[\\b#{orignal_word}\\b]\n text.gsub(regex, replaced_word)\nend", "def replace_all(source_text, replacement)\n case\n # For simple cases we just replace runs to try and keep formatting/layout of source\n when replacement.is_a?(String)\n @main_doc.replace_all_with_text(source_text, replacement)\n when (replacement.is_a?(Magick::Image) or replacement.is_a?(Magick::ImageList))\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n runs.each { |r| r.replace_with_run_fragment(create_image_run_fragment(replacement)) }\n when replacement.is_a?(Hash)\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n runs.each { |r| r.replace_with_body_fragments(create_body_fragments(replacement, {:create_table => true})) }\n when replacement.is_a?(Nokogiri::XML::Element)\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n if replacement.name == \"w:tbl\"\n runs.each { |r| r.replace_with_body_fragments(create_body_fragments(replacement)) }\n else\n runs.each { |r| r.replace_with_run_fragment(create_body_fragments(replacement)) }\n end\n else\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n runs.each { |r| r.replace_with_body_fragments(create_body_fragments(replacement)) }\n end\n end", "def escape(text)\n replacements.inject(text.to_s) do |corpus, (pattern, replacement)|\n corpus.gsub(pattern, replacement)\n end\n end", "def gsub(pattern, replacement = nil, &blk)\n if block_given?\n @string.gsub(pattern, &blk)\n else\n @string.gsub(pattern, replacement)\n end\n end", "def gsub(pattern, replacement = nil, &blk)\n if block_given?\n @string.gsub(pattern, &blk)\n else\n @string.gsub(pattern, replacement)\n end\n end", "def apply_replacements(word)\n @replacements.each do |pattern, target|\n word.gsub!(pattern, target)\n end\n \n word\n end", "def escape_re(str)\n str.gsub(@re_chars) {|c| @re_esc + c}\n end", "def gsub(value, context, parameters)\n # Try to find a full replacement match - if found, return the actual value of that reference.\n return get_reference_value($1, context, parameters) if value.match(REPLACE_REGEX)\n # No full match, substitute all references with their string representations\n value.gsub(INTERPOLATE_REGEX) { get_reference_value($1, context, parameters) }\n end", "def gsub!(*args, &block)\n str = self.gsub(*args, &block)\n if str != self\n self.replace(str)\n self\n else\n nil\n end\n end", "def gsub(pat, rep)\n inject(self.class.new) { |res, fn| res << fn.gsub(pat, rep) }\n end", "def gsub(*)\n self\n end", "def post_process_text(s) \n # extract math\n math, arrays = [], []\n s.scan(/\\$([^$]+)\\$/) {|m| math << m } # $$\n s.scan(/\\\\\\[([^$]+)\\\\\\]/) {|m| arrays << m } # \\[ \\]\n # citations\n s = replace_citations(s)\n # listings, algorithms, tables\n s = replace_listings(s)\n # custom \n s = replace_custom_refs(s)\n # texttt\n s = replace_texttt(s)\n # emph\n s = replace_emph(s)\n # textbf\n s = replace_bf(s)\n # urls\n s = replace_urls(s)\n # footnotes\n s = replace_footnotes(s)\n # paragrams\n s = replace_paragraphs(s)\n # chapter refs\n s = replace_chapter_refs(s)\n # section refs\n s = remove_section_refs(s)\n # replace markboth with nothing\n s = replace_markboth(s)\n # remove hypenation suggestions\n s = remove_hyph_suggestions(s)\n # umlats etc\n s = character_processing(s)\n # replace \\% with %\n s = s.gsub(\"\\\\%\", \"\\%\")\n # replace \"\\ \" with a space\n s = s.gsub(\"\\\\ \", \" \")\n # replace \\\" and \\' with nothing\n s = s.gsub(\"\\\\\\\"\", \"\")\n s = s.gsub(\"\\\\\\'\", \"\")\n # replace ~ with space\n s = s.gsub(\"~\", \" \")\n # replace \\$ with $ (testing algorithms)\n s = s.gsub(\"\\\\$\", \"$\")\n # replace \\_ with _ (testing algorithms)\n s = s.gsub(\"\\\\_\", \"_\") \n # replace \\# with # (appendix)\n s = s.gsub(\"\\\\#\", \"#\")\n # replace \\{ with { (appendix)\n s = s.gsub(\"\\\\{\", \"{\")\n # replace \\} with } (appendix)\n s = s.gsub(\"\\\\}\", \"}\") \n # replace \\\\ with <br /> (appendix, de)\n s = s.gsub(\"\\\\\\\\\", \"<br />\") \n # replace \\Latex with LaTex\n s = s.gsub(\"\\\\LaTeX\", \"LaTex\") \n # replace \\copyright with html copyright\n s = s.gsub(\"\\\\copyright\", \"&copy;\")\n # replace \\mybookdate\\ with publication date 2011\n s = s.gsub(\"\\\\mybookdate\", DATE)\n # replace \\mybookauthor with the author ame\n s = s.gsub(\"\\\\mybookauthor\", \"Jason Brownlee\")\n # replace \\mybooktitle with the book title\n s = s.gsub(\"\\\\mybooktitle\", TITLE)\n # replace \\mybooksubtitle with the book subtitle\n s = s.gsub(\"\\\\mybooksubtitle\", SUBTITLE)\n # finally switch ` for ' (late in the subs)\n s = s.gsub(\"`\", \"'\")\n \n # put the math back\n if !math.empty?\n index = 0\n s = s.gsub(/\\$([^$]+)\\$/) do |m|\n index += 1\n \"$#{math[index - 1]}$\"\n end\n end \n if !arrays.empty?\n index = 0\n s = s.gsub(/\\\\\\[([^$]+)\\\\\\]/) do |m|\n index += 1\n \"\\\\[#{arrays[index - 1]}\\\\]\"\n end\n end\n return s\nend", "def process_text text\n newtext = text.gsub(/if/, 'IF')\n\n 30.times { |i|\n newtext.gsub!(/for/, 'FOR')\n newtext.gsub!(/while/, 'WHILE')\n newtext.gsub!(/switch/, 'SWITCH')\n newtext.gsub!(/case/, 'CASE')\n newtext.gsub!(/goto/, 'GOTO')\n newtext.gsub!(/struct/, 'STRUCT')\n newtext.gsub!(/int/, 'INT')\n newtext.gsub!(/char/, 'CHAR')\n newtext.gsub!(/return/, 'RETURN')\n }\n\n return newtext\nend", "def sub(text, regexp, with)\n linestart = text.index('insert linestart')\n lineend = linestart.lineend\n line = text.get(linestart, lineend)\n\n text.replace(linestart, lineend, line) if line.sub!(regexp, with)\n end", "def replace_contents!(pattern, replace_with)\n\t\twrite contents.gsub(pattern, replace_with)\n\tend", "def replace_contents!(pattern, replace_with)\n\t\twrite contents.gsub(pattern, replace_with)\n\tend", "def substText(text,bodyStack)\n if(text.kind_of?(Text)) \n rawtext = text.string ;\n elsif(text.kind_of?(Attribute))\n rawtext = text.value ;\n elsif(text.kind_of?(String))\n rawtext = text ;\n else\n return ;\n end\n\n result = rawtext.clone() ;\n\n# result.gsub!(ArgFormat) {|dat| \n# getSubstText($1,bodyStack,dat) ;\n# }\n substTextBody(result,bodyStack) ;\n\n return result ;\n end", "def gsub_file(path, regexp, *args, &block)\n content = File.read(path).gsub(regexp, *args, &block)\n File.open(path, 'wb') { |file| file.write(content) }\nend", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def pattern2regex(pattern); end", "def format!\n substitutions.each { |s| sub_string.gsub!(match(s), replace(s)) }\n sub_string\n end", "def gsub!(pat, rep)\n each_with_index { |fn, i| self[i] = fn.gsub(pat,rep) }\n self\n end", "def mreplace regexp, &block\n matches = []\n offset = 0\n while self[offset..-1] =~ regexp\n matches << [offset, $~]\n offset += $~.end($~.size - 1)\n end\n raise 'unmatched' if matches.empty?\n\n matches.reverse.each do |offset, match|\n slice = self[offset...-1]\n send = (1...match.size).map {|i| slice[match.begin(i)...match.end(i)]}\n if send.length == 1\n recv = block.call(send.first)\n self[offset+match.begin(1)...offset+match.end(1)] = recv\n else\n recv = block.call(*send)\n next unless recv\n (1...match.size).map {|i| [match.begin(i), match.end(i), i-1]}.sort.\n reverse.each do |start, fin, i|\n self[offset+start...offset+fin] = recv[i]\n end\n end\n end\n self\n end", "def url_replace(url)\n URL_SUBSTITUTION.each do |pattern, replacement|\n if url.match(pattern)\n return url.gsub(Regexp.new(\".*#{pattern}.*\",\"uxim\"), replacement)\n end\n end\n return \"[url]\"\n end", "def replace(line)\n return line if line !~ /\\{\\{Gc/\n return line if line =~ /link=none/ || line =~ /dis=false/ || line =~ /dis=true/\n return line.gsub!(/\\{\\{[Gg]c|mod=(\\S+)\\|/, '{{Gc|mod=\\1|dis=false|')\nend", "def prepare_for_regexp(output_str)\n split_lines(output_str).map do |str|\n Regexp.new(Regexp.escape(str), Regexp::EXTENDED)\n end\n end", "def replace_placeholders(string, placeholder_regex, &block)\n string.gsub(/%{(#{placeholder_regex})}/) do |arg|\n yield($~[1]) || arg\n end\n end", "def make_regexp\n @intent = self.intent\n regexp = self.pattern.dup.downcase\n words = regexp.split(\" \")\n words.each do |word|\n if word.include? '/'\n regexp = regexp.gsub(word,\"(#{word})\")\n\n end\n\n end\n regexp = regexp.gsub('/',\"|\")\n regexp = regexp.gsub('^ ','.{0,60}').gsub(' ^','.{0,60}').gsub(' *','.{1,60}').gsub('* ','.{1,60}').gsub('^','.{1,60}').gsub(' [','.{0,60}[')\n regexp = regexp.gsub(' .{0,60}','.{0,60}')\n regexp = regexp.gsub(' .{1,60}','.{1,60}')\n regexp = '.{0,60}' + regexp + '.{0,60}'\n self.regexp = regexp\n chunks = self.pattern.split(' ')\n chunks.each do |ch|\n result= Regexp.new(/\\[.{0,12}\\]/) =~ ch\n if(result==0)\n set = WordSet.find_by_keyword(ch[1..-2])\n str = '(' + set.words.join('|') + ')'\n regexp = self.regexp.gsub(ch,str)\n self.regexp = regexp\n end\n end\n self.save\n end", "def gsub_functions(text)\n\tlast_function_end = 0\n\n\tresult = text\n\tadjust = 0\n\n\tscan_ignore_comments(/((\\w+)::)?(\\w+)\\s*\\(([^\\)]*?)\\)\\s*\\{/m, text) do |match|\n\t\toffset = match.pre_match.length\n\n\t\tif offset > last_function_end\n\t\t\tclass_name = match[2]\n\t\t\tname = match[3]\n\t\t\tend_offset = find_block_end(text, offset) + 1\n\n\t\t\tblock = text[offset, end_offset - offset]\n\n\t\t\t# Get replacement text.\n\n\t\t\treplacement = yield class_name, name, block\n\n\t\t\t# Substitute old text for new text:\n\n\t\t\tbefore_text = result[0, offset + adjust]\n\t\t\tafter_text = result[end_offset + adjust,\n\t\t\t result.length]\n\t\t\tresult = before_text + replacement + after_text\n\t\t\tadjust += replacement.length - block.length\n\n\t\t\t# Save end position of function so that we won't\n\t\t\t# change anything in this block again.\n\n\t\t\tlast_function_end = end_offset\n\t\tend\n\tend\n\n\tresult\nend", "def search_match(regex, replace, command, method)\n\n #convert regex to a Regexp object (if not already is one) and store it in exp.\n exp = Regexp.new(regex)\n\n #loop through contents and do the appropriate operation depending on 'command' and 'method'\n new_contents = []\n\n contents.each do |line|\n if line.match(exp)\n self.file_edited = true\n case\n when command == 'r'\n new_contents << ((method == 1) ? replace : line.gsub!(exp, replace))\n when command == 'd'\n if method == 2\n new_contents << line.gsub!(exp, \"\")\n end\n when command == 'i'\n new_contents << line\n new_contents << replace unless method == 2\n end\n else\n new_contents << line\n end\n end\n if command == 'i' && method == 2 && ! file_edited\n new_contents << replace\n self.file_edited = true\n end\n\n self.contents = new_contents\n end", "def justLikeSed(file, text_to_replace, text_to_put_in_place)\n text = File.read(file)\n File.open(file, 'w+'){|f| f << text.gsub(text_to_replace, text_to_put_in_place)}\n end", "def gsub!(pat, rep)\n each_with_index { |fn, i| self[i] = fn.gsub(pat,rep) }\n self\n end", "def escape input, regexp, map\n input.gsub(regexp) { | char | map[char] || char }\n end", "def replace_text_nodes_matching(pattern)\n return doc if project.nil?\n\n search_text_nodes(doc).each do |node|\n content = node.to_html\n\n next unless content.match(pattern)\n next if ignored_ancestry?(node)\n\n html = yield content\n\n next if html == content\n\n node.replace(html)\n end\n\n doc\n end", "def replace_contents!(pattern, with_text)\n entries.each do |entry|\n entry.replace_contents!(pattern, with_text) unless entry.dir?\n end\n end", "def rsub(pattern, replacement)\n if i = rindex(pattern) # rubocop:disable Lint/AssignmentInCondition\n s = @string.dup\n s[i] = replacement\n self.class.new s\n else\n self\n end\n end", "def replace_text(text)\n @txt .set_editable(true) # .freeze\n @txt .buffer .set_text(\"\")\n# hdr, value = text .split(\"\\n\\n\", 2)\n# hdr .to_s .each_line{|line|\n# case line\n# when /^Subject:/ ;color = BLUE\n# when /^X-SC-Subject:/ ;color = BLUE\n# when /^From:/ ;color = PURPLE\n# #when /^To:|Cc:/ ;color = ORANGE\n# #when /^Date:/ ;color = GREEN\n# when /^X-SC-(Time|Day):/ ;color = RED\n# else ;color = BLACK\n# end\n# @txt .insert(nil, color, nil, line) if line != ''\n# }\n# @txt .insert(nil, RED, WHITE, hdr .to_s)\n# @txt .insert(nil, BLACK, nil, \"\\n\\n\" + value .to_s)\n\n @txt .buffer .insert(@txt.buffer.start_iter, MhcKconv::todisp(text))\n @txt .set_editable(@text_editable) #.thaw\n end", "def modify_content(source, content, replace_value)\n file = File.read(source)\n replace = file.gsub(/#{content}/, replace_value)\n File.open(source, \"w\"){|f|\n f.puts replace \n }\n end", "def gsubs(replacements)\n str = self.dup\n replacements.each do |r|\n str = str.gsub(r[0],r[1])\n end\n str\n end", "def sub!(pattern, replacement = T.unsafe(nil), &block); end", "def gsub!(pat, rep)\n each_with_index { |fn, i| self[i] = fn.gsub(pat, rep) }\n self\n end", "def replace(ast, pattern, &replacement)\n buffer = Parser::Source::Buffer.new('replacement')\n buffer.source = ast.loc.expression.source\n to_replace = search(ast, pattern)\n types = to_replace.grep(Parser::AST::Node).map(&:type).uniq\n rewriter = Rewriter.new\n rewriter.buffer = buffer\n rewriter.search = pattern\n rewriter.replacement = replacement\n rewriter.replace_on(*types)\n rewriter.rewrite(buffer, ast)\n end", "def initialize find, replace\n @regexp = Regexp.new(\"^#{find}$\")\n @replace = replace\n end", "def search_file_replace(regex, replace)\n search_match(regex, replace, 'r', 2)\n end", "def sed_hack_on_file(file_name, match_regex, replace_with)\n original_content = File.read(file_name)\n new_content = original_content.gsub(match_regex, replace_with)\n if new_content != original_content\n File.open(file_name, 'w') { |file| file.write(new_content) }\n else\n puts \"No change to file during sed hackery...\"\n end\nend", "def sub!(pattern, replacement)\n regex = self.__get_pattern(pattern, true)\n # stores into caller's $~\n if match = regex.__match_vcglobals(self, 0x30)\n replace(__replace_match_with(match, replacement))\n # self.taint if replacement.tainted?\n self\n else\n nil\n end\n end", "def match_string_to_regexp(str)\n #str = str.split(/(\\(\\(.*?\\)\\))(?!\\))/).map{ |x|\n # x =~ /\\A\\(\\((.*)\\)\\)\\Z/ ? $1 : Regexp.escape(x)\n #}.join\n #str = str.gsub(/\\\\\\s+/, '\\s+')\n #Regexp.new(str, Regexp::IGNORECASE)\n\n #str = str.split(/([#$]\\(.*?\\))/).map{ |x|\n # x =~ /\\A[#$]\\((.*)\\)\\Z/ ? ($1.start_with?('#') ? \"(#{$1})\" : $1 ) : Regexp.escape(x)\n #}.join\n #str = str.gsub(/\\\\\\s+/, '\\s+')\n #Regexp.new(str, Regexp::IGNORECASE)\n\n$stderr.puts \"HERE!!!!!!\"\n\n str = str.split(PATTERN).map{ |x|\n case x\n when /\\A\\(\\((.*)\\)\\)\\Z/\n $1\n when /\\A[#$]\\((.*)\\)\\Z/\n $1.start_with?('#') ? \"(#{$1})\" : $1\n else\n Regexp.escape(x)\n end\n }.join\n\n str = str.gsub(/\\\\\\s+/, '\\s+')\n\n Regexp.new(str, Regexp::IGNORECASE)\n\n #rexps = []\n #str = str.gsub(/\\(\\((.*?)\\)\\)/) do |m|\n # rexps << '(' + $1 + ')'\n # \"\\0\"\n #end\n #str = Regexp.escape(str)\n #rexps.each do |r|\n # str = str.sub(\"\\0\", r)\n #end\n #str = str.gsub(/(\\\\\\ )+/, '\\s+')\n #Regexp.new(str, Regexp::IGNORECASE)\n end", "def pig_it(text)\n text.gsub(/\\b([a-z0-9]?)([a-z0-9]+)\\b/i, '\\2\\1ay')\n # text.gsub(/\\b([a-z0-9])([a-z0-9]+)*\\b/i, '\\2\\1ay')\n # text.gsub(/([a-z0-9])([a-z0-9]+)*/i, '\\2\\1ay')\nend", "def replace_pattern\n id = Readline.readline(\"ID of task to perform replace: \").to_i\n old_pattern = Readline.readline('replace : ').chomp\n new_pattern = Readline.readline('with : ').chomp\n ok = ReplacePattern.new(id, old_pattern, new_pattern).execute\n puts \"No such task\" if !ok\n end", "def subs(input, the_story)\n subbed = the_story.gsub(\"lion\", input).gsub(\"r\", \"rrr\")\n return subbed\nend", "def regex(pattern)\n Regexp.new pattern.regex\n end", "def format_text(text)\n # Reflow\n reformatted = text.gsub(/\\s*\\n\\s*\\n+/, '$#$').gsub(/\\s*\\n\\s*/, ' ').gsub('$#$', \"\\n\\n\")\n return reformatted\n end", "def build_regex(string, params = nil)\n result = build_regex_str(string, params)\n Regexp.new \"^#{result}$\"\n end", "def filter_text(text)\n text = text.to_s\n text.gsub('&', '&amp;')\n text.gsub('\\'', '&#039;')\n text.gsub('\"', '&quot;')\n text.gsub('<', '&lt;')\n text.gsub('>', '&gt;')\n text\n end", "def regex\n Regexp.new(@str)\n end", "def sanitize_regexp(value)\n original = value.dup\n\n SANITIZE_REGEXP.each do |pattern, replacement|\n value.gsub!(pattern, replacement)\n end\n\n value2 = ''\n group_index = 0\n value.scan(/((?:[^\\\\(]+|\\\\[^\\d])+)|(\\\\\\d+)|(\\(\\??)/m) do |content, backref, capture|\n value2 << if capture == '('\n \"(?<_#{group_index += 1}>\"\n elsif backref\n \"\\\\k<_#{backref[/\\d+/]}>\"\n else\n (content || capture)\n end\n end\n\n Regexp.new(value2)\n rescue RegexpError => ex\n if ex.message =~ /^invalid multibyte escape:/\n begin\n /#{value2.force_encoding(Encoding::BINARY)}/n\n rescue RegexpError => ex\n error(ex, original, value2)\n end\n else\n error(ex, original, value2)\n end\n end", "def tex_escape(text)\n replacements = {\n '&' => '\\&',\n '%' => '\\%',\n '$' => '\\$',\n '#' => '\\#',\n '_' => '\\_',\n '{' => '\\{',\n '}' => '\\}',\n '~' => '\\textasciitilde{}',\n '^' => '\\^{}',\n '\\\\' => '\\textbackslash{}',\n '<' => '\\textless',\n '>' => '\\textgreater',\n }\n\n replacements.each do |search, escaped_replacement|\n text = text.gsub(search, escaped_replacement)\n end\n\n text\n end", "def on_call_translate(context, input, find, replace)\n input_str = on_call_string(context, input)\n find_chars = on_call_string(context, find).chars.to_a\n replace_chars = on_call_string(context, replace).chars.to_a\n replaced = input_str\n\n find_chars.each_with_index do |char, index|\n replace_with = replace_chars[index] ? replace_chars[index] : ''\n replaced = replaced.gsub(char, replace_with)\n end\n\n return replaced\n end", "def clean_latex(s)\n # Clean &\n s = s.gsub(/(?<!\\\\)\\&(?!\\\\)/, '\\\\\\&')\n\n # Clean $\n s = s.gsub(/(?<!\\\\)\\$(?!\\\\)/, '\\\\\\$')\n\n # Clean %\n s = s.gsub(/(?<!\\\\)%(?!\\\\)/, '\\\\\\%')\n\n # # Clean ~\n s = s.gsub(/\\~/, '\\\\\\textasciitilde')\n\n # # Clean >\n s = s.gsub(/\\>/, '\\\\\\textgreater')\n\n # # Clean <\n s = s.gsub(/\\</, '\\\\\\textless')\n\n s\nend", "def replace_dashes_with_hyphens(text)\t\t\t\n\ttext.gsub!(/(?<=[a-zA-Z])-(?=[a-zA-Z])/,'\\hyp ')\n\t\n\ttext.scan(/\\*\\*(.*?)\\*\\*/).each do |match|\n\t\tdamaged = match[0]\n\t\trepaired = damaged.gsub('\\hyp ','-')\n\t\ttext.gsub!(damaged,repaired)\n\tend\t\n\n\ttext.scan(/\\[\\[(.*?)\\]\\]/).each do |match|\n\t\tdamaged = match[0]\n\t\trepaired = damaged.gsub('\\hyp ','-')\n\t\ttext.gsub!(damaged,repaired)\n\tend\n\t\n\ttext.scan(/cite{(.*?)}/).each do |match|\n\t\tdamaged = match[0]\n\t\trepaired = damaged.gsub('\\hyp ','-')\n\t\ttext.gsub!(damaged,repaired)\n\tend\t\n\n\ttext\nend", "def update_query(find_text, replace_text, table, field)\n return \"UPDATE #{table} SET #{field} = REPLACE(#{field}, '#{find_text}', '#{replace_text}')\"\n end", "def beautify(txt)\n #txt.gsub!(/\\*(.*)\\*/, \"<span style=\\\"font-weight: bold;\\\">\\\\1</span>\")\n #txt.gsub!(/\\/(.*)\\//, \"<em>\\\\1</em>\") # Italic\n #txt.gsub!(/\\_(.*)\\_/, \"<span style=\\\"font-decoration: underline;\\\">\\\\1</span>\")\n #txt.gsub!(/\\-(.*)\\-/, \"<span style=\\\"font-decoration: line-through;\\\">\\\\1</span>\")\n # <span style=\"font-size: large;\">ok?</span>\n # <span style=\"color: #FF0000;\">ok?</span>\n txt\n end", "def replace_in_file(file, pattern, replacement)\n str = File.read(file)\n str.gsub!(pattern, replacement)\n File.open(file, \"w\") { |f| f.write(str) }\nend", "def regex(**mapping)\n render(STANDARD, REGEX, **mapping)\n end" ]
[ "0.7216716", "0.7045514", "0.6968202", "0.67358905", "0.67265934", "0.6683212", "0.66611296", "0.6518081", "0.64273727", "0.64228755", "0.64181393", "0.62994695", "0.6286472", "0.6207523", "0.6197219", "0.6154564", "0.6150717", "0.61427104", "0.6124004", "0.61055475", "0.60955924", "0.60729015", "0.6027127", "0.59760165", "0.5973612", "0.59717155", "0.59322804", "0.59224683", "0.58880806", "0.58874726", "0.58690095", "0.5855637", "0.58355", "0.58355", "0.58181137", "0.5801518", "0.5798542", "0.57818574", "0.57475555", "0.5717292", "0.57162553", "0.5715806", "0.57076937", "0.5695398", "0.5695398", "0.5693388", "0.56843984", "0.56493676", "0.56493676", "0.56493676", "0.56493676", "0.56493676", "0.56493676", "0.56493676", "0.56493676", "0.5649063", "0.56385195", "0.56252974", "0.5584775", "0.5567691", "0.5555939", "0.5539261", "0.5517704", "0.5505656", "0.5502504", "0.5490797", "0.5487573", "0.54546684", "0.5433937", "0.54300827", "0.5426422", "0.54186296", "0.5404591", "0.5403105", "0.5401958", "0.54002744", "0.5396554", "0.5369513", "0.5358892", "0.53562707", "0.5324197", "0.53236586", "0.53176135", "0.52999014", "0.5286679", "0.52783436", "0.5260814", "0.52576244", "0.5256379", "0.5250297", "0.5240841", "0.5235751", "0.52334595", "0.5213339", "0.520385", "0.52015805", "0.5189553", "0.51875585", "0.51825166", "0.5164784" ]
0.55705154
59
Replace a string in text with another string value Replaces all occurrences of the input string in the input content, and returns the result
def edit_text_replace_simple(request, opts = {}) data, _status_code, _headers = edit_text_replace_simple_with_http_info(request, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modify_text(book_text, string_values)\n string_values.each do |search_string, change_string|\n regex = %r[#{search_string}]\n book_text = book_text.gsub(regex, change_string)\n end\n\n return book_text\nend", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def sub_replacements text\n if REPLACEABLE_TEXT_RX.match? text\n # NOTE interpolation is faster than String#dup\n text = text.to_s\n REPLACEMENTS.each do |pattern, replacement, restore|\n # NOTE Using gsub! as optimization\n text.gsub!(pattern) { do_replacement $LAST_MATCH_INFO, replacement, restore }\n end\n end\n text\n end", "def regex_replace(string, search, replace)\n return string.gsub(/#{search}/m, replace)\n end", "def replace_string_inside_node!(search_string_or_regex, replace_string, xn)\n if xn.text? && '' != xn.text && !xn.text.nil?\n xn.content = xn.text.gsub(search_string_or_regex, replace_string)\n else\n xn.children.each { |child_xn|\n replace_string_inside_node!(search_string_or_regex, replace_string, child_xn)\n }\n end\n end", "def rewrite!(content)\n return content unless match?\n \n content.gsub(/#{pattern}/, replacement)\n end", "def replace_placeholders(text)\n matches = text.scan(/\\{([a-z_]+)\\}/).flatten\n\n return text unless matches.any?\n\n replaced = text.dup\n\n matches.each do |match|\n value = @filing_history.description_values.dig(match.to_sym)\n replaced.sub!(/{#{match}}/, value)\n end\n\n replaced\n end", "def gsub(value, context, parameters)\n # Try to find a full replacement match - if found, return the actual value of that reference.\n return get_reference_value($1, context, parameters) if value.match(REPLACE_REGEX)\n # No full match, substitute all references with their string representations\n value.gsub(INTERPOLATE_REGEX) { get_reference_value($1, context, parameters) }\n end", "def replace_word_in_text(text, orignal_word, replaced_word)\n regex = %r[\\b#{orignal_word}\\b]\n text.gsub(regex, replaced_word)\nend", "def str_replace(orig, rep, with)\n s = orig\n while s.include?(rep)\n s.sub! rep, with\n end\n orig\n end", "def modify_content(source, content, replace_value)\n file = File.read(source)\n replace = file.gsub(/#{content}/, replace_value)\n File.open(source, \"w\"){|f|\n f.puts replace \n }\n end", "def on_call_translate(context, input, find, replace)\n input_str = on_call_string(context, input)\n find_chars = on_call_string(context, find).chars.to_a\n replace_chars = on_call_string(context, replace).chars.to_a\n replaced = input_str\n\n find_chars.each_with_index do |char, index|\n replace_with = replace_chars[index] ? replace_chars[index] : ''\n replaced = replaced.gsub(char, replace_with)\n end\n\n return replaced\n end", "def format!\n substitutions.each { |s| sub_string.gsub!(match(s), replace(s)) }\n sub_string\n end", "def apply_replacements(word)\n @replacements.each do |pattern, target|\n word.gsub!(pattern, target)\n end\n \n word\n end", "def replace_word(template, replaced_word, new_word)\r\n template.gsub(/#{replaced_word}/, new_word)\r\n end", "def replace_contents!(pattern, replace_with)\n\t\twrite contents.gsub(pattern, replace_with)\n\tend", "def replace_contents!(pattern, replace_with)\n\t\twrite contents.gsub(pattern, replace_with)\n\tend", "def justLikeSed(file, text_to_replace, text_to_put_in_place)\n text = File.read(file)\n File.open(file, 'w+'){|f| f << text.gsub(text_to_replace, text_to_put_in_place)}\n end", "def replace(input, string, replacement = T.unsafe(nil)); end", "def replace!(regexp, string, force)\n return if base.options[:pretend]\n content = File.binread(destination)\n if force || !content.include?(replacement)\n content.gsub!(regexp, string)\n File.open(destination, \"wb\") { |file| file.write(content) }\n end\n end", "def update_query(find_text, replace_text, table, field)\n return \"UPDATE #{table} SET #{field} = REPLACE(#{field}, '#{find_text}', '#{replace_text}')\"\n end", "def replace_contents!(pattern, with_text)\n entries.each do |entry|\n entry.replace_contents!(pattern, with_text) unless entry.dir?\n end\n end", "def str_replace(filepath, search_str, replace_str)\n File.write(f = filepath, File.read(f).gsub(search_str, replace_str))\n end", "def replace_child(to_replace, replacement); end", "def recursive_gsub(search_txt, txt_to_replace)\n res = self\n res = res.gsub(search_txt, txt_to_replace).recursive_gsub(search_txt, txt_to_replace) if res.include?(search_txt)\n res\n end", "def perform_substitutions(input)\n @data[:presubs].each { |s| input.gsub!(s[0], s[1]) }\n input\nend", "def replace_all(source_text, replacement)\n case\n # For simple cases we just replace runs to try and keep formatting/layout of source\n when replacement.is_a?(String)\n @main_doc.replace_all_with_text(source_text, replacement)\n when (replacement.is_a?(Magick::Image) or replacement.is_a?(Magick::ImageList))\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n runs.each { |r| r.replace_with_run_fragment(create_image_run_fragment(replacement)) }\n when replacement.is_a?(Hash)\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n runs.each { |r| r.replace_with_body_fragments(create_body_fragments(replacement, {:create_table => true})) }\n when replacement.is_a?(Nokogiri::XML::Element)\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n if replacement.name == \"w:tbl\"\n runs.each { |r| r.replace_with_body_fragments(create_body_fragments(replacement)) }\n else\n runs.each { |r| r.replace_with_run_fragment(create_body_fragments(replacement)) }\n end\n else\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n runs.each { |r| r.replace_with_body_fragments(create_body_fragments(replacement)) }\n end\n end", "def replace_str(str, substr, replacement)\n output = \"\"\n i = 0\n substrlength = substr.length\n while i < str.length\n if str[i, substrlength] == substr\n output << replacement\n i += substrlength\n else\n output += str[i]\n i += 1\n end\n end\n return output\nend", "def replace(file, original_text, new_text)\n text=File.open(file).read\n text.gsub!(\"#{original_text}\", \"#{new_text}\")\n File.open(file, 'w') { |f| f.puts text }\nend", "def replace_in_string(str, replace, start, finish)\n str[start..finish] = replace * (finish + 1 - start)\n str\n end", "def translate(input_word)\n input_word.gsub(self.match_word, self.replacement_word)\n end", "def replace\n end", "def replace!(target, replacement)\n @contents.gsub!(target, replacement)\n end", "def replace_text(text)\n @txt .set_editable(true) # .freeze\n @txt .buffer .set_text(\"\")\n# hdr, value = text .split(\"\\n\\n\", 2)\n# hdr .to_s .each_line{|line|\n# case line\n# when /^Subject:/ ;color = BLUE\n# when /^X-SC-Subject:/ ;color = BLUE\n# when /^From:/ ;color = PURPLE\n# #when /^To:|Cc:/ ;color = ORANGE\n# #when /^Date:/ ;color = GREEN\n# when /^X-SC-(Time|Day):/ ;color = RED\n# else ;color = BLACK\n# end\n# @txt .insert(nil, color, nil, line) if line != ''\n# }\n# @txt .insert(nil, RED, WHITE, hdr .to_s)\n# @txt .insert(nil, BLACK, nil, \"\\n\\n\" + value .to_s)\n\n @txt .buffer .insert(@txt.buffer.start_iter, MhcKconv::todisp(text))\n @txt .set_editable(@text_editable) #.thaw\n end", "def substText(text,bodyStack)\n if(text.kind_of?(Text)) \n rawtext = text.string ;\n elsif(text.kind_of?(Attribute))\n rawtext = text.value ;\n elsif(text.kind_of?(String))\n rawtext = text ;\n else\n return ;\n end\n\n result = rawtext.clone() ;\n\n# result.gsub!(ArgFormat) {|dat| \n# getSubstText($1,bodyStack,dat) ;\n# }\n substTextBody(result,bodyStack) ;\n\n return result ;\n end", "def danish(text)\n p text.sub(/\\b(apple|cherry|blueberry)\\b/, 'danish')\nend", "def replace(content)\n \n # pre-structuring\n content.gsub!( /^(\\w.*)\\n(\\w.*)/ ) { \"#{$1} #{$2}\" } # remove single line breaks between text in order to avoid false paragraph markup\n content.gsub!( /<!--/ ) { \"--\" } # replace opening html commentaries\n content.gsub!( /-->/ ) { \"--\" } # replace closing html commentaries\n \n # templates\n content.gsub!( /\\{\\{Zitat\\|(.*)\\|.*\\}\\}\\s*$\\n/ ) { \"\\{p\\}\\\"#{$1}\\\"\\{/p\\}\\n\" } # citation\n content.gsub!( /\\{\\{.*(Finale Version).*\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1}</font>{/status}<br>\" } # final version\n content.gsub!( /\\{\\{Vorlage:(Dokument.*)\\n*(.*)\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1} #{$2}</font>{/status}<br>\" } # document status\n content.gsub!( /\\{\\{.*\\}\\} *$/ ) { '' } # remove single line templates\n content.gsub!( /\\{\\{.*\\n?.*\\}\\} *$/ ) { '' } # remove all remaining templates\n \n # tags\n content.gsub!( /<nowiki>(.*?)<\\/nowiki>/ ) { \"<pre>#{$1}</pre>\" }\n content.gsub!( /^ +(.*)/ ) { \"<pre>#{$1}</pre>\" }\n\n # special markup of qualidative data analysis\n content = content + \"\\n\\n{!end}\"\n \n # categories\n content.gsub!( /\\[\\[Kategorie:(.*?)\\]\\]/i ) { \"{category}<font color=\\\"#FF0000\\\">Kategorie:#{$1}</font>{/category}<br>\" }\n \n # images\n content.gsub!( /\\[\\[Bild:(.*?)\\]\\]/i ) { \"{image}Bild:#{$1.gsub!(/.*\\|/,'')}{/image}<br>\"} # Bild:lpscreen.jpg|thumb|Bereichseite des Landesportals\n\n # bold\n content.gsub!(/'''(.*?)'''/) {\"<strong>#{$1}</strong>\"}\n content.gsub!(/'''(.*?)$/) {\"<strong>#{$1}</strong>\"}\n\n # italics\n content.gsub!(/''(.*?)''/) {\"<em>#{$1}</em>\"}\n content.gsub!(/''(.*?)$/) {\"<em>#{$1}</em>\"}\n\n # headings\n 6.downto(1) { |i| content.gsub!( /^={#{i}}(.*?)={#{i}} *$/ ) { \"<h#{i}>\\{h>#{i}\\}#{$1}\\{/h>#{i}\\}</h#{i}>\" } }\n \n # links, internal\n content.gsub!( /\\[\\[([^\\[\\n]*?)\\| *(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[\\[(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n\n # links, external\n content.gsub!( /\\[([^\\[\\n]*?)\\| *(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n \n # lists\n content.gsub!(/^:+/,'') # remove forced indenting\n content.gsub!( /^((?:\\*.*\\n+)+)/ ) { \"\\{l>ul\\}<ul>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^\\*/,'')}</li>\\n\" }.join}</ul>\\{/l>ul\\}<br>\\n\" } # first level ul\n content.gsub!( /^((?:#.*\\n+)+)/ ) { \"\\{l>ol\\}<ol>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^#/,'')}</li>\\n\" }.join}</ol>\\{/l>ol\\}<br>\\n\" } # first level ol\n content.gsub!( /<li>\\s*<\\/li>\\n/ ) { '' } # remove empty list entries (this may occur if first-level wiki-lists are entered with \\n\\n; they look like a single list when, in fact, they are but multiple single lists)\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # second level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # second level ol\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # third level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # third level ol\n\n # tables\n # the table conversion barely works, cf. http://johbuc6.coconia.net/doku.php/mediawiki2html_machine/code?DokuWiki=7c542b97df2bc0f82fec0f4875265a20 for an implementation in PHP\n content.gsub!( /^\\{\\|(.*)/ ) { \"\\{table\\}\\n<table #{$1}>\" }\n content.gsub!( /\\|\\}/ ) { \"</table>\\n\\{/table\\}\" }\n content.gsub!( /^\\|-(.*)/ ) { \"<tr>#{$1}\" }\n content.gsub!( /^!(.*?)\\|(.*)/ ) { \"<th #{$1}>#{$2}</th>\" } # table header with piped markup\n content.gsub!( /^!(.*)/ ) { \"<th>#{$1}</th>\" } # table header without piped markup\n content.gsub!( /^\\|(.*?)\\|(.*)/ ) { \"<td #{$1}>#{$2}\" } # table data with piped markup\n content.gsub!( /^\\|(.*)/ ) { \"<td>#{$1}\" } # table data without piped markup\n \n # line breaks\n content.gsub!( /(^(?:\\w|<strong|<em|<a|\\\").*)\\n\\s*\\n/ ) {\"<p>\\{p\\}#{$1}\\{/p\\}</p>\\n\"}\n \n # special markup of qualidative data analysis\n content.gsub!( /(\\{id\\}.*\\{\\/title\\})/ ) { \"<p><strong><em>#{$1.gsub(/_/,' ')}</em></strong></p>\" }\n \n# //$html = nl2br($html);\n# \t// line breaks\n# \t$html = preg_replace('/[\\n\\r]{4}/',\"<br/><br/>\",$html);\n# \t$html = preg_replace('/[\\n\\r]{2}/',\"<br/>\",$html);\n\n# \t$html = preg_replace('/[>]<br\\/>[<]/',\"><\",$html);\n \n# // allowed tags\n# \t$html = preg_replace('/&lt;(\\/?)(small|sup|sub|u)&gt;/','<${1}${2}>',$html);\n#\n# \t$html = preg_replace('/\\n*&lt;br *\\/?&gt;\\n*/',\"\\n\",$html);\n# \t$html = preg_replace('/&lt;(\\/?)(math|pre|code|nowiki)&gt;/','<${1}pre>',$html);\n# \t$html = preg_replace('/&lt;!--/','<!--',$html);\n# \t$html = preg_replace('/--&gt;/',' -->',$html);\n# \n return content\n\nend", "def replace_string keyword, user_word\n #loop through keywords here\n @story_template.gsub(\"[#{keyword}]\", user_word) # We have to add the [] staples back in so that the story_template function below works \n end", "def string_replacements\nend", "def replace!(cell, target, value)\n replace_word = value.is_a?(Integer) ? cell.value.gsub(target, value.to_s).to_i : cell.value.gsub(target, value)\n cell.change_contents(replace_word, cell.formula)\n end", "def replace(range, content)\n @source_rewriter.replace(range, content)\n end", "def replace(range, content)\n @source_rewriter.replace(range, content)\n end", "def replace!(regexp, string)\n unless base.options[:pretend]\n content = File.read(destination)\n content.gsub!(regexp, string)\n File.open(destination, 'wb') { |file| file.write(content) }\n end\n end", "def changer_sub(content)\n\n if content =~ /Superman/\n p \"did you say Superman!!\"\n p \"no sir, I think you said:\"\n end\n\n p content.gsub( /Superman/, \"Batman\")\nend", "def replace(text)\n @text = text\n @cursor = @text.length # put cursor outside of text\n replace_mode\n end", "def modify_string_in_file(target_file, string_to_replace, string_to_replace_with)\n FileUtils.cp_r target_file , \"#{target_file}_tmp\"\n\n text = File.read(\"#{target_file}_tmp\")\n text.gsub!(string_to_replace, string_to_replace_with)\n File.open(target_file, 'w') {|f| f.puts text}\n if (open(target_file).grep(/#{string_to_replace_with}/).length) == 0\n raise \"XML file was NOT modified with correct text: #{target_file}\"\n end\n File.delete \"#{target_file}_tmp\"\n end", "def replace(input_field, regex, into_field, replacement, options = {})\n output = options[:output] || all_fields # Overrides Cascading default\n\n input_field = fields(input_field)\n raise \"input_field must declare exactly one field, was '#{input_field}'\" unless input_field.size == 1\n into_field = fields(into_field)\n raise \"into_field must declare exactly one field, was '#{into_field}'\" unless into_field.size == 1\n\n parameters = [into_field, regex.to_s, replacement.to_s, options[:replace_all]].compact\n each(\n input_field,\n :function => Java::CascadingOperationRegex::RegexReplace.new(*parameters),\n :output => output\n )\n end", "def replace_substrings_at(text, positions, replacements = nil, &block)\n offset = 0\n positions.each_with_index do |p, i|\n p = (p...p) if p.is_a?(Fixnum)\n from = p.begin + offset\n to = p.end + offset\n p = p.exclude_end? ? (from...to) : (from..to)\n # block returns the substitution, e.g.: { |text, pos| text[pos].upcase }\n r = replacements ? replacements[i] : block.call(text[p], p, text)\n text[p] = r\n # add the change in length to offset\n offset += r.size - (p.end - p.begin + (p.exclude_end? ? 0 : 1))\n end\n text\n end", "def transform(text)\n\t\t\[email protected] do |rule|\n\t\t\t\tif rule.replace.is_a?(String)\n\t\t\t\t\ttext = text.gsub(rule.pattern, rule.replace)\n\t\t\t\telse\n\t\t\t\t\ttext = text.gsub(rule.pattern) {rule.replace.call($~)}\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn text\n\t\tend", "def replace(text)\n @text = text\n @cursor = @text.length # put cursor outside of text\n end", "def replace!(destination, regexp, string)\n content = File.binread(destination)\n content.gsub!(regexp, string)\n File.open(destination, 'wb') { |file| file.write(content) }\nend", "def replace_dynamic_string(string, context)\n raise 'input is not a string' unless string.is_a?(String)\n replace_targets = string.split('>>>').map { |target| target.match(/<<<.*/).to_s }\n replace_targets.each do |target|\n key = target.match(/<<<(.*)/)\n if key\n temp_value = context\n key[1].split(' ').each do |current_key|\n raise \"no value '#{current_key}' defined in context\" unless temp_value.key?(current_key.to_sym)\n temp_value = temp_value[current_key.to_sym]\n end\n string = string.gsub(\"#{target}>>>\", temp_value)\n end\n end\n string\n end", "def gsub!(*args, &block)\n str = self.gsub(*args, &block)\n if str != self\n self.replace(str)\n self\n else\n nil\n end\n end", "def search_replace\n print (\"Enter a string for manipulation: \")\n string = gets.chomp.to_s\n print (\"Enter the word to replace: \")\n search = gets.chomp.to_s\n print (\"Enter the replacement character: \")\n newWord = gets.chomp.to_s\n words = string.split(\" \").to_a\n for word in words.each\n if word == search\n word.replace(newWord)\n else\n puts (\"No matching word found.\")\n end\n end\n string = words.join(\" \").to_s\n puts (string)\nend", "def find_and_replace(dir, findstr, replacestr)\n Dir[dir].each do |name|\n text = File.read(name)\n replace = text.gsub(findstr, replacestr)\n replaced = text.index(replacestr)\n next if !replaced.nil? || text == replace\n\n puts \"Patching #{name}\"\n File.open(name, 'w') { |file| file.puts replace }\n $stdout.flush\n end\n Dir[\"#{dir}*/\"].each(&method(:find_and_replace))\nend", "def replace_text old_text, new_text, slide_number = 0\n \n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if old_text == ''\n raise 'old text not specified'\n end\n \n if new_text == ''\n raise 'new text not specified'\n end\n \n if(slide_number == 0)\n str_uri = $product_uri + '/slides/' + @filename + '/replaceText?oldValue=' + old_text + '&newValue=' + new_text + '&ignoreCase=true'\n else\n str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '/replaceText?oldValue=' + old_text + '&newValue=' + new_text + '&ignoreCase=true'\n end\n \n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.post(str_signed_uri, '', {:accept=>'application/json'})\n \n valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)\n \n if valid_output == ''\n folder = Aspose::Cloud::AsposeStorage::Folder.new\n output_stream = folder.get_file(@filename)\n output_path = $out_put_location + @filename \n Aspose::Cloud::Common::Utils.save_file(output_stream,output_path)\n return ''\n else\n return valid_output\n end \n \n rescue Exception=>e\n print e\n end\n \n end", "def replace(*args)\n @replacements ||= {}\n\n if args.size == 2\n @replacements[args[0]] = args[1]\n\n else\n @replacements.update(args.first)\n end\n end", "def replace_content(name, content)\n render :update do |page|\n page.replace_html name, content\n end\n end", "def subs(input, the_story)\n subbed = the_story.gsub(\"lion\", input).gsub(\"r\", \"rrr\")\n return subbed\nend", "def replace_content_with_text(node_or_nodeset, text)\n each_node(node_or_nodeset) do |node|\n node.content = text\n end\n end", "def update(text); end", "def replace_using(tag, string)\n Tags[tag][1] = string\n end", "def regex_replace_first(input, regex, replacement = NOTHING)\n input.to_s.sub(Regexp.new(regex), replacement.to_s)\n end", "def replace(p0) end", "def replace(p0) end", "def replace(p0) end", "def gsub(pattern, replacement = nil, &blk)\n if block_given?\n @string.gsub(pattern, &blk)\n else\n @string.gsub(pattern, replacement)\n end\n end", "def gsub(pattern, replacement = nil, &blk)\n if block_given?\n @string.gsub(pattern, &blk)\n else\n @string.gsub(pattern, replacement)\n end\n end", "def set(desired_text, desired_replacement_text = nil)\n pre_replacement_text_validation(desired_text, desired_replacement_text)\n\n if replacement_desired?(desired_replacement_text)\n desired_replacement_text = validate_replacement_text(desired_replacement_text)\n\n desired_text = replace_unsupported_characters(from: desired_text, with: desired_replacement_text)\n end\n\n post_replacement_text_validation(desired_text)\n validate_text_contents(desired_text)\n validate_text_image_dimensions(desired_text)\n\n # set the text to a duplicate of the original text to avoid string injection\n self.text = desired_text.dup\n\n desired_text\n end", "def change_letters(string)\r\n if string.include? \"s\"\r\n string.gsub!(/s/, \"th\")\r\n end\r\n\r\n puts string\r\nend", "def highlight(search_str, text)\n text.gsub!(search_str, \"<strong>#{search_str}</strong>\")\n end", "def replace(string, char, replacement)\n new_string = \"\"\n string.each_char do |c|\n new_string += c == char ? replacement : c\n end\n new_string\nend", "def write_replace(find_replace_var)\n\n # Validate user input\n form_validate(find_replace_var.fetch(:original))\n\n # First set the file locations only if the correct extension\n files = Dir.glob(\"#{@base_theme_directory}/**/**.{php,css,txt,scss,js,json}\")\n\n files.each do |file_name|\n text = File.read(file_name)\n replace = text.gsub(find_replace_var.fetch(:original), find_replace_var.fetch(:replacement))\n File.open(file_name, 'w') { |file| file.puts replace }\n end\n end", "def replace_string(str_to_replace,file_to_edit,envVar)\n # load the file as a string\n data = File.read(\"#{file_to_edit}\")\n # globally substitute\n filtered_data = data.gsub(\"#{str_to_replace}\", \"#{envVar}\")\n # open the file for writing\n File.open(\"#{file_to_edit}\", \"w\") do |f|\n f.write(filtered_data)\n end\n end", "def replace(filter = '')\n q(filter) { |e| e.replace(@strings.values) }\n self\n end", "def word_substituter(string)\n# dictionary.has_key(\"hello\") == true\n replace= []\n \n replace << string.split.each do |word| \n if dictionary.has_key?(\"#{word}\") == true\n word.replace(dictionary[\"#{word}\"])\n else word\n \n end\n \n end \n replace.flatten.join(\" \")\nend", "def find_and_replace(file, output_path, find_replace_hash, output_name)\n\ttext = File.read(file)\n\tfind_replace_hash.each do |k,v|\n\t\[email protected] \"find = #{k}, replace = #{v}\" if @debug\n\t\ttext.gsub!(/#{k}/,v)\n\tend\t\n\tFile.open(\"#{output_path}/#{output_name}.xml\", \"w\") {|file| file.puts text}\nend", "def replaceAll(oldStr,newStr)\n while @container.index(oldStr)!=nil\n repStr = String.new(oldStr)\n if(@container.index(oldStr)==0)\n str1=\"\"\n else\n str1=@container[[email protected](oldStr)-1]\n end\n \n str2=@container[@container.index(oldStr)[email protected]]\n \n if(newStr!=\"\")\n repStr.replace(newStr)\n @container=str1+repStr+str2\n else\n @container=str1+str2\n end\n end\n return @container \n end", "def add_more_ruby(string)\n string.gsub(\"sad\", \"happy\").gsub(\"Sad\", \"Happy\").gsub(\"SAD\", \"HAPPY\")\nend", "def find_and_replace(dir, findstr, replacestr)\n Dir[dir].each do |name|\n text = File.read(name)\n replace = text.gsub(findstr,replacestr)\n if text != replace\n puts \"Fix: \" + name\n File.open(name, \"w\") { |file| file.puts replace }\n STDOUT.flush\n end\n end\n Dir[dir + '*/'].each(&method(:find_and_replace))\nend", "def format(text, &block)\n extract(text).each_with_object(text.clone) do |extract, redacted_text|\n sub = block_given? ? block.call(extract) : default_replacement\n redacted_text[extract.start..extract.finish] = sub\n end\n end", "def tricky_method_two(a_string_param, an_array_param)\n a_string_param.gsub!('pumpkins', 'pumpkinsrutabaga')\n an_array_param = ['pumpkins', 'rutabaga']\nend", "def say_goodbye\n str = \"Hello\"\n abc = str\n str.replace(\"Goodbye\")\n puts str\n puts abc\nend", "def gsub(pattern, replace)\n lambda do |rec, acc|\n acc.collect! { |v| v.gsub(pattern, replace) }\n end\n end", "def replace_text()\n @replace['replace']['tables'].each do |table, fields|\n fields.each do |field|\n #begin\n query = update_query(@replace['replace']['find'], @replace['replace']['replace'], table, field)\n puts query\n @dbconn.query(query)\n #rescue\n # return false\n #end\n end\n end\n return true\n end", "def replace pattern, substitute\n if pattern.is_a? Regexp\n ArelExtensions::Nodes::RegexpReplace.new self, pattern, substitute\n else\n ArelExtensions::Nodes::Replace.new self, pattern, substitute\n end\n end", "def subst(str)\n s = [\" MA\", \" VA\", \" OK\", \" PA\", \" CA\", \" AZ\", \" ID\", \" IN\"]\n st = [\", Massachusetts\", \", Virginia\", \", Oklahoma\", \", Pennsylvania\", \", California\", \", Arizona\", \", Idaho\", \", Indiana\"]\n i = 0; a = str\n while (i < s.length) do\n a = a.gsub(s[i], st[i])\n i += 1\n end\n a\nend", "def replace(in_str)\n @out_str = in_str + \" \" + in_str\n end", "def _rl_replace_text(text, start, _end)\r\n rl_begin_undo_group()\r\n rl_delete_text(start, _end + 1)\r\n @rl_point = start\r\n n = rl_insert_text(text)\r\n rl_end_undo_group()\r\n n\r\n end", "def escape(text)\n replacements.inject(text.to_s) do |corpus, (pattern, replacement)|\n corpus.gsub(pattern, replacement)\n end\n end", "def process_text text\n newtext = text.gsub(/if/, 'IF')\n\n 30.times { |i|\n newtext.gsub!(/for/, 'FOR')\n newtext.gsub!(/while/, 'WHILE')\n newtext.gsub!(/switch/, 'SWITCH')\n newtext.gsub!(/case/, 'CASE')\n newtext.gsub!(/goto/, 'GOTO')\n newtext.gsub!(/struct/, 'STRUCT')\n newtext.gsub!(/int/, 'INT')\n newtext.gsub!(/char/, 'CHAR')\n newtext.gsub!(/return/, 'RETURN')\n }\n\n return newtext\nend", "def replacements; end", "def update(text)\n text\n end", "def replace_pattern\n id = Readline.readline(\"ID of task to perform replace: \").to_i\n old_pattern = Readline.readline('replace : ').chomp\n new_pattern = Readline.readline('with : ').chomp\n ok = ReplacePattern.new(id, old_pattern, new_pattern).execute\n puts \"No such task\" if !ok\n end" ]
[ "0.762407", "0.68984413", "0.68984413", "0.68984413", "0.68984413", "0.68984413", "0.68984413", "0.68984413", "0.68984413", "0.67544174", "0.6717642", "0.66559976", "0.6648128", "0.66168153", "0.661061", "0.6596554", "0.65858436", "0.65445876", "0.64956063", "0.6458525", "0.645039", "0.6426702", "0.6399085", "0.6399085", "0.6395604", "0.63822544", "0.6379834", "0.63470715", "0.6323517", "0.62973535", "0.62963843", "0.62801546", "0.6277558", "0.62271243", "0.619883", "0.6195724", "0.6191986", "0.61801815", "0.61776584", "0.61731523", "0.6167074", "0.6164654", "0.6138697", "0.61279637", "0.61216176", "0.6101005", "0.60542506", "0.60444766", "0.60444766", "0.60256386", "0.6016289", "0.5998338", "0.5963235", "0.596166", "0.59534913", "0.59498525", "0.59258837", "0.59244657", "0.5910737", "0.59083307", "0.5898609", "0.5891503", "0.5891276", "0.5885625", "0.58456916", "0.5845565", "0.5842083", "0.58383656", "0.5822759", "0.5815828", "0.5791475", "0.5791475", "0.5788789", "0.577841", "0.577841", "0.5775853", "0.5769642", "0.5764276", "0.5760011", "0.5751843", "0.5749602", "0.57365626", "0.5735238", "0.5725479", "0.5719197", "0.5716629", "0.57127553", "0.57016295", "0.56956476", "0.5694922", "0.56859666", "0.56844753", "0.56776667", "0.56752694", "0.5673235", "0.56725097", "0.5666002", "0.56537133", "0.564265", "0.563297", "0.56252295" ]
0.0
-1
Replace a string in text with another string value Replaces all occurrences of the input string in the input content, and returns the result
def edit_text_replace_simple_with_http_info(request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_replace_simple ...' end # verify the required parameter 'request' is set if @api_client.config.client_side_validation && request.nil? fail ArgumentError, "Missing the required parameter 'request' when calling EditTextApi.edit_text_replace_simple" end # resource path local_var_path = '/convert/edit/text/replace/string' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(request) auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ReplaceStringSimpleResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_replace_simple\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modify_text(book_text, string_values)\n string_values.each do |search_string, change_string|\n regex = %r[#{search_string}]\n book_text = book_text.gsub(regex, change_string)\n end\n\n return book_text\nend", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def replace(range, content); end", "def sub_replacements text\n if REPLACEABLE_TEXT_RX.match? text\n # NOTE interpolation is faster than String#dup\n text = text.to_s\n REPLACEMENTS.each do |pattern, replacement, restore|\n # NOTE Using gsub! as optimization\n text.gsub!(pattern) { do_replacement $LAST_MATCH_INFO, replacement, restore }\n end\n end\n text\n end", "def regex_replace(string, search, replace)\n return string.gsub(/#{search}/m, replace)\n end", "def replace_string_inside_node!(search_string_or_regex, replace_string, xn)\n if xn.text? && '' != xn.text && !xn.text.nil?\n xn.content = xn.text.gsub(search_string_or_regex, replace_string)\n else\n xn.children.each { |child_xn|\n replace_string_inside_node!(search_string_or_regex, replace_string, child_xn)\n }\n end\n end", "def rewrite!(content)\n return content unless match?\n \n content.gsub(/#{pattern}/, replacement)\n end", "def replace_placeholders(text)\n matches = text.scan(/\\{([a-z_]+)\\}/).flatten\n\n return text unless matches.any?\n\n replaced = text.dup\n\n matches.each do |match|\n value = @filing_history.description_values.dig(match.to_sym)\n replaced.sub!(/{#{match}}/, value)\n end\n\n replaced\n end", "def gsub(value, context, parameters)\n # Try to find a full replacement match - if found, return the actual value of that reference.\n return get_reference_value($1, context, parameters) if value.match(REPLACE_REGEX)\n # No full match, substitute all references with their string representations\n value.gsub(INTERPOLATE_REGEX) { get_reference_value($1, context, parameters) }\n end", "def replace_word_in_text(text, orignal_word, replaced_word)\n regex = %r[\\b#{orignal_word}\\b]\n text.gsub(regex, replaced_word)\nend", "def str_replace(orig, rep, with)\n s = orig\n while s.include?(rep)\n s.sub! rep, with\n end\n orig\n end", "def modify_content(source, content, replace_value)\n file = File.read(source)\n replace = file.gsub(/#{content}/, replace_value)\n File.open(source, \"w\"){|f|\n f.puts replace \n }\n end", "def on_call_translate(context, input, find, replace)\n input_str = on_call_string(context, input)\n find_chars = on_call_string(context, find).chars.to_a\n replace_chars = on_call_string(context, replace).chars.to_a\n replaced = input_str\n\n find_chars.each_with_index do |char, index|\n replace_with = replace_chars[index] ? replace_chars[index] : ''\n replaced = replaced.gsub(char, replace_with)\n end\n\n return replaced\n end", "def format!\n substitutions.each { |s| sub_string.gsub!(match(s), replace(s)) }\n sub_string\n end", "def apply_replacements(word)\n @replacements.each do |pattern, target|\n word.gsub!(pattern, target)\n end\n \n word\n end", "def replace_word(template, replaced_word, new_word)\r\n template.gsub(/#{replaced_word}/, new_word)\r\n end", "def replace_contents!(pattern, replace_with)\n\t\twrite contents.gsub(pattern, replace_with)\n\tend", "def replace_contents!(pattern, replace_with)\n\t\twrite contents.gsub(pattern, replace_with)\n\tend", "def justLikeSed(file, text_to_replace, text_to_put_in_place)\n text = File.read(file)\n File.open(file, 'w+'){|f| f << text.gsub(text_to_replace, text_to_put_in_place)}\n end", "def replace(input, string, replacement = T.unsafe(nil)); end", "def replace!(regexp, string, force)\n return if base.options[:pretend]\n content = File.binread(destination)\n if force || !content.include?(replacement)\n content.gsub!(regexp, string)\n File.open(destination, \"wb\") { |file| file.write(content) }\n end\n end", "def update_query(find_text, replace_text, table, field)\n return \"UPDATE #{table} SET #{field} = REPLACE(#{field}, '#{find_text}', '#{replace_text}')\"\n end", "def replace_contents!(pattern, with_text)\n entries.each do |entry|\n entry.replace_contents!(pattern, with_text) unless entry.dir?\n end\n end", "def str_replace(filepath, search_str, replace_str)\n File.write(f = filepath, File.read(f).gsub(search_str, replace_str))\n end", "def replace_child(to_replace, replacement); end", "def recursive_gsub(search_txt, txt_to_replace)\n res = self\n res = res.gsub(search_txt, txt_to_replace).recursive_gsub(search_txt, txt_to_replace) if res.include?(search_txt)\n res\n end", "def perform_substitutions(input)\n @data[:presubs].each { |s| input.gsub!(s[0], s[1]) }\n input\nend", "def replace_all(source_text, replacement)\n case\n # For simple cases we just replace runs to try and keep formatting/layout of source\n when replacement.is_a?(String)\n @main_doc.replace_all_with_text(source_text, replacement)\n when (replacement.is_a?(Magick::Image) or replacement.is_a?(Magick::ImageList))\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n runs.each { |r| r.replace_with_run_fragment(create_image_run_fragment(replacement)) }\n when replacement.is_a?(Hash)\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n runs.each { |r| r.replace_with_body_fragments(create_body_fragments(replacement, {:create_table => true})) }\n when replacement.is_a?(Nokogiri::XML::Element)\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n if replacement.name == \"w:tbl\"\n runs.each { |r| r.replace_with_body_fragments(create_body_fragments(replacement)) }\n else\n runs.each { |r| r.replace_with_run_fragment(create_body_fragments(replacement)) }\n end\n else\n runs = @main_doc.replace_all_with_empty_runs(source_text)\n runs.each { |r| r.replace_with_body_fragments(create_body_fragments(replacement)) }\n end\n end", "def replace_str(str, substr, replacement)\n output = \"\"\n i = 0\n substrlength = substr.length\n while i < str.length\n if str[i, substrlength] == substr\n output << replacement\n i += substrlength\n else\n output += str[i]\n i += 1\n end\n end\n return output\nend", "def replace(file, original_text, new_text)\n text=File.open(file).read\n text.gsub!(\"#{original_text}\", \"#{new_text}\")\n File.open(file, 'w') { |f| f.puts text }\nend", "def replace_in_string(str, replace, start, finish)\n str[start..finish] = replace * (finish + 1 - start)\n str\n end", "def replace\n end", "def translate(input_word)\n input_word.gsub(self.match_word, self.replacement_word)\n end", "def replace!(target, replacement)\n @contents.gsub!(target, replacement)\n end", "def replace_text(text)\n @txt .set_editable(true) # .freeze\n @txt .buffer .set_text(\"\")\n# hdr, value = text .split(\"\\n\\n\", 2)\n# hdr .to_s .each_line{|line|\n# case line\n# when /^Subject:/ ;color = BLUE\n# when /^X-SC-Subject:/ ;color = BLUE\n# when /^From:/ ;color = PURPLE\n# #when /^To:|Cc:/ ;color = ORANGE\n# #when /^Date:/ ;color = GREEN\n# when /^X-SC-(Time|Day):/ ;color = RED\n# else ;color = BLACK\n# end\n# @txt .insert(nil, color, nil, line) if line != ''\n# }\n# @txt .insert(nil, RED, WHITE, hdr .to_s)\n# @txt .insert(nil, BLACK, nil, \"\\n\\n\" + value .to_s)\n\n @txt .buffer .insert(@txt.buffer.start_iter, MhcKconv::todisp(text))\n @txt .set_editable(@text_editable) #.thaw\n end", "def substText(text,bodyStack)\n if(text.kind_of?(Text)) \n rawtext = text.string ;\n elsif(text.kind_of?(Attribute))\n rawtext = text.value ;\n elsif(text.kind_of?(String))\n rawtext = text ;\n else\n return ;\n end\n\n result = rawtext.clone() ;\n\n# result.gsub!(ArgFormat) {|dat| \n# getSubstText($1,bodyStack,dat) ;\n# }\n substTextBody(result,bodyStack) ;\n\n return result ;\n end", "def danish(text)\n p text.sub(/\\b(apple|cherry|blueberry)\\b/, 'danish')\nend", "def replace(content)\n \n # pre-structuring\n content.gsub!( /^(\\w.*)\\n(\\w.*)/ ) { \"#{$1} #{$2}\" } # remove single line breaks between text in order to avoid false paragraph markup\n content.gsub!( /<!--/ ) { \"--\" } # replace opening html commentaries\n content.gsub!( /-->/ ) { \"--\" } # replace closing html commentaries\n \n # templates\n content.gsub!( /\\{\\{Zitat\\|(.*)\\|.*\\}\\}\\s*$\\n/ ) { \"\\{p\\}\\\"#{$1}\\\"\\{/p\\}\\n\" } # citation\n content.gsub!( /\\{\\{.*(Finale Version).*\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1}</font>{/status}<br>\" } # final version\n content.gsub!( /\\{\\{Vorlage:(Dokument.*)\\n*(.*)\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1} #{$2}</font>{/status}<br>\" } # document status\n content.gsub!( /\\{\\{.*\\}\\} *$/ ) { '' } # remove single line templates\n content.gsub!( /\\{\\{.*\\n?.*\\}\\} *$/ ) { '' } # remove all remaining templates\n \n # tags\n content.gsub!( /<nowiki>(.*?)<\\/nowiki>/ ) { \"<pre>#{$1}</pre>\" }\n content.gsub!( /^ +(.*)/ ) { \"<pre>#{$1}</pre>\" }\n\n # special markup of qualidative data analysis\n content = content + \"\\n\\n{!end}\"\n \n # categories\n content.gsub!( /\\[\\[Kategorie:(.*?)\\]\\]/i ) { \"{category}<font color=\\\"#FF0000\\\">Kategorie:#{$1}</font>{/category}<br>\" }\n \n # images\n content.gsub!( /\\[\\[Bild:(.*?)\\]\\]/i ) { \"{image}Bild:#{$1.gsub!(/.*\\|/,'')}{/image}<br>\"} # Bild:lpscreen.jpg|thumb|Bereichseite des Landesportals\n\n # bold\n content.gsub!(/'''(.*?)'''/) {\"<strong>#{$1}</strong>\"}\n content.gsub!(/'''(.*?)$/) {\"<strong>#{$1}</strong>\"}\n\n # italics\n content.gsub!(/''(.*?)''/) {\"<em>#{$1}</em>\"}\n content.gsub!(/''(.*?)$/) {\"<em>#{$1}</em>\"}\n\n # headings\n 6.downto(1) { |i| content.gsub!( /^={#{i}}(.*?)={#{i}} *$/ ) { \"<h#{i}>\\{h>#{i}\\}#{$1}\\{/h>#{i}\\}</h#{i}>\" } }\n \n # links, internal\n content.gsub!( /\\[\\[([^\\[\\n]*?)\\| *(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[\\[(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n\n # links, external\n content.gsub!( /\\[([^\\[\\n]*?)\\| *(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n \n # lists\n content.gsub!(/^:+/,'') # remove forced indenting\n content.gsub!( /^((?:\\*.*\\n+)+)/ ) { \"\\{l>ul\\}<ul>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^\\*/,'')}</li>\\n\" }.join}</ul>\\{/l>ul\\}<br>\\n\" } # first level ul\n content.gsub!( /^((?:#.*\\n+)+)/ ) { \"\\{l>ol\\}<ol>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^#/,'')}</li>\\n\" }.join}</ol>\\{/l>ol\\}<br>\\n\" } # first level ol\n content.gsub!( /<li>\\s*<\\/li>\\n/ ) { '' } # remove empty list entries (this may occur if first-level wiki-lists are entered with \\n\\n; they look like a single list when, in fact, they are but multiple single lists)\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # second level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # second level ol\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # third level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # third level ol\n\n # tables\n # the table conversion barely works, cf. http://johbuc6.coconia.net/doku.php/mediawiki2html_machine/code?DokuWiki=7c542b97df2bc0f82fec0f4875265a20 for an implementation in PHP\n content.gsub!( /^\\{\\|(.*)/ ) { \"\\{table\\}\\n<table #{$1}>\" }\n content.gsub!( /\\|\\}/ ) { \"</table>\\n\\{/table\\}\" }\n content.gsub!( /^\\|-(.*)/ ) { \"<tr>#{$1}\" }\n content.gsub!( /^!(.*?)\\|(.*)/ ) { \"<th #{$1}>#{$2}</th>\" } # table header with piped markup\n content.gsub!( /^!(.*)/ ) { \"<th>#{$1}</th>\" } # table header without piped markup\n content.gsub!( /^\\|(.*?)\\|(.*)/ ) { \"<td #{$1}>#{$2}\" } # table data with piped markup\n content.gsub!( /^\\|(.*)/ ) { \"<td>#{$1}\" } # table data without piped markup\n \n # line breaks\n content.gsub!( /(^(?:\\w|<strong|<em|<a|\\\").*)\\n\\s*\\n/ ) {\"<p>\\{p\\}#{$1}\\{/p\\}</p>\\n\"}\n \n # special markup of qualidative data analysis\n content.gsub!( /(\\{id\\}.*\\{\\/title\\})/ ) { \"<p><strong><em>#{$1.gsub(/_/,' ')}</em></strong></p>\" }\n \n# //$html = nl2br($html);\n# \t// line breaks\n# \t$html = preg_replace('/[\\n\\r]{4}/',\"<br/><br/>\",$html);\n# \t$html = preg_replace('/[\\n\\r]{2}/',\"<br/>\",$html);\n\n# \t$html = preg_replace('/[>]<br\\/>[<]/',\"><\",$html);\n \n# // allowed tags\n# \t$html = preg_replace('/&lt;(\\/?)(small|sup|sub|u)&gt;/','<${1}${2}>',$html);\n#\n# \t$html = preg_replace('/\\n*&lt;br *\\/?&gt;\\n*/',\"\\n\",$html);\n# \t$html = preg_replace('/&lt;(\\/?)(math|pre|code|nowiki)&gt;/','<${1}pre>',$html);\n# \t$html = preg_replace('/&lt;!--/','<!--',$html);\n# \t$html = preg_replace('/--&gt;/',' -->',$html);\n# \n return content\n\nend", "def replace_string keyword, user_word\n #loop through keywords here\n @story_template.gsub(\"[#{keyword}]\", user_word) # We have to add the [] staples back in so that the story_template function below works \n end", "def string_replacements\nend", "def replace!(cell, target, value)\n replace_word = value.is_a?(Integer) ? cell.value.gsub(target, value.to_s).to_i : cell.value.gsub(target, value)\n cell.change_contents(replace_word, cell.formula)\n end", "def replace(range, content)\n @source_rewriter.replace(range, content)\n end", "def replace(range, content)\n @source_rewriter.replace(range, content)\n end", "def replace!(regexp, string)\n unless base.options[:pretend]\n content = File.read(destination)\n content.gsub!(regexp, string)\n File.open(destination, 'wb') { |file| file.write(content) }\n end\n end", "def changer_sub(content)\n\n if content =~ /Superman/\n p \"did you say Superman!!\"\n p \"no sir, I think you said:\"\n end\n\n p content.gsub( /Superman/, \"Batman\")\nend", "def replace(text)\n @text = text\n @cursor = @text.length # put cursor outside of text\n replace_mode\n end", "def modify_string_in_file(target_file, string_to_replace, string_to_replace_with)\n FileUtils.cp_r target_file , \"#{target_file}_tmp\"\n\n text = File.read(\"#{target_file}_tmp\")\n text.gsub!(string_to_replace, string_to_replace_with)\n File.open(target_file, 'w') {|f| f.puts text}\n if (open(target_file).grep(/#{string_to_replace_with}/).length) == 0\n raise \"XML file was NOT modified with correct text: #{target_file}\"\n end\n File.delete \"#{target_file}_tmp\"\n end", "def replace(input_field, regex, into_field, replacement, options = {})\n output = options[:output] || all_fields # Overrides Cascading default\n\n input_field = fields(input_field)\n raise \"input_field must declare exactly one field, was '#{input_field}'\" unless input_field.size == 1\n into_field = fields(into_field)\n raise \"into_field must declare exactly one field, was '#{into_field}'\" unless into_field.size == 1\n\n parameters = [into_field, regex.to_s, replacement.to_s, options[:replace_all]].compact\n each(\n input_field,\n :function => Java::CascadingOperationRegex::RegexReplace.new(*parameters),\n :output => output\n )\n end", "def replace_substrings_at(text, positions, replacements = nil, &block)\n offset = 0\n positions.each_with_index do |p, i|\n p = (p...p) if p.is_a?(Fixnum)\n from = p.begin + offset\n to = p.end + offset\n p = p.exclude_end? ? (from...to) : (from..to)\n # block returns the substitution, e.g.: { |text, pos| text[pos].upcase }\n r = replacements ? replacements[i] : block.call(text[p], p, text)\n text[p] = r\n # add the change in length to offset\n offset += r.size - (p.end - p.begin + (p.exclude_end? ? 0 : 1))\n end\n text\n end", "def transform(text)\n\t\t\[email protected] do |rule|\n\t\t\t\tif rule.replace.is_a?(String)\n\t\t\t\t\ttext = text.gsub(rule.pattern, rule.replace)\n\t\t\t\telse\n\t\t\t\t\ttext = text.gsub(rule.pattern) {rule.replace.call($~)}\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn text\n\t\tend", "def replace(text)\n @text = text\n @cursor = @text.length # put cursor outside of text\n end", "def replace!(destination, regexp, string)\n content = File.binread(destination)\n content.gsub!(regexp, string)\n File.open(destination, 'wb') { |file| file.write(content) }\nend", "def replace_dynamic_string(string, context)\n raise 'input is not a string' unless string.is_a?(String)\n replace_targets = string.split('>>>').map { |target| target.match(/<<<.*/).to_s }\n replace_targets.each do |target|\n key = target.match(/<<<(.*)/)\n if key\n temp_value = context\n key[1].split(' ').each do |current_key|\n raise \"no value '#{current_key}' defined in context\" unless temp_value.key?(current_key.to_sym)\n temp_value = temp_value[current_key.to_sym]\n end\n string = string.gsub(\"#{target}>>>\", temp_value)\n end\n end\n string\n end", "def gsub!(*args, &block)\n str = self.gsub(*args, &block)\n if str != self\n self.replace(str)\n self\n else\n nil\n end\n end", "def search_replace\n print (\"Enter a string for manipulation: \")\n string = gets.chomp.to_s\n print (\"Enter the word to replace: \")\n search = gets.chomp.to_s\n print (\"Enter the replacement character: \")\n newWord = gets.chomp.to_s\n words = string.split(\" \").to_a\n for word in words.each\n if word == search\n word.replace(newWord)\n else\n puts (\"No matching word found.\")\n end\n end\n string = words.join(\" \").to_s\n puts (string)\nend", "def replace_text old_text, new_text, slide_number = 0\n \n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if old_text == ''\n raise 'old text not specified'\n end\n \n if new_text == ''\n raise 'new text not specified'\n end\n \n if(slide_number == 0)\n str_uri = $product_uri + '/slides/' + @filename + '/replaceText?oldValue=' + old_text + '&newValue=' + new_text + '&ignoreCase=true'\n else\n str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '/replaceText?oldValue=' + old_text + '&newValue=' + new_text + '&ignoreCase=true'\n end\n \n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.post(str_signed_uri, '', {:accept=>'application/json'})\n \n valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)\n \n if valid_output == ''\n folder = Aspose::Cloud::AsposeStorage::Folder.new\n output_stream = folder.get_file(@filename)\n output_path = $out_put_location + @filename \n Aspose::Cloud::Common::Utils.save_file(output_stream,output_path)\n return ''\n else\n return valid_output\n end \n \n rescue Exception=>e\n print e\n end\n \n end", "def find_and_replace(dir, findstr, replacestr)\n Dir[dir].each do |name|\n text = File.read(name)\n replace = text.gsub(findstr, replacestr)\n replaced = text.index(replacestr)\n next if !replaced.nil? || text == replace\n\n puts \"Patching #{name}\"\n File.open(name, 'w') { |file| file.puts replace }\n $stdout.flush\n end\n Dir[\"#{dir}*/\"].each(&method(:find_and_replace))\nend", "def replace(*args)\n @replacements ||= {}\n\n if args.size == 2\n @replacements[args[0]] = args[1]\n\n else\n @replacements.update(args.first)\n end\n end", "def replace_content(name, content)\n render :update do |page|\n page.replace_html name, content\n end\n end", "def subs(input, the_story)\n subbed = the_story.gsub(\"lion\", input).gsub(\"r\", \"rrr\")\n return subbed\nend", "def replace_content_with_text(node_or_nodeset, text)\n each_node(node_or_nodeset) do |node|\n node.content = text\n end\n end", "def update(text); end", "def replace_using(tag, string)\n Tags[tag][1] = string\n end", "def regex_replace_first(input, regex, replacement = NOTHING)\n input.to_s.sub(Regexp.new(regex), replacement.to_s)\n end", "def replace(p0) end", "def replace(p0) end", "def replace(p0) end", "def set(desired_text, desired_replacement_text = nil)\n pre_replacement_text_validation(desired_text, desired_replacement_text)\n\n if replacement_desired?(desired_replacement_text)\n desired_replacement_text = validate_replacement_text(desired_replacement_text)\n\n desired_text = replace_unsupported_characters(from: desired_text, with: desired_replacement_text)\n end\n\n post_replacement_text_validation(desired_text)\n validate_text_contents(desired_text)\n validate_text_image_dimensions(desired_text)\n\n # set the text to a duplicate of the original text to avoid string injection\n self.text = desired_text.dup\n\n desired_text\n end", "def gsub(pattern, replacement = nil, &blk)\n if block_given?\n @string.gsub(pattern, &blk)\n else\n @string.gsub(pattern, replacement)\n end\n end", "def gsub(pattern, replacement = nil, &blk)\n if block_given?\n @string.gsub(pattern, &blk)\n else\n @string.gsub(pattern, replacement)\n end\n end", "def change_letters(string)\r\n if string.include? \"s\"\r\n string.gsub!(/s/, \"th\")\r\n end\r\n\r\n puts string\r\nend", "def highlight(search_str, text)\n text.gsub!(search_str, \"<strong>#{search_str}</strong>\")\n end", "def replace(string, char, replacement)\n new_string = \"\"\n string.each_char do |c|\n new_string += c == char ? replacement : c\n end\n new_string\nend", "def write_replace(find_replace_var)\n\n # Validate user input\n form_validate(find_replace_var.fetch(:original))\n\n # First set the file locations only if the correct extension\n files = Dir.glob(\"#{@base_theme_directory}/**/**.{php,css,txt,scss,js,json}\")\n\n files.each do |file_name|\n text = File.read(file_name)\n replace = text.gsub(find_replace_var.fetch(:original), find_replace_var.fetch(:replacement))\n File.open(file_name, 'w') { |file| file.puts replace }\n end\n end", "def replace_string(str_to_replace,file_to_edit,envVar)\n # load the file as a string\n data = File.read(\"#{file_to_edit}\")\n # globally substitute\n filtered_data = data.gsub(\"#{str_to_replace}\", \"#{envVar}\")\n # open the file for writing\n File.open(\"#{file_to_edit}\", \"w\") do |f|\n f.write(filtered_data)\n end\n end", "def replace(filter = '')\n q(filter) { |e| e.replace(@strings.values) }\n self\n end", "def word_substituter(string)\n# dictionary.has_key(\"hello\") == true\n replace= []\n \n replace << string.split.each do |word| \n if dictionary.has_key?(\"#{word}\") == true\n word.replace(dictionary[\"#{word}\"])\n else word\n \n end\n \n end \n replace.flatten.join(\" \")\nend", "def find_and_replace(file, output_path, find_replace_hash, output_name)\n\ttext = File.read(file)\n\tfind_replace_hash.each do |k,v|\n\t\[email protected] \"find = #{k}, replace = #{v}\" if @debug\n\t\ttext.gsub!(/#{k}/,v)\n\tend\t\n\tFile.open(\"#{output_path}/#{output_name}.xml\", \"w\") {|file| file.puts text}\nend", "def replaceAll(oldStr,newStr)\n while @container.index(oldStr)!=nil\n repStr = String.new(oldStr)\n if(@container.index(oldStr)==0)\n str1=\"\"\n else\n str1=@container[[email protected](oldStr)-1]\n end\n \n str2=@container[@container.index(oldStr)[email protected]]\n \n if(newStr!=\"\")\n repStr.replace(newStr)\n @container=str1+repStr+str2\n else\n @container=str1+str2\n end\n end\n return @container \n end", "def add_more_ruby(string)\n string.gsub(\"sad\", \"happy\").gsub(\"Sad\", \"Happy\").gsub(\"SAD\", \"HAPPY\")\nend", "def find_and_replace(dir, findstr, replacestr)\n Dir[dir].each do |name|\n text = File.read(name)\n replace = text.gsub(findstr,replacestr)\n if text != replace\n puts \"Fix: \" + name\n File.open(name, \"w\") { |file| file.puts replace }\n STDOUT.flush\n end\n end\n Dir[dir + '*/'].each(&method(:find_and_replace))\nend", "def format(text, &block)\n extract(text).each_with_object(text.clone) do |extract, redacted_text|\n sub = block_given? ? block.call(extract) : default_replacement\n redacted_text[extract.start..extract.finish] = sub\n end\n end", "def tricky_method_two(a_string_param, an_array_param)\n a_string_param.gsub!('pumpkins', 'pumpkinsrutabaga')\n an_array_param = ['pumpkins', 'rutabaga']\nend", "def say_goodbye\n str = \"Hello\"\n abc = str\n str.replace(\"Goodbye\")\n puts str\n puts abc\nend", "def gsub(pattern, replace)\n lambda do |rec, acc|\n acc.collect! { |v| v.gsub(pattern, replace) }\n end\n end", "def replace_text()\n @replace['replace']['tables'].each do |table, fields|\n fields.each do |field|\n #begin\n query = update_query(@replace['replace']['find'], @replace['replace']['replace'], table, field)\n puts query\n @dbconn.query(query)\n #rescue\n # return false\n #end\n end\n end\n return true\n end", "def replace pattern, substitute\n if pattern.is_a? Regexp\n ArelExtensions::Nodes::RegexpReplace.new self, pattern, substitute\n else\n ArelExtensions::Nodes::Replace.new self, pattern, substitute\n end\n end", "def subst(str)\n s = [\" MA\", \" VA\", \" OK\", \" PA\", \" CA\", \" AZ\", \" ID\", \" IN\"]\n st = [\", Massachusetts\", \", Virginia\", \", Oklahoma\", \", Pennsylvania\", \", California\", \", Arizona\", \", Idaho\", \", Indiana\"]\n i = 0; a = str\n while (i < s.length) do\n a = a.gsub(s[i], st[i])\n i += 1\n end\n a\nend", "def _rl_replace_text(text, start, _end)\r\n rl_begin_undo_group()\r\n rl_delete_text(start, _end + 1)\r\n @rl_point = start\r\n n = rl_insert_text(text)\r\n rl_end_undo_group()\r\n n\r\n end", "def replace(in_str)\n @out_str = in_str + \" \" + in_str\n end", "def escape(text)\n replacements.inject(text.to_s) do |corpus, (pattern, replacement)|\n corpus.gsub(pattern, replacement)\n end\n end", "def process_text text\n newtext = text.gsub(/if/, 'IF')\n\n 30.times { |i|\n newtext.gsub!(/for/, 'FOR')\n newtext.gsub!(/while/, 'WHILE')\n newtext.gsub!(/switch/, 'SWITCH')\n newtext.gsub!(/case/, 'CASE')\n newtext.gsub!(/goto/, 'GOTO')\n newtext.gsub!(/struct/, 'STRUCT')\n newtext.gsub!(/int/, 'INT')\n newtext.gsub!(/char/, 'CHAR')\n newtext.gsub!(/return/, 'RETURN')\n }\n\n return newtext\nend", "def replacements; end", "def update(text)\n text\n end", "def replace_pattern\n id = Readline.readline(\"ID of task to perform replace: \").to_i\n old_pattern = Readline.readline('replace : ').chomp\n new_pattern = Readline.readline('with : ').chomp\n ok = ReplacePattern.new(id, old_pattern, new_pattern).execute\n puts \"No such task\" if !ok\n end" ]
[ "0.7625409", "0.6899294", "0.6899294", "0.6899294", "0.6899294", "0.6899294", "0.6899294", "0.6899294", "0.6899294", "0.67564654", "0.67163825", "0.66556567", "0.66488314", "0.66175383", "0.6611373", "0.6597033", "0.6585868", "0.6544969", "0.64935786", "0.6457031", "0.6451065", "0.64262795", "0.6398766", "0.6398766", "0.6396333", "0.6382876", "0.63794625", "0.63472843", "0.6324176", "0.62962854", "0.6295815", "0.6279572", "0.6277207", "0.6228395", "0.6198103", "0.61966014", "0.61919373", "0.61787885", "0.6178697", "0.6173604", "0.6169155", "0.6166428", "0.6139212", "0.6128798", "0.612179", "0.61028904", "0.6053944", "0.60452205", "0.60452205", "0.6025615", "0.601645", "0.5999961", "0.59640974", "0.5960293", "0.5954005", "0.59508896", "0.5927739", "0.59247124", "0.5910995", "0.5909456", "0.5896766", "0.5892779", "0.58906174", "0.5884813", "0.58459187", "0.5845312", "0.58448565", "0.5839896", "0.5822585", "0.581617", "0.57924074", "0.57924074", "0.57897174", "0.57782644", "0.5777775", "0.5777775", "0.57705694", "0.57650936", "0.5759676", "0.575001", "0.57489884", "0.57349306", "0.5734629", "0.5724142", "0.5719324", "0.5717735", "0.5711605", "0.570321", "0.5697655", "0.5696305", "0.56847525", "0.56846476", "0.5676888", "0.56745183", "0.5673876", "0.5672595", "0.5668284", "0.5654643", "0.56439716", "0.5634754", "0.56241745" ]
0.0
-1
Detect text encoding of file Checks text encoding of file
def edit_text_text_encoding_detect(input_file, opts = {}) data, _status_code, _headers = edit_text_text_encoding_detect_with_http_info(input_file, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_encoding\n\tall_encoding = []\n\tfiles = Dir.glob(\"**/*.rb\") + Dir.glob(\"**/*.yml\") + Dir.glob(\"**/*.feature\")\n\tfiles.each do |file|\n\t\tall_encoding.push(File.open(file).map { |line| line.to_s.encoding })\n\tend\n\n\tnb = all_encoding.flatten.count { |encoding| encoding.name != 'UTF-8' }\n\tif nb > 0\n\t\tputs \"Error encoding file\"\n\t\t$errors = true\n\tend\nend", "def found_encoding; end", "def found_encoding; end", "def encoding_found; end", "def encoding_found; end", "def file_encoding(file)\n output = %x{file --mime-encoding #{file} 2>&1}.chomp\n regexp = Regexp.new(\"#{file}: (\\\\S+)\")\n matched = output.match(regexp)\n encoding = matched[1] if matched\n encoding = begin Encoding.find(encoding) rescue nil end\n end", "def detect_charset(path)\n Process.run_command 'uchardet', path\n rescue Errno::ENOENT\n # :nocov:\n Process.run_command('encguess', path).sub(/^.*\\s+/, '')\n # :nocov:\n end", "def find_encoding(encoding); end", "def is_text?(line)\n case NKF.guess(line)\n when NKF::BINARY then\n #puts \"===> it is binary file!\"\n return false;\n when NKF::JIS then \n #puts \"===> it is jis file!\"\n when NKF::SJIS then\n #puts \"===> it is sjis file!\"\n when NKF::UNKNOWN then\n #puts \"===> it is unknwon file!\"\n return false;\n when NKF::ASCII then\n #puts \"===> it is ascii file!\"\n when NKF::UTF8 then\n #puts \"===> it is utf8 file!\"\n when NKF::UTF16 then\n #puts \"===> it is utf16 file!\"\n end\n true\nend", "def external_utf8_check?(safe_path)\n iconv = system('command -v iconv > /dev/null 2>&1')\n return false unless iconv\n\n path = SafeFile.safepath_to_string(safe_path)\n system(\"iconv -f UTF-8 #{Shellwords.escape(path)} > /dev/null 2>&1\")\n end", "def find_enoding\n scmdlog = `file -I #{@file_name}`.strip\n scmdlog[/charset=(.+?)$/, 1]\n end", "def explicit_transcode(filename, from_encoding, to_encoding)\n puts ''\n puts `file test_files/#{filename}`\n puts \"transcoding from #{from_encoding.name} to #{to_encoding.name}\"\n\n file_str = read_file(filename)\n encoded_str = file_str.force_encoding(from_encoding).encode!(Encoding::UTF_8, from_encoding)\n\n puts encoded_str\n puts 'valid encoding: ' + encoded_str.valid_encoding?.to_s\n puts ''\nend", "def with_encoding_check(safe_path)\n forced_encoding = nil\n\n stream = ::File.open(SafeFile.safepath_to_string(safe_path))\n\n unless external_utf8_check?(safe_path)\n stream = StringIO.new ensure_utf8!(stream.read)\n forced_encoding = 'UTF8'\n end\n\n yield stream, forced_encoding\n end", "def isutf8;\tKconv.isutf8(self) end", "def encodings; end", "def iconv() end", "def encodings(safe_path)\n @encodings ||= determine_encodings!(safe_path)\n end", "def handle_encoding str\n str = str.dup\n has_enc = str.respond_to? :encoding # TODO: remove\n encoding = nil\n\n header = str.each_line.first(2)\n header.map! { |s| s.force_encoding \"ASCII-8BIT\" } if has_enc\n\n first = header.first || \"\"\n encoding, str = +\"utf-8\", str.b[3..-1] if first =~ /\\A\\xEF\\xBB\\xBF/\n\n encoding = $1.strip if header.find { |s|\n s[/^#.*?-\\*-.*?coding:\\s*([^ ;]+).*?-\\*-/, 1] ||\n s[/^#.*(?:en)?coding(?:\\s*[:=])\\s*([\\w-]+)/, 1]\n }\n\n if encoding then\n if has_enc then\n encoding.sub!(/utf-8-.+$/, \"utf-8\") # HACK for stupid emacs formats\n hack_encoding str, encoding\n else\n warn \"Skipping magic encoding comment\"\n end\n else\n # nothing specified... ugh. try to encode as utf-8\n hack_encoding str if has_enc\n end\n\n str\n end", "def content_encoding\n v = @meta['content-encoding']\n if v && %r{\\A#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?(?:,#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?)*}o =~ v\n v.scan(RE_TOKEN).map {|content_coding| content_coding.downcase}\n else\n []\n end\n end", "def check_utf8_encoding\n return nil if self.encoding != Encoding.find('utf-8')\n state = :s0\n n_of_chars = 0\n self.bytes.each do |byte|\n case state\n when :s0\n n_of_chars += 1\n if (0x00..0x7F).include?(byte) then state = :s0\n elsif (0xC2..0xDF).include?(byte) then state = :s1\n elsif 0xE0 == byte then state = :s2\n elsif (0xE1..0xEC).include?(byte) || (0xEE..0xEF).include?(byte) then state = :s3\n elsif 0xED == byte then state = :s4\n elsif 0xF0 == byte then state = :s5\n elsif (0xF1..0xF3).include?(byte) then state = :s7\n elsif 0xF4 == byte then state = :s8\n else return nil end\n when :s1\n if (0x80..0xBF).include?(byte) then state = :s0 \n else return nil end\n when :s2\n if (0xA0..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s3\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s4\n if (0x80..0x9F).include?(byte) then state = :s1\n else return nil end\n when :s5\n if (0x90..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s6\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s7\n if (0x80..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s8\n if (0x80..0x8F).include?(byte) then state = :s6\n else return nil end\n end # case\n end # self.bytes.each\n if state == :s0 then return n_of_chars\n else return nil end\n end", "def try_with_encoding(string, encoding); end", "def try_with_encoding(string, encoding); end", "def process_encoding(source)\n source.force_encoding(Encoding::UTF_8)\n end", "def convert_encoding(content); end", "def is_utf8?\n case encoding\n when Encoding::UTF_8, Encoding::US_ASCII\n valid_encoding?\n when Encoding::ASCII_8BIT\n dup.force_encoding(Encoding::UTF_8).valid_encoding?\n else\n false\n end\n end", "def text_file?(file)\n return false unless File.readable?(file)\n bytes = File.stat(file).blksize\n bytes = 4096 if bytes > 4096\n s = (File.read(file, bytes) || \"\")\n s = s.encode('US-ASCII', :undef => :replace).split(//)\n return (s.grep(\" \"..\"~\").size.to_f / s.size.to_f) > 0.85\n end", "def only_valid_chars(text)\n return \"\" unless text\n xmltext=\"\"\n File.open(text) do |f|\n # this removes bad control characters\n xmltext = Iconv.conv('UTF-8//IGNORE', 'UTF-8', f.read.gsub(/[\\u0001-\\u001A]/ , ''))\n \n end\n\n xmltext.encode('UTF-8', 'UTF-8', {:invalid => :replace, :undef => :replace, :replace => \"\"})\n \n return xmltext\nend", "def texte\n @texte ||= begin\n exist? && File.read(path).force_encoding('utf-8')\n end\n end", "def encoding(encoding); end", "def meta_encoding; end", "def meta_encoding; end", "def read_text(filename); end", "def ascii?\n ASCII_ENCODINGS.include?(encoding)\n end", "def detect_encodings(hint_enc=nil)\n detector = CharlockHolmes::EncodingDetector.new\n detector.detect_all(self, hint_enc)\n end", "def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end", "def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end", "def file_mode(m)\n Cucumber::RUBY_1_9 ? \"#{m}:#{keyword_hash['encoding']}\" : m\n end", "def determine_encodings!(safe_path)\n # delimiter encoding => # FasterCSV encoding string\n supported_encodings = {\n 'UTF-8' => 'bom|utf-8',\n 'Windows-1252' => 'windows-1252:utf-8'\n }\n\n successful_options = nil\n supported_encodings.each do |delimiter_encoding, csv_encoding|\n begin\n col_sep = @options['col_sep']\n options = {\n :col_sep => (col_sep || ',').force_encoding(delimiter_encoding),\n :encoding => csv_encoding\n }\n\n row_num = 0\n # Iterate through the file; if we reach the end, this encoding worked:\n CSVLibrary.foreach(safe_path, options) { |_line| row_num += 1 }\n rescue ArgumentError => e\n next if e.message =~ /invalid byte sequence/ # This encoding didn't work\n raise(e)\n rescue CSVLibrary::MalformedCSVError => e\n description = (col_sep ? col_sep.inspect + ' delimited' : 'CSV')\n\n raise(CSVLibrary::MalformedCSVError, \"Invalid #{description} format \" \\\n \"on row #{row_num + 1} of #{::File.basename(safe_path)}. Original: #{e.message}\")\n end\n\n # We got this far => encoding choice worked:\n successful_options = options\n break\n end\n\n # We tried them all, and none worked:\n unless successful_options\n fail \"None of the encodings #{supported_encodings.values.inspect} were successful!\"\n end\n\n successful_options\n end", "def file_sanitizer(file)\n\t file = File.open(file, mode=\"r+\")\n\t content = File.read(file)\n\t\tcontent.force_encoding(Encoding::Windows_1252)\n\t\tcontent = content.encode!(Encoding::UTF_8, :universal_newline => true)\n\t content.gsub!(\"\\r\\n\",\"\\n\")\n\t\tcontent\n\tend", "def determine_encodings!(*)\n @encoding ||= super\n end", "def isBinary?(fname)\n readbuf = get_file_contents(fname)\n count = 0\n# puts \"The size is: #{readbuf.length()}.\"\n threshold = Integer(readbuf.length() * 0.25)\n# puts \"Threshold: #{threshold}.\"\n readbuf.each_byte do |byte| #I have to use each_byte because Ruby 1.8.6 (Darwin) is\n #fucked and doesnt have String::each_char\n if !(0x20..0x7f).include?(byte) then\n #puts \"Non-ascii byte found: #{byte}\"\n count+=1 \n end\n end\n# puts \"#{count} nonascii bytes found in file.\"\n if count >= threshold then\n return true\n else \n return false\n end\nend", "def default_encoding; end", "def default_encoding; end", "def convert_encoding(content)\n return content if RUBY18\n if content =~ /\\A\\s*#.*coding:\\s*(\\S+)\\s*$/\n content.force_encoding($1)\n else\n content\n end\n end", "def ruby_m17n?\n return true if \"\".respond_to? :encoding\nend", "def extract_charset_from_text(text)\n force_to_utf8(text.to_s&.first(5_000))&.scan(%r{<meta(?!\\s*(?:name|value)\\s*=)[^>]*?charset\\s*=[\\s\"']*([^\\s\"'\\/>]*)})\n &.first\n &.upcase\n &.gsub('-', '_')\n rescue ArgumentError => e\n raise e unless e.to_s.include?('invalid byte')\n\n nil\n end", "def guess_encoding(guesser = CharDet)\n Encoding.find(guesser.detect(self, :silent => true)[\"encoding\"])\n end", "def encoding_line; end", "def binary?(file)\n return false if file =~ /\\.(rb|txt)$/\n\n s = File.read(file, 1024) or return false\n\n have_encoding = s.respond_to? :encoding\n\n if have_encoding then\n return false if s.encoding != Encoding::ASCII_8BIT and s.valid_encoding?\n end\n\n return true if s[0, 2] == Marshal.dump('')[0, 2] or s.index(\"\\x00\")\n\n if have_encoding then\n s.force_encoding Encoding.default_external\n\n not s.valid_encoding?\n else\n if 0.respond_to? :fdiv then\n s.count(\"\\x00-\\x7F\", \"^ -~\\t\\r\\n\").fdiv(s.size) > 0.3\n else # HACK 1.8.6\n (s.count(\"\\x00-\\x7F\", \"^ -~\\t\\r\\n\").to_f / s.size) > 0.3\n end\n end\n end", "def ignore_encoding_error; end", "def transliterate_whole_file_to_utf8!\n if ::UnixUtils.available?('iconv')\n local_copy.in_place :iconv, RemoteTable::EXTERNAL_ENCODING_ICONV, encoding\n else\n ::Kernel.warn %{[remote_table] iconv not available in your $PATH, not performing transliteration}\n end\n # now that we've force-transliterated to UTF-8, act as though this is what the user had specified\n @encoding = RemoteTable::EXTERNAL_ENCODING\n end", "def text?\n\t\t\t\t#!! %x/file #{self.to_s}/.match(/text/)\n\t\t\t\treturn false if directory?\n\t\t\t\t!binary?\n\t\t\tend", "def check_format(file)\n \tbegin\n content = file_content(file)\n content = content.split(\"\\n\").reject { |c| c.empty? }\n read_file(content)\n rescue\n raise_error ERROR_READING_FILE\n end\n end", "def raise_encoding_error(filename, encoding)\n raise \"Could not read #{filename} because the file is not valid #{encoding}.\"\n end", "def external_encoding()\n #This is a stub, used for indexing\n end", "def open_file\n begin\n @text = File.open(@file_name).read\n @text.gsub!(/\\r\\n?/, '\\n')\n rescue => e\n Utils_errors::critical_error('could not open file ' + @file_name.yellow, e)\n end\n true\n end", "def normalize_encoding(text)\n text.encode('windows-1252')\n rescue ::Encoding::InvalidByteSequenceError,\n ::Encoding::UndefinedConversionError\n\n raise Prawn::Errors::IncompatibleStringEncoding,\n \"Your document includes text that's not compatible with the \" \\\n \"Windows-1252 character set.\\n\" \\\n \"If you need full UTF-8 support, use TTF fonts instead of PDF's \" \\\n \"built-in fonts.\\n\"\n end", "def html_encoding?(html)\n chunk = html[0..1024]\n\n charset = nil\n chunk.split(/\\n/).each do |l|\n m = /Content-Type.*\"(.*?)\"/i.match(l)\n if m && m[1]\n return encoding_from_content_type(m[1])\n end\n end\n nil\n end", "def encoding_from_feed_data\n if @encoding_from_feed_data.blank?\n raw_data = self.feed_data\n return nil if raw_data.nil?\n encoding_from_xml_instruct = \n raw_data.scan(\n /^<\\?xml [^>]*encoding=\"([^\\\"]*)\"[^>]*\\?>/\n ).flatten.first\n unless encoding_from_xml_instruct.blank?\n encoding_from_xml_instruct.downcase!\n end\n if encoding_from_xml_instruct.blank?\n begin\n doc = REXML::Document.new(raw_data)\n encoding_from_xml_instruct = doc.encoding.downcase\n if encoding_from_xml_instruct == \"utf-8\"\n # REXML has a tendency to report utf-8 overzealously, take with\n # grain of salt\n encoding_from_xml_instruct = nil\n end\n rescue\n end\n else\n @encoding_from_feed_data = encoding_from_xml_instruct\n end\n if encoding_from_xml_instruct.blank?\n sniff_table = {\n \"Lo\\247\\224\" => \"ebcdic-cp-us\",\n \"<?xm\" => \"utf-8\"\n }\n sniff = self.feed_data[0..3]\n if sniff_table[sniff] != nil\n @encoding_from_feed_data = sniff_table[sniff].downcase\n end\n else\n @encoding_from_feed_data = encoding_from_xml_instruct\n end\n if @encoding_from_feed_data.blank?\n # Safest assumption\n @encoding_from_feed_data = \"utf-8\"\n end\n end\n return @encoding_from_feed_data\n end", "def charset\n #@data.charset ||= CharGuess.guess(document).downcase\n end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def iso8859_1?\n encoding == \"ISO-8859-1\"\n end", "def iso8859_1?\n encoding == \"ISO-8859-1\"\n end", "def mime_type_charset_detecter(mime_type)\n if type = config[:mime_types][mime_type]\n if detect = type[:charset]\n return detect\n end\n end\n end", "def check_file(filename)\n result = [[], filename, :unknown, :clean]\n\n File.open(filename, \"rb\") do |f|\n\n # ファイルを読み込む\n begin\n header = f.read(8)\n f.seek(-12, IO::SEEK_END)\n footer = f.read(12)\n rescue\n result[0].push(\"ファイルが破損しています\")\n return result\n end\n\n # ファイル破損チェック\n if header[0, 2].unpack(\"H*\") == [ \"ffd8\" ]\n unless footer[-2, 2].unpack(\"H*\") == [ \"ffd9\" ] then\n result[3] = :damaged\n end\n result[2] = \".jpg\"\n elsif header[0, 3].unpack(\"A*\") == [ \"GIF\" ]\n unless footer[-1, 1].unpack(\"H*\") == [ \"3b\" ] then\n result[0].push(\"ファイルが破損しています\")\n result[3] = :damaged\n end\n result[2] = \".gif\"\n elsif header[0, 8].unpack(\"H*\") == [ \"89504e470d0a1a0a\" ]\n unless footer[-12, 12].unpack(\"H*\") == [ \"0000000049454e44ae426082\" ]\n result[0].push(\"ファイルが破損しています\")\n result[3] = :damaged\n end\n result[2] = \".png\"\n end\n\n # 拡張子の齟齬チェック\n if File.extname(filename) != result[2]\n result[0].push(\"拡張子が間違っています\")\n if(result[3] == :damaged)\n result[3] = :ext_error_damaged\n else\n result[3] = :ext_error\n end\n end\n\n end\n\n result\nend", "def infected?(filename)\n file = File.open(filename)\n data = file.read\n file.close\n\n if data.include? '#@! infected by virus !@#'\n true\n else\n false\n end\nend", "def readfile(path, opt={})\n if File.readable?(path)\n bin = File.read(path).utf8!\n [bin, bin.former_enc ||'ascii-8bit' ]\n else\n raise ArgumentError.new(\"File is not readable!\")\n end\n end", "def force_utf32; end", "def force_utf32; end", "def force_utf32; end", "def find_file(path_info, accept_encoding:); end", "def binary?\n BINARY_ENCODINGS.include?(encoding)\n end", "def convert_string_to_utf8(string)\n begin\n # string is probably already unicode if it parses at UTF-8\n Iconv.iconv('UTF-8', 'UTF-8', string)\n return false\n rescue\n # try ISO-8859-15, then give up.\n begin\n return Iconv.iconv( 'UTF-8', 'ISO-8859-15', string )\n rescue\n return false\n end\n end\n return false\nend", "def is_utf8?\n ActiveSupport::Multibyte::Handlers::UTF8Handler.consumes?(self)\n end", "def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end", "def have_encoding?\n Object.const_defined? :Encoding\n end", "def encoding\n @content[pn(:Encoding)]\n end", "def convert_encoding(content)\n return content unless content.respond_to?(:force_encoding)\n if content =~ ENCODING_LINE\n content.force_encoding($1)\n else\n content.force_encoding('binary')\n ENCODING_BYTE_ORDER_MARKS.each do |encoding, bom|\n bom.force_encoding('binary')\n if content[0, bom.size] == bom\n content.force_encoding(encoding)\n return content\n end\n end\n content.force_encoding('utf-8') # UTF-8 is default encoding\n content\n end\n end", "def file_sanitizer(file)\n file = File.open(file, mode=\"r+\")\n content = File.read(file)\n\tcontent.force_encoding(Encoding::Windows_1252)\n\tcontent = content.encode!(Encoding::UTF_8, :universal_newline => true)\n content.gsub!(\"\\r\\n\",\"\\n\")\n file.write(content)\nend", "def utf8read(x)\n File.open(x,\"rb\"){|f|\n if f.getbyte!=0xef || f.getbyte!=0xbb || f.getbyte!=0xbf\n f.pos=0 # skip UTF-8 byte order mark\n end\n data=f.read\n ec1=Encoding::Converter.new(\"utf-8\",\"utf-16\",{\n :undef=>:replace,\n :invalid=>:replace\n })\n ec2=Encoding::Converter.new(\"utf-16\",\"utf-8\",{\n :undef=>:replace,\n :invalid=>:replace,\n :replace=>\"\\uFFFD\"\n })\n data=ec1.convert(data)\n data=ec2.convert(data)\n return data\n }\nend", "def characterize(save: true)\n TikaFileCharacterizationService.new(file_node: file_node, persister: persister).characterize\n external_metadata_service.characterize if external_metadata_service.valid?\n end", "def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message.scrub =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end", "def test_self_to_nfc_encoding\n assert_equal @unistr_up.NFC.encoding, Encoding::UTF_8\n end", "def charset; end", "def charset; end", "def charset; end" ]
[ "0.7468341", "0.7315846", "0.7315846", "0.7143658", "0.7143658", "0.7135522", "0.70065147", "0.6690792", "0.66232216", "0.6559273", "0.6357972", "0.6327798", "0.63072276", "0.6252365", "0.60887176", "0.6066811", "0.60543954", "0.60470784", "0.5998056", "0.5984209", "0.59748805", "0.59748805", "0.5974118", "0.59612936", "0.5958269", "0.59581274", "0.5947069", "0.593833", "0.59205616", "0.5917292", "0.5917292", "0.5870407", "0.586127", "0.5859421", "0.5852351", "0.5852351", "0.5842253", "0.5837809", "0.583353", "0.58222866", "0.58089375", "0.5780852", "0.5780852", "0.57763183", "0.5758612", "0.5754462", "0.57346976", "0.57272995", "0.572181", "0.57073444", "0.57043296", "0.56917477", "0.56722766", "0.56716996", "0.56680137", "0.56479734", "0.5637538", "0.5620323", "0.561689", "0.56155026", "0.5611683", "0.5611683", "0.5611683", "0.5611683", "0.5611683", "0.5611683", "0.5611683", "0.5611683", "0.5611683", "0.5611683", "0.5611683", "0.5611683", "0.5611683", "0.5611683", "0.5611683", "0.5607104", "0.5607104", "0.56007326", "0.5599195", "0.5565134", "0.55646604", "0.5548844", "0.5548844", "0.5548844", "0.5548522", "0.55465734", "0.5544286", "0.55385894", "0.5532372", "0.5531875", "0.55235755", "0.5518352", "0.5516036", "0.5512101", "0.54984397", "0.5498128", "0.5492241", "0.5479142", "0.5479142", "0.5479142" ]
0.7079332
6
Detect text encoding of file Checks text encoding of file
def edit_text_text_encoding_detect_with_http_info(input_file, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_text_encoding_detect ...' end # verify the required parameter 'input_file' is set if @api_client.config.client_side_validation && input_file.nil? fail ArgumentError, "Missing the required parameter 'input_file' when calling EditTextApi.edit_text_text_encoding_detect" end # resource path local_var_path = '/convert/edit/text/encoding/detect' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = {} form_params['inputFile'] = input_file # http body (model) post_body = nil auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'TextEncodingDetectResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_text_encoding_detect\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_encoding\n\tall_encoding = []\n\tfiles = Dir.glob(\"**/*.rb\") + Dir.glob(\"**/*.yml\") + Dir.glob(\"**/*.feature\")\n\tfiles.each do |file|\n\t\tall_encoding.push(File.open(file).map { |line| line.to_s.encoding })\n\tend\n\n\tnb = all_encoding.flatten.count { |encoding| encoding.name != 'UTF-8' }\n\tif nb > 0\n\t\tputs \"Error encoding file\"\n\t\t$errors = true\n\tend\nend", "def found_encoding; end", "def found_encoding; end", "def encoding_found; end", "def encoding_found; end", "def file_encoding(file)\n output = %x{file --mime-encoding #{file} 2>&1}.chomp\n regexp = Regexp.new(\"#{file}: (\\\\S+)\")\n matched = output.match(regexp)\n encoding = matched[1] if matched\n encoding = begin Encoding.find(encoding) rescue nil end\n end", "def edit_text_text_encoding_detect(input_file, opts = {})\n data, _status_code, _headers = edit_text_text_encoding_detect_with_http_info(input_file, opts)\n data\n end", "def detect_charset(path)\n Process.run_command 'uchardet', path\n rescue Errno::ENOENT\n # :nocov:\n Process.run_command('encguess', path).sub(/^.*\\s+/, '')\n # :nocov:\n end", "def find_encoding(encoding); end", "def is_text?(line)\n case NKF.guess(line)\n when NKF::BINARY then\n #puts \"===> it is binary file!\"\n return false;\n when NKF::JIS then \n #puts \"===> it is jis file!\"\n when NKF::SJIS then\n #puts \"===> it is sjis file!\"\n when NKF::UNKNOWN then\n #puts \"===> it is unknwon file!\"\n return false;\n when NKF::ASCII then\n #puts \"===> it is ascii file!\"\n when NKF::UTF8 then\n #puts \"===> it is utf8 file!\"\n when NKF::UTF16 then\n #puts \"===> it is utf16 file!\"\n end\n true\nend", "def external_utf8_check?(safe_path)\n iconv = system('command -v iconv > /dev/null 2>&1')\n return false unless iconv\n\n path = SafeFile.safepath_to_string(safe_path)\n system(\"iconv -f UTF-8 #{Shellwords.escape(path)} > /dev/null 2>&1\")\n end", "def find_enoding\n scmdlog = `file -I #{@file_name}`.strip\n scmdlog[/charset=(.+?)$/, 1]\n end", "def explicit_transcode(filename, from_encoding, to_encoding)\n puts ''\n puts `file test_files/#{filename}`\n puts \"transcoding from #{from_encoding.name} to #{to_encoding.name}\"\n\n file_str = read_file(filename)\n encoded_str = file_str.force_encoding(from_encoding).encode!(Encoding::UTF_8, from_encoding)\n\n puts encoded_str\n puts 'valid encoding: ' + encoded_str.valid_encoding?.to_s\n puts ''\nend", "def with_encoding_check(safe_path)\n forced_encoding = nil\n\n stream = ::File.open(SafeFile.safepath_to_string(safe_path))\n\n unless external_utf8_check?(safe_path)\n stream = StringIO.new ensure_utf8!(stream.read)\n forced_encoding = 'UTF8'\n end\n\n yield stream, forced_encoding\n end", "def isutf8;\tKconv.isutf8(self) end", "def encodings; end", "def iconv() end", "def encodings(safe_path)\n @encodings ||= determine_encodings!(safe_path)\n end", "def handle_encoding str\n str = str.dup\n has_enc = str.respond_to? :encoding # TODO: remove\n encoding = nil\n\n header = str.each_line.first(2)\n header.map! { |s| s.force_encoding \"ASCII-8BIT\" } if has_enc\n\n first = header.first || \"\"\n encoding, str = +\"utf-8\", str.b[3..-1] if first =~ /\\A\\xEF\\xBB\\xBF/\n\n encoding = $1.strip if header.find { |s|\n s[/^#.*?-\\*-.*?coding:\\s*([^ ;]+).*?-\\*-/, 1] ||\n s[/^#.*(?:en)?coding(?:\\s*[:=])\\s*([\\w-]+)/, 1]\n }\n\n if encoding then\n if has_enc then\n encoding.sub!(/utf-8-.+$/, \"utf-8\") # HACK for stupid emacs formats\n hack_encoding str, encoding\n else\n warn \"Skipping magic encoding comment\"\n end\n else\n # nothing specified... ugh. try to encode as utf-8\n hack_encoding str if has_enc\n end\n\n str\n end", "def content_encoding\n v = @meta['content-encoding']\n if v && %r{\\A#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?(?:,#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?)*}o =~ v\n v.scan(RE_TOKEN).map {|content_coding| content_coding.downcase}\n else\n []\n end\n end", "def check_utf8_encoding\n return nil if self.encoding != Encoding.find('utf-8')\n state = :s0\n n_of_chars = 0\n self.bytes.each do |byte|\n case state\n when :s0\n n_of_chars += 1\n if (0x00..0x7F).include?(byte) then state = :s0\n elsif (0xC2..0xDF).include?(byte) then state = :s1\n elsif 0xE0 == byte then state = :s2\n elsif (0xE1..0xEC).include?(byte) || (0xEE..0xEF).include?(byte) then state = :s3\n elsif 0xED == byte then state = :s4\n elsif 0xF0 == byte then state = :s5\n elsif (0xF1..0xF3).include?(byte) then state = :s7\n elsif 0xF4 == byte then state = :s8\n else return nil end\n when :s1\n if (0x80..0xBF).include?(byte) then state = :s0 \n else return nil end\n when :s2\n if (0xA0..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s3\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s4\n if (0x80..0x9F).include?(byte) then state = :s1\n else return nil end\n when :s5\n if (0x90..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s6\n if (0x80..0xBF).include?(byte) then state = :s1\n else return nil end\n when :s7\n if (0x80..0xBF).include?(byte) then state = :s6\n else return nil end\n when :s8\n if (0x80..0x8F).include?(byte) then state = :s6\n else return nil end\n end # case\n end # self.bytes.each\n if state == :s0 then return n_of_chars\n else return nil end\n end", "def try_with_encoding(string, encoding); end", "def try_with_encoding(string, encoding); end", "def process_encoding(source)\n source.force_encoding(Encoding::UTF_8)\n end", "def convert_encoding(content); end", "def is_utf8?\n case encoding\n when Encoding::UTF_8, Encoding::US_ASCII\n valid_encoding?\n when Encoding::ASCII_8BIT\n dup.force_encoding(Encoding::UTF_8).valid_encoding?\n else\n false\n end\n end", "def text_file?(file)\n return false unless File.readable?(file)\n bytes = File.stat(file).blksize\n bytes = 4096 if bytes > 4096\n s = (File.read(file, bytes) || \"\")\n s = s.encode('US-ASCII', :undef => :replace).split(//)\n return (s.grep(\" \"..\"~\").size.to_f / s.size.to_f) > 0.85\n end", "def only_valid_chars(text)\n return \"\" unless text\n xmltext=\"\"\n File.open(text) do |f|\n # this removes bad control characters\n xmltext = Iconv.conv('UTF-8//IGNORE', 'UTF-8', f.read.gsub(/[\\u0001-\\u001A]/ , ''))\n \n end\n\n xmltext.encode('UTF-8', 'UTF-8', {:invalid => :replace, :undef => :replace, :replace => \"\"})\n \n return xmltext\nend", "def texte\n @texte ||= begin\n exist? && File.read(path).force_encoding('utf-8')\n end\n end", "def encoding(encoding); end", "def meta_encoding; end", "def meta_encoding; end", "def read_text(filename); end", "def ascii?\n ASCII_ENCODINGS.include?(encoding)\n end", "def detect_encodings(hint_enc=nil)\n detector = CharlockHolmes::EncodingDetector.new\n detector.detect_all(self, hint_enc)\n end", "def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end", "def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end", "def file_mode(m)\n Cucumber::RUBY_1_9 ? \"#{m}:#{keyword_hash['encoding']}\" : m\n end", "def determine_encodings!(safe_path)\n # delimiter encoding => # FasterCSV encoding string\n supported_encodings = {\n 'UTF-8' => 'bom|utf-8',\n 'Windows-1252' => 'windows-1252:utf-8'\n }\n\n successful_options = nil\n supported_encodings.each do |delimiter_encoding, csv_encoding|\n begin\n col_sep = @options['col_sep']\n options = {\n :col_sep => (col_sep || ',').force_encoding(delimiter_encoding),\n :encoding => csv_encoding\n }\n\n row_num = 0\n # Iterate through the file; if we reach the end, this encoding worked:\n CSVLibrary.foreach(safe_path, options) { |_line| row_num += 1 }\n rescue ArgumentError => e\n next if e.message =~ /invalid byte sequence/ # This encoding didn't work\n raise(e)\n rescue CSVLibrary::MalformedCSVError => e\n description = (col_sep ? col_sep.inspect + ' delimited' : 'CSV')\n\n raise(CSVLibrary::MalformedCSVError, \"Invalid #{description} format \" \\\n \"on row #{row_num + 1} of #{::File.basename(safe_path)}. Original: #{e.message}\")\n end\n\n # We got this far => encoding choice worked:\n successful_options = options\n break\n end\n\n # We tried them all, and none worked:\n unless successful_options\n fail \"None of the encodings #{supported_encodings.values.inspect} were successful!\"\n end\n\n successful_options\n end", "def file_sanitizer(file)\n\t file = File.open(file, mode=\"r+\")\n\t content = File.read(file)\n\t\tcontent.force_encoding(Encoding::Windows_1252)\n\t\tcontent = content.encode!(Encoding::UTF_8, :universal_newline => true)\n\t content.gsub!(\"\\r\\n\",\"\\n\")\n\t\tcontent\n\tend", "def determine_encodings!(*)\n @encoding ||= super\n end", "def isBinary?(fname)\n readbuf = get_file_contents(fname)\n count = 0\n# puts \"The size is: #{readbuf.length()}.\"\n threshold = Integer(readbuf.length() * 0.25)\n# puts \"Threshold: #{threshold}.\"\n readbuf.each_byte do |byte| #I have to use each_byte because Ruby 1.8.6 (Darwin) is\n #fucked and doesnt have String::each_char\n if !(0x20..0x7f).include?(byte) then\n #puts \"Non-ascii byte found: #{byte}\"\n count+=1 \n end\n end\n# puts \"#{count} nonascii bytes found in file.\"\n if count >= threshold then\n return true\n else \n return false\n end\nend", "def default_encoding; end", "def default_encoding; end", "def convert_encoding(content)\n return content if RUBY18\n if content =~ /\\A\\s*#.*coding:\\s*(\\S+)\\s*$/\n content.force_encoding($1)\n else\n content\n end\n end", "def ruby_m17n?\n return true if \"\".respond_to? :encoding\nend", "def extract_charset_from_text(text)\n force_to_utf8(text.to_s&.first(5_000))&.scan(%r{<meta(?!\\s*(?:name|value)\\s*=)[^>]*?charset\\s*=[\\s\"']*([^\\s\"'\\/>]*)})\n &.first\n &.upcase\n &.gsub('-', '_')\n rescue ArgumentError => e\n raise e unless e.to_s.include?('invalid byte')\n\n nil\n end", "def guess_encoding(guesser = CharDet)\n Encoding.find(guesser.detect(self, :silent => true)[\"encoding\"])\n end", "def encoding_line; end", "def binary?(file)\n return false if file =~ /\\.(rb|txt)$/\n\n s = File.read(file, 1024) or return false\n\n have_encoding = s.respond_to? :encoding\n\n if have_encoding then\n return false if s.encoding != Encoding::ASCII_8BIT and s.valid_encoding?\n end\n\n return true if s[0, 2] == Marshal.dump('')[0, 2] or s.index(\"\\x00\")\n\n if have_encoding then\n s.force_encoding Encoding.default_external\n\n not s.valid_encoding?\n else\n if 0.respond_to? :fdiv then\n s.count(\"\\x00-\\x7F\", \"^ -~\\t\\r\\n\").fdiv(s.size) > 0.3\n else # HACK 1.8.6\n (s.count(\"\\x00-\\x7F\", \"^ -~\\t\\r\\n\").to_f / s.size) > 0.3\n end\n end\n end", "def ignore_encoding_error; end", "def transliterate_whole_file_to_utf8!\n if ::UnixUtils.available?('iconv')\n local_copy.in_place :iconv, RemoteTable::EXTERNAL_ENCODING_ICONV, encoding\n else\n ::Kernel.warn %{[remote_table] iconv not available in your $PATH, not performing transliteration}\n end\n # now that we've force-transliterated to UTF-8, act as though this is what the user had specified\n @encoding = RemoteTable::EXTERNAL_ENCODING\n end", "def text?\n\t\t\t\t#!! %x/file #{self.to_s}/.match(/text/)\n\t\t\t\treturn false if directory?\n\t\t\t\t!binary?\n\t\t\tend", "def raise_encoding_error(filename, encoding)\n raise \"Could not read #{filename} because the file is not valid #{encoding}.\"\n end", "def check_format(file)\n \tbegin\n content = file_content(file)\n content = content.split(\"\\n\").reject { |c| c.empty? }\n read_file(content)\n rescue\n raise_error ERROR_READING_FILE\n end\n end", "def external_encoding()\n #This is a stub, used for indexing\n end", "def open_file\n begin\n @text = File.open(@file_name).read\n @text.gsub!(/\\r\\n?/, '\\n')\n rescue => e\n Utils_errors::critical_error('could not open file ' + @file_name.yellow, e)\n end\n true\n end", "def normalize_encoding(text)\n text.encode('windows-1252')\n rescue ::Encoding::InvalidByteSequenceError,\n ::Encoding::UndefinedConversionError\n\n raise Prawn::Errors::IncompatibleStringEncoding,\n \"Your document includes text that's not compatible with the \" \\\n \"Windows-1252 character set.\\n\" \\\n \"If you need full UTF-8 support, use TTF fonts instead of PDF's \" \\\n \"built-in fonts.\\n\"\n end", "def html_encoding?(html)\n chunk = html[0..1024]\n\n charset = nil\n chunk.split(/\\n/).each do |l|\n m = /Content-Type.*\"(.*?)\"/i.match(l)\n if m && m[1]\n return encoding_from_content_type(m[1])\n end\n end\n nil\n end", "def encoding_from_feed_data\n if @encoding_from_feed_data.blank?\n raw_data = self.feed_data\n return nil if raw_data.nil?\n encoding_from_xml_instruct = \n raw_data.scan(\n /^<\\?xml [^>]*encoding=\"([^\\\"]*)\"[^>]*\\?>/\n ).flatten.first\n unless encoding_from_xml_instruct.blank?\n encoding_from_xml_instruct.downcase!\n end\n if encoding_from_xml_instruct.blank?\n begin\n doc = REXML::Document.new(raw_data)\n encoding_from_xml_instruct = doc.encoding.downcase\n if encoding_from_xml_instruct == \"utf-8\"\n # REXML has a tendency to report utf-8 overzealously, take with\n # grain of salt\n encoding_from_xml_instruct = nil\n end\n rescue\n end\n else\n @encoding_from_feed_data = encoding_from_xml_instruct\n end\n if encoding_from_xml_instruct.blank?\n sniff_table = {\n \"Lo\\247\\224\" => \"ebcdic-cp-us\",\n \"<?xm\" => \"utf-8\"\n }\n sniff = self.feed_data[0..3]\n if sniff_table[sniff] != nil\n @encoding_from_feed_data = sniff_table[sniff].downcase\n end\n else\n @encoding_from_feed_data = encoding_from_xml_instruct\n end\n if @encoding_from_feed_data.blank?\n # Safest assumption\n @encoding_from_feed_data = \"utf-8\"\n end\n end\n return @encoding_from_feed_data\n end", "def charset\n #@data.charset ||= CharGuess.guess(document).downcase\n end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def iso8859_1?\n encoding == \"ISO-8859-1\"\n end", "def iso8859_1?\n encoding == \"ISO-8859-1\"\n end", "def mime_type_charset_detecter(mime_type)\n if type = config[:mime_types][mime_type]\n if detect = type[:charset]\n return detect\n end\n end\n end", "def check_file(filename)\n result = [[], filename, :unknown, :clean]\n\n File.open(filename, \"rb\") do |f|\n\n # ファイルを読み込む\n begin\n header = f.read(8)\n f.seek(-12, IO::SEEK_END)\n footer = f.read(12)\n rescue\n result[0].push(\"ファイルが破損しています\")\n return result\n end\n\n # ファイル破損チェック\n if header[0, 2].unpack(\"H*\") == [ \"ffd8\" ]\n unless footer[-2, 2].unpack(\"H*\") == [ \"ffd9\" ] then\n result[3] = :damaged\n end\n result[2] = \".jpg\"\n elsif header[0, 3].unpack(\"A*\") == [ \"GIF\" ]\n unless footer[-1, 1].unpack(\"H*\") == [ \"3b\" ] then\n result[0].push(\"ファイルが破損しています\")\n result[3] = :damaged\n end\n result[2] = \".gif\"\n elsif header[0, 8].unpack(\"H*\") == [ \"89504e470d0a1a0a\" ]\n unless footer[-12, 12].unpack(\"H*\") == [ \"0000000049454e44ae426082\" ]\n result[0].push(\"ファイルが破損しています\")\n result[3] = :damaged\n end\n result[2] = \".png\"\n end\n\n # 拡張子の齟齬チェック\n if File.extname(filename) != result[2]\n result[0].push(\"拡張子が間違っています\")\n if(result[3] == :damaged)\n result[3] = :ext_error_damaged\n else\n result[3] = :ext_error\n end\n end\n\n end\n\n result\nend", "def readfile(path, opt={})\n if File.readable?(path)\n bin = File.read(path).utf8!\n [bin, bin.former_enc ||'ascii-8bit' ]\n else\n raise ArgumentError.new(\"File is not readable!\")\n end\n end", "def infected?(filename)\n file = File.open(filename)\n data = file.read\n file.close\n\n if data.include? '#@! infected by virus !@#'\n true\n else\n false\n end\nend", "def force_utf32; end", "def force_utf32; end", "def force_utf32; end", "def find_file(path_info, accept_encoding:); end", "def binary?\n BINARY_ENCODINGS.include?(encoding)\n end", "def convert_string_to_utf8(string)\n begin\n # string is probably already unicode if it parses at UTF-8\n Iconv.iconv('UTF-8', 'UTF-8', string)\n return false\n rescue\n # try ISO-8859-15, then give up.\n begin\n return Iconv.iconv( 'UTF-8', 'ISO-8859-15', string )\n rescue\n return false\n end\n end\n return false\nend", "def is_utf8?\n ActiveSupport::Multibyte::Handlers::UTF8Handler.consumes?(self)\n end", "def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end", "def have_encoding?\n Object.const_defined? :Encoding\n end", "def encoding\n @content[pn(:Encoding)]\n end", "def convert_encoding(content)\n return content unless content.respond_to?(:force_encoding)\n if content =~ ENCODING_LINE\n content.force_encoding($1)\n else\n content.force_encoding('binary')\n ENCODING_BYTE_ORDER_MARKS.each do |encoding, bom|\n bom.force_encoding('binary')\n if content[0, bom.size] == bom\n content.force_encoding(encoding)\n return content\n end\n end\n content.force_encoding('utf-8') # UTF-8 is default encoding\n content\n end\n end", "def file_sanitizer(file)\n file = File.open(file, mode=\"r+\")\n content = File.read(file)\n\tcontent.force_encoding(Encoding::Windows_1252)\n\tcontent = content.encode!(Encoding::UTF_8, :universal_newline => true)\n content.gsub!(\"\\r\\n\",\"\\n\")\n file.write(content)\nend", "def utf8read(x)\n File.open(x,\"rb\"){|f|\n if f.getbyte!=0xef || f.getbyte!=0xbb || f.getbyte!=0xbf\n f.pos=0 # skip UTF-8 byte order mark\n end\n data=f.read\n ec1=Encoding::Converter.new(\"utf-8\",\"utf-16\",{\n :undef=>:replace,\n :invalid=>:replace\n })\n ec2=Encoding::Converter.new(\"utf-16\",\"utf-8\",{\n :undef=>:replace,\n :invalid=>:replace,\n :replace=>\"\\uFFFD\"\n })\n data=ec1.convert(data)\n data=ec2.convert(data)\n return data\n }\nend", "def characterize(save: true)\n TikaFileCharacterizationService.new(file_node: file_node, persister: persister).characterize\n external_metadata_service.characterize if external_metadata_service.valid?\n end", "def encoding_error?(parser=nil)\n parser = self.parser unless parser\n return false if parser.errors.empty?\n parser.errors.any? do |error|\n error.message.scrub =~ /(indicate\\ encoding)|\n (Invalid\\ char)|\n (input\\ conversion\\ failed)/x\n end\n end", "def test_self_to_nfc_encoding\n assert_equal @unistr_up.NFC.encoding, Encoding::UTF_8\n end", "def charset; end", "def charset; end", "def charset; end" ]
[ "0.7467405", "0.7315119", "0.7315119", "0.71428925", "0.71428925", "0.71347225", "0.7080432", "0.7006854", "0.6690197", "0.6623114", "0.65585196", "0.6356964", "0.6327214", "0.63073605", "0.6253385", "0.6087701", "0.6067097", "0.60535413", "0.6048344", "0.5997201", "0.59839606", "0.5975694", "0.5975694", "0.5974719", "0.596089", "0.5958472", "0.5957913", "0.5948114", "0.5939615", "0.5920044", "0.59168464", "0.59168464", "0.58718044", "0.5860955", "0.5858918", "0.5852366", "0.5852366", "0.58420855", "0.5837295", "0.5832366", "0.58216316", "0.5809112", "0.5781389", "0.5781389", "0.5776137", "0.57581383", "0.5755306", "0.5734346", "0.57257813", "0.5721884", "0.5707507", "0.5704096", "0.56924385", "0.5671351", "0.5671063", "0.5666936", "0.56491876", "0.5637767", "0.56205636", "0.56157327", "0.56157005", "0.5610804", "0.5610804", "0.5610804", "0.5610804", "0.5610804", "0.5610804", "0.5610804", "0.5610804", "0.5610804", "0.5610804", "0.5610804", "0.5610804", "0.5610804", "0.5610804", "0.5610804", "0.5606171", "0.5606171", "0.5600263", "0.5596912", "0.5565396", "0.5564511", "0.55489475", "0.55489475", "0.55489475", "0.55480814", "0.5546432", "0.554488", "0.553921", "0.5532026", "0.5531683", "0.5522601", "0.55173045", "0.5515026", "0.55118454", "0.5497943", "0.5497805", "0.54915506", "0.5479236", "0.5479236", "0.5479236" ]
0.0
-1
Trim leading and trailing whitespace from text string Trim leading and trailing whitespace from text, leaving behind a trimmed string. Whitespace includes newlines, spaces and other whitespace characters.
def edit_text_trim_whitespace(request, opts = {}) data, _status_code, _headers = edit_text_trim_whitespace_with_http_info(request, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trimmed_whitespace(text)\n text.gsub(/[\\t\\n\\f\\r ]+/ium, ' ')\n end", "def trim_whitespace; end", "def strip_trailing_whitespace(text)\n text.split(\"\\n\").collect(&:strip).join(\"\\n\")\n end", "def strip_leading_whitespace(text)\n return text if text.empty?\n leading_spaces = text.lines.first[/^(\\s+)/, 1]\n text.gsub(/^#{leading_spaces}/, '')\n end", "def trim(string)\n string.sub(/^[  ]+/, '').sub(/[  ]+$/, '')\n end", "def strip(s)\n s.gsub(/^\\s+/, '').gsub(/\\s+$/, '')\n end", "def trim_all_whitespace(text)\n text.to_a.map do |line|\n left_spacing(line) + line.squeeze(\" \").squeeze(\" \").lstrip #the 2. is a tab\n end.join\n end", "def normalize_whitespace(text)\n text.to_s.gsub(/[[:space:]]+/, ' ').strip\n end", "def trim\n self.gsub(/^\\s+/,'').gsub(/\\s+$/,'')\n end", "def trim(**props)\n transform(type: :trim, **props) do |value|\n if value\n value = value.strip\n value = nil if value.empty?\n end\n value\n end\n end", "def whitespace_fixup(text)\n text.andand.gsub(/\\r/, \"\")\n end", "def str_trim(str)\n str_limit(str.gsub(/\\n/, '\\n').gsub(/\\r/, '\\r'))\n end", "def pre_proccess(text)\n text.to_s.strip.gsub(/[[:space:]]+/, ' ').gsub(/\\s{2,}/, ' ')\n end", "def admin_strip_text(str)\n\t\tstr.gsub(/\\t|\\n/,'')\n\t\tstr.strip\n\tend", "def strip_all_spaces(text)\n text&&text.gsub(/&nbsp;|\\xC2\\xA0|\\xA0/, ' ').strip\n end", "def whitespace_fixup(text)\n text.andand.gsub(/\\r/, \"\")\n end", "def trim_whitespace=(_arg0); end", "def remove_leading_and_trailing_whitespace(text)\n pre_blocks = text.split(DO_NOT_TOUCH_WHITESPACE)\n\n output = []\n pre_blocks.each.with_index do |block, index|\n if index % 2 == 0\n output << block.gsub(/[ \\t]*\\n[ \\t]*/im, \"\\n\").gsub(/ *\\t */im, \"\\t\")\n else\n output << block\n end\n end\n\n output.join\n end", "def clean(str)\n return nil unless str\n str.gsub(/\\p{Space}/, ' ').strip.squeeze(' ')\n end", "def clean text\n text.gsub(/(\\n|\\t|\\r)/, ' ').gsub(/>\\s*</, '><').squeeze(' ')\n end", "def trim_whitespace\n @expression.strip!\n end", "def remove_whitespace( answer_string )\n if @whitespace.nil?\n answer_string\n elsif [:strip, :chomp].include?(@whitespace)\n answer_string.send(@whitespace)\n elsif @whitespace == :collapse\n answer_string.gsub(/\\s+/, \" \")\n elsif [:strip_and_collapse, :chomp_and_collapse].include?(@whitespace)\n result = answer_string.send(@whitespace.to_s[/^[a-z]+/])\n result.gsub(/\\s+/, \" \")\n elsif @whitespace == :remove\n answer_string.gsub(/\\s+/, \"\")\n else\n answer_string\n end\n end", "def unindent(text)\n text.strip.gsub(/^\\s+/, \"\")\n end", "def dewhitespace\n gsub(/\\s+/,' ').strip\n end", "def trimming_for_diff_text(code)\n # gsub(/^\\s*$/, '') means remove empty lines\n code.strip.gsub(/^\\s*$/, '')\n end", "def clean_up_spaces(string)\n string.gsub(\"\\n\", ' ').gsub(/[[:space:]]+/, ' ').strip if string.is_a? String\n end", "def squash(text)\n return text.scrub.gsub(/[[:space:]]+/, ' ').strip\nend", "def compact_whitespace s\n s.gsub(/\\s+/, ' ').gsub(/>\\s</, '><').strip\n end", "def cleanup_string(string, strip: true)\n return \"\" if string.nil?\n raise ArgumentError, \"Expected a string or an object that implements #to_str\" unless string.respond_to?(:to_str)\n\n s = strip_tags(string.to_str)\n s = s.dup if s.frozen?\n s.gsub!(/\\s+/, \" \")\n s.strip! if strip\n\n s\n end", "def strip_string string\n string.strip\n end", "def strip(string)\n while string[-1] == \" \" || string[-1] == \"\\n\" || string[-1] == \"\\t\"\n string[-1] = \"\"\n end\n while string[0] == \" \" || string[0] == \"\\n\" || string[0] == \"\\t\"\n string[0] = \"\"\n end\n return string\nend", "def trim\n self.fetch(:trim, self.skipInitialSpace ? 'start' : false)\n end", "def normalize_spacing(text)\n text\n .delete(REMOVED_CHARACTERS)\n .tr(SQUEEZED_SPACES, ' ')\n .squeeze(' ')\n .sub(LEADING_SPACES, '')\n .sub(TRAILING_SPACES, '')\n .tr(NON_BREAKING_SPACE, ' ')\n end", "def strip(str); end", "def strip_squeeze\n strip.squeeze(\" \")\n end", "def strip_leading_whitespace(str)\n str.gsub(/^(\\s+)/, '').gsub(/^->/, '')\n end", "def auto_trim!; end", "def trim\n return if skip_step?(@names.get('trim'), 'trimming')\n run_cmd(\\\n 'fastx_trimmer -Q33 -f 2' \\\n \" -i #{@names.get('clip')}\" \\\n \" -o #{@names.get('trim')}\"\n )\n end", "def strip_whitespace!\n replace(self.strip_whitespace)\n end", "def rstrip\r\n match = rewrite(/\\s+\\z/)\r\n match ? match[0] : ''\r\n end", "def strip_space!\n replace self.gsub(/:\\s*/, \":\").gsub(/\\n/, \"\").gsub(/\\s+/, \" \").gsub(/(\\/\\*).*?(\\*\\/)/, \"\")\n end", "def unindent(text)\n return \"\" if text.nil?\n\n len = text.split(\"\\n\").reject { |l| l.strip.empty? }.map { |x| x.index(/[^\\s]/) }.compact.min\n text.gsub(/^[[:blank:]]{#{len}}/, \"\").strip\n end", "def white_out(str)\n str.delete(\" \\n\\t\")\nend", "def trim\n self.content = self.content.squeeze(\"\\n\").squeeze(\" \").strip\n end", "def left_strip(str)\n output = \"\"\n whitespace = \"\\n\\t \"\n i = 0\n left = true\n while i < str.length\n if !left\n output << str[i]\n elsif !whitespace.include? str[i]\n left = false\n output << str[i]\n end\n i+=1\n end\n return output\nend", "def rstrip!\n erase! @result.length - 1 - (@result.rindex(/[^\\s]/) || -1)\n end", "def remove_whitespaces(myString)\n\treturn myString.gsub(/\\s+/, \"\")\nend", "def strip!\n acc = 0\n new_te = self.text_elements.drop_while { |te|\n te.text == ' ' && acc += 1\n }\n self.left += self.text_elements.take(acc).inject(0) { |m, te| m += te.width }\n self.text_elements = new_te\n\n self.text_elements.reverse!\n acc = 0\n new_te = self.text_elements.drop_while { |te|\n te.text == ' ' && acc += 1\n }\n self.right -= self.text_elements.take(acc).inject(0) { |m, te| m += te.width }\n self.text_elements = new_te.reverse\n self\n end", "def strip\n lambda do |rec, acc|\n acc.collect! do |v|\n # unicode whitespace class aware\n v.sub(/\\A[[:space:]]+/,'').sub(/[[:space:]]+\\Z/, '')\n end\n end\n end", "def clean_whitespace(a)\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\nend", "def clean_whitespace(a)\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\nend", "def ltrim(chars)\n _trim(\"^%s*\", chars)\n end", "def clean_string(s)\n s.lstrip! if s\n s.rstrip! if s\n s\n end", "def stripped\n @stripped ||= strip @text\n end", "def trim other = ' '\n ArelExtensions::Nodes::Trim.new [self, other]\n end", "def rstrip() end", "def remove_blank_lines(text)\n text.split(\"\\n\").reject { |l| l.strip == '' }.join(\"\\n\") + \"\\n\"\n end", "def clean_whitespace(a)\n\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\n\nend", "def clean_whitespace(a)\n\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\n\nend", "def auto_trim?; end", "def strip() end", "def strip_naked\n return self if blank?\n self.downcase.strip.gsub(/([\\s]{2,})/, ' ')\n end", "def clean_string s\n s.gsub(/\\s/, \"\")\n end", "def no_auto_trim!; end", "def sanitize text\n [' ', '\\r\\n', \"\\r\\n\", \"\\n\", \"\\r\", \"\\t\", / ^/, / $+/, /^  /, /^ /].each { |text_to_remove|\n text.gsub!(text_to_remove,'')\n }\n return text\n end", "def right_strip(str)\n i = str.length - 1\n while i >= 0 && (str[i] == \" \" || str[i] == \"\\t\" || str[i] == \"\\n\")\n i -= 1\n end\n\n return str[0, i + 1]\nend", "def strip(s)\n Sanitize.clean(s)\n end", "def force_strip(str)\n str[0] = \"\"\n end", "def strong_strip\n reverse.gsub(/^\\p{Zs}+|^\\p{Cf}+/, '').reverse.gsub(/^\\p{Zs}+|^\\p{Cf}+/, '')\n end", "def trim(string, size)\n if string\n if string.strip.length > size\n string.strip.slice(0,size)\n else\n string.strip.ljust(size)\n end\n end\n end", "def truncate(str)\n str ||= \"\"\n return str.gsub(/\\s+/, ' ').strip\n end", "def remove_whitespace\n self.first_name = self.first_name.strip\n self.last_name = self.last_name.strip\n self.biography = self.biography.strip\n end", "def trim(chars = \"\\s\")\n\t\treturn self.\n\t\t\tsub(/^[#{Regexp.escape(chars)}]*/, \"\").\n\t\t\tsub(/[#{Regexp.escape(chars)}]*$/, \"\")\n\tend", "def sstrip!(str)\n str = Regexp.quote(str)\n self.gsub!(/^(#{str})+|(#{str})+$/, '')\n end", "def remove_whitespace\n # NOTE: According to the docs, \\s only matches [ \\t\\r\\n\\f], i.e. it does not\n # match e.g. non-breaking space (&nbsp). The POSIX character class\n # [[:space:]] does match non-breaking space. This is relevant because\n # in Heroku, space in ENV variables might be translated as &nbsp.\n # DOC: http://ruby-doc.org/core-2.5.1/Regexp.html#class-Regexp-label-Character+Classes\n # SOURCE: http://stackoverflow.com/a/13288542\n gsub(/[[:space:]]/, '')\n end", "def strain(string)\n string = string.strip.gsub(/[#{ALWAYS_STRIP.join('')}#{@also_strip}]/, '')\n string.truncate!(@max_chars, @ellipsis) if @max_chars\n string if string.length >= @min_chars\n end", "def clean_text(text)\n text.gsub!(/\\r\\n/, '')\n text.gsub!(/\\r/, '')\n text\n end", "def clean_text(string)\n if string\n string.chomp!\n string.gsub!(/\\t+|\\(.+?\\)\\s*/,'')\n string.gsub!(/‘|’|„|“/, \"'\")\n string.squeeze!(\"?|!\")\n string.gsub!(/!\\?|\\?!/, \"?\")\n string.gsub!(/…|!|\\.\\.\\./, \".\") # Used the three marks to keep the count clean\n string.gsub!(/(Na)(ja)/i, '\\1 \\2')\n string.squeeze(\" \").strip\n else\n \"\"\n end\n end", "def lstrip\n `return self.replace(/^\\s*/, '');`\n end", "def lstrip\n `return self.replace(/^\\s*/, '');`\n end", "def remove_whitespace\n self.name = self.name.strip\n self.phone = self.phone.strip\n end", "def cleanup(text)\n text.gsub(/[^a-z]/i,\" \").squeeze(\" \")\nend", "def cleanup(text)\n text && text.gsub(\"\\t\", ' ').dedent\n end", "def clean_text(text)\n text = strip_html_quote_entities(text)\n text = Helper::Text.strip_html_tags(text)\n text = strip_copyright_text(text)\n text.strip!\n text = Helper::Text.clean_verse_start(text)\n text = Helper::Text.clean_verse_end(text)\n end", "def clean_html_string(string)\n string.\n inner_text.\n gsub(/\\s+/, \" \").\n strip\n end", "def normalize_whitespace(string)\n # in most cases there is nothing to do, then leave immediately\n return string unless string.match(/\\s\"\\s/)\n\n scanner = StringScanner.new(string)\n reset_direct_speech_status\n string_with_normalized_whitespace(scanner)\n end", "def odb_trim\n \"#{to_s}.trim()\"\n end", "def sstrip(str)\n self.dup.tap { |duped|\n duped.sstrip!(str)\n }\n end", "def cleanup(string)\n string.gsub(/[^a-z0-9]/, \" \").gsub(/\\s+/, \" \")\n # string.gsub(/[^a-z]/, ' ').squeeze(' ')\nend", "def clean_text(text)\n lines = text.strip.each_line\n lines = lines.reject { |line| SOURCE_LINE =~ line }\n lines.join.strip.delete(\"\\r\")\n end", "def remove_whitespace\n self.description = self.description.strip\n end", "def strip_surrounding_empty_lines(str)\n str.sub(/\\A[[:space:]]*^/, \"\")\n .sub(/$[[:space:]]*\\z/, \"\")\n end", "def left_strip(string)\n whitespaces = [\"\\n\", \"\\t\"]\n i = 0\n output = \"\"\n while i<=string.length-1\n if string[i] == whitespaces[1] || string[i] == whitespaces[2]\n i+=1 \n else\n while i<=string.length-1\n output += string[i]\n i+=1\n end\n return output\n end\n end\n return output\nend", "def strip_side_space!\n replace self.gsub(/^\\s+/, \"\").gsub(/\\s+$/, $/)\n end", "def right_strip(string)\n whitespaces = [\"\\n\", \"\\t\"]\n i = string.length-1\n i2 = 0\n output = \"\"\n while i>=0\n if string[i] == whitespaces[1] || string[i] == whitespaces[2]\n i-=1 \n else\n while i2<=i\n output += string[i2]\n i2+=1\n end\n return output\n end\n end\n return output\nend", "def wp_trim_words(text, num_words = 55, more = nil)\n if more.nil?\n more = '&hellip;'\n end\n\n original_text = text\n text = wp_strip_all_tags(text)\n\n if false # no asian...\n else\n words_array = text.split(/[\\n\\r\\t ]+/, num_words + 1)\n sep = ' '\n end\n\n if words_array.length > num_words\n words_array.pop\n text = words_array.join(sep)\n text = text + more\n else\n text = words_array.join(sep)\n end\n\n # Filters the text content after words have been trimmed.\n apply_filters('wp_trim_words', text, num_words, more, original_text)\n end", "def trim\n repeat_until_unchanged(&:trim_once)\n end", "def remove_whitespace\n self.title = self.title.strip\n self.description = self.description.strip\n end", "def clean_body(text)\n text = strip_bad_chars(text)\n text.gsub!(/(\\r)?\\n/, \"\");\n text.gsub!(/\\s+/, ' ');\n\n # clean start and end whitespace\n text = text.strip;\n return text\nend", "def cleanup(txt)\n txt.gsub(/[^a-z]/i, ' ').squeeze(' ')\nend" ]
[ "0.78723127", "0.74349684", "0.7423679", "0.7282651", "0.7208551", "0.7148014", "0.70951265", "0.7042206", "0.7039366", "0.6947847", "0.6894527", "0.6841162", "0.68303525", "0.6811027", "0.6784939", "0.67613214", "0.67364526", "0.67206913", "0.6702575", "0.66930556", "0.667706", "0.6608336", "0.6537095", "0.65253943", "0.65113926", "0.6498408", "0.6448818", "0.64198184", "0.64185184", "0.64053124", "0.6366057", "0.6356758", "0.6342345", "0.6338484", "0.6334353", "0.63215876", "0.6308779", "0.62983656", "0.62968284", "0.6287447", "0.6286566", "0.6284199", "0.627802", "0.6270524", "0.6263735", "0.62538034", "0.624736", "0.6231232", "0.62265587", "0.6212529", "0.6212529", "0.6205914", "0.6184988", "0.6184461", "0.61836356", "0.6182363", "0.6160423", "0.6159279", "0.6159279", "0.61587", "0.61572343", "0.6156005", "0.6149112", "0.61467475", "0.60995126", "0.6097744", "0.6096445", "0.609281", "0.60896206", "0.6082773", "0.60685426", "0.60672295", "0.6052449", "0.60408336", "0.60375386", "0.60351217", "0.6013719", "0.6012584", "0.5988091", "0.5988091", "0.5974089", "0.5972072", "0.59663665", "0.5957005", "0.59468776", "0.59441376", "0.59197116", "0.5912871", "0.59072167", "0.5906561", "0.5904082", "0.5900436", "0.58973795", "0.58907706", "0.589011", "0.5876394", "0.5866469", "0.58605236", "0.5840732", "0.58391804" ]
0.6285772
41
Trim leading and trailing whitespace from text string Trim leading and trailing whitespace from text, leaving behind a trimmed string. Whitespace includes newlines, spaces and other whitespace characters.
def edit_text_trim_whitespace_with_http_info(request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_trim_whitespace ...' end # verify the required parameter 'request' is set if @api_client.config.client_side_validation && request.nil? fail ArgumentError, "Missing the required parameter 'request' when calling EditTextApi.edit_text_trim_whitespace" end # resource path local_var_path = '/convert/edit/text/remove/whitespace/trim' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(request) auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'RemoveWhitespaceFromTextResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_trim_whitespace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trimmed_whitespace(text)\n text.gsub(/[\\t\\n\\f\\r ]+/ium, ' ')\n end", "def trim_whitespace; end", "def strip_trailing_whitespace(text)\n text.split(\"\\n\").collect(&:strip).join(\"\\n\")\n end", "def strip_leading_whitespace(text)\n return text if text.empty?\n leading_spaces = text.lines.first[/^(\\s+)/, 1]\n text.gsub(/^#{leading_spaces}/, '')\n end", "def trim(string)\n string.sub(/^[  ]+/, '').sub(/[  ]+$/, '')\n end", "def strip(s)\n s.gsub(/^\\s+/, '').gsub(/\\s+$/, '')\n end", "def trim_all_whitespace(text)\n text.to_a.map do |line|\n left_spacing(line) + line.squeeze(\" \").squeeze(\" \").lstrip #the 2. is a tab\n end.join\n end", "def normalize_whitespace(text)\n text.to_s.gsub(/[[:space:]]+/, ' ').strip\n end", "def trim\n self.gsub(/^\\s+/,'').gsub(/\\s+$/,'')\n end", "def trim(**props)\n transform(type: :trim, **props) do |value|\n if value\n value = value.strip\n value = nil if value.empty?\n end\n value\n end\n end", "def whitespace_fixup(text)\n text.andand.gsub(/\\r/, \"\")\n end", "def str_trim(str)\n str_limit(str.gsub(/\\n/, '\\n').gsub(/\\r/, '\\r'))\n end", "def pre_proccess(text)\n text.to_s.strip.gsub(/[[:space:]]+/, ' ').gsub(/\\s{2,}/, ' ')\n end", "def admin_strip_text(str)\n\t\tstr.gsub(/\\t|\\n/,'')\n\t\tstr.strip\n\tend", "def strip_all_spaces(text)\n text&&text.gsub(/&nbsp;|\\xC2\\xA0|\\xA0/, ' ').strip\n end", "def whitespace_fixup(text)\n text.andand.gsub(/\\r/, \"\")\n end", "def trim_whitespace=(_arg0); end", "def remove_leading_and_trailing_whitespace(text)\n pre_blocks = text.split(DO_NOT_TOUCH_WHITESPACE)\n\n output = []\n pre_blocks.each.with_index do |block, index|\n if index % 2 == 0\n output << block.gsub(/[ \\t]*\\n[ \\t]*/im, \"\\n\").gsub(/ *\\t */im, \"\\t\")\n else\n output << block\n end\n end\n\n output.join\n end", "def clean(str)\n return nil unless str\n str.gsub(/\\p{Space}/, ' ').strip.squeeze(' ')\n end", "def clean text\n text.gsub(/(\\n|\\t|\\r)/, ' ').gsub(/>\\s*</, '><').squeeze(' ')\n end", "def trim_whitespace\n @expression.strip!\n end", "def remove_whitespace( answer_string )\n if @whitespace.nil?\n answer_string\n elsif [:strip, :chomp].include?(@whitespace)\n answer_string.send(@whitespace)\n elsif @whitespace == :collapse\n answer_string.gsub(/\\s+/, \" \")\n elsif [:strip_and_collapse, :chomp_and_collapse].include?(@whitespace)\n result = answer_string.send(@whitespace.to_s[/^[a-z]+/])\n result.gsub(/\\s+/, \" \")\n elsif @whitespace == :remove\n answer_string.gsub(/\\s+/, \"\")\n else\n answer_string\n end\n end", "def unindent(text)\n text.strip.gsub(/^\\s+/, \"\")\n end", "def dewhitespace\n gsub(/\\s+/,' ').strip\n end", "def trimming_for_diff_text(code)\n # gsub(/^\\s*$/, '') means remove empty lines\n code.strip.gsub(/^\\s*$/, '')\n end", "def clean_up_spaces(string)\n string.gsub(\"\\n\", ' ').gsub(/[[:space:]]+/, ' ').strip if string.is_a? String\n end", "def squash(text)\n return text.scrub.gsub(/[[:space:]]+/, ' ').strip\nend", "def compact_whitespace s\n s.gsub(/\\s+/, ' ').gsub(/>\\s</, '><').strip\n end", "def cleanup_string(string, strip: true)\n return \"\" if string.nil?\n raise ArgumentError, \"Expected a string or an object that implements #to_str\" unless string.respond_to?(:to_str)\n\n s = strip_tags(string.to_str)\n s = s.dup if s.frozen?\n s.gsub!(/\\s+/, \" \")\n s.strip! if strip\n\n s\n end", "def strip_string string\n string.strip\n end", "def strip(string)\n while string[-1] == \" \" || string[-1] == \"\\n\" || string[-1] == \"\\t\"\n string[-1] = \"\"\n end\n while string[0] == \" \" || string[0] == \"\\n\" || string[0] == \"\\t\"\n string[0] = \"\"\n end\n return string\nend", "def trim\n self.fetch(:trim, self.skipInitialSpace ? 'start' : false)\n end", "def normalize_spacing(text)\n text\n .delete(REMOVED_CHARACTERS)\n .tr(SQUEEZED_SPACES, ' ')\n .squeeze(' ')\n .sub(LEADING_SPACES, '')\n .sub(TRAILING_SPACES, '')\n .tr(NON_BREAKING_SPACE, ' ')\n end", "def strip(str); end", "def strip_squeeze\n strip.squeeze(\" \")\n end", "def strip_leading_whitespace(str)\n str.gsub(/^(\\s+)/, '').gsub(/^->/, '')\n end", "def auto_trim!; end", "def trim\n return if skip_step?(@names.get('trim'), 'trimming')\n run_cmd(\\\n 'fastx_trimmer -Q33 -f 2' \\\n \" -i #{@names.get('clip')}\" \\\n \" -o #{@names.get('trim')}\"\n )\n end", "def strip_whitespace!\n replace(self.strip_whitespace)\n end", "def rstrip\r\n match = rewrite(/\\s+\\z/)\r\n match ? match[0] : ''\r\n end", "def strip_space!\n replace self.gsub(/:\\s*/, \":\").gsub(/\\n/, \"\").gsub(/\\s+/, \" \").gsub(/(\\/\\*).*?(\\*\\/)/, \"\")\n end", "def edit_text_trim_whitespace(request, opts = {})\n data, _status_code, _headers = edit_text_trim_whitespace_with_http_info(request, opts)\n data\n end", "def unindent(text)\n return \"\" if text.nil?\n\n len = text.split(\"\\n\").reject { |l| l.strip.empty? }.map { |x| x.index(/[^\\s]/) }.compact.min\n text.gsub(/^[[:blank:]]{#{len}}/, \"\").strip\n end", "def white_out(str)\n str.delete(\" \\n\\t\")\nend", "def trim\n self.content = self.content.squeeze(\"\\n\").squeeze(\" \").strip\n end", "def left_strip(str)\n output = \"\"\n whitespace = \"\\n\\t \"\n i = 0\n left = true\n while i < str.length\n if !left\n output << str[i]\n elsif !whitespace.include? str[i]\n left = false\n output << str[i]\n end\n i+=1\n end\n return output\nend", "def rstrip!\n erase! @result.length - 1 - (@result.rindex(/[^\\s]/) || -1)\n end", "def remove_whitespaces(myString)\n\treturn myString.gsub(/\\s+/, \"\")\nend", "def strip!\n acc = 0\n new_te = self.text_elements.drop_while { |te|\n te.text == ' ' && acc += 1\n }\n self.left += self.text_elements.take(acc).inject(0) { |m, te| m += te.width }\n self.text_elements = new_te\n\n self.text_elements.reverse!\n acc = 0\n new_te = self.text_elements.drop_while { |te|\n te.text == ' ' && acc += 1\n }\n self.right -= self.text_elements.take(acc).inject(0) { |m, te| m += te.width }\n self.text_elements = new_te.reverse\n self\n end", "def strip\n lambda do |rec, acc|\n acc.collect! do |v|\n # unicode whitespace class aware\n v.sub(/\\A[[:space:]]+/,'').sub(/[[:space:]]+\\Z/, '')\n end\n end\n end", "def clean_whitespace(a)\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\nend", "def clean_whitespace(a)\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\nend", "def ltrim(chars)\n _trim(\"^%s*\", chars)\n end", "def clean_string(s)\n s.lstrip! if s\n s.rstrip! if s\n s\n end", "def stripped\n @stripped ||= strip @text\n end", "def trim other = ' '\n ArelExtensions::Nodes::Trim.new [self, other]\n end", "def rstrip() end", "def remove_blank_lines(text)\n text.split(\"\\n\").reject { |l| l.strip == '' }.join(\"\\n\") + \"\\n\"\n end", "def clean_whitespace(a)\n\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\n\nend", "def clean_whitespace(a)\n\n a.gsub(\"\\r\", ' ').gsub(\"\\n\", ' ').squeeze(\" \").strip\n\nend", "def auto_trim?; end", "def strip() end", "def strip_naked\n return self if blank?\n self.downcase.strip.gsub(/([\\s]{2,})/, ' ')\n end", "def clean_string s\n s.gsub(/\\s/, \"\")\n end", "def no_auto_trim!; end", "def right_strip(str)\n i = str.length - 1\n while i >= 0 && (str[i] == \" \" || str[i] == \"\\t\" || str[i] == \"\\n\")\n i -= 1\n end\n\n return str[0, i + 1]\nend", "def sanitize text\n [' ', '\\r\\n', \"\\r\\n\", \"\\n\", \"\\r\", \"\\t\", / ^/, / $+/, /^  /, /^ /].each { |text_to_remove|\n text.gsub!(text_to_remove,'')\n }\n return text\n end", "def strip(s)\n Sanitize.clean(s)\n end", "def force_strip(str)\n str[0] = \"\"\n end", "def strong_strip\n reverse.gsub(/^\\p{Zs}+|^\\p{Cf}+/, '').reverse.gsub(/^\\p{Zs}+|^\\p{Cf}+/, '')\n end", "def trim(string, size)\n if string\n if string.strip.length > size\n string.strip.slice(0,size)\n else\n string.strip.ljust(size)\n end\n end\n end", "def truncate(str)\n str ||= \"\"\n return str.gsub(/\\s+/, ' ').strip\n end", "def remove_whitespace\n self.first_name = self.first_name.strip\n self.last_name = self.last_name.strip\n self.biography = self.biography.strip\n end", "def trim(chars = \"\\s\")\n\t\treturn self.\n\t\t\tsub(/^[#{Regexp.escape(chars)}]*/, \"\").\n\t\t\tsub(/[#{Regexp.escape(chars)}]*$/, \"\")\n\tend", "def sstrip!(str)\n str = Regexp.quote(str)\n self.gsub!(/^(#{str})+|(#{str})+$/, '')\n end", "def remove_whitespace\n # NOTE: According to the docs, \\s only matches [ \\t\\r\\n\\f], i.e. it does not\n # match e.g. non-breaking space (&nbsp). The POSIX character class\n # [[:space:]] does match non-breaking space. This is relevant because\n # in Heroku, space in ENV variables might be translated as &nbsp.\n # DOC: http://ruby-doc.org/core-2.5.1/Regexp.html#class-Regexp-label-Character+Classes\n # SOURCE: http://stackoverflow.com/a/13288542\n gsub(/[[:space:]]/, '')\n end", "def strain(string)\n string = string.strip.gsub(/[#{ALWAYS_STRIP.join('')}#{@also_strip}]/, '')\n string.truncate!(@max_chars, @ellipsis) if @max_chars\n string if string.length >= @min_chars\n end", "def clean_text(text)\n text.gsub!(/\\r\\n/, '')\n text.gsub!(/\\r/, '')\n text\n end", "def clean_text(string)\n if string\n string.chomp!\n string.gsub!(/\\t+|\\(.+?\\)\\s*/,'')\n string.gsub!(/‘|’|„|“/, \"'\")\n string.squeeze!(\"?|!\")\n string.gsub!(/!\\?|\\?!/, \"?\")\n string.gsub!(/…|!|\\.\\.\\./, \".\") # Used the three marks to keep the count clean\n string.gsub!(/(Na)(ja)/i, '\\1 \\2')\n string.squeeze(\" \").strip\n else\n \"\"\n end\n end", "def lstrip\n `return self.replace(/^\\s*/, '');`\n end", "def lstrip\n `return self.replace(/^\\s*/, '');`\n end", "def remove_whitespace\n self.name = self.name.strip\n self.phone = self.phone.strip\n end", "def cleanup(text)\n text.gsub(/[^a-z]/i,\" \").squeeze(\" \")\nend", "def cleanup(text)\n text && text.gsub(\"\\t\", ' ').dedent\n end", "def clean_text(text)\n text = strip_html_quote_entities(text)\n text = Helper::Text.strip_html_tags(text)\n text = strip_copyright_text(text)\n text.strip!\n text = Helper::Text.clean_verse_start(text)\n text = Helper::Text.clean_verse_end(text)\n end", "def clean_html_string(string)\n string.\n inner_text.\n gsub(/\\s+/, \" \").\n strip\n end", "def normalize_whitespace(string)\n # in most cases there is nothing to do, then leave immediately\n return string unless string.match(/\\s\"\\s/)\n\n scanner = StringScanner.new(string)\n reset_direct_speech_status\n string_with_normalized_whitespace(scanner)\n end", "def odb_trim\n \"#{to_s}.trim()\"\n end", "def sstrip(str)\n self.dup.tap { |duped|\n duped.sstrip!(str)\n }\n end", "def cleanup(string)\n string.gsub(/[^a-z0-9]/, \" \").gsub(/\\s+/, \" \")\n # string.gsub(/[^a-z]/, ' ').squeeze(' ')\nend", "def clean_text(text)\n lines = text.strip.each_line\n lines = lines.reject { |line| SOURCE_LINE =~ line }\n lines.join.strip.delete(\"\\r\")\n end", "def remove_whitespace\n self.description = self.description.strip\n end", "def strip_surrounding_empty_lines(str)\n str.sub(/\\A[[:space:]]*^/, \"\")\n .sub(/$[[:space:]]*\\z/, \"\")\n end", "def left_strip(string)\n whitespaces = [\"\\n\", \"\\t\"]\n i = 0\n output = \"\"\n while i<=string.length-1\n if string[i] == whitespaces[1] || string[i] == whitespaces[2]\n i+=1 \n else\n while i<=string.length-1\n output += string[i]\n i+=1\n end\n return output\n end\n end\n return output\nend", "def right_strip(string)\n whitespaces = [\"\\n\", \"\\t\"]\n i = string.length-1\n i2 = 0\n output = \"\"\n while i>=0\n if string[i] == whitespaces[1] || string[i] == whitespaces[2]\n i-=1 \n else\n while i2<=i\n output += string[i2]\n i2+=1\n end\n return output\n end\n end\n return output\nend", "def strip_side_space!\n replace self.gsub(/^\\s+/, \"\").gsub(/\\s+$/, $/)\n end", "def wp_trim_words(text, num_words = 55, more = nil)\n if more.nil?\n more = '&hellip;'\n end\n\n original_text = text\n text = wp_strip_all_tags(text)\n\n if false # no asian...\n else\n words_array = text.split(/[\\n\\r\\t ]+/, num_words + 1)\n sep = ' '\n end\n\n if words_array.length > num_words\n words_array.pop\n text = words_array.join(sep)\n text = text + more\n else\n text = words_array.join(sep)\n end\n\n # Filters the text content after words have been trimmed.\n apply_filters('wp_trim_words', text, num_words, more, original_text)\n end", "def trim\n repeat_until_unchanged(&:trim_once)\n end", "def remove_whitespace\n self.title = self.title.strip\n self.description = self.description.strip\n end", "def clean_body(text)\n text = strip_bad_chars(text)\n text.gsub!(/(\\r)?\\n/, \"\");\n text.gsub!(/\\s+/, ' ');\n\n # clean start and end whitespace\n text = text.strip;\n return text\nend", "def cleanup(txt)\n txt.gsub(/[^a-z]/i, ' ').squeeze(' ')\nend" ]
[ "0.78716844", "0.74339074", "0.7422887", "0.7281248", "0.7207586", "0.7147139", "0.70955426", "0.70419943", "0.70376605", "0.69464564", "0.6892956", "0.6840761", "0.68293494", "0.68102765", "0.67847615", "0.6759722", "0.6735669", "0.67207277", "0.67022103", "0.66914845", "0.66756123", "0.6607957", "0.6535656", "0.652474", "0.65094876", "0.64988434", "0.644738", "0.6419493", "0.6418203", "0.6404278", "0.6366288", "0.6354944", "0.63422585", "0.6337108", "0.63339597", "0.63203883", "0.63071096", "0.62975115", "0.62951326", "0.6285618", "0.6285136", "0.6284948", "0.6283548", "0.6276871", "0.62688273", "0.62643266", "0.6252602", "0.6247136", "0.62311465", "0.62253976", "0.62122214", "0.62122214", "0.6205193", "0.6184679", "0.61823237", "0.6181634", "0.6180325", "0.6159817", "0.61588913", "0.61588913", "0.61571425", "0.6155166", "0.61544144", "0.61490405", "0.6144937", "0.6098394", "0.6097762", "0.6095237", "0.6091222", "0.6088112", "0.60828006", "0.6068687", "0.60663927", "0.6051045", "0.6038651", "0.6036796", "0.6034005", "0.60116976", "0.6011458", "0.5986331", "0.5986331", "0.5973204", "0.597092", "0.5965366", "0.59556377", "0.5946567", "0.59450006", "0.5918162", "0.59118664", "0.59070814", "0.5904359", "0.5902194", "0.5899148", "0.58981884", "0.58907384", "0.5889344", "0.5877043", "0.5865021", "0.58591574", "0.58390117", "0.58381134" ]
0.0
-1
create new instance of review for current presentation instance
def create @review = Presentation.find(params[:id]).reviews.build(reviews_params) @review.user_id = current_user.id @review.save redirect_to current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n\t\t@review = Review.new\n\tend", "def new\n @review = Review.new\n end", "def new\n @review = Review.new\n end", "def new\n @review = Review.new\n end", "def new\n @review = Review.new\n end", "def new\n @review = Review.new\n end", "def new\n @review = Review.new\n end", "def new\n @review = Review.new\n end", "def new\n @review = Review.new\n end", "def new\n member = Review.new\n end", "def new\n @review = Review.new\nend", "def create\n @post = Post.new(post_params)\n @post.user_id=current_user.id\n create_review(@post)\n end", "def create\n\t\t@review = Review.new(params[:review])\n\t\[email protected] = Establishment.find(params[:establishment])\n\t\[email protected] = Category.find(params[:category])\n\t\[email protected] = Clientele.find(params[:clientele])\n\t\[email protected]_level = SoundLevel.find(params[:sound_level])\n\t\[email protected] = Hygiene.find(params[:hygiene])\n\t\[email protected] = Rating.find(params[:rating])\n\n\t\trespond_to do |format|\n\t\t\tif @review.save\n\t\t\t\tformat.html { redirect_to(@review, :notice => 'Review was successfully created.') }\n\t\t\t\tformat.xml { render :xml => @review, :status => :created, :location => @review }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @review.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @review = Review.new(review_params)\n if @review.save\n redirect_to reviews_path\n else\n render 'new'\n end\n end", "def show\n @review = Review.new\n end", "def show\n @review = Review.new\n end", "def show\n @review = Review.new\n end", "def show\n @review = Review.new\n end", "def create\n @review = @post.reviews.where(user_id: current_user.id).create(params[:review])\n respond_with @post, @review, location: post_path(@post, anchor: \"review_#{@review.id}\")\n end", "def create\n\n\t\t# Initiate instance\n\t\tinterview = InterviewReview.new\n\n\t\t# Populate with relevant information\n\t\tinterview.description = params[:description]\n\t\tinterview.position = params[:position]\n\t\tinterview.experience = params[:experience]\n\t\tinterview.offer = params[:offer]\n\t\tinterview.difficulty = params[:difficulty]\n\t\tinterview.company_id = params[:company_id]\n\t\tinterview.title = params[:title]\n\t\tcompany_name = Company.find(params[:company_id]).title\n\t\tinterview.company_name = company_name\n\t\tinterview.save\n\n\t\t# Redirect to public profile of the company being reviewed.\n\t\tredirect_var = \"/employerprofile/#{params[:company_id]}\"\n\t\tredirect_to redirect_var\n\tend", "def new\n\t\t@review = Review.new\n\t\[email protected] = Establishment.new\n\t\[email protected] = Category.new\n\t\[email protected] = Clientele.new\n\t\[email protected]_level = SoundLevel.new\n\t\[email protected] = Hygiene.new\n\t\[email protected] = Rating.new\n\t\t\n\t\tcollect_additional_params()\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @review }\n\t\tend\n\tend", "def new\n # this is the form for adding a new review\n # once we generated the model \"Review\", using the variable we are adding a form to feed into the db\n @review = Review.new\n end", "def create\n @establishment = Establishment.find(params[:establishment_id])\n @review = Review.new(establishment: @establishment)\n @review = Review.new(params[:review].permit(:ratings, :review_content))\n #@review = Review.new(review_params)\n #@review = Review.new(params[:review])\n @review.establishment = @establishment\n #@review.user = current_user\n @review.user_id = current_user.id\n respond_to do |format|\n if @review.save\n format.html { redirect_to current_user, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { redirect_to current_user, notice: \"Problem!\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n @review.exceptional ||= 0\n if @review.save\n @apn.update_attribute(:reviewed, true)\n link = reviews_path\n name = @apn.profile.first_name.capitalize + \" \".to_s + @apn.profile.last_name.capitalize\n redirect_to new_review_path, notice: (\"#{name} successfully reviewed.\" +\n \" New application loaded. If you're feeling lazy, <a href='#{link}'>\" +\n \"go to the Dashboard</a>\").html_safe\n else\n render action: \"new\", alert: \"something went wrong with submitting the review\"\n end\n end", "def create\n @review = @publication.reviews.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review.publication, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@review = Review.new(review_params)\n\t\t# ensure that there is a description\n\t\tif @review.description.blank?\n\t\t\tflash[:error] = 'Your review must have a description!'\n\t\t\tredirect_to new_review_path\n\t\telse\n\t\t\t# continue with rest of saving\n\t\t\[email protected] = current_user #.id?\n\t\t\tif @review.save\n\t\t\t\tredirect_to trip_path(id: @review.trip.id)\n\t\t\telse\n\t\t\t\tflash[:error] = @review.errors.full_messages.to_sentence\n\t\t\t\tredirect_to new_review_path\n\t\t\tend\n\t\tend\n\tend", "def review\n @users = User.all\n @review = Review.new\n end", "def create\n pr = params[:review]\n review = Review.new\n \n if review.cadastrar(current_user, pr[:project_id], pr[:tipo], pr[:texto])\n redirect_to project_path(review.project_id), :notice => 'Revisao Cadastrada Com Sucesso.'\n else\n flash[:error] = \"Revisao Nao Cadastrada #{review.errors.messages}.\"\n redirect_to project_path(review.project_id)\n end\n end", "def create\n @review = Review.new(params[:review])\n @review.user = current_user\n\n respond_to do |format|\n if @review.save\n flash[:notice] = 'Review was successfully created.'\n format.html { redirect_to(@review) }\n format.xml { render :xml => @review, :status => :created, :location => @review }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @review.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new_review(review_type, veteran_file_number, establishment_error)\n create(review_type, veteran_file_number: veteran_file_number, establishment_error: establishment_error)\n end", "def create\n\t\t@review = Review.new(review_params)\n\t\[email protected]_id = current_user.id\n\t\trespond_to do |format|\n\t\t\tif @review.save\n\t\t\t\t@reviews = Review.order(:heading).paginate(page: params[:page], per_page: 18)\n\t\t\t\tformat.html { redirect_to @review; flash[:success]= 'review was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @review }\n\t\t\t\tformat.js\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @review.errors, status: :unprocessable_entity }\n\t\t\t\tformat.js\n\t\t\tend\n\t\tend\n\tend", "def new\n\t\tif !authenticate_user!(\"You must be logged in to write a review. Login now or sign up!\", true) \n\t\t\treturn \n\t\tend\t\t\n\t\t@store_review = @store.store_reviews.build\t\t\n\t\trender layout: false\t\t\n\tend", "def require_new_review\n\t\t@review = @profile.reviews.build\n\tend", "def create\n @experience = Experience.find(params[:experience_id])\n @review = Review.new(review_params)\n @review.experience = @experience\n authorize @experience\n # @review.user = current_user\n # authorize @review\n # @experience.user = current_user\n\n if @review.save!\n redirect_to experience_path(@experience, anchor: \"review\"), notice: 'Review was successfully created'\n else\n # flash[:alert] = \"Something went wrong.\"\n redirect_to experience_path(@experience)\n end\n end", "def create\n @review = Review.new(review_params)\n @review.user = current_user\n\n if @review.save\n render :show, status: :created, location: @review\n else\n render json: { Error: @review.errors }, status: :unprocessable_entity\n end\n end", "def add_review(restaurant, content)\n Review.new(self, restaurant, content)\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @idea = Idea.find params[:idea_id]\n review_params = params.require(:review).permit(:body)\n @review = Review.new review_params\n @review.idea = @idea\n @review.user = current_user\n\n if @review.save\n redirect_to idea_path(@idea), notice: \"Review created!\"\n else\n flash[:alert] = 'Problem creating review'\n render 'ideas/show'\n end\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render action: 'show', status: :created, location: @review }\n else\n format.html { render action: 'new' }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(params[:review])\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render json: @review, status: :created, location: @review }\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @m = current_member\n @review = Review.new(review_params(params).merge(:member => @m, :status => (@m.is_public? ? \"list\" : \"hide\")))\n @review.local_site = @local_site\n @review.referrer_code = params[:ref]\n story = @review.story\n\n # SSS: Weird bug? What is going on? Excerpts are lost if they aren't inspected and hence materialized?\n # Am I doing something wrong with setting these up?\n @review.excerpts.inspect\n\n # Update story information since the story could be reviewed from the todays feeds page where the\n # story status is not yet list, and the submitter is still bot!\n params[:story][:status] = Story::LIST if (story.status == Story::QUEUE) || (story.status == Story::PENDING)\n params[:story][:submitted_by_id] = @m.id if (story.submitted_by_id == Member.nt_bot.id)\n\n update_story_attributes(@review, params[:story]); story.reload # reload story after save\n update_member_settings(@review, params[:review_form_expanded])\n update_source_review(story, params[:source_ratings])\n\n begin\n saved = @review.save_and_process_with_propagation\n rescue ActiveRecord::StatementInvalid => e\n # Likely double submits that got through any front-end protections we have!\n logger.error \"Exception #{e} trying to save review for #{story.id} by member #{@m.id}. Recovering!\"\n\n # Fetch saved review -- turn off tweet (to prevent a duplicate tweet!)\n @review = Review.find_by_story_id_and_member_id(story.id, @m.id)\n if @review\n saved = true\n if params[:post_on_twitter] == \"1\"\n params[:post_on_twitter] = nil\n notice = \"Your review might have been tweeted. Because of an unexpected error, we cannot confirm this. Please check your twitter stream.\"\n end\n params[:post_on_facebook] = nil\n else\n saved = false\n end\n end\n\n if saved\n notice = tweet_if_requested(@review, params[:short_url])\n with_message = @m.status == \"guest\" ? :guest : [email protected]_public? ? :suspended : nil\n render :json => { :go => :story_actions,\n :form_transition => {:from => :review, :to => :story_actions},\n :delayed_form_reload => [:review], # No need to forcibly reload the entire toolbar right away!\n :notice => notice,\n :fb_stream_story => toolbar_facebook_stream_story(@review),\n :with_message => with_message }.to_json\n else\n # If we get an error in saving the review, it is likely because of double submits that got through any front-end checks we have!\n render :json => {:error_message => \"Failed to save review. Please try again.\"}.to_json\n end\n end", "def set_review_project\n @proyect = Project.find(params[:id])\n @review_project = ReviewProject.find_or_create_by(:project_id => params[:id])\n end", "def create\n @review = Review.new(review_params)\n @review.memberid = current_account.id\n @state = false\n if @review.save\n @paper = @review.paper\n @rate = 0.0\n @top = 0.0\n @bottem = 0.0\n @paper.reviews.each do |review| \n @top += review.score * review.confidence\n @bottem += review.confidence\n end\n @rate = @top / @bottem\n @paper.committee.tracks.each do |track| \n if( track.userid == current_account.id && track.role == \"PC Member\" )\n @state = true\n end\n end\n if(@state)\n respond_to do |format|\n @paper.update_attribute(:rating, @paper.rating = @rate)\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n end\n else\n @review.destroy\n redirect_to @paper.committee.conference, notice: \"You are not an PC member of that committee. Review not created.\"\n end\n else\n respond_to do |format|\n format.html { render :new}\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n current_user = User.find(session_params)\n @review = Review.new(\n user_id: current_user.id,\n product_id: params[:product_id],\n rating: params[:rating],\n description: params[:review][:description]\n )\n if @review.valid?\n @review.save\n redirect_to product_path(params[:product_id])\n else\n redirect_to root_path\n end\n end", "def create\n @review = Review.new(review_params)\n current_user.reviews << @review\n respond_to do |format|\n if @review.save\n format.json { render :show, status: :created, location: @review }\n else\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = @story.reviews.new(review_params)\n if @review.save\n redirect_to @review.story, notice: 'Review was successfully created.'\n else\n render :new\n end\n end", "def create\n @review = Review.new(params[:review])\n @review.review_date = Time.now\n @review.user_id = current_user.id\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to place_url(@review.place), notice: 'Review was successfully created.' }\n format.json { render json: @review, status: :created, location: @review }\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = current_author.reviews.create(review_params)\n render json: @review, status: 201\n end", "def new\n @proposal = Proposal.new\n end", "def add_review(restaurant, content)\n Review.new(restaurant, self, content)\n end", "def new\r\n @reviewId = params[:review_id]\r\n @review = Review.find(@reviewId)\r\n \r\n @reviewer = TeamMember.find_by_name('Eric Peterson')\r\n\r\n @reviewee_name = @review.TeamMember.name\r\n @reviewer_name = @reviewer.name\r\n\r\n @evaluation = Evaluation.new\r\n @evaluation.Review = @review\r\n @evaluation.TeamMember = @reviewer\r\n\r\n @questions = Question.all\r\n @answers = @questions.compact.map { |q|\r\n @r = Response.new\r\n @r.Evaluation = @evaluation\r\n @r.Question = q\r\n @r.Answer = Answer.new\r\n\r\n @r\r\n }\r\n\r\n @evaluation.answer_set = @answers\r\n \r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @evaluation }\r\n end\r\n end", "def create\n # any registered user can add a review\n unless current_user.is_general_user?\n redirect_to denied_path\n return\n end\n\n @review = Review.new(params[:review])\n @review.user_id = current_user.id\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to(@review, :notice => 'Review was successfully created.') }\n format.xml { render :xml => @review, :status => :created, :location => @review }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @review.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create \n @refrigerator = Refrigerator.find(params[:refrigerator_id])\n @review = Review.create(create_update_params)\n @refrigerator.reviews << @review\n\n if @review.save!\n\n flash[:notice] = 'Review successfully created.'\n redirect_to refrigerator_path(params[:refrigerator_id])\n else\n flash[:notice] = 'Could not create new review.'\n redirect_to (new_refrigerator_review_path(@refrigerator))\n end\n end", "def create\n\t\t# Review properties filled using user inputs from view\n\t\t@review = Review.create(review_params)\n\t\t# Linking review to car\n\t\[email protected]_id = @car.id\n\t\t# Linking review to user \n\t\[email protected]_id = current_user.id\n\t\t# Attempts to save review\n\t\tif @review.save\n\t\t\t# Once saved, redirected to show page of car, review should be visible\n\t\t\tredirect_to car_path(@car)\n\t\telse\n\t\t\t# If not saved, go to new review page again\n\t\t\trender 'new'\n\t\tend\n\tend", "def create\n @review = Review.new(params[:review])\n if @review.save\n flash[:notice] = \"Review Created\"\n redirect_to \"/products\"\n else\n render \"create\"\n end\n end", "def create\n @review = Review.new(params[:review])\n @review.submitter = current_user\n\n respond_to do |format|\n if @review.save\n @submission = ReviewSubmission.new(:review_id => @review.id, :submission_date => Time.now)\n if @submission.save\n SubmissionNotifier.deliver_new_submission_notification(@submission)\n format.html { redirect_to(@review, :notice => 'Review and Submission were successfully created.') }\n else\n format.html { redirect_to(@review, :notice => 'Review was successfully created but the submission was not.') }\n end\n format.xml { render :xml => @review, :status => :created, :location => @review }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @review.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @title = t 'conclusion_draft_review.new_title'\n @conclusion_draft_review = ConclusionDraftReview.list.new(\n conclusion_draft_review_params)\n\n respond_to do |format|\n if @conclusion_draft_review.save\n flash.notice = t 'conclusion_draft_review.correctly_created'\n format.html { redirect_to(edit_conclusion_draft_review_url(@conclusion_draft_review)) }\n else\n format.html { render action: :new }\n end\n end\n end", "def add_review(restaurant, content)\n new_review = Review.new(restaurant, content)\n new_review.customer = self\n new_review.restaurant = restaurant\n end", "def create\n\t\t\t\t@review = DriverReview.new(create_driver_review_params)\n\t\t\t\[email protected]_id = @request.driver_id\n\t\t\t\t# render_invalid_action(@review) unless @review.save\n\t\t\t\[email protected]!\n\t\t\t\tlogger.debug @review.errors.messages\t\t\t\t\n\t\t\tend", "def create\n @review = reviewable.reviews.build(params[:review])\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to reviewable_review_url(reviewable, @review), notice: 'Review was successfully created.' }\n format.json { render json: @review, status: :created, location: @review }\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if !!@review && current_user\n current_user.reviews << @review\n @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n if(@review.save)\n redirect_to game_path(@review.game)\n else\n @games = Game.all-current_user.games\n render :new\n end\n end", "def create\n @review = Review.new(review_params)\n\n if @review.save\n render json: @review, status: :created, location: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def create\n @review = Review.new(review_params)\n\n if @review.save\n render json: @review, status: :created, location: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def create\n @review = Review.new(review_params)\n\n if @review.save\n render json: @review, status: :created, location: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def new\n\t\t@proposal = Proposal.new\n\tend", "def show\n @review = Review.new\n @review.item_id = @item.id\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: \"レビューが作成されました\" }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n _params = review_init_params\r\n _params[:id] = SecurityManager.md5(\"#{@user.id}_#{@task.id}\")\r\n _params[:score] = _params[:score].to_i\r\n _params[:author_id] = @user.id\r\n\r\n begin\r\n @review = @task.reviews.create(_params)\r\n rescue Mongo::Error::OperationFailure\r\n return bad_request(\"duplicated\")\r\n end\r\n\r\n respond_to do |format|\r\n if @review.save\r\n format.html { redirect_to '/task' }\r\n else\r\n return unprocessable_entity\r\n end\r\n end\r\n end", "def create\n #binding.pry\n review = Review.new(review_params) \n if review.save\n render json: ReviewSerializer.new(review)\n else\n render json: {errors: review.errors.full_messages}\n end\n end", "def set_review\n @review = Review.find(params[:id])\n end", "def set_review\n @review = Review.find(params[:id])\n end", "def set_review\n @review = Review.find(params[:id])\n end", "def set_review\n @review = Review.find(params[:id])\n end", "def set_review\n @review = Review.find(params[:id])\n end", "def set_review\n @review = Review.find(params[:id])\n end", "def set_review\n @review = Review.find(params[:id])\n end", "def add_review(restaurant, content)\n review = Review.new(restaurant, self)\n review.content = content\n end", "def create\n item = Item.find(params[:review][:rateable_id])\n @review = item.reviews.new\n @review.user_id = current_user.id\n @review.rating = params[:review][:rating]\n @review.comment = params[:review][:comment]\n if @review.save\n redirect_to item_path(item)\n else\n flash[:alet] = \"There was a problem creating the review\"\n render :new\n end\n end", "def create\n @product = Product.find params[:product_id] \n @review = @product.reviews.create(review_params)\n if @review.save\n redirect_to :back\n end\n end", "def create\n @fourth_review = FourthReview.new(fourth_review_params)\n @fourth_review.proposition_id = @proposition.id\n @fourth_review.team_id = @proposition.team_id\n\n respond_to do |format|\n if @fourth_review.save\n format.html { redirect_to team_path(@fourth_review.team_id), notice: 'Fourth review was successfully created.' }\n format.json { render :show, status: :created, location: @fourth_review }\n else\n format.html { render :new }\n format.json { render json: @fourth_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @review = current_user.reviews.new\n 1.times { @review.review_photos.build }\n @place = Place.first\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def start_review!\n @saving_review = true\n end", "def start_review!\n @saving_review = true\n end", "def create\n @professor_review = ProfessorReview.new(params[:professor_review])\n\n respond_to do |format|\n if @professor_review.save\n format.html { redirect_to(@professor_review, :notice => 'Professor review was successfully created.') }\n format.xml { render :xml => @professor_review, :status => :created, :location => @professor_review }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @professor_review.errors, :status => :unprocessable_entity }\n end\n end\n end", "def review\n end", "def new\n @business = Business.find(params[:business_id])\n @review = @business.reviews.build(review_params)\n end", "def create\n\n @product = Product.find( params[:product_id])\n @product.reviews.create(review_params)\n @product.save\n\n if current_user.try(:admin?)\n redirect_to product_path(@product)\n else\n redirect_to store_show_path(@product)\n end\n\n @review = Review.new(review_params)\n\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n # TODO redirect to page that shows what their review will look like. \n format.html { redirect_to thanks_path, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @tour_reviews = TourReview.new\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to dashboard_path, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\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 set_review\n @review = Review.find(params[:id])\n end", "def create\n review = course.reviews.new(review_params)\n \n if review.save\n render json: ReviewSerializer.new(review).serialized_json\n else\n render json: { error: review.errors.messages }, status: 422\n end\n end", "def set_review\n @review = Review.find(params[:id])\n end", "def set_review\n @review = Review.find(params[:id])\n end", "def set_review\n @review = Review.find(params[:id])\n end", "def set_review\n @review = Review.find(params[:id])\n end", "def set_review\n @review = Review.find(params[:id])\n end" ]
[ "0.7421345", "0.7372323", "0.7372323", "0.7372323", "0.7372323", "0.7372323", "0.7372323", "0.7372323", "0.7372323", "0.73486525", "0.698937", "0.69290376", "0.68627757", "0.6862681", "0.6855386", "0.6855386", "0.6855386", "0.6855386", "0.6824502", "0.6819315", "0.6772726", "0.6764408", "0.6763797", "0.67033666", "0.66655886", "0.66574204", "0.6656147", "0.66470325", "0.66096985", "0.66084534", "0.65863454", "0.65857154", "0.6576226", "0.65729576", "0.65727115", "0.657242", "0.6558909", "0.6558909", "0.6542761", "0.653839", "0.65285116", "0.6524933", "0.6506193", "0.6505375", "0.65014225", "0.64993656", "0.64910364", "0.6473432", "0.6466089", "0.6462956", "0.64621216", "0.644665", "0.64442474", "0.64363545", "0.64355636", "0.64347404", "0.6434377", "0.643155", "0.6428376", "0.6417195", "0.6414695", "0.6413598", "0.64095557", "0.6402204", "0.6402204", "0.6402204", "0.6388831", "0.63882655", "0.63830256", "0.63775307", "0.6373993", "0.6372884", "0.6372884", "0.6372884", "0.6372884", "0.6372884", "0.6372884", "0.6372884", "0.6368019", "0.6363046", "0.6355095", "0.63527596", "0.63454956", "0.63435566", "0.63435566", "0.63391966", "0.63325006", "0.63275564", "0.63219", "0.63202083", "0.63192576", "0.6307735", "0.6296728", "0.6284399", "0.62830836", "0.62818795", "0.62818795", "0.62818795", "0.62818795", "0.62818795" ]
0.7245043
10
instantiates tuples for join table of reviews and User model
def index @user = current_user @presentation = Presentation.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_reviews\n self.reviews.select do |review|\n review.user.id = self.id \n end \n end", "def create_users_products\n @db.create_join_table(:user_id => :users, :product_id => :products) do\n end\n end", "def user_reviews\n Review.all.select {|review| review.user == self}\n end", "def user_reviews\n list_of_reviews = self.reviews\n list_of_reviews.map{|review| \"User: #{review.user.name}, Rating: #{review.rating}, Review: #{review.description}\"}\n end", "def rated_users\n User.where(user_id: ratings.pluck(:user_id))\n end", "def review\n @users = User.all\n @review = Review.new\n end", "def find_reviews_by_user(user) \n reviewable = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s\n \n Review.find(:all,\n :conditions => [\"user_id = ? and reviewable_type = ?\", user.id, reviewable],\n :order => \"created_at DESC\"\n )\n end", "def reviews\n reviews = []\n katas = Kata.all\n katas.each { |k| reviews += k.reviews.where(user_id: self.id) }\n return reviews\n end", "def make_project_feedbacks\n users = User.all\n projects = Project.all\n ProjectFeedback.create!(from_id: users.first.id, to_project_id: projects.first.id, project_attribute_identifier: \"1\", rating_given: \"7\")\n ProjectFeedback.create!(from_id: users.first.id, to_project_id: projects.first.id, project_attribute_identifier: \"1\", rating_given: \"4\")\n ProjectFeedback.create!(from_id: users.first.id, to_project_id: projects.first.id, project_attribute_identifier: \"2\", rating_given: \"5\")\nend", "def reviewers\n reviews.map { |r|\n r.user }.uniq\n end", "def reviews_as_owner\n Review.where(:product_id => product_ids)\n end", "def reviews\n Review.all.select do |r|\n r.user == self\n end\n end", "def listing_reviews\n Review.where(listing_id: listings.select(:id).collect(&:id))\n end", "def review_lender(user)\n\t\t5.times do |m|\n\t\t\tauthor \t\t\t= User.all.sample # random author, User.all bad for memory\n\t\t\treviews_hash \t= random_reviews_hash # generate a radom review (title/stars/summary)\n\t\t\ttitle \t\t\t= reviews_hash[:title]\n\t\t\tstars \t\t\t= reviews_hash[:stars]\n\t\t\tsummary \t\t= reviews_hash[:summary]\n\t\t\tcategory \t\t= random_category\n\n\t\t\t# Create rating\n\t\t\tauthor.ratings_given.create!(lender_id: user.id, stars: stars)\n\t\t\t# Create review\n\t\t\tauthor.reviews_given.create!(lender_id: user.id,\n\t\t\t\t\t\t\t\t\t\t\ttitle: title, \n\t\t\t\t\t\t\t\t\t\t\tstars: stars,\n\t\t\t\t\t\t\t\t\t\t\tsummary: summary, \n\t\t\t\t\t\t\t\t\t\t\tcategory: category)\n\t\tend\n\tend", "def create\n @user = User.find(params[:id])\n @user.reviews.push(current_user)\n redirect_to reviews_path\n end", "def logging_in\n guest_reviews = guest_user.reviews.all\n guest_reviews.each do |review|\n review.user_id = current_user.id\n review.save\n end\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save\n # end\n end", "def review_feedback\n @reviews = Feedback.where(:expert_id => params[:expert_id]).order(\"id DESC\")\n @review_list = []\n @reviews.each do |review|\n @review_list << {:consumer_id => review.user_id, :consumer_name=> review.user.username,\n :exp_id => review.expert_id, :exp_name => review.expert.first_name,\n :job_id => review.job_id, :issue_name => review.job.issue_name,\n :rating => review.rating, :feedback => review.description, :comp_date => review.job.complete_date, \n :status => review.job.status, :current_status => review.job.current_status}\n end \n end", "def make_service_provider_accessors\n ## Creating Many Service Providers for single user(accessor)\n service_providers = User.where(:role_id=>2).limit(20)\n accessor = User.where(:role_id=>3).first\n service_providers.each { |service_provider| Following.create(:user_id=>accessor.id,:follower_id=>service_provider.id) }\n\n ## Creating Many accessors for single user(Service Provider)\n accessors = User.where(:role_id=>3).order('created_at DESC').limit(20)\n service_provider = User.where(:role_id=>2).first\n accessors.each { |accessors| Following.create(:user_id=>accessors.id,:follower_id=>service_provider.id) }\nend", "def reviews\n # output = []\n # Review.all.each do |review|\n # if review.user == self\n # output << review\n # end\n # end\n # output\n Review.all.select { |review| review.user == self }\n end", "def liked_users \n users = object.liked_users.collect do |liked_user|\n # user = User.find_by(id: liked_user.liked_user_id)\n # user.attributes.except!(\"created_at\", :updated_at, :email)\n user = User.select(:id, :name, :gender, :age, :bio).find_by(id: liked_user.liked_user_id)\n end\n end", "def getUserReviews(u)\n @allR = []\n @es = User.find_by(id: u).events\n @es.each do |e|\n @rs = e.reviews\n @rs.each do |r|\n @allR.push(r)\n end\n end\n return @allR\n end", "def user_associations(users)\n x = []\n users.each do |u|\n puts \" collecting #{u.login}'s records\"\n\n ## PSEUDS will dump the actual user record and the user's preferences\n ## so they don't need to be dumped here.\n PSEUDS << u.pseuds\n\n # the roles are all dumped separately, so just dump the association here\n x << u.roles_users\n\n x << u.profile unless MULTI # profile's may have sensitive information that isn't visible\n\n TAGS << u.fandoms if u.tag_wrangler\n\n x << u.skins\n\n u.readings.find_in_batches(:batch_size => NTH) do |readings|\n x << readings.last\n WORKS << readings.last.work if MULTI\n end\n\n u.inbox_comments.find_in_batches(:batch_size => NTH) do |batch|\n inbox_comment = batch.last\n x << inbox_comment\n x << inbox_comment.feedback_comment\n commentable = inbox_comment.feedback_comment.ultimate_parent\n if MULTI\n if commentable.is_a?(Work)\n WORKS << commentable\n elsif commentable.is_a?(Tag)\n TAGS << commentable\n else\n x << commentable\n end\n end\n PSEUDS << inbox_comment.feedback_comment.pseud\n commentable = inbox_comment.feedback_comment.ultimate_parent\n WORKS << commentable if (MULTI && commentable.is_a?(Work))\n end\n\n # most of the associations are actually through the pseuds\n u.pseuds.each do |p|\n p.comments.find_in_batches(:batch_size => NTH) do |comments|\n comment = comments.last\n x << comment\n if MULTI\n commentable = comment.ultimate_parent\n if commentable.is_a?(Work)\n WORKS << commentable\n elsif commentable.is_a?(Tag)\n TAGS << commentable\n elsif commentable\n x << commentable\n end\n end\n end\n p.bookmarks.each do |bookmark|\n if !bookmark.private? || !MULTI\n x << bookmark\n x << bookmark.taggings\n TAGS << bookmark.tags\n if MULTI\n bookmarkable = bookmark.bookmarkable\n if bookmarkable.is_a?(Work)\n WORKS << bookmarkable\n elsif bookmarkable.is_a?(Series)\n x << bookmarkable\n bookmarkable.works.each {|w| WORKS << w}\n elsif bookmarkable.is_a?(ExternalWork)\n x << bookmarkable\n x << bookmarkable.taggings\n TAGS << bookmarkable.tags\n end\n end\n end\n end\n x << p.creatorships\n p.creatorships.map(&:creation).each do |item|\n if item.is_a?(Work)\n if item.posted? || !MULTI\n WORKS << item\n x << item.related_works\n item.related_works.each do |parent|\n if parent.is_a? Work\n WORKS << parent\n else\n x << parent\n end\n end\n x << item.parent_work_relationships\n item.children.each {|w| WORKS << w}\n end\n elsif item.is_a?(Chapter)\n # chapters get pulled in from works\n elsif item.is_a?(Series)\n x << item\n end\n end\n x << p.collections\n p.collections.each do |c|\n x << c.collection_profile\n x << c.collection_preference\n x << c.collection_participants\n PSEUDS << c.collection_participants.map(&:pseud)\n end\n end\n end\n x.flatten.compact.uniq\nend", "def index\n @reviews = Review.find params[:id]\n\n @user = User.find(params[user:id])\n @review = Review.new\n end", "def connect(user)\n user.purchases.each do |purchase|\n purchase.purchaser_id = self.id\n purchase.save\n end\n\n user.contributions.each do |contribution|\n contribution.user_id = self.id\n contribution.save\n end\n\n user.obligations.each do |obligation|\n obligation.user_id = self.id\n obligation.save\n end\n\n user.friendships.each do |friendship|\n friendship.user_id = self.id\n friendship.save\n end\n\n Friendship.where(friend: user).each do |friendship|\n friendship.friend_id = self.id\n friendship.save\n end\n\n user.memberships.each do |membership|\n membership.user_id = self.id\n membership.save\n end\n\n user.organized_trips.each do |trip|\n trip.organizer_id = self.id\n trip.save\n end\n\n self.facebook_id ||= user.facebook_id\n self.facebook_access_token ||= user.facebook_access_token\n self.facebook_access_token_expires_at ||= user.facebook_access_token_expires_at\n\n self.twitter_id ||= user.twitter_id\n self.twitter_access_token ||= user.twitter_access_token\n self.twitter_access_secret ||= user.twitter_access_secret\n\n self.save\n\n User.destroy(user.id)\n end", "def generate_user_pref(user_id, movie_id, rating)\n\t\tif (@user_set[user_id] != nil)\n\t\t\t#@user_set[user_id].push([movie_id, rating])\n\t\t\t@user_set[user_id][movie_id] = rating\n\t\telse\n\t\t\t@user_set[user_id] = Hash.new#Array.new.push([movie_id, rating])\n\t\t\t@user_set[user_id][movie_id] = rating\n\t\tend\n\tend", "def construct_join_attributes(*records)\n if @reflection.source_reflection.macro != :belongs_to\n raise HasManyThroughCantAssociateThroughHasOneOrManyReflection.new(@owner, @reflection)\n end\n\n join_attributes = {\n @reflection.source_reflection.foreign_key =>\n records.map { |record|\n record.send(@reflection.source_reflection.association_primary_key)\n }\n }\n\n if @reflection.options[:source_type]\n join_attributes[@reflection.source_reflection.foreign_type] =\n records.map { |record| record.class.base_class.name }\n end\n\n if records.count == 1\n Hash[join_attributes.map { |k, v| [k, v.first] }]\n else\n join_attributes\n end\n end", "def lacticate_users(user1,user2)\n # PostgresUser.lacticate_users(user1,user2)\n lacticate_pg_users(user1,user2)\n end", "def listing_ratings\n review_ids = Review.where(listing_id: listings.select(:id).collect(&:id)).select(&:id).collect(&:id)\n ReviewRating.where(review_id: review_ids)\n end", "def tags_with_user_ids\n model_tags.inject([]) do |arr, tag|\n tag.user_ids.each{|user_id| arr << [tag.id, user_id]}\n arr\n end\n end", "def make_service_provider_students\n ## Creating Many Service Providers for single user(student)\n service_providers = User.where(:role_id=>2).limit(20)\n student = User.where(:role_id=>4).first\n service_providers.each { |service_provider| Following.create(:user_id=>student.id,:follower_id=>service_provider.id) }\n\n ## Creating Many Students for single user(Service Provider)\n students = User.where(:role_id=>4).order('created_at DESC').limit(20)\n service_provider = User.where(:role_id=>2).first\n students.each { |student| Following.create(:user_id=>student.id,:follower_id=>service_provider.id) }\nend", "def set_reviews\n @reviews = Review.where(restaurant_id: @restaurant.id).order(\"created_at DESC\")\n end", "def find_my_students \n User.joins(learnables: {skill: {teachables: :user}}).where(\"users_relationships.id = ? and users.id != ?\", id, id).distinct\n end", "def fetch\n Product.includes(:reviews).all\n end", "def associate_review\n review = Review.find_by(user_id: self.user_id, skin_id: self.skin_id)\n self.review_id = review.id if review\n end", "def users_ranking\n User.find_by_sql(\"SELECT U.id, U.name, COUNT(R.id) ediciones\n FROM users U, reviews R, species S, groups G, group_users GU, species_groups SG, models m\n WHERE U.id = R.user_id AND U.id = GU.user_id AND GU.group_id = G.id\n AND SG.group_id = G.id AND S.id=SG.species_id AND m.id =R.model_id\n AND m.species_id = S.id AND SG.species_group_state_id=1 AND GU.group_user_state_id=1\n AND G.id = \"+self.id.to_s+\"\n GROUP BY U.name\n ORDER BY COUNT(R.id) DESC\n LIMIT 10\")\n end", "def has_many_ratings(veteran)\n in_active_review_reference_id = KNOWN_REQUEST_ISSUE_REFERENCE_ID\n in_active_review_receipt_date = Time.zone.parse(\"2018-04-01\")\n completed_review_receipt_date = in_active_review_receipt_date - 30.days\n completed_review_reference_id = \"cleared-review-ref-id\"\n contention = Generators::Contention.build\n\n Generators::PromulgatedRating.build(\n participant_id: veteran.participant_id\n )\n Generators::PromulgatedRating.build(\n participant_id: veteran.participant_id,\n profile_date: ama_begin_date + 3.days,\n promulgation_date: ama_begin_date + 7.days,\n issues: [\n { decision_text: \"Left knee\" },\n { decision_text: \"Right knee\" },\n { decision_text: \"PTSD\" },\n { decision_text: \"This rating is in active review\", reference_id: in_active_review_reference_id },\n { decision_text: \"I am on a completed Higher Level Review\", contention_reference_id: contention.id }\n ]\n )\n Generators::PromulgatedRating.build(\n participant_id: veteran.participant_id,\n profile_date: ama_begin_date - 10.days,\n promulgation_date: ama_begin_date - 5.days,\n issues: [\n { decision_text: \"Issue before AMA not from a RAMP Review\", reference_id: \"before_ama_ref_id\" },\n { decision_text: \"Issue before AMA from a RAMP Review\",\n associated_claims: { bnft_clm_tc: \"683SCRRRAMP\", clm_id: \"ramp_claim_id\" },\n reference_id: \"ramp_reference_id\" }\n ]\n )\n ramp_begin_date = Date.new(2017, 11, 1)\n Generators::PromulgatedRating.build(\n participant_id: veteran.participant_id,\n profile_date: ramp_begin_date - 20.days,\n promulgation_date: ramp_begin_date - 15.days,\n issues: [\n { decision_text: \"Issue before test AMA not from a RAMP Review\", reference_id: \"before_test_ama_ref_id\" },\n { decision_text: \"Issue before test AMA from a RAMP Review\",\n associated_claims: { bnft_clm_tc: \"683SCRRRAMP\", clm_id: \"ramp_test_claim_id\" },\n reference_id: \"ramp_reference_id\" }\n ]\n )\n Generators::PromulgatedRating.build(\n participant_id: veteran.participant_id,\n promulgation_date: Time.zone.today - 395,\n profile_date: Time.zone.today - 400,\n issues: [\n { decision_text: \"Old injury\" }\n ]\n )\n hlr = HigherLevelReview.find_or_create_by!(\n veteran_file_number: veteran.file_number,\n receipt_date: in_active_review_receipt_date\n )\n epe = EndProductEstablishment.find_or_create_by!(\n reference_id: in_active_review_reference_id,\n veteran_file_number: veteran.file_number,\n source: hlr,\n payee_code: EndProduct::DEFAULT_PAYEE_CODE\n )\n RequestIssue.find_or_create_by!(\n decision_review: hlr,\n benefit_type: \"compensation\",\n end_product_establishment: epe,\n contested_rating_issue_reference_id: in_active_review_reference_id\n ) do |reqi|\n reqi.contested_rating_issue_profile_date = (Time.zone.today - 100).to_s\n end\n Generators::EndProduct.build(\n veteran_file_number: veteran.file_number,\n bgs_attrs: { benefit_claim_id: in_active_review_reference_id }\n )\n previous_hlr = HigherLevelReview.find_or_create_by!(\n veteran_file_number: veteran.file_number,\n receipt_date: completed_review_receipt_date\n )\n cleared_epe = EndProductEstablishment.find_or_create_by!(\n reference_id: completed_review_reference_id,\n veteran_file_number: veteran.file_number,\n source: previous_hlr,\n synced_status: \"CLR\",\n payee_code: EndProduct::DEFAULT_PAYEE_CODE\n )\n RequestIssue.find_or_create_by!(\n decision_review: previous_hlr,\n benefit_type: \"compensation\",\n end_product_establishment: cleared_epe,\n contested_rating_issue_reference_id: completed_review_reference_id,\n contention_reference_id: contention.id\n ) do |reqi|\n reqi.contested_rating_issue_profile_date = Time.zone.today - 100\n end\n Generators::EndProduct.build(\n veteran_file_number: veteran.file_number,\n bgs_attrs: { benefit_claim_id: completed_review_reference_id }\n )\n Generators::PromulgatedRating.build(\n participant_id: veteran.participant_id,\n promulgation_date: ama_begin_date + 10.days,\n issues: [\n { decision_text: \"Lorem ipsum dolor sit amet, paulo scaevola abhorreant mei te, ex est mazim ornatus.\" },\n { decision_text: \"Inani movet maiestatis nec no, verear periculis signiferumque in sit.\" },\n { decision_text: \"Et nibh euismod recusabo duo. Ne zril labitur eum, ei sit augue impedit detraxit.\" },\n { decision_text: \"Usu et praesent suscipiantur, mea mazim timeam liberavisse et.\" },\n { decision_text: \"At dicit omnes per, vim tale tota no.\" }\n ]\n )\n Generators::PromulgatedRating.build(\n participant_id: veteran.participant_id,\n promulgation_date: ama_begin_date + 12.days,\n issues: [\n { decision_text: \"In mei labore oportere mediocritatem, vel ex dicta quidam corpora.\" },\n { decision_text: \"Vel malis impetus ne, vim cibo appareat scripserit ne, qui lucilius consectetuer ex.\" },\n { decision_text: \"Cu unum partiendo sadipscing has, eius explicari ius no.\" },\n { decision_text: \"Cu unum partiendo sadipscing has, eius explicari ius no.\" },\n { decision_text: \"Cibo pertinax hendrerit vis et, legendos euripidis no ius, ad sea unum harum.\" }\n ]\n )\n end", "def create_recommendable_sets\n [create_liked_by_set, create_disliked_by_set]\n end", "def create_recommendable_sets\n [create_liked_by_set, create_disliked_by_set]\n end", "def create_recommendable_sets\n [create_liked_by_set, create_disliked_by_set]\n end", "def this_user_and_assignment\n rec = CONNECTION.execute(\"SELECT * FROM #{table} WHERE user_id = #{user.id} AND assignment_id = #{assignment.id};\").first\n if rec.blank?\n Collaborator.new\n else\n Collaborator.new(rec)\n end\n end", "def review_user\n self.user\n end", "def get_students \n User.joins(learnables: {skill: {teachables: :user}}).where(\"users_users_skills.id = ? and users.id != ?\", id, id).distinct\n end", "def user_list\n @user_ratings.map(&:user_id).sort\n end", "def make_assignments(assigned_users)\n assigned_users.each do |user|\n existing_assignment = Assignment.find_by_user_id_and_question_id(user.id,self.id)\n Assignment.create(:user_id => user.id , :question_id => self.id)if existing_assignment == nil\n end \n end", "def movies\n # output = []\n # Review.all.each do |review|\n # if review.user == self\n # output << review.movie\n # end\n # end\n # output\n reviews.map { |review| review.movie }\n end", "def set_reviews_and_rating\n @reviews_and_rating = ReviewsAndRating.find(params[:id])\n end", "def find_reviewers(topic)\n User.all.collect{|u| u if u.reviews.count > 0}.compact\n end", "def arel\n users = User.arel_table\n users.where(users[:name].eq(@name))\n .project(users[:email])\n end", "def jobs_to_review\n jobs = Job.find(:all, :joins => [:user], \n :conditions =>[\"users.distributor_id = ? and (jobs.status_id = ? or jobs.status_id = ?)\",\n self.id, Status.find_by_label(\"review\").id, Status.find_by_label(\"improved\").id] )\n end", "def construct_nested_join_attributes( reflection = @reflection, \n association_class = reflection.klass,\n table_ids = {association_class.table_name => 1})\n if reflection.through_reflection\n construct_has_many_through_attributes(reflection, table_ids)\n else\n construct_has_many_or_belongs_to_attributes(reflection, association_class, table_ids)\n end\n end", "def likers\n likes.map do |like|\n like.user\n end\n end", "def library_reviewers\n Role.find_by(name: 'library_reviewers').users.to_a\n end", "def rates_by\n recommendable_likes.map(&:user_id) + recommendable_dislikes.map(&:user_id)\n end", "def reviews\n ([host_review] + [guest_review]).compact\n end", "def user_likes\n q = \"INNER JOIN liked_info ON users.id = liked_info.user_id WHERE liked_info.thing_id = #{id} AND liked_info.thing_type = 'Serial'\"\n User.joins(q)\n end", "def review_type_role_assignment\n\n # Get all of the reviewer roles.\n @roles = Role.get_manager_review_roles + Role.get_review_roles\n @review_types = ReviewType.get_active_review_types\n @role_types = {}\n @roles.each do |role|\n\n rtypes = {}\n role.review_types.each do |rtype|\n rtypes[rtype.name] = rtype.id\n end\n\n @role_types[role.id] = rtypes\n end\n\n end", "def find_store_review\n store_id = @store.id\n \n store_review = StoreReview.new\n Category.all.each do |c|\n store_review.add_category(c.category)\n storetagusers = StoreTagUser.joins(:tag => :category).select(\"name, count(*) as tag_num\").where(\"category = ? and store_id = ?\",c.category, store_id).group(\"tag_id,name\").order(\"tag_num DESC\")\n storetagusers.each do |s|\n store_review.add_tag(c.category, s.name)\n end\n end\n \n return store_review\n end", "def my_reviews\n Review.all.select do |review_instance|\n review_instance.traveller == self\n end\n end", "def initialize_reviewers\n reviewers = MinHeap.new\n course.get_real_students.shuffle.each do |r|\n reviews = evaluations.forUser(r)\n # Don't assign new reviews to someone who as completed all their reviews\n unless reviews.length > 0 and reviews.length == reviews.select{|e| e.finished }.length\n # Create a bias towards assigning reviewers who have not yet submitted so as avoid entrapment by the self-review prohibition\n bias = submissions.any?{|s| s.user_id == getTeamID(r)} ? 1 : 0\n reviewers.push(2 * reviews.length + bias, r)\n end\n end\n reviewers\n end", "def reviewer_list\n\n reviewers = []\n design_review_results =\n DesignReviewResult.find_all_by_design_review_id(self.id)\n\n design_review_results.each do |dr_result|\n reviewer = User.find(dr_result.reviewer_id)\n reviewers << reviewer.email if reviewer.active?\n end\n \n return reviewers.uniq\n\n end", "def join_tables(db)\n db.execute(\"SELECT users.user_name, platform.platform_name, music.artist, music.song, music.explicit_lyrics FROM music JOIN users ON music.user_id = users.id JOIN platform ON music.platform_id = platform.id\")\nend", "def reviews( params={} )\n reviews = get_connections(\"reviews\", params)\n return map_connections reviews, :to => Facebook::Graph::Review\n end", "def get_stars()\n sql = \"\n SELECT stars.* FROM stars\n INNER JOIN castings\n ON castings.star_id = stars.id\n WHERE movie_id = $1;\n \"\n values = [@id]\n pg_array = SqlRunner.run(sql, values)\n stars = pg_array.map { |star| Star.new(star) }\n return stars\nend", "def create\n @review = Presentation.find(params[:id]).reviews.build(reviews_params)\n @review.user_id = current_user.id\n @review.save\n redirect_to current_user\n end", "def reviewer_list\n\n reviewers = []\n design_review_results =\n DesignReviewResult.find_all_by_design_review_id(self.id)\n\n design_review_results.each do |dr_result|\n reviewer = User.find(dr_result.reviewer_id)\n reviewers << reviewer.email if reviewer.active?\n end\n\n return reviewers.uniq\n\n end", "def show\n @reviews = Review.where(user_id: @user.id).includes(:spot)\n end", "def relation_method\n :join\n end", "def index\n @reviews_and_ratings = ReviewsAndRating.all\n end", "def user_info(user_id, list_id)\n return [db.execute(\"SELECT * FROM users WHERE user_id=?\", user_id), db.execute(\"SELECT * FROM listings WHERE list_id=?\", list_id)]\nend", "def userindex\n @user = User\n .left_joins(:reviews).includes(:reviews)\n .find(current_user.id)\n\n reviews = @user.reviews\n render json: reviews\n end", "def commenters\n # User.joins(:comments).where(comments: {discussion_id: id}).uniq\n User.where(id: comments.pluck(:author_id))\n end", "def show\n @owner_id = @product.originaluser_id \n # @reviews = Review.where('owner_id = ?', @owner_id)\n @reviews = Review.where('owner_id = ?', @owner_id).where('reviews.approved = ?', true)\n \n # Review.joins(:user).where('reviews.approved = ?', true).where('users.id = ?', @owner_id)\n end", "def loop_it(users, trait)\n users.each do |user|\n users.each do |boozer|\n rand_num = rand(1..100)\n Rating.create(value: rand_num, rater_id: user.id, ratee_id: boozer.id, trait_id: trait.id)\n end\n end\nend", "def create\n @seller_review = SellerReview.new(seller_review_params)\n @seller_review.reviewer_id = current_user.id\n\n\n respond_to do |format|\n if @seller_review.save\n User.find(@seller_review.seller_id).seller_reviews << @seller_review\n format.html { redirect_to @seller_review, notice: 'Seller review was successfully created.' }\n format.json { render :show, status: :created, location: @seller_review}\n else\n format.html { render :new }\n format.json { render json: @seller_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @user = User.find(params[:id])\n @items = Item.where(user_id: @user.id)\n @reviews = Review.where(user_id: @user.id)\n end", "def queryk\n \t@user = User.select(:email).joins(:reviews).group(:email).having('count(review) > ?', params[:num_reviews]).count.keys\n end", "def user_posts_and_comments\n %w(posts comments).freeze\n end", "def all_for_user\n \n puts \"GETS HEREEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\"\n @user = User.find(params[:id])\n puts @user.to_yaml\n @user_reviews = UserReview.find(:all, :conditions => ['user_id = ?', @user.id])\n end", "def users_with_vote(vote_value)\n voted_users.where(\"personality_review_votes.vote=?\", vote_value)\n end", "def authors_join_table\n self.class.authors_join_table\n end", "def readers\n group_users(readers_join_table)\n end", "def user_review(user_id, book_id, params = {})\n data = request('/review/show_by_user_and_book.xml', params.merge(v: \"2\", user_id: user_id, book_id: book_id))\n Hashie::Mash.new(data[\"review\"])\n end", "def my_results(user)\n self.design_review_results.to_ary.find_all { |drr| drr.reviewer == user }\n end", "def set_user\n @comments = Comment.all\n @favorites = Favorite.all\n @votes = Vote.all\n end", "def triples\n requesters, approvers, observers = self.partitioned_roles\n requesters = requesters.map { |r| [r.user, \"Requester\", nil] }\n approvers = approvers.map { |r| [r.user, \"Approver\", nil] }\n observers = observers.map { |r| [r.user, nil, self.observation_for(r.user)] }\n\n requesters + approvers + observers\n end", "def users_for_new_pull_reviewers(pull)\n users = users_for_new_pull(pull)\n\n users.select{|user| pull.reviewable?(user) }\n end", "def generate_reviews\n pos_probs = cond_probs(:pos)\n neg_probs = cond_probs(:neg)\n reviews = { pos: [], neg: [] }\n\n 5.times do\n reviews[:pos] << generate_feature_vector(pos_probs)\n reviews[:neg] << generate_feature_vector(neg_probs)\n end\n reviews[:pos].map! { |f| convert(f) }\n reviews[:neg].map! { |f| convert(f) }\n reviews\n end", "def link!\n base = ::ActiveRecord::Associations::ClassMethods::JoinDependency.new(\n @model, [], nil\n )\n \n @fields.each { |field|\n field.model ||= @model\n field.columns.each { |col|\n field.associations[col] = associations(col.__stack.clone)\n field.associations[col].each { |assoc| assoc.join_to(base) }\n }\n }\n \n @attributes.each { |attribute|\n attribute.model ||= @model\n attribute.columns.each { |col|\n attribute.associations[col] = associations(col.__stack.clone)\n attribute.associations[col].each { |assoc| assoc.join_to(base) }\n }\n }\n end", "def viewers(m)\n\t\tviewer_list = []\n\t\ttraining_set.each do |row|\n\t\t\tif row[\"movie_id\"] == m\n\t\t\t\tviewer_list.push({\"user_id\"=>row[\"user_id\"],\"rating\"=>row[\"rating\"]})\n\t\t\tend\n\t\tend\n\t\treturn viewer_list\n\tend", "def database_field_names\n [\"user_id\", \"assignment_id\"]\n end", "def show\n @member = User.find(params[:id])\n conn = Connection.where(:user_id => @current_user.id).pluck(:connection_id)\n user = Connection.where(:connection_id => @current_user.id).pluck(:user_id)\n all = user + conn\n @connections = User.where(:id => all)\n @member = User.find(params[:id])\n @reviews = UsersQuest.where(:assignee_id => @current_user.id)\n\tend", "def _arel\n if _on\n [_join.new(_table, _on)]\n else\n @associations.each.with_index.inject([]) do |joins, (assoc, i)|\n construct @associations[0..i], joins, assoc._join\n end\n end\n end", "def add_user(rating)\n @user_list[rating.user_id] ||= User.new\n @user_list[rating.user_id].add(rating)\n end", "def reviews\n Review.all.select {|review| review.customer == self}\n end", "def map_skills_to_users\n puts 'Giving Users a random set of Skills'\n\n skills = Skill.all\n locations_skills_users = []\n User.find_each do |user|\n #generates a random number (between 1 and 3) of skills per person, and gives a random proficiency level\n max_num_skills = 3\n user_skills = Set.new\n (1..rand(1..max_num_skills)).each do\n random_skill = skills.sample\n user_skills.include?(random_skill) ? next : user_skills.add(random_skill)\n\n\n random_proficiency_level = rand(1..5)\n locations_skills_users << LocationsSkillsUsers.new(location_id: user.location.id, skill_id: random_skill.id,\n user_id: user.id, proficiency_level: random_proficiency_level)\n end\n end\n LocationsSkillsUsers.import(locations_skills_users)\n end", "def recommend_new_users\n user_ids = following_ids + [self.id]\n User.only(:id, :name, :avatar, :recommend_note).nin(id: user_ids).desc(:recommend_priority, :karma)\n end", "def load_feedbacks\n feedbacks = Walmart.get_feedbacks_for self.name\n\n feedbacks.each do |f|\n self.reviews.create! :text => f\n end\n end", "def customers\n self.reviews.collect do |review|\n review.customer\n end\n end", "def knowledgable_users\n topic_answers = self.answers\n topic_user_scores = Hash.new(){0}\n authors_with_answers = Hash.new(){0}\n\n topic_answers.each do |answer|\n answer_author = answer.author\n authors_with_answers.push(answer_author)\n topic_user_scores[answer_author] += 1\n end\n\n authors_with_answers.each do |author|\n prev_record = TopicUserKnow.find_by({author_id: author.id, topic_id: topic.id})\n if prev_record\n prev_record.update_attributes({score: topic_user_scores[author] })\n else\n TopicUserKnow.create({author_id: author.id, topic_id: topic.id, score: topic_user_scores[author]})\n end\n end\n\n end", "def reviews\n @items = ProductComment.includes(:account).where({product: @product}).all\n end", "def create\n @review = Review.new(review_params)\n @review.user_id = current_user.id\n @review.post_date = Time.now\n\n if @review.save\n # Create notifications for the user's friends\n current_user.friends.each do |friend|\n Notification.create(recipient: friend, actor: current_user, action: 'posted', notifiable: @review)\n end\n\n # Create and attach the tags\n create_tags collect_tags(params[:review]), @review.id\n redirect_to '/profile'\n else\n redirect_to '/home'\n end\n end" ]
[ "0.6087441", "0.6030822", "0.575462", "0.5687787", "0.5681288", "0.56111884", "0.55482954", "0.5392939", "0.53920627", "0.53743136", "0.53597075", "0.53304", "0.5269897", "0.52576977", "0.522217", "0.51144004", "0.509312", "0.5079994", "0.5061492", "0.50453436", "0.5027106", "0.5014577", "0.49958488", "0.4986088", "0.4982252", "0.49381453", "0.49368742", "0.49346396", "0.49211448", "0.48692232", "0.48677197", "0.48602882", "0.4852527", "0.48245314", "0.4818306", "0.48002768", "0.4797997", "0.4797997", "0.4797997", "0.4797153", "0.47896275", "0.47772855", "0.4774974", "0.4760182", "0.47567332", "0.47558373", "0.4755625", "0.47545242", "0.47537485", "0.47459453", "0.4740054", "0.47356442", "0.47254878", "0.4725297", "0.47245264", "0.47214118", "0.47090265", "0.47082937", "0.47077572", "0.47072655", "0.47056964", "0.4701039", "0.46992946", "0.46773237", "0.46766803", "0.46722102", "0.46626788", "0.4661723", "0.46600726", "0.46576345", "0.46555424", "0.4652303", "0.46505573", "0.46434855", "0.4634817", "0.46341977", "0.4633588", "0.463249", "0.46297655", "0.46230346", "0.46226022", "0.46208212", "0.4620693", "0.46187532", "0.46103355", "0.4608566", "0.4604712", "0.45968702", "0.45940337", "0.4588764", "0.458043", "0.45716", "0.45643216", "0.4561994", "0.4560384", "0.45566788", "0.45519555", "0.4551868", "0.45476338", "0.45461792", "0.45442107" ]
0.0
-1
returns attributes for reviews instance from form data of post request
def reviews_params params.permit(:score, :comment) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def review_params\n params.fetch(:review, {}).permit(:rating, :body, :restaurant_id, :timestamp)\n end", "def review_params\n params.require(:review).permit( :comment, :attraction_id)\n end", "def review_params\n parm = params.fetch(:review, {}).permit!\n p 'params', parm\n parm\n end", "def visitor_review_params\n params.fetch(:visitor_review, {})\n end", "def critic_review_params\n params[:critic_review]\n end", "def reviews_and_rating_params\n params.fetch(:reviews_and_rating, {})\n end", "def reviews\n @reviews\n end", "def review_params\n # params.require(:review).permit(:membership_id, :user_id, :rating, :comments, :lti_app_id)\n end", "def review_params\n params.require(:review).permit(:first_name, :last_name, :product_name, :image_url, :location, :feedback, :stars, :category_id)\n end", "def review\n @review\n end", "def review_params\n params.require(:review).permit(:product_image, :email, :location_id, :comment, :reviewer_image, :visibility, :product_name, :first_name, :last_name)\n end", "def review_params\n params.require(:review).permit( :description, :rating)\n end", "def reviews_params\n params.require(:review).permit(:name, :email, :content, :score)\n end", "def review_params\n params.require(:review).permit(:yelp_business_id, :yelp_user_id, :content, :stars)\n end", "def review_params\n\n params_new = params.require(:review).permit(:rating, :comments)\n params_new[:customer_id] = session[:customer_id]\n @bookings = Booking.find(params[:id])\n params_new[:listing_id] = @bookings.listing_id\n params_new[:anonymous] = params[:anonymous]\n params_new\n end", "def review_params\n params.require(:review).permit(:description, :rating)\n end", "def review_params\n params.require(:review).permit(:description, :rating, :restaurant_id)\n end", "def form_params\n params.require(:review).permit(:title, :restaurant, :body, :score, :ambiance, :cuisine, :price, :address, :photo)\n end", "def review_params\n params.require(:review).permit(:rating, :description)\n end", "def review_params\n params.require(:review).permit(:rating, :comment, :site_id)\n end", "def review_params\n params.require(:review).permit(:rating, :comment)\n end", "def review_params\n params.require(:review).permit(:rating, :review_content, :date_time)\n end", "def review_params\n params.require(:review).permit(:property_id, :body, :title, :property_rating, :created_at, :updated_at, :landlord_rating, :landlord_comments, :duration, :is_anonymous, :is_current_tenant)\n end", "def review_params\n params.require(:review).permit(:rating, :comment)\n end", "def review_params\n params.require(:review).permit(:rating, :comment)\n end", "def review_params\n params.require(:review).permit(:customer_id, :car_id, :reservation_id, :content, :rating)\n end", "def review_params\n params.require(:review).permit(:product_id, :user_id, :description, :rating)\n end", "def review_params\n params.require(:review).permit(:product_id, :user_id, :description, :rating)\n end", "def review_params\n params.require(:review).permit(:product_id, :user_id, :description, :rating)\n end", "def review_params\n params.require(:review).permit(:name, :comment, :rating, :product_id)\n end", "def review_params\n params.require(:review).permit(:rating, :description, :professor_id, :course_id)\n end", "def review_params\n params.require(:review).permit(:rating, :content)\n end", "def review_params\n params.require(:review).permit(:rating, :comment)\n end", "def review_params\n params.require(:review).permit(:content, :rating)\n end", "def review_params\n params.permit(:reviewer, :comment, :rating, :restaurant_id)\n end", "def review_params\n params.require(:review).permit(:user_id, :comic_id, :review_text, :review_title, :netabare, :tag_list, :star)\n end", "def review_params\n\t\t\tparams.require(:review).permit(:comment, :rating)\n\t\tend", "def review_params\n params.require(:review).permit(:content, :rating)\n end", "def review_params\n params.require(:review).permit(:title, :body, :rating, :brewery)\n end", "def review_params\n params.require(:restaurant_review).permit(:content, :rating, :restaurant_id)\n end", "def review_params\n params.require(:review).permit(:lecture_id, :user_id, :content, :rating)\n end", "def review_params\n params.require(:review).permit(:overall_rating, :supervisor_rating, :time_commitment, :expected, :work_description, :anonymous, :reflection, :supervisor_id, :student_id) \n end", "def permited_params\n params.require(:review).permit(:title, :detail, :rating)\n end", "def review_params\n params.require(:review).permit(:rating, :review_text, :book_id, :user_id)\n end", "def review_params\n params.require(:review).permit(:title, :body, :score, :hotel_id, :user_id)\n end", "def review_params\n params.require(:review).permit(:title, :body, :user_id, :movie_id, :rating)\n end", "def review_params\n params.require(:review).permit(:name, :email, :title, :body)\n end", "def review_params\n params.require(:review).permit(:reviewer, :body)\n end", "def review_params\n params[:review].permit(:title, :content)\n end", "def review_params\n params.require(:review).permit(:name, :description, :body, :year, :date, :place, :img, :artist_id, :category_id, :author_id, :fav1, :fav2, :fav3)\n end", "def review_params\n params.require(:review).permit(:score, :confidence, :comments, :paper_id)\n end", "def reviews\n self.reviews\n end", "def review_params\n params.require(:review).permit(:user_id, :target, :rating, :review)\n end", "def review_params\n params.permit(:review, :body, :title, :reviewable_id, :reviewable_type)\n end", "def review_params\n params.require(:review).permit(:debt_placement_id, :review_level, :service_level, :aggresive_level, :speed_level, :description)\n end", "def review_params\n params.require(:review).permit(:title, :description, :score, :course_id)\n end", "def review_params\n params.require(:review).permit(:reviewer, :reviewee, :skill_id, :stars, :body)\n end", "def review_params\n params.require(:review).permit(:title, :description, :overall_rating, :replayability, :first_time_difficulty, :user_id, :boardgame_id)\n end", "def restaurant_review_params\n params.require(:restaurant_review).permit(:reviewer_name, :rating, :comment, :restaurant_id)\n end", "def review_params\n params.require(:review).permit(:comment, :rating, :book_id, :user_id)\n end", "def review_params\n params.require(:review).permit(:comment, :rating, :user_id)\n end", "def review\n fetch('restaurant.review')\n end", "def review_params\n params.fetch(:comment_review, {}).permit(:id,:comment_id,:review_text,:admin_id)\n end", "def review_params\n params.require(:review).permit(:menu, :comment, :image)\n end", "def item_review_params\n params.require(:item_review).permit(:restaurant_id, :user_id, :item_id, :review, :rating, :date)\n end", "def review_params\n params.require(:review).permit(:name, :email, :content, :score, :subscription_id, :user_id)\n end", "def review_params\n params.require(:review).permit(:author, :content, :rating, :user_id)\n end", "def review_params\n params.require(:review).permit(:title, :published, :author, :category_id, :score, :content, :portrait)\n end", "def review_params\n params.require(:review).permit(:title, :author, :rating, :user_id)\n end", "def review_params\n params.require(:review).permit(:title, :poster, :date, :article)\n end", "def create\n final_set = []\n params['doctors_review'].permit!\n doctors_id = params['doctors_review']['doctors_id']\n specialties_id = DoctorsSpecialty.where(doctors_id: doctors_id).first\n .specialties_id\n specialty = Specialty.find(specialties_id)\n unless specialties_id.nil?\n params['doctors_review']['specialties_id'] = specialties_id\n end\n @doctors_reviews = DoctorsReview.new(params['doctors_review'])\n if @doctors_reviews.save\n rating = params['doctors_review']['rating']\n unless rating.nil?\n all_reviews = DoctorsReview.where(specialties_id: specialties_id)\n .where('rating >= ?', rating).order('rating')\n all_reviews&.each do |review|\n doctor = Doctor.find(review['doctors_id'])\n recommendations = { specialty: specialty.name,\n doctor: doctor.name,\n rating: review.rating,\n comments: review.comments\n }\n final_set << recommendations\n end\n end\n final_set\n else\n @doctors_reviews.errors.full_messages\n end\n end", "def review_params\n params.permit(:appointment_id, :talent_id)\n params.require(:review).permit(:mark, :comment)\n end", "def review_params\n params.require(:review).permit(:user_id, :shop_id, :order_id, :content, :score)\n end", "def review_params\n params.require(:review).permit(:title, :taste_eval,:price_eval,:service_eval,:contents, :restaurant_id,:image_path)\n end", "def review_params\n params.permit(:body, :city, :country, :user_name, :rating)\n end", "def review_params\nparams.require(:review).permit(:rating, :comment)\n\tend", "def reviews\n @reviews ||= (@doc/\"ProductReview\").collect { |it| Element.new(it) }\n end", "def review_params\n params.require(:review).permit(:game_id, :user_id, :score, :content)\n end", "def facility_review_params\n params.require(:facility_review).permit(:reviewer, :facility, :title, :description, :rating)\n end", "def create\n review = course.reviews.new(review_params)\n \n if review.save\n render json: ReviewSerializer.new(review).serialized_json\n else\n render json: { error: review.errors.messages }, status: 422\n end\n end", "def review_show_data\n review = Review.find(params[:review])\n\n @data = {\n user_name: review.user.full_name,\n user_id: review.user.id,\n user_email: review.user.email,\n org_name: review.user.organization.name,\n org_id: review.user.organization.id,\n vendor_name: review.vendor.name,\n vendor_id: review.vendor.id,\n rating: review.rating,\n public_review: review.review_content,\n private_review: review.review_private_content,\n private_review_permission: private_review_permission(review.user),\n logo_link: review.user.organization.logo_link,\n days_ago: review.days_old\n }\n\n render json: @data\n end", "def review_params\n params.require(:review).permit(:body)\n end", "def review_params\n\t\tparams.require(:review).permit(:name, :priority, :comment)\n\tend", "def review_params\n params.require(:review).permit(:comment)\n end", "def review_params\n params.require(:review).permit(:comment)\n end", "def rating_params\n params.fetch(:rating, {})\n end", "def review_params\n params.require(:review).permit(:comment, :title, :rating,\n :parking_space_id, :owner_name)\n end", "def dealer_review_params\n params.require(:dealer_review).permit(:rating, :content)\n end", "def review_params\n params.require(:review).permit(:user_id, :service_id, :text)\n end", "def review_params\n params.require(:review).permit(:content,:user_id,:entry_id,:rating)\n end", "def auditreview_params\n #params.fetch(:auditreview, {})\n params.require(:auditreview).permit(:tenant_id, :date, :correct, :incorrect, :mealtime, :category, :rating)\n end", "def blade_review_params\n params.require(:blade_review).permit(:text, :date, :razor_id, :blade_id)\n end", "def new\n @review = reviewable.reviews.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def review_params\n params.require(:review).permit(:content)\n end", "def rating_params\n params[:rating]\n end", "def new\n @review = Review.new\nend", "def review_params\n params.require(:review).permit(:content)\n end", "def review_params\n params.require(:review).permit(:content)\n end", "def review_params\n params.require(:review).permit(:title, :body, :book_id)\n end", "def review_params\n params.require(:review).permit(\n :overall_rating,\n :letter_grade,\n :semester,\n :year,\n :course_required,\n :interesting,\n :difficult,\n :standardized_course,\n :course_other_thoughts,\n :used_textbook,\n :attendance_mandatory,\n :course_format,\n :cared_about_material,\n :open_to_questions,\n :cared_about_students,\n :clear_grading,\n :homework_heavy,\n :clear_explanations,\n :fast_grading,\n :professor_other_thoughts,\n :professor_id,\n :course_id\n )\n end" ]
[ "0.66076064", "0.6541703", "0.65186834", "0.6511674", "0.64998484", "0.648443", "0.6455477", "0.6448019", "0.63681144", "0.6337014", "0.6321367", "0.6294514", "0.6292441", "0.62871933", "0.62807584", "0.62787795", "0.62758386", "0.6268009", "0.6266792", "0.62548", "0.6239934", "0.62377524", "0.6233852", "0.62240994", "0.62240994", "0.6222637", "0.62215114", "0.62215114", "0.62215114", "0.62100816", "0.62081325", "0.6190432", "0.6189069", "0.6184088", "0.6171856", "0.6167806", "0.61667025", "0.61580884", "0.6155051", "0.61384183", "0.61360705", "0.6113245", "0.6091659", "0.6086569", "0.6076958", "0.60767674", "0.6072481", "0.60521764", "0.6042015", "0.6041595", "0.60408336", "0.6025988", "0.60215557", "0.60166955", "0.60086566", "0.60056853", "0.59961605", "0.5982928", "0.59804016", "0.59741354", "0.59727716", "0.5960828", "0.5960821", "0.5957545", "0.5950853", "0.59442204", "0.5942463", "0.59312856", "0.592509", "0.5920496", "0.5897464", "0.5897343", "0.58932483", "0.5867489", "0.58577216", "0.5848906", "0.58482695", "0.5841898", "0.58414465", "0.58356506", "0.5835545", "0.583046", "0.58242375", "0.5816988", "0.5816988", "0.58156013", "0.5807412", "0.5804817", "0.579693", "0.57967776", "0.5795882", "0.5779684", "0.5779142", "0.57760084", "0.5766929", "0.5764691", "0.57537955", "0.57537955", "0.5750434", "0.5722183" ]
0.6050048
48
GET /catalogs/locations GET /catalogs/locations.json
def index @resources = Catalogs::Location.search(params[:search]).order("#{sort_column} #{sort_direction}").paginate(per_page: 11, page: params[:page]) authorize @resources end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def locations\n get('locations')\n end", "def index\n @catalog_locations = Catalog::Location.all\n end", "def get_location\n as_json(get_results('/locations.json'))\n end", "def index\n locations = Location.all\n render json: locations\n end", "def index\n @service_locations = ServiceLocation.all\n render json: @service_locations\n end", "def index\n locations = @project.locations.all\n render json: { locations: locations }\n end", "def index\n @locations = Location.roots.order(:location_name) \n render :json => @locations #Using Location serializer by default\n end", "def index\n @api_v1_locations = Api::V1::Location.all\n respond_to do |format|\n format.html { @api_v1_locations }\n format.json { render json: {results: @api_v1_locations, message: 'Locations have loaded successfully.'} }\n end\n end", "def catalogs\n path = \"#{api_root}/index/catalogs\"\n process_api_request(:get, path)\n end", "def list_locations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: V1LocationsApi.list_locations ...\"\n end\n # resource path\n local_var_path = \"/v1/me/locations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n \n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<V1Merchant>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: V1LocationsApi#list_locations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @clinic_locations = ClinicLocation.all\n\n # respond_to do |f|\n # f.json { render :index, location: @clinic_locations }\n # end\n end", "def get_locations\n response = execute_get(\"/reference/location\")\n Location.from_array(decode(response))\n end", "def index\r\n @locations = Location.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @locations }\r\n end\r\n end", "def locations(place)\n get :loc => place\n end", "def index\n @locations = Location.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @locations }\n end\n end", "def index\n @locs = Loc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locs }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locations }\n end\n end", "def locations(query = {})\n get('location', query)\n end", "def list_locations # :nologin:\n query = create_query(:Location, :all, :by => :name)\n show_selected_locations(query, :link_all_sorts => true)\n end", "def index\n @locations = Spree::Location.all\n end", "def locations\n farm = Farm.find(params[:id])\n\n @locations = []\n # Find which locations this user is authorized to access\n if (current_user.is_hog_owner? || current_user.is_farm_owner? || current_user.is_admin?)\n @locations = farm.locations\n elsif current_user.is_barn_manager?\n @locations << current_user.owner.barn.location\n elsif current_user.is_site_manager?\n @locations << current_user.owner.location\n end\n\n @page_title = \"Sites\"\n @header_icon_class = \"icon-road\"\n @page_subtitle = \"\"\n \n respond_to do |format|\n format.html { render '/locations/index' }\n format.json { render json: @locations }\n end\n end", "def locations\n @client.get('/BikePoint')\n end", "def locations\n locations_params = Hashie::Mash.new( {f: params.f} )\n response = make_request(LOCATIONS_BASE, locations_params)\n return not_available (response) unless response.status == 200\n response_body = Hashie::Mash.new(JSON.parse(response.body))\n response_body.data\n end", "def index\n @locations = current_user.locations\n respond_with @locations\n end", "def query\n { :locations => [] }\n end", "def get_synthetics_locations\n request(Net::HTTP::Get, \"/api/#{API_VERSION}/synthetics/locations\", nil, nil, false)\n end", "def show\n @corp_location = CorpLocation.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @corp_location }\n end\n end", "def index\n @locations = Location.order(\"id desc\").page(params[:page]).per(50)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locations }\n end\n end", "def list_locations\n @company = Company.find(params[:company_id])\n @pagetitle = \"#{@company.name} - Locations\"\n \n if(@company.can_view(current_user))\n @locations = Location.where(company_id: @company.id).order(\"name\")\n else\n errPerms()\n end\n end", "def locations id, date = Date.today.to_s\n uri = \"#{BASE_URL}/gauges/#{id}/locations?date=#{date}\"\n fetch uri\n end", "def index\n @locations = Location.all\n\n respond_with(@locations)\n end", "def locations\n locations = Occi::Core::Locations.new\n\n all(params[:entity]).each do |bt|\n bt_ids = backend_proxy_for(bt).identifiers\n locations_from(bt_ids, bt, locations)\n end\n return if locations.empty?\n\n respond_with locations\n end", "def set_catalogs_location\n @resource = Catalogs::Location.find(params[:id])\n end", "def list\n @locations = Location.find(:all, :order => \"name\")\n end", "def show\n render json: @service_location\n end", "def index\n @processed_locations = ProcessedLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @processed_locations }\n end\n end", "def get(params = {})\n client.get(\"/v1/reference-data/locations/#{@location_id}\", params)\n end", "def list_locations\n query = create_query(:Location, :all, by: default_sort_order)\n show_selected_locations(query, link_all_sorts: true)\n end", "def index\n @locations = Location.order(:country).order(:region).order(:city).page(params[:page])\n respond_with(@locations)\n end", "def index\r\n @locations = Location.all\r\n @mv = MapsVersion.first\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @locations }\r\n end\r\n end", "def list_locations\n warn 'Endpoint list_locations in V1LocationsApi is deprecated'\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v1/me/locations'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url,\n headers: _headers\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end", "def getAllLocations()\n coll = self.coll_locations\n puts coll.find()\n coll.find.each { |row| puts row.inspect }\n end", "def client_locations\n @entries = @locations\n end", "def index\n @items_locations = ItemsLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items_locations }\n end\n end", "def cities\n CS.get :us, :ca\n end", "def show\n @campus_food = CampusFood.find(params[:id])\n\t@loc = params[:loc]\n\t\n\t@locations = Location.all(:conditions =>[ \"loc like ? \", \"%#{params[:loc]}%\"])\n\tif [email protected]?\n @lat = @locations[0].lat\n @lng = @locations[0].lng\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @locations }\n end\n end", "def get_json\n response = conn.get(@current_location)\n parsed = JSON.parse(response.body, symbolize_names: true)\n\n end", "def get_all_locations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: LocationApi.get_all_locations ...\"\n end\n # resource path\n local_var_path = \"/location/all\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2003')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: LocationApi#get_all_locations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @service_locations = ServiceLocation.all\n end", "def show\n respond_to do |format|\n format.html { @api_v1_location }\n format.json { render json: {results: @api_v1_location, message: 'Locations have loaded successfully.'} }\n end\n end", "def get_locations\n splits = SplitLocationFinder.splits(params).where.not(course_id: @event.course_id)\n render json: splits, each_serializer: SplitLocationSerializer\n end", "def get_locations\n splits = SplitLocationFinder.splits(params).where.not(course_id: @event.course_id)\n render json: splits, each_serializer: SplitLocationSerializer\n end", "def get_json\n response = @api.request(:get, @location)\n response.body if response.status == 200\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def set_catalogs_location\n @catalogs_location = Catalogs::Location.find(params[:id])\n end", "def list_catalog_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CatalogApi.list_catalog ...\"\n end\n # resource path\n local_var_path = \"/v2/catalog/list\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?\n query_params[:'types'] = opts[:'types'] if !opts[:'types'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n \n header_params['Square-Version'] = \"2018-07-12\"\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ListCatalogResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CatalogApi#list_catalog\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @prod_locs = ProdLoc.all\n end", "def index\n @specific_locations = SpecificLocation.all\n end", "def location_primer\n render(json: location_list)\n end", "def lookup\n respond_to do |format|\n @grid = Grid.find_by_location(params[:location])\n format.json {render json: @grid.colors, status: :ok, location: @grid }\n end\n end", "def index\n @ms_locations = MsLocation.all\n end", "def location(location,types=nil)\n handle_response(get(\"/content/location.json\", :query => {:location => location,:types=>types}))\n end", "def index\n @recipe_locations = RecipeLocation.all\n end", "def show\n @loc = Loc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @loc }\n end\n end", "def locations\n\t\t[]\n\tend", "def listing_locations_search_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ListingsApi.listing_locations_search ...'\n end\n # resource path\n local_var_path = '/v1/listings/locations'\n\n # query parameters\n query_params = {}\n query_params[:'terms'] = opts[:'terms'] if !opts[:'terms'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<DomainPublicAdapterWebApiModelsV1ListingsListingLocation>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ListingsApi#listing_locations_search\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n render json: Location.find(params[\"id\"])\n end", "def show\n render :json => Location.find(params[:id])\n end", "def index\r\n @backend_locations = Backend::Location.all\r\n end", "def index\n @map = Map.find(params[:map_id])\n if @map.kind == \"activity\"\n @locations = @map.locations.activity\n elsif @map.kind == \"news\"\n @locations = @map.locations.news\n else\n @locations = @map.locations\n end\n respond_to do |format|\n format.json { render :json => @locations.as_json(:include => :location_pin)}\n end\n end", "def get_locations_with_http_info(latitude, longitude, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CompanyApi.get_locations ...\"\n end\n # verify the required parameter 'latitude' is set\n fail ArgumentError, \"Missing the required parameter 'latitude' when calling CompanyApi.get_locations\" if latitude.nil?\n # verify the required parameter 'longitude' is set\n fail ArgumentError, \"Missing the required parameter 'longitude' when calling CompanyApi.get_locations\" if longitude.nil?\n # resource path\n local_var_path = \"/company/locations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'latitude'] = latitude\n query_params[:'longitude'] = longitude\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse20024')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CompanyApi#get_locations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_all_locations\n @locations = []\n results = Location.all\n results.each do |loc|\n @locations << loc.to_hash\n end\n end", "def locations\n locations_res.data.locations.map {|loc| location_res_to_map(loc)}\n end", "def create\n @catalogs_location = Catalogs::Location.new(catalogs_location_params)\n\n respond_to do |format|\n if @catalogs_location.save\n format.html { redirect_to @catalogs_location, notice: t('.created') }\n format.json { render :show, status: :created, location: @catalogs_location }\n format.js { redirect_to @catalogs_location, notice: t('.created') }\n else\n format.html { render :new }\n format.json { render json: @catalogs_location.errors, status: :unprocessable_entity }\n format.js { render :new }\n end\n end\n end", "def describe_locations(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'DescribeLocations'\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? :namespace\n\t\t\targs[:query]['Namespace'] = optional[:namespace]\n\t\tend\n\t\tif optional.key? :namespace_uid\n\t\t\targs[:query]['NamespaceUid'] = optional[:namespace_uid]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tself.run(args)\n\tend", "def get_static_assests\n types = LocationType.all\n facilities = Facility.all\n type_array = []\n facility_array = []\n types.each do |type|\n type_array << type.name\n end\n facilities.each do |facility|\n facility_array << facility.name\n end\n render json: { location_types: type_array, location_facilities: facility_array }\n end", "def location\n @client.get(\"#{path}/location\")\n end", "def location(id, options = {})\n get \"locations/#{id}\", options\n end", "def index\n @drop_locations = DropLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drop_locations }\n end\n end", "def show\n @curpg = :admintools\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location_url_map = LocationUrlMap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location_url_map }\n end\n end", "def index\n @locations = salor_user.get_locations(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @locations }\n end\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def index\n @locations = @organization.locations.all\n\n @map = Cartographer::Gmap.new( 'map' )\n @map.zoom = :bound\n @map.icons << Cartographer::Gicon.new\n \n @organization.locations.each do |location|\n @map.markers << \n Cartographer::Gmarker.new(\n :name => 'location_'+Digest::MD5.hexdigest(location.name),\n :marker_type => \"Building\",\n :position => [location.lat, location.lng],\n :info_window_url => \"fixme.org\"\n )\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locations }\n end\n end", "def index\n @categories = Category.all\n @locations = Locations.all\n end", "def index\n @loc_categories = LocCategory.all\n end", "def index\n @locations = Location.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @locations }\n end\n end", "def index\n @locations = Location.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @locations }\n end\n end", "def location\n fetch('hey_arnold.locations')\n end", "def retrieve_locations_with_http_info(accept, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: LocationsApi.retrieve_locations ...\"\n end\n # verify the required parameter 'accept' is set\n fail ArgumentError, \"Missing the required parameter 'accept' when calling LocationsApi.retrieve_locations\" if accept.nil?\n # resource path\n local_var_path = \"/locations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n header_params[:'Accept'] = accept\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<Location>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: LocationsApi#retrieve_locations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end" ]
[ "0.7658977", "0.7414822", "0.7125742", "0.68398523", "0.6815061", "0.6758357", "0.670795", "0.6701871", "0.6701353", "0.66858673", "0.6682732", "0.66826105", "0.6674633", "0.6664289", "0.66210115", "0.65417254", "0.6537305", "0.6520054", "0.649505", "0.6479827", "0.64735633", "0.64603436", "0.64480585", "0.6444082", "0.6440215", "0.64264935", "0.64108497", "0.6402498", "0.639567", "0.63920444", "0.6387267", "0.637485", "0.63477606", "0.6326765", "0.6325037", "0.6298375", "0.62975055", "0.62957484", "0.6279544", "0.6273758", "0.62677634", "0.6267486", "0.62664473", "0.6253152", "0.62462866", "0.6214029", "0.620308", "0.6201613", "0.61995155", "0.61955935", "0.6184924", "0.6184924", "0.6176473", "0.6166923", "0.6166923", "0.6166923", "0.6166923", "0.6166923", "0.6166923", "0.6166923", "0.6166923", "0.6166923", "0.6166923", "0.6166923", "0.6151383", "0.61510766", "0.61433005", "0.61410385", "0.61280763", "0.61017925", "0.6100809", "0.6088944", "0.6074681", "0.6070589", "0.6066877", "0.6056957", "0.6056332", "0.6050492", "0.603637", "0.6031943", "0.60281503", "0.6023359", "0.6015657", "0.6012395", "0.60105246", "0.6009085", "0.5996956", "0.5993493", "0.5988992", "0.5981562", "0.5978053", "0.5974428", "0.5971764", "0.5971764", "0.5961782", "0.5957727", "0.59545666", "0.5953733", "0.5953733", "0.5952293", "0.59460336" ]
0.0
-1
GET /catalogs/locations/1 GET /catalogs/locations/1.json
def show authorize @resource respond_to do |format| format.html format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @catalog_locations = Catalog::Location.all\n end", "def locations\n get('locations')\n end", "def catalogs\n path = \"#{api_root}/index/catalogs\"\n process_api_request(:get, path)\n end", "def get_location\n as_json(get_results('/locations.json'))\n end", "def index\n @api_v1_locations = Api::V1::Location.all\n respond_to do |format|\n format.html { @api_v1_locations }\n format.json { render json: {results: @api_v1_locations, message: 'Locations have loaded successfully.'} }\n end\n end", "def index\n @clinic_locations = ClinicLocation.all\n\n # respond_to do |f|\n # f.json { render :index, location: @clinic_locations }\n # end\n end", "def index\n @service_locations = ServiceLocation.all\n render json: @service_locations\n end", "def index\n locations = Location.all\n render json: locations\n end", "def show\n @corp_location = CorpLocation.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @corp_location }\n end\n end", "def index\n locations = @project.locations.all\n render json: { locations: locations }\n end", "def list_catalog_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CatalogApi.list_catalog ...\"\n end\n # resource path\n local_var_path = \"/v2/catalog/list\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?\n query_params[:'types'] = opts[:'types'] if !opts[:'types'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n \n header_params['Square-Version'] = \"2018-07-12\"\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ListCatalogResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CatalogApi#list_catalog\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\r\n @locations = Location.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @locations }\r\n end\r\n end", "def set_catalogs_location\n @resource = Catalogs::Location.find(params[:id])\n end", "def index\n @locations = Location.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @locations }\n end\n end", "def list_locations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: V1LocationsApi.list_locations ...\"\n end\n # resource path\n local_var_path = \"/v1/me/locations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n \n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<V1Merchant>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: V1LocationsApi#list_locations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locations }\n end\n end", "def index\n @locs = Loc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locs }\n end\n end", "def show\n respond_to do |format|\n format.html { @api_v1_location }\n format.json { render json: {results: @api_v1_location, message: 'Locations have loaded successfully.'} }\n end\n end", "def index\n @locations = Location.roots.order(:location_name) \n render :json => @locations #Using Location serializer by default\n end", "def index\n @locations = Location.order(\"id desc\").page(params[:page]).per(50)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locations }\n end\n end", "def api_catalog\n @data = helpers.recursive_catalog_json(taxon_name: @taxon_name, target_depth: params[:target_depth] || 0 )\n render '/taxon_names/api/v1/catalog'\n end", "def get_catalog\n # Instanciating the Catalog API\n api_instance = SquareConnect::CatalogApi.new\n\n # The JSON request object\n object_ids = {\n \"object_ids\": [\n \"JPIVA25GH6HPBFEXOWDB47PO\",\n \"3IDQ2B6D7XC4H6JKNZP37PYT\"\n ],\n \"include_related_objects\": true\n }\n\n begin\n # p catalog_items from the API databaase\n catalog_items = api_instance.batch_retrieve_catalog_objects(object_ids)\n # Check for Errors in the api call and sends back the error\n rescue SquareConnect::ApiError => e\n puts \"Exception when calling CatalogApi->batch_retrieve_catalog_objects: #{e}\"\n end\n render json: result1\n end", "def locations id, date = Date.today.to_s\n uri = \"#{BASE_URL}/gauges/#{id}/locations?date=#{date}\"\n fetch uri\n end", "def show\n render json: @service_location\n end", "def locations(place)\n get :loc => place\n end", "def show\n @loc = Loc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @loc }\n end\n end", "def index\r\n @locations = Location.all\r\n @mv = MapsVersion.first\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @locations }\r\n end\r\n end", "def get(params = {})\n client.get(\"/v1/reference-data/locations/#{@location_id}\", params)\n end", "def show\n @campus_food = CampusFood.find(params[:id])\n\t@loc = params[:loc]\n\t\n\t@locations = Location.all(:conditions =>[ \"loc like ? \", \"%#{params[:loc]}%\"])\n\tif [email protected]?\n @lat = @locations[0].lat\n @lng = @locations[0].lng\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @locations }\n end\n end", "def index\n @processed_locations = ProcessedLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @processed_locations }\n end\n end", "def query\n { :locations => [] }\n end", "def set_catalogs_location\n @catalogs_location = Catalogs::Location.find(params[:id])\n end", "def lookup\n respond_to do |format|\n @grid = Grid.find_by_location(params[:location])\n format.json {render json: @grid.colors, status: :ok, location: @grid }\n end\n end", "def index\n @items_locations = ItemsLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items_locations }\n end\n end", "def show\n render json: Location.find(params[\"id\"])\n end", "def get_json\n response = @api.request(:get, @location)\n response.body if response.status == 200\n end", "def get_json\n response = conn.get(@current_location)\n parsed = JSON.parse(response.body, symbolize_names: true)\n\n end", "def show\n @curpg = :admintools\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def index\n @locations = Location.order(:country).order(:region).order(:city).page(params[:page])\n respond_with(@locations)\n end", "def index\n @locations = Location.all\n\n respond_with(@locations)\n end", "def show\n render :json => Location.find(params[:id])\n end", "def cities\n CS.get :us, :ca\n end", "def index\n @locations = Spree::Location.all\n end", "def show\n @processed_location = ProcessedLocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @processed_location }\n end\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def show\r\n @discounts_on_location = DiscountsOnLocation.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @discounts_on_location }\r\n end\r\n end", "def index\n @locations = current_user.locations\n respond_with @locations\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username2,\n :password => $password2,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def show\n @location = Location.find(params[:id])\n render json: @locationProut\n end", "def show\n @location_url_map = LocationUrlMap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location_url_map }\n end\n end", "def location_primer\n render(json: location_list)\n end", "def locations\n farm = Farm.find(params[:id])\n\n @locations = []\n # Find which locations this user is authorized to access\n if (current_user.is_hog_owner? || current_user.is_farm_owner? || current_user.is_admin?)\n @locations = farm.locations\n elsif current_user.is_barn_manager?\n @locations << current_user.owner.barn.location\n elsif current_user.is_site_manager?\n @locations << current_user.owner.location\n end\n\n @page_title = \"Sites\"\n @header_icon_class = \"icon-road\"\n @page_subtitle = \"\"\n \n respond_to do |format|\n format.html { render '/locations/index' }\n format.json { render json: @locations }\n end\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username1,\n :password => $password1,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def index\n @api_v1_stores = Store.all\n json_response(@api_v1_stores)\n end", "def index\n @prod_locs = ProdLoc.all\n end", "def catalog_info_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CatalogApi.catalog_info ...\"\n end\n # resource path\n local_var_path = \"/v2/catalog/info\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n \n header_params['Square-Version'] = \"2018-07-12\"\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'CatalogInfoResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CatalogApi#catalog_info\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_locations\n splits = SplitLocationFinder.splits(params).where.not(course_id: @event.course_id)\n render json: splits, each_serializer: SplitLocationSerializer\n end", "def get_locations\n splits = SplitLocationFinder.splits(params).where.not(course_id: @event.course_id)\n render json: splits, each_serializer: SplitLocationSerializer\n end", "def locations\n @client.get('/BikePoint')\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :timeout => -1,\n :headers => { :accept => :json,\n :content_type => :json ,\n :params => { \"page\" => 1, \"per_page\" => 25000 }}\n ).execute\n results = JSON.parse(response.to_str)\n end", "def client_locations\n @entries = @locations\n end", "def create\n @catalogs_location = Catalogs::Location.new(catalogs_location_params)\n\n respond_to do |format|\n if @catalogs_location.save\n format.html { redirect_to @catalogs_location, notice: t('.created') }\n format.json { render :show, status: :created, location: @catalogs_location }\n format.js { redirect_to @catalogs_location, notice: t('.created') }\n else\n format.html { render :new }\n format.json { render json: @catalogs_location.errors, status: :unprocessable_entity }\n format.js { render :new }\n end\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @items_location = ItemsLocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @items_location }\n end\n end", "def index\n @specific_locations = SpecificLocation.all\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @location }\n end\n end", "def show\n @records_location = RecordsLocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @records_location }\n end\n end", "def get_all_locations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: LocationApi.get_all_locations ...\"\n end\n # resource path\n local_var_path = \"/location/all\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2003')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: LocationApi#get_all_locations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def show\r\n @location = Location.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @location }\r\n end\r\n end", "def index\n @region = Region.find_by_id params[:region_id]\n @locations = @region.locations.select(\"id,name,region_id\")\n\n respond_with @locations #Location.select(\"id,name\")\n end", "def get_region\n respond_to do |format|\n format.json{ render :json => { :region => Region.all } }\n end\n end", "def get_locations_with_http_info(latitude, longitude, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CompanyApi.get_locations ...\"\n end\n # verify the required parameter 'latitude' is set\n fail ArgumentError, \"Missing the required parameter 'latitude' when calling CompanyApi.get_locations\" if latitude.nil?\n # verify the required parameter 'longitude' is set\n fail ArgumentError, \"Missing the required parameter 'longitude' when calling CompanyApi.get_locations\" if longitude.nil?\n # resource path\n local_var_path = \"/company/locations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'latitude'] = latitude\n query_params[:'longitude'] = longitude\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse20024')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CompanyApi#get_locations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @service_locations = ServiceLocation.all\n end", "def from_search\n name = params[:id]\n lat = params[:lat]\n lon = params[:lon]\n @locations = Location.locations_from_candy_ids(Candy.ids_by_name(name))\n if(lat and lon)\n @locations = Location.nearest_five(lat.to_f, lon.to_f, @locations)\n end\n\n respond_to do |format|\n format.html\n format.json { render :json => @locations }\n end\n end", "def show\n @item_catalog = ItemCatalog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_catalog }\n end\n end", "def index\n @cities = City.all\n\n render json: @cities\n end", "def index\n @loc_categories = LocCategory.all\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def index\n @drop_locations = DropLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drop_locations }\n end\n end", "def list_locations\n warn 'Endpoint list_locations in V1LocationsApi is deprecated'\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v1/me/locations'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url,\n headers: _headers\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end", "def show\n\t\t@all_locations = Location.where(:faculty => params[:id])\n\t\trender :json => @all_locations\n\tend", "def index\n @recipe_locations = RecipeLocation.all\n end", "def list_locations # :nologin:\n query = create_query(:Location, :all, :by => :name)\n show_selected_locations(query, :link_all_sorts => true)\n end", "def get_synthetics_locations\n request(Net::HTTP::Get, \"/api/#{API_VERSION}/synthetics/locations\", nil, nil, false)\n end", "def catalog_dcat()\n return uri(\"api/dcat.json\")\n end", "def location\n @client.get(\"#{path}/location\")\n end", "def get_static_assests\n types = LocationType.all\n facilities = Facility.all\n type_array = []\n facility_array = []\n types.each do |type|\n type_array << type.name\n end\n facilities.each do |facility|\n facility_array << facility.name\n end\n render json: { location_types: type_array, location_facilities: facility_array }\n end", "def index\n @map = Map.find(params[:map_id])\n if @map.kind == \"activity\"\n @locations = @map.locations.activity\n elsif @map.kind == \"news\"\n @locations = @map.locations.news\n else\n @locations = @map.locations\n end\n respond_to do |format|\n format.json { render :json => @locations.as_json(:include => :location_pin)}\n end\n end", "def location(id, options = {})\n get \"locations/#{id}\", options\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end" ]
[ "0.7068212", "0.6955868", "0.6842533", "0.67034024", "0.6642539", "0.660242", "0.6562066", "0.6539946", "0.6520473", "0.651868", "0.64098555", "0.64075917", "0.6400084", "0.6377357", "0.6361328", "0.6350239", "0.6345115", "0.63340205", "0.63269997", "0.632488", "0.6251556", "0.6239137", "0.62241304", "0.6222577", "0.6200548", "0.6178291", "0.61688006", "0.6163293", "0.61612064", "0.61478484", "0.6122361", "0.6109989", "0.6109374", "0.6108043", "0.6090418", "0.607072", "0.6066893", "0.6053814", "0.60354275", "0.6032052", "0.6026012", "0.60223544", "0.60004336", "0.59816927", "0.5975445", "0.5975445", "0.5974661", "0.59548235", "0.59516394", "0.5948485", "0.5946523", "0.5941726", "0.59254605", "0.59218514", "0.59063685", "0.5894113", "0.5891385", "0.588961", "0.588961", "0.5884017", "0.5883372", "0.58756566", "0.58719707", "0.5865647", "0.5865647", "0.5865647", "0.5865647", "0.5865647", "0.5865647", "0.5865647", "0.5865647", "0.5865647", "0.58649683", "0.58530897", "0.5835518", "0.58269244", "0.5821844", "0.581918", "0.58160025", "0.5814335", "0.5814135", "0.5811895", "0.5808144", "0.5799408", "0.5799315", "0.57955384", "0.5786843", "0.57815313", "0.5779198", "0.5777398", "0.5773864", "0.57735515", "0.5769979", "0.5769504", "0.5764949", "0.5762167", "0.57591903", "0.5753394", "0.57520056", "0.57511926", "0.57511926" ]
0.0
-1
POST /catalogs/locations POST /catalogs/locations.json
def create @resource = Catalogs::Location.new(catalogs_location_params) respond_to do |format| if @resource.save index flash[:success] = t('notices.saved_successfully') format.html { redirect_to @resource, notice: 'Location was successfully created.' } format.json { render :show, status: :created, location: @resource } else format.html { render :new } format.json { render json: @resource.errors, status: :unprocessable_entity } end format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @catalogs_location = Catalogs::Location.new(catalogs_location_params)\n\n respond_to do |format|\n if @catalogs_location.save\n format.html { redirect_to @catalogs_location, notice: t('.created') }\n format.json { render :show, status: :created, location: @catalogs_location }\n format.js { redirect_to @catalogs_location, notice: t('.created') }\n else\n format.html { render :new }\n format.json { render json: @catalogs_location.errors, status: :unprocessable_entity }\n format.js { render :new }\n end\n end\n end", "def create\n @catalog_location = Catalog::Location.new(catalog_location_params)\n\n respond_to do |format|\n if @catalog_location.save\n format.html { redirect_to @catalog_location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @catalog_location }\n else\n format.html { render :new }\n format.json { render json: @catalog_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @regions = Region.all\n @location = Location.new(location_params)\n\n if params[:regions]\n @location_regions = Region.find(params[:regions])\n else\n @location_regions = []\n end\n\n @location.regions = @location_regions\n\n respond_to do |format|\n if @location.save\n @location.create_stat\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @curpg = :admintools\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to :controller => \"locations\", :action => \"index\" }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @service_location = ServiceLocation.new(service_location_params)\n if @service_location.save\n render json: @service_location, status: :created, location: @service_location\n else\n render json: @service_location.errors, status: :unprocessable_entity\n end \n end", "def create\n @location = Spree::Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to '/admin/locations', notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n if @location.save \n render :json => { status: :created, location: @location }\n else\n render :json => { errors: @location.errors, status: :unprocessable_entity }\n end\n end", "def create\r\n @location = Location.new(params[:location])\r\n\r\n respond_to do |format|\r\n if @location.save\r\n format.json { render json: @location, status: :created, location: @location }\r\n else\r\n format.json { render json: @location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @locations = Location.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n @location = Location.create(params[:location])\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.json { render :show, status: :created }\n else\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n \n @location.location = current_location\n @location.location_type = \"shelf\"\n \n respond_to do |format|\n if @location.save\n format.html { redirect_to current_location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n @location.save \n @hide_map = true\n if params[:subcategories] \n params[:subcategories].uniq.each do |subcategory| \n s = Subcategory.where(id: subcategory[:id]).first\n @location.subcategories << s if s\n end\n end\n respond_to do |format|\n if @location.valid?\n format.html { redirect_to @location, :notice => 'Location was successfully created.' }\n format.json { render :json => @location, :status => :created, :location => @location }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @processed_location = ProcessedLocation.new(params[:processed_location])\n\n respond_to do |format|\n if @processed_location.save\n format.html { redirect_to @processed_location, notice: 'Processed location was successfully created.' }\n format.json { render json: @processed_location, status: :created, location: @processed_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @processed_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\t\n\t\n\t\n respond_to do |format|\n if @location.save\n format.html { redirect_to admin_locations_url(:site => current_site.id), notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: admin_locations_url(:site => current_site.id) }\n else\n \n \tset_site_entities @location\n \t\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe_location = RecipeLocation.new(recipe_location_params)\n\n respond_to do |format|\n if @recipe_location.save\n format.html { redirect_to @recipe_location, notice: 'Recipe location was successfully created.' }\n format.json { render :show, status: :created, location: @recipe_location }\n else\n format.html { render :new }\n format.json { render json: @recipe_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def postLocation( location_id, type, country, language, name, formal_name, resolution, population, description, timezone, latitude, longitude, parent_town, parent_county, parent_province, parent_region, parent_neighbourhood, parent_district, postalcode, searchable_id, searchable_ids)\n params = Hash.new\n params['location_id'] = location_id\n params['type'] = type\n params['country'] = country\n params['language'] = language\n params['name'] = name\n params['formal_name'] = formal_name\n params['resolution'] = resolution\n params['population'] = population\n params['description'] = description\n params['timezone'] = timezone\n params['latitude'] = latitude\n params['longitude'] = longitude\n params['parent_town'] = parent_town\n params['parent_county'] = parent_county\n params['parent_province'] = parent_province\n params['parent_region'] = parent_region\n params['parent_neighbourhood'] = parent_neighbourhood\n params['parent_district'] = parent_district\n params['postalcode'] = postalcode\n params['searchable_id'] = searchable_id\n params['searchable_ids'] = searchable_ids\n return doCurl(\"post\",\"/location\",params)\n end", "def create\n @location = @organization.locations.build(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to [@organization, @location], notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n\tlogger.info \"location saved successfully\"\n\tlogger.info @location.to_json\n format.html { redirect_to @location, :notice => 'Location was successfully created.' }\n format.json { render :json => @location }\n else\n\tlogger.info \"error saving location\"\n format.html { render :action => \"new\" }\n format.json { render :json => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @records_location = RecordsLocation.new(params[:records_location])\n\n respond_to do |format|\n if @records_location.save\n format.html { redirect_to @records_location, notice: 'Records location was successfully created.' }\n format.json { render json: @records_location, status: :created, location: @records_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @records_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(\n name: location_params[:name],\n address_line_1: location_params[:lineOne],\n address_line_2: location_params[:lineTwo],\n lat: location_params[:lat],\n lng: location_params[:lng]\n )\n if @location.save\n render json: @location\n else\n render json: {message: 'creation failed'}\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, flash: {success: \"Successfully created #{@location.name} location!\" }}\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to locations_path, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @corp_location = CorpLocation.new(corp_location_params)\n\n respond_to do |format|\n if @corp_location.save\n format.html { redirect_to @corp_location, notice: 'Corp location was successfully created.' }\n format.json { render json: @corp_location, status: :created, location: @corp_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @corp_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.'}\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render action: 'show', status: :created, location: @location }\n else\n format.html { render action: 'new' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def coordinates\n location = Location.new(location_params)\n if location.save\n render json: location\n else\n render json: \"ERROR\"\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created }\n else\n format.html { redirect_to root_path, notice: 'Please fill in all fields!' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @specific_location = SpecificLocation.new(specific_location_params)\n\n respond_to do |format|\n if @specific_location.save\n format.html { redirect_to @specific_location, notice: 'Specific location was successfully created.' }\n format.json { render :show, status: :created, location: @specific_location }\n else\n format.html { render :new }\n format.json { render json: @specific_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @locacao = Locacao.new(params[:locacao])\n\n respond_to do |format|\n if @locacao.save\n format.html { redirect_to @locacao, :notice => 'Locacao was successfully created.' }\n format.json { render :json => @locacao, :status => :created, :location => @locacao }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @locacao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\r\n @discounts_on_location = DiscountsOnLocation.new(params[:discounts_on_location])\r\n\r\n respond_to do |format|\r\n if @discounts_on_location.save\r\n format.html { redirect_to @discounts_on_location, notice: 'Discounts on location was successfully created.' }\r\n format.json { render json: @discounts_on_location, status: :created, location: @discounts_on_location }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @discounts_on_location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @loc = current_user.locs.new(params[:loc])\n\n respond_to do |format|\n if @loc.save\n format.html { redirect_to @loc, notice: 'Loc was successfully created.' }\n format.json { render json: @loc, status: :created, location: @loc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @loc.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @location = Location.new\n @location.build_series\n @city = @location.build_city\n \n set_site_entities @location\n \n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def create\n @location = Location.new(location_params)\n#binding.pry\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n return unless representsCompany?\n\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to new_job_path, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @clinic_location = ClinicLocation.new(clinic_location_params)\n\n respond_to do |format|\n if @clinic_location.save\n format.html { redirect_to @clinic_location, notice: 'Clinic location was successfully created.' }\n format.json { render :show, status: :created, location: @clinic_location }\n else\n format.html { render :new }\n format.json { render json: @clinic_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n @locations = Location.index_locations\n format.html { redirect_to(@location, :notice => 'Location was successfully created.') }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n format.js\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def create\r\n @backend_location = Backend::Location.new(backend_location_params)\r\n\r\n respond_to do |format|\r\n if @backend_location.save\r\n format.html { redirect_to @backend_location, notice: 'Location was successfully created.' }\r\n format.json { render :show, status: :created, location: @backend_location }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @backend_location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def index\n @catalog_locations = Catalog::Location.all\n end", "def locations\n get('locations')\n end", "def create\n @sicoss_location = SicossLocation.new(params[:sicoss_location])\n flash[:notice] = t('scaffold.notice.created', :item => SicossLocation.model_name.human) if @sicoss_location.save\n respond_with(@sicoss_location, :location => sicoss_locations_path)\n end", "def create\n @location = Geolocation.new(params[:geolocation])\n @scene = Scene.new(:title => params[:title])\n @location.scenes << @scene\n @location.save\n @scene.save\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully create.'}\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\"}\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n @location.save\n respond_with(@location)\n end", "def create\n\t\t@location = Location.new(params[:location])\n\n\t\trespond_to do |format|\n\t\t\tif @location.save\n\t\t\t\tformat.html { redirect_to @location, notice: 'Location was successfully created.' }\n\t\t\t\tformat.json { render json: @location, status: :created, location: @location }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @location.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n end", "def create\n @location = Location.new(params[:location])\n if @location.save\n flash[:notice] = 'Location was successfully created.'\n end\n respond_with(@location, location: locations_url) \n end", "def create\n @admin_location = Admin::Location.new(admin_location_params)\n\n respond_to do |format|\n if @admin_location.save\n format.html { redirect_to @admin_location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @admin_location }\n else\n format.html { render :new }\n format.json { render json: @admin_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tLocation.create(params[:location])\n\t\tredirect_to locations_path\n\tend", "def create\n @prod_loc = ProdLoc.new(prod_loc_params)\n\n respond_to do |format|\n if @prod_loc.save\n format.html { redirect_to localidad_path(@prod_loc.localidad_id), notice: 'Se agregó el producto satisfactoriamente.' }\n format.json { render :show, status: :created, location: @prod_loc }\n else\n format.html { render :new }\n format.json { render json: @prod_loc.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @slocation = Slocation.new(slocation_params)\n\n respond_to do |format|\n if @slocation.save\n format.html { redirect_to @slocation, notice: 'Story location was successfully created.' }\n format.json { render :show, status: :created, slocation: @slocation }\n else\n format.html { render :new }\n format.json { render json: @slocation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @locations_locationset = LocationsLocationset.new(params[:locations_locationset])\n\n respond_to do |format|\n if @locations_locationset.save\n format.html { redirect_to(@locations_locationset, :notice => 'Locations locationset was successfully created.') }\n format.xml { render :xml => @locations_locationset, :status => :created, :location => @locations_locationset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @locations_locationset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def location_primer\n render(json: location_list)\n end", "def create\n @location_url_map = LocationUrlMap.new(params[:location_url_map])\n\n respond_to do |format|\n if @location_url_map.save\n format.html { redirect_to @location_url_map, notice: 'Location url map was successfully created.' }\n format.json { render json: @location_url_map, status: :created, location: @location_url_map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location_url_map.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_catalogs_location\n @resource = Catalogs::Location.find(params[:id])\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n format.js\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @api_v1_location = Api::V1::Location.new(api_v1_location_params)\n\n respond_to do |format|\n if @api_v1_location.save\n format.html { redirect_to @api_v1_location, notice: 'Location was successfully created.' }\n format.json { render json: { results: @api_v1_location, message: 'Location was successfully created.' } }\n else\n format.html { render :new }\n format.json { render json: { results: @api_v1_location.errors, message: 'Location was NOT successfully created.' } }\n end\n end\n end", "def attach_locations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CompanyApi.attach_locations ...\"\n end\n # resource path\n local_var_path = \"/company/add-location\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'description'] = opts[:'description'] if !opts[:'description'].nil?\n query_params[:'latitude'] = opts[:'latitude'] if !opts[:'latitude'].nil?\n query_params[:'longitude'] = opts[:'longitude'] if !opts[:'longitude'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse20023')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CompanyApi#attach_locations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n GlobalData.reload(:locations)\n format.html { redirect_to(:action => 'new', :notice => I18n.t(\"views.notice.model_create\", :model => Location.model_name.human)) }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @clinic_locations = ClinicLocation.all\n\n # respond_to do |f|\n # f.json { render :index, location: @clinic_locations }\n # end\n end", "def create\n @location = Location.new(params[:location])\n end", "def create\n @locationmap = Locationmap.new(params[:locationmap])\n\n respond_to do |format|\n if @locationmap.save\n format.html { redirect_to @locationmap, notice: 'Locationmap was successfully created.' }\n format.json { render json: @locationmap, status: :created, location: @locationmap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @locationmap.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@location = Location.new(location_params)\n\n\t\trespond_to do |format|\n\t\t\tif @location.save\n\t\t\t\tformat.html { redirect_to @location, notice: 'Location was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @location }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @location.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @location = Location.new(params[:location])\n @location.user_id = current_user.id\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to locations_path, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def catalogs_location_params\n params.require(:catalogs_location).permit(:abbr, :name_es, :name_en)\n end", "def new\n @location = @organization.locations.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def set_catalogs_location\n @catalogs_location = Catalogs::Location.find(params[:id])\n end", "def create\n @maplocation = Maplocation.new(maplocation_params)\n\n respond_to do |format|\n if @maplocation.save\n format.html { redirect_to @maplocation, notice: 'Maplocation was successfully created.' }\n format.json { render :show, status: :created, location: @maplocation }\n else\n format.html { render :new }\n format.json { render json: @maplocation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t @location = Location.new(location_params)\n\n\t respond_to do |format|\n\t if @location.save\n\t format.html { redirect_to @location, notice: 'location was successfully created.' }\n\t format.json { render json: @location, status: :created, location: @location }\n\t format.js\n\t else\n\t format.html { render action: \"new\" }\n\t format.json { render json: @location.errors, status: :unprocessable_entity }\n\t end\n\t end\n\t end", "def create\n @totem_location = TotemLocation.new(totem_location_params)\n\n respond_to do |format|\n if @totem_location.save\n format.html { redirect_to @totem_location, notice: 'Totem location was successfully created.' }\n format.json { render action: 'show', status: :created, location: @totem_location }\n else\n format.html { render action: 'new' }\n format.json { render json: @totem_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @service_locations = ServiceLocation.all\n render json: @service_locations\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to(@location, notice: 'Location was successfully created.') }\n format.xml { render xml: @location, status: :created, location: @location }\n else\n format.html { render action: 'new' }\n format.xml { render xml: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_locations(locations)\n File.open('location_data.json', 'w') do |file|\n file.puts locations\n end\n end", "def create\n @drop_location = DropLocation.new(params[:drop_location])\n\n respond_to do |format|\n if @drop_location.save\n format.html { redirect_to @drop_location, notice: 'Drop location was successfully created.' }\n format.json { render json: @drop_location, status: :created, location: @drop_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @drop_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vehicle_location = VehicleLocation.new(vehicle_location_params)\n\n respond_to do |format|\n if @vehicle_location.save\n format.html { redirect_to @vehicle_location, notice: 'Vehicle location was successfully created.' }\n format.json { render :show, status: :created, location: @vehicle_location }\n else\n format.html { render :new }\n format.json { render json: @vehicle_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n # allow_comma(params[:location][:price])\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location}\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n city = params['city'].downcase\n state = params['state'].upcase\n @result = process_location(city, state)\n\n if @result[:type] == \"error\"\n flash[:error] = @result[:value]\n redirect_to '/artists'\n else\n redirect_to \"/artists?select_location=#{@result[:value].id}\"\n end\n end", "def create\n @location = Location.new(params[:location])\n\t\t@project = Project.find(@location.project_id)\n respond_to do |format|\n if @location.save\n format.html { redirect_to @project, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location].merge!(:user => current_user))\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'La habitación se ha guardado exitosamente.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n flash[:notice] = 'Location was successfully created.'\n format.html { redirect_to(@location) }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n flash[:notice] = 'Location was successfully created.'\n format.html { redirect_to(@location) }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n flash[:notice] = 'Location was successfully created.'\n format.html { redirect_to(@location) }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n #I'm wondering if this create method even works at this point\n #### also gerry?????\n respond_to do |format|\n if @item_location.save\n format.html { redirect_to @item_location, notice: 'Item location was successfully created.' }\n format.json { render :show, status: :created, location: @item_location }\n else\n format.html { render :new }\n format.json { render json: @item_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @city_district = CityDistrict.new(params[:city_district])\n\n respond_to do |format|\n if @city_district.save\n format.html { redirect_to @city_district, :notice => 'City district was successfully created.' }\n format.json { render :json => @city_district, :status => :created, :location => @city_district }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @city_district.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @job_location = JobLocation.new(job_location_params)\n\n \n if @job_location.save\n render json: {job_location: @job_location, status: 'Job location was successfully created.'}, status: :created\n else\n render json: { errors: @job_location.errors.full_messages }, status: :bad_request \n end\n \n end", "def locations\n locations = Occi::Core::Locations.new\n\n all(params[:entity]).each do |bt|\n bt_ids = backend_proxy_for(bt).identifiers\n locations_from(bt_ids, bt, locations)\n end\n return if locations.empty?\n\n respond_with locations\n end", "def create\n @status_catalog = StatusCatalog.new(status_catalog_params)\n\n respond_to do |format|\n if @status_catalog.save\n format.html { redirect_to @status_catalog, notice: 'Status catalog was successfully created.' }\n format.json { render :show, status: :created, location: @status_catalog }\n else\n format.html { render :new }\n format.json { render json: @status_catalog.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.find(params[:location_id])\n @shelf = @location.shelves.new\n respond_to do |format|\n if @shelf.save\n format.html { redirect_to @location, notice: 'Shelf added.' }\n format.js { render js: \"thot.increase_counter('#shc_#{@location.id}');\" }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lab.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_location\n new_r = @location.new_record?\n headers ={}\n if @location.save\n headers= ( new_r ? {status: :created, location: api_v1_location_url(id: @location.id, format: (params[:format] || :json) ) } : {status: :ok} )\n end \n respond_with(@location, headers)\n end", "def update\n respond_to do |format|\n if @catalogs_location.update(catalogs_location_params)\n format.html { redirect_to @catalogs_location, notice: t('.updated') }\n format.json { render :show, status: :ok, location: @catalogs_location }\n else\n format.html { render :edit }\n format.json { render json: @catalogs_location.errors, status: :unprocessable_entity }\n format.js { render :edit }\n end\n end\n end", "def create\n @book_location = BookLocation.new(book_location_params)\n\n respond_to do |format|\n if @book_location.save\n format.html { redirect_to @book_location, notice: 'Book location was successfully created.' }\n format.json { render :show, status: :created, location: @book_location }\n else\n format.html { render :new }\n format.json { render json: @book_location.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7232983", "0.7151177", "0.6698", "0.65391666", "0.65108997", "0.6459051", "0.6453451", "0.644441", "0.6422136", "0.63830936", "0.63439965", "0.6340161", "0.6299384", "0.6282217", "0.62808484", "0.6267307", "0.6265283", "0.61773825", "0.61661524", "0.61661524", "0.61661524", "0.61661524", "0.6155132", "0.61509854", "0.6147166", "0.614417", "0.61345494", "0.6117569", "0.6110465", "0.6110465", "0.6110465", "0.6110465", "0.6110465", "0.6110465", "0.6110465", "0.61104107", "0.6098863", "0.60872716", "0.6067031", "0.606478", "0.6049541", "0.60444725", "0.60421145", "0.6028134", "0.6020721", "0.60203564", "0.6004381", "0.600269", "0.5995484", "0.59839827", "0.5975626", "0.59635216", "0.59366286", "0.5926884", "0.5926781", "0.5924891", "0.59064674", "0.58800346", "0.5878229", "0.5866287", "0.5863538", "0.58599305", "0.5853514", "0.58353204", "0.5834671", "0.58296514", "0.58228296", "0.58204824", "0.5819455", "0.58075625", "0.580753", "0.5805084", "0.5798749", "0.5795274", "0.5788447", "0.57813704", "0.5774025", "0.57685184", "0.5742588", "0.57350576", "0.57297236", "0.57130176", "0.57070214", "0.5705848", "0.5700297", "0.56999695", "0.56931394", "0.5691159", "0.5689181", "0.5689181", "0.5689181", "0.56795955", "0.5676471", "0.5673778", "0.5673147", "0.56670725", "0.5661811", "0.56590605", "0.56548494", "0.5653618" ]
0.69537973
2
PATCH/PUT /catalogs/locations/1 PATCH/PUT /catalogs/locations/1.json
def update respond_to do |format| if @resource.update(catalogs_location_params) # Load records in order to refresh index page index flash[:success] = t('notices.updated_successfully') format.html { redirect_to @resource, warning: 'Location was successfully updated.' } format.json { render :show, status: :ok, location: @resource } format.js else format.html { render :edit } format.json { render json: @resource.errors, status: :unprocessable_entity } format.js end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @catalogs_location.update(catalogs_location_params)\n format.html { redirect_to @catalogs_location, notice: t('.updated') }\n format.json { render :show, status: :ok, location: @catalogs_location }\n else\n format.html { render :edit }\n format.json { render json: @catalogs_location.errors, status: :unprocessable_entity }\n format.js { render :edit }\n end\n end\n end", "def update\n respond_to do |format|\n if @catalog_location.update(catalog_location_params)\n format.html { redirect_to @catalog_location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @catalog_location }\n else\n format.html { render :edit }\n format.json { render json: @catalog_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render json: Location.update(params[\"id\"], params[\"location\"])\n end", "def update_location(params)\n @client.put(\"#{path}/location\", nil, params, \"Content-Type\" => \"application/json\")\n end", "def update\n respond_to do |format|\n if @catalog.update(catalog_params)\n format.html { redirect_to @catalog }\n format.json { render :show, status: :ok, location: @catalog }\n else\n format.html { render :edit }\n format.json { render json: @catalog.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @catalog.update(catalog_params)\n format.html { redirect_to @catalog, notice: 'Catalog was successfully updated.' }\n format.json { render :show, status: :ok, location: @catalog }\n else\n format.html { render :edit }\n format.json { render json: @catalog.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @location = Location.find(params[:id])\r\n \r\n respond_to do |format|\r\n if @location.update_attributes(params[:location])\r\n format.json { head :no_content }\r\n else\r\n format.json { render json: @location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @status_catalog.update(status_catalog_params)\n format.html { redirect_to @status_catalog, notice: 'Status catalog was successfully updated.' }\n format.json { render :show, status: :ok, location: @status_catalog }\n else\n format.html { render :edit }\n format.json { render json: @status_catalog.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @prod_loc.update(prod_loc_params)\n format.html { redirect_to @prod_loc, notice: 'Prod loc was successfully updated.' }\n format.json { render :show, status: :ok, location: @prod_loc }\n else\n format.html { render :edit }\n format.json { render json: @prod_loc.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @locations = []\n @errors = []\n @hide_map = true\n if params.has_key? :id\n location = Location.find(params[:id])\n @locations = [ location ]\n location_params = params.clone\n [:created_at, :id, :updated_at, :category, :subcategories, :markerVisible, :action, :controller, :location].each do |param|\n location_params.delete param\n end\n location.update_attributes location_params\n @errors = location.errors\n elsif params.has_key? :locations\n params[:locations][:location].each do |data|\n l = Location.find data[0]\n if not l.update_attributes data[1]\n pp l.errors\n @errors.push l.errors\n end\n @locations.push l\n end\n end\n\n respond_to do |format|\n if @errors.empty?\n format.html { redirect_to :locations, :notice => 'Locations successfully updated.'}\n format.json { head :no_content }\n else\n format.html { render :action =>\"edit\" }\n format.json { render :json => @errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @curpg = :admintools\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to :controller => \"locations\", :action => \"index\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n logger.info params[:location].to_json\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, :notice => 'Location was successfully updated.' }\n format.json { render :json => @location, :status => :updated, :location => @location }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @clinic_location.update(clinic_location_params)\n format.html { redirect_to @clinic_location, notice: 'Clinic location was successfully updated.' }\n format.json { render :show, status: :ok, location: @clinic_location }\n else\n format.html { render :edit }\n format.json { render json: @clinic_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @service_location.update(service_location_params)\n render json: @service_location, status: :ok, location: @service_location\n else\n render json: @service_location.errors, status: :unprocessable_entity\n end \n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n if @location.dt_devolucao.nil?\n else\n @vehicle = Vehicle.find_by(id: @location.vehicle_id)\n @client = Client.find_by(id: @location.client_id)\n \n @vehicle.update_attribute(:status, 'DISPONÍVEL')\n @client.update_attribute(:status, 'DISPONÍVEL')\n end\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @record = Location.find(params[:id])\n @record.update_attributes(params[:location]) \n respond_to do |format|\n# format.html\n format.json {\n render json: {}\n }\n end\n end", "def update\n @location = Location.find(params[:id])\n \n @previousMap = Location.WhereAmI(@location.region_id)\n\n #binding.pry\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @previousMap, notice: 'Location was successfully updated.' }\n format.json { respond_with_bip(@location) }\n else\n format.html { render action: \"edit\" }\n format.json { respond_with_bip(@location) }\n end\n end\n end", "def update\n respond_to do |format|\n if @catalogo.update(catalogo_params)\n format.html { redirect_to @catalogo, notice: 'Catalogo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @catalogo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.friendly.find(params[:id])\n respond_to do |format|\n if @location.update_attributes!(location_params)\n format.html { redirect_to @location, notice: 'location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @processed_location = ProcessedLocation.find(params[:id])\n\n respond_to do |format|\n if @processed_location.update_attributes(params[:processed_location])\n format.html { redirect_to @processed_location, notice: 'Processed location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @processed_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @specific_location.update(specific_location_params)\n format.html { redirect_to @specific_location, notice: 'Specific location was successfully updated.' }\n format.json { render :show, status: :ok, location: @specific_location }\n else\n format.html { render :edit }\n format.json { render json: @specific_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe_location.update(recipe_location_params)\n format.html { redirect_to @recipe_location, notice: 'Recipe location was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_location }\n else\n format.html { render :edit }\n format.json { render json: @recipe_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @regions = Region.all\n if params[:regions]\n @location_regions = Region.find(params[:regions])\n else\n @location_regions = []\n end\n @location.regions = @location_regions\n\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @catalogo.update(catalogo_params)\n format.html { redirect_to @catalogo, notice: 'Catalogo was successfully updated.' }\n format.json { render :show, status: :ok, location: @catalogo }\n else\n format.html { render :edit }\n format.json { render json: @catalogo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_location.update(api_v1_location_params)\n format.html { redirect_to @api_v1_location, notice: 'Location was successfully updated.' }\n format.json { render json: { location: @api_v1_location, message: 'Location was successfully updated.' } }\n else\n format.html { render :edit }\n format.json { render json: { results: @api_v1_location.errors, message: 'Location was NOT successfully update.' } }\n end\n end\n end", "def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n respond_to do |format|\n if @product_catalog.update(product_catalog_params)\n format.html { redirect_to @product_catalog, notice: 'Product catalog was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_catalog }\n else\n format.html { render :edit }\n format.json { render json: @product_catalog.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n set_location\n\n respond_to do |format|\n if @location.update_attributes(location_params)\n format.html { redirect_to @location, flash: {success: \"Successfully updated #{@location.name} location!\" }}\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n flash[:notice] = t('scaffold.notice.updated', :item => SicossLocation.model_name.human) if @sicoss_location.update_attributes(params[:sicoss_location])\n respond_with(@sicoss_location, :location => sicoss_locations_path)\n end", "def update\n respond_to do |format|\n if @catalog_item.update(name: params[:name], description: params[:description])\n format.json { render json: @catalog_item }\n end\n end\n end", "def update\n @storage_location = StorageLocation.find(params[:id])\n\n respond_to do |format|\n if @storage_location.update_attributes(params[:storage_location])\n format.html { redirect_to @storage_location, notice: 'Storage location was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @storage_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end", "def update!(**args)\n @locations = args[:locations] if args.key?(:locations)\n end", "def update!(**args)\n @locations = args[:locations] if args.key?(:locations)\n end", "def update!(**args)\n @locations = args[:locations] if args.key?(:locations)\n end", "def update\n @corp_location = CorpLocation.get(params[:id])\n\n respond_to do |format|\n if @corp_location.update(corp_location_params)\n format.html { redirect_to @corp_location, notice: 'Corp location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @corp_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_catalogs_location\n @resource = Catalogs::Location.find(params[:id])\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to [@organization, @location], notice: 'Location was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cat_poly.update(cat_poly_params)\n format.html { redirect_to @cat_poly, notice: 'Cat poly was successfully updated.' }\n format.json { render :show, status: :ok, location: @cat_poly }\n else\n format.html { render :edit }\n format.json { render json: @cat_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n old_location = Location.find(@car.location_id)\n if @car.update(car_params)\n new_location = Location.find(@car.location_id)\n \n old_location.status = \"Available\"\n old_location.save\n \n new_location.status = \"Unavailable\"\n new_location.save\n \n format.html { redirect_to @car, notice: 'Car was successfully updated.' }\n format.json { render :show, status: :ok, location: @car }\n else\n format.html { render :edit }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n puts \"Location::update (params): \" + location_params.inspect\n \n if @location.update(location_params)\n render :json => {status: :ok, location: @location }\n else\n render :json => {errors: @location.errors, status: :unprocessable_entity }\n end\n end", "def update\n respond_to do |format|\n if @service_location.update(service_location_params)\n format.html { redirect_to @service_location, notice: \"Updated Information for location: '#{@service_location.location.name}'\" }\n format.json { render :show, status: :ok, location: @service_location }\n else\n format.html { render :edit }\n format.json { render json: @service_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @catalogs_supplier.update(catalogs_supplier_params)\n format.html { redirect_to @catalogs_supplier, notice: 'Supplier was successfully updated.' }\n format.json { render :show, status: :ok, location: @catalogs_supplier }\n else\n format.html { render :edit }\n format.json { render json: @catalogs_supplier.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_location(location={})\n\t\tclient.update(location)\n\tend", "def update\n \n @job_location.update(job_location_params)\n \n end", "def update\n respond_to do |format|\n if @catalogo.update(catalogo_params)\n format.html { redirect_to @catalogo, notice: 'Registro actualizado exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @catalogo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @locations = Location.where(\"status <> 'NORMAL'\").order(\"state, township desc\")\n respond_to do |format|\n if @aid_offer.update(aid_offer_params)\n format.html { redirect_to @aid_offer, notice: 'Aid offer was successfully updated.' }\n format.json { render :show, status: :ok, location: @aid_offer }\n else\n format.html { render :edit }\n format.json { render json: @aid_offer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item_catalog = ItemCatalog.find(params[:id])\n\n respond_to do |format|\n if @item_catalog.update_attributes(params[:item_catalog])\n format.html { redirect_to @item_catalog, notice: 'Item catalog was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item_catalog.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @latstraps1.update(latstraps1_params)\n format.html { redirect_to \"/latstraps1s\"}\n format.json { render :show, status: :ok, location: @latstraps1 }\n else\n format.html { render :edit }\n format.json { render json: @latstraps1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@items_location = ItemsLocation.find(params[:id])\n\n respond_to do |format|\n #if @items_location.update_attributes(params[:items_location])\n # format.html { redirect_to @items_location, notice: 'Items location was successfully updated.' }\n # format.json { head :no_content }\n #else\n # format.html { render action: \"edit\" }\n # format.json { render json: @items_location.errors, status: :unprocessable_entity }\n #end\n end\n end", "def update\n respond_to do |format|\n if @location_option.update(location_option_params)\n format.html { redirect_to @location_option, notice: 'Location option was successfully updated.' }\n format.json { render :show, status: :ok, location: @location_option }\n else\n format.html { render :edit }\n format.json { render json: @location_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @catalog_category.update(catalog_category_params)\n format.html { redirect_to catalog_categories_url }\n format.json { render :show, status: :ok, location: @catalog_category }\n else\n format.html { render :edit }\n format.json { render json: @catalog_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @records_location = RecordsLocation.find(params[:id])\n\n respond_to do |format|\n if @records_location.update_attributes(params[:records_location])\n format.html { redirect_to @records_location, notice: 'Records location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @records_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @locacao = Locacao.find(params[:id])\n\n respond_to do |format|\n if @locacao.update_attributes(params[:locacao])\n format.html { redirect_to @locacao, :notice => 'Locacao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @locacao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to '/admin/locations', notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n puts \"\\nUPDATE: #{@location.inspect}\"\n format.html { redirect_to @location, notice: \"Location was successfully updated.\" }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n @location_have_location = LocationHaveLocation.find(params[:id])\n\n respond_to do |format|\n if @location_have_location.update_attributes(params[:location_have_location])\n format.html { redirect_to @location_have_location, notice: 'Location have location was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location_have_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to user_locations_path, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @catalog_supplier.update(catalog_supplier_params)\n format.html { redirect_to @catalog_supplier, notice: 'Supplier was successfully updated.' }\n format.json { render :show, status: :ok, location: @catalog_supplier }\n else\n format.html { render :edit }\n format.json { render json: @catalog_supplier.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to locations_path, notice: 'Adres pomyślnie zaktualizowany.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n logger.debug params.inspect\n\n begin\n @location = if (current_user.has_role?(:administrator))\n Location.find_by_slug(params[:id])\n else\n current_user.locations.find_by_slug(params[:id])\n end\n rescue\n # Just continue -- no location found\n end\n\n if (current_user.has_role?(:administrator))\n unless params[:user].blank? || params[:user][:login].blank?\n new_owner = User.find_by_login(params[:user][:login])\n @location.change_user(new_owner.id, current_user)\n end\n end\n\n respond_to do |format|\n if @location\n if (params[:location] && contacts = params[:location].delete(:contacts))\n contacts_array = hash_to_array(contacts)\n\n contacts_array.each do |contact|\n if (phones = contact.delete(:phone))\n contact[:phone] = hash_to_array(phones)\n end\n end\n\n @location.contacts = contacts_array\n end\n @location.attributes = params[:location]\n @location.geocode\n end\n\n if @location && @location.save\n flash[:notice] = t 'club_updated'\n format.html { redirect_to(location_path(@location.slug)) }\n format.xml { head :ok }\n else\n format.html do\n if @location\n render :action => \"edit\"\n else\n flash[:error] = t 'club_unknown'\n redirect_to locations_url\n end\n end\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n @pagetitle = \"Edit location\"\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(locations_params)\n format.html { redirect_to(@location, :notice => 'Location was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n \n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @location.update_attribute(params[:geolocation])\n format.html { redirect_to @location, notice: 'Location was successfully updated.'}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @current_location.update(current_location_params)\n format.html { redirect_to @current_location, notice: 'Current location was successfully updated.' }\n format.json { render :show, status: :ok, location: @current_location }\n else\n format.html { render :edit }\n format.json { render json: @current_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(shop_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @callout.update(callout_params)\n format.html { redirect_to @callout, notice: 'Callout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @callout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @backend_location.update(backend_location_params)\r\n format.html { redirect_to @backend_location, notice: 'Location was successfully updated.' }\r\n format.json { render :show, status: :ok, location: @backend_location }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @backend_location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Ubicacion actualizada correctamente!' }\n format.json { head :no_content }\n else\n format.html { redirect_to '/locations/'[email protected]_s+'/edit',notice: 'Ingrese una direccion y un numero de casa!' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @campus_food = CampusFood.find(params[:id])\n\t@campus_food.location = params[:tags]\n respond_to do |format|\n if @campus_food.update_attributes(params[:campus_food])\n format.html { redirect_to campus_foods_path, notice: 'Campus food was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @campus_food.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to locations_path, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @loc = current_user.locs.find(params[:id])\n\n respond_to do |format|\n if @loc.update_attributes(params[:loc])\n format.html { redirect_to @loc, notice: 'Loc was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @loc.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n @locations = Location.index_locations\n format.html { redirect_to(@location, :notice => 'Location was successfully updated.') }\n format.xml { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def update\r\n @discounts_on_location = DiscountsOnLocation.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @discounts_on_location.update_attributes(params[:discounts_on_location])\r\n format.html { redirect_to @discounts_on_location, notice: 'Discounts on location was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @discounts_on_location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @locations_locationset = LocationsLocationset.find(params[:id])\n\n respond_to do |format|\n if @locations_locationset.update_attributes(params[:locations_locationset])\n format.html { redirect_to(@locations_locationset, :notice => 'Locations locationset was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @locations_locationset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def update\n respond_to do |format|\n if @location_detail.update(location_detail_params)\n format.html { redirect_to @location_detail, notice: 'Location detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @location_detail }\n else\n format.html { render :edit }\n format.json { render json: @location_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to locations_url, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n \n #abort\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to :back, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n set_site_entities @location\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @catalogo_catalogo = Catalogo::Catalogo.find(params[:id])\n\n @catalogo_tipo_catalogo = Catalogo::TipoCatalogo.find(@catalogo_catalogo.tipo_catalogo_id)\n\n respond_to do |format|\n if @catalogo_catalogo.update_attributes(params[:catalogo_catalogo])\n format.html { redirect_to edit_catalogo_tipo_catalogo_path(@catalogo_tipo_catalogo), notice: 'Guardado Correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @catalogo_catalogo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n recipe.update(recipe_params)\n render json: recipe\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n return false unless authorize(permissions = [\"administer_catalog\"])\n @catalog = Catalog.find(params[:id])\n\n respond_to do |format|\n if @catalog.update_attributes(params[:catalog])\n flash.now[:notice] = t('admin.catalog.flash.updated')\n format.html { redirect_to(@catalog) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @catalog.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @totem_location.update(totem_location_params)\n format.html { redirect_to @totem_location, notice: 'Totem location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @totem_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_catalogs_location\n @catalogs_location = Catalogs::Location.find(params[:id])\n end", "def update\n\t @location = Location.find(params[:id])\n\n\t respond_to do |format|\n\t if @location.update_(location_params)\n\t format.html { redirect_to @location, notice: 'location was successfully updated.' }\n\t format.json { head :no_content }\n\t else\n\t format.html { render action: \"edit\" }\n\t format.json { render json: @location.errors, status: :unprocessable_entity }\n\t end\n\t end\n\t end" ]
[ "0.6973116", "0.6766193", "0.662001", "0.64670026", "0.6360028", "0.6312289", "0.6268607", "0.62132907", "0.6202481", "0.61735505", "0.6159568", "0.6149059", "0.6100566", "0.60905176", "0.6040952", "0.6022997", "0.60228384", "0.60180384", "0.60162354", "0.59800595", "0.59777176", "0.59639007", "0.59515274", "0.59365845", "0.593156", "0.5922089", "0.5908977", "0.5907119", "0.5905474", "0.5900087", "0.5899845", "0.5889994", "0.588431", "0.58764577", "0.5875803", "0.58729535", "0.58729535", "0.587282", "0.58686215", "0.58614504", "0.58600074", "0.58586955", "0.5840482", "0.5832164", "0.5832164", "0.5832164", "0.5832164", "0.5831554", "0.58286804", "0.5825491", "0.5820478", "0.58204544", "0.5819809", "0.5814873", "0.58084434", "0.57977855", "0.5797732", "0.578594", "0.57814926", "0.5778188", "0.5775877", "0.5771849", "0.5771275", "0.5770286", "0.5762962", "0.5762962", "0.5758805", "0.5758696", "0.57460827", "0.57457125", "0.5745396", "0.57450783", "0.574258", "0.5737992", "0.57320166", "0.572371", "0.57159185", "0.57140946", "0.57025087", "0.5701237", "0.5698838", "0.5689905", "0.56862396", "0.56823504", "0.5678594", "0.5678516", "0.5674132", "0.5671889", "0.56694335", "0.5667277", "0.56671894", "0.5661266", "0.5659413", "0.5659325", "0.5652271", "0.5646066", "0.56430054", "0.5639826", "0.5637357", "0.56363696" ]
0.6483199
3
DELETE /catalogs/locations/1z DELETE /catalogs/locations/1.json
def destroy @resource.destroy respond_to do |format| format.html { redirect_to catalogs_locations_url, flash: {warning: t('notices.destroyed') }} format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @catalog_location.destroy\n respond_to do |format|\n format.html { redirect_to catalog_locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @storage_location = StorageLocation.find(params[:id])\n @storage_location.destroy\n\n respond_to do |format|\n format.html { redirect_to storage_locations_url }\n format.json { head :ok }\n end\n end", "def destroy\n @catalog.destroy\n respond_to do |format|\n format.html { redirect_to catalogs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @storage_location = StorageLocation.find(params[:id])\n @storage_location.destroy\n\n respond_to do |format|\n format.html { redirect_to(storage_locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @corp_location = CorpLocation.get(params[:id])\n @corp_location.destroy\n\n respond_to do |format|\n format.html { redirect_to corp_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @record = Location.find(params[:id])\n @record.trash\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @status_catalog.destroy\n respond_to do |format|\n format.html { redirect_to status_catalogs_url, notice: 'Status catalog was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_location.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_locations_url, notice: 'Location was successfully destroyed.' }\n format.json { render json: { results: @api_v1_location, message: 'Location was successfully destroyed.' } }\n end\n end", "def destroy\n @prod_loc.destroy\n respond_to do |format|\n format.html { redirect_to prod_locs_url, notice: 'Prod loc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @specific_location.destroy\n respond_to do |format|\n format.html { redirect_to specific_locations_url, notice: 'Specific location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ms_location.destroy\n respond_to do |format|\n format.html { redirect_to ms_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @location = Location.find(params[:id])\r\n @location.destroy\r\n\r\n respond_to do |format|\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @catalog.destroy\n respond_to do |format|\n format.html { redirect_to catalogs_url, notice: 'Catalog was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n #@client = Client.find(@location.client_ids)\n #@contact = Contact.find(@location.contact_ids)\n \n @location.destroy\n\n respond_to do |format|\n \n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @location = Location.find(params[:id])\r\n RemovedLocation.create(server_id: Integer(params[:id]))\r\n directory = Rails.root.join('app','assets','locations');\r\n\r\n path = File.join(directory, @location.image)\r\n File.delete(path)\r\n @location.destroy\r\n mv = MapsVersion.first\r\n mv.version = mv.version+1\r\n mv.save\r\n respond_to do |format|\r\n format.html { redirect_to locations_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\r\n @backend_location.destroy\r\n respond_to do |format|\r\n format.html { redirect_to backend_locations_url, notice: 'Location was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @records_location = RecordsLocation.find(params[:id])\n @records_location.destroy\n\n respond_to do |format|\n format.html { redirect_to records_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @zt020.destroy\n respond_to do |format|\n format.html { redirect_to zt020s_url, notice: 'Zt020 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @discounts_on_location = DiscountsOnLocation.find(params[:id])\r\n @discounts_on_location.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to discounts_on_locations_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @storeloc = Storeloc.find(params[:id])\n @storeloc.itemlocs.each do |loc|\n loc.destroy\n end\n\n @storeloc.destroy\n\n respond_to do |format|\n format.html { redirect_to(storelocs_url) }\n format.xml { head :ok }\n end\n end", "def delete\n render json: Location.delete(params[\"id\"])\n end", "def destroy\n @catalogo.destroy\n respond_to do |format|\n format.html { redirect_to catalogos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @catalogo.destroy\n respond_to do |format|\n format.html { redirect_to catalogos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n set_location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, flash: {success: \"Successfully deleted #{@location.name} location!\" }}\n format.json { head :no_content }\n end\n end", "def destroy\n @clinic_location.destroy\n respond_to do |format|\n format.html { redirect_to clinic_locations_url, notice: 'Clinic location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/locations', notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @totem_location.destroy\n respond_to do |format|\n format.html { redirect_to totem_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @processed_location = ProcessedLocation.find(params[:id])\n @processed_location.destroy\n\n respond_to do |format|\n format.html { redirect_to processed_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n render :json => { status: :deleted, head: :no_content }\n end", "def destroy\n @zona = Zona.find(params[:id])\n @zona.destroy\n\n respond_to do |format|\n format.html { redirect_to zone_url }\n format.json { head :no_content }\n end\n end", "def destroy\n dns_entry_response = RestClient.delete('https://api.cloudflare.com/client/v4/zones/:zone_identifier/dns_records/:identifier',:content_type => :json, :accept => :json, :'x-auth-key' => session[:key] :'x-auth-email' => session[:email])\n @dns_entry.destroy\n respond_to do |format|\n format.html { redirect_to dns_entries_url, notice: \"Dns entry was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_location.destroy\n respond_to do |format|\n format.html { redirect_to admin_locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @zonal.destroy\n respond_to do |format|\n format.html { redirect_to zonals_url, notice: 'Zonal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @spatial_coverages = SpatialCoverages.find(params[:id])\n @spatial_coverages.destroy\n\n respond_to do |format|\n format.html { redirect_to spatial_coverage_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @clientz.destroy\n respond_to do |format|\n format.html { redirect_to clientzs_url, notice: 'Clientz was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #@items_location = ItemsLocation.find(params[:id])\n #@items_location.destroy\n\n respond_to do |format|\n format.html { redirect_to items_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @storage = @client.storages.find(params[:id])\n @storage.destroy\n\n respond_to do |format|\n format.html { redirect_to client_url(@client) }\n format.json { head :no_content }\n end\n end", "def destroy\n @locations = nil\n\n if params.has_key? :id\n location = Location.find params[:id]\n @locations = [ location ]\n elsif params.has_key? :ids\n @locations = Location.find params[:ids].split(\",\")\n end\n\n if not @locations.empty?\n @locations.each do |l|\n l.destroy\n end\n end\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aws_az.destroy\n respond_to do |format|\n format.html { redirect_to aws_azs_url, notice: 'Aws az was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe_location.destroy\n respond_to do |format|\n format.html { redirect_to recipe_locations_url, notice: 'Recipe location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to geolocation_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_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 @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :ok }\n end\n end", "def destroy\n @catalog = current_user.catalogs.find_by_id(params[:id])\n @catalog.destroy\n respond_to do |format|\n format.html { redirect_to catalogs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_index_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @ge_city_api.destroy\n respond_to do |format|\n format.html { redirect_to ge_city_apis_url, notice: 'Ge city api was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @catalog = Catalog.find(params[:id])\n @catalog.destroy\n\n respond_to do |format|\n format.html { redirect_to(catalogs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = apply_scopes(Location).find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_locations_url(:site => current_site.id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to trip_locations_path, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @accession_location_entry = AccessionLocationEntry.find(params[:id])\n @accession_location_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to accession_location_entries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @zone.destroy\n respond_to do |format|\n format.html { redirect_to action: \"index\" }\n format.json { head :no_content }\n #testing\n end\n end", "def deleteLocation _args\n \"deleteLocation _args;\" \n end", "def destroy\n puts \"\\nDESTROY: #{@location.inspect}\"\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: \"Location was successfully destroyed.\" }\n format.json { head :no_content }\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 @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cakestore.destroy\n respond_to do |format|\n format.html { redirect_to cakestores_url, notice: 'Cakestore was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n debug('Removing location')\n crm('configure', 'delete', @resource[:name])\n @property_hash.clear\n end", "def destroy\n @cityzone.destroy\n respond_to do |format|\n format.html { redirect_to cityzones_url, notice: 'Cityzone was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @store = Store.find(params[:id])\n #tib_res = Tibbr::ExternalResource.find_by_resource_key({:resource => {:key => \"ID_#{@store.id}\", :resource_type => \"ad:store\"}, :client_id => session[:app_id]})\n # tib_res.destroy\n @store.destroy\n \n \n\n respond_to do |format|\n format.html { redirect_to stores_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @slocation.destroy\n respond_to do |format|\n format.html { redirect_to slocations_url, notice: 'Story Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @couch.destroy\n respond_to do |format|\n format.html { redirect_to couches_url, notice: 'Couch was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @maplocation.destroy\n respond_to do |format|\n format.html { redirect_to maplocations_url, notice: 'Maplocation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: \"Location was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @geo.destroy\n respond_to do |format|\n format.html { redirect_to geos_url, notice: 'Geo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n return unless admin?\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @locations_locationset = LocationsLocationset.find(params[:id])\n @locations_locationset.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_locationsets_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.70818424", "0.6831045", "0.6726676", "0.66676116", "0.6643871", "0.65990657", "0.654962", "0.65441644", "0.6518476", "0.6516719", "0.6503322", "0.6494045", "0.64939845", "0.6491001", "0.6490741", "0.64897543", "0.64838725", "0.6483559", "0.64463705", "0.64400375", "0.6438007", "0.64362454", "0.64362454", "0.6436174", "0.6422414", "0.64201045", "0.64036644", "0.6401564", "0.6388098", "0.6382769", "0.637691", "0.6375847", "0.6365163", "0.63647217", "0.6349089", "0.634584", "0.634584", "0.634584", "0.634584", "0.63394433", "0.6327552", "0.6325263", "0.63165516", "0.63109636", "0.63080555", "0.63034344", "0.6299052", "0.62954175", "0.62954175", "0.62954175", "0.62954175", "0.62954175", "0.62954175", "0.62954175", "0.62954175", "0.6288249", "0.6285398", "0.6285398", "0.62811726", "0.6274469", "0.62700313", "0.62671125", "0.6264779", "0.62601274", "0.62542045", "0.6254112", "0.623972", "0.62370306", "0.6235156", "0.62350315", "0.6229792", "0.62224007", "0.62194103", "0.6218221", "0.6210923", "0.62053585", "0.62047267", "0.62044156", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6203115", "0.6201812", "0.6198959", "0.6198", "0.61975664", "0.61920726", "0.61904424" ]
0.6650272
4
Use callbacks to share common setup or constraints between actions.
def set_catalogs_location @resource = Catalogs::Location.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup\n #implement in subclass;\n end", "def after_set_callback; end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.53314966", "0.53114754", "0.52984965", "0.52977055", "0.5296272", "0.5260649", "0.5245076", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.5235081", "0.52321917", "0.5228592", "0.5220735", "0.52198535", "0.52139324", "0.5208539", "0.5206585", "0.5178542", "0.5175199", "0.5173538", "0.5167041", "0.51614195", "0.51577675", "0.5153909", "0.51528823", "0.5152225", "0.51429904", "0.5141399", "0.51345575", "0.51145", "0.5114052", "0.5114052", "0.5110216", "0.5108656", "0.50935394", "0.5089196", "0.5081936", "0.5079627", "0.50675833", "0.5056105", "0.5053687", "0.5050475", "0.5050475", "0.503471", "0.5028311", "0.501982", "0.50157547", "0.5013552", "0.50014806", "0.50011593", "0.49976763", "0.4990292", "0.4990292", "0.49882022", "0.4981269", "0.49792367", "0.49766538", "0.4967978", "0.49667212", "0.4958987", "0.49572337", "0.49550423", "0.4954479", "0.4952353", "0.494726", "0.4944055", "0.4935437", "0.4931248", "0.49283475", "0.49281213", "0.49268973", "0.4921738", "0.49204507", "0.4918924", "0.49182287", "0.4916538", "0.49158585", "0.49156788" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def catalogs_location_params params.require(:catalogs_location).permit(:abbr, :name_es, :name_en) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def filtering_params\n params.permit(:email)\n end", "def active_code_params\n params[:active_code].permit\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def url_whitelist; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.6978086", "0.6780264", "0.6742658", "0.6738813", "0.67338693", "0.65908474", "0.6501793", "0.6495506", "0.64796513", "0.64755446", "0.6454826", "0.6437561", "0.6377127", "0.63722163", "0.6364058", "0.63178706", "0.62979764", "0.62968165", "0.62913024", "0.6289789", "0.6289145", "0.62875307", "0.6280997", "0.62420976", "0.62388235", "0.6216686", "0.62122375", "0.6208949", "0.619173", "0.6176307", "0.6173907", "0.6170346", "0.616111", "0.6150513", "0.6150023", "0.61446756", "0.6120429", "0.6112975", "0.6104845", "0.6102966", "0.6087884", "0.6079323", "0.60699135", "0.60602236", "0.60191786", "0.60170597", "0.60100305", "0.6009527", "0.60052776", "0.60052776", "0.600042", "0.5999317", "0.59933805", "0.5991528", "0.5991221", "0.5990094", "0.5979497", "0.5966058", "0.5958738", "0.59579456", "0.5957759", "0.5956938", "0.5951788", "0.59511644", "0.59423065", "0.59373474", "0.59361076", "0.59361076", "0.59331447", "0.5928005", "0.5924882", "0.5924011", "0.59169155", "0.5908037", "0.5907541", "0.59061426", "0.59056246", "0.5897408", "0.58960444", "0.58951247", "0.5893136", "0.5892312", "0.5890385", "0.58853275", "0.58801144", "0.58784765", "0.5872648", "0.58682626", "0.5867028", "0.58661693", "0.586578", "0.58643955", "0.5863193", "0.58609086", "0.5859997", "0.5858935", "0.5858632", "0.5853379", "0.5852741", "0.584806", "0.5847703" ]
0.0
-1
GET /users GET /users.json
def index @users = User.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def users(args = {})\n get(\"/users.json\",args)\n end", "def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end", "def GetUsers params = {}\n\n params = params.merge(path: 'users.json')\n APICall(params)\n\n end", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end", "def list_users\n self.class.get('/users')\n end", "def users\n get('get_users')\n end", "def index\n users = User.all\n json_response(users)\n end", "def show\n @users = User.all\n json_response(@users)\n end", "def list\r\n users = User.all\r\n render json: users\r\n end", "def show\n @users = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @users }\n end\n end", "def get \n render :json => User.find(params[:id])\n end", "def index\n @users = User.all\n\n render json: @users\n end", "def index\n users = User.all\n render json: { users: users }, status: :ok\n end", "def index\r\n users = User.all\r\n render json: users\r\n end", "def users(params = {})\n params.merge!(key: 'users')\n objects_from_response(Code42::User, :get, 'user', params)\n end", "def index\n users = User.all\n render json: users\n end", "def index\n users = User.all\n render json: users\n end", "def index\n users = User.all\n render json: users\n end", "def index\n users = User.all\n render json: users\n end", "def users(params = {})\n make_get_request('/account/users', params)\n end", "def index\n users = User.all\n render json: users \n end", "def index\n users = User.all\n\n render json: users, each_serializer: Api::V1::UsersSerializer\n end", "def index\n user= User.all\n render json: {users:user}\n end", "def index\n @users = User.all\n render json: @users, status: :ok\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n json_response(User.all) \n end", "def index\n @users = User.all\n\n render json: @users\n end", "def index\n @users = User.all\n\n render json: @users\n end", "def index\n @users = User.all\n\n render json: @users\n end", "def index\n @users = User.all\n\n render json: @users\n end", "def index\n @users = User.all\n\n render json: @users\n end", "def index\n @users = User.all\n\n render json: @users\n end", "def user_info\n @user = @github.users.get user: params[:username]\n render json: Hash[@user]\n end", "def index\n users = User.all \n render json: users \n end", "def index\n\t\t# specifying json format in the URl\n\t uri = \"#{API_BASE_URL}/users.json\"\n\t # It will create new rest-client resource so that we can call different methods of it\n\t rest_resource = RestClient::Resource.new(uri, USERNAME, PASSWORD)\n\n\t # this next line will give you back all the details in json format, \n\t #but it will be wrapped as a string, so we will parse it in the next step.\n\t users = rest_resource.get \n\n\t # we will convert the return data into an array of hash. see json data parsing here\n\t @users = JSON.parse(users, :symbolize_names => true)\n\tend", "def index\n\t\t@users = User.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @users.map(&:as_json) }\n\t\tend\n\tend", "def list\n render json: User.all\n end", "def index\n @users = User.all\n render json: @users, status: :ok\n end", "def user\n render :json=> User.find(params[:id])\n end", "def index\n\n users = User.all \n render json: users\n\n end", "def show\n render json: Users.find(params[\"id\"])\n end", "def GetUser id\n\n APICall(path: \"users/#{id}.json\")\n\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html\n format.json { render json: @users }\n end\n end", "def show\n @users = User.find(params[:id])\n if @users\n respond_to do |format|\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n else\n head :not_found\n end\n end", "def index\n \t@users = User.all\n\n respond_to do |format| \n format.json { render json: @users }\n end\n end", "def list\n get('users')['users']\n end", "def index\n render ActiveModelSerializers::SerializableResource.new(@users,\n each_serializer: UserSerializer\n ).to_json, status: 200\n end", "def index\n @users = User.all \n render json: @users, status: :ok \n end", "def index\n @users = User.all\n logger.debug(\"user index\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n render json: User.all\n end", "def index\n @users = User.order_by(last_name: :desc)\n if @users\n render json: Oj.dump(json_for(@users, include: ['phones', 'cards'], meta: meta), mode: :compat)\n else\n return head :unauthorized\n end\n end", "def users(params = {})\n response = get('users/lookup.json', params)\n response.map {|user| Croudia::Object::User.new(user) }\n end", "def index\n render json: User.all\n end", "def index\n render json: User.all\n end", "def show\n user = User.find(params[:id])\n render json: @user\nend", "def list_users(user_id)\n self.class.get(\"/users/#{user_id}\")\n end", "def show\n user = User.find(params[:id])\n render json: user\n end", "def index\n\t\t@users = User.all\n\n\t\trespond_to do |format|\n\t\t format.html # index.html.erb\n\t\t format.json { render json: @users }\n\t\tend\n\tend", "def index\n @users = User.all(limit: 100)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users.as_json(user: current_user) }\n end\n end", "def get_users\r\n # Prepare query url.\r\n _path_url = '/users'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n decoded.map { |element| User.from_hash(element) }\r\n end", "def show\n # When a http GET request to '/users/1' is received, have it show,\n # in json format, user 1's information.\n @id = params[:id]\n @user = User.find(@id)\n render json: @user\n end", "def show\n user = User.find(params[:id])\n\n render json: user\n end", "def index \n render json: User.all\n end", "def index\n @myusers = Myuser.all\n\n render json: @myusers\n end", "def index\n\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def query_users(options={}) path = \"/api/v2/users\"\n get(path, options, AvaTax::VERSION) end", "def list\n response = @client.get(\"/users\")\n response[\"users\"].map {|u| User.new(@client, u) }\n end", "def users\n\t\trespond_with User.all\n\tend", "def index\n @users = User.all\n\n respond_with do |format|\n format.json do\n render json: @users,\n each_serializer: Api::UserSerializer,\n root: 'users'\n end\n end\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end" ]
[ "0.82109934", "0.7873764", "0.7860689", "0.78108346", "0.78067017", "0.7678852", "0.76586664", "0.76318866", "0.7582366", "0.75291824", "0.7487637", "0.74485743", "0.7439024", "0.7437192", "0.7427442", "0.73978853", "0.73978853", "0.73978853", "0.73978853", "0.7377353", "0.7372414", "0.736885", "0.7368531", "0.7367068", "0.7358582", "0.7358582", "0.7358582", "0.7358582", "0.7358582", "0.7358582", "0.7358582", "0.7358582", "0.7358582", "0.7358582", "0.7351495", "0.7350187", "0.7350187", "0.7350187", "0.7350187", "0.7350187", "0.7350187", "0.73463756", "0.73426867", "0.7331111", "0.73231107", "0.73227614", "0.73126787", "0.7295692", "0.7274169", "0.7265484", "0.72624177", "0.72607577", "0.722517", "0.72189873", "0.71941674", "0.71883225", "0.7187108", "0.71815044", "0.717089", "0.71695215", "0.7156781", "0.71546155", "0.71546155", "0.7140691", "0.7135879", "0.7134857", "0.71316093", "0.71315825", "0.712011", "0.7114429", "0.7112858", "0.7107888", "0.7098051", "0.70957917", "0.70957917", "0.7093039", "0.70904744", "0.70890427", "0.70889443", "0.7085115", "0.7085115", "0.7085115", "0.7085115", "0.7085115", "0.7085115", "0.7085115", "0.7081685", "0.7081685", "0.7081685", "0.7081685", "0.7081685", "0.7081685", "0.7081685", "0.7081685", "0.7081685", "0.7081685", "0.7081685", "0.7081685", "0.7081685", "0.7081685", "0.7081685" ]
0.0
-1
GET /users/1 GET /users/1.json
def show redirect_to user_articles_path(@user) unless @user == @current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end", "def get \n render :json => User.find(params[:id])\n end", "def GetUser id\n\n APICall(path: \"users/#{id}.json\")\n\n end", "def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end", "def users(args = {})\n get(\"/users.json\",args)\n end", "def show\n # When a http GET request to '/users/1' is received, have it show,\n # in json format, user 1's information.\n @id = params[:id]\n @user = User.find(@id)\n render json: @user\n end", "def user\n render :json=> User.find(params[:id])\n end", "def fetch_one_user_data\n get_url(\"/api/v1/users/#{@filter}\")\n end", "def show\n user = User.find(params[:id])\n render json: @user\nend", "def show\n user = User.find(params[:id])\n render json: user\n end", "def show\n user = User.find(params[:id])\n\n render json: user\n end", "def show\n render json: Users.find(params[\"id\"])\n end", "def show\n user = User.find(params[:id])\n render json: user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n user = User.select(:id, :username, :email).find(params[:id])\n render :json => user\n end", "def show\n render json: User.find(params[\"id\"])\n end", "def show\n @users = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @users }\n end\n end", "def show\n @user = User.find(params[:id])\n render json: @user\nend", "def user_info\n @user = @github.users.get user: params[:username]\n render json: Hash[@user]\n end", "def show\n render json: User.find(params[:id])\n end", "def show\n @user = User.find(params[:id])\n render json:@user\n end", "def show\n @user = User.find(params[:id])\n render json:@user\n end", "def get_by_id\n \n # the user_id param comes from our route\n user = User.find(params[:user_id])\n \n if user\n render json: user, status: :ok\n else\n render json: { errors: 'User not found' }, status: :not_found\n end\n end", "def GetUsers params = {}\n\n params = params.merge(path: 'users.json')\n APICall(params)\n\n end", "def get_user_details\n @user = User.find_by_id(params[:user_id])\n render json: @user\n end", "def show\n render json: User.find(params[:id])\n end", "def show\n user = User.find_by(id: params[:id])\n render json: user, status: :ok\n end", "def user(id)\n self.class.get(\"/user/#{id}\", @options).parsed_response\n end", "def show\n @user = User.find(params[:id])\n render json: {user: @user}\n end", "def list_users\n self.class.get('/users')\n end", "def show\n user = User.find(params[:id])\n render json: user\n end", "def show\n user = User.friendly.find(params[:user_id]) \n render json: user\n end", "def show\n render :json => User.find(params[:id])\n end", "def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response[\"user\"]\n end", "def index\n users = User.all\n json_response(users)\n end", "def show\n @user = ActiveRecord::Base.connection.execute(\"\n SELECT * \n FROM users \n WHERE username = '#{params[:username].downcase}' \n LIMIT 1\").first\n\n respond_to do |format|\n format.html\n format.json {render json: User.find(@user[0])}\n end\n end", "def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response.first[1]\n end", "def show\n @users = User.all\n json_response(@users)\n end", "def index\n json_response(User.all) \n end", "def get(user_id:)\n path = '/users/{userId}'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::User\n )\n end", "def index\n users = User.all\n render json: { users: users }, status: :ok\n end", "def show\n # @user = User.first\n user = User.find(params[:id])\n render json: user\n end", "def user(user_id, params = {})\n make_get_request(\"/users/#{user_id}\", params)\n end", "def show_user_profile\n @user = User.find(username: params[:username])\n render json: @user\n end", "def user(id = nil)\n id.to_i.zero? ? get('/user') : get(\"/users/#{id}\")\n end", "def get_user id, options={}, headers={}\n @connection.get \"users/#{id}.json\", options, headers\n end", "def user(user=nil)\n if user\n get(\"/users/#{user}\", {}, 3)\n else\n get(\"/user\", {}, 3)\n end\n end", "def index\n \n @user = User.find(current_user.id) \n\n respond_to do |format|\n format.html { render action: \"show\" }\n format.json { render json: @user }\n end\n end", "def show\n @user = User.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @user }\n end\n end", "def get_user(user_id:)\n parse(JSON.parse(connection.get(\"users/#{user_id}\").body))\n end", "def index\n user= User.all\n render json: {users:user}\n end", "def index\r\n users = User.all\r\n render json: users\r\n end", "def show\n # puts params[:id]\n render json: User.find(params[:id])\n end", "def get_user_info\n id = params[\"id\"]\n error_list = []\n status = 1\n json_response = {}\n user = User.find_by(id: id)\n\n if user.nil?\n error_list.append(\"Error: The specified user doesn't exist.\")\n status = -1\n else\n json_response[\"user\"] = user.get_user_json_data\n end\n\n if status == -1\n json_response[\"errors\"] = error_list\n end\n\n json_response[\"status\"] = status\n\n # Format the json_response into proper JSON and respond with it\n json_response = json_response.to_json\n\n respond_to do |format|\n format.json { render json: json_response }\n end\n end", "def show\n @user = User.find(params[:id])\n if @user\n render json: {\n user: @user\n }\n else\n render json: {\n status: 500,\n errors: ['user not found']\n }\n end\n end", "def index\n users = User.all\n render json: users\n end", "def index\n users = User.all\n render json: users\n end", "def index\n users = User.all\n render json: users\n end", "def index\n users = User.all\n render json: users\n end", "def show\n @user = User.find(params[:id])\n render json: {\n username: @user.username,\n first_name: @user.first_name,\n last_name: @user.last_name,\n email: @user.email,\n phone_number: @user.phone_number,\n contacts: @user.contacts\n }, status: :ok\n end", "def get_user(user_id)\n request(Route.new(:GET, '/users/%{user_id}', user_id: user_id))\n end", "def show\n @user = User.find(params[:id])\n render 'api/v1/users/show'\n end", "def index\n users = User.all\n\n render json: users, each_serializer: Api::V1::UsersSerializer\n end", "def index\n users = User.all\n render json: users \n end", "def user(user_id)\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n get(\"users/#{user_id}.json\", params)\n end", "def index\n users = User.all \n render json: users \n end", "def list\r\n users = User.all\r\n render json: users\r\n end", "def json_show_user_profile_by_user_id\n @user = User.find(params[:user_id])\n\n respond_to do |format|\n format.json { render json: @user.as_json(only:[:email,:username]) }\n end\n end", "def index\n\t\t# specifying json format in the URl\n\t uri = \"#{API_BASE_URL}/users.json\"\n\t # It will create new rest-client resource so that we can call different methods of it\n\t rest_resource = RestClient::Resource.new(uri, USERNAME, PASSWORD)\n\n\t # this next line will give you back all the details in json format, \n\t #but it will be wrapped as a string, so we will parse it in the next step.\n\t users = rest_resource.get \n\n\t # we will convert the return data into an array of hash. see json data parsing here\n\t @users = JSON.parse(users, :symbolize_names => true)\n\tend", "def show\n user = User.find_by(uid: params[:id])\n if user\n puts 'USER FOUND'\n render json: user\n else\n puts 'NO USER'\n render json: 'no user'.to_json\n end\n end", "def show\n render json: UserService.get_user(params[:id]), includes: 'questions, answers'\n end", "def index\n @users = User.all(limit: 100)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users.as_json(user: current_user) }\n end\n end", "def index\n render :json => User.all, status: 200\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users, status: :ok\n end", "def show\n @users = User.find(params[:id])\n if @users\n respond_to do |format|\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n else\n head :not_found\n end\n end", "def index\n @users = User.all\n\n render json: @users\n end", "def index\n @users = User.all\n\n render json: @users\n end" ]
[ "0.81046426", "0.7703556", "0.77011716", "0.76262826", "0.7582106", "0.74818", "0.7461394", "0.7446168", "0.730656", "0.7300699", "0.72902125", "0.72781444", "0.72358584", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.7225407", "0.7225407", "0.7225407", "0.7225407", "0.7225407", "0.7225407", "0.7225407", "0.7225407", "0.72222257", "0.72165024", "0.72137505", "0.72096044", "0.71930283", "0.7182953", "0.7182144", "0.7182144", "0.7180289", "0.71750754", "0.7173851", "0.71640617", "0.71636444", "0.71453786", "0.7145053", "0.7129776", "0.71256554", "0.71160513", "0.7095665", "0.70941204", "0.70772994", "0.7070785", "0.7070607", "0.7063351", "0.70552826", "0.7025071", "0.7014598", "0.70047677", "0.6998373", "0.69910055", "0.6984177", "0.6979766", "0.6972448", "0.6972228", "0.6968384", "0.69666255", "0.6956339", "0.69506294", "0.6945614", "0.6943135", "0.69351804", "0.6932212", "0.6932212", "0.6932212", "0.6932212", "0.6927094", "0.69255126", "0.6925136", "0.6917375", "0.6907744", "0.68947464", "0.6882589", "0.6875701", "0.68749416", "0.68633634", "0.6861618", "0.6858055", "0.6855495", "0.68530583", "0.685255", "0.685255", "0.685255", "0.685255", "0.685255", "0.685255", "0.685255", "0.685255", "0.685255", "0.685255", "0.6849599", "0.6847195", "0.6847074", "0.6847074" ]
0.0
-1
POST /users POST /users.json
def create @user = User.new(user_params) respond_to do |format| if @user.save format.html { redirect_to login_url, notice: '注册成功,可以登录了!' } format.json { render :show, status: :created, location: @user } else format.html { render :new } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end", "def post body=nil, headers={}\n @connection.post \"users.json\", body, headers\n end", "def create\n # render json: params\n render json: Users.create(params[\"user\"])\n end", "def create_user(params:)\n parse(JSON.parse(connection.post(\"users\", params.to_json).body))\n end", "def create\n user = User.create(user_params) \n render json: user, status: :created\n end", "def create\n user = User.new(user_params)\n if user.save\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(form_params)\n\n respond_to do |format|\n if @user.save\n format.json { render json: { users: @user }, status: :created }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = User.new(\n username: user_params[:username],\n password: user_params[:password])\n if user.save\n create_example_collection(user)\n render json: user, except: [:password_digest, :created_at, :updated_at]\n else\n render json: {errors: user.errors.full_messages}\n end\n end", "def create\n user= User.create(user_params)\n render json: user\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n\t\t@user = User.new(users_params)\n\t\tif @user.save\n\t\t\tjson_response(@user, \"User is created Successfully.\")\n\t\telse\n\t\t\trender json: {message: @user.errors.full_messages.join(\" \")}, status: 400\n\t\tend\t\t\n\tend", "def create\n user = User.new(@user_info)\n if user.save && user.errors.empty?\n render json: { status: 200, data: UserSerializer.new(user).as_json }\n else\n render json: { status: 400, error: user.errors.full_messages }\n end\n end", "def create\n user = User.create(user_params)\n if user.valid?\n render json: user\n else\n render json: user.errors, status: :unprocessable_entity\n end\n end", "def create(options = {})\n request(:post, '/users.json', default_params(options))\n end", "def create\n @user = User.new user_params(params[:user])\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new user_params(params[:user])\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.create user_params\n \n if @user.save\n respond_with(@user) do |format|\n format.json {render}\n end\n end\n end", "def create\n @user = User.new(user_params(params))\n \n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params(params))\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params(params))\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create_user\n @user = User.new(user_params)\n if @user.save\n render json: UserSerializer.new(@user).serialized_json\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = @application.users.create(user_params)\n\n if @user.valid?\n render json: @user, status: :created, location: api_application_user_path(@application,@user)\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n user = User.create(user_params)\n if user.save\n render json: user\n else\n render json: user.errors, status: :bad\n end\n end", "def create\n r = @api.create_user(user_params)\n respond_to do |format|\n if r.code == 201\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\n else\n response = JSON.parse(r.body)\n format.html { redirect_to users_url, alert: response['message']}\n end\n end\n end", "def create\n\n puts '-----------------------create in user controller'\n\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: UserSerializer.new(@user).serialized_json\n else\n render json: { error: I18n.t('user_create_error') }, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n if @user.save\n render json: { user: @user, success: 'User registration successful' }\n else\n render json: { error: 'User registration unsuccessful' }\n end\n end", "def create\n @user = User.new(user_params)\n \n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n\t\tputs user_params\n\t\tuser = User.new(user_params)\n\t\tif user.save\n\t\t\trender json: { user: user, status: :success }\n\t\telse\n\t\t\trender json: { status: :failure, errors: user.errors.full_messages.join('') }\n\t\tend\n\tend", "def create\n\t\t@user = User.new(user_params)\n\t\tif @user.save\n\t\t\trender json: @user, status: :created, location: @user\n\t\telse\n\t\t\trender json: @user.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def add_user(name, value)\n self.class.post(\"/users/#{name}\",\n body: value,\n headers: {\n 'Content-Type' => 'application/json; charset=UTF-8',\n Connection: 'keep-alive',\n Accept: 'application/json, text/plain, */*'\n })\n end", "def create\n user = User.new(user_params)\n\n respond_to do |format|\n if user.save\n render json: user, status: :ok\n else\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = current_user.users.build(user_params)\n\n if @user.save\n render json: @user\n else\n @user_items = []\n end\n end", "def create\n user = User.new(user_params)\n render json: { status: 200, msg: 'User was created.', data: \"User Id #{user.id}\" } if user.save\n end", "def create\n @users = User.new(params[:user])\n\n respond_to do |format|\n if @users.save\n format.html { redirect_to @users, notice: 'Regist was successfully created.' }\n format.json { render json: @users, status: :created, location: @users }\n else\n format.html { render action: \"new\" }\n format.json { render json: @users.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = User.new(user_params)\n if user.save\n render :json => user, :status => :created\n else\n render :json => {:ok => false, :message => user.errors}, :status => :unprocessable_entity\n end\n end", "def create\n logger.debug user_params\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :ok\n else\n render json: @user.errors, status: :not_acceptable\n end\n end", "def create\n user = User.create(user_params)\n render json: user, message: 'user succefully create', status: 200\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n\n up = user_params\n\n if up[:name].present?\n up[:first_name] = up[:name].split(' ')[0]\n up[:last_name] = up[:name].split(' ')[1]\n up.delete :name\n end\n @user = User.new(up)\n\n respond_to do |format|\n if @user.save\n # render json: {user: user, token: token}\n\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: api_user_url(@user)}\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = User.new(user_params)\n if user.save\n render json: {status: \"Se creo el usuario\"}, status: :ok\n else\n render json: {status: \"Error al crear el usuario\", errors: user.errors }, status: :unprocessable_entity\n end\n end", "def create\n user = User.new(params[:user].permit(:username))\n if user.save\n render json: user\n else\n render json: user.errors.full_messages, status: :unprocessable_entity\n end\n end", "def create\n puts '>>> params:'\n puts params.inspect\n @user = User.new(params[:user])\n puts '>>> User:'\n puts @user.inspect\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n \tdata = { data: @user, status: :created, message: \"User was successfully created.\" }\n render :json => data\n else\n \tdata = { data: @user.errors, status: :unprocessable_entity }\n render :json => data\n end\n end", "def create\n user_details = params.permit(:first_name, :last_name, :email)\n success = User.create(user_details)\n\n render json: { success: success }\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user.as_json(only: [:email, :authentication_token]), status: :created\n else\n head(:unprocessable_entity)\n end\n end", "def create_user\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n post(\"users.json\", params)\n end", "def create\n @user = User.new(params[:user])\n\n if @user.save\n respond_to do |format|\n format.json { render :json => @user.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { redirect_to :action => :index }\n end\n else\n respond_to do |format|\n format.json { render :text => \"Could not create user\", :status => :unprocessable_entity } # placeholder\n format.xml { head :ok }\n format.html { render :action => :new, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n if @user.save\n render :ok, json: @user.to_json\n else\n @errors = @user.errors.full_messages\n render json: { message: @errors }, status: :unauthorized\n end\n end", "def create\n puts params\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user.as_json(user: current_user), status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = User.new(user_params)\n if user.save\n render json: {status: 200, msg: 'User was created.'}\n else\n render json: {errors: user.errors.messages}\n end\n end", "def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, :notice => 'User was successfully created.' }\n format.json { render :json => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new({name: params[:name], email: params[:email], password: params[:password], photo: params[:photo]})\n @user.save\n render json:@user\n end", "def create\n user = User.create(user_params)\n\n if user.valid?\n render json: {user: UserSerializer.new(user), token: encode_token(user.id)}\n else\n render json: user.errors.full_messages\n end\n end", "def create\n\t\tresp = {} \n user = User.create(user_params)\n \tif user.valid?\n if user.save\n return render :json => user.as_json\n end\n end\n render json: user.errors.full_messages \n\tend", "def create\n\t\tnew_user = User.new(user_params)\n\t\tif new_user.save\n\t\t render status: 200, json: {\n\t\t \tstatus: 200,\n\t\t message:\"New User Created\",\n\t\t response: {\n\t\t name: new_user.name,\n\t\t email: new_user.email,\n\t\t id: new_user.id,\n\t\t facebook_id: new_user.facebook_id,\n\t\t device_id: new_user.device_id,\n\t\t authentication_token: new_user.authentication_token\n\t\t }\n\t\t \n\t\t }.to_json\n\t\telse\n\t\t render status: 404, json: {\n\t\t \tstatus: 404,\n\t\t errors: new_user.errors\n\t\t }.to_json\n\t\tend\n\tend", "def post_users_with_http_info(users, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UsersApi.post_users ...'\n end\n # verify the required parameter 'users' is set\n if @api_client.config.client_side_validation && users.nil?\n fail ArgumentError, \"Missing the required parameter 'users' when calling UsersApi.post_users\"\n end\n # resource path\n local_var_path = '/users'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(users) \n\n # return_type\n return_type = opts[:return_type] || 'User' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UsersApi#post_users\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create_user(options = {})\n post \"/users\", options\n end", "def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save \n format.html { redirect_to users_url, notice: \"User #{@user.name} was successfully created.\" }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n user = User.new(user_params)\n\n if user.save\n\n render json: {status: 200, msg: 'User was created.'}\n\n else \n render json: {\n errors: user.errors.full_messages\n }, status: :unprocessable_entity\n\n end\n\n end", "def create_user(body)\n post 'create_user', body\n end", "def create\n @user = User.new(user_params)\n @user.email = params[:email].downcase\n if @user.save\n render json: @user, status: 200\n else\n render json: { errors: @user.errors.full_messages }, status: 400\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json:@user\n elsif @user.errors\n render json: {error: {code: 400, server_message: @user.errors}}, status: :bad_request\n else\n render json: {error: {code: 500, message: \"Could not save user\", server_message: @user.errors}}, status: :internal_server_error\n end\n\n end", "def create\n user = User.new(user_params)\n\n if user.valid?\n user.save\n render json: {user: user, token: encode_token({user_id: user.id})}\n else\n render json: {error: \"Failed to create the user\"}\n end\n end", "def create\n @user = User.new(user_params)\n @user.save\n respond_with @user\n end", "def create\n @user = User.new(user_params)\n render json: @user && return if @user.save\n\n render json: { error: \"Unable to save user: #{@user.errors.messages}\" }, status: 400\n end", "def create\n params[:user][\"_id\"] = params[:user][:name]\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save()\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_user(attributes)\n post(\"/v1/users\", attributes)\n end", "def create\n user = User.new(user_params)\n\n # if user is saved sucessfully it will return user and ith status 201 for created\n if user.save\n render json:user,status: :created\n #if request is properly served but data is wrong it ll give ubprocessable_entity with code 422\n else\n render json: user.errors, status: :unprocessable_entity\n end \n end", "def create\r\n @user = User.new(params[:user])\r\n\r\n respond_to do |format|\r\n if @user.save\r\n format.html { redirect_to users_path, notice: 'Os dados do usuário foram salvos com sucesso!' }\r\n format.json { render json: @user, status: :created, location: @user }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @user.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @user = User.new(\n first_name: params[:first_name],\n last_name: params[:last_name],\n birth_date: params[:birth_date],\n height: params[:height],\n weight: params[:weight],\n user_name: params[:user_name],\n password: params[:password],\n password_confirmation: params[:password_confirmation],\n facebook_url: params[:facebook_url],\n twitter_url: params[:twitter_url],\n instagram_url: params[:instagram_url],\n address: params[:address],\n email: params[:email]\n ) \n if @user.save!\n render 'successful.json.jb', status: :created\n else\n render 'unsuccessful.json.jb', status: :bad_request\n end\n end", "def post(hash)\n HttpClient::Preconditions.assert_class('hash', hash, Hash)\n @client.request(\"/users\").with_json(hash.to_json).post { |hash| Apidoc::Models::User.new(hash) }\n end", "def create\n user = User.create!(user_params)\n session[:user_id] = user.id\n render json: user, status: :created\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: {message: \"user create successfuly\"}\n else\n render json: {message: \"Error\"}\n end \n end", "def create\n # Insert new user in database\n user = User.new(user_params)\n\n if user.save\n # On success, send token information to authenticate user\n token = create_token(user.id, user.username)\n render json: {status: 200, token: token, user: user}\n # render json: @user, status: :created, location: @user\n else\n render json: user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(params[:user])\n @user.status = 'active'\n\n respond_to do |format|\n if @user.save\n format.json { render :json => @user, :status => :created }\n format.html { redirect_to(users_path) }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n respond_with(@user, location: users_url, notice: 'User was successfully created.')\n else\n respond_with(@user)\n end\n end", "def create\n user = User.new(user_params)\n \n if user.save\n token = JsonWebToken.encode(user_id: user.id)\n render json: { auth_token: token, user: AuthUserSerializer.new(user).serializable_hash }, status: 201\n else \n render json: { errors: user.errors.full_messages }, status: 400\n end\n end", "def create\n @user = User.new(params[:user])\n puts params[:user]\n respond_to do |format|\n if @user.save\n format.html { redirect_to :users, notice: 'Registration successful.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render :show, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render :show, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n user = User.create(user_params)\n if user.valid?\n user.username.downcase\n @token = issue_token(user)\n list = List.create(name: user.username)\n list.user_id = user.id\n user.save\n list.save\n render json: { user: UserSerializer.new(user), jwt: @token }, status: :created \n else \n render json: { error: user.errors.full_messages }, status: :not_acceptable\n end \n end", "def create\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user_response = API::V1::Users.authenticate params.as_json\n if user_response.success?\n json = HashWithIndifferentAccess.new(user_response.parsed_response)\n auth_response = API::V1::Auth.issue json[:data]\n respond_with auth_response.body, auth_response.code\n else\n respond_with nil, :unauthorized\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render :json => { :status => 0 }\n else\n render :json => { :status => 1, :msg => @user.errors}\n end\n end", "def create\n @user = User.new(user_params)\n if @user.save\n auth_token = Knock::AuthToken.new payload: { sub: @user.id }\n render json: { username: @user.username, jwt: auth_token.token }, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n authorize :user, :create?\n @user = User.new(user_params)\n @user.save\n\n respond_to do |format|\n format.html\n format.json { render :json => @user, status: 200 }\n end\n end", "def post_accounts(json_hash)\n @options = {:path => '/users.json',\n :body => json_hash[:json]}.merge(@options)\n\n request(\n :expects => 201,\n :method => :post,\n :body => @options[:body]\n )\n end", "def create\n user = User.new(username: params[:username])\n if user.save\n payload = {'user_id': user.id}\n token = JWT.encode(payload, 'chatapp')\n render json: {\n user: user,\n token: token\n }\n else \n render json: { message: 'There was an error creating your account' }\n end\n end", "def create\n user = User.create!(user_params)\n if user\n session[:user_id] = user.id\n render json: user, status: :created\n else\n render json: { errors: user.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def create\r\n @user = User.new user_params\r\n\r\n if @user.save\r\n render json: @user, serializer: SessionSerializer, root: nil\r\n else\r\n render json: { errors: @user.errors }, status: :unprocessable_entity\r\n end\r\n end", "def create\n user = User.new(user_params)\n if user.save\n render json: { status: 'OK', msg: 'User was created.', error: 'nil' },\n status: :created\n else\n not_good(422)\n end\n end" ]
[ "0.77178615", "0.751936", "0.73831904", "0.72412014", "0.719768", "0.7140784", "0.7103724", "0.70586866", "0.7041747", "0.70236677", "0.7003012", "0.7002012", "0.7002012", "0.7002012", "0.6992873", "0.6990429", "0.6980341", "0.69790155", "0.6978697", "0.6978697", "0.69763535", "0.6962294", "0.695194", "0.694517", "0.694517", "0.69202316", "0.6917723", "0.6913987", "0.69009656", "0.68981147", "0.6894472", "0.68896914", "0.68803185", "0.6879835", "0.6879686", "0.6879056", "0.6877317", "0.68685913", "0.68557876", "0.6850744", "0.68438756", "0.68140614", "0.68034494", "0.6777382", "0.6776193", "0.6767001", "0.675744", "0.6747358", "0.67386395", "0.67346144", "0.6733921", "0.6720284", "0.6710678", "0.6670139", "0.6658037", "0.665726", "0.6653911", "0.66385335", "0.66329634", "0.6619689", "0.6614647", "0.66141474", "0.6597641", "0.6590211", "0.65788305", "0.6578527", "0.65731233", "0.6572486", "0.65565205", "0.6553143", "0.6551308", "0.65460217", "0.6540497", "0.65400976", "0.6538745", "0.6534923", "0.65333605", "0.652561", "0.6510388", "0.6508043", "0.65071523", "0.65030766", "0.6489865", "0.6488904", "0.6487186", "0.6473134", "0.64718515", "0.6469831", "0.6469831", "0.6469282", "0.646749", "0.6461641", "0.6461577", "0.6461024", "0.645465", "0.6453074", "0.6449793", "0.6447059", "0.6446711", "0.6446099", "0.6441262" ]
0.0
-1
PATCH/PUT /users/1 PATCH/PUT /users/1.json
def update respond_to do |format| if @user.update(user_params) format.html { redirect_to @user, notice: '所有的信息都已经更新。' } else format.html { render :edit } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end", "def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end", "def update \n user = User.find(params[:id])\n # byebug\n user.update(user_params)\n\n render json: user\n end", "def update\n user = User.find(params[:id])\n\n # Use update with user_params to do a mass-assignment update and save. \n if user.update_attributes(user_params)\n render json: user\n else \n render json: user.errors.full_messages, status: :unprocessable_entity\n end\n end", "def update\n user = User.find_by(id: params[:id])\n user.update(user_params)\n render json: user\n end", "def update\n \trespond_to do |format|\n if @user.update(user_params)\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n\t \t\n end", "def update\n user = find_user\n user.update!(user_params)\n render json: user\n end", "def update\n if user.update(user_params)\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n end\n end", "def update\n if @api_v1_user.update(api_v1_user_params)\n head :no_content\n else\n render json: @api_v1_user.errors, status: :unprocessable_entity\n end\n end", "def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update\n @user = User.find(params[:id])\n\n if @user.update_attributes(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update_attributes(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update_user(options)\n patch(\"/user\", options, 3)\n end", "def modify_user(user)\n query_api_object Model::User, '/rest/user', user.to_hash, 'PUT'\n end", "def update\n user = User.find(params[:id])\n user.update(user_params)\n if user.valid?\n render json: user\n else\n render json: user.errors\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { render action: \"edit\"}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.role = params[:type]\n @user.save\n render json:@user\n end", "def update\n if @user.id == current_api_user.id\n if @user.update(user_params)\n render json: @user.as_json(except: [:updated_at]), status: :ok\n else\n render json: @user.errors, status: :bad_request\n end\n else\n render json: '', status: :forbidden\n end\n end", "def update\n if @user.update(user_params)\n render json: @user\n else\n render json: {error: \"Could not update user\"}\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n render json:@user\n else\n render json: { error: {code: 404, message: 'Invalid user' }}, status: :not_found\n end\n end", "def update\n user = User.find(params[:id])\n if user.update(params_user)\n render json: user, status: 200\n else\n render json: user.errors, status: 422\n end\n\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update user_params(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.save\n render json:@user\n end", "def updateUser\n options = {\n :body => params.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n results = HTTParty.put(\"http://192.168.99.101:4051/users/\"+@current_user[\"id\"].to_s, options)\n render json: results.parsed_response, status: results.code\n end", "def update\n user = @user_service.update_user(params[:id])\n render json: user, status: :ok\n end", "def update\n @user = User.find(params[:id]) \n \n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User #{@user.name} was successfully created.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n if @user.update(user_params)\n render json: @user, status: 200\n else\n render json: @user.errors, status: 422\n end\n end", "def update\n begin\n user = User.find(params[:user_id])\n if user.update(user_params)\n render json: { users: user }, status: :ok\n else\n render json: { errors: user.errors.messages }, status: 422\n end\n rescue => e\n render json: { errors: e.message }, status: 404\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if user.update(user_params)\n render json: user, status: :ok\n else\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params[:user]))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n @user.update_attributes(params[:user])\n respond_with @user\n end", "def update\n @user = User.find(params[:id])\n @user.update_attributes(params[:user])\n respond_with @user\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User was successfully updated.' }\n\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes_from_api(params[:user])\n format.html { redirect_to @user, :notice => 'User was successfully updated.' }\n format.json { render_for_api :user, :json => @user }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @user = current_org.users.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch_user(user_id, body)\n raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?\n raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty? || body.empty?\n path = \"#{users_path}/#{user_id}\"\n patch(path, body)\n end", "def update\n @user = User.find(params[:id])\n @user.update(user_params)\n render json: @current_user\n end", "def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend", "def update\n user = User.find(params[:id])\n render json: { status: 200, msg: 'User details have been updated.' } if user.update(user_params)\n end", "def modify_user(user)\n query_api_object User, \"/rest/user\", user.dump(), \"PUT\"\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_path, :notice => 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n user = User.find(params[:id])\n if user.update(user_params)\n render json: user\n else\n render json: user.errors.full_messages\n end\n end", "def update\n respond_to do |format|\n if @user.update(form_params)\n format.json { render json: { users: @user }, status: :ok, location: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user.update(user_params)\n respond_with @user\n end", "def update\n @user = user.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'user was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_user\n @user = User.find(params[:id])\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = get_user(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to root_url, notice: \"User #{@user.login_name} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @v1_user.update(v1_user_params)\n format.html { redirect_to @v1_user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @v1_user }\n else\n format.html { render :edit }\n format.json { render json: @v1_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @user.update(user_params)\n render json: @user, status: :ok\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, :notice => t('user.update_success') }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status=> :unprocessable_entity }\n end\n end\n end", "def update\n @user.update(user_params_update)\n json_response(@user)\n end", "def update\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to users_path }\n format.json { render :json => @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user.as_json(user: current_user), notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = selected_user\n if @user.update(users_params)\n render 'api/users/show'\n else\n render json: @user.errors.full_messages, status: 422\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.json { head :ok }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to root_path}\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = V1::User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'V1::User was successfully updated.'\n format.html { redirect_to(@user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update \n user = User.where(:id => current_user.user)\n if user.update(user_params)\n render :json => {:user => user }\n else\n render :json => {:error => user.errors.full_messages.first}\n end\nend", "def update\n\t\tif @user.update(user_params)\n\t\t\trender json: @user\n\t\telse\n\t\t\trender json: @user.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def update\n @user = User.find(params[:id])\n \n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, :notice => 'User was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(id, params = {})\n request(:put, \"/users/#{id}\", body: params)\n end", "def update\n @user = current_api_user\n unless @user.update(user_params)\n render json: { error: @user.errors.full_messages.to_sentence }, status: :not_found\n end\n end", "def update\n # not_found unless @user\n # @user = User.get(params[:id]) || not_found\n\n respond_to do |format|\n if @user.update(params[:user])\n format.html { redirect_to @user, :notice => 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, :notice => \"This user was successfully updated!\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n user = User.find(params[:id])\n if user.update(user_params)\n render json: {\n status: 'OK',\n msg: 'User details have been updated.',\n error: 'nil'\n }, status: :accepted\n else\n not_good(406)\n end\n end", "def update\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: I18n.t(:users_update) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = ::User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @todo = Todo.find(params[:todo][:id])\n if @todo.update_attributes(user_params)\n render json: @todo\n else\n render nothing: true, status: :bad_request\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to user_path(@user), notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update \n @current_user.update(user_params)\n render json: @current_user\n end", "def update\n @user = User.find(params[:id])\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.72248507", "0.7128768", "0.7003289", "0.6902831", "0.68211025", "0.681476", "0.6707567", "0.6692646", "0.667998", "0.66728854", "0.66717863", "0.666447", "0.666447", "0.66587144", "0.66587144", "0.6653841", "0.6647832", "0.6642772", "0.6640692", "0.6634225", "0.66175383", "0.66145873", "0.6609172", "0.66066575", "0.6582737", "0.658135", "0.6581107", "0.65785617", "0.65604025", "0.6558004", "0.6558004", "0.65429235", "0.6536029", "0.6515055", "0.65137506", "0.650549", "0.65044487", "0.65044487", "0.6500681", "0.64674795", "0.64656246", "0.64632845", "0.6452952", "0.6448593", "0.64431345", "0.6440601", "0.64367294", "0.6427621", "0.6427621", "0.6426918", "0.6426237", "0.6425996", "0.6423854", "0.6423854", "0.6423452", "0.6417562", "0.64143384", "0.64105093", "0.64043516", "0.6404183", "0.6397541", "0.63935435", "0.6389889", "0.6389614", "0.6386804", "0.63830155", "0.6382917", "0.6382128", "0.63813", "0.63772064", "0.63738424", "0.63737214", "0.6372401", "0.6372274", "0.63699526", "0.63624233", "0.635997", "0.6359779", "0.63555807", "0.6355325", "0.6349326", "0.6342009", "0.6333391", "0.633307", "0.63277715", "0.6326328", "0.6326328", "0.6326328", "0.6326328", "0.6326328", "0.6326328", "0.6326328", "0.6326328", "0.6326328", "0.6326328", "0.6326328", "0.6326328", "0.6326328", "0.6326328", "0.6326328", "0.6326328" ]
0.0
-1
DELETE /users/1 DELETE /users/1.json
def destroy @user.destroy respond_to do |format| format.html { redirect_to users_url, notice: '用户已删除。' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end", "def delete\n render json: Users.delete(params[\"id\"])\n end", "def delete\n @user.destroy\n respond_to do |format|\n format.html { redirect_to v1_resources_users_all_path, notice: 'User was deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end", "def destroy\n @user = V1::User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(v1_users_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n \"\"\"\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n \"\"\"\n end", "def destroy\n debugger\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user.destroy\n format.json { head :no_content }\n end", "def destroy\n user = User.find(params[:id]) # from url, nothing to do with table\n user.destroy\n render json: user\n end", "def destroy\n @user.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find_by_id_or_username params[:id]\n @user.destroy\n render api_delete @user\n end", "def destroy\n @user = user.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def delete_user\n @user = User.find(params[:id])\n if @user.destroy\n render :json => @user\n else\n render :json => @user.errors.full_messages\n end\n end", "def destroy\n @v1_user.destroy\n respond_to do |format|\n format.html { redirect_to v1_users_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n \n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.78750724", "0.77518034", "0.7713981", "0.7610077", "0.747295", "0.74073994", "0.74073994", "0.7369968", "0.7346072", "0.7340465", "0.7328618", "0.7309635", "0.73095363", "0.7306841", "0.7297868", "0.72917855", "0.7291585", "0.7289111", "0.7284347", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7250935", "0.7245172", "0.7242216", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177", "0.7232177" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @user = User.find( params[:id] ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
category_id min_price, max_price deadline
def filter page = params[:page] || 1 want_ads = WantAd.active.joins(:user) .joins("LEFT OUTER JOIN addresses a ON a.addressable_id = want_ads.id and a.addressable_type = 'WantAd'") .joins("LEFT OUTER JOIN cities ON cities.id = a.city_id") .select('users.name as user_name, cities.name as city_name, want_ads.*') want_ads = want_ads.where(category_id: params[:category_id]) if params[:category_id].present? want_ads = want_ads.where("cities.id = #{params[:city_id]}") if params[:city_id].present? want_ads = want_ads.where("price >= #{params[:min_price]}") if params[:min_price].present? want_ads = want_ads.where("price <= #{params[:max_price]}") if params[:max_price].present? want_ads = want_ads.where("deadline <= '#{params[:date]}'") if params[:date].present? want_ads = want_ads.where("title ILIKE '%#{params[:search]}%' OR description ILIKE '%#{params[:search]}%'") if params[:search].present? want_ads = want_ads.order("#{params[:sort_by]}") if params[:sort_by].present? want_ads = want_ads.page(page) want_ads.map do |want_ad| { id: want_ad.id, title: want_ad.title, description: want_ad.description, deadline: want_ad.deadline, owner_name: want_ad.user_name, city_name: want_ad.city_name, price: want_ad.price } end render json: { want_ads: want_ads, number_pages: want_ads.total_pages, current_page: page } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_max_price\n if price_min.blank?\n errors.add(:max_price, \"Minimum Price can't be blank \")\n elsif (price_min.present? and price_max.present?) and price_max < price_min\n errors.add(:max_price, \"can't be less than minimum price\")\n end\n end", "def set_min_max_price_values\n price_facet_rows = @products.facet(:price).rows.sort_by{|row| row.value}\n @min_price = price_facet_rows.first.try(:value) || 0\n @max_price = price_facet_rows.last.try(:value) || 1000\n end", "def centry_ids_prices\n ordered_variants = ::Product.where.not(id_product_centry: [nil, \"\"]).order(\"id_product_centry, price\").pluck(:id_product_centry, :price)\n ordered_variants.group_by{|pid, price| pid}.map { |pid, price| ENV[\"UPDATE_WITH_MAX_PRICE\"] == \"true\" ? price.max() : price.min()}\n end", "def price_between(products, min, max)\n# list = []\n# products.each do |product|\n# if product[:price] > min && product[:price] < max\n# list << product\n# end \n# end\n# list\n# end\n products.select do |product|\n product[:price] > min && product[:price] < max \n end\nend", "def price_is_right(bids, actual_retail_price)\n bids.select{|bid|bid<=actual_retail_price}.max\n\nend", "def on_2(prices)\n max_profit = 0\n min_valley = prices.max\n\n prices.each do |number|\n if number < min_valley\n min_valley = number\n elsif number - min_valley > max_profit\n max_profit = number - min_valley\n end\n end\n\n max_profit\n end", "def ids_between_values(min_value, max_value, options = {:subject => :placeholder} )\n matching_recipes = []\n if [:price, :kcal].include?(options[:subject])\n if min_value > max_value\n tmp = min_value\n min_value = max_value\n max_value = tmp\n end\n \n if options[:subject] == :price\n if min_value > 0\n matching_recipes = self.all.reject {|recipe| (min_value..max_value).include?(recipe.calculated_price) == false }\n else\n matching_recipes = self.all.reject {|recipe| recipe.calculated_price < max_value }\n end\n else\n if min_value > 0\n matching_recipes = self.all.reject {|recipe| (min_value..max_value).include?(recipe.number_of_kcal_per_meal) == false }\n else\n matching_recipes = self.all.reject {|recipe| recipe.number_of_kcal_per_meal < max_value }\n end\n end \n end\n matching_recipes.collect(&:id)\n end", "def calculate_price\t\n\t\tnumber_of_days = calculate_number_of_days\n\t\tif number_of_days == FIRST_RANGE_LOWER_INTERVAL\n\t\t\tprice_time_component = @car.price_per_day\n\t\telsif number_of_days > FIRST_RANGE_LOWER_INTERVAL && number_of_days <= SECOND_RANGE_LOWER_INTERVAL\n\t\t\t# price per day decreases by 10% after 1 day\n\t\t\tprice_time_component = @car.price_per_day + (@car.price_per_day * (number_of_days - FIRST_RANGE_LOWER_INTERVAL) * 0.9)\n\t\telsif number_of_days > SECOND_RANGE_LOWER_INTERVAL && number_of_days <= THIRD_RANGE_LOWER_INTERVAL\n\t\t\t# price per day decreases by 30% after 4 days\n\t\t\tprice_time_component = @car.price_per_day + (@car.price_per_day * (SECOND_RANGE_LOWER_INTERVAL - FIRST_RANGE_LOWER_INTERVAL) * 0.9) +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(@car.price_per_day * (number_of_days - SECOND_RANGE_LOWER_INTERVAL) * 0.7)\n\t\telse\n\t\t\t# price per day decreases by 50% after 10 days\n\t\t\tprice_time_component = @car.price_per_day + (@car.price_per_day * (SECOND_RANGE_LOWER_INTERVAL - FIRST_RANGE_LOWER_INTERVAL) * 0.9) +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(@car.price_per_day * (THIRD_RANGE_LOWER_INTERVAL - SECOND_RANGE_LOWER_INTERVAL) * 0.7) +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(@car.price_per_day * (number_of_days - THIRD_RANGE_LOWER_INTERVAL) * 0.5)\n\t\tend\n\t\tprice_distance_component = @car.price_per_km * @distance\n\t\tprice_time_component.to_i + price_distance_component\n\tend", "def calculate_price\t\n\t\tnumber_of_days = calculate_number_of_days\n\t\tif number_of_days == FIRST_RANGE_LOWER_INTERVAL\n\t\t\tprice_time_component = @car.price_per_day\n\t\telsif number_of_days > FIRST_RANGE_LOWER_INTERVAL && number_of_days <= SECOND_RANGE_LOWER_INTERVAL\n\t\t\t# price per day decreases by 10% after 1 day\n\t\t\tprice_time_component = @car.price_per_day + (@car.price_per_day * (number_of_days - FIRST_RANGE_LOWER_INTERVAL) * 0.9)\n\t\telsif number_of_days > SECOND_RANGE_LOWER_INTERVAL && number_of_days <= THIRD_RANGE_LOWER_INTERVAL\n\t\t\t# price per day decreases by 30% after 4 days\n\t\t\tprice_time_component = @car.price_per_day + (@car.price_per_day * (SECOND_RANGE_LOWER_INTERVAL - FIRST_RANGE_LOWER_INTERVAL) * 0.9) +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(@car.price_per_day * (number_of_days - SECOND_RANGE_LOWER_INTERVAL) * 0.7)\n\t\telse\n\t\t\t# price per day decreases by 50% after 10 days\n\t\t\tprice_time_component = @car.price_per_day + (@car.price_per_day * (SECOND_RANGE_LOWER_INTERVAL - FIRST_RANGE_LOWER_INTERVAL) * 0.9) +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(@car.price_per_day * (THIRD_RANGE_LOWER_INTERVAL - SECOND_RANGE_LOWER_INTERVAL) * 0.7) +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(@car.price_per_day * (number_of_days - THIRD_RANGE_LOWER_INTERVAL) * 0.5)\n\t\tend\n\t\tprice_distance_component = @car.price_per_km * @distance\n\t\tprice_time_component.to_i + price_distance_component\n\tend", "def validate_consumption_and_production_prices\n %i[marginal_costs max_consumption_price].each do |price_attribute|\n value = public_send(price_attribute)\n\n next if value.nil?\n\n if merit_order&.type != :flex\n errors.add(price_attribute, 'is only allowed when the merit_order type is \"flex\"')\n next\n end\n\n errors.add(price_attribute, 'must not be less than zero') if value.negative?\n end\n end", "def price_range\n return @price_range if @price_range\n return @price_range = ['N/A', 'N/A'] if active_variants.empty?\n @price_range = active_variants.minmax {|a,b| a.price <=> b.price }.map(&:price)\n end", "def budget\n if @budget\n @budget\n else\n if self.budget_category == \"< $30/Day\"\n @budget = 1\n elsif self.budget_category == \"$30-75/Day\"\n @budget = 2\n elsif self.budget_category == \"$75-150/Day\"\n @budget = 3\n elsif self.budget_category == \"> $150/Day\"\n @budget = 4\n end\n end\n end", "def max_profit(prices)\n max_profit = 0\n min_price = prices[0]\n \n prices.each do |price|\n min_price = [min_price, price].min\n max_profit = [max_profit, price - min_price].max\n end\n \n max_profit\nend", "def price_range\n return @price_range if @price_range\n return @price_range = ['N/A', 'N/A'] if active_variants.empty?\n @price_range = active_variants.inject([active_variants.first.price, active_variants.first.price]) do |a, variant|\n a[0] = variant.price if variant.price < a[0]\n a[1] = variant.price if variant.price > a[1]\n a\n end\n end", "def price_excl_options\n duration_price = 0\n (1..duration).each do |day|\n if day == 1\n duration_price += @selected_car.price_per_day\n # price per day decreases by 10% after 1 day\n elsif day.between?(2,4)\n duration_price += @selected_car.price_per_day * 0.9\n # price per day decreases by 30% after 4 days\n elsif day.between?(5,10)\n duration_price += @selected_car.price_per_day * 0.7\n # price per day decreases by 50% after 10 days\n else\n duration_price += @selected_car.price_per_day * 0.5\n end\n end\n\n price_excl_options = duration_price + @distance * @selected_car.price_per_km\n price_excl_options.to_i\n end", "def validate_price_points(pricePoints)\n if pricePoints != pricePoints.uniq \n errors.add(:base, \"Cannot have duplicate price points!\")\n elsif pricePoints != pricePoints.sort\n errors.add(:base, \"Price range is not sufficient, must order smallest to largest!\") \n else \n return pricePoints\n end\n end", "def max_profit(prices)\n min_price = prices[0]\n max_pro = 0 \n price.each do |price|\n if price <= min_price\n min_price = price\n elsif price - min_price > max_pro\n max_pro = price - min_price\n end\n end\n max_pro\nend", "def discount_price_cannot_be_greater_than_price_value\n if discount_price.present? && price.present? && discount_price > price\n errors.add(:discount_price, \"can't be greater than price value\")\n end\n end", "def price_at_maximum\n qty = breaks.last.minimum\n qty -= 1 unless breaks.empty?\n brk = breaks.last.marginal.nil? ? breaks[-2] : breaks[-1]\n return nil unless brk\n brk.price_at(qty)\n end", "def get_max_profit(prices)\n raise IndexError(\"Must be at least 2 prices\") if prices.length < 2\n #initialize a current_max_profit and current_min\n current_min = prices[0]\n current_max_profit = prices[1] - prices[0]\n\n prices.each do |price|\n #calculate the potential profit and check if it's larger than current max profit\n potential_profit = price - current_min\n current_max_profit = [potential_profit, current_max_profit].max\n #update current_min\n current_min = [current_min, price].min\n end\n current_max_profit\nend", "def discount_for_category(line_items)\n item_counter = max_items || 1000\n product_or_group = apply_to_type == 'product' ? apply_to_product.name : apply_to_group\n line_items\n .select { |l| l.send(apply_to_type).to_s == product_or_group }\n .sort_by { |l| -l.unit_price }\n .take(max_items.nil? ? 1000 : max_items)\n .reduce(0) do |sum, line_item|\n total_quantity = max_items.nil? ? line_item.quantity : [item_counter, line_item.quantity].min\n if item_counter < 1\n # If we've gone over our limit for max_items, don't add anymore to the discount\n sum\n else\n item_counter -= total_quantity\n total_amount = amount * total_quantity\n if discount_type == 'fixed'\n sum + (total_amount > line_item.total_price ? line_item.total_price : total_amount)\n elsif discount_type == 'percentage'\n sum + (line_item.unit_price * total_quantity * amount * 0.01).round(2)\n end\n end\n end\n end", "def mid_price\n price\n end", "def min_bid(company)\n return 0 unless company\n\n high_bid = highest_bid(company)&.price || 0\n [high_bid + min_increment, company.min_bid].max\n end", "def validate_discount_range_values\n curr_val = curr_per = 0\n first = true\n discount_values.each do |val, per|\n if per > 100\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.invalid_range_percentage\"))\n break\n end\n unless first\n if val <= curr_val or per <= curr_per\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.invalid_range_secuence\"))\n break\n end\n end\n first = false\n curr_val, curr_per = val, per\n end\n end", "def find minmax, options = {}\n\t\tproducts, price_type = parse_options options\n\t\tproducts.group_by(&price_type).send(minmax).last\n\tend", "def price\n case category \n when 'book'\n unit_cost * 1.10\n when 'audiobook'\n unit_cost * 1.20\n when 'magazine'\n unit_cost * 1.15\n end\n end", "def minimum_price(price)\n set_limiting_value(:minimum, :price, price)\n end", "def official_answer(input)\n min_price = input[0]\n max_profit = 0\n\n input.each do |current_price|\n min_price = [min_price, current_price].min\n potential_profit = current_price - min_price\n max_profit = [max_profit, potential_profit].max\n end\n max_profit\nend", "def _item_price_in_category(which_category, capacity)\n item_prices_in_category = self.upgrade_options.select { |item_price| item_price[\"categories\"].find { |category| category[\"categoryCode\"] == which_category } }\n item_prices_in_category.find { |ram_item| ram_item[\"item\"][\"capacity\"].to_i == capacity}\n end", "def list_price\n support_product_number = type == 'hw' ? 'HA104A' : 'HA107A'\n year1 = PricingDbHpPrice.option_price(:product_number => support_product_number, :year => 1, :option_number => option_number)\n year3 = PricingDbHpPrice.option_price(:product_number => support_product_number, :year => 3, :option_number => option_number)\n year4 = PricingDbHpPrice.option_price(:product_number => support_product_number, :year => 4, :option_number => option_number)\n @list_price = [(year4 - year3)/BigDecimal(\"12.0\"), (year3 - year1)/BigDecimal(\"24.0\")].max\n end", "def stock_picker(prices) \n min_price = Float::INFINITY\n day_min_cost = 0\n max_price = -Float::INFINITY\n profit = -Float::INFINITY\n best_days = []\n\n prices.each_with_index do |price, day|\n if price < min_price \n min_price = price\n day_min_cost = day\n end\n \n if price - min_price > profit && day > day_min_cost\n max_price = price\n profit = price - min_price\n best_days = [day_min_cost, day]\n end\n end\n\n if best_days.empty?\n # In the case that the prices are decreasing order and there are no duplicates, the best days \n # to buy is the second to last day and the best day to sell is the last day\n best_days = [prices.length - 2, prices.length - 1]\n else\n best_days\n end\nend", "def ranged_lot_category_params\n params.require(:ranged_lot_category).permit(:name, :minimum_value, :maximum_value)\n end", "def price(price_range)\n set_range_parameter(:price, price_range)\n end", "def price_range\n prices = variants.collect(&:price).collect(&:to_f)\n format = \"%0.2f\"\n if prices.min != prices.max\n \"#{format % prices.min} - #{format % prices.max}\"\n else\n format % prices.min\n end\n end", "def keep_calculating\n self.max_price = broker.max_mortgage.price.to_i\n self.min_price = broker.min_mortgage.price.to_i\n self.rate = broker.max_mortgage.rate\n end", "def price_is_right(bids, actual_retail_price)\n diff = actual_retail_price\n best_bid = nil\n bids.each do |bid|\n\n highest = actual_retail_price - bid\n\n if highest > 0 && highest <= diff\n diff, best_bid = highest, bid\n end\n end\n\n best_bid\nend", "def min_next_bid_amount\n highest_bid_value = self.highest_bid.bid_amount \n if highest_bid_value.present? \n highest_bid_value+highest_bid_value*0.05\n else\n self.cost\n end\n end", "def max_profit(prices)\n max = 0\n min = (2**(0.size * 8 -2) -1)\n\n prices.each do |price|\n if price < min\n min = price\n else\n max = [max, price - min].max\n end\n end\n\n max\nend", "def total_cost\n return (date_range.end_date - date_range.start_date) * (200 * (1 - discount))\n end", "def shrink_boundaries(min_odds, max_odds)\n min_odds = quote.bid.odds + 0.005 if quote.bid\n max_odds = quote.ask.odds - 0.005 if quote.ask\n if min_odds > max_odds\n [min_odds, min_odds]\n else\n [min_odds, max_odds]\n end\n end", "def max_price\n Money.new(MAX_OFFER_CENTS, self.default_currency)\n end", "def enough_money?(maxAmount)\r\n self.price<=maxAmount\r\n end", "def align_budget\n if self.minbudget_realcurrency.nil?\n self.minbudget = nil\n elsif self.minbudget_realcurrency > 0\n self.minbudget = (self.minbudget_realcurrency / app_setting('grant_value_for_currency')).ceil\n else\n self.minbudget = 0\n end\n\n if self.maxbudget_realcurrency.nil?\n self.maxbudget = nil\n elsif self.maxbudget_realcurrency > 0\n self.maxbudget = (self.maxbudget_realcurrency / app_setting('grant_value_for_currency')).ceil\n else\n self.maxbudget = 0\n end\n end", "def set_minimum_price\n @minimum_price = MinimumPrice.find(params[:id])\n end", "def check_min_max\n\nend", "def maximum_price(price)\n set_limiting_value(:maximum, :price, price)\n end", "def costs_by_category(params = {})\n costs = Hash.new\n options = Hash.new\n params[:from] = self.activated_at if params[:from].blank?\n params[:to] = Time.now if params[:to].blank?\n\n payments.between(params[:from], params[:to]).closed.each do |payment|\n costs[payment.bill.category.name] = 0 if costs[payment.bill.category.name].blank?\n costs[payment.bill.category.name] += payment.amount\n end\n costs\n end", "def is_overbudget ( cruises ) \n\tfor cruise in cruises.each\n\t\ttotalprice = totalprice.to_i + cruise.price.to_i\n\t\ttotaldays = totaldays.to_i + cruise.length.to_i\n\tend\n\tif totalprice > $max_price || (totalprice/totaldays) > $max_ppn || cruises.length > $max_cruises\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def price_is_right(bids, actual_retail_price)\n\n best_bid = nil\n smallest_diff = nil\n\n bids.each do |bid|\n diff = actual_retail_price - bid\n\n if diff > 0\n if best_bid == nil or smallest_diff > diff\n smallest_diff = diff\n best_bid = bid\n end\n end\n end\n best_bid\nend", "def price_range?\n !(price_range.first == price_range.last)\n end", "def price_range?\n !(price_range.first == price_range.last)\n end", "def call_price(attrs)\n i_per_second_rate = attrs.fetch(:\"#{key}_initial_rate\").to_f / 60.0\n n_per_second_rate = attrs.fetch(:\"#{key}_next_rate\").to_f / 60.0\n # duration that will be on next calls monitoring run\n duration = attrs.fetch(:duration).to_i + MONITORING_INTERVAL # TODO: check if needed cast to int\n initial_interval = attrs.fetch(:\"#{key}_initial_interval\").to_i # TODO: check if needed cast to int\n next_interval = attrs.fetch(:\"#{key}_next_interval\").to_i # TODO: check if needed cast to int\n connect_fee = attrs.fetch(:\"#{key}_fee\").to_f\n vat = key == 'destination' ? attrs.fetch(:customer_acc_vat, 0).to_f : 0\n initial_interval_billing = connect_fee + initial_interval * i_per_second_rate\n next_interval_billing = (duration > initial_interval ? 1 : 0) * ((duration - initial_interval).to_f / next_interval).ceil * next_interval * n_per_second_rate\n (initial_interval_billing + next_interval_billing) * (1 + vat / 100.0)\n end", "def validation min, max\n\n end", "def stock_picker(prices)\n\t# Initialize everything to 0\n\tmin = 0\t\t\t# Day with lowest price so far\t\t\t\t\t\n\tbuy = 0\t\t\t# Buy day with best max_diff so far\n\tsell = 0\t\t# Sell day with best max_diff so far\n\tmax_diff = 0\t# Best value of prices[sell]-prices[buy]\n\t(1...prices.length).each do |i|\n\t\t# Go through each day - not necessary to do the first\n\t\tif prices[i] < prices[min]\n\t\t\t# If current price is less than current min:\n\t\t\tmin = i\t\t\t\t\t\t# Set as current min\n\t\tend\n\t\tdiff = prices[i] - prices[min]\t# Compare difference to current min\n\t\tif diff > max_diff\n\t\t\t# If it's better:\n\t\t\tbuy = min\t\t\t\t\t# Record min as day to buy\n\t\t\tsell = i\t\t\t\t\t# Record current day as day to sell\n\t\t\tmax_diff = diff\t\t\t\t# Record new max difference\n\t\tend\n\tend\n\t[buy, sell]\nend", "def price_setter(min, max)\n price_range = []\n (min..max).step(5) { |x| price_range.push(x) }\n return price_range.sample\nend", "def solution(a)\n return 0 if a.count <= 1\n \n max_profit = 0\n min_price = a.first\n a[1..-1].each { |price|\n max_profit = [max_profit, price - min_price].max\n min_price = [min_price, price].min\n }\n max_profit\nend", "def _item_prices_in_category(which_category)\n @virtual_server.upgrade_options.select { |item_price| item_price['categories'].find { |category| category['categoryCode'] == which_category } }\n end", "def sort_category_by_price(category)\n category.sort! {|a,b| a.price <=> b.price}\n end", "def availability start_time, end_time\n hours = ((end_time - start_time) / 3600).round - 1\n available = (0..hours).to_a.collect do |hour|\n best_selling_price_at(start_time + hour.hours, [start_time, end_time])\n end.compact\n\n available.length*1.0 / (hours+1)*1.0 * 100\n end", "def lowest_price\n has_price = 0\n has_price = $postings.select{|p| p[1][/(?<=\\$)\\d+/].to_i >= 1}\n cheap_post = has_price.min {|a,b| a[1][/(?<=\\$)\\d+/].to_i <=> b[1][/(?<=\\$)\\d+/].to_i}\n cheap_price = cheap_post[1][/(?<=\\$)\\d+/].to_i\n cheap_ads = has_price.select{|i| i[1][/(?<=\\$)\\d+/].to_i == cheap_price}\n list_apt(cheap_ads)\nend", "def stock_picker(stock_prices)\n best_margin = 0\n\n #require \"pry\"; binding.pry\n\n for day in 0..stock_prices.length - 1\n lowest_price = stock_prices[day]\n highest_price = stock_prices[day..-1].max\n margin = highest_price - lowest_price\n\n if best_margin < margin\n best_margin = margin\n best = [lowest_price, highest_price]\n end\n end\n\n lowest_day = stock_prices.index(best[0])\n highest_day = stock_prices.index(best[1])\n [lowest_day, highest_day]\nend", "def calculate_price(start_time, end_time)\n days = days_between(start_time, end_time)\n\n if days == 0\n hourlyrates(start_time, end_time)\n else\n daily_charge = (days - 1) * @parking_space[:price][:daily]\n\n start_day_hours = 24 - Time.parse(start_time).hour\n start_day_charge = cost_for_hours(start_day_hours)\n\n end_day_hours = Time.parse(end_time).hour\n if Time.parse(end_time).min > 0\n end_day_hours += 1\n end\n end_day_charge = cost_for_hours(end_day_hours)\n\n daily_charge + start_day_charge + end_day_charge\n end\nend", "def bid_greater_than_current_price\n\t\tif bid < item.current_price\n\t\t\terrors.add(:bid, \"can't be lower than current price\")\n\t\tend\n\tend", "def stock_prices(arr)\n min = arr[0]\n max = arr[0]\n big_gain = 0\n\n arr.each do |n|\n if n < min\n min = n\n max = n\n elsif n > max\n max = n\n end\n big_gain = max - min if max - min > big_gain\n end\n\n big_gain\nend", "def validate #:doc:\n errors.add(:price, \"should be positive\") unless price.nil? || price >= 0.01\n end", "def apply(start_time, end_time)\n start_minute = TimeSanitizer.output(start_time).minute_of_a_day\n end_minute = TimeSanitizer.output(end_time).minute_of_a_day\n day = TimeSanitizer.output(start_time).strftime('%A').to_s.downcase.to_sym\n\n if applies_to?(start_minute, end_minute, day)\n starts = start_minute_of_a_day > start_minute ? start_minute_of_a_day : start_minute\n ends = end_minute_of_a_day < end_minute ? end_minute_of_a_day : end_minute\n\n (ends - starts) * price / 60\n else\n 0.0\n end\n end", "def category_in_bounds(swy, swx, ney, nex, category_id, to_return = 10, start_from = 0)\n results_from_search many.within_bounds_in_category(swy, swx, ney, nex, category_id, to_return, start_from)\n end", "def buy_and_sell_price(prices)\n return if prices.length < 2\n\n buy_price = prices[0]\n current_buy_price = buy_price\n max_profit = (prices[1] - buy_price)\n\n for i in 2..prices.length - 1\n profit = prices[i] - current_buy_price\n\n if profit > max_profit\n buy_price = current_buy_price\n max_profit = profit\n else\n current_buy_price = [current_buy_price, prices[i]].min\n end\n end\n\n [buy_price, max_profit + buy_price]\nend", "def max_profit(prices)\n sell_one, sell_two = 0, 0\n buy_one, buy_two = Float::INFINITY, Float::INFINITY\n \n prices.each do |price|\n buy_one = [buy_one, price].min\n sell_one = [sell_one, price - buy_one].max\n buy_two = [buy_two, price - sell_one].min\n sell_two = [sell_two, price - buy_two].max\n end\n sell_two\nend", "def best_bid\n @bids.max_by { |x| x.fetch(:price) }\n end", "def assign_default_price\n self.cost_per_min = 120\n end", "def max_profit_cooldown(prices)\n return 0 if prices.length < 2\n\n p \"has1_doNothing\", has1_doNothing = -prices[0]\n\tp \"has0_Buy\", has0_Buy = -prices[0]\n\tp \"has0_doNothing\", has0_doNothing = 0\n p \"has1_Sell\", has1_Sell = 0\n i = 1\n while i < prices.length\n\t\tp \"has1_doNothing\", has1_doNothing = has1_doNothing > has0_Buy ? has1_doNothing : has0_Buy\n\t\tp \"has0_Buy\", has0_Buy = -prices[i] + has0_doNothing\n\t\tp \"has0_doNothing\", has0_doNothing = has0_doNothing > has1_Sell ? has0_doNothing : has1_Sell\n\t\tp \"has1_Sell\", has1_Sell = prices[i] + has1_doNothing\n i += 1\n\tend\n has1_Sell > has0_doNothing ? has1_Sell : has0_doNothing\nend", "def min(cat)\n @categories[cat][:min]\n end", "def equilibrium_price\n [((securities.uniq.reject{|s| s.percent == 0.0}.map{|s| (s.cap || 0.0)/s.percent}.max) || liq_pref), liq_pref].max \n end", "def price_is_right(bids, actual_retail_price)\n \nend", "def price_range(from, to)\n content_tag(:span, class: 'price-range') do\n fancy_price_range(from, to)\n end\n end", "def find_between(min, max)\n #place solution here\n end", "def max_consumption_price\n dataset_get(:max_consumption_price) || marginal_costs\n end", "def positive_price\n errors.add(:price, \"should be positive\") unless price.nil? || price >= 0.01\n end", "def price_validate\n\t\tif (self.pay_mode == \"free\") || (self.pay_mode == \"FREE\") || (self.pay_mode == \"Free\")\n\t\t\tunless self.price == nil \n\t\t\t\t errors.add(:price, \"price should be nil\")\n\t\t\tend\t\n\t\telsif (self.pay_mode == \"paid\") || (self.pay_mode == \"PAID\") || (self.pay_mode == \"Paid\")\n\t\t\tunless self.price > 0 \n\t\t\t\t errors.add(:price, \"price should have a value not either nil nor 0\")\n\t\t\tend\n\t\telsif (self.pay_mode == \"donation\") || (self.pay_mode == \"DONATION\") || (self.pay_mode == \"Donation\")\n\t\t\tunless self.price == nil \n\t\t\t\t errors.add(:price, \"price should be nil\")\n\t\t\tend\t\t\t\t\t\t\t\n\t\tend\n\tend", "def on2_2(prices)\n max_profit = 0\n\n return max_profit if prices.empty?\n\n prices.each_with_index do |number, index|\n max_price_after_date = prices[index..-1].max\n\n next if max_price_after_date <= number\n\n max_profit = [max_price_after_date - number, max_profit].max\n end\n\n max_profit\n end", "def stock_profit(stocks)\n minimum = stocks[0]\n profit = stocks[1] - stocks[0]\n\n (1...stocks.size).each do |price|\n current_price = stocks[price]\n current_profit = current_price - minimum\n\n minimum = [minimum, current_price].min\n\n profit = [profit, current_profit].max\n end\n\n profit\nend", "def max_profit(prices)\n buy = nil\n profit = 0\n \n prices.each do |p|\n if buy.nil?\n buy = p\n elsif p < buy\n buy = p\n else\n profit = p - buy if p - buy > profit\n end\n end\n profit\nend", "def price_adjustment \n price_adjustment_fixed / 100.0 \n end", "def profit(start_date, end_date)\n price(end_date) - price(start_date)\n end", "def show\n @company_price = CompanyPrice.find(params[:id])\n @company_prices = @company_price.user.company_prices.order(\"created_at DESC\") \n @other_company_prices = CompanyPrice.where(\"category1_id = ? AND user_id != ?\", @company_price.category1_id, @company_price.user_id).order(\"created_at DESC\").limit(6)\n @new_company_prices = CompanyPrice.order(\"created_at DESC\").limit(8)\n end", "def savings(category, cost)\n if category == category_one\n if cost < amount_one\n cost\n else\n cost - ((cost - amount_one) * (1.0 - (percentage_one.to_f/100.to_f))) \n end\n elsif category == category_two\n if cost < amount_two\n cost\n else\n cost - ((cost - amount_two) * (1.0 - (percentage_two.to_f/100.to_f)))\n end\n else\n 0\n end\n end", "def min_price\n result = case self.payment_type\n when :credit_card then Money.new(MIN_CREDIT_CARD_OFFER_CENTS, self.default_currency)\n else\n Money.new(MIN_PIGGY_BANK_OFFER_CENTS, self.default_currency)\n end\n if self.kase && self.kase.offers_reward?\n result = Money.max(result, self.kase.max_reward_price || result).convert_to(self.default_currency) +\n Money.new(MIN_PIGGY_BANK_OFFER_CENTS, self.default_currency)\n end\n result\n end", "def cheapest_price\n # CARYN SAYS: this should be cheapest restaurant! \n Recipe.all.min { |recipe_a, recipe_b| recipe_a.average_price <=> recipe_b.average_price }\n end", "def find_cvs_interval\n max = -1.0 / 0\n min = 1.0 / 0\n current = 0\n\n self.each do |elt|\n current += elt\n if current < min\n min = current\n end\n if current > max\n max = current\n end\n end\n [min, max]\n end", "def stock_picker prices\n max_profit = 0-Float::INFINITY\n buy_day = 0\n sell_day = 0\n\n prices.each.with_index do |first_price,first_index|\n profits_for_day = prices.map.with_index do |second_price,second_index|\n if first_index < second_index\n second_price - first_price\n else\n 0-Float::INFINITY\n end\n end\n max_profit_for_day = profits_for_day.max\n if max_profit_for_day > max_profit\n max_profit = max_profit_for_day\n buy_day = first_index\n sell_day = profits_for_day.index(max_profit_for_day)\n end\n end\n\n return [buy_day,sell_day]\nend", "def key_for_min_value(name_hash)\nminval = 9999\nlowprice = nil\nname_hash.each do |name,price|\n if minval > price\n lowprice =name\n minval = price\n end\n \nend\nlowprice\nend", "def valid_discount_amount?\n\t\tif current_price.between?(max_discount_amount, min_discount_amount) \n\t\t\treturn true\t\t\t\n\t\telse\n\t\t\treturn false\t\t\n\t\tend \n\tend", "def stock_picker(prices)\n\n buy = 0\n sell = 0\n max = 0\n \n prices.each_index do |x|\n prices.each_index do |y|\n if prices[y] - prices[x] > 0 and prices[y] - prices[x] > max and y > x\n buy = x\n sell = y\n max = prices[y] - prices[x]\n end\n end\n end\n \n [buy, sell]\nend", "def max_profit(prices)\n max_profit = 0\n min_price = 1_000_000\n\n 0.upto(prices.length - 1) do |i|\n if prices[i] < min_price\n min_price = prices[i]\n elsif prices[i] - min_price > max_profit\n max_profit = prices[i] - min_price\n end\n end\n\n max_profit\nend", "def validate_discount_range\n if self.discount =~ self.class.reg_discount_range and !self.discount.blank?\n validate_discount_range_values\n else\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.invalid\") )\n end\n end", "def prices_te_by_articles_categories\n order_items_by_article_categories.reduce({}) do |hash, order_items_by_article_category|\n hash.merge(\n order_items_by_article_category.first =>\n formatted_price(order_items_by_article_category.last.sum(&:product_price_te))\n )\n end\n end", "def stock_picker(prices)\n combinations = prices.combination(2).to_a\n profits = combinations.map { |days| days[1] - days[0] }\n (0...prices.size).to_a.combination(2).to_a[profits.index(profits.max)]\nend", "def discountedPrice(nbDays, pricePerDay, dayThreshold, discount)\n (1 - discount) * (nbDays - dayThreshold) * pricePerDay;\nend", "def stock_picker(prices)\n index = 0\n lowest = 0\n best_value = []\n for i in prices\n for j in prices[index..prices.length-1]\n if i - j < lowest\n lowest = i - j # lowest will be equal to the greatest price difference (greatest negative number)\n min = prices.index(i) # index of buy date\n max = prices.index(j) # index of sell date\n end\n end\n index += 1 # increments each iteration to ensure sell dates cannot be past dates\n end \n best_value << min\n best_value << max\n puts \"#{best_value} If you buy on day #{min} and sell on day #{max},\n you will make $#{lowest.abs} profit.\"\nend", "def cigaret_price\n 0.30\n end" ]
[ "0.6294308", "0.6114247", "0.57694495", "0.57682294", "0.575426", "0.57185185", "0.56026673", "0.5500002", "0.5500002", "0.5496618", "0.54170084", "0.53784925", "0.5342436", "0.5337434", "0.53291327", "0.5317286", "0.529486", "0.5271505", "0.52558035", "0.5243964", "0.5233515", "0.52223647", "0.5182778", "0.5171304", "0.51468897", "0.513865", "0.5127991", "0.51109844", "0.5088124", "0.50827044", "0.50674635", "0.5051231", "0.5026038", "0.50189203", "0.50140417", "0.5014007", "0.50101376", "0.5010059", "0.50087696", "0.4988894", "0.4985156", "0.4977262", "0.4974013", "0.4972892", "0.49706575", "0.4970562", "0.4967503", "0.49565834", "0.49498683", "0.494704", "0.494704", "0.49408683", "0.49375504", "0.49316248", "0.49243715", "0.49210656", "0.4918734", "0.49099967", "0.49052313", "0.48845196", "0.48780856", "0.4875151", "0.4870304", "0.48668706", "0.48658553", "0.4864714", "0.48502454", "0.48455274", "0.48388764", "0.4827925", "0.48210552", "0.48182875", "0.4806315", "0.48034388", "0.48023942", "0.47973973", "0.4795539", "0.47875094", "0.47844002", "0.4770769", "0.47675034", "0.47633773", "0.4760632", "0.47595954", "0.47595257", "0.47568518", "0.47566873", "0.47536358", "0.47521594", "0.4731654", "0.4729502", "0.4725555", "0.47216436", "0.47164768", "0.47147533", "0.47000146", "0.4698404", "0.46980157", "0.46967083", "0.46954513", "0.46924245" ]
0.0
-1
File actionpack/lib/action_view/helpers/text_helper.rb, line 215
def word_wrap(text, line_width = 80) text.split("\n").collect do |line| line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line end * "\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def text_helper\n gem 'actionpack'\n require 'action_controller' # bringing this in for autolinks\n helper = Object.new\n helper.extend ActionView::Helpers::TextHelper\n helper.extend ActionView::Helpers::TagHelper\n helper\nend", "def text_message_content_from_erb\n # TODO: Remove the following error after views are rendering. - TW\n end", "def text ; view.text ; end", "def helpers; end", "def helpers; end", "def helpers; end", "def helper\n unless @helper\n @helper = Object.new\n @helper.extend ActionView::Helpers::TextHelper # for truncate\n @helper.extend ActionView::Helpers::OutputSafetyHelper # for safe_join\n end\n return @helper\n end", "def view_renderer; end", "def view_renderer; end", "def utf8_enforcer_tag; end", "def renderHelper(el)\n\t\tif el === nil\n\t\t\treturn ' '\n\t\telse\n\t\t\treturn el\n\t\tend\n\tend", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text\n #just returns view\n end", "def render_string_from_view(view_file)\n end", "def render_string_from_view(view_file)\n end", "def text_help\n Helper.instance\nend", "def inner_text; end", "def inner_text; end", "def text text\n end", "def render_to_string(*args, &block); end", "def h(text); end", "def h(text); end", "def texts; end", "def define_action_helpers; end", "def url_helpers_module; end", "def partial_text_name\n put_together_name(:part).t.html_to_ascii\n end", "def render; ''; end", "def rendered=(_arg0); end", "def helpers\n ActionController::Base.helpers # you can also try @template.helpers OR self.class.helpers OR include ActionView::Helpers\n end", "def test_lying_with_magic_comment\n assert_raises(ActionView::Template::Error) do\n @template = new_template(\"# encoding: UTF-8\\nhello \\xFCmlat\", virtual_path: nil)\n render\n end\n end", "def helpers\n ActionController::Base.helpers\n end", "def helpers\n ActionController::Base.helpers\n end", "def tpl_text; ''; end", "def tpl_text; ''; end", "def tpl_text; ''; end", "def render_to_string(*_arg0); end", "def path_helpers_module; end", "def text(_content)\n raise NotImplementedError\n end", "def text\n raise 'Abstract Method'\n end", "def helpers\n ActionController::Base.helpers\nend", "def define_helpers; end", "def text?; end", "def text?; end", "def text?; end", "def get_text\n raise NotImplementedError\n end", "def render_tech\n object.render_tech * \", \"\n end", "def render_variable(context); end", "def html_markup_text(text); end", "def getText\r\n @debug = true \r\n init \r\n \r\n if $action\r\n actionStr = $action.string\r\n else\r\n actionStr = 'default_template'\r\n end\r\n \r\n return eval(actionStr)\r\nend", "def markup_context; end", "def view_question_text\n nil\n end", "def view_question_text\n nil\n end", "def strip_tags_custom\n ActionController::Base.helpers.strip_tags(self)\n end", "def exception_renderer; end", "def define_action_helpers?; end", "def getText\n @debug = true \n init \n \n if $action\n actionStr = $action.string\n else\n actionStr = 'default_template'\n end\n eval(actionStr)\nend", "def special_text\n @special_text\n end", "def html_markup_textile_strict(text); end", "def text=(_arg0); end", "def rendered_format; end", "def rendered_format; end", "def show\n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n end", "def excerpt_separator; end", "def content_helper\n\t\tif session[:source]\n\t\t\tgreeting = \"Gracias por visitarme desde #{session[:source]}\"\n content_tag(:p, greeting, class: 'source-greeting')\n end\n # primero le pasamos el tag que queremos que tenga\n # despues el string o la variable que queremos que ponga dentro de ese tag\n # Al final la clase si es que queramos que tenga una\n #Tambien le podemos pasar argumentos a los helpers\n\tend", "def render(context)\n # Sanitize the code inside the block\n resolve_code = super.to_s.gsub(/\\A(\\n|\\r)+|(\\n|\\r)+\\z/, \"\")\n \n # Invoke Rouge to format our code\n formatted_code = rouge_resolve(resolve_code)\n \n # Output the formatted code with the proper HTML tags\n to_html_code(formatted_code)\n end", "def show\n @title = \"#{@press_release.title} - Think India NITR club\"\n @description = ActionController::Base.helpers.strip_tags(@press_release.article)[0..200] \n end", "def stextilize(text)\n if text.blank?\n \"\"\n else\n if ENV['RAILS_ENV'] == 'test'\n # For some reason, the call to :sanitize_html causes problems in tests. Weird.\n textilized = RedCloth.new(text, [ :hard_breaks, :filter_styles ])\n else\n textilized = RedCloth.new(text, [ :hard_breaks, :sanitize_html, :filter_styles ])\n end\n textilized.to_html\n end\n end", "def herebody_s; end", "def all_application_helpers; end", "def helpers\n ActionController::Base.helpers\n end", "def help\n #render(text: \"Help method in StaticPages controller class\");\n end", "def html?; end", "def html?; end", "def html?; end", "def _view; end", "def render_string\n str = \"42\"\n render :string => str, :layout => false\n end", "def clean_description\n ActionView::Base.full_sanitizer.sanitize(description)\n end", "def debriefingText _args\n \"debriefingText _args;\" \n end", "def return_tag(text); end", "def add_tags chars\n # TODO: write your code here\nend", "def _normalize_render(*args, &block); end", "def markup_context=(_arg0); end", "def version_helper; end", "def version_helper; end", "def version_helper; end", "def version_helper; end", "def open_text\n \"\"\n end", "def exception_renderer=(_arg0); end" ]
[ "0.7388642", "0.6205606", "0.60055816", "0.5845168", "0.5845168", "0.5845168", "0.5727737", "0.57178885", "0.57178885", "0.5691172", "0.56843746", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5677834", "0.56570655", "0.56570655", "0.5650452", "0.5622603", "0.5622603", "0.5587199", "0.5553025", "0.55009484", "0.55009484", "0.5493302", "0.5492478", "0.54887927", "0.5486341", "0.54852605", "0.5472545", "0.5450223", "0.54492575", "0.54362273", "0.54362273", "0.54290134", "0.54290134", "0.54290134", "0.5418537", "0.54045814", "0.5399058", "0.5396976", "0.5379024", "0.5376646", "0.5376488", "0.5376488", "0.5376488", "0.5374053", "0.5360967", "0.5353567", "0.535238", "0.53402555", "0.53255695", "0.5324381", "0.53231186", "0.5316667", "0.5310071", "0.53062356", "0.5298781", "0.52966386", "0.5291962", "0.5290816", "0.52700096", "0.52700096", "0.52652305", "0.52462125", "0.5242348", "0.5235033", "0.5233767", "0.5233514", "0.5218515", "0.52168155", "0.52131885", "0.5204515", "0.52035505", "0.52035505", "0.52035505", "0.52021635", "0.51961774", "0.5193246", "0.5193212", "0.5192268", "0.5191934", "0.51878273", "0.5187713", "0.5182682", "0.5182682", "0.5182682", "0.5182682", "0.51785576", "0.51670486" ]
0.0
-1
Convenience method to test if we're missing any required switches
def missing_switches? !@missing_switches.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def detect_unsupported_switches!(args)\n return unless (unsupported = UNSUPPORTED_SWITCHES & args).any?\n\n $stdout.puts \"Please set the following switches in your vite.json instead: #{ unsupported }.\"\n exit!\n end", "def check_for_missing_enabled_option(hash); end", "def missing_args?(opts)\n !(opts[:server] && opts[:username] && opts[:api_token] &&\n ENDPOINT.keys.include?(opts[:server].to_sym))\n end", "def not_found?\n @flags.empty?\n end", "def needed_if_relevant?\n false\n end", "def available?(params)\n unavailability_reasons(params).empty?\n end", "def needed_if_relevant?\n false\n end", "def check_options\n unless @options[:stub]\n STDERR.puts \"Please specify a host to connect to using --host\" unless @options[:host]\n STDERR.puts \"Please specify a model to check using --model\" unless @options[:model]\n return false unless @options[:host] && @options[:model]\n end\n\n true\n end", "def test_not_run?(test_case)\n test_case[:exec_status] == 'n'\n end", "def has_missing_required_arg?\n !missing_required_arguments.empty?\n end", "def options_valid?\n loaded_config? &&\n output_base_valid? &&\n have_sample_ids? &&\n sample_ids_in_config?\nend", "def skip?\n $game_switches[CP::VICTORY::SKIP_SWITCH]\n end", "def conditions_met?\n class_name = SceneManager.scene.class.name.to_sym\n return false unless scene_whitelist.empty? || scene_whitelist.include?(class_name)\n return false if scene_blacklist.include?(class_name)\n return false unless $game_switches[@event.switch_id]\n return true\n end", "def verify_unused(names,flags,switches,context) # :nodoc:\n names.each do |name|\n verify_unused_in_option(name,flags,\"flag\",context)\n verify_unused_in_option(name,switches,\"switch\",context)\n end\n end", "def options_valid?\n missing = MANDATORY_OPTIONS.select { |arg| @options[arg].nil? }\n missing.empty?\n end", "def no_user_opts?\n !(opts[:methods] || opts['instance-methods'] || opts[:ppp] ||\n opts[:globals] || opts[:locals] || opts[:constants] || opts[:ivars])\n end", "def specified?\n !options[:model].blank?\n end", "def failed?\n false if @opts[:help]\n true if @opts[:get].nil?\n true if @opts[:token].nil? && @opts[:user].nil?\n true if @opts[:token].nil? && @opts[:pass].nil?\n end", "def unknown?\n !dir? && !file? && !symlink? && !device?\n end", "def setting_provided?(key)\n !settings[key].nil?\n end", "def toggable?\n @switch != nil\n end", "def toggable?\n return @switch != nil\n end", "def sanity_check\n if bootstrap_vault_item && (bootstrap_vault_json || bootstrap_vault_file)\n ui.warn \"--vault-item given with --vault-list or --vault-file, ignoring the latter\"\n end\n\n if bootstrap_vault_json && bootstrap_vault_file\n ui.warn \"--vault-list given with --vault-file, ignoring the latter\"\n end\n end", "def check_mandatory!\n if options.work_dir.nil?\n kill \"missing file operand\"\n end\n if options.contents_template.nil?\n kill \"could not find contents template\"\n end\n end", "def desired?(opt)\n st = @wopts[opt]\n st = false if st.nil?\n st\n end", "def check_features\n case params[:action]\n when \"index\"\n current_features.include?('shift_index') ? true : invalid_features\n when \"new\"\n current_features.include?('shift_new') ? true : invalid_features\n when \"edit\"\n current_features.include?('shift_edit') ? true : invalid_features\n when \"destroy\"\n current_features.include?('shift_delete') ? true : invalid_features\n end\n # return true\n end", "def precheck\n if !BinarySolo.dir_valid?\n puts \"this is not a binary_solo directoy => better run $ binarysolo init\".colorize(:red)\n false\n elsif !BinarySolo.config_valid?\n puts \"your config is invalid - but I dont have any details for you (yet)\".colorize(:red)\n false\n else\n true\n end\nend", "def test_disabled?\n ENV['NO_TEST'] == '1'\nend", "def test_disabled?\n ENV['NO_TEST'] == '1'\nend", "def has_option?(arg)\n !!find_option(arg)\n end", "def action_argument_required?\n !AVAILABLE_ACTIONS.empty?\n end", "def no_options_in_arguments?\n ARGV.grep(/^-/).empty? # Match args that start with - (or --). Those are the options.\n end", "def missing?; false; end", "def check_sanity\n errors = []\n [:site, :uri, :user, :password, :confdir].each do |sym|\n if @config[sym].nil?# or @config[sym].empty?\n errors << \"Option '#{sym}' is required\"\n end\n end\n unless errors.empty?\n $stderr.puts 'ERROR: The following problems were detected:'\n errors.map { |e| $stderr.puts \" * #{e}\" }\n $stderr.puts \"\\nConfiguration options:\\n\"\n ap @config\n exit 1\n end\n end", "def use?(opts)\n !(opts.keys & @takes).empty?\n end", "def any_unrecognized_keys?(expected, given)\n unrecognized_keys(expected, given).any?\n end", "def gui?\n !ENV.fetch('GUI', '').empty?\nend", "def finished_wizard?\n !empty? && !informations? && !parameters? && !parameters_details? && !upload? && !review?\n end", "def verify_unused(names) # :nodoc:\n names.each do |name|\n verify_unused_in_option(name,flags,\"flag\")\n verify_unused_in_option(name,switches,\"switch\")\n end\n end", "def optional?\n !@required\n end", "def expects_argument?\n config[:argument] && config[:argument] != :optional\n end", "def check_option_support\n assert_option_supported(:foodcritic) &&\n assert_option_supported(:scmversion, 'thor-scmversion') &&\n assert_default_supported(:no_bundler, 'bundler')\n end", "def flags?\n [email protected]?\n end", "def test_option_required\n\n # All options are optional by default\n assert(!Option.new(nil, nil).required)\n assert(!Option.new(\"-h|--help\", nil).required)\n\n # All options may be required\n assert(Option.new(nil, nil, required:true).required)\n assert(Option.new(\"-h|--help\", nil, required:true).required)\n end", "def complain_about_bad_flags?\n @complain_about_bad_flags\n end", "def check_config\n %w(token).each do |param|\n (usage and return false) if Weechat.get_plugin_config(param).to_s.empty?\n end\n true\nend", "def early_option?(args)\n if @options[:version]\n puts(\"boson #{Boson::VERSION}\")\n true\n elsif args.empty? || (@command.nil? && !@options[:execute])\n print_usage\n true\n else\n false\n end\n end", "def check_features\n # case params[:action]\n # when \"index\"\n # current_features.include?('feature_key') ? true : invalid_features \n # end\n return true\n end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def check(cmd)\n # check requisite options\n list.each do |item|\n if item.requisite and not(cmd.model[item.key])\n raise OptionError.new(cmd, 'option \"%s\" is requisite' % [item.long])\n end\n end\n end", "def environmentOK?()\n\tcommandsMissing = []\n\tNEEDED_COMMANDS.each{ |command|\n\t\tif !which(command)\n\t\t\tcommandsMissing.push(command)\n\t\tend\n\t}\n\tif commandsMissing.size > 0\n\tputs \"You are missing following programs:\\n\"\n\tcommandsMissing.each { |command|\n\t\tputs \"\\t#{command}\\n\"\n\t}\n\treturn false\n\tend\n\treturn true\nend", "def comp_noncomp_past_step_1?\n !spectator? && status_is_active?(\"base_details\")\n end", "def test?\n params.key?('testMode') && params['testMode'] != '0'\n end", "def not_applicable(note = nil)\n $stderr.puts ['TEST SKIPPED', 'NOT APPLICABLE', note].compact.join(' - ')\n true\n end", "def valid_arguments?\n begin\n if(@options.file)\n raise LoadError,\"The file you specified doesn't exist: #{@options.file}\" if File.exist?(@options.file) == false\n else\n @log.error \"Select a file using -f or --file FILE\"\n exit!\n end\n \n if(@options.output)\n # not going to worry about this one.\n else\n @log.error \"No output was specified select using -o or --output\"\n exit!\n end\n rescue LoadError => bam\n @log.error bam\n exit!\n end\n \n return true\n end", "def required?\n mode == \"REQUIRED\"\n end", "def check_unknown_options?(config) #:nodoc:\n options = check_unknown_options\n return false unless options\n\n command = config[:current_command]\n return true unless command\n\n name = command.name\n\n if subcommands.include?(name)\n false\n elsif options[:except]\n !options[:except].include?(name.to_sym)\n elsif options[:only]\n options[:only].include?(name.to_sym)\n else\n true\n end\n end", "def baremetal?\n if dell_server?\n !related_switches.empty? && related_volumes.empty? && related_clusters.empty?\n else\n related_volumes.empty? && related_clusters.empty?\n end\n end", "def already_used?\n p \"Checking already used\"\n vehicle.present? and state == 1\n end", "def agent_should_start?\n !blacklisted_constants? &&\n !blacklisted_executables? &&\n !in_blacklisted_rake_task?\n end", "def isok(input)\n # make sure that the input does not contain system ''\n ! input.downcase.include? 'system'\n end", "def option?(param)\n param[0] == \"-\"\n end", "def required_capabilities?(tcp)\n (ToolProxy::ENABLED_CAPABILITY - tcp['capability_offered']).blank?\n end", "def optional?\n\t\t!required?\n\tend", "def missing?\n @missing\n end", "def completely_probed?\n !(@probe_nodes.find{|node| node.nil?})\n end", "def has_missing_params?(required_params)\n required_params.each do |param|\n return true if params[param].blank?\n end\n false\n end", "def arguments_valid?\n true if ['install','list','uninstall'].include?(@arguments[0])\n end", "def has_pref?(preference)\n !prefs[preference].to_s.empty?\nend", "def valid?(options)\n (@required_options - options.keys).size == 0\n end", "def check(params)\n false\n end", "def includes_arguments?\n !default_data.empty? || !flags.empty? ||\n !required_args.empty? || !optional_args.empty? ||\n !remaining_arg.nil? || flags_before_args_enforced?\n end", "def check_params #:doc:\n if params[:username] !~ /.{1,}/ or params[:password] !~ /.{1,}/ or\n params[:devicename] !~ /.{1,}/ or params[:dev_type] !~ /.{1,}/ or\n (params[:port] != nil and params[:port] !~ /\\d{1,10}/)\n return false\n else\n return true\n end\n end", "def check_options action, modes\n if modes['help']\n display_options(action)\n exit\n end\n options = action.options\n unsupported = modes.keys.select{|k| !options.has_key?(k.to_sym)}\n return if unsupported.empty?\n $stderr.puts \"Action --#{action_name action} does not support #{unsupported.size >1 ? 'these options' : 'this option'}: #{unsupported*', '}\"\n display_options(action, $stderr)\n exit 1\n end", "def optional?\n not required\n end", "def required_args_present?(metric, args)\n (@metrics[metric]['required'] - args.keys).empty?\n end", "def invalid_options?\n options[:api_key].nil? || options[:blog].nil?\n end", "def check_no_extra_args!\n if @argv.length > 0\n Braid::Command.handle_error(\n Braid::BraidError.new('Extra argument(s) passed to command.'))\n end\n end", "def arguments_valid?\n ret = false\n ret = true unless (@options.action == nil)\n end", "def valid_arguments?\n begin\n if(@options.file)\n raise LoadError,\"The file you specified doesn't exist: #{@options.file}\" if File.exist?(@options.file) == false\n else\n @log.error \"Select a file using -f or --file FILE\"\n end\n \n if(@options.output)\n # not going to worry about this one.\n else\n @log.error \"No output was specified select using -o or --output\"\n end\n rescue LoadError => bam\n @log.error bam\n exit\n end\n \n return true\n end", "def valid_arguments?\n begin\n if(@options.file)\n raise LoadError,\"The file you specified doesn't exist: #{@options.file}\" if File.exist?(@options.file) == false\n else\n @log.error \"Select a file using -f or --file FILE\"\n end\n \n if(@options.output)\n # not going to worry about this one.\n else\n @log.error \"No output was specified select using -o or --output\"\n end\n rescue LoadError => bam\n @log.error bam\n exit\n end\n \n return true\n end", "def valid_arguments?\n begin\n if(@options.file)\n raise LoadError,\"The file you specified doesn't exist: #{@options.file}\" if File.exist?(@options.file) == false\n else\n @log.error \"Select a file using -f or --file FILE\"\n end\n \n if(@options.output)\n # not going to worry about this one.\n else\n @log.error \"No output was specified select using -o or --output\"\n end\n rescue LoadError => bam\n @log.error bam\n exit\n end\n \n return true\n end", "def has_a_wizard?\n @wizard != nil\n end", "def have_sample_ids?\n if @options.samples && @options.samples.size > 0\n return true\n end\n @stderr.puts \"Missing sample id(s) to processor\"\n return false\nend", "def optional?\n required.empty? && required_keywords.empty?\n end", "def valid?()\n (@invalid_reason.nil? && !(@hops.find { |h| h.is_a?(Symbol) or h.is_a?(String) }))\n end", "def has_demand?(demand)\n !get_demand(demand).nil?\n end", "def unknown?\n\t\treturn ( major.text.include?('InsufficientInformation') )\n\tend", "def none?\n if @requirements.size == 1\n @requirements[0] == DefaultRequirement\n else\n false\n end\n end", "def should_halt?(request = default_request)\n request_info(request.floor) && direction_matches?(request)\n end", "def arguments_valid?\n # check the parameters have values\n return false unless @options.has_key?(:hcdFile)\n return false unless @options.has_key?(:etdFile) \n return false if @options[:mzArray].empty?\n return false unless (@options[:mzTolerance] > 0.0 || @options[:ppmTolerance] > 0.0 )\n # check the file exists\n return false unless File.file?(@options[:hcdFile])\n return false unless File.file?(@options[:etdFile])\n true\n end", "def setup_args_valid?(argsArr)\r\n if nil==argsArr[0] or argsArr[0]==\"\"\r\n return \"Bot token cannot be empty or nil.\"\r\n elsif nil==argsArr[1] or argsArr[1]==\"\"\r\n return \"Bot clientId cannot be empty or nil.\"\r\n elsif nil==argsArr[2]\r\n return \"Bot command prefix cannot be nil.\"\r\n end\r\n\r\n return nil\r\n end" ]
[ "0.68960816", "0.64150405", "0.6221129", "0.6208155", "0.61850625", "0.6174304", "0.610002", "0.6052477", "0.60170853", "0.6014367", "0.6007846", "0.5994656", "0.59869766", "0.5974065", "0.5972064", "0.5942299", "0.59315133", "0.5925655", "0.5922561", "0.5915957", "0.5893687", "0.5891139", "0.58873546", "0.5877887", "0.58675694", "0.5856067", "0.5848632", "0.58345896", "0.58345896", "0.5831626", "0.57718587", "0.5763591", "0.5755347", "0.5729595", "0.5720762", "0.5717097", "0.57037395", "0.5693509", "0.5688758", "0.5684747", "0.5673747", "0.56579554", "0.5656046", "0.56542295", "0.5653631", "0.56504595", "0.56486", "0.56164575", "0.561043", "0.561043", "0.561043", "0.561043", "0.561043", "0.561043", "0.561043", "0.561043", "0.561043", "0.5607207", "0.560301", "0.560286", "0.55972016", "0.5591069", "0.5588326", "0.5587827", "0.55794656", "0.55789095", "0.55770797", "0.5573736", "0.55693465", "0.5564739", "0.556075", "0.5555803", "0.55514413", "0.55367535", "0.5536313", "0.552542", "0.5524723", "0.55220443", "0.5521294", "0.55143094", "0.55136335", "0.55077904", "0.5504572", "0.5502234", "0.54976517", "0.5488829", "0.548872", "0.54860026", "0.54860026", "0.54860026", "0.5484324", "0.5483734", "0.548362", "0.5480455", "0.5478872", "0.5477082", "0.5471795", "0.54709625", "0.5470361", "0.54663384" ]
0.8438237
0
Wrapper for OptionParser::make_switch to allow for required switches
def make_switch(opts, block = nil) # Test if a switch is required required = opts.delete(:required) return_values = pickled_make_switch(opts, block) # Make sure required switches are given if required short = return_values[1][0].nil? ? nil : "-#{return_values[1][0]}" long = return_values[2][0].nil? ? nil : "--#{return_values[2][0]}" if !(default_argv.include?(short) || default_argv.include?(long)) @missing_switches ||= [] # Should be placed in initialize if incorporated into Ruby proper # Ugly and hard to read, should figure out a prettier way of doing this @missing_switches << "Missing switch: #{short if !short.nil?}#{" or " if !short.nil? && !long.nil?}#{long if !long.nil?}" end end return return_values end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_switch(opts, block = nil)\n short, long, nolong, style, pattern, conv, not_pattern, not_conv, not_style = [], [], []\n ldesc, sdesc, desc, arg = [], [], []\n default_style = Switch::NoArgument\n default_pattern = nil\n klass = nil\n q, a = nil\n has_arg = false\n\n opts.each do |o|\n # argument class\n next if search(:atype, o) do |pat, c|\n klass = notwice(o, klass, 'type')\n if not_style and not_style != Switch::NoArgument\n not_pattern, not_conv = pat, c\n else\n default_pattern, conv = pat, c\n end\n end\n\n # directly specified pattern(any object possible to match)\n if (!(String === o || Symbol === o)) and o.respond_to?(:match)\n pattern = notwice(o, pattern, 'pattern')\n if pattern.respond_to?(:convert)\n conv = pattern.method(:convert).to_proc\n else\n conv = SPLAT_PROC\n end\n next\n end\n\n # anything others\n case o\n when Proc, Method\n block = notwice(o, block, 'block')\n when Array, Hash\n case pattern\n when CompletingHash\n when nil\n pattern = CompletingHash.new\n conv = pattern.method(:convert).to_proc if pattern.respond_to?(:convert)\n else\n raise ArgumentError, \"argument pattern given twice\"\n end\n o.each {|pat, *v| pattern[pat] = v.fetch(0) {pat}}\n when Module\n raise ArgumentError, \"unsupported argument type: #{o}\", ParseError.filter_backtrace(caller(4))\n when *ArgumentStyle.keys\n style = notwice(ArgumentStyle[o], style, 'style')\n when /^--no-([^\\[\\]=\\s]*)(.+)?/\n q, a = $1, $2\n o = notwice(a ? Object : TrueClass, klass, 'type')\n not_pattern, not_conv = search(:atype, o) unless not_style\n not_style = (not_style || default_style).guess(arg = a) if a\n default_style = Switch::NoArgument\n default_pattern, conv = search(:atype, FalseClass) unless default_pattern\n ldesc << \"--no-#{q}\"\n (q = q.downcase).tr!('_', '-')\n long << \"no-#{q}\"\n nolong << q\n when /^--\\[no-\\]([^\\[\\]=\\s]*)(.+)?/\n q, a = $1, $2\n o = notwice(a ? Object : TrueClass, klass, 'type')\n if a\n default_style = default_style.guess(arg = a)\n default_pattern, conv = search(:atype, o) unless default_pattern\n end\n ldesc << \"--[no-]#{q}\"\n (o = q.downcase).tr!('_', '-')\n long << o\n not_pattern, not_conv = search(:atype, FalseClass) unless not_style\n not_style = Switch::NoArgument\n nolong << \"no-#{o}\"\n when /^--([^\\[\\]=\\s]*)(.+)?/\n q, a = $1, $2\n if a\n o = notwice(NilClass, klass, 'type')\n default_style = default_style.guess(arg = a)\n default_pattern, conv = search(:atype, o) unless default_pattern\n end\n ldesc << \"--#{q}\"\n (o = q.downcase).tr!('_', '-')\n long << o\n when /^-(\\[\\^?\\]?(?:[^\\\\\\]]|\\\\.)*\\])(.+)?/\n q, a = $1, $2\n o = notwice(Object, klass, 'type')\n if a\n default_style = default_style.guess(arg = a)\n default_pattern, conv = search(:atype, o) unless default_pattern\n else\n has_arg = true\n end\n sdesc << \"-#{q}\"\n short << Regexp.new(q)\n when /^-(.)(.+)?/\n q, a = $1, $2\n if a\n o = notwice(NilClass, klass, 'type')\n default_style = default_style.guess(arg = a)\n default_pattern, conv = search(:atype, o) unless default_pattern\n end\n sdesc << \"-#{q}\"\n short << q\n when /^=/\n style = notwice(default_style.guess(arg = o), style, 'style')\n default_pattern, conv = search(:atype, Object) unless default_pattern\n else\n desc.push(o)\n end\n end\n\n default_pattern, conv = search(:atype, default_style.pattern) unless default_pattern\n if !(short.empty? and long.empty?)\n if has_arg and default_style == Switch::NoArgument\n default_style = Switch::RequiredArgument\n end\n s = (style || default_style).new(pattern || default_pattern,\n conv, sdesc, ldesc, arg, desc, block)\n elsif !block\n if style or pattern\n raise ArgumentError, \"no switch given\", ParseError.filter_backtrace(caller)\n end\n s = desc\n else\n short << pattern\n s = (style || default_style).new(pattern,\n conv, nil, nil, arg, desc, block)\n end\n return s, short, long,\n (not_style.new(not_pattern, not_conv, sdesc, ldesc, nil, desc, block) if not_style),\n nolong\n end", "def parse_switch(arg)\n argument = arg[1..-1].downcase\n\n # Version\n if argument =~ /^(v|-version)$/\n print_version\n end\n\n # Argument output_dir\n if argument.eql?(\"m\")\n @merge = true\n @edit_in_place=false unless @mset==true\n @mset=true\n end\n\n # In place\n if argument.eql?(\"i\")\n @edit_in_place=true\n @merge=false unless @mset==true\n end\n\n # Argument threshold\n if argument.eql?(\"t\")\n if @expecting_threshold==false\n @expecting_threshold=true\n else\n puts \"Argument threshold expected after -t switch\\n\"\n print_help\n end\n end\n\n # Arguments -H, -h, --help, -help...\n if argument =~ /^-*h+(elp)*$/i\n print_help\n end\n\n end", "def switch_option(arg)\n if match = no_or_skip?(arg) # rubocop:disable AssignmentInCondition\n @switches[arg] || @switches[\"--#{match}\"]\n else\n @switches[arg]\n end\n end", "def switch(*names)\n names = [names].flatten\n verify_unused(names,flags,switches,\"in global options\")\n switch = Switch.new(names,@@next_desc,@@next_long_desc)\n switches[switch.name] = switch\n clear_nexts\n end", "def switch(*names)\n options = extract_options(names)\n names = [names].flatten\n\n verify_unused(names)\n switch = Switch.new(names,options)\n switches[switch.name] = switch\n\n clear_nexts\n switches_declaration_order << switch\n switch\n end", "def initialize options_to_parse_by_name = {},\n option_default_values = {},\n stop_on_unknown = false,\n disable_required_check = false\n @stop_on_unknown = stop_on_unknown\n @disable_required_check = disable_required_check\n\n options = options_to_parse_by_name.values\n super( options )\n\n # Add defaults\n option_default_values.each do |option_name, value|\n @assigns[ option_name.to_s ] = value\n\n @non_assigned_required.delete \\\n options_to_parse_by_name[ option_name ]\n end\n\n @shorts = {}\n @switches = {}\n @extra = []\n\n options.each do |option|\n @switches[option.switch_name] = option\n\n option.aliases.each do |short|\n name = short.to_s.sub(/^(?!\\-)/, \"-\")\n @shorts[name] ||= option.switch_name\n end\n end\n end", "def parse(switch, value, argv)\n raise \"value specified for switch: #{switch}\" if value\n value = (switch == negative_long ? false : true)\n block ? block.call(value) : value\n end", "def define(*opts, &block)\n top.append(*(sw = make_switch(opts, block)))\n sw[0]\n end", "def initialize(switches)\n @defaults = {}\n @shorts = {}\n \n @leading_non_opts, @trailing_non_opts = [], []\n\n @switches = switches.inject({}) do |mem, (name, type)|\n if name.is_a?(Array)\n name, *shorts = name\n else\n name = name.to_s\n shorts = []\n end\n # we need both nice and dasherized form of switch name\n if name.index('-') == 0\n nice_name = undasherize name\n else\n nice_name = name\n name = dasherize name\n end\n # if there are no shortcuts specified, generate one using the first character\n shorts << \"-\" + nice_name[0,1] if shorts.empty? and nice_name.length > 1\n shorts.each { |short| @shorts[short] = name }\n \n # normalize type\n case type\n when TrueClass then type = :boolean\n when String\n @defaults[nice_name] = type\n type = :optional\n when Numeric\n @defaults[nice_name] = type\n type = :numeric\n end\n \n mem[name] = type\n mem\n end\n \n # remove shortcuts that happen to coincide with any of the main switches\n @shorts.keys.each do |short|\n @shorts.delete(short) if @switches.key?(short)\n end\n end", "def switch(*names)\n names = [names].flatten\n GLI.verify_unused(names,flags,switches,\"in command #{name}\")\n switch = Switch.new(names,@next_desc,@next_long_desc)\n switches[switch.name] = switch\n clear_nexts\n end", "def parse! opts, config\n @long_switch = \"#{@long_switch} #{@key.to_s.upcase}\" if @type == :posix and \\\n defined?(@key) && @key\n switches = []\n switches << (defined?(@short_switch) && @short_switch) ? @short_switch : nil\n switches << (defined?(@long_switch) && @long_switch) ? @long_switch : nil\n @description = \"#{@description} (Default: #{@default})\" if @default\n opts.on(switches[0], switches[1], @description) do |o|\n config[@key] = o\n end\n end", "def initialize(names,options = {})\n super(names,options)\n @default_value = false if options[:default_value].nil?\n @negatable = options[:negatable].nil? ? true : options[:negatable]\n if @default_value != false && @negatable == false\n raise \"A switch with default #{@default_value} that isn't negatable is useless\"\n end\n end", "def handle_switch(directive, names, extras); end", "def apply_command_line_switch_overrides(options)\n present_switches = environment.options.present_switches\n registered_task_options.each do |option|\n # present_switches is a list of all valid switches that have been supplied by the user.\n if option.switch && present_switches.include?(option.switch)\n options.update(option.key, !option.default, add_missing: false)\n end\n end\n end", "def init_switch(hash)\n @default = false if @default.nil? && !hash[:not_initialize]\n @switch = hash[:sw]\n @values = [hash[:off], hash[:on]]\n end", "def common_switch(name)\n case name\n when :quiet then [[\"-q\", \"--quiet\"], :quiet]\n when :verbose then [[\"-v\", \"--verbose\"], :verbose]\n when :debug then [[\"-d\", \"--debug\"], :debug]\n when :force then [[\"-f\", \"--force\"], :force]\n else name\n end\n end", "def init_switch(hash)\n @default = false if @default.nil?\n @switch = hash[:sw]\n @values = [hash[:off], hash[:on]]\n end", "def proc_arg(opt)\n case opt\n when '-h'\n :hash\n when '-m'\n :merge\n when '-n'\n :nested\n else\n nil\n end\nend", "def switch!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 49 )\n\n type = SWITCH\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 170:10: 'switch'\n match( \"switch\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 49 )\n\n end", "def consume_option(switches, args)\n # consume from left to right; rightmost will win\n while index = args.find_index { |arg| Array(switches).include?(arg) }\n switch, value = args.slice!(index, 2)\n raise ArgumentError, \"missing option (expected after #{switch})\" unless value\n end\n\n value\n end", "def test_stringflag_as_flag\n @p.opt :xyz, \"desc\", :type => :stringflag\n @p.opt :abc, \"desc\", :type => :flag\n opts = @p.parse %w(--xyz )\n assert_equal true, opts[:xyz_given]\n assert_equal true, opts[:xyz]\n assert_equal false, opts[:abc]\n opts = @p.parse %w(--xyz --abc)\n assert_equal true, opts[:xyz_given]\n assert_equal true, opts[:xyz]\n assert_equal true, opts[:abc]\n end", "def initialize(options={})\n super\n raise ArgumentError, \"arg_name specified for switch: #{arg_name}\" if arg_name\n raise ArgumentError, \"no long specified\" unless long\n @negative_long = Utils.prefix_long(long, 'no-')\n end", "def switch?(parameter)\n return true if %W[true on yes start begin 1].include?(parameter.to_s.downcase)\n return false if %W[false off no stop end 0].include?(parameter.to_s.downcase)\n nil\nend", "def lex_option option\n self.option[option.to_sym] = true\n end", "def normalize_switch raw_switch_arg\n (@shorts[raw_switch_arg] || raw_switch_arg).tr(\"_\", \"-\")\n end", "def options_create opts, colors\n\t\t\t\t#todo create, switch\n\t\t\t\topts.separator \" *\".colorize(colors[:cyan]) + \" create, switch\".colorize(colors[:yellow]) + \n\t\t\t\t\" creates a new list or switches to an existing one\".colorize(colors[:magenta])\n\t\t\t\topts.separator \" usage: \".colorize(colors[:cyan]) + USAGE[:create].colorize(colors[:red])\n\t\t\tend", "def test_stringflag_as_string\n @p.opt :xyz, \"desc\", :type => :stringflag\n @p.opt :abc, \"desc\", :type => :flag\n opts = @p.parse %w(--xyz abcd)\n assert_equal true, opts[:xyz_given]\n assert_equal \"abcd\", opts[:xyz]\n assert_equal false, opts[:abc]\n opts = @p.parse %w(--xyz abcd --abc)\n assert_equal true, opts[:xyz_given]\n assert_equal \"abcd\", opts[:xyz]\n assert_equal true, opts[:abc]\n end", "def parse_boolean(switch)\n if current_is_value?\n if [\"true\", \"TRUE\", \"t\", \"T\", true].include?(peek)\n shift\n true\n elsif [\"false\", \"FALSE\", \"f\", \"F\", false].include?(peek)\n shift\n false\n else\n !no_or_skip?(switch)\n end\n else\n @switches.key?(switch) || !no_or_skip?(switch)\n end\n end", "def switches\n Commandorobo::Utils::consume_switch(@raw.join(' '))\n end", "def switches #:nodoc:\n @switches ||= {}\n end", "def switch_source(options = {})\n\t\treturn {} if preferences.blank?\n\t\tif options[:disabled]\n\t\t\t\"\"\n\t\telsif preferences && preferences[:switch]\n\t\t\tpreferences[:switch].collect { |s| \"switch-#{s}\" }.join(\" \")\n\t\telse\n\t\t\t\"\"\n\t\tend\n\tend", "def switch_statement\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 16 )\n return_value = SwitchStatementReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n\n _last = _first_0 = nil\n string_literal60 = nil\n expression61 = nil\n case_clause62 = nil\n default_clause63 = nil\n\n tree_for_string_literal60 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 95:5: ^( 'switch' expression ( case_clause )* ( default_clause )? )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal60 = match( SWITCH, TOKENS_FOLLOWING_SWITCH_IN_switch_statement_477 )\n\n tree_for_string_literal60 = @adaptor.copy_node( string_literal60 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal60, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_switch_statement_479 )\n expression61 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression61.tree )\n # at line 95:28: ( case_clause )*\n while true # decision 16\n alt_16 = 2\n look_16_0 = @input.peek( 1 )\n\n if ( look_16_0 == CASE )\n alt_16 = 1\n\n end\n case alt_16\n when 1\n # at line 95:28: case_clause\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_case_clause_IN_switch_statement_481 )\n case_clause62 = case_clause\n @state.following.pop\n\n @adaptor.add_child( root_1, case_clause62.tree )\n\n\n else\n break # out of loop for decision 16\n end\n end # loop for decision 16\n # at line 95:41: ( default_clause )?\n alt_17 = 2\n look_17_0 = @input.peek( 1 )\n\n if ( look_17_0 == DEFAULT )\n alt_17 = 1\n end\n case alt_17\n when 1\n # at line 95:41: default_clause\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_default_clause_IN_switch_statement_484 )\n default_clause63 = default_clause\n @state.following.pop\n\n @adaptor.add_child( root_1, default_clause63.tree )\n\n\n end\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 16 )\n\n end\n \n return return_value\n end", "def switches \n @switches ||= {}\n end", "def test_option_key_composed_of_short_long_hint\n\n # Mal-formed named options\n #---------------------------------------------------------------------------\n $stdout.stub(:write, nil){\n\n # No long hand given, long hand is required\n assert_raises(SystemExit){Option.new(\"-s\", nil)}\n assert_raises(SystemExit){Option.new(\"-s=COMPONENTS\", nil)}\n\n # HINT can not include equal symbol\n assert_raises(SystemExit){Option.new(\"--skip=FOO=BAR\", nil)}\n assert_raises(SystemExit){Option.new(\"-s|--skip=FOO=BAR\", nil)}\n\n # Long hand form is invalid\n assert_raises(SystemExit){Option.new(\"--skip|\", nil)}\n assert_raises(SystemExit){Option.new(\"-s|skip\", nil)}\n assert_raises(SystemExit){Option.new(\"-s|=HINT\", nil)}\n assert_raises(SystemExit){Option.new(\"-s|--skip|\", nil)}\n\n # Short hand form is invalid\n assert_raises(SystemExit){Option.new(\"--skip|-s\", nil)}\n assert_raises(SystemExit){Option.new(\"-s, --skip=FOO\", nil)}\n }\n\n # Well-formed named options\n #---------------------------------------------------------------------------\n # long hand only, simple name, flag\n opt = Option.new(\"--skip\", nil)\n assert_nil(opt.hint)\n assert_equal(\"--skip\", opt.key)\n assert_equal(\"--skip\", opt.long)\n assert_nil(opt.short)\n\n # long hand only with dash in name, flag\n opt = Option.new(\"--skip-foo\", nil)\n assert_nil(opt.hint)\n assert_equal(\"--skip-foo\", opt.key)\n assert_equal(\"--skip-foo\", opt.long)\n assert_nil(opt.short)\n\n # long hand only with incoming String value\n opt = Option.new(\"--skip=HINT\", nil, type:String)\n assert_equal(\"HINT\", opt.hint)\n assert_equal(\"--skip\", opt.long)\n assert_nil(opt.short)\n\n # short/long hand simple name, flag\n opt = Option.new(\"-s|--skip\", nil)\n assert_nil(opt.hint)\n assert_equal(\"-s|--skip\", opt.key)\n assert_equal(\"-s\", opt.short)\n assert_equal(\"--skip\", opt.long)\n\n # short/long hand with incoming String value\n opt = Option.new(\"-s|--skip=HINT\", nil, type:String)\n assert_equal(\"HINT\", opt.hint)\n assert_equal(\"-s|--skip=HINT\", opt.key)\n assert_equal(\"-s\", opt.short)\n assert_equal(\"--skip\", opt.long)\n end", "def detect_unsupported_switches!(args)\n return unless (unsupported = UNSUPPORTED_SWITCHES & args).any?\n\n $stdout.puts \"Please set the following switches in your vite.json instead: #{ unsupported }.\"\n exit!\n end", "def set_option(symbol, *opts, &block)\n @mandatory_arguments[symbol] = {:key => symbol, :argument => opts[0], :switch => opts[1]} if opts[3] == true\n if block.nil?\n on(*opts) do |x|\n case symbol\n when :server\n @options[symbol] = @test_options.environments[x]\n else\n @options[symbol] = x\n end\n end\n else\n on(*opts, &block)\n end\n end", "def opt &blk\r\n build_piece Optional, blk\r\n end", "def opt name, desc=\"\", opts={}\n raise ArgumentError, \"you already have an argument named '#{name}'\" if @specs.member? name\n\n ## fill in :type\n opts[:type] = \n case opts[:type]\n when :flag, :boolean, :bool; :flag\n when :int, :integer; :int\n when :string; :string\n when :double, :float; :float\n when Class\n case opts[:type].to_s # sigh... there must be a better way to do this\n when 'TrueClass', 'FalseClass'; :flag\n when 'String'; :string\n when 'Integer'; :int\n when 'Float'; :float\n else\n raise ArgumentError, \"unsupported argument type '#{opts[:type].class.name}'\"\n end\n when nil; nil\n else\n raise ArgumentError, \"unsupported argument type '#{opts[:type]}'\" unless TYPES.include?(opts[:type])\n end\n\n type_from_default =\n case opts[:default]\n when Integer; :int\n when Numeric; :float\n when TrueClass, FalseClass; :flag\n when String; :string\n when nil; nil\n else\n raise ArgumentError, \"unsupported argument type '#{opts[:default].class.name}'\"\n end\n\n raise ArgumentError, \":type specification and default type don't match\" if opts[:type] && type_from_default && opts[:type] != type_from_default\n\n opts[:type] = (opts[:type] || type_from_default || :flag)\n\n ## fill in :long\n opts[:long] = opts[:long] ? opts[:long].to_s : name.to_s.gsub(\"_\", \"-\")\n opts[:long] =\n case opts[:long]\n when /^--([^-].*)$/\n $1\n when /^[^-]/\n opts[:long]\n else\n raise ArgumentError, \"invalid long option name #{opts[:long].inspect}\"\n end\n raise ArgumentError, \"long option name #{opts[:long].inspect} is already taken; please specify a (different) :long\" if @long[opts[:long]]\n\n ## fill in :short\n opts[:short] = opts[:short].to_s if opts[:short] unless opts[:short] == :none\n opts[:short] =\n case opts[:short]\n when nil\n c = opts[:long].split(//).find { |c| c !~ INVALID_SHORT_ARG_REGEX && [email protected]?(c) }\n raise ArgumentError, \"can't generate a short option name for #{opts[:long].inspect}: out of unique characters\" unless c\n c\n when /^-(.)$/\n $1\n when /^.$/\n opts[:short]\n when :none\n nil\n else\n raise ArgumentError, \"invalid short option name '#{opts[:short].inspect}'\"\n end\n if opts[:short]\n raise ArgumentError, \"short option name #{opts[:short].inspect} is already taken; please specify a (different) :short\" if @short[opts[:short]]\n raise ArgumentError, \"a short option name can't be a number or a dash\" if opts[:short] =~ INVALID_SHORT_ARG_REGEX\n end\n\n ## fill in :default for flags\n opts[:default] = false if opts[:type] == :flag && opts[:default].nil?\n\n opts[:desc] ||= desc\n @long[opts[:long]] = name\n @short[opts[:short]] = name if opts[:short]\n @specs[name] = opts\n @order << [:opt, name]\n end", "def make_option_list\n end", "def make_option_list\n end", "def to_switches(options)\n options.map do |key, value|\n case value\n when true\n \"--#{key}\"\n when Array\n \"--#{key} #{value.map { |v| v.inspect }.join(\" \")}\" unless value.empty?\n when Hash\n \"--#{key} #{value.map { |k, v| \"#{k}:#{v}\" }.join(\" \")}\" unless value.empty?\n when nil, false\n \"\"\n else\n \"--#{key} #{value.inspect}\"\n end\n end.join(\" \")\n end", "def getopts(*args)\n argv = Array === args.first ? args.shift : default_argv\n single_options, *long_options = *args\n\n result = {}\n\n single_options.scan(/(.)(:)?/) do |opt, val|\n if val\n result[opt] = nil\n define(\"-#{opt} VAL\")\n else\n result[opt] = false\n define(\"-#{opt}\")\n end\n end if single_options\n\n long_options.each do |arg|\n arg, desc = arg.split(';', 2)\n opt, val = arg.split(':', 2)\n if val\n result[opt] = val.empty? ? nil : val\n define(\"--#{opt}=#{result[opt] || \"VAL\"}\", *[desc].compact)\n else\n result[opt] = false\n define(\"--#{opt}\", *[desc].compact)\n end\n end\n\n parse_in_order(argv, result.method(:[]=))\n result\n end", "def optparse_args\n if short\n [\"--#{name}\", \"-#{short}\", desc, :REQUIRED]\n else\n [\"--#{name}\", desc, :REQUIRED]\n end\n end", "def switches\n [long, negative_long, short].compact\n end", "def create_switch( key, value_filters_map )\n switch = Switch.new\n value_filters_map.each do |value, (filters, listener)|\n create_chain( value.to_s.downcase, filters, listener ) do |chain|\n switch.add_proposition( Selector.new( key, value ), chain )\n end\n end\n switch\n end", "def thor_options_to_optparse\n flags = []\n %i[color progress debug interactive].each do |option|\n if options[option] then flags << \"--#{option}\"\n else flags << \"--no-#{option}\"\n end\n end\n flags\n end", "def parseOption()\n\toptions = {:dryrun => false, :auto => false, :debug => false, :worldcat => true, :rename => false}\n\tOptionParser.new do |opts|\n\t\topts.banner = \"shelfer.rb [options]\"\n\t\topts.version = \"0.1\"\n\n\t\topts.on(\"-fFILE\", \"File to shelf\") { |f| options[:file] = f }\n\t\topts.on(\"-n\", \"Dry-run\") { |n| options[:dryrun] = true }\n\t\topts.on(\"-a\", \"Auto\") { |n| options[:auto] = true }\n\t\topts.on(\"-d\", \"Debug\") { |n| options[:debug] = true }\n opts.on(\"-r\", \"--rename-only\", \"Rename only, no shelfing\") { |n| options[:rename] = true }\n\t\topts.on(\"-w\", \"--noworldcat\", \"Do not use WorldCat\") { |n| options[:worldcat] = false }\n\tend.parse!\n\toptions[:input] = ARGV\n\treturn options\nend", "def method_missing(m)\n\n case m\n when :createproj\n @args[:projectdir] = @options[m]\n @args[m] = true\n \n when :quickpkg\n # raise BoilerMakerErr.new(\"Option -Q: This option is unimplemented.\") \n @args[m] = @options[:quickpkg]\n \n when :projectdir\n unless @options[:createproj] or @options[:tconvert] or @options[:fetch] or @options[:package] or @options[:boil] or @options[:rollup]\n raise BoilerMakerErr.new(\"Option --#{m}: This flag is only useful when combined with: -C, -t, -f or -p\") \n end\n @args[m] = File.expand_path(@options[m])\n unless @options[:createproj]\n raise BoilerMakerErr.new(\"No such file or dir: #{@args[m]}\") unless File.exists?(@args[m])\n end\n \n when :ktcheck\n if @options[:createproj] or @options[:projectdir] or @options[:tconvert] or @options[:fetch]\n raise BoilerMakerErr.new(\"Option --#{m}: This flag is only useful when combined with: -c, -h or -w\") \n end\n raise BoilerMakerErr.new(\"Option --#{m}: Use the -h to specify a Radmind server host\") unless @options[:radhost]\n @args[m] = @options[m]\n \n when :tconvert\n @args[m] = File.expand_path(@options[m])\n raise BoilerMakerErr.new(\"No such file or dir: #{@args[m]}\") unless File.exists?(@args[m])\n \n when :fetch\n raise BoilerMakerErr.new(\"Option --#{m}: Use the -h to specify a Radmind server host\") unless @options[:radhost]\n @args[m] = File.expand_path(@options[m])\n raise BoilerMakerErr.new(\"No such file or dir: #{@args[m]}\") unless File.exists?(@args[m])\n \n when :radhost\n unless @options[:ktcheck] or @options[:fetch]\n raise BoilerMakerErr.new(\"Option --#{m}: This flag is only useful when combined with: -K or -f\") \n end\n @args[m] = @options[m]\n\n when :boil\n @args[m] = @options[m]\n \n when :package\n @args[m] = @options[m]\n\n when :rollup\n @args[m] = @options[m]\n \n when :secure\n unless @options[:ktcheck] or @options[:fetch]\n raise BoilerMakerErr.new(\"Option --#{m}: This flag is only useful when combined with: -K or -f\")\n end\n @args[m] = @options[m]\n\n when :cksum\n unless @options[:ktcheck] or @options[:fetch]\n raise BoilerMakerErr.new(\"Option --#{m}: This flag is only useful when combined with: -K or -f\")\n end\n @args[m] = @options[m]\n \n end\n \n end", "def create\n puts \"(V)oter or (P)olitician\"\n options = gets.chomp.downcase # voter or politician\n case(options)\n when \"v\"\n voterclass\n when \"p\"\n politicianclass\n end\n end", "def parse_options\n @opts = Slop.parse do |o| \n o.string '-f1', '--file1', 'First source file'\n o.string '-f2', '--file2', 'Second source file'\n o.on '-v', '--version' do\n puts Slop::VERSION\n end\n end\n rescue Exception => e\n raise\n end", "def switch\n '-t'\n end", "def switch_statement(var_env)\n return nil unless eql_lit?(ECMA262::ID_SWITCH)\n\n if eql_lit?(ECMA262::PUNC_LPARENTHESIS) and e=exp(var_env, {}) and eql_lit?(ECMA262::PUNC_RPARENTHESIS) and c = case_block(var_env)\n ECMA262::StSwitch.new(e, c)\n else\n raise ParseError.new(\"unexpected token\", self)\n end\n end", "def test_stringflag_with_false_default\n @p.opt :log, \"desc\", :type => :stringflag, default: false\n opts = @p.parse []\n assert_nil opts[:log_given]\n assert_equal false, opts[:log]\n\n opts = @p.parse %w(--no-log)\n assert_equal true, opts[:log_given]\n assert_equal false, opts[:log]\n\n opts = @p.parse %w(--log)\n assert_equal true, opts[:log_given]\n assert_equal true, opts[:log]\n\n opts = @p.parse %w(--log other.log)\n assert_equal true, opts[:log_given]\n assert_equal \"other.log\", opts[:log]\n end", "def switch(name,aliases,desc,long_desc,negatable)\n abstract!\n end", "def options_spec\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 7)\n return_value = OptionsSpecReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n __OPTIONS28__ = nil\n char_literal30 = nil\n char_literal31 = nil\n option29 = nil\n\n tree_for_OPTIONS28 = nil\n tree_for_char_literal30 = nil\n tree_for_char_literal31 = nil\n stream_T__71 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__71\")\n stream_T__72 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__72\")\n stream_OPTIONS = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token OPTIONS\")\n stream_option = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule option\")\n begin\n # at line 140:4: OPTIONS ( option ';' )+ '}'\n __OPTIONS28__ = match(OPTIONS, TOKENS_FOLLOWING_OPTIONS_IN_options_spec_659) \n if @state.backtracking == 0\n stream_OPTIONS.add(__OPTIONS28__)\n end\n # at file 140:12: ( option ';' )+\n match_count_13 = 0\n loop do\n alt_13 = 2\n look_13_0 = @input.peek(1)\n\n if (look_13_0 == TOKEN_REF || look_13_0 == RULE_REF) \n alt_13 = 1\n\n end\n case alt_13\n when 1\n # at line 140:13: option ';'\n @state.following.push(TOKENS_FOLLOWING_option_IN_options_spec_662)\n option29 = option\n @state.following.pop\n if @state.backtracking == 0\n stream_option.add(option29.tree)\n end\n char_literal30 = match(T__71, TOKENS_FOLLOWING_T__71_IN_options_spec_664) \n if @state.backtracking == 0\n stream_T__71.add(char_literal30)\n end\n\n else\n match_count_13 > 0 and break\n @state.backtracking > 0 and raise(ANTLR3::Error::BacktrackingFailed)\n\n eee = EarlyExit(13)\n\n\n raise eee\n end\n match_count_13 += 1\n end\n\n char_literal31 = match(T__72, TOKENS_FOLLOWING_T__72_IN_options_spec_668) \n if @state.backtracking == 0\n stream_T__72.add(char_literal31)\n end\n # AST Rewrite\n # elements: OPTIONS, option\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream(\"rule return_value\", return_value.tree) : subtree_stream(\"token return_value\")\n\n root_0 = @adaptor.create_flat_list!\n # 140:30: -> ^( OPTIONS ( option )+ )\n # at line 140:33: ^( OPTIONS ( option )+ )\n root_1 = @adaptor.create_flat_list!\n root_1 = @adaptor.become_root(stream_OPTIONS.next_node, root_1)\n\n # at line 140:43: ( option )+\n unless stream_option.has_next?\n raise ANTLR3::RewriteEarlyExit\n end\n\n while stream_option.has_next?\n @adaptor.add_child(root_1, stream_option.next_tree)\n\n end\n\n stream_option.reset\n\n @adaptor.add_child(root_0, root_1)\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look(-1)\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing(root_0)\n @adaptor.set_token_boundaries(return_value.tree, return_value.start, return_value.stop)\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node!(@input, return_value.start, @input.look(-1), re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 7)\n\n end\n \n return return_value\n end", "def parse_options_helper(args,global_options,command,command_options,arguments) # :nodoc:\n non_flag_i = find_non_flag_index(args)\n all_flags = false\n if non_flag_i == 0\n # no flags\n if !command\n command_name = args.shift\n command = find_command(command_name)\n raise UnknownCommand.new(\"Unknown command '#{command_name}'\") if !command\n return parse_options_helper(args,\n global_options,\n command,\n Hash.new,\n arguments)\n elsif((index = flag_switch_index(args)) >= 0)\n try_me = args[0..index-1]\n rest = args[index..args.length]\n new_args = rest + try_me\n return parse_options_helper(new_args,\n global_options,\n command,\n Hash.new,\n arguments)\n else\n return global_options,command,command_options,arguments + args\n end\n elsif non_flag_i == -1\n all_flags = true\n end\n\n try_me = args[0..non_flag_i]\n rest = args[(non_flag_i+1)..args.length]\n if all_flags\n try_me = args\n rest = []\n end\n\n # Suck up whatever options we can\n switch_hash = switches\n flag_hash = flags\n options = global_options\n if command\n switch_hash = command.switches\n flag_hash = command.flags\n options = command_options\n end\n\n switch_hash.each do |name,switch|\n value = switch.get_value!(try_me)\n options[name] = value if !options[name]\n end\n\n flag_hash.each do |name,flag|\n value = flag.get_value!(try_me)\n # So, there's a case where the first time we request the value for a flag,\n # we get the default and not the user-provided value. The next time we request\n # it, we want to override it with the real value.\n # HOWEVER, sometimes this happens in reverse, so we want to err on taking the\n # user-provided, non-default value where possible.\n if value\n if options[name]\n options[name] = value if options[name] == flag.default_value\n else\n options[name] = value\n end\n end\n end\n\n if try_me.empty?\n return [global_options,command,command_options,arguments] if rest.empty?\n # If we have no more options we've parsed them all\n # and rest may have more\n return parse_options_helper(rest,global_options,command,command_options,arguments)\n else\n if command\n check = rest\n check = rest + try_me if all_flags\n check.each() do |arg|\n if arg =~ /^\\-\\-$/\n try_me.delete arg\n break\n end\n raise UnknownCommandArgument.new(\"Unknown option #{arg}\",command) if arg =~ /^\\-/\n end\n return [global_options,command,command_options,try_me + rest]\n else\n # Now we have our command name\n command_name = try_me.shift\n raise UnknownGlobalArgument.new(\"Unknown option #{command_name}\") if command_name =~ /^\\-/\n\n command = find_command(command_name)\n raise UnknownCommand.new(\"Unknown command '#{command_name}'\") if !command\n\n return parse_options_helper(rest,\n global_options,\n command,\n Hash.new,\n arguments)\n end\n end\n end", "def switch?(value)\n return true if %W[true on yes start begin 1].include?(value.to_s.downcase)\n return false if %W[false off no stop end 0].include?(value.to_s.downcase)\n nil\n end", "def init\n # Validate and parse the flags\n OptionParser.new do |o|\n o.on('-a ALIAS', '--alias ALIAS') { |a| $alias = a }\n o.on('-r RECIEVER', '--reciever RECIEVER') { |e| $email = e }\n o.on('-h', '--help') { usage }\n o.parse!\n end\nend", "def initiate(opt, enable, who)\n option(opt)\n\n case who\n when :him\n willdo = DO.chr\n wontdont = DONT.chr\n whoq = :himq\n when :us\n willdo = WILL.chr\n wontdont = WONT.chr\n whoq = :usq\n else\n # Error\n end\n\n case @state[opt].send(who)\n when :no\n if enable\n @state[opt].send(\"#{who}=\", :wantyes)\n @pstack.conn.sendmsg(IAC.chr + willdo + opt.chr)\n else\n # Error already disabled\n log.error(\"(#{@pstack.conn.object_id}) Telnet negotiation: option #{opt.to_s} already disabled\")\n end\n when :yes\n if enable\n # Error already enabled\n log.error(\"(#{@pstack.conn.object_id}) Telnet negotiation: option #{opt.to_s} already enabled\")\n else\n @state[opt].send(\"#{who}=\", :wantno)\n @pstack.conn.sendmsg(IAC.chr + wontdont + opt.chr)\n end\n when :wantno\n if enable\n case @state[opt].send(whoq)\n when :empty\n @state[opt].send(\"#{whoq}=\", :opposite)\n when :opposite\n # Error already queued enable request\n log.error(\"(#{@pstack.conn.object_id}) Telnet negotiation: option #{opt.to_s} already queued enable request\")\n end\n else\n case @state[opt].send(whoq)\n when :empty\n # Error already negotiating for disable\n log.error(\"(#{@pstack.conn.object_id}) Telnet negotiation: option #{opt.to_s} already negotiating for disable\")\n when :opposite\n @state[opt].send(\"#{whoq}=\", :empty)\n end\n end\n when :wantyes\n if enable\n case @state[opt].send(whoq)\n when :empty\n #Error already negotiating for enable\n log.error(\"(#{@pstack.conn.object_id}) Telnet negotiation: option #{opt.to_s} already negotiating for enable\")\n when :opposite\n @state[opt].send(\"#{whoq}=\", :empty)\n end\n else\n case @state[opt].send(whoq)\n when :empty\n @state[opt].send(\"#{whoq}=\", :opposite)\n when :opposite\n #Error already queued for disable request\n log.error(\"(#{@pstack.conn.object_id}) Telnet negotiation: option #{opt.to_s} already queued for disable request\")\n end\n end\n end\n end", "def missing_option=(_arg0); end", "def missing_option=(_arg0); end", "def missing_option=(_arg0); end", "def missing_option=(_arg0); end", "def missing_option=(_arg0); end", "def missing_option=(_arg0); end", "def initialize(spec, has_value)\n # Parse spec string\n if(spec =~ /^[a-zA-Z0-9]$/)\n @short_name = spec\n elsif(spec =~ /^[a-zA-Z][\\w\\-]+$/)\n @long_name = spec\n elsif(spec =~ /^([a-zA-Z0-9]),([a-zA-Z][\\w\\-]+)$/)\n @short_name = $1\n @long_name = $2\n else\n raise \"Invalid option spec '#{spec}'\"\n end\n\n # Finish initialization\n @has_value = has_value\n end", "def parse_option(obj, opt, argv)\n x = opt.sub(/^--/, '')\n #if obj.respond_to?(\"#{x}=\")\n obj.send(\"#{x}=\", true)\n #else\n # obj.option_missing(x, true)\n #end\n end", "def getopt opt, hash, default = nil\n keys = opt.respond_to?('each') ? opt : [opt]\n keys.each do |key|\n return hash[key] if hash.has_key? key\n key = \"#{ key }\"\n return hash[key] if hash.has_key? key\n key = key.intern\n return hash[key] if hash.has_key? key\n end\n return default\n end", "def flag(*names)\n names = [names].flatten\n verify_unused(names,flags,switches,\"in global options\")\n flag = Flag.new(names,@@next_desc,@@next_arg_name,@@next_default_value,@@next_long_desc)\n flags[flag.name] = flag\n clear_nexts\n end", "def unshift_split_options argv, initial_boolean_option, remaining_str\n if boolean_option? initial_boolean_option.to_sym\n # boolean option, so put remaining on as option(s)\n argv.unshift \"-\" + remaining_str\n else\n # not a boolean option, so put remaining on as an arg\n argv.unshift remaining_str\n end\n\n # recurse to handle option through regular code paths\n argv.unshift \"-\" + initial_boolean_option\n end", "def parse_smashed(arg)\n opts = {}\n # preceding dash and flag have been removed\n val = arg.dup\n loop {\n break if val.empty?\n char = val.slice!(0, 1)\n sym = @index[:short][char]\n raise \"unknown flag smashed in: #{char} in #{arg}\" unless sym\n\n spec = @option_specs.fetch(sym)\n if spec[:value]\n val.slice!(0, 1) if val[0] == '='\n if val.empty?\n opts[sym] = nil # tell parse() we need another arg; ugh, hack!\n else\n opts[sym] = val\n end\n break # a value always ends the smash\n else\n opts[sym] = true\n end\n }\n opts\n end", "def initialize(option_specs, input = ARGV)\n build_dict(option_specs)\n\n @options = {}\n leftover = []\n until input.empty?\n arg = input.shift\n\n case arg\n # Stop if you hit --\n when '--' \n break \n\n # Long form \n when /^--(\\S+)/\n o, a = $1.split('=', 2)\n input.unshift(a) if a\n input = process_arguments(o, input) \n\n # Short form\n when /^-(\\S+)/\n o, a = $1.split('=', 2)\n input.unshift(a) if a\n o.scan(/./) do |c|\n input = process_arguments(c, input)\n end\n\n # Not an option, leave it\n else\n leftover << arg\n end\n end \n\n # Put what didn't parse back into input\n input.concat(leftover)\n end", "def test_stringflag_unset\n @p.opt :xyz, \"desc\", :type => :stringflag\n @p.opt :abc, \"desc\", :type => :flag\n opts = @p.parse %w()\n assert_equal false, opts[:xyz]\n assert_equal false, opts[:abc]\n opts = @p.parse %w(--abc)\n assert_equal false, opts[:xyz]\n assert_equal true, opts[:abc]\n end", "def prepare_options(opts = [])\n opts.inject('') do |string, (option, value)|\n string += case\n when value\n create_option(option, value)\n when option.respond_to?(:each_pair)\n prepare_options(option)\n else\n create_option(option)\n end\n end\n end", "def parse_specific_options(parser)\n parser.separator \"\"\n parser.separator \"Specific options:\"\n\n parser.on(\"-d\", \"--dry-run\", \"Run without pdf generation\") do |contents_template|\n options.task = :dry\n end\n\n parser.on(\"-m\", \"--merge-config [CONFIG]\",\n \"Merge config with key from .texasrc\") do |key|\n options.merge_config = key\n end\n\n parser.on(\"-n\", \"--new [NAME]\",\n \"Create new texas project directory\") do |name|\n options.task = :new_project\n options.check_mandatory_arguments = false\n options.load_local_libs = false\n options.new_project_name = name\n end\n\n parser.on(\"-r\", \"--require [LIBRARY]\", \"Require library before running texas\") do |lib|\n # this block does nothing\n # require was already performed by lookup_and_execute_require_option\n # this option is here to ensure the -r switch is listed in the help option\n end\n\n parser.on(\"--watch\", \"Watch the given template\") do |contents_template|\n options.task = :watch\n options.open_pdf = false\n end\n end", "def optionMapping(options, name, mes = false)\n # in this method I recieve the missing options for a given choice which I \n # then map over and add to the global string \n # incase this method wants to be used by another program for example the rspec\n # I have added the mes variable if given a string it will use that string instead of\n # what was left over from a previous method\n mes ? $message = mes : \"\"\n string = name + \":\"\n options.map do |n, i|\n # if value isn't the first options a comma is added to the start of the \n # word to separate it from the one before it\n options.keys[0] === n ? string = string + \" \" + n : string = string + \", \" + n \n\n end\n $message = $message + string + \"\\n\"\nend", "def test_add_option02d\n assert_raise( RuntimeError ) { \n ArgumentManager.add_option(\n [ 'f' ],\n :bind => 'boolean opt'\n )\n }\n end", "def update_option_switch_selection(option_switch)\n if Input.trigger?(Input::B)\n Sound.play_cancel\n cancel_command()\n elsif Input.repeat?(Input::LEFT) || Input.repeat?(Input::RIGHT)\n old_val = $game_switches[option_switch]\n if Input.trigger?(Input::LEFT)\n $game_switches[option_switch] = true\n elsif Input.trigger?(Input::RIGHT)\n $game_switches[option_switch] = false\n end\n if old_val != $game_switches[option_switch]\n Sound.play_cursor\n @system_window.window_update()\n end\n end\n end", "def expect_usage_option(short_switch, long_switch, description)\n expected_switch = \"-#{Regexp.escape(short_switch)}, --#{Regexp.escape(long_switch)}[ ]+#{Regexp.escape(description)}\"\n expect_output(Regexp.new(expected_switch))\n end", "def parse_value val\n case\n when val == nil then true # --flag option on its own means 'set that option'\n when val == '' then nil # --flag='' the explicit empty string means nil\n else val # else just return the value\n end\n end", "def parse_cmd_opts!\n @to_a=nil\n# puts \"@cmd_opts = #{@cmd_opts.inspect}\"\n\n if x = cmd_opts[:_]\n cmd_opts.delete(:_)\n @select_constraint = x\n end\n\n if x = cmd_opts[:T]\n @select_top_level = true\n @select_available = false\n @select_required = false\n end\n\n if x = cmd_opts[:A]\n @select_available = x\n @select_required = false\n @select_top_level = false\n end\n\n if x = cmd_opts[:R]\n @select_required = x\n @select_available = false\n @select_top_level = false\n end\n\n if x = cmd_opts[:D]\n @select_dependencies = x\n end\n\n self\n end", "def switches\n [short, long].map(&:to_s)\n end", "def _add_question=(switch)\n self.add_blank_question if switch == \"1\"\n end", "def make_flag(options)\n\tflagString=\" \"\n\tif(options.list != nil)\n\t\tflagString+=\" -l\"\n\tend\n\tif(options.all != nil)\n\t\tflagString+= \" -a\"\n\tend\n\treturn flagString\nend", "def parse(options, args)\n # Return empty hash if the parsing adventure would be fruitless.\n return {} if options.nil? || !options || args.nil? || !args.is_a?(Array)\n\n # Operate on a copy of the inputs\n args = args.dup\n\n # If we are passed an array, make the best of it by converting it\n # to a hash.\n options = options.inject({}) do |hash, value|\n value.is_a?(Array) ? hash.merge(value.first => value[1]) : hash\n end if options.is_a? Array\n\n # Define local hashes we're going to use. choices is where we store\n # the actual values we've pulled from the argument list.\n hashes, longs, required, validators, choices, arrayed = {}, {}, {}, {}, {}, {}\n hard_required = {}\n\n # We can define these on the fly because they are all so similar.\n params = %w[short cast filter action default valid]\n params.each { |param| hashes[\"#{param}s\"] = {} }\n\n # Inspect each option and move its info into our local hashes.\n options.each do |name, obj|\n name = name.to_sym\n\n # Only take hashes or hash-like duck objects.\n raise HashExpectedForOption unless obj.respond_to? :to_h\n obj = obj.to_h\n\n # Is this option required?\n hard_required[name] = true if obj['required']\n\n # Set the local hashes if the value exists on this option object.\n params.each { |param| hashes[\"#{param}s\"][name] = obj[param] if obj[param] }\n\n # If there is a validate statement, make it a regex or proc.\n validators[name] = make_validation(obj['validate']) if obj['validate']\n\n # Parse the long option. If it contains a =, figure out if the\n # argument is required or optional. Optional arguments are formed\n # like [=ARG], whereas required are just ARG (in --long=ARG style).\n if obj['long'] && obj['long'] =~ /(=|\\[| )/\n # Save the separator we used, as we're gonna need it, then split\n sep = $1\n option, *argument = obj['long'].split(sep)\n\n # The actual name of the long switch\n longs[name] = option\n\n # Preserve the original argument, as it may contain [ or =,\n # by joining with the character we split on. Add a [ in front if\n # we split on that.\n argument = (sep == '[' ? '[' : '') << Array(argument).join(sep)\n\n # Do we expect multiple arguments which get turned into an array?\n arrayed[name] = true if argument =~ /^\\[?=?\\*(.+)\\]?$/\n\n # Is this long required or optional?\n required[name] = true unless argument =~ /^\\[=?\\*?(.+)\\]$/\n elsif obj['long']\n # We can't have a long as a switch when valid is set -- die.\n raise ArgumentRequiredWithValid if obj['valid']\n\n # Set without any checking if it's just --long\n longs[name] = obj['long']\n end\n\n # If we were given a list of valid arguments with 'valid,' this option\n # is definitely required.\n required[name] = true if obj['valid']\n end\n\n rest = []\n\n # Go through the arguments and try to figure out whom they belong to\n # at this point.\n while arg = args.shift\n if hashes['shorts'].value?(arg)\n # Set the value to the next element in the args array since\n # this is a short.\n\n # If the next argument isn't a value, set this value to true\n if args.empty? || args.first.match(/^-/)\n value = true\n else\n value = args.shift\n end\n\n # Add this value to the choices hash with the key of the option's\n # name. If we expect an array, tack this argument on.\n name = hashes['shorts'].key(arg)\n if arrayed[name]\n choices[name] ||= []\n choices[name] << value unless value.nil?\n choices[name] += arrayize_arguments(args)\n else\n choices[name] = value\n end\n\n elsif (m = arg.match(/^(--[^=]+)=?/)) && longs.value?(m[1])\n # The joke here is we always accept both --long=VALUE and --long VALUE.\n\n # Grab values from --long=VALUE format\n name, value = arg.split('=', 2)\n name = longs.key(name)\n\n if value.nil? && args.first !~ /^-/\n # Grab value otherwise if not in --long=VALUE format. Assume --long VALUE.\n # Value is nil if we don't have a = and the next argument is no good\n value = args.shift\n end\n\n # If we expect an array, tack this argument on.\n if arrayed[name]\n # If this is arrayed and the value isn't nil, set it.\n choices[name] ||= []\n choices[name] << value unless value.nil?\n choices[name] += arrayize_arguments(args)\n else\n # If we set the value to nil, that means nothing was set and we\n # need to set the value to true. We'll find out later if that's\n # acceptable or not.\n choices[name] = value.nil? ? true : value\n end\n\n else\n # If we're here, we have no idea what the passed argument is. Die.\n if arg =~ /^-/\n raise UnknownOption\n else\n rest << arg\n end\n end\n end\n\n # Okay, we got all the choices. Now go through and run any filters or\n # whatever on them.\n choices.each do |name, value|\n # Check to make sure we have all the required arguments.\n raise ArgumentRequired if required[name] && value === true\n\n # Validate the argument if we need to, against a regexp or a block.\n if validators[name]\n if validators[name].is_a?(Regexp) && validators[name] =~ value\n elsif validators[name].is_a?(Proc) && validators[name].call(value)\n else raise ArgumentValidationFails\n end\n end\n\n # Make sure the argument is valid\n raise InvalidArgument unless Array(value).all? { |v| hashes['valids'][name].include?(v) } if hashes['valids'][name]\n\n # Cast the argument using the method defined in the constant hash.\n value = value.send(CAST_METHODS[hashes['casts'][name]]) if hashes['casts'].include?(name)\n\n # Run the value through a filter and re-set it with the return.\n value = hashes['filters'][name].call(value) if hashes['filters'].include?(name)\n\n # Run an action block if there is one associated.\n hashes['actions'][name].call(value) if hashes['actions'].include?(name)\n\n # Now that we've done all that, re-set the element of the choice hash\n # with the (potentially) new value.\n if arrayed[name] && choices[name].empty?\n choices[name] = true\n else\n choices[name] = value\n end\n end\n\n # Die if we're missing any required arguments\n hard_required.each do |name, value|\n raise ArgumentRequired unless choices[name]\n end\n\n # Home stretch. Go through all the defaults defined and if a choice\n # does not exist in our choices hash, set its value to the requested\n # default.\n hashes['defaults'].each do |name, value|\n choices[name] = value unless choices[name]\n end\n\n # Return the choices hash and the rest of the args\n [ choices, rest ]\n end", "def options_spec\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 7 )\n return_value = OptionsSpecReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n __OPTIONS28__ = nil\n char_literal30 = nil\n char_literal31 = nil\n option29 = nil\n\n tree_for_OPTIONS28 = nil\n tree_for_char_literal30 = nil\n tree_for_char_literal31 = nil\n stream_T__71 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__71\" )\n stream_T__72 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__72\" )\n stream_OPTIONS = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token OPTIONS\" )\n stream_option = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule option\" )\n begin\n # at line 131:4: OPTIONS ( option ';' )+ '}'\n __OPTIONS28__ = match( OPTIONS, TOKENS_FOLLOWING_OPTIONS_IN_options_spec_654 )\n if @state.backtracking == 0\n stream_OPTIONS.add( __OPTIONS28__ )\n end\n # at file 131:12: ( option ';' )+\n match_count_13 = 0\n while true\n alt_13 = 2\n look_13_0 = @input.peek( 1 )\n\n if ( look_13_0 == TOKEN_REF || look_13_0 == RULE_REF )\n alt_13 = 1\n\n end\n case alt_13\n when 1\n # at line 131:13: option ';'\n @state.following.push( TOKENS_FOLLOWING_option_IN_options_spec_657 )\n option29 = option\n @state.following.pop\n if @state.backtracking == 0\n stream_option.add( option29.tree )\n end\n char_literal30 = match( T__71, TOKENS_FOLLOWING_T__71_IN_options_spec_659 )\n if @state.backtracking == 0\n stream_T__71.add( char_literal30 )\n end\n\n else\n match_count_13 > 0 and break\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n eee = EarlyExit(13)\n\n\n raise eee\n end\n match_count_13 += 1\n end\n\n char_literal31 = match( T__72, TOKENS_FOLLOWING_T__72_IN_options_spec_663 )\n if @state.backtracking == 0\n stream_T__72.add( char_literal31 )\n end\n # AST Rewrite\n # elements: OPTIONS, option\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 131:30: -> ^( OPTIONS ( option )+ )\n # at line 131:33: ^( OPTIONS ( option )+ )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( stream_OPTIONS.next_node, root_1 )\n\n # at line 131:43: ( option )+\n stream_option.has_next? or raise ANTLR3::RewriteEarlyExit\n\n while stream_option.has_next?\n @adaptor.add_child( root_1, stream_option.next_tree )\n\n end\n stream_option.reset\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 7 )\n\n end\n \n return return_value\n end", "def parse_def(opt)\n\t\t# Determines for definition string: class, body and default.\n\t\t# The determined class is either a special one (by signature at the beginning),\n\t\t# a \"value_option\" (by a '=' in the string) or otherwise a \"plain_option\".\n\t\tklass = nil\n\t\tword = opt\n\t\t@special_class.keys.each do |sig|\n\t\t\tif opt.index(sig) == 0\n\t\t\t\tword = opt[sig.length .. -1]\n\t\t\t\tklass = @special_class[sig]\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\t\teqs = /=/\n\t\tif eqs.match word\n\t\t\tbody, value = word.split(eqs, 2)\n\t\t\tvalue = nil if value.empty?\n\t\t\tklass ||= @value_option\n\t\telse\n\t\t\tbody = word\n\t\t\tvalue = nil\n\t\t\tklass ||= @plain_option\n\t\tend\n\t\t[klass, body, value]\n\tend", "def option(sym, default = nil, &block)\n _defmetasyntax(\"option\", _intern(sym), block) {|target|\n seq() { default } | seq(sym)\n }\n end", "def setup_switch_case\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n act_result = nil\n act_hash = @acts[1]\n \n # Get valid action key\n act_hash.each do |cond, action_key|\n bool = false\n begin\n # Try to evaluate script\n bool = eval(cond)\n rescue StandardError => err\n # Blame script user if error :v\n display_error(\"[#{SEQUENCE_CASE},]\",err)\n end\n next unless bool # If condition valid\n act_result = action_key # Assign action key\n break # Break loop checking\n end\n \n # Evaluate action key\n return unless act_result\n is_array = act_result.is_a?(Array)\n \n # If nested array (triggered if first element is array)\n if is_array && act_result[0].is_a?(Array)\n act_result.each do |action|\n next unless action.is_a?(Array)\n @acts = action\n execute_sequence\n end\n # If normal array\n elsif is_array\n @acts = act_result\n execute_sequence\n else\n @acts = [:action, act_result]\n execute_sequence\n end\n end", "def task1(argument, option:)\nend", "def default_if_not_specified(opt,default_opt)\n opt ? opt : default_opt\nend", "def parse_options(opts)\n # rubocop:disable Layout/FirstArgumentIndentation\n opts.banner =\n\"Usage: #{$PROGRAM_NAME} -w <warehouse> -s <service> -o <output directory>\n\nWrite DNS resolver stub declarations from a Palletjack warehouse\ninto Salt state configuration for unbound.\n\nE.g.\n palletjack2unbound -w /etc/salt/respository/warehouse \\\\\n -s example-com \\\\\n -o /etc/salt/repository/state/unbound/files\"\n # rubocop:enable Layout/FirstArgumentIndentation\n\n opts.on('-o DIR', '--output DIR', 'output directory', String) {|dir|\n options[:output] = dir\n options[:conf_dir] = \"#{dir}/conf.d\"\n options[:local_dir] = \"#{dir}/local.d\"\n }\n opts.on('-s SERVICE', '--service SERVICE',\n 'service name for global configuration', String) {|service|\n options[:service] = service\n }\n\n required_option :output\n required_option :service\n end", "def parse_flags(obj, opt, args)\n x = opt.sub(/^-/, '')\n #c = 0\n x.split(//).each do |k|\n #if obj.respond_to?(\"#{k}=\")\n obj.send(\"#{k}=\", true)\n #else\n # obj.option_missing(x, true)\n #end\n end\n end", "def parse_option\n case params[:option]\n when \"id\", \"single_id\"\n # Render the id select field.\n \"shared/id_select\"\n when \"id_list\", \"id_array\"\n # Render the id multi select field.\n \"shared/id_multi_select\"\n when \"conditions_array\", \"conditions_hash\"\n # Render the conditions fields.\n @partial = \"shared/conditions\"\n when \"sub_method\", \"amount\", \"dynamic_find_by\", \"batches\", \"attributes\"\n # Render the corresponding option field(s).\n params[:option]\n end\n end", "def switch\n return true if @switch.nil?\n return true if @switch == 0\n if @switch.is_a?(Integer)\n $game_switches[@switch]\n else\n $game_settings[@switch]\n end\n end", "def option(*args, &block)\n #p [:option, args, :optional, optional?]\n key_values, args = args.partition{ |x| x.kind_of?(Hash)}\n key_values = key_values.inject({ }){ |hash, kv| hash.merge(kv)}\n\n errors = []\n\n # handle optional/required flipflop\n if optional?\n required = { :default => nil }\n if key_values.delete(:required)\n if key_values.key?(:optional)\n errors << \"Can't specify both :required and :optional\"\n end\n if key_values.key?(:default)\n errors << \"Can't specify both :required and :default\"\n end\n required = { }\n elsif key_values.delete(:optional) && !key_values.key?(:default)\n required = { :default => nil }\n end\n else\n key_values.delete(:required)\n required = { }\n end\n args = [{ :using => Option }.merge(required).merge(key_values), *args]\n da = has(*args, &block)\n if errors.size > 0\n raise ArgumentError, \"#{da.name}: #{errors.join(', ')}\", [caller[-1]]\n end\n da.instance_eval do\n #p [:checking_values, values, values.class]\n if da.values.kind_of?(Range)\n must \"be in range #{da.values}\" do |s|\n da.values.include?(s)\n end\n elsif da.values.respond_to?(:size) && da.values.size > 0\n must \"be one of #{da.values.join(', ')}\" do |s|\n da.values.include?(s)\n end\n end\n if da.match\n must \"match pattern #{da.match.inspect}\" do |s|\n #p [:matching, s, da.match.inspect]\n s.to_s =~ da.match\n end\n end\n end\n da\n end", "def switch(name,aliases,desc,long_desc,negatable)\n if negatable\n name = \"[no-]#{name}\" if name.to_s.length > 1\n aliases = aliases.map { |_| _.to_s.length > 1 ? \"[no-]#{_}\" : _ } \n end\n invocations = ([name] + aliases).map { |_| add_dashes(_) }.join('|')\n @io.puts \"#{@nest}=== #{invocations}\"\n @io.puts String(desc).strip\n @io.puts\n @io.puts String(long_desc).strip\n @io.puts\n end", "def make_opts(s)\r\n opts = {}\r\n s.split(';').each do |part|\r\n args = part.split('=')\r\n opts[args[0]] = args[1]\r\n end\r\n RIAPI::parse_params(opts)\r\nend", "def test_parse05a\n ArgumentManager.add_option( [ 'v-opt' ], :type => :string, :mandatory => true )\n \n assert_raise( RuntimeError ) {\n options = ArgumentManager.parse( [ '--u-opt=foo' ] )\n }\n end", "def option\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 8)\n return_value = OptionReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n char_literal33 = nil\n id32 = nil\n option_value34 = nil\n\n tree_for_char_literal33 = nil\n stream_LABEL_ASSIGN = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token LABEL_ASSIGN\")\n stream_id = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule id\")\n stream_option_value = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule option_value\")\n begin\n # at line 144:9: id '=' option_value\n @state.following.push(TOKENS_FOLLOWING_id_IN_option_693)\n id32 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add(id32.tree)\n end\n char_literal33 = match(LABEL_ASSIGN, TOKENS_FOLLOWING_LABEL_ASSIGN_IN_option_695) \n if @state.backtracking == 0\n stream_LABEL_ASSIGN.add(char_literal33)\n end\n @state.following.push(TOKENS_FOLLOWING_option_value_IN_option_697)\n option_value34 = option_value\n @state.following.pop\n if @state.backtracking == 0\n stream_option_value.add(option_value34.tree)\n end\n # AST Rewrite\n # elements: LABEL_ASSIGN, id, option_value\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream(\"rule return_value\", return_value.tree) : subtree_stream(\"token return_value\")\n\n root_0 = @adaptor.create_flat_list!\n # 144:29: -> ^( '=' id option_value )\n # at line 144:32: ^( '=' id option_value )\n root_1 = @adaptor.create_flat_list!\n root_1 = @adaptor.become_root(stream_LABEL_ASSIGN.next_node, root_1)\n\n @adaptor.add_child(root_1, stream_id.next_tree)\n @adaptor.add_child(root_1, stream_option_value.next_tree)\n\n @adaptor.add_child(root_0, root_1)\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look(-1)\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing(root_0)\n @adaptor.set_token_boundaries(return_value.tree, return_value.start, return_value.stop)\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node!(@input, return_value.start, @input.look(-1), re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 8)\n\n end\n \n return return_value\n end" ]
[ "0.7106335", "0.66314226", "0.63676155", "0.6356591", "0.6319967", "0.6226244", "0.6107747", "0.594925", "0.59243083", "0.59128886", "0.5761938", "0.573902", "0.5707391", "0.5636656", "0.5626769", "0.5619589", "0.5597715", "0.5506363", "0.54627615", "0.5454238", "0.5394043", "0.5378509", "0.535772", "0.5275731", "0.5239133", "0.5223887", "0.52235866", "0.5196994", "0.5193213", "0.51790607", "0.51686233", "0.5157276", "0.5155195", "0.51514524", "0.5143453", "0.513125", "0.51271236", "0.5077222", "0.50721663", "0.50721663", "0.50453204", "0.50428015", "0.50349647", "0.5034879", "0.5019405", "0.5018461", "0.501152", "0.50082433", "0.50055045", "0.4998321", "0.4969", "0.49669728", "0.49612635", "0.49599868", "0.4952485", "0.49523434", "0.49267063", "0.4908364", "0.49074024", "0.48964354", "0.48964354", "0.48964354", "0.48964354", "0.48964354", "0.48964354", "0.48896164", "0.4887775", "0.48767227", "0.48741853", "0.48727325", "0.4864552", "0.48622546", "0.48618415", "0.48503155", "0.48474175", "0.48456055", "0.48416412", "0.4838107", "0.48359376", "0.48327115", "0.48324594", "0.48290014", "0.48200798", "0.48192498", "0.48177385", "0.48119307", "0.48021662", "0.4800179", "0.47897616", "0.47886455", "0.47800052", "0.47782937", "0.47765365", "0.4775959", "0.47714096", "0.47682604", "0.47629955", "0.4759003", "0.47512162", "0.47498325" ]
0.7906773
0
Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash) array = [] array = name_hash.collect { |key, value| value } array.sort! array = name_hash.collect { |key, value| value == array.first ? key : nil } array.find { |item| item != nil } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |k, v|\n if v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n smallest_value = nil\n smallest_key = nil\n hash.each do |name, num|\n if smallest_value == nil || num < smallest_value\n smallest_value = num\n smallest_key = name\n end\n end\n smallest_key\nend", "def key_for_min_value(hash)\n min_val = Float::INFINITY\n min_key = nil\n hash.each do |key, value|\n if value < min_val\n min_val = value\n min_key = key\n end\n end\n min_key\nend", "def key_for_min_value(hash)\n \n min_val = Float::INFINITY\n min_key = nil\n hash.each do |k, v|\n if min_val > v\n min_val = v\n min_key = k\n end\n end\n return min_key\nend", "def key_for_min_value(hash)\n smallest_key = nil\n tiny_value = nil\n hash.each do |key, value|\n if tiny_value == nil || value < tiny_value\n tiny_value = value\n smallest_key = key\n end\n end\n smallest_key\nend", "def key_for_min_value(hash)\n smallest = nil\n key = nil\n hash.collect do |name, val|\n if smallest == nil || val < smallest\n smallest = val\n key = name\n end\n end\n key\nend", "def key_for_min_value(hash)\n int_hash = hash.select { |key, val| val.class == Fixnum }\n smallest = int_hash[int_hash.keys.sample]\n # debugger\n int_hash.each do |key, val|\n if val < smallest\n smallest = val \n end\n end\n int_hash.key(smallest)\nend", "def key_for_min_value(hash)\r\n smallest_key = nil\r\n tiniest_value = nil\r\n hash.each do |key, value|\r\n if tiniest_value == nil || value < tiniest_value\r\n tiniest_value = value\r\n smallest_key = key\r\n end\r\n end\r\n smallest_key\r\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = 0\n\n\n hash.each do |key,value|\n if lowest_value == 0 || value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n min = nil\n hash.each_pair do |key, value|\n min ||= value\n min = value if value < min\n end\n hash.key(min)\nend", "def key_for_min_value(hash)\n smallest = nil\n hash.each do |key, value|\n if smallest == nil\n smallest = key\n end\n if hash[key] < hash[smallest]\n smallest = key\n end\n end\n smallest\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k, v|\n if lowest_value == nil || v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k, v|\n if lowest_value == nil || v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n smallest_key = nil\n tiniest_value = nil\n hash.each do |key, value|\n if tiniest_value == nil || value < tiniest_value\n \n # this way, the smallest value in the hash so far always overwrites the existing tiniest value\n \n tiniest_value = value\n smallest_key = key\n end\n end\n smallest_key\nend", "def key_for_min_value(hash)\n hash_key = nil\n hash_value = nil\n hash.each do |key, value|\n if hash_value == nil || value < hash_value\n hash_value = value\n hash_key = key\n end\n end\n hash_key\nend", "def key_for_min_value(hash)\n min_key = nil\n hash.each do |key, value|\n if min_key.nil?\n min_key = key\n elsif value < hash[min_key]\n min_key = key\n else\n next\n end\n end\n min_key\nend", "def key_for_min_value(hash)\n min_key = nil\n hash.each do |key, value|\n if min_key.nil?\n min_key = key\n elsif value < hash[min_key]\n min_key = key\n else\n next\n end\n end\n min_key\nend", "def key_for_min_value(hash)\n min = 99999999\n min_key = nil\n hash.select do |key, value|\n if value < min\n min = value\n min_key = key\n end\n end\n min_key\nend", "def key_for_min_value(hash)\n key = nil\n lowest_value = nil\n hash.each do |name, value|\n if lowest_value == nil || value < lowest_value\n lowest_value = value\n key = name\n end\nend\nkey\nend", "def key_for_min_value(hash)\n if hash.empty?\n return nil\n end\n ans = [hash.first[0],hash.first[1]]\n hash.each do |k,v|\n if v < ans[1]\n ans[1] = v\n ans[0] = k\n end\n end\n return ans[0]\nend", "def key_for_min_value(hash)\n hash_key = nil\n hash_value = nil\n hash.each do |a, b|\n if hash_value == nil || b < hash_value\n hash_value = b\n hash_key = a\n end\n end\n hash_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil \n hash.each do |key, value|\n if lowest_value == nil || value < lowest_value \n lowest_value = value \n lowest_key = key \n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n lowestnum = 1000\n name_hash.each_value do |hashvalue|\n if hashvalue < lowestnum\n lowestnum = hashvalue\n end\n end\n name_hash.index(lowestnum)\nend", "def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_number = nil\n name_hash.each do |name, number|\n if lowest_number == nil || number < lowest_number\n lowest_number = number\n lowest_key = name\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k,v|\n # first iteration\n ## this creates a starting point for comparison\n if lowest_value == nil || lowest_value > v\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n low = Float::INFINITY\n name_hash.each do |k,v|\n if v < low\n low = v\n end\n end\n name_hash.key(low)\nend", "def key_for_min_value(hash)\n small_key = nil\n small_value = nil\n \n hash.each do |key, value|\n if small_value == nil || value < small_value\n small_value = value\n small_key = key\n end\nend\nsmall_key\nend", "def key_for_min_value(hash)\n low_min = 1000\n min_key = nil\n hash.each do |key, value|\n if(low_min > value)\n low_min = value\n min_key = key\n end\nend\n min_key\nend", "def key_for_min_value(name_hash)\n lowest = nil\n key = nil\n if name_hash.length == 0\n return \n end\n \n name_hash.each do |name, number|\n if lowest == nil\n lowest = number\n end\n if key == nil\n key = name\n end\n if number < lowest\n lowest = number\n key = name\n end\n end\n key\nend", "def key_for_min_value(hash)\n least_value = nil \n least_key = nil\n hash.each do |a, b|\n if least_value == nil || b < least_value\n least_value = b\n least_key = a\n end\n end\n least_key\nend", "def key_for_min_value(name_hash)\n\tif name_hash == {}\n\t\tnil\n\tend\n\n\tsmallest_key = nil\n\tsmallest_value = nil\n\tname_hash.each do |key, value|\n\t\tif !smallest_value || value < smallest_value\n\t\t\tsmallest_key = key\n\t\t\tsmallest_value = value\n\t\tend\n\tend\n\tsmallest_key\nend", "def key_for_min_value(hash)\n i = 0\n lowest1 = :key\n lowest = 0\n if hash.empty? == true \n return nil\n end\n hash.each do |name, value|\n if i == 0\n lowest1 = name\n lowest = value\n i =+ 1\n end\n if value < lowest\n lowest1 = name\n lowest = value\n end\n if hash.empty? == true \n lowest1 = nil\n end\n end\n lowest1\nend", "def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n name_hash.each do |name, amount|\n if amount < lowest_value\n lowest_value = amount\n lowest_key = name\n end\n end\n lowest_key\n end", "def key_for_min_value(hash)\n lo_key = nil \n lo_value = nil \n hash.each do |k,v| \n if lo_key == nil || v < lo_value\n lo_key = k \n lo_value = v \n end \n end \n lo_key\n end", "def key_for_min_value(hash)\n\n lowest_key = nil \n lowest_value = nil \n \n hash.each do |key,value|\n if lowest_value == nil || lowest_value > value\n\n lowest_key = key\n lowest_value = value \n end \n \n end \n lowest_key\nend", "def key_for_min_value(name_hash)\n small_num = Float::INFINITY\n smallest_key = \"\"\n if name_hash.length == 0\n return nil\n end\n name_hash.each do |key, value|\n if value < small_num\n small_num = value\n smallest_key = key\n end\n end\nsmallest_key\nend", "def key_for_min_value(hash)\n value_only_array = []\n hash.each_pair do |key, value|\n value_only_array << value\n end\n value_only_array.sort!\n hash.key(value_only_array[0])\nend", "def key_for_min_value(hash)\n return nil if hash.empty?\n arr = hash.collect {|key, value| value}.sort\n hash.each {|key, value| return key if value == arr[0]}\nend", "def key_for_min_value(hash)\n array = []\n hash.each do |key, value|\n array << value\n end\n array.sort!\n hash.key(array[0])\nend", "def key_for_min_value(name_hash)\n lowest_key=nil\n lowest_value=Float::INFINITY\n name_hash.each{|key, value| \n if value<lowest_value\n lowest_value=value\n lowest_key=key\n end\n }\n lowest_key\nend", "def key_for_min_value(name_hash)\n empty_hash = nil\n lowest_value = 10000000000000000000000\n name_hash.collect do |name, value|\n if value < lowest_value\n lowest_value = value\n empty_hash = name\n end\n end\n empty_hash\nend", "def key_for_min_value(name_hash)\n lowest = \"\"\n lowest = nil if name_hash.empty?\n high_num = 100000000000000000\n name_hash.each do | key, value |\n lowest = key if value < high_num\n high_num = value if value < high_num\n end\n lowest\nend", "def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = nil\n name_hash.each do |name, num|\n if lowest_key == nil || num < lowest_value\n lowest_key = name\n lowest_value = num\n elsif name_hash == nil\n nil\n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n num = nil\n name_hash.collect do |key, value|\n if value < num\n num = value\n end\n end \n name_hash.key(num)\nend", "def key_for_min_value(name_hash)\n smallest_val = 0\n smallest_key = nil\n name_hash.each do|key, val|\n if smallest_val == 0 || val < smallest_val\n smallest_val = val\n smallest_key = key\n end\n end\n smallest_key\n\nend", "def key_for_min_value(name_hash)\n smallest_hash_key = nil\n name_hash.each do |key, val|\n if smallest_hash_key == nil\n smallest_hash_key = key\n next\n elsif val < name_hash[smallest_hash_key]\n smallest_hash_key = key\n end\n end\n smallest_hash_key\nend", "def key_for_min_value(name_hash)\n return nil if name_hash.empty?\n lowest_number = name_hash.first[1];\n key_value = \"\"\n name_hash.each do |key, value|\n if value <= lowest_number\n lowest_number = value\n key_value = key\n end\n end\n key_value\nend", "def key_for_min_value(hash)\n if hash.count < 2\n return hash[0]\n else \n num = 42\n hash.each do |key, value|\n if value <= num\n num = value\n end\n end\n hash.invert[num] \n end\nend", "def key_for_min_value(name_hash)\n current = 0\n lowest = 0\n lowest_key = nil\n name_hash.collect do |key, value|\n current = value\n if current < lowest || lowest == 0\n lowest = current\n lowest_key = key\n end\n\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n lowest_key = nil\n lowestvalue = 1000\n name_hash.each do |name, value|\n if value < lowestvalue\n lowest_key = name\n lowestvalue = value\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_value = nil\n lowest_key = nil\n\n hash.each do |key, value|\n if lowest_value == nil # tell me if this makes sense\n lowest_value = value\n lowest_key = key\n elsif lowest_value > value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key #you want to return the key for min\nend", "def key_for_min_value(name_hash)\n small_value = 10000000000\n small_key = nil\n name_hash.each do |k,v|\n if v < small_value\n small_value = v\n small_key = k\n end\n end\n small_key\nend", "def key_for_min_value(name_hash)\n low_key = nil\n low_value = nil\n name_hash.each do |k, v|\n if low_value == nil || v < low_value\n low_value = v\n low_key = k\n end\n end\n low_key\n end", "def key_for_min_value(hash)\n \n if hash.empty?\n return nil\n end\n min_value=500\n min_key=:symbol\n \n hash.each do |key, value|\n if value<min_value\n min_value=value\n min_key=key\n end\n end\n return min_key\nend", "def key_for_min_value(name_hash)\n lowestKey = nil\n lowestValue = Float::INFINITY\n name_hash.each do |k, v|\n if v < lowestValue\n lowestValue = v\n lowestKey = k\n end\n end\n lowestKey\n\nend", "def key_for_min_value(name_hash)\n smallest_val = 0\n smallest_key = 0\n comp = nil\n name_hash.each do |key,val|\n comp = val\n if smallest_key == 0\n smallest_key = key\n smallest_val = val\n end \n if comp < smallest_val\n smallest_val = comp\n smallest_key = key\n end\n end\n if smallest_key == 0 \n return nil \n else\n return smallest_key\n end\nend", "def key_for_min_value(name_hash)\n lowest_key=nil\n lowest_val=0\n name_hash.collect do |key,value|\n if value<lowest_val or lowest_val==0\n lowest_key=key\n lowest_val=value\n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n smallest = nil\n this_num = 0\n previous_num = 1000000\n name_hash.collect { |item, qty|\n this_num = qty\n if this_num < previous_num\n smallest = item\n previous_num = this_num\n end\n }\n smallest\nend", "def key_for_min_value(name_hash)\n rkey = nil\n rvalue = 10000000000000000\n name_hash.each do |key, value|\n if value < rvalue\n rkey = key\n rvalue = value\n end\n end\n rkey\nend", "def key_for_min_value(name_hash)\n\tsmallest_value = nil\n\tassociated_key = nil \n\tname_hash.collect do |key, value|\n\t\tif smallest_value == nil || value < smallest_value\n\t\t\tsmallest_value = value \n\t\t\tassociated_key = key\n\t \tend\n\tend\n\tassociated_key\nend", "def key_for_min_value(hash)\n # binding.pry\n lowest_key = nil\n lowest_value = 0\n # binding.pry\n hash.each do |key, value|\n if lowest_key == nil || value < lowest_value\n # binding.pry\n lowest_value = value\n lowest_key = key\n # binding.pry\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n hash.key(hash.values.min)\nend", "def key_for_min_value(hash)\n hash.key(hash.values.min)\nend", "def key_for_min_value(name_hash)\n smallest_value = 100\n name_hash.each do |key, value| \n if value < smallest_value\n smallest_value = value \n end \n end\n name_hash.key(smallest_value)\nend", "def key_for_min_value(name_hash)\n lowest=\"\"\n lowest=nil if name_hash.empty?\n tracker=100000000\n name_hash.each do |key,value|\n lowest=key if value<tracker\n tracker=value if value<tracker\n # if value<tracker\n end\n lowest\nend", "def key_for_min_value(name_hash)\n if name_hash.length == 0 \n nil\n else\n smallest_num = nil\n smallest_num_key = nil\n name_hash.collect do |key, value|\n if smallest_num == nil\n smallest_num = value\n smallest_num_key = key\n elsif smallest_num > value\n smallest_num = value\n smallest_num_key = key\n end\n end\n smallest_num_key\n end\n\nend", "def key_for_min_value(name_hash)\n low_key = nil\n low_value = nil\n name_hash.each do |n, s|\n if low_value == nil\n low_value = s\n low_key = n\n elsif low_value > s\n low_value = s\n low_key = n\n end\n end\n low_key\nend", "def key_for_min_value(name_hash)\n return nil if name_hash == nil || name_hash == {}\n number_array = name_hash.collect do |name, number|\n number\n end\n number_array.sort!\n name_hash.key(number_array[0])\nend", "def key_for_min_value(name_hash)\n lowestId = nil\n lowestNum = 0\n name_hash.each{ |id, val|\n if lowestNum == 0 \n lowestNum = val\n end\n if val <= lowestNum\n lowestNum = val\n lowestId = id\n end\n }\n return lowestId\nend", "def key_for_min_value(name_hash)\n lowest_v = nil\n lowest_k = nil\n name_hash.each do |name, value|\n if lowest_v == nil\n lowest_v = value\n lowest_k = name\n elsif value < lowest_v\n lowest_v = value\n lowest_k = name\n end\n end\n lowest_k\n end", "def key_for_min_value(name_hash)\n smallest_key = nil\n smallest_value = nil\n name_hash.each do |j, r|\n if smallest_value == nil || r < smallest_value\n smallest_value = r\n smallest_key = j\n end\n end\n smallest_key\nend", "def key_for_min_value(name_hash)\nlowest = 1000000\n low_key = nil\n name_hash.each {|key, value|\n if value < lowest\n lowest = value\n low_key = key\n end\n }\n low_key\nend", "def key_for_min_value(name_hash)\n lowest_key = nil\n name_hash.each_key do |key|\n if lowest_key == nil\n lowest_key = key\n elsif name_hash[key] < name_hash[lowest_key]\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n\n if name_hash.empty?\n return nil\n end\n lowest = Float::INFINITY\n name_hash.each_pair do |k, v|\n if v < lowest\n lowest = v\n end\n end\n name_hash.each_pair do |k, v|\n if v == lowest\n return k\n end\n end\nend", "def key_for_min_value(name_hash)\n output = 0\n smallest = nil\n name_hash.map do |key, value|\n if value < output || output == 0\n output = value\n smallest = key\n end\n end\n\n smallest\nend", "def key_for_min_value(name_hash)\n lowest_num = 1000000000\n lowest_num_key = \" \"\n if name_hash == {}\n return nil\n else\n name_hash.each do |name, num|\n if num < lowest_num\n lowest_num = num\n lowest_num_key = name\n end\n end\n return lowest_num_key\n end\nend", "def key_for_min_value(my_hash)\n #what is my value?\n lowest_value = 500\n lowest_key = nil\n\n my_hash.collect do |key, value|\n # what is my value?\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n nums = name_hash.collect do |item, num|\n num\n end\n nums.sort!\n nums[0]\n \n min_key = nil\n name_hash.map do |item, num|\n if num == nums[0]\n min_key = item\n end\n end\n min_key\nend", "def key_for_min_value(name_hash)\n vals = name_hash.collect { |key, value| value }\n keys = name_hash.collect { |key, value| key }\n low = vals[0]\n lowkey = keys[0]\n if name_hash.empty?\n nil\n else\n name_hash.collect do |key, value|\n if value < low\n low = value\n lowkey = key\n end\n end\n lowkey\n end\nend", "def key_for_min_value(name_hash)\n value1 = 0\n lowestKey = nil\n name_hash.each do |key, value|\n if(value1 == 0)\n value1 = value\n lowestKey = key\n end\n if(value1 > value)\n value1 = value\n lowestKey = key\n elsif (value1 < value)\n lowestKey = lowestKey\n value1 = value1\n end\n end\n return lowestKey\nend", "def key_for_min_value(hash)\n return nil if hash.empty?\n arr = hash.collect { |k, v| v }.sort\n hash.each { |k, v| return k if v == arr[0] }\nend", "def key_for_min_value(name_hash)\n # saves the smaller value in memo, and takes the first elem of memo at the end (the key)\n smallest = name_hash.inject do|memo, (k, v)|\n memo = v < memo[1] ? [k,v] : memo\n end\n #handle the empty hash case...\n smallest ? smallest[0] : nil\nend", "def key_for_min_value(name_hash)\n key = \"\"\n low_value = nil\n if name_hash.empty? == true\n return nil\n end\n name_hash.each do |name, number|\n if low_value == nil || number < low_value\n low_value = number\n key = name\n end\n end\n key\nend", "def key_for_min_value(name_hash)\n answer = nil\n smallest = nil\n name_hash.each {|key, value|\n if smallest.nil?\n smallest = value\n end\n if value <= smallest\n smallest = value\n answer = key\n end\n }\n answer\nend", "def smallest_key(q, hash)\n\t\ttemp = {}\n\t\tq.each do |v|\n\t\t\ttemp[v] = hash[v]\n\t\tend\n\t\treturn temp.key(temp.each_value.min)\n\tend", "def key_for_min_value(name_hash)\n lowest_value = 0\n lowest_key = \"\"\n if name_hash.empty? == true\n nil\n else\n name_hash.each_with_index do |(key, value), i|\n if i == 0\n lowest_value = value\n lowest_key = key\n elsif value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\n end\nend", "def key_for_min_value(name_hash)\n low=10000000000000000000\n return_key=nil\n name_hash.each do |key, value|\n if value<low\n low=value\n return_key=key\n end\n end\n return_key\nend", "def key_for_min_value(hash)\n if hash.length == 0\n return nil\n else\n smallest = 1000\n printme = \"\"\n hash.each do |thing, number|\n if number < smallest\n smallest = number\n printme = thing\n end\n end\n printme\n end\nend", "def key_for_min_value(name_hash)\n \n lowest_key = nil\n lowest_value = nil\n name_hash.each do |name_key, name_value|\n if lowest_value == nil || name_value < lowest_value\n lowest_value = name_value\n lowest_key = name_key\n end\n end\n lowest_key\n \n end", "def key_for_min_value(name_hash)\n the_key = nil \n the_value = 1/0.0\n # Infinity...can also be expressed as FLOAT::Infinity\n name_hash.each do |id, num|\n if num <= the_value\n the_value = num\n the_key = id\n end\n end\n the_key\nend", "def key_for_min_value(hash)\n array = []\n hash.each {|key,value| \n if array.empty? || value < array[1] \n array[0] = key \n array[1] = value \n end }\n if !array.empty? \n array.first \n else \n nil \n end\nend", "def key_for_min_value(name_hash)\n return nil if name_hash == {}\n smallest_key = name_hash.first[0]\n smallest_val = name_hash.first[1]\n\n name_hash.each do |pair|\n if pair[1] < smallest_val\n smallest_key = pair[0]\n end\n end\n smallest_key\nend", "def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n name_hash.each do |k,v|\n if v < lowest_value\n lowest_value = v\n lowest_key = k\n end \nend\nlowest_key\nend", "def key_for_min_value(name_hash)\n key_of_smallest_value = \"\"\n smallest_value = 99999\n name_hash.each do |key, value|\n if smallest_value > value\n smallest_value = value\n key_of_smallest_value = key\n end\n end\n if name_hash.size == 0\n key_of_smallest_value = nil\n end\n key_of_smallest_value\nend", "def key_for_min_value(name_hash)\n smallest_value = Float::INFINITY\n key_for_smallest_val = nil\n name_hash.each do |key, value|\n if smallest_value > value\n smallest_value = value\n key_for_smallest_val = key\n end \n end \n key_for_smallest_val\nend", "def key_for_min_value(name_hash)\n minKey = nil\n minVal = 2 ** (64 - 2) - 1\n name_hash.each {|key, value|\n if value < minVal\n minVal = value\n minKey = key\n end}\n minKey\nend", "def key_for_min_value(name_hash)\n if name_hash == {}\n return nil\n end\n lowest_number = nil\n name_hash.collect do |name, value|\n if lowest_number == nil\n lowest_number = value\n elsif lowest_number > value\n lowest_number = value\n end\n end\n \n name_hash.each do |name, value|\n if lowest_number == value\n return name\n end\n end\nend", "def key_for_min_value(hash)\n min_value = hash.values.min\n keys = hash.collect do |key, num|\n \tkey if num == min_value\n end\n keys\nend", "def key_for_min_value(name_hash)\n lowest_value = nil\n key_value = nil\n name_hash.collect do |name, number|\n if lowest_value == nil || number < lowest_value\n lowest_value = number\n key_value = name\n end\n end\n key_value\nend", "def key_for_min_value(name_hash)\n smallest_value = 1/0.0\n key_of_smallest_value = nil\n name_hash.each do |key, value|\n if smallest_value > value\n key_of_smallest_value = key\n smallest_value = value\n end\n end\n return key_of_smallest_value\nend" ]
[ "0.88215435", "0.8777964", "0.8777547", "0.87461567", "0.868959", "0.865596", "0.8652915", "0.8617178", "0.8587992", "0.85718757", "0.8567488", "0.85516495", "0.8529784", "0.8529784", "0.8518652", "0.8493093", "0.8475329", "0.8475329", "0.84659123", "0.8448963", "0.844864", "0.84355617", "0.84328914", "0.84303117", "0.8428149", "0.8408939", "0.83879274", "0.8368652", "0.83565944", "0.8352528", "0.83457017", "0.83439726", "0.8328677", "0.8328165", "0.8326319", "0.8325275", "0.83207417", "0.8315823", "0.83121765", "0.83118165", "0.8304724", "0.8301034", "0.83005065", "0.82916695", "0.8287707", "0.8286939", "0.8274178", "0.8266868", "0.8266243", "0.8252164", "0.8250042", "0.82442456", "0.8243966", "0.8243222", "0.82412297", "0.82406485", "0.82382184", "0.8236802", "0.82286584", "0.8226193", "0.8220675", "0.8218339", "0.8213271", "0.8213271", "0.821007", "0.82095677", "0.8206457", "0.8200053", "0.819837", "0.8196407", "0.81956655", "0.81935143", "0.81869036", "0.81863165", "0.8185119", "0.8183298", "0.81831217", "0.81828", "0.8179708", "0.8172912", "0.8172674", "0.8172615", "0.81721926", "0.8171008", "0.8168255", "0.8166514", "0.8160531", "0.815916", "0.81590766", "0.8157363", "0.8153598", "0.8153124", "0.8152728", "0.81527275", "0.8151724", "0.81517", "0.8150185", "0.8146749", "0.81433654", "0.81422555", "0.8141299" ]
0.0
-1
Returns the Pearson correlation coefficient for p1 and p2
def sim_pearson( prefs, p1, p2) # Get the list of mutually rated items si = {} for item in prefs[p1].keys si[item] = 1 if prefs[p2].include? item end # Find the number of elements n = si.length puts n # If there are no ratings in common, return 0 return 0 if n == 0 # Add up all the preferences sum1 = si.keys.inject(0) { |sum,value| sum += prefs[p1][value] } sum2 = si.keys.inject(0) { |sum,value| sum += prefs[p2][value] } puts "sum1 #{sum1}" puts "sum2 #{sum2}" # Sum up the squares sum1Sq = si.keys.inject(0) { |sum,value| sum += prefs[p1][value] ** 2 } sum2Sq = si.keys.inject(0) { |sum,value| sum += prefs[p2][value] ** 2 } # Sum up the products pSum = si.keys.inject(0) { |sum,value| sum += (prefs[p1][value] * prefs[p2][value])} puts "pSum #{pSum}" # Calculate the Pearson score num = pSum - (sum1*sum2/n) puts "num #{num}" den = Math.sqrt((sum1Sq - (sum1 ** 2)/n) * (sum2Sq - (sum2 ** 2)/n)) puts "den #{den}" return 0 if den == 0 r = num / den end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pearson(v1,v2)\n v1a,v2a=Statsample.only_valid_clone(v1,v2)\n return nil if v1a.size ==0\n if Statsample.has_gsl?\n GSL::Stats::correlation(v1a.to_gsl, v2a.to_gsl)\n else\n pearson_slow(v1a,v2a)\n end\n end", "def pearson x, y\n\txbar, ybar = x.reduce(:+)/x.size, y.reduce(:+)/y.size\n\tnumerator = [x.map{|i| i-xbar}, y.map{|i| i-ybar}].transpose.map{|pair| pair.reduce(:*)}.reduce(:+)\n\tdenomerator = Math.sqrt(x.map{|i| (i-xbar)*(i-xbar)}.reduce(:+)) * Math.sqrt(y.map{|i| (i-ybar)*(i-ybar)}.reduce(:+))\n\tcorr = (numerator/denomerator)\n\traise \"pearson value out of bounds: #{corr}\" if corr > 1.0000001 or corr < -1.0000001\n\tcorr.round(5)\nend", "def partial_correlation(v1,v2,control)\n v1a,v2a,cona=Statsample.only_valid_clone(v1,v2,control)\n rv1v2=pearson(v1a,v2a)\n rv1con=pearson(v1a,cona)\n rv2con=pearson(v2a,cona) \n (rv1v2-(rv1con*rv2con)).quo(Math::sqrt(1-rv1con**2) * Math::sqrt(1-rv2con**2))\n end", "def t_pearson(v1,v2)\n v1a,v2a=Statsample.only_valid_clone(v1,v2)\n r=pearson(v1a,v2a)\n if(r==1.0) \n 0\n else\n t_r(r,v1a.size)\n end\n end", "def ruby_pearson(x,y)\n n=x.length\n\n sumx=x.inject(0) {|r,i| r + i}\n sumy=y.inject(0) {|r,i| r + i}\n\n sumxSq=x.inject(0) {|r,i| r + i**2}\n sumySq=y.inject(0) {|r,i| r + i**2}\n\n prods=[]; x.each_with_index{|this_x,i| prods << this_x*y[i]}\n pSum=prods.inject(0){|r,i| r + i}\n\n # Calculate Pearson score\n num=pSum-(sumx*sumy/n)\n den=((sumxSq-(sumx**2)/n)*(sumySq-(sumy**2)/n))**0.5\n if den==0\n return 0\n end\n r=num/den\n return r\nend", "def sim_pearson( prefs, p1, p2)\n # Get the list of mutually rated items\n si = {}\n for item in prefs[p1].keys\n si[item] = 1 if prefs[p2].include? item\n end\n\n # Find the number of elements\n n = si.length\n # If there are no ratings in common, return 0\n return 0 if n == 0\n\n # Add up all the preferences\n sum1 = si.keys.inject(0) { |sum,value| sum += prefs[p1][value] }\n sum2 = si.keys.inject(0) { |sum,value| sum += prefs[p2][value] }\n\n # Sum up the squares\n sum1Sq = si.keys.inject(0) { |sum,value| sum += prefs[p1][value] ** 2 }\n sum2Sq = si.keys.inject(0) { |sum,value| sum += prefs[p2][value] ** 2 }\n\n # Sum up the products\n pSum = si.keys.inject(0) { |sum,value| sum += (prefs[p1][value] * prefs[p2][value])}\n\n # Calculate the Pearson score\n num = pSum - (sum1*sum2/n)\n den = Math.sqrt((sum1Sq - (sum1 ** 2)/n) * (sum2Sq - (sum2 ** 2)/n))\n\n return 0 if den == 0\n r = num / den\n end", "def spearman(v1,v2)\n v1a,v2a = Statsample.only_valid_clone(v1,v2)\n v1r,v2r = v1a.ranked, v2a.ranked\n pearson(v1r,v2r)\n end", "def pearson(a,b)\n\n # sift out empty values\n x = [0.0]\n y = [0.0]\n idx = 0\n a.each_with_index{|point, i|\n if point.nil?\n #puts \" skipped x[#{i}]\"\n elsif b[i].nil?\n #puts \" skipped y[#{i}]\"\n else\n x[idx] = point\n y[idx] = b[i]\n idx += 1\n end\n }\n #puts \" x= #{x}\"\n #puts \" y= #{y}\"\n\n n=x.length\n\n sumx=x.inject(0) {|r,i| r + i}\n sumy=y.inject(0) {|r,i| r + i}\n\n sumxSq=x.inject(0) {|r,i| r + i**2}\n sumySq=y.inject(0) {|r,i| r + i**2}\n\n prods=[]; x.each_with_index{|this_x,i| prods << this_x*y[i]}\n pSum=prods.inject(0){|r,i| r + i}\n\n # Calculate Pearson score\n num=pSum-(sumx*sumy/n)\n den=((sumxSq-(sumx**2)/n)*(sumySq-(sumy**2)/n))**0.5\n if den==0\n return 0\n end\n r=num/den\n return r.real\nend", "def computeCor(a1, a2)\n s1 = a1.size \n \n return -100 if s1 < 2 or s1 != a2.size\n \n sumsqx, sumsqy, sumcproduct = 0,0,0\n meanx, meany = a1[0], a2[0]\n 1.upto(s1-1) do |i|\n j = i + 1.0\n sweep = (j -1.0) / j\n deltax = a1[i] - meanx\n deltay = a2[i] - meany\n sumsqx += deltax * deltax * sweep\n sumsqy += deltay * deltay * sweep\n sumcproduct += deltax * deltay * sweep\n meanx += deltax / j\n meany += deltay / j\n end\n \n popsdx = (sumsqx / s1.to_f)**0.5\n popsdy = (sumsqy / s1.to_f)**0.5\n covxy = sumcproduct/s1.to_f\n cc = covxy / (popsdx * popsdy)\n return cc\nend", "def koeff( p1, p2)\n fab = p1 * p2\n dab = (1 - p1) * (1 - p2)\n (fab ** 2) / (fab + dab)\n end", "def sim_pearson(preferences, p1, p2)\n # Get the list of shared_items \n shared_items=[] \n preferences[p1].each do |movie, rating| \n shared_items << movie if preferences[p2].keys.include?(movie) \n end\n \n # if they have no ratings in common, return 0 \n return 0 if shared_items.size == 0\n \n # Add up all the preferences \n sum1 = shared_items.inject(0) { |sum, movie| sum + preferences[p1][movie] }\n sum2 = shared_items.inject(0) { |sum, movie| sum + preferences[p2][movie] }\n \n # Sum up the squares \n sum1Sq = shared_items.inject(0) { |sum, movie| sum + preferences[p1][movie]**2 }\n sum2Sq = shared_items.inject(0) { |sum, movie| sum + preferences[p2][movie]**2 }\n \n # Sum up the products \n pSum = shared_items.inject(0) { |sum, movie| sum + preferences[p1][movie] * preferences[p2][movie] }\n\n # Calculate Pearson score \n num = pSum-(sum1*sum2/shared_items.size) \n den = sqrt((sum1Sq - sum1**2 / shared_items.size)*(sum2Sq - sum2**2 / shared_items.size)) \n return 0 if den == 0\n r = num/den \n return r\nend", "def correlation\n @properties.correlation\n end", "def pearson_similarity (u1,u2)\n\t\tsimilarity = @train_data[u1].movie_and_rating.keys & @train_data[u2].movie_and_rating.keys\n\t\tif similarity.empty?\n\t\t\treturn 0\n\t\tend\n\t\tsum_1 = 0\n\t\tsum_2 = 0\n\t\tsum_1_sq = 0\n\t\tsum_2_sq = 0\n\t\tproduct = 0\n\n\t\tsimilarity.each do |mov|\n\t\t\tsum_1 += @train_data[u1].return_rating(mov)\n\t\t\tsum_1_sq += @train_data[u1].return_rating(mov)**2\n\t\t\tsum_2 += @train_data[u2].return_rating(mov)\n\t\t\tsum_2_sq += @train_data[u2].return_rating(mov)**2\n\t\t\tproduct += @train_data[u1].return_rating(mov)*@train_data[u2].return_rating(mov)\n\t\tend\n\n\t\tnumerator = product - (sum_1*sum_2/similarity.length)\n\t\tdenom = Math.sqrt((sum_1_sq-(sum_1**2)/similarity.length)*(sum_2_sq-(sum_2**2)/similarity.length))\n\n\t\tif denom == 0 \n\t\t\treturn 0\n\t\tend\n\t\treturn numerator/denom\n\tend", "def corr\n raise NotImplementedError, \"Does not work for complex dtypes\" if complex_dtype?\n standard_deviation = std\n cov / (standard_deviation.transpose.dot(standard_deviation))\n end", "def r_squared(a1, a2, mean1 = nil, mean2 = nil)\n mean1 ||= mean(a1)\n mean2 ||= mean(a2)\n cov = covariance(a1, a2, false, mean1, mean2)\n var1 = variance(a1, false, mean1)\n var2 = variance(a2, false, mean2)\n cov * cov / (var1 * var2)\n end", "def coeficiente(p1,p2)\n return p2.abs.subPoint(p1.abs)\n end", "def corals\n @corals ||= [@first_coral, @second_coral].sort\n end", "def c\n @c ||= self.p1.x * self.p2.y - self.p1.y * self.p2.x\n end", "def correlation feature, zero_padding = 0\n Statistics.correlation @data, feature, zero_padding\n end", "def cosine_similarity(x1, y1, x2, y2)\n dp = (x1 * x2) + (y1 * y2)\n mag1 = Math.sqrt((x1 ** 2) + (y1 ** 2))\n mag2 = Math.sqrt((x2 ** 2) + (y2 ** 2))\n return 0 if mag1 == 0 || mag2 == 0\n return (dp / (mag1 * mag2))\n end", "def chi2_calc(cs1, cs2)\n \n r1 = cs1.values.sum\n r2 = cs2.values.sum\n n = r1+r2\n \n q = 0.0\n \n each_class do |k|\n ck = cs1[k]+cs2[k]\n \n ek1 = r1*ck/n\n ek2 = r2*ck/n\n \n #\n # we can't implement exactly the same as illustrated\n # in the literature, but the following best reproduces\n # the results as in Table 1\n #\n #ek1 = 0.1 if r1.zero? or ck.zero?\n #ek2 = 0.1 if r2.zero? or ck.zero?\n \n if ek1.zero? and ek2.zero?\n q += 0.10\n elsif ek1.zero?\n q += 0.05 + \n (cs2[k]-ek2)**2/ek2\n elsif ek2.zero?\n q += (cs1[k]-ek1)**2/ek1 + \n 0.05\n else\n q += (cs1[k]-ek1)**2/ek1+\n (cs2[k]-ek2)**2/ek2\n end\n end\n \n q\n end", "def obliquity_corr(t)\n\te_0 = mean_ecliptic_obliquity(t)\n\tomega = 125.04 -t*1934.136\n\trad(deg(e_0) + 0.00256*Math.cos(rad(omega)))\nend", "def cornacchia(d, p)\r\n\t\treturn nil if -1 == kronecker_symbol(-d, p)\r\n\r\n\t\t# Compute square root\r\n\t\tx0 = mod_sqrt(-d, p)\r\n\t\tx0 = p - x0 if x0 <= p >> 1\r\n\t\ta = p\r\n\t\tb = x0\r\n\t\tborder = isqrt(p)\r\n\r\n\t\t# Euclidean algorithm\r\n\t\twhile border < b\r\n\t\t\ta, b = b, a % b\r\n\t\tend\r\n\r\n\t\t# Test solution\r\n\t\tc, r = (p - b ** 2).divmod(d)\r\n\t\treturn nil if 0 != r\r\n\r\n\t\tq = c.square?\r\n\t\treturn nil unless q\r\n\r\n\t\treturn [b, q]\r\n\tend", "def law_of_cosines_distance_from(p2)\n Math.acos(Math.sin(latr) * Math.sin(p2.latr) + Math.cos(latr) * Math.cos(p2.latr) * Math.cos(p2.lonr - lonr)) * RADIUS\n end", "def dist(r1, c1, r2, c2)\r\n return Math.sqrt((c1-c2)**2 + (r1-r2)**2)\r\nend", "def covariance(a1, a2, bias_corrected = true, mean1 = nil, mean2 = nil)\n raise ArgumentError.new(\"length of both arrays must match\") unless (a1.count == a2.count)\n mean1 ||= mean(a1)\n mean2 ||= mean(a2)\n denominator = (bias_corrected)?(a1.count-1):(a1.count)\n tot = 0.0\n # a1.each_index {|i| tot += (a1[i] * a2[i])}\n # (tot / denominator) - (mean1 * mean2)\n a1.each_index {|i| tot += (a1[i] - mean1) * (a2[i] - mean2)}\n tot / denominator\n end", "def component_matrix_correlation(m=nil)\n m||=@m\n raise \"m should be > 0\" if m<1\n omega_m=::Matrix.build(@n_variables, m) {0}\n gammas=[]\n m.times {|i|\n omega_m.column=i, @eigenpairs[i][1]\n gammas.push(Math::sqrt(@eigenpairs[i][0]))\n }\n gamma_m=::Matrix.diagonal(*gammas)\n cm=(omega_m*(gamma_m)).to_matrix\n \n cm.extend CovariateMatrix\n cm.name=_(\"Component matrix\")\n cm.fields_x = @variables_names\n cm.fields_y = m.times.map { |i| \"PC_#{i+1}\".to_sym }\n cm\n end", "def calculateDistance(r1,c1,r2,c2)\r\n\treturn Math.sqrt(((c1-c2) ** 2 + (r1 -r2) ** 2))\r\nend", "def get_op_cor(player, opponent)\n p_corner = (player & @corners) # determine the player's corners\n o_corner = (opponent & @corners) # determine the opponent's corners\n if (@opcor_1 & p_corner).size == 0 && (@opcor_1 & o_corner).size == 1\n position = (@opcor_1 - o_corner)[0] # opposite corner is in @opcor_1\n elsif (@opcor_2 & p_corner).size == 0 && (@opcor_2 & o_corner).size == 1\n position = (@opcor_2 - o_corner)[0] # opposite corner is in @opcor_2\n else\n get_avail_cor(player, opponent) # otherwise check for any open corner\n end\n end", "def probability_of_pair r1, r2\n\t\tdistribution[r1] * distribution[r2]\n\tend", "def chisq_calc(cs1, cs2)\n r1 = cs1.values.sum\n r2 = cs2.values.sum\n n = r1+r2\n \n q = 0.0\n \n each_class do |k|\n ek1 = r1*(cs1[k]+cs2[k])/n\n ek2 = r2*(cs1[k]+cs2[k])/n\n \n q += (cs1[k]-ek1)**2/(ek1<0.5?0.5:ek1)+\n (cs2[k]-ek2)**2/(ek2<0.5?0.5:ek2)\n end\n \n q\n end", "def corr(hash, metadata, property)\n counts = []\n meta = []\n hash.keys.each {|key|\n if (!metadata[key].nil? && !metadata[key][property].nil?)\n if (metadata[key][property] != \"NA\")\n\tmeta.push(metadata[key][property].to_f)\n\tcounts.push(hash[key])\n end\n end\n }\n return counts.correlationWith(meta)\nend", "def calculate_fairness\n strengths = @teams.map(&:strength)\n scores = @scores.values\n\n FairnessCheck.pearson_product_moment_correlation_coefficient strengths, scores\n end", "def io_corr\n @io_corr\n end", "def angle_between(p1, p2)\n vect_p1 = p1 - self\n vect_p2 = p2 - self\n\n theta = vect_p1.polar - vect_p2.polar\n theta += 360.0 if theta < 0.0\n theta = 360.0 - theta if theta > 180.0\n return theta\n end", "def correlation_matrix(ds)\n vars, cases = ds.ncols, ds.nrows\n if !ds.include_values?(*Daru::MISSING_VALUES) and Statsample.has_gsl? and prediction_optimized(vars,cases) < prediction_pairwise(vars,cases)\n cm=correlation_matrix_optimized(ds)\n else\n cm=correlation_matrix_pairwise(ds)\n end\n cm.extend(Statsample::CovariateMatrix)\n cm.fields = ds.vectors.to_a\n cm\n end", "def getCentralAngle(c1,c2)\n # Using the Vincenty Formula\n dlon = rad(c1[0] - c2[0])\n a = Math.cos(rad(c2[1])) * Math.sin(dlon)\n b = Math.cos(rad(c1[1]))*Math.sin(rad(c2[1])) - Math.sin(rad(c1[1])) * Math.cos(rad(c2[1]))*Math.cos(dlon)\n c = Math.sin(rad(c1[1]))*Math.sin(rad(c2[1])) + Math.cos(rad(c1[1])) * Math.cos(rad(c2[1]))*Math.cos(dlon)\n\n angle = Math.atan2(Math.sqrt(a*a + b*b),c)\n\n # Using the Haversine Formula\n\n dLon = rad(c2[0] - c1[0])\n dLat = rad(c2[1] - c1[1])\n lat1 = rad(c1[1])\n lat2 = rad(c2[1])\n\n a = Math.sin(dLat/2) * Math.sin(dLat/2) +\n Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);\n c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));\n end", "def distance(p1, p2)\n\t\tc = p1.count\n\t\tt = 0\n\t\tc.times do \t|n|\n\t\t\te = (p1[n] - p2[n]) ** 2\n\t\t\tt = t + e\t\t\n\t\tend\t\n\t\tt = Math.sqrt(t)\n\tend", "def distance(p1, p2)\n a = [p1[:lat], p1[:lon]]\n b = [p2[:lat], p2[:lon]]\n\n rad_per_deg = Math::PI/180 # PI / 180\n rkm = 6371 # Earth radius in kilometers\n rm = rkm * 1000 # Radius in meters\n\n dlon_rad = (b[1]-a[1]) * rad_per_deg # Delta, converted to rad\n dlat_rad = (b[0]-a[0]) * rad_per_deg\n\n lat1_rad, lon1_rad = a.map! {|i| i * rad_per_deg }\n lat2_rad, lon2_rad = b.map! {|i| i * rad_per_deg }\n\n a = Math.sin(dlat_rad/2)**2 + Math.cos(lat1_rad) * Math.cos(lat2_rad) * Math.sin(dlon_rad/2)**2\n c = 2 * Math::atan2(Math::sqrt(a), Math::sqrt(1-a))\n rm * c # Delta in meters\nend", "def distance(p1, p2)\n a = [p1[:lat], p1[:lon]]\n b = [p2[:lat], p2[:lon]]\n\n rad_per_deg = Math::PI/180 # PI / 180\n rkm = 6371 # Earth radius in kilometers\n rm = rkm * 1000 # Radius in meters\n\n dlon_rad = (b[1]-a[1]) * rad_per_deg # Delta, converted to rad\n dlat_rad = (b[0]-a[0]) * rad_per_deg\n\n lat1_rad, lon1_rad = a.map! {|i| i * rad_per_deg }\n lat2_rad, lon2_rad = b.map! {|i| i * rad_per_deg }\n\n a = Math.sin(dlat_rad/2)**2 + Math.cos(lat1_rad) * Math.cos(lat2_rad) * Math.sin(dlon_rad/2)**2\n c = 2 * Math::atan2(Math::sqrt(a), Math::sqrt(1-a))\n rm * c # Delta in meters\nend", "def correlation_id\n return @correlation_id\n end", "def distance_between(p1, p2)\n Math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)\n end", "def r2\n @n_predictors.times.inject(0) {|ac,i| ac+@coeffs_stan[i]* @matrix_y[i,0]} \n end", "def correlation_probability_matrix(ds, tails=:both)\n rows=ds.fields.collect do |row|\n ds.fields.collect do |col|\n v1a,v2a=Statsample.only_valid_clone(ds[row],ds[col])\n (row==col or ds[row].type!=:numeric or ds[col].type!=:numeric) ? nil : prop_pearson(t_pearson(ds[row],ds[col]), v1a.size, tails)\n end\n end\n Matrix.rows(rows)\n end", "def confidence(data1, data2, conf)\n d1 = data1.to_statarray\n d2 = data2.to_statarray\n diff = d2.mean - d1.mean\n plus_minus = conf * Math.sqrt( d1.variance / d1.size + d2.variance / d2.size)\n [diff, diff - plus_minus, diff + plus_minus ]\n end", "def chp_potential_elec(val1 = total_mwh_ch4, val2 = 0.3)\n\t\t(val1 * val2).round 2\n\tend", "def distance(p0, p1)\n a = factory.point(p0.x, p0.y)\n b = factory.point(p1.x, p1.y)\n\n a.distance(b) / 1000.0\n end", "def distance(p1,p2)\ndelta_x = p1[0] - p2[0]\ndelta_y = p1[1] - p2[1]\n\nMath.sqrt(delta_x ** 2 + delta_y **2)\n\nend", "def correlate(data, count, lag)\r\n result = 0.0\r\n\r\n (0...count).each do |idx|\r\n result += data[idx] * data[idx+lag]\r\n end\r\n\r\n result\r\n end", "def distance(c1,c2)\n x = c1[0] - c2[0]\n y = c1[1] - c2[1]\n y = y <= -180 ? y + 360 : y\n y = y >= 180 ? y - 360 : y\n return Math.sqrt(x*x+y*y)\n end", "def charge_at_pH(pep_charges, pH)\n\tcharge = 0\n\tcharge += -1/(1+10**(pep_charges.c_term-pH))\n\tcharge += -pep_charges.d_num/(1+10**(ResidueTable[:D][2]-pH))\n\tcharge += -pep_charges.e_num/(1+10**(ResidueTable[:E][2]-pH))\n\tcharge += -pep_charges.c_num/(1+10**(ResidueTable[:C][2]-pH))\n\tcharge += -pep_charges.y_num/(1+10**(ResidueTable[:Y][2]-pH))\n\tcharge += 1/(1+10**(pH - pep_charges.n_term))\n\tcharge += pep_charges.h_num/(1+10**(pH-ResidueTable[:H][2]))\n\tcharge += pep_charges.k_num/(1+10**(pH-ResidueTable[:K][2]))\n\tcharge += pep_charges.r_num/(1+10**(pH-ResidueTable[:R][2]))\n\tcharge\nend", "def calc_total_potential_income_chp(val1= calc_potential_income_heat, val2= calc_potential_income_elec)\n\t\tval1 + val2\n\tend", "def calculate_distance(p1, p2)\r\n sum = 0\r\n for i in (0...p1.length)\r\n sum += (p1[i] - p2[i])**2\r\n end\r\n sum = sum.to_f\r\n return Math.sqrt(sum)\r\nend", "def euclidean_dist(c1,c2)\n Math.sqrt(c1.zip(c2).map{|p| (p[1]-p[0])**2}.reduce(:+))\n end", "def q_f(df1, df2, f)\r\n if (f <= 0.0) then return 1.0; end\r\n if (df1 % 2 != 0 && df2 % 2 == 0)\r\n return 1.0 - q_f(df2, df1, 1.0 / f)\r\n end\r\n cos2 = 1.0 / (1.0 + df1.to_f * f / df2.to_f)\r\n sin2 = 1.0 - cos2\r\n \r\n if (df1 % 2 == 0)\r\n prob = cos2 ** (df2.to_f / 2.0)\r\n temp = prob\r\n i = 2\r\n while i < df1\r\n temp *= (df2.to_f + i - 2) * sin2 / i\r\n prob += temp\r\n i += 2\r\n end\r\n return prob\r\n end\r\n prob = Math.atan(Math.sqrt(df2.to_f / (df1.to_f * f)))\r\n temp = Math.sqrt(sin2 * cos2)\r\n i = 3\r\n while i <= df1\r\n prob += temp\r\n temp *= (i - 1).to_f * sin2 / i.to_f;\r\n i += 2.0\r\n end\r\n temp *= df1.to_f\r\n i = 3\r\n while i <= df2\r\n prob -= temp\r\n temp *= (df1.to_f + i - 2) * cos2 / i.to_f\r\n i += 2\r\n end\r\n prob * 2.0 / Math::PI\r\n end", "def update_similarity_coefficient(inst1, inst2)\n coeff = klass.similarity_for(inst1, inst2)\n \n update_coefficient inst1, inst2, coeff\n \n nil\n end", "def relacion_cc\n\t\t(ccintura / ccadera).round(2)\n\tend", "def set_correlation\n @correlation = Correlation.find(params[:id])\n end", "def calc_point_rotated_relative(x,y, theta)\r\n# - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n theta = conv_degree_to_radian(theta)\r\n xr= Math.cos(theta)*x - Math.sin(theta)*y \r\n yr = Math.sin(theta)*x + Math.cos(theta)*y \r\n pRes = CNCPoint.new(xr,yr)\r\nend", "def ui_corr\n input.ui_corr\n end", "def reciprocal\n if coeffs.first.zero?\n ContinuedFraction.new(coeffs.suffix(1))\n else\n ContinuedFraction.new(coeffs.prepend(0))\n end\n end", "def cosine_similarity(a, b)\n dot_product(a, b) / (magnitude(a) * magnitude(b))\n end", "def cross(o, p)\n ((p.x - o.x) * (self.y - o.y) - (p.y - o.y) * (self.x - o.x)).round(CROSS_PRODUCT_ROUNDING)\n end", "def c_radius \n Math.sqrt((@x*@x)+(@y*@y))\n end", "def equation\n if p1.x == p2.x\n return \"x - #{p1.x}\"\n elsif p1.y == p2.y\n return \"#{p2.y} - p1.y\"\n end\n\n \"#{a}*x + #{b}*y + #{c} = 0\"\n end", "def euc_2d(c1, c2)\n Math.sqrt((c1[0] - c2[0])**2.0 + (c1[1] - c2[1])**2.0).round\nend", "def euclid point1, point2\n\treturn Math.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2)\nend", "def euc_2d(c1, c2)\n Math.sqrt((c1[0] - c2[0])**2.0 + (c1[1] - c2[1])**2.0).round\n end", "def cosine_similarity(a, b)\n dot_product(a, b) / (magnitude(a) * magnitude(b))\n end", "def price_coefficient_rate\n hash[\"PriceCoefficientRate\"]\n end", "def perform_calc(opr, val1, val2)\n result = 0\n case opr\n when '*'\n result = val1.to_f * val2.to_f\n when \"/\"\n result = val1.to_f / val2.to_f\n when \"+\"\n result = val1.to_f + val2.to_f\n when \"-\"\n result = val1.to_f - val2.to_f\n end\n result.round(2)\n end", "def item_total_correlation\n vecs = @ds.vectors.to_a\n @itc ||= vecs.inject({}) do |a,v|\n [email protected]_sum(vecs - [v])\n a[v]=Statsample::Bivariate.pearson(@ds[v],total)\n a\n end\n end", "def score_phq2\n raise_unless_finished_and_valid!\n q1 + q2\n end", "def intersection_center(other)\n p0 = center\n p1 = other.center\n a = distance_to_chord other\n d = center.distance other.center\n (p1 - p0).scale(a/d) + p0\n end", "def circum_circle(p, p1, p2, p3, cache = nil)\n dx,dy,rsqr,drsqr = []\n cached = cache && cache[[p1, p2, p3]]\n xc, yc, r = []\n rsqr = 0\n\n if cached\n\t\t\txc, yc, r, rsqr = cached\n else\n # Check for coincident points\n if (points_are_coincident(p1,p2) || points_are_coincident(p2,p3) || points_are_coincident(p1,p3))\n #puts(\"CircumCircle: Points are coincident.\")\n return [ false, 0, 0, 0 ]\n end\n\n if (p2.y-p1.y).abs < EPSILON\n m2 = - (p3.x-p2.x) / (p3.y-p2.y)\n mx2 = (p2.x + p3.x) * 0.5\n my2 = (p2.y + p3.y) * 0.5\n xc = (p2.x + p1.x) * 0.5\n yc = m2 * (xc - mx2) + my2\n elsif (p3.y-p2.y).abs < EPSILON\n m1 = - (p2.x-p1.x) / (p2.y-p1.y)\n mx1 = (p1.x + p2.x) * 0.5\n my1 = (p1.y + p2.y) * 0.5\n xc = (p3.x + p2.x) * 0.5\n yc = m1 * (xc - mx1) + my1\n else\n m1 = - (p2.x-p1.x) / (p2.y-p1.y)\n m2 = - (p3.x-p2.x) / (p3.y-p2.y)\n mx1 = (p1.x + p2.x) * 0.5\n mx2 = (p2.x + p3.x) * 0.5\n my1 = (p1.y + p2.y) * 0.5\n my2 = (p2.y + p3.y) * 0.5\n xc = (m1 * mx1 - m2 * mx2 + my2 - my1) / (m1 - m2)\n yc = m1 * (xc - mx1) + my1\n end\n\n dx = p2.x - xc\n dy = p2.y - yc\n\t\t\trsqr = dx*dx + dy*dy\n\t\t\tr = Math.sqrt(rsqr)\n cache[[p1, p2, p3]] = [ xc, yc, r, rsqr ] if cache\n end\n\n dx = p.x - xc\n dy = p.y - yc\n drsqr = dx*dx + dy*dy\n\n [ (drsqr <= rsqr), xc, yc, r ]\n end", "def correlation_id; @message_impl.getCorrelationId; end", "def calc_carbon_savings_from_chp_combined(val1= calc_carbon_savings_from_chp_heat,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tval2= calc_carbon_savings_from_chp_elec)\n\t\t(val1 + val2).round 2\n\tend", "def analyze tud_map1, tud_map2\n r2 = r_squared tud_map1, tud_map2\n r = pearsons_r r2\n t = t_test r, tud_map1.count\n if t > 1.97\n significant = true\n else\n significant = false\n end \n { r_squared: r2, t: t, significant: significant }\nend", "def multiplyPolys(poly1, poly2)\n newPoly = poly1.*(poly2)\n\n newPoly = modX(newPoly, 2)\n newPoly = reduce(newPoly)\n newPoly = modX(newPoly, 2)\n \n newPoly\n end", "def calc_potential_cars_fueled(val1= calc_upg_ch4, val2= 1035)\n\t\t(val1 / val2).round 1\n\tend", "def getTotalCO2Emissions\n\t\t# Get all the connections in the supply chain\n\t\tsupply_chain_connections = SupplierConnection.where(supply_chain_id: self.id)\n\t\t\n\t\t# Add up all co2 emissions\n\t\ttotal_co2 = 0\n\t\tsupply_chain_connections.each do |c|\n\t\t\ttotal_co2 += c.co2_emission\n\t\tend\n\n\t\t# Return the total co2 emissions\n\t\ttotal_co2\n\tend", "def mathy(n1, n2, operation)\n answer = n1.send(operation, n2).round(4)\n return answer\nend", "def r2 \n 0.5 #apparently not 0.5 * sqrt(2)\n end", "def crossProduct( vector2 )\n @angle = self.getAngleOf2Vector(vector2)\n @lenght = @length * vector2.length * @angle\n return 0\n end", "def polar(x,y)\n theta = Math.atan2(y,x) # Compute the angle\n r = Math.hypot(x,y) # Compute the distance\n [r, theta] # The last expression is the return value\nend", "def pythagorean_theorem(a, b)\n a_squared = a * a \n b_squared = b * b\n a_squared_plus_b_squared = a_squared + b_squared\nend", "def polar(x,y)\n theta = Math.atan2(y,x) # Compute the angle\n r = Math.hypot(x,y) # Compute the distance\n [r, theta] # The last expression is the return value\nend", "def calc_distance(x1,y1, x2,y2)\r\n# - - - - - - - - - - - - - - - - - - - -\r\n if (x1 == x2) && (y1 == y2)\r\n c = 0\r\n else\r\n a = (x1 - x2).abs * 1.0\r\n b = (y1 - y2).abs * 1.0\r\n csqd = (a*a) + (b * b)\r\n c = Math.sqrt(csqd)\r\n end # else\r\n return c\r\nend", "def dj_dp1(p0, p1)\n raise \"Training set x,y array sizes are not equal\" if @x_t.length != @y_t.length\n sum = 0.0\n for i in 0...@m\n sum += @norm_x_t[i]*(p0 + p1*@norm_x_t[i] - @norm_y_t[i])\n end\n sum/@m\n end", "def propose(x)\n y = x.clone\n two_pi_r = 2*GSL::M_PI*rand\n sqrt_n2_ln_phi = Math.sqrt(-2*log(rand))\n z1 = cos(two_pi_r) * sqrt_n2_ln_phi\n z2 = sin(two_pi_r) * sqrt_n2_ln_phi\n c1 = sqrt(1.0+@correlation)/2.0\n c2 = sqrt(1.0-@correlation)/2.0\n y[@indices[0]] = x[@indices[0]] + @stdev1*(c1*z1+c2*z2)\n y[@indices[1]] = x[@indices[1]] + @stdev2*(c1*z1-c2*z2)\n y\n end", "def /(other)\n Resistor::CombinedResistor.new(1 / (1 / @ohm + 1 / other.ohm))\n end", "def similarity(doc1_id, doc2_id)\n @tfidf ||= calculate\n CosineSimilarity.new.calculate(@tfidf[doc1_id], @tfidf[doc2_id])\n end", "def ** (other)\n if other == 0\n return Complex(1)\n end\n if other.kind_of?(Complex)\n r, theta = polar\n ore = other.real\n oim = other.image\n nr = Math.exp!(ore*Math.log!(r) - oim * theta)\n ntheta = theta*ore + oim*Math.log!(r)\n Complex.polar(nr, ntheta)\n elsif other.kind_of?(Integer)\n if other > 0\n\tx = self\n\tz = x\n\tn = other - 1\n\twhile n != 0\n\t while (div, mod = n.divmod(2)\n\t\t mod == 0)\n\t x = Complex(x.real*x.real - x.image*x.image, 2*x.real*x.image)\n\t n = div\n\t end\n\t z *= x\n\t n -= 1\n\tend\n\tz\n else\n\tif defined? Rational\n\t (Rational(1) / self) ** -other\n\telse\n\t self ** Float(other)\n\tend\n end\n elsif Complex.generic?(other)\n r, theta = polar\n Complex.polar(r**other, theta*other)\n else\n x, y = other.coerce(self)\n x**y\n end\n end", "def norm_2(other)\n dot = dot(other)\n Math::sqrt(dot)\n end", "def getBearing(p1, p2)\n dLon = rad(p2[0]-p1[0])\n lat2 = rad(p2[1])\n lat1 = rad(p1[1])\n y = Math.sin(dLon) * Math.cos(lat2)\n x = Math.cos(lat1)*Math.sin(lat2) -\n Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon)\n brng = Math.atan2(y, x)\n end", "def correlation_id\n\n opt('correlation_id') || ''\n end", "def intersect(p1, v2, p2)\n # If this vector and v2 doesn't intersect, return early.\n return :no_intersect unless intersect?(p1, v2, p2)\n\n # Calculate t2\n # x1 + a1 * t1 = x2 + a2 * t2\n # t1 = (x1 + a2 * t2 + x2) / a1\n # y1 + b1 * (x1 + a2 * x + x2) / a1 = y2 + b2 * x\n # t2 = (a1 * y1 - a1 * y2 + b1 * x1 + b1 * x2) / (a1 * b2 - a2 * b1)\n t2 = (to_a[0] * p1.y - to_a[0] * p2.y + to_a[1] * p1.x + to_a[1] * p2.x) /\n (to_a[0] * v2.to_a[1] - v2.to_a[0] * to_a[1])\n\n # Use t2 to calculate the intersection\n [\n p2.x + v2.to_a[0] * t2,\n p2.y + v2.to_a[1] * t2,\n p2.z + v2.to_a[2] * t2,\n ]\n end", "def conv_xy_to_polar(x,y)\r\n# - - - - - - - - - - - - - - - - - - - -\r\n if (x == 0)\r\n if (y >= 0)\r\n return 0\r\n else\r\n return 180\r\n end #else\r\n elsif (y == 0)\r\n if (x2 >= 0)\r\n return 90\r\n else\r\n return 270\r\n end #else\r\n end #else\r\n\r\n x = x + 0.0\r\n y = y + 0.0\r\n dist = Math.sqrt((x*x) + (y*y))\r\n slope = y / x\r\n aradian = Math.atan(slope)\r\n degrees = conv_radian_to_degree(aradian) \r\n print \"degrees before adj=\", degrees,\"\\n\"\r\n if (x > 0)\r\n if (y > 0)\r\n # Quadrent 1;\r\n degrees = degrees\r\n else\r\n # Quadrent 2\r\n degrees = 90 - degrees\r\n end # else\r\n else\r\n if (y < 0)\r\n #Quadrent 3\r\n degrees = 270 - degrees\r\n else\r\n # must be Quadrent 4\r\n degrees = 270 - degrees\r\n end # else\r\n end #else\r\n pp = CNCPolar.new(dist, degrees)\r\n return pp\r\nend", "def correlation_for( object )\n self.correlations.detect { |c| c.matches?( object ) }\n end", "def prop_pearson(t, size, tails=:both)\n tails=:both if tails==2\n tails=:right if tails==1 or tails==:positive\n tails=:left if tails==:negative\n \n n_tails=case tails\n when :both then 2\n else 1\n end\n t=-t if t>0 and (tails==:both)\n cdf=Distribution::T.cdf(t, size-2)\n if(tails==:right)\n 1.0-(cdf*n_tails)\n else\n cdf*n_tails\n end\n end" ]
[ "0.75894415", "0.7104931", "0.68175733", "0.6656453", "0.6395304", "0.6372642", "0.627266", "0.61372995", "0.59260774", "0.5779789", "0.5698323", "0.568836", "0.5669646", "0.5526602", "0.53528136", "0.5314602", "0.51679915", "0.5163969", "0.512641", "0.5065346", "0.5033453", "0.50295687", "0.5008109", "0.49662533", "0.49109513", "0.48354477", "0.48114353", "0.47792825", "0.4750771", "0.47010872", "0.46761644", "0.4672448", "0.46314847", "0.46027002", "0.45806658", "0.45687383", "0.4523278", "0.45219642", "0.45188537", "0.45188537", "0.45135185", "0.4461773", "0.44612598", "0.44465926", "0.4429134", "0.4369118", "0.4353404", "0.43496445", "0.4349441", "0.43421847", "0.43312523", "0.43293774", "0.4326629", "0.4289089", "0.4288791", "0.42863035", "0.42708403", "0.42695025", "0.42663872", "0.42614368", "0.42564863", "0.42535266", "0.42506835", "0.42483953", "0.42459697", "0.4235232", "0.42337027", "0.4231339", "0.4224319", "0.42076176", "0.41923577", "0.41877788", "0.4179974", "0.41763872", "0.4174358", "0.41727278", "0.4172276", "0.41707322", "0.41694078", "0.41637388", "0.41591632", "0.41580364", "0.4146342", "0.4145043", "0.41396624", "0.41370222", "0.41323084", "0.41312382", "0.4130541", "0.4126316", "0.41180506", "0.41162795", "0.41156003", "0.41004735", "0.40970805", "0.40934154", "0.40922475", "0.40887862", "0.40837705", "0.4077314" ]
0.5994895
8
Ranking the critics TODO lacks the scorefunctionasparamter aspect of original.
def topMatches( prefs, person, n=5, scorefunc = :sim_pearson ) scores = [] for other in prefs.keys if scorefunc == :sim_pearson scores << [ sim_pearson(prefs,person,other), other] if other != person else scores << [sim_distance(prefs,person,other), other] if other != person end end return scores.sort.reverse.slice(0,n) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def army_rank; end", "def coast_guard_rank; end", "def rank_precedence() = RANKS_SCORES[self.rank]", "def rank; end", "def rank; end", "def calc_rank\n return (self.score * 20001) + self.speaks;\n end", "def navy_rank; end", "def calc_ranking\n ranked = Set.new # Variables to reify (and rank)\n symbol_table.root.defns.each_value do |entry|\n next unless entry.kind_of?(LogVar)\n\n assocs = blackboard.associations_for(entry.i_name, true)\n if assocs.nil? || assocs.empty?\n ranked << entry.i_name\n else\n assocs.each do |a|\n if a.kind_of?(Fusion)\n comb_moves = blackboard.i_name2moves[a.i_name]\n ranked << entry.i_name if comb_moves.size == 1\n else\n dependents = a.dependencies(self)\n dependents.each do |i_name|\n dep_idx = blackboard.i_name2moves[i_name]\n if dep_idx.nil? || dep_idx.empty?\n ranked << i_name\n # TODO: consider transitive closure\n end\n end\n end\n end\n end\n end\n # Rank the variables...\n scope = symbol_table.current_scope\n sorted_entries = []\n loop do\n vars_in_scope = scope.defns.values.select { |e| e.kind_of?(LogVar) }\n vars_in_scope&.reverse_each do |e|\n sorted_entries.unshift(e) if ranked.include? e.i_name\n end\n scope = scope.parent\n break if scope.nil?\n end\n\n rk_number = 0\n # Ensure that fused variables have same rank number\n sorted_entries.each do |e|\n if blackboard.fused?(e.i_name)\n siblings = cv2vars[blackboard.vars2cv[e.i_name]]\n if siblings\n occurred = siblings.find do |sb|\n ranking.include? sb\n end\n if occurred\n ranking[e.i_name] = ranking[occurred]\n end\n end\n end\n unless ranking.include? e.i_name\n ranking[e.i_name] = rk_number\n rk_number += 1\n end\n end\n ranking\n end", "def calculate_rank_and_grade \n points_off = 0\n points_off += self.opt_out_count * 5 \n points_off += self.un_solicited_count * 10 \n points_off += self.sell_count * 21 \n points_off += self.vulgar_count * 31 \n points_off = points_off/(self.surveys.count) \n result = case rank = 100 - points_off\n when 96..500 then \"A+\"\n when 90..95 then \"A-\"\n when 80..89 then \"B\"\n when 70..79 then \"C\"\n when 60..69 then \"D\"\n when 0..60 then \"F\"\n end\n self.grade = result\n self.rank = rank\n end", "def rank\n return inv + neg + nsp\n end", "def ranking\n self['ranking'] = score + self['num_comments']\n end", "def ranking\n self['ranking'] = score + self['num_comments']\n end", "def fix_calculation_ranks\n # Need to reload calculations because otherwise the array may still contained destroyed ones.\n calculations(true).sort_by(&:rank).each_with_index{ |c,i| c.rank = i + 1 }\n end", "def sort_using_rank\n score[1]\n end", "def compute_all_issues_rank\n\t\tissues = Issue.find :all\n\t\tranking = Hash.new()\n\t\tissues.each {|i| ranking[i.id] = 0.75 }\n\t\treturn ranking\n\tend", "def invertirRanking(unPunto, otroPunto)\n # ToDo\n end", "def score_priority(x)\n priority = 0\n 0.upto(x.size-1) { |i|\n if x[i] == @instance.final_capacities[i]\n priority += 7\n elsif @instance.final_capacities.include?(x[i])\n priority += 5\n elsif x[i] > 0 && x[i] != @instance.capacities[i]\n priority += 2\n end\n }\n return priority\n end", "def rank\n groups = PoliceGroup.all.sort_by(&:grand_total)\n index = groups.index(self) + 1\n place = index / groups.size.to_f\n if place > 0.75\n 'High'\n elsif place > 0.25\n 'Moderate'\n else\n 'Low'\n end\n end", "def rank\n case @owner\n # Prefer volumes from Princeton most strongly\n when 'njp'\n @rank = 4\n # Recap partners are next in order of preference\n when 'nyp', 'nnc1', 'nnc2.ark'\n @rank = 3\n # Followed by Borrow Direct partners\n when 'yale', 'hvd', 'coo', 'chi'\n @rank = 2\n # These are mentioned by Meagan\n when 'mdp', 'miun', 'uc1', 'uc2', 'loc.ark', 'uva', 'umn', 'dul1.ark', 'ien', 'inu', 'nc01.ark', 'pst', 'pur1', 'ucm', 'uiug', 'wu'\n @rank = 1\n # Anything else is unknown; rank lowest.\n else\n @rank = 0\n end\n @rank # return the rank\n end", "def space_force_rank; end", "def rank(prog); @ranks[prog]; end", "def reindeer_ranking\n\t\t\treindeer = [\"Rudolph\", \"Dasher\", \"Dancer\", \"Prancer\", \"Vixen\", \"Comet\", \"Cupid\", \"Donner\", \"Blitzen\"]\n\t\tend", "def rank\n @team_records.sort_by! do |team|\n team.wins\n end #still correct\n @team_records.reverse! #up until here we're okay\n\n @team_records.each_with_index do |team, index| #line that doesn't function as expected\n team.rank = index + 1 #returns only two teams repeated twice, with wrong indexes\n end\n end", "def ranking\n [what_rank, tie_breaker]\n end", "def calculate_rank(gravity=1.8)\n item_hour_age = (Time.now - created_at) / 3600 \n return (vote_score - 1) / (item_hour_age+2) ** gravity\n end", "def bayesian_rank\n\n #this is an ad hoc value, which basically represents the minimum number of \n #votes we think an Idea should have before it's even considered relevant. \n #eventually this value will come from the admin screen\n @magic_number_of_votes = 0.5\n\n @return_value = ((@magic_number_of_votes*Idea.average_rank_of_all_ideas.to_f)+(self.count_of_users_ranked*self.average_rank.to_f))/(@magic_number_of_votes+self.count_of_users_ranked)\n\n if @return_value == 0\n return 10\n else\n return @return_value.round(2)\n end\n\nend", "def rank\n\t\trr = self.clone\n\t\trr.row_reduce_below\n\t\trr.rank_rr\n\tend", "def get_interest_rank\n \n rank = (self.stories.count * 2) + (self.adding_users.count * 5)\n\n end", "def assign_score; end", "def total_rank(words)\n result = 0\n words.each_with_index { |word, index| result += word_worth(word) * (index + 1) }\n result\nend", "def re_rank\n all_member.each(&:uncache_rank_key)\n next_rank = 0\n all_member.\n sort_by(&:rank_key).\n each do |member|\n member.ordinal = next_rank\n next_rank += 1\n end\n end", "def marines_rank; end", "def alt_ranks\n { Division: \"Phylum\" }\n end", "def score\n if g = royal_flush?\n r = 5000\n elsif g = straight_flush?\n r = 4000 + g.last.rank\n elsif g = four_of_a_kind?\n r = 3500 + g.first.rank\n elsif g = full?\n high1 = three_of_a_kind?.first.rank\n high2 = pair?.first.rank\n r = 3000 + high1 * 100 + high2\n elsif g = flush?\n highest = g.last.rank\n r = 2500 + highest\n elsif g = straight?\n r = 2000 + g.last.rank\n elsif g = three_of_a_kind?\n r = 1500 + 100 * g.first.rank\n elsif g = two_pairs?\n high1 = g.last.rank\n high2 = g.first.rank\n r = 1000 + 100 * high1 + high2\n elsif g = pair?\n r = 500 + g.first.rank\n else\n g = highest?\n r = highest?.rank\n end\n [val - [g].flatten, r]\n end", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def rank_valuation_ratios(companies)\n\tranked_comps = { 'price_to_sales' => [], 'PEG' => [], 'EBITDA' => [] }\n\tcompanies.each do |comp|\n comp_info = [comp[0], comp[1], comp[2]]\n\t\tranked_comps['price_to_sales'] << (comp_info + [comp[3][5]['price_to_sales'][1]])\n\t\tranked_comps['PEG'] \t \t\t\t << (comp_info + [comp[3][5]['PEG'][1]])\n\t\tranked_comps['EBITDA'] \t\t\t\t << (comp_info + [comp[3][5]['EBITDA'][1]])\n\tend\n\n\tranked_comps.each do |ratio, companies|\n if ratio != 'PEG'\n\t\t ranked_comps[ratio] = (companies.sort_by { |c| c[3] }).reverse\n else\n ranked_comps[ratio] = companies.sort_by { |c| c[3] }\n end\n\tend\n\n ranked_comps\nend", "def getRecommendations( prefs, person, scorefunc = :sim_pearson )\n totals = {}\n simSums = {}\n for other in prefs.keys\n # don't compare me to myself\n next if other == person\n \n if scorefunc == :sim_pearson\n sim = sim_pearson( prefs, person, other )\n else\n sim = sim_pearson( prefs, person, other )\n end\n puts \"rec sim val: #{sim}\"\n #ignore scores of zero or lower\n next if sim <= 0\n \n for item in prefs[other].keys\n # only score movies I haven't seen yet\n if !prefs[person].include? item or prefs[person][item] == 0\n # similarity * score\n totals.default = 0\n totals[item] += prefs[other][item] * sim\n # sum of similarities\n simSums.default = 0\n simSums[item] += sim\n end\n end\n end\n \n # create a normalised list\n rankings = []\n totals.each do |item,total|\n rankings << [total/simSums[item], item]\n end\n \n # Return the sorted list\n return rankings.sort.reverse\n end", "def f2p_clues_rank(clue_type)\n f2p_rank [[\"clues_#{clue_type}\", :DESC],\n [\"id\", :ASC]]\n end", "def votes_ranking_for(opinion)\n ranking_for(opinion, opinion_votes_count: :desc)\n end", "def topMatches( prefs, person, n=5, scorefunc = :sim_pearson )\n scores = []\n for other in prefs.keys\n if scorefunc == :sim_pearson\n scores << [ sim_pearson(prefs,person,other), other] if other != person\n else\n scores << [ sim_distance(prefs,person,other), other] if other != person\n end\n end\n return scores.sort.reverse.slice(0,n)\n end", "def priority\n Rational(@successes + 1, tries_adj + 2) * ($use_cats && (self == $cur_element || category == $cur_category) ? 2 : 1)\n rescue ZeroDivisionError\n Float::INFINITY # this can happen if the element is yet to be skipped twice\n end", "def endorsements_ranking_for(opinion)\n ranking_for(opinion, endorsements_count: :desc)\n end", "def base_score\n rank.last\n end", "def assign_score_limit; end", "def rank_actors \n top_actors.inject([]) do |sorted, element|\n sorted << if sorted.last and sorted.last[:count] == element.last[:count]\n { :actor => element.first, :count => element.last[:count], :rank => sorted.last[:rank] }\n else\n { :actor => element.first, :count => element.last[:count], :rank => sorted.length + 1 }\n end\n end\n end", "def oldrank(prog); @oldranks[prog]; end", "def rank() User.withVerifiedWeighins.paid.sort_by {|u| u.percentWeightChange }.index(self)+1 end", "def find_relative_ranks(nums)\n hash = {}\n nums.each_with_index do |num, index|\n hash[num] = index\n end\n hash = hash.sort.to_h\n print hash\n count = 0\n hash.each do |k, v|\n if count == nums.size - 3\n nums[v] = \"Bronze Medal\"\n elsif count == nums.size - 2\n nums[v] = \"Silver Medal\"\n elsif count == nums.size - 1\n nums[v] = \"Gold Medal\"\n else\n nums[v] = (nums.size - count).to_s\n end\n count += 1\n end\n nums\nend", "def check_rank_rules\n defined_rules.each do |scoped_model, level_and_rules|\n level_and_rules.sort.each do |level, rule|\n grant_when_applies(scoped_model, rule, level)\n end\n end\n end", "def ordered_by_qualifications(candidates)\n ordered_candidates = candidates.sort_by { |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n return (ordered_candidates).reverse\n\n # @ordered_by_qualifications = []\n\n # candidates.each do |candidate|\n # years_exp s=candidate[:years_of_experience]\n # @ordered_by_qualifications << years_exp\n # if years_exp == years_exp += 1\n # candidate[:github_points] > candidate[github_points] += 1\n # end \n \n # end\n # return @ordered_by_qualifications.sort!.reverse\n #This line returns the values 12..1 \n # return @ordered_by_qualifications.sort!.reverse\nend", "def top_three_recipes \n a = recipes.sort_by do |i| \n i.rating \n end \n a[-3..-1]\n end", "def f2p_gains_rank(skill, time)\n f2p_rank [[\"(#{skill}_ehp - #{skill}_ehp_#{time}_start)\", :DESC],\n [\"(#{skill}_xp - #{skill}_xp_#{time}_start)\", :DESC],\n [\"#{skill}_ehp\", :DESC],\n [\"#{skill}_xp\", :DESC],\n [\"id\", :ASC]],\n \"overall_ehp_day_start > 0 AND (overall_ehp > 250 OR player_name IN #{Player.sql_supporters})\"\n\n end", "def rank(result_array)\n # Highest first.\n return result_array.sort_by{ |hash| - hash[:score] + (hash[:enabled]==false ? 10 : 0) }\n end", "def page_rank damping = 0.85, &weight\n weight ||= proc {|item| 1.0}\n\n @total = 0\n @rank = {}\n @enumerable.each do |item|\n @total += \n (@rank[item] = weight.call(item) * 1.0)\n end\n # Normalize:\n @enumerable.each do |item|\n @rank[item] /= @total\n end\n\n 50.times do |iteration|\n @enumerable.each do |item|\n links = (precursors(item) + followers(item)).uniq\n linked_rank = links.map do |l|\n onward_links = (precursors(l) + followers(l)).uniq || @enumerable.size\n @rank[l] / onward_links.size\n end.inject(&:+) || 0\n @rank[item] = (1.0-damping) + damping*linked_rank\n end\n end\n\n @rank\n end", "def what_rank\n 10 - all_ranks.find_index{ |truth| truth != 2014} \n end", "def calc_score(f, rs, rk, nbrs)\n score = 0.0\n \n nbrs.each do |k, s|\n if k == rk # near hit\n score -= diff_feature(f, rs, s)**2\n else # near_miss\n score += diff_feature(f, rs, s)**2\n end\n end\n \n score\n end", "def percent_high_ranking\n\n count_high = 0\n\n cards.each do |card|\n\n if card.rank >= 11\n count_high += 1\n end\n\n end\n\n\n count_high_f = count_high.to_f\n count_total = cards.length\n count_total_f = count_total.to_f\n\n (100 * (count_high_f/count_total_f)).round(2)\n\n end", "def relevancy_score\n header_score\n end", "def getRecommendations(prefs, person, scorefunc = :sim_pearson )\n totals = {}\n simSums = {}\n for other in prefs.keys\n # don't compare me to myself\n next if other == person\n\n if scorefunc == :sim_pearson\n sim = sim_pearson( prefs, person, other)\n else\n sim = sim_distance( prefs, person, other)\n end\n\n # ignore scores of zero or lower\n next if sim <= 0\n\n for item in prefs[other].keys\n # only score movies I haven't seen yet\n if !prefs[person].include? item or prefs[person][item] == 0\n # similarity * score\n totals.default = 0\n totals[item] += prefs[other][item] * sim\n # sum of similarities\n simSums.default = 0\n simSums[item] += sim\n end\n end\n end\n\n # Create a normalized list\n rankings = []\n totals.each do |item,total|\n rankings << [total/simSums[item], item]\n end\n\n # Return the sorted list\n return rankings.sort.reverse\n end", "def rate_profit_revision(profit_revision)\n ## Deprecated see OnVistaExtractor.extract_profit_revision(...)\n # u = profit_revision.up\n # e = profit_revision.equal\n # d = profit_revision.down\n # case\n # when u > e && u > d\n # score = 1\n # when e > u && e > d\n # score = 0\n # when d > u && d > e\n # score = -1\n # when u == e && e == d\n # score = 0\n # when u == e || u > d\n # score = 0\n # when u == d\n # score = 0\n # else\n # score = -1\n # end\n # profit_revision.score = score\n \n case\n when profit_revision.up == 1\n score = 1\n when profit_revision.equal == 1\n score = 0\n when profit_revision.down == 1\n score = -1\n else\n score = -1\n end\n profit_revision.score = score\n return score\n end", "def match_ranking(og, fg, abv, ibu, color)\n rank_attr(og, og_min, og_max) +\n rank_attr(fg, fg_min, fg_max) +\n rank_attr(abv, abv_min, abv_max) +\n rank_attr(ibu, ibu_min, ibu_max) +\n rank_attr(color, color_min, color_max)\n end", "def most_points_scored\nplayer_with_most(:points)\nend", "def score\n s = Settings.instance\n s.faculty_weight.to_f * (s.rank_weight.to_f/self.rank.to_f + s.mandatory_weight.to_f*(self.mandatory ? 1.0 : 0.0))\n end", "def rate_reaction(reaction)\n stock_performance = Util.perf(reaction.price_after, reaction.price_before)\n Rails.logger.debug(\"#{self.class}: stock performance: #{stock_performance}\")\n reaction.share_perf = stock_performance\n index_performance = Util.perf(reaction.index_after, reaction.index_before)\n Rails.logger.debug(\"#{self.class}: index performance: #{index_performance}\")\n reaction.index_perf = index_performance\n diff = stock_performance - index_performance\n Rails.logger.debug(\"#{self.class}: performance diff: #{diff}\")\n case \n when diff > 1\n score = 1\n when diff < -1\n score = -1\n else\n score = 0\n end\n reaction.score = score\n return score\n end", "def rerank\n s = score * DAY_POINTS\n self.rank = Time.now.to_i + s\n end", "def force_rating\n rating = 0\n # Force rating is 1 if either of the 3 specializations is a force tree.\n if self.specialization_1\n tree = TalentTree.find(self.specialization_1)\n if tree.force_tree\n rating = 1\n end\n end\n if self.specialization_2\n tree = TalentTree.find(self.specialization_2)\n if tree.force_tree\n rating = 1\n end\n end\n if self.specialization_3\n tree = TalentTree.find(self.specialization_3)\n if tree.force_tree\n rating = 1\n end\n end\n\n # Add one rank for each Force Rating talent.\n CharacterExperienceCost.where(:character_id => self.id, :resource_type => 'talent').each do |talent|\n if talent.resource_id && talent.resource_id > 0 && Talent.find(talent.resource_id).name == \"Force Rating\"\n rating += 1\n end\n end\n\n rating\n end", "def top_three_recipes\n self.find_user_recipe_cards.sort_by{|rcard| rcard.rating}.reverse![0..2]\n end", "def rank\n @rank > 10 ? 10 : @rank\n end", "def sort_ranks(_ranks)\n raise NotImplementedError\n end", "def custom_popularity(popularity, tracker_count)\n popularity *= self.rank if self.rank.present?\n\n return popularity, tracker_count\n end", "def sort_ranking\n @sorted_hash = @hash_ranking.sort_by { |_name, points| -points }\n @sorted_hash = @sorted_hash.first(10)\n @sorted_hash.map { |k, v| \"#{k}\\t#{v}\" }.join(\"\\n\")\n end", "def frequency_score(character_hash)\n frequency_pairs = frequency_order.each_with_index.map {|el, idx| [el, idx]}\n critical_indices = (0..7).to_a + frequency_pairs[-5..-1].map {|el| el[1]}\n frequency_pairs.sort_by do |pair|\n -character_hash[pair[0]] end.each_with_index.map do |pair, idx|\n critical_indices.include?(idx) ? (pair[1] - idx).abs : 0\n end.inject(&:+) * (1 + character_hash.values.inject(&:+)/10)\nend", "def update_ranks\n i = 0\n rank = 0\n ncon = nil\n Contributor.all_with_ncontributions.each do |contributor|\n i += 1\n if contributor.ncontributions != ncon\n rank = i\n ncon = contributor.ncontributions\n end\n contributor.update_attribute(:rank, rank) if contributor.rank != rank\n end\n end", "def calculated_priority\n employer_partner = employer.employer_partner\n \n value = if employer_partner && inbound && recurring\n 0\n elsif employer_partner && inbound\n 1\n elsif inbound\n 2\n elsif employer_partner && recurring\n 3\n elsif employer_partner\n 4\n elsif recurring\n 5\n else\n 6\n end\n \n value += 10 if published?\n \n value\n end", "def normalizeRankings\n setRankings = []\n ranking.each do |allRanking|\n if(allRanking.rank != nil)\n setRankings.push(allRanking)\n end\n end\n \n #setRankings = ranking.where.not(:rank => nil)\n setRankings.order(:rank, :desc)\n setRankings.each_with_index do |iterationRanking, index|\n iterationRanking.rank = index + 1\n end\n end", "def rank\n\t\tRANKINGS.each do |ranking|\n\t\t\treturn ranking if self.send(\"#{ranking}?\".to_sym)\n\t\tend\n\tend", "def placings\n score_ordering = low? ? :asc : :desc\n\n scores.order(disqualified: :asc)\n .order(participated: :desc)\n .order(tier: :asc)\n .order(score: score_ordering)\n .order(tiebreaker_place: :asc)\n end", "def initial_ranks\n raise NotImplementedError\n end", "def max_total_score\n review_criterions.collect{|c| c.max_score}.sum\n end", "def rank(hits)\n\t\thits = Search.fill_meta(hits)\n\t\t\n\t\thits.each do |h|\n\t\t\th[:distance] = distance(query, h[:object].display)\n\t\t\th[:score] = h[:distance] * HIT_WEIGHT_SIMILARITY + \n\t\t\t h[:popularity] * HIT_WEIGHT_POPULARITY\n\t\tend\n\t\t\n\t\thits = hits.sort_by { |h| -1 * h[:score] }\n\tend", "def f2p_skill_rank(skill)\n f2p_rank [[\"#{skill}_ehp\", :DESC],\n [\"#{skill}_lvl\", :DESC],\n [\"#{skill}_xp\", :DESC],\n [\"#{skill}_rank\", :ASC],\n [\"id\", :ASC]]\n end", "def ordered_by_qualifications(candiates)\n # Candidates with the most experience are at the top\n return candiates.sort_by { | obj | [obj[:years_of_experience], obj[:github_points]] }\n # return candiates.sort! { |a, b| b[:years_of_experience] <=> a[:years_of_experience] }\n\n # return candiates.sort_by {|:years_of_experience, :github_points|[ :github_points, :years_of_experience]}\n\n # return candiates.sort { | a, b | }\n # array.sort { |a,b| [ a[1], a[0] ] <=> [ b[1], b[0] ] }\n\n\n # For Candidates that have the same years of experience, \n #they are further sorted by their number of Github points (highest first)\nend", "def score\n 3*@tally + 5*@strength + 2*@wealth + @food + 30*@monsters_killed\n end", "def get_TPR(ranks, universe_length, threshold = 0.1)\n\t# Metric limit\n\tlimit = threshold * universe_length\n\t# Obtain number of ranks which are found before LIMIT\n\tnum_uppers = ranks.select{|rank| rank <= limit}.length\n\t# return rate\n\treturn (num_uppers*100 / ranks.length)\nend", "def score; end", "def score3\r\n score1ot\r\n end", "def compute_impact_factor(tweets)\n\t\tretweets = Array.new\n\t\ttweets.each do |tweet|\n\t\t\tretweets << tweet.get_retweet_count\n\t\tend\n\t\tretweets = retweets.sort\n\t\tretweets = retweets.reverse\n\t\th_index = get_h_index(retweets)\n\t\tputs \"H_INDEX\"+ h_index.to_s\n\t\treturn h_index\n\tend", "def total_score\n total = 0\n @cards.each do |card|\n total += card.value\n end\n\n sorted_cards = @cards.sort\n\n straights = get_straight(sorted_cards).reverse\n straights.each do |straight|\n total += 40\n sorted_cards.slice!(straight[0]..straight[1])\n end\n\n three_cards = get_number_of_a_kind(sorted_cards, 3)\n three_cards.each do |three|\n total += 20\n sorted_cards.slice!(three[0]..three[1])\n end\n\n pairs = get_number_of_a_kind(sorted_cards, 2)\n pairs.each do |pair|\n total += 10\n sorted_cards.slice!(pair[0]..pair[1])\n end\n\n total\n end", "def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend", "def score_factor_count\n com_count = self.complaints.finished.count\n dep_review_count = count_scorable_department_reviews\n city_review_count = count_scorable_city_reviews\n petition_count = self.petitions.finished.count\n return score_count = com_count + dep_review_count + city_review_count + petition_count\n end", "def rank\n y + 1\n end", "def display_score score, rank\r\n\r\n end", "def update_rankings\n winner = Player.find(winner_id)\n loser = Player.find(loser_id)\n\n if self.draw\n if (winner.rank - loser.rank) < 1\n winner.update_ranking 1\n elsif winner.rank - loser.rank > 1\n loser.update_ranking 1\n end\n else\n if winner.rank < loser.rank\n return\n else\n diff = winner.rank - loser.rank\n loser.update_ranking 1\n winner.update_ranking (diff/2)*-1\n end\n end\n\n\n end", "def ranked_repositories\n repositories_review.sort_by do |repository|\n repository.fully_reviewed? ? 1 : -1\n end\n end", "def percent_high_ranking\n high = 0.0\n low = 0.0\n cards.each do |card|\n if card.rank >= 11\n high += 1\n else\n low += 1\n end\n end\n (high * 100 / (high + low)).ceil(2)\n end", "def ranks\n @teams = Team.where(\"wins > 0\t\").order(win_percentage: :desc)\n end", "def ranking\n (1..Survey.count).to_a.sample\n end", "def stockRankings(stat)\n stock_count = {} #Hash to store Product Name and Stock Units\n @@products.each { |p| stock_count [p.units] = p.name } \n\n if stat == \"max\"\n pnames = []\n stock_count.keys.sort!.last(3).each { |count| pnames << stock_count[count] }\n\n puts \"\\n Please find below Product Details for Top-3 Products with maximum units in Stock : \"\n pnames.reverse.each { |pname| getProdbyName(pname) }\n elsif stat == \"min\"\n pnames = [] \n stock_count.keys.sort!.first(3).each { |count| pnames << stock_count[count] }\n\n puts \"\\n Please find below Product Details for Top-3 Products with minimum units in Stock : \"\n pnames.each { |pname| getProdbyName(pname) }\n end\n end", "def best(n)\n @score.sort{|a,b| b[1][0] <=> a[1][0]}[0..n-1]\n end", "def score=(_); end" ]
[ "0.690859", "0.68162215", "0.6675271", "0.6641978", "0.6641978", "0.6626971", "0.65653944", "0.6545263", "0.6497229", "0.6389432", "0.6332983", "0.6332983", "0.6309176", "0.6299042", "0.6260107", "0.6220353", "0.62186444", "0.6206703", "0.6159537", "0.6133324", "0.61007375", "0.60977024", "0.6079744", "0.6079354", "0.6062508", "0.6056111", "0.60506827", "0.5996277", "0.5983746", "0.5925238", "0.59190965", "0.5915798", "0.59149945", "0.5910179", "0.5888943", "0.58863795", "0.5882631", "0.58775264", "0.5872758", "0.585913", "0.5857056", "0.58568734", "0.58412814", "0.5840298", "0.5839916", "0.58321875", "0.5826803", "0.5813711", "0.5813196", "0.58090687", "0.5792475", "0.57837415", "0.57742375", "0.5767134", "0.57549566", "0.57487243", "0.5746596", "0.574313", "0.5740867", "0.5733879", "0.5730624", "0.5723962", "0.57144195", "0.57123715", "0.57070434", "0.5701187", "0.56936693", "0.5681732", "0.56812865", "0.5668382", "0.566577", "0.5663916", "0.5658157", "0.5656309", "0.565603", "0.5652794", "0.5652431", "0.5638562", "0.56358624", "0.5635356", "0.56260717", "0.56187963", "0.56178254", "0.56177235", "0.5616533", "0.561366", "0.5605822", "0.56040514", "0.5597892", "0.5596158", "0.5595099", "0.5588291", "0.5581174", "0.5579492", "0.5579389", "0.5579004", "0.55734676", "0.5571636", "0.55660367", "0.55644464" ]
0.58627325
39
Gets recommendations for a person by using a wieghted average of every other user's rankings uses sim_pearson only
def getRecommendations( prefs, person, scorefunc = :sim_pearson ) totals = {} simSums = {} for other in prefs.keys # don't compare me to myself next if other == person if scorefunc == :sim_pearson sim = sim_pearson( prefs, person, other ) else sim = sim_pearson( prefs, person, other ) end puts "rec sim val: #{sim}" #ignore scores of zero or lower next if sim <= 0 for item in prefs[other].keys # only score movies I haven't seen yet if !prefs[person].include? item or prefs[person][item] == 0 # similarity * score totals.default = 0 totals[item] += prefs[other][item] * sim # sum of similarities simSums.default = 0 simSums[item] += sim end end end # create a normalised list rankings = [] totals.each do |item,total| rankings << [total/simSums[item], item] end # Return the sorted list return rankings.sort.reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getRecommendations(prefs, person, scorefunc = :sim_pearson )\n totals = {}\n simSums = {}\n for other in prefs.keys\n # don't compare me to myself\n next if other == person\n\n if scorefunc == :sim_pearson\n sim = sim_pearson( prefs, person, other)\n else\n sim = sim_distance( prefs, person, other)\n end\n\n # ignore scores of zero or lower\n next if sim <= 0\n\n for item in prefs[other].keys\n # only score movies I haven't seen yet\n if !prefs[person].include? item or prefs[person][item] == 0\n # similarity * score\n totals.default = 0\n totals[item] += prefs[other][item] * sim\n # sum of similarities\n simSums.default = 0\n simSums[item] += sim\n end\n end\n end\n\n # Create a normalized list\n rankings = []\n totals.each do |item,total|\n rankings << [total/simSums[item], item]\n end\n\n # Return the sorted list\n return rankings.sort.reverse\n end", "def getRecommendations()\n totals=Hash.new(0)\n simSum=Hash.new(0)\n \n \n @prefs.each_pair do |other,ranks|\n \n # next if it's me\n next if other == @person\n \n # check the affinity \n sim = @similarity.compute(other)\n \n # next if no affinity\n next if sim <= 0\n \n # for each unranked element\n ranks.each_pair do |name,rank|\n if !@prefs[@person].include?(name) or @prefs[@person].length == 0\n \n totals[name] += rank * sim\n simSum[name] += sim\n \n end\n end \n end\n \n # Array creation\n totals.to_a.collect do |e|\n [e[1]/simSum[e[0]],e[0]]\n end.sort do |a,b|\n b[0] <=> a[0]\n end\n \n end", "def get_recommended_items(data, item_sim, user)\n user_rating = data[user]\n scores = {}\n total_sim = {}\n\n user_rating.each do |item, rating|\n item_sim[item].each do |similarity, item2|\n if user_rating[item2].nil?\n # weighted sum of rating times similarity\n scores[item2] ||= 0\n scores[item2] += similarity*rating\n\n # sum of all similarities\n total_sim[item2] ||= 0\n total_sim[item2] += similarity\n end\n end\n end\n\n rankings = scores.collect do |item, score|\n [score/total_sim[item], item]\n end\n rankings.sort!\n rankings.reverse! \n end", "def recommend_by_item_based(user, top = @default_recommendation_count)\n return unless @similarity_matrix\n \n weighted_similar_items = Hash.new(0.0)\n similarity_sum_per_item = Hash.new(0.0)\n \n user.list.items.each_value do |user_item|\n item = @items[user_item.id]\n \n sim_objs = @similarity_matrix[item.id]\n sim_objs.each do |obj|\n next if user.has_item? obj[:id]\n weighted_similar_items[obj[:id]] += user_item.rating * obj[:similarity].abs\n similarity_sum_per_item[obj[:id]] += obj[:similarity].abs\n end\n end\n \n recommendations = weighted_similar_items.collect do |k, v|\n next if v == 0.0 or similarity_sum_per_item[k] == 0.0\n { :id => k, :est => (v / similarity_sum_per_item[k]) }\n end\n recommendations.compact.sort{ |x, y| y[:est] <=> x[:est] }.first(top || recommendations.size)\n end", "def sim_pearson(preferences, p1, p2)\n # Get the list of shared_items \n shared_items=[] \n preferences[p1].each do |movie, rating| \n shared_items << movie if preferences[p2].keys.include?(movie) \n end\n \n # if they have no ratings in common, return 0 \n return 0 if shared_items.size == 0\n \n # Add up all the preferences \n sum1 = shared_items.inject(0) { |sum, movie| sum + preferences[p1][movie] }\n sum2 = shared_items.inject(0) { |sum, movie| sum + preferences[p2][movie] }\n \n # Sum up the squares \n sum1Sq = shared_items.inject(0) { |sum, movie| sum + preferences[p1][movie]**2 }\n sum2Sq = shared_items.inject(0) { |sum, movie| sum + preferences[p2][movie]**2 }\n \n # Sum up the products \n pSum = shared_items.inject(0) { |sum, movie| sum + preferences[p1][movie] * preferences[p2][movie] }\n\n # Calculate Pearson score \n num = pSum-(sum1*sum2/shared_items.size) \n den = sqrt((sum1Sq - sum1**2 / shared_items.size)*(sum2Sq - sum2**2 / shared_items.size)) \n return 0 if den == 0\n r = num/den \n return r\nend", "def get_recommendation(data, key, metric = Pearson.new)\n totals = {}\n sim_sums = {}\n\n others = data.keys - [key]\n others.each do |other|\n sim = metric.distance(data, key, other)\n\n # only check others with similarity > 0\n if sim > 0\n data[other].each do |item, score|\n # only check item not rated by me\n if data[key][item].nil? or data[key][item] == 0\n totals[item] = 0 if totals[item].nil?\n sim_sums[item] = 0 if sim_sums[item].nil?\n\n totals[item] += score * sim\n sim_sums[item] += sim\n end\n end\n end\n end\n\n rankings = totals.collect do |item, score|\n [score/sim_sums[item], item] \n end\n rankings.sort!\n rankings.reverse!\n end", "def similarity_by_pearson_for_items(item1, item2, list)\n common_users = find_common_users(item1, item2, list)\n size = common_users.size\n \n return 0 if size < 1\n \n i1_sum_ratings = i2_sum_ratings = i1_sum_sq_ratings = i2_sum_sq_ratings = sum_of_products = 0.0\n common_users.each do |user|\n i1_rating = user.rating_for item1.id\n i2_rating = user.rating_for item2.id\n \n # Sum of all ratings by users\n i1_sum_ratings += i1_rating\n i2_sum_ratings += i2_rating\n \n # Sum of all squared ratings by users\n i1_sum_sq_ratings += i1_rating**2\n i2_sum_sq_ratings += i2_rating**2\n \n # Sum of product of the ratings that given to the same item\n sum_of_products += i1_rating * i2_rating\n end\n \n # Long lines of calculations, see http://davidmlane.com/hyperstat/A56626.html for formula.\n numerator = sum_of_products - ((i1_sum_ratings * i2_sum_ratings) / size)\n denominator = Math.sqrt((i1_sum_sq_ratings - (i1_sum_ratings**2) / size) * (i2_sum_sq_ratings - (i2_sum_ratings**2) / size))\n \n result = denominator == 0 ? 0 : (numerator / denominator)\n \n result = -1.0 if result < -1\n result = 1.0 if result > 1\n result\n end", "def prediction(user, item)\n av_user = user_average_rating(user)\n upper_sum, bottom_sum = 0, 0\n neighbours = get_neighbours(user)\n\n neighbours.each_with_index do |neighbour, i|\n if neighbour_rating = Review.where(user_id: neighbour.id, item_id: item.id).first\n upper_sum = upper_sum + ( similarity(user, neighbour) * (neighbour_rating.rating - user_average_rating(neighbour)) )\n bottom_sum = bottom_sum + similarity(user, neighbour)\n end\n\n end\n\n if upper_sum > 0 and bottom_sum > 0\n av_user + (upper_sum / bottom_sum)\n else\n 0\n end\n end", "def topMatches( prefs, person, n=5, scorefunc = :sim_pearson )\n scores = []\n for other in prefs.keys\n if scorefunc == :sim_pearson\n scores << [ sim_pearson(prefs,person,other), other] if other != person\n else\n scores << [sim_distance(prefs,person,other), other] if other != person\n end\n end\n return scores.sort.reverse.slice(0,n)\n end", "def topMatches( prefs, person, n=5, scorefunc = :sim_pearson )\n scores = []\n for other in prefs.keys\n if scorefunc == :sim_pearson\n scores << [ sim_pearson(prefs,person,other), other] if other != person\n else\n scores << [ sim_distance(prefs,person,other), other] if other != person\n end\n end\n return scores.sort.reverse.slice(0,n)\n end", "def sim_pearson( prefs, p1, p2)\n # Get the list of mutually rated items\n si = {}\n for item in prefs[p1].keys\n si[item] = 1 if prefs[p2].include? item\n end\n\n # Find the number of elements\n n = si.length\n puts n \n # If there are no ratings in common, return 0\n return 0 if n == 0\n\n # Add up all the preferences\n sum1 = si.keys.inject(0) { |sum,value| sum += prefs[p1][value] }\n sum2 = si.keys.inject(0) { |sum,value| sum += prefs[p2][value] }\n puts \"sum1 #{sum1}\"\n puts \"sum2 #{sum2}\"\n # Sum up the squares\n sum1Sq = si.keys.inject(0) { |sum,value| sum += prefs[p1][value] ** 2 }\n sum2Sq = si.keys.inject(0) { |sum,value| sum += prefs[p2][value] ** 2 }\n\n # Sum up the products\n pSum = si.keys.inject(0) { |sum,value| sum += (prefs[p1][value] * prefs[p2][value])}\n puts \"pSum #{pSum}\"\n # Calculate the Pearson score\n num = pSum - (sum1*sum2/n)\n puts \"num #{num}\"\n den = Math.sqrt((sum1Sq - (sum1 ** 2)/n) * (sum2Sq - (sum2 ** 2)/n))\n puts \"den #{den}\"\n return 0 if den == 0\n r = num / den\n end", "def sim_pearson( prefs, p1, p2)\n # Get the list of mutually rated items\n si = {}\n for item in prefs[p1].keys\n si[item] = 1 if prefs[p2].include? item\n end\n\n # Find the number of elements\n n = si.length\n # If there are no ratings in common, return 0\n return 0 if n == 0\n\n # Add up all the preferences\n sum1 = si.keys.inject(0) { |sum,value| sum += prefs[p1][value] }\n sum2 = si.keys.inject(0) { |sum,value| sum += prefs[p2][value] }\n\n # Sum up the squares\n sum1Sq = si.keys.inject(0) { |sum,value| sum += prefs[p1][value] ** 2 }\n sum2Sq = si.keys.inject(0) { |sum,value| sum += prefs[p2][value] ** 2 }\n\n # Sum up the products\n pSum = si.keys.inject(0) { |sum,value| sum += (prefs[p1][value] * prefs[p2][value])}\n\n # Calculate the Pearson score\n num = pSum - (sum1*sum2/n)\n den = Math.sqrt((sum1Sq - (sum1 ** 2)/n) * (sum2Sq - (sum2 ** 2)/n))\n\n return 0 if den == 0\n r = num / den\n end", "def rates_by\n recommendable_likes.map(&:user_id) + recommendable_dislikes.map(&:user_id)\n end", "def get_rating_averages\n set = GumRatingRelationship.where(:gum_id => self.id)\n return([set.average(:rank_1), set.average(:rank_2), set.average(:rank_3), set.average(:rank_4), set.average(:rank_5) ])\n end", "def closest_neighbours(person, number_of_users)\n\n\tfile = File.read('./json/user_data.json')\n\tdata_hash = JSON.parse(file)\n\n\tscores = Array.new\n\tperson_collection = Array.new\n\n\t# Returns the number of similar uses to a specific person\n\tdata_hash.each do |key,value|\n\t\tif key != person\n\t\t\tperson_collection.push(key)\n\t\t\tscores.push(pearson_correlation(person, key))\n\t\tend\n\tend\n\n\tfinal_score = scores.zip(person_collection)\n\n\t# Sort the highest similar person to lowest\n\tfinal_score.sort!{|x,y| y <=> x}\n\tfinal_score[0 .. number_of_users - 1]\nend", "def recommendations\n User.where.not(id: self.friends).or(User.where.not(id: self.inverse_friends)).limit(5)\n end", "def pearson_similarity (u1,u2)\n\t\tsimilarity = @train_data[u1].movie_and_rating.keys & @train_data[u2].movie_and_rating.keys\n\t\tif similarity.empty?\n\t\t\treturn 0\n\t\tend\n\t\tsum_1 = 0\n\t\tsum_2 = 0\n\t\tsum_1_sq = 0\n\t\tsum_2_sq = 0\n\t\tproduct = 0\n\n\t\tsimilarity.each do |mov|\n\t\t\tsum_1 += @train_data[u1].return_rating(mov)\n\t\t\tsum_1_sq += @train_data[u1].return_rating(mov)**2\n\t\t\tsum_2 += @train_data[u2].return_rating(mov)\n\t\t\tsum_2_sq += @train_data[u2].return_rating(mov)**2\n\t\t\tproduct += @train_data[u1].return_rating(mov)*@train_data[u2].return_rating(mov)\n\t\tend\n\n\t\tnumerator = product - (sum_1*sum_2/similarity.length)\n\t\tdenom = Math.sqrt((sum_1_sq-(sum_1**2)/similarity.length)*(sum_2_sq-(sum_2**2)/similarity.length))\n\n\t\tif denom == 0 \n\t\t\treturn 0\n\t\tend\n\t\treturn numerator/denom\n\tend", "def avg_rating\n movie_recs = self.given_movie_recommendations\n book_recs = self.given_book_recommendations\n ratings = (movie_recs + book_recs).map(&:recommendee_rating).compact\n return 0 if ratings.empty?\n (ratings.sum.to_f / ratings.size.to_f).round(1)\n end", "def predict(user, movie)\n\t\tother_users = viewers(movie)\n\t\tratings_combined = 0.0\n\t\t#2.5 is a default value in case there is no other data to base the rating off of.\n\t\tif other_users == nil\n\t\t\treturn 2.5\n\t\tend\n\t\trating_count = other_users.length\n\t\tother_users.each do |other_user|\n\t\t\tratings_combined += rating(other_user, movie).to_f\n\t\tend\n\t\t#The algorithm sets the prediction equal to the average of all other ratings for the movie.\n\t\treturn ratings_combined / rating_count\n\tend", "def predict(u,m)\n similar_users=most_similar(u)\n weighted_rate=0.0\n sum=0.0\n similar_users.each do |user|\n rate=rating(user[0],m)\n if rate!=0\n weighted_rate+=user[1]*rate\n sum+=user[1]\n end\n end\n if sum==0\n return 0\n end\n return weighted_rate/sum\n end", "def recommendations\n unless params[:user_id].present?\n render json: { response: 'User id not present' }, status: :bad_request\n end\n\n user = User.find_by_id(params[:user_id])\n recommendations = []\n\n user.movies.each do |movie|\n recommendations_for_movie = Tmdb::Movie.recommendations(movie[:id])\n recommendations_for_movie[:results].each do |recommendation|\n recommendations << recommendation\n end\n end\n\n render json: { response: recommendations }, status: :ok\n end", "def get_recommendations\n result = []\n DIST[@pain_severity].each do |element|\n unique = false\n while !unique\n recommendation = weighted_sample(Recommendation.send(element).suggestable)\n if result.include? recommendation\n recommendation = weighted_sample(Recommendation.send(element).suggestable)\n else\n result << recommendation\n unique = true\n end\n end\n end\n result\n end", "def predict(user_id, movie_id)\n movie_average_rating = set.popularity(movie_id)\n #puts \"The popularity of movie #{movie_id} is #{movie_average_rating}\"\n\n most_similar_users_list_ratings = set.most_similar(user_id)[0..29].collect do |u, r|\n if rating(u, movie_id)!=0 then\n rating(u, movie_id)\n end\n end.compact[0..9]\n #puts \"Actual rating: #{rating(user_id, movie_id)}\"\n #puts \"most_similar_users_list_ratings: #{most_similar_users_list_ratings}\"\n #puts \"Prediction: #{take_average(most_similar_users_list_ratings)}\"\n\n if most_similar_users_list_ratings.size > 0\n avg_most_similar_users_ratings = take_average(most_similar_users_list_ratings)\n 0.3*avg_most_similar_users_ratings+0.7*movie_average_rating\n else\n movie_average_rating\n end\n end", "def sim_distance(preferences, person1, person2)\n have_movies_in_common = preferences[person1].detect {|movie, rating| preferences[person2].keys.include?(movie) }\n \n # if they have no ratings in common, return 0 \n return 0 unless have_movies_in_common\n \n # Add up the squares of all the differences \n sum_of_squares = 0\n preferences[person1].each do |movie, rating| \n sum_of_squares += (rating - preferences[person2][movie])**2 if preferences[person2].keys.include?(movie) \n end\n\n return 1/(1 + sum_of_squares)\nend", "def similarity(user1, user2)\n similar_movies_avg = []\n\n #fill in user1_data and user2_data\n #find similar watched movies, remove differences in both lists\n $unique_user_data[user1.to_i - 1].each_key {|movieId, rating|\n if $unique_user_data[user2.to_i - 1].has_key?(movieId)\n similar_movies_avg.push((rating.to_i - $unique_user_data[user2.to_i - 1][movieId].to_i).abs)\n end\n }\n #find average\n return similar_movies_avg.inject{ |sum, el| sum + el }.to_f / similar_movies_avg.size\n end", "def predict(u,m)\n \n # 1. the average\n \t\tcount=0\n \t\tsum=0.0\n \t\tdatab.each do |line| \n\t\t\tif line[\"user_id\"]==u.to_i\n\t\t\tcount+=1\n\t\t\tsum+=line[\"rating\"]\n\t\t\tend\n \t\tend\n \t\tans1 = sum/count\n \t# 2. rating from the most similar user\n \t \ta_movie_data = MovieData0.new(datab)\n \t \t\n \t \tsimilar_user_info_arr = a_movie_data.most_similar(u)\n \t puts\tsimilar_user_info_arr\n \t \tputs \"here predict2\"\n \t \tsimilar_rating = 0.0\n \t \ttop_20percent_index = 0.2*similar_user_info_arr.size() #only search in top 20percent most similar users\n \t \t\n \t \tsimilar_user_info_arr[0..top_20percent_index].each do |hs| \n \t \t\n \t \t\tuser_id=hs[\"user_id\"] \n\t\t\tif z.rating(user_id,m)!=0\n\t\t\tsimilar_rating z.rating(user_id,m)\n\t\t\tend\n \t \tend\n \t \t\n \t \tif similar_rating == 0 \n \t \t\tputs \"no matches\"\n \t \t\treturn ans1\n \t \telse\n \t \t\treturn (similar_rating+ans1)/2\n \t \tend\n end", "def predict_rating(u, m)\n\t\t\tif past_rating(u, m) != 0\n\t\t\t\treturn past_rating(u,m)\n\t\t\tend\n\t\t\tsim_users = most_similar(u)\n\t\t\trating = 0\n\t\t\tdivisor = 0\n\t\t\tsim_users.each do |user|\n\t\t\t\ttheir_rating = past_rating(user, m)\n\t\t\t\tif (their_rating != 0)\n\t\t\t\t\trating += their_rating\n\t\t\t\t\tdivisor += 1\n\t\t\t\tend\n\t\t\tend\n\t\t\tif divisor == 0\n\t\t\t\treturn 4\n\t\t\tend\n\t\t\treturn rating/divisor\n\t\tend", "def calculate\n\t\taverage_rank\n\t\tfound_percent\n\tend", "def overall_weighted_rating\n @ratings.group_by(&:evaluation_criteria_id).sum do |criteria_group|\n criteria = EvaluationCriteriaRepository.new.find(criteria_group[0])\n calc = Calculator.new(ratings_for(criteria_group), criteria)\n calc.weighted_avg_all_users\n end\n end", "def predict(user, movie)\n popularity = popularity(movie)\n if popularity\n return (@users[user][:average] + popularity) / 2\n end\n 3\n end", "def predict(u,m)\n rating = 0\n count = 0\n most_similar = -1\n\n #the rating from the user who has rated m and is most similar to user u is\n #our prediction\n\n #to avoid we repeat computing similarity between two users, we use similarity_list to\n #contain similarity between users.\n if !@similarity_list.has_key?(u)\n @similarity_list[u] = Hash.new\n end\n\n viewers(m).each do |viewer|\n similarity = 0\n #if this similarity is already in the similarity_list, we directly access it from the list\n if @similarity_list[u].has_key?(viewer)\n similarity = @similarity_list[u][viewer]\n elsif @similarity_list.has_key?(viewer) && @similarity_list[viewer].has_key?(u)\n similarity = @similarity_list[viewer][u]\n else\n #if this similarity is not in the list, we compute it and put it into the list\n similarity = similarity(u, viewer)\n @similarity_list[u][viewer] = similarity\n end\n\n #then we look for the user who is most similar to user u. If there exists more than one,\n #we average the sum of ratings.\n if similarity > most_similar\n most_similar = similarity\n count = 1\n rating = @moviemap[m][viewer]\n elsif similarity == most_similar\n count = count + 1\n rating += @moviemap[m][viewer]\n end\n end\n\n if count == 0\n #if no one ever rates this movie, predict an average rating 3\n 3\n else\n rating/count.to_f\n end\n end", "def top_matches(preferences, person, limit = 5)\n scores = preferences.map {|pref| [sim_pearson(preferences, person, pref[0]), pref[0]] unless pref[0] == person}.compact\n scores.sort! {|a,b| b[0] <=> a[0]}\n return scores[0...limit]\nend", "def predict u, m\n #for each movie mw watched my u, determine mw's prediction for r\n predictions = movies(u).map do |mw|\n #rw = u's rating of movie mw\n rw = rating(u, mw)\n #for all users ux that have given mw the same rating as u, record ux's rating for m\n r_given_rw = Array.new(0)\n @mv_rating[mw].each do |ux, rwx|\n rx = rating ux, m\n #record ux's rating for m if agree with u on rating for mw\n r_given_rw.push(rx) if rx && rwx == rw\n end\n\n #mw's prediction for r(m) is average of all user's rating of m that have agreed with u on mw\n return r_given_rw.mean.round unless r_given_rw.empty?\n end\n\n #default to 3 because neutral rating\n return predictions.median_ish || 3\n end", "def similarity(user1, user2)\n if @userdata.has_key? user1.to_s.to_sym and @userdata.has_key? user2.to_s.to_sym\n\n sim_rating = 0\n user1ratings = @userdata[user1.to_s.to_sym]\n user2ratings = @userdata[user2.to_s.to_sym]\n user2ids = []\n user2ratings.each{ |id, rating| user2ids.push id }\n user1ratings.each{ |id, rating| sim_rating += 5 - (rating - user2ratings[user2ids.index id][1]).abs if user2ids.include? id}\n return sim_rating\n else\n puts \"User not found\"\n return nil\n end\n end", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def recommend_for_user(user,opts={})\n o = slope_one_options\n q = %Q{\n SELECT a.*\n FROM #{o[:resource_table]} a, (#{frequency_matrix}) f\n JOIN #{o[:rating_table]} r1 ON r1.#{o[:resource_key]} = f.target_id\n LEFT JOIN #{o[:rating_table]} r2 ON r2.#{o[:resource_key]} = f.source_id AND r2.#{o[:rater_key]} = r1.#{o[:rater_key]}\n WHERE r1.#{o[:rater_key]} = ?\n AND f.frequency > 0 \n AND a.id = f.source_id\n #{\"AND r2.#{o[:resource_key]} IS NULL\" if opts[:exclusive]}\n GROUP BY f.source_id, a.id\n ORDER BY ( SUM(f.difference + f.frequency * r1.#{o[:rating_property]}) / SUM(f.frequency) ) DESC LIMIT ?;\n }\n find_by_sql [q, user.id, opts[:limit] || 20]\n end", "def calculate_team_ratings(roster)\n ratings = Array.new\n roster.each do|player|\n if (player && player.profile && player.profile.rating)\n ratings.push(player.profile.rating.total)\n end\n end\n \n top_ratings = ratings.sort.reverse.take(10)\n top_ratings.sum\n end", "def spearman(v1,v2)\n v1a,v2a = Statsample.only_valid_clone(v1,v2)\n v1r,v2r = v1a.ranked, v2a.ranked\n pearson(v1r,v2r)\n end", "def best_matches(n,user)\n best = []\n connections = []\n\n self.similar_answers.each do |sa|\n best << Answer.find(sa)\n end\n\n best.sort_by! do |element|\n element.connections.where(target_answer_id:self.id).first.weight\n end\n\n best.reverse!\n\n if user.student? && (not user.admin?)\n best[0..n-1].keep_if { |a| a.user_id == user.id }\n else\n best[0..n-1]\n end\n\n end", "def similarity(user1, user2)\n\t\tif @userdata.has_key? user1.to_s.to_sym and @userdata.has_key? user2.to_s.to_sym\n\n\t\t\tsim_rating = 0\n\t\t\tuser1ratings = @userdata[user1.to_s.to_sym]\n\t\t\tuser2ratings = @userdata[user2.to_s.to_sym]\n\t\t\tuser2ids = []\n\t\t\tuser2ratings.each{ |id, rating| user2ids.push id }\n\t\t\tuser1ratings.each{ |id, rating| sim_rating += 5 - (rating - user2ratings[user2ids.index id][1]).abs if user2ids.include? id}\n\t\t\t\t\treturn sim_rating\n\t\telse\n\t\t\tputs \"User not found\"\n\t\t\treturn nil\n\t\tend\n\tend", "def mean()\n diff = @list.collect {|item| item[:prediction] - item[:rating]}\n sum(diff) / diff.length\n end", "def user_average_rating(user)\n #av = promedio (avarage), counter = contador(para calcular el total de reviews realizada)\n av, counter = 0.0, 0.0\n \n Review.where(user_id: user.id).each_with_index do |review, i|\n if review.rating\n av = av + review.rating\n counter = counter + 1.0\n end\n end\n\n av / counter\n end", "def recommend_a_place\n # 1- Find the person we are giving the recommendation to (determined by the user_id)\n # 2- Calculate the total VALUE that each place has for that given user (algorithm)\n # 3- Sort by value the array of recommended places\n # 4- Return the data for the user and the array of recommended places in the specified format \n if params[:user_id]\n @person = User.find(params[:user_id])\n else \n wrong_user_id = true\n end\n \n unless wrong_user_id\n # The algorithm to calculate the total VALUE of each place returns an array of arrays, where the 1st element is the value\n # of the place which is in the 2nd element.\n array_values_places = calculate_value_of_places(@person)\n @sorted_array_values_places = array_values_places.sort_by { |e| e[0] }.reverse\n\n respond_to do |format|\n if wrong_user_id\n format.json { render :json => { :status => \"Error\", :response => {} }}\n else\n format.json { render :file => \"places/recommend_a_place.json.erb\", :content_type => 'application/json' }\n end\n end\n end \n \n end", "def similar user\n #somethig\n #somethig\n out = JSON.parse(%x|java -jar #{File.dirname(__FILE__)}/recommender.jar #{FILE_IN}|)\n\n u = Matrix[*out[1]]\n s = Matrix[*out[0]]\n vt = Matrix[*out[2]]\n\n #pp u.column(0)\n u_collapsed = Matrix.columns([u.column(0),u.column(1)]) # Items\n s_collapsed = Matrix.columns([s.column(0),s.column(1)])\n vt_collapsed = Matrix.columns([vt.column(0),vt.column(1)]) # Users\n\n pp u_collapsed\n pp s_collapsed\n pp vt_collapsed\n\n #user.transpose * Matrix[u.column(0), u.column(1)]\n #p (s * Matrix[s.column(0), s.column(1)])\n\nend", "def k_nearest_neighbours(k)\n other_users = User.where.not(id: id)\n users_with_similarity = []\n\n other_users.each do |other_user|\n user_similarity = Calculations.pearson_correlation(ratings_vector, other_user.ratings_vector)\n users_with_similarity.push(other_user[:id] => user_similarity)\n end\n\n users_with_similarity.to_a.sort_by! { |user_with_similarity| -user_with_similarity.values.first }[0, k]\n end", "def calculate_fairness\n strengths = @teams.map(&:strength)\n scores = @scores.values\n\n FairnessCheck.pearson_product_moment_correlation_coefficient strengths, scores\n end", "def mean()\n\t\taverage = 0.0\n\t\[email protected] do |row|\n\t\t\taverage += (row[\"rating\"].to_f - row[\"predicted\"]).abs\n\t\tend\n\n\t\treturn average/results.length\n\tend", "def similarity(user_a, user_b)\n av_a, av_b = user_average_rating(user_a), user_average_rating(user_b)\n sum_both, sum_a, sum_b = 0, 0, 0\n\n rating_a = Review.where(user_id: user_a.id)\n\n rating_a.each do |rating_a|\n if rating_b = Review.where(user_id: user_b.id, item_id: rating_a.item_id).first\n sum_a = sum_a + ( (rating_a.rating - av_a)**2 )\n sum_b = sum_b + ( (rating_b.rating - av_b)**2 )\n sum_both = sum_both + ( (rating_a.rating - av_a) * (rating_b.rating - av_b) )\n end\n end\n\n sum_both / ( (Math.sqrt(sum_a)) * (Math.sqrt(sum_b)) )\n end", "def predict(predictive_users, movie_id, user_id)\n score = 0.0\n total = 0.0\n tally = 0.0\n predictive_users.each do |user|\n score = rating(user, movie_id).to_i #Takes the average score of users in the predictive \n #array and sets that to the prediction. \n if score != 0\n total += score\n tally += 1\n end\n end\n \n base_prediction = (total / tally).to_f\n prediction = prediction_modifiers(base_prediction, movie_id, user_id)\n return prediction\n end", "def similarity(user1, user2)\n\n user1 = user1.to_s\n user2 = user2.to_s\n \n weight_num = 0.20\n weight_movies = 0.40\n weight_rating = 0.40\n \n user1_num_movies = @user_database[user1].length\n user2_num_movies = @user_database[user2].length\n score_num_movies = ((user1_num_movies + user2_num_movies).to_f / ([user1_num_movies, user2_num_movies].max * 2)) * 100.0 \n \n #hash consists of movieID(string) => rating(float)\n user1_hash = {}\n user2_hash = {} \n @user_database[user1].each do |movieID, rating, time|\n user1_hash[movieID] = rating.to_f\n end\n @user_database[user2].each do |movieID, rating, time|\n user2_hash[movieID] = rating.to_f\n end \n common_movies = user1_hash.keys & user2_hash.keys\n num_common_movies = common_movies.length\n score_common_movies = (num_common_movies / [user1_hash.keys.length, user2_hash.keys.length].max ) * 100.0\n \n rating_difference = 0\n common_movies.each do |movieID|\n rating_difference += (user1_hash[movieID] - user2_hash[movieID]).abs\n end\n \n #in case of num_common_movies being 0, then penalize the rating score by 100\n if num_common_movies == 0\n avg_rating_diff = 100 \n else\n avg_rating_diff = rating_difference / num_common_movies.to_f\n end\n \n score_rating = 100 - avg_rating_diff\n \n similarity_score = (weight_num * score_num_movies + weight_movies * score_common_movies + weight_rating * score_rating)\n \n return similarity_score\n \n end", "def most_similar(u)\n\t\tif (!@sim_set[u].nil?)\n\t\t\treturn @sim_set[u]\n\t\tend\n\t\tcommon_list = Array.new\n\t\t@user_set.keys.each do |user|\n\t\t\tcommon_list.push([similarity(u, user.to_i), user]) if (u != user && similarity(u, user.to_i) > 0)\n\t\tend\n\t\ttop_ratings = common_list.to_h.keys.sort.last(5)\n\t\tsim_users = Array.new\n\t\ttop_ratings.each do |key| sim_users.push(common_list.to_h[key]) end\n\t\tgenerate_relative_similarities(u, sim_users)\n\t\t\treturn sim_users\n\t\tend", "def predict (user1, movie)\n\t\tuser1= user1.to_s\n\t\tmovie = movie.to_s\n list_of_users = most_similar(user1)\n counter=0.0\n weighted_sum=0.0\n list_of_users.each do |sim, user| #go through each user, sim = similarity level \n user_rating = rating(user,movie) \n next if (user_rating == 0 || sim.to_i==0)\n weighted_sum = (5.0/sim.to_f) * user_rating + weighted_sum #take weighted average\n counter = (5.0/sim.to_f) + counter\n end\n begin\n num = (weighted_sum/counter).round\n return num\n rescue FloatDomainError\n end\n end", "def similar_raters(options = {})\n defaults = { :count => 10 }\n options = defaults.merge(options)\n \n rater_ids = Recommendable.redis.zrevrange(similarity_set, 0, options[:count] - 1).map(&:to_i)\n raters = Recommendable.user_class.where(\"ID IN (?)\", rater_ids)\n \n # The query loses the ordering, so...\n return raters.sort do |x, y|\n rater_ids.index(x.id) <=> rater_ids.index(y.id)\n end\n end", "def cal_mean\n sum = @data.inject(0) do |accu, hash|\n accu + hash[:prediction] - hash[:rating]\n end\n sum.to_f / @data.size\n end", "def all_ratings_calculated_ratio\n\t\tif number_of_ratings > 0\n\t\t\tratio = mean_calculated_ratio\n\t\telse\n\t\t\tratio = chapter.mean_calculated_ratio\n\t\tend\n\t\treturn ratio\n\tend", "def predict_for(user_id, klass, item_id)\n user_id = user_id.to_s\n item_id = item_id.to_s\n\n liked_by_set = Recommendations::Helpers::RedisKeyMapper.liked_by_set_for(klass, item_id)\n similarity_sum = 0.0\n\n # Get sum of similarities of each item in set\n similarity_sum = similarity_total_for(user_id, liked_by_set)\n\n liked_by_count = Recommendations.redis.pipelined do\n Recommendations.redis.scard(liked_by_set)\n end\n prediction = similarity_sum / (liked_count).to_f\n prediction.finite ? prediction : 0.0\n end", "def similarity (u1, u2)\r\n\t\t# make sure data is loaded first\r\n\t\tif @user_ratings.nil?\r\n\t\t\tputs \"data has not been loaded\"\r\n\t\t\treturn 0\r\n\t\telse\r\n\t\t\t# make sure users exist before calculating similarity\r\n\t\t\tif check(u1, u2)==1\r\n\t\t\t\tu1_rate_hash = @user_ratings[u1]\r\n\t\t\t\tu2_rate_hash = @user_ratings[u2]\r\n\t\t\t\t# merge the two hashes since that produces a set \r\n\t\t\t\t# then can get the length to get # of unique movies the two users have rated (in case users have not ranked all the same movies)\r\n\t\t\t\tnum_total_movies = u1_rate_hash.merge(u2_rate_hash).keys.length\r\n\t\t\t\t# make combination of all movies that both users ahve seen\r\n\t\t\t\tboth_seen = u1_rate_hash.keys & u2_rate_hash.keys\r\n\t\t\t\tsum = 0\r\n\t\t\t\t# loops throught the movies both users have seen and takes the difference between the ratings\r\n\t\t\t\t# this is subtracted from 4 (the max difference) to give an inverse on the difference if they have the same rating then 4 is added to the sum\r\n\t\t\t\tboth_seen.each do |id|\r\n\t\t\t\t\tsum +=4 - (u1_rate_hash[id] - u2_rate_hash[id]).abs\r\n\t\t\t\tend\r\n\t\t\t\t# the formula for similarity\r\n\t\t\t\t# the # movies both have seen /the number of unique movies both have seen\r\n\t\t\t\t# this gives a percentage of similarity between the movies both users have rated\r\n\t\t\t\t# ensures similarity in preference of movies not just ratings\r\n\t\t\t\t# those who have more similar taste in movies ranked will have thier percentage of similarity affected less as it will be close to 1\r\n\t\t\t\t# where those who have disparate tastes in music will be closer to 0 reducing the total score and reflecting their difference in tastes\r\n\t\t\t\t# the sum is divided by 0 to normalize it(if all ranks are the same the sum comes to 4*number of movies both seen \r\n\t\t\t\t# and needs to be removed to get a # below #movies both seen)\r\n\t\t\t\t# divide by total number of movies seen to get a percentage of similarity of ranks\r\n\t\t\t\t# +0.0 TO TURN INTO DECIMALS *100 TO GET THE PERCENT\r\n\t\t\t\tn =((0.0+both_seen.length)/(num_total_movies))*(((0.0+sum)/4)/both_seen.length)*100\r\n\t\t\t\tif n.nan?\r\n\t\t\t\t\tn = 0.0\r\n\t\t\t\tend\r\n\t\t\t\treturn n\r\n\t\t\telse\r\n\t\t\t\treturn 0\r\n\t\t\tend\r\n\t\tend\r\n\tend", "def most_similar(u)\n sim_list=Array.new\n #for each user in the data we calculate the similarity of it with the user \"u\"\n #and create a list of similarity\n @users.each_key do |user|\n if user!=u\n sim_list.push([user,similarity(u,user)])\n end\n end\n #sorts the similarity list in decreasing order and returns the top 100\n sim_list.sort_by!{|itm| -itm[1]}\n return sim_list\n end", "def recommend\n recs = []\n User.all.each do |user|\n if user.hotspots.include?(self)\n user.hotspots.each do |hs|\n recs << hs\n end#user.hotspots end\n end#if include? end\n return recs.uniq\n end#users.each end\n end", "def similarity(user1,user2)\n #retrieves the recorded related to user1 and user2\n #then create an array which contains the movie ids which both user have rated them\n u1=@users[user1]\n u2=@users[user2]\n u1_movies=u1.collect{|itm| itm[1]}\n u2_movies=u2.collect{|itm| itm[1]}\n common_movies=u1_movies & u2_movies\n \n if common_movies.empty?\n return 0\n end\n \n #Similarity is defined as the average of (4 - distance between rating of user 1 and 2) for movie id\n #which both usres have rated\n similarity=0.0\n common_movies.each do |movie|\n rating1=u1.rassoc(movie)[2]\n rating2=u2.rassoc(movie)[2]\n similarity+=4-(rating1-rating2).abs\n end\n return similarity/common_movies.size\n end", "def average_score\n responses = Response.all\n sum = 0\n count = 0\n\n responses.each do |response|\n r_summary = response.summarize\n if r_summary[self.name][:nrm]\n sum += r_summary[self.name][:nrm]\n count += 1\n end\n end\n\n return (sum/count).round\n end", "def similarity(user1, user2) \n\t\tsimil = 0;\n\t\tuser1_movie_list = reviews_hash[user1.to_i].transpose\n\t\tuser2_movie_list = reviews_hash[user2.to_i].transpose\n\t\tmovie_in_common = user1_movie_list[0] & user2_movie_list[0]\n\t\tmovie_in_common.each do |x|\n\t\t\t#find index of the common movie/ratings\n\t\t\tindex1 = user1_movie_list[0].index(x)\n\t\t\tindex2 = user2_movie_list[0].index(x)\n\t\t\tsimil1 = user1_movie_list[1][index1]\n\t\t\tsimil2 = user2_movie_list[1][index2]\n\t\t\tsimil += (5-(simil1.to_i - simil2.to_i).abs)/5.0\n\t\tend\n\t\tbegin \n\t\t\treturn (simil * 1.0/movie_in_common.size)\n\t\trescue\n\t\t\treturn 0.0\n\t\tend\n\tend", "def predict(u, m)\n if @testSet != nil\n aveUserRating = @testSet.average(@testSet.allUsersHash[\"#{u}\"].values) #returns the average rating u gave all movies\n popularity = @testSet.popularity(m)\n popularity + aveUserRating*0.01\n end\n end", "def predict(u_id,m_id)\n #puts \"u:#{u_id},m#{m_id}\"\n sim=most_similar(u_id,m_id).map { |item| [data.rating(item[0],m_id),item[1]] }\n result=@aggregation_func.call(data,u_id,sim)\n result.finite? ? result : data.avg_rating(u_id)\n end", "def predict(m, viewer_list)\n return 3 if viewer_list.size == 0\n prediction, similarity_tally = 0, 0\n viewer_list.each do |viewer|\n sim = similarity(viewer)\n similarity_tally += sim\n prediction += sim * viewer.rating_list[m].rating\n end\n return prediction/similarity_tally.to_f unless similarity_tally == 0\n return 3\n end", "def recommendations\n check_preference_setup \n check_last_played_time\n add_personality_recommendations\n\n @recommendations\n end", "def avg_rating(user_id)\n @user_index[user_id].col(:rating).mean\n end", "def predict(user, movie)\n list = most_similar(user) #array of similar users\n done = true\n user_predicted_rating = 0;\n\n #see which user has seen the movie\n while done && !list.empty?\n first_user = list.shift #user similar to u\n\n if $unique_user_data[first_user.to_i - 1].has_key?(movie)\n user_predicted_rating = $unique_user_data[first_user.to_i - 1][movie]\n return user_predicted_rating\n end\n end\n return user_predicted_rating\n end", "def update_score\n sum = 0.0\n total = 0.0\n ratings.each do |rating|\n vp = User.find(rating.user_id).voting_power \n sum = sum + rating.score * vp\n total = total + vp\n end\n average = sum / total\n variance = ratings.inject(0.0){ |sum, element| sum + \n (element.score - average) ** 2 }\n penalty = Math.log10((variance / ratings.size) + 1) + 1.0;\n update_attribute(:score, average / penalty)\n end", "def predict (u, m)\n\t\tusers = most_similar(u)\n\n\t\tusers.each do |el|\n\t\t\tif @train_data[el[0]].return_rating(m)\n\t\t\t\tif el[1] >= 0 \n\t\t\t\t\treturn @train_data[el[0]].return_rating(m)\n\t\t\t\telse return 6-@train_data[el[0]].return_rating(m)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def rates_by\n likes.map(&:user_id) + dislikes.map(&:user_id)\n end", "def rates_by\n likes.map(&:user_id) + dislikes.map(&:user_id)\n end", "def average_rating(driver)\n sum = 0.0\n \n driver.each do |find_rating|\n driver_rating = find_rating[:rating]\n sum += driver_rating\n end\n\n average = sum / driver.length\n\n return average\nend", "def rating_for(active_user, item)\n return unless @similarity_matrix\n \n weighted_similar_items = similarity_sum = 0\n\n sim_objs = @similarity_matrix[item.id]\n sim_objs.each do |obj|\n active_user_rating = active_user.rating_for obj[:id]\n next unless active_user_rating\n weighted_similar_items += active_user_rating * obj[:similarity].abs\n similarity_sum += obj[:similarity].abs\n end\n \n return nil if weighted_similar_items == 0 or similarity_sum == 0\n \n rating = weighted_similar_items / similarity_sum\n rating = 5 if rating > 5\n rating = 1 if rating < 1\n rating\n end", "def predict(u,m,k=25) \n\t\tt1=Time.now\n\t\t@predict_call_count+=1\n\t\tcandidate_list=[]\n\t\tif viewers(m).empty?\n\t\t\treturn rand(5) #if a movie has no viewer then return a random score\n\t\tend\n\t\tviewers(m).each do |viewer|\n\t\t\tsimilarity_score=similarity(viewer,u)\n\t\t\tfind_and_replace(candidate_list,viewer,similarity_score,k)\n\t\tend\n\t\tresult=0\n\t\tcandidate_list.each do |element|\n\t\t\tresult+=rating(element.user,m)\n\t\tend\n\t\tt2=Time.now\n\t\t@timmer+=t2-t1\n\t\treturn result/Float(candidate_list.length)\n\tend", "def similarity_with(rater)\n rater.create_recommended_to_sets\n agreements = common_likes_with(rater, :return_records => false).size\n agreements += common_dislikes_with(rater, :return_records => false).size\n disagreements = disagreements_with(rater, :return_records => false).size\n \n similarity = (agreements - disagreements).to_f / (likes.count + dislikes.count)\n rater.destroy_recommended_to_sets\n \n return similarity\n end", "def similarities u1\n sims = Hash.new()\n (@usr_rating.keys - [u1]).each do |u2|\n sims.store(u2, similarity(u1, u2))\n end\n return sims\n end", "def recommendations_for(obj)\n recommend_by_item_based obj\n end", "def users_pattern_rating(base_prediction, modified_prediction, movie_id, user_id)\n user_rating_avg = 0.0 \n movies = @user_hash[user_id]\n movies.each do |hash|\n user_rating_avg += hash[hash.keys[0]].to_i\n end\n user_rating_avg = user_rating_avg / @user_hash[user_id].length\n if base_prediction > user_rating_avg\n modified_prediction -= 0.5 *(base_prediction - user_rating_avg).abs \n elsif base_prediction < user_rating_avg\n modified_prediction += 0.5 * (base_prediction - user_rating_avg).abs\n end\n return modified_prediction\n end", "def similarity(user1, user2) \n\t\tsimil = 0;\n\t\tuser1_movie_list = reviews_hash[user1.to_i].transpose\n\t\tuser2_movie_list = reviews_hash[user2.to_i].transpose\n\t\tmovie_in_common = user1_movie_list[0] & user2_movie_list[0]\n\t\tmovie_in_common.each do |x|\n\t\t\t#find index of the common movie/ratings\n\t\t\tindex1 = user1_movie_list[0].index(x)\n\t\t\tindex2 = user2_movie_list[0].index(x)\n\t\t\tsimil1 = user1_movie_list[1][index1]\n\t\t\tsimil2 = user2_movie_list[1][index2]\n\t\t\tsimil += 1.0/((simil1.to_i - simil2.to_i).abs + 1) # 1/(rating difference + 1)\n\t\tend\n\t\treturn simil.round(2)\n\tend", "def update_recommendations_for(user_id)\n user_id = user_id.to_s\n\n nearest_neighbors = Recommendable.config.nearest_neighbors || Recommendable.config.user_class.count\n Recommendable.config.ratable_classes.each do |klass|\n rated_sets = [\n Recommendable::Helpers::RedisKeyMapper.gemd_set_for(klass, user_id),\n Recommendable::Helpers::RedisKeyMapper.disgemd_set_for(klass, user_id),\n Recommendable::Helpers::RedisKeyMapper.hidden_set_for(klass, user_id),\n Recommendable::Helpers::RedisKeyMapper.bookmarked_set_for(klass, user_id)\n ]\n temp_set = Recommendable::Helpers::RedisKeyMapper.temp_set_for(Recommendable.config.user_class, user_id)\n similarity_set = Recommendable::Helpers::RedisKeyMapper.similarity_set_for(user_id)\n recommended_set = Recommendable::Helpers::RedisKeyMapper.recommended_set_for(klass, user_id)\n most_similar_user_ids = Recommendable.redis.zrevrange(similarity_set, 0, nearest_neighbors - 1)\n least_similar_user_ids = Recommendable.redis.zrange(similarity_set, 0, nearest_neighbors - 1)\n\n # Get gems from the most similar users\n sets_to_union = most_similar_user_ids.inject([]) do |sets, id|\n sets << Recommendable::Helpers::RedisKeyMapper.gemd_set_for(klass, id)\n end\n\n # Get disgems from the least similar users\n least_similar_user_ids.inject(sets_to_union) do |sets, id|\n sets << Recommendable::Helpers::RedisKeyMapper.disgemd_set_for(klass, id)\n end\n\n return if sets_to_union.empty?\n\n # SDIFF rated items so they aren't recommended\n Recommendable.redis.sunionstore(temp_set, *sets_to_union)\n item_ids = Recommendable.redis.sdiff(temp_set, *rated_sets)\n scores = item_ids.map { |id| [predict_for(user_id, klass, id), id] }\n scores.each do |s|\n Recommendable.redis.zadd(recommended_set, s[0], s[1])\n end\n\n Recommendable.redis.del(temp_set)\n\n if number_recommendations = Recommendable.config.recommendations_to_store\n length = Recommendable.redis.zcard(recommended_set)\n Recommendable.redis.zremrangebyrank(recommended_set, 0, length - number_recommendations - 1)\n end\n end\n\n true\n end", "def compute_score\n @query.items.map.with_index do |element, index|\n weight(index) * weight(@classification.items.index(element))\n end.sum\n end", "def similarity (user1, user2)\n\t\tuser1= user1.to_s\n\t\tuser2 = user2.to_s\n\t\tuser1_index = @user_rating_index[user1]\n\t\tuser2_index = @user_rating_index[user2]\n\t\ttotal_diff = 0\n\t\tcounter=0\n\n\t\tuser1_index.each_key do |movie|\n\t\t\tif user2_index.has_key? (movie) \n\t\t\t\tdiff = (user1_index[movie].to_i - user2_index[movie].to_i).abs #abs value difference to be summed then divided by total\n\t\t\t\ttotal_diff += diff\n\t\t\t\tcounter+=1\n\t\t\tend\n\t\tend\n\t\tif counter == 0\n\t\t\treturn 5.0\n\t\tend\n\t\treturn (total_diff.to_f/counter) \n\tend", "def closest_user\n users = User.includes(ratings: :movie)\n\n result = [users.first.id, pearson_correlation(users.first)]\n\n users.each do |user|\n next if user.id == self.id\n current_pearson_correlation = pearson_correlation(user)\n\n if (1 - current_pearson_correlation).abs < (1 - result.last).abs\n result = [user, current_pearson_correlation]\n end\n end\n result[1] == 0 ? nil : result[0]\n end", "def predict_for(user_id, klass, item_id)\n user_id = user_id.to_s\n item_id = item_id.to_s\n\n Recommendable.set_shard_key user_id\n liked_by_set = Recommendable::Helpers::RedisKeyMapper.liked_by_set_for(klass, item_id)\n disliked_by_set = Recommendable::Helpers::RedisKeyMapper.disliked_by_set_for(klass, item_id)\n similarity_set = Recommendable::Helpers::RedisKeyMapper.similarity_set_for(user_id)\n similarity_sum = 0.0\n\n similarity_sum += Recommendable.redis.eval(similarity_total_for_lua, keys: [liked_by_set, similarity_set]).to_f\n similarity_sum -= Recommendable.redis.eval(similarity_total_for_lua, keys: [disliked_by_set, similarity_set]).to_f\n\n liked_by_count, disliked_by_count = Recommendable.redis.pipelined do\n Recommendable.redis.scard(liked_by_set)\n Recommendable.redis.scard(disliked_by_set)\n end\n prediction = similarity_sum / (liked_by_count + disliked_by_count).to_f\n prediction.finite? ? prediction : 0.0\n end", "def rating_calculation\n ratings_collection = Rating.where(user_id: self.id)\n average = -1\n if !ratings_collection.empty?\n sum = 0\n ratings_collection.each do |r|\n sum += r.rating\n end\n average = (sum.to_f / ratings_collection.count).round\n end\n average\n end", "def mean_calc\n error = 0\n @predictions.each do |p|\n puts \"User: #{p.user} Movie: #{p.movie}\" if p.error.to_f.nan?\n error += p.error\n end\n return error/@predictions.size.to_f\n end", "def update_similarities_for_(user_id)\n user_id = user_id.to_s # For comparison. Redis returns all set members as strings.\n similarity_set = Recommendable::Helpers::RedisKeyMapper.similarity_set_for(user_id)\n\n Recommendable.set_shard_key user_id\n\n # Only calculate similarities for users who have rated the items that\n # this user has rated\n relevant_user_ids = Recommendable.config.ratable_classes.inject([]) do |memo, klass|\n liked_set = Recommendable::Helpers::RedisKeyMapper.liked_set_for(klass, user_id)\n disliked_set = Recommendable::Helpers::RedisKeyMapper.disliked_set_for(klass, user_id)\n\n item_ids = Recommendable.redis.sunion(liked_set, disliked_set)\n\n unless item_ids.empty?\n sets = item_ids.map do |id|\n liked_by_set = Recommendable::Helpers::RedisKeyMapper.liked_by_set_for(klass, id)\n disliked_by_set = Recommendable::Helpers::RedisKeyMapper.disliked_by_set_for(klass, id)\n\n [liked_by_set, disliked_by_set]\n end\n\n memo | Recommendable.redis.sunion(*sets.flatten)\n else\n memo\n end\n end\n\n similarity_values = relevant_user_ids.map { |id| similarity_between_(user_id, id) }\n Recommendable.redis.pipelined do\n relevant_user_ids.zip(similarity_values).each do |id, similarity_value|\n next if id == user_id # Skip comparing with self.\n Recommendable.redis.zadd(similarity_set, similarity_value, id)\n end\n end\n\n if knn = Recommendable.config.nearest_neighbors\n length = Recommendable.redis.zcard(similarity_set)\n kfn = Recommendable.config.furthest_neighbors || 0\n\n Recommendable.redis.zremrangebyrank(similarity_set, kfn, length - knn - 1)\n end\n\n true\n end", "def predict(user_id, movie_id)\n prediction = 0\n most_similar_users = @the_data.most_similar(user_id)\n #find first user who has rated movie_id\n most_similar_users.each do |u, ranking|\n #we want the first user in most_similar_users who rated movie_id\n if @the_data.users[u].ratings[movie_id] != nil\n prediction = @the_data.users[u].ratings[movie_id]\n break\n end\n end\n return prediction\n end", "def get_average_feedback_ratings\n recv_feedbacks = Feedback.where(target_team_id: self.id)\n ratings = []\n recv_feedbacks.each do |feedback|\n response = feedback.get_response_for_question(1).nil? ? 0 : feedback.get_response_for_question(1).to_i\n ratings.append(response)\n end\n {:all => get_average_for_ratings(ratings)}\n end", "def similarity(other_user)\n similarity_count = 0\n @rating_list.each_value do |rating|\n if other_rating = other_user.rating_list[rating.movie_id] and \\\n other_rating.rating.to_i >= rating.rating.to_i - 1 and \\\n other_rating.rating.to_i <= rating.rating.to_i + 1\n similarity_count += 1\n end\n end\n return similarity_count\n end", "def similarity(other_user)\n similarity_count = 0\n @rating_list.each_value do |rating|\n if other_rating = other_user.rating_list[rating.movie_id] and other_rating.rating.to_i >= rating.rating.to_i - 1 and other_rating.rating.to_i <= rating.rating.to_i + 1\n similarity_count += 1\n end\n end\n return similarity_count\n end", "def compute_user_rate(user)\n user_rate = Hash.new(0)\n user_movies = @data.select { |item| item[0].to_i == user }.each { |item| user_rate[item[1].to_i] = item[2].to_i }\n user_rate\n end", "def get_average_evaluation_ratings\n ratings_hash = {}\n peer_evaluations_hash = self.get_evaluations_for_own_team\n overall_ratings = []\n peer_evaluations_hash.each do |milestone_id, evaluations_hash|\n ratings = []\n evaluations_hash.each do |key, evaluation|\n if not evaluation.nil?\n private_parts = JSON.parse(evaluation.private_content)\n rating = private_parts[Milestone.find(milestone_id).get_overall_rating_question_id]\n if key.is_a? Symbol # TODO: a temporary solution for testing whether it is from adviser or not\n ratings.append(rating)\n overall_ratings.append(rating)\n end\n ratings.append(rating)\n overall_ratings.append(rating)\n end\n end\n ratings_hash[milestone_id] = get_average_for_ratings(ratings)\n end\n ratings_hash[:all] = get_average_for_ratings(overall_ratings)\n return ratings_hash\n end", "def average_fitness\n total_fitness = 0\n @all_persons.each do |person|\n total_fitness += person.get_energy_level\n end\n if @all_persons.empty?\n return 0\n else\n total_fitness / @total_people\n end\n end", "def getTheSimilarityRating\n @user_movieAndRating.each do |key, value|\n arr = value.strip.split(\"\\s\")\n i = 0\n movie_id = nil\n rating = nil\n sumOfXY = 0\n sumofYY = 0\n sumOfXX = 0\n arr.each do |element|\n if i % 2 ==0\n movie_id = element\n else\n rating = element\n sumOfXY += movie_id.to_f * rating.to_f\n sumofYY += rating.to_f * rating.to_f\n sumOfXX += movie_id.to_f * movie_id.to_f\n end\n i += 1\n\n end#end of loop arr\n # sumOfXX is all the same, ignore it.\n cos = (sumOfXY / (Math.sqrt(sumOfXX) * Math.sqrt(sumofYY))).round(1)\n\n addUserWithSimilarityrating(key, cos)#key is user_id\n end#end of loop @user_movieAndRating\n end", "def score\n track_similarity = shared_count(:tracks) / (((@user1.tracks.uniq.count + @user2.tracks.uniq.count) - shared_count(:tracks)) * 1.0)\n artist_similarity = shared_count(:artists) / (((@user1.artists.uniq.count + @user2.artists.uniq.count) - shared_count(:artists)) * 1.0)\n genre_similarity = shared_count(:genres) / (((@user1.genres.uniq.count + @user2.genres.uniq.count) - shared_count(:genres)) * 1.0)\n\n # Maximum possible raw score is seven (with yourself). Most people are between 0 and 1.\n raw = (track_similarity * 4) + (artist_similarity * 2) + (genre_similarity * 1)\n score = raw * 100\n score.round\n end", "def score\n track_similarity = shared_count(:tracks) / (((@user1.tracks.uniq.count + @user2.tracks.uniq.count) - shared_count(:tracks)) * 1.0)\n artist_similarity = shared_count(:artists) / (((@user1.artists.uniq.count + @user2.artists.uniq.count) - shared_count(:artists)) * 1.0)\n genre_similarity = shared_count(:genres) / (((@user1.genres.uniq.count + @user2.genres.uniq.count) - shared_count(:genres)) * 1.0)\n\n # Maximum possible raw score is seven (with yourself). Most people are between 0 and 1.\n raw = (track_similarity * 4) + (artist_similarity * 2) + (genre_similarity * 1)\n score = raw * 100\n score.round\n end", "def predict_all\r\n @recommendations = Professional.all.map do |professional|\r\n Recommender.new(professional).recommend\r\n end\r\n true\r\n end", "def update_recommendations_for(user_id)\n user_id = user_id.to_s\n\n Recommendable.set_shard_key user_id\n\n nearest_neighbors = (Recommendable.config.nearest_neighbors || Recommendable.config.user_class.count).to_i\n Recommendable.config.ratable_classes.each do |klass|\n rated_sets = [\n Recommendable::Helpers::RedisKeyMapper.liked_set_for(klass, user_id),\n Recommendable::Helpers::RedisKeyMapper.disliked_set_for(klass, user_id),\n Recommendable::Helpers::RedisKeyMapper.hidden_set_for(klass, user_id),\n Recommendable::Helpers::RedisKeyMapper.bookmarked_set_for(klass, user_id),\n ]\n temp_set = Recommendable::Helpers::RedisKeyMapper.temp_set_for(klass, user_id)\n similarity_set = Recommendable::Helpers::RedisKeyMapper.similarity_set_for(user_id)\n recommended_set = Recommendable::Helpers::RedisKeyMapper.recommended_set_for(klass, user_id)\n most_similar_user_ids, least_similar_user_ids = Recommendable.redis.pipelined do\n Recommendable.redis.zrevrange(similarity_set, 0, nearest_neighbors - 1)\n Recommendable.redis.zrange(similarity_set, 0, nearest_neighbors - 1)\n end\n\n # Get likes from the most similar users\n sets_to_union = most_similar_user_ids.inject([]) do |sets, id|\n sets << Recommendable::Helpers::RedisKeyMapper.liked_set_for(klass, id)\n end\n\n # Get dislikes from the least similar users\n sets_to_union = least_similar_user_ids.inject(sets_to_union) do |sets, id|\n sets << Recommendable::Helpers::RedisKeyMapper.disliked_set_for(klass, id)\n end\n\n return if sets_to_union.empty?\n\n # SDIFF rated items so they aren't recommended\n Recommendable.redis.sunionstore(temp_set, *sets_to_union)\n item_ids = Recommendable.redis.sdiff(temp_set, *rated_sets)\n\n item_ids.each do |id|\n Recommendable.redis.eval(predict_for_lua('((liked_by_count + disliked_by_count) > 0) and similarity_sum / (liked_by_count + disliked_by_count) or 0'),\n [ recommended_set ],\n [ user_id, id,\n Recommendable.config.redis_namespace,\n Recommendable.config.user_class.to_s.tableize,\n klass.to_s.tableize ])\n end\n\n Recommendable.redis.del(temp_set)\n\n if Recommendable.config.recommendations_to_store\n number_recommendations = Recommendable.config.recommendations_to_store.to_i\n length = Recommendable.redis.zcard(recommended_set).to_i\n Recommendable.redis.zremrangebyrank(recommended_set, 0, length - number_recommendations - 1) if length > number_recommendations\n end\n end\n\n true\n end" ]
[ "0.6991422", "0.69263554", "0.6664773", "0.6481484", "0.64040965", "0.62665015", "0.6218784", "0.60484815", "0.6026915", "0.60092866", "0.60069346", "0.59365696", "0.59244215", "0.59199107", "0.5895304", "0.5887364", "0.5802603", "0.5760123", "0.57487303", "0.5742281", "0.5673148", "0.5664878", "0.5653461", "0.5652702", "0.5650777", "0.5643559", "0.55949044", "0.55806386", "0.5568145", "0.5560911", "0.555013", "0.5539706", "0.55129164", "0.55049765", "0.5474978", "0.54676455", "0.5461148", "0.5459995", "0.5459234", "0.5445256", "0.5438397", "0.54343545", "0.5423619", "0.54180056", "0.5417634", "0.54139477", "0.54129076", "0.54050577", "0.54021657", "0.53998506", "0.5396376", "0.53794456", "0.5367406", "0.53650826", "0.5362337", "0.5361432", "0.5355844", "0.5354863", "0.53538555", "0.53372645", "0.53232235", "0.5321477", "0.5321166", "0.5317298", "0.53119653", "0.53093505", "0.5303637", "0.5301025", "0.52943796", "0.52901304", "0.5289664", "0.5289664", "0.5287368", "0.52819765", "0.5277774", "0.52720845", "0.5271735", "0.52713025", "0.52641153", "0.5255216", "0.5249259", "0.5240637", "0.52400506", "0.5239158", "0.5231236", "0.5226565", "0.5224484", "0.52222013", "0.522194", "0.5217102", "0.5208476", "0.5208032", "0.5196933", "0.51913893", "0.51859933", "0.517967", "0.51715827", "0.51715827", "0.5168288", "0.5167644" ]
0.7043448
0
source: This algorithm was created by Landon Kryger to solve the problem of testing if a set of dice is fair. If you have n players and s sides, the standard approach would require you to test every roll and would run in O(s^n). This algorithm runs in approximately O(snn!). For small s,n, it's not a very noticeable difference, but for large values like n=5;s=30 the benefit is huge. This algorithm also works with dice with different number of sides. The input can be either a string, e.g. state = 'abcddbaccbadcabddacbdbcadcbadcabbcaddacbbacdabcdacbdbcaddbacdabccabddcba' or an array of characters, e.g. state = ['0', '1', '1', '0'] The output, count, will contain how many ways each substring can occur.
def counts(state) counts = {'' => 1} state = state.split("") if state.kind_of?(String) state.each do |char| counts.keys.each do |key| if key.count(char) == 0 key_char = key + char counts[key_char] = (counts[key_char] || 0) + counts[key] end end end counts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def countingValleys(n, s)\n # check constraints\n # do steps match string length\n n_does_not_equal_s_length = n != s.scan(/[UD]/).count\n steps_are_invalid = n < 2 && n > 10**6\n\n returned_to_sea_level_count = 0\n sea_level = 0\n\n if (steps_are_invalid || n_does_not_equal_s_length)\n return 0\n end\n\n # s.scan(/(DU{1}U{2,}UD{1})/).count\n s.split('').each do |l|\n previous_sea_level = sea_level\n\n if l == 'U'\n sea_level += 1\n elsif l == 'D'\n sea_level -= 1\n end\n\n if sea_level == 0 && previous_sea_level < 0\n returned_to_sea_level_count += 1\n end\n end\n\n returned_to_sea_level_count\nend", "def countingValleys(n, s)\n valleys, counter, flag, prev_flag = 0, 0, \"sea level\", \"\"\n s.chars.each do |x|\n prev_flag = flag\n if x == \"U\" \n counter += 1 \n elsif x == \"D\"\n counter -= 1\n end\n flag = \"valley\" if counter < 0\n flag = \"sea level\" if counter == 0 \n if prev_flag == \"valley\" && flag == \"sea level\"\n valleys += 1\n elsif prev_flag == \"sea level\" && flag == \"valley\"\n valleys += 1\n end\n end\n valleys/2\nend", "def countingValleys(n, s)\n level = 0; valleys = 0; isDownSeaLevel = false\n for i in 0..n\n level += (s[i] == 'U' ? 1 : -1)\n isDownSeaLevel = true if level == -1\n if level == 0 && isDownSeaLevel\n valleys += 1\n isDownSeaLevel = false\n end\n end\n valleys\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", "def countingValleys(n, s)\n vcount = 0\n level = 0\n n.times do |i|\n if s[i] == \"U\"\n level +=1\n vcount +=1 if level == 0\n elsif s[i] == \"D\"\n level -=1\n end\n end\n return vcount \nend", "def howManyGames(p, d, m, s)\n n = (p-m)/d\n dp = [p]git\n i = 1\n j = 0\n n.times do \n dp << p - (d*i)\n i += 1 \n end \n\n total = dp.sum\n if s > total\n purchased_at_min = (s-total)/m\n end\n \n if s < p\n result = 0\n elsif s < total\n sum = p\n dps = [p]\n i = 1\n if s - p > d\n result = 1\n else\n dp.each do |v|\n sum += v\n dps << p - (d*i)\n i += 1\n break if sum > s\n end\n end\n result = dps.length\n \n else \n result = dp.length+purchased_at_min\n end\n result\nend", "def countingValleys(n, s)\n level = 0\n valley = 0\n s.each_char do |direction|\n if level == 0 && direction == 'D'\n valley += 1 \n end\n\n if direction == 'D'\n level -= 1\n else\n level += 1\n end\n end\n return valley\nend", "def num_decodings(s)\n\n decode = ('A'..'Z').to_a\n number_of_prev_ended_singly = 1\n\n ways_count = 1\n number_of_prev_ended_singly = 1\n\n s.chars[1..-1].each_with_index do |ch, idx|\n if s[idx - 1].to_i == 1 ||\n s[idx - 1] == 2.to_i && ch.to_i.between?(1,6)\n\n numbers_added_this_time = ways_count - number_of_prev_ended_singly\n ways_count += numbers_added_this_time\n number_of_prev_ended_singly = numbers_added_this_time\n else\n number_of_prev_ended_singly = 0\n end\n end\n\n ways_count\n\nend", "def dice_outcomes(die=1, rolls=1)\n\tresults = Hash.new(0)\n\n\t# Roll the dice rolls times and track the sums in hash\n\trolls.times do \n\t\tresults[roll_dice(die)] += 1 # Utilize existing function! Ruby will evaluate L side first\n\tend\n\n\t# Print out number each possible outcome occurred\n\t(1..(6*die)).each do |key|\n\t\tputs \"#{key}: \" + \"\\#\"*results[key]\n\tend\nend", "def repeatedString(s, n)\r\n # Write your code here\r\n numOfA = 0\r\n index = 0\r\n \r\n if s.length == 1 && s[0] == 'a'\r\n return n\r\n elsif s.length == 1 && s[0] != 'a'\r\n return 0\r\n \r\n else\r\n firstRoundUpperLimit = n < s.length ? n : s.length\r\n \r\n for i in 0 ... firstRoundUpperLimit\r\n if s[i] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n\r\n if (numOfA > 0 && n > s.length) \r\n repeatingOccurrences = (n / s.length) - 1\r\n remainingOccurrences = n % s.length\r\n\r\n\r\n\r\n numOfA = numOfA + (numOfA * repeatingOccurrences)\r\n\r\n for j in 0 ... remainingOccurrences\r\n if s[j] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n end\r\n\r\n \r\n end\r\n return numOfA\r\nend", "def num_repeats(string)\n tallies = {}\n\n (0..string.length - 1).each do |idx|\n letter = string[idx]\n tallies[letter] ||= 0\n tallies[letter] += 1\n end\n\n count_tallies_greater_than_two(tallies)\nend", "def countingValleys(n, s)\n level = valleys = 0\n s.each_char do |step|\n valleys +=1 if level==0 && step =='D'\n level = step == 'D' ? level-1 : level+1\n end\n valleys\nend", "def countingValleys(n, s)\n valleysNum = 0\n level = 0\n s.each_char do | step |\n step == \"D\" ? level -= 1 : level += 1\n valleysNum += 1 if (level == 0 && step == \"U\")\n end\n p valleysNum\nend", "def countingValleys(_n, s)\n val = 0\n valley = [false]\n s.split('').map do |c|\n c == 'U' ? 1 : -1\n end.each do |v|\n val += v\n if val.negative? && valley.last == false\n valley << 1\n valley << true\n elsif val.negative? && valley.last == true\n valley << true\n else\n valley << false\n end\n end\n valley\n .reject! { |x| x == false }\n .reject! { |x| x == true }\n p valley.empty? ? 0 : valley.inject(0) { |sum, x| sum + x }\nend", "def dice_outcomes(dice, rolls)\n outcomes = []\n rolls.times do |roll|\n outcomes << roll_dice(dice)\n end\n occurences = outcomes.each_with_object(Hash.new(0)) do |outcome, count|\n count[outcome] += 1\n end\n occurences.sort.map do |key, val|\n outcome = \"\"\n val.times do\n outcome << '#'\n end\n $stdout.puts \"#{key}: #{outcome}\"\n end\nend", "def sherlock(str)\n str_len = str.length\n str_arr = str.split('')\n substrings_count = {}\n result = 0\n str_arr.each_with_index do |alpha, index|\n n = str_len - index\n n.times do |pos|\n ss = str_arr[index..(index+pos)].sort.join('')\n substrings_count[ss] = substrings_count[ss] ? substrings_count[ss]+1 : 1\n end\n end\n\n substrings_count.each do |key, val|\n result = result + ((val*(val-1))/2) if val > 1\n end\n result\nend", "def countingValleys(n, s)\n valleys = 0\n pre = 0\n ac = 0\n for i in 0..n\n pre = ac\n ac += val(s[i]) \n valleys +=1 if pre == -1 && ac == 0\n end\n return valleys\nend", "def score( dice )\n res = 0\n val = { \"111\" => 1000, \"666\" => 600, \"555\" => 500, \"444\" => 400,\n \"333\" => 300, \"222\" => 200, \"1\" => 100, \"5\" => 50 }\n\n [*1..6].each do |num|\n next if dice.count(num).nil?\n many = dice.count(num)\n if many >= 3\n res += val[num.to_s * 3]\n many -= 3\n end\n if num == 1 || num == 5\n until many < 1\n res += val[num.to_s]\n many -= 1\n end\n end\n end\n \n res\nend", "def solve(str)\n idx = 0\n count = 0\n\n substr_1 = ''\n substr_2 = ''\n\n loop do\n substr_1 = str[0..idx]\n substr_2 = str[(idx + 1)..-1]\n\n substr_1.to_i.odd? ? count += 1 : nil \n substr_2.to_i.odd? ? count += 1 : nil \n \n idx += 1\n break if idx >= str.length\n end\n count\nend", "def f(n,d) # returns total number of times d shows up in range 0..n including n\n total = 0\n (n+1).times do |k|\n total += k.to_s.count(d.to_s)\n end\n return total\nend", "def count_substrings(s)\n size = s.size\n count = 0\n\n # the matrix represents substrings from one idx to another\n # we use the length of the string to determine the size\n # we start with all false values and update it to true when the substring is a palindrome\n\n dp = Array.new(size) { Array.new(size, false) }\n\n # substrings of one char are all palindromes\n\n (0...size).each do |idx|\n dp[idx][idx] = true\n count += 1\n end\n\n # check substrings of two chars\n # only if the 2 chars as the same will it be a palindrome\n\n (1...(size - 1)).each do |idx|\n if s[idx] == s[idx + 1]\n dp[idx][idx + 1] = true\n count += 1\n end\n end\n\n p dp\n\n # check longer substrings\n\n # this first loop represents the length of the substring, from 3 up to the total size of the original string\n\n (3..size).each do |length|\n # then we iterate according to index\n (0...(size - length)).each do |idx1|\n idx2 = (idx1 + length) - 1\n if dp[idx1 + 1][idx2 - 1] && (s[idx1] == s[idx2])\n dp[idx1][idx2] = true\n count += 1\n binding.pry\n end\n end\n end\n\n count\nend", "def count_triple( str )\n (2...str.length).inject 0 do |count,i|\n count += 1 if str[i] == str[i-1] && str[i-1] == str[i-2]\n count\n end\nend", "def game_of_thrones string\n s1 = string.chars\n freq = Hash.new(0)\n count = 0\n\n s1.each{ |key| freq[key]+=1 }\n\n freq.each{ |k,v| count+=1 if v.odd? }\n\n puts count < 2 ? 'YES' : 'NO'\n \nend", "def repeatedString(s, n)\n num_a = s.count(\"a\")\n if num_a == 0\n return 0\n end\n slen = s.length\n total = num_a*(n/slen)\n total += s[0...n%slen].count(\"a\")\nend", "def score( dice )\n total = []\n one_and_five = [[1000, 100], [500, 50]]\n [1, 5].each_with_index do |e, i|\n arr_size = dice.select {|s| s == e}.size\n if arr_size > 0\n if arr_size == 3\n total << one_and_five[i][0]\n elsif arr_size < 3\n total << one_and_five[i][1] * arr_size\n else\n total << one_and_five[i][1] * (arr_size - 3) + one_and_five[i][0]\n end\n end\n end\n [2, 3, 4, 6].each do |e|\n total << e * 100 if dice.join.count(e.to_s) >= 3\n end\n total.sum\nend", "def jewels_and_stones(j,s)\n\n if (s == nil || s.length < 1 || j == nil || j.length < 1)\n return 0\n end\n\n hash = Hash.new\n\n j.each_char do |char|\n hash[char] = 1\n end\n\n count = 0\n s.each_char do |char|\n if (hash[s[char]] == 1)\n count = count + 1\n end\n end\n return count\n\nend", "def repeatedString(s, n)\n char_array = s.split('')\n count_of_a_in_string = 0\n char_array.each do |letter|\n if letter == \"a\"\n count_of_a_in_string += 1\n end\n end\n\n factor = n/s.length()\n reminder = n % s.length()\n count_of_a_in_final_string = factor * count_of_a_in_string\n\n reminder.times do |index|\n count_of_a_in_final_string += 1 unless s[index] != \"a\"\n end\n count_of_a_in_final_string\nend", "def num_repeats(string)\n i = 0 \n count = 0\n check = nil\n \n while i < string.length\n letter = string[i]\n i2 = 1 \n while i2 < string.length\n letter2 = string[i2]\n \n if i < i2\n if letter == letter2\n if check == nil\n check = letter\n count += 1\n elsif letter != check\n count += 1\n check = letter\n end\n end\n end\n \n i2 += 1\n end\n i += 1\n end\n return(count)\nend", "def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend", "def count_code(str)\n times = 0\n str.size.times do |n|\n if n != (str.size - 1) && n != (str.size - 2) && n != (str.size - 3) && str[n] == \"c\" && str[n + 1] == \"o\" && str[n + 3] == \"e\"\n times += 1\n end\n end\n return times\nend", "def num_jewels_in_stones(j, s)\n hash_table = {}\n (0..s.length-1).each do |i|\n if hash_table.include? s[i]\n hash_table[s[i]] = hash_table[s[i]] + 1\n else\n hash_table[s[i]] = 1\n end\n end\n\n count = 0\n (0..j.length-1).each do |i|\n if hash_table.include? (j[i])\n if hash_table[j[i]] != nil\n count = count + hash_table[j[i]]\n hash_table[j[i]] = nil\n else\n fail (\"Letters in J are not distinct\")\n end\n end\n end\n\n return count\nend", "def countingValleys(n, s)\n elevation = 0\n valley_count = 0\n steps = s.split('')\n steps.each do |s|\n if s == \"U\"\n elevation += 1\n elsif s == \"D\" && elevation == 0\n valley_count += 1\n elevation -= 1\n elsif s == \"D\"\n elevation -= 1\n end\n end\n\nreturn valley_count\nend", "def solution(s)\n size = 0\n s.each_char do |c|\n if c == \"(\"\n size += 1\n elsif c == \")\"\n size -= 1\n return 0 if size < 0\n end\n end\n return 0 if size > 0\n return 1\nend", "def isLucky(n)\r\nhalf1 = []\r\nhalf2 = []\r\nn_string = n.to_s\r\n\r\n\r\nfirsthalf = (n_string.length / 2) - 1\r\nsecondhalfstart = (n_string.length / 2)\r\nsecondhalfend = (n_string.length - 1)\r\n(0..firsthalf).each do |idx|\r\n half1 << n_string[idx].to_i\r\nend\r\n\r\n(secondhalfstart..secondhalfend).each do |idx|\r\n half2 << n_string[idx].to_i\r\nend\r\n\r\nreturn true if half1.inject(:+) == half2.inject(:+)\r\nreturn false\r\nend", "def solve(n, s, d, m)\n # Complete this function\n records = s;\n\n (1...n).each do |i|\n records[i] += records[i-1]\n end\n\n numberOfWays = (m <= n && records[m - 1] == d) ? 1 : 0;\n\n (m...n).each do |i|\n if records[i] - records[i - m] == d\n numberOfWays += 1\n end\n end\n\n numberOfWays\n\nend", "def sandwich(str)\n i = 0\n j = 0\n bread1 = 0\n bread2 = 0\n breadcount = 0\n while i < str.size - 4\n (str.length).times do\n slice = str[i..(i+4)] \n if slice == \"bread\" && breadcount == 0\n breadcount += 1\n bread1 = i + 5\n end\n i = i + 1\n slice = str[i..(i+4)]\n if breadcount == 1 && slice == \"bread\"\n breadcount += 1\n j = i - 1\n bread2 = j\n end\n end\n if breadcount < 2\n enough = false\n elsif breadcount > 2\n toomuch = true\n end\n i = i + 1\n end\n if enough == false\n puts \"ERROR: NOT ENOUGH BREAD, YOU HAVE #{breadcount} SLICES.\"\n elsif toomuch == true\n puts \"ERROR: TOO MANY SLICES, YOU HAVE #{breadcount} SLICES.\"\n elsif enough != false && toomuch != true\n return str[bread1..bread2]\n end\nend", "def score( dice )\n total_score = 0\n hash = Hash.new(0)\n dice.each {|x| hash[x] += 1}\n total_score += hash[1] < 3 ? hash[1] * 100 : 1000 + (hash[1] - 3) * 100\n total_score += hash[5] < 3 ? hash[5] * 50 : 500 + (hash[5] -3) * 50\n total_score += hash[6] > 2 ? 600 : 0\n total_score += hash[4] > 2 ? 400 : 0\n total_score += hash[3] > 2 ? 300 : 0\n total_score += hash[2] > 2 ? 200 : 0\n total_score\n end", "def repeatedString(s, n)\n # First approach times out\n # s = s * ((n/s.length)+1)\n # p s[0..n-1].count('a')\n a_count = s.count('a')\n times_to_repeat = ((n/s.length))\n num_a_in_string = a_count * times_to_repeat\n leftover = (n%(s.length))\n num_a_in_string += s[0..leftover-1].count('a') if leftover >= 1\n p num_a_in_string\nend", "def count_matches( n )\n i = 1\n p = n\n while p.to_s.size == i\n p *= n\n i += 1\n end\n i - 1\n end", "def score( dice )\n @result = []\n values = [*1..6]\n values.each do |i|\n if dice.count(i) >= 3\n case i\n when 1\n result << 1000\n when 2\n result << 200\n when 3\n result << 300\n when 4\n result << 400\n when 5\n result << 500\n when 6\n result << 600\n end\n if (dice.count(i) - 3) > 0\n case i\n when 1\n result << 100 * (dice.count(1) - 3)\n when 5\n result << 50 * (dice.count(5) - 3)\n end\n end\n else\n once_check(i)\n # case i\n # when 1\n # result << 100 * dice.count(1)\n # when 5\n # result << 50 * dice.count(5)\n # end\n end\n end\n result.sum\nend", "def num_jewels_in_stones(j, s)\n s.count(j)\nend", "def challenge(args)\n @dice_bag.select { |d| d == args[:value] }.size == args[:dice]\n end", "def countingValleys(_n, s)\n array = s.split('')\n altitude = 0\n valleys = 0\n # start at sea level. If there is a step up\n # add 1 to altitude. If there is a step down\n # minus 1 from altitude.\n # if there was a step down from 0, altitude will equal -1\n # if there was a second step down, altitude will equal -2\n # if there is a step up now, altitude will equal -1\n # if there is another step up, valleys will equal to 1,\n # altitude will equal to 0.\n array.each do |step|\n if step == 'U'\n valleys += 1 if altitude == -1\n altitude += 1\n end\n altitude -= 1 if step == 'D'\n end\n valleys\nend", "def repeatedString(s, n)\n remainder_matches = 0\n\n length = s.length\n puts 'length: %d' % [length]\n\n matches = s.scan('a').count\n puts 'matches: %d' % [matches]\n\n quotient = n / length\n puts 'quotient: %d' % [quotient]\n\n remainder = n % length\n puts 'remainder: %d' % [remainder]\n\n remainder.times.each\\\n {|idx|\n remainder_matches += 1 if s[idx] == 'a'\n }\n puts 'remainder_matches: %d' % [remainder_matches]\n\n return matches*quotient + remainder_matches\nend", "def isValid(s)\n hash = s.strip.chars.inject(Hash.new(0)) { |total, e| total[e] += 1 ;total}\n puts hash.to_s\n values = hash.values.sort\n if values.count(values[0]) == values.size or\n (values.count(values[0]) == values.size - 1 and values[-1] - values[-2] == 1) or \n (values.count(values[-1]) == values.size - 1 and values[0] == 1)\n \"YES\"\n else\n \"NO\"\n end\n\nend", "def find_key_lengths string\n array = []\n string_array = string.split(\"\")\n guess = (3..8).to_a #if generalizing, 8 can be string_array.length\n guess.each do |x|\n matches = 0\n string_array.each.with_index do |y, i|\n if string_array[i] == string_array[i + x]\n matches += 1\n end\n end\n array.push(matches)\n end\n array.map.with_index{|x, i| i + 3 if x >= (array.max)}.compact\nend", "def score(dice)\n dice.sort\n\n if !dice.any?\n return 0\n end\n\n arr = Array.new (6)\n count = 1\n 6.times do\n arr[count-1] = dice.count(count)\n count +=1\n end\n\n sum = 0\n count = 1\n arr.each do |item|\n p \" #{count + 1} = #{item} :\"\n if item == 0 || item == nil\n count += 1\n next\n end\n\n if item >= 3 && count == 1\n sum += 1000 + 100 * (item - 3)\n elsif item >= 3 && count == 5\n sum += 5 * 100 + 50 * (item - 3)\n elsif item >= 3\n sum += count * 100\n end\n\n if item < 3 && count == 1\n sum += item * 100\n elsif item < 3 && count == 5\n sum += item * 50\n end\n\n count +=1\n end\n sum\nend", "def count_and_say(sequence)\n\treturn 0 if sequence == nil\n\tsequence = sequence.to_s\n\tn = sequence.to_s.size\n result = ''\n\ti = 1\n\trepeat = sequence[0]\n\ttimes = 1\n\twhile (i<=n) do\n\t\tif sequence[i] == repeat\n\t\t\ttimes += 1\n else\n \tresult += times.to_s + repeat.to_s\n \ttimes = 1\n repeat \t= sequence[i].to_i\n end\n i+=1\n end \n\treturn result \nend", "def repeatedString(s, n)\n count = s.count(\"a\")\n rep = (n / s.length)\n if n % s.length != 0\n short_s = s.slice(0, n % s.length)\n return (count * rep) + short_s.count(\"a\")\n else\n return (count * rep)\n end\n \nend", "def probability_n_of_a_kind(minimum_count, actual_count)\n debug = false\n gap = [(minimum_count - actual_count), 0].max # number of dice needed for minimum\n puts \"minimum count: #{minimum_count}, actual count: #{actual_count}, gap: #{gap}\" if debug\n if gap == 0 \n useful_results = 1\n reroll_count = 0\n else\n case [minimum_count, gap]\n when [3, 1] # need 1 of 3 to match\n # sequences with 1 of 3 dice: --*, -*-, *--\n # sequences with 2 of 3 dice: -**, *-*, **-\n # sequences with 3 of 3 dice: *** \n useful_results = (3*5*5)+(3*5)+1 \n when [3, 2] # need 2 of 4 to match\n # sequences with 2 of 4 dice: --**, -*-*, -**-, *--*, *-*-, **--\n # sequences with 3 of 4 dice: -***, *-**, ***-\n # sequences with 4 of 4 dice: ****\n useful_results = (6*5*5)+(4*5)+1\n when [3, 3] # need 3 of 5 to match\n # sequences with 3 of 5: --***, -**-*, -***-, *--**, *-*-*, *-**-, **--*, **-*-, ***--\n # sequences with 4 of 5: -****, *-***, ***-*, ****-\n # sequences with 5 of 5: ***** \n useful_results = (9*5*5)+(4*5)+1\n when [4, 1] # need 1 of 2 to match\n # sequences with 1 of 2 dice: -*, *-\n # sequences with 2 of 2 dice: **\n useful_results = (2*5)+1 \n when [4, 2] # need 2 of 3 to match\n # sequences with 2 of 3: -**, *-*, **-\n # sequences with 3 of 3: ***\n useful_results = (4*5)+1\n when [4, 3] # need 3 of 4 dice to match\n # sequences with 3 of 4 dice: -***, *-**, ***-\n # sequences with 4 of 4 dice: ****\n useful_results = (3*5)+1\n when [4, 4] # need 4 of 5 dice to match\n # sequences with 4 of 5: -****, *-***, ***-*, ****-\n # sequences with 5 of 5: ***** \n useful_results = (4*5)+1 \n else\n raise \"pair [#{minimum_count}, #{gap}] not expected\"\n end\n reroll_count = 5 - actual_count\n end\n puts \"useful results: #{useful_results}, reroll count: #{reroll_count}\" if debug\n p = calculate_probability(useful_results, reroll_count)\n return p\n end", "def num_repeats(string)\n\tcount = 0\n\tdix = 0\n\tnew = \"\"\n\twhile dix < string.length\n\t\tletter = string[dix]\n\t\tunless new.include?(letter)\n\t\t\tnew = new + letter\n\t\telse\n\t\t #...\n\t\tend\n\t\tdix2 = dix + 1\n\t\twhile dix2 < string.length\n\t\t\tif letter == string[dix2]\n\t\t\t\tcount +=1\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tdix2 +=1\n\t\tend\n\t\tdix += 1\n\tend\n\tputs(count.to_s)\n\treturn count\n\n\nend", "def roll( dice, sides, array, total )\n # Recursively roll dice and tally the frequency of each possible result.\n if 0 < dice\n (1..sides).each {|s| roll( dice - 1, sides, array, s + total )}\n else\n array[total - 1] += 1.0\n end\n end", "def score(dice)\n score = 0\n # n refers to an array which members are non-special die faces except when occurring three times in a roll of three or more.\n n = [2,3,4,6]\n # Creates an empty hash referred to as scorer with default value of zero\n scorer = Hash.new(0)\n # Iterates through the dice roll and creates a key/value pair in scorer\n # where the key is the die face and the value is increased by one for every occurrence of that die face\n dice.each do |die| scorer[die] += 1\n end\n # Iterates through the hash scorer, looking for the key 1 with a value equal to or greater than 3.\n if scorer[1] >= 3\n # 1000 is added to score for 3 occurrences of die face 1, and 100 is added for each additional occurrence.\n score += 1000+(100*(scorer[1]-3))\n # If the value of the key 1 is less than 3 it adds 100 to score for every occurrence of the die face 1.\n elsif scorer[1] < 3\n score += scorer[1]*100\n end\n # Iterates through the hash scorer, looking for the key 5 with a value equal to or greater than 3.\n if scorer[5] >= 3\n # 500 is added to score for 3 occurrences of die face 5, and 50 is added for each additional occurrence.\n score += 500+(50*(scorer[5]-3))\n # If the value of the key 5 is less than 3 it adds 50 to score for every occurrence of the die face 5.\n elsif scorer[5] < 3\n score += scorer[5]*50\n end\n# Iterates through array referred to as n.\n n.each do |x|\n if scorer[x] == 3\n score += x * 100\n end\n end\n # Returns the value of score after all the die values have been summed.\n score\nend", "def get_sandwhich(sandwhich)\n count = 0\n (sandwhich.size - 4).times do |i|\n slice = sandwhich[i..(i + 4)]\n puts slice\n if sandwhich[i, (i+4)] == \"bread\"\n count += 1\n end \n if slice == \"bread\"\n puts slice\n end\n end\n return count \nend", "def num_jewels_in_stones(j, s)\n jewels = 0\n s.each_char do |stone|\n if j.include?(stone)\n jewels += 1\n end\n end\n jewels\nend", "def nb_dig(n, d)\n counter = 0\n string_of_squares(n).split(\"\").each { |c| counter += 1 if d == c.to_i }\n counter\nend", "def is_happy(n)\n i = 0\n r = false\n destination = []\n while r == false\n n.to_s.split(\"\").each do |x|\n destination << ((x.to_i * x.to_i))\n end\n i = i + 1\n n = destination.inject(&:+)\n r = true if n == 1\n destination = []\n break if i == 1000\n end\n if r == true\n p r\n else\n p false\n end\nend", "def is s, d, done, i\n return 0, [] if i == s.length\n return done[i] if !!done[i]\n cuc, cs = is s, d, done, i + 1\n muc = 1 + cuc\n msplit = cs\n d.each do |w|\n if w == s[i...i + w.length]\n cuc, cs = is s, d, done, i + w.length\n if cuc < muc\n muc = cuc\n msplit = [i - 1, i + w.length - 1] + cs\n end\n end\n end\n done[i] = [muc, msplit]\n return [muc, msplit]\nend", "def isLucky(n)\n a = n.to_s.split(\"\")\n full = a.count - 1\n half = a.count/2 - 1\n \n total_1 = 0\n total_2 = 0\n \n for i in 0..full\n if i > half\n total_2 += a[i].to_i\n else\n total_1 += a[i].to_i\n end\n end\n \n if total_1 == total_2\n true\n else\n false\n end\nend", "def card_count(input)\n count = 0\n\n return false if input.size > CARDS_IN_A_DECK\n\n played_cards = input.chars\n\n played_cards.each do |input|\n if input == '2' || input == '3' || input == '4' || input == '5' || input == '6'\n count += 1\n elsif input == 'T' || input == 'J' || input == 'Q' || input == 'K' || input == 'A'\n count -= 1\n end\n end\n\n # return false if more_than_four_of_each_rank_played(played_cards)\n #\n # count += case card\n # when '2', '3', '4', '5', '6'\n # 1\n # when 'T', 'J', 'Q', 'K', 'A'\n # -1\n # else\n # 0\n # end\n\n return count\nend", "def palin_per(string)\n hist={}\n \n for i in 0..string.length-1\n unless string[i]==\" \"\n hist[string[i]]||=0\n hist[string[i]]+=1\n end \n end \n\nodd_appear=1\n hist.values.each do |value|\n odd_appear-=1 if (value % 2 !=0)\n return false if odd_appear <0\n end \n return true\nend", "def num_repeats(string)\n\n\ti = 0\n\tcount = 0\n\tcounted = []\n\t\n\twhile i < string.length - 1\n\t\tj = i + 1\n\t\twhile j < string.length\n\t\t\tif string[i] == string[j]\n\t\t\t\tk = 0\n\t\t\t\tis_counted = false\n\t\t\t\twhile k < counted.size\n\t\t\t\t\tif counted[k] == string[j]\n\t\t\t\t\t\tis_counted = true\n\t\t\t\t\tend\n\t\t\t\t\tk += 1\n\t\t\t\tend\n\n\t\t\t\tbreak if is_counted\n\t\t\t\t\n\t\t\t\tif !is_counted\n\t\t\t\t\tcount += 1\n\t\t\t\t\tcounted.push(string[i])\n\t\t\t\tend\n\t\t\tend\n\t\t\tj += 1\n\t\tend\n\n\t\ti += 1\n\tend\n\treturn count\nend", "def count_string(string, characters)\n i = 0\n size = characters.length\n hits = 0\n while i < string.length - size + 1\n if string[i,size] == characters\n hits += 1\n end\n i += 1\n end\n return hits\nend", "def nice_strings(input)\n strings = input.split(\"\\n\").map(&:strip)\n nice_count = 0\n strings.each do |string|\n twinsy = twinsies(string)\n vowel_count = get_vowel_count(string)\n nice_count += 1 if !illegal(string) && vowel_count > 2 && twinsy == true\n end\n nice_count\nend", "def isBalanced? str\n\n nParentheses = 0\n smiley = 0\n frowny = 0\n\n (0...str.length).each do |i|\n \n if str[i] == \":\" && str[i+1] == \"(\" then frowny += 1 \n elsif str[i] == \":\" && str[i+1] == \")\" then smiley += 1 end\n\n if str[i] == \"(\" then nParentheses += 1\n elsif str[i] == \")\" then nParentheses -= 1 end\n\n if nParentheses < 0 \n if smiley >= nParentheses.abs\n smiley -= nParentheses.abs\n nParentheses = 0\n else\n return false\n end\n end\n end\n\n if nParentheses == 0 then return true\n elsif frowny >= nParentheses then return true\n else return false end\n \nend", "def g_happy(string)\n count_g = 0 \n next_to = 0 \n string.size.times do |n|\n if string[n] == \"g\"\n count_g += 1\n end\n if string[n] == \"g\" && string[n+1] == \"g\"\n next_to += 1\n end \n end \n if next_to == (count_g-1) \n return true\n else \n return false\n end \nend", "def num_repeats(string)\n\tio = 0\n\ti = io + 1\n\tyo = 0\n\ty = yo + 1\n\tletters = []\n\tcounter = 0\n\n\twhile io < string.length\n\t\twhile i <= string.length\n\t\t\tif string[io] == string[i]\n\t\t\t\tletters.push(string[io])\n\t\t\t\tio += 1\n\t\t\t\ti = io + 1\n\t\t\t\twhile yo < letters.length\n\t\t\t\t\t\tif string[io] == letters[yo]\n\t\t\t\t\t\t\tio += 1\n\t\t\t\t\t\t\ti = io + 1\n\t\t\t\t\t\t\tyo = 1\n\t\t\t\t\t\telse yo += 1\n\t\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\tcounter += 1\n\t\t\tend\n\n\t\ti += 1\n\t\tend\n\t\tio += 1\n\t\ti = io + 1\n\tend\n\treturn counter\n\nend", "def co_ecount(str)\n times = 0\n (str.length - 3).times do |i|\n if str[i] == \"c\" && str[i+1] == \"o\" && str[i+3] == \"e\"\n times += 1\n end\n end\n return times\nend", "def nicer_strings(input)\n strings = input.split(\"\\n\").map(&:strip)\n nice_count = 0\n strings.each do |string|\n match = match?(string)\n triplets = triplets?(string)\n nice_count += 1 if match && triplets\n end\n nice_count\nend", "def valleyCounter(n,s)\n currentAltitude = 0\n lastAltitude = 0\n index = 0\n numberOfValleys = 0\n s.each_char do |char|\n if char == \"U\"\n currentAltitude += 1\n lastAltitude = currentAltitude - 1\n else\n currentAltitude -= 1\n lastAltitude = currentAltitude + 1\n end\n if currentAltitude == 0 && lastAltitude < 0\n numberOfValleys += 1\n end\n end\n puts numberOfValleys\nend", "def count_chars(n)\n return THOUSAND if n == 1_000\n total = 0\n if n >= 100\n total += ONES[n/100] + HUNDRED\n total += AND unless n%100 == 0\n n %= 100\n end\n (total += TEENS[n]; return total) if n > 10 && n < 20\n (total += TENS[n/10]; n %= 10) if n >= 10\n total += ONES[n] if n > 0\n total\nend", "def checkWinner(state, player1, player2)\n\n for i in 0..2\n\n row_candidate = true\n column_candidate = true\n\n for j in 1..2\n\n # check rows\n if state[i * 3 + j] == '0' || state[i * 3 + j] != state[i * 3 + j - 1] then\n row_candidate = false\n elsif row_candidate && state[i * 3 + j] == state[i * 3 + j - 1] then\n if j == 2 then\n winner = if state[i * 3 + j] == '1' then player1 else player2 end\n return winner\n end\n end\n\n # check columns\n if state[j * 3 + i] == '0' || state[j * 3 + i] != state[(j - 1) * 3 + i] then\n column_candidate = false\n elsif column_candidate && state[j * 3 + i] == state[(j - 1) * 3 + i] then\n if j == 2 then\n winner = if state[j * 3 + i] == '1' then player1 else player2 end\n return winner\n end\n end\n end\n end\n\n # check diagonals\n if state[0] == state[4] && state[4] == state[8] && state[0] != '0' then\n winner = if state[0] == '1' then player1 else player2 end\n return winner\n end\n\n if state[2] == state[4] && state[4] == state[6] && state[2] != '0' then\n winner = if state[2] == '1' then player1 else player2 end\n return winner\n end\n\n return nil\n end", "def how_many(srt)\n arr = srt.split(\" \")\n count = {}\n\n #arr.map{ |s| \"#{s} #{arr.count s}\" }\n\n # arr.each do |s|\n # s.downcase!\n # count[s] = count.key?(s) ? count[s]+1 : 1\n # end\nend", "def num_repeats(string)\n \nidx1 = 0 #Made a counter for first loop\nidx2 = 0 #Made another counter for the second loop\nrepeat_count = 0 #Assigned a variable to tally the number of letters that had repeated in the string\ncurrent_repeat_count= []\nidx3 = 0\n while idx1 < string.length #The characters in the string will be scanned over and over again until it reaches the string.length\n idx2 = idx1 + 1 #the the second loop will always be 1 element ahead of the idx1 to scan them properly\n \n while idx2 < string.length #Same logic with the first loop\n unless current_repeat_count[idx3] == string[idx2]\n if string[idx1] == string[idx2] #if the current element of idx1 is the same with the current element of idx2, \n current_repeat_count << string[idx2]\n repeat_count = repeat_count + 1# repeat_count will increase by 1 each time\n end\n end\n \n idx2 = idx2 + 1 #idx2 will increase by 1 to go to the next element\n end\n idx1 = idx1 + 1 #after the first round of the first element pairs up with the rest of the elements, 1 will be added \n end #to go the next element to be compared with the rest\n \n return repeat_count #once it's done, the code returns the tally of repeated letters. \n\nend", "def score(str)\n score = 0.0\n mine = @secret.each_byte.map{ |x| x.to_s(2) }.join\n theirs = str.each_byte.map{ |x| x.to_s(2) }.join\n\n mine.each_byte.zip(theirs.each_byte) do |a,b|\n score += 1 if a == b\n end\n (score / mine.length)\n end", "def turn()\n die = roll()\n count = 0\n lim = 0\n lands = []\n total = 0 \n if die[0] == die[1] && lim < 3\n while die[0] == die[1] && lim < 3\n count += die.sum \n die = roll()\n lim += 1\n lands << count\n end\n else\n if count != 20 \n lands << die.sum\n end \n end \n for n in lands \n if n == 6 || n == 8\n total += 950\n elsif n == 9\n total += 1000\n end\n end\n return total \nend", "def num_decodings(s)\n return 0 if !s || s == '0'\n return 1 if s.size == 1\n dp = [0] * (s.size + 1)\n dp[0] = 1\n dp[1] = s[0] == '0' ? 0 : 1\n\n for i in 2..s.size do \n char = s[i - 1].to_i\n chars = s[(i - 2)..(i - 1)].to_i\n\n if char >= 1 && char <= 9\n dp[i] += dp[i - 1]\n end\n\n if chars >= 10 && chars <= 26\n dp[i] += dp[i - 2]\n end\n end\n\n dp.last\nend", "def score(dice)\n n = 0\n (1..9).each do |i|\n amount = dice.find_all{|d| d == i}.size\n case i\n when 1\n if amount > 2\n n += 1000 + (amount - 3) * 100\n else\n n += amount * 100\n end\n when 5\n if amount > 2\n n += 500 + (amount - 3) * 50\n else\n n += amount * 50\n end\n else\n if amount > 2\n n += i * 100\n end\n end\n end\n\n return n\nend", "def solution(s)\n stack = s.split('').inject(0) do |acc, el|\n next acc + 1 if el == '('\n return 0 if acc == 0\n acc - 1\n end\n stack == 0 ? 1 : 0\nend", "def repeatedString(s, n)\n length = s.length\n\n repeat_count = n / length\n\n remainder = n % length\n\n count_a(s) * repeat_count + count_a(s[0...remainder])\nend", "def isBalanced(s)\n puts \"\"\n puts \"Initial Array: #{s}\"\n puts \"\"\n \n # sting to array \n print\n s_array = s.chars\n # elemen count\n\n # ele_count = []\n # s.chars.each do |var, i|\n # p i\n # p var\n # # ele_count[i].include?( ) ? ele_count << var\n # end\n\n left = 0\n right = 0\n left_squared = 0\n right_squared = 0\n left_curly = 0\n right_curly = 0\n\n\n \"s_array size: #{s_array.size} \"\n \"s_array 1/2 : #{s_array.size / 2} \"\n\n bytes_array = []\n\n s_array.each do |char|\n case char\n when \"(\"\n left += 1\n bytes_array << 40\n when \")\"\n right += 1\n bytes_array << 41\n when \"[\"\n left_squared += 1\n bytes_array << 91\n when \"]\"\n right_squared += 1\n bytes_array << 93\n when \"{\"\n left_curly += 1\n bytes_array << 123\n else\n right_curly += 1\n bytes_array << 125\n end\n end\n \"( #{left}\"\n \") #{right}\"\n \"[ #{left_squared}\"\n \"] #{right_squared}\"\n \"{ #{left_curly}\"\n \"} #{right_curly}\"\n\n bytes_array\n\n diff = left - right\n diff_squared = left_squared - right_squared\n diff_curly = left_curly - right_curly\n\n # the number of each of the elements is balanced\n condition1 = diff == 0 && diff_squared == 0 && diff_curly == 0\n condition1\n\n if condition1\n \"the number of elements is balanced? || for each open there is a close ? : YES\"\n \"is the opening and closing balanced ?\"\n else\n \"the number of elements is NOT balanced \"\n end\n\n puts \"first half: #{s_arriba = s_array.slice(0, s_array.size / 2)}\"\n puts \"first half bytes : #{bytes_array1 = bytes_array.slice(0, s_array.size / 2)}\"\n\n # how to check if the position is balanced ?\n\n puts \"second half #{s_abajo = s_array.slice((s_array.size / 2), s_array.size).reverse}\"\n puts \"second half bytes : #{bytes_array2 = bytes_array.slice((bytes_array.size / 2), bytes_array.size).reverse}\"\n\n bytes_array1\n bytes_array2\n\n pos_balanced = 0\n igual = [81, 184, 248]\n ((bytes_array.size) / 2).times do |i|\n pos_comparison = bytes_array1[i] + bytes_array2[i]\n\n if igual.include?(pos_comparison)\n pos_balanced = pos_balanced + 0\n else\n pos_balanced = pos_balanced + 1\n end\n end\n pos_balanced == 0 ? condition2 = true : condition2 = false\n\n if condition1 && condition2\n puts \"YES\"\n else\n puts \"YES\"\n end\nend", "def find_anagrams(s, p)\n results = []\n\n return results if p.length > s.length\n\n d = {}\n\n p.chars.each do |char|\n d[char] = d.fetch(char, 0) + 1\n end\n\n count = p.length\n\n left, right = 0, 0\n\n while right < s.length\n if d.include?(s[right])\n count -= 1 if d[s[right]] > 0\n\n d[s[right]] -= 1\n end\n\n right += 1\n\n while count == 0\n if d.include?(s[left] )\n d[s[left]] += 1\n\n count += 1 if d[s[left]] > 0\n end\n\n results << left if right - left == p.length\n\n left += 1\n end\n end\n\n results\nend", "def gameOfThrones(s)\n words = s.split('')\n frequency = Hash.new(0)\n words.each { |word| frequency[word.downcase] += 1 }\n odd = 0\n even = 0\n frequency.each do |k,v|\n if v.even?\n even += 1\n else \n odd += 1\n end\n end\n if odd > 1\n \"NO\"\n else \n \"YES\"\n end\nend", "def solution(a)\n\traise ArgumentError.new(\"a has to be non empty array of max size #{MAX_LEN}\") if !a.is_a? Array or a.empty? or a.length > MAX_LEN\n\tret = 0\n\t#puts a.inspect\n\tmy_h = Hash.new\n\ta.each do |e|\n\t\tif my_h.include? e\n\t\t\tmy_h[e] += 1\n\t\telse\n\t\t\tmy_h[e] = 1\n\t\tend\n\tend\n\n\tmy_h_sort = my_h.sort_by {|k, v| -v}\n\t# -> my_h_sort[value][occurances]\n\treturn 0 if my_h_sort.first[1] < a.size/2\n\tleader_val = my_h_sort.first[0]\n\n\tocc_array = Array.new\n\toccurances = 0\n\ta.each do |e|\n\t\toccurances += 1 if e == leader_val\n\t\tocc_array.push(occurances)\n\tend\n\t#puts occ_array.inspect\n\n\tfor idx in (0...a.length-1) do\n\t\tsum1 = occ_array[idx]\n\t\tsum2 = occ_array.last - occ_array[idx]\n\n\t\t# puts \"#{idx}+1 < #{sum1*2}\"\n\t\t# puts \"#{(a.length - idx -1)} < #{(sum2*2 )} \"\n\n\t\tif (idx+1) < sum1 * 2 && (a.length - idx - 1 ) < sum2 * 2\n\t\t\t## we have a leader\n\t\t\t#puts \"YEAH #{idx}\"\n\t\t\tret += 1\n\t\tend\n\t\t\t#puts \"-------- ret: #{ret}\"\n\tend\n\treturn ret\nend", "def homocount(str)\n\ts = str.size\n lasts = ''\n homo = {}\n st = 0\n flag = 0\n 0.upto(s-1) do |i|\n cur = str[i,1].upcase\n if cur == lasts\n if flag == 0 # this is the second \n homo[i-1] = 2\n st = i - 1\n else # this is the third or more\n homo[st] += 1\n end\n flag = 1\n else\n flag = 0\n end\n lasts = cur\n end\n if homo.size > 0\n top = homo.keys.sort {|a,b| homo[b] <=> homo[a]}[0]\n xx = homo[top]\n else\n xx = 0\n end\n return xx\nend", "def num_repeats(string)\nnums = Hash.new(0)\ncount = 0\n\nstring.each_char do |letter| nums[letter] += 1 end\n\nnums.keys.each do |key|\n\tif nums[key] > 1\n\t\tcount += 1\n\tend\nend\ncount\n\nend", "def solution(s, p, q)\n counts = [nil, [0], [0], [0], [0]]\n factors = s.split(//).map do |nu|\n case nu\n when 'A'\n 1\n when 'C'\n 2\n when 'G'\n 3\n when 'T'\n 4\n end\n end\n for i in (1..factors.length)\n fa = factors[i - 1]\n for j in [1, 2, 3, 4]\n counts[j][i] = counts[j][i - 1]\n end\n counts[fa][i] += 1\n end\n \n (0..p.count - 1).map { |k|\n if p[k] == q[k]\n factors[p[k]]\n else\n [1, 2, 3, 4].index do |i|\n counts[i][q[k] + 1] - counts[i][p[k]] > 0\n end + 1\n end\n }\nend", "def solve(nums)\n count = 0\n nums.each do |num|\n if num.to_s.length % 2 != 0\n count += 1\n end\n end\n return count\nend", "def string_search(main_string, sub_string)\n count = 0\n i = 0\n while i <= (main_string.length - sub_string.length) do # number of potential tests\n if main_string[i, sub_string.length] == sub_string # string slice is starting position, length\n count += 1;\n end\n i +=1;\n end\n return count\nend", "def score( dice )\n score = 0\n\n [1,6,5,4,3,2,1,5].each { |x|\n if dice.count(x) >= 3 # Three 1's => 1000 points\n 3.times { dice.delete_at(dice.index(x) || dice.length) }\n case x\n when 1\n score += 1000\n else\n score += (x*100)\n end\n end\n }\n\n 2.times {\n if dice.count(1) >= 1 # One 1 => 100 points\n dice.delete_at(dice.index(1) || dice.length)\n score += 100\n end\n\n if dice.count(5) >= 1 # One 5 => 100 points\n dice.delete_at(dice.index(5) || dice.length)\n score += 50\n end\n }\n score\nend", "def balloon_count(s)\n # make some data structure to represent counts needed of each character to spell \"balloon\" (balloon_counts)\n balloon_counts = {\n \"b\" => 1,\n \"a\" => 1,\n \"l\" => 2,\n \"o\" => 2,\n \"n\" => 1\n }\n # make another data structure that will store counts of all characters in s (s_counts)\n \n s_counts = {\n \"b\" => 0,\n \"a\" => 0,\n \"l\" => 0,\n \"o\" => 0,\n \"n\" => 0\n }\n # iterate through s to populate s_counts\n s.each_char do |c|\n if (s_counts[c])\n s_counts[c] += 1\n end\n end\n\n # create array to represent s_counts['b'] / balloon_counts['b'] and so on (letter_ratios)\n letter_ratios = []\n s_counts.each do |letter, count|\n letter_ratios << count / balloon_counts[letter]\n end\n return letter_ratios.min\nend", "def score_bowling_game_rolls(rolls)\n padded_rolls = pad_rolls(rolls)\n frames = map_to_frames(padded_rolls)\n chunks = map_to_chunks(frames)\n chunks.map { |chunk| chunk_to_score(chunk) }.sum(&:to_i)\n end", "def homocount(str)\n s = str.size\n lasts = ''\n homo = {}\n st = 0\n flag = 0\n 0.upto(s-1) do |i|\n cur = str[i,1].upcase\n if cur == lasts\n if flag == 0 # this is the second \n homo[i-1] = 2\n st = i - 1\n else # this is the third or more\n homo[st] += 1\n end\n flag = 1\n else\n flag = 0\n end\n lasts = cur\n end\n if homo.size > 0\n top = homo.keys.sort {|a,b| homo[b] <=> homo[a]}[0]\n xx = homo[top]\n else\n xx = 1\n end\n return xx\nend", "def homocount(str)\n s = str.size\n lasts = ''\n homo = {}\n st = 0\n flag = 0\n 0.upto(s-1) do |i|\n cur = str[i,1].upcase\n if cur == lasts\n if flag == 0 # this is the second \n homo[i-1] = 2\n st = i - 1\n else # this is the third or more\n homo[st] += 1\n end\n flag = 1\n else\n flag = 0\n end\n lasts = cur\n end\n if homo.size > 0\n top = homo.keys.sort {|a,b| homo[b] <=> homo[a]}[0]\n xx = homo[top]\n else\n xx = 1\n end\n return xx\nend", "def maurice_wins(maurice, steve)\n score = 0\n\n # slow vs fast (Maurice vs Steve)\n score += 1 if maurice[0] > steve[2]\n\n # medium vs slow\n score += 1 if maurice[1] > steve[0]\n\n # fast vs medium\n score += 1 if maurice[2] > steve[1]\n\n score >= 2 ? true : false\nend", "def winning_streak(str)\n\nend", "def hex_string_square(str)\n count = 0\n\n if square?(str.hex)\n return 1\n else\n combos = combos(str)\n\n combos.each do |combo| # combo is a k,v pair turned into an array\n if square?(combo[1].hex) # hence combo[1] => str to be converted to hex\n count = 1 # is square so increment count\n current_str = str # alias str for a comparison to be made later\n current_str.slice!(0, combo[0]) # slice alias to recurse on remainder\n \n r_count = hex_string_square(current_str) # momoize recursed value\n \n if r_count > 0\n count += r_count\n elsif current_str == str # on last permutation\n return -1\n else # try next permutation, reset count\n count = 0\n end\n end\n end\n \n end\n\n count > 0 ? count : -1\nend", "def sols( n, sq, cb )\n count = 0\n\n # Subtract cubes until they're too big to produce a positive difference.\n cb.each do |c|\n break if c > n - 1\n count += 1 if sq.has_key?( n - c )\n end\n \n count\n end", "def fourth_anagram?(string, strong)\n s_hash = Hash.new(0)\n ss_hash = Hash.new(0)\n string.chars.each do |el|\n s_hash[el] += 1\n end\n strong.chars.each do |el|\n ss_hash[el] += 1\n end\n s_hash.to_a.sort == ss_hash.to_a.sort\nend", "def score(dice)\n # You need to write this method\n if dice.empty?\n return 0\n end\n total = 0\n dice.sort!\n if dice.size >= 3\n dice.each_slice(3) do |slice|\n if slice.uniq.size == 1\n if slice.first == 1\n total += 1000\n else\n total += get_single_score_points slice\n end\n else\n total += get_single_score_points slice\n end\n\n end\n else\n total += get_single_score_points dice\n end\n total\nend" ]
[ "0.684635", "0.6608983", "0.6588201", "0.6485433", "0.6435639", "0.64073086", "0.62390244", "0.61810786", "0.61759895", "0.6123667", "0.61217266", "0.6070245", "0.6038976", "0.6020436", "0.598535", "0.59503984", "0.59415495", "0.59283185", "0.59206885", "0.5869518", "0.5855349", "0.58540606", "0.5851831", "0.58464104", "0.58448577", "0.5840841", "0.5838092", "0.5834139", "0.58319014", "0.58140343", "0.5797946", "0.5787755", "0.57739687", "0.57733834", "0.5767971", "0.575341", "0.57389003", "0.5727771", "0.57140493", "0.5713634", "0.5707897", "0.56882733", "0.568709", "0.56823784", "0.56823343", "0.5679318", "0.56725454", "0.5670102", "0.566432", "0.5652439", "0.5648873", "0.56401217", "0.5640031", "0.56368226", "0.5636504", "0.56357515", "0.56306726", "0.56305677", "0.5625761", "0.56255454", "0.5622248", "0.56123364", "0.5610178", "0.56082267", "0.56025535", "0.56009334", "0.55980164", "0.5592212", "0.55849123", "0.55830073", "0.5570455", "0.5567179", "0.55627763", "0.55562", "0.55538136", "0.5551408", "0.55504787", "0.55413795", "0.5537976", "0.55369973", "0.55365115", "0.5534471", "0.5530443", "0.55240947", "0.5523412", "0.5523047", "0.5522227", "0.5522151", "0.5520977", "0.5519413", "0.5518594", "0.55124515", "0.55104595", "0.55104595", "0.5506456", "0.5506198", "0.54966986", "0.54950637", "0.54885566", "0.54812056" ]
0.5794759
31
counts_by_length takes counts hash as input and generates another hash, where the keys are the lengths of substrings (as a string), and the values are arrays containing the number of appearances.
def counts_by_length(counts) counts_by_length = {} counts.each do |key, value| l = key.length.to_s if counts_by_length.has_key?(l) counts_by_length[l] << value else counts_by_length[l] = [value] end end counts_by_length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def length_finder(words)\n lengths = {}\n words.each do |word|\n lengths[word] = word.length\n end\n lengths.values\nend", "def word_sizes(words)\n length_arr = []\n hash_words = {}\n words.gsub(/[^[:word:]\\s]/, '').split(' ').each do |word| \n length_arr << word.length\n end\n length_arr.uniq.each do |element|\n hash_words[element] = length_arr.count(element)\n end\n hash_words\nend", "def group_words_by_length\n words = [\"alice\", \"tony\", \"steve\", \"carlos\", \"rick\", \"martin\", \"chris\", \"tom\", \"david\", \"megan\", \"sue\"]\n\n # words.group_by { |word| word.size }\n words.group_by(&:size)\n #=> {5 => [\"alice\", \"steve\", \"carlos\", \"chris\", \"david\", \"megan\"], 4 => [\"tony\", \"rick\"], 3 => [\"sue\", \"tom\"]}\nend", "def word_sizes(str)\n ary = str.split\n # Create array of word lengths\n num_array = ary.map do |word|\n word.length\n end\n rtn_hsh = ary.each_with_object({}) do |word, hsh|\n hsh[word.length] = num_array.count(word.length)\n end\n rtn_hsh\nend", "def word_lengths(str)\n # nested = []\n # str.split.each do |word|\n # nested << [word, word.length]\n # end\n # nested.to_h\n\n lengths = {}\n str.split.each {|word| lengths[word] = word.length}\n lengths\nend", "def word_sizes(str)\n length_hsh = {}\n\n str.split(' ').each do |word|\n if length_hsh.key?(word.length)\n length_hsh[word.length] += 1\n else\n length_hsh[word.length] = 1\n end\n end\n\n length_hsh\nend", "def word_lengths(str)\n hashed = str.split(\" \").map {|word| [word, word.length]}.flatten\n return Hash[*hashed]\nend", "def word_sizes2(string)\n frequency = Hash.new(0) #set the default value to 0\n string.split.each do |word| \n frequency[word.length] += 1\n end\n frequency\nend", "def word_sizes(string)\n keys =[]\n words = string.split.each do |word|\n keys << word.length\n end\n keys = keys.uniq\n size = {}\n keys.each do |key|\n size[key] = words.count{|wordies| key == wordies.length}\n end\n size\nend", "def word_lengths(str)\n new_arr = str.split(\" \")\n hsh = {}\n new_arr.each do |ele|\n hsh[ele] = ele.length \n end\n hsh\nend", "def word_sizes(string)\n split_string_array = string.split(\" \")\n keys = []\n results = {}\n\n split_string_array.each do |word|\n keys << word.length\n end\n\n keys.each do |key|\n results[key] = keys.count(key)\n end\n\n results.sort_by {|k,v| k}.to_h\nend", "def word_lengths(str)\n hash = {}\n str.split.each do |word|\n hash[word] = word.length\n end\n hash\nend", "def twist_lengths input\n lengths = input.chars.map(&:ord) + [17, 31, 73, 47, 23]\n 64.times { lengths.each {|l| twist l } }\n hash\n end", "def group_words_by_length\n words = [\"alice\", \"tony\", \"steve\", \"carlos\", \"rick\", \"martin\", \"chris\", \"tom\", \"david\", \"megan\", \"sue\"]\n\n #=> {5 => [\"alice\", \"steve\", \"carlos\", \"chris\", \"david\", \"megan\"], 4 => [\"tony\", \"rick\"], 3 => [\"sue\", \"tom\"]}\nend", "def word_lengths(str)\n hsh = {}\n str.split(' ').each { |k| hsh[k] = k.length }\n hsh\nend", "def word_lengths(str)\n hsh = Hash.new\n str.split.each do |word|\n hsh[word] = word.length\n end\n hsh\nend", "def count_index(to_count)\n\tmy_hash = Hash.new{|hash, key| hash[key] = []}\n\tcount = 0\n\tto_count.split('').each do |letter|\n\t\tcount += 1\n\t\tmy_hash[letter].push(count)\n\tend\n\tmy_hash\t\nend", "def word_length(list)\n hash = {}\n list.each { |w| hash[w] = w.size }\n hash\nend", "def word_sizes(words_string)\n\n # We create a new hash, but we have to initialize is this way vs hash = {}\n # Because the first time we go to count[word.size] += 1, the element doesn't\n # exist yet, and returns nil. Since nil can't be added to 1, we have to do it this way\n counts = Hash.new(0)\n\n # Next we're going to split the string into words, then iterate over each word.\n # We assign a new variable clean_word equal to the word that we're iterating on\n # and delete anything that's not a letter using a simple REGEX.\n\n # We will then be counting the length of each word (based on the new variable clean_word)\n # that we're iterating, and storing that in our hash, counts.\n\n words_string.split.each do |word|\n clean_word = word.delete('^A-Za-z')\n counts[clean_word.size] += 1\n end\n # Return our hash\n counts\nend", "def dictionary\n hash = {}\n @length_indexed_dict.each do |len, words_of_same_length|\n hash.merge! words_of_same_length\n end\n hash\n end", "def word_sizes(words)\n word_count = Hash.new(0) #this initializes default values as 0\n\n words.split.each do |word|\n word_count[word.length] += 1\n end\n\n word_count.sort.to_h\nend", "def frequency_distribution (sequence, length_pattern)\n assert(length_pattern > 0, \"The pattern length must be grater than 0\")\n frequency = Hash.new\n index = 0\n while index < sequence.length do\n codon = sequence[index .. index + length_pattern - 1]\n frequency[codon] == nil ? frequency[codon] = 1 : frequency[codon] += 1\n index += length_pattern\n end\n frequency\nend", "def word_sizes(str)\n hsh = {}\n new_str = str.gsub(/[^a-z ]/i, '')\n arry = new_str.split.map(&:size)\n arry.map { |word| hsh[word] = arry.count(word) }\n hsh\nend", "def substrings(input, dictionary)\n\thash = {}\t\t\t\t\t# Initialize empty hash\n\tdictionary.each do |word|\n\t\t# For each word, count the number of times it appears\n\t\tcount = input.downcase.scan(word.downcase).length\n\t\tif count > 0\n\t\t\t# If greater than 0:\n\t\t\thash[word] = count\t# Add word => count to hash\n\t\tend\n\tend\n\thash\nend", "def word_sizes(str)\n arr = str.split(' ')\n hsh = Hash.new(0)\n \n arr.each {|word|\n hsh[word.length] += 1\n }\n \n hsh\nend", "def word_sizes(string)\n \n sizes = string.gsub(/[^a-z A-Z]/, '').split(' ').map{ |word| word.size }.sort\n sizes.uniq.zip(sizes.uniq.map { |size| sizes.count(size) }).to_h\n \n # Method 2\n # h = {}\n # sizes.uniq.each { |size| h[size] = sizes.count(size) }\n # h\n \nend", "def count_frequencies s\n s.downcase.split(//).inject(Hash.new(0)) do |hash,item|\n hash[item] += 1\n hash\n end\n end", "def word_sizes(string)\n\n arr_words = string.split \n hash_counts = Hash.new(0)\n\n arr_words.each do |word|\n size = word.size\n hash_counts[size] += 1\n end\n\n hash_counts\nend", "def word_lengths(sentence)\n split = sentence.split(\" \")\n hash = {}\n\n split.each do |word|\n hash[word] = word.length\n end\n\n return hash\nend", "def word_sizes(str)\n hash = {}\n str = str.split(\" \")\n str.each_index {|i| str[i] = str[i].length}\n str.each {|v| hash[v] = str.count(v)}\n hash\nend", "def word_lengths(str)\n counter = Hash.new(0)\n str.split(\" \").each do |x|\n counter[x] = x.length\n end\n counter\nend", "def find_word_lengths(word_list)\n word_list.reduce(Hash.new(0)) do |hash, el|\n hash[el] += el.size\n hash\n end\nend", "def word_lengths(str)\n str.split.reduce({}) do |acc, word|\n acc[word] = word.length\n acc\n end\nend", "def word_lengths(sentence)\n words_lengths = Hash.new\n words = Array.new\n lengths = Array.new\n\n words = sentence.split\n\n words.each do |word|\n lengths << word.length\n end\n\n words_lengths = Hash[words.zip(lengths)]\n\n puts words_lengths\n\nend", "def word_sizes(input)\n hash = {}\n input .split.each do |word|\n num_of_letters = word.chars.count\n if hash.has_key?(num_of_letters)\n hash[num_of_letters] += 1\n else\n hash[num_of_letters] = 1\n end\n end\n hash\nend", "def substrings words, dictionary\n hits = Hash.new\n dictionary.each do |lookup|\n hits[lookup] = words.scan(/#{lookup}/i).length\n end\n hits.delete_if {|k,v| v == 0} # squeeze out the empties\nend", "def counts(state)\n counts = {'' => 1}\n state = state.split(\"\") if state.kind_of?(String)\n state.each do |char|\n counts.keys.each do |key|\n if key.count(char) == 0\n key_char = key + char\n counts[key_char] = (counts[key_char] || 0) + counts[key]\n end\n end\n end\n counts\nend", "def word_sizes(words)\n word_count = Hash.new(0)\n words = words.delete \"^a-zA-Z \"\n\n words.split.each do |word|\n word_count[word.length] += 1\n end\n\n word_count.sort.to_h\nend", "def word_sizes(words)\n result_hash = Hash.new(0)\n words.split.each do |word| \n word = word.gsub(/[^a-z]/i,\"\")\n result_hash[word.length] += 1\n end\n result_hash\nend", "def word_lengths(str)\n ans = Hash.new\n str.split.each do |word|\n ans[word] = word.length\n end\n ans\nend", "def word_lengths(sentence)\n\twords = sentence.split(\" \")\n \thash = {}\n words.each {|word| hash[word] = word.length}\n return hash\n \nend", "def word_lengths(str)\n words = str.split(\" \")\n word_length = Hash.new(0)\n words.each {|ele| word_length[ele] = ele.length}\n word_length\nend", "def checkSearchTerms(wordHash, searchTermsArray, documentCounter, resultsHash, wordArray)\n documentCounter;\n documentNumber = \"Document \" + documentCounter.to_s\n searchTermsArray.each do |word|\n resultsHash.merge!(word => { documentNumber => wordHash[word]})\n # need to figure out the frequency based on the wordHash[word] and the wordArray.length\n end\n # puts wordArray.length\n # puts resultsHash\nend", "def word_lengths(str)\n result = {}\n str.split.each {|word| result[word] = word.length}\n result\nend", "def hash_letter_freq( array )\n\n i = 0 # keeps track of outter loop\n hash = Hash.new()\n\n while( array.length > i )\n\n count = 1\n\n i2 = 1 + i # keeps track of inner while loop\n\n while( array.length > i2 ) # this will never check the last element of the array - otherwise have i2 check itself by doing i2 = i\n\n # puts(\"i #{i} | i2 #{i2}\") -- check if iteration is made right\n\n if( array[i] == array[i2] )\n count += 1\n end\n\n i2 += 1\n end # inner - while\n\n # alternative cond: hash.has_key?(\"#{array[i]}\") http://ruby-doc.org/core-1.9.3/Hash.html#method-i-has_key-3F\n if( hash[\"#{array[i]}\"] == nil ) # checks if key exists\n hash[\"#{array[i]}\"] = count\n end\n\n # for the last element in the array -- skipped by i2\n if( i2 == array.length )\n if( hash[\"#{array[i]}\"] == nil )\n hash[\"#{array[i]}\"] = 1\n end\n end\n\n\n i += 1\n end # while -outter\n\n # puts( hash )\n return hash\n\nend", "def word_sizes(words)\n count_hash = Hash.new(0)\n words.split.each do |word|\n count_hash[word.size] += 1\n end\n p count_hash\nend", "def word_sizes(str)\n arr = str.split(' ')\n hsh = Hash.new(0)\n \n arr.each {|word|\n hsh[word.delete('^A-Za-z').length] += 1\n }\n \n hsh\nend", "def word_lengths(sentence)\n words = sentence.split(\" \")\n lengths = {}\n\n words.each { |word| lengths[word] = word.length}\n\n return lengths\nend", "def word_sizes(input)\n\n occurrences = Hash.new(0)\n\n input.split.each do |element|\n occurrences[element.size] += 1\n end\n \n occurrences\nend", "def word_lengths(str)\n words = str.split(\" \")\n word_lengths = {}\n\n words.each do |word|\n word_lengths[word] = word.length\n end\n\n word_lengths\nend", "def words_of_length(length)\n @generated_word_lengths ||= [0]\n @words_by_length ||= {0 => ['']}\n\n while @generated_word_lengths[-1] < length \n last_length = @generated_word_lengths[-1] \n next_length = last_length + 1\n @words_by_length[next_length] = @words_by_length[last_length].collect{|word| next_words_for word }.flatten\n @generated_word_lengths << next_length\n end\n\n @words_by_length[length]\n end", "def word_sizes(str)\n str.gsub!(/[^A-Za-z0-9 ]/, '')\n hash = {}\n str = str.split(\" \")\n str.each_index {|i| str[i] = str[i].length}\n str.each {|v| hash[v] = str.count(v)}\n hash\nend", "def word_sizes(str)\n str.split.each_with_object({}) do |word, hsh|\n hsh[word.size] ||= 0\n hsh[word.size] += 1\n end\nend", "def letter_counter2(string)\n string.split.each_with_object({}) do | word, hash| # word (calling on array)\n if hash.has_key?(word.size) \n hash[word.size] += 1\n else\n hash[word.size] = 1\n end\n end\nend", "def word_sizes(words)\n count_hash = Hash.new(0)\n words.split.each do |word|\n clean_word = word.delete('^a-zA-Z')\n count_hash[clean_word.size] += 1\n end\n count_hash\nend", "def frequencies(chars)\n freq = Hash.new(0)\n chars.each do |char|\n freq[char] += 1\n end\n freq = freq.sort_by { |char, count| count } # order by highest frequency\n freq.reverse!\n freq = Hash[freq]\n return freq\nend", "def frequency(a)\r\n a.group_by do |e|\r\n e\r\n end.map do |key, values|\r\n [values.size]\r\n end\r\nend", "def word_sizes(input_string)\n counts = Hash.new(0) # => {}\n input_string.split.each do |word| # => [\"Four\", \"score\", \"and\", \"seven.\"]\n counts[word.size] += 1 # => 1, 1, 1, 1\n end # => [\"Four\", \"score\", \"and\", \"seven.\"]\n counts # => {4=>1, 5=>1, 3=>1, 6=>1}\n # input_string.split(' ').map { |word| word.chars.count } # => [4, 5, 3, 6]\nend", "def compare_array(sub_strings, dictionary)\n sub_strings.reduce(Hash.new(0)) do |hash, word|\n dictionary.each do |dict_word|\n if word == dict_word\n hash[dict_word] += 1\n end\n end\n hash\n end\nend", "def word_sizes(str)\n\n\tcounts = Hash.new(0)\n\n\tstr.split.each do |word|\n\tcounts[word.size] += 1\n\tend\t\n\tcounts\nend", "def word_sizes(string)\n hash = Hash.new(0)\n string.split.each do |word|\n hash[word.size] += 1\n end\n hash\nend", "def histogram(a_string)\n an_array = Array.new(a_string.length)\n ls_compact_string = a_string.delete(' ')\n an_array = ls_compact_string.downcase\n str_hash = Hash.new(0)\n for idx in 0..an_array.length\n item = an_array[idx]\n str_hash[item] += 1\n end\n return str_hash\nend", "def number_of_unique_words\n @frequencies.keys.length\n end", "def word_sizes(sentence)\n cleaned = sentence.gsub(/[^0-9a-z]/i, ' ')\n grouped = cleaned.split.group_by {|x| x.length }\n results = grouped.each {|x, i| grouped[x] = i.length}\n end", "def find_key_lengths string\n array = []\n string_array = string.split(\"\")\n guess = (3..8).to_a #if generalizing, 8 can be string_array.length\n guess.each do |x|\n matches = 0\n string_array.each.with_index do |y, i|\n if string_array[i] == string_array[i + x]\n matches += 1\n end\n end\n array.push(matches)\n end\n array.map.with_index{|x, i| i + 3 if x >= (array.max)}.compact\nend", "def string_frequency(string, hash)\n string.each_char do |char|\n hash[char]+=1\n end\n return hash\n end", "def substrings text,dictionary\n\ttext.downcase!\n\thash = {}\n\tdictionary.each do |word|\n\t\tcount = text.scan(word.downcase).length\n\t\thash[word] = count if count > 0\n\tend\n\thash\nend", "def letter_counts(word)\n hashed = word.chars.map {|char| [char, word.count(char)]}.flatten\n return Hash[*hashed]\nend", "def make_hash_with_count(passage)\n array_from_excerpt = strip_text(passage)#input from first question\n names_and_counts = Hash.new 0 #initializes at 0\n array_from_excerpt.each do |word|\n names_and_counts[word] += 1#for all subs. occurences, add 1\n end\n names_and_counts # must have the last line return the array!\nend", "def word_sizes(str)\n str = str.gsub(/[^a-zA-Z ]/,\"\")\n h1 = Hash.new(0)\n str.split.each do |element|\n h1[element.size] += 1\n end\n h1\nend", "def frequency\n # normal string which has assigned all the alphabets\n name = 'abcdefghijklmnopqrstuvwxyz'\n # this line will first split 'name' string and then assign it to hash\n @letters = name.split('').reduce(@letters){|alphabet,count| alphabet[count] +=0; alphabet}\n # this will convert all the alphabets of 'str' to lower case\n @str = @str.downcase\n # this will remove special characters from the string and only allow lower case alphabets\n @str = @str.gsub(/[^a-z]/, '')\n # this will split the 'str' and assign the letters to hash and add 1 each time the letter appeared\n @letters = @str.split('').reduce(@letters){|alphabet,count| alphabet[count] +=1; alphabet}\n\n end", "def key_sorter(hash)\n hash.keys.map(&:to_s).sort_by do |item|\n item.length\n end\nend", "def word_lengths(sentence)\n array = sentence.split.map { |ele| [ele, ele.length] }\n array.to_h\nend", "def word_sizes(sentence)\n hash = Hash.new(0)\n sentence.split.each do |word|\n hash[word.size] += 1\n end\n hash\nend", "def make_anagram a, b\n s1 = a.chars\n s2 = b.chars\n freq = Hash.new 0\n count = 0\n\n s1.each{ |key| freq[key]+=1 }\n\n s2.each{ |letter| freq[letter]-=1 }\n\n freq.each{ |k,v| count += v.abs }\n puts count\nend", "def word_sizes(string)\n word_count = Hash.new(0)\n\n string.split.each do |element|\n word_count[element.size] += 1\n end\n word_count\nend", "def word_sizes(sentence)\n hash = Hash.new(0)\n words = sentence.split(\" \")\n words.map! { |word| word.gsub(/[^a-zA-Z]/, ' ')}\n words.map! { |word| word.delete(\" \")}\n words.each { |word| hash[word.length] += 1 }\n hash\nend", "def char_count (arr, hash)\n arr.each_with_index do |k, i|\n hash[k] = 0\n end\n \n arr.each_with_index do |char, j|\n if hash.has_key?(char)\n hash[char] += 1\n end\n end\n\n return hash\nend", "def string_lengths input_array\n\n results = []\n input_array.each do |n| \n results.push(n.length)\n end\n results\nend", "def num_unique_words\n @frequencies.keys.length\n end", "def frequencies\n inject(Hash.new(0)) { |h,v| h[v] += 1; h }\n end", "def make_anagram word1, word2\n s1 = word1.chars\n s2 = word2.chars\n\n count = 0\n\n # s1.each do |x|\n # if s2.include? x\n # count +=1\n # end\n # end \n # ana = (word1.size - count)*2\n\n freq = Hash.new(0)\n s1.each do |key|\n freq.store(key, freq[key]+1)\n end\n freq\n\n s2.each do |x|\n if freq[x] != nil\n freq[x] -= 1\n end\n end\n\n freq\n\n freq.each do |key,value|\n if value != 0\n count += value.abs\n end\n end\n\n count\n\nend", "def word_lengths(sentence)\n hassh = Hash.new(0)\n sentence.split(\" \").each {|w| hassh[w] = w.length }\n return hassh\nend", "def letter_counts(word)\n hash = {}\n word.chars.uniq.each {|char| hash[char] = word.count(char)}\n hash\nend", "def word_sizes(string)\n\tword_count = {}\n\tstring.split.each do |word|\n\t\tword_s = word.size\n\t\tif word_count[word_s]\n\t\t\tword_count[word_s] += 1\n\t\telse\n\t\t\tword_count[word_s] = 1\n\t\tend\n\tend\n\tword_count\nend", "def counts\n @counts ||=\n begin\n h = {}\n by_label.each do |label, notes|\n h[label] = notes.size\n end\n h\n end\n end", "def count_letters(input_string)\n letter = input_string.scan /\\w/\n freq = Hash.new(0)\n\n # this will create a histogram count for each letter\n letter.each do |letter|\n freq[letter] += 1\n end\n\n\n\n # output letter and count\n freq.each do |letter, count|\n puts letter + \" \" + count.to_s\n end\n\nend", "def word_sizes(string)\n keys = string.split(\" \").map { |word| word.delete('^A-Za-z') }.map(&:size)\n values = keys.map { |n| keys.count(n) }\n Hash[keys.zip values]\nend", "def how_many(srt)\n arr = srt.split(\" \")\n count = {}\n\n #arr.map{ |s| \"#{s} #{arr.count s}\" }\n\n # arr.each do |s|\n # s.downcase!\n # count[s] = count.key?(s) ? count[s]+1 : 1\n # end\nend", "def string_lengths (foo)\n foo.map {|word| word.length }\nend", "def substrings(str, dictionary)\n frequencies = {}\n str.downcase!\n str_arr = str.split(' ')\n #iterate through each word in the dictionary to see if it is a substring of any word in the string.\n dictionary.each do |substring|\n str_arr.each do |word|\n if word.include?substring\n if frequencies.include?substring\n frequencies[substring] +=1\n else\n frequencies[substring] = 1\n end\n end\n end\n end\n frequencies\nend", "def word_sizes(txt)\n arr = txt.split\n hsh = {}\n arr.each do |e|\n hsh.has_key?(e.size) ? hsh[e.size] += 1 : hsh[e.size] = 1\n end\n hsh\nend", "def collect_words_of_length\n\t\[email protected]! { |el| el.length == @word_length + 1 }\n\t\tmake_smart_dictionary\n\tend", "def frequency\n counts = Hash.new(0)\n self.words.each { |word| counts[word] += 1 }\n counts\n end", "def word_sizes(str)\n counts = Hash.new(0)\n if str == \"\"\n return {}\n else\n str.gsub!(/[^0-9A-Za-z\\s]/, \"\").split.each do |word|\n counts[word.size] += 1\n end\nend\n counts\n\nend", "def word_sizes(str)\n word_counts = Hash.new(0)\n str.gsub(/[^a-zA-Z ]/, '').split.each { |word| word_counts[word.length] += 1 }\n word_counts\nend", "def word_sizes(sentence)\n sentence.split.each_with_object(Hash.new(0)) { |word, obj| obj[word.size] += 1 } \nend", "def word_sizes(str)\n hash = {}\n idx = 0\n\n loop do \n break if idx == (str.split.size)\n word = str.split[idx]\n hash[word.size] = 0 unless hash.keys.include?(word.size)\n hash[word.size] += 1\n idx += 1\n end\n\n hash\nend", "def substrings(string,dictionary)\n\tword_count = Hash[dictionary.map {|i| [i, 0]}]\n\twords = string.downcase.split(\" \")\n\n\twords.each do |word|\n\t\tword_count.each do |key,value|\n\t\t\tword_count[key] += 1 if word.include?(key)\n\t\tend\n\tend\n\n\tword_count.delete_if {|key, value| value == 0 }\n\tword_count\nend", "def string_lengths array_of_strings\n array_of_strings.map {|str| str.length}\nend" ]
[ "0.68282866", "0.6705068", "0.66054076", "0.65641004", "0.6474005", "0.64435613", "0.64107734", "0.6398544", "0.63863635", "0.638351", "0.63834137", "0.637002", "0.6347228", "0.63283277", "0.6306427", "0.6286599", "0.6224484", "0.62089884", "0.620613", "0.6183934", "0.61780286", "0.61667544", "0.6155042", "0.6139216", "0.61287206", "0.61132604", "0.6102501", "0.60944", "0.6093877", "0.6089313", "0.60853004", "0.60818994", "0.60748327", "0.60698277", "0.60695606", "0.6064666", "0.60641426", "0.60588145", "0.6051612", "0.605028", "0.6033549", "0.6018094", "0.60003525", "0.5992712", "0.5990778", "0.5963323", "0.5918509", "0.5917794", "0.59176314", "0.591734", "0.590062", "0.58717966", "0.58708245", "0.58631617", "0.5856127", "0.5855065", "0.5850968", "0.5833922", "0.5831341", "0.58288366", "0.58214074", "0.58121884", "0.58057976", "0.58000356", "0.57966995", "0.57919925", "0.5790886", "0.57885426", "0.5786902", "0.578334", "0.5780995", "0.57636344", "0.57545847", "0.5753728", "0.57452136", "0.5743759", "0.5740777", "0.5735924", "0.57295406", "0.5700307", "0.5689237", "0.5686337", "0.56805557", "0.5680246", "0.5675657", "0.5670645", "0.56679827", "0.5667168", "0.56608087", "0.56531405", "0.5644928", "0.56337667", "0.5622749", "0.56183463", "0.5615532", "0.56080306", "0.5589586", "0.5578882", "0.5568576", "0.55663073" ]
0.8085512
0
short_circuit_check is similar to counts_by_length but it does comparison as it builts the hash the comparison is stopped once the check result is clear
def short_circuit_check(counts) counts_by_length = {} counts.each do |key, value| l = key.length.to_s if counts_by_length.has_key?(l) if counts_by_length[l][0] != value return false else counts_by_length[l][1] += 1 end else counts_by_length[l] = [value, 1] end end complete?(counts_by_length) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complete?(counts_by_length)\n num_players = counts_by_length['1'][1]\n counts_by_length.each do |key, value|\n l = key.to_i\n if l > 1\n num_perms = 1\n l.times do |index|\n num_perms *= (num_players - index)\n end\n return false if num_perms != counts_by_length[key][1]\n end\n end\n true\nend", "def chkall\n (1..@@pow2_N).to_a.each do |i|\n h = sha32b(\"#{i}\")\n @allhash[h] = 0 if !@allhash[h]\n @allhash[h] += 1\n end\n @allhash.size\n end", "def build_failed_fast?\n if fail_fast.nil? || fail_fast.zero?\n return false\n end\n\n @redis.multi do\n @redis.hlen(key_failures)\n @redis.hlen(key_errors)\n end.inject(:+) >= fail_fast\n end", "def exactly?(arr, n, &blck)\n # n == arr.count { |el| blck.call(el) }\n counter = 0\n arr.each do |el|\n counter += 1 if blck.call(el)\n end\n return counter == n\nend", "def expected_count?\n return !!expected_count\n end", "def long_planeteer_calls(planeteer_calls)\nplaneteer_calls.any? { |string| string.length > 4 }\nend", "def check(hash)\n # not implemented\n end", "def triplet_true?(str)\n hash = Hash.new { |h, k| h[k] = 0 }\n str.chars { |char| hash[char] += 1 }\n hash.any? { |k, v| v > 2 }\nend", "def secure_compare(a, b)\n\tif a.length == b.length\n\t\tresult = 0\n\t\tfor i in 0..(a.length - 1)\n\t\t\tresult |= a[i] ^ b[i]\n\t\tend\n\t\tresult == 0\n\telse\n\t\tfalse\n\tend\nend", "def secure_compare(a, b)\n if a.length == b.length\n result = 0\n for i in 0..(a.length - 1)\n result |= a[i].ord ^ b[i].ord # #ord calls added for ruby1.9\n end\n result == 0\n else\n false\n end\n end", "def long_planeteer_calls(calls)\n res1 = calls.any? { |num| num.length>4} \n return res1\nend", "def valid_password_count(...) = valid_passwords(...).size", "def secure_compare(a, b); end", "def secure_compare(a, b); end", "def secure_compare(a, b); end", "def secure_compare(a, b)\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\nend", "def constant_time_comparison(mac_a, mac_b)\n result = mac_a.length ^ mac_b.length\n for i in 0..[mac_a.length, mac_b.length].min - 1\n result |= mac_a[i].ord ^ mac_b[i].ord\n end\n result.zero?\n end", "def isValid(s)\n hash = s.strip.chars.inject(Hash.new(0)) { |total, e| total[e] += 1 ;total}\n puts hash.to_s\n values = hash.values.sort\n if values.count(values[0]) == values.size or\n (values.count(values[0]) == values.size - 1 and values[-1] - values[-2] == 1) or \n (values.count(values[-1]) == values.size - 1 and values[0] == 1)\n \"YES\"\n else\n \"NO\"\n end\n\nend", "def secure_compare(a, b)\n return false if a.nil? || b.nil? || a.empty? || b.empty? || a.bytesize != b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end", "def isValid(s)\n freqs = Array.new 26,0\n s.split('').each do |char|\n freqs[char.ord - 'a'.ord] += 1\n end\n uniqueValues = Set.new freqs.select {|ele| ele != 0}\n uniqueValues = uniqueValues.to_a.sort\n return \"NO\" if uniqueValues.length > 2\n return \"YES\" if uniqueValues.length == 1 || (count(freqs, uniqueValues[0]) == 1 && (uniqueValues[1] - uniqueValues[0] == 1 || uniqueValues[0] == 1)) || (count(freqs, uniqueValues[1]) == 1 && (uniqueValues[1] - uniqueValues[0] == 1 || uniqueValues[1] == 1)) \n return \"NO\"\nend", "def long_planeteer_calls(calls_long)\n calls_long.any? do |word|\n word.length > 4\n # if word.length>4\n # return true\n # end\n end\n\n \nend", "def long_planeteer_calls(calls)# code an argument here\n # Your code here\n calls.any? {|x| x.chars.length>4}\nend", "def threshold?\n hash_size / 2 == buckets.compact.count / 2\n end", "def test_hash_long\r\n hash_calc = Minitest::Mock.new('test_hash_calculator')\r\n block_checker = Minitest::Mock.new('test_block_checker')\r\n block = '0|abc|1234>1234(4)|1213.34123|1234'\r\n output = \"Line 0: Invalid hash set to 12345\\nHash length is too big\"\r\n assert_equal output, @g.hash( block, '12345', hash_calc, block_checker, 0)\r\n end", "def \n \n long_planeteer_calls(planeteer_calls)\n \n puts \n p planeteer_calls \n puts\n \n planeteer_calls.any? { |any_string| any_string.length > 4 }\n # !! (<) !!\n # >__<\n \nend", "def check_length_and_if_exists highway_to_check\n cleaned_highway_to_check = check_highway_number(highway_to_check)\n length_is_ok = check_highway_number_length (cleaned_highway_to_check)\n\n if length_is_ok\n check_highway_exists (cleaned_highway_to_check)\n else\n return false\n end\n\n end", "def abundant?\n divisors.reduce(:+) > self\n end", "def long_planteer_calls(calls)\n calls.any? {|call| call.length > 4} # code from lecture\nend", "def test_truthy_count(tests, method, options = {})\n tests.each do |test|\n matches = Ramparts.send(method, test[:text], options)\n expect(matches)\n .to eq(test[:matches].length),\n \"Expected #{test[:matches].length}, got #{matches} for '#{test[:text]}'\"\n end\nend", "def long_planeteer_calls(array)\n array.each do |element|\n return true unless element.to_s.length <= 4\n end\n return false\nend", "def long_planeteer_calls(calls)\n # t_f = []\n # calls.each do |call|\n # t_f << call.include?(call.length > 4)\n # end\n # if t_f.include?(true)\n # true\n # else\n # false\n # end\n new_calls = calls.find do |call|\n (call.length > 4)\n end\n !!new_calls\nend", "def long_planeteer_calls(calls) \n calls.any? do |call|\n call.length > 4 \n end\nend", "def long_planeteer_calls(calls)\n calls.any? { |word| word.length > 4 }\nend", "def secure_compare(a, b)\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end", "def solution(*arr)\n return false if arr.empty?\n arr.join.chars.length != arr.join.chars.uniq.length\nend", "def my_count n = nil\n if block_given?\n truths = 0\n self.my_each {|o| truths += 1 if yield(o)}\n truths\n elsif n.nil?\n self.length\n else\n my_count {|x| x==n}\n end\n end", "def secure_compare(a, b)\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n\tputs l.class\n\n res = 0\n b.each_byte do |byte| \n\t k = l.shift\n\t res |= byte ^ k\n\t puts \"#{byte}-#{k}-#{res}\"\n\tend\n\tputs res\n res == 0\n end", "def at_least?(arr, n, &blck)\n count = 0\n arr.each do |el|\n count += 1 if blck.call(el)\n end\n count >= n\nend", "def magic?(arr)\n n = arr.size / 2\n (0...n).map { |i| (arr[i] + arr[i + 1 < n ? i + 1 : 0] + arr[n + i]) }.reduce { |s, memo| s == memo ? memo : false }\nend", "def how_long thing\n $lengthCache[thing] ||= $things[thing] && (1 + $things[thing].map{|t|how_long(t)}.inject(&:+)) || 0\nend", "def test_prev_hash_correct_true\n assert @bv.prev_hash_correct?(0, \"abcd\", \"abcd\")\n end", "def hash_two_sum?(arr, target)\n hash_count = {}\n\n arr.each { |el| hash_count[el] = true }\n\n hash_count.each_key do |key|\n return true unless hash_count[target - key].nil?\n end\n\n false\n \nend", "def secure_compare(other)\n return false unless self.bytesize == other.bytesize\n\n l = self.unpack \"C#{self.bytesize}\"\n\n res = 0\n other.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end", "def optimizable?\n super || !predicate.equal?(operation.predicate)\n end", "def check_permutation(str1, str2)\n return false if str1.length != str2.length\n return true if str1 == str2\n strHash = Hash.new(0)\n i = 0\n\n while i < str1.length\n strHash[str1[i]] += 1\n strHash[str2[i]] += 1\n i += 1\n end\n\n strHash.values.all? {|el| (el % 2) == 0}\nend", "def secure_compare(a, b)\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end", "def long_planeteer_calls(calls)\n calls.any? do |call|\n call.length > 4\n end\nend", "def exactly?(arr, n , &prc)\n count = 0\n arr.each do |ele|\n count += 1 if prc.call(ele)\n end\n return true if n == count\n false\nend", "def checksum?\n self.checksum == compute_checksum\n end", "def mutation?(string_1, string_2)\n \n string_2.each_char do |char|\n if string_1.count(char) < string_2.count(char)\n return false\n break\n else\n return true\n break\n end \n end \nend", "def valid?\n expected = {}\n\n count = 0\n self.each_unsafe do |k,v|\n return false if @data[k][2] != v\n count += 1\n end\n count == @data.count\n end", "def one_away?(str1, str2)\n if (str1.length - str2.length).between?(0,1)\n str1_index = 0\n str2_index = 0\n errors = 0\n\n count_errors = lambda do |str1, str2|\n if str1[str1_index] == str2[str2_index]\n str1_index += 1\n str2_index += 1\n else\n if errors.zero?\n errors += 1\n else\n return false\n end\n\n if str1.length > str2.length\n str1_index += 1\n elsif str2.length > str1.length\n str2_index += 1\n else\n str1_index += 1\n str2_index += 1\n end\n end\n end\n\n [str1.length, str2.length].max.times do |k|\n return false if !count_errors.call(str1, str2)\n end\n else\n false\n end\n\n return true\nend", "def secure_compare(value)\n a = self.secret\n b = value\n\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end", "def test_check_hash_unequal\r\n assert_equal false, @g.check_hash(1, 0)\r\n end", "def secure_compare(a, b)\n\t\treturn false if a.blank? || b.blank? || a.bytesize != b.bytesize\n\t\tl = a.unpack \"C#{a.bytesize}\"\n\n\t\tres = 0\n\t\tb.each_byte { |byte| res |= byte ^ l.shift }\n\t\tres == 0\n\tend", "def long_planeteer_calls(calls)\n calls.any? {|call| call.length > 4}\nend", "def run_length_encode\n elem = nil\n len = 0\n\n if block_given?\n each do |x|\n if elem == x\n len += 1\n else\n yield elem, len if len != 0\n elem = x\n len = 1\n end\n end\n yield elem, len if len != 0\n else\n enum_for :run_length_encode\n end\n end", "def check_consistency count\n raise \"Not implemented\"\n end", "def check_passwords_old(passwords, conditions)\n correct_passwords = []\n passwords.each_with_index do |password, i|\n range1 = conditions[i][0].to_i\n range2 = conditions[i][1].to_i\n letter = conditions[i][2]\n num = password.count(letter)\n correct_passwords << password if num.between?(range1, range2)\n end\n correct_passwords.size\nend", "def test_hash_match\n v = Verify.new\n return_code = v.verify_second_pipeset('as3', 'as3')\n assert_equal 0, return_code\n end", "def one_rv\n count = 0\n for x in [email protected]\n if @elements[x].remaining_vals.length == 1\n count+=1\n end\n end\n count\n end", "def test_block_count_correct_false\n assert_equal(false, @bv.block_count_correct?(1, [1,2,3,4]))\n end", "def secure_compare(a, b)\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end", "def step_through_with(s)i\n # It doesn't solve the kata because it returns true even if same chars are met in diffrent part of the word. Like \"ThaT\"\n s.chars.count == s.chars.uniq.count\nend", "def same_num_elements?(hash1, hash2)\n hash1.size == hash2.size\n end", "def long_planeteer_calls(calls)\n calls.each do |word|\n if word.length > 4\n return true\n else\n return false\n end\n end\nend", "def long_planeteer_calls(arr)\n arr.any? {|call|call.length > 4}\nend", "def conditions_met?\n puts nodes.map { |node| connected_to(node).length }.min\n puts nodes.length.to_f / 2\n nodes.map { |node| connected_to(node).length }.min >= (nodes.length.to_f / 2)\n end", "def armstrong? num\n n = num.length\n num.chars.inject(0) { |sum,d| sum + (d.to_i ** n) } == num.to_i\nend", "def secure_compare(a, b)\n return false unless a.bytesize == b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end", "def long_planeteer_calls(planeteer_calls)\n planeteer_calls.any? { |call| call.length > 4 }\nend", "def long_planeteer_calls(planeteer_calls)\n planeteer_calls.any? { |call| call.length > 4 }\nend", "def long_planeteer_calls(calls)\n\tcalls.any? {|item| item.length > 4}\nend", "def my_all?(&block)\n counter = 0\n my_each do |elem|\n counter += 1 if block.call(elem) == true\n end\n return true if counter == size\n\n false\n end", "def custom_comparisons_len()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.Run_custom_comparisons_len(@handle.ptr)\n result\n end", "def test_block_count_correct_true\n assert @bv.block_count_correct?(1, [1,2,3,4,5])\n end", "def have?(length)\n return length <= @buffer.bytesize \n end", "def test_num_check_fail\n assert_equal num_check([]), false # pass\n assert_equal num_check(['1']), false # pass\n assert_equal num_check(['1', '1']), false # pass\n assert_equal num_check(['k', 'k', 'k', 'k']), false # pass\n end", "def long_planeteer_calls(names)\n names.any? {|name| name.length > 4}\n \nend", "def long_planeteer_calls(arr)\n arr.any? { |word| word.length > 4} # <-- needed a space between \"{\" and pipe to pass test...???\nend", "def eql(input)\n return 0 if input.size == 1\n counter = 1\n while counter < input.size - 1\n outputl = 0\n outputr = 0\n counter2 = 0\n while counter2 < input.size\n if counter < counter2\n outputl += input[counter2]\n elsif counter > counter2\n outputr += input[counter2]\n end\n counter2 += 1\n end\n return counter if outputl == outputr\n counter += 1\n end\nend", "def test_prev_hash_correct_false\n assert_equal(false, @bv.prev_hash_correct?(0, \"abcd\", \"efgh\"))\n end", "def verify(buffer)\n if buffer[0..buffer.length-2].uniq.length == 1\n return buffer.last\n else\n puts buffer\n raise \"Error, validation of self-checks failed\"\n end\nend", "def check(n_val)\n res = ''\n\n tests.each do |sym, val|\n res += get_string(sym, n_val) if (n_val % val).zero?\n end\n\n res.empty? ? n_val.to_s : res\n end", "def long_planeteer_calls(calls) # code an argument here\n # Your code here\n calls.any? { |call| call.length > 4 }\nend", "def left_optimizable?\n !left.equal?(operation.left)\n end", "def partial_review_self_check_count\n check_count = 0\n self.sections.each do |s|\n next if !s.dot_rev_check?\n s.subsections.each do |ss|\n next if !ss.dot_rev_check?\n ss.checks.each { |c| check_count += 1 if c.bare_board_design_check? && c.is_self_check? }\n end\n end\n check_count\n end", "def long_planeteer_calls(array)\n return array.any?{|item| item.length > 4}\n # code an argument here\n # Your code here\nend", "def count_ok?\n\t\tcount <= 5\n\tend", "def array_equals(array1, array2)\n if array1.nil? && array2.nil?\n return true\n end\n\n if array1 == nil || array2 == nil\n return false\n end\n\n if array1.length != array2.length\n return false\n end\n\nmatching_elem = Hash.new\n\ni = 0\nwhile i < array1.length\n elem = array1[i]\n if matching_elem[elem]\n matching_elem[elem] += 1\n else\n matching_elem[elem] = 1\n end\n i += 1\nend\n\ni = 0\nwhile i < array2.length\n elem = array2[i]\n if matching_elem[elem]\n matching_elem[elem] -= 1\n elsif matching_elem[elem] && matching_elem[elem] < 0\n return false\n else\n return false\n end\n i += 1\nend\n\nreturn true\n# x = \"\"\n# same_count =\n# same_elements =\n# elements_match = 0\n# first_array_counter = 0\n# second_array_counter = 0\n#\n# array1.each_index do |i|\n# i += 1\n# first_array_counter += i\n# end\n# print first_array_counter\n#\n# array2.each_index do |i|\n# i += 1\n# second_array_counter += i\n# end\n# print second_array_counter\n#\n# # list_one = array1.size\n# # list_two = array2.size\n#\n# if first_array_counter == second_array_counter\n# same_count = true\n# elsif array1 == nil && array2 == nil\n# same_elements = true\n# elsif array1 == nil && array2 != nil\n# same_elements = false\n# elsif array2 == nil && array1 != nil\n# same_elements = false\n# else\n# same_count = false\n# end\n#\n# if same_count == true\n# first_array_counter.times do |i|\n# if array1[i] == array2[i]\n# elements_match += 1\n# end\n# end\n# end\n#\n# if elements_match == (first_array_counter) && elements_match == (second_array_counter)\n# same_elements = true\n# end\n#\n# if same_count == same_elements\n# x = true\n# else\n# x = false\n# end\n#\n# return x\nend", "def test_length\n pw1 = \"Test1\"\n pw2 = \"Test2test\"\n\n assert_equal(false, StringChecker.is_safe_pw?(pw1)) # to short, min 8 character inputs\n assert_equal(true, StringChecker.is_safe_pw?(pw2))\n end", "def check_person(person)\n count = 1 \n person.keys.each do |k|\n if !is_valid(k,person)\n count = 0 \n return count \n end \n end \n return count \nend", "def check_arguments(exp_num, args, cond=nil)\n cond = Proc.new{|n| !n.nil?} if cond.nil?\n return exp_num == args.select{|n| cond.call(n)}.size\n end", "def valid_anagram_counter(s, t)\n return false if s.length != t.length || s.empty? || t.empty?\n \n counter_arr = Array.new(256, 0)\n \n # can't check all of them together coz first string might have string that might add to the positive value\n for i in (0...s.length)\n counter_arr[s[i].ord] += 1\n counter_arr[t[i].ord] -= 1\n end\n \n counter_arr.each do |a|\n return false if a != 0\n end\n true\nend", "def safe_equals? a, b\n check = a.bytesize ^ b.bytesize\n a.bytes.zip(b.bytes) { |x, y| check |= x ^ y.to_i }\n check.zero?\n end", "def secure_compare(a, b)\n return false unless a.bytesize == b.bytesize\n\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end", "def shrink?\n hash_size / 4 == buckets.compact.count / 4\n end", "def abundant?(num)\nend", "def awesome(arr, target)\n hash = Hash.new(0)\n i = 0\n j = i + 1\n while i < arr.size\n hash[arr[i] + arr[j]] += 1 \n if j < arr.size\n j += 1\n else\n i += 1\n if j = i + 1 > arr.length\n j = i \n else\n j = i + 1\n \n end\n\n end\n \n end\n return true if hash[target] >= 1\n false\nend", "def secure_compare(a, b)\n return false unless a.bytesize == b.bytesize\n\n l = a.unpack(\"C*\")\n\n r, i = 0, -1\n b.each_byte { |v| r |= v ^ l[i+=1] }\n r == 0\n end" ]
[ "0.60192484", "0.5814405", "0.564393", "0.5636694", "0.5578881", "0.55409706", "0.5539765", "0.54885304", "0.5465793", "0.5460929", "0.54466486", "0.54205924", "0.5405991", "0.5405991", "0.5405991", "0.5374539", "0.5372885", "0.5371269", "0.53646654", "0.5350986", "0.5336949", "0.53258556", "0.5313917", "0.5303332", "0.53021795", "0.52967066", "0.52938116", "0.5278686", "0.5273616", "0.52634287", "0.5249442", "0.5245606", "0.52381027", "0.5236988", "0.5231773", "0.52177185", "0.5204147", "0.5202149", "0.5193998", "0.5193701", "0.5192248", "0.51829803", "0.5182101", "0.51793224", "0.51781744", "0.5176094", "0.51744574", "0.5169825", "0.51669496", "0.5159557", "0.51506656", "0.5146611", "0.51406896", "0.5131437", "0.51312995", "0.51278657", "0.51274353", "0.5123057", "0.51206595", "0.5118199", "0.5111989", "0.51031405", "0.50967216", "0.50963104", "0.50914407", "0.5076886", "0.50742775", "0.50656116", "0.5063809", "0.5054417", "0.50541466", "0.50541466", "0.5050537", "0.50499225", "0.50403154", "0.5034654", "0.50331056", "0.5032163", "0.50229895", "0.50180906", "0.5015919", "0.5014965", "0.50145686", "0.5006068", "0.5005235", "0.5003181", "0.50026315", "0.50024724", "0.499954", "0.4998149", "0.4995047", "0.4992802", "0.4990697", "0.49874157", "0.49871138", "0.4985551", "0.49844852", "0.49820265", "0.49813312", "0.49782592" ]
0.820483
0
check if counts_by_length is complete
def complete?(counts_by_length) num_players = counts_by_length['1'][1] counts_by_length.each do |key, value| l = key.to_i if l > 1 num_perms = 1 l.times do |index| num_perms *= (num_players - index) end return false if num_perms != counts_by_length[key][1] end end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def short_circuit_check(counts)\n counts_by_length = {}\n\n counts.each do |key, value|\n l = key.length.to_s\n if counts_by_length.has_key?(l)\n if counts_by_length[l][0] != value\n return false \n else\n counts_by_length[l][1] += 1\n end\n else\n counts_by_length[l] = [value, 1]\n end\n end\n complete?(counts_by_length)\nend", "def length; count end", "def is_full()\n if @q.count == @length\n true\n else\n false\n end\n end", "def complete?\n buff.length < @maxlen\n end", "def full\n count == @size\n end", "def full?\n return (@fill_count == size)\n end", "def full?\n self.count == self.max_space\n end", "def length() end", "def length() end", "def length() end", "def length() end", "def expected_length?(length)\n expected == length\n end", "def have?(length)\n return length <= @buffer.bytesize \n end", "def full?\n @counter.zero? || @counter.nil?\n end", "def length\n count = 0\n each { count += 1 }\n count\n end", "def size?() end", "def length\n count\n end", "def empty?\n total_count == 0\n end", "def empty?\n total_count == 0\n end", "def empty?\n count.zero?\n end", "def valid_length?(length)\n expected == length\n end", "def length; return @results.length; end", "def determine_length\n determine_length_support\n end", "def full?\n length && subscriber && length >= subscriber.max_events\n end", "def complete_result?\n @result_count < 1000\n end", "def verify_table_length(records)\n records.size == TestRecord.count\n end", "def empty?\n return @fill_count == 0\n end", "def query_len; @seq1.len; end", "def empty?\n count.zero?\n end", "def empty?\n count.zero?\n end", "def empty?\n count.zero?\n end", "def length(*) end", "def length(*) end", "def length\r\n self.count\r\n end", "def incomplete_count\n incomplete.count\n end", "def length; end", "def length; end", "def length; end", "def length; end", "def length; end", "def length; end", "def length; end", "def length\n @count\n end", "def full?\n return false if capacity.nil?\n capacity - mentor_terms_count <= 0\n end", "def counts_by_length(counts)\n counts_by_length = {}\n counts.each do |key, value|\n l = key.length.to_s\n if counts_by_length.has_key?(l)\n counts_by_length[l] << value\n else\n counts_by_length[l] = [value] \n end\n end\n counts_by_length\nend", "def length\n @items.count do |item|\n !item.nil?\n end\n end", "def complete?\n @bytes == [[0, @length - 1, true]]\n end", "def length\n each.count\n end", "def empty?\n length.zero?\n end", "def length\n count(:up)\n end", "def is_length(word)\n\t\tword.length == WORD_LENGTH\n\tend", "def empty?\n @count == 0\n end", "def empty?\n @count == 0\n end", "def empty?\n @count == 0\n end", "def empty?\n @count == 0\n end", "def long_planeteer_calls(calls)\n calls.any? { |word| word.length > 4 }\nend", "def length\n length = 0; each {length += 1}; length\n end", "def long_planeteer_calls(planeteer_calls)\nplaneteer_calls.any? { |string| string.length > 4 }\nend", "def query_len; seq1.len; end", "def length\n\n count_objects()\n end", "def capacity_full?\n (batches.sum(:capacity) <= events_candidates.count('batch_id is not null'))\n end", "def is_full()\n @queue.count { _1 } == @queue.size\n end", "def empty?\n count <= 0\n end", "def long_planeteer_calls(calls_long)\n calls_long.any? do |word|\n word.length > 4\n # if word.length>4\n # return true\n # end\n end\n\n \nend", "def length; @records.length; end", "def length\n len = 0\n @locations.each do |x|\n if x.sequence\n len += x.sequence.size\n else\n len += (x.to - x.from + 1)\n end\n end\n len\n end", "def length()\n #This is a stub, used for indexing\n end", "def length()\n #This is a stub, used for indexing\n end", "def check\n len = 0\n @sig_waveforms.each do |pair|\n values = pair[1]\n if len == 0\n len = values.length\n else\n return false if values.length != len\n end\n end\n return true\n end", "def empty?\n count == 0\n end", "def long_planeteer_calls(calls) \n calls.any? do |call|\n call.length > 4 \n end\nend", "def finished?\n #positions = {:a => 25, :b => 30}\n @position.each do |pl, pos|\n if pos >= @length\n return true\n else\n return false\n end\n end\n end", "def empty?\r\n @length == 0\r\n end", "def length=(_); end", "def check_full? \n \t\treturn true if @size==16 #size increase by 1 with every turn so when it reaches 16 we know that all cells are full\n\tend", "def empty?\r\n @length == 0\r\n end", "def empty?\r\n @length == 0\r\n end", "def empty?\r\n @length == 0\r\n end", "def empty?\r\n @length == 0\r\n end", "def expect_selector_length(length)\n if SurroGate::HAVE_EXT\n expect(map_rd.length).to eq(length)\n expect(map_wr.length).to eq(length)\n else\n expect(pairing.length).to eq(length)\n end\n end", "def long_planeteer_calls(words)\n words.any? { |word| word.length>4}\nend", "def length\n end", "def length\n end", "def length\n end", "def length\n end", "def length\n end", "def length\n end", "def all_empty?(words = [])\n # words.all? { |word| word == '' }\n # words.all?(&:empty?)\n # words.reduce(:+).gsub(' ', '').length.zero? => Omits spaces as ASCII characters\n # words.map(&:size).reduce(:+).zero? \n # words.all? { |word| word.empty? || word == ' ' }\n words.count(\"\") == words.length \nend", "def empty?\n @length == 0\n end", "def full?\n # return true if the value of the abolute value of the instance var @tail\n # is equal to the value of the instance var @size\n # otherwise return false\n @tail.abs == (@size)\n # end the full? method\n end", "def check_length_and_if_exists highway_to_check\n cleaned_highway_to_check = check_highway_number(highway_to_check)\n length_is_ok = check_highway_number_length (cleaned_highway_to_check)\n\n if length_is_ok\n check_highway_exists (cleaned_highway_to_check)\n else\n return false\n end\n\n end", "def count_incomplete\n return self.incomplete_tests.size\n end", "def complete?\n @cards.length == 5\n end", "def one_rv\n count = 0\n for x in [email protected]\n if @elements[x].remaining_vals.length == 1\n count+=1\n end\n end\n count\n end", "def message_length; complete_message.length; end", "def empty?\n count == 0\n end", "def empty?\n count == 0\n end", "def run_length_encode\n elem = nil\n len = 0\n\n if block_given?\n each do |x|\n if elem == x\n len += 1\n else\n yield elem, len if len != 0\n elem = x\n len = 1\n end\n end\n yield elem, len if len != 0\n else\n enum_for :run_length_encode\n end\n end", "def long_planeteer_calls(calls)\n\tcalls.any? {|item| item.length > 4}\nend", "def finished?\n @players.values.each do|num|\n if num.sum >=@length\n return true\n end\n end\n false\n\n end" ]
[ "0.7159641", "0.6795858", "0.6679854", "0.6658281", "0.66254085", "0.6604647", "0.64624006", "0.6386218", "0.6386218", "0.6386218", "0.6386218", "0.6374855", "0.6361468", "0.62993425", "0.6291191", "0.62612695", "0.6213323", "0.6195204", "0.6195204", "0.61934996", "0.61859185", "0.61847776", "0.6154909", "0.61462307", "0.6132875", "0.61286694", "0.61241525", "0.61007637", "0.606257", "0.606257", "0.606257", "0.6057282", "0.6057282", "0.6042837", "0.60335594", "0.6024806", "0.6024806", "0.6024806", "0.6024806", "0.6024806", "0.6024806", "0.6024806", "0.6024509", "0.60236317", "0.60085094", "0.60000974", "0.5994214", "0.5957567", "0.5944198", "0.5943221", "0.59177506", "0.59063506", "0.59063506", "0.59063506", "0.59063506", "0.58933055", "0.5888437", "0.58882624", "0.58865833", "0.5885542", "0.58855224", "0.58812666", "0.5881014", "0.5874288", "0.5870361", "0.5847306", "0.58326495", "0.5817853", "0.5799868", "0.5798131", "0.5792263", "0.5790058", "0.57875603", "0.57808006", "0.57784474", "0.577182", "0.577182", "0.577182", "0.577182", "0.57685935", "0.57685393", "0.57595116", "0.5756186", "0.5756186", "0.5756186", "0.5756186", "0.5756186", "0.5750456", "0.5747263", "0.57456404", "0.5742245", "0.57366896", "0.5734062", "0.5731081", "0.5724534", "0.5724393", "0.5724393", "0.57225454", "0.5720694", "0.571866" ]
0.7250031
0
Use callbacks to share common setup or constraints between actions.
def set_global_user @global_user = GlobalUser.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup\n #implement in subclass;\n end", "def after_set_callback; end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.53314966", "0.53114754", "0.52984965", "0.52977055", "0.5296272", "0.5260649", "0.5245076", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.5235081", "0.52321917", "0.5228592", "0.5220735", "0.52198535", "0.52139324", "0.5208539", "0.5206585", "0.5178542", "0.5175199", "0.5173538", "0.5167041", "0.51614195", "0.51577675", "0.5153909", "0.51528823", "0.5152225", "0.51429904", "0.5141399", "0.51345575", "0.51145", "0.5114052", "0.5114052", "0.5110216", "0.5108656", "0.50935394", "0.5089196", "0.5081936", "0.5079627", "0.50675833", "0.5056105", "0.5053687", "0.5050475", "0.5050475", "0.503471", "0.5028311", "0.501982", "0.50157547", "0.5013552", "0.50014806", "0.50011593", "0.49976763", "0.4990292", "0.4990292", "0.49882022", "0.4981269", "0.49792367", "0.49766538", "0.4967978", "0.49667212", "0.4958987", "0.49572337", "0.49550423", "0.4954479", "0.4952353", "0.494726", "0.4944055", "0.4935437", "0.4931248", "0.49283475", "0.49281213", "0.49268973", "0.4921738", "0.49204507", "0.4918924", "0.49182287", "0.4916538", "0.49158585", "0.49156788" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def global_user_params params.require(:global_user).permit(:manager, :manager_id, :user_dept, :dept_manager, :dispatch, :holiday_bird_caps, :master_user, :order_input, :pricing, :prospects, :rapid_order, :refusals, :short_term_trucks, :take_in, :temp_hire, :truck_monitoring, :hardware, :campaign_rep1, :campaign_rep2, :campaigns, :campaigns_admin, :cod, :cod_role, :campaign_role, :campaign_manager, :focus_items, :focus_items_rep1, :focus_items_rep2, :focus_items_role, :focus_items_manager, :retail_order_input, :retail_rapid_order, :retail_order_input_rep1, :retail_order_input_rep2, :retail_rapid_order_role, :complaints, :complaints_role, :complaints_dc) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def filtering_params\n params.permit(:email)\n end", "def active_code_params\n params[:active_code].permit\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def url_whitelist; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.6978086", "0.6780264", "0.6742658", "0.6738813", "0.67338693", "0.65908474", "0.6501793", "0.6495506", "0.64796513", "0.64755446", "0.6454826", "0.6437561", "0.6377127", "0.63722163", "0.6364058", "0.63178706", "0.62979764", "0.62968165", "0.62913024", "0.6289789", "0.6289145", "0.62875307", "0.6280997", "0.62420976", "0.62388235", "0.6216686", "0.62122375", "0.6208949", "0.619173", "0.6176307", "0.6173907", "0.6170346", "0.616111", "0.6150513", "0.6150023", "0.61446756", "0.6120429", "0.6112975", "0.6104845", "0.6102966", "0.6087884", "0.6079323", "0.60699135", "0.60602236", "0.60191786", "0.60170597", "0.60100305", "0.6009527", "0.60052776", "0.60052776", "0.600042", "0.5999317", "0.59933805", "0.5991528", "0.5991221", "0.5990094", "0.5979497", "0.5966058", "0.5958738", "0.59579456", "0.5957759", "0.5956938", "0.5951788", "0.59511644", "0.59423065", "0.59373474", "0.59361076", "0.59361076", "0.59331447", "0.5928005", "0.5924882", "0.5924011", "0.59169155", "0.5908037", "0.5907541", "0.59061426", "0.59056246", "0.5897408", "0.58960444", "0.58951247", "0.5893136", "0.5892312", "0.5890385", "0.58853275", "0.58801144", "0.58784765", "0.5872648", "0.58682626", "0.5867028", "0.58661693", "0.586578", "0.58643955", "0.5863193", "0.58609086", "0.5859997", "0.5858935", "0.5858632", "0.5853379", "0.5852741", "0.584806", "0.5847703" ]
0.0
-1
Overwriting the sign_out redirect path method
def after_sign_out_path_for(resource_or_scope) new_admin_session_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_sign_out_path_for(resource_or_scope)\n '/signed_out'\n end", "def after_sign_out_path_for(_resource_or_scope)\n '/'\n end", "def after_sign_out_path_for(resource_or_scope); end", "def signout_url\n {:controller => 'auth', :action => 'signout'}\n end", "def after_sign_out_path_for(resource_or_scope)\n '/users/sign_in'\n end", "def after_sign_out_path_for(resource_or_scope)\n \"/app/users/sign_in\"\n end", "def after_sign_out_path_for(resource_or_scope)\n Faraday.get(logout_path) if logout_path.present?\n super(resource_or_scope)\n end", "def after_sign_out_path_for(resource)\n '/'\n end", "def after_sign_out_path_for(user)\n '/'\n end", "def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end", "def sign_out_and_redirect(resource_or_scope); end", "def after_sign_out_path_for(resource_or_scope)\n # caught by apache to trigger pubcookie logout\n '/logout'\n end", "def after_sign_out_path_for(resource_or_scope)\n flash[:logout] = true\n root_path\n end", "def sign_out_and_redirect!(return_to = \"/\")\n sign_out_user\n redirect_to sign_out_url(return_to)\n end", "def after_sign_out_path_for(resource)\n \tnew_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n user_session_path\n end", "def after_sign_out_path_for(resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n '/'\n end", "def after_sign_out_path_for(resource_or_scope)\n '/'\n end", "def after_sign_out_path_for user\n reset_session\n\n # for hijacking\n # cookies.delete :secure_user_id\n\n new_user_session_path\n # root_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n # require 'pry'\n # binding.pry\n # Note: at this time: flash[:notice] => \"Signed out successfully.\"\n # current_user is nil.\n new_user_session_path # signIn page\n end", "def after_sign_out_path_for(resource_or_scope)\n # path before sign out request\n \"#{URI(request.referer).path}?logged_out=1\"\n end", "def destroy\n super\n after_sign_out_path_for(resource)\n end", "def sign_out\n\n # mark them as signed out.\n # (this is a helper method of devise, the rails ruby gem we're using for\n # authentication in the sample app.)\n # \n # \n #session_sign_out <---- NEED TO CHANGE TO CUSTOM USER SIGN OUT\n\n # send them back to the homepage.\n redirect_to root_path\n\n end", "def after_sign_out_path_for(resource_or_scope)\n if request.params[:type] == \"sso\"\n Rails.configuration.devise[:sign_out_redirect_url]\n else\n super\n end\n end", "def after_sign_out_path_for(resource_or_scope)\r\n '/'\r\n end", "def after_sign_out_path_for(resource_or_scope)\n sign_in_path\n end", "def after_sign_out_path_for(resource_or_scope)\n sign_in_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(_resource)\n root_path\n end", "def after_sign_out_path_for(_resource)\n root_path\n end", "def after_sign_out_path_for(_resource_or_scope)\n root_path\n # new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n cookies.delete :pa_auth_token\n \n \"#{Civiccommons::PeopleAggregator.URL}/logout.php?redirect=http://#{request.host}#{request.port == \"80\" ? nil : \":#{request.port}\"}\"\n end", "def after_sign_out_path_for(resource)\n #if current_user_signed_in?\n # redirect_to home_path \n # else\n redirect_to site_index_path \n #end \n end", "def after_sign_out_path_for(_resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource)\n\t\tnew_user_session_path\n\tend", "def after_sign_out_path_for(resource_or_scope)\n user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path \n end", "def sign_out\n logout\n end", "def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end", "def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end", "def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end", "def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end", "def after_sign_out_path_for(resource_or_scope)\n \tuser_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n \tlogin_path\n \tend", "def after_sign_out_path_for(resource_or_scope)\n login_url\n end", "def after_sign_out_path_for(resource_or_scope)\n home_path(:ref => \"logout\")\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n \tlogin_path\n end", "def after_sign_out_path_for(resource_or_scope)\n \t\t\troot_path\n \t\t end", "def after_sign_out_path_for(_resource)\n root_url\n end", "def after_sign_out_path_for resource_or_scope\n redirect_uri = params[:redirect_uri]\n redirect_uri ? redirect_uri : super\n end", "def after_sign_out_path_for(resource_or_scope)\n '/members/sign_in'\n end", "def signout\n self.oaw_signout\n redirect_to root_url\n end", "def after_sign_out_path_for(resource)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n login_path\n end", "def after_sign_out_path_for(resource_or_scope)\n # root_path\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\r\n login_path\r\n end", "def after_sign_out_path_for(_)\n root_url\n end", "def after_sign_out_path_for(resource)\r\n app_root + \"/sessions/new\"\r\n end", "def after_sign_out_path_for(resource)\n root_path\n end", "def after_sign_out_path_for(resource)\n root_path\n end", "def after_sign_out_path_for(resource)\n root_path\n end", "def signed_out_user\n redirect_to root_path unless !user_signed_in?\n end", "def after_sign_out_path_for(params)\n bienvenida_path\n end", "def destroy\n redirect_path = after_sign_out_path_for(\"user\")\n signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(\"user\"))\n set_flash_message :notice, :signed_out if signed_out && is_navigational_format?\n super\n end", "def after_sign_out_path_for(_resource)\n I18n.locale == I18n.default_locale ? '/' : \"/#{I18n.locale}\"\n end", "def after_sign_out_path_for(_resource_or_scope)\n home_path\n end", "def after_sign_out_path_for(resource_or_scope)\n \tnew_user_session_path\n end", "def after_sign_out_path_for(user)\n new_user_session_path\n end", "def after_sign_out_path_for(resource)\n home_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end", "def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end" ]
[ "0.8102037", "0.8007481", "0.7984188", "0.79324496", "0.7897868", "0.78892565", "0.7874593", "0.78685254", "0.7857867", "0.78436327", "0.78436327", "0.78436327", "0.78436327", "0.7842701", "0.7821579", "0.77880424", "0.7748489", "0.77373666", "0.7731692", "0.77291566", "0.77291566", "0.77291566", "0.77291566", "0.77291566", "0.77275157", "0.77275157", "0.77213097", "0.7716111", "0.77091455", "0.7708274", "0.7705286", "0.7694537", "0.769133", "0.76831216", "0.76831216", "0.7682263", "0.7682263", "0.76777554", "0.76777554", "0.766948", "0.76651865", "0.7643722", "0.7641334", "0.7640336", "0.7632876", "0.76290107", "0.7623703", "0.7622437", "0.7622437", "0.7622437", "0.7622437", "0.7620571", "0.76168233", "0.76150995", "0.7613417", "0.76068157", "0.7601874", "0.75970936", "0.75918543", "0.7589092", "0.7588269", "0.75851965", "0.7572588", "0.75579655", "0.75575614", "0.7550016", "0.75415194", "0.75405365", "0.7534009", "0.7534009", "0.7534009", "0.7527172", "0.7521995", "0.75215167", "0.75173414", "0.7514277", "0.7509254", "0.7504709", "0.74846214", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154", "0.74819154" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_flowdef @flowdef = Flowdef.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
note: this quickanddirty parsing leaves us with the data in y/x coordinates rather than x/y. Keep this in mind. :)
def tally_trees( slope ) pos = Coordinates.new( 0, 0 ) tally = 0 pos.x = ( pos.x + slope.x ) % @matrix[0].count pos.y = pos.y + slope.y while pos.y < @matrix.count do tally = tally + 1 if @matrix[pos.y][pos.x] == "\#" pos.x = ( pos.x + slope.x ) % @matrix[0].count pos.y = pos.y + slope.y end return tally end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def input_parse(input)\n list_coords = []\n height = 0\n xMin, xMax, yMin = [500, 0, 500]\n input.split(\"\\n\").each do |com_coords|\n if com_coords[0]=='x'\n x_raw, y_raw = com_coords.split(\",\")\n x = x_raw.delete(\"^0-9\").to_i\n xMin, xMax = [[xMin, x].min, [xMax, x].max]\n y_min, y_max = y_raw.delete(\" y=\").split('..').map{|i| i.to_i}\n height = [height, y_max].max\n (y_min..y_max).each do |y| \n list_coords.push({x: x, y: y})\n end\n else\n y_raw, x_raw = com_coords.split(\",\")\n y = y_raw.delete(\"^0-9\").to_i\n height = [height, y].max\n x_min, x_max = x_raw.delete(\" x=\").split('..').map{|i| i.to_i}\n xMin, xMax = [[xMin, x_min].min, [xMax, x_max].max]\n (x_min..x_max).each do |x| \n list_coords.push({x: x, y: y})\n end\n end\n end\n\n drawing = []\n height.times{|h| drawing.push(' '*((xMax - xMin)+3))}\n list_coords.each{|coords| drawing[coords[:y]-1][coords[:x] - xMin+1] = '#'} # draw clay\n drawing[0][500-xMin+1] = '|'\n drawing\nend", "def parse_coordinate_data(input_string)\n # extract substrings matching ( int , int ) into an array, ignoring whitespace\n coords_string = input_string.scan(@coords_regex)\n\n #if nothing matches then return an empty array\n if coords_string == nil\n return []\n end\n\n # remove the brackets, split the coordinate strings, convert to integers, leave as array of arrays\n coords_array = coords_string.map do |a|\n b = a.gsub(/[()]/, \"\")\n c = b.split(/,\\s*/)\n x, y = c.map { |x| x.to_i}\n end\n\n @logger.info coords_array\n\n # check here that the coordinates in the array don't exceed the grid dimensions ever\n coords_array.each do |a|\n if a[0] > @grid_dimensions[0] || a[0] < 0\n raise ArgumentError, \"x-coord exceeds grid size. Destination: #{a} in grid #{@grid_dimensions}\"\n end\n\n if a[1] > @grid_dimensions[1] || a[1] < 0\n raise ArgumentError, \"y-coord exceeds grid size. Destination: #{a} in grid #{@grid_dimensions}\"\n end\n end\n end", "def parse_points\n points = Array.new\n begin\n file = File.open(\"../data/data_points.txt\", \"r\") do |f|\n f.each do |line|\n arr = line.split(\",\")\n points.push(ChunkyPNG::Point.new(arr[0], arr[1]))\n end\n f.close\n File.delete(f)\n end\n rescue \n return nil\n end\n return points\n end", "def parse_string string\n self.coords = string.split(separator).map(&:to_f)\n end", "def parse\n start_x = 0\n start_y = 0\n\n @maze.each_with_index do |line, index|\n if line.include? 'S'\n start_y = line.index('S')\n start_x = index\n break\n end\n end\n [start_x, start_y]\n end", "def load_xy_file(filename)\n xy_data = Array.new\n File.open(filename, \"r\") do |xy_file|\n xy_file.each_line do |line|\n x, y = line.split(' ')\n xy_data << [ string_to_number(x), string_to_number(y) ] \n end\n end\n xy_data\n end", "def parse_point(point_data)\n point_data.gsub(/[^-\\d\\. ]/, '').split(' ').map(&:to_f)\n end", "def parse(data); end", "def separate_coordinates\n piece = @input[0..1]\n @row = input_to_row(piece[1])\n @col = input_to_col(piece[0])\n\n location = @input[2..3]\n @row_new = input_to_row(location[1])\n @col_new = input_to_col(location[0])\n end", "def load_xy_file(filename)\n xy_data = Array.new\n File.open(filename, \"r\") do |xy_file|\n xy_file.each_line do |line|\n x, y = line.split(' ')\n xy_data << [ string_to_number(x), string_to_number(y) ]\n end\n end\n xy_data\n end", "def parse_coord_args(x, y = 0)\n if x.is_a?(String)\n x, y = *Axlsx.name_to_indices(x)\n end\n if x.is_a?(Cell)\n x, y = *x.pos\n end\n if x.is_a?(Array)\n x, y = *x\n end\n [x, y]\n end", "def coordinates\n [@data[:szer_geogr].to_f, @data[:dl_geogr].to_f]\n end", "def xy() @records.get_data(GRT_XY); end", "def parse(rawdata)\n end", "def convert_user_coord(input)\n input.split\n end", "def text_coordinates\n return 28, 5, 152, 16\n end", "def coordinates\n raw_coords = multivalue_field('coordinates_ssim')\n coords = []\n raw_coords.each do |raw_coord|\n split_coord = raw_coord.split('|')\n coords << { :name => split_coord[0], :lat => split_coord[1], :lon => split_coord[2] }\n end\n coords\n end", "def decode(line)\n split = line.split(/[<>,]/)\n return {pos: [split[1].to_i, split[2].to_i], vel: [split[4].to_i, split[5].to_i]}\nend", "def parse_lat_long(raw)\n m = raw.match(/(\\d+)\\s+(\\d+\\.?\\d*)\\s*([NS])\\s+(\\d+)\\s+(\\d+\\.?\\d*)\\s*([WE])/i)\n if m.nil? || m.size != 5\n return nil\n else\n # Parse out degrees and minutes\n latitude = m[1].to_f + (m[2].to_f / 60.0)\n longitude = m[4].to_f + (m[5].to_f / 60.0)\n\n # Figure out negative vs positive\n latitude *= (m[3] =~ /N/i ? 1 : -1)\n longitude += (m[6] =~ /E/i ? 1 : -1)\n\n return [latitude, longitude]\n end\n end", "def coordinates(string)\n return nil if string.length != 2\n # interpret letter as column\n column = self.class::COLUMNS.index(string[0])\n row = self.class::ROWS.index(string[1])\n return nil if !column || !row\n [row, column]\n end", "def parse_raw_data\n data_slices.to_a\n end", "def viewbox_coords(viewbox) # :nodoc:\n return viewbox.text.split(' ').map do |coords|\n coords.split(',').map { |c| c.to_f }\n end\n\n end", "def parse(data)\n cmd = values = nil\n value = \"\"\n @subpath_initial_point = @last_point = nil\n @previous_control_point = @previous_quadratic_control_point = nil\n @calls = []\n\n data.each_char do |c|\n if c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z'\n values << value.to_f if value != \"\"\n run_path_command(cmd, values) if cmd\n cmd = c\n values = []\n value = \"\"\n elsif c >= '0' && c <= '9' || c == '.' || (c == \"-\" && value == \"\")\n unless cmd\n raise InvalidError, \"Numerical value specified before character command in SVG path data\"\n end\n value << c\n elsif c == ' ' || c == \"\\t\" || c == \"\\r\" || c == \"\\n\" || c == \",\"\n if value != \"\"\n values << value.to_f\n value = \"\"\n end\n elsif c == '-'\n values << value.to_f\n value = c\n else\n raise InvalidError, \"Invalid character '#{c}' in SVG path data\"\n end\n end\n \n values << value.to_f if value != \"\"\n run_path_command(cmd, values) if cmd\n \n @calls\n end", "def meshcode2coordinate(code)\n unless code.instance_of?(String)\n STDERR.puts \"E: argument must be String.\"\n return nil\n end\n latitude = 0.0\n longitude = 100.0\n case code.length\n when 4\n latitude, longitude = parse4(code, latitude, longitude)\n return {latitude: latitude, longitude: longitude, width: WIDTH4,\n height: HEIGHT4}\n when 6\n latitude, longitude = parse6(code, latitude, longitude)\n return {latitude: latitude, longitude: longitude, width: WIDTH6,\n height: HEIGHT6}\n when 8\n latitude, longitude = parse8(code, latitude, longitude)\n return {latitude: latitude, longitude: longitude, width: WIDTH8,\n height: HEIGHT8}\n when 9\n latitude, longitude = parse9(code, latitude, longitude)\n return {latitude: latitude, longitude: longitude, width: WIDTH9,\n height: HEIGHT9}\n when 10\n latitude, longitude = parse10(code, latitude, longitude)\n return {latitude: latitude, longitude: longitude, width: WIDTH10,\n height: HEIGHT10}\n when 11\n latitude, longitude = parse11(code, latitude, longitude)\n return {latitude: latitude, longitude: longitude, width: WIDTH11,\n height: HEIGHT11}\n else\n STDERR.puts \"E: invalid length of code: #{code.length}\"\n return {latitude: nil, longitude: nil, width: nil, height: nil}\n end\nend", "def coords; {:x => @x, :y => @y} end", "def coordinates\n [@data['latitude'].to_f, @data['longitude'].to_f]\n end", "def coordinates\n [@data['latitude'].to_f, @data['longitude'].to_f]\n end", "def parse_geom(lat, lon)\n @lat, @lon = lat.to_f, lon.to_f\n\n if defined? GeoRuby\n @geom = GeoRuby::SimpleFeatures::Point.from_x_y(@lon, @lat)\n else\n { lat: @lat, lon: @lon }\n end\n end", "def get_lots_coordinates\n xml = get_lots\n coords = xml.xpath '/ArrayOflot/lot/latitude | /ArrayOflot/lot/longitude'\n coords.each_slice(2).to_a.map { |p| [p[0].text, p[1].text] }\n end", "def convert_values\n @x_size = @x_size.to_i\n @y_size = @y_size.to_i\n @x_offset = @x_offset.to_i\n @y_offset = @y_offset.to_i\n @point = @point.to_s\n @blank_space = @blank_space.to_s\n end", "def parse(row)\n gid, name, @ascii, @alternates, lat, lon, feat, kind,\n @nation, _cc2, @region, @code, _adm3, _adm4, @pop, @ele,\n @gtop, @tz, @up = row.split(/\\t/)\n\n @name = name #name.encode(Encoding::ISO_8859_1)\n @gid = @geoname_id = gid.to_i\n @kind = human_code(kind)\n\n @abbr = @alternates.split(',').find { |n| n =~ /^[A-Z]{2,3}$/ }\n\n parse_geom(lat, lon)\n # puts \"#{@kind} - #{@code} - #{@region}\"\n end", "def s_coords(attrs)\n height = (attrs['HEIGHT'] || 0).to_i\n width = (attrs['WIDTH'] || 0).to_i\n hpos = (attrs['HPOS'] || 0).to_i\n vpos = (attrs['VPOS'] || 0).to_i\n [hpos, vpos, width, height]\n end", "def coordinates(image)\n image.each_with_index.flat_map do |row,x|\n (0...row.length).find_all{|i| row[i] == @char }.map{|y| [x,y] }\n end\n end", "def parse(line)\n line = line.gsub('(', '')\n line = line.gsub(')', '')\n tokens = line.split(',')\n\n start_row, start_col = tokens[1].split(':')\n end_row, end_col = tokens[2].split(':')\n\n {\n id: tokens[0],\n end_row: end_row.to_i,\n end_col: end_col.to_i,\n start_row: start_row.to_i,\n start_col: start_col.to_i\n }\n end", "def parse(row)\n gid, @name, @ascii, @alternates, lat, lon, feat, kind,\n @country, cc2, adm1, adm2, adm3, adm4, @pop, @ele,\n @gtop, @tz, @up = row.split(/\\t/)\n parse_geom(lat, lon)\n @gid = @geoname_id = gid.to_i\n @kind = human_code(kind)\n @province = adm1\n @code = adm2\n\n # puts \"#{@kind} - #{@code} - #{@province}\"\n end", "def parse_geom(lat, lon)\n @lat, @lon = lat.to_f, lon.to_f\n\n if defined?(\"GeoRuby\")\n @geom = GeoRuby::SimpleFeatures::Point.from_x_y(@lon, @lat)\n else\n { :lat => @lat, :lon => @lon }\n end\n end", "def get_coordinates(widget)\n x = widget[\"x\"]\n y = widget[\"y\"]\n return x, y\nend", "def clean_positions\n self.x_pos = self.x_pos.strip.to_i.to_s\n self.y_pos = self.y_pos.strip.to_i.to_s\n end", "def parse(data)\n\n # convert to utf-8\n data_utf8 = data.encode('UTF-8', :invalid => :replace, :replace => \"\")\n\n # split into nice rows\n rows = data_utf8.split(/\\r\\n?|\\n/)\n\n # to store units info\n units = {}\n\n # read values, store each doc in array\n docs = []\n\n rows.each do |row|\n doc = {}\n row.split(/\\s+|\\\\t+/).each_with_index do |value, index|\n if index < @@header.length\n name = @@header[index]\n if !value.nil? and !value.empty?\n # try to see if this can be a float\n begin\n value = Float(value.gsub(',', '.'))\n rescue ArgumentError\n end\n\n doc[name] = value\n end\n end\n end\n\n # point to our schema\n doc[\"schema\"] = \"http://api.npolar.no/schema/radiation-zeppelin-1.0-rc1\"\n\n docs << doc\n end\n\n docs\n end", "def coordinate_from_string(s)\n matches = coordinate?(s)\n if matches\n column, row = matches.captures\n return [column, row.to_i]\n else\n raise Xl::CellCoordinatesError, \"Invalid cell coordinates #{s}\"\n end\n end", "def geom_coords\n# self.geom.geometry_n(0).y.to_s + \" \" + self.geom.geometry_n(0).x.to_s\n \"\" + self.latitude.to_s + \" \" + self.longitude.to_s\n end", "def get_xdata\n\t\txData = []\n\t\[email protected]_line do |line|\n\t\t\txData << line.split(\" \")[0].to_f\n\t\tend\n\t\txData\n\tend", "def test_parsing_from_syntheyes_2dp\n fixture = File.open(File.dirname(__FILE__) + '/sy_subpix_2dpaths.txt')\n trackers = Tracksperanto::Import::Syntheyes.new(:io => fixture, :width => 720, :height => 576).to_a\n \n bl_kf = trackers[2][0]\n assert_in_delta 0.0, bl_kf.abs_x, DELTA\n assert_in_delta 0.0, bl_kf.abs_y, DELTA\n\n tr_kf = trackers[3][0]\n assert_in_delta 720.0, tr_kf.abs_x, DELTA\n assert_in_delta 576.0, tr_kf.abs_y, DELTA\n end", "def marshal_load(s)\n# Unpack coords from unmarshaled string\n@coords = s.unpack(\"w*\") # and use them to initialize the object\nend", "def parse(lines)\n lines.map do |line|\n line =~ /Sensor at x=(-?\\d+), y=(-?\\d+): closest beacon is at x=(-?\\d+), y=(-?\\d+)/\n sensor = Point.new(::Regexp.last_match(1).to_i, ::Regexp.last_match(2).to_i)\n beacon = Point.new(::Regexp.last_match(3).to_i, ::Regexp.last_match(4).to_i)\n [sensor, beacon, sensor.manhattan_distance(beacon)]\n end\n end", "def parse_claim(claim)\n cid, coords = claim.split('@')\n orig, size = coords.split(':')\n tx, ty = orig.strip.split(',')\n tdx, tdy = size.strip.split('x')\n x1 = tx.to_i\n y1 = ty.to_i\n x2 = x1 + tdx.to_i\n y2 = y1 + tdy.to_i\n [cid, x1...x2, y1...y2 ]\nend", "def test_lat_lon_xml_format\n tracepoint = build(:tracepoint, :latitude => 0.00004 * GeoRecord::SCALE, :longitude => 0.00008 * GeoRecord::SCALE)\n\n assert_match /lat=\"0.0000400\"/, tracepoint.to_xml_node.to_s\n assert_match /lon=\"0.0000800\"/, tracepoint.to_xml_node.to_s\n end", "def convert(data_array, format)\n formated_text_and_coordinates=[]\n for i in 0 ... format.items.size\n formated_text_current = format.items[i][2].clone\n for j in 0 ... data_array.size\n if formated_text_current =~ /__#{j}__/\n if ! data_array[j] then data_array[j]=\"\" end\n eval \"formated_text_current.gsub!(/__#{j}__/,data_array[j])\"\n end\n end\n formated_text_and_coordinates.push([format.items[i][0], format.items[i][1], formated_text_current])\n end\n return formated_text_and_coordinates\nend", "def convert(data_array, format)\n formated_text_and_coordinates=[]\n for i in 0 ... format.items.size\n formated_text_current = format.items[i][2].clone\n for j in 0 ... data_array.size\n if formated_text_current =~ /__#{j}__/\n if ! data_array[j] then data_array[j]=\"\" end\n eval \"formated_text_current.gsub!(/__#{j}__/,data_array[j])\"\n end\n end\n formated_text_and_coordinates.push([format.items[i][0], format.items[i][1], formated_text_current])\n end\n return formated_text_and_coordinates\nend", "def coordinates\n [@y_location, @x_location]\n end", "def extract_coordinates(parsed)\n parsed['results'].first['geometry']['location']\nend", "def convert_position!\n trx = self[:TrX]\n try = self[:TrY]\n\n self[:TrX] = 0\n self[:TrY] = 0\n self[:TrZ] = 0\n\n # To fix an issue with pto reading files ignoring attributes that have a =0\n trx = '0.0' if trx == 0.0\n try = '0.0' if try == 0.0\n\n self[:d] = trx\n self[:e] = try\n self\n end", "def latlon(line)\n # Extracting lat and lon from trkpt line \n # <trkpt lat=\"38.329948\" lon=\"-119.636582\"> # this shows format of the line with lat and lon\n line =~ /<trkpt lat=\\\"(\\-?[\\d\\.]+)\\\" lon=\\\"(\\-?[\\d\\.]+)\\\">/ # (\\-?[\\d\\.]+) gets the sign and the digits\n # lat = $1, lon = $2\n return alatlon=[$1,$2]\nend", "def text_coordinate\n return 39, 5, 222, 16\n end", "def point\n x = []\n y = []\n case geometry.type\n when 'MultiPolygon'\n coordinates.each { |list| append_list list, x, y }\n when 'LineString'\n append coordinates, x, y\n when 'Point'\n x << coordinates.first\n y << coordinates.last\n else\n append_list coordinates, x, y\n end\n lon = x.reduce(&:+) / x.size\n lat = y.reduce(&:+) / y.size\n [lon.round(7), lat.round(7)]\n end", "def parse_line(line, hash, max_xy)\n parts = line.split(' ')\n id = parts[0][1..-1]\n x,y = parts[2].sub(':', '').split(',')\n x = x.to_i\n y = y.to_i\n l,w = parts[3].split('x')\n l = l.to_i\n w = w.to_i\n \n x2 = x+l-1\n y2 = y+w-1\n \n hash[id] = {\n 'id' => id,\n 'overlap' => false,\n 'x' => x,\n 'y' => y,\n 'x2' => x2,\n 'y2' => y2,\n 'l' => l,\n 'w' => w\n }\n #puts \"#{line} id=#{id} x,y=#{x},#{y} #{l}x#{w} #{x2},#{y2} max #{max_xy['x']},#{max_xy['y']}\"\n max_xy['x'] = x2 if x2 > max_xy['x']\n max_xy['y'] = y2 if y2 > max_xy['y']\nend", "def coordinates(alt_format = false)\n coordinates_array = []\n if alt_format\n return ['-80.394617, 31.066399'] unless has_coordinates?\n dcterms_spatial.each do |el|\n coordinates_array << \"#{longitude(el)}, #{latitude(el)}\" if element_has_coordinates el\n end\n else\n return ['31.066399, -80.394617'] unless has_coordinates?\n dcterms_spatial.each do |el|\n coordinates_array << \"#{latitude(el)}, #{longitude(el)}\" if element_has_coordinates el\n end\n end\n coordinates_array\n end", "def parse_place\n s0 = @scanner.pos\n s1 = parse_num\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s2 = parse_numkan\n if s2 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'x' => s1, 'y' => s2 }\n end\n end\n if s0 == :failed\n s0 = @scanner.pos\n if match_regexp('同') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_str(' ')\n @reported_pos = s0\n s0 = { 'same' => true }\n end\n end\n s0\n end", "def svg_coord(row, col)\n\t\t[col*10 + 5, row*10 + 5]\n\tend", "def parse_coordinates(coordinates, format: :array, third_dim: ABSENT)\n return coordinates if format == :array\n\n key = THIRD_DIM_MAP[third_dim]\n\n coordinates.map do |c|\n if third_dim == ABSENT\n [c[:lat], c[:lng]]\n else\n [c[:lat], c[:lng], c[key]]\n end\n end\n end", "def get_data\n white_x = Shared::interpret_bytes_4(@data[0..3].unpack(\"C*\"))/100000.0\n white_y = Shared::interpret_bytes_4(@data[4..7].unpack(\"C*\"))/100000.0\n red_x = Shared::interpret_bytes_4(@data[8..11].unpack(\"C*\"))/100000.0\n red_y = Shared::interpret_bytes_4(@data[12..15].unpack(\"C*\"))/100000.0\n green_x = Shared::interpret_bytes_4(@data[16..19].unpack(\"C*\"))/100000.0\n green_y = Shared::interpret_bytes_4(@data[20..23].unpack(\"C*\"))/100000.0\n blue_x = Shared::interpret_bytes_4(@data[24..27].unpack(\"C*\"))/100000.0\n blue_y = Shared::interpret_bytes_4(@data[28..31].unpack(\"C*\"))/100000.0\n return [white_x, white_y,\n red_x, red_y,\n green_x, green_y,\n blue_x, blue_y]\n end", "def parse()\n #This is a stub, used for indexing\n end", "def xy_record() @records.get(GRT_XY); end", "def gps_data\n\t conversion_factor = 60.0\n\t lat_multiplier = 1.0\n\t long_multiplier = 1.0\n\n if (latitude.nil? or longitude.nil?)\n if file.queued_for_write[:original].nil?\n errors.add(:file, \" not selected\")\n return\n end\n \n # Extract meta data as a hash\n exif = EXIFR::JPEG.new(file.queued_for_write[:original].path).to_hash\n if not exif[:gps_longitude].nil? # GPS Data Exists\n \tnorth_degree = exif[:gps_latitude][0].to_f\n north_minute = exif[:gps_latitude][1].to_f\n \tnorth_second = exif[:gps_latitude][2].to_f\n \teast_degree = exif[:gps_longitude][0].to_f\n \teast_minute = exif[:gps_longitude][1].to_f\n \teast_second = exif[:gps_longitude][2].to_f\n \n # Correct references\n if exif[:gps_latitude_ref] == 'N'\n\t lat = lat_multiplier\n else\n lat = -lat_multiplier\n end\n \n if exif[:gps_longitude_ref] == 'E'\n lng = long_multiplier\n else \n lng = -long_multiplier\n end\n \n lat *= (north_degree + (north_minute + (north_second/conversion_factor))/conversion_factor)\n \t lng *= (east_degree + (east_minute + (east_second/conversion_factor))/conversion_factor)\n \n \t self.latitude = lat\n self.longitude = lng\n else\n errors.add(:base, \"GPS data not present in file\")\n end\n end\n end", "def on_text_node_cell_id_coords(attributes, buf, ctx)\n data_in = buf.strip.split(/[\\s=,]+/).map(&:to_i)\n data = []\n until data_in.empty?\n row, col, cell_id = data_in.shift(3)\n data << (row << 16) + col\n data << cell_id\n end\n @esf.put_u4_ary data\n end", "def assoc_coord_names(data)\n if s = data.get_att(\"coordinates\")\n nms = s.split(/ +/)\n case data.file\n when NArray\n fl = data.file[0]\n else\n fl = data.file\n end\n nms.delete_if{|nm| !fl.var(nm)}\n nms.delete_if{|nm| fl.dim_names.include?(nm)}\n nms\n else\n nil\n end\n end", "def meshcode2_coordinate(gps_info)\n grid_square_code = gps_info.to_s\n \n # calc from 1st grid square code\n lat = grid_square_code[0..1].to_f / 1.5; lon = grid_square_code[2..3].to_f + 100\n\n # calc from 2nd grid square code\n latcode = grid_square_code[4].to_f; loncode = grid_square_code[5].to_f\n lat += latcode * 5 / 60; lon += loncode * 7.5 / 60\n\n # calc from 3rd grid square code \n latcode = grid_square_code[6].to_f; loncode = grid_square_code[7].to_f\n lat += latcode * 0.5 / 60; lon += loncode * 0.75 / 60\n\n # calc from 4th grid square code \n num = grid_square_code[8].to_f - 1; latcode = (num / 2).to_i\n loncode = (num - latcode * 2).to_f; \n lat += latcode * 0.5 / 2 / 60; lon += loncode * 0.75 / 2 / 60\n\n # calc from 5th grid square code \n num = grid_square_code[9].to_f - 1\n latcode = (num / 2).to_i; loncode = (num - latcode * 2).to_f\n lat += latcode * 0.5 / 4 / 60; lon += loncode * 0.75 / 4 / 60\n\n # calc from 6th grid square code \n num = grid_square_code[10].to_f - 1\n latcode = (num / 2).to_i; loncode = (num - latcode * 2).to_f\n lat += latcode * 0.5 / 8 / 60; lon += loncode * 0.75 / 8 / 60\n\n mlat = 0.5 / 8; mlon = 0.75 / 8\n \n # left-down lat/ lon\n lat0 = lat; lon0 = lon\n # right-up lat/ lon\n lat1 = lat0 + mlat / 60; lon1 = lon0 + mlon / 60\n \n return lon0, lat0, lon1, lat1\n end", "def parse(file)\n line = file.gets\r\n if line == nil then return end\r\n counter = 0\r\n increase = 0\r\n \r\n # read 1st line, must be maze header, check if valid\r\n if line !~ /^maze:\\s([\\d]+)\\s([\\d]+):([\\d]+)\\s->\\s([\\d]+):([\\d]+)$/\r\n if $tag\r\n $invalid[increase] = \"invalid maze\"\r\n increase = increase + 1\r\n $tag = false\r\n end\r\n $invalid[increase] = line\r\n increase = increase + 1\r\n else\r\n $result[counter] = \"#{$1} #{$2} #{$3} #{$4} #{$5}\"\r\n counter = counter + 1\r\n end\r\n\r\n # read additional lines\r\n while line = file.gets do\r\n x_y = '(\\d),(\\d)'\r\n direc = '([u|d|l|r]*)'\r\n mass = '([0-9]*).([0-9]*)'\r\n mass_s = '([0-9]*).([0-9]*)'\r\n total = mass_s + ',' + mass_s + ',' + mass_s + ',' + mass_s\r\n sum = Regexp.new('^' + x_y + ':\\s' + direc + '\\s' + total + '$')\r\n \r\n # begins with \"path\", must be path specification\r\n if line =~ /^\"[^:\\s]+:\\([\\d]+,[\\d]+\\)/\r\n line_o = line.split(/\",\"/)\r\n \r\n i = 0\r\n while i < line_o.size\r\n if line_o[i] !~ /^\"/\r\n line_o[i] = \"\\\"#{line_o[i]}\"\r\n end\r\n \r\n if line_o[i] !~ /\"$/\r\n line_o[i] = \"#{line_o[i]}\\\"\"\r\n end\r\n i = i + 1\r\n end\r\n \r\n i = 0\r\n while i < line_o.size\r\n if line_o[i] =~ /^\"([^:\\s]+):\\(([\\d]+),([\\d]+)\\),(([udlr],)*[udlr])\"$/\r\n a = String.new(\"#{$1}\")\r\n b = String.new(\"#{$2}\")\r\n c = String.new(\"#{$3}\")\r\n d = String.new(\"#{$4}\")\r\n d.delete! \",\"\r\n \r\n j = 0\r\n while j < a.size\r\n if a[j] == 92 && a[j + 1] == 34\r\n a[j] = \"\"\r\n end\r\n j = j + 1\r\n end\r\n \r\n $result[counter] = \"path #{a} #{b} #{c} #{d}\"\r\n counter = counter + 1\r\n else\r\n if $tag\r\n $invalid[increase] = \"invalid maze\"\r\n increase = increase + 1\r\n $tag = false\r\n end\r\n $invalid[increase] = line\r\n increase = increase + 1\r\n i = line_o.size\r\n end\r\n i = i + 1\r\n \r\n end\r\n \r\n # otherwise must be cell specification (since maze spec must be valid)\r\n elsif line =~ /^([\\d]+),([\\d]+):\\s*$/\r\n $result[counter] = \"#{$1} #{$2}\"\r\n counter = counter + 1\r\n elsif line =~ /^([\\d]+),([\\d]+): ([udlr]) ([0-9]+).([0-9]+)$/\r\n $result[counter] = \"#{$1} #{$2} #{$3} #{$4}.#{$5}\"\r\n counter = counter + 1\r\n elsif line =~ /^([\\d]+),([\\d]+): ([udlr][udlr]) ([0-9]+).([0-9]+),([0-9]+).([0-9]+)$/\r\n $result[counter] = \"#{$1} #{$2} #{$3} #{$4}.#{$5} #{$6}.#{$7}\"\r\n counter = counter + 1\r\n elsif line =~ /^([\\d]+),([\\d]+): ([udlr][udlr][udlr]) ([0-9]+).([0-9]+),([0-9]+).([0-9]+),([0-9]+).([0-9]+)$/\r\n $result[counter] = \"#{$1} #{$2} #{$3} #{$4}.#{$5} #{$6}.#{$7} #{$8}.#{$9}\"\r\n counter = counter + 1\r\n elsif line =~ /^([\\d]+),([\\d]+): ([udlr][udlr][udlr][udlr]) ([0-9]+).([0-9]+),([0-9]+).([0-9]+),([0-9]+).([0-9]+),([0-9]+).([0-9]+)$/\r\n $result[counter] = \"#{$1} #{$2} #{$3} #{$4}.#{$5} #{$6}.#{$7} #{$8}.#{$9} #{$10}.#{$11}\"\r\n counter = counter + 1\r\n else\r\n if $tag\r\n $invalid[increase] = \"invalid maze\"\r\n increase = increase + 1\r\n $tag = false\r\n end\r\n $invalid[increase] = line\r\n increase = increase + 1\r\n end\n end\r\n \r\n if $tag\r\n $result.collect{|i| puts i}\r\n else\r\n $invalid.collect{|i| puts i}\r\n end\r\n end", "def read_points(points_file)\n points = []\n\n File.open \"../../samples/\" << points_file do |file|\n file.each_line do |line|\n coordinates = line.split(' ').map { |x| x.to_f }\n points << Geometry::Point.new(coordinates[0], coordinates[1])\n end\n end\n points\nend", "def getline_fromcoords(array)\n array.collect {|x,y| @tbls[:notformated][x][y].to_i}\n end", "def parse(ewkb)\r\n @factory.reset\r\n @unpack_structure=UnpackStructure::new(ewkb)\r\n @with_z = false\r\n @with_m = false\r\n parse_geometry\r\n @unpack_structure.done\r\n @srid=nil\r\n end", "def parse(text)\n\n # get lat, lon, gmt\n regex = /\\{(N|S)\\s*([0-9]*).\\s*([0-9]*)'\\}\\s*\\{(E|W)\\s*([0-9]*).\\s*([0-9]*)'\\}\\s*\\{GMT\\s*(.*)\\s*Hours\\}/\n match_data = text.match(regex)\n if match_data.nil?\n puts \"Can't find lat/lon/gmt\"\n return\n else\n\n @lat = match_data[2].to_f + (match_data[3].to_f)/60.0\n if match_data[1] == 'S'\n @lat = -@lat\n end\n\n @lon = match_data[5].to_f + (match_data[6].to_f)/60.0\n if match_data[4] == 'W'\n @lon = -@lon\n end\n\n @gmt = match_data[7]\n end\n\n # get elevation\n regex = /Elevation --\\s*(.*)m (above|below) sea level/\n match_data = text.match(regex)\n if match_data.nil?\n puts \"Can't find elevation\"\n return\n else\n @elevation = match_data[1].to_f\n if match_data[2] == 'below'\n @elevation = -@elevation\n end\n end\n\n\n\n\n\n\n\n # get heating and cooling degree days\n cdd10Regex = /-\\s*(.*) annual \\(standard\\) cooling degree-days \\(10.*C baseline\\)/\n match_data = text.match(cdd10Regex)\n if match_data.nil?\n puts \"Can't find CDD 10\"\n else\n @cdd10 = match_data[1].to_f\n end\n\n hdd10Regex = /-\\s*(.*) annual \\(standard\\) heating degree-days \\(10.*C baseline\\)/\n match_data = text.match(hdd10Regex)\n if match_data.nil?\n puts \"Can't find HDD 10\"\n else\n @hdd10 = match_data[1].to_f\n end\n\n cdd18Regex = /-\\s*(.*) annual \\(standard\\) cooling degree-days \\(18.3.*C baseline\\)/\n match_data = text.match(cdd18Regex)\n if match_data.nil?\n puts \"Can't find CDD 18\"\n else\n @cdd18 = match_data[1].to_f\n end\n \n hdd18Regex = /-\\s*(.*) annual \\(standard\\) heating degree-days \\(18.3.*C baseline\\)/\n match_data = text.match(hdd18Regex)\n if match_data.nil?\n puts \"Can't find HDD 18\"\n else\n @hdd18 = match_data[1].to_f\n end\n \n \n # Design Stat\tColdestMonth\tDB996\tDB990\tDP996\tHR_DP996\tDB_DP996\tDP990\tHR_DP990\tDB_DP990\tWS004c\tDB_WS004c\tWS010c\tDB_WS010c\tWS_DB996\tWD_DB996\t\n # \tUnits\t{}\t{�C}\t{�C}\t{�C}\t{}\t{�C}\t{�C}\t{}\t{�C}\t{m/s}\t{�C}\t{m/s}\t{�C}\t{m/s}\t{deg}\t\n # \tHeating\t12\t-7\t-4\t-13.9\t1.1\t-5\t-9.6\t1.7\t-2.9\t14.2\t5.9\t11.9\t6.8\t2.9\t100\n #use regex to get the temperatures\n regex = /\\s*Heating(\\s*\\d+.*)\\n/\n match_data = text.match(regex)\n if match_data.nil?\n puts \"Can't find heating design information\"\n else\n # first match is outdoor air temps\n \n heating_design_info_raw = match_data[1].strip.split(/\\s+/)\n\n # have to be 14 data points\n if heating_design_info_raw.size != 15\n puts \"Can't find cooling design info, found #{heating_design_info_raw.size}\"\n end\n\n # insert as numbers\n heating_design_info_raw.each do |value| \n @heating_design_info << value.to_f \n end\n #puts @heating_design_info\n end\n \n regex = /\\s*Cooling(\\s*\\d+.*)\\n/ \n match_data = text.match(regex)\n if match_data.nil?\n puts \"Can't find cooling design information\"\n else\n # first match is outdoor air temps\n \n design_info_raw = match_data[1].strip.split(/\\s+/)\n\n # have to be 14 data points\n if design_info_raw.size != 32\n puts \"Can't find cooling design info, found #{design_info_raw.size} \"\n end\n\n # insert as numbers\n design_info_raw.each do |value| \n @cooling_design_info << value \n end\n #puts @cooling_design_info\n end\n \n regex = /\\s*Extremes\\s*(.*)\\n/\n match_data = text.match(regex)\n if match_data.nil?\n puts \"Can't find extremes design information\"\n else\n # first match is outdoor air temps\n \n design_info_raw = match_data[1].strip.split(/\\s+/)\n\n # have to be 14 data points\n if design_info_raw.size != 16\n #puts \"Can't find extremes design info\"\n end\n\n # insert as numbers\n design_info_raw.each do |value| \n @extremes_design_info << value \n end\n #puts @extremes_design_info\n end\n \n \n\n\n #use regex to get the temperatures\n regex = /Daily Avg(.*)\\n/\n match_data = text.match(regex)\n if match_data.nil?\n puts \"Can't find outdoor air temps\"\n else\n # first match is outdoor air temps\n monthly_temps = match_data[1].strip.split(/\\s+/)\n\n # have to be 12 months\n if monthly_temps.size != 12\n puts \"Can't find outdoor air temps\"\n end\n\n # insert as numbers\n monthly_temps.each { |temp| @monthly_dry_bulb << temp.to_f }\n #puts \"#{@monthly_dry_bulb}\"\n end\n\n # now we are valid\n @valid = true\n end", "def parse_values; end", "def coordinates\n return 166, 72\n end", "def convert_position_to_array(position)\n\t\t@coordinate = position.chars\n\t\ttemp = @coordinate[0]\n\t\tx = @coordinate[1]\n\t\tx = (8 - position[1].to_i )\n\t\tconvert_y = { a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6 , h: 7 }\n\t\ty= convert_y.values_at(temp.to_sym)\n\t\t@coordinate[0]=x\n\t\t@coordinate[1]= y[0]\n\t\tposition_array = @coordinate\n\tend", "def name_text_coordinates\n return 8, 5, 98, 16\n end", "def to_array str\n array = []\n str.split().each do |i|\n entry = i.split(\",\")\n\n width = entry[0].to_i\n height = entry[1].to_i\n\n if entry.length == 2\n array << [width, height]\n else\n ALL_MACROS[entry[2]].call(width, height, array)\n end\n end\n\n array\nend", "def parse_doc_data\n begin\n raw_data = File.open(\"doc_data.txt\", \"r\").read\n ary_data = raw_data.split(/\\n/)\n\n parsed_info = []\n\n ary_data.each_with_index do |elem, i|\n next_elem = ary_data[i + 1]\n\n if (elem.match(/InfoKey/) && (next_elem.match(/InfoValue/)))\n parsed_info.push(elem.split(/\\:/, 2)[1].strip => next_elem.split(/\\:/, 2)[1].strip)\n else\n if (!elem.match(/InfoValue/))\n parsed_info.push(elem.split(/\\:/, 2)[0].strip => elem.split(/\\:/, 2)[1].strip)\n end\n end\n end\n rescue\n parsed_info = []\n @convert_errors.push(\"There is no generated 'doc_data.txt' file during converting file\")\n end\n\n return parsed_info\n end", "def parse; end", "def parse; end", "def parse; end", "def read filename\n # Open file, Read in and process data.\n file = File.open(filename)\n file.each do |line|\n # Comma seperated data.\n # E.g. 1,2,1 => x=1, y=2, output=1\n line = line.chomp\n if line.size > 0\n # If the line is not empty, then it has data\n line = line.split \",\"\n @x << line[0].to_i\n @y << line[1].to_i\n @output << line[2].to_i\n end\n end\n end", "def lvl_text_coordinates\n return 121, 5, 35, 16\n end", "def coordinates_for(x, y)\n build_request do |xml|\n xml.PixToLL {\n xml.PointCollection {\n xml.X x\n xml.Y y\n }\n set_map_state xml\n set_display_state xml\n authenticate xml\n }\n end\n \n remote_call(:map)\n \n coll = @response['PixToLLResponse']['LatLngCollection']\n \n {:latitude => coll['Lat'].to_i / 1000000.0, :longitude => coll['Lng'].to_i / 1000000.0}\n end", "def process_data(data)\n puts '=' * 100\n puts data.class\n hash = {}\n data.split('&').each do |kv|\n key, value = kv.split('=')\n hash[key] = value\n end\n puts hash\n puts hash['glass'].chars.each_slice(10).to_a.reverse.map(&:join).join(\"\\n\")\n puts '-' * 100\n puts empty = hash['glass'].index(' ')\n puts hash['glass'][hash['x'].to_i+1]\n if hash['y'].to_i == 17\n @result = 'drop'\n return\n end\n if hash['figure'] = 'I'\n if hash['x'].to_i == empty\n @result = 'drop'\n else\n @result = \"left=#{hash['x'].to_i-empty}\"\n end\n else\n if (hash['x'].to_i == empty) && (hash['glass'][hash['x'].to_i + 1] == ' ')\n @result = 'drop'\n else\n @result = \"left=#{hash['x'].to_i-empty}\"\n end\n end\n\n # @result = 'drop'\n end", "def parse(raw)\n frames = raw.split(/\\n/)\n @value = frames.map {|f| f.lstrip }.select {|f| f.length > 0 }\n end", "def map_data\n res = {}\n res[:timestamp] = timestamp\n res[:position] = [xtl, ytl, xbr, ybr]\n res\n end", "def coords\n coord_list = []\n (@x..(@x + @size_x - 1)).each do |i|\n (@y..(@y + @size_y - 1)).each do |j|\n coord = [i, j]\n coord_list << coord\n end\n end\n\n return coord_list\n end", "def parse_pair(code, value)\n case code\n when '10' then self.x = value.to_f\n when '20' then self.y = value.to_f\n when '70' then self.flag = value.to_f\n when '42' then self.bulge = value.to_f\n when '62' then self.color_code = value.to_i\n end\n end", "def parse(lines)\n \n # build character grid\n @grid = []\n lines.each do |line|\n @grid << []\n line.each_byte do |c|\n @grid.last << c.chr\n end\n end\n \n # get height and width in characters\n @width = @grid[0].length\n @height = @grid.length\n \n row = -1\n col = -1\n colspan = 1\n rowspan = 1\n row_y = -1\n @height.times do |y|\n @width.times do |x|\n if check_upperleft(x,y) # new cell\n if row_y == y # new column\n col += 1 + colspan - 1\n else # new row\n row += 1\n col = 0\n row_y = y\n end\n topside, rightside, leftside, bottomside = trace(x,y)\n colspan = [topside.count('+'), bottomside.count('+')].max - 1\n rowspan = [rightside.count('+'), leftside.count('+')].max - 1\n width = calc_width(col, colspan, topside.length, @width)\n content = scan_cell(x, y, topside.length, leftside.length)\n @cells << Cell.new(self, x, y, col, row, colspan, rowspan, width, content)\n end\n end\n end\n \n end", "def parse_NMEA(raw)\n\t\tdata = { :last_nmea => nil }\n\t\tif raw.nil?\n\t\t\treturn data\n\t\tend\n\t\traw.gsub!(/[\\n\\r]/, \"\")\n\n\t\tline = raw.split(\",\");\n\t\tif line.size < 1\n\t\t\treturn data\n\t\tend\n\t\t\n\t\t# Invalid sentence, does not begin with '$'\n\t\tif line[0][0, 1] != \"$\"\n\t\t\treturn data\n\t\tend\n\t\t\n\t\t# Parse sentence\n\t\ttype = line[0][3, 3]\n\t\tline.shift\n\n\t\tif type.nil?\n\t\t\treturn data\n\t\tend\n\t\t\n\t\tcase type\n\t\t\twhen \"GGA\"\n\t\t\t\tdata[:last_nmea] = type\n\t\t\t\tdata[:time]\t\t\t\t= line.shift\n\t\t\t\tdata[:latitude]\t\t\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:lat_ref]\t\t\t= line.shift\n\t\t\t\tdata[:longitude]\t\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:long_ref]\t\t\t= line.shift\n\t\t\t\tdata[:quality]\t\t\t= line.shift\n\t\t\t\tdata[:num_sat]\t\t\t= line.shift.to_i\n\t\t\t\tdata[:hdop]\t\t\t\t= line.shift\n\t\t\t\tdata[:altitude]\t\t\t= line.shift\n\t\t\t\tdata[:alt_unit]\t\t\t= line.shift\n\t\t\t\tdata[:height_geoid]\t\t= line.shift\n\t\t\t\tdata[:height_geoid_unit] = line.shift\n\t\t\t\tdata[:last_dgps]\t\t= line.shift\n\t\t\t\tdata[:dgps]\t\t\t\t= line.shift\n\t\n\t\t\twhen \"RMC\"\n\t\t\t\tdata[:last_nmea] = type\n\t\t\t\tdata[:time]\t\t\t= line.shift\n\t\t\t\tdata[:validity]\t\t= line.shift\n\t\t\t\tdata[:latitude]\t\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:lat_ref]\t\t= line.shift\n\t\t\t\tdata[:longitude]\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:long_ref]\t\t= line.shift\n\t\t\t\tdata[:speed]\t\t= line.shift\n\t\t\t\tdata[:course]\t\t= line.shift\n\t\t\t\tdata[:date]\t\t\t= line.shift\n\t\t\t\tdata[:variation]\t= line.shift\n\t\t\t\tdata[:var_direction] = line.shift\n\t\t\t\t\n\t\t\twhen \"GLL\"\n\t\t\t\tdata[:last_nmea] \t= type\n\t\t\t\tdata[:latitude]\t\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:lat_ref]\t\t= line.shift\n\t\t\t\tdata[:longitude]\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:long_ref]\t\t= line.shift\n\t\t \tdata[:time]\t\t\t\t= line.shift\n\t\t\t\t\n\t\t\twhen \"RMA\"\n\t\t\t\tdata[:last_nmea] = type\n\t\t\t\tline.shift # data status\n\t\t\t\tdata[:latitude]\t\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:lat_ref]\t\t= line.shift\n\t\t\t\tdata[:longitude]\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:long_ref]\t\t= line.shift\n\t\t \t\tline.shift # not used\n\t\t \t\tline.shift # not used\n\t\t\t\tdata[:speed]\t\t\t= line.shift\n\t\t\t\tdata[:course]\t\t\t= line.shift\n\t\t\t\tdata[:variation]\t= line.shift\n\t\t\t\tdata[:var_direction]\t= line.shift\n\t\t \t\n\t\t\twhen \"GSA\"\n\t\t\t\tdata[:last_nmea] = type\n\t\t\t\tdata[:mode]\t\t\t\t\t\t= line.shift\n\t\t\t\tdata[:mode_dimension]\t= line.shift\n\t\t \t\n\t\t \t# Satellite data\n\t\t \tdata[:satellites] ||= []\n\t\t \t12.times do |i|\n\t\t \t\tid = line.shift\n\t\t \t\t\n\t\t \t\t# No satallite ID, clear data for this index\n\t\t \t\tif id.empty?\n\t\t \t\t\tdata[:satellites][i] = {}\n\t\t \t\t\n\t\t \t\t# Add satallite ID\n\t\t \t\telse\n\t\t\t \t\tdata[:satellites][i] ||= {}\n\t\t\t \t\tdata[:satellites][i][:id] = id\n\t\t \t\tend\n\t\t \tend\n\t\t \t\n\t\t \tdata[:pdop]\t\t\t= line.shift\n\t\t \tdata[:hdop]\t\t\t= line.shift\n\t\t \tdata[:vdop]\t\t\t= line.shift\n\t\t \t\n\t\t\twhen \"GSV\"\n\t\t\t\tdata[:last_nmea] \t= type\n\t\t\t\tdata[:msg_count]\t= line.shift\n\t\t\t\tdata[:msg_num]\t\t= line.shift\n\t\t\t\tdata[:num_sat]\t\t= line.shift.to_i\n\t\t\t\t\n\t\t\t\t# Satellite data\n\t\t \t\tdata[:satellites] ||= []\n\t\t\t\t4.times do |i|\n\t\t \t\t\tdata[:satellites][i] ||= {}\n\t\t \t\t\n\t\t\t\t\tdata[:satellites][i][:elevation]\t= line.shift\n\t\t\t\t\tdata[:satellites][i][:azimuth]\t\t= line.shift\n\t\t\t\t\tdata[:satellites][i][:snr]\t\t\t= line.shift\n\t\t\t\tend\n\t\t \t\n\t\t when \"HDT\"\n\t\t\t\tdata[:last_nmea] = type\n\t\t\t\tdata[:heading]\t= line.shift\n\t\t\t\t\n\t\t\twhen \"ZDA\"\n\t\t\t\tdata[:last_nmea] = type\n\t\t\t\tdata[:time]\t= line.shift\n\t\t\t\t\n\t\t\t\tday\t\t= line.shift\n\t\t\t\tmonth\t= line.shift\n\t\t\t\tyear\t= line.shift\n\t\t\t\tif year.size > 2\n\t\t\t\t\tyear = year[2, 2]\n\t\t\t\tend\n\t\t\t\tdata[:date] = \"#{day}#{month}#{year}\"\n\t\t\t\t\n\t\t\t\tdata[:local_hour_offset]\t\t= line.shift\n\t\t\t\tdata[:local_minute_offset]\t= line.shift\n\t\tend\n\t\t\n\t\t# Remove empty data\n\t\tdata.each_pair do |key, value|\n\t\t\tif value.nil? || (value.is_a?(String) && value.empty?)\n\t\t\t\tdata.delete(key)\n\t\t\tend\n\t\tend\n\t\t\n\t\tdata\n\tend", "def parse_xml(file)\n @data_pts = Array.new\n doc = REXML::Document.new File.new(file)\n doc.elements.each('data/pt'){|pt|\n value = nil\n error = nil\n vars = Hash.new\n pt.attributes.each{|tag,val|\n\tif(tag == 'value')\n\t value = val.to_f\n\telsif(tag == 'error')\n\t error = val.to_f\n\telse\n\t vars[tag] = val.to_f\n\tend\t\n }\n @data_pts.push(DataPt.new(value,error,vars))\n }\n end", "def get_coords_from_node(node)\n\t\t[node.x,node.y]\n\tend", "def read_wire_points(str)\n points = []\n point_dists = {}\n x, y, len = 0, 0, 0\n\n str\n .split(',')\n .map { |s| m=s.match(/([LRUD])(\\d+)/); point(m[1], m[2].to_i) }\n .each do |dir, dist|\n while dist > 0\n case dir\n when \"L\" then x -= 1\n when \"R\" then x += 1\n when \"U\" then y -= 1\n when \"D\" then y += 1\n end\n dist -= 1\n len += 1\n p = point(x,y)\n points << p\n point_dists[p] = len\n end\n end\n\n Wire.new(points, point_dists)\nend", "def determine_coordinates\n coordinates = Hash.new()\n coordinates[:x] = @scaled_meta.domain_x.lower +\n calculated_dimension_delta(@scaled_meta.domain_x)\n coordinates[:y] = @scaled_meta.domain_y.lower +\n calculated_dimension_delta(@scaled_meta.domain_y)\n return coordinates\n end", "def parse_positions(line)\n positions = bracket_positions(line)\n positions.flatten\n end", "def coordinates(datum=:osgb36, options={})\n if matches = self.match(/(-?\\d+\\.\\d+)[^\\d\\-]+(-?\\d+\\.\\d+)/)\n lat,lng = matches[1,2]\n Osgb::Point.new(lat, lng, datum, options[:precision])\n else\n nil\n end\n end", "def to_xy\n a = self\n a = [a[0].x, a[0].y] if length == 1\n return *a\n end", "def read(y, x)\n cy, cx = Vedeu::Geometry::Position[y, x].as_indices\n\n row = fetch(cells, cy)\n cell = fetch(row, cx)\n\n cell\n end", "def parse(data)\n docs = []\n rows = CSV::parse(data)\n if rows.length > 4\n # TODO/FIXME: get Tor Ivan to make a proper csv header\n header = rows[1]\n\n rows[4, rows.length].each do |row|\n doc = Hash[header.zip(row)]\n\n doc.each do |key, val|\n\n # try for int, if that fails, go for float, else string\n begin\n doc[key] = Integer(val)\n rescue ArgumentError\n begin\n doc[key] = Float(val)\n rescue ArgumentError\n end\n end\n\n end\n\n # make the timestamp ours\n toks = doc.delete(\"TIMESTAMP\").split()\n doc[\"measured\"] = toks[0]+\"T\"+toks[1]+\"Z\"\n\n # generate the sha256 digest based on the measurement time and use it as\n # a namespaced UUID seed to prevent duplicate data from entering the database.\n seed = Digest::SHA256.hexdigest doc[\"measured\"]\n doc[\"id\"] = seed[0,8] + \"-\" + seed[8,4] + \"-\" + seed[12,4] + \"-\" + seed[16,4] + \"-\" + seed[20,12]\n\n # point to our schema\n doc[\"schema\"] = \"http://api.npolar.no/schema/weather-bouvet-1.0-rc1\"\n docs << doc\n end\n end\n\n docs\n end", "def parse_input (input_string)\n lines = input_string.split(/\\n/)\n\n state = :reading_map\n\n rover_x_start = 0\n rover_y_start = 0\n rover_facing_start = 0\n\n lines.each do |line|\n # drop empty lines\n next unless /(\\w)+/ =~ line\n\n case state\n when :reading_map\n match = /^\\s*(\\d+)\\s+(\\d+)\\s*$/.match(line)\n raise ArgumentError.new(\"Invalid map data >>#{line}<<\") unless match\n\n x_size = $1.to_i\n y_size = $2.to_i\n\n # the format is not the size, it's the greatest valid index\n init_map(x_size,y_size)\n\n state = :reading_rover_init\n\n when :reading_rover_init\n match = /^\\s*(\\d+)\\s+(\\d+)\\s+([NSWE])\\s*$/.match(line)\n # match = line.match /^\\s*(\\d+)\\s+(\\d+)\\s+([NSWE])\\s*$/\n raise ArgumentError.new(\"Invalid rover init >>#{line}<<\") unless match\n\n rover_x_start = $1.to_i\n rover_y_start = $2.to_i\n rover_facing_start = $3\n\n state = :reading_rover_instructions\n when :reading_rover_instructions\n match = /^\\s*([LRM]+)\\s*$/.match(line)\n raise ArgumentError.new(\"Invalid rover init >>#{line}<<\") unless match\n\n rover_instructions = $1\n\n add_rover(rover_x_start,rover_y_start,rover_facing_start,rover_instructions)\n\n state = :reading_rover_init\n end\n end\n\n end" ]
[ "0.6731602", "0.65340585", "0.6228304", "0.61461437", "0.61038715", "0.6054457", "0.59944683", "0.5959736", "0.5954485", "0.59362435", "0.58552074", "0.58502394", "0.5849467", "0.58485097", "0.58484674", "0.5834266", "0.58264166", "0.58180034", "0.5801265", "0.5786077", "0.5654467", "0.5635289", "0.5601455", "0.55736953", "0.5550213", "0.5540593", "0.5540593", "0.55366266", "0.55341744", "0.5518975", "0.5512307", "0.5511594", "0.5504701", "0.5489777", "0.5479512", "0.54676825", "0.5461189", "0.5453343", "0.54448825", "0.54378176", "0.54335225", "0.5406902", "0.54046756", "0.5400524", "0.54004824", "0.53970164", "0.53925467", "0.53888816", "0.5388852", "0.53876567", "0.5387621", "0.53794056", "0.5368199", "0.53629196", "0.5356865", "0.5351384", "0.5328783", "0.5328313", "0.5277066", "0.527604", "0.52714986", "0.5271361", "0.52705103", "0.5252994", "0.52504534", "0.5248903", "0.52435124", "0.52324766", "0.52153265", "0.52068675", "0.5205607", "0.5202687", "0.51931334", "0.5190054", "0.51851785", "0.51669234", "0.51640487", "0.51620966", "0.51613206", "0.51613206", "0.51613206", "0.5159538", "0.5153215", "0.51477796", "0.51368034", "0.5121692", "0.51181555", "0.5114876", "0.5108358", "0.51054287", "0.50997275", "0.50862473", "0.50852484", "0.508128", "0.5080528", "0.5079219", "0.5078517", "0.50779283", "0.5072238", "0.5067373", "0.5059888" ]
0.0
-1
Escape single quotes, remove newline, split on tabs, wrap each item in quotes, and join with commas
def prepare_for_insert(s) s.gsub(/'/,"\\\\'").chomp.split(/\t/).map {|str| "'#{str}'"}.join(", ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_csv\n map {|row|\n row.map {|f|\n f =~ /[[:punct:]]/ ? '\"' + f.gsub(/\"/, '\"\"') + '\"' : f }.\n join(\",\")}.\n join(\"\\n\")\n end", "def csv_multi_replacements\n [\n [/\\n\\n/ , \"\\n\"]\n ]\n end", "def escape_for_csv(str)\n str.include?(',') ? add_double_quotes(str) : str\nend", "def csv(array)\n nilfix = array.map { |s| blank(s) ? \"\" : s }\n quoted = nilfix.map { |s| '\"' + s.gsub('\"',\"'\") + '\"' }\n return quoted.join(',')\nend", "def output_values(raw)\n raw.map do |x|\n if x.is_a? Array\n x.map!{|s| escape(s)}\n x.join(@internal_delimiter)\n else\n escape(x)\n end\n end\n end", "def for_commas\n each_line! do |line| \n begin\n line.gsub! /,(\\S)/, ', \\1' unless line.match /.*\\\".*,.*\\\".*/ or line.match /','/\n rescue Exception => e\n puts e.message + \", ignored.\"\n end\n end\n end", "def csvize(value)\n [value].join(\",\")\nend", "def format_csv\n data.match(TIDE_REGEX)[1].gsub('<br>', \"\\n\").gsub(';', ',')\n end", "def csv_from_row(op, row)\n res = \"\"\n until row.empty?\n entry = row.shift.to_s\n if /[,\"]/ =~ entry\n entry = entry.gsub(/\"/, '\"\"')\n res << '\"' << entry << '\"'\n else\n res << entry\n end\n res << \",\" unless row.empty?\n end\n op << res << CRLF\nend", "def escape_for_csv(value)\n return nil if value.blank?\n text = value.to_s.gsub(text_delim, escape_text_delim).gsub(\"\\n\", '\\\\n')\n\n text = \"#{text_delim}#{text}#{text_delim}\" if(text.include?(csv_delimiter) && text.present?)\n text\n end", "def parse_line(delim , line)\n temp_array = Array.new #Array to hold data\n index = 0 #Position of array index\n token = \"\" #To hold the string\n grouping = false #Grouping characters flag\n\n #Parse line with delimeter\n line.each_char do |char|\n #Grouping Block \n if char == \"\\\"\" and !grouping\n token += char\n grouping = true\n elsif char == \"\\\"\" and grouping \n token += char\n grouping = false\n elsif char == delim and !grouping \n temp_array.push(clean(token)) \n token = \"\" \n else\n token += char\n end\n end \n \n #Store last token on line\n temp_array.push(clean(token))\n \n return temp_array\nend", "def csv(rows)\n rows.map { |r| r.join(';') }.join(\"\\n\")\n end", "def substitute_new_lines_and_commas(contents)\n\t\t\tcontents.gsub(/[,+\\n+]+/, \"|\")\n\t\tend", "def decommafy\n gsub(/(.+), (.+)/) { |s| \"#{$2} #{$1}\" }.strip.squeeze(' ')\n end", "def csv_replacements\n replacements = [\n [/\\r\\n/ , \"\\n\"]\n ]\n\n replacements\n end", "def internal_space_old(line)\n arr = []\n single_quote = line.count('\"')\n # This method won't work when there is two consecutive double quote\n # so we must replace them else they will get removed.\n line.gsub!('\"\"', '☠')\n line.split('\"').each_with_index do |item, i|\n # if odd number of double quote we are in a string else we are out\n # process only if out of a string\n item.gsub!(/ +/, ' ') if i.even?\n arr.push(item)\n end\n output = arr.join('\"')\n output.gsub!('☠', '\"\"')\n output += '\"' unless single_quote == output.count('\"')\n return output\n end", "def strip_csv_quotes(src_path, dest_path)\n\n require 'csv'\n open('LoginHistory-comma-delim.csv', 'w') do |f|\n first_line = true\n CSV.foreach('LoginHistory.csv') do |row|\n if first_line\n first_line = false\n else\n f.puts( row.join(',') )\n end\n \n end\n end\n\nend", "def do_comma s; a = mega_pop(s); String == a.class ? s[:output] << \"#{a}\" : s[:output] << \"#{a.chr}\" end", "def parse_smart_quotes; end", "def quote(*args)\n arr = args.map {|x| '\"' + x + '\"'}\n return arr.join(\" \")\nend", "def format_list(items)\n items.join('` or `')\n end", "def chopSeparator(oldLines)\r\n newLines = Array.new\r\n for line in oldLines\r\n line.chomp!\r\n line.delete!(\"'\")\r\n newLines.push(line)\r\n end\r\n newLines\r\nend", "def to_s\r\n clean!\r\n \r\n map do |name|\r\n name.include?(delimiter) ? \"\\\"#{name}\\\"\" : name\r\n end.join(delimiter.ends_with?(\" \") ? delimiter : \"#{delimiter} \")\r\n end", "def join_list(delim, list) { :'Fn::Join' => [ delim, list ] } end", "def prepare(text)\n de_quoted = text\n .gsub(/\\'(.*?)\\'/, \"\").gsub(/\\\"(.*?)\\\"/, \"\")\n de_quoted.scan(/[\\(\\)\\[\\]\\{\\}'\"]/)\nend", "def format_csv()\n require 'iconv'\n \n str = self.to_s\n \n str.gsub!(\",\", \"\")\n str.gsub!(10.chr, \" - \")\n str.gsub!(13.chr, \"\")\n str = Iconv.conv('ISO-8859-1', 'utf-8', str)\n \n return str\n end", "def quotelist( *args )\n\t\t\treturn args.flatten.collect {|part| part =~ /\\s/ ? part.inspect : part}\n\t\tend", "def sanitize_and_merge_order(*orders)\n orders = orders.reject(&:blank?).map do |order|\n order.strip!\n order = order.last == ',' ? order.chop : order\n end\n orders = orders.reject(&:blank?)\n orders.empty? ? nil : orders.join(\", \")\n end", "def to_s\n data.map { |ar| ar.map { |v| v.to_s.gsub(/\\t|\\n|\\r/,' ') }.join \"\\t\" }.join( $/ )\n end", "def requote(value) return restore_ends(value, '\"') end", "def replace_new_line_in_quote(content)\n stack = []\n\n rs = StringIO.new\n content.chars.each do |c|\n if c == '\"'\n if stack.empty?\n stack << c\n else\n stack.pop\n end\n end\n\n # TODO: parse as \\n\\r\n if (c =~ /[\\n\\r]/) and (!stack.empty?)\n rs << NEW_LINE_HOLDER\n else\n rs << c\n end\n end\n rs.string\nend", "def tidy(data)\n indent = 0\n data.split(/\\n/).map do |line|\n line.gsub!(/^\\s*/, '')\n next if line.empty?\n indent -= 1 if line =~ /^\\s*\\}\\s*$/\n line = (' ' * (indent * 2)) + line\n indent += 1 if line =~ /\\{\\s*$/\n line\n end.compact.join(\"\\n\") + \"\\n\"\n end", "def convert_to tokens\r\n join( tokens.map{|t| process(t.to_s) })\r\n end", "def format_multiline(text)\n Array.wrap(text).flat_map { |s| s.to_s.split(/ *[;\\n] */) }.compact_blank!\n end", "def unquote\n s = self.dup\n\n case self[0,1]\n when \"'\", '\"', '`'\n s[0] = ''\n end\n\n case self[-1,1]\n when \"'\", '\"', '`'\n s[-1] = ''\n end\n\n return s\n end", "def strip_quotes(term, separator: ', ')\n if term.is_a?(Array)\n terms = term.map { |t| strip_quotes(t, separator: separator) }\n html = terms.all?(&:html_safe?)\n html ? html_join(terms, separator) : terms.join(separator)\n elsif !term.is_a?(String)\n term.to_s\n elsif term.html_safe?\n quote = HTML_QUOTES.find { |q| term.start_with?(q) && term.end_with?(q) }\n quote ? term.delete_prefix(quote).delete_suffix(quote).html_safe : term\n else\n term = term.to_s.strip\n quote = QUOTE_MARKS.find { |q| term.start_with?(q) && term.end_with?(q) }\n quote ? term.delete_prefix(quote).delete_suffix(quote) : term\n end\n end", "def parse_csv_line(text_line)\n # Split the text_line by comma\n columns = text_line.split(\",\")\n # But some of the values are padded with spaces\n # And add the cleaned up values to the new array (called values)\n # strip --> predefined string function which trims spaces\n values = []\n columns.each {|x| values << x.strip}\n return values\n\nend", "def escape_text_delim\n return '\"' if text_delim == \"\\'\"\n \"\\'\"\n end", "def double_quotes_to_sections(text)\n text.to_s.gsub(/\"\" \"\"|\"\"\"\"/, '\"\"; \"\"')\n end", "def quoted_newlines\n @gapi.csv_options.allow_quoted_newlines\n end", "def quoted_newlines\n @gapi.csv_options.allow_quoted_newlines\n end", "def quote_array(value)\n \"(#{value.map { |entry| quote_value(entry) }.join(', ')})\"\n end", "def quote_transform(input)\n input.gsub(/\"/, '&quot;')\n end", "def tabify(item)\n item = item.split(\"\\n\") if item.kind_of? String\n item.map { |i| \" \" + i }.join(\"\\n\")\n end", "def compress_lines(spaced = true)\n split($/).map { |line| line.strip }.join(spaced ? ' ' : '')\n end", "def to_s\n value.map { |ar| ar.map { |v| v.to_s.gsub(/\\t|\\n|\\r/,' ') }.join \"\\t\" }.join($/)\n end", "def map_join(list, *opts, &block)\n options = opts.extract_options!\n if options[:nowrap]\n options[:surround] = [raw('<span style=\"white-space: nowrap;\">'), raw(''), raw('</span> ')]\n end\n separator = options[:separator] || opts[0] || raw(options[:surround] ? ',' : ', ')\n last_separator = options[:last_separator] || opts[1] || separator\n\n results = list.map &block\n case results.length\n when 0 then ''\n when 1 then results[0]\n else\n # Array#join doesn't support html_safe => concatenate with inject\n if options[:surround]\n s1,s2,s3 = options[:surround]\n s1 + results[0..-2].inject { |a,b| a.to_s + s2 + separator + s3 + s1 + b.to_s } +\n s2 + last_separator + s3 + results.last\n else\n results[0..-2].inject {|a,b| a.to_s + separator + b.to_s } + last_separator + results.last\n end\n end\n end", "def separate_out_strings(input)\n output = []\n current_quote_type = nil\n\n (0...input.length).each do |i|\n # Find the current character\n char = input[i]\n\n # Is the previous character a '\\'?\n is_escaped = i >= 1 && input[i - 1] == '\\\\'\n\n # Start / end +Lib::String+s\n unless is_escaped\n if current_quote_type.nil? && ['\"', \"'\"].include?(char)\n current_quote_type = char\n output.push Lib::String.new\n next\n elsif current_quote_type == char\n current_quote_type = nil\n next\n end\n end\n\n # Add current +char+ to +output+\n if output.empty?\n output.push char\n elsif output.last.is_a?(Lib::String) && current_quote_type.nil?\n output.push char\n else\n output.last.concat char\n end\n end\n\n output\n end", "def quote(item)\n \"\\\"#{item}\\\"\"\n end", "def tokenize_quot(txt)\n self.tokenize_quoted ||= txt.split(Awesome::Definitions::Stopwords::QUOTED_REGEX)\n end", "def space_around_comma!\n substitute!(/[[:space:]]*,[[:space:]]*/, ',\n ')\n end", "def bracketed_list(values)\n temp=\"\"\n temp += \"[\"\n values.each {|val| temp += \"#{val.to_s}, \"}\n temp += \"]\"\n return temp\nend", "def compress_lines(spaced = true)\n split($/).map { |line| line.strip }.join(spaced ? ' ' : '')\n end", "def shellsplit(line)\n words = []\n field = ''\n line.scan(/\\G\\s*(?>([^\\s\\\\\\'\\\"]+)|'([^\\']*)'|\"((?:[^\\\"\\\\]|\\\\.)*)\"|(\\\\.?)|(\\S))(\\s|\\z)?/) do\n |word, sq, dq, esc, garbage, sep|\n raise ArgumentError, \"Unmatched double quote: #{line.inspect}\" if garbage\n field << (word || sq || (dq || esc))\n if sep\n words << field\n field = ''\n end\n end\n words\n end", "def from_sql_array\n retval = Array.new\n quotes = false\n\n # Chop off the leading and trailing braces...\n str = self[1..-2]\n j = 0\n\n # Scan through the characters, looking for quotes and grabbing Array\n # elements when we find them.\n str.split(//).each_with_index do |c, i|\n if c == '\"' && (i == 0 || str[i - 1].chr != '\\\\')\n quotes = !quotes\n elsif c == ',' && !quotes\n retval << str[j, i - j]\n j = i + 1\n end\n end\n\n # Plop on the rest of the string that wasn't accounted for above.\n retval << str[j..-1]\n\n # Get rid of escapes on quotes and backslashes.\n retval.each_with_index do |v, i|\n retval[i] = v.gsub(/^\\\"(.*)\\\"$/, '\\1').gsub(/\\\\\\\"/, '\"').gsub(/\\\\\\\\/, '\\\\')\n end\n end", "def format_csv_para_text(text)\n return text unless text.is_a?(String) && !text.blank?\n\n # We convert to Markdown since there is a gem to do it and it's much more\n # readable. Conversion also strips unknown tags.\n text = ReverseMarkdown.convert(text, unknown_tags: :drop)\n\n # Excel seems to like \\r\\n, so replace all plain \\ns with \\r\\n in all string-type cells.\n # Also ReverseMarkdown adds extra whitespace -- trim it.\n text = text.split(/\\r?\\n/).map(&:strip).join(\"\\r\\n\")\n\n # Also remove html entities.\n text.gsub(/&(?:[a-z\\d]+|#\\d+|#x[a-f\\d]+);/i, \"\")\n end", "def create_arr_strs(csv)\n\tarr_of_strings = csv.read.split(\"\\r\")\n\tarr_of_strings\nend", "def convert_string(item)\n escape(item).\n\n # convert ... to elipsis (and make sure .... becomes .<elipsis>)\n gsub(/\\.\\.\\.\\./, '.\\ldots{}').gsub(/\\.\\.\\./, '\\ldots{}').\n\n # convert single closing quote\n gsub(%r{([^ \\t\\r\\n\\[\\{\\(])\\'}, '\\1\\'').\n gsub(%r{\\'(?=\\W|s\\b)}, \"'\" ).\n\n # convert single opening quote\n gsub(/'/, '`').\n\n # convert double closing quote\n gsub(%r{([^ \\t\\r\\n\\[\\{\\(])\\\"(?=\\W)}, \"\\\\1''\").\n\n # convert double opening quote\n gsub(/\"/, \"``\").\n\n # convert copyright\n gsub(/\\(c\\)/, '\\copyright{}')\n\n end", "def frankenstring(strings)\n result = \"\"\n strings.each do |string|\n result += \"#{string},\"\n end\n result.chop\nend", "def tokenize_quoted_string(&block) # :yields: SQLTree::Token::String\n string = ''\n until next_char.nil? || current_char == \"'\"\n string << (current_char == \"\\\\\" ? next_char : current_char)\n end\n handle_token(SQLTree::Token::String.new(string), &block)\n end", "def to_csv\n str = ''\n str << ( columns.join(\",\") + \"\\n\" )\n rows.each { |row|\n next if is_hr(row) || !row_visible(row)\n str << ( row.map{|x|\n x = x.to_s\n x.gsub(/[\\r\\n]/, ' ').gsub(/\\s+/, ' ').gsub('\"', '\"\"')\n }.map{|x| \"\\\"#{x}\\\"\" }.join(\",\") + \"\\n\" )\n }\n str\n end", "def format_sexp(args)\n args.map{|x| format_object(x, \" \", \"'\")}.join(' ')\n end", "def getCsvText\r\n sep = \"|\"\r\n t = \"\"\r\n \r\n t << \"Question Number\" + sep \r\n questions.size.times do |i| \r\n t << (i + 1).to_s + sep \r\n end\r\n t << \"Points\"\r\n t << \"\\n\"\r\n \r\n t << \"Correct Answer\" + sep\r\n for question in questions \r\n t << correctAnswerText(question).to_s + sep \r\n end \r\n t << \"\\n\"\r\n \r\n for user in users \r\n t << user.getName + sep\r\n for question in questions \r\n t << answerText(user, question) + sep\r\n end \r\n t << getPoints(user).to_s\r\n t << \"\\n\" \r\n end\r\n return t \r\nend", "def fill_line(str)\n str = str.chop + ',\"\",\"\"'\nend", "def transpile\n template.lines.map { |line| Line.new(line).to_text }.join\n end", "def quote( val )\n\t\treturn %q{\"%s\"} % [ val.to_s.gsub(/\"/, '\\\\\"') ]\n\tend", "def csv_to_js \n csv.gsub('\"', '\\\\\"').gsub(\"\\r\\n\", '\\\\n').strip\n end", "def notes_to_char_string_csv\n notes_to_char_string_array.join(',')\n end", "def unquote\n\t\teach { |e| Concatenative::System.process e }\n\tend", "def remove_delim(row)\n\n\trow.each do |f|\n\t\tf.gsub!(/@regex_delim|\\r\\n|\\r|\\n|\\\\/,'') if f\n\tend\n\trow\nend", "def quotes\n body.scan(/^> /).collect { |q| q.sub(/^(> *)*/, '') }\n end", "def convert\n @text\n .split(\"\\n\\n\")\n .map { |line| decode_digits(parse_line(line)) }\n .join(',')\n end", "def email_quote(text, level=1)\n width = EMAIL_WRAP_WIDTH - level - 1\n\n lines = word_wrap(text, line_width: width).split(\"\\n\")\n lines.map!(&:lstrip)\n lines.map! { |line| '>'*level + ' ' + line }\n lines.join(\"\\n\")\n end", "def arrayify(str)\n str.split(\"\\n\")\n end", "def to_s\n [line1, line2, \"#{city}, #{state} #{zip}\"].compact.join(\", \")\n end", "def html2csv(data)\r\n dbg= data.gsub! \"\\n\", \"\"\r\n dbg= data.gsub! \"\\xA0\", \" \"\r\n dbg= data.gsub! \"\\r\", \"\"\r\n dbg = data.gsub! /<br>/, \"\\n\"\r\n dbg = data.gsub! /<\\/p>/, \"\\n\"\r\n dbg = data.gsub! /<\\/div>/, \"\\n\"\r\n dbg = data.gsub! /<ul[^>]*>/, \"\\n\"\r\n dbg = data.gsub! /<li[^>]*>/, \"\\x95 \"\r\n dbg = data.gsub! /<\\/li>/, \"\\n\"\r\n dbg = data.gsub! /<\\/?\\??\\w+[^>]*>/, \"\"\r\n dbg = data.gsub! /[ ]{2,}/, \" \"\r\n dbg = data.gsub! /(\\s?\\n\\s?){2,}/, \"\\n\"\r\n dbg = data.strip!\r\n return data\r\n end", "def workaround_quotations(text)\n if single_quote?(text) && !double_quote?(text)\n double_quoted(text)\n elsif double_quote?(text) && !single_quote?(text)\n single_quoted(text)\n elsif single_quote?(text) && double_quote?(text)\n single_quoted(text.tr(\"'\", \"\\u2019\"))\n else\n single_quoted(text)\n end\n end", "def to_s\n\t\t\t# out = \"\"\n\t\t\t\n\t\t\t# self.each do |i|\n\t\t\t# \tout << i.to_s\n\t\t\t# \tout << ','\n\t\t\t# end\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t# self.each do |i|\n\t\t\t# \tout << \"#{i},\"\n\t\t\t# end\n\t\t\t\n\t\t\t# return out\n\t\t\t\n\t\t\treturn self.inject(\"\"){|out, i| out << \"#{i},\"}\n\t\tend", "def quotation_filter(text)\n text.gsub QuotationPattern do |w|\n wrap_result w.gsub('\"', '')\n end\n end", "def to_s\n \"{#{@rep.map { |c| \"\\\"#{c}\\\"\" }.join ', '}}\"\n end", "def process_text arr\n puts arr.map { |s| s.strip }.join(\" \") \nend", "def quote(term, quote: '\"', separator: ', ')\n if term.is_a?(Array)\n terms = term.map { |t| quote(t, quote: quote, separator: separator) }\n html = terms.all?(&:html_safe?)\n html ? html_join(terms, separator) : terms.join(separator)\n\n elsif !term.is_a?(String)\n \"#{quote}#{term}#{quote}\"\n\n elsif term.html_safe?\n quote = ERB::Util.h(quote)\n quotes = [*HTML_QUOTES, quote].uniq\n quoted = quotes.any? { |q| term.start_with?(q) && term.end_with?(q) }\n quoted ? term : \"#{quote}#{term}#{quote}\".html_safe\n\n else\n term = term.strip\n quotes = [*QUOTE_MARKS, quote].uniq\n quoted = quotes.any? { |q| term.start_with?(q) && term.end_with?(q) }\n quoted ? term : \"#{quote}#{term}#{quote}\"\n end\n end", "def escape_quotes(unfiltered)\n unfiltered.to_s.gsub(/'/, \"''\")\n end", "def serialize(row)\n row\n .map { |c| db_format(c) }\n .join(\",\")\nend", "def join(x, sep = \",\")\n y = []\n x.each do |element|\n y.push element.text\n end\n y.join(sep)\n end", "def split_on_white_space(values)\n values.map { |v| v.gsub('&#10;', \"\\n\").split(\"\\n\") }.flatten.compact\n end", "def to_s(sep=\"\\t\")\n map do |row|\n row.join(sep)\n end.join(\"\\n\")\n end", "def preprocess_line line\n line.split(/,/).collect { |l| l.strip }\n end", "def shellsplit(line)\n words = []\n field = ''\n line.scan(/\\G\\s*(?>([^\\s\\\\\\'\\\"]+)|'([^\\']*)'|\"((?:[^\\\"\\\\]|\\\\.)*)\"|(\\\\.?)|(\\S))(\\s|\\z)?/) do |word, sq, dq, esc, garbage, sep|\n raise ArgumentError, \"Unmatched double quote: #{line.inspect}\" if garbage\n token = (word || sq || (dq || esc))\n token.gsub!(/\\\\(.)/, '\\1') unless Vagrant::Util::Platform.windows?\n field << token\n if sep\n words << field\n field = ''\n end\n end\n words\n end", "def internal_space(line)\n # For each single quote, if there is an odd number of double quote before\n # we are in a string, but if there is an even number of double quote before\n # we are out of a string.\n double_quote = 0\n previous_char = nil\n output = ''\n i = 0\n line.each_char do |c|\n double_quote += 1 if c == '\"'\n output += c unless previous_char == ' ' && c == ' ' && double_quote.even?\n i += 1\n previous_char = c\n end\n return output\n end", "def comma(str)\n \"#{str.to_s},\"\n end", "def tokenize_unquot(txt)\n self.tokenize_unquoted ||= txt.split(Awesome::Definitions::Stopwords::UNQUOTED_REGEX)\n end", "def quote(value) # :doc:\n if value.respond_to? :each_pair\n return value.map do |k, v|\n \"#{k}: #{quote(v)}\"\n end.join(\", \")\n end\n return value.inspect unless value.is_a? String\n\n if value.include?(\"'\")\n value.inspect\n else\n \"'#{value}'\"\n end\n end", "def parse(list)\n return list if list.is_a?(Array)\n list.include?(',') ? parse_with_commas(list) : parse_with_spaces(list)\n end", "def to_csv( separateur = ':' )\n DBC.require( separateur.size == 1, \"#{self}.to_csv: separateur invalide: #{separateur}\" )\n [numero.to_s,\n vie,\n attaque,\n defense,\n tete,\n tetedefense,\n torse,\n torsedefense,\n mains,\n mainsdefense,\n pantalons,\n pantalonsdefense,\n bottes,\n bottesdefense,\n arme,\n armeattaque,\n type.to_s,\n nom,\n puissance\n ].join(separateur)\n end", "def processSection0(section)\n string = '';\n buffer_array = [];\n text = section.inner_html;\n text.split('<br>').each do |info|\n buffer_array << info.strip().delete(',');\n end\n string += buffer_array.join(\",\");\n return string;\nend", "def shell_split; end", "def quoted_string_self_values\n vals = []\n self_values.each do |x|\n vals << self.class.add_quotes_if_string(x)\n end\n vals\n end", "def array_to_string(arr)\n arr.map { |e| \"'#{sanitize(e)}'\" }.join(\",\")\n end", "def formatAnswerFromArray( answerString )\n answerRows = answerString.split(\"~\")\n answerArr = Array.new()\n answerRows.each { |ans|\n row = \"\"\n ansarr = ans.split(\",\")\n ansarr.each { |a|\n row += a unless a == \",\"\n }\n answerArr.push(row)\n } \n answerArr\n end" ]
[ "0.6540647", "0.62299854", "0.62273955", "0.6123004", "0.60439557", "0.6022842", "0.5892201", "0.5805178", "0.57960224", "0.57826674", "0.5633326", "0.56082076", "0.55652905", "0.5546583", "0.5517654", "0.549291", "0.5452453", "0.5424162", "0.5414239", "0.5411293", "0.5365037", "0.5342436", "0.5329217", "0.53242487", "0.5322709", "0.53219855", "0.53164047", "0.5286459", "0.52667415", "0.5259171", "0.52479374", "0.52377284", "0.52348095", "0.5227294", "0.52252287", "0.5217616", "0.5208028", "0.5205654", "0.5201943", "0.5195129", "0.5195129", "0.5188754", "0.5169773", "0.5138894", "0.5091183", "0.5089602", "0.5079058", "0.50601166", "0.50576264", "0.5036972", "0.5021261", "0.5020049", "0.50063694", "0.5005205", "0.50042295", "0.5000607", "0.50004774", "0.49874422", "0.4985722", "0.49844897", "0.49821272", "0.49812806", "0.49775127", "0.4977361", "0.4966014", "0.49460357", "0.49447393", "0.49410105", "0.49273026", "0.4915164", "0.49104702", "0.4905027", "0.49005532", "0.49004796", "0.4898643", "0.48969916", "0.488929", "0.48859155", "0.48798713", "0.48746246", "0.4864145", "0.48616555", "0.48595724", "0.48571748", "0.48538932", "0.48407215", "0.48288178", "0.4820276", "0.48174712", "0.48135436", "0.4808888", "0.48032025", "0.48026446", "0.47971475", "0.4796458", "0.47880325", "0.47840628", "0.47828773", "0.47737572", "0.47719514" ]
0.55607986
13
Attempts to log the user in, creates a new session If login attempt is successful, set user in session and redirect to user_homeindex If not successful, kick back to /login and display error
def create user = User.find_by_username(user_login_params[:username]) if user and user.authenticate(user_login_params[:password]) session[:current_user_key] = user.key redirect_to '/home' else redirect_to login_url, alert: "Invalid user/password combination" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n user = User.find_by(username: params[:session][:username])\n\n if user && user.authenticate(params[:session][:password])\n # Log the user in\n log_in user\n user.update_attribute(:is_login, true)\n redirect_to index_path\n else\n # Using render in case any error flash message is to shown in future. \n render 'new'\n end # END IF-ELSE login\n end", "def login\n return if generate_blank\n @user = User.new(params[:user])\n if session[:user] = User.authenticate(params[:user][:login], params[:user][:password])\n session[:user].logged_in_at = Time.now\n session[:user].save\n flash[:notice] = 'Login successful'\n redirect_to_stored_or_default :action => 'home'\n else\n @login = params[:user][:login]\n flash.now[:warning] = 'Login unsuccessful'\n end\n end", "def create\n\n logger.debug \"### Processing new login details\"\n user = User.authenticate(params[:email], params[:password])\n\n if user\n\n logger.debug \"### Login details matched - creating login session\"\n session[:user_id] = user.id\n flash[:notice] = \"Logged in!\"\n redirect_to(session[:return_to] || home_index_path) \n session.delete(:return_to)\n else\n logger.debug \"### User details didn't match - login denied\"\n flash[:error] = \"Invalid email or password\"\n render \"new\"\n end\n\n end", "def create\n user = User.where(:username => params[:session][:username].downcase).first\n \n if user && user.authenticate(params[:session][:password])\n log_in user\n user['last_login'] = Time.now.to_datetime\n user.save\n flash[:success] = \"Welcome back #{user.username}!\"\n redirect_to home_path\n else\n # Otherwise, keep them on the login page.\n flash.now[:danger] = 'Invalid username or password'\n render 'new'\n end\n end", "def login_attempt\n authorized_user = User.authenticate(params[:username], params[:login_password])\n if authorized_user\n session[:user_id] = authorized_user.id\n uname = authorized_user.username\n flash[:notice] = \"Welcome, #{authorized_user.username}!\"\n redirect_to(:action => 'home')\n else\n flash[:notice] = \"Invalid username!\"\n flash[:color] = \"invalid\"\n render \"login\"\n end\n end", "def login_check\n if not is_logged_in session\n # should never get in here\n redirect_to :action => :index\n end\n sunet = session[:user_hash][\"username\"]\n if User.find_by_sunet(sunet)\n redirect_to :action => :index\n else\n # create new user\n gn = session[:user_hash][\"gn\"] || \"\"\n sn = session[:user_hash][\"sn\"] || \"\"\n phone = session[:user_hash][\"phone_number\"] || \"\"\n major = session[:user_hash][\"org\"] || \"\"\n @user = User.new(:sunet => sunet, :first_name => gn.titlecase, :last_name => sn.titlecase, :bio => \"I dance for Basmati Raas!\", :is_alumni => false, :is_undergrad => true, :phone => phone, :major => major)\n @user.save\n flash[:notice] = \"Welcome! We started filling out your profile. Please upload a picture and update your information.\"\n redirect_to \"/users/#{@user.id}/edit\"\n end\n end", "def login_check\n if not is_logged_in session\n # should never get in here\n redirect_to :action => :index\n end\n sunet = session[:user_hash][\"username\"]\n if User.find_by_sunet(sunet)\n redirect_to :action => :index\n else\n # create new user\n gn = session[:user_hash][\"gn\"] || \"\"\n sn = session[:user_hash][\"sn\"] || \"\"\n phone = session[:user_hash][\"phone_number\"] || \"\"\n major = session[:user_hash][\"org\"] || \"\"\n @user = User.new(:sunet => sunet, :first_name => gn.titlecase, :last_name => sn.titlecase, :bio => \"I dance for Basmati Raas!\", :is_alumni => false, :is_undergrad => true, :phone => phone, :major => major)\n @user.save\n flash[:notice] = \"Welcome! We started filling out your profile. Please upload a picture and update your information.\"\n redirect_to \"/users/#{@user.id}/edit\"\n end\n end", "def index\n \n # Check if user is already logged in according to session data and redirec\n # to the appropriate start path\n if session[:user_id]\n redirect_to login_startpath(session[:user_access])\n \n # If not, check if user is logging in right now\n elsif params[:email] && params[:password]\n user_lookup = User.find_by email: params[:email]\n login_result = check_login user_lookup, params[:password]\n login_success = login_result['success']\n @login_error = login_result['error_text']\n login_register user_lookup.id, login_success\n \n # If not, check if user has a saved session\n elsif cookies.permanent.signed[:remember_user_id] &&\n cookies.permanent.signed[:remember_user_token]\n \n user_lookup = User.find(cookies.permanent.signed[:remember_user_id])\n login_result = check_session user_lookup\n login_success = login_result['success']\n @login_error = login_result['error_text']\n login_register user_lookup.id, login_success\n end\n \n # Proceed with the login if everything checks out\n if login_success == true\n \n # Set session variables\n set_session user_lookup\n \n # Check if the user wanted the session to be saved.\n if params[:remember]\n save_session user_lookup\n end\n \n # Redirect to the correct view\n redirect_to login_startpath(user_lookup.access)\n end\n end", "def login\n #Variable setting\n email = params[:user][:email]\n pw = params[:user][:password]\n flash[:login_error]= \"penis\"\n #user instance we are trying to validate\n @user = User.find_by_email(email)\n\n #Does the current user exist?\n if @user\n @current_user = @user.authenticate(pw)\n\n #Is the current user authenticated?\n if @current_user\n session[:user_id] = @user.id\n redirect_to :controller => :users, :action => :home\n else\n flash[:login_error] = \"The password you specified was incorrect\"\n render :index\n end\n\n else\n flash[:login_error] = \"The username you specified does not exist\"\n @user = User.new\n render :index\n end\n end", "def create\n reset_session\n u = User.authenticate(params[:session][:login], params[:session][:password])\n \n if u\n reset_session\n session[:user_id] = u.id\n session[:user_login] = u.login\n @current_user = User.find(session[:user_id])\n flash[:notice] = 'hi, again!'\n redirect_to dashboard_url\n else\n flash[:error] = 'Invalid login or password.'\n redirect_to root_url\n end\n end", "def create\n @user = User.find_by(email: params[:session][:email].downcase)\n @err = nil\n\n # if the information is valid, log the user in and redirect them to their homepage\n if @user && @user.authenticate(params[:session][:password])\n log_in @user\n render '/users/home'\n\n # otherwise notify error that the value is invalid and print it to the log in page\n else\n # user info is incorrect\n @err = 'Invalid email/password combination'\n redirect_to '/sessions/new'\n end\n end", "def authenticate_login\n if session[:user].nil? #There's definitely no user logged in\n flash[:notice] = \"<div class=\\\"flash_failure\\\">&nbsp;You are not logged in!</div>\"\n redirect_to :action => \"login\", :controller => \"../browse\"\n else #there's a user logged in, but what type is he?\n @user = User.find(session[:user][:id]) # make sure user is in db, make sure they're not spoofing a session id\n if @user.nil?\n flash[:notice] = \"<div class=\\\"flash_failure\\\">&nbsp;You are not logged in!</div>\"\n redirect_to :action => \"login\", :controller => \"../browse\"\n else\n #session passed too!\n end\n end\n end", "def login\n @user = User.find_or_create_from_auth_hash(auth_hash)\n @user_name = @user.display_name\n\n session[:current_user_id] = @user.id\n\n render :login, :layout => false\n end", "def create\n unless current_user_session.nil?\n redirect_to root_url, :notice => \"You are already logged in.\"\n return\n end\n @user_session = UserSession.new(params[:user_session])\n\n if @user_session.save\n redirect_to(@user_session.user, :notice => \"Login successful. Welcome!\") \n else\n render :action => \"new\" \n end\n end", "def login\n username = params[:user][:username]\n found_user = User.find_by(username: username)\n if found_user\n session[:user_id] = found_user.id\n flash[:success] = \"Successfully logged in as existing user #{found_user.username}\"\n else\n @user = User.new(username: username)\n if @user.save\n session[:user_id] = @user.id\n flash[:success] = \"Successfully created new user #{@user.username} with ID #{@user.id}\"\n else\n flash.now[:error] = \"A problem occurred: Could not log in\"\n # render \"users/login_form\"\n render \"users/login_form\"\n return\n end\n end\n \n return redirect_to root_path\n end", "def login\n @user = User.authenticate(params[:username], params[:user_password])\n if @user\n session[:user] = @user\n flash['notice'] = \"Login successful\"\n redirect_back_or_default :controller => 'schedule', :action => \"index\"\n else\n if !params[:username].blank? or !params[:user_password].blank? \n flash.now['notice'] = \"Login unsuccessful\"\n end\n @login = params[:username]\n end\n end", "def create\n action = LogUserIn.new :web\n @session = Session.new params[:session]\n\n if user = action.run(@session.login, @session.password)\n previous_path = session[:login_redirect_to]\n set_new_user_session user, @session.remember_me\n\n redirect_to previous_path || root_path\n else\n flash.now[:login_error] = true\n render action: \"new\"\n end\n end", "def login_post\n @user = User.find_by_username(params[:user][:username])\n \n if @user == nil or not @user.password_valid?(params[:user][:password]) then\n respond_to do |format|\n format.html { redirect_to login_users_path, notice: \"Either the username or password is invalid. Please try again.\"}\n format.json { head :no_content }\n end\n return\n else\n session[:user] = @user\n\n if session[:previous_page] then\n respond_to do |format| \n session[:no_back] = true\n format.html { redirect_to session[:previous_page] }\n format.json { head :no_content }\n end\n\n session[:previous_page] = nil\n return\n end\n \n logged_in_home_page = users_path + '/' + session[:user][:id].to_s\n respond_to do |format|\n format.html { redirect_to gardens_path}\n format.json { head :no_content }\n end\n return\n end\n end", "def check_user_for_loggin\n @user = User.find_by(email: user_params[:email])\n if @user \n if @user.authenticate(user_params[:password])\n session[:user_id] = @user.id\n cookies.encrypted[:user_id] = @user.id\n redirect_to @user\n else\n @current_uri = request.env['PATH_INFO']\n @user = User.new(email: user_params[:email],password: user_params[:password])\n flash[:notice] = \"Wrong email or password\"\n render \"users/new\", :layout => \"signup_login\" \n end\n else \n @current_uri = request.env['PATH_INFO']\n flash[:notice] = \"Wrong email or password\"\n @user = User.new(email: user_params[:email],password: user_params[:password])\n render \"users/new\", :layout => \"signup_login\"\n end\n end", "def attempt_login\n if params[:username].present? && params[:password].present?\n found_user = User.where(:username => params[:username]).first #this will return the first record\n if found_user\n authorized_user= found_user.authenticate(params[:password])\n end\n end\n if authorized_user\n # reset_session if session[:last_seen] < 1.minutes.ago\n #session[:last_seen] = Time.now\n cookies[:user_id]=authorized_user.id\n #cookies[:user_id]={:expires=>1.minute.from_now}\n cookies[:user_name]=authorized_user.username\n cookies[:hotel_id_for_login_user]=authorized_user.hotel_id\n flash[:notice]=\"You are now logged in.\"\n redirect_to(:action=>'index')\n else\n # session[:last_seen] = Time.now\n flash[:notice]=\"Invalid username/password combination.\" \n redirect_to(:controller=>'homepage',:action=>'login') \nend\nend", "def create\n user = User.authenticate(params[:session][:email], params[:session][:password])\n if user.nil?\n flash.now[:error] = \"invalid emails/password combination\"\n render 'new'\n else #user logs in, creates session\n session[:remember_token] = user.id\n @user = User.find_by_id(session[:remember_token]) \n if(@user.email==\"[email protected]\") #redirect admin to her page\n redirect_to :controller => 'users', :action => 'index'\n elsif session[:url] == nil\n redirect_to :controller => :users, :action => :show, :id => user.id\n else\n redirect_to session[:url]\n session[:url] = nil\n end\n end \n end", "def exec_login\n if core_createSession(params[:username], params[:password])\n redirect_to lato_core.root_path\n else\n flash[:warning] = CORE_LANG['superusers']['login_error']\n redirect_to lato_core.login_path\n end\n end", "def create\n \t@user = User.find_by(e_mail: params[:session][:email].downcase)\n \tif @user && @user.authenticate(params[:session][:password])\n \t\t# Login successful, save user_id to session and redirect to user page\n \t\tlog_in @user\n \t\tredirect_to home_path\n \telse\n \t\t# Login unsuccessful, redirect to Log In Page and display an error message\n \t\tflash.now[:danger] = 'Invalid email/password combination'\n render \"new\"\n \tend\n end", "def login\r\n if request.get?\r\n # Logout user\r\n self.logged_in_user = nil\r\n else\r\n # Authenticate user\r\n user = User.try_to_login(params[:login], params[:password])\r\n if user\r\n self.logged_in_user = user\r\n # user.update_attribute(:ip_last, request.remote_ip)\r\n journal(\"log_in\",user.id)\r\n # generate a key and set cookie if autologin\r\n if params[:autologin] && Setting.autologin?\r\n token = Token.create(:user => user, :action => 'autologin')\r\n cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }\r\n end\r\n puts \"aqui\"\r\n if user.show? \r\n puts \"1\"\r\n redirect_back_or_default :controller => 'my', :action => 'athletes'\r\n else \r\n puts \"2\" \r\n redirect_back_or_default :controller => 'my', :action => 'page'\r\n end\r\n else\r\n # if user.locked?\r\n # flash.now[:notice] = l(:status_locked)\r\n # else\r\n flash.now[:notice] = l(:notice_account_invalid_creditentials)\r\n # end\r\n journal(\"invalid-\"+params[:login]+\"-\"+params[:password],0)\r\n end\r\n end\r\n end", "def create\n user=ApiM8::Client::Account::Users.instance.login(params[:login], params[:password])\n puts user.current_user\n\n if user\n session[:current_user_id]=user.id\n redirect_to role_super_admin_dashboards_url, :notice => \"Logged in as #{params[:login]}!\"\n else\n flash[:danger] = 'Invalid email/password combination' # Not quite right!\n render \"new\"\n end\n\n\n end", "def make_user_login\n #If you aren't logged in redirect to login page\n if !logged_in?\n redirect_to(:controller => 'sessions', :action => 'login')\n end\n end", "def login\n @user = User.find_by(username: params[:session][:username])\n if @user && @user.authenticate(params[:session][:password]) \n flash[:success] = \"Welcome!\"\n session[:signed_in_user_id] = @user.id\n redirect_to user_path(@user)\n else\n flash[:error] = \"Username or Password Incorrect\"\n redirect_to new_login_path\n end\n end", "def create\n #Try to find the user in the database\n user = User.find_by(email: params[:session][:email].downcase)\n #If the password matches, log the user in and redirect them to the user profile page\n if user && user.authenticate(params[:session][:password])\n log_in(user) #store id in cache\n redirect_to user_url(user)\n #Display error message and refresh the page if password is invalid\n else\n flash.now[:danger] = \"Invalid username or password\"\n #refresh the page\n render 'new'\n end\n end", "def create\n session[:user] = User.login_or_signup(params[:session])\n if logged_in?\n redirect_to('/')\n flash[:notice] = \"Logged in successfully\"\n else\n add_warning \"Bad username/password combination! Please try again.\"\n render :action => 'new'\n end\n end", "def login_attempt\n @user = User.where(email: params[:email]).first\n if @user && @user.password == params[:password]\n session[:user_id] = @user.id\n\n redirect_to root_path\n else\n flash[:notice] = \"Invalid Username or Password\"\n\n render \"login\"\n end\n end", "def create\n # find the user based on email in params from post action. Downcase as all emails are downcased in database.\n user = User.find_by(email: params[:session][:email].downcase)\n # is user returned valid? If so, authenticate (.authenticate comes from bcrypt gem. Checks if the password matches.)\n if user && user.authenticate(params[:session][:password])\n # Save the user id in the session's hash (add a :user_id key & save the current user's id as the value)\n session[:user_id] = user.id\n # show success message & redirect to the logged in user's profile page\n flash[:success] = \"You have successfully logged in\"\n redirect_to user_path(user)\n # If either is false, then show fail message and render the login page again\n else\n flash.now[:danger] = \"There was something wrong with your login info\"\n render 'new'\n end\n end", "def login\n if request.get?\n session[:user_id] = nil\n else\n # Try to get the user with the supplied username and password\n logged_in_user = User.login(params[:user][:name], params[:login][:password])\n\n # Create the session and redirect\n unless logged_in_user.blank?\n session[:user_id] = logged_in_user.id\n jumpto = session[:jumpto] || root_path\n session[:jumpto] = nil\n redirect_to(jumpto)\n else\n flash.now[:login_error] = 'Invalid username or password.'\n end\n end\n end", "def login_user\n\t @user_session = UserSession.new\t \n\tend", "def successful_login(user,url=nil)\n # Protects against session fixation attacks, causes request forgery\n # protection if user resubmits an earlier form using back\n # button. Uncomment if you understand the tradeoffs.\n # reset_session\n self.current_user = user\n new_cookie_flag = (params[:remember_me] == \"1\")\n handle_remember_cookie!(new_cookie_flag)\n\n # self.return_to = params[:url] if params[:url] and !is_home_or_login_or_signup(params[:url])\n # if params[:url] and not is_home_or_login_or_signup(params[:url])\n # self.return_to = params[:url]\n # else\n # self.return_to = user.last_visited if user.last_visited and session[:return_to].blank?\n # end \n update_logins\n \n flash[:notice] = \"Logged in successfully\"\n if url.blank?\n redirect_back_or_default(root_url)\n else\n redirect_to url\n end\n \n end", "def create_user\n \tunless @user\n \t\tflash[:notice_login] = \"Incorrect password or username.\"\n \t return render action: 'new_user'\n \tend\n \tsession[:comedian_id] = nil\n \tsession[:user_id] = @user.id\n\n \tflash[:notice_login] = 'Signed in!'\n \tredirect_to root_path\n end", "def login\n\t\tuser = User.authenticate(params[:username],params[:password])\n\t\tif user\n\t\t\tsession[:current_user_id] = user.id\n\t\t\tflash[:notice] = \"logged in\"\n\t\t\tredirect_to '/home'\n\t\telse\n\t\t\tflash[:notice] = \"Wrong username/password\"\n\t\t\tredirect_to '/index'\n\t\tend\n\tend", "def try_login\n if user = http_auth_login || validation_login || remember_me_login\n session[:uid] = user.id\n end\n end", "def create\n if user = User.find_by_login(params[:login])\n # Save the user ID in the session so it can be used in subsequent requests\n session[:current_user_id] = user.id\n redirect_to root_url\n end\n end", "def create\n validate_params; return if performed?\n user = User.find_by(user_name: params[:session][:user_name])\n if user && user.authenticate(params[:session][:password])\n log_in user\n redirect_to root_path\n else\n flash.now[:error] = I18n.t('errors.log_in.create')\n render :new\n end\n end", "def create\r\n\t\t# find the user based on the email\r\n\t\tuser = User.find_by(email: params[:session][:email].downcase) # all our emails in our database is downcased\r\n\t\t# check if the email is valid\r\n\t\tif user && user.authenticate(params[:session][:password])\r\n\t\t\t# simulate logging in\r\n\t\t\tsession[:user_id] = user.id # saving the user id in the session. The browsers cookies is going to handle this\r\n\t\t\t# saving the users id in the session hash which is backed by the browser\r\n\t\t\t# display a message\r\n\t\t\tflash[:success] = \"You have successfully logged in\"\r\n\t\t\tredirect_to user_path(user)\r\n\t\telse\r\n\t\t\t# give a message since it is not a model back form\r\n\t\t\tflash.now[:danger] = \"There was something wrong with your login information\"\r\n\t\t\t# flash.new persists for one http request. When we redirect the message will display in the next screen\r\n\t\t\t# render the new template to login\r\n\t\t\trender 'new'\r\n\t\tend\r\n\tend", "def create\n session_params = params[:session]\n @user = User.where(username: session_params['username']).first\n puts \"USER IS #{@user.inspect}\"\n\n if @user and @user.authenticate(session_params['password'])\n session[:user_id] = @user.id\n# redirect to the user's profile page\n flash[:notice] = \"You're logged in\"\n redirect_to user_path @user\n # or use redirect_to '/users/' + @user.id.to_s\n else\n# if it doesn't work, flash noticeand redirect to login\n flash[:notice] = \"... something went wrong. Please try again!\"\n redirect_to '/'\n end\n end", "def create\n @user = User.find_by(email: params[:session][:email])\n #@user = User.find_by(password_digest: params[:session][:password_digest])\n @user && @user.authenticate(params[:session][:password])\n if @user\n log_in(@user)\n flash[:success] = 'Log in successful.'\n redirect_to @user #first problem identified#\n else\n flash.now[:danger] = 'The user id you entered does not exist.'\n render 'new'\n #render html:'<strong>HTML String</strong>'\n end\n end", "def login\n if params['username'] and params['password']\n user = User.where(name:params['username'], password: params['password']).first \n if user\n session['user_attributes'] = user.attributes\n session['user_attributes']['id'] = user.id\n else\n flash[:error] = \"Login failed\"\n end\n end \n \n if session['user_attributes']\n unless params['redirect_to'].nil?\n redirect_to(\"#{params['redirect_to']}\")\n else\n redirect_to(root_url)\n end\n else\n flash[:redirect_to] = params['redirect_to'] unless flash[:redirect_to]\n end\n end", "def user_log_in(user)\n if user && user.authenticate(params[:user][:password])\n session[:user_id] = user.id\n redirect \"/users/#{user.id}\"\n\n else\n flash[:message] = \"Account could not be authenticated. Please enter username and password.\"\n redirect '/login'\n end\n end", "def create\n @user_session = UserSession.new(params[:user_session])\n if @user_session.save\n record_action!(:login, current_user)\n flash[:notice] = \"Login successful!\"\n redirect_back_or_default after_login_url\n else\n @failed = true\n render :action => :new\n end\n end", "def login\n if session[:user] != nil then\n logged_in_home_page = home_index_path\n respond_to do |format|\n format.html { redirect_to logged_in_home_page}\n format.json { head :no_content }\n end\n return\n end\n\n @user = User.new\n \n respond_to do |format|\n format.html # login.html.erb\n format.json { render json: @user }\n end\n end", "def create\n # logging in can be done via email or username interchangeably\n user = User.find_by email: params[:session][:username].downcase\n # ||= only runs the find command if the user was not set by the above\n user ||= User.find_by username: params[:session][:username].downcase\n\n if user && user.authenticate(params[:session][:password])\n # Log the user in and redirect to the user's show page\n log_in user\n flash[:success] = \"Logged in as #{user.username}\"\n redirect_to user_url(user)\n else\n # Flash an error message\n flash.now[:danger] = 'Invalid email or password'\n render 'new'\n end\n end", "def create\n user = User.find_by(email: params[:session][:email].downcase)\n \n #if the user was found and the user.authenticate based on enetered password\n if user && user.authenticate(params[:session][:password])\n # we are saving user id into the session so the browsers cookies will handle this\n # this id will be used across sessions\n session[:user_id] = user.id\n \n # flash a success and redirect to the users page\n flash[:success] = \"You have successfully logged in\"\n redirect_to user_path(user)\n else\n # re render the login page, but since this is not a model backed form we wont have validation messages\n # add a message with flash\n flash.now[:danger] = \"Username or Password were incorrect\"\n render 'new'\n end\n end", "def create\n @user_session = UserSession.new(user_session_params.to_h)\n if @user_session.save\n flash[:notice] = \"Login successfully!\"\n redirect_back_or root_path\n else\n redirect_to login_path,\n alert: \"A problem's occured while logging in, please try again.\"\n end\n end", "def login\r\n # If the user is already logged in, send them into the application, rather than requesting authentication again.\r\n if is_authorized\r\n logger.debug(\"User is already logged in\")\r\n redirect_to :controller => :bodysize\r\n return\r\n end\r\n \r\n # The user is not logged in yet. Reset their session\r\n session[:user_id] = nil\r\n \r\n if request.post?\r\n user = User.authenticate(params[:email_address], params[:password])\r\n if user && user.enabled?\r\n login_user_by_id(user.id) \r\n\r\n uri = session[:original_uri]\r\n session[:original_uri] = nil\r\n redirect_to( uri || '/bodysize/index' )\r\n return\r\n else\r\n flash[:notice] = 'Invalid username/password combination'\r\n AuditLog.create(:action => \"A user failed to login with the username: #{params[:email_address]}\") \r\n end\r\n end\r\n end", "def create\n # refactor this\n user = User.find_by(username: params[:session][:username_or_email].downcase) ||\n User.find_by(email: params[:session][:username_or_email].downcase)\n if authenticated_successfully?(user)\n login(user)\n redirect_to(session[:intended_url] || root_path)\n else\n flash.now[:danger] = \"Hmm... #{$SITE_TITLE} couldn't authenicate your account with those credentials.\"\n render 'new'\n end\n end", "def login\n redirect_to(root_url) && return if logged_in?\n @user = User.new params[:user]\n if meth = params[:type]\n usr = @user.send(meth)\n unless usr.new_record? # registration/login success\n session[:user_id] = usr.id\n redirect_to(root_url)\n end\n end\n end", "def login_required\n if session[:user]\n begin\n load_session_user\n rescue\n logout_and_redirect_to_login\n else\n return session[:user]\n end\n else\n self.store_location\n redirect_to users_login_url, :alert => \"You don't have access to that, please login.\"\n end\n end", "def login\n if request.get?\n session[:user_id] = nil\n @user = User.new\n else\n @user = User.new(params[:user])\n logged_in_user = @user.try_to_login\n if logged_in_user\n session[:user_id] = logged_in_user.id\n redirect_to(:controller => \"admin\")\n else\n flash[:notice] = \"Sorry, Invalid user/password combination!\"\n end \n end\n end", "def log_in_user\n unless log_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_path\n end\n end", "def login\n# **********\n user_name = params[:user][:user_name]\n\n if user_name and @user = User.find_by(user_name: user_name)\n session[:user_id] = @user.id\n flash[:result_text] = \"Successfully logged in as exsisting user #{@user.user_name}\"\n else\n @user = User.new(user_name: user_name)\n if @user.save\n session[:user_name] = @user.user_name\n flash[:result_text] = \"Successfully created new user #{@user.user_name} with ID #{@user.id}.\"\n else\n flash.now[:status] = :failure\n flash.now[:message] = @user.errors.messages\n render \"new\", status: :bad_request\n return\n end\n end\n redirect_to root_path\n end", "def login\n @user = User.find_by nickname: params[:nickname]\n if @user\n if (@user.is_password?(params[:password]))\n session[:id] = @user.id\n redirect_to url_for(:controller => :users, :action => :show, id: @user.id)\n else\n redirect_to action: \"index\", :notice => \"Login failed. Invalid password.\"\n end\n else\n redirect_to action: \"index\", :notice => \"Login failed. Invalid username.\"\n end\n end", "def create\n if user = User.authenticate_with_credentials(params_for_login)\n # a session cookie is assigned to logged users\n session[:user_id] = user.id\n redirect_to session[:return_to]\n else\n redirect_to session[:return_to], flash: { error: \"Invalid email address\" }\n end\n end", "def save_login_state\n # redirect to home Page\n if session[:user_id]\n redirect_to(:controller => 'sessions', :action => 'home')\n return false\n else\n return true\n end\n end", "def create\n @user = User.find_by_credentials(params[:user][:email],params[:user][:password])\n\n if @user.nil?\n flash.now[:errors] = [\"incorrect email/password combination\"]\n render :log_in\n else\n @user.reset_session_token!\n session[:session_token] = @user.session_token\n # fail\n redirect_to user_url(@user)\n end\n end", "def logged_in_user\n return if logged_in?\n\n store_location\n flash[:danger] = 'Please log in first'\n render 'sessions/new', status: :unauthorized\n true # return true to indicate that this triggered things\n end", "def create\n user = User.find_by(email: params[:session][:email].downcase)\n if user && user.authenticate(params[:session][:password])\n log_in user\n redirect_to home_path\n else\n flash.now[:danger] = 'Invalid email/password combination'\n render 'new'\n end\n end", "def save_login_state\n #You are logged in\n if session[:user_id]\n #go back home you can't log in twice!\n redirect_to(:controller => 'sessions', :action => 'home')\n return false\n else\n #you aren't logged in so you may login or signup\n return true\n end\n end", "def login()\n session[:cas_user] = nil\n \n if request.post?\n clear_page_vars\n user = User.authenticate(params[:username])\n if user\n session[:cas_user] = user.username\n \n # Cache some common looked-up user fields.\n person = lookup_cas_user(user.username)\n if person\n session[:title] = person.title\n session[:phone] = person.phone\n end\n \n uri = session[:original_uri]\n session[:original_uri] = nil\n home = user_home(user) \n redirect_to(uri || {:action => home})\n else\n flash.now[:notice] = \"Invalid user.\" \n end\n end\n end", "def login\n # redirect to main page if user is already logged in.\n if logged_in? && !request.post?\n if @real_user.admin_user?\n redirect_to(admin_path)\n elsif allowed_to?(:role_is_switched?)\n redirect_to course_assignments_path(session[:role_switch_course_id])\n else\n redirect_to(courses_path)\n end\n return\n end\n unless Settings.remote_auth_login_url || Settings.validate_file\n flash_now(:error, t('main.sign_in_not_supported'))\n end\n if remote_auth? && remote_user_name\n flash_message(:error,\n I18n.t('main.external_authentication_user_not_found',\n name: Settings.remote_auth_login_name ||\n I18n.t('main.external_authentication_default_name')))\n end\n return unless request.post?\n\n # Get information of the user that is trying to login if his or her\n # authentication is valid\n unless validate_login(params[:user_login], params[:user_password])\n render :login, locals: { user_login: params[:user_login] }\n return\n end\n\n session[:auth_type] = 'local'\n\n found_user = User.find_by(user_name: params[:user_login])\n if found_user.nil? || !(found_user.admin_user? || found_user.end_user?)\n flash_now(:error, Settings.validate_user_not_allowed_message || I18n.t('main.login_failed'))\n render :login, locals: { user_login: params[:user_login] }\n return\n end\n\n self.real_user = found_user\n\n uri = session[:redirect_uri]\n session[:redirect_uri] = nil\n refresh_timeout\n # redirect to last visited page or to main page\n if cookies.encrypted[:lti_data].present?\n lti_data = JSON.parse(cookies.encrypted[:lti_data]).symbolize_keys\n redirect_url = lti_data.key?(:lti_redirect) ? lti_data[:lti_redirect] : root_url\n redirect_to redirect_url\n elsif uri.present?\n redirect_to(uri)\n elsif found_user.admin_user?\n redirect_to(admin_path)\n else\n redirect_to(courses_path)\n end\n end", "def do_login\n type = :unknown\n\n if !cookies[:user].nil? && cookies[:user] != \"\"\n @user = User.find( :first,\n\t\t\t :conditions =>\n\t\t\t [ \"MD5(CONCAT(?,'|',?,'|',username,'|',password))=?\",\n\t\t\t PW_SALT, request.remote_ip, cookies[:user]\n\t\t\t ]\n );\n\n type = :cookie\n\n elsif params[:token]\n token = Token.find_by_token( params[:token] );\n @user = token.user if ( !token.nil? )\n\t\n type = :token\n\n elsif params[:user]\n @user = User.find( :first,\n\t\t\t :conditions =>\n\t\t\t [ \"username = ? AND password = ?\",\n\t\t\t params[:user][:username],\n\t\t\t User.make_hashed_password(params[:user][:password])\n\t\t\t ]\n )\n\n type = :form\n end\n\n if ( type == :form && !verify_recaptcha() )\n flash[:error] = \"are you not human?\"\n return( redirect_to :action => \"login\")\n end\n\n if [email protected]?\n session[:user] = @user.id\n return( redirect_to :controller => \"home\", :action => \"index\" )\n\n else\n flash[:error] = \"Login failed.<br/>\"\n\n if type == :cookie\n\tflash[:error] += \"Your login cookie was not valid\"\n\tcookies[:user] = nil\n\n elsif type == :form\n\tflash[:error] += \"Username and password do not match\"\n\n elsif type == :token\n\tflash[:error] += \"The token is invalid\"\n\n else\n\tflash[:error] += \"Something went terribly wrong.\"+\n\t \"We have been informed, please try again later\"\n\tRAILS_DEFAULT_LOGGER.error(\"Unknown login type found\");\n\n end\n\n return( redirect_to :action => \"login\" )\n end\n end", "def create\n\t\t#render 'new'\n\t\tuser = User.find_by(email: params[:session][:email].downcase)\n\t\tif user && user.authenticate(params[:session][:password])\n\t\t\tsession[:user_id] = user.id\n\t\t\tflash[:success] = \"You have successfully logged in!\"\n\t\t\tredirect_to user_path(user)\n\t\telse\n\t\t\t#when u render using flash.now and when u redirect_to using flash.\n\t\t\tflash.now[:danger] = \"There is something wrong with your login information!\"\n\t\t\trender 'new'\n\t\tend\n\tend", "def create\n # Find the user by their name\n user = User.find_by(name: params[:session][:name].downcase)\n # If the user exists and the user credentials are correct\n if user && user.authenticate(params[:session][:password])\n # Log the user in\n login user\n # Take the user to their profile page\n redirect_to me_path\n else\n # Notify the user that their credentials are incorrect\n flash[:error] = 'Invalid email/password combination'\n # Redirect to the home page\n redirect_to root_path\n end\n end", "def create\n # Get submitted email and password\n address = params[:session][:email]\n password = params[:session][:password]\n\n # Pull the user from the db\n user = User.find_by(email: address.downcase)\n\n # User exists and password is correct\n if user && user.authenticate(password)\n # Login user\n create_session user\n\n # Show user profile page\n redirect_to user\n\n # There were invalid credentials\n else\n # Show an error message\n flash.now[:warning] = \"You cocked up. Try again.\"\n\n # Show login page again\n render 'new'\n end\n end", "def create\n\t\tuser = User.find_by(email: params[:login][:email])\n\n\t\tif user && user.authenticate(params[:login][:password])\n\t\t\tsession[:user_id] = user.id.to_s\n\t\t\tredirect_to root_path\n\t\telse\n\t\t\trender :new\n\t\tend\n\n\tend", "def create\n @user = User.where(username: params[:session][:username]).first\n if @user.password == params[:session][:password]\n session[:user_id][email protected]\n log_in @user\n puts \"my sess = #{session[:user_id]}\"\n redirect_to @user\n else\n flash[:alert] = \"Invalid Username/Password. Please try again\"\n redirect_to login_path\n end\n end", "def login\n return unless request.post?\n ::ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_expires => 4.weeks.from_now) if params[:remember_me]\n self.current_user = User.authenticate(params[:login], params[:password])\n if current_user\n redirect_back_or_default(:controller => '/')\n flash[:notice] = \"Logged in successfully\"\n else\n flash[:notice] = \"Please try again\"\n end\n end", "def save_login_state\n if session[:user_id]\n redirect_to(:controller => 'sessions', :action => 'home')\n return false\n else\n return true\n end\n end", "def logged_in_user\n return if logged_in?\n store_location\n redirect_to sessions_new_path, alert: 'Please log in.'\n end", "def create\n # Locate user in database using given email.\n @user = User.find_by(email: params[:session][:email].downcase)\n\n # Did the user enter the correct password?\n if @user && @user.authenticate(params[:session][:password])\n\n log_in @user\n\n # Only remember the user if the checkbox is ticked.\n params[:session][:remember_me] == '1' ? remember(@user) : forget(@user)\n\n # Show success message, and send user to their profile page.\n flash[:success] = \"Welcome back #{@user.name}!\"\n redirect_back_or @user\n else\n flash.now[:danger] = 'Incorrect username and/or password!'\n render 'new'\n end\n end", "def login\n session[:job_id] = nil\n\n # external auth has been done, skip markus authorization\n if Settings.remote_user_auth\n if @markus_auth_remote_user.nil?\n render 'shared/http_status', formats: [:html], locals: { code: '403', message: HttpStatusHelper::ERROR_CODE['message']['403'] }, status: 403, layout: false\n return\n else\n login_success, login_error = login_without_authentication(@markus_auth_remote_user)\n if login_success\n uri = session[:redirect_uri]\n session[:redirect_uri] = nil\n refresh_timeout\n # redirect to last visited page or to main page\n redirect_to( uri || { action: 'index' } )\n return\n else\n render :remote_user_auth_login_fail, locals: { login_error: login_error }\n return\n end\n end\n end\n\n # Check if it's the user's first visit this session\n # Need to accommodate redirects for locale\n if params.key?(:locale)\n if session[:first_visit].nil?\n @first_visit = true\n session[:first_visit] = 'false'\n else\n @first_visit = false\n end\n end\n\n @current_user = current_user\n # redirect to main page if user is already logged in.\n if logged_in? && !request.post?\n redirect_to action: 'index'\n return\n end\n return unless request.post?\n\n # strip username\n params[:user_login].strip!\n\n # Get information of the user that is trying to login if his or her\n # authentication is valid\n validation_result = validate_user(params[:user_login], params[:user_login], params[:user_password])\n unless validation_result[:error].nil?\n flash_now(:error, validation_result[:error])\n render :login, locals: { user_login: params[:user_login] }\n return\n end\n # validation worked\n found_user = validation_result[:user]\n if found_user.nil?\n return\n end\n\n # Has this student been hidden?\n if found_user.student? && found_user.hidden\n flash_now(:error, I18n.t('main.account_disabled'))\n redirect_to(action: 'login') && return\n end\n\n self.current_user = found_user\n\n if logged_in?\n uri = session[:redirect_uri]\n session[:redirect_uri] = nil\n refresh_timeout\n # redirect to last visited page or to main page\n redirect_to( uri || { action: 'index' } )\n else\n flash_now(:error, I18n.t('main.login_failed'))\n end\n end", "def post_login\n \t\tif logged_in?\n \t\t\tflash[:error] = \"You are already logged in as #{current_user_full_name}\"\n \t\t\tredirect_to(:controller => :photos, :action => :index, :id => session[:current_user_id])\n \t\telse\n\t \t\tcurrent_user = User.find_by_login(params[:login])\n\t\t\t\tif(current_user == nil) then\n\t\t\t\t\t# If no user exists with the given login, redisplay login form with error message.\n\t \t\t\t\tflash[:error] = \"Invalid username\"\n\t \t\t\t\tredirect_to(:action => :login)\n\t\t\t\telsif(!current_user.password_valid?(params[:password])) then\n\t\t\t\t\t# If incorrect password, display error message\n\t\t\t\t\tflash[:error] = \"Invalid password\"\n\t \t\t\t\tredirect_to(:action => :login)\n\t\t\t\telse\n\t\t\t \t\t# Upon successful login, stores user id in session where it can be checked by other code and\n\t\t\t \t\t# redirects to the page displaying the user's photos.\n\t\t \t\t\tsession[:current_user_id] = current_user.id\n\t\t \t\t\tflash[:success] = \"Welcome, #{current_user_first_name}!\"\n\t\t \t\t\tredirect_to(:controller => :photos, :action => :index, :id => session[:current_user_id])\n\t \t\t\tend\n\t \tend\n \tend", "def authenticate\n unless session[:user_id]\n session['return_url'] = request.url\n logger.debug request.url\n # Recreate user abilities on each login\n @current_ability = nil\n redirect_to polymorphic_url(:new_user_session)\n end\n end", "def login\n user = User.find_by_email(params[:username])\n if user.nil? || (user && user.authenticate(params[:password]) == false) || user.deleted\n render status: 400, json: nil \n else\n session[:user_id] = user.id\n session[:username] = user.username\n session[:email] = user.email\n session[:verified] = user.verified\n user.last_ip_login = request.remote_ip\n user.save\n render status: 200, json: session\n end\n end", "def save_login_state\n if session[:user_id]\n redirect_to(:controller => 'sessions', :action => 'home')\n return false\n else\n return true\n end\n end", "def login\n \t# Find a user with params\n \tuser = User.authenticate(@credentials[:password], @credentials[:username])\n \tif user\n\t \t# Save them in the session\n\t \tlog_in user\n\t \t# Redirect to articles page\n\t \tredirect_to articles_path\n\telse\n\t\tredirect_to :back, status: :created\n\tend\n end", "def user_login\n #Search the database for a record that matches the name input by the user\n @user = User.find_by username: params[:username]\n #if the username input is invalid flash notice appears and redirects back to login\n if @user.nil?\n flash[:notice] = \"Username is not valid\"\n redirect_to '/register/login'\n #if password is invalid flash notice appears and redirects back to login\n elsif @user.password != params[:password]\n flash[:notice] = \"Password is not valid\"\n redirect_to '/register/login'\n #if everything is valid redirect to welcome page and store user id as a cookie\n else\n session[:id] = @user.id\n redirect_to '/register/welcome'\n end\n end", "def create\n if user = User.Authenticate(params[:login][:email], params[:login][:password])\n # Save the user ID in the session so it can be used in\n # subsequent requests\n session[:current_user_id] = user.id\n redirect_to root_url\n else\n \tflash[:error] = \"Email ou senha incorreto.\"\n \trender :index\n end\n end", "def create\n # find user from session cookie -> email, then authenticate\n @user = User.find_for_database_authentication(email: session_params[:email])\n if @user && @user.valid_password?(session_params[:password])\n sign_in(@user)\n # after signing in the user, refresh to show most updated saved user\n @user.reload\n render :show\n return\n end\n # return prevents login error\n invalid_login_attempt_error\n end", "def create\n user = User.find_by_credentials(params[:user][:name], params[:user][:password])\n if user \n #rails creates session cookie for us, session is a hash\n #generate new session token and set our session to that token\n login!(user)\n redirect_to chirps_url\n else\n # flash used for collecting errors \n # flash - lasts for now and the next response cycle, usually for redirects\n # flash.now - only persist for this response, usually for render\n\n #we want errors to render once but not again on refresh\n flash[:errors] = [\"Invalid username/password\"]\n # render :new\n redirect_to new_session_url\n end\n end", "def login\n @user = User.find_by(email: params[:email])\n if @user && @user.authenticate(params[:password])\n session[:user_id] = @user.id\n redirect_to \"/users/#{@user.id}\"\n else\n flash[:errors] = \"Incorrect login information!\"\n redirect_to :back\n end\n end", "def checklogin\n\t\t@login = User.where(\"username = '#{params[:username]}'\").first\n\n\t\tp params, @login\n\n\t\tif @login && @login.password == params[:password]\n\t\t\tsession[:user_id] = @login.id\n\t\telse\n\t\t\tflash[:notice] = \"YOU ARE AN IMPOSTER\"\n\t\t\t@login = nil\n\t\t\tredirect_to '/'\n\t\tend\n\tend", "def create\n user = User.find_by(username: params[:session][:username])\n if (user && (!user.disabled? && user.authenticate(params[:session][:password]))) \n log_in user \n redirect_back_or active_jobs_path \n else \n flash.now[:danger] = \"Invalid Username/Password Combination\" \n render :new\n end\n end", "def create\n user = User.find_by_login(params[:session][:login])\n if user && user.authenticate(params[:session][:password])\n sign_in user\n redirect_back_or user_path(user.login)\n else\n flash.now[:error] = \"Ungültige Passwort / Login Kombination\"\n render 'new'\n end\n end", "def create\n if @user = login(params[:email], params[:password])\n redirect_back_or_to(projects_path, notice: 'Login successful!')\n # redirect_back_or_to Remebers the page you were on before login and takes you there\n # to this without sorcery, you'd need to store the info in a cookie through the session hash\n # Anytime you want to be able to access a cookie, it's through the sessions hash.\n else\n flash.now[:alert] = 'Login failed'\n render action: :new\n end\n end", "def login\n respond_to do|format|\n format.html \n if request.post?\n @user=Userlogindetail.new(params[:userlogindetail])\n userinfo=Userlogindetail.find_by_useremail_and_userpassword(@user.useremail,@user.userpassword)\n if userinfo\n # session[:user_id]=userinfo.id\n # flash[:notice]=\"User #{userinfo.username} logged in.\" \n redirect_to :action=>'index'\n return\n else\n @user.userpassword=nil\n format.html { render action: \"login\" }\n flash[:notice]='Invalid Email/Password combination' \n end\n end\n end\n end", "def login\n # pull the user info from the user model with the login params\n user = User.find_by_login(params[:login])\n # Authenciate with password\n if user and user.authenticate(params[:password])\n session[:user_id] = user.id\n session[:user_login] = user.login\n session[:user_authority] = user.authority\n # redirect to the landing page\n redirect_to \"/projects\"\n # failed \n else\n redirect_to login_url, alert: \"無効なID、パスワードの組み合わせです。\"\n end\n end", "def logged_in_user\n\t\tunless logged_in?\n\t\tstore_location\n\t\tflash[ :danger] = \"Please log in\"\n\t\tredirect_to login_url\n\tend\n\tend", "def create \n user = User.find_by(:email => params[:session][:email]) #make sure that they are saved as a user. if not, returns nil. if yes, returns user.\n if user && user.authenticate(params[:session][:password]) #if both of these work, log user in\n login(user)\n redirect_to user\n else \n redirect_to :back\n end\n end", "def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to user_login_url\n end\n end", "def create\n user = User.find_by(email: params[:session][:email].downcase)\n if user && user.authenticate(params[:session][:password])\n session[:user_id] = user.id\n flash[:success] = \"You have successfully logged in\"\n redirect_to user_path(user)\n\n else\n\n flash.now[:danger] = \"There was something wrong with your login information\"\n render 'new'\nend\n end", "def login\n session[:user_id] = nil\n session[:is_admin] = nil\n session[:is_editor] = nil\n if request.post?\n user = User.authenticate(params[:name], params[:password])\n puts user\n if user\n session[:user_id] = user.id\n session[:is_admin] = (user.is_admin == 1)\n session[:is_editor] = (user.is_editor == 1)\n redirect_to :controller => 'home'\n else\n flash[:notice] = \"Invalid user/password combination\"\n end\n end\n end", "def create\n # Find the user\n user = User.find_by(email: params[:session][:email].downcase)\n # Get the password from the parameters\n password = params[:session][:password]\n # Try to authenticate the user\n if user && user.authenticate(password)\n flash[:success] = \"Welcome back #{user.username}\"\n # Store the user id in the session\n session[:user_id] = user.id\n # Redirect the user to its page\n redirect_to user_path(user)\n else\n # Since we are using render, there won't be another request, so we need to use flash.now\n flash.now[:danger] = \"Wrong email or password. Please try again.\"\n render :new\n end\n end", "def login_as\n unless session[:user] && session[:user].admin?\n redirect_to \"/\"\n return\n end\n\n user = params[:login_as]\n new_user = LinkedData::Client::Models::User.find_by_username(user).first\n\n if new_user\n session[:admin_user] = session[:user]\n session[:user] = new_user\n session[:user].apikey = session[:admin_user].apikey\n end\n\n #redirect_to request.referer rescue redirect_to \"/\"\n redirect_to \"/\"\n end", "def create\n puts \"I am in sessions create method with params.inspect of #{params.inspect}\"\n puts \"I am in sessions create method with params for user of #{params[:user]}\"\n puts \"I am in sessions create method with params of user's email #{params[:user][:email]}\"\n\n #TEST with LOWER case (as when saved to database):\n email = params[:user][:email]\n email.downcase!\n @user=User.find_by_email(email).try(:authenticate, params[:user][:password])\n puts \"Printing response from try to authenticate in sessions create method (null or user, or false): #{@user}\"\n \n # THIS IS WHERE SESSION GETS SET:\n # ================================\n if @user #(if !null or !false)\n session[:user_id][email protected]\n # Authenticate is true\n # -> save user id to session\n # -> redirect_to users profile page (i.e. get 'users/:id')\n redirect_to \"/groups\"\n else\n puts \"...Authenticate must have not found user or not authenticated. Displaying two flash errors on redirect to login...\"\n # If authenticate false or null,\n # 1) add an error message:\n # ====================================\n # flash[:notice] = [\"Message 1\"]\n # flash[:notice] << \"Message 2\"\n # AND IN VIEW: \n # <%= flash[:notice].join(\"<br>\") %>\n # ====================================\n flash[:errors] = [\"Invalid Login.\"]\n flash[:errors] << \"Incorrect Email or Wrong Password detected!\"\n # NOTE: \"notice\" and \"alert\" are very common keys in flash:\n # *****************************************************************\n # redirect_to root_url, flash: { referral_code: 1234 }\n # redirect_to root_url, notice: \"You have successfully logged out.\" \n # redirect_to root_url, alert: \"You're stuck here!\"\n # ******************************************************************\n # 2) and redirect_to 'login' view:\n redirect_to '/sessions/main'\n # Can ALSO simply *render* on unsuccessful submit, with flash.now[:error]=[\"Invalid Login\"], \n # to display flash *now*, instead of on next redirect. \n # (NOTE: also use flash.keep to persist for yet another redirect if used on next action to *catch it*)\n # ( render 'new' # renders the 'new.html.erb' in the sessions controller.)\n end\n end" ]
[ "0.7768877", "0.77146", "0.7703834", "0.75671303", "0.7548197", "0.753731", "0.753731", "0.75142854", "0.74666554", "0.74396724", "0.7395939", "0.7389997", "0.73797965", "0.73612833", "0.7356513", "0.73490715", "0.73417276", "0.7331857", "0.7320191", "0.73147863", "0.7310536", "0.72949797", "0.7293158", "0.72800833", "0.727682", "0.726924", "0.72686183", "0.7245603", "0.72435313", "0.72411996", "0.7193441", "0.7190058", "0.7185383", "0.7184417", "0.7176266", "0.7172944", "0.7170186", "0.7169339", "0.7166828", "0.716201", "0.7154259", "0.71477467", "0.7146167", "0.7135089", "0.713298", "0.7126642", "0.7125283", "0.7119009", "0.71049464", "0.7096957", "0.70855343", "0.70844877", "0.708419", "0.7082428", "0.7071317", "0.7070169", "0.70629054", "0.7059619", "0.7059421", "0.7040235", "0.70379555", "0.70334125", "0.7024726", "0.7024587", "0.70146513", "0.70129985", "0.7008454", "0.7003267", "0.7002157", "0.7001502", "0.7001208", "0.6988173", "0.6984991", "0.6980101", "0.6978043", "0.69747144", "0.69714284", "0.6971365", "0.6970746", "0.6965866", "0.69650626", "0.69506437", "0.6948543", "0.69444513", "0.69419587", "0.69384277", "0.693315", "0.6931834", "0.69301623", "0.6927897", "0.6927399", "0.6927202", "0.6926917", "0.69234806", "0.6918091", "0.6916552", "0.6904466", "0.690136", "0.6896535", "0.6892114" ]
0.731647
19
Logs out the user
def destroy session.delete(:current_user_key) redirect_to welcome_index_path, alert: "Logged out." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_out\n\t\t# current_user.delete_auth_token # won't work with curl, but html is good\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n reset_session\n @current_user = nil\n end", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user= nil\n\tend", "def log_out\n\t \tsession.delete(:user_id)\n\t \t@current_user =nil\n\t end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n\t\tforget(current_user) #call user.forget\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n \tsession.delete(:user_id)\n \t@current_user = nil\n end", "def log_out\n session.delete(:user_credentials)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n flash[:danger] = 'Logoff realizado!'\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out \n session.clear\n @current_user = nil\n end", "def log_out\n if !current_user.nil?\n forget(current_user)\n\n session.delete(:user_id)\n session.delete(:user_type)\n @current_user = nil\n end\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil \n end", "def log_out\n session.delete(:user_id)\n session.delete(:type)\n @current_user = nil\n end", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n forget current_user\n session.delete :user_id\n @current_user = nil\n end", "def log_out\n forget current_user\n reset_session\n @current_user = nil\n end", "def log_out\n forget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:id)\n\t\t@current_user = nil\n\t\tadmin_session(false)\n\tend", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n reset_session\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n session.delete(:user_name)\n session.delete(:user_email)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n session.delete(:user_type)\n session.delete(:user_email)\n @current_user = nil\n end", "def user_log_out\n user_forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n forget(@current_user)\n @current_user=nil\n end", "def log_out\n session.delete(:uid)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n session.delete(:user_type_string)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:username)\n @current_user = nil\n end", "def log_out\n session.delete(:username)\n session.delete(:token)\n @current_user = nil\n end", "def log_out\r\n forget(current_user)\r\n session.delete(:user_id)\r\n @current_user = nil\r\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user=nil\n end", "def log_out\n session.delete(:user_id) #remove the user id from the browser cache\n @current_user = nil\n end", "def user_log_out\n forget_user(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\t\t# Setting @current_user to nil would only matter if @current_user were created before the destroy action (which it isn’t) and if we didn’t issue an immediate redirect (which we do). This is an unlikely combination of events, and with the application as presently constructed it isn’t necessary, but because it’s security-related I include it for completeness\n\tend", "def log_out\n session.delete(:email)\n @current_user = nil\n end", "def log_out\n\t\tsession[:user_id] = nil\n\tend", "def log_out\n session.clear\n cookies.clear\n @current_user = nil\n end" ]
[ "0.86802506", "0.86800635", "0.8676711", "0.8676711", "0.8676711", "0.8676711", "0.867611", "0.86037326", "0.86012846", "0.8592121", "0.8592121", "0.8592121", "0.8592121", "0.8592121", "0.85710555", "0.8560465", "0.85463935", "0.8543438", "0.85410494", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.85408753", "0.8526091", "0.8517043", "0.8506113", "0.8498893", "0.84810865", "0.8479706", "0.8479706", "0.8479706", "0.8479706", "0.8479706", "0.8466147", "0.8460814", "0.8442614", "0.84342456", "0.8430976", "0.84304297", "0.84280545", "0.8425655", "0.84103715", "0.84062654", "0.8397619", "0.8386709", "0.83853316", "0.83852977", "0.8369959", "0.8362736", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356795", "0.8356307", "0.8354916", "0.832124", "0.8310746", "0.8304602", "0.8289231", "0.82741886", "0.8258356" ]
0.0
-1
Whitelist for user login parameters
def user_login_params params.permit(:username, :password) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def allow_params_authentication!; end", "def user_whitelist\r\n return [:user_id, :first_name, :last_name, :email, :account_type, :password, :password_confirmation, :security_question_id, :security_question_answer]\r\n end", "def require_login\n end", "def capable_login_auth?; end", "def require_login\n unless params[\"login\"].nil?\n #Call the devise helper to authenticate the user (returns back to orig dest)\n authenticate_user! if params[\"login\"] == \"true\"\n end\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n admin_access? && admin_user_filter || normal_user_filter\n end", "def access_whitelist\n current_user.try(:admin?) || current_user.try(:editor?) || current_user.try(:door_super?)\n end", "def param_whitelist\n [:role, :title]\n end", "def require_login\n unless params[\"login\"].nil?\n #Call the devise helper to authenticate the user (returns back to orig dest)\n authenticate_user! if params[\"login\"] == \"true\"\n end\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def users_params\n # Only allow :username & :password\n # Users can login with their username & passwords\n # Note: email support can be added later if needed.\n params.require(:user).permit(:username, :password)\n end", "def skip_login? \n false \nend", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def login_params\n begin\n p = params.require(:login)\n rescue\n return false\n end\n p.permit(:username, :password)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def user_params\n params.permit(:login, :password)\n end", "def needs_login?() false end", "def login_params\n params.permit(:username)\n end", "def valid_for_params_auth?; end", "def user_params\n params.require(:user).permit(:login)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def login_not_required\n false\n end", "def validate_login_user(params)\n params[\"username\"] and params[\"password\"] and params[\"password\"] == params[\"password_2\"]\n end", "def forbid_anonymous_user_param\n if is_anonymous? && params.has_key?('user')\n raise Forbidden, 'Not allowed to list other users environments, because '\\\n 'you are seen as an anonymous one'\n end\n end", "def login_required?\n true\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def skip_login?\n false\n end", "def login_required\n not_authorized unless current_user\n end", "def user_params\n allowed_params = [:username, :email, :jabber_id, :jabber_otr_fingerprint, :avatar]\n allowed_params << [:password, :password_confirmation] unless params[:user][:password].blank?\n allowed_params << [:role] if current_user.moderator_or_admin?\n allowed_params << [:tenant_ids => []] if current_user.admin?\n allowed_params << [:user_ids => []] if current_user.moderator_or_admin?\n params.require(:user).permit(allowed_params)\n end", "def login_params\n\t \tparams.require(:login).permit!\n\t end", "def restrict_access\n if session[:user_id]\n if !setting_params.nil?\n setting_params[:user_id] = session[:user_id]\n end\n else\n authenticate_or_request_with_http_token do |token, options|\n @user = User.where(:auth_token => token).first()\n if (@user)\n if !setting_params.nil?\n setting_params[:user_id] = @user.id\n end\n return true\n end\n false\n end\n end\n end", "def login_params\n params.require(:login).permit(:username, :password, :id, :telephone, :wishes, :reservations)\n end", "def refresh_ignores(e, params)\n return unless params.first == @password\n load_ignore_list\nend", "def set_login_attribute(opts)\n opts = check_params(opts,[:login_attributes])\n super(opts)\n end", "def login_check\n if current_user\n unless Whitelist.exists?(domain: current_user.email.match(/@.*/).to_s)\n redirect_to('/not_allow')\n end\n else\n redirect_to('/')\n end\n end", "def user_login_params\n params.require(:user_login).permit(:timestamp, :user_id)\n end", "def login_filter\n\t\tif not protect?( action_name )\n\t\t\treturn true \n\t\tend\n\n\t\tif not session[:user_id]\n\t\t\t# user isn't logged in\n\t\t\tstore_location\n\t\t\tredirect_to :controller=>\"account\", :action=>\"login\"\n\t\t\treturn false\n\t\tend\n\n\t\t# initialize the @user variable\n\t\t@user = User.find( session[:user_id] )\n\t\t\n\t\tif not @user.validated?\n\t\t\t# user is logged in, but they haven't been validated\n\t\t\tredirect_to :controller=>\"account\", :action=>\"not_activated\"\n\t\t\treturn false\n\t\telsif not authorized?( @user, action_name )\n\t\t\t# user is logged in and validated, but not authorized\n\t\t\tredirect_to :controller=>\"account\", :action =>\"denied\"\n\t\t\treturn false\n\t\telse\n\t\t\t# user is logged in AND validated AND authorized! let 'em in!\n\t\t\treturn true\t\n\t\tend\n\n\t\t# we shouldn't get here\n\t\traise \"Serious malfunction in 'login_filter' -- please contact manufacturer ([email protected])...\"\n\tend", "def login_request\n #TODO validate incoming parameters\n client_user = User.new params.require(:user).permit(\n :user,\n :external_id,\n :name,\n :email,\n :access_token,\n :profile_pictures)\n client_user.password = \"1\"\n\n # This is to spam calls to api which will cause unwanted entries into database \n\n existing_user = User.find_by(external_id: client_user.external_id)\n if existing_user.blank?\n client_user.save\n else\n # WHY IS THIS REQUIRED?\n existing_user.name = client_user.name\n\n # NO POINT SAVING THIS TOKEN - this is short lived.\n existing_user.access_token = client_user.access_token\n existing_user.email = client_user.email\n #existing_user.profile_pictures = client_user.profile_pictures\n existing_user.save\n end\n log_in(client_user)\n render :nothing => true\n end", "def login_params\n params.require(:login).permit(:user_login, :password)\n end", "def require_user_login *valid_users\n if !current_user or (!valid_users.empty? and !valid_users.include?(current_user))\n # TODO: if current_user, but not valid, use 403, otherwise 401\n session[:last_params] = params\n flash[:notice] = 'You need to login to proceed.'\n redirect_to login_url_for_this_controller\n return\n else\n true\n end\n end", "def login_required\n raise Forbidden unless @current_member #ログイン状態でないとForbiddenを発生させる\n end", "def authenticate_user\n render_403 'Invalid user.' if @user.blank? || [email protected]?\n end", "def login_required\n return if authorized?\n unauthorized! unless auth.provided?\n bad_request! unless auth.basic?\n unauthorized! unless authorize(*auth.credentials)\n @req.env['REMOTE_USER'] = auth.username\n end", "def clean_args(args)\r\n require_arg(args, :username)\r\n require_arg(args, :password)\r\n args[:username] = args[:username].downcase\r\n args[:override] = false unless args.key?(:override)\r\n return args\r\n end", "def user_params\n params.permit(\n :username,\n :password\n )\n end", "def user_params\n {username: params[:username], email: params[:email], password: params[:password], admin: false }\n end", "def login_params\n # params.require(:login).permit(:paassword)\n end", "def user_params\n if params[:user].present? && params[:user].key?(:password)\n if !current_user.is_admin || params[:user][:password].blank?\n params[:user].delete :password\n end\n end\n\n if params[:user].present? && params[:user].key?(:name)\n if !current_user.is_admin || params[:user][:name].blank?\n params[:user].delete :name\n end\n end\n\n params.require(:user).permit(:name, :handle, :password)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def before_request\n self.login if require_login? && !@authenticating\n end", "def filter_users\n allowed_keys=[\"email\", \"admin\"]\n filtering_keys=allowed_keys & params.keys\n filtering_keys.each {|key| filter_by_key(key)}\n end", "def user_params\n params.require(:user).permit(:login, :email, :password, :password_confirmation, :character_id, :city, :admin, :provider, :url)\n end", "def check_if_login_required\n false\n end", "def login(username:, password:)\n if password == 'test'\n print username, 'ALLOWED'\n else\n print username, 'DENIED'\n end\nend", "def sanitize_credentials\n if params[:user_session]\n params[:user_session][:login].strip!\n params[:user_session][:password].strip!\n end\n end", "def sanitize_credentials\n if params[:user_session]\n params[:user_session][:login].strip!\n params[:user_session][:password].strip!\n end\n end", "def allow_login_as_specific_user?\n return self.class.allow_login_as_specific_user?\n end", "def auth_param; end", "def user_params\n params.permit(\n :username,\n :password\n )\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def login_params\n params.permit(:email, :password)\n end", "def login_required\n authenticate_user! \n end", "def user_params\n params.require(:user).permit(:login, :password)\n end", "def user_params\nparams.require(:user).permit(:name, :login, :password)\nend", "def login; end", "def user_credentials\n keys = %w[nome cognome email password]\n user_params = select_params(params, keys)\n user_params\n end", "def login_params\n params.require(:login).permit(:username, :password)\n end", "def login_params\n params.permit(:email, :password)\n end", "def user_params #este metodo SE PUEDE LLAMAR COMO QUIERAS, pero es necesario para que al crear un objeto se autorice su creacion (porque si no nos podrían meter codigo malicioso)\n\t\tparams.require(:user).permit(:name, :email, :password)\n\tend", "def require_user\n end", "def user_params\n params.require(:user).permit(:login_id, :name, :kana, :mailaddress, :password, :password_confirmation)\n end", "def allowedusers_only\n \n\t\tallowed_users=[VendorPortal::Application.config.operationadmin.to_s,VendorPortal::Application.config.operationuser.to_s,VendorPortal::Application.config.vendor.to_s]\n\t\n if !current_user.userrole.in?(allowed_users)\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end", "def allowedusers_only\n \n\t\tallowed_users=[VendorPortal::Application.config.operationadmin.to_s,VendorPortal::Application.config.operationuser.to_s,VendorPortal::Application.config.vendor.to_s]\n\t\n if !current_user.userrole.in?(allowed_users)\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end", "def allowedusers_only\n \n\t\tallowed_users=[VendorPortal::Application.config.operationadmin.to_s,VendorPortal::Application.config.operationuser.to_s,VendorPortal::Application.config.vendor.to_s]\n\t\n if !current_user.userrole.in?(allowed_users)\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end", "def allowedusers_only\n \n\t\tallowed_users=[VendorPortal::Application.config.operationadmin.to_s,VendorPortal::Application.config.operationuser.to_s,VendorPortal::Application.config.vendor.to_s]\n\t\n if !current_user.userrole.in?(allowed_users)\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end", "def user_params\n params.\n require(:user).\n permit :name, :password, :password_confirmation, :password_digest, :import, :import_type_id, :import_contents\n end", "def userl_params\n params.require(:userl).permit(:name, :email, :login)\n end", "def user_params\n params.require(:user).permit(:name, :password, :logins)\n end", "def skip_password_check(*)\n puts \"Skipped password check\"\n true\n end", "def require_login\n not_authorized(\"Please sign up or log in above to access this resource.\") unless current_user\n end", "def user_params\n params.require(:user).permit(:username, :email, :age, :political_affiliation, :password)\n # this is saying go into params look for a key of what is in the require() method and look inside that object for the keys included in permit()\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def login\n self.class.trace_execution_scoped(['Custom/login/find_user']) do\n @u = (User.find_by_primary_email(params[:username].downcase) || User.find_by_nickname(params[:username].downcase.to_s)) if params[:username]\n end\n\n self.class.trace_execution_scoped(['Custom/login/if_block']) do\n if @u and @u.has_password? and @u.valid_password?(params[:password])\n @user = @u\n elsif @u and (params[:password] == \"anonymous\") and (@u.user_type == User::USER_TYPE[:anonymous])\n @user = @u\n else\n query = {:auth_failure => 1, :auth_strategy => \"that username/password\"}\n query[:redir] = params[:redir] if params[:redir]\n redirect_to add_query_params(request.referer || Settings::ShelbyAPI.web_root, query) and return\n end\n end\n\n # any user with valid email/password is a valid Shelby user\n # this sets up redirect\n self.class.trace_execution_scoped(['Custom/login/sign_in_current_user']) do\n sign_in_current_user(@user)\n end\n redirect_to clean_query_params(@opener_location) and return\n end", "def session_params\n params.require(:login).permit(:username_or_email, :password)\n end", "def user_params\n params.require(:user).permit(:login, :email, :username, :password, :password_confirmation, :admin)\n end", "def check_login\n head :forbidden unless self.current_user\n end", "def authenticate_user!\n token, options = ActionController::HttpAuthentication::Token.token_and_options(request)\n\n super unless token == 'rbMmEeoH8RxRDyN24PQv'\n end", "def find_for_authentication(tainted_conditions); end", "def user_params\n end", "def user_params_without_password\n params.required(:user).permit(:first_name, :last_name, :email)\n end", "def sys_user_params\n params.require(:sys_user).permit(:login_name, :name)\n end", "def allow_anon\n end", "def user_params\n params.fetch(:user).permit(:name, :email, :is_admin, :password)\n end", "def user_params\n params.permit(:name, :email, :pw)\n end", "def require_login_by\n @attributes[:require_login_by]\n end", "def user_params\n params.require(:user).permit(\n :email, :is_administrator, :is_data_viewer, :is_data_downloader\n )\n end", "def user_params\r\n end" ]
[ "0.70640767", "0.7019153", "0.7005046", "0.67017156", "0.66738164", "0.6460137", "0.64267594", "0.640785", "0.63886124", "0.63816863", "0.6336889", "0.6334745", "0.6329563", "0.63078976", "0.6278103", "0.6277226", "0.62734133", "0.62715596", "0.6265148", "0.6239603", "0.6223809", "0.62138724", "0.6210349", "0.6205002", "0.61891466", "0.61882603", "0.6169208", "0.6139134", "0.6130344", "0.61196554", "0.6101532", "0.6089391", "0.60862964", "0.6076962", "0.60714424", "0.6062381", "0.6061477", "0.60594976", "0.6052568", "0.60370344", "0.6021535", "0.6012474", "0.601115", "0.5997786", "0.59899837", "0.59836406", "0.59834987", "0.5982927", "0.59717315", "0.59695554", "0.5965641", "0.5965641", "0.59540737", "0.59491533", "0.594816", "0.59480953", "0.5942875", "0.5941749", "0.5941749", "0.59255373", "0.59240603", "0.59039176", "0.58979106", "0.5887782", "0.5886363", "0.5884682", "0.5882", "0.58679366", "0.58658755", "0.58617944", "0.58514637", "0.5850096", "0.5842393", "0.5841405", "0.5840159", "0.5840159", "0.5840159", "0.5840159", "0.5834899", "0.58333063", "0.58277166", "0.58226955", "0.58223933", "0.5819792", "0.5816916", "0.5812534", "0.58100843", "0.58060724", "0.5803541", "0.5802836", "0.5801363", "0.57999873", "0.5798947", "0.5796247", "0.5795109", "0.5792338", "0.5791112", "0.57903826", "0.5780006", "0.57796925" ]
0.64515394
6
GET /auth_properties GET /auth_properties.json
def index @auth_properties = AuthProperty.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_properties()\n resp = conn.get('/users/'+name+'/props/')\n \n case resp.code.to_i\n when 200\n return JSON.parse(resp.body)\n when 404\n raise RestAuthUserNotFound.new( resp )\n else\n raise RestAuthUnknownStatus.new( rest )\n end\n end", "def get_property( propname )\n resp = conn.get('/users/'+name+'/props/'+propname+'/')\n \n case resp.code.to_i\n when 200\n return JSON.parse( resp.body )\n when 404\n case resp.header['resource-type']\n when 'user'\n raise RestAuthUserNotFound.new( resp )\n when 'property'\n raise RestAuthPropertyNotFound.new( resp )\n else\n raise RestAuthBadResponse.new( resp, \"Received 404 without Resource-Type header\" )\n end\n else\n raise RestAuthUnknownStatus.new( resp )\n end\n end", "def index\n properties = current_user.properties\n\n if properties.any?\n render status: 200, json: { properties: properties.to_json }\n else\n render status: 404, json: { error: 'You have no properties' }\n end\n end", "def property_keys\n headers = { 'Accept' => 'application/json; charset=UTF-8' }\n get_request 'propertykeys', headers\n end", "def my_properties\n @api_v1_properties = current_api_v1_user.properties.\n includes(:reservations).\n order(\"reservations.created_at DESC\")\n\n render template: '/api/v1/properties/index', status: 200\n end", "def my_properties\n @api_v1_properties = current_api_v1_user.properties\n .includes(:reservations)\n .order('reservations.created_at DESC')\n\n render template: '/api/v1/properties/index', status: 200\n end", "def index\n @properties = Property.all\n authorize @properties\n end", "def index\n @properties = current_user.properties.order(:id => :desc)\n render \"index.json.jb\"\n end", "def show\n authorize_action_for @property, at: current_store\n\n respond_to do |format|\n format.json { render json: @property.product_properties, status: 200 }\n format.html\n end\n end", "def index\n @current_api_v1_user = current_api_v1_user\n @api_v1_properties = Property.all\n end", "def get_server_properties\n http_get(:uri=>\"/server/properties\", :fields=>x_cookie)\n end", "def index\n properties = current_user.properties\n respond_to do |format|\n format.json { render :json => jsonp(properties_to_json(properties)) }\n format.xml { render :xml => properties_to_xml(properties) }\n format.text { render :text => text_not_supported }\n end\n end", "def show\n id = user_is_admin? ? params[:id] : session[:current_user_id]\n @user = User.find(id)\n\n @properties = @user.properties\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user }\n end\n end", "def index\n @properties = @user.properties.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @properties }\n end\n end", "def set_auth_property\n @auth_property = AuthProperty.find(params[:id])\n end", "def get_properties\n xml = client.call(\"#{attributes[:url]}/property\").parsed_response\n xml.css('properties property').map { |p| Vebra::Property.new(p, self) }\n end", "def index\n if @property.nil? || @property.user.id != @user.id\n redirect_to properties_path, notice: \"Not Authorized\" \n end\n end", "def index\n @api_v1_properties = Api::V1::Property.all\n end", "def index\n @request_properties = current_user.request_property\n end", "def index\n authorize_action_for Property, at: current_store\n @properties = current_store.properties\n end", "def get_app_properties(*properties)\n json = @session.post('facebook.admin.getAppProperties', :properties => properties.to_json)\n hash = JSON.parse(CGI.unescapeHTML(json))\n @properties = ApplicationProperties.from_hash(hash)\n end", "def get_app_properties(*properties)\n json = @session.post('facebook.admin.getAppProperties', :properties => properties.to_json)\n hash = JSON.parse(CGI.unescapeHTML(json))\n @properties = ApplicationProperties.from_hash(hash)\n end", "def show\n property = Property.by_key(params[:id], nil, current_user.id)\n if property\n respond_to do |format|\n format.json { render :json => jsonp(properties_to_json([property])) }\n format.xml { render :xml => properties_to_xml([property]) }\n format.text { render :text => text_not_supported }\n end\n else\n render_error('Not found', 404)\n end\n end", "def show\n @property_user = PropertyUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property_user }\n end\n end", "def update\n respond_to do |format|\n if @auth_property.update(auth_property_params)\n format.html { redirect_to [@owner, @token, @auth_property], notice: 'Auth property was successfully updated.' }\n format.json { render :show, status: :ok, location: @auth_property }\n else\n format.html { render :edit }\n format.json { render json: @auth_property.errors, status: :unprocessable_entity }\n end\n end\n end", "def properties\n # vendor = Vendor.find(params[:vendor_id])\n search_params = { vendor_id: params[:vendor_id].to_i, results_per_page: 150 }\n search_params[:p] = params[:p].to_i if params[:p]\n pd = PropertySearchApi.new(filtered_params: search_params )\n pd.query[:size] = 1000\n results, status = pd.filter\n results[:results].each { |e| e[:address] = PropertyDetails.address(e) }\n response = results[:results].map { |e| e.slice(:udprn, :address) }\n response = response.sort_by{ |t| t[:address] }\n #Rails.logger.info \"sending response for vendor properties -> #{response.inspect}\"\n render json: response, status: status\n end", "def web_properties\n WebProperty.all(:account => self)\n end", "def properties_get(opts = {})\n data, _status_code, _headers = properties_get_with_http_info(opts)\n return data\n end", "def auth_property_params\n params.require(:auth_property).permit(:key, :txtValue, :numValue, :token)\n end", "def properties_get_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PropertiesApi.properties_get ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling PropertiesApi.properties_get\"\n end\n # resource path\n local_var_path = '/v1/properties/{id}'.sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'text/html'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'DomainPublicAdapterWebApiModelsV1PropertiesProperty')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PropertiesApi#properties_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @contact = Contact.find(params[:contact_id])\n @property = Property.find(params[:id])\n authorize @property\n end", "def index\n @allowed = false\n if check_permissions?(session[:user_type], \"create_property\")\n @allowed = true\n end\n @properties = Property.all\n end", "def get_properties\n\n begin\n str_uri = $product_uri + '/words/' + @filename + '/documentProperties'\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n\n response_stream = RestClient.get(signed_str_uri, {:accept => 'application/json'})\n\n stream_hash = JSON.parse(response_stream)\n\n return stream_hash['DocumentProperties']['List'] if stream_hash['Code'] == 200\n false\n\n rescue Exception => e\n print e\n end\n\n end", "def property_properties\n _property_properties\n end", "def my_listing\n \tif authorize_agent?\n \t\t@property = @current_user.properties.where(is_active: true).includes(:property_detail).order(\"id DESC\")#.where(status: \"For Sale\")\n \t\tif @property.present?\n \t\t\trender :file => 'api/v1/property/my_listing'\n \t\telse\n \t\t\trender_json({\"status\" => \"Fail\", \"message\" => \"No property found.\"}.to_json)\n \t\tend\n \telse\n \t\trender_json({\"status\" => \"Fail\", \"message\" => \"Not authorize to view property(LogIn as Agent).\"}.to_json)\n \tend\n end", "def index\n @properties = Property.all\n\n render json: @properties\n end", "def get_properties\n \n begin\n \n if @filename == \"\"\n raise \"Base file not specified.\"\n end\n \n str_uri = $productURI + \"/words/\" + @filename + \"/documentProperties\"\n signed_str_uri = Common::Utils.sign(str_uri)\n \n response_stream = RestClient.get(signed_str_uri,{:accept=>\"application/json\"})\n \n stream_hash = JSON.parse(response_stream)\n \n if(stream_hash[\"Code\"] == 200)\n return stream_hash[\"DocumentProperties\"][\"List\"]\n else\n return false\n end\n \n rescue Exception=>e\n print e\n end\n \n end", "def auth_oauth\n @attributes[:auth_oauth]\n end", "def show\n @property = Property.find(params[:id])\n\n render json: @property\n end", "def available_properties\n @properties ||= list.properties\n end", "def get_view_properties_with_http_info(name, password = nil, folder = nil, storage = nil)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.get_view_properties ...'\n end\n\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling SlidesApi.get_view_properties\"\n end\n # resource path\n local_var_path = '/slides/{name}/viewProperties'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'name', name)\n\n # query parameters\n query_params = {}\n query_params[:'folder'] = @api_client.prepare_for_query(folder) unless folder.nil?\n query_params[:'storage'] = @api_client.prepare_for_query(storage) unless storage.nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'password'] = password unless password.nil?\n\n # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'ViewProperties')\n return data, status_code, headers\n end", "def show\n format = params[:format] || 'json'\n data = @container.config.get_properties(flavor: :public, format: format)\n\n render response_ok data\n end", "def index\n @properties = @user.properties.all\n # if params[:search]\n # @properties = @user.properties.search(params[:search], params[:page]).order(\"created_at DESC\")\n \n\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @properties }\n # end\n # else\n # @properties = Property.order(\"created_at DESC\")\n # end\n\n end", "def relationship_get_all_props id\n headers = {\n 'Accept' => 'application/json; charset=UTF-8',\n }\n get_request 'relationship/' + id + '/properties', headers\n end", "def get_properties\n \n begin\n \n if @filename == ''\n raise 'Base file not specified.'\n end\n \n str_uri = $product_uri + '/slides/' + @filename + '/documentProperties'\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n \n response_stream = RestClient.get(signed_str_uri,{:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n if(stream_hash['Code'] == 200)\n return stream_hash['DocumentProperties']['List']\n else\n return false\n end\n \n rescue Exception=>e\n print e\n end\n \n end", "def properties\n @properties\n end", "def fetch_properties(host)\n fetcher = Commands::PropertiesFetcher.new(credentials)\n fetcher.call(mc_id: host.identifier)\n end", "def properties\n return @values['properties'] if @values.key?('properties')\n @values['properties'] = {}\n @values['properties']\n end", "def query\n @property_hash\n end", "def client_properties\n end", "def index\n @properties = Property.with_deleted.where(id: AccessResource.get_ids(resource_klass: 'Property', user: current_user))\n @properties = @properties.where(deleted_at: nil) unless params[:trashed].to_b\n @properties = @properties.where.not(deleted_at: nil) if params[:trashed].to_b\n @last = @properties.try(:last).try(:id) || 0\n if params[\"purchased\"]\n if ((params[\"purchased\"][\"accepted\"] == \"1\") && (params[\"prospective_purchase\"][\"accepted\"] == \"1\"))\n elsif ((params[\"purchased\"][\"accepted\"] == \"0\") && (params[\"prospective_purchase\"][\"accepted\"] == \"0\"))\n @properties = @properties.where.not(ownership_status: ['Prospective Purchase', 'Purchased'])\n else\n @properties = @properties.where(ownership_status: 'Purchased') if params[\"purchased\"][\"accepted\"] == \"1\"\n @properties = @properties.where(ownership_status: 'Prospective Purchase') if params[\"prospective_purchase\"][\"accepted\"] == \"1\"\n end\n end\n @properties = @properties.order(created_at: :desc).paginate(page: params[:page], per_page: sessioned_per_page)\n @activeId = params[:active_id]\n \n render template: 'properties/xhr_list', layout: false if request.xhr?\n end", "def get_protection_properties_with_http_info(name, password = nil, folder = nil, storage = nil)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.get_protection_properties ...'\n end\n\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling SlidesApi.get_protection_properties\"\n end\n # resource path\n local_var_path = '/slides/{name}/protection'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'name', name)\n\n # query parameters\n query_params = {}\n query_params[:'folder'] = @api_client.prepare_for_query(folder) unless folder.nil?\n query_params[:'storage'] = @api_client.prepare_for_query(storage) unless storage.nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'password'] = password unless password.nil?\n\n # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'ProtectionProperties')\n return data, status_code, headers\n end", "def show\n @estate_agent = EstateAgent.find(params[:id])\n @properties = Property.where(\"estate_agent_id = ?\", @estate_agent.id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @properties }\n end\n end", "def show\n if @canister.nil?\n head :not_found\n else\n render json: @canister.properties\n end\n end", "def index\n @properties = Property.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @properties }\n end\n end", "def get_properties(options={})\n return send_message(SkyDB::Message::GetProperties.new(options))\n end", "def featured\n properties = []\n begin\n # Try to get the 3 properties with priority flag\n Property.where(priority: true, status: :active).order('RANDOM()').limit(3).each { |p| properties << p }\n\n # Get the missing properties\n missing = 3 - properties.count\n Property.where(priority: false, status: :active).order('RANDOM()').limit(missing).each { |p| properties << p } if missing > 0\n\n @api_v1_properties = properties\n\n render template: '/api/v1/properties/index', status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end\n end", "def get_properties()\n return @properties\n end", "def get_user_info\n get(\"/api/v1/oauth_user_info.json\")\n end", "def create\n @auth_property = AuthProperty.new(auth_property_params)\n @token.authProperties << @auth_property\n\n respond_to do |format|\n if @auth_property.save\n format.html { redirect_to [@owner, @token, @auth_property], notice: 'Auth property was successfully created.' }\n format.json { render :show, status: :created, location: @auth_property }\n else\n format.html { render :new }\n format.json { render json: @auth_property.errors, status: :unprocessable_entity }\n end\n end\n end", "def relationship_get_property id, name\n headers = {\n 'Accept' => 'application/json; charset=UTF-8',\n }\n\n get_request 'relationship/' + id + '/properties/' + name, headers\n end", "def all_ant_properties\n _get_ant_properties_as_hash\n end", "def web_properties\n Management::WebProperty.all(self)\n end", "def params_auth_hash; end", "def auth_info\n render :action => 'auth_info.json', :layout => false\n end", "def index\n @properties = ((current_person== current_admin)? Property.all : Property.where(user:current_person)).paginate(:page => params[:page], :per_page => 3)\n\n end", "def index\n\n @properties = Property.search( params[:query] || \"\" )\n\n respond_to do |format|\n\n format.html\n format.json { render json: @properties }\n\n end\n\n end", "def properties\n _properties\n end", "def properties\n @properties\n end", "def property_params\n params[:property]\n end", "def get_prop(values)\n cmd = \"{\\\"id\\\":1,\\\"method\\\":\\\"get_prop\\\",\\\"params\\\":[#{values}]}\\r\\n\"\n request(cmd)\n end", "def show\n @property = Property.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end", "def show\n @product_template = ProductTemplate.find(params[:id])\n @keys = @product_template.properties.keys\n @values = @product_template.properties.values\n end", "def auth\n cfg_get(:auth)\n end", "def index\n @contact_properties = @active_org.contact_properties\n\n if current_person.has_role?(:super_admin)\n @contact_properties = ContactProperty.all\n end\n end", "def get_auth()\n\t\t\tfind_attributes(\"auth\").first\n\t\tend", "def property_details\n details = VendorApi.new(params[:udprn].to_i, nil, params[:vendor_id].to_i).property_details\n render json: details, status: 200\n end", "def index\n @properties = Property.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @properties }\n end\n end", "def index\n @properties = Property.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @properties }\n end\n end", "def index\n @properties = Property.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @properties }\n end\n end", "def get_properties_with_http_info(uuid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectPropertyApi.get_properties ...'\n end\n # verify the required parameter 'uuid' is set\n if @api_client.config.client_side_validation && uuid.nil?\n fail ArgumentError, \"Missing the required parameter 'uuid' when calling ProjectPropertyApi.get_properties\"\n end\n # resource path\n local_var_path = '/v1/project/{uuid}/property'.sub('{' + 'uuid' + '}', CGI.escape(uuid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<ProjectProperty>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectPropertyApi#get_properties\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def properties(path, ctype=DEFAULT_CTYPE)\n node = metadata(path, ctype, :properties)[:properties]\n node ? node.contents : @metadata_tree.default_data(:properties)\n end", "def show\n @property = Property.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end", "def show\n @property = Property.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end", "def show\n @property = Property.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end", "def show\n @property = Property.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end", "def auth_oauth_custom\n @attributes[:auth_oauth_custom]\n end", "def get_property\n @xml = client.call(url).parsed_response.css('property').first\n @attributes.merge!(parse_xml_to_hash)\n end", "def index\n @properties = Property.order(:id).page (params[:page])\n end", "def show\n property = Property.find params[:id]\n respond_to do |format|\n format.html {}\n format.json { render :json => property}\n end\n end", "def get_by_property\n @api_v1_reservation = current_api_v1_user.properties.find(params[:id]).reservations\n render template: '/api/v1/reservations/index', status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end", "def index\n auth_response = plaid_client.auth.get(access_token)\n render json: auth_response.to_json\n end", "def read_properties\n buf = ''\n File.open( properties_file, 'r' ) { |f| buf = f.read }\n h = JSON.parse(buf, {:symbolize_names => true})\n @name = h.delete(:name).to_s\n @created= h.delete(:created).to_s\n @description = h.delete(:description).to_s\n @repo_properties = h\n end", "def show\n @auth = Auth.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @auth }\n end\n end", "def featured\n properties = []\n begin\n # Tenta pegar 3 propriedades com a flag de prioridade\n Property.where(priority: true, status: :active).order(\"RANDOM()\").limit(3).each {|p| properties << p}\n # Verifica quantas propriedades faltam pra completar 3\n missing = 3 - properties.count\n # Pega as propriedades faltantes caso existam\n Property.where(status: :active).order(\"RANDOM()\").limit(missing).each {|p| properties << p} if missing > 0\n\n @api_v1_properties = properties\n\n render template: '/api/v1/properties/index', status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end\n end", "def auth\n cfg_get(:auth)\n end", "def index\n @client_properties = ClientProperty.all\n end", "def http_auth_hash; end", "def required_properties\n {\n \"cc\" => {\n \"internal_service_hostname\" => \"cc.service.cf.internal\"\n },\n \"loggregator\" => {\n \"etcd\" => {\n \"machines\" => []\n },\n \"uaa\" => {\n \"client_secret\" => \"secret\"\n }\n },\n \"system_domain\" => \"bosh-lite.com\",\n }\n end", "def get_slide_show_properties_with_http_info(name, password = nil, folder = nil, storage = nil)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.get_slide_show_properties ...'\n end\n\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling SlidesApi.get_slide_show_properties\"\n end\n # resource path\n local_var_path = '/slides/{name}/slideShowProperties'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'name', name)\n\n # query parameters\n query_params = {}\n query_params[:'folder'] = @api_client.prepare_for_query(folder) unless folder.nil?\n query_params[:'storage'] = @api_client.prepare_for_query(storage) unless storage.nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'password'] = password unless password.nil?\n\n # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'SlideShowProperties')\n return data, status_code, headers\n end" ]
[ "0.80248255", "0.6984377", "0.6936408", "0.6901678", "0.68921906", "0.6604292", "0.65807223", "0.6557547", "0.655344", "0.64932954", "0.6402689", "0.6352764", "0.6323409", "0.6283516", "0.6257075", "0.6247004", "0.62343067", "0.6204378", "0.61678505", "0.6162262", "0.61421895", "0.61421895", "0.61324745", "0.61273295", "0.6059208", "0.6058673", "0.60574263", "0.60333335", "0.6009386", "0.5995633", "0.59934396", "0.59555894", "0.5947655", "0.59344375", "0.5908562", "0.5907621", "0.5893818", "0.58778465", "0.58730346", "0.58705425", "0.5866898", "0.5864746", "0.58524567", "0.58516", "0.5836112", "0.5821774", "0.57998675", "0.5790843", "0.5787758", "0.57847095", "0.57754713", "0.57720107", "0.5768182", "0.5763542", "0.5761617", "0.57358176", "0.5735176", "0.573157", "0.5719931", "0.5714303", "0.571369", "0.5710444", "0.5704427", "0.57007295", "0.5687238", "0.5681609", "0.567045", "0.5641301", "0.5641293", "0.5640206", "0.56392974", "0.5639291", "0.5631542", "0.5624857", "0.5624506", "0.562183", "0.56109774", "0.5610441", "0.5610441", "0.56102055", "0.56012404", "0.5600742", "0.5589209", "0.5589209", "0.5589209", "0.5589209", "0.5588008", "0.55830336", "0.55826074", "0.55772734", "0.55727863", "0.556647", "0.55660385", "0.5545229", "0.55451334", "0.55438805", "0.5542543", "0.553873", "0.55377835", "0.5533302" ]
0.75055593
1
GET /auth_properties/1 GET /auth_properties/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_properties()\n resp = conn.get('/users/'+name+'/props/')\n \n case resp.code.to_i\n when 200\n return JSON.parse(resp.body)\n when 404\n raise RestAuthUserNotFound.new( resp )\n else\n raise RestAuthUnknownStatus.new( rest )\n end\n end", "def index\n @auth_properties = AuthProperty.all\n end", "def get_property( propname )\n resp = conn.get('/users/'+name+'/props/'+propname+'/')\n \n case resp.code.to_i\n when 200\n return JSON.parse( resp.body )\n when 404\n case resp.header['resource-type']\n when 'user'\n raise RestAuthUserNotFound.new( resp )\n when 'property'\n raise RestAuthPropertyNotFound.new( resp )\n else\n raise RestAuthBadResponse.new( resp, \"Received 404 without Resource-Type header\" )\n end\n else\n raise RestAuthUnknownStatus.new( resp )\n end\n end", "def my_properties\n @api_v1_properties = current_api_v1_user.properties.\n includes(:reservations).\n order(\"reservations.created_at DESC\")\n\n render template: '/api/v1/properties/index', status: 200\n end", "def index\n properties = current_user.properties\n\n if properties.any?\n render status: 200, json: { properties: properties.to_json }\n else\n render status: 404, json: { error: 'You have no properties' }\n end\n end", "def index\n @current_api_v1_user = current_api_v1_user\n @api_v1_properties = Property.all\n end", "def my_properties\n @api_v1_properties = current_api_v1_user.properties\n .includes(:reservations)\n .order('reservations.created_at DESC')\n\n render template: '/api/v1/properties/index', status: 200\n end", "def property_keys\n headers = { 'Accept' => 'application/json; charset=UTF-8' }\n get_request 'propertykeys', headers\n end", "def index\n @properties = current_user.properties.order(:id => :desc)\n render \"index.json.jb\"\n end", "def show\n authorize_action_for @property, at: current_store\n\n respond_to do |format|\n format.json { render json: @property.product_properties, status: 200 }\n format.html\n end\n end", "def set_auth_property\n @auth_property = AuthProperty.find(params[:id])\n end", "def index\n @api_v1_properties = Api::V1::Property.all\n end", "def index\n @properties = Property.all\n authorize @properties\n end", "def index\n if @property.nil? || @property.user.id != @user.id\n redirect_to properties_path, notice: \"Not Authorized\" \n end\n end", "def index\n @properties = @user.properties.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @properties }\n end\n end", "def show\n id = user_is_admin? ? params[:id] : session[:current_user_id]\n @user = User.find(id)\n\n @properties = @user.properties\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user }\n end\n end", "def show\n @property_user = PropertyUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property_user }\n end\n end", "def show\n property = Property.by_key(params[:id], nil, current_user.id)\n if property\n respond_to do |format|\n format.json { render :json => jsonp(properties_to_json([property])) }\n format.xml { render :xml => properties_to_xml([property]) }\n format.text { render :text => text_not_supported }\n end\n else\n render_error('Not found', 404)\n end\n end", "def get_properties\n xml = client.call(\"#{attributes[:url]}/property\").parsed_response\n xml.css('properties property').map { |p| Vebra::Property.new(p, self) }\n end", "def get_server_properties\n http_get(:uri=>\"/server/properties\", :fields=>x_cookie)\n end", "def index\n properties = current_user.properties\n respond_to do |format|\n format.json { render :json => jsonp(properties_to_json(properties)) }\n format.xml { render :xml => properties_to_xml(properties) }\n format.text { render :text => text_not_supported }\n end\n end", "def properties_get_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PropertiesApi.properties_get ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling PropertiesApi.properties_get\"\n end\n # resource path\n local_var_path = '/v1/properties/{id}'.sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'text/html'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'DomainPublicAdapterWebApiModelsV1PropertiesProperty')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PropertiesApi#properties_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @property = Property.find(params[:id])\n\n render json: @property\n end", "def web_properties\n WebProperty.all(:account => self)\n end", "def update\n respond_to do |format|\n if @auth_property.update(auth_property_params)\n format.html { redirect_to [@owner, @token, @auth_property], notice: 'Auth property was successfully updated.' }\n format.json { render :show, status: :ok, location: @auth_property }\n else\n format.html { render :edit }\n format.json { render json: @auth_property.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @request_properties = current_user.request_property\n end", "def relationship_get_property id, name\n headers = {\n 'Accept' => 'application/json; charset=UTF-8',\n }\n\n get_request 'relationship/' + id + '/properties/' + name, headers\n end", "def index\n authorize_action_for Property, at: current_store\n @properties = current_store.properties\n end", "def properties\n # vendor = Vendor.find(params[:vendor_id])\n search_params = { vendor_id: params[:vendor_id].to_i, results_per_page: 150 }\n search_params[:p] = params[:p].to_i if params[:p]\n pd = PropertySearchApi.new(filtered_params: search_params )\n pd.query[:size] = 1000\n results, status = pd.filter\n results[:results].each { |e| e[:address] = PropertyDetails.address(e) }\n response = results[:results].map { |e| e.slice(:udprn, :address) }\n response = response.sort_by{ |t| t[:address] }\n #Rails.logger.info \"sending response for vendor properties -> #{response.inspect}\"\n render json: response, status: status\n end", "def get_app_properties(*properties)\n json = @session.post('facebook.admin.getAppProperties', :properties => properties.to_json)\n hash = JSON.parse(CGI.unescapeHTML(json))\n @properties = ApplicationProperties.from_hash(hash)\n end", "def get_app_properties(*properties)\n json = @session.post('facebook.admin.getAppProperties', :properties => properties.to_json)\n hash = JSON.parse(CGI.unescapeHTML(json))\n @properties = ApplicationProperties.from_hash(hash)\n end", "def index\n @allowed = false\n if check_permissions?(session[:user_type], \"create_property\")\n @allowed = true\n end\n @properties = Property.all\n end", "def index\n @properties = Property.all\n\n render json: @properties\n end", "def show\n @contact = Contact.find(params[:contact_id])\n @property = Property.find(params[:id])\n authorize @property\n end", "def show\n @property = Property.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end", "def my_listing\n \tif authorize_agent?\n \t\t@property = @current_user.properties.where(is_active: true).includes(:property_detail).order(\"id DESC\")#.where(status: \"For Sale\")\n \t\tif @property.present?\n \t\t\trender :file => 'api/v1/property/my_listing'\n \t\telse\n \t\t\trender_json({\"status\" => \"Fail\", \"message\" => \"No property found.\"}.to_json)\n \t\tend\n \telse\n \t\trender_json({\"status\" => \"Fail\", \"message\" => \"Not authorize to view property(LogIn as Agent).\"}.to_json)\n \tend\n end", "def properties_get(opts = {})\n data, _status_code, _headers = properties_get_with_http_info(opts)\n return data\n end", "def auth_property_params\n params.require(:auth_property).permit(:key, :txtValue, :numValue, :token)\n end", "def relationship_get_all_props id\n headers = {\n 'Accept' => 'application/json; charset=UTF-8',\n }\n get_request 'relationship/' + id + '/properties', headers\n end", "def featured\n properties = []\n begin\n # Try to get the 3 properties with priority flag\n Property.where(priority: true, status: :active).order('RANDOM()').limit(3).each { |p| properties << p }\n\n # Get the missing properties\n missing = 3 - properties.count\n Property.where(priority: false, status: :active).order('RANDOM()').limit(missing).each { |p| properties << p } if missing > 0\n\n @api_v1_properties = properties\n\n render template: '/api/v1/properties/index', status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end\n end", "def get_properties\n\n begin\n str_uri = $product_uri + '/words/' + @filename + '/documentProperties'\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n\n response_stream = RestClient.get(signed_str_uri, {:accept => 'application/json'})\n\n stream_hash = JSON.parse(response_stream)\n\n return stream_hash['DocumentProperties']['List'] if stream_hash['Code'] == 200\n false\n\n rescue Exception => e\n print e\n end\n\n end", "def get_property property_name\n\n begin\n\n if property_name == ''\n raise 'Property name not specified.'\n end\n\n str_uri = $product_uri + '/words/' + @filename + '/documentProperties/' + property_name\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n\n response_stream = RestClient.get(signed_str_uri, {:accept => 'application/json'})\n\n stream_hash = JSON.parse(response_stream)\n stream_hash['Code'] == 200 ? stream_hash['DocumentProperty'] : false\n\n rescue Exception => e\n print e\n end\n\n end", "def get_properties\n \n begin\n \n if @filename == \"\"\n raise \"Base file not specified.\"\n end\n \n str_uri = $productURI + \"/words/\" + @filename + \"/documentProperties\"\n signed_str_uri = Common::Utils.sign(str_uri)\n \n response_stream = RestClient.get(signed_str_uri,{:accept=>\"application/json\"})\n \n stream_hash = JSON.parse(response_stream)\n \n if(stream_hash[\"Code\"] == 200)\n return stream_hash[\"DocumentProperties\"][\"List\"]\n else\n return false\n end\n \n rescue Exception=>e\n print e\n end\n \n end", "def index\n @properties = Property.with_deleted.where(id: AccessResource.get_ids(resource_klass: 'Property', user: current_user))\n @properties = @properties.where(deleted_at: nil) unless params[:trashed].to_b\n @properties = @properties.where.not(deleted_at: nil) if params[:trashed].to_b\n @last = @properties.try(:last).try(:id) || 0\n if params[\"purchased\"]\n if ((params[\"purchased\"][\"accepted\"] == \"1\") && (params[\"prospective_purchase\"][\"accepted\"] == \"1\"))\n elsif ((params[\"purchased\"][\"accepted\"] == \"0\") && (params[\"prospective_purchase\"][\"accepted\"] == \"0\"))\n @properties = @properties.where.not(ownership_status: ['Prospective Purchase', 'Purchased'])\n else\n @properties = @properties.where(ownership_status: 'Purchased') if params[\"purchased\"][\"accepted\"] == \"1\"\n @properties = @properties.where(ownership_status: 'Prospective Purchase') if params[\"prospective_purchase\"][\"accepted\"] == \"1\"\n end\n end\n @properties = @properties.order(created_at: :desc).paginate(page: params[:page], per_page: sessioned_per_page)\n @activeId = params[:active_id]\n \n render template: 'properties/xhr_list', layout: false if request.xhr?\n end", "def show\n property = Property.find params[:id]\n respond_to do |format|\n format.html {}\n format.json { render :json => property}\n end\n end", "def get_view_properties_with_http_info(name, password = nil, folder = nil, storage = nil)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.get_view_properties ...'\n end\n\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling SlidesApi.get_view_properties\"\n end\n # resource path\n local_var_path = '/slides/{name}/viewProperties'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'name', name)\n\n # query parameters\n query_params = {}\n query_params[:'folder'] = @api_client.prepare_for_query(folder) unless folder.nil?\n query_params[:'storage'] = @api_client.prepare_for_query(storage) unless storage.nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'password'] = password unless password.nil?\n\n # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'ViewProperties')\n return data, status_code, headers\n end", "def query\n @property_hash\n end", "def create\n @auth_property = AuthProperty.new(auth_property_params)\n @token.authProperties << @auth_property\n\n respond_to do |format|\n if @auth_property.save\n format.html { redirect_to [@owner, @token, @auth_property], notice: 'Auth property was successfully created.' }\n format.json { render :show, status: :created, location: @auth_property }\n else\n format.html { render :new }\n format.json { render json: @auth_property.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @estate_agent = EstateAgent.find(params[:id])\n @properties = Property.where(\"estate_agent_id = ?\", @estate_agent.id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @properties }\n end\n end", "def show\n format = params[:format] || 'json'\n data = @container.config.get_properties(flavor: :public, format: format)\n\n render response_ok data\n end", "def index\n @properties = Property.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @properties }\n end\n end", "def show\n @property = Property.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end", "def show\n @property = Property.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end", "def show\n @property = Property.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end", "def show\n @property = Property.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end", "def get_by_property\n @api_v1_reservation = current_api_v1_user.properties.find(params[:id]).reservations\n render template: '/api/v1/reservations/index', status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end", "def get_properties\n \n begin\n \n if @filename == ''\n raise 'Base file not specified.'\n end\n \n str_uri = $product_uri + '/slides/' + @filename + '/documentProperties'\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n \n response_stream = RestClient.get(signed_str_uri,{:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n if(stream_hash['Code'] == 200)\n return stream_hash['DocumentProperties']['List']\n else\n return false\n end\n \n rescue Exception=>e\n print e\n end\n \n end", "def property_properties\n _property_properties\n end", "def index\n id = params[:id].to_i\n\n if id != 0\n @properties = @properties.paginate(page: params[:page], per_page: 10).\n order('ensure_availability_before_booking desc, name').\n find_all_by_id(id)\n if @properties.any?\n @property_name = @properties.first.name\n end\n else\n @properties = @properties.paginate(page: params[:page], per_page: 10).\n order('ensure_availability_before_booking desc, name').find(:all)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @properties }\n end\n end", "def index\n @properties = @user.properties.all\n # if params[:search]\n # @properties = @user.properties.search(params[:search], params[:page]).order(\"created_at DESC\")\n \n\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @properties }\n # end\n # else\n # @properties = Property.order(\"created_at DESC\")\n # end\n\n end", "def properties\n return @values['properties'] if @values.key?('properties')\n @values['properties'] = {}\n @values['properties']\n end", "def property_details\n details = VendorApi.new(params[:udprn].to_i, nil, params[:vendor_id].to_i).property_details\n render json: details, status: 200\n end", "def get_property\n @xml = client.call(url).parsed_response.css('property').first\n @attributes.merge!(parse_xml_to_hash)\n end", "def show\n #@property = Property.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end", "def fetch_properties(host)\n fetcher = Commands::PropertiesFetcher.new(credentials)\n fetcher.call(mc_id: host.identifier)\n end", "def get_protection_properties_with_http_info(name, password = nil, folder = nil, storage = nil)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.get_protection_properties ...'\n end\n\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling SlidesApi.get_protection_properties\"\n end\n # resource path\n local_var_path = '/slides/{name}/protection'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'name', name)\n\n # query parameters\n query_params = {}\n query_params[:'folder'] = @api_client.prepare_for_query(folder) unless folder.nil?\n query_params[:'storage'] = @api_client.prepare_for_query(storage) unless storage.nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'password'] = password unless password.nil?\n\n # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'ProtectionProperties')\n return data, status_code, headers\n end", "def web_properties\n Management::WebProperty.all(self)\n end", "def available_properties\n @properties ||= list.properties\n end", "def get_property(*args)\n return unless alive?\n\n command(\"get_property\", *args)[\"data\"]\n end", "def index\n @properties = ((current_person== current_admin)? Property.all : Property.where(user:current_person)).paginate(:page => params[:page], :per_page => 3)\n\n end", "def index\n\n @properties = Property.search( params[:query] || \"\" )\n\n respond_to do |format|\n\n format.html\n format.json { render json: @properties }\n\n end\n\n end", "def index\n @properties = Property.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @properties }\n end\n end", "def index\n @properties = Property.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @properties }\n end\n end", "def index\n @properties = Property.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @properties }\n end\n end", "def get_properties_with_http_info(uuid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectPropertyApi.get_properties ...'\n end\n # verify the required parameter 'uuid' is set\n if @api_client.config.client_side_validation && uuid.nil?\n fail ArgumentError, \"Missing the required parameter 'uuid' when calling ProjectPropertyApi.get_properties\"\n end\n # resource path\n local_var_path = '/v1/project/{uuid}/property'.sub('{' + 'uuid' + '}', CGI.escape(uuid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<ProjectProperty>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectPropertyApi#get_properties\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @properties = Property.order(:id).page (params[:page])\n end", "def client_properties\n end", "def featured\n properties = []\n begin\n # Tenta pegar 3 propriedades com a flag de prioridade\n Property.where(priority: true, status: :active).order(\"RANDOM()\").limit(3).each {|p| properties << p}\n # Verifica quantas propriedades faltam pra completar 3\n missing = 3 - properties.count\n # Pega as propriedades faltantes caso existam\n Property.where(status: :active).order(\"RANDOM()\").limit(missing).each {|p| properties << p} if missing > 0\n\n @api_v1_properties = properties\n\n render template: '/api/v1/properties/index', status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end\n end", "def show\n @property_details = PropertyDetail.find_by_property_id(params[:id])\n end", "def show\n @property = Property.find(params[:id])\n end", "def show\n if @canister.nil?\n head :not_found\n else\n render json: @canister.properties\n end\n end", "def set_api_v1_property\n @api_v1_property = Property.find(params[:id])\n end", "def get_property property_name\n \n begin\n \n if @filename == \"\"\n raise \"Base file not specified.\"\n end\n \n if property_name == \"\"\n raise \"Property name not specified.\"\n end\n \n str_uri = $productURI + \"/words/\" + @filename + \"/documentProperties/\" + property_name\n signed_str_uri = Common::Utils.sign(str_uri)\n \n response_stream = RestClient.get(signed_str_uri,{:accept=>\"application/json\"})\n \n stream_hash = JSON.parse(response_stream)\n \n if(stream_hash[\"Code\"] == 200)\n return stream_hash[\"DocumentProperty\"]\n else\n return false\n end\n \n rescue Exception=>e\n print e\n end\n \n end", "def get_prop(values)\n cmd = \"{\\\"id\\\":1,\\\"method\\\":\\\"get_prop\\\",\\\"params\\\":[#{values}]}\\r\\n\"\n request(cmd)\n end", "def show\n @property_field = PropertyField.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property_field }\n end\n end", "def property_params\n params[:property]\n end", "def index\n @client_properties = ClientProperty.all\n end", "def auth_oauth\n @attributes[:auth_oauth]\n end", "def get_properties(options={})\n return send_message(SkyDB::Message::GetProperties.new(options))\n end", "def get_document_property(name, property_name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_property_with_http_info(name, property_name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_property_with_http_info(name, property_name, opts)\n else\n raise\n end\n return data\n end", "def get_property(name, default= \"\")\n\t\treturn @transport.get_path(\"meta\",\"properties\", name) { default }\n\tend", "def index\n\t\t@properties = Property.all\n\tend", "def get_property property_name\n \n begin\n \n if @filename == ''\n raise 'Base file not specified.'\n end\n \n if property_name == ''\n raise 'Property name not specified.'\n end\n \n str_uri = $product_uri + '/slides/' + @filename + '/documentProperties/' + property_name\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n \n response_stream = RestClient.get(signed_str_uri,{:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n if(stream_hash['Code'] == 200)\n return stream_hash['DocumentProperty']\n else\n return false\n end\n \n rescue Exception=>e\n print e\n end\n \n end", "def get_slide_show_properties_with_http_info(name, password = nil, folder = nil, storage = nil)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.get_slide_show_properties ...'\n end\n\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling SlidesApi.get_slide_show_properties\"\n end\n # resource path\n local_var_path = '/slides/{name}/slideShowProperties'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'name', name)\n\n # query parameters\n query_params = {}\n query_params[:'folder'] = @api_client.prepare_for_query(folder) unless folder.nil?\n query_params[:'storage'] = @api_client.prepare_for_query(storage) unless storage.nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'password'] = password unless password.nil?\n\n # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'SlideShowProperties')\n return data, status_code, headers\n end", "def get_profile_configuration(args = {}) \n get(\"/profiles.json/#{args[:profileId]}/configuration\", args)\nend", "def properties(path, property_names)\n result = properties_for_path(path, property_names, 0)\n if result[0].key?(200)\n return result[0][200]\n else\n return []\n end\n end", "def edit\n if @property.user.id != @user.id\n redirect_to properties_path, notice:\"Not authorized\"\n end\n end", "def show\n render json: @property\n end", "def index\n @sys_properties = Sys::Property.find_mine(params).paginate(page: params[:page])\n end", "def show\n respond_to do |format|\n format.html {}\n format.json { render json: @property }\n end\n end", "def properties\n @properties\n end" ]
[ "0.7909022", "0.74378896", "0.7308449", "0.704606", "0.6856806", "0.677006", "0.6751695", "0.6745252", "0.66370744", "0.65402", "0.6507988", "0.6502517", "0.6467627", "0.6337173", "0.63112265", "0.6310055", "0.630863", "0.6301934", "0.628738", "0.6256664", "0.6229946", "0.6229474", "0.61675364", "0.6146587", "0.6139273", "0.6112816", "0.6079905", "0.6071166", "0.60676485", "0.605165", "0.605165", "0.60104394", "0.5976375", "0.59715086", "0.5964217", "0.59405524", "0.59367085", "0.59308577", "0.5927412", "0.5913193", "0.5910311", "0.59073275", "0.58984965", "0.58981574", "0.5896073", "0.588872", "0.5887092", "0.5886326", "0.5883426", "0.58781743", "0.5870202", "0.58668643", "0.58668643", "0.58668643", "0.58668643", "0.5863538", "0.58625734", "0.58362216", "0.58314264", "0.5829348", "0.5801656", "0.5799238", "0.5777579", "0.5776596", "0.57735485", "0.5768351", "0.5753408", "0.5751311", "0.57504225", "0.5747468", "0.57284904", "0.571884", "0.571884", "0.5718782", "0.57068866", "0.57056046", "0.5702524", "0.5701835", "0.5697509", "0.5695063", "0.56893384", "0.5683385", "0.56785023", "0.56591004", "0.56577253", "0.5650286", "0.5645093", "0.56393063", "0.563076", "0.5629814", "0.5624883", "0.5611682", "0.5610279", "0.56014925", "0.5600296", "0.5599268", "0.55913574", "0.559017", "0.55868584", "0.55794084", "0.5578746" ]
0.0
-1
POST /auth_properties POST /auth_properties.json
def create @auth_property = AuthProperty.new(auth_property_params) @token.authProperties << @auth_property respond_to do |format| if @auth_property.save format.html { redirect_to [@owner, @token, @auth_property], notice: 'Auth property was successfully created.' } format.json { render :show, status: :created, location: @auth_property } else format.html { render :new } format.json { render json: @auth_property.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auth_property_params\n params.require(:auth_property).permit(:key, :txtValue, :numValue, :token)\n end", "def create_property( propname, value )\n params = { 'prop' => propname, 'value' => value }\n resp = conn.post( '/users/'+name+'/props/', params )\n \n case resp.code.to_i\n when 201\n return\n when 404\n raise RestAuthUserNotFound.new( resp )\n when 409\n raise RestAuthPropertyExists.new( resp )\n else\n raise RestAuthUnknownStatus.new( resp )\n end\n end", "def create\n property = current_user.properties.new(\n title: params[:title],\n value: params[:value]\n )\n\n if property.save\n render status: 200, json: { property_id: property.id }\n else\n render status: 422, json: {\n error: property.errors.full_messages.join(', ')\n }\n end\n end", "def update\n respond_to do |format|\n if @auth_property.update(auth_property_params)\n format.html { redirect_to [@owner, @token, @auth_property], notice: 'Auth property was successfully updated.' }\n format.json { render :show, status: :ok, location: @auth_property }\n else\n format.html { render :edit }\n format.json { render json: @auth_property.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_properties()\n resp = conn.get('/users/'+name+'/props/')\n \n case resp.code.to_i\n when 200\n return JSON.parse(resp.body)\n when 404\n raise RestAuthUserNotFound.new( resp )\n else\n raise RestAuthUnknownStatus.new( rest )\n end\n end", "def property_params\n params.require(:property).permit(\n :property_name,\n :property_address,\n :landlord_first_name,\n :landlord_last_name,\n :landlord_email,\n :tenancy_start_date,\n :tenancy_security_deposit,\n :tenancy_monthly_rent,\n :rented,\n :tenants_emails,\n :multiple_landlords, \n :other_landlords_emails\n )\n end", "def set_property( propname, value )\n params = { 'value' => value }\n resp = conn.put('/users/'+name+'/props/'+propname+'/', params)\n \n case resp.code.to_i\n when 200\n return JSON.parse( resp.body )\n when 201\n return\n when 404\n raise RestAuthResourceNotFound.new( resp )\n else\n raise RestAuthUnknownStatus.new( resp )\n end\n end", "def create\n @property = Property.new(property_params)\n @property.landlord = authenticated_user\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to @property, notice: \"Property was successfully created.\" }\n format.json { render :show, status: :created, location: @property }\n else\n format.html { render :new }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_auth_property\n @auth_property = AuthProperty.find(params[:id])\n end", "def process_properties(properties); end", "def property_params\n params.require(:property).permit(:resource_id, :resource_type, :name, :value)\n end", "def properties_params\n\t\t\tparams.require(:property).permit(:status,:address,:city,:state,:zip,:lat,:lon)\n\t\tend", "def property_params\n params.require(:property).permit!\n end", "def users_property_params\n params.require(:users_property).permit(:user_id, :property, :property_value)\n end", "def index\n @auth_properties = AuthProperty.all\n end", "def set_app_properties(properties)\n properties.respond_to?(:to_json) ? properties.to_json : properties\n (@session.post 'facebook.admin.setAppProperties', :properties => properties) == '1'\n end", "def create\n if !check_permissions?(session[:user_type], \"create_property\")\n redirect_to root_path\n end\n @property = Property.new(property_params)\n respond_to do |format|\n if @property.save\n # , :, :in_unit_laundry, :parking\n add_property_feature(@property)\n format.html { redirect_to @property, notice: \"Property was successfully created.\" }\n format.json { render :show, status: :created, location: @property }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def property_params\n params.require(:property).permit!\n end", "def create\n @property_hash = {\n name: @resource[:name],\n ensure: :present,\n value: @resource[:value]\n }\n end", "def property_params\n params.require(:property).permit(:name, :address, :property_type, :description, :size_type, :rent, :date_available, :security_deposit, :image_urls, :landlord_id)\n end", "def set_app_properties(properties)\n properties = properties.respond_to?(:to_json) ? properties.to_json : properties\n (@session.post 'facebook.admin.setAppProperties', :properties => properties) == '1'\n end", "def property_keys\n headers = { 'Accept' => 'application/json; charset=UTF-8' }\n get_request 'propertykeys', headers\n end", "def property_params\n params.require(:property).permit(:title, :propType, :address, :latitude, :longitude,:price, :beds, :rooms, :guests, :description, :user_id)\n end", "def create\n key = params[:key]\n value = params[:value]\n if key\n begin\n Property.clear(key, nil, current_user.id)\n property=Property.create(:prop_key => key, :text_value => value, :user_id => current_user.id)\n respond_to do |format|\n format.json { render :json => jsonp(properties_to_json([property])) }\n format.xml { render :xml => properties_to_xml([property]) }\n format.text { render :text => text_not_supported }\n end\n\n rescue Exception => e\n render_error(e.message, 500)\n end\n else\n render_error('Bad request: missing key', 400)\n end\n end", "def create\n @property_hash = {\n name: @resource[:name],\n ensure: :present,\n first: @resource[:first],\n second: @resource[:second],\n kind: @resource[:kind],\n symmetrical: @resource[:symmetrical],\n new: true\n }\n end", "def create\n @property = Property.new(property_params)\n\n if @property.save\n render json: @property, status: :created, location: @property\n else\n render json: @property.errors, status: :unprocessable_entity\n end\n end", "def create\n @users_property = UsersProperty.new(users_property_params)\n\n respond_to do |format|\n if @users_property.save\n format.html { redirect_to @users_property, notice: 'Users property was successfully created.' }\n format.json { render :show, status: :created, location: @users_property }\n else\n format.html { render :new }\n format.json { render json: @users_property.errors, status: :unprocessable_entity }\n end\n end\n end", "def properties_value_params\r\n params.fetch(:properties_value, {}).permit(:value, :property_id, :is_show_website)\r\n end", "def property_params\n params.require(:property).permit(:name, :area, :price, :description, :property_type_id, :interest, :status, :user_id, :bed_rooms, :bath_rooms, :address, :county_id, :state_id, :city_id, :latitude, :longitude, :video_url, option_ids: [])\n end", "def property_params\n params.require(:property).permit(:number, :buildinginfo, :building_id, :suitedfor, :notes, :rented, :avatar)\n end", "def create\n @property = Property.create(property_params)\n # @property = Property.new(safe_params)\n\n if @property.save\n render json: @property, status: :created, location: @property\n else\n render json: @property.errors, status: :unprocessable_entity\n end\n end", "def property_params\n params.require(:property).permit(:address, :apt, :city, :state, :zip)\n end", "def create\n @api_v1_property = Api::V1::Property.new(api_v1_property_params)\n\n if @api_v1_property.save\n render :show, status: :created, location: @api_v1_property\n else\n render json: @api_v1_property.errors, status: :unprocessable_entity\n end\n end", "def create\n @property_user = PropertyUser.new(params[:property_user])\n\n respond_to do |format|\n if @property_user.save\n format.html { redirect_to @property_user, notice: 'Property user was successfully created.' }\n format.json { render json: @property_user, status: :created, location: @property_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @property_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def property_params\n params\n .require(:property)\n .permit(\n :name,\n :type_of_property,\n :street,\n :external_number,\n :internal_number,\n :neighborhood,\n :city,\n :country,\n :rooms,\n :bathrooms,\n :comments\n )\n end", "def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end", "def property_params\n params.require(:property).permit(:lol3, :unit, :group, :tenantid, :resident_name, :resident_rent, :unit_rent, :discount, :status, :days_vacant, :move_out, :lease_to, :amenities, :amenities_amount, :discounts, :company_id, :unit_type_id)\n end", "def index\n @allowed = false\n if check_permissions?(session[:user_type], \"create_property\")\n @allowed = true\n end\n @properties = Property.all\n end", "def property_params\n params.require(:property).permit(:name, :description, :beds, :baths, :square_feet, :price, :address, :city, :state, :zip_code, :has_laundry, :has_parking, :image_url, :is_available, :date_available)\n end", "def property_params\n params[:property]\n end", "def property_params\n params.require(:property).permit(:title, :property_type_id, :description)\n end", "def create\n @property = Property.new(property_params)\n @property.user=current_person\n respond_to do |format|\n @property.add_location_to_property\n if @property.save\n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render :show, status: :created, location: @property }\n else\n format.html { render :new }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contact.find(params[:contact_id])\n @property = Property.new(property_params)\n @property.contact = @contact\n authorize @property\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to edit_contact_path(@contact), notice: 'Property was successfully created.' }\n format.json { redirect_to edit_contact_path(@contact), status: :created, location: @property }\n else\n format.html { render :new }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @property = Property.new(property_params)\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to after_save_path, notice: 'Property was successfully created.' }\n format.json { render :show, status: :created, location: @property }\n else\n format.html { render :new }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_property( propname )\n resp = conn.get('/users/'+name+'/props/'+propname+'/')\n \n case resp.code.to_i\n when 200\n return JSON.parse( resp.body )\n when 404\n case resp.header['resource-type']\n when 'user'\n raise RestAuthUserNotFound.new( resp )\n when 'property'\n raise RestAuthPropertyNotFound.new( resp )\n else\n raise RestAuthBadResponse.new( resp, \"Received 404 without Resource-Type header\" )\n end\n else\n raise RestAuthUnknownStatus.new( resp )\n end\n end", "def property_params\n #params.fetch(:property, {})\n params.require(:property).permit(:address, :suburb, :landsize, :bedrooms, :bathrooms, :private_parking, :expected_price)\n end", "def sys_property_params\n params.require(:sys_property).permit(:name, :status, :values_name).merge({account_id: current_account.id, updater_id: current_user.id})\n end", "def property_params\n params.require(:property).permit(\n :marketing_name,\n :website,\n :description,\n :contact_email,\n :contact_phone,\n :street,\n :city,\n :state,\n :zip,\n :latitude,\n :longitude,\n :pet_dog,\n :pet_cat,\n :amenities,\n { floorplan_ids: [] },\n )\n end", "def new\n @property = @user.properties.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @property }\n end\n end", "def property_params\n params.require(:property).permit(:code, :name, :description, :property_type_id, :static, :variant, :property_kind_id)\n end", "def property_params\n params.require(:property).permit(:title, :description_short, :description_long, :city, :state, :country, :latitude, :longitude, :postcode, :image, :remote_image_url, :image_cache, :remove_image, :image_url, :property_pictures_attributes => [:id, :avatar_url, :name, :_destroy, :avatar_url_cache])\n end", "def properties=(value)\n @properties = value\n end", "def create\n @property = Property.new(property_params)\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to user_path(@property.user_id) }\n else\n format.html { render :new }\n end\n end\n end", "def property_params\n params.require(:property).permit(:city, :number, :state, :street, :zip)\n end", "def property_params\n pp = params.require(:property).permit(:title, :info, :description, :status, :development_id, :property_type_id, :age, :environments, :garages, :bathrooms, :toilettes, :expenses, :sale_price, :sale_currency, :rent_price, :rent_currency, :area_unit, :constructed_area, :unconstructed_area, :zone_id, :address, :zip_code, :lat, :lng)\n pp[:expenses].tr!('.', '') if pp[:expenses].present?\n pp[:sale_price].tr!('.', '') if pp[:sale_price].present?\n pp[:rent_price].tr!('.', '') if pp[:rent_price].present?\n pp[:constructed_area].tr!('.', '') if pp[:constructed_area].present?\n pp[:unconstructed_area].tr!('.', '') if pp[:unconstructed_area].present?\n return pp\n end", "def create\n @property = Property.new(property_params)\n @property.rent_table_version = 0\n @property.lease_base_rent = @property.current_rent\n @property.user_id = current_user.id\n\n if !(@property.owner_person_is.nil? || @property.owner_person_is==0)\n if @property.owner_person_is == 1 && [email protected]_entity_id_indv.nil?\n @property.owner_entity_id = @property.owner_entity_id_indv\n end\n else\n @property.owner_entity_id = @property.owner_entity_id_indv = 0\n end\n\n respond_to do |format|\n if @property.save\n AccessResource.add_access({ user: current_user, resource: @property })\n flash[:success] = \"Congratulations, you have just created a record for #{@property.title}\"\n format.html { redirect_to edit_property_path(@property.key, type_is: 'basic_info') }\n # format.html { redirect_to properties_path }\n format.js { render json: @property.to_json, status: :ok }\n format.json { render action: 'show', status: :created, location: @property }\n else\n # flash[:error] = \"Failed to create new property.\"\n format.html { render action: 'new' }\n format.js { render action: 'new', status: :unprocessable_entity, layout: false }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_custom_property property_list\n \n begin\n \n if @filename == ''\n raise 'Base file not specified.'\n end\n \n if property_list == ''\n raise 'Property list not specified.'\n end\n \n json_data = property_list.to_json\n \n # post_hash = { 'Value' => property_value}\n # json_data = post_hash.to_json \n \n str_uri = $product_uri + '/slides/' + @filename + '/documentProperties'\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n response_stream = RestClient.put(signed_str_uri,json_data,{:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n if(stream_hash['Code'] == 200)\n return stream_hash\n else\n return false\n end\n \n rescue Exception=>e\n print e\n end\n \n end", "def required_properties\n {\n \"cc\" => {\n \"internal_service_hostname\" => \"cc.service.cf.internal\"\n },\n \"loggregator\" => {\n \"etcd\" => {\n \"machines\" => []\n },\n \"uaa\" => {\n \"client_secret\" => \"secret\"\n }\n },\n \"system_domain\" => \"bosh-lite.com\",\n }\n end", "def get_app_properties(*properties)\n json = @session.post('facebook.admin.getAppProperties', :properties => properties.to_json)\n hash = JSON.parse(CGI.unescapeHTML(json))\n @properties = ApplicationProperties.from_hash(hash)\n end", "def get_app_properties(*properties)\n json = @session.post('facebook.admin.getAppProperties', :properties => properties.to_json)\n hash = JSON.parse(CGI.unescapeHTML(json))\n @properties = ApplicationProperties.from_hash(hash)\n end", "def property_type_params\n params.require(:property_type).permit(:property_type)\n end", "def create\n @property = Property.new(params[:property])\n\n respond_to do |format|\n if @property.save\n users = User.all\n users.each { |u|\n options = {\n :registration_id => u.registration_id,\n :message => \"New property added to Property Market!\",\n :id => @property.id,\n :name => @property.name,\n :ptype => @property.ptype,\n :collapse_key => @property.id.to_s\n }\n puts options.inspect\n response = SpeedyC2DM::API.send_notification(options)\n puts response.inspect\n }\n \n\n \n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render json: @property, status: :created, location: @property }\n else\n format.html { render action: \"new\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def property_params\n params.require(:property).permit(\n :value_type, :measurement_unit_id, :unit_pricing, :searchable,\n :name, :external_name\n )\n end", "def property_params\n params.require(:property).permit(:situation, :type_property, :status, :iptu,\n :project_id, :cep, :region, :district, :group,\n :block, :number, :address, :complement, :reference_point, \n :address_link_visible, :rooms, :unit, :value, :value_m2, \n :area, :suit, :parking_spaces, :floor, :sun_position, \n :link_tour, :value_rent,:description, :commercial, :elevator, :coverage, \n :expiration_date, :name, image_path: [], construction_companies_id: [], sellers_id: [], property_attribute_id: [])\n end", "def create\n authorize_action_for Property, at: current_store\n @property = current_store.properties.build(property_params.merge(priority: current_store.properties.count))\n\n respond_to do |format|\n if @property.save\n track @property\n format.html { redirect_to edit_admin_property_path(@property),\n notice: t('.notice', property: @property) }\n format.json { render :show, status: :created, location: admin_property_path(@property) }\n else\n format.html { render :new }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n if @property.nil? || @property.user.id != @user.id\n redirect_to properties_path, notice: \"Not Authorized\" \n end\n end", "def property_params\n params.require(:property).permit(:state_policy_id, :stop_initiating_evictions, :stop_enforcing_evictions, :grace_period_or_security_deposit_towards_rent, :froze_utility_shut_offs, :froze_mortgage_payments)\n end", "def destroy\n @auth_property.destroy\n respond_to do |format|\n format.html { redirect_to owner_token_auth_properties_path [@owner, @token], notice: 'Auth property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def createCustomer(customer_properties)\n url_data = \"/api/customers/\"\n @json_customer_properties = customer_properties.to_json\n options = {\n :digest_auth => @auth_digest,\n :body => @json_customer_properties\n }\n url_request = \"#{url_data}\"\n postData(url_request, options)\n end", "def api_v1_property_params\n params.require(:api_v1_property).permit(:title, :description)\n end", "def api_v1_property_params\n params.require(:api_v1_property).permit(:title, :description)\n end", "def property_params\n params.require(:property).permit(:street_address_1, :street_address_2, :city, :state_id, :postal_code)\n end", "def create\n respond_to do |format|\n if @property.save\n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render json: @property, status: :created, location: @property }\n else\n format.html { render action: \"new\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def property_params\n params.require(:property).permit(:business_name, :street_address, :city, :state, :zip, :mdu, :units, :content)\n end", "def create\n @sys_property = Sys::Property.new(sys_property_params)\n\n respond_to do |format|\n if @sys_property.save\n format.html { redirect_to @sys_property, notice: 'Property was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sys_property }\n else\n format.html { render action: 'new' }\n format.json { render json: @sys_property.errors, status: :unprocessable_entity }\n end\n end\n end", "def params_auth_hash; end", "def create\n @property_hash = {\n :name => @resource[:name],\n :ensure => :present,\n :primitive => @resource[:primitive],\n :node_name => @resource[:node_name],\n :score => @resource[:score],\n :resource_discovery => @resource[:resource_discovery],\n :cib => @resource[:cib],\n :rule => @resource[:rule]\n }\n end", "def property_params\n params.require(:property).permit(:country, :province, :city, :address, :holding_type, :project_name, :project_code, :property_name, :property_code, :main_photo, :cover_photo, :city_location_photo, :description, :price, :featured, :latitude, :longitude, :facilities => [], :gallery_photos => [], :floor_plan_photos => [])\n end", "def property_params\n params.require(:property).permit(:name, :address, :size, :units, :terms_available, :earliest_start_date, :application_fee, :monthly_rent)\n end", "def validate_properties\n true\n end", "def validate_properties\n true\n end", "def create\n @property_hash = {\n :name => @resource[:name],\n :ensure => :present,\n :primitive => @resource[:primitive],\n :node_name => @resource[:node_name],\n :node_score => @resource[:node_score],\n :rules => @resource[:rules],\n :cib => @resource[:cib],\n }\n end", "def my_properties\n @api_v1_properties = current_api_v1_user.properties.\n includes(:reservations).\n order(\"reservations.created_at DESC\")\n\n render template: '/api/v1/properties/index', status: 200\n end", "def property_params\n params.require(:property).permit(:name, :price, :population, :state, :region, :town, :kind, :position, :description)\n end", "def canister_params\n params.require(:canister).permit(:_id, :properties)\n end", "def create\n @property = Property.new(property_params)\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render :show, status: :created, location: @property }\n else\n format.html { render :new }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @property = Property.new(property_params)\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render :show, status: :created, location: @property }\n else\n format.html { render :new }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @property = Property.new(property_params)\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render :show, status: :created, location: @property }\n else\n format.html { render :new }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @property = Property.new(property_params)\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render :show, status: :created, location: @property }\n else\n format.html { render :new }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @property = Property.new(property_params)\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render :show, status: :created, location: @property }\n else\n format.html { render :new }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @property = Property.new(property_params)\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render :show, status: :created, location: @property }\n else\n format.html { render :new }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @property = Property.new(property_params)\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render :show, status: :created, location: @property }\n else\n format.html { render :new }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @property = Property.new(property_params)\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render json: @property, status: :created, location: @property }\n else\n format.html { render action: \"new\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def property_params\n params.require(:property).permit(:id,:account_id,:featured,:comision,:duenos_id,:descripcion,:tipoOp,:tipoProp, :zona, :colonia, :precio, :mConst, :mTerreno, :banos,:ac,:alarm,:lift,:balcony,:furnished,:bbq,:heating,:fireplace,:backyard,:pool,:terrace,:security,:comision, :recamaras,:cover_picture,pictures: [],ids: [])\n end", "def add_properties\n cmd = []\n # validproperties is a list of properties in undefined order\n # sort them to have a predictable command line in tests\n Puppet::Type.type(:user).validproperties.sort.each do |property|\n value = get_value_for_property(property)\n next if value.nil? || property == :password\n # the value needs to be quoted, mostly because -c might\n # have spaces in it\n cmd << flag(property) << munge(property, value)\n end\n cmd\n end", "def property_params\n params.require(:property).permit(:Code, :County, :Price, :CurrentPrice, :Shares, :Rate, :ShareValue, :locality, :LR, :Title, :Reason, :StartOffer, :EndOffer, :user_id, :Area_of_land, :brochure)\n end", "def property_params\n params.require(:property).permit(:id, :auctionStatus, :caseID, :caseType, :judgement, :assesed, :parcel, :address, :city, :state, :zip, :legal, :beds, :baths, :area, :lot, :year, :estimate, :rentEstimate, :zillow, :date)\n end", "def property_details\n details = VendorApi.new(params[:udprn].to_i, nil, params[:vendor_id].to_i).property_details\n render json: details, status: 200\n end", "def create\n @property = Property.new(property_params)\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render action: 'show', status: :created, location: @property }\n else\n format.html { render action: 'new' }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @property = Property.new(property_params)\n\n respond_to do |format|\n if @property.save\n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render action: 'show', status: :created, location: @property }\n else\n format.html { render action: 'new' }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.71893424", "0.64241874", "0.6403528", "0.62121916", "0.61966485", "0.6188421", "0.6187812", "0.6144945", "0.610698", "0.6106747", "0.6086319", "0.6076893", "0.60689944", "0.6041595", "0.604103", "0.60404426", "0.59903556", "0.5968608", "0.5943977", "0.5919014", "0.5886966", "0.5877096", "0.5873255", "0.5863979", "0.58429444", "0.58419913", "0.58397776", "0.5814017", "0.58116287", "0.58113515", "0.58104616", "0.5805352", "0.57860607", "0.5781112", "0.5739447", "0.5673986", "0.56727314", "0.56602037", "0.56585675", "0.5651095", "0.5650207", "0.5635844", "0.56345594", "0.5626774", "0.5626739", "0.562312", "0.562001", "0.5608217", "0.56054145", "0.5596434", "0.5583583", "0.558327", "0.5582566", "0.5580667", "0.5578166", "0.55702764", "0.55662894", "0.5556944", "0.5546975", "0.5546975", "0.55440223", "0.5532079", "0.5525346", "0.5524101", "0.55079716", "0.55039185", "0.5503094", "0.54988813", "0.54985005", "0.54933715", "0.54933715", "0.54924583", "0.5488998", "0.5485122", "0.54845136", "0.5483895", "0.5451356", "0.5449395", "0.5440336", "0.5434131", "0.5434131", "0.54341227", "0.5432094", "0.5430196", "0.5422472", "0.5420193", "0.5420193", "0.5420193", "0.5420193", "0.5420193", "0.5420193", "0.5420193", "0.54172295", "0.541457", "0.5409181", "0.5395985", "0.5394668", "0.5384186", "0.5375489", "0.5375489" ]
0.71722054
1
PATCH/PUT /auth_properties/1 PATCH/PUT /auth_properties/1.json
def update respond_to do |format| if @auth_property.update(auth_property_params) format.html { redirect_to [@owner, @token, @auth_property], notice: 'Auth property was successfully updated.' } format.json { render :show, status: :ok, location: @auth_property } else format.html { render :edit } format.json { render json: @auth_property.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def set_property( propname, value )\n params = { 'value' => value }\n resp = conn.put('/users/'+name+'/props/'+propname+'/', params)\n \n case resp.code.to_i\n when 200\n return JSON.parse( resp.body )\n when 201\n return\n when 404\n raise RestAuthResourceNotFound.new( resp )\n else\n raise RestAuthUnknownStatus.new( resp )\n end\n end", "def update\n if !check_permissions?(session[:user_type], \"edit_property\")\n redirect_to root_path\n end\n puts \"The params in update are\",params\n respond_to do |format|\n if @property.update(property_params)\n add_property_feature(@property)\n format.html { redirect_to @property, notice: \"Property was successfully updated.\" }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update\n if @property.user.id != @user.id\n redirect_to properties_path, notice:\"Not authorized\"\n end\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n else\n format.html { render action: 'edit' }\n end\n end\n end", "def update\n new_properties = params[:d]\n profile = Profile[params[:id]]\n profile.update_with(new_properties)\n\n respond_with(profile) do |format|\n format.json { render json: profile.stripped }\n end\n end", "def update_principal(path, prop_patch)\n end", "def update\n if @api_v1_property.update(api_v1_property_params)\n render :show, status: :ok, location: @api_v1_property\n else\n render json: @api_v1_property.errors, status: :unprocessable_entity\n end\n end", "def update\n @contact = Contact.find(params[:contact_id])\n @property = Property.find(params[:id])\n authorize @property\n\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to edit_contact_path(@contact), notice: 'Property was successfully updated.' }\n format.json { redirect_to edit_contact_path(@contact), status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if(@property.user == current_person || current_person== current_admin)\n\n if @property.update(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n\n else\n format.html { redirect_to @property, alert: 'Please update your property only.' }\n end\n end\n end", "def update!(**args)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @sign_in_required = args[:sign_in_required] if args.key?(:sign_in_required)\n end", "def update\n @property_user = PropertyUser.find(params[:id])\n\n respond_to do |format|\n if @property_user.update_attributes(params[:property_user])\n format.html { redirect_to @property_user, notice: 'Property user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @property_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n if @property.user.id != @user.id\n redirect_to properties_path, notice:\"Not authorized\"\n end\n end", "def update\n @property = Property.find(params[:id])\n\n if @property.update(property_params)\n head :no_content\n else\n render json: @property.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @request_property.update(request_property_params)\n format.html { redirect_to @request_property, notice: 'Request property was successfully updated.' }\n format.json { render :show, status: :ok, location: @request_property }\n else\n format.html { render :edit }\n format.json { render json: @request_property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_current_logged_in_users_password(args = {}) \n id = args['id']\n temp_path = \"/users.json/current/password\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend", "def update!(**args)\n @client_id = args[:client_id] if args.key?(:client_id)\n @kind = args[:kind] if args.key?(:kind)\n @web_property_id = args[:web_property_id] if args.key?(:web_property_id)\n end", "def set_auth_property\n @auth_property = AuthProperty.find(params[:id])\n end", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update\n puts 'kkkkkkkkkkkkkkkkkkkkk'\n puts property_params\n\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: \"Property was successfully updated.\" }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to user_path(@property.user_id) }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n @property = Property.find(params[:id])\n\n if @property.update(params[:property])\n head :no_content\n else\n render json: @property.errors, status: :unprocessable_entity\n end\n end", "def update\n authorize_action_for @property, at: current_store\n\n respond_to do |format|\n if @property.update(property_params)\n track @property\n format.html { redirect_to admin_property_path(@property),\n notice: t('.notice', property: @property) }\n format.json { render :show, status: :ok, location: admin_property_path(@property) }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_property\n @api_v1_property = Property.find(params[:id])\n end", "def update\n respond_to do |format|\n if @prop.update(prop_params)\n format.html { redirect_to @prop, notice: \"Prop was successfully updated.\" }\n format.json { render :show, status: :ok, location: @prop }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @prop.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update_attributes(params[:property])\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n # Remove all features by property objects\n @property.features_properties.delete_all\n\n # Get features parameter\n features = params[:features]\n\n # Verify whether features array comes in the parameters list\n if features.present?\n # Intantiate & create features by property\n features_property_create = FeaturesPropertyCreate.new(@property)\n features_property_create.create(features, params[:quantities])\n end\n\n # Remove all photos by property objects\n #@property.photos.delete_all\n\n # Get photos parameter\n photos = params[:photos]\n\n # Verify whether photos array comes in the parameters list\n if photos.present?\n # Intantiate & create photos by property\n photo_create = PhotoCreate.new(@property)\n photo_create.create(photos)\n end\n\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_property\n @api_v1_property = Property.find(params[:id])\n end", "def update\n #@property = Property.find(params[:id])\n\n respond_to do |format|\n if @property.update_attributes(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def relationship_set_props id, data\n headers = {\n 'Accept' => 'application/json; charset=UTF-8',\n 'Content-Type' => 'application/json',\n }\n\n put_request 'relationship/' + id + '/properties', data, headers\n end", "def http_prop_patch(request, response)\n path = request.path\n\n begin\n prop_patch = @server.xml.expect('{DAV:}propertyupdate', request.body)\n rescue Tilia::Xml::ParseException => e\n raise Exception::BadRequest, e.message, nil, e\n end\n\n new_properties = prop_patch.properties\n\n result = @server.update_properties(path, new_properties)\n\n prefer = @server.http_prefer\n response.update_header('Vary', 'Brief,Prefer')\n\n if prefer['return'] == 'minimal'\n # If return-minimal is specified, we only have to check if the\n # request was succesful, and don't need to return the\n # multi-status.\n ok = true\n result.each do |_prop, code|\n ok = false if code.to_i > 299\n end\n\n if ok\n response.status = 204\n return false\n end\n end\n\n response.status = 207\n response.update_header('Content-Type', 'application/xml; charset=utf-8')\n\n # Reorganizing the result for generateMultiStatus\n multi_status = {}\n result.each do |property_name, code|\n if multi_status.key?(code)\n multi_status[code][property_name] = nil\n else\n multi_status[code] = { property_name => nil }\n end\n end\n multi_status['href'] = path\n\n response.body = @server.generate_multi_status([multi_status])\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end", "def create_or_update_profile_configuration(args = {}) \n id = args['profileId']\n temp_path = \"/profiles.json/{profileId}/configuration\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"profileId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n respond_to do |format|\n if @client_property.update(client_property_params)\n format.html { redirect_to @client_property, notice: 'Client property was successfully updated.' }\n format.json { render :show, status: :ok, location: @client_property }\n else\n format.html { render :edit }\n format.json { render json: @client_property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @account = args[:account] if args.key?(:account)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n @profile = args[:profile] if args.key?(:profile)\n @redirect_uri = args[:redirect_uri] if args.key?(:redirect_uri)\n @webproperty = args[:webproperty] if args.key?(:webproperty)\n end", "def update!(**args)\n @client_id = args[:client_id] if args.key?(:client_id)\n @hashed_client_id = args[:hashed_client_id] if args.key?(:hashed_client_id)\n @kind = args[:kind] if args.key?(:kind)\n @web_property_id = args[:web_property_id] if args.key?(:web_property_id)\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update\n respond_to do |format|\n if @users_property.update(users_property_params)\n format.html { redirect_to @users_property, notice: 'Users property was successfully updated.' }\n format.json { render :show, status: :ok, location: @users_property }\n else\n format.html { render :edit }\n format.json { render json: @users_property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @youtube_uri = args[:youtube_uri] if args.key?(:youtube_uri)\n end", "def update!(**args)\n @trust_prop = args[:trust_prop] if args.key?(:trust_prop)\n end", "def update!(**args)\n @principal_email = args[:principal_email] if args.key?(:principal_email)\n @service_metadata = args[:service_metadata] if args.key?(:service_metadata)\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @property = Property.find(params[:id])\n\n respond_to do |format|\n if @property.update_attributes(params[:property])\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @property = Property.find(params[:id])\n\n respond_to do |format|\n if @property.update_attributes(params[:property])\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @property = Property.find(params[:id])\n\n respond_to do |format|\n if @property.update_attributes(params[:property])\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to after_save_path, notice: 'Property was successfully updated.' }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n p = recipe_params\n @recipe.properties = RecipeProperties.new(p.delete(:properties))\n respond_to do |format|\n if @recipe.update(p)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @property.update(property_params)\n format.html { redirect_to @property, notice: \"Property was successfully updated.\" }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @property = Property.find(params[:id])\n\n respond_to do |format|\n if @property.update_attributes(params[:property])\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @property = Property.find(params[:id])\n\n respond_to do |format|\n if @property.update_attributes(params[:property])\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def auth_property_params\n params.require(:auth_property).permit(:key, :txtValue, :numValue, :token)\n end", "def update_users_password_by_e_mail(args = {}) \n put(\"/users.json/backoffice/email/#{args[:email]}/password/#{args[:password]}\", args)\nend", "def update_users_password_by_e_mail(args = {}) \n put(\"/users.json/backoffice/email/#{args[:email]}/password/#{args[:password]}\", args)\nend", "def update\n respond_to do |format|\n if @property_form.update_attributes(params[:property])\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { render json: {message:'Property successfully updated!', id:@property.id}, status: :accepted }\n else\n format.html { render action: 'edit' }\n format.json { render json: @property_form.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_app_properties(properties)\n properties.respond_to?(:to_json) ? properties.to_json : properties\n (@session.post 'facebook.admin.setAppProperties', :properties => properties) == '1'\n end", "def update_resource(resource, params)\n resource.role_id = 1\n resource.update_without_password(params)\n end", "def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @signed_jwt = args[:signed_jwt] if args.key?(:signed_jwt)\n end", "def update_company_properties(client_id, facebook_id, twitter_handle)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/properties\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n 'properties': {'FBPageID': facebook_id,\n 'TwitterHandle': twitter_handle}\n }.to_json)\n puts response.body\n puts \"Client's FBPageID & TwitterHandle were saved.\" if response.success?\n end", "def updatea_properties\n if @teacher.update(edit_profile_params)\n flash[ :success] = \"Properties update successful\"\n redirect_to edit_teacher_path(@teacher)\n else\n render 'edita'\n end\n end", "def update\n @property_field = PropertyField.find(params[:id])\n\n respond_to do |format|\n if @property_field.update_attributes(params[:property_field])\n format.html { redirect_to @property_field, notice: 'Property field was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @property_field.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_app_properties(properties)\n properties = properties.respond_to?(:to_json) ? properties.to_json : properties\n (@session.post 'facebook.admin.setAppProperties', :properties => properties) == '1'\n end", "def update\n respond_to do |format|\n if @property_detail.update(property_detail_params)\n format.html { redirect_to @property_detail, notice: 'Property detail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @property_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @metadata = args[:metadata] if args.key?(:metadata)\n @pomeroy_id = args[:pomeroy_id] if args.key?(:pomeroy_id)\n @trust_level = args[:trust_level] if args.key?(:trust_level)\n end", "def update\n respond_to do |format|\n if @property_owner.update(property_owner_params)\n format.html { redirect_to @property_owner, notice: 'Property owner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @property_owner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update!(**args)\n @first_party_principal = args[:first_party_principal] if args.key?(:first_party_principal)\n @third_party_principal = args[:third_party_principal] if args.key?(:third_party_principal)\n end", "def update_principal(path, prop_patch)\n value = nil\n principal_index = nil\n principal = nil\n\n @principals.each_with_index do |value, i|\n principal_index = i\n if value['uri'] == path\n principal = value\n break\n end\n end\n\n return nil unless principal\n\n prop_patch.handle_remaining(\n lambda do |mutations|\n mutations.each do |prop, value|\n if value.nil? && principal.key?(prop)\n principal.delete(prop)\n else\n principal[prop] = value\n end\n end\n\n @principals[principal_index] = principal\n\n return true\n end\n )\n end", "def update!(**args)\n @access_control = args[:access_control] if args.key?(:access_control)\n @final_properties = args[:final_properties] if args.key?(:final_properties)\n @id = args[:id] if args.key?(:id)\n @insert_time = args[:insert_time] if args.key?(:insert_time)\n @last_used_credential = args[:last_used_credential] if args.key?(:last_used_credential)\n @manifest = args[:manifest] if args.key?(:manifest)\n @name = args[:name] if args.key?(:name)\n @properties = args[:properties] if args.key?(:properties)\n @runtime_policies = args[:runtime_policies] if args.key?(:runtime_policies)\n @type = args[:type] if args.key?(:type)\n @update = args[:update] if args.key?(:update)\n @update_time = args[:update_time] if args.key?(:update_time)\n @url = args[:url] if args.key?(:url)\n @warnings = args[:warnings] if args.key?(:warnings)\n end", "def update!(**args)\n @account = args[:account] if args.key?(:account)\n @kind = args[:kind] if args.key?(:kind)\n @profile = args[:profile] if args.key?(:profile)\n @webproperty = args[:webproperty] if args.key?(:webproperty)\n end", "def update!(**args)\n @external_identity = args[:external_identity] if args.key?(:external_identity)\n @resolution_status_code = args[:resolution_status_code] if args.key?(:resolution_status_code)\n end", "def update!(**args)\n @external_identity = args[:external_identity] if args.key?(:external_identity)\n @resolution_status_code = args[:resolution_status_code] if args.key?(:resolution_status_code)\n end", "def update\n property=Property.find(params[:id]) \n if property.update(params[:property].permit(:property_name,:property_desc,:property_price,:property_address))\n render json: {errors:property.errors.full_messages}\n else\n render 'edit'\n end\n end", "def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update_resource(resource, params)\n # if params['email'] != current_user.email || params['password'].present?\n # resource.update_with_password(params)\n # else\n resource.update_without_password(params.except('password', 'password_confirmation', 'current_password'))\n # end\n end", "def update\n @quick_property = QuickProperty.find(params[:id])\n\n respond_to do |format|\n if @quick_property.update_attributes(params[:quick_property])\n format.html { redirect_to @quick_property, notice: 'Quick property was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quick_property.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_property\n @api_v1_property = Api::V1::Property.find(params[:id])\n end", "def update_user_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/users/{userId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n @auth = Auth.find(params[:id])\n\n respond_to do |format|\n if @auth.update_attributes(params[:auth])\n format.html { redirect_to @auth, notice: 'Auth was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @auth.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_resource(object, attrs)\n object.update_with_password(*attrs)\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @internal_web_property_id = args[:internal_web_property_id] if args.key?(:internal_web_property_id)\n @kind = args[:kind] if args.key?(:kind)\n @level = args[:level] if args.key?(:level)\n @name = args[:name] if args.key?(:name)\n @profiles = args[:profiles] if args.key?(:profiles)\n @starred = args[:starred] if args.key?(:starred)\n @website_url = args[:website_url] if args.key?(:website_url)\n end", "def update\n @property = Property.find(params[:id])\n\n respond_to do |format|\n if @property.update_attributes(params[:property])\n format.html { redirect_to [@category, @sub_category, @item, @property], notice: 'Property was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_profile(body={})\n perform_post(\"/account/update_profile.json\", :body => body)\nend", "def update\n respond_to do |format|\n if @sys_property.update(sys_property_params)\n @sys_property.save_property_values(params[:property_values_name])\n format.html { redirect_to @sys_property, notice: 'Property was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sys_property.errors, status: :unprocessable_entity }\n end\n end\n end", "def flush\n if @attribute_json\n @updated_json = @attribute_json.dup\n else\n @updated_json = default_attribute\n end\n \n # Update the attribute's JSON values based on any new params. Sadly due to the\n # structure of the JSON vs the flat nature of the puppet properties, this\n # is a bit of a manual task.\n if not @property_hash[:secured1].to_s.empty?\n @updated_json[\"secured1\"] = @property_hash[:secured1]\n end\n if not @property_hash[:secured2].to_s.empty?\n @updated_json[\"secured2\"] = @property_hash[:secured2]\n end\n if not @property_hash[:secured3].to_s.empty?\n @updated_json[\"secured3\"] = @property_hash[:secured3]\n end\n if not @property_hash[:secured4].to_s.empty?\n @updated_json[\"secured4\"] = @property_hash[:secured4]\n end\n\n #Either arg1 or encrypted_arg1 is returned by Opsview, so we need to make sure to do the right thing\n #when transitioning to and from encrypted arguments\n\n if not @resource[:arg1].nil?\n @updated_json[\"secured1\"] = \"0\"\n @updated_json[\"arg1\"] = @property_hash[:arg1]\n if defined?@updated_json[\"encrypted_arg1\"]\n \t@updated_json.delete(\"encrypted_arg1\")\n end\n elsif not @property_hash[:encrypted_arg1].to_s.empty?\n @updated_json[\"encrypted_arg1\"] = @property_hash[:encrypted_arg1]\n @updated_json[\"secured1\"] = \"1\"\n if defined?@updated_json[\"arg1\"]\n \t@updated_json.delete(\"arg1\")\n end\n end\n\n if not @resource[:arg2].nil?\n @updated_json[\"secured2\"] = \"0\"\n @updated_json[\"arg2\"] = @property_hash[:arg2]\n if defined?@updated_json[\"encrypted_arg2\"]\n \t@updated_json.delete(\"encrypted_arg2\")\n end\n elsif not @property_hash[:encrypted_arg2].to_s.empty?\n @updated_json[\"encrypted_arg2\"] = @property_hash[:encrypted_arg2]\n @updated_json[\"secured2\"] = \"1\"\n if defined?@updated_json[\"arg2\"]\n \t@updated_json.delete(\"arg2\")\n end\n end\n\n if not @resource[:arg3].nil?\n @updated_json[\"secured3\"] = \"0\"\n @updated_json[\"arg3\"] = @property_hash[:arg3]\n if defined?@updated_json[\"encrypted_arg3\"]\n \t@updated_json.delete(\"encrypted_arg3\")\n end\n elsif not @property_hash[:encrypted_arg3].to_s.empty?\n @updated_json[\"encrypted_arg3\"] = @property_hash[:encrypted_arg3]\n @updated_json[\"secured3\"] = \"1\"\n if defined?@updated_json[\"arg3\"]\n \t@updated_json.delete(\"arg3\")\n end\n end\n\n if not @resource[:arg4].nil?\n @updated_json[\"secured4\"] = \"0\"\n @updated_json[\"arg4\"] = @property_hash[:arg4]\n if defined?@updated_json[\"encrypted_arg4\"]\n \t@updated_json.delete(\"encrypted_arg4\")\n end\n elsif not @property_hash[:encrypted_arg4].to_s.empty?\n @updated_json[\"encrypted_arg4\"] = @property_hash[:encrypted_arg4]\n @updated_json[\"secured4\"] = \"1\"\n if defined?@updated_json[\"arg4\"]\n \t@updated_json.delete(\"arg4\")\n end\n end\n\n if not @property_hash[:value].to_s.empty?\n @updated_json[\"value\"] = @property_hash[:value]\n end\n\n if not @property_hash[:label1].nil?\n @updated_json[\"label1\"] = @property_hash[:label1]\n end\n if not @property_hash[:label2].nil?\n @updated_json[\"label2\"] = @property_hash[:label2]\n end\n if not @property_hash[:label3].nil?\n @updated_json[\"label3\"] = @property_hash[:label3]\n end\n if not @property_hash[:label4].nil?\n @updated_json[\"label4\"] = @property_hash[:label4]\n end\n\n\n @updated_json[\"name\"] = @resource[:attribute]\n \n # Flush changes:\n put @updated_json.to_json\n\n if defined? @resource[:reload_opsview]\n if @resource[:reload_opsview].to_s == \"true\"\n Puppet.notice \"Configured to reload opsview\"\n do_reload_opsview\n else\n Puppet.notice \"Configured NOT to reload opsview\"\n end\n end\n\n @property_hash.clear\n @attribute_properties.clear\n\n false\n end", "def update!(**args)\n @account_id = args[:account_id] if args.key?(:account_id)\n @internal_web_property_id = args[:internal_web_property_id] if args.key?(:internal_web_property_id)\n @profile_id = args[:profile_id] if args.key?(:profile_id)\n @profile_name = args[:profile_name] if args.key?(:profile_name)\n @table_id = args[:table_id] if args.key?(:table_id)\n @web_property_id = args[:web_property_id] if args.key?(:web_property_id)\n end", "def update!(**args)\n @account_id = args[:account_id] if args.key?(:account_id)\n @internal_web_property_id = args[:internal_web_property_id] if args.key?(:internal_web_property_id)\n @profile_id = args[:profile_id] if args.key?(:profile_id)\n @profile_name = args[:profile_name] if args.key?(:profile_name)\n @table_id = args[:table_id] if args.key?(:table_id)\n @web_property_id = args[:web_property_id] if args.key?(:web_property_id)\n end" ]
[ "0.65150845", "0.6458099", "0.640293", "0.6400613", "0.6400613", "0.6400613", "0.6400613", "0.6400613", "0.63936716", "0.63407576", "0.6278915", "0.62030935", "0.6201829", "0.6122758", "0.60915357", "0.6067378", "0.6001033", "0.59925795", "0.5991794", "0.5990218", "0.59744406", "0.59715116", "0.59689295", "0.59499633", "0.59499633", "0.5945412", "0.5936145", "0.59264755", "0.5916253", "0.588958", "0.58751124", "0.5843085", "0.5843085", "0.5835555", "0.5812369", "0.5810948", "0.5804669", "0.58033735", "0.5798443", "0.57978314", "0.57879895", "0.578616", "0.5785762", "0.5777261", "0.57719034", "0.57680106", "0.5758613", "0.5752665", "0.5735199", "0.5735199", "0.5735199", "0.5735199", "0.5735199", "0.5735199", "0.5735199", "0.5735199", "0.57137966", "0.57137966", "0.57137966", "0.571188", "0.5710567", "0.5706657", "0.5704888", "0.5704783", "0.57042", "0.569069", "0.569069", "0.56821567", "0.56744224", "0.56691986", "0.5667541", "0.5663644", "0.5653964", "0.56377316", "0.56342924", "0.5630286", "0.5623484", "0.562256", "0.56164235", "0.5615262", "0.56079817", "0.560601", "0.55861676", "0.5575112", "0.5575112", "0.55711144", "0.55669403", "0.5560742", "0.55459386", "0.55438673", "0.55421734", "0.55260736", "0.5511639", "0.55110264", "0.55077964", "0.5506524", "0.55059737", "0.54891443", "0.54873765", "0.54873765" ]
0.7076053
0
DELETE /auth_properties/1 DELETE /auth_properties/1.json
def destroy @auth_property.destroy respond_to do |format| format.html { redirect_to owner_token_auth_properties_path [@owner, @token], notice: 'Auth property was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def del_property( propname )\n resp = conn.delete('/users/'+name+'/props/'+propname+'/')\n \n case resp.code.to_i\n when 204\n return\n when 404\n case resp.header['resource-type']\n when 'user'\n raise RestAuthUserNotFound.new( resp )\n when 'property'\n raise RestAuthPropertyNotFound.new( resp )\n else\n raise RestAuthBadResponse.new( resp, \"Received 404 without Resource-Type header\" )\n end\n else\n raise RestAuthUnknownStatus.new( resp )\n end\n end", "def destroy\n if @property.user.id != @user.id\n redirect_to properties_path, notice:\"Not authorized\"\n end\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url }\n end\n end", "def destroy\n @api_v1_property.destroy\n end", "def destroy\n begin\n if params[:id]\n Property.clear(params[:id], nil, current_user.id)\n end\n render_success(\"Property deleted\")\n rescue Exception => e\n logger.error(\"Fails to execute #{request.url} : #{e.message}\")\n render_error(e.message)\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if !check_permissions?(session[:user_type], \"checkin_applicant\")\n redirect_to root_path\n end\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: \"Property was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete_property property_name\n\n begin\n raise 'Property name not specified.' if property_name.empty?\n\n str_uri = $product_uri + '/words/' + @filename + '/documentProperties/' + property_name\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n\n response_stream = RestClient.delete(signed_str_uri, {:accept => 'application/json'})\n\n stream_hash = JSON.parse(response_stream)\n stream_hash['Code'] == 200\n\n rescue Exception => e\n print e\n end\n\n end", "def delete_property(id)\n delete(\"/properties/#{id}\")\n end", "def destroy\n #@property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.photos.delete_all\n @property.features_properties.delete_all\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n properties_delete(@property)\n @property.destroy\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { render json: {success: true} }\n end\n end", "def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :ok }\n end\n end", "def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :ok }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to my_properties_properties_url , notice: \"Property was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete_properties(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_properties_with_http_info(name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_properties_with_http_info(name, opts)\n else\n raise\n end\n return data\n end", "def destroy\n onesecgroup('delete', resource[:name])\n @property_hash.clear\n end", "def destroy\n @property_user = PropertyUser.find(params[:id])\n @property_user.destroy\n\n respond_to do |format|\n format.html { redirect_to property_users_url }\n format.json { head :no_content }\n end\n end", "def delete_property property_name\n \n begin\n \n if @filename == \"\"\n raise \"Base file not specified.\"\n end\n \n if property_name == \"\"\n raise \"Property name not specified.\"\n end\n \n str_uri = $productURI + \"/words/\" + @filename + \"/documentProperties/\" + property_name\n signed_str_uri = Common::Utils.sign(str_uri)\n \n response_stream = RestClient.delete(signed_str_uri,{:accept=>\"application/json\"})\n \n stream_hash = JSON.parse(response_stream)\n \n if(stream_hash[\"Code\"] == 200)\n return true\n else\n return false\n end\n \n rescue Exception=>e\n print e\n end\n \n end", "def destroy\n @client_property.destroy\n respond_to do |format|\n format.html { redirect_to client_properties_url, notice: 'Client property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @users_property.destroy\n respond_to do |format|\n format.html { redirect_to users_properties_url, notice: 'Users property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n onevnet('delete', resource[:name])\n @property_hash.clear\n end", "def destroy\n authorize_action_for @property, at: current_store\n track @property\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_properties_path,\n notice: t('.notice', property: @property) }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact = Contact.find(params[:contact_id])\n @property = Property.find(params[:id])\n authorize @property\n @property.destroy\n respond_to do |format|\n format.html { redirect_to edit_contact_path(@contact), notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @request_property.destroy\n respond_to do |format|\n format.html { redirect_to request_properties_url, notice: 'Request property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n onetemplate('delete', resource[:name])\n @property_hash.clear\n end", "def destroy\n @property_detail.destroy\n respond_to do |format|\n format.html { redirect_to property_details_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: \"Property was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n head :no_content\n end", "def destroy\n @property.destroy\n\n head :no_content\n end", "def destroy\n @prop = Prop.find(params[:id])\n @prop.destroy\n\n respond_to do |format|\n format.html { redirect_to props_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n format.js { render nothing: true}\n end\n end", "def delete_property property_name\n \n begin\n \n if @filename == ''\n raise 'Base file not specified.'\n end\n \n if property_name == ''\n raise 'Property name not specified.'\n end\n \n str_uri = $product_uri + '/slides/' + @filename + '/documentProperties/' + property_name\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n response_stream = RestClient.delete(signed_str_uri,{:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n if(stream_hash['Code'] == 200)\n return true\n else\n return false\n end\n \n rescue Exception=>e\n print e\n end\n \n end", "def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_properties_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to runner_home_path, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sys_property.destroy\n respond_to do |format|\n format.html { redirect_to sys_properties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to user_path(@property.user_id) }\n end\n end", "def destroy\n #@property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to(properties_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to(properties_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to propertys_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property_field = PropertyField.find(params[:id])\n @property_field.destroy\n\n respond_to do |format|\n format.html { redirect_to property_fields_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @quick_property = QuickProperty.find(params[:id])\n @quick_property.destroy\n\n respond_to do |format|\n format.html { redirect_to quick_properties_url }\n format.json { head :no_content }\n end\n end", "def delete\n @property = Property.find(params[:id])\n end", "def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_properties_url }\n format.json { head :ok }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to after_destroy_path, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location_property = LocationProperty.find(params[:id])\n @location_property.destroy\n\n respond_to do |format|\n format.html { redirect_to location_properties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: \"物件情報を消去しました\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @prop.destroy\n respond_to do |format|\n format.html { redirect_to props_url, notice: \"Prop was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/customFields/#{id}\")\n end", "def destroy\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to :back, alert: @property.errors[:base][0] }\n format.json { head :ok }\n end\n end", "def destroy\n @property_owner.destroy\n respond_to do |format|\n format.html { redirect_to property_owners_url }\n format.json { head :no_content }\n end\n end", "def destroy\n property = current_user.properties.find_by(id: params[:property_id])\n\n render(\n status: 422,\n json: { error: 'You are not an owner of this property' }\n ) and return unless property\n\n property.destroy\n\n if property.destroyed?\n render status: 200, json: { property_id: params[:property_id] }\n else\n render status: 422, json: {\n error: property.errors.full_messages.join(', ')\n }\n end\n end", "def destroy\n @chef_property.destroy\n respond_to do |format|\n format.html { redirect_to chef_properties_url, notice: 'Chef property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to category_sub_category_item_properties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stolen_property.destroy\n respond_to do |format|\n format.html { redirect_to stolen_properties_url, notice: 'Stolen property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if @tenant_of.property.user.id != @user.id\n redirect_to properties_path, notice: \"Not Authorized\"\n else\n @tenant_of.destroy\n redirect_to :back, notice: 'Tenant was removed.' \n end \n end", "def destroy\n @prop = Prop.find(params[:id])\n @prop.destroy\n\n respond_to do |format|\n format.html { redirect_to(props_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @property = Property.find(params[:id]).destroy\n redirect_to(:action => 'index')\n end", "def destroy\n @owner_property.destroy\n respond_to do |format|\n format.html { redirect_to owner_owner_properties_url(@owner), notice: 'Owner property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @r_property_definition.destroy\n respond_to do |format|\n format.html { redirect_to r_property_definitions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @auth = Auth.find(params[:id])\n @auth.destroy\n\n respond_to do |format|\n format.html { redirect_to auths_url }\n format.json { head :no_content }\n end\n end", "def delete(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'delete'}.merge(authentication))\n end", "def delete\n request('delete').auth_required!\n end", "def destroy\n @horizontal_property.destroy\n respond_to do |format|\n format.html { redirect_to act_path(@act), notice: 'Horizontal property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n # @credential.destroy\n # respond_to do |format|\n # format.html { redirect_to credentials_url, notice: 'Credential was successfully destroyed.' }\n # format.json { head :no_content }\n # end\n end", "def destroy\n @contact_property.destroy\n respond_to do |format|\n format.html { redirect_to contact_properties_url, notice: 'Contact property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @line_property.destroy\n respond_to do |format|\n format.html { redirect_to line_properties_url, notice: 'Line property was successfully destroyed.' }\n format.json { head :no_content }\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 @property_attachment.destroy\n respond_to do |format|\n format.html { redirect_to property_attachments_url, notice: \"Property attachment was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete_and_give_me_a_json(additional_path, params = nil)\n if self.service_base_path != nil\n if params == nil\n params = Hash.new\n end\n params[:api_key] = self.access_token\n message = self.http_client.delete \"#{self.base_url}#{self.service_base_path}/#{additional_path}.json\", params\n trata_erro(message.content)\n end\n end", "def delete(path, data = {})\n self.class.delete path, :body => data.merge(:u => access_token)\n end", "def destroy\n @usr_vendor_property.destroy\n respond_to do |format|\n format.html { redirect_to usr_vendor_properties_url, notice: 'Usr vendor property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @checklist_property = ChecklistProperty.find(params[:id])\n @checklist_property.destroy\n\n respond_to do |format|\n format.html { redirect_to checklists_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @relassignpropertywithvalue.destroy\n respond_to do |format|\n format.html { redirect_to relassignpropertywithvalues_url, notice: 'Relassignpropertywithvalue was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_properties_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.delete_properties ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.delete_properties\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/documentproperties\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#delete_properties\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def destroy\n @property_hash[:ensure] = :absent\n end", "def destroy\n @property_heating.destroy\n respond_to do |format|\n format.html { redirect_to property_heatings_url, notice: 'Property heating was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @property_and_casualty\n @policy.destroy\n respond_to do |format|\n format.html { redirect_to back_path || insurance_path, notice: 'Insurance policy was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @env_pref = EnvPref.find(params[:id])\n @env_pref.destroy\n\n respond_to do |format|\n format.html { redirect_to env_prefs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @prop_value = PropValue.find(params[:id])\n @prop_value.destroy\n\n respond_to do |format|\n format.html { redirect_to(prop_values_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @usr_buyer_property.destroy\n respond_to do |format|\n format.html { redirect_to usr_buyer_properties_url, notice: 'Usr buyer property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @propose = Propose.find(params[:id])\n @propose.destroy\n\n respond_to do |format|\n format.html { redirect_to proposes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sample_property = SampleProperty.find(params[:id])\n @sample = Sample.find(@sample_property.sample_id)\n @sample_property.destroy\n\n respond_to do |format|\n format.html { redirect_to project_sample_set_sample_path(params[:project_id],params[:sample_set_id],@sample) }\n format.json { head :no_content }\n end\n end", "def destroy\n @property_closet.destroy\n respond_to do |format|\n format.html { redirect_to property_closets_url, notice: 'Property closet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @external_credential.destroy\n respond_to do |format|\n flash[:success] = 'Success! ExternalCredential destroyed.'\n format.html { redirect_to external_credentials_url }\n format.json { head :no_content }\n end\n end", "def http_delete(opts={})\n ret=http_delete_low(opts)\n if ret.is_a?(Hash) and ret.has_key?('error') and ret['error']=='Invalid Credentials' then\n\tauthdefault\n\tret=http_delete_low(opts)\n\treturn ret\n else\n\treturn ret\n end\n end", "def destroy\n @credential.destroy\n respond_to do |format|\n format.html { redirect_to credentials_url, notice: 'Credential was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @property_service_type.destroy\n respond_to do |format|\n format.html { redirect_to property_service_types_url, notice: 'Property service type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7440488", "0.7127522", "0.70492405", "0.7034347", "0.69556034", "0.69556034", "0.6921843", "0.6912386", "0.6906535", "0.6901997", "0.6879539", "0.68787664", "0.6842096", "0.6842096", "0.6839829", "0.6839829", "0.68157214", "0.6814176", "0.68130285", "0.6790191", "0.6787141", "0.6777806", "0.6764465", "0.6743326", "0.6701166", "0.6698167", "0.6689687", "0.6674961", "0.66664267", "0.665978", "0.665978", "0.665978", "0.665978", "0.665978", "0.665978", "0.665978", "0.665978", "0.665978", "0.665978", "0.66579074", "0.6651914", "0.6650015", "0.6640735", "0.6628235", "0.66160876", "0.66124", "0.66107994", "0.6606994", "0.660597", "0.6605516", "0.65859073", "0.6563404", "0.6538908", "0.6531879", "0.6523567", "0.65141714", "0.6508775", "0.6477525", "0.6456356", "0.6455416", "0.6420144", "0.64154375", "0.6403328", "0.6371969", "0.63663644", "0.6365595", "0.63655126", "0.6344118", "0.6319187", "0.6306283", "0.6273054", "0.6261428", "0.62479997", "0.623953", "0.6232975", "0.6229737", "0.62065876", "0.619855", "0.61891615", "0.6184283", "0.6184141", "0.61758506", "0.61482954", "0.61478674", "0.61469406", "0.613668", "0.612386", "0.6112438", "0.6095046", "0.6086252", "0.6084348", "0.6084139", "0.6081566", "0.6073125", "0.60725486", "0.60635066", "0.6062191", "0.6061033", "0.60555935", "0.6049896" ]
0.7467164
0
Use callbacks to share common setup or constraints between actions.
def set_auth_property @auth_property = AuthProperty.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def auth_property_params params.require(:auth_property).permit(:key, :txtValue, :numValue, :token) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def valid_params_request?; end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def filtering_params\n params.permit(:email)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def url_whitelist; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.6980957", "0.6783065", "0.6747844", "0.6741468", "0.67356336", "0.6592548", "0.65036845", "0.64978707", "0.64825076", "0.64795035", "0.64560914", "0.64397955", "0.6379666", "0.6376688", "0.6366702", "0.6319728", "0.6300833", "0.6300629", "0.6294277", "0.6293905", "0.6291174", "0.62905735", "0.6283171", "0.6242344", "0.62403613", "0.6218049", "0.62143815", "0.62104696", "0.61949855", "0.6178671", "0.6176147", "0.6173327", "0.6163395", "0.6153005", "0.6151833", "0.6147288", "0.61224324", "0.6118827", "0.61075264", "0.61054534", "0.6092497", "0.6080082", "0.60710967", "0.60627776", "0.60219413", "0.60175914", "0.60153484", "0.60107356", "0.60081726", "0.60081726", "0.60013986", "0.6000165", "0.59978646", "0.59936947", "0.59925723", "0.5992084", "0.59796256", "0.5967569", "0.5960056", "0.59589803", "0.5958441", "0.5958401", "0.5952607", "0.5952406", "0.5944409", "0.59391016", "0.593842", "0.593842", "0.5933845", "0.59312123", "0.5926475", "0.59248453", "0.59179676", "0.59109294", "0.59101623", "0.5908172", "0.59058356", "0.5899052", "0.5897749", "0.5896101", "0.58942914", "0.58939576", "0.5892063", "0.5887407", "0.588292", "0.58797663", "0.587367", "0.58681566", "0.5868038", "0.5866578", "0.58665025", "0.58655846", "0.58640826", "0.5863465", "0.5862226", "0.586065", "0.58581287", "0.5854443", "0.5854172", "0.58507544", "0.5849934" ]
0.0
-1
Write a program that solicits 6 numbers from the user, then prints a message that describes whether or not the 6th number appears amongs the first 5 numbers.
def compare(num1, num2, num3, num4, num5, num6) num_array = [num1, num2, num3, num4, num5] if num_array.include?(num6) p "The number #{num6} appears in #{num_array}" else p "The number #{num6} does not appear in #{num_array}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_problem()\n\n\tcount = 10\n\twhile count > 0\n\t\tputs \"you have #{count} times you can do this!\"\n\n\t\tputs \"Please enter a number that is a multiple of 3 or 5, 1-100 for a phrase or word back!\"\n\t\tnumber = gets.chomp\n\n\t\tmult_of_three = [\"3\", \"6\", \"9\", \"12\", \"18\", \"21\", \"24\", \"27\", \"33\", \"36\", \"39\", \"42\", \"48\", \"51\", \"54\", \"57\", \"63\", \"66\", \"69\", \"72\", \"78\", \"81\", \"84\", \"87\", \"93\", \"96\", \"99\"]\n\t\tmult_of_five = [\"5\", \"10\", \"20\", \"25\", \"35\", \"40\", \"50\", \"55\", \"65\", \"70\", \"80\", \"85\", \"95\", \"100\"]\n\t\tmult_of_both = [\"15\", \"30\", \"45\", \"60\", \"75\", \"90\"]\n\n\t\tif mult_of_three.include?(number)\n\t\t\tputs \"Bit\"\n\n\t\telsif mult_of_five.include?(number)\n\t\t\tputs \"Maker\"\n\n\t\telsif mult_of_both.include?(number)\n\t\t\tputs \"BitMaker!\"\n\n\t\telse\n\t\t\tputs \"That number is not 1-100, or is not a multiple of 3 and/or 5!\"\n\t\tend\n\n\t\tcount -= 1\n\n\tend\n\n\n\nend", "def last_include\n result = []\n\n puts \"Enter your first number\"\n first = gets.chomp\n result << first\n\n puts \"Enter your second number\"\n second = gets.chomp\n result << second\n\n puts \"Enter your third number\"\n third = gets.chomp\n result << third\n\n puts \"Enter your fourth number\"\n fourth = gets.chomp\n result << fourth\n\n puts \"Enter your fifth number\"\n fifth = gets.chomp\n result << fifth\n\n puts \"Enter your sixth number\"\n sixth = gets.chomp\n\n if result.include?(sixth)\n puts \"The number #{sixth} appears in #{result}.\"\n else\n puts \"The number #{sixth} doesn't appear in #{result}\"\n end\nend", "def featured(number)\n loop do\n number +=1\n characters = number.to_s.split('')\n if (number.odd?) && (number % 7 == 0) && (characters.uniq == characters) \n p number\n break\n end \n end \nend", "def featured(num)\n num +=1 \n until num % 7 == 0 && num.odd?\n num += 1\n end\n\n loop do\n return num if num.to_s.chars.uniq == num.to_s.chars\n num += 14\n break if num >= 9_876_543_210\n end\n\n \"Your quest is doomed. There is no featured number beyond these walls.\"\nend", "def featured(int)\n int += 1\n int += 1 until int % 7 == 0 && int.odd?\n \n loop do\n double_check = int.to_s.split(\"\")\n if double_check.uniq == double_check\n return int\n else\n int += 14\n end \n break if int >= 9_876_543_210 \n end\n \"There is no possible number that fulfills those requirements\"\nend", "def find_number_in_arr\n arr = []\n suffixes = {1 => 'st', 2 => 'nd', 3 => 'rd', 4 => 'th', 5 => 'th'}\n 1.upto(5) do |n|\n puts \"Enter the #{n.to_s + suffixes[n]} number:\"\n arr << gets.to_i \n end\n puts \"Enter the last number:\"\n num = gets.to_i\n\n appear_phrase = arr.include?(num) ? \" appears \" : \" does not appear \"\n puts \"The number #{num}\" + appear_phrase + \"in #{arr.inspect}.\"\nend", "def featured(n)\n n += 1\n n += 1 until n % 7 == 0 && n.odd?\n loop do\n break if n.to_s.chars.uniq.join == n.to_s\n n += 14\n if n > 9876543210\n puts \"There is no possible number that fulfills those requirements\"\n return nil\n end\n end\n n\nend", "def featured(num)\n num += 1\n num += 1 until num.odd? && (num % 7).zero?\n loop do\n return num if num.to_s.chars.size == num.to_s.chars.uniq.size\n num += 14\n break if num > 9_876_543_210\n end\n 'There is no possible number that fulfills those requirements'\nend", "def featured2(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def featured(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number > 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def featured(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def featured(num)\n divisor = num / 7\n count = 1\n total = 0\n\n until (count > divisor) && (total.odd? && total > num) \n total = count * 7\n count += 1\n end\n\n loop do\n number_chars = total.to_s.split('')\n return total if number_chars.uniq == number_chars\n total += 7\n break if num >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements'\nend", "def answer_validation(name)\n puts \"\\nHello, #{name}! What would you like to do today?\\n\n [1] Check allergy score.\n [2] Check allergies based on score.\n [3] Check if allergic to.\n [4] See allergy score table\n [5] Exit\"\n answer_keys = [*1..5]\n ans = gets.chomp.to_i\n while !answer_keys.include?(ans)\n puts \"Please navigate through the options using the numbers given.\"\n ans = gets.chomp.to_i\n end\n ans\nend", "def featured(int)\n loop do \n int += 1\n if int.odd? && int % 7 == 0\n return int if int.to_s.chars.uniq == int.to_s.chars\n end\n break if int == 9_999_999\n end\n \"There is no possible number that fulfils those requirements\"\nend", "def featured(number)\n featured = 0\n loop do \n number += 1\n if number % 7 == 0 &&\n number.odd? &&\n number.to_s.length == number.to_s.chars.uniq.length\n featured = number\n break\n end\n if number.to_s.length > 10\n puts \"Invalid\"\n featured = 0\n break\n end\n end\n featured\nend", "def ask_user_for_a_number(message)\n puts message\n print \">\"\n gets.chomp #return iimplicite en dernière d'un f\n\n #until first.include(\"x\") = true\nend", "def print_it(given_num)\n\n # create initialize a stop variable\n num = 0\n\n # continously loop until num is equal to given_num\n until num == given_num\n\n # if num is a multiple of both 3 and 5 print statement\n if ((num % 3) == 0) && ((num % 5) == 0)\n puts \"#{num} - FizzBuzz\"\n\n # if num is only a multiple of 3 print statement\n elsif (num % 3) == 0\n puts \"#{num} - Fizz\"\n\n # if num is only a multiple of 5 print statement\n elsif (num % 5) == 0\n puts \"#{num} - Buzz\"\n\n # if num is not a mutiple of either 3 or 5 print only the num\n else\n puts num\n end\n\n # increment num for next iteration\n num += 1\n end\n\nend", "def featured(num)\n loop do\n num += num % 7 == 0 ? 7 : 1\n num_str = num.to_s.chars\n return num if num.odd? && num % 7 == 0 && num_str.uniq == num_str\n break if num >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def find_number\n\ti = 0 \n\tnot_found = true\n\twhile not_found \n\t\ti+=1\n\t\t#puts i \n\t\t#puts is_int(f6(i))\n\t\tnot_found = ! is_int(f6(i.to_f))\n\tend\n\ti\nend", "def cheat\n puts 'What number do you want to roll?'\n\tnumber = gets.chomp.to_i\n\tif number >= 1 && number <= 6\n\t @number_showing = number\n\telse\n\t puts 'Cheater!!!'\n end\n @number_showing\t\n end", "def featured(number)\n sum = 7\n loop do \n return \"There is no possible number that fulfills those requirements\" if number >= 9_876_543_210\n if sum <= number\n sum += 7\n elsif sum.even?\n sum += 7\n elsif sum.digits.uniq != sum.digits\n sum += 7\n else\n break\n end\n end\n sum\nend", "def featured(i) # found digits method but only works > v2.4 so...\n i = i - i % 7\n loop do\n i += 7\n list = []\n x = i\n while x > 0 do\n list.unshift(x % 10)\n x /= 10\n end\n if list.length > 9; return \"There is no possible number that fulfills those requirements\" end\n if list == list.uniq; break end\n end \n i\nend", "def solve ()\n @num_tested = 0\n @num_solutions = 0\n print \"Enter Answer: \"\n answer = gets.chomp.to_i\n print \"Enter Numbers:\\n\"\n numbers = []\n 6.times{numbers << gets.chomp.to_i}\n puts \"Solving...\"\n pick_two(numbers, answer, \"\")\n [@num_tested, @num_solutions]\nend", "def prompt_user\n puts \"Please choose a number between 1 and 6\"\nend", "def run_guessing_game\n\tuser_number =\"\"\n\twhile user_number != \"exit\"\n\t\tcom_number = rand(1..6)\n\t\tputs \"Guess a number between 1 and 6.\"\n\t\tuser_number = gets.chomp\n\t\tif com_number == user_number.to_i\n\t\t\tputs \"You guessed the correct number!\"\n\t\telse \n\t\t\tputs \"The computer guessed #{com_number}.\"\n\t\tend\n\tend\n\texit_guessing_cli\nend", "def number(N)\r\n N =gets.strip.to_i\r\n if\r\n ( N%2==1 || N>5 && N <= 20)\r\n puts \"Weird\"\r\n else\r\n puts \"Not Weird\"\r\n end\r\nend", "def featured(number)\n max = 9_876_543_210\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n loop do\n number_chars = number.to_s.chars\n if number_chars.size == number_chars.uniq.size\n return number\n end\n if number > max\n break\n end\n number += 14\n end\n \"ERROR! No next featured number!\"\nend", "def get_toppings_\n puts \"how many pizzas?\"\n pizzanumber = gets.chomp.to_i\n pizza_array = (1..pizzanumber).to_a\n pizza_array.each do |number|\n puts \"how many toppings for #{number} pizza?\"\n toppings = gets.chomp.to_i\n end\n pizza_array.each do |number|\n puts \"Pizaa ##{number} has #{toppings} toppings\"\n end\nend", "def featured(num)\n return 'Error! No featured numbers exist over 10 digits!' if num >= 9876543210\n loop do\n num += 1\n break if num.odd? && (num % 7).zero? && num.digits.uniq! == nil\n end\n num\nend", "def run_guessing_game\n \n random_num = rand(6) + 1\n guess_num_between_1_6 = \"\"\n user_input = \"exit\" \nend", "def guess_the_number(prog_num)\ncounter=0\nwhile counter < 10\nnumber=user_guessing\ncounter+=1\nif number>prog_num\n if number-(prog_num)>5\n puts \"cooold try no.#{counter}\"\n else\n puts \"hooot try no.#{counter}\"\n end\nelsif number<prog_num\n if (prog_num)-number>5\n puts \"cold try no.#{counter}\"\n else\n puts \"hot try no.#{counter}\"\n end\nelsif number==prog_num\n return puts \"you win after #{counter} try(s).\"\nend\nend\nend", "def featured(int)\n for num in (int + 1...9_999_999_999) \n return num if num.odd? && num % 7 == 0 && num.digits == num.digits.uniq\n end\n \"There is no possible number that fulfills those requirements\"\nend", "def pe52(startAt, endAt)\n (startAt..endAt).step(6).each do |x|\n bNum = x/6\n bNumCSort = bNum.to_s.chars.sort\n next if bNumCSort != x.to_s.chars.sort\n next if bNumCSort != (bNum*5).to_s.chars.sort\n next if bNumCSort != (bNum*4).to_s.chars.sort\n next if bNumCSort != (bNum*3).to_s.chars.sort\n next if bNumCSort != (bNum*2).to_s.chars.sort\n return bNum\n end\n false\nend", "def fizz_buzz_woof(max)\n 1.upto(max).each do |x|\n if (x % 3 == 0) && (x % 5 == 0) && (x % 7 == 0)\n puts \"FizzBuzzWoof\"\n elsif (x % 3 == 0) && (x % 5 == 0)\n puts \"FizzBuzz\"\n elsif (x % 3 == 0) && (x % 7 == 0)\n puts \"FizzWoof\"\n elsif (x % 5 == 0) && (x % 7 == 0)\n puts \"BuzzWoof\"\n elsif x % 3 == 0\n puts \"Fizz\"\n elsif x % 5 == 0\n puts \"Buzz\"\n elsif x % 7 == 0\n puts \"Woof\"\n else\n puts x\n end\n end\nend", "def counter()\n number = gets.chomp\n number = number.to_i\nfor num in 1..number.to_i\n # if num % 15 == 0\n if num % 5 == 0 && num % 3 == 0\n p \"FizzBuzz\"\n elsif num % 5 == 0\n p \"Buzz\"\n elsif num % 3 == 0\n p \"Fizz\"\n else\n p num\n end\nend\nend", "def featured(number)\n number += 1\n\n until number % 7 == 0 && number.odd?\n number += 1\n end\n\n loop do\n if number.digits.uniq == number.digits\n return number\n else\n number += 14\n end\n break if number.digits.size > 10\n end\n\n \"Error\"\nend", "def featured(integer)\n return \"There is no possible number that fulfills those requirements\" if \n integer >= 9_876_543_210\n integer += 1\n until integer % 7 == 0 && integer.odd? && integer.digits.uniq! == nil\n integer += 1\n end\n integer\nend", "def fizzbuzz(num)\n i = 0;\n num.times do\n i += 1\n # Check to see if num is a multiple of 3 but not 5\n if (i % 3 == 0 && i % 5 != 0)\n p \"Fizz\"\n # Check to see if num is a multiple of 5 but not 3\n elsif (i % 5 == 0 && i % 3 != 0)\n p \"Buzz\"\n # Check to see if num is a multiple of 3 and 5\n elsif (i % 5 == 0 && i % 3 == 0)\n p \"FizzBuzz\"\n else\n p i\n end\n end\nend", "def exes_and_ohs(input)\n # Your code goes here\n arr = input.downcase.split('')\n\n if arr.uniq.count == 2 && arr.count <= 6\n puts true\n else\n puts false\n end\nend", "def featured?(num)\n num.odd? && num % 7 == 0 && num.digits.uniq.size == num.digits.size\nend", "def y\n puts \"type a number\"\n u = gets.to_i\n puts \"type a max value\"\n m = gets.to_i\n\n a = []\n i = 0\n while i < m\n i += 1\n a << i\n end\n\n a.each do |x|\n if x % u == 0\n puts x\n else\n end\n end\n\nend", "def multisum(number) # number 1..10 determines which numbers are divisible by 3 and 5\n sum = 0\n 1.upto(number) do |num|\n if num % 3 == 0 || num % 5 == 0\n sum += num # this adds the numbers from 1..num that either are multiples of 3 or 5\n end\n end\n sum # returns sum, need this here to run program successfully\nend", "def run\n puts \"How many prime numbers' products table do you want to check? (default is 10).\" + \"\\n\"\n n = gets.chomp\n if n.empty?\n print_table(10)\n elsif n.to_i == 0\n puts \"Please run program again and provide a valid number.\" + \"\\n\"\n else\n print_table(n.to_i)\n end\n end", "def print_list(limit)\n\n 1.upto(limit) do |number|\n\n if divisible_by?(15, number)\n puts \"Fizzbuzz\"\n\n elsif divisible_by?(3, number)\n puts \"Fizz\"\n\n elsif divisible_by?(5, number)\n puts \"Buzz\"\n\n else\n puts number\n\n end\n end\nend", "def featured(num)\n # next_num = 7 # assume input is only positive\n closer_num = num / 7 * 7 # to start closer to the next required number instead of starting from 7\n next_num = closer_num.odd? ? closer_num : closer_num + 7 # so that next_num is odd and we can increment by 14 in the while loop\n\n while next_num < 9_999_999_999\n if next_num % 7 == 0 \\\n && next_num.to_s.size == next_num.to_s.chars.uniq.size \\\n && next_num > num\n return next_num\n else\n next_num += 14\n end\n end\nend", "def choose_number_of_games\n win_count = nil\n loop do\n say 'First to how many wins takes the match (1-10)? '\n win_count = gets.chomp\n break if win_count =~ /\\A([1-9]|10)\\z/\n say 'Enter a whole number between one and 10, please.', 1\n end\n win_count = win_count.to_i\n match_wins_text =\n 1 == win_count ? 'win' : match_count_text(win_count) + ' wins'\n say \"Ok, first #{match_wins_text} takes the match.\", 2\n win_count\n end", "def fizzbuzz(num)\n collection = (1..num).to_a\n collection.each do |num|\n if (num % 3 == 0) && (num % 5 != 0)\n puts \"Fizz #{num}\"\n elsif (num % 5 == 0) && (num % 3 != 0)\n puts \"Buzz #{num}\"\n elsif (num % 3 == 0) && (num % 5 == 0)\n puts \"FizzBuzz #{num}\"\n end\n end\nend", "def fizzbuzz(start, finish)\n start.upto(finish) do |num|\n if div_by_3?(num) && div_by_5?(num)\n puts \"FizzBuzz\"\n elsif div_by_5?(num)\n puts \"Buzz\"\n elsif div_by_3?(num)\n puts \"Fizz\"\n else\n puts num\n end\n end\nend", "def featured(integer)\n count = 0\n\n loop do \n break if count >= 9_999_999_999\n count += 7\n if count.odd? && count % 7 == 0 && count.digits.uniq == count.digits && count > integer\n return count\n end\n end\n \"There is no possible number that fulfills those requirements.\"\nend", "def guess_the_number\n prog_num=rand(1..20)\ncounter=0\nwhile counter < 10\nnumber=user_guessing\ncounter+=1\nif number>prog_num\n if number-(prog_num)>5\n puts \"too large try no.#{counter}\"\n else number-(prog_num)>5\n puts \"bit large try no.#{counter}\"\n end\nelsif number<prog_num\n if (prog_num)-number>5\n puts \"too small try no.#{counter}\"\n else (prog_num)-number>5\n puts \"bit small try no.#{counter}\"\n end\nelsif number==prog_num\n return puts \"you win after #{counter} try(s).\"\nend\nend\nend", "def fizzbuzz(int1, int2)\n int1.upto(int2) do | number |\n if (number % 5 == 0) && (number % 3 == 0)\n puts \"FizzBuzz\"\n elsif number % 3 == 0\n puts \"Fizz\"\n elsif number % 5 == 0\n puts \"Buzz\"\n else\n puts number\n end\n end\nend", "def featured?(num)\n chars = num.to_s.split(//)\n num.odd? && (num % 7).zero? && chars.size == chars.uniq.size\nend", "def pling_plang_plung\n print \"What is your number? \"\n your_number = gets.to_f\n message = \"\"\n\n if your_number % 3 == 0\n message += \"Pling \"\n puts \"Pling\"\n end\n if your_number % 5 == 0\n message += \"Plang \"\n puts \"Plang\"\n end\n if your_number % 7 == 0\n message += \"Plong \"\n puts \"Plong\"\n end\n if your_number % 3 != 0 && your_number % 5 != 0 && your_number % 7 != 0\n message += your_number\n puts your_number\n end\n\n puts message\n\nend", "def user_number\n puts 'enter your number'\n numb1 = gets.chomp!.to_i\n if numb1 <= 50\n puts 'your number is equal to or less than 50'\n elsif numb1 == 51\n puts 'you number must be 51'\n elsif numb1 <= 100\n puts 'you number is equal to or less than 100'\n else\n 'puts you got a high number'\n end\n end", "def by_five?(n)\n return n % 5 == 0\nend", "def multiples(num)\n# \"each\" loop for each integer\n (1..num).each do |num|\n # numbers that are mulitples of 3 and 5\n if num % 3 == 0 && num % 5 == 0\n puts \"FizzBuzz\"\n # multiples of 5\n elsif num % 5 == 0\n puts \"Buzz\"\n # multiples of 3\n elsif num % 3 == 0\n puts \"Fizz\"\n # if not divisible by 5 or 3, just print number\n else\n puts num\n end\n end\nend", "def runFizzBuzz()\n\twhile true\n\t\tputs \"Number to stop \" + $fizz + $buzz + \"-ing at?\"\n\t\tn = gets.chomp.to_i\n\t\tif n < 1\n\t\t\tputs \"You need to input a number which is equal to or more than 1\"\n\t\t\tnext\n\t\tend\n\t\tfor i in 1..n\n\t\t\tout = isFizzBuzz(i)\n\t\t\tputs out\n\t\tend\n\t\tbreak\n\tend\nend", "def challenge5 \n\tcounter = 1\n\tnumber = rand(1..100)\n\tputs \"Guess a number between 1 and 100\"\n\tguess = gets.chomp.to_i\n\n\twhile guess != number do\n\t\tif guess > 100 || guess < 0\n\t\t\tputs \"Please guess a number between 1 and 100. Guess again\"\n\t\t\tguess = gets.chomp.to_i\n\t\t\tcounter +=1\n\t\telsif guess < number\n\t\t\tputs \"the number is greater than #{guess}. Guess again.\"\n\t\t\tguess = gets.chomp.to_i\n\t\t\tcounter +=1\n\t\telsif guess > number\n\t\t\tputs \"the number is less than #{guess}. Guess again.\"\n\t\t\tguess = gets.chomp.to_i\n\t\t\tcounter +=1\n\t\tend\n\tend\n\tputs \"You got it in #{counter} attempt(s)!\"\nend", "def main\n return (N.split(\"\").map(&:to_i).sum % 9 == 0) ? \"Yes\" : \"No\"\nend", "def fizzbang(limit)\r\n\t1.upto(limit) do |number|\r\n\t\tif number % 3 == 0 and number % 5 == 0\r\n\t\t\tputs \"fizzbang\"\r\n\t\telsif number % 3 == 0\r\n\t\t\tputs \"fizz\"\r\n\t\telsif number % 5 == 0\r\n\t\t\tputs \"bang\"\r\n\t\telse\r\n\t\t\tputs number\r\n\t\tend\r\n\tend\r\nend", "def how_many_players\n puts \"How many human players are there?\"\n num = gets.chomp.to_i\n until num.between?(1, 2)\n puts \"Please choose a number between 1-2\"\n num = gets.chomp.to_i\n end\n num\n end", "def user_num\n loop do\n prompt(MESSAGES['number_request'])\n num1 = Kernel.gets().chomp()\n num2 = Kernel.gets().chomp()\n if number?(num1) && number?(num2)\n return num1, num2\n else\n prompt(MESSAGES['invalid_numbers'])\n end\n end\nend", "def featured_num?(num)\n num.odd? && num % 7 == 0 && num.digits.uniq == num.digits\nend", "def featured(int)\n if int >= 9_876_543_210\n return 'There is no possible number that fulfills those requirements.'\n end\n \n featured_num = 0\n until featured_num > int\n loop do\n featured_num += 7\n next if featured_num.even?\n next if featured_num.digits != featured_num.digits.uniq\n break\n end\n end\n featured_num\nend", "def check_report(input, number, total)\n input.combination(number).detect { |tuple| tuple.sum == total }.reduce(:*)\nend", "def featured?(num)\n chars = num.to_s.chars\n num % 7 == 0 && num.odd? && chars.none? { |char| chars.count(char) > 1 }\nend", "def featured(int)\n next_num = 0\n loop do\n next_num = int.succ\n break if next_num.odd? && next_num % 7 == 0\n int = next_num\n end\n loop do\n break if next_num >= 9_876_543_210\n if next_num.to_s.chars.uniq == next_num.to_s.chars\n return next_num\n else next_num += 14\n end\n end\n \"There is no possible number that fulfills those requirements.\"\nend", "def prompt_numbers\n numbers = []\n while numbers.size < 4 do\n numbers << rand(0..9)\n numbers.uniq!\n end\n return numbers.to_s\n end", "def quick_num_checker(num)\n num = num.to_s\n if num == \"5\"\n return true\n elsif num == \"1\"\n return false\n elsif num == \"2\"\n return true\n elsif num == \"3\"\n return true\n elsif num == \"7\"\n return true \n elsif num.include?(\"0\") || num.include?(\"2\") || num.include?(\"4\") || num.include?(\"5\") || num.include?(\"6\") || num.include?(\"8\")\n return false\n # elsif num[-1]==\"2\"\n # return false\n # elsif num[-1]==\"4\"\n # return false\n # elsif num[-1]==\"5\"\n # return false\n # elsif num[-1]==\"6\"\n # return false\n # elsif num[-1]==\"8\"\n # return false\n else\n return true\n end\nend", "def featured_num?(num)\n return false unless num.odd?\n return false unless num % 7 == 0\n return false unless num.digits.size == num.digits.uniq.size\n true\nend", "def small_numbers(a)\n small = a.count {|x| x < 5}\n print small\n \nend", "def fizz_buzz(max)\n (1...max).select{|number| (number % 4 == 0 || number % 6 == 0) && !(number % 4 == 0 && number % 6 == 0)}\nend", "def super_fizz(number)\n(0..1000).each do |number|\ndivisible_by_3 = number % 3\ndivisible_by_5 = number % 5\ndivisible_by_7 = number % 7\nif divisible_by_3 == 0\n if divisible_by_5 == 0\n if divisible_by_7 == 0\n puts \"SuperFizzBuzz\"\n else\n puts \"FizzBuzz\"\n end\n elsif divisible_by_7 == 0\n puts \"SuperFizz\"\n else\n puts \"Fizz\"\n end\nelsif divisible_by_5 == 0\n if divisible_by_7 == 0\n puts \"SuperBuzz\"\n else\n puts \"Buzz\"\n end\nelsif divisible_by_7 == 0\n puts \"Super\"\nelse\n puts number\nend\nend\nend", "def request_player_input(message = 'Please enter an array of numbers 1-6 each separated by \" \"')\n puts message.to_s\n temp_input = gets.chomp\n temp_input = temp_input.split\n temp_input = temp_input.map(&:to_i)\n end", "def featured(integer)\n return \"Error: There is no possible number that fulfills those requirements\" if integer >= 9_876_543_210\n counter = integer + 1\n counter += 1 until counter % 7 == 0 && counter.odd?\n \n loop do\n return counter if counter.digits.uniq.size == counter.digits.size\n counter += 14\n end\nend", "def cracklePop\n (1..100).to_a.each do |x|\n if x % 3 && x % 5 == 0\n puts \"CracklePop\"\n elsif x % 3 == 0\n puts \"Crackle\"\n elsif x % 5 == 0\n puts \"Pop\"\n else\n puts x\n end\n end\nend", "def fizzbuzz(start_num, end_num)\n start_num.upto(end_num) do |num|\n if num % 5 == 0 && num % 3 == 0\n puts \"FizzBuzz\"\n elsif num % 3 == 0 then puts \"Fizz\"\n elsif num % 5 == 0 then puts \"Buzz\"\n else puts num\n end\n end\nend", "def test_input1(matches, card1, card2,number_of_cards)\n while matches.include?(card1.to_i) || !(/^[1-#{number_of_cards}]$/).match?(card1)\n if !(/^[1-#{number_of_cards}]$/).match?(card1)\n puts \"Please input an integer in the specified range\"\n else\n puts \"That card is already open\"\n end\n card1 = askforcard1(number_of_cards)\n end\n return card1.to_i\nend", "def validate_numeric_stdin(a)\n print \"\\n(use commas for multiple selections): \"\n nums = gets.chomp.split(\",\").select { |x| /\\d+/.match x }.uniq.map(&:to_i)\n nums.reject { |z| z >= a.size }\nend", "def dont_give_me_five(start_,end_)\n number = 0\n (start_..end_).each do |n|\n n = n.to_s.split('')\n if n.include?(\"5\")\n else\n number += 1\n end\n end\n return number\nend", "def ask_user\n puts 'enter a number:'\n input = gets.chomp.to_i\n check_num(input)\n end", "def featured(n)\n # The next 2 lines guarantees we start with odd multiples of 7 that is higher than n\n n += 1\n n += 1 until n.odd? && n % 7 == 0\n\n while n < 9_876_543_201\n return n if featured?(n)\n n += 14 # this hastens the loop - we only iterate odd multiples of 7\n end\n raise StandardError, \"No more featured number available\"\nend", "def mult_five(number)\n if number%5 === 0\n puts \"#{number} is a multiple of 5.\"\n else\n puts \"#{number} is not a multiple of 5.\" # You need the hash stuff here because you can't add an integer to a string, you idiot.\n end\nend", "def multiples\n \tfor n in 1..100\n \t\tif n%3==0 && n%5==0\n \t\t\tputs \"FizzBuzz\"\n \t elsif n%3==0\n \t \tputs \"Buzz\"\n \t else\n \t \tputs n\n \t end\n \tend\nend", "def fizzbuzz(a,b)\n numbers = (a..b).to_a\n\n numbers.each do |number|\n if number % 15 == 0\n puts \"FizzBuzz\"\n elsif number % 3 == 0\n puts \"Fizz\"\n elsif number % 5 == 0\n puts \"Buzz\"\n else\n puts number\n end\n end\nend", "def supafizbuz(max_num)\n range = (0..max_num).to_a\n range.each do |num|\n if num % 3 == 0\n if num % 7 == 0\n if num % 5 == 0\n puts(\"SuperFizzBuzz\")\n next\n end\n puts(\"SuperFizz\")\n next\n end\n puts(\"Fizz\")\n next\n elsif num % 7 == 0\n if num % 5 == 0\n puts(\"SuperBuzz\")\n next\n end\n puts(\"Super\")\n next\n elsif num % 5 == 0\n puts(\"Buzz\")\n next\n end\n puts(num)\n end\n return nil\n\n range = (0..max_num).to_a\n range.each do |num|\n a = num % 7 == 0 ? \"Super\" : \"\"\n b = num % 3 == 0 ? \"Fizz\" : \"\"\n c = num % 5 == 0 ? \"Buzz\" : \"\"\n puts (a + b + c) == \"\" ? num : (a + b + c)\n end\n return nil\n\nend", "def fizz_buzz_check\n @numbers.collect do |x|\n if multiple_of(15, x)\n 'FizzBuzz'\n elsif multiple_of(3, x)\n 'Fizz'\n elsif multiple_of(5, x)\n 'Buzz'\n else\n x\n end\n end\n end", "def fizzbuzz()\n numbers = Array(1..100)\n numbers.each do |num|\n if num % 15 == 0\n puts \"FizzBuzz\" \n elsif num % 3 == 0\n puts \"Fizz\"\n elsif num % 5 == 0\n puts \"Buzz\"\n else\n puts num\n end\n end\nend", "def print_names_less_than_x_characters\n puts \"Please set the max character length of names to display\"\n number = STDIN.gets.chomp\n match_array = []\n #Will not continue unless input is an integer, and avoided cases in which to_i for a string returns 0, AKA an integer\n while number.to_i.to_s != number\n puts \"Please enter an integer\"\n number = STDIN.gets.chomp\n end\n @students.each_with_index do |student, index|\n if student[:name].length <= number.to_i\n match_array.push(student)\n end\n end\n print(match_array)\n if match_array.length == 1\n puts \"We have found #{match_array.size} student with a name of #{number} characters or less\"\n elsif match_array.length > 1\n puts \"We have found #{match_array.size} students with names of #{number} characters or less\"\n end\nend", "def cheat number\n if number > 0 && number < 7\n @numberShowing = number\n return true\n end\n return false\n end", "def gets_random_10\n\n count = 0\n\nwhile count < 10\n @num = rand(9)\n divider = \"=========\"\n\n\n if @num == 0\n puts divider\n puts \"#{@num}\" + \" we've got 0\"\n\n elsif @num.odd?\n @result = \"#{@num}\" + \" the number is odd\"\n puts divider\n check_if_five_exists\n elsif @num.even?\n puts divider\n @result = \"#{@num}\" + \" the number is even\"\n check_if_five_exists\n else\n puts \"I can't guess the number\"\n end\n\n count += 1\nend\nend", "def repeat(input)\n # while i < 6\n i = 0\n numbers = [ ]\n for i in (1 .. input)\n puts \"At the top i is #{i}\"\n numbers.push(i)\n\n puts \"Numbers now: \", numbers\n puts \"At the bottom i is #{i}\"\n end\n\n puts \"The number: \"\n numbers.each {|num| puts num }\nend", "def by_five?(num)\n num % 5 == 0\nend", "def run_guessing_game\n picked_number = rand(6) +1 \n \n puts \"Guess my number. It is a number between 1 and 6\"\n input = gets.chomp\n\n if(input == 'exit')\n puts \"Goodbye!\"\n elsif (input.to_i == picked_number)\n puts \"You guessed the correct number!\"\n else \n puts \"Sorry! The computer guessed #{picked_number}.\"\n end\nend", "def divby2not6(n)\n 1.upto(n) { |e| puts e if (e % 2 == 0) && !(e % 6 == 0) }\nend", "def findFiveHundred(numberOfFactors)\n count = 1\n triangleNumber = 0\n factors = 0;\n while(factors <= numberOfFactors)\n triangleNumber = triangleNumber + count\n factors = countFactors(triangleNumber)\n\n if(factors > numberOfFactors)\n return triangleNumber\n end\n count += 1\n end\n\n\nend", "def run_numbers(numbers)\n\t#Define a variable to receive the winners\n\twinners = []\n\tarray_numbers = generateWinnNumbers();\n\tnumbers.each do |number|\n\t\n\t\tarray_numbers.each do |value|\n\t\t\t#For each char of the number compare with our numbers\t\n\t\t\t if number == value\t\t\n\t\t\twinners.push(value) \t\t\t\n\t\t\tend\n\t\tend\n\tend\t\n\tprint array_numbers\n\tprint numbers\n\tprint winners\n\treturn winners\n\nend", "def get_puzzle_number\n\tputs \"What puzzle(s) would you like to solve today?\"\n\tputs \"---------------------------------------------\"\n\tputs \"Please enter a number from 1-15\"\n\tinput = gets.chomp\n\ttry_again_check(input)\nend", "def list_topics\n\tputs \"1. Social Media\"\n\tputs \"2. Tech\"\n\tputs \"3. Business\"\n\tputs \"4. Entertainment\"\n\tputs \"5. World\"\n\tputs \"6. Watercooler\"\n\tputs \" \"\n\tputs \"Which topic interests you most?\"\n\tprint \"Please enter a number 1 through 6 or press any other # to quit: \"\nend", "def featured(num)\n number = 0\n\n loop do\n if num % 7 != 0 && num.even?\n number += 7 \n elsif num % 7 != 0 && num.odd?\n number += 7\n else\n number += 7\n end\n break if number % 7 == 0 && number > num && number.odd?\n end\nend" ]
[ "0.6842517", "0.6824047", "0.67023516", "0.64872897", "0.6443282", "0.64010066", "0.6394573", "0.63698477", "0.63668793", "0.6345415", "0.63336974", "0.63268435", "0.632397", "0.63175577", "0.6305798", "0.6277707", "0.6262173", "0.6256298", "0.62343603", "0.62290215", "0.6206164", "0.6099126", "0.60969937", "0.6094212", "0.6083952", "0.6083934", "0.60693526", "0.6026617", "0.6001449", "0.5992171", "0.5971962", "0.5950386", "0.5948448", "0.59479123", "0.5944605", "0.5931685", "0.59243834", "0.59145087", "0.59004486", "0.5897616", "0.5860214", "0.5851676", "0.5851612", "0.58509153", "0.58485925", "0.5844704", "0.5844298", "0.5843845", "0.5836687", "0.5836286", "0.5829803", "0.58216506", "0.5818707", "0.5808091", "0.5806715", "0.579461", "0.57884103", "0.57870615", "0.57867265", "0.57866675", "0.5781961", "0.57814753", "0.5777167", "0.57731223", "0.5769132", "0.576906", "0.57665694", "0.57625026", "0.57618535", "0.57466793", "0.57391304", "0.5733973", "0.57248163", "0.57165164", "0.57116693", "0.5710919", "0.5699312", "0.56982404", "0.5698091", "0.5697895", "0.56972784", "0.5691758", "0.5691652", "0.56884325", "0.5685387", "0.56821525", "0.5680669", "0.56790787", "0.56734973", "0.5671078", "0.5668425", "0.5663745", "0.56588894", "0.5654095", "0.56288666", "0.56271654", "0.56216675", "0.5618146", "0.5615664", "0.5604344" ]
0.67892206
2
Writes log_hash to, by default, currently set log file or custom file passed to it
def write_file(filename: @filename) raise 'Filename is not set, you need to initialize RSpecLog before writing' if filename.nil? RSpecLog.write_hash_to_file(RSpecLog.log_hash, filename) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_file\n @hash[\"LogFile\"]\n end", "def log_file\n @_log_file ||= begin\n log_file = ::File.new(log_path, 'a+')\n log_file.sync = true # Dumps the logs to disk immediately\n\n log_file\n end\n end", "def log_to(file)\n @log_file = file\n end", "def log(log)\n # Since only one appender thread will be writing to the file at a time\n # it is not necessary to protect access to the file with a semaphore\n # Allow this logger to filter out log levels lower than it's own\n @log.write(@formatter.call(log) << \"\\n\") if level_index <= (log.level_index || 0)\n end", "def writeHashToJSON(hash, jsonfile, logkey='')\n if not hash.empty?\n Mcmlln::Tools.write_json(hash, jsonfile)\n else\n logstring = 'no data to write to json (empty hash)'\n end\nrescue => logstring\nensure\n\tMcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend", "def log_file=(log_file)\n set_default :logfile, log_file\n end", "def log_file; end", "def log(value=nil)\n @_log ||= File.join(dir, \"log/#{File.basename(file)}.log\") if exists?(dir, file)\n value.nil? ? @_log : @_log = value\n end", "def log_file\n @log_file ||= (user_configuration_from_key('solr', 'log_file') || default_log_file_location )\n end", "def log(filename = '')\n options[:log] = filename\n end", "def initialize_log(log)\n close if @log # be sure that we don't leave open files laying around.\n\n if log.respond_to?(:write)\n @log = log\n elsif File.exist?(log)\n @log = open(log, (File::WRONLY | File::APPEND))\n @log.sync = true\n else\n FileUtils.mkdir_p(File.dirname(log)) unless File.directory?(File.dirname(log))\n @log = open(log, (File::WRONLY | File::APPEND | File::CREAT))\n @log.sync = true\n @log.write(\"#{Time.now.httpdate} #{delimiter} info #{delimiter} Logfile created\\n\")\n end\n end", "def set_log_file(filename)\n\t @logfile = RequestStore.LOGS_PATH + filename\n\tend", "def set_log_file(filename)\n\t @logfile = RequestStore.LOGS_PATH + filename\n\tend", "def log(value=nil)\n @_log ||= File.join(dir, \"log/#{File.basename(file)}.log\") if exists?(dir, file)\n value ? @_log = value : @_log\n end", "def log(value=nil)\n @_log ||= File.join(dir, \"log/#{File.basename(file)}.log\") if exists?(dir, file)\n value ? @_log = value : @_log\n end", "def log_file\n end", "def file_log\n @file_log ||= @repo.file_log @path\n end", "def log\n @options[:log] || DEFAULT_LOG_FILE\n end", "def store_log_file_permanently!\n f = Tempfile.new(\"processing_log\")\n f.write(log_contents)\n f.close\n store_permanently!(f.path)\n end", "def __write_with_log(name)\n __log_report(name) do\n open(\"OCP_tmp/#{name}\", \"w\") { |io| yield io }\n end\n end", "def append_log_file(str)\n append_file(@log_file, str)\n end", "def start_log(log)\n File.open(log, 'w')\nend", "def write\n File.write(cache_file, @cache_log.to_json)\n end", "def logfh\n @logfh ||= nil\n return $stderr if show_log?\n return @logfh if @logfh && [email protected]?\n\n @logfh = File.open(output_file, 'w')\n end", "def write_file(log)\n log[:files_revised] += 1\n File.open(@name, \"w\") {|f| f.write(@content) }\n end", "def log_writer; end", "def setup_logfile\n # strip any trailing '/' in case the user supplied this as part of\n # an absolute path, so we can match it against File.expand_path()\n path = @options.log_path.chomp(\"/\")\n if path.empty?\n path = File.join(Backup::Config.root_path, \"log\")\n elsif path != File.expand_path(path)\n path = File.join(Backup::Config.root_path, path)\n end\n FileUtils.mkdir_p(path)\n log_file = @options.log_file || \"backup.log\"\n path = File.join(path, log_file)\n if File.exist?(path) && !File.writable?(path)\n raise Error, \"Log File at '#{path}' is not writable\"\n end\n\n path\n end", "def log\n if @log.nil?\n @options[:possible_log_files].each do |log_file|\n begin\n file = File.open(log_file, File::WRONLY|File::APPEND|File::CREAT)\n @log = CertificateDepot::Log.new(file)\n rescue Errno::EACCES\n end\n end\n end; @log\n end", "def log(msg)\n @script = File.basename $0 \n logfile = $config[\"settings\"][\"log_directory\"] + \"/#{@script}.log\"\n if $config[\"settings\"][\"log_file\"]\n File.open(logfile, 'a') do |file|\n now = Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n file.puts \"#{@script} #{now} -> #{msg}\"\n end\n end\n puts \"#{@script} -> #{msg}\"\nend", "def log_file(log_path = nil)\n # Get hostname\n host = session.sys.config.sysinfo[\"Computer\"]\n\n # Create Filename info to be appended to downloaded files\n filenameinfo = \"_\" + ::Time.now.strftime(\"%Y%m%d.%M%S\")\n\n # Create a directory for the logs\n logs = if log_path\n ::File.join(log_path, 'logs', 'persistence', Rex::FileUtils.clean_path(host + filenameinfo))\n else\n ::File.join(Msf::Config.log_directory, 'persistence', Rex::FileUtils.clean_path(host + filenameinfo))\n end\n\n # Create the log directory\n ::FileUtils.mkdir_p(logs)\n\n # logfile name\n logfile = logs + ::File::Separator + Rex::FileUtils.clean_path(host + filenameinfo) + \".rc\"\n logfile\n end", "def log\n STDOUT\n# @log_file ||= File.new(LOG_PATH, \"w\") # System.Text.Encoding.Unicode)\nend", "def log_file\n Vedeu::Configuration.log\n end", "def log_file\n @log_file ||= @options[:log_file] ? File.expand_path(@options[:log_file]) : File.join(Rails.root, 'log', \"#{rails_environment}.log\")\n end", "def log_file\n File.join(FileUtils.pwd, 'log', \"sunspot-solr.log\")\n end", "def log_file\n return @log_file\n end", "def log=(log); end", "def logger_filename=(filename)\n $logger_filename = filename\n end", "def path_log\n @path_log ||= File.join(folder, 'log.txt')\n end", "def save_log\n logfile = File.open(\"DietLog.txt\", \"w\")\n @logHash.each do |date, items|\n items.each do |item|\n logfile.write(\"#{date},#{item.name}\\n\")\n end\n end\n logfile.close()\n @dirty = false\n end", "def default_log_file_name\n @options['log_file_name'] || \"#{@name}.log\"\n end", "def hardlink_log(log)\n FileUtils.mkdir_p(\"log\")\n FileUtils.touch(log)\n\n kochiku_base_dir = File.join(__dir__, \"../../..\")\n\n FileUtils.mkdir_p(\"#{kochiku_base_dir}/logstreamer/logs/#{@build_attempt_id}/\")\n FileUtils.ln(log, \"#{kochiku_base_dir}/logstreamer/logs/#{@build_attempt_id}/stdout.log\")\n end", "def log_file\n get_value :logfile\n end", "def log_file(id)\n \"#{log_file_directory}/#{log_file_name(id)}\"\n end", "def apply_to_log\n if can_apply_to_log?\n File.open actual_log_location, 'a' do |f|\n f.puts build_with_template\n end\n end\n end", "def log_path\n @_log ||= ::File.join('log', \"#{ENV.fetch('RACK_ENV')}.log\")\n\n ENV.fetch('LOG_FILE', @_log)\n end", "def log_full_pathname( data_import_session )\n # Memo-ize the filename the first time this is called:\n @log_filename ||= File.join( Rails.root, 'log', \"#{ get_log_basename(data_import_session) }#{ get_log_extension(data_import_session) }\" )\n end", "def write_log_to_file(uuid, text)\n filename = File.join(Dir.pwd, $output_dir, \"#{uuid}.log\")\n File.open(filename, 'w') { |f| f.write(text) }\nend", "def write_to_log(text)\n File.open(@log_file_path, 'a') do |file|\n # threadsafe write\n file.flock(File::LOCK_EX)\n file.puts text\n file.flush\n file.flock(File::LOCK_UN)\n end\n end", "def overwriteFile(path, filecontents, logkey='')\n\tMcmlln::Tools.overwriteFile(path, filecontents)\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend", "def log_file\n File.join(Dir.pwd, 'log', \"sunspot-solr-#{ENV['RACK_ENV']}.log\")\n end", "def jsonlogger(status,certname,jsonuuid)\n tempHash = {\n \"status\" => status,\n \"certname\" => certname,\n \"uuid\" => jsonuuid\n }\n File.open(logfile,\"a\") do |f|\n f.puts(tempHash.to_json)\n end\nend", "def log=(logger); end", "def log_file\n if Merb::Config[:log_file]\n Merb::Config[:log_file]\n elsif Merb.testing?\n log_path / \"merb_test.log\"\n elsif !(Merb::Config[:daemonize] || Merb::Config[:cluster])\n STDOUT\n else\n log_path / \"merb.#{Merb::Config[:port]}.log\"\n end\n end", "def store_logger_name\n @config.connection.sadd(@config.log_set_key, @config.stream_name)\n rescue StandardError => exception\n @error_logger.warn \"unable to store name of log: #{exception}\"\n end", "def log_new(msg)\n @script = File.basename($0).split(/\\./)[0] \n logfile = $script_dir + \"/var/log/#{@script}_new.log\"\n logfile = $config[\"settings\"][\"log_directory\"] + \"/#{@script}_new.log\" if $config[\"settings\"].has_key? 'log_directory'\n if $config[\"settings\"][\"log_file\"]\n File.open(logfile, 'a') do |f|\n now = Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n f.puts \"#{@script} #{now} -> #{msg}\"\n end\n end\n puts \"#{@script} -> #{msg}\"\nend", "def autoflush_log=(_arg0); end", "def autoflush_log=(_arg0); end", "def write_single(log)\n nil\n end", "def log_file\n File.join(::Rails.root, 'log', \"sunspot-solr-#{::Rails.env}.log\")\n end", "def overwriteFile(path,filecontents, logkey='')\n\tMcmlln::Tools.overwriteFile(path, filecontents)\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend", "def overwriteFile(path, filecontents, logkey='')\n\tMcmlln::Tools.overwriteFile(path, filecontents)\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend", "def log(file)\n RestClient.log = file\n end", "def set_log_file\n @log_file = LogFile.find(params[:id])\n end", "def default_log_file_location\n File.join(::Rails.root, 'log', \"solr_\" + ::Rails.env + \".log\")\n end", "def log_file\n factorio.server.log_file\n end", "def setupLog(fileName)\n\t# Setting up logging feature\n\tlogFile = File.open(fileName, 'w')\n\tlog = Logger.new(logFile)\n\tlog.formatter = proc do |severity, datetime, progname, msg|\n\t Time.now.asctime + \":: #{msg}\\n\"\n\tend\n\treturn log\nend", "def logger=(writer); end", "def logger=(writer); end", "def logger=(writer); end", "def logger=(writer); end", "def logger=(writer); end", "def write_message(log_file, string)\n File.open(@@logs[log_file], 'a') {|out| out.puts string }\n end", "def log_write(level=\"I\",string)\n filepath=LOG_PATH + who?\n if File.exist?(filepath)\n log_file=File.open(filepath,\"a+\")\n else\n log_file=File.new(filepath,\"a+\")\n end\n \n log_file.syswrite(\"[#{get_time}] #{level} #{string}\\n\")\n log_file.close\n end", "def log\n \"#{self.dir}.log\"\n end", "def log(message)\n File.open(@log_file, 'a') do |file|\n file.puts message\n end\n end", "def write_log( user = User.anonymous )\n options = { :user => user, :ip_address => user.ip_address }\n @changed_attributes.each do |a, v|\n options[:attribute] = a\n options[:old_value] = v.first\n options[:new_value] = v.last\n self.related_object.log_entries.create options unless options[:old_value].nil?\n end unless @changed_attributes.nil?\n end", "def put_hash(name, hash)\n file_name = File.join(@db_dir, name + '.json')\n begin\n RobustFile.write(file_name, hash.to_json)\n rescue IOError => e\n PEROBS.log.fatal \"Cannot write hash file '#{file_name}': #{e.message}\"\n end\n end", "def log_f(txt, file = nil)\n if file\n unless File.exist?(file) && !@overwrite_logs\n mode = is_old_file?(file) && @overwrite_logs ? \"w+\" : \"a+\"\n txt = (\"#{Time.now}\\n\" + txt) if mode == \"w+\" \n open(file, mode) do |f|\n f.puts txt\n end\n end\n else\n log_f(txt)\n end\n end", "def log_and_stream(output)\n write_file output, @filename if @filename\n @block.call(output)\n end", "def output_log(str)\n if @outputdir\n outputfilename = @outputdir+\"/testoutput.log\"\n FileUtils.mkdir_p(@outputdir)\n else\n outputfilename = @dirs ? @dirs.testoutput : '/dev/null'\n end\n begin\n File.open(outputfilename, \"a\") do |file|\n file.print(str)\n end\n rescue Errno::ENOENT\n end\n @result.append_log(str) if @result\n end", "def self_log_file\n return File.join(File.dirname(__FILE__), 'sshsurveyor.log')\n end", "def write_to_log(*args)\n if args.size == 1\n s = args[0]\n # log to STDOUT\n elsif args.size == 2\n if args[0].is_a?(File)\n file, s = args\n # log to File object\n else\n fn, s = args\n # log to file path\n end\n else\n raise \"invalid arguments: #{args}\"\n end\nend", "def log_filename\n log_file.nil? || log_file.empty? || log_file == '-' ? nil : log_file\n end", "def reopen\n return unless @filename\n\n @log = open(@filename, (::File::WRONLY | ::File::APPEND | ::File::CREAT))\n # Force all log entries to write immediately without buffering\n # Allows multiple processes to write to the same log file simultaneously\n @log.sync = true\n @log.set_encoding(Encoding::BINARY) if @log.respond_to?(:set_encoding)\n @log\n end", "def default_log_path\n if @config.log_root\n File.join(@config.log_root, default_log_file_name)\n else\n nil\n end\n end", "def write(json_hash:)\n JSON.pretty_generate(json_hash).tap do |json_string|\n @pathname.write(json_string)\n end\n end", "def logging( log_str )\n begin\n file = open(File.expand_path('../_log_watcher2',__FILE__),'a')\n file.print Time.now.to_s, \"\\t\", log_str, \"\\n\"\n STDOUT.sync = true\n print Time.now.to_s, \"\\t\", log_str, \"\\n\"\n STDOUT.sync = false\n ensure\n file.close\n end\nend", "def ensure_program_log_file\n return if File.file? LOG_FILE\n CSV.open(LOG_FILE, \"wb\") { |csv|\n csv << LOG_HEADER\n }\nend", "def setup_logger(log_name)\n date = Time.new.localtime.strftime('%F %H.%M.%S%L')\n logger = Logger.new(\"#{$VALUE}/test_logs/#{log_name}_#{date}.log\")\n logger.formatter = proc do |severity, datetime, _progname, msg|\n date_format = datetime.strftime('%Y-%m-%d %H:%M:%S%L')\n if (severity == 'INFO') || (severity == 'WARN')\n \"[#{date_format}] #{severity} (#{ENV['PRODUCT_NAME']}): #{msg}\\n\"\n else\n \"[#{date_format}] #{severity} (#{ENV['PRODUCT_NAME']}): #{msg}\\n\"\n end\n end\n logger\nend", "def file_log\n @repo.file_log repo_path\n end", "def initialize\n @username = nil\n @id = 0\n @file = File.open('execution.log', 'w+')\n @file.truncate(0)\n @file.write(\"File created: #{Time.now}\\n\")\n\n end", "def logging( log_str )\n begin\n file = open(File.expand_path('../_log_posts',__FILE__),'a')\n file.print Time.now.to_s, \"\\t\", log_str, \"\\n\"\n STDOUT.sync = true\n print Time.now.to_s, \"\\t\", log_str, \"\\n\"\n STDOUT.sync = false\n ensure\n file.close\n end\nend", "def updateLogFile(operation)\n file = File.open(\"log.txt\", \"a\")\n \n if operation == \"Login\"\n file.puts \"#{$credentials[0]} logged in at #{Time.now}\"\n elsif operation == \"Logout\"\n file.puts \"#{$credentials[0]} logged out at #{Time.now}\"\n elsif operation == \"Updated\"\n file.puts \"#{$credentials[0]} proposed an update to the wiki content at #{Time.now}\"\n elsif operation == \"Deleted\"\n file.puts \"#{$credentials[0]} deleted the wiki content at #{Time.now}\"\n elsif operation == \"Backup\"\n file.puts \"#{$credentials[0]} created a backup of wiki content at #{Time.now}\"\n elsif operation == \"Updateapproved\"\n file.puts \"#{$credentials[0]} approved an update to the wiki at #{Time.now}\"\n elsif operation == \"Updatedenied\"\n file.puts \"#{$credentials[0]} denied a proposed update to the wiki at #{Time.now}\"\n elsif operation == \"Adminupdate\"\n file.puts \"The administrator updated the wiki at #{Time.now}\"\n elsif operation == \"Viewlog\"\n file.puts \"#{$credentials[0]} viewed this file at #{Time.now}\"\n else\n #Do something\n end\n file.close\n end", "def logger=(logr); @logger = logr end", "def init_logs\n begin\n if [email protected]_directory.nil?\n node_log_file = @cloud.log_directory + \"/#{@name.to_s}.log\"\n if !File.exists?(node_log_file)\n File.new(node_log_file, \"a+\")\n @log_file = node_log_file\n @logger.info \"Created #{node_log_file}\"\n end\n outputter = Log4r::FileOutputter.new(\"#{@name.to_s}-file\", :formatter => FileFormatter.new, :filename => node_log_file, :truncate => false)\n @logger.add(outputter)\n end\n rescue RuntimeError => rerr\n if !rerr.message.eql?(\"Maestro not configured correctly. Either RAILS_ROOT, Rails.root, or ENV['MAESTRO_DIR'] must be defined\")\n @logger.error \"Unexpected Error\"\n @logger.error rerr\n end\n rescue SystemCallError => syserr\n @logger.error \"Error creating Node log file\"\n @logger.error syserr\n rescue StandardError => serr\n @logger.error \"Unexpected Error\"\n @logger.error serr\n end\n end", "def output_file\n staged_root.join(\"output.log\")\n end", "def set_sh_logger(logger)\n @sh_logger = logger\n end", "def log= logger\n @log = logger\n end", "def log= logger\n @log = logger\n end", "def create_file_appender\n pattern = @config_manager['logging.file.pattern']\n date_pattern = @config_manager['logging.file.date_pattern']\n layout = Logging::Layouts::Pattern.new(pattern: pattern, date_pattern: date_pattern)\n #\n run_result_directory = @config_manager['run.result.directory']\n log_file = \"#{run_result_directory}/#{log_file_name}.log\"\n @appender = Logging::Appenders::File.new('file', filename: log_file, layout: layout)\n #\n Logging::Logger.root.add_appenders(@appender)\n end" ]
[ "0.66926897", "0.6623391", "0.66177714", "0.65326667", "0.64954245", "0.6487172", "0.6454372", "0.63792247", "0.637706", "0.6352852", "0.6351051", "0.6331727", "0.6331727", "0.63139015", "0.63139015", "0.631353", "0.60908157", "0.6055892", "0.6046484", "0.60194176", "0.6014703", "0.6008501", "0.5949669", "0.5922873", "0.5911089", "0.5887287", "0.58752626", "0.5863695", "0.58474535", "0.5845971", "0.5829723", "0.5828162", "0.5821626", "0.58078605", "0.5780336", "0.5771579", "0.5767379", "0.5748362", "0.57455677", "0.5741866", "0.5736371", "0.57343775", "0.573051", "0.5690115", "0.56689936", "0.56603116", "0.56559175", "0.5644922", "0.56411487", "0.5636236", "0.56356096", "0.56292295", "0.56256545", "0.56189424", "0.5618571", "0.5600314", "0.5600314", "0.5599465", "0.5594054", "0.55924034", "0.5591743", "0.55865175", "0.5579964", "0.55629724", "0.5548468", "0.5546946", "0.55415", "0.55415", "0.55415", "0.55415", "0.55415", "0.5530381", "0.55295527", "0.55293614", "0.55249906", "0.55240995", "0.55205995", "0.55115086", "0.55100244", "0.54918134", "0.5484463", "0.54834676", "0.54778886", "0.545956", "0.54580283", "0.54532194", "0.5452891", "0.544347", "0.544237", "0.54411954", "0.5441063", "0.5428788", "0.5418141", "0.5410992", "0.54100513", "0.54086", "0.54072976", "0.54059196", "0.54059196", "0.53949785" ]
0.7050351
0
Its not generating the instances of associated classes from the rows
def test_find_includes # Old style products = Product.includes(:product_tariffs).all assert_equal(3, products.length) assert_equal(3, products.inject(0) {|sum, product| sum + product.product_tariffs.length}) # New style products = Product.includes(:product_tariffs) assert_equal(3, products.length) assert_equal(3, products.inject(0) {|sum, product| sum + product.product_tariffs.length}) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transpose_hbase_row_to_record_attributes_and_raw_data(row) # :nodoc:\n if field = attributes_schema[inheritance_attribute]\n if cell_with_record_sti_class = row.columns[field.unique_name] and cell_with_record_sti_class.present?\n if klass = field.decode(cell_with_record_sti_class.value) and klass.present?\n ensure_sti_class_is_loaded(klass)\n end\n end\n end\n\n super\n end", "def eager_graph_build_associations(rows)\n objects = super\n\n if eager_data = @opts[:eager_graph_eager]\n eager_data.each do |deps, assocs|\n current = objects\n\n last_class, *deps = deps\n deps.each do |dep, is_multiple|\n current_assocs = current.map(&:associations)\n\n if is_multiple\n current = current_assocs.flat_map{|a| a[dep]}\n else\n current = current_assocs.map{|a| a[dep]}\n current.compact!\n end\n\n current.uniq!(&:object_id)\n end\n\n last_class.dataset.send(:eager_load, current, assocs)\n end\n end\n\n objects\n end", "def association_symbol_for_rows\n @importing_reflection ||= self.class.import_into\n end", "def populate_instances #:nodoc:\n if reference = @field.reference\n values_hash = rows.inject({}) do |hash, row|\n hash[row.value] = row\n hash\n end\n instances = Adapters::DataAccessor.create(Sunspot::Util.full_const_get(reference)).load_all(\n values_hash.keys\n )\n instances.each do |instance|\n values_hash[Adapters::InstanceAdapter.adapt(instance).id].instance = instance\n end\n true\n end\n end", "def load\n rows = fire\n columns = rows.shift\n result = []\n rows.map do |el|\n obj = table_name.camelize.singularize.constantize.new\n columns.each_with_index do |column,index|\n obj.instance_variable_set(\"@#{column}\".to_sym, el[index])\n end\n result << obj\n end\n reset\n result\n end", "def classes\n #Regroupement.where(:etablissement => self, :type_regroupement_id => \"CLS\").to_hash\n #DB[:regroupement].where(:etablissement => self, :type_regroupement_id => \"CLS\").to_hash\n regroupement_dataset.where(:type_regroupement_id => \"CLS\").all\n end", "def process_row\n # overwrite this class\n end", "def build_model(row)\n row[:id] = row[:id].to_i # Convert column to Integer\n new_instance = Employee.new(row)\n return new_instance\n end", "def build_model(row)\n row[:id] = row[:id].to_i # Convert column to Integer\n new_instance = Customer.new(row)\n return new_instance\n end", "def all_as_objects\n table_name = self.to_s.pluralize\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name};\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n \n results_as_objects << self.new(result_hash)\n \n end\n \n return results_as_objects\n \n end", "def model_instances(subclass_sym)\n\t\traise \"model_instances called for nil symbol\" if subclass_sym.nil?\n\n\t\ttable_class = table_class(subclass_sym)\n\t\tsubclass = self.namespaced_class(subclass_sym)\n\t\tcmd = \"self.#{table_class.to_s.pluralize.downcase}.where{self.type == #{subclass}.to_s}\"\n\t\tself.instance_eval(cmd)\n\tend", "def reify\n model.new(object.select{|k,v| k != inheritance_column})\n end", "def _write_class_code\n cname = @table.to_s.split('_').map(&:capitalize).join\n klass = Taupe::Model.const_set cname, Class.new(Taupe::Model::Table)\n klass._cname = cname\n klass._table = @table\n klass._columns = @_column_stack\n end", "def classify\n temp_table_name = self.new_table_name\n Class.new(ActiveRecord::Base) do\n set_table_name temp_table_name\n acts_as_spatial :attach_geocoder => true\n end\n end", "def to_class\n\t\[email protected] { |kname, klass| klass.to_class( @model ) } +\n\t\t\[email protected]_through.map { |t| t.to_class }\n\tend", "def build_report\n klass = model_class.constantize\n @cols = klass.columns.map { |c| c.name.to_sym }\n @assocs = klass.reflect_on_all_associations\n\n through = @assocs.each_with_object({}) { |x, hsh| hsh[x.options[:through]] = 1 }\n # through={} ; @assocs.each { |x| through[x.options[:through]] = 1 }\n @assocs = @assocs.select { |x| !through[x.name] }\n @tire_saved = klass.tire.mapping.keys\n end", "def map_from_row!(row_data)\n model_data = {}\n\n BREAKOUT_COLUMNS.each do |property_name|\n model_data[property_name] = row_data.delete(property_name) if row_data.key?(property_name)\n end\n\n# Merb.logger.info(\"Container Model Data is: #{model_data}\")\n\n model_data\n end", "def prerecord(klass, name); end", "def reify_from_row(row)\n #the tap method allows preconfigured methods and values to\n #be associated with the instance during instantiation while also automatically returning\n #the object after its creation is concluded.\n self.new.tap do |card|\n self.attributes.keys.each.with_index do |key, index|\n #sending the new instance the key name as a setter with the value located at the 'row' index\n card.send(\"#{key}=\", row[index])\n #string interpolation is used as the method doesn't know the key name yet\n #but an = sign is implemented into the string in order to asssociate it as a setter\n end\n end\n end", "def index t,param\n subclass,id = param\n models = t.find_models subclass\n if models\n models.values[0].each do |model_name, model_attributes|\n if model_name.to_s ==\"sql_query\"\n #some magic is needed here ..parse the sql query?\n else\n m = Model.new model_name, models.keys[0].to_s\n row_values=m.get_row_by_id(id).first\n c1=Hash.new\n if row_values\n m.model.columns_hash.each_with_index do |column_name,i|\n c1[column_name[0]]=eval(\"row_values.#{column_name}\")\n end\n t.extract_id_line model_attributes, c1,row_values,m.get_datatypes\n t.make_triples(c1, models.keys[0].to_s , \"\", m.get_datatypes)\n end\n end\n end\n end\n #render :text => t.make_triples(c1, controller , \"\", t.dbd_types)\n \n end", "def from_hash( h)\n\t\th.each { |name,attributes|\n\t\t\tklass = Klass.new\n\t\t\tklass.from_hash( { name => attributes } )\n\t\t\tself.add_class( klass)\n\t\t}\n\n\t\t# this is an experiment in handling \"through\" attributes\n\t\t# i.e. enriching the model with the join classes\n\tend", "def map(type, row_hash, session, prefix = type.name.underscore)\n entity_name = type.name.underscore.to_sym\n resolve_name = \"jet_set__#{type.name.underscore}\".to_sym\n entity_mapping = @mapping.get(entity_name)\n row = Row.new(row_hash, entity_mapping.fields, prefix)\n\n reference_hash = {}\n row.reference_names.each do |reference_name|\n if entity_mapping.references.key? reference_name.to_sym\n reference_id_name = reference_name + '__id'\n unless row_hash[reference_id_name.to_sym].nil?\n type = entity_mapping.references[reference_name.to_sym].type\n reference_hash[reference_name.to_sym] = map(type, row_hash, session, reference_name)\n end\n end\n end\n\n object = @container.resolve(resolve_name, row.attributes_hash.merge(reference_hash))\n entity = @entity_builder.create(object)\n entity.load_attributes!(row.attributes)\n\n reference_hash.each do |key, value|\n entity.set_reference! key.to_s, value\n end\n\n session.attach(entity)\n entity\n end", "def associations; self.class.class_eval(\"@@associations\") end", "def css_classes_for_row(); \"rsrcRow #{self.kind}row #{@tag}row #{self.kind}Row #{@tag}Row\" end", "def grid_row_model_class\n row_model_class\n end", "def grid_row_model_class\n row_model_class\n end", "def process_row(table, row)\n Log.write_log(table.name, \"Processing row: #{row.pretty_inspect}\")\n row.each do |v|\n row.to_h.each do |k,v|\n row[k] = Utf8_Converter::convert(v) if v.kind_of?(String)\n end\n end\n pk_string = ''\n table.primary_key.each do |pk|\n pk_string << row[pk].to_s\n end\n if pk_string.empty?\n row.each {|c| pk_string << c.to_s}\n end\n if (table.__id_store__)\n default_table_row = InsertRow.new(table.__default_table__, IdStore.new(table.name, pk_string))\n else\n default_table_row = InsertRow.new(table.__default_table__)\n end\n default_table_row.prototype_table_map = table\n default_table_row.prototype_result_set = row\n table_rows = []\n\n table.each_column do |attr_name, maps_to|\n next if maps_to == IGNORE\n\n if maps_to.kind_of?(ReaktorColumn)\n #\n # ReaktorColumn\n #\n default_table_row.add(*process_reaktor_column(maps_to, attr_name, row))\n elsif maps_to.kind_of?(ReaktorRow)\n #\n # ReaktorRow\n #\n table_rows << process_reaktor_row(maps_to, attr_name, row)\n elsif maps_to.kind_of?(Class)\n #\n # Plugin\n #\n plugin = process_plugin(maps_to, attr_name, row)\n list = plugin.each\n if list.kind_of?(Array)\n list.each do |reaktor_object|\n if reaktor_object.kind_of?(ReaktorColumn)\n default_table_row.add(*process_reaktor_column(reaktor_object, attr_name, row))\n elsif reaktor_object.kind_of?(ReaktorRow)\n table_rows << process_reaktor_row(reaktor_object, attr_name, row)\n else\n STDERR.puts \"reaktor_object was a #{reaktor_object.class} class\"\n exit\n end\n end\n end\n else\n STDERR.puts \"maps_to was of class: #{maps_to.class} and not processed\"\n exit\n end\n end\n \n table.__set__.each do |set|\n t = set.value\n if set.value.kind_of?(Query)\n tsth = $dbh_pg.prepare(set.value.sql)\n begin\n tsth.execute(row[:id])\n rescue\n $stderr.puts \"### Error in #{__FILE__} on line #{__LINE__}. See errorlog\"\n Log.write_log('error', \"Could not process query. Message: #{$!} query: #{get_query_string(tsth)}.\")\n raise\n exit\n end\n r = tsth.fetch\n t = r.nil? ? r : r[0]\n else\n t = set.parse_value(nil, row)\n end\n t = Filter.apply_filters(t, row, set.filters)\n default_table_row.add(set.name, t)\n end\n table_rows.insert(0, default_table_row) unless table.__default_table__.nil?\n return table_rows\nend", "def build_result(columns:, rows:, column_types: {})\n ActiveRecord::Result.new(columns, rows, column_types)\n end", "def translated_columns(klass); end", "def initialize(rows)\n @rows = rows\n end", "def rows\n RowCollection.new(@data)\n end", "def row; end", "def each(&block)\n target.call().find_each do |model|\n row = ETL::Row.new()\n row[self.name] = model\n if map.nil?\n model.attributes.symbolize_keys.each{|k,v| row[k]=v}\n else\n map.each do |obj|\n if obj.kind_of?(Symbol)\n row[obj] = model.send(obj)\n elsif obj.kind_of?(Hash)\n obj.each do |key, val|\n if val.kind_of?(Proc)\n row[key] = val.call(model)\n else\n row[key] = model.resolve_value(val)\n end\n end\n end\n end\n end\n block.call(row)\n end\n end", "def build_class(form)\n @labels = []\n\n dataset = WPDB.db[:\"#{WPDB.prefix}rg_lead___l\"]\n .where(:\"l__form_id\" => form.id)\n\n dataset = join_fields(dataset, form.fields)\n dataset = dataset.select_all(:l)\n dataset = select_fields(dataset, form.fields)\n dataset = dataset.from_self\n\n Class.new(Sequel::Model) do\n set_dataset dataset\n end\n end", "def gymclasses()\n sql = \"SELECT gymclasses.* FROM gymclasses INNER JOIN bookings\n ON gymclasses.id = bookings.gymclass_id WHERE client_id = $1\"\n values = [@id]\n gymclasses = SqlRunner.run(sql,values)\n result = gymclasses.map{|gymclass| GymClass.new(gymclass)}\n return result\n end", "def exercise_classes\n sql = \"SELECT exercise_classes.* FROM exercise_classes INNER JOIN booking_infos ON exercise_classes.id = booking_infos.exercise_class_id WHERE member_id = $1;\"\n values = [@id]\n results = SqlRunner.run(sql, values)\n return results.map {|exercise_class| ExerciseClass.new(exercise_class)}\n end", "def build_element(row)\n # Unlike the meal, there are no customer specific\n # convertions to be done on Row\n Customer.new(row) # returns a Customer instance\n end", "def build_element(row)\n # Unlike the meal, there are no customer specific\n # convertions to be done on Row\n Customer.new(row) # returns a Customer instance\n end", "def columns; self.class.columns.dup; end", "def init_object_from_row(row)\n if row\n data = Hash[columns.zip(row)]\n new(data)\n end\n end", "def populate_hits #:nodoc:\n id_hit_hash = Hash.new { |h, k| h[k] = {} }\n hits.each do |hit|\n id_hit_hash[hit.class_name][hit.primary_key] = hit\n end\n id_hit_hash.each_pair do |class_name, hits|\n ids = hits.map { |id, hit| hit.primary_key }\n data_accessor = data_accessor_for(Util.full_const_get(class_name))\n hits_for_class = id_hit_hash[class_name]\n data_accessor.load_all(ids).each do |result|\n hit = hits_for_class.delete(Adapters::InstanceAdapter.adapt(result).id.to_s)\n hit.result = result\n end\n hits_for_class.values.each { |hit| hit.result = nil }\n end\n end", "def css_classes_for_row(); \"rsrcRow #{self.kind}row #{@tag}row\" end", "def generate_active_record(mdm_model, config)\n #do the code to create new classes based on model metadata\n #and load them up in the Ruby VM\n #below NOTE! Need table created first for AR\n #AR provides a #column_names method that returns an array of column names\n useconnection = nil\n mdm_model.mdm_objects.each do |mdm_object|\n klass = Class.new ActiveRecord::Base do\n #establish_connection(config)\n #AR to set the physical tablename\n before_save :diff_row\n self.table_name = mdm_object.name\n \n #below does composite keys!\n \n if mdm_object.mdm_primary_keys.size > 0\n pkeys = mdm_object.mdm_primary_keys.collect{|x| x.mdm_column.name.to_sym }\n self.primary_keys = pkeys\n @@pklist = pkeys\n puts \"-\" * 80\n puts mdm_object.name, pkeys.size\n end\n #note this is FK implementation\n # has_many :statuses, :class_name => 'MembershipStatus', :foreign_key => [:user_id, :group_id]\n\n def name\n \n end\n \n def diff_row\n #here we send changes out over to the queue\n #we need PK followed by row\n puts self.changes\n pkvals = {}\n changevals = {}\n self.class.primary_keys.each do |k|\n pkvals[k] = self.read_attribute(k)\n end\n changevals['colvals'] = self.changes\n changevals['pkeys'] = pkvals\n redis = Redis.new\n redis.publish(\"mdm:freemdm\", changevals.to_json)\n end\n end\n \n \n #NOTE will need some adjustments to fit legacy tables to AR\n Object.const_set mdm_object.name.capitalize, klass\n puts config.symbolize_keys\n klass.establish_connection(config.symbolize_keys) \n useconnection = klass.connection if !useconnection\n # eval(\"class #{klass.name}; attr_accessible *columns;end\")\n #\n generate_column_meta(klass)\n\n klass.connection.jdbc_connection.close\n end\n \n end", "def _associated_dataset\n associated_class.dataset.clone\n end", "def all\n table_name = self.to_s.pluralize.underscore\n results = DATABASE.execute(\"SELECT * FROM #{table_name}\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end", "def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n # TODO put these lines back in and create another method to turn results_as_objects array of \n # objects in to array of hashes!!!!!!!\n results_as_objects = []\n\n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end", "def column_level_klass_masked_mappings\n ensure_mappings_define_klass\n\n # Loop through each klass\n masked_mappings = {}\n @columns.map { |mapping| mapping['klass'] }.flatten.compact.uniq.each do |klass|\n # Duplicate the column mappings and do not capture fields that relate to other klasses\n masked_mappings[klass] = mask_mappings_by_klass(klass)\n end\n masked_mappings\n end", "def associated_rows_for(record)\n @includes.map do |method, attributes|\n associated_rows(Array.wrap(record.send(method)), attributes)\n end\n end", "def normalize(row)\n purchaser = Purchaser.find_by_name(row.fields[0])\n purchaser = Purchaser.create!({ name: row.fields[0] }) unless purchaser\n\n item = Item.find_by_description(row.fields[1])\n item = Item.create!({ description: row.fields[1], price: row.fields[2] }) unless item\n\n purchase = Purchase.new({ purchaser_id: purchaser.id, item_id: item.id, quantity: row.fields[3] })\n purchase.save!\n\n merchant = Merchant.find_by_name(row.fields[5])\n merchant = Merchant.create!({ name: row.fields[5], address: row.fields[4] }) unless merchant\n\n sale = Sale.new({ item_id: item.id, merchant_id: merchant.id})\n sale.save!\n end", "def csv=(klass); end", "def has_many_polymorphic_xdb_records(name, options = {})\n association_name = options[:as] || name.to_s.underscore\n id_field, type_field = \"#{association_name}_id\", \"#{association_name}_type\"\n object_name = options[:class_name] || name.to_s.singularize.camelize\n object_class = object_name.classify.constantize\n\n self.instance_eval do\n define_method(name) do |reload = false|\n reload and self.instance_variable_set(\"@#{name}\", nil)\n if self.instance_variable_get(\"@#{name}\").blank?\n new_value = object_class.where(id_field => self.id, type_field => self.class.name)\n self.instance_variable_set(\"@#{name}\", new_value)\n end\n self.instance_variable_get(\"@#{name}\")\n end\n end\n end", "def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = QUIZ.execute(\"SELECT * FROM #{table_name}\")\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end", "def build_daos_for_row(row)\n dao_class.new parent: dao_node, row: row\n end", "def columns; self.class.columns; end", "def create_row(xml)\n row = self.rowclass.new\n self.columns.each { |colname|\n row.send(colname +\"=\", xml[colname]) # row content ignored so far (needs to be added!!!)\n }\n if xml.children && xml.containers.length > 0\n xml.containers.each { |child|\n el = EAAL::Result::ResultElement.parse_element(self.rowclass.name, child)\n row.add_element(el.name, el)\n }\n end\n row\n end", "def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n \n return results_as_objects\n end", "def instantiate_instance_of(klass, attributes, column_types = {}, &block)\n attributes = klass.attributes_builder.build_from_database(attributes, column_types)\n klass.allocate.init_with_attributes(attributes, &block)\n end", "def instantiate_instances(result, readonly = false, order = false)\n documents = result['rows'].map{|doc| doc['value']}.map{|attrs| instantiate(attrs) }\n documents.each { |record| record.readonly! } if readonly\n documents.sort! {|a,b| a.send(order) <=> b.send(order)} if order\n documents\n end", "def initialize\n @columns = { }\n @primary_keys = []\n @to_avoid = []\n @default_values = { }\n @associations = \n {\n :belongs_to => { },\n :has_one => { },\n :has_n => { }\n }\n end", "def objects(with_table=false, &block)\n hashes(with_table) do |row|\n row = Row.convert(row, self.fetch_fields, with_table)\n (block) ? yield(row) : row\n end\n end", "def run_single(us)\n #debugger\n initial_data = []\n column_names = us.get_column_names\n num_rows = 1\n \n c = 0\n 0.upto(num_rows - 1) do\n o = OpenStruct.new\n class << o\n attr_accessor :id\n end\n\n #turn the outgoing object into a VO if neccessary\n map = VoUtil.get_vo_definition_from_active_record(us.class.to_s)\n if map != nil\n o._explicitType = map[:outgoing]\n end\n \n #first write the primary \"attributes\" on this AR object\n column_names.each_with_index do |v,k|\n k = column_names[k]\n val = us.send(:\"#{k}\")\n eval(\"o.#{k}=val\")\n end\n \n associations = us.get_associates\n if(!associations.empty?)\n #debugger\n #now write the associated models with this AR\n associations.each do |associate|\n na = associate[1, associate.length]\n ar = us.send(:\"#{na}\")\n\t\n ok = false;\n if (ar.instance_of? Array)\n if (!ar.empty? && !ar.nil?)\n ok=true;\n end\n else\n isArray = true\n end\n\n if (isArray && !ar.nil?) || ok \n\n\t if(use_single?(ar))\n initial_data_2 = run_single(ar) #recurse into single AR method for same data structure\n else\n initial_data_2 = run_multiple(ar) #recurse into multiple AR method for same data structure\n end\n eval(\"o.#{na}=initial_data_2\")\n end\n end\n end\n #\tdebugger\n # if us.single? # apparenty this is not needed since it seems to always return nil :)\n initial_data = o \n # else\n # initial_data << o\n # end\n c += 1\n end\n initial_data\n end", "def naked_tuple_from_row row, type\n\t\tnaked_tuple get_row_cells(row), type\n\tend", "def has_many_composite_xdb_records(name, options = {})\n association_name = options[:as] || name.to_s.underscore\n composite_field = \"#{association_name}_key\".to_sym\n object_name = options[:class_name] || name.to_s.singularize.camelize\n object_class = object_name.classify.constantize\n\n self.instance_eval do\n # Set default reload arg to true since Dynamoid::Criteria::Chain is stateful on the query\n define_method(name) do |reload = true|\n reload and self.instance_variable_set(\"@#{name}\", nil)\n if self.instance_variable_get(\"@#{name}\").blank?\n new_value = object_class.where(composite_field => \"#{self.class.name}#{ActivityNotification.config.composite_key_delimiter}#{self.id}\")\n self.instance_variable_set(\"@#{name}\", new_value)\n end\n self.instance_variable_get(\"@#{name}\")\n end\n end\n end", "def instances_from_matches\n return single_class_results if one_class\n \n groups = results[:matches].group_by { |match|\n match[:attributes][\"class_crc\"]\n }\n groups.each do |crc, group|\n group.replace(\n instances_from_class(class_from_crc(crc), group)\n )\n end\n \n results[:matches].collect do |match|\n groups.detect { |crc, group|\n crc == match[:attributes][\"class_crc\"]\n }[1].compact.detect { |obj|\n obj.primary_key_for_sphinx == match[:attributes][\"sphinx_internal_id\"]\n }\n end\n end", "def build_inheritances(arel)\n return unless self.cast_records_value.present?\n\n mergeable = inheritance_mergeable_attributes\n\n columns = build_inheritances_joins(arel, self.cast_records_value)\n columns = columns.map do |column, arel_tables|\n next arel_tables.first[column] if arel_tables.size == 1\n\n if mergeable.include?(column)\n list = arel_tables.each_with_object(column).map(&:[])\n ::Arel::Nodes::NamedFunction.new('COALESCE', list).as(column)\n else\n arel_tables.map { |table| table[column].as(\"#{table.left.name}__#{column}\") }\n end\n end\n\n columns.push(build_auto_caster_marker(arel, self.cast_records_value))\n self.select_extra_values += columns.flatten if columns.any?\n end", "def each\n @cursor.forEach { |row| yield @model_class.new(row) }\n end", "def load_table_class\n @table_class = InverseCsvImporter.load_class(InverseCsvImporter.table_name(self.file))\n end", "def resultset; end", "def log_row(row)\n #overwrite this class\n end", "def make_class(klass)\n %Q{\n <td class=\"class_item\" colspan=\"#{klass.intervals}\">\n <p>#{klass.name} - #{klass.location}</p>\n <p>#{klass.type}</p>\n </td>}\n end", "def handle_row(business, row)\n\n end", "def makena_classes\n Rails.application.eager_load!\n pass = ActiveRecord::Base.descendants.map{|a| a.to_s}\n pass.shift\n pass\n end", "def construct(ar_parent, parent, row, rs, seen, model_cache, aliases)\n normal_children = []\n\n parent.children.each do |node|\n if node.reflection.macro != :count_loader\n normal_children << node\n next\n end\n\n key = aliases.column_alias(node, node.primary_key)\n ar_parent.association(node.reflection.name).target = row[key].to_i\n end\n return if normal_children.blank?\n\n normal_parent = Associations::JoinDependency::JoinBase.new(parent.base_klass, normal_children)\n super\n end", "def has_many_relations(ar_instance)\n\t\t\tcolumn_name = \"#{ar_instance.class.name.underscore}_id\"\n\t\t\tdescendents = ActiveRecord::Base.connection.tables\n\t\t\tdescendents.reject!{ |table| false unless table.classify.constantize rescue true }\n\t\t\tdescendents.reject!{ |table| true unless table.classify.constantize.column_names.include?(column_name) }\n\t\tend", "def build_inheritances_joins(arel, types)\n columns = Hash.new{ |h, k| h[k] = [] }\n base_on_key = model.arel_table[primary_key]\n base_attributes = model.attribute_names\n\n # Iterate over each casted dependent calculating the columns\n types.each.with_index do |model, idx|\n join_table = model.arel_table.alias(\"\\\"i_#{idx}\\\"\")\n arel.outer_join(join_table).on(base_on_key.eq(join_table[primary_key]))\n (model.attribute_names - base_attributes).each do |column|\n columns[column] << join_table\n end\n end\n\n # Return the list of needed columns\n columns.default_proc = nil\n columns\n end", "def initialize_rows\n @transform_lookup = {}\n if is_time?\n initialize_time_rows\n elsif is_distance?\n initialize_distance_rows\n else\n initialize_numeric_rows\n end\n end", "def map_association(target, name, rows, session)\n singular_name = name.to_s.singularize.to_sym\n entity_mapping = @mapping.get(singular_name)\n\n if target.is_a? Array\n relations = {}\n target_name = target[0].class.name.underscore\n back_relations = {}\n\n if rows.length > 0\n target_id_name = \"#{target_name.underscore}_id\"\n target_reference = entity_mapping.references[target_name.to_sym]\n\n rows.each do |row|\n relation = map(entity_mapping.type, row, session, singular_name.to_s)\n target_id = row[target_id_name.to_sym]\n\n if target_id.nil?\n raise MapperError, \"Field \\\"#{target_id_name}\\\" is not defined in the query but it's required to construct \\\"#{name} to #{target_name}\\\" association. Just add it to SELECT clause.\"\n end\n\n relations[target_id] ||= []\n relations[target_id] << relation\n back_relations[relation.id] = target.select{|t| t.id == target_id}\n end\n\n target.each do |entry|\n target_id = entry.id\n relation_objects = relations[target_id]\n\n if relation_objects\n if target_reference\n relation_objects.each {|obj| obj.set_reference!(target_reference.name, entry)}\n end\n\n # set forward collection relation\n entry.set_collection!(name, relations[target_id])\n\n # set reverse collection relation if it's present\n if entity_mapping.collections[target_name.pluralize.to_sym]\n relation_objects.each{|obj| obj.set_collection!(target_name.pluralize.to_sym, back_relations[obj.id])}\n end\n end\n end\n end\n\n ids = []\n relations.values.each do |associations|\n ids << associations.map{|a| a.id}\n end\n\n {result: relations, ids: ids.flatten.uniq}\n else\n result = rows.map do |row|\n map(entity_mapping.type, row, session, singular_name.to_s)\n end\n\n target.set_collection!(name, result)\n\n {result: result, ids: result.map {|i| i.id}}\n end\n\n end", "def from_template(template, &block)\n if template.is_a?(Array)\n template.map { |tpl| from_template(tpl, &block) }\n else\n new_attrs = template.slice(*🌊[:columns])\n template.slice(*🌊[:associations]).each do |association, association_template|\n new_attrs[association] = reflect_on_association(association).klass.from_template(association_template)\n end\n new(new_attrs, &block)\n end\n end", "def model_class\n @model_class ||= mapping.to\n end", "def with_model_class(name, columns={})\n create_model_class(name, columns)\n yield\n ensure\n destroy_model_class(name)\n end", "def meta_def_ar_class\n klass = table_name.to_s.classify\n binder = self.class\n\n @table =\n if binder.const_defined? klass\n binder.const_get klass\n else\n binder.const_set(klass,\n Class.new(ActiveRecord::Base) do # class `TableName` < ActiveRecord::Base\n singleton_class.send(:define_method, :connect) do # def self.connect\n ActiveRecord::Base.establish_connection(binder.connection_data)\n end # end\n end) # end\n end #if\n end", "def ignored_translation_table_colums(klass); end", "def format_data(csv_row)\n\t\tklass = @import_type.classify.constantize\n\t\tklass_object = klass.new({original_row: csv_row})\n\t\tformatted_data = klass_object.get_data\n\t\tformatted_data\n\tend", "def load_from_row(row)\n row.each_with_index { |val, i| self[i] = val } # @dbs[i].kind_of?(Numeric) ? val.to_i : val }\n return self\n end", "def generate_models\n (translation.tables + translation.polymorphic_tables).each do |table|\n build_model(table)\n end\n end", "def pluck_instances(*cols)\n options = cols.last.is_a?(Hash) ? cols.pop : {}\n all.each_instance(options).pluck(*cols)\n end", "def new_row(pair)\n InstantiatedFacetRow.new(pair, self)\n end", "def build_element(row)\n # Price MUST be an integer\n # binding.pry\n row[:price] = row[:price].to_i\n # binding.pry\n Meal.new(row) # returns a Meal instance\n end", "def type(return_id = false)\n query, levels = self.class.cti_outer_join_sql(id)\n result = self.class.connection.execute(query).first\n # replace returned ids with the levels corresponding to their classes\n result_levels = result.inject({}) do |hash, (k,v)|\n hash[k] = levels[k] unless v.nil?\n hash\n end\n # find class with maximum level value\n foreign_key = result_levels.max_by { |k,v| v }.first\n class_name = DBViewCTI::Names.table_to_class_name(foreign_key[0..-4])\n if return_id\n id_ = result[foreign_key].to_i\n [class_name, id_]\n else\n class_name\n end\n end", "def run_multiple(um)\n #debugger\n initial_data = []\n column_names = um[0].get_column_names\n num_rows = um.length\n\n c = 0\n 0.upto(num_rows - 1) do\n o = OpenStruct.new\n class << o\n attr_accessor :id\n end\n \n #turn the outgoing object into a VO if neccessary\n map = VoUtil.get_vo_definition_from_active_record(um[0].class.to_s)\n if map != nil\n o._explicitType = map[:outgoing]\n end\n \n #first write the primary \"attributes\" on this AR object\n column_names.each_with_index do |v,k|\n k = column_names[k]\n val = um[c].send(:\"#{k}\")\n eval(\"o.#{k}=val\")\n end\n\n \n associations = um[0].get_associates\n if(!associations.empty?)\n #now write the associated models with this AR\n associations.each do |associate|\n na = associate[1, associate.length]\n ar = um[c].send(:\"#{na}\")\n #if !ar.empty? && !ar.nil?\n\t #debugger \n\n\t ok = false;\n if (ar.instance_of? Array)\n if (!ar.empty? && !ar.nil?)\n ok=true;\n end\n else\n\t \tisArray = true\n\t end\n\n if (isArray && !ar.nil?) || ok\n\n\t if(use_single?(ar))\n initial_data_2 = run_single(ar) #recurse into single AR method for same data structure\n else\n initial_data_2 = run_multiple(ar) #recurse into multiple AR method for same data structure\n end\n eval(\"o.#{na}=initial_data_2\")\n end\n end\n end\n\n c += 1\n initial_data << o\n end\n initial_data\n end", "def process_class(current_class)\n\n STDERR.print \"\\tProcessing #{current_class}\\n\" if @options.verbose\n\n generated = false\n \n # Is current_clas derived from ActiveRecord::Base?\n if current_class.respond_to?'reflect_on_all_associations'\n\n\n node_attribs = []\n if @options.brief || current_class.abstract_class?\n node_type = 'model-brief'\n else \n node_type = 'model'\n\n # Collect model's content columns\n\n\tcontent_columns = current_class.content_columns\n\t\n\tif @options.hide_magic \n # From patch #13351\n # http://wiki.rubyonrails.org/rails/pages/MagicFieldNames\n magic_fields = [\n \"created_at\", \"created_on\", \"updated_at\", \"updated_on\",\n \"lock_version\", \"type\", \"id\", \"position\", \"parent_id\", \"lft\", \n \"rgt\", \"quote\", \"template\"\n ]\n magic_fields << current_class.table_name + \"_count\" if current_class.respond_to? 'table_name' \n content_columns = current_class.content_columns.select {|c| ! magic_fields.include? c.name}\n else\n content_columns = current_class.content_columns\n end\n \n content_columns.each do |a|\n content_column = a.name\n content_column += ' :' + a.type.to_s unless @options.hide_types\n node_attribs << content_column\n end\n end\n @graph.add_node [node_type, current_class.name, node_attribs]\n generated = true\n # Process class associations\n associations = current_class.reflect_on_all_associations\n if @options.inheritance && ! @options.transitive\n superclass_associations = current_class.superclass.reflect_on_all_associations\n \n associations = associations.select{|a| ! superclass_associations.include? a} \n # This doesn't works!\n # associations -= current_class.superclass.reflect_on_all_associations\n end\n associations.each do |a|\n process_association current_class.name, a\n end\n elsif @options.all && (current_class.is_a? Class)\n # Not ActiveRecord::Base model\n node_type = @options.brief ? 'class-brief' : 'class'\n @graph.add_node [node_type, current_class.name]\n generated = true\n elsif @options.modules && (current_class.is_a? Module)\n @graph.add_node ['module', current_class.name]\n end\n\n # Only consider meaningful inheritance relations for generated classes\n if @options.inheritance && generated && \n (current_class.superclass != ActiveRecord::Base) &&\n (current_class.superclass != Object)\n @graph.add_edge ['is-a', current_class.superclass.name, current_class.name]\n end \n\n end", "def model\n if object[inheritance_column]\n object[inheritance_column].constantize\n else\n original_class\n end\n end", "def convert_to(klass)\n #if !self.instance_of?(klass)\n adapted_object = self.adapt_to(klass)\n\n adapted_object.relationships.each_statement do |statement|\n if statement.predicate == \"info:fedora/fedora-system:def/model#hasModel\"\n adapted_object.remove_relationship(:has_model, statement.object)\n #puts statement.object\n end\n end\n\n adapted_object.assert_content_model\n adapted_object.save\n adapted_object\n #end\n\n end", "def construct_target_record(row)\n record=(0..filtered_target_fields.size-1).collect do |index|\n field = filtered_target_fields[index]\n value = row[index]\n value = 'NULL' if value.nil?\n (filtered_map[field].class.name == \"Array\" ? filtered_map[field][1].call(value) : value)\n end\n embed_string_in_quotes(record)\n end", "def cellClass\n ElementTableViewCell\n end", "def rows\n fail \"Implement #{self.class}#rows\"\n end", "def add_virtuals!(row)\n if mapping[:virtual]\n mapping[:virtual].each do |key,value|\n # If the row already has the virtual set, assume that's correct\n next if row[key]\n # Engine.logger.debug \"Mapping virtual #{key}/#{value} for row #{row}\"\n case value\n when Class\n generator = generators[key] ||= value.new\n row[key] = generator.next\n when Symbol\n generator = generators[key] ||= ETL::Generator::Generator.class_for_name(value).new(options)\n row[key] = generator.next\n when Proc\n row[key] = value.call(row)\n else\n if value.is_a?(ETL::Generator::Generator)\n row[key] = value.next\n else\n row[key] = value\n end\n end\n end\n end\n end", "def before_load\n data_class.rebuild_table\n super\n end", "def all_objects\n processed_rows.collect { |_i, rp| rp.all_objects }.flatten\n end", "def row(row)\n Row.new(@data, row)\n end", "def map_nested_models\n end" ]
[ "0.6723646", "0.63869137", "0.634353", "0.63341016", "0.62597936", "0.62184864", "0.6139677", "0.6086968", "0.6084822", "0.60667866", "0.6006603", "0.5997283", "0.59431756", "0.5942243", "0.581694", "0.5765691", "0.5735786", "0.5722222", "0.5705314", "0.5681461", "0.56772625", "0.5659878", "0.56565297", "0.5655555", "0.56303", "0.56303", "0.5606891", "0.5594206", "0.5587899", "0.558392", "0.55795157", "0.55761474", "0.55692816", "0.5567617", "0.5552497", "0.5552212", "0.5541572", "0.5540121", "0.55318797", "0.5527382", "0.55242896", "0.5517344", "0.55121773", "0.549834", "0.54955095", "0.5495087", "0.54836595", "0.54809946", "0.54739577", "0.5461607", "0.5455692", "0.5451109", "0.54472136", "0.5443127", "0.54174", "0.5414594", "0.5414294", "0.53987014", "0.5386572", "0.5375259", "0.5351064", "0.53492665", "0.53470665", "0.53460306", "0.5345484", "0.53420484", "0.5322601", "0.53222686", "0.53123635", "0.5302429", "0.53013456", "0.5297015", "0.52944124", "0.52939004", "0.5288685", "0.52850795", "0.5272656", "0.5267039", "0.5264621", "0.5261441", "0.5254049", "0.52522933", "0.5248534", "0.5247746", "0.5244023", "0.5239458", "0.52327996", "0.5230416", "0.52276945", "0.5218589", "0.5216152", "0.52099246", "0.51995033", "0.519523", "0.51899016", "0.5187778", "0.51849693", "0.5180569", "0.51769423", "0.51752055", "0.51746845" ]
0.0
-1
This overrides the Objectmethod method to return the mocked method when the mocked method is being requested. For methods that aren't being tested, this method returns a proc that will raise an error when called. This is to assure that only the mocked grpc method is being called.
def method(symbol) return @mock_method if symbol == @expected_symbol # The requested method is not being tested, raise if it called. proc do raise "The method #{symbol} was unexpectedly called during the " \ "test for #{@expected_symbol}." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_grpc_method(grpc_method_object)\n owner = grpc_method_object.owner\n\n return VALUE_UNKNOWN unless owner.instance_variable_defined?(:@rpc_descs)\n\n method, = owner.rpc_descs.find do |k, _|\n ::GRPC::GenericService.underscore(k.to_s) == grpc_method_object.name.to_s\n end\n\n return VALUE_UNKNOWN if method.nil?\n\n method.to_s\n end", "def mock_facade_method(object, message, ret_val: nil)\n expect(object).to receive(message).and_return(ret_val)\n end", "def instance_call(method_name)\n Scenario::Orchestrator.new(self, @mock_instance_double, :instance, method_name)\n end", "def stub_call(method:, message: :any, response:)\n savon.expects(method).with(message: message).returns(response)\n end", "def class_call(method_name)\n Scenario::Orchestrator.new(self, @mock_class_double, :class, method_name)\n end", "def remote_call name, args\n m = public_method(name)\n if m && m.owner == self.class\n m.call(*args)\n else\n raise NoMethodError, \"method #{name} is not found\"\n end\n rescue NameError\n raise NoMethodError, \"method #{name} is not found\"\n end", "def flexmock_invoke_original(object, method, *args, &block)\n object.instance_variable_get(:@flexmock_proxy).proxy.flexmock_invoke_original(method, args, &block)\n end", "def flexmock_invoke_original(object, method, *args, &block)\n object.instance_variable_get(:@flexmock_proxy).proxy.flexmock_invoke_original(method, args, &block)\n end", "def verify_stubbed_calls; end", "def flexmock_invoke_original(method, args)\n method_proc = @method_definitions[method]\n method_proc.call(*args)\n end", "def internal_deliver(mode, method_name, return_type, *args, &b) \n exp = expectations.find(method_name, mode, *args)\n# exp = expectations.find(method_name.underscore, mode, *args) unless exp\n bl = record_call(method_name, mode, exp, *args, &b)\n is_value_type = return_type && return_type != System::Void.to_clr_type && return_type.is_value_type \n res = nil\n if exp\n block = exp.block || b\n res = instance.__send__(method_name, *args, &block) if exp.super_before?\n exp.event_recorder do |ev_nm, ev_ar, ev_h|\n recorder.record_event_raise ev_nm, mode, *ev_ar, &ev_h if ev_nm\n end if recorder && exp\n res = exp.execute *args, &bl\n res = instance.__send__(method_name, *args, &block) if !exp.super_before? and exp.call_super?\n end\n res ||= System::Activator.create_instance(return_type) if is_value_type \n res\n end", "def stubbing(object, method_name)\n @stubs[object.object_id][method_name]\n end", "def stub_ar_method(object, method, return_value, params = {})\n if params.blank?\n object.stub!(method).and_return(return_value ? false : true)\n else\n object.stub!(method).with(hash_including(params)).and_return(return_value ? false : true)\n end\n end", "def some_method(message)\n # Write your own code here to build request and parse response\n request = ProtobufRubyExample::Proto::RequestPb.new(id: rand(100), message: message)\n\n response = @rpc_stub.some_method(request)\n\n return response.status\n end", "def refute_called(object, method_name, message = nil, &block)\n assert_called(object, method_name, message, times: 0, &block)\n end", "def internal_deliver(mode, method_name, return_type, *args, &b) \n res = nil \n is_value_type = return_type && return_type != System::Void.to_clr_type && return_type.is_value_type\n exp = expectations.find(method_name, mode, *args)\n# exp = expectations.find(method_name.underscore, mode, *args) unless exp\n exp.event_recorder do |ev_nm, ev_ar, ev_h|\n recorder.record_event_raise ev_nm, mode, *ev_ar, &ev_h if ev_nm\n end if recorder && exp\n bl = record_call(method_name, mode, exp, *args, &b)\n res = exp.execute *args, &bl if exp\n res ||= System::Activator.create_instance(return_type) if is_value_type \n res\n end", "def stub_implementation; end", "def wrapped_request(rpc_method, request)\n request = request_class(rpc_method).new(request) if request.is_a?(Hash)\n\n ::Protobuf::Socketrpc::Request.new(\n :service_name => subject_service.to_s,\n :method_name => rpc_method.to_s,\n :request_proto => request.encode,\n :caller => 'protobuf-rspec'\n )\n end", "def stub_twilio_request\n allow_any_instance_of(TwilioService).to receive(:send_message)\nend", "def remote_call(meth, *args)\r\n loc = meth\r\n loc = get_proc(loc) if loc.kind_of? String\r\n loc = Ragweed::Ptr.new loc\r\n raise \"bad proc name\" if loc.null?\r\n t = Trampoline.new(self, loc)\r\n t.call *args\r\n end", "def expected_method; end", "def test_Method_InstanceMethods_to_proc\n\t\tpass\n\tend", "def stubbed?\n raise NotImplementedError\n end", "def stub_instance_method(klass, name, val_or_callable, &block)\n if defined?(::Minitest::Moar::Stubbing)\n instance_stub klass, name, val_or_callable, &block\n elsif defined?(::Minitest::StubAnyInstance)\n klass.stub_any_instance(name, val_or_callable, &block)\n else\n begin\n new_name = \"__minitest_stub_instance_method__#{name}\"\n owns_method = instance_method(name).owner == klass\n klass.class_eval do\n alias_method new_name, name if owns_method\n\n define_method(name) do |*args|\n if val_or_callable.respond_to?(:call)\n instance_exec(*args, &val_or_callable)\n else\n val_or_callable\n end\n end\n end\n\n yield\n ensure\n klass.class_eval do\n remove_method name\n if owns_method\n alias_method name, new_name\n remove_method new_name\n end\n end\n end\n end\n end", "def method_missing(methodSymbol, *params)\n # get the remote method name\n remoteMethod = methodSymbol.to_s.gsub(\"_\", \".\")\n if methodSymbol.to_s.match(/cached_(.*)/)\n log_debug \"** RFACEBOOK(GEM) - DEPRECATION NOTICE - cached methods are deprecated, making a raw call without caching.\"\n tokens.shift\n end\n \n # there can only be one parameter, a Hash, for remote methods\n unless (params.size == 1 and params.first.is_a?(Hash))\n log_debug \"** RFACEBOOK(GEM) - when you call a remote Facebook method\"\n end\n \n # make the remote method call\n return remote_call(remoteMethod, params.first) \n end", "def rpc_send(method_name, *args, &block)\n return yield if rpc_in_server_mode? || rpc_enabled?\n begin\n rpc_client << [method_name, args]\n response = rpc_client.read\n rescue => e\n #FIXME: error handling as an error occured at the transport layer\n end\n if response.erred?\n #will have response.message = {:em => 'error msg', :eb => ['error backtrace'], :om => 'original message'}\n end\n response.message\n end", "def stub_for method_name\n @stubs[method_name] ||= new_stub_for(method_name)\n end", "def rest_method(name, options = { default_result: '...' })\n # @!method promise_[name]\n # @return [Promise] on success the .then block will receive the result of the RPC call as arg\n # on failure the .fail block will receive the HTTP response object as arg\n define_method(\"promise_#{name}\") do |*args|\n name_args = self.class._name_args(name, *args)\n @fetch_states[name_args] = 'i'\n @rest_methods[name] = {}.merge!(options) unless @rest_methods.has_key?(name)\n @rest_methods[name_args] = { result: options[:default_result] } unless @rest_methods.has_key?(name_args) && @rest_methods[name_args].has_key?(:result)\n raise \"#{self.class.to_s}[_no_id_].#{name}, can't execute instance rest_method without id!\" unless self.id\n self.class._promise_get_or_patch(\"#{resource_base_uri}/#{self.id}/methods/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\", *args).then do |response_json|\n @rest_methods[name_args][:result] = response_json[:result] # result is parsed json\n @fetch_states[name_args] = 'f'\n _notify_observers\n @rest_methods[name_args][:result]\n end.fail do |response|\n error_message = \"#{self.class.to_s}[#{self.id}].#{name}, a rest_method, failed to execute!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name]\n # @return result either the default_result ass specified in the options or the real result if the RPC call already finished\n define_method(name) do |*args|\n _register_observer\n name_args = self.class._name_args(name, *args)\n @rest_methods[name] = {}.merge!(options) unless @rest_methods.has_key?(name)\n @rest_methods[name_args] = { result: options[:default_result] } unless @rest_methods.has_key?(name_args) && @rest_methods[name_args].has_key?(:result)\n unless @fetch_states.has_key?(name_args) && 'fi'.include?(@fetch_states[name_args])\n self.send(\"promise_#{name}\", *args)\n end\n @rest_methods[name_args][:result]\n end\n # @!method update_[name] mark internal structures so that the method is called again once it is requested again\n # @return nil\n define_method(\"update_#{name}\") do |*args|\n @fetch_states[self.class._name_args(name, *args)] = 'u'\n nil\n end\n end", "def method_missing(method, *args, &block)\n __proxy_result__.send(method, *args, &block)\n end", "def have_received(expected_method_name)\n HaveReceived.new(expected_method_name)\n end", "def method_missing(meth, *args, &block)\n if not @impl.nil? and @impl.respond_to?(meth)\n return @impl.send(meth.to_s, *args, &block)\n end\n # :nocov:\n return super\n # :nocov:\n end", "def stub_method(object, method, &block) #:nodoc:\n unless @stubbed_methods.include?([object, method])\n @stubbed_methods << [object, method]\n add_hook(object, method, &block)\n end\n end", "def define_proxy_method(method_name)\n if method_name.to_s =~ /=$/\n eval_line = __LINE__ + 1\n sclass.class_eval %{\n def #{method_name}(*args, &block)\n @flexmock_proxy.mock.__send__(:#{method_name}, *args, &block) \n end\n }, __FILE__, eval_line\n else\n eval_line = __LINE__ + 1\n sclass.class_eval %{\n def #{method_name}(*args, &block)\n @flexmock_proxy.mock.#{method_name}(*args, &block) \n end\n }, __FILE__, eval_line\n make_rcov_recognize_the_above_eval_is_covered = true\n end\n end", "def proc_method\n\tproc_a = proc { |x| return x }\n\tproc_a.call(@expected_proc_return)\n\t\"unexpected proc return\"\nend", "def test_errors_from_handled_requests_are_noticed\n desc = basic_grpc_desc\n def desc.trace_with_newrelic?; true; end # force a true response from this method\n def desc.process_distributed_tracing_headers(ac); end # noop this DT method (tested elsewhere)\n def desc.metadata_for_call(call); NewRelic::EMPTY_HASH; end # canned. test metadata_for_call elsewhere\n raised_error = RuntimeError.new\n new_transaction_called = false\n NewRelic::Agent::Transaction.stub(:start_new_transaction, proc { new_transaction_called = true; transaction }) do\n received_error = nil\n notice_stub = proc { |e| received_error = e }\n NewRelic::Agent.stub(:notice_error, notice_stub) do\n assert_raises(RuntimeError) do\n result = desc.handle_with_tracing(nil, nil, method, nil) { raise raised_error }\n end\n\n assert_equal raised_error, received_error\n assert new_transaction_called\n end\n end\n end", "def stub_member_call(source, target)\n _env_change\n @env.patch_op [:stub_member, target, source]\n end", "def define_proxy_method(method_name)\n if method_name.to_s =~ /=$/\n eval_line = __LINE__ + 1\n target_class_eval %{\n def #{method_name}(*args, &block)\n instance_variable_get('@flexmock_proxy').\n mock.__send__(:#{method_name}, *args, &block)\n end\n }, __FILE__, eval_line\n else\n eval_line = __LINE__ + 1\n target_class_eval %{\n def #{method_name}(*args, &block)\n instance_variable_get('@flexmock_proxy').\n mock.#{method_name}(*args, &block)\n end\n }, __FILE__, eval_line\n _ = true # make rcov recognize the above eval is covered\n end\n end", "def verify\n if @count > 0\n flunk \"mocked method %p not called %d time(s)\" %\n [@meth, @count]\n end\n self\n end", "def method_object\n @method_object ||= get_method_or_raise(args.empty? ? nil : args.join(\" \"), @method_target,\n :super => opts[:super],\n :instance => opts.present?(:'instance-methods') && !opts.present?(:'methods'),\n :methods => opts.present?(:'methods') && !opts.present?(:'instance-methods')\n )\n end", "def new_stub_for method_name\n response = Response.new(Http::Request.new, Http::Response.new)\n response.request_type = method_name\n response.request_options = {}\n send(\"simulate_#{method_name}_response\", response)\n response.signal_success\n response\n end", "def new_stub_for method_name\n response = Response.new(Http::Request.new, Http::Response.new)\n response.request_type = method_name\n response.request_options = {}\n send(\"simulate_#{method_name}_response\", response)\n response.signal_success\n response\n end", "def method_missing(sym, *args, &block)\n begin\n retval = Cspice_wrapper.send sym, *args, &block\n rescue NoMethodError\n super\n end\n\n if Cspice_wrapper.failed_c\n #The CSPICE method just called reported an error. Translate it into an RSpice exception\n short = get_error_message :short\n long = get_error_message :long\n traceback = get_error_message :traceback\n explain = get_error_message :explain\n\n # Reset the error state so subsequent CSPICE calls do not immediately fail\n Cspice_wrapper.reset_c()\n\n raise CSpiceError.new(short, long, traceback, explain)\n end\n\n retval\n end", "def call_rpc(method, args)\n method = sanitize_parameters(method)\n args = sanitize_parameters(args)\n resp = @rpc.call(\"#{@service}.#{method}\", args)\n\n return true if resp == 'OK'\n return resp\n end", "def method_missing (method, *args, &block)\n __proxy_result__.send(method, *args, &block)\n end", "def call(method, *args)\n self.class.rpc_execute(method, *args)\n end", "def invoke(optional_destination, rpc_method, *args)\n # TODO\n end", "def send_without_checking(method, *args)\n @mock_redis.send(method, *args)\n @real_redis.send(method, *args)\n end", "def __proxy_result__\n @proxy_result = @method_call.call unless defined?(@proxy_result)\n @proxy_result\n end", "def invoked_method()\n obj = get_receiver_object\n if obj.nil?\n Undef\n else\n begin\n obj.method(@name)\n rescue NameError\n Undef\n end\n end\n end", "def discovered_method(rpc_name, api, version=nil)\n if !rpc_name.kind_of?(String) && !rpc_name.kind_of?(Symbol)\n raise TypeError,\n \"Expected String or Symbol, got #{rpc_name.class}.\"\n end\n rpc_name = rpc_name.to_s\n api = api.to_s\n version = version || 'v1'\n service = self.discovered_api(api, version)\n if service.to_h[rpc_name]\n return service.to_h[rpc_name]\n else\n return nil\n end\n end", "def fake_exec_api(agent, operation, params)\n call = Call.new(agent, operation, params)\n stub = API.stubs.shift\n assert stub, \"Unexpected API call (no response stub set)\\n#{call}\"\n assert stub.test(call), \"Stub didn't match API call:\\n#{call}\"\n\n res = stub.response\n res = res.to_json_response if res.kind_of? CommandResponse\n logger.debug res\n return res\n end", "def method_missing(msg, *args, &block)\n puts \"#{self.class}#method_missing(#{msg})\" \n proc = self.singleton_class.resolve_dynamic_method(msg) || self.class.resolve_dynamic_method(msg)\n\n begin\n if !proc.nil?\n args.unshift self \n res = if block.nil?\n proc.call(*args)\n else\n proc.call(*args, &block)\n end\n return res\n elsif msg != :method_missing! && self.respond_to?(:method_missing!)\n puts \"\\tdelgating to method_missing!\"\n return method_missing!(msg, *args, &block)\n else\n return super(msg, *args, &block)\n # TODO - report RM bug for when block is empty\n end\n rescue NoMethodError => ex\n new_ex = NoMethodError.new(\"undefined method \\`#{msg}' for #{self.inspect}:#{self.class}\")\n new_ex.set_backtrace ex.backtrace\n raise new_ex\n end\n end", "def stub_for method_name\n @stubs ||= {}\n @stubs[method_name] ||= new_stub_for(method_name)\n end", "def should_receive(*args)\n ContainerHelper.parse_should_args(@mock, args) do |sym|\n unless @methods_proxied.include?(sym)\n hide_existing_method(sym)\n end\n ex = @mock.should_receive(sym)\n ex.mock = self\n ex\n end\n end", "def callee\n @method\n end", "def flexmock_call_original(object, method, *args, &block)\n Test.warn \"#flexmock_call_original is deprecated, use #flexmock_invoke_original instead\"\n flexmock_invoke_original(object, method, *args, &block)\n end", "def flexmock_call_original(object, method, *args, &block)\n Test.warn \"#flexmock_call_original is deprecated, use #flexmock_invoke_original instead\"\n flexmock_invoke_original(object, method, *args, &block)\n end", "def test_do_not_call_finish_on_an_absent_segment\n desc = basic_grpc_desc\n def desc.trace_with_newrelic?; true; end # force a true response from this method\n def desc.process_distributed_tracing_headers(ac); end # noop this DT method (tested elsewhere)\n def desc.metadata_for_call(call); NewRelic::EMPTY_HASH; end # canned. test metadata_for_call elsewhere\n # force finishable to be nil\n NewRelic::Agent::Tracer.stub(:start_transaction_or_segment, nil) do\n result = desc.handle_with_tracing(nil, nil, method, nil) { return_value }\n\n assert_equal return_value, result\n # MiniTest does not have a wont_raise, but this test would fail if\n # finishable called #finish when nil\n end\n end" ]
[ "0.6446494", "0.6170767", "0.603632", "0.58104575", "0.57906324", "0.57888126", "0.5743578", "0.5743578", "0.5736099", "0.572942", "0.57138884", "0.56847304", "0.56567526", "0.5644068", "0.5631608", "0.5600883", "0.5585982", "0.5581288", "0.5580837", "0.55619633", "0.55441946", "0.55407846", "0.5502225", "0.550006", "0.54948115", "0.54880273", "0.5478718", "0.5470651", "0.546184", "0.5452874", "0.54422855", "0.54376465", "0.5434136", "0.5422835", "0.53991926", "0.5380247", "0.53718305", "0.53702915", "0.53694624", "0.5369393", "0.5369393", "0.53669107", "0.5366829", "0.5365292", "0.53593814", "0.53572965", "0.5349837", "0.5335393", "0.5321859", "0.53132945", "0.5311366", "0.5309433", "0.5302913", "0.5302766", "0.5301214", "0.52932703", "0.52932703", "0.5286693" ]
0.613194
37
Since the ProQuest status report has many filters, we apply them all here.
def filter_proquest_status(theses) term_filtered = filter_theses_by_term theses dept_filtered = filter_theses_by_department term_filtered degree_filtered = filter_theses_by_degree_type dept_filtered multi_author_filtered = filter_theses_by_multiple_authors degree_filtered filter_theses_by_published multi_author_filtered end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_filter\n end", "def get_feed_filters\n filters = self.filters.to_h.reject{ |k, _v| PROHIBITED_FILTERS.include?(k.to_s) }\n filters.merge!({ 'report_status' => ['published'] }) if self.published\n filters\n end", "def postFetchFilter\n @filtered= Filter.new(@detail.waypoints)\n\n # caches with warnings we choose not to include.\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['includeArchived']\n @appliedFilters['--includeArchived'] = { 'f' => \"\", 't' => \"also archived\" }\n else\n # this would cause too much noise, don't advertise\n #@appliedFilters['--excludeArchived'] = { 'f' => \"\", 't' => \"not archived\" }\n @filtered.removeByElement('archived')\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Archived\")\n #\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['includeDisabled']\n @appliedFilters['-z'] = { 'f' => \"\", 't' => \"also disabled\" }\n else\n @appliedFilters['+z'] = { 'f' => \"\", 't' => \"not disabled\" }\n @filtered.removeByElement('disabled')\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Disabled\")\n\n # exclude Premium Member Only caches on request\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['noPMO']\n @appliedFilters['-O'] = { 'f' => \"\", 't' => \"no PMO\" }\n @filtered.removeByElement('membersonly')\n end\n if @option['onlyPMO']\n @appliedFilters['-Q'] = { 'f' => \"\", 't' => \"PMO\" }\n @filtered.removeByElement('membersonly', false)\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"PM-Only\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['descKeyword']\n @appliedFilters['-K'] = { 'f' => \"#{@option['descKeyword']}\", 't' => \"matching descr. keyword\" }\n @filtered.descKeyword(@option['descKeyword'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Keyword\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['difficultyMin']\n @appliedFilters['-d'] = { 'f' => \"#{@option['difficultyMin']}\", 't' => \"difficulty min\" }\n @filtered.difficultyMin(@option['difficultyMin'].to_f)\n end\n if @option['difficultyMax']\n @appliedFilters['-D'] = { 'f' => \"#{@option['difficultyMax']}\", 't' => \"difficulty max\" }\n @filtered.difficultyMax(@option['difficultyMax'].to_f)\n end\n if @option['terrainMin']\n @appliedFilters['-t'] = { 'f' => \"#{@option['terrainMin']}\", 't' => \"terrain min\" }\n @filtered.terrainMin(@option['terrainMin'].to_f)\n end\n if @option['terrainMax']\n @appliedFilters['-T'] = { 'f' => \"#{@option['terrainMax']}\", 't' => \"terrain max\" }\n @filtered.terrainMax(@option['terrainMax'].to_f)\n end\n if @option['sizeMin']\n @appliedFilters['-s'] = { 'f' => \"#{@option['sizeMin']}\", 't' => \"size min\" }\n @filtered.sizeMin(@option['sizeMin'])\n end\n if @option['sizeMax']\n @appliedFilters['-S'] = { 'f' => \"#{@option['sizeMax']}\", 't' => \"size max\" }\n @filtered.sizeMax(@option['sizeMax'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"D/T/Size\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['favFactorMin']\n @appliedFilters['-g'] = { 'f' => \"#{@option['favFactorMin']}\", 't' => \"favFactor min\" }\n @filtered.favFactorMin(@option['favFactorMin'].to_f)\n end\n if @option['favFactorMax']\n @appliedFilters['-G'] = { 'f' => \"#{@option['favFactorMax']}\", 't' => \"favFactor max\" }\n @filtered.favFactorMax(@option['favFactorMax'].to_f)\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"FavFactor\")\n\n # We filter for users again. While this may be a bit obsessive, this is in case\n # our local cache is not valid.\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['userExclude']\n @appliedFilters['-E'] = { 'f' => \"#{@option['userExclude']}\", 't' => \"not done by\" }\n @option['userExclude'].split($delimiters).each{ |user|\n @filtered.userExclude(user)\n }\n end\n if @option['userInclude']\n @appliedFilters['-e'] = { 'f' => \"#{@option['userInclude']}\", 't' => \"done by\" }\n @option['userInclude'].split($delimiters).each{ |user|\n @filtered.userInclude(user)\n }\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"User\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['attributeExclude']\n @appliedFilters['-A'] = { 'f' => \"#{@option['attributeExclude']}\", 't' => \"attr no\" }\n @option['attributeExclude'].split($delimiters).each{ |attribute|\n @filtered.attributeExclude(attribute)\n }\n end\n if @option['attributeInclude']\n @appliedFilters['-a'] = { 'f' => \"#{@option['attributeExclude']}\", 't' => \"attr yes\" }\n @option['attributeInclude'].split($delimiters).each{ |attribute|\n @filtered.attributeInclude(attribute)\n }\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Attribute\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['minLongitude']\n @appliedFilters['--minLon'] = { 'f' => \"#{@option['minLongitude']}\", 't' => \"West\" }\n @filtered.longMin(@option['minLongitude'])\n end\n if @option['maxLongitude']\n @appliedFilters['--maxLon'] = { 'f' => \"#{@option['maxLongitude']}\", 't' => \"East\" }\n @filtered.longMax(@option['maxLongitude'])\n end\n if @option['minLatitude']\n @appliedFilters['--minLat'] = { 'f' => \"#{@option['minLatitude']}\", 't' => \"South\" }\n @filtered.latMin(@option['minLatitude'])\n end\n if @option['maxLatitude']\n @appliedFilters['--maxLat'] = { 'f' => \"#{@option['maxLatitude']}\", 't' => \"North\" }\n @filtered.latMax(@option['maxLatitude'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Lat/Lon\")\n\n displayMessage \"Post-fetch filter complete, #{caches(@filtered.totalWaypoints)} left.\"\n return @filtered.totalWaypoints\n end", "def status_filter_options\n helpers.options_for_select([[\"Any\", \"ANY\"]], params.dig(:query, :status)) +\n helpers.grouped_options_for_select(\n { \"open/closed\" => [[\"Open\", \"\"], [\"Closed\", \"closed\"]],\n \"status\" => Admin::DigitizationQueueItem::STATUSES.\n find_all {|s| s != \"closed\" }.\n collect {|s| [s.humanize, s]}\n },\n params.dig(:query, :status) || \"\"\n )\n\n # helpers.options_for_select(\n # Admin::DigitizationQueueItem::STATUSES.\n # find_all {|s| s != \"closed\" }.\n # collect {|s| [s.humanize, s]},\n # params.dig(:query, :status)\n # )\n end", "def set_filters\n @filters = ''\n @filters.concat(\"status:'Available'\")\n unless @manufacturer_or_publisher.blank?\n @filters.concat(\" AND (manufacturer:'#{@manufacturer_or_publisher}'\")\n @filters.concat(\" OR publisher:'#{@manufacturer_or_publisher}')\")\n end\n @filters.concat(\" AND category:'#{@category}'\") unless @category.blank?\n @filters.concat(\" AND seller_name:'#{@seller_name}'\") unless @seller_name.blank?\n end", "def ts_apply_filters\n # TODO: Make filters for Thinking Sphinx\n end", "def setup_summary_report\n assign_to_from_dates\n @filter = @filter.remove_blanks_in_arrays\n @filter_name = @filter[:name]\n assign_grouping_type\n assign_facilities\n end", "def filters; end", "def filters; end", "def recalculate_report_status\n self.status = 'pending' if resource_statuses.any? {|rs| rs.status == 'pending' } &&\n resource_statuses.none? {|rs| rs.status == 'failed'}\n self.status = 'failed' if self.logs.any? {|l| l.level == 'err' }\n end", "def index\n @received_filter = FilterPresenter.new(['true', 'false'], 'all')\n @received_filter.current = params[:received]\n @graded_filter = FilterPresenter.new(['true', 'false'], 'all')\n @graded_filter.current = params[:graded]\n @patient = if patient_signed_in?\n current_patient\n elsif params[:patient_id]\n Patient.find(params[:patient_id])\n end\n\tgraded_flag = (@graded_filter.active == 'true')\n\treceived_flag = (@received_filter.active == 'true')\n\n\tif @graded_filter.active == 'all' and @received_filter.active == 'all'\n\t\t@records = (@patient ? @patient.records : Record.includes(:patient)).includes(:grade).order('created_at DESC')#.page(params[:page])\n\telsif @graded_filter.active == 'all'\n\t\t@records = (@patient ? @patient.records : Record.includes(:patient)).includes(:grade).where(received: received_flag).order('created_at DESC')#.page(params[:page])\n\telsif @received_filter.active == 'all'\n\t\t@records = (@patient ? @patient.records : Record.includes(:patient)).includes(:grade).where(graded: graded_flag).order('created_at DESC')#.page(params[:page])\n\telse\n\t\t@records = (@patient ? @patient.records : Record.includes(:patient)).includes(:grade).where(graded: graded_flag, received: received_flag).order('created_at DESC')#.page(params[:page])\n\tend\n\n respond_to do |format|\n format.html # index.html.erb\n format.json do\n render json: @records.to_json(\n include: {\n grade: {\n only: [:grade, :comment]\n }\n },\n only: [:id, :device, :comment, :status, :patient_id,\n :created_at, :updated_at, :meta, :pill_time_at, :received],\n methods: [:is_excuse?])\n end\n format.csv\n end\n end", "def filters\n end", "def preFetchFilter\n @filtered = Filter.new(@combinedWaypoints)\n debug \"Filter running cycle 1, #{caches(@filtered.totalWaypoints)} left.\"\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['cacheType']\n # post-filter by cacheType\n @appliedFilters['-c'] = { 'f' => \"#{@option['cacheType']}\", 't' => \"type\" }\n # event+ is now all_event, unknown+ is now all_unknown\n if @option['cacheType'] !~ /\\+$/ and\n @option['cacheType'] !~ /^all_/\n # but only if there's no \"all xxx\" chosen\n # we must trust that the query returns correct data here...\n @filtered.cacheType(@option['cacheType'])\n else\n displayWarning \"Not filtering for cache type!\"\n end\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Cache type\")\n\n # caches with warnings we choose not to include.\n beforeFilterTotal = @filtered.totalWaypoints\n if not @option['includeArchived']\n @filtered.removeByElement('archived')\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Archived\")\n #\n beforeFilterTotal = @filtered.totalWaypoints\n if not @option['includeDisabled']\n @filtered.removeByElement('disabled')\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Disabled\")\n\n # exclude Premium Member Only caches on request\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['noPMO']\n @filtered.removeByElement('membersonly')\n end\n # may not be accurate before fetching details?\n if @option['onlyPMO']\n @filtered.removeByElement('membersonly', false)\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"PM-Only\")\n\n if $DTSFILTER\n #-------------------\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['difficultyMin']\n @appliedFilters['-d'] = { 'f' => \"#{@option['difficultyMin']}\", 't' => \"difficulty min\" }\n @filtered.difficultyMin(@option['difficultyMin'].to_f)\n end\n if @option['difficultyMax']\n @appliedFilters['-D'] = { 'f' => \"#{@option['difficultyMax']}\", 't' => \"difficulty max\" }\n @filtered.difficultyMax(@option['difficultyMax'].to_f)\n end\n if @option['terrainMin']\n @appliedFilters['-t'] = { 'f' => \"#{@option['terrainMin']}\", 't' => \"terrain min\" }\n @filtered.terrainMin(@option['terrainMin'].to_f)\n end\n if @option['terrainMax']\n @appliedFilters['-T'] = { 'f' => \"#{@option['terrainMax']}\", 't' => \"terrain max\" }\n @filtered.terrainMax(@option['terrainMax'].to_f)\n end\n if @option['sizeMin']\n @appliedFilters['-s'] = { 'f' => \"#{@option['sizeMin']}\", 't' => \"size min\" }\n @filtered.sizeMin(@option['sizeMin'])\n end\n if @option['sizeMax']\n @appliedFilters['-S'] = { 'f' => \"#{@option['sizeMax']}\", 't' => \"size max\" }\n @filtered.sizeMax(@option['sizeMax'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"D/T/Size\")\n #-------------------\n end # $DTSFILTER\n\n debug \"Filter running cycle 2, #{caches(@filtered.totalWaypoints)} left.\"\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['foundDateInclude']\n @appliedFilters['-r'] = { 'f' => \"#{@option['foundDateInclude']}\", 't' => \"found age max\" }\n @filtered.foundDateInclude(@option['foundDateInclude'].to_f)\n end\n if @option['foundDateExclude']\n @appliedFilters['-R'] = { 'f' => \"#{@option['foundDateExclude']}\", 't' => \"found age min\" }\n @filtered.foundDateExclude(@option['foundDateExclude'].to_f)\n end\n if @option['placeDateInclude']\n @appliedFilters['-j'] = { 'f' => \"#{@option['placeDateInclude']}\", 't' => \"cache age max\" }\n @filtered.placeDateInclude(@option['placeDateInclude'].to_f)\n end\n if @option['placeDateExclude']\n @appliedFilters['-J'] = { 'f' => \"#{@option['placeDateExclude']}\", 't' => \"cache age min\" }\n @filtered.placeDateExclude(@option['placeDateExclude'].to_f)\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Date\")\n\n debug \"Filter running cycle 3, #{caches(@filtered.totalWaypoints)} left.\"\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['notFound']\n @appliedFilters['-n'] = { 'f' => \"\", 't' => \"virgins\" }\n @filtered.notFound\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Unfound\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['travelBug']\n @appliedFilters['-b'] = { 'f' => \"\", 't' => \"trackables\" }\n @filtered.travelBug\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Trackable\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['ownerExclude']\n @appliedFilters['-I'] = { 'f' => \"#{@option['ownerExclude']}\", 't' => \"not owned by\" }\n @option['ownerExclude'].split($delimiters).each{ |owner|\n @filtered.ownerExclude(owner)\n }\n end\n if @option['ownerInclude']\n @appliedFilters['-i'] = { 'f' => \"#{@option['ownerInclude']}\", 't' => \"owned by\" }\n @option['ownerInclude'].split($delimiters).each{ |owner|\n @filtered.ownerInclude(owner)\n }\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Owner\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['userExclude']\n @appliedFilters['-E'] = { 'f' => \"#{@option['userExclude']}\", 't' => \"not done by\" }\n @option['userExclude'].split($delimiters).each{ |user|\n @filtered.userExclude(user)\n }\n end\n if @option['userInclude']\n @appliedFilters['-e'] = { 'f' => \"#{@option['userInclude']}\", 't' => \"done by\" }\n @option['userInclude'].split($delimiters).each{ |user|\n @filtered.userInclude(user)\n }\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"User\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['titleKeyword']\n @appliedFilters['-k'] = { 'f' => \"#{@option['titleKeyword']}\", 't' => \"matching title keyword\" }\n @filtered.titleKeyword(@option['titleKeyword'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Title\")\n\n displayMessage \"Pre-fetch filter complete, #{caches(@filtered.totalWaypoints)} left.\"\n end", "def add_by_filter_reporter( period_s = 60 * 10.0 )\n @main_by_filter_period = period_s\n end", "def add_filters(filters); end", "def apply_filter\n offset = (params[:page].to_i - 1) * params[:perpage].to_i\n limit = params[:perpage]\n\n results = get_results(offset, limit)\n result_list = get_fields_to_show(results['elements'])\n \n data = Hash.new\n data['total'] = results['total']\n data['result'] = result_list\n respond_to do |format|\n format.json { render :json => data.to_json }\n end\n end", "def select_filters\n @screen = session.active_screen\n @report = Report.find(params[:id])\n @available_field_filters = @report.fields_for_filters\n @set_field_filters = {}\n @report.field_report_filters.each{|frf|\n @set_field_filters[frf.reference_screen_index] ||= {}\n @set_field_filters[frf.reference_screen_index][frf.field_id] = frf\n }\n\n respond_to do |format|\n format.html # formats.html.erb\n format.xml { render :xml => @report }\n end\n end", "def set_filters\n filter_param_keys = [\n 'brand', 'color',\n 'size', 'department', 'keywords'\n ]\n @filters = []\n filter_param_keys.each do |key|\n if !params[key].blank?\n params[key].split(',').each do |val|\n @filters << {:key => key, :val => val}\n end\n end\n end\n \n \n if params[:price]\n params[:price].split(',').each_slice(2).to_a.each do |range|\n @filters << {:key => 'price', :val => range.join(',')}\n end\n end\n\n if @products\n @brands = @products.facet('brand_facet').rows.sort_by{ |brand| brand.value.capitalize}\n @departments = @products.facet('department_facet').rows\n end\n \n @colors = ['green', 'blue', 'purple', 'red', 'pink', 'beige', 'brown', 'yellow', 'orange', 'black', 'white', 'gray', 'teal', 'glowing', 'gold', 'silver']\n \n if [email protected]? && @taxon.has_size?\n sizes = (Spree::Product.sizes.sort_by{|size| size.position}.map(&:presentation) & @products.facet(\"size_facet\").rows.map(&:value))\n end\n end", "def super_search\n @browse_state.attributes=(params)\n @search_filter1 = @browse_state.make_search_filter\n \n ## Condition - when to include or exlude romance from the search list.\n if params[:search_filter].nil? || (!params[:search_filter].nil? && params[:search_filter][:romance] == \"19\") \n cond = params[:search_filter][:romance].to_i if !params[:search_filter].nil? && !params[:search_filter][:romance].nil?\n cond = 19 if !params[:search_filter].nil? && params[:search_filter][:romance].nil?\n cond = 19 if params[:search_filter].nil?\n else\n cond = 0\n end\n \n ## Month validation as it should not be greater than 12.\n if !params[:search_filter].nil? && ( !params[:search_filter][:start_time].nil? || !params[:search_filter][:end_time].nil?) \n if params[:search_filter][:start_time] && params[:search_filter][:start_time] != \"MM/DD/YYYY\"\n s = params[:search_filter][:start_time].split('/')\n if s[0].to_i > 12\n params[:search_filter][:start_time] = Time.now.utc\n end\n end\n \n if params[:search_filter][:end_time] && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n s = params[:search_filter][:end_time].split('/')\n if s[0].to_i > 12\n params[:search_filter][:end_time] = Time.now.utc\n end\n end\n end\n \n ## Condition for getting activity id range.\n if !params[:search_filter].nil? && !params[:search_filter][:purpose_id].blank? \n p_id = params[:search_filter][:purpose_id].to_i\n elsif !params[:search_filter].nil? && params[:search_filter][:purpose_id].blank?\n p_id = 1..21\n end \n \n ## Condition for getting purpose id range.\n if !params[:search_filter].nil? && !params[:search_filter][:activity_id].blank? \n a_id = params[:search_filter][:activity_id].to_i\n elsif !params[:search_filter].nil? && params[:search_filter][:activity_id].blank?\n a_id = 1..14\n end \n \n ## Condition for getting zip codes in the given radius.\n if params[:checked_locat] == \"1\"\n if params[:search_filter][:city] == \"Atlanta\" or params[:search_filter][:city] == \"atlanta\" or params[:search_filter][:city] == \"ATLANTA\"\n st = \"GA\"\n elsif params[:search_filter][:city] == \"Boulder\" or params[:search_filter][:city] == \"boulder\" or params[:search_filter][:city] == \"BOULDER\"\n st = \"CO\"\n elsif params[:search_filter][:city] == \"San Diego\" or params[:search_filter][:city] == \"san diego\" or params[:search_filter][:city] == \"SAN DIEGO\"\n st = \"CA\"\n elsif params[:search_filter][:city] == \"Dallas\" or params[:search_filter][:city] == \"dallas\" or params[:search_filter][:city] == \"DALLAS\"\n st = \"TX\"\n elsif params[:search_filter][:city] == \"Houston\" or params[:search_filter][:city] == \"houston\" or params[:search_filter][:city] == \"HOUSTON\"\n st = \"TX\"\n elsif params[:search_filter][:city] == \"Miami\" or params[:search_filter][:city] == \"miami\" or params[:search_filter][:city] == \"MIAMI\"\n st = \"FL\"\n elsif params[:search_filter][:city] == \"San Francisco\" or params[:search_filter][:city] == \"san francisco\" or params[:search_filter][:city] == \"SAN FRANCISCO\"\n st = \"CA\"\n elsif params[:search_filter][:city] == \"Portland\" or params[:search_filter][:city] == \"portland\" or params[:search_filter][:city] == \"PORTLAND\"\n st = \"OR\"\n elsif params[:search_filter][:city] == \"San Jose\" or params[:search_filter][:city] == \"san jose\" or params[:search_filter][:city] == \"SAN JOSE\"\n st = \"CA\"\n end\n \n if !params[:search_filter].nil? && (!params[:search_filter][:zip].blank? || !params[:search_filter][:city].blank?)\n if st != \"\"\n r = ZipCode.find(:first,:select => \"latitude,longitude\",:conditions => [\"zip = ? or (city = '#{params[:search_filter][:city]}' and state = '#{st}')\",params[:search_filter][:zip]])\n else\n r = ZipCode.find(:first,:select => \"latitude,longitude\",:conditions => [\"zip = ? or city = ?\",params[:search_filter][:zip],params[:search_filter][:city]])\n end\n rad = params[:search_filter][:radius].to_i\n if !r.nil?\n sql = \"SELECT dest.id,dest.zip,3956 * 2 * ASIN(SQRT( POWER(SIN((orig.latitude - dest.latitude) * pi()/180 / 2), 2) + COS(orig.latitude * pi()/180) * COS(dest.latitude * pi()/180) * POWER(SIN((orig.longitude -dest.longitude) * pi()/180 / 2), 2) )) as distance FROM zip_codes dest, zip_codes orig WHERE dest.id = orig.id and dest.longitude between #{r.longitude}-#{rad}/abs(cos(radians(#{r.latitude}))*69) and #{r.longitude}+#{rad}/abs(cos(radians(#{r.latitude}))*69) and dest.latitude between #{r.latitude}-(#{rad}/69) and #{r.latitude}+(#{rad}/69) LIMIT 4096\"\n z = ZipCode.find_by_sql(sql)\n zcids = z.collect(&:id)\n end\n else\n zcids = \"\"\n end\n end\n \n zcids = \"\" if r.nil?\n \n params[:search_filter] ||= params[\"amp;search_filter\"] # Hack to stop a malformed feed url from causing an exception - dave\n if params[:search_filter].nil?\n @search_filter = SearchFilter.new\n else\n @search_filter = SearchFilter.new(params[:search_filter])\n end\n \n if !params[:search_filter].nil?\n if params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @search_filter.start_time = Time.now.utc\n elsif params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @search_filter.start_time = params[:search_filter][:start_time].to_date.to_time\n elsif params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n @search_filter.start_time = params[:search_filter][:end_time].to_date.to_time\n @search_filter.end_time = nil\n elsif params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n if params[:search_filter][:start_time].nil? && !params[:search_filter][:start_date].nil?\n params[:search_filter][:start_time] = params[:search_filter][:start_date]\n end\n @search_filter.start_time = params[:search_filter][:start_time].to_date.to_time if !params[:format] && !params[:search_filter][:start_time].nil?\n @search_filter.start_time = Time.now.utc if !params[:format] && params[:search_filter][:start_time].nil?\n @search_filter.end_time = params[:search_filter][:end_time].to_date.to_time if !params[:search_filter][:end_time].nil? \n end\n end\n \n if !params[:search_filter].nil?\n location = params[:search_filter][:location] ? params[:search_filter][:location] : ''\n terms = params[:search_filter][:terms] ? params[:search_filter][:terms] : ''\n person = params[:search_filter][:person] ? params[:search_filter][:person] : ''\n state = params[:search_filter][:state] ? params[:search_filter][:state] : ''\n country = params[:search_filter][:country] ? params[:search_filter][:country] : ''\n airport_id = params[:search_filter][:airport_id] ? params[:search_filter][:airport_id] : ''\n param_string = \"posted #{country} #{state} #{location} #{terms} #{person} #{airport_id}\" if !private_mw?\n param_string = \"posted #{state} #{location} #{terms} #{person} #{airport_id}\" if private_mw?\n if params[:search_filter][:virtual_f] == \"0\" && params[:checked_locat] == \"1\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:virtual_f => \"no_flag\",:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:start_time].to_date.to_time.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:virtual_f => \"no_flag\",:university_name => @univ_account}, :order => :id, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:virtual_f => \"no_flag\",:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:end_time].to_date.to_time,:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:virtual_f => \"no_flag\",:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n elsif params[:search_filter][:virtual_f] == \"v_flag\" && (params[:checked_locat] == \"0\" || params[:checked_locat] == \"\")\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id},:conditions => {:virtual_f => \"v_flag\",:university_name => @univ_account}, :without => {:purpose_id => cond}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 \n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:start_time].to_date.to_time.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id}, :without => {:purpose_id => cond},:conditions => {:virtual_f => \"v_flag\",:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id},:conditions => {:virtual_f => \"v_flag\",:university_name => @univ_account}, :without => {:purpose_id => cond}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:end_time].to_date.to_time,:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id}, :without => {:purpose_id => cond},:conditions => {:virtual_f => \"v_flag\",:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n else\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :id, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:start_time].to_date.to_time.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:end_time].to_date.to_time,:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\" && !params[:search_filter][:start_time].nil? && !params[:search_filter][:end_time].nil? && !params[:format]\n\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:start_time].to_date.to_time.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\" && !params[:search_filter][:start_time].nil? && params[:search_filter][:end_time].nil? && !params[:format]\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:start_time].to_date.to_time.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\" && !params[:search_filter][:start_time].nil? && params[:search_filter][:end_time].nil? && !params[:format]\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_date].to_date.to_time..params[:search_filter][:start_date].to_date.to_time,:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\" && params[:format]\n end\n else\n @search_filter.start_time = Time.now.utc\n @invitations = Invitation.search \"posted\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 \n end\n @feed_params = @search_filter.to_rss_params \n if params[:format]\n handle_rss()\n else\n render :action => \"new_super_search\", :layout => 'new_super_search' unless check_render_facebook('super_search')\n end\n end", "def add_filters\n add_term_filters\n add_terms_filters\n add_range_filters\n end", "def filter_prepare(current_filter = @filter, subfilter = @subfilter)\n verified_filter = @filters.assoc(current_filter) ? current_filter : @filters.first[0]\n subfilter ||= {}\n the_filter = @filters.assoc(verified_filter)[1]\n # I had to do this in this kind of funny way to avoid actually modifying @filters.\n find_conditions = the_filter.has_key?(:conditions) ? the_filter[:conditions].dup : ['1']\n find_include = []\n # find_conditions += filter[:conditions] if filter.has_key?(:conditions)\n find_include += the_filter[:include] if the_filter.has_key?(:include)\n # If no subfilters have been checked, this should be skipped, accept all\n # If some subfilters have been checked, only the checked ones will be traversed.\n # Within a single key, two checks yields OR\n # Across keys, two checks yield AND\n # The idea is that the subfilter conditions will read \"field in (?)\"\n # And then the keys will provide the array of options\n subfilter.each do |key, sf|\n fsf = the_filter[:subfilters].assoc(key)[1].dup\n find_conditions[0] += (' and ' + fsf[:conditions])\n find_conditions << sf.keys\n find_include << fsf[:include] if fsf.has_key?(:include)\n end\n total_records = scoped_model.count(:all, :include => find_include, :conditions => find_conditions)\n # puts \"%%%%% FILTER INFO IN FILTER_PREPARE: include:[#{find_include.inspect}], conditions:[#{find_conditions.inspect}].\"\n return[verified_filter, subfilter, find_include, find_conditions, total_records]\n end", "def initialize_available_filters_with_ayty_custom_columns\n\n principals = []\n subprojects = []\n versions = []\n categories = []\n issue_custom_fields = []\n\n if project\n principals += project.principals.visible\n unless project.leaf?\n subprojects = project.descendants.visible.to_a\n principals += Principal.member_of(subprojects).visible\n end\n versions = project.shared_versions.to_a\n categories = project.issue_categories.to_a\n issue_custom_fields = project.all_issue_custom_fields\n else\n if all_projects.any?\n principals += Principal.member_of(all_projects).visible\n end\n versions = Version.visible.where(:sharing => 'system').to_a\n issue_custom_fields = IssueCustomField.where(:is_for_all => true)\n end\n principals.uniq!\n principals.sort!\n principals.reject! {|p| p.is_a?(GroupBuiltin)}\n users = principals.select {|p| p.is_a?(User)}\n\n add_available_filter \"status_id\",\n :type => :list_status, :values => IssueStatus.sorted.collect{|s| [s.name, s.id.to_s] }\n\n if project.nil?\n project_values = []\n if User.current.logged? && User.current.memberships.any?\n project_values << [\"<< #{l(:label_my_projects).downcase} >>\", \"mine\"]\n end\n project_values += all_projects_values\n add_available_filter(\"project_id\",\n :type => :list, :values => project_values\n ) unless project_values.empty?\n end\n\n add_available_filter \"tracker_id\",\n :type => :list, :values => trackers.collect{|s| [s.name, s.id.to_s] }\n add_available_filter \"priority_id\",\n :type => :list, :values => IssuePriority.all.collect{|s| [s.name, s.id.to_s] }\n\n author_values = []\n author_values << [\"<< #{l(:label_me)} >>\", \"me\"] if User.current.logged?\n author_values += users.collect{|s| [s.name, s.id.to_s] }\n add_available_filter(\"author_id\",\n :type => :list, :values => author_values\n ) unless author_values.empty?\n\n assigned_to_values = []\n assigned_to_values << [\"<< #{l(:label_me)} >>\", \"me\"] if User.current.logged?\n assigned_to_values += (Setting.issue_group_assignment? ?\n principals : users).collect{|s| [s.name, s.id.to_s] }\n add_available_filter(\"assigned_to_id\",\n :type => :list_optional, :values => assigned_to_values\n ) unless assigned_to_values.empty?\n\n group_values = Group.givable.visible.collect {|g| [g.name, g.id.to_s] }\n add_available_filter(\"member_of_group\",\n :type => :list_optional, :values => group_values\n ) unless group_values.empty?\n\n role_values = Role.givable.collect {|r| [r.name, r.id.to_s] }\n add_available_filter(\"assigned_to_role\",\n :type => :list_optional, :values => role_values\n ) unless role_values.empty?\n\n add_available_filter \"fixed_version_id\",\n :type => :list_optional,\n :values => versions.sort.collect{|s| [\"#{s.project.name} - #{s.name}\", s.id.to_s] }\n\n add_available_filter \"category_id\",\n :type => :list_optional,\n :values => categories.collect{|s| [s.name, s.id.to_s] }\n\n add_available_filter \"subject\", :type => :text\n add_available_filter \"description\", :type => :text\n add_available_filter \"created_on\", :type => :date_past\n add_available_filter \"updated_on\", :type => :date_past\n add_available_filter \"closed_on\", :type => :date_past\n add_available_filter \"start_date\", :type => :date\n add_available_filter \"due_date\", :type => :date\n add_available_filter \"estimated_hours\", :type => :float\n add_available_filter \"done_ratio\", :type => :integer\n\n if User.current.allowed_to?(:set_issues_private, nil, :global => true) ||\n User.current.allowed_to?(:set_own_issues_private, nil, :global => true)\n add_available_filter \"is_private\",\n :type => :list,\n :values => [[l(:general_text_yes), \"1\"], [l(:general_text_no), \"0\"]]\n end\n\n if User.current.logged?\n add_available_filter \"watcher_id\",\n :type => :list, :values => [[\"<< #{l(:label_me)} >>\", \"me\"]]\n end\n\n if subprojects.any?\n add_available_filter \"subproject_id\",\n :type => :list_subprojects,\n :values => subprojects.collect{|s| [s.name, s.id.to_s] }\n end\n\n add_custom_fields_filters(issue_custom_fields.ayty_filter_access_level(User.current))\n\n add_associations_custom_fields_filters :project, :author, :assigned_to, :fixed_version\n\n IssueRelation::TYPES.each do |relation_type, options|\n add_available_filter relation_type, :type => :relation, :label => options[:name]\n end\n add_available_filter \"parent_id\", :type => :tree, :label => :field_parent_issue\n add_available_filter \"child_id\", :type => :tree, :label => :label_subtask_plural\n\n Tracker.disabled_core_fields(trackers).each {|field|\n delete_available_filter field\n }\n\n # deleta filtros\n delete_available_filter \"priority_id\"\n delete_available_filter \"due_date\"\n delete_available_filter \"fixed_version_id\"\n\n versions_open = []\n\n if project\n versions_open = project.shared_versions.to_a\n else\n #versions = Version.visible.where(:sharing => 'system').to_a\n versions_open = Version.open.visible.where(:sharing => 'system').to_a\n end\n\n # caso o usuario nao seja ayty remove prioridade\n #add_available_filter \"priority_id\",\n # :type => :list, :values => IssuePriority.all.collect{|s| [s.name, s.id.to_s] }\n add_available_filter \"priority_id\",\n :type => :list, :values => IssuePriority.all.collect{|s| [s.name, s.id.to_s] } if User.current.ayty_is_user_ayty?\n\n # caso o usuario nao seja ayty remove data prevista\n #add_available_filter \"due_date\", :type => :date\n add_available_filter \"due_date\", :type => :date if User.current.ayty_is_user_ayty?\n\n if versions_open.any?\n add_available_filter \"fixed_version_id\",\n :type => :list_optional,\n :values => versions_open.sort.collect{|s| [\"#{s.project.name} - #{s.name}\", s.id.to_s] }\n end\n\n # pega somente usuarios ayty\n ayty_users = []\n ayty_users << [\"<< #{l(:label_me)} >>\", User.current.id] if User.current.logged?\n # projeto especifico\n if project\n ayty_users += project.ayty_assignable_users(true).collect{|s| [s.name, s.id.to_s] }\n else\n # todos projetos\n if all_projects.any?\n ayty_users += Principal.joins(:ayty_access_level).where(:ayty_access_levels => {:ayty_access => true}).member_of(all_projects).visible.collect{|s| [s.name, s.id.to_s] }\n end\n end\n ayty_users.uniq!\n ayty_users.sort!\n\n # inclui filtros\n add_available_filter(\"assigned_to_bd_id\",\n :type => :list_optional, :values => ayty_users\n ) unless ayty_users.empty?\n\n add_available_filter(\"assigned_to_net_id\",\n :type => :list_optional, :values => ayty_users\n ) unless ayty_users.empty?\n\n add_available_filter(\"assigned_to_test_id\",\n :type => :list_optional, :values => ayty_users\n ) unless ayty_users.empty?\n\n add_available_filter(\"assigned_to_aneg_id\",\n :type => :list_optional, :values => ayty_users\n ) unless ayty_users.empty?\n\n add_available_filter(\"assigned_to_areq_id\",\n :type => :list_optional, :values => ayty_users\n ) unless ayty_users.empty?\n\n add_available_filter(\"assigned_to_inf_id\",\n :type => :list_optional, :values => ayty_users\n ) unless ayty_users.empty?\n\n end", "def index\n render_collection filter_reports(filter_params), status: :ok\n end", "def index\n render_collection filter_reports(filter_params), status: :ok\n end", "def filtered_single_interview\n @user_company = JointUserCompany.find_by(user_id: @user.id, company_id: @company.id)\n @user_status = @user_company.status\n @submissions = @interview.submissions.where(current_no: 500, status: params[:status].to_i).paginate(:page => params[:page], :per_page => 24).order('created_at DESC')\n @meg = params[:status].to_i\n if (@meg == 0 )\n @peg = \"Shortlist\"\n @prefiled_mes = \"In response to the Interview you took with our company, we glad to inform you have been shorlisted\"\n elsif(@meg == 2)\n @peg = \"Reject\"\n @prefiled_mes = \"Thank you for taking interview with us.\n However, you did not make the final list\n We wish you best in future endeavors\"\n end\n render :action => 'single_interview_submissions', :layout => 'single_interview_submissions'\nend", "def run_filters\n status = :no_match\n matching_filters = [] \n DataFileFilter.active.each do |filter|\n case filter.match(self)\n when :positive_match\n status = :accepted if status == :no_match\n matching_filters << filter\n when :negative_match\n status = :rejected\n matching_filters << filter\n when :no_match\n next\n end\n end\n return [status,matching_filters]\n end", "def global_filter; end", "def uhook_filtered_search filters = {}\n create_scopes(filters) do |filter, value|\n case filter\n when :locale\n {:conditions => {:locale => value}}\n end\n end\n end", "def init_contract_filters\n\t \n\t statusable = Category.statusable\n\t if statusable.length == 0\n\t @conditions << \"(true = false)\"\n\t else\n\t @conditions << \"(category_id in (#{Category.statusable.collect{|c|c.id}.join(',')}))\"\n end\n\tend", "def filter(params)\n\n\t self.log << \"Started filtering cases\"\n\n\t\[email protected] do |adrc_case|\n\n\t\t self.log << {:message => \"packing #{adrc_case[:subject_id]}\"}\n\t\t vgroup = Vgroup.joins(\"LEFT JOIN enrollment_vgroup_memberships ON vgroups.id = enrollment_vgroup_memberships.vgroup_id\")\n\t\t \t\t\t\t.joins(\"LEFT JOIN scan_procedures_vgroups ON scan_procedures_vgroups.vgroup_id = vgroups.id\")\n\t\t \t\t\t\t.where(\"enrollment_vgroup_memberships.enrollment_id = ?\",Enrollment.where(:enumber => adrc_case[:enumber]).first.id)\n\t\t \t\t\t\t.where(\"scan_procedures_vgroups.scan_procedure_id = ?\",adrc_case[:scan_procedure].id)\n\t\t \t\t\t\t.first\n\n\n\t\t #does this vgroup have the right image datasets?\n\t\t visits = Visit.where(:appointment_id => vgroup.appointments.select{|item| item.appointment_type == 'mri'}.map(&:id))\n\t\t images = Jobs::NaccUpload::ImageDataset.where(:visit_id => visits.map(&:id)).select{|item| (@sdm_filter.map{|x| x.series_description.downcase}.include? item.series_description.downcase) and (item.series_description != 'DTI whole brain 2mm FATSAT ASSET')}\n\t\t ppt = vgroup.enrollments.first.participant\n\n\t # if we only have 2 different scan types, or the status flag for this case is 'R', fail the case\n\t series_description_counts = images.each_with_object(Hash.new(0)){|item,hash| hash[@sdm_filter.select{|sdm| sdm.series_description.downcase == item.series_description.downcase}.first.series_description_type_id] += 1}\n\t if series_description_counts.keys.count < 2\n\t \tself.exclusions << {:protocol => adrc_case[:scan_procedure].codename, :subject => adrc_case[:enumber], :message => \"too few scan types\"}\n\t \tnext\n\t end\n\n\t if adrc_case[:status_flag] == 'R'\n\t \tself.exclusions << {:protocol => adrc_case[:scan_procedure].codename, :subject => adrc_case[:enumber], :message => \"status is 'R' for this case\"}\n\t \tnext\n\t end\n\n\t #this case passes, so let's set it up for prep\n\n\t\t adrc_case[:case_dir] = \"#{adrc_case[:subject_id]}_#{vgroup.vgroup_date.strftime(\"%Y%m%d\")}_wisc\"\n\t\t adrc_case[:subject_dir] = \"#{params[:target_dir]}/#{adrc_case[:case_dir]}\"\n\t\t adrc_case[:participant] = ppt\n\n\t\t if !File.directory?(adrc_case[:subject_dir])\n\t\t Dir.mkdir(adrc_case[:subject_dir])\n\t\t end\n\n\t\t subject_subdirs = []\n\t adrc_case[:images] = []\n\n\t\t images.each do |image|\n\n\t\t \t#check that there's nothing rated \"severe\" or \"incomplete\" on the IQC checks for this image\n\t\t \tif image.passed_iqc?\n\n\t\t\t \tpath_parts = image.path.split(\"/\")\n\t\t\t \timage_target_dir = \"#{adrc_case[:subject_dir]}/#{path_parts.last}\"\n\n\t\t\t \tif subject_subdirs.include? image_target_dir\n\t\t\t \t\t#tack something on the end so that we don't overwrite\n\t\t\t \t\timage_target_dir = \"#{image_target_dir}_#{subject_subdirs.count}}\"\n\t\t\t \tend\n\n\t\t\t \tsubject_subdirs << image_target_dir\n\t\t \t\tadrc_case[:images] << {:path => File.realpath(image.path), :target_dir => image_target_dir}\n\t\t \tend\n\t\t end\n\n\t\t @driver << adrc_case\n\n\t\tend\n\n\t\tself.log << \"Filtering cases complete (#{@driver.count} new cases, #{self.exclusions.count} exclusions from processing)\"\n\tend", "def filter\n filter_type = params[:filter][:type]\n case filter_type\n when \"last_seven\", \"weekly\"\n @filter = \"Weekly\"\n @filtered_runs = current_user.runs.in_the_last_week\n when \"last_thirty\", \"monthly\"\n @filter = \"Monthly\"\n @filtered_runs = current_user.runs.in_the_last_thirty_days\n when \"year\", \"yearly\"\n @filter = \"Yearly\"\n @filtered_runs = current_user.runs.in_the_last_year\n when \"lifetime\"\n @filter = \"Lifetime\"\n @filtered_runs = current_user.runs.most_recent_by_date\n end\n\n respond_to do |format|\n format.js\n end\n\n end", "def add_filter\n @filter = true \n end", "def filter\n end", "def apply_filter(rel)\n if filter.present?\n Response.do_search(rel, filter, :mission => mission)\n else\n rel\n end\n end", "def apply_filtering(collection)\n @filters = Question.get_advanced_filter_collection(collection,true,'click')\n Question.filtering_scopes.each do |scope|\n collection = collection.filter_by(scope, filter_params[scope], \"email\") unless filter_params[scope].blank?\n end\n return collection\n end", "def index \n\n ...\r\n \r\n #add/remove any selected filters\n selected_filter_conditions(Widget)\n\n @widgets = Widget.find(:all,{}, {:conditions => @conditions, :include => @included}) \n \n # This can be combined with any named scopes eg \n # @widgets = Widget.active.popular.find(:all,{}, {:conditions => @conditions, :include => @included}) \n\r\n \n #generate filters for results\n filter_headings(Widget, @widgets)\n\n ...\n\r\n end\n\n\n....\n\n\nend", "def filters=(_arg0); end", "def filters=(_arg0); end", "def _filter_display\n @apotomo_emit_raw_view = true\n render :view => '_filters'\n end", "def exclude_draft_and_approved solr_parameters, user_parameters\n solr_parameters[:fq] ||= []\n (Sufia.config.workflow_status - Sufia.config.review_dashboard_status).each do |s|\n solr_parameters[:fq] << '-'+Solrizer.solr_name(\"MediatedSubmission_status\", :symbol)+':'+s\n end\n end", "def extra_search_actions(items, extra_filters = [], kind = nil)\n (extra_filters || []).each do |filter|\n case filter\n when 'my_country'\n case kind || params[:type]\n when 'people', 'counselors'\n items = items.where(country: current_user.country)\n when 'churches', 'groups'\n items = items.joins(:user).where(users:{ country: current_user.country })\n when 'contents'\n items = items.joins(:user).where(users:{ country: current_user.country })\n when 'events'\n items = items.joins('inner join user_groups on user_groups.id = events.eventable_id and events.eventable_type = \\'UserGroup\\' inner join users on users.id = user_groups.user_id').where('users.country = ?', current_user.country)\n \n # TODO\n end\n when 'my_groups'\n case kind || params[:type]\n when 'people', 'counselors'\n items = items.joins(:user_groups).where(user_groups: {id: current_user.user_groups.pluck(:id)})\n when 'churches', 'groups'\n items = items.where(id: current_user.user_groups.select(:id))\n when 'contents'\n items = items.where(user_id: current_user.user_groups_members.select(:id))\n when 'events'\n items = items.where(id: current_user.user_groups_events.select(:id))\n end\n end\n end\n items\n end", "def set_case_filters(status_array = nil)\n if status_array.nil?\n status = Array.new\n AppConstants::CASE_SORT_ORDER.each do |s|\n if retrieve_case(s).viewable == true\n status << s\n end\n end\n return status\n else\n status_array.each do |status|\n retrieve_case(status).update_attribute(:viewable, true)\n end\n (AppConstants::CASE_SORT_ORDER - status_array).each do |status|\n retrieve_case(status).update_attribute(:viewable, false)\n end\n return status_array\n end\n end", "def add_range_filters\n %i(word_count hit_count kudos_count comments_count bookmarks_count revised_at).each do |countable|\n next unless options[countable]\n range = Search::RangeParser.string_to_range(options[countable])\n body.filter(:range, countable => range) unless range.blank?\n end\n add_date_range_filter\n add_word_count_filter\n end", "def index\n @selected_filters = Hash.new\n @events = Event.all\n if params[:filter]\n if params[:filter][:my]\n @events = @events.user_events current_user\n @selected_filters[:my] = 1\n end\n if params[:filter][:all]\n @selected_filters[:all] = 1 \n else\n @selected_filters[:recent] = 1 \n @events = @events.after\n end \n else\n @events = @events.after\n end\n end", "def process_inv_status_response(raw_data)\n results = []\n raw_data.map do |inv_status|\n\n begin\n mapped = response_mapper(inv_status, {\n 'Inv_Status.Warehouse' => 'warehouse',\n 'Inv_Status.ProdCode' => 'sku',\n 'Inv_Status.Available' => 'quantity',\n })\n\n if (mapped['warehouse'] === 'Main Warehouse')\n results << mapped\n end\n rescue => error\n issue_error(AcumenAgentError.new(\n 'process_inv_status_response',\n 'Failed while processing Prod_Mkt record',\n { sku: get_field_value(inv_status, 'Inv_Status.ProdCode') },\n error,\n ))\n end\n end\n\n results\n end", "def pre_filter\n @records = records\n .select {|event| event[:lang] != \"en\" }\n .select {|event| event[:reply_to].nil? }\n .select {|event| event[:text] =~ /^[0-9]{4}/ }\n end", "def list_filters\n {\n track_end_date: 'TrkEndDate gt VALUE',\n track_first_submitted: 'TrkFirstSubmitted gt VALUE',\n app_no: 'AppNo eq VALUE',\n first_name: 'AppFirstName eq VALUE',\n last_name: 'AppLastName eq VALUE',\n email: 'AppEmailAddress eq VALUE'\n }\n end", "def assign_filters\n if self.location_id && self.location.filter_list\n\t\t\tvalues = self.location.filter_list.split(',').map { |f| \"(#{f},#{self.id})\" }.join(',')\n self.connection.execute(\"INSERT DELAYED INTO report_filters (filter_id,report_id) VALUES #{values}\") if !values.blank?\n\t\tend\n\t\ttrue\n end", "def assign_filters\n if self.location_id && self.location.filter_list\n\t\t\tvalues = self.location.filter_list.split(',').map { |f| \"(#{f},#{self.id})\" }.join(',')\n self.connection.execute(\"INSERT DELAYED INTO report_filters (filter_id,report_id) VALUES #{values}\") if !values.blank?\n\t\tend\n\t\ttrue\n end", "def filter_proc(filters = {})\n lambda do |p|\n (filters[:name].nil? || p.name =~ filters[:name]) &&\n (filters[:appid_name].nil? || p.app_id_name =~ filters[:appid_name]) &&\n (filters[:appid].nil? || p.entitlements.app_id =~ filters[:appid]) &&\n (filters[:uuid].nil? || p.uuid =~ filters[:uuid]) &&\n (filters[:team].nil? || p.team_name =~ filters[:team] || p.team_ids.any? { |id| id =~ filters[:team] }) &&\n (filters[:exp].nil? || (p.expiration_date < DateTime.now) == filters[:exp]) &&\n (filters[:has_devices].nil? || !(p.provisioned_devices || []).empty? == filters[:has_devices]) &&\n (filters[:all_devices].nil? || p.provisions_all_devices == filters[:all_devices]) &&\n (filters[:aps_env].nil? || match_aps_env(p.entitlements.aps_environment, filters[:aps_env])) &&\n true\n end\n end", "def pipeline\n if params[:purchase_channel] && params[:status]\n @orders = Order.where([\"purchase_channel = ? AND status = ?\", params[:purchase_channel].downcase, params[:status].downcase])\n @orders = @orders.page(params[:page] || 1).per(params[:per_page] || 10)\n render json: @orders, status: :ok\n else\n render json: {error: \"bad parameters\"}, status: :bad_request\n return\n end\n end", "def set_flds\n self.status = 'active' if status.blank?\n self.status = 'scheduled' if has_appt? && !is_completed?\n self.status = 'completed' if is_completed?\n end", "def apply_filters(results:)\n return results unless filter_params.present?\n\n if filter_params[:organization_id].present? && !filter_params[:funder_id].present?\n return DataManagementPlan.find_by_organization(\n organization_id: filter_params[:organization_id]\n )\n end\n\n if filter_params[:funder_id].present? && !filter_params[:organization_id].present?\n return DataManagementPlan.find_by_funder(\n organization_id: filter_params[:funder_id]\n )\n end\n\n DataManagementPlan.find_by_organization(organization_id: filter_params[:organization_id])\n .find_by_funder(organization_id: filter_params[:funder_id])\n end", "def test_filter_creation\n md_report = @twitter_reporter.reports.create(:body => 'here in #21108')\n assert_equal 5, (md_report.filters & %w(annapolis baltimore maryland northamerica unitedstates).map { |c| Filter.find_by_name(c) }).size\n ca_report = @twitter_reporter.reports.create(:body => 'all is well in 94107')\n assert_equal 4, (ca_report.filters & %w(sanfrancisco california northamerica unitedstates).map { |c| Filter.find_by_name(c) }).size\n end", "def filter\n conditions = [\"isEstimate = ?\"]\n values = [ 0 ]\n if(params[:filter])\n session[:filter] = params[:filter]\n end\n if(session[:filter])\n if(session[:filter][:date_max])\n conditions << \"moment <= ?\"\n values << session[:filter][:date_max]\n end\n if(session[:filter][:date_min])\n conditions << \"moment >= ?\"\n values << session[:filter][:date_min]\n end\n if(session[:filter][:name] && session[:filter][:name] != \"\") \n conditions << \"name LIKE ?\"\n values << \"%\" + session[:filter][:name] + \"%\"\n end\n end\n conditions = values.insert(0, conditions.join(\" AND \"))\n\n \n session[:event_results] = getResults(conditions, params[:event_page])\n conditions[1] = 1\n session[:estimate_results] = getResults(conditions, params[:estimate_page])\n \n session[:event_time] = Time.now.to_f\n #raise session[:event_time].to_s + \" \" + Event.last_update.to_s\n end", "def filter_by_status(bookings)\n return bookings if params[:status].blank?\n\n bookings.filter_by_status(params[:status])\n end", "def index\n @runs = policy_scope(Run)\n filtering_service = FilterRunsService.new from: params[:from], to: params[:to], runs: @runs\n\n # making a readable description to user filter\n @desc = filtering_service.description\n @runs = filtering_service.filter \n end", "def index\n @filter_name_val =''\n @filter_notes_val =''\n @filter_is_paid = ''\n @button_search_text=''\n @button_search_data=''\n\n\n @filter_is_paid = params[:filter_is_paid] if params[:filter_is_paid].present?\n @filter_name_val =params[:filter_name] if params[:filter_name].present?\n @filter_notes_val =params[:filter_notes] if params[:filter_notes].present?\n if params[:commit].present?\n @display = ''\n @button_search_text='Hide Search'\n @button_search_data='open'\n else\n @display = 'display: none;'\n @button_search_text='Show Search'\n @button_search_data='close'\n end\n\n @programs = Program\n @programs [email protected](\"name ilike '%#{params[:filter_name]}%'\") if params[:filter_name].present?\n @programs [email protected](\"notes ilike '%#{params[:filter_notes]}%'\") if params[:filter_notes].present?\n if @filter_is_paid!='' && params[:filter_is_paid].present?\n @programs [email protected](\"COALESCE(is_paid,0) =#{@filter_is_paid}\",)\n end\n @programs = @programs.paginate(:page => params[:page]).order(:id).all()\n\n @statuses = [{\"name\"=>\"All\", \"id\"=>\"\"}, {\"name\"=>\"Yes\", \"id\"=>\"1\"}, {\"name\"=>\"No\", \"id\"=>\"0\"}]\n\n end", "def get_filter_conditions(filters, applied_filters)\n return {} if applied_filters.empty?\n filter_conditions = {}\n applied_filters.each do |applied_filter_key, applied_filter_values|\n applied_filter_details = array_item_by_key_value(filters, :name, applied_filter_key)\n case applied_filter_details[:es_type]\n when 'keyword'\n filter_conditions[applied_filter_details[:name]] = { terms: { applied_filter_details[:options][:field] => applied_filter_values } }\n when 'bool'\n filter_conditions[applied_filter_details[:name]] = { term: { applied_filter_details[:options][:field] => applied_filter_values } }\n when 'integer'\n if applied_filter_details[:options][:field].is_a? Array\n filter_conditions[applied_filter_details[:options][:field][0]] = { range: { applied_filter_details[:options][:field][0] => { gte: applied_filter_values[0] } } }\n filter_conditions[applied_filter_details[:options][:field][1]] = { range: { applied_filter_details[:options][:field][1] => { lte: applied_filter_values[1] } } }\n else\n filter_conditions[applied_filter_details[:name]] = { range: { applied_filter_details[:name] => { gte: applied_filter_values[0], lte: applied_filter_values[1] } } }\n end\n when 'datetime'\n min = Time.parse(\"#{Time.parse(applied_filter_values[0]).strftime('%Y/%m/%d %H:%M:%S')} #{\"UTC\"}\").utc.strftime('%Y%m%dT%H%M%S%z')\n max = Time.parse(\"#{Time.parse(applied_filter_values[1]).strftime('%Y/%m/%d %H:%M:%S')} #{\"UTC\"}\").utc.strftime('%Y%m%dT%H%M%S%z')\n filter_conditions[applied_filter_details[:name]] = { range: { applied_filter_details[:name] => { gte: min, lte: max } } }\n end\n end\n filter_conditions\n end", "def current_status\n\t\t@workflows = WorkFlow.where(is_active: true, is_in_use: false)\n\t\t@report_include_canceled = session[:report_include_canceled]\n \t@report_include_completed = session[:report_include_completed]\n\t \n\t if session[:report_wildcard].present?\n\t @wildcard = session[:report_wildcard]\n\t end\n\t if session[:report_exact].present?\n\t @exact = session[:report_exact]\n\t end\n\t if request.post? or session[:report_q_string].present?\n\t \tq_string = ''\n \t\t\tif request.post?\n \t\t\t\tsession[:params_search] = params \n\t\t\t if params[:report_include_canceled].presence\n\t\t\t @report_include_canceled = params[:report_include_canceled]\n\t\t\t session[:report_include_canceled] = @report_include_canceled\n\t\t\t else\n\t\t\t session.delete(:report_include_canceled)\n\t\t\t end\n\t\t\t if params[:report_include_completed].presence\n\t\t\t @report_include_completed = params[:report_include_completed]\n\t\t\t session[:report_include_completed] = @report_include_completed\n\t\t\t else\n\t\t\t session.delete(:report_include_completed)\n\t\t\t end\n\n \t\t\t\t@serach_result = search[0]\n \t\t\t\tq_string = search[1]\n \t\t\telse\n \t\t\t \tq_string = session[:report_q_string]\n \t\t\t \tif q_string != ''\n\t\t\t\t\tif @report_include_canceled == 'report_include_canceled' and @report_include_completed == 'report_include_completed'\n\t\t\t\t\t\t@serach_result = WorkFlow.search(q_string)\n\t\t\t\t\telsif @report_include_canceled == 'report_include_canceled'\n\t\t\t\t\t\t@serach_result = WorkFlow.search_exclude_complete(q_string)\n\t\t\t\t\telsif @report_include_completed == 'report_include_completed'\n\t\t\t\t\t\t@serach_result = WorkFlow.search_exclude_cancel(q_string)\n\t\t\t\t\telse\n\t\t\t\t\t\t@serach_result = WorkFlow.search_exclude_cancel_and_complete(q_string)\n\t\t\t\t\tend\n\t \t\t\tend\n \t\t\tend\n\n\t\t\tif q_string != ''\n\t\t if @report_include_canceled == 'report_include_canceled' and @report_include_completed == 'report_include_completed'\n\t\t\t\t@report_serach_result = WorkFlow.current_report_search(q_string)\n\t\t elsif @report_include_canceled == 'report_include_canceled'\n\t\t \t@report_serach_result = WorkFlow.current_report_search_exclude_complete(q_string)\n\t\t elsif @report_include_completed == 'report_include_completed'\n\t\t \t@report_serach_result = WorkFlow.current_report_search_exclude_cancel(q_string)\n\t\t else\n\t\t \t@report_serach_result = WorkFlow.current_report_search_exclude_cancel_and_complete(q_string)\n\t\t end\n\t\t\tend\n \t\tend\n\tend", "def prominence!\n @filters[:prominent].each do |filter|\n @query = Ydl::Videos.where(filter => @options[filter])\n return @query if @query.any?\n end\n end", "def filter_results(current_role, results, filter_data)\n if filter_data['annotationText'].present?\n results = results.joins(annotations: :annotation_text)\n .where('lower(annotation_texts.content) LIKE ?',\n \"%#{AnnotationText.sanitize_sql_like(filter_data['annotationText'].downcase)}%\")\n end\n if filter_data['section'].present?\n results = results.joins(grouping: :section).where('section.name': filter_data['section'])\n end\n if filter_data['markingState'].present?\n remark_results = results.where.not('results.remark_request_submitted_at': nil)\n .where('results.marking_state': Result::MARKING_STATES[:incomplete])\n released_results = results.where.not('results.id': remark_results).where('results.released_to_students': true)\n case filter_data['markingState']\n when 'remark_requested'\n results = remark_results\n when 'released'\n results = released_results\n when 'complete'\n results = results.where.not('results.id': released_results)\n .where('results.marking_state': Result::MARKING_STATES[:complete])\n when 'in_progress'\n results = results.where.not('results.id': remark_results).where.not('results.id': released_results)\n .where('results.marking_state': Result::MARKING_STATES[:incomplete])\n end\n end\n\n unless current_role.ta? || filter_data['tas'].blank?\n results = results.joins(grouping: { tas: :user }).where('user.user_name': filter_data['tas'])\n end\n if filter_data['tags'].present?\n results = results.joins(grouping: :tags).where('tags.name': filter_data['tags'])\n end\n unless filter_data.dig('totalMarkRange', 'max').blank? && filter_data.dig('totalMarkRange', 'min').blank?\n result_ids = results.ids\n total_marks_hash = Result.get_total_marks(result_ids)\n if filter_data.dig('totalMarkRange', 'max').present?\n total_marks_hash.select! { |_, value| value <= filter_data['totalMarkRange']['max'].to_f }\n end\n if filter_data.dig('totalMarkRange', 'min').present?\n total_marks_hash.select! { |_, value| value >= filter_data['totalMarkRange']['min'].to_f }\n end\n results = Result.where('results.id': total_marks_hash.keys)\n end\n unless filter_data.dig('totalExtraMarkRange', 'max').blank? && filter_data.dig('totalExtraMarkRange', 'min').blank?\n result_ids = results.ids\n total_marks_hash = Result.get_total_extra_marks(result_ids)\n if filter_data.dig('totalExtraMarkRange', 'max').present?\n total_marks_hash.select! do |_, value|\n value <= filter_data['totalExtraMarkRange']['max'].to_f\n end\n end\n if filter_data.dig('totalExtraMarkRange', 'min').present?\n total_marks_hash.select! do |_, value|\n value >= filter_data['totalExtraMarkRange']['min'].to_f\n end\n end\n results = Result.where('results.id': total_marks_hash.keys)\n end\n if filter_data['criteria'].present?\n results = results.joins(marks: :criterion)\n temp_results = Result.none\n num_criteria = 0\n filter_data['criteria'].each do |name, range|\n num_criteria += 1\n if range.present? && range['min'].present? && range['max'].present?\n temp_results = temp_results.or(results\n .where('criteria.name = ? AND marks.mark >= ? AND marks.mark <= ?',\n name, range['min'].to_f, range['max'].to_f))\n elsif range.present? && range['min'].present?\n temp_results = temp_results.or(results\n .where('criteria.name = ? AND marks.mark >= ?',\n name, range['min'].to_f))\n elsif range.present? && range['max'].present?\n temp_results = temp_results.or(results\n .where('criteria.name = ? AND marks.mark <= ?',\n name, range['max'].to_f))\n else\n temp_results = temp_results.or(results\n .where(criteria: { name: name }))\n end\n end\n results = temp_results.group(:id).having('count(results.id) >= ?', num_criteria)\n end\n results.joins(grouping: :group)\n end", "def update_filter\n @screen = session.active_screen\n field_report_filter_id = params[:id]\n \n if field_report_filter_id =~ /_/\n # Create\n @field_report_filter = FieldReportFilter.create(\n :reference_screen_index => params[:reference_screen_index],\n :field_id => params[:field_id],\n :report_id => params[:report_id],\n :value => params[:value])\n else\n @field_report_filter = FieldReportFilter.find(field_report_filter_id.to_i)\n \n if params.has_key?(:destroy)\n # Delete\n @field_report_filter.destroy\n else\n # Update\n @field_report_filter.value = params[:value]\n @field_report_filter.save\n end\n end\n @set_field_filters = {\n @field_report_filter.reference_screen_index => { @field_report_filter.field_id => @field_report_filter }\n }\n @available_field_filters = @field_report_filter.report.fields_for_filters\n\n respond_to do |format|\n format.html # edit_format.html.erb\n format.xml { render :xml => @field_report_filter }\n end\n end", "def filter_data\n case params[:filter][:info]\n when 'Public'\n @tag = Tag.find_by(tag: 'Public')\n when 'Basketball Courts'\n @tag = Tag.find_by(tag: 'Basketball Courts')\n when 'Book Store'\n @tag = Tag.find_by(tag: 'Book Store')\n end\n\n @joins = Tagtoilet.where('tag_id = ?', @tag.id)\n @toilets = @joins.map{|join| Toilet.find(join.toilet_id)}\n @toilets.to_json\n end", "def data_context_filter_1\r\n\r\n ckie = (RUBY_VERSION =~ /^1.8/) ? Iconv.new('UTF-8//IGNORE', 'latin1').iconv(cookies[:active_filters] || \"\") : (cookies[:active_filters] || \"\").force_encoding(Encoding::ISO_8859_1).encode!(Encoding::UTF_8)\r\n if !ckie.blank?\r\n find_hash = BgWorker.named_scope_active_filter_method(ActiveSupport::JSON.decode(ckie))\r\n conds = find_hash[:conditions]\r\n @joins_fields = find_hash[:joins]\r\n\r\n BgWorker.send(:with_scope, {:find => {:conditions => conds, :joins => (@joins_fields || [])}}) {\r\n yield\r\n }\r\n\r\n else\r\n yield\r\n end\r\n end", "def filters\n # Call model column on self (metadata since element in array is a string, not a variable hence we use send) <=> self.send(profile) == true\n %w[sight_seeing_adventurer art_lover serial_shopper nature_lover food_addict sport_lover history_passionate tech_fan relaxed city_wanderer].select! {|profile| send(profile) == true }\n end", "def applicable_filters\n fs = []\n products_searched = []\n\n if params[:search] \n if @products\n @products.each do |p|\n products_searched << p.id\n end\n end\n else\n products_searched = @taxon.products.all.pluck(:id)\n end\n\n fs << Spree::Core::ProductFilters.selective_filter('Quantity', :selective_quantity_any, products_searched) if Spree::Core::ProductFilters.respond_to?(:selective_filter)\n fs << Spree::Core::ProductFilters.selective_filter('Manufacturer', :selective_manufacturer_any, products_searched) if Spree::Core::ProductFilters.respond_to?(:selective_filter)\n fs << Spree::Core::ProductFilters.selective_filter('Use Type', :selective_use_type_any, products_searched) if Spree::Core::ProductFilters.respond_to?(:selective_filter)\n fs << Spree::Core::ProductFilters.selective_filter('Bullet Type', :selective_bullet_type_any, products_searched) if Spree::Core::ProductFilters.respond_to?(:selective_filter)\n fs << Spree::Core::ProductFilters.selective_filter('Bullet Weight', :selective_bullet_weight_any, products_searched) if Spree::Core::ProductFilters.respond_to?(:selective_filter)\n fs << Spree::Core::ProductFilters.selective_filter('Ammo Casing', :selective_ammo_casing_any, products_searched) if Spree::Core::ProductFilters.respond_to?(:selective_filter)\n fs << Spree::Core::ProductFilters.selective_filter('Ammo Caliber', :selective_ammo_caliber_any, products_searched) if Spree::Core::ProductFilters.respond_to?(:selective_filter)\n fs << Spree::Core::ProductFilters.selective_filter('Primer Type', :selective_primer_type_any, products_searched) if Spree::Core::ProductFilters.respond_to?(:selective_filter)\n fs << Spree::Core::ProductFilters.selective_filter('Condition', :selective_condition_any, products_searched) if Spree::Core::ProductFilters.respond_to?(:selective_filter)\n fs << Spree::Core::ProductFilters.price_filter(products_searched) if Spree::Core::ProductFilters.respond_to?(:price_filter)\n fs\n \n end", "def status_filter_to_int\n params[:filter]&.each do |key, value|\n # filter key is comprised of <filterterm>_<relationship>\n # e.g. id_eq, status_in, etc - check if filter term is status\n next unless key.split('_').first == 'status'\n\n # split status terms in case there is a list of them\n status_terms = value.split(',')\n status_enum_values = []\n\n # for each status term, try to convert to enum value,\n # and add to list of converted enum values\n status_terms.each do |term|\n enum_value = Transcription.statuses[term]\n status_enum_values.append(enum_value.to_s) if enum_value\n end\n\n # if list of converted enum values is not empty,\n # update params to reflect converted values\n unless status_enum_values.empty?\n params[:filter][key] = status_enum_values.join(',')\n end\n end\n end", "def marketing_statuses\n sources = []\n changed_sources = []\n\n \n # collect l2l source source\n @resident.sources.where(:property_id => params[:prop_id]).each_with_index do |s, i|\n pp \"#{s.status}, #{s.status_date}, #{s.created_at}\"\n if s.status\n sources << {\n :status => s.status,\n :status_date => s.created_at,\n :move_in => s.move_in,\n :move_out => s.move_out\n }\n end\n end\n\n #collect only changed source (status & status_date changed)\n # must order by status_date asc, status_date always exists\n sorted_sources = sources.sort{|a, b| a[:status_date] <=> b[:status_date] }\n sorted_sources.each_with_index do |s, i|\n if i == 0\n changed_sources << s\n\n elsif s[:status] != sorted_sources[i-1][:status]\n changed_sources << s\n\n end\n end\n\n\n @statuses = changed_sources.sort{|a, b| b[:status_date] <=> a[:status_date] }\n \n render :json => @statuses.collect{|n| \n {\n :status => n[:status],\n :status_date => n[:status_date].to_s(:utc_date),\n :move_in => pretty_move_in(n[:move_in]),\n :move_out => pretty_move_in(n[:move_out])\n }\n }\n end", "def selected_filter_conditions(filter_class)\n\n @conditions = \"\"\n @included = []\n\n #pass in existing filters\n if params[:selected_filters]\n @selected_filters = params[:selected_filters] \n else \n @selected_filters = {} \n end\n\n #intialise hashes to store filters\n filter_class.filters.each do |j_f|\n @selected_filters[j_f] = {} if !defined?(@selected_filters[j_f]) || @selected_filters[j_f] == nil \n end\n\n @filtered = params[:filter]\n\n #new filter passed in - add or remove from existing as needed\n if @filtered\n\n if params[:remove]\n @selected_filters[@filtered].delete(params[:id])\n else\n @filter_id = params[:id]\n @filter_name = params[:name]\n @selected_filters[@filtered] = {params[:id] => params[:name]}\n end\n\n end\n\n #build up list of conditions to filter results\n if @selected_filters != {}\n @selected_filters.each do |filter, values|\n\n if values != {}\n\t @included << filter.to_sym\n @conditions += \" AND \" if @conditions != \"\"\n @ids = []\n \n values.each do | v | \n @ids << v[0]\n end\n \n @conditions += \"#{filter}.id IN (#{@ids})\"\n\t end \n end\n end\n\n end", "def filter; end", "def filter; end", "def filter; end", "def add_terms_filters\n add_work_type_filter\n add_user_filter\n add_pseud_filter\n add_collection_filter\n end", "def filter_by_status\n ids = TaskFilter.filter_status_ids(session)\n status_values = []\n hidden = \"(tasks.hidden = 0 OR tasks.hidden IS NULL)\"\n\n if ids.include?(0)\n status_values << \"tasks.status = 0\"\n# status_values << \"tasks.status = 1\"\n ids.delete(0)\n end\n if ids.include?(2)\n status_values << \"tasks.status > 1\"\n ids.delete(2)\n end\n if ids.include?(-2)\n hidden = \"tasks.hidden = 1\"\n ids.delete(-2)\n end\n if ids.include?(-1) # all statuses\n status_values.clear\n ids.delete(-1)\n end\n\n # the other values can be used untouched \n status_values += ids.map { |id| \"tasks.status = #{ id }\" }\n status_values = status_values.join(\" OR \")\n status_values = \"(#{ status_values }) AND \" if !status_values.blank?\n return \"#{ status_values } (#{ hidden }) AND \"\n end", "def filter\n\tfilter_disabled\n\tfilter_repeated\n\tfilter_silenced\n\tfilter_dependencies\n end", "def check_filter_options() #:nodoc:\r\n table_name = @tables.first[1]\r\n model = @tables.first[0]\r\n session[table_name] ||= {}\r\n# process page\r\n session[table_name][:page] = params[:page] if params[:page]\r\n# new filter is applied\r\n if params[:filter]\r\n set_session_filter(table_name)\r\n session[table_name][:page] = 1\r\n end\r\n# if data model has field dc_site_id ensure that only documents which belong to the site are selected.\r\n site_id = dc_get_site._id if dc_get_site\r\n# dont't filter site if no dc_site_id field or user is ADMIN\r\n site_id = nil if !model.method_defined?('dc_site_id') or dc_user_can(DcPermission::CAN_ADMIN)\r\n# \r\n if @records = DcFilter.get_filter(session[table_name][:filter])\r\n @records = @records.and(dc_site_id: site_id) if site_id\r\n else\r\n @records = if site_id\r\n model.where(dc_site_id: site_id)\r\n else\r\n model\r\n end\r\n end\r\n=begin \r\n# TODO Use only fields requested. Higly experimental but necessary in some scenarios\r\n if (columns = @form['result_set']['columns'])\r\n cols = []\r\n columns.each { |k,v| cols << v['name'] }\r\n p '*',cols,'*'\r\n @records = @records.only(cols)\r\n end\r\n=end \r\n# pagination if required\r\n per_page = (@form['result_set']['per_page'] || 30).to_i\r\n if per_page > 0\r\n @records = @records.page(session[table_name][:page]).per(per_page)\r\n end\r\nend", "def data_context_filter_1\r\n\r\n ckie = (RUBY_VERSION =~ /^1.8/) ? Iconv.new('UTF-8//IGNORE', 'latin1').iconv(cookies[:active_filters] || \"\") : (cookies[:active_filters] || \"\").force_encoding(Encoding::ISO_8859_1).encode!(Encoding::UTF_8)\r\n if !ckie.blank?\r\n find_hash = DevFeedback.named_scope_active_filter_method(ActiveSupport::JSON.decode(ckie))\r\n conds = find_hash[:conditions]\r\n @joins_fields = find_hash[:joins]\r\n\r\n DevFeedback.send(:with_scope, {:find => {:conditions => conds, :joins => (@joins_fields || [])}}) {\r\n yield\r\n }\r\n\r\n else\r\n yield\r\n end\r\n end", "def index\n @sighting = Sighting.where(:user_id => current_user.id)\n @location = Location.new\n @location.user_id = current_user.id\n\n\n @complaints_filter= Sighting.where(\"user_id != ?\",current_user.id).where(\"status != ?\",true)\n\n @complaints_filter2= Directsighting.where(\"status != ?\",true)\n\n @complaints_attending= Sighting.where(:rescuer_id => current_user.id)\n end", "def filter\n super\n end", "def applicable_filters\n fs = []\n fs << Spree::ProductFilters.taxons_below(self)\n ## unless it's a root taxon? left open for demo purposes\n\n fs << Spree::ProductFilters.price_filter if Spree::ProductFilters.respond_to?(:price_filter)\n fs << Spree::ProductFilters.brand_filter if Spree::ProductFilters.respond_to?(:brand_filter)\n #fs << Spree::ProductFilters.occasion_filter if Spree::ProductFilters.respond_to?(:occasion_filter)\n #fs << Spree::ProductFilters.holiday_filter if Spree::ProductFilters.respond_to?(:holiday_filter)\n fs << Spree::ProductFilters.selective_occasion_filter(self) if Spree::ProductFilters.respond_to?(:selective_occasion_filter)\n fs << Spree::ProductFilters.selective_holiday_filter(self) if Spree::ProductFilters.respond_to?(:selective_holiday_filter)\n fs\n end", "def applicable_filters\n fs = []\n fs << Spree::ProductFilters.taxons_below(self)\n ## unless it's a root taxon? left open for demo purposes\n\n fs << Spree::ProductFilters.price_filter if Spree::ProductFilters.respond_to?(:price_filter)\n fs << Spree::ProductFilters.brand_filter if Spree::ProductFilters.respond_to?(:brand_filter)\n #fs << Spree::ProductFilters.occasion_filter if Spree::ProductFilters.respond_to?(:occasion_filter)\n #fs << Spree::ProductFilters.holiday_filter if Spree::ProductFilters.respond_to?(:holiday_filter)\n fs << Spree::ProductFilters.selective_occasion_filter(self) if Spree::ProductFilters.respond_to?(:selective_occasion_filter)\n fs << Spree::ProductFilters.selective_holiday_filter(self) if Spree::ProductFilters.respond_to?(:selective_holiday_filter)\n fs\n end", "def set_filters\n @filters = []\n section_ids = Section.pluck(:id)\n\n [:ministers, :departments].each do |filter_type|\n if params[filter_type].present?\n id_list = params[filter_type].map(&:to_i)\n\n id_list.reject! do |item|\n !section_ids.include? item\n end\n\n @filters += Section.where(id: id_list)\n end\n end\n end", "def update_filters(l_filter)\n handle_action_exceptions(__method__) do\n raise 'Filters file not valid.' unless File.exist?(l_filter)\n\n do_upload_and_update_filter(l_filter)\n @json ? { 'result' => 'Success' } : true\n end\n end", "def status(*values)\n params.bury(:query, :filter, :state_filter, states: values)\n self\n end", "def update\n @report_request = ReportRequest.find(params[:report_request][:id])\n @fields = params[:field_filter]\n\n @fields.each do |k, v|\n field_filter = @report_request.field_filter(k.to_i)\n field_filter.update_attributes(v)\n end\n \n respond_to do |format|\n format.html\n format.xml { head :ok }\n end\n end", "def index\n case params[:filter]\n when \"Completed\" then @concepts = Concept.completed.paginate :page => params[:page], :per_page => 5\n when \"Approved\" then @concepts = Concept.approved.paginate :page => params[:page], :per_page => 5\n when \"Unapproved\" then @concepts = Concept.unapproved.paginate :page => params[:page], :per_page => 5\n else @concepts = Concept.paginate :page => params[:page], :per_page => 5\n end\n \n if params[:query]\n @concepts = Concept.find(:all, :conditions => [\"title LIKE ?\", \"%#{params[:query]}%\"]).paginate :page => params[:page], :per_page => 5 \n end\n @user = current_user\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @concepts }\n format.csv { render :text => @concepts.to_csv }\n end\n \n end", "def global_filter=(_arg0); end", "def report_filter_options\n @@report_filter_options ||= [\n filter_config(kind: 'date_filter', param: 'created_at', in_required_date_group: true),\n filter_config(kind: 'object_filter', param: 'user_id', collection: :users, label: 'user'),\n filter_config(kind: 'string_filter', param: 'user_email')\n ]\n end", "def filter!(collection)\n # Limit by type\n collection = collection.where(type: params[:type]) if params.has_key?(:type)\n\n # Limit by Tracker ID\n if params.has_key? :tracker_id\n tracker_ids = (params[:tracker_id] || '').to_s.split(\",\")\n collection = collection.where(tracker_id: tracker_ids)\n\n # not a perfect place, but should be okay for now...\n Tracker.where(id: tracker_ids).each { |tracker| tracker.delay.remote_sync_if_necessary(state: \"open\", person: current_user) }\n end\n\n # Limit by Tracker Type\n if params.has_key?(:tracker_type)\n constant_names = tracker_constant_names_for_type(params[:tracker_type])\n collection = collection.joins(:tracker).where('trackers.type IN (?)', constant_names) unless constant_names.blank?\n end\n\n # Filter by Tracker owner type and id\n if params.has_key?(:tracker_team_id)\n collection = filter_by_tracker_team_id(collection, params[:tracker_team_id])\n end\n\n # Filter by issue open/closed\n collection = collection.where(can_add_bounty: params[:can_add_bounty].to_bool) if params.has_key?(:can_add_bounty)\n\n #Filter by issue paid_out\n collection = collection.where(paid_out: params[:paid_out].to_bool) if params.has_key?(:paid_out)\n\n # Filter by Featured\n collection = collection.where(featured: params[:featured].to_bool) if params.has_key?(:featured)\n\n # Filter by issue accepting request_for_proposals\n if params[:accepting_proposals].to_bool\n collection = filter_by_accepting_proposals(collection.joins(:request_for_proposal))\n end\n\n if params.has_key?(:bounty_min) || params.has_key?(:bounty_max)\n collection = filter_by_bounty_total(collection)\n end\n\n # Filter by Tracker owner type and id\n if params.has_key?(:thumbed_by_person_id)\n if params[:thumbed_by_person_id] == 'me' && current_user\n person_id = current_user.id\n else\n person_id = params[:thumbed_by_person_id]\n end\n collection = collection.joins(:thumbs).where(\"thumbs.person_id\" => person_id, \"thumbs.downvote\" => false)\n end\n\n collection\n end", "def filter\n filter = \"\"\n\n filter = filter_by_user\n filter += filter_by_status\n filter += filter_by_milestones_projects_and_customers\n filter += filter_by_properties\n\n if session[:hide_deferred].to_i > 0\n filter << \"(tasks.hide_until IS NULL OR tasks.hide_until < '#{@tz.now.utc.to_s(:db)}') AND \"\n end \n filter << \"(tasks.milestone_id NOT IN (#{@completed_milestone_ids}) OR tasks.milestone_id IS NULL) AND \"\n\n filter = filter.gsub(/( AND )$/, \"\")\n return filter\n end", "def usage_filters\n get('/1/reporting/filters').to_a\n end", "def set_filter_collection\n # @category_collection = Schedule::CATEGORY\n @applicant_collection = current_company.applicants.are_qualified.map{|applicant| [applicant.name, applicant.id, {\"data-job-id\": applicant.job_id}]}\n @job_collection = current_company.jobs.published_and_closed_jobs.map{|job| [job.title, job.id]}\n end", "def index\n @stockholders = Stockholder.all\n \n if params[:set_not_completed]\n @stockholders = @stockholders.filter_not_completed\n end\n \n if params[:set_completed]\n @stockholders = @stockholders.filter_completed\n end\n \n end", "def Filter=(arg0)", "def index\n pagination = {}\n query = {}\n\n search_term = params[:search_term] || ''\n sortfield = params[:sortfield] || 'created_at'\n sortdir = params[:sortdir] || 'DESC'\n\n user = params[:user]\n\n is_archived_str = params[:is_archived] || ''\n apply_archive_filter = false\n if is_archived_str.downcase.eql?('true') || is_archived_str.eql?('1')\n is_archived = true\n apply_archive_filter = true\n elsif is_archived_str.downcase.eql?('false') || is_archived_str.eql?('0')\n is_archived = false\n apply_archive_filter = true\n end\n\n to_be_invoiced_str = params[:to_be_invoiced] || ''\n apply_to_be_invoiced_filter = false\n if to_be_invoiced_str.downcase.eql?('true') || to_be_invoiced_str.eql?('1')\n to_be_invoiced = true\n apply_to_be_invoiced_filter = true\n elsif to_be_invoiced_str.downcase.eql?('false') || to_be_invoiced_str.eql?('0')\n to_be_invoiced = false\n apply_to_be_invoiced_filter = true\n end\n\n\n current_location = params[:currentLocation] || ''\n current_location = '' if current_location.downcase.eql?('null')\n current_location = '' if current_location.eql?('0')\n current_location = '' if current_location.downcase.eql?('all')\n\n order_type = params[:mediaType] || ''\n order_type = '' if order_type.downcase.eql?('null')\n order_type = '' if order_type.eql?('0')\n order_type = '' if order_type.downcase.eql?('all')\n\n\n # Set status group to all if parameter is missing\n status_group = params[:status_group] || 'all'\n status_group = 'all' if status_group.eql?('0')\n status_group = 'all' if status_group.eql?('null')\n status_group_obj = StatusGroup.find_by_label(status_group)\n status_group_obj ? apply_status_group_filter = true : apply_status_group_filter = false\n\n\n delivery_source = params[:delivery_source] || ''\n delivery_source_obj = DeliverySource.find_by_label(delivery_source)\n delivery_source_obj ? apply_delivery_source_filter = true : apply_delivery_source_filter = false\n\n @orders = Order.paginate(page: params[:page])\n if @orders.current_page > @orders.total_pages\n @orders = Order.paginate(page: 1)\n end\n\n if apply_archive_filter\n @orders = @orders.where(is_archived: is_archived)\n end\n\n if apply_to_be_invoiced_filter\n @orders = @orders.where(to_be_invoiced: to_be_invoiced)\n end\n\n if apply_delivery_source_filter\n @orders = @orders.where(delivery_source_id: delivery_source_obj[:id])\n end\n\n if apply_status_group_filter\n @orders = @orders.where(status_id: status_group_obj.statuses.map(&:id))\n end\n\n @orders = @orders.where(location_id: current_location) if current_location.present?\n @orders = @orders.where(user_id: user) if user.present?\n @orders = @orders.where(order_type_id: order_type) if order_type.present?\n\n\n if search_term.present?\n st = search_term.downcase\n #the_user = User.where(\"id = ?\", st[/^\\d+$/] ? search_term.to_i : nil)\n user_xkonto_hit = User.where(\"(xkonto = ?)\", st)\n user_name_hit = User.where(\"(lower(name) LIKE ?)\", \"%#{st}%\")\n\n note_hits = Order.joins(:notes).where(\n \"(lower(notes.message) LIKE ?)\n OR (lower(notes.subject) LIKE ?)\",\n \"%#{st}%\",\n \"%#{st}%\").to_a\n note_hit_ids = Array.new()\n note_hits.to_a.each do |hit|\n note_hit_ids << hit[:id]\n end\n logger.debug \"note_hit_ids: #{note_hit_ids}\"\n\n @orders = @orders.where(\n \"(lower(name) LIKE ?)\n OR (lower(title) LIKE ?)\n OR (lower(authors) LIKE ?)\n OR (lower(publication_year) LIKE ?)\n OR (lower(journal_title) LIKE ?)\n OR (lower(issn_isbn) LIKE ?)\n OR (lower(reference_information) LIKE ?)\n OR (lower(library_card_number) = ?)\n OR (lower(order_number) LIKE ?)\n OR (lower(comments) LIKE ?)\n OR (lower(libris_lf_number) = ?)\n OR (libris_request_id = ?)\n OR (lower(librisid) = ?)\n OR (lower(librismisc) LIKE ?)\n OR (user_id = ?)\n OR (user_id IN (?))\n OR (id IN (?))\",\n \"%#{st}%\",\n \"%#{st}%\",\n \"%#{st}%\",\n \"%#{st}%\",\n \"%#{st}%\",\n \"%#{st}%\",\n \"%#{st}%\",\n st,\n \"%#{st}%\",\n \"%#{st}%\",\n st,\n st[/^\\d+$/] ? search_term.to_i : nil,\n st,\n \"%#{st}%\",\n user_xkonto_hit,\n user_name_hit,\n note_hit_ids\n )\n end\n\n logger.info \"OrdersController#index: current_location = #{current_location}\"\n logger.info \"OrdersController#index: sortfield == #{sortfield}\"\n logger.info \"OrdersController#index: sortdir == #{sortdir}\"\n\n @orders = @orders.order(sortfield)\n @orders = @orders.reverse_order if sortdir.upcase == 'DESC'\n\n pagination[:pages] = @orders.total_pages\n pagination[:page] = @orders.current_page\n pagination[:next] = @orders.next_page\n pagination[:previous] = @orders.previous_page\n\n query[:total] = @orders.total_entries\n\n logger.info @orders.to_sql\n logger.info \"OrdersController#index: Now rendering orders...\"\n render json: {orders: @orders, meta: {pagination: pagination, query: query}}, status: 200\n end", "def apply_filter_config\r\n exec(\r\n 'require_once(\"shaper.inc\");',\r\n 'require_once(\"filter.inc\");',\r\n 'filter_configure_sync();'\r\n )\r\n end", "def prepare_filters(filters, page, per_page, filter_group_start_index = 0)\n filter_array = []\n if filters.present?\n filters[:filter_groups].each_with_index do |filter_group, group_index|\n filter_group[:filters].each_with_index do |filter, filter_index|\n filter_string = \"searchCriteria[filter_groups][#{group_index + filter_group_start_index}][filters][#{filter_index}][field]=#{filter[:field]}&\"\n filter_string += \"searchCriteria[filter_groups][#{group_index + filter_group_start_index}][filters][#{filter_index}][value]=#{filter[:value]}&\"\n filter_string += \"searchCriteria[filter_groups][#{group_index + filter_group_start_index}][filters][#{filter_index}][conditionType]=#{filter[:condition]}\"\n filter_array.push(filter_string)\n end\n end\n\n filters[:order].each_with_index do |order, index|\n order_string = \"searchCriteria[sortOrders][#{index}][field]=#{order[:field]}&\"\n order_string += \"searchCriteria[sortOrders][#{index}][direction]=#{order[:direction]}\"\n filter_array.push(order_string)\n end\n end\n\n filter_array.push(\"searchCriteria[pageSize]=#{per_page}\") if per_page.present?\n filter_array.push(\"searchCriteria[currentPage]=#{page}\") if page.present?\n filter_array.join '&'\n end", "def current_status_aaa\n\t\t@workflows = WorkFlow.where(is_active: true, is_in_use: false)\n\t if session[:report_wildcard].present?\n\t @wildcard = session[:report_wildcard]\n\t end\n\t if session[:report_exact].present?\n\t @exact = session[:report_exact]\n\t end\n\t \n\t\tif request.post? or session[:report_q_string].present?\n\t\t\tif request.post?\n\t\t\t\t@serach_result = search[0]\n\t\t\t\tif search[1] != ''\n\t\t\t\t\t@report_serach_result = WorkFlow.current_report_search(search[1])\n\t\t\t\tend\n\t\t\t\n\t\t\telse\n\t\t\t \tq_string = session[:report_q_string]\n\t\t\t \tif q_string != ''\n\t\t\t\t\t@serach_result = WorkFlow.search(q_string)\n\t\t\t\t\t@report_serach_result = WorkFlow.current_report_search(q_string)\n\t\t\t\tend\n\t\t\tend\t\n\t\tend\n\tend", "def index\n \n binary_select_options = [['Yes', true], ['No', false]]\n status_of_project = [['Open', 'open'], ['In Process', 'in process'], ['Complete', 'complete']]\n\n @filterrific = initialize_filterrific(\n Project,\n params[:filterrific],\n select_options: {\n project_status: status_of_project,\n plattform_mobile: binary_select_options,\n plattform_desktop: binary_select_options,\n platform_tablet: binary_select_options,\n assets_text: binary_select_options,\n assets_images: binary_select_options,\n assets_videos: binary_select_options,\n assets_audio: binary_select_options,\n assets_database: binary_select_options,\n due_date_less_then_month: binary_select_options,\n due_date_one_month: binary_select_options,\n due_date_three_month: binary_select_options,\n due_date_plus_three_month: binary_select_options,\n pages_landing_pages: binary_select_options,\n pages_two_pages: binary_select_options,\n\n },\n default_filter_params: {},\n sanitize_params: false,\n ) or return\n @projects = @filterrific.find.order(created_at: :desc)\n respond_to do |format|\n format.html\n format.js\n end\n end" ]
[ "0.62592906", "0.61782485", "0.61355776", "0.61026406", "0.60719156", "0.60378873", "0.59948856", "0.59870553", "0.59870553", "0.58553326", "0.5827876", "0.58108443", "0.5769749", "0.57685274", "0.57639503", "0.5695986", "0.5695155", "0.5632832", "0.5601328", "0.5580405", "0.55738384", "0.5572987", "0.5561813", "0.5561813", "0.5553673", "0.5531771", "0.55204564", "0.5505028", "0.54967403", "0.547778", "0.5475579", "0.5468179", "0.54604596", "0.544617", "0.54437333", "0.5433771", "0.5423857", "0.5423857", "0.5419631", "0.5396132", "0.5393635", "0.5388867", "0.53773415", "0.5375551", "0.5365345", "0.5361205", "0.53557163", "0.5341236", "0.5341236", "0.53397834", "0.53244317", "0.5318787", "0.531256", "0.5307838", "0.5296338", "0.5291883", "0.5289515", "0.52693677", "0.5260418", "0.52518004", "0.52485913", "0.5246649", "0.52432644", "0.524192", "0.52391255", "0.5228244", "0.522319", "0.52225494", "0.5220681", "0.52186316", "0.5212588", "0.5212588", "0.5212588", "0.52098244", "0.52091044", "0.51952875", "0.51944333", "0.51849926", "0.5178915", "0.5177935", "0.51701224", "0.51701224", "0.51672226", "0.5162236", "0.516142", "0.51546794", "0.51510274", "0.5148051", "0.51453817", "0.5144246", "0.51339614", "0.5127705", "0.5126745", "0.5112508", "0.5111612", "0.5111591", "0.5107703", "0.51064014", "0.5102856", "0.50951076" ]
0.6502465
0
Determines if there is a conflict between authors' ProQuest optin.
def evaluate_proquest_status(thesis) proquest_status = thesis.authors.map(&:proquest_allowed).uniq return 'conflict' if proquest_status.length > 1 proquest_status.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_conflict?\n prefix == 'U'\n end", "def is_conflict?\n from_json\n (@order && @order.paid?).tap do |x|\n @error = true if x\n end\n end", "def merge_conflict?; end", "def check_version_conflict(other) # :nodoc:\n return if self.version == other.version\n\n # This gem is already loaded. If the currently loaded gem is not in the\n # list of candidate gems, then we have a version conflict.\n\n msg = \"can't activate #{full_name}, already activated #{other.full_name}\"\n\n e = Gem::LoadError.new msg\n e.name = self.name\n\n raise e\n end", "def dependents?\n approved_synonym_of_correctly_spelt_proposed_name? ||\n correctly_spelled_ancestor_of_proposed_name? ||\n ancestor_of_correctly_spelled_name?\n end", "def conflict?(other)\n return false unless self.class == other.class\n self.eql?(other) && self != other\n end", "def conflict?(placement)\n placement_dots(placement).any? { |d| taken_dots.include?(d) }\n end", "def allow_conflicts\n ((s = self.sections[\"Settings\"]) &&\n (a = s.attributes[\"AllowSetConflicts\"]) &&\n (a.value.pri == '1'))\n end", "def author_and_participation_same_organization\n return if !participation || !author\n errors.add(:participation, :invalid) unless author.organization == participation.organization\n end", "def conflicts_with_member?(member)\n motion_conflicts = conflicts\n member_conflicts = member.conflicts\n (member_conflicts & motion_conflicts).size > 0\n end", "def options_conflicts_with\n data.options_conflicts_with\n end", "def conflict?\n from_values.select{ |d,e| d != e }.any?\n end", "def duplicate_authorship?(pub)\n authorship = pub.pub_hash[:authorship]\n if authorship.length > 1\n authorship_ids = authorship.pluck(:cap_profile_id)\n authorship_set = authorship_ids.to_set\n if authorship_set.length != authorship_ids.length\n @logger.warn \"Publication #{pub[:id]} should be modified\"\n @logger.warn \"Publication #{pub[:id]} created_at #{pub[:created_at]}\"\n @logger.warn \"Publication #{pub[:id]} updated_at #{pub[:updated_at]}\"\n @logger.warn \"Publication #{pub[:id]} provenance: #{pub.pub_hash[:provenance]}\"\n @logger.warn \"Publication #{pub[:id]} authorship: #{JSON.dump(authorship)}\"\n # Preliminary analysis indicated that all duplicate authorship\n # records did NOT have any duplicates in the source records.\n # source_record_authorship_dedup?(pub)\n return true\n end\n end\n false\n rescue StandardError => e\n msg = \"Problem with publication: #{pub[:id]}\\n\"\n msg += \"#{e.inspect}\\n\"\n msg += e.backtrace.join(\"\\n\")\n @logger.error msg\n end", "def is_unavailable_and_has_conflicts?\n \tself.is_unavailable? && self.has_conflicts?\n end", "def respond_to_proposal_from( other )\n case\n # Is there a preference for the candidate?\n when !prefers?( other )\n false\n\n # Are there available positions for more matches?\n when free?\n match! other\n\n # Is the passed Candidate a better match than any other match?\n when better_match?( other )\n free!\n match! other\n\n else\n false\n end\n end", "def shouldnt_count_as_a_contribution?\n merge? || backported_from_master?\n end", "def conflict?\n conflicts = users_events.select{|e| e.start_time < self.end_bound && e.end_time > self.start_bound}.sort{|a,b| a.start_time <=> b.start_time}\n conflicts -= [self]\n if conflicts.empty?\n return false\n else\n return (!self.resolve_conflict([self]))\n end\n end", "def prefers?( other )\n preferences.include? other\n end", "def ocare_rel_previously_collected?(question)\n answer_for(question, valid_response_exists?(\"PARTICIPANT_VERIF.OCARE_REL\"))\n end", "def can_be_used_jointly?\n ids = order.order_promo_codes.collect(&:promo_code_id).uniq\n singular_promo_codes = PromoCode.where(id: ids).where(combined: false)\n # cant use count since that data isnt saved yet and count would fire an query\n if order.order_promo_codes.size > 1 and singular_promo_codes.count > 0\n self.errors.add(:promo_code_id, 'Cant be used with conjuction with other codes') unless self.promo_code.combined\n end\n end", "def ensure_not_referenced_by_adoption\n if adoptions.empty?\n return true\n else\n errors.add(:base, 'Adoption present')\n return false\n end\n end", "def has_problem?(options = {})\n options = options.reverse_merge(:include_owner => true)\n\n problem = self.class.problem_court_status.include?(court_status)\n\n if options[:include_owner]\n problem || owner.try(has_problem?)\n else\n problem\n end\n end", "def message\n \"#{base} already defines #{conflicts}, also defined on #{owner}\"\n end", "def parcelle_assoc_saison_incoh\n err = false\n self.parcelles.each { |p| err = true unless p.saison_id.eql?(self.saison_id) }\n self.factoparcelles.each { |a| err = true unless a.saison_id.eql?(self.saison_id) }\n return (err)\n end", "def different_committer?\n author_name != committer_name || author_email != committer_email\n end", "def assessment_changed?( a = nil )\n ( pub_assmt != new_assmt ) || ( new_assmt != ( a || assessment ))\n end", "def ensure_not_referenced_by_any_adoption\n if adoptions.empty?\n return true\n else\n errors.add(:base, 'Adoption present')\n return false\n end\n end", "def check_prefecture\n if prefecture == \"--未選択--\"\n errors.add(:prefecture, \"選択して下さい\")\n end\n end", "def meeting_conflict?(other)\n return false if self.start_time.nil? or other.start_time.nil?\n section_days = other.days.split(\"\")\n section_days.each do |day|\n if( self.days.include?(day) )\n if (self.start_time.to_i >= other.start_time.to_i and self.start_time.to_i <= other.end_time.to_i) or \n (other.start_time.to_i >= self.start_time.to_i and other.start_time.to_i <= self.end_time.to_i)\n return true\n end \n end\n end\n return false\n end", "def candownload?(issue = nil)\n if self.isregistered?\n #durante il periodo di prova l'utente NON accede ai attachment degli contenuti rossi che hanno una sezione protetta\n if issue && issue.section && issue.section.protetto\n #tranne quelli che hanno una sezione protetta\n return false\n end\n end\n return true\n end", "def no_proposals_unless_manages_proposals\n return true if manages_proposals or proposals.empty?\n errors.add(:manages_proposals,\n _('This conference already has received %d proposals (%s) - ' +\n 'Cannot specify not to handle them.') %\n [self.proposals.size, self.proposals.map {|p| p.id}.join(', ')])\n end", "def valid_ordering?(proposed_ordering)\n achievements_hash.keys.sort == proposed_ordering.sort\n end", "def overlap_ok?\n # if overlap: true\n end", "def invited_user_is_not_associated_with_project\n\t if invited_user.is_associated_with_project?(project)\n\t\t errors[:base] << \"#{invited_user.username} is already collaborating on this project.\"\n\t\t end\n\t\tend", "def recombination?\n return false unless protonym.name.is_a?(SpeciesGroupName)\n name.genus_epithet != protonym.name.genus_epithet\n end", "def verify_vote_proposal_options\n return true unless vote_proposal_options\n if status == \"preview\"\n correct_options = vote_proposal.vote_proposal_options.map(&:name)\n correct_options << \"Accept\"\n correct_options << \"Decline\"\n else\n correct_options = vote_proposal.vote_proposal_options.map(&:name)\n end\n\n vote_proposal_options.all? do |option|\n correct_options.index(option.name)\n end \n end", "def different_committer?\n author_name != committer_name || author_email != committer_email\n end", "def conflicts\n @grid.values.select { |claims| claims.size > 1 }\n end", "def candidates_exist_for_all_forced_changes?\n forced_packages_missing_candidates.empty?\n end", "def has_conflicting_session_with( session )\n has_conflict = false\n\n session.resident_sessions.all.each do |resident_session|\n #puts \">>> finding conflicts with #{resident_session.resident.name}'s session: #{resident_session.session.id} @ #{resident_session.session.time_hhmm}\"\n if has_resident_session_conflict( resident_session )\n has_conflict = true\n end\n end\n\n\n has_conflict\n end", "def conflicts(s1,e1,s2,e2)\n if s1<=s2 and e1>s2\n return true\n elsif s1<e2 and s1>s2\n return true\n end\n return false\n end", "def skip_pr?(pr)\n return false unless pr[:title].include?(SKIP_MERGE)\n\n failure_status(pr, \"Skipping #{pr[:head][:ref]}.\")\n\n true\n end", "def isCompatible(items, cand)\n candAuthKeys = $authKeys[cand]\n return true if candAuthKeys.empty?\n ok = true\n ids = {}\n\n # Make sure the candidate has same type-id. Well, only check that if we're trying to match non-Elements\n # things. Elements appears to ignore types in its matching, so we follow suit.\n #items.each { |item|\n # if item.typeName != cand.typeName\n # if !item.isFromElements && !cand.isFromElements\n # #puts \"Type-id mismatch for scheme #{scheme.inspect}: #{cand.typeName.inspect} vs #{item.typeName.inspect}\"\n # ok = false\n # end\n # end\n #}\n\n # Make sure the candidate overlaps at least one author of every pub in the set\n items.each { |item|\n itemAuthKeys = $authKeys[item]\n next if itemAuthKeys.empty?\n overlap = itemAuthKeys & candAuthKeys\n if overlap.empty?\n #puts \"No overlap: #{itemAuthKeys.to_a.join(',')} vs. #{candAuthKeys.to_a.join(',')}\"\n ok = false\n end\n item.ids.each { |scheme, text|\n ids[scheme] = text\n }\n }\n\n # Make sure the candidate has no conflicting IDs\n cand.ids.each { |scheme, text|\n next if isCampusID(scheme) # we know that campus IDs overlap each other, and that's expected\n next if scheme==\"elements\" # we also know that Elements IDs can overlap and that's expected\n if ids.include?(scheme) && ids[scheme] != text\n #puts \"ID mismatch for scheme #{scheme.inspect}: #{text.inspect} vs #{ids[scheme].inspect}\"\n ok = false\n end\n }\n\n # All done.\n return ok\nend", "def find_resident_session_conflict(resident_session)\n conflicting_resident_session = nil\n resident = resident_session.resident\n session = resident_session.session \n\n self.sessions.resident_sessions.all.each do |existing_resident_session|\n\n if existing_resident_session.resident.name == resident.name \n if existing_resident_session.session.overlaps? session\n #puts \" >>> found overlap...<<<\"\n conflicting_resident_session = existing_resident_session\n end\n \n #puts \">>> printing all conflicts after adding\"\n #puts all_conflicts\n #puts \"<<<\"\n end\n end\n \n conflicting_resident_session\n end", "def fulfills_prereq?( prereq )\n\t\[email protected] do |i|\n\t\t\tif i == prereq\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\trecurse = NERO_Skill.lookup(i)\n\t\t\t\tif recurse.is_a? NERO_Skill and recurse.fulfills_prereq?(prereq)\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend", "def skip_pledge_modal?\n org_details[:skip_pledge_modal]\n end", "def university_pending?\n university && line_items_pending_any?\n end", "def validate_prereq(prereqs, prereq)\n if(prereq && (!prereqs || !prereqs.include?(prereq)))\n raise \"Not all special prereqs were in the given set of prereqs\"\n end\n prereq\n end", "def entertained?\n return (gladiators.map { |g| g.name }).include? \"Maximus\"\n end", "def in_conflict?(local_diff, remote_diff)\n return true if\n local_diff.target.parent.is_a?(Array) &&\n local_diff.target.value.is_a?(DataModel::Referenceable) &&\n local_diff.target.value.id == remote_diff.target.value.id &&\n local_diff != remote_diff\n\n case [local_diff, remote_diff].map { |d| d.class.name.split('::').last }.sort\n when %w(Change Change)\n local_diff.changed_from.value == remote_diff.changed_from.value &&\n local_diff.target.value != remote_diff.target.value\n when %w(Change Delete)\n true\n else\n false\n end\n end", "def check_email_name_conflict()\n mail_header_output.name_conflicts = mail_header_output.firstname_lastname && mail_header_output.flastname\n if (!mail_header_output.firstname_lastname && !mail_header_output.flastname)\n mail_header_output.correct_email_format=MailHeader.unknown\n end\n\tend", "def existing_agreement?\n (existing_agreement == 'Y')\n end", "def add_conflict(name, specifics)\n @conflicts << Requirement.parse(name, specifics)\n end", "def is_reservation_and_has_conflicts?\n self.is_reservation? && self.has_conflicts?\n end", "def prerelease?\n [email protected]? && [email protected]?\n end", "def has_common_coauthor_with(other_authors)\n end", "def treat_reserved_as_conflict; end", "def conjunction?\n type != HQMF::PopulationCriteria::OBSERV\n end", "def on_ambiguity\n @on_ambiguity\n end", "def unmatched?\r\n @partner.nil?\r\n end", "def main_team_member?(pr, months_back)\n (committer_team(pr, months_back) + merger_team(pr, months_back)).uniq.include? requester(pr)\n end", "def has_conflicts?\n return true unless Gem.env_requirement(name).satisfied_by?(version)\n self.dependencies.any? do |dep|\n if dep.runtime?\n spec = Gem.loaded_specs[dep.name]\n spec and not spec.satisfies_requirement? dep\n else\n false\n end\n end\n end", "def is_request_pending_to_same_club_from_another_club?\n self.class.preloaded_data.where(sadhak_profile_id: self.sadhak_profile_id, to_club_id: self.to_club_id, status: self.class.statuses['requested']).each do |req|\n errors.add(:sadhak, \"Name: #{req.requester_user.name} has already created a request for transfer from #{req.transfer_out_club.name.titleize} forum to #{req.transfer_in_club.name.titleize} froum.\")\n end\n errors.empty?\n end", "def candidates_included_in_all_the_others(candidates_in_correct_position)\n\tcandidates_in_correct_position.each do |small|\n\t\tok = true\n\t\tcandidates_in_correct_position.each do |big|\n\t\t\tif small!=big\n\t\t\t\tunless big.source.position.include?(small.source.position)\n\t\t\t\t\tok = false\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn small if ok\n\tend\n\tnil\nend", "def fix_association(current_user)\n if self.user == current_user # duplicate\n 'Already associated with this Oauth'\n elsif self.user # conflict\n 'Oauth is associated with another user'\n else # unassigned\n self.add_association(current_user)\n end\n end", "def translator_cant_change_approved\n if approved? && translator && !translator.reviewer?\n errors.add :base, :illegal_change\n return false\n end\n return true\n end", "def raise_if_conflicts # :nodoc:\n if has_conflicts?\n raise Gem::ConflictError.new self, conflicts\n end\n end", "def merged?\n !!merge_ticket_id\n end", "def has_three_bonus_parts\n # placeholder\n # will fill in if issue of accidentally not associating bonus parts\n # becomes actually problematic\n end", "def conflicts\n @conflicts ||= []\n end", "def conflicts\n @conflicts ||= []\n end", "def awaiting_other_colleges?(college)\n if college.nil?\n return false\n end\n\n college_ids = Course.select('courses.college_id')\n .joins(:course_selections)\n .where('course_selections.application_id' => self.id)\n .where('course_selections.college_offer' => nil)\n\t\t.map { |r| r.college_id }\n\n college_ids.any? && !college_ids.include?(college.id)\n end", "def supporting_document_other?\n supporting_document_list.include?('OTHER')\n end", "def open?\n return accepted_proposal_id == nil\n end", "def checkNewAssoc(scheme, campusID, oapID, campusCache)\n if campusCache.empty?\n db_execute(\"SELECT campus_id FROM ids WHERE oap_id = ?\", [oapID]) { |row|\n foundScheme, foundID = row[0].split('::')\n campusCache[foundScheme] << foundID\n }\n end\n if campusCache[scheme].length > 0 && !campusCache[scheme].include?(campusID)\n puts \"Warning: possible dupe: campus ID #{scheme}::#{campusID} being added to oapID #{oapID} which already had #{campusCache[scheme].to_a.inspect}.\"\n end\nend", "def pcare_rel_previously_collected?(question)\n answer_for(question, valid_response_exists?(\"PARTICIPANT_VERIF.PCARE_REL\"))\n end", "def accepted_agreement?\n return license != DEFAULT_LICENSE\n end", "def publication_match_in_profile\n @info.available_related_content_types.include? 'emp'\n end", "def succeeds?(other)\n range_precedes(other, self)\n end", "def handleAssocChanges(postNum, pub, ids, oapID, assocChanges)\n\n # Collate the records by old OAP ID\n fromOAPs = Hash.new { |h,k| h[k] = Set.new }\n assocChanges.each { |campusID, fromOAP, toOAP| fromOAPs[fromOAP] << campusID }\n\n # Figure out which old OAP IDs will end up abandoned, and which are being disassociated\n abandoned = []\n fromOAPs.each { |fromOAP, campusIDs|\n existing = Set.new(db_execute(\"SELECT campus_id FROM ids WHERE oap_id = ?\", fromOAP).map { |row| row[0] })\n if (existing - campusIDs).empty?\n abandoned << fromOAP\n end\n }\n\n disassoc = assocChanges.map{ |campusID, fromOAP, toOAP| toOAP ? nil : fromOAP }.compact\n\n # Ensure that all IDs being abandoned or disassociated haven't been worked on by the users\n errs = []\n (abandoned+disassoc).each { |fromOAP|\n pubs = db_execute(\"SELECT pub_id FROM pubs WHERE oap_id = ?\", fromOAP).map { |row| row[0] }\n pubs.each { |pubID|\n n = db_get_first_value(\"SELECT count(*) FROM eschol_equiv WHERE pub_id = ?\", pubID)\n if n > 0\n errs << \"An eschol_equiv record is associated with publication #{pubID.inspect}, OAP #{fromOAP.inspect}.\"\n end\n n = $arkDb.get_first_value(\"SELECT count(*) FROM arks WHERE source = ? AND external_id = ?\", \"elements\", pubID)\n if n > 0\n errs << \"A file was deposited to eschol for publication #{pubID.inspect}, OAP #{fromOAP.inspect}.\"\n end\n }\n }\n\n if !errs.empty?\n puts \"Warning: The following association change will *not* be performed because of potential problems.\"\n assocChanges.each { |campusID, fromOAP, toOAP|\n if toOAP\n puts \" Change: Campus item #{campusID} switching from oapID #{fromOAP.inspect} to #{toOAP.inspect}.\"\n else\n puts \" Change: Campus item #{campusID} leaving oapID #{fromOAP.inspect}.\"\n end\n }\n errs.each { |err|\n puts \" Potential problem: #{err}\"\n }\n return false\n end\n\n puts \"Note: The following association change appears to be OK, going ahead.\"\n if !abandoned.empty?\n puts \" Abandoned IDs: #{abandoned.inspect}\"\n end\n assocChanges.each { |campusID, fromOAP, toOAP|\n if toOAP\n puts \" Change: Campus item #{campusID} switching from oapID #{fromOAP.inspect} to #{toOAP.inspect}.\"\n else\n puts \" Change: Campus item #{campusID} leaving oapID #{fromOAP.inspect}.\"\n end\n }\n\n # Drop the old OAP record in Elements\n abandoned.each { |fromOAP|\n puts \" Deleting abandoned record #{fromOAP.inspect}.\"\n if $testMode\n puts \" (test mode: not deleting old OAP item)\"\n next\n end\n uri = URI(\"#{$elementsAPI}/publication/records/c-inst-1/#{CGI.escape(fromOAP)}\")\n req = Net::HTTP::Delete.new(uri)\n req.basic_auth $apiCred[0], $apiCred[1]\n (1..10).each { |tryNumber|\n\n $transLog.write(\"\\n---------------------------------------------------------------\\n\")\n $transLog.write(\"\\nDELETE #{uri}\\n\")\n $transLog.flush\n\n res = $elementsAPIConn.request(req)\n\n # Log the response\n $transLog.write(\"Response:\\n\")\n $transLog.write(\"#{res} code=#{res.code} message=#{res.message.inspect}\\n\")\n $transLog.write(\"#{res.body}\\n\")\n\n # HTTPConflict and HTTPGatewayTimeOut happen occasionally, and are likely transitory\n if res.is_a?(Net::HTTPConflict) || res.is_a?(Net::HTTPGatewayTimeOut)\n puts \" Note: failed due to #{res} (likely a transitory concurrency issue).\"\n if tryNumber < 20\n puts \" Will retry after a 30-second pause.\"\n sleep 30\n next\n else\n puts \" Out of retries. Aborting.\"\n end \n end\n\n # Fail if the DELETE failed\n res.is_a?(Net::HTTPSuccess) or raise(\"Error: delete failed: #{res}\")\n }\n }\n\n # Make the changes in our database\n assocChanges.each { |campusID, fromOAP, toOAP|\n if toOAP\n db_execute(\"INSERT OR REPLACE INTO ids (campus_id, oap_id) VALUES (?, ?)\", [campusID, toOAP])\n else\n db_execute(\"DELETE FROM ids WHERE campus_id = ? AND oap_id = ?\", [campusID, fromOAP])\n end\n }\n abandoned.each { |fromOAP|\n db_execute(\"DELETE FROM ids WHERE oap_id = ?\", fromOAP)\n db_execute(\"DELETE FROM pubs WHERE oap_id = ?\", fromOAP)\n db_execute(\"DELETE FROM oap_hashes WHERE oap_id = ?\", fromOAP)\n db_execute(\"DELETE FROM oap_flags WHERE oap_id = ?\", fromOAP)\n }\n\n # All done, and ready to proceed with import.\n return true\n\nend", "def in_use?\n published? || has_answers? || has_choices?\n end", "def is_author_of?(name)\n self.is_author? and !self.programs.find_by_name(name).nil?\n end", "def reedition_should_be_known\n if @reedition_title.present? && !reedition_id\n errors.add(:reedition_title, :invalid)\n end\n end", "def incomplete_policyfile_options?\n policy_group, policy_name = @name_args[1..]\n (policy_group.nil? || policy_name.nil? || @name_args[1..-1].size > 2)\n end", "def ambiguous?\n found = chart.sets.find { |set| !set.ambiguities.empty? }\n !found.nil?\n end", "def chosen(already, owner, other)\n\t\tif already && already.owner_id == owner.id && current_user\n\t\t\t\"chosen\"\n\t\telse\n\t\t\tother\n\t\tend\n\tend", "def accepted?\n verdict && verdict.accepted?\n end", "def ambiguous?\n @is_ambiguous\n end", "def required_secondary_output\n if (needs_to_relay_associations? || requires_accepted_name_assignment?) &&\n secondary_output.nil?\n errors.add(:secondary_output, \"Must have a secondary output\")\n return false\n end\n true\n end", "def is_conjunction?(language)\n pos == 'J' || xpos == ',' || lemma == ',' || CONJUNCTIONS[language]&.include?(lemma)\n end", "def can_show_prequel_for?(team)\n self.has_prequel? && self.teams.include?(team)\n end", "def ensure_not_last_option\n return false if good.options.count == 1\n end", "def cannot_have_conflicts\n \terrors.add(:base, \"Conflicts with another reservation\") if self.has_conflicts?\n end", "def is_agreement?(options = {})\n return false if frozen?\n o = options[:observation] || observation\n return false if o.taxon_id.blank?\n return false if o.user_id == user_id\n return true if taxon_id == o.taxon_id\n taxon.in_taxon? o.taxon_id\n end", "def prescriptively_ok?\n acceptance & PRESCRIPTIVE == PRESCRIPTIVE\n end", "def can_combine?(order)\n self.combine &&\n order.credits(:join => :adjustment_source).all?{|pc| pc.adjustment_source.combine}\n end", "def complete?(options = {})\n return false unless super() or (types.present? and types.any?) or (actor_ids.present? and actor_ids.any?)\n return true if options[:no_listings] == true\n not listing.nil? and not photo.nil?\n end", "def ident_viol_candidates?\n @ident_viol_candidates\n end", "def respondent_is_not_author_poll?\n #\n # respondend.id == author.id\n\n if question.poll.author.id == user.id\n errors[:user_id] << 'author should not answer to his/her poll'\n end\n end", "def unlocked?; prereqs_sat @prereqs; end" ]
[ "0.6441109", "0.5956657", "0.583592", "0.578828", "0.57494783", "0.56846005", "0.55172384", "0.5475199", "0.54699", "0.5443352", "0.54129577", "0.5399809", "0.5393467", "0.5331197", "0.5324871", "0.53027874", "0.5294821", "0.52847314", "0.5275738", "0.52712935", "0.5270399", "0.5256504", "0.5217475", "0.5193365", "0.5151249", "0.51280886", "0.51257616", "0.5114479", "0.5085801", "0.5078595", "0.5077653", "0.5072556", "0.5071978", "0.5064307", "0.5060316", "0.5052186", "0.5045692", "0.50378317", "0.50344974", "0.50275016", "0.50248754", "0.50087106", "0.50069594", "0.5002317", "0.49921006", "0.49888086", "0.49881285", "0.49856782", "0.49719474", "0.49630165", "0.4958879", "0.49569094", "0.49513832", "0.49506855", "0.49491975", "0.49468562", "0.49457338", "0.49451986", "0.4943547", "0.4943342", "0.49327794", "0.49321702", "0.4931667", "0.4930066", "0.49270332", "0.4925232", "0.4921797", "0.4920317", "0.49186975", "0.4916639", "0.4916639", "0.49155164", "0.4914692", "0.4912444", "0.4902601", "0.49025878", "0.4895825", "0.48917124", "0.4887254", "0.48848775", "0.48781258", "0.4872978", "0.48726684", "0.48688954", "0.48678872", "0.4866087", "0.48448083", "0.48430943", "0.48358324", "0.48350874", "0.48348582", "0.48341787", "0.4828568", "0.48267856", "0.4824404", "0.48101133", "0.480631", "0.48000312", "0.47976464", "0.4792322" ]
0.5837913
2
Renders a friendly version of the thesis' ProQuest optin status for reports.
def render_proquest_status(thesis) status = evaluate_proquest_status(thesis) return 'Opt-in status not reconciled' if status == 'conflict' return 'No opt-in status selected' if status.nil? return 'Yes' if status == true return 'No' if status == false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_status(criterion, f, project, is_disabled)\n render(partial: 'status_chooser',\n locals: { f: f, project: project, is_disabled: is_disabled,\n criterion: Criteria[criterion] })\n end", "def pay_status_to_s\n if self.paid?\n %Q|<span style=\"color:green;\">#{self.bonus.nil? ? \"paid\" : \"bonus (#{self.bonus})\"}</span>|\n elsif self.rejected?\n %Q|<span style=\"color:red;\">rej</span>|\n end\n end", "def status_desc\n case self.proposal_status\n when 0\n 'Pending'\n when 1\n 'Accepted'\n when 2\n 'Declined'\n end\n end", "def display_status\n # Provisioning Status has priority\n if display_provisioning_status != 'Done'\n return display_provisioning_status\n end\n\n case status\n when 'running'\n 'Running'\n when 'stopping'\n 'Shutting Down'\n when 'shutoff'\n 'Powered Off'\n else\n status\n end\n end", "def status_text\n\t s = Enrollment::STATUS_NAMES[self.enrollment_status]\n\t \n\t if [Enrollment::STATUS_CLOSED,Enrollment::STATUS_FINALIZED].include? self.enrollment_status\n\t s += \"-#{Enrollment::COMPLETION_NAMES[self.completion_status]}\"\n\t end\n\t s\n\tend", "def status\n status = \"\"\n if points < 4000\n status = \"Baby Seeder\"\n elsif points < 8000\n status = \"Aspiring Gardener\"\n elsif points < 15000\n status = \"Garden Hero\"\n else\n status = \"Plant Wizard\"\n end\n end", "def display_provisioning_status\n case provisioning_status.to_s\n when 'initializing'\n 'Initializing'\n else\n 'Done'\n end\n end", "def status_text\n case @state\n when 0\n H87Enchant::ST1\n when 1\n H87Enchant::ST2\n when 2\n H87Enchant::STQ\n when 3\n H87Enchant::ST3\n when 4\n H87Enchant::ST4\n when 5\n H87Enchant::ST5\n else\n ; 'ERRORE 01'\n end\n end", "def contest_status_label(contest)\n if contest.closed?\n \"Votação Encerrada\"\n elsif contest.open?\n \"<span class='label label-success'>Votação Aberta</span>\".html_safe\n elsif contest.open_enrollment?\n \"<span class='label label-info'>Inscrições Abertas</span>\".html_safe\n elsif contest.idle?\n \"<span class='label label-default'>Votação inicia em #{format_date_old(contest.opening)}</span>\".html_safe\n elsif contest.waiting?\n \"<span class='label label-default'>Inscrições iniciam em #{format_date_old(contest.opening_enrollment)}</span>\".html_safe\n end\n end", "def print_status\n puts \"Stats:\"\n puts \"* HP: #{@stats[:hp]}/#{@stats[:max_hp]}\"\n puts \"* Attack: #{@stats[:attack]}\"\n puts \"* Defense: #{@stats[:defense]}\"\n puts \"* Agility: #{@stats[:agility]}\"\n print \"\\n\"\n\n puts \"Equipment:\"\n print \"* Weapon: \"\n puts @outfit[:weapon] ? \"#{@outfit[:weapon].name}\" : \"none\"\n\n print \"* Shield: \"\n puts @outfit[:shield] ? \"#{@outfit[:shield].name}\" : \"none\"\n\n print \"* Helmet: \"\n puts @outfit[:helmet] ? \"#{@outfit[:helmet].name}\" : \"none\"\n\n print \"* Torso: \"\n puts @outfit[:torso] ? \"#{@outfit[:torso].name}\" : \"none\"\n\n print \"* Legs: \"\n puts @outfit[:legs] ? \"#{@outfit[:legs].name}\" : \"none\"\n\n print \"\\n\"\n end", "def status\n puts \"Player #{@playerNo}\".center(60)\n puts \"Name: #{@name}\".center(60)\n puts \"Class: #{@fightClass[:name]}\".center(60)\n puts \"Race: #{@race[:name]}\".center(60)\n puts \"HP: #{@hp}\".center(60)\n puts \"Level: #{@level}\".center(60)\n puts \"Actions: #{@actions.map(&:unCamelize).join(', ')}\".center(60)\n puts \"Attacks: #{@attacks.map(&:unCamelize).join(', ')}\".center(60)\n puts \"Inventory: #{@inventory.join(', ')}\".center(60)\n puts \"\"\n end", "def display_cohort_info\n puts '=========================================='\n puts @name\n puts \"Start Phase 0: #{@p0_start_date}\"\n puts \"Start Immersive: #{immersive_start_date}\"\n puts \"Graduate: #{graduation_date}\"\n puts \"Enrollment: #{self.num_of_students}\"\n puts \"Current Phase: #{currently_in_phase}\"\n end", "def display_status\n exam_state = (all_questions_answered? ? FINISHED_STATE : UNFINISHED_STATE).titleize\n \"#{exam_state} Subject\"\n end", "def status\n if params[:id]\n @source = \"confessor_status\"\n else\n @source = \"priest_status\"\n end\n end", "def status\n \"#{@description} #{@status}\"\n end", "def mailout_status_display\n if self.mailout_status == 'n'\n return 'Not sent'\n end\n if self.mailout_status == 'r'\n return 'Send requested'\n end\n if self.mailout_status == 'i'\n return 'Send in progress'\n end\n if self.mailout_status == 's' \n return 'Sent'\n end\n end", "def show_table(game_status)\n prompt \"================================\"\n prompt \"================================\"\n prompt \"#{game_status[:current_game_status]}\"\n prompt \"================================\"\n prompt \"================================\"\nend", "def show_table(game_status)\n prompt \"================================\"\n prompt \"================================\"\n prompt \"#{game_status[:current_game_status]}\"\n prompt \"================================\"\n prompt \"================================\"\nend", "def label_status_inscription(participant)\n if participant.pending?\n '<span class=\"label label-warning\">Inscrição enviada para aprovação</span>'.html_safe\n elsif participant.failed?\n '<span class=\"label label-danger\">Sua inscrição foi recusada</span>'.html_safe\n elsif participant.approved?\n '<span class=\"label label-success\">Inscrição aprovada</span>'.html_safe\n end\n end", "def status\n if complete?\n \"PAID\"\n else\n \"PENDING\"\n end\n end", "def show_status(commander)\n puts \"#{commander} was #{@users[commander][:times_commander] } times Commanding officer of the week.\"\n puts \"#{commander} is currently on vacation\" if @users[commander][:vacation]\n @users[commander][:vacations].each { |x| puts x}\n end", "def render\r\n t(:div, {},\r\n *splat_each(props.appointment_proposal_infos) do |appointment_proposal_info|\r\n t(:div, {},\r\n if appointment_proposal_info.anytime_for_date\r\n t(:p, {}, \"any time for #{Moment.new(appointment_proposal_info.anytime_for_date).format('YYYY-MM-DD')}\")\r\n else\r\n t(:p, {}, \"#{appointment_proposal_info.doctor.profile.name}: #{Moment.new(appointment_proposal_info.date_from).format('HH:mm')} - #{Moment.new(appointment_proposal_info.date_to).format('HH:mm')}\")\r\n end\r\n )\r\n end\r\n )\r\n end", "def status_text\n return 'Unknown' if state.blank?\n\n return I18n.t(\"activerecord.attributes.export_job.status.#{state}\") unless in_progress?\n\n I18n.t('activerecord.attributes.export_job.status.in_progress') + progress_text\n end", "def render_review_status(opts)\n field = opts[:document][opts[:field]]\n # binding.pry\n if field.is_a? Array\n field.map { |s| t \"mxd_type_labels.review_status_labels.#{s}\" }.join ' ; '\n else\n t \"mxd_type_labels.review_status_labels.#{field}\"\n end\n end", "def display_status(item_status_code)\n case item_status_code\n when 'I' # Initiated (Assigned)\n 'incomplete'\n when 'A', 'R' # Active (Processing) / Received\n 'beingProcessed'\n when 'C', 'W' # Completed / Waived\n 'completed'\n when 'Z' # Incomplete\n 'furtherActionNeeded'\n else\n 'incomplete'\n end\n end", "def team_work_show\n\t\tif self.team_work == true\n\t\t\t\"小組\"\n\t\telse\n\t\t\t\"個人\"\n\t\tend\t\n\tend", "def status_string\n if waiting_confirmation?\n return \"À confirmer\"\n elsif confirmed?\n return \"Confirmé\"\n elsif forgiven?\n return \"Pardonné\"\n else\n return \"Rejeté\"\n end\n end", "def print_status\n puts \"HP: #{hp}/#{max_hp}\"\n puts \"Attack: #{attack}\"\n puts \"Defense: #{defense}\"\n print \"\\n\"\n\n print \"Weapon: \"\n if (!@outfit[:weapon].nil?)\n puts \"#{@outfit[:weapon].name}\"\n else\n puts \"none\"\n end\n\n print \"Helmet: \"\n if (!@outfit[:helmet].nil?)\n puts \"#{@outfit[:helmet].name}\"\n else\n puts \"none\"\n end\n\n print \"\\n\"\n end", "def show_status_label_method\n \"#{self.status}\"\n end", "def status\n output = \"\"\n player = @game.player\n output << \"You won!! you have scaped with life from the castle!!! \"\n output << \"WELL DONE!!\"\n end", "def to_s()\r\n\t\tres = \"Printing Statistic -#{self.object_id}-\\n\\t\"\r\n\t\tres += \" - Time : #{@time}\\n\\t\"\r\n\t\tres += \" - Penalty : #{@penalty}\\n\\t\"\r\n\t\tres += \" - isFinished : #{@isFinished}\\n\\t\"\r\n\t\tres += \" - Used help : #{@usedHelp}\\n\\t\"\r\n\t\tres += \" - Nb Stars : #{@numberOfStars}\\n\\t\"\r\n\t\tres += \" - NbClick : #{@nbClick}\\n\\t\"\r\n\t\treturn res\r\n\tend", "def status_to_css\n if status != \"Active\" || docks_available < 1\n \"error\"\n elsif docks_available == 1\n \"warning\"\n else\n \"success\"\n end\n end", "def printable_status\n Statusable.printable(status)\n end", "def do_status\n return pretty_status(current_status)\n end", "def opt_in_flag\n member_supplementry_histories.first.opt_in_flag.strip rescue \"\"\n end", "def verdict\n if self.is_complete?\n return self.status_str.titleize\n elsif self.ready_to_submit?\n return 'Ready to submit'\n elsif self.status_str == 'missing information'\n return \"Waiting on response from #{self.user.name || self.user.email} \"\n elsif ['unopened', 'in review' ].include? self.status_str\n return \"Waiting on response from #{self.current_reviewer.name || self.current_reviewer.email}\"\n elsif next_reviewer.nil?\n return \"Error\"\n else\n return \"Waiting on response from #{next_reviewer.name || next_reviewer.email}\"\n end\n end", "def print_status\n\t\tputs \"#{status}\"\n\tend", "def display_goal\n puts \"\\nYOUR CURRENT GOAL IS: #{self.description}\".light_white\n if self.target_date\n puts \"\\nTARGET DATE TO REACH YOUR GOAL: #{self.target_date.strftime('%-d %B %Y')}\".light_white\n end\n if self.attainable\n puts \"\\nWHY I CAN ACHIEVE THIS GOAL: #{self.attainable}\".light_white\n end\n if self.relevant\n puts \"\\nWHY THIS GOAL MATTERS: #{self.relevant}\".light_white\n end\n end", "def ppg_status\n params[:page] ||= 1\n\n default_ppg_status_code = \"1\"\n @ppg_status_code = params[:ppg_status_code] || default_ppg_status_code\n\n result = PpgStatusHistory.current_ppg_status.with_status(@ppg_status_code).select(\"distinct ppg_status_histories.*, people.last_name\").joins(\n \"inner join participant_person_links on participant_person_links.participant_id = ppg_status_histories.participant_id\n inner join people on people.id = participant_person_links.person_id\"\n ).where(\"participant_person_links.relationship_code = '1'\").order(\"people.last_name\")\n @ppg_statuses = result.paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render :json => result.all }\n end\n end", "def jira_issue_status_stats_text(errata)\n always_shown = Settings.jira_always_shown_states || ['QA In Progress', 'Verified']\n params = {\n :issues => errata.jira_issues,\n :field_name => :status,\n :always_shown => always_shown,\n }\n issue_status_stats_text(params)\n end", "def status\n if index.disert_theme\n @status ||= if index.disert_theme.defense_passed? || index.final_exam_passed?\n ''\n elsif all_subjects_finished?\n I18n::t(:study_plan_completed, :scope => [:model, :plan])\n elsif canceled?\n I18n::t(:study_plan_not_approved, :scope => [:model, :plan])\n elsif approved?\n I18n::t(:study_plan_approved, :scope => [:model, :plan])\n elsif admited?\n I18n::t(:study_plan_admited, :scope => [:model, :plan])\n end\n else\n I18n::t(:missing_disert_theme_title, :scope => [:model, :plan])\n end\n end", "def project_status\n\t\t@project = Project.find(params[:id])\n\n\t\trender 'projects/project_status'\n\tend", "def build_status city_or_county, state, num_killed, num_injured, url\n status = \"#{city_or_county}, #{state}: \"\n\n if num_killed.zero? && num_injured.zero?\n status.concat('no one was hurt. ')\n elsif num_killed.zero?\n status.concat(\"#{num_injured} \")\n .concat('person'.pluralize(num_injured))\n .concat(' injured. ')\n elsif num_injured.zero?\n status.concat(\"#{num_killed} \")\n .concat('person'.pluralize(num_killed))\n .concat(' killed. ')\n else\n status.concat(\"#{num_killed} \")\n .concat('person'.pluralize(num_killed))\n .concat(' killed and ')\n .concat(\"#{num_injured} \")\n .concat('person'.pluralize(num_injured))\n .concat(' injured. ')\n end\n\n status.concat(\"Full report: #{url}\")\n end", "def running_nexus_pro?\n status['edition_long'] == \"Professional\"\n end", "def senpai_title\n \"Senpai\" if grade.senpai?\n end", "def show_state\n return \"#{@name} a #{life_points} points de vie et une amre de niveau #{weapon_level}\"\n end", "def format_status(status)\n value = \"completed\".colorize(:green) if status == true\n value = \"pending\".colorize(:red) if status == false\n \"#{value}\".ljust(10)\n end", "def status\n output = StringIO.new\n output << @game.player.to_s\n output << \"\\n\"\n\n output << \"#{@game.current_room_model.description}\\n\"\n\n treasure = @game.current_room_model.treasure\n output << \"\\nThere is treasure here worth $#{treasure}.\\n\" if treasure && treasure > 0\n\n monster = @game.current_room_model.monster\n if monster\n output << \"\\nDANGER... THERE IS A MONSTER HERE....\\n\\n\"\n output << \"#{@game.current_room_model.monster}\\n\\n\"\n end\n\n if @game.current_room_model.name != \"Exit\"\n output << \"\\nWhat do you want to do? \"\n end\n \n output.string\n end", "def status\n\t\treturn \"Pending\" if !completed\n\t\t\"Completed\"\n\tend", "def print_status\n puts \"HP: #{hp}/#{max_hp}\"\n puts \"Attack: #{attack}\"\n puts \"Defense: #{defense}\"\n print \"\\n\"\n\n print \"Weapon: \"\n if ([email protected]?)\n puts \"#{weapon.name}\"\n else\n puts \"none\"\n end\n\n print \"Helmet: \"\n if ([email protected]?)\n puts \"#{helmet.name}\"\n else\n puts \"none\"\n end\n\n print \"\\n\"\n end", "def show\n set_project_stat\n end", "def show\n set_project_stat\n end", "def online_access_facet_display(value)\n 'Yes'\n end", "def show_status(status_hash)\n ok_butt = cli_say('*',:ok)\n bad_butt = cli_say('*',:warn)\n conf_str = \"\"\n plan_str = \"\"\n proj_str = \"\"\n build_str = \"\"\n\n # :config => {:status => ok,:value =>'Myconfig' }\n status_hash.each do |component_name,component_value|\n case component_value\n when nil\n status = \"[\" + bad_butt + \"] \"\n else\n status = \"[\" + ok_butt + \"] \"\n end\n\n case component_name\n when :config\n conf_str = status + \"Config: \" + (component_value || 'N/A')\n when :testplan\n plan_str = status + \"Test Plan: \" + (component_value || 'N/A')\n when :testproject\n proj_str = status + \"Test Project: \" + (component_value || 'N/A')\n when :build\n build_str = status + 'Build: ' + (component_value || 'N/A')\n end\n end\n\n str=<<-EOF\n#{conf_str}\n#{proj_str}\n#{plan_str}\n#{build_str}\n EOF\n end", "def completion_status\n returnValue = {status: '' , percentage: 0.0}\n #status\n if self.target_amount and self.total_amount\n twenty_five = self.target_amount*0.25\n fifty = self.target_amount*0.5\n seventy_five = self.target_amount*0.75\n if self.total_amount.to_s.to_i > seventy_five\n returnValue[:percentage] = 0.75\n returnValue[:status] = \"Project is almost funded! (Over 75% funded)\"\n elsif self.total_amount.to_s.to_i > fifty\n returnValue[:percentage] = 0.50\n returnValue[:status] = \"Project is half way there! (Over 50% funded)\"\n elsif self.total_amount.to_s.to_i >= twenty_five\n returnValue[:percentage] = 0.25\n returnValue[:status] = \"Project is starting to shape up! (Over 25% funded)\"\n elsif self.total_amount.to_s.to_i < twenty_five\n returnValue[:percentage] = 0.01\n returnValue[:status] = \"Project has got its first donation! (0-25% funded)\"\n else\n returnValue[:percentage] = 0.0\n returnValue[:status] = \"Project has no funding!\"\n end\n returnValue\n else\n nil\n end\n\n end", "def print_out_line\n\t\t\t#p ['id', id, 'ctd', ctd]\n\t\t\t#p rcp.results.zip(rcp.results.map{|r| send(r)})\n\t\t\tname = @run_name\n\t\t\tname += \" (res: #@restart_id)\" if @restart_id\n\t\t\tname += \" real_id: #@real_id\" if @real_id\n\t\t\tbeginning = sprintf(\"%2d:%d %-60s %1s:%2.1f(%s)\", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s)\n\t\t\tif @status == :Incomplete and @completed_timesteps\n\t\t\t\tbeginning += sprintf(\" %d steps \", @completed_timesteps)\n\t\t\telsif @percent_complete\n \t\t\t\tbeginning+=sprintf(\" %3s%1s \", percent_complete, \"%\")\n\t\t\tend\n\t\t\tif ctd\n\t\t\t\t#beginning += sprintf(\"Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20\", fusionQ, pfus, ti0, te0, ne0)\n\t\t\tend\n\t\t\tbeginning += \" ---#{@comment}\" if @comment\n\t\t\tbeginning\n\t\tend", "def render(bool = false)\n if bool && !@empty\n return \"S\"\n end\n if @ship != nil && @ship.sunk\n return \"X\"\n end\n @status\n end", "def status(max_size=nil)\n \" Result for #{title}: \" \\\n + \"Success? #{succeeded? ? 'Yes'.green : 'No'.red}, \" \\\n + \"Skipped: #{skips.to_s.yellow}, \" \\\n + \"Total user time: #{Logger.time(time).blue}, \" \\\n + \"Output files: #{output_files.length.to_s.bold}\"\n end", "def approval_status\n self.approved? ? 'Approved ' : 'Pending '\n end", "def status\n respond_to do |format|\n quest = Quest.find(params[:id])\n quest.update(:status=> params[:string])\n #update status in the db when it is done\n if (params[:string] == \"Done\")\n quest.is_completed=true\n quest.completed_at = DateTime.now.utc\n quest.save\n user = User.find(@current_user.id)\n user.points += 10\n user.save\n if @current_user.gender\n gender = 'Male'\n else\n gender = 'Female'\n end\n User.publish_event :gender, ({:gender => gender})\n\n userQuest = UsersQuest.find_by_quest_id(quest.id)\n if @current_user.id==userQuest.assignor_id && @current_user.id==userQuest.assignee_id\n User.publish_event :quest_type, ({:self_assigned => 'Self Assigned'})\n else\n User.publish_event :quest_type, ({:self_assigned => 'Not Self Assigned'})\n end\n\n notif_user = User.find_by(:id => userQuest.assignor_id)\n notif = Notification.create(:user_id => userQuest.assignor_id,\n :title => \"#{@current_user.first_name} #{@current_user.last_name} has completed your assigned quest: #{quest.title}\",\n :url => quest_path(userQuest.quest_id))\n @options = {:channel => \"/notifs/#{userQuest.assignor_id}\",\n :message => notif.title,\n :count => \"#{User.unread_notifications_count notif_user}\", :redirect => quest_path(params[:id]),\n :url => quest_path(userQuest.quest_id),\n :id => notif.id}\n\n end\n format.html {redirect_to quest_path(params[:id])}\n format.js\n end\n end", "def print_out_line\n #p ['id', id, 'ctd', ctd]\n #p rcp.results.zip(rcp.results.map{|r| send(r)})\n name = @run_name\n name += \" (res: #@restart_id)\" if @restart_id\n name += \" real_id: #@real_id\" if @real_id\n beginning = sprintf(\"%2d:%d %-60s %1s:%2.1f(%s) %3s%1s\", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s, percent_complete, \"%\")\n if ctd and fusionQ\n beginning += sprintf(\"Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20\", fusionQ, pfus, ti0, te0, ne0)\n end\n beginning += \" ---#{@comment}\" if @comment\n beginning\n end", "def get_status()\n\n puts \"Rounds: #{@rounds}\"\n puts \"Player wins: #{@player_wins}\"\n puts \"Computer wins: #{@computer_wins}\"\n puts \"Ties: #{@ties}\\n\\n\"\n \n\n end", "def select_project_to_update_production_progress\n @projects = current_user.assigned_projects_for( PROJECT_ROLE[:post_production] ) \n add_breadcrumb \"Select Project\", 'select_project_to_update_production_progress_url'\n \n render :file => \"projects/project_management/select_project_to_update_production_progress\"\n end", "def patient_status_str\n case self.status\n when 0\n return 'New visit' \n when 7 \n return 'Cancelled' \n when 3..5 \n return 'Complete' \n else\n return 'In Process'\n end\n end", "def status\n case status_id\n when ReferenceData::PO_ITEM_PREPARING\n \"<em style='color:red'>Ordering</em>\"\n when ReferenceData::PO_ITEM_SENT_TO_CENTRAL\n \"<em style='color:brown'>Sent to Central</em>\"\n when ReferenceData::PO_ITEM_SENT_TO_SUPPLIER\n \"<em style='color:green'>Sent to PO</em>\"\n when ReferenceData::PO_ITEM_UNCATEGORIZED\n \"<em style='color:red'>Uncategorized</em>\"\n end\n \n end", "def show_state\n return puts \"#{super} et une arme de niveau \\\"#{@weapon_level}\\\"\"\n end", "def status_message\n if self.deleted_at\n return \"Cancelled\"\n else\n if self.chosen_presenter == nil\n if self.help_required\n return \"Help Required\"\n elsif self.presenters.present?\n return \"Bids Pending\"\n else\n return \"Awaiting Bids\"\n end\n else\n if self.booking_date < Time.now\n return \"Completed\"\n else\n return \"Locked in\"\n end\n end\n end\n end", "def to_s\n status = done? ? \"[X]\" : \"[ ]\"\n \"#{status} \"\\\n \"Name: #{@name} | \"\\\n \"Description: #{@description[0..20]} | \"\\\n \"Prep: #{@prep_time}\"\n end", "def other_game_status\n status = []\n\n unless @game.offering.empty?\n status << h(:h3, 'Offering')\n comps = @game.offering.map do |company|\n h(Company, company: company)\n end\n status << h(:div, comps)\n end\n\n status << h(:h3, 'Remaining Deck')\n if @game.company_deck.empty?\n status << h(:div, '(Empty)')\n else\n deck = @game.company_deck.reverse.map do |company|\n deck_item_style = {\n display: 'inline-block',\n backgroundColor: @game.company_colors(company)[0],\n padding: '4px',\n border: '1px solid black',\n height: '20px',\n margin: '4px',\n }\n h(:div, { style: deck_item_style })\n end\n status << h(:div, deck)\n end\n\n table_props = {\n style: {\n backgroundColor: 'white',\n color: 'black',\n margin: '0',\n border: '1px solid',\n borderCollapse: 'collapse',\n },\n }\n tr_props = {\n style: {\n border: '1px solid black',\n },\n }\n th_props = {\n style: {\n border: '1px solid black',\n },\n }\n\n status << h(:h3, 'Current Cost of Ownership')\n\n cost_card_props = {\n style: {\n display: 'inline-block',\n backgroundColor: @game.class::STAR_COLORS[@game.cost_level]&.[](0) || 'white',\n color: 'black',\n padding: '20px 60px 20px 60px',\n border: '1px solid',\n borderRadius: '10px',\n },\n }\n\n cost_rows = [h(:tr, tr_props, [h(:th, th_props, 'Level'), h(:th, th_props, 'Cost')])]\n @game.cost_table[@game.cost_level].each_with_index do |cost, idx|\n level_props = {\n style: {\n backgroundColor: @game.class::STAR_COLORS[idx + 1][0],\n border: '1px solid',\n },\n }\n td_props = {\n style: {\n border: '1px solid',\n },\n }\n cost_rows << h(:tr, tr_props, [\n h(:td, level_props, @game.level_symbol(idx + 1)),\n h(:td, td_props, @game.format_currency(cost)),\n ])\n end\n status << h(:div, cost_card_props, [\n h(:table, table_props, [\n h(:tbody, cost_rows),\n ]),\n ])\n\n # show target book/stars for each share price\n status << h(:h3, @game.share_card_description)\n sorted_prices = @game.prices.keys.sort\n share_cards = sorted_prices.map { |p| share_card(@game.prices[p]) }\n status << h(:div, share_cards)\n\n status\n end", "def status\n output = \"\"\n\n output << \"You are dead!!!\"\n output << \"Game Over\"\n end", "def display_job_status(job_status)\n job_display_entries = {\n \"status\" => job_status[\"status_description\"],\n \"progress\" => \"#{job_status[\"progress\"]}%\",\n \"cluster_id\" => job_status[\"cluster_id\"],\n \"job submitted at\" => job_status[\"start_timestamp\"],\n \"job began running at\" => job_status[\"running_timestamp\"],\n \"job finished at\" => job_status[\"stop_timestamp\"],\n \"job running for\" => job_status[\"duration\"],\n \"job run with parameters\" => job_status[\"parameters\"],\n }\n\n \n unless job_status[\"error\"].nil? || job_status[\"error\"][\"message\"].nil?\n error_context = get_error_message_context(job_status[\"error\"][\"message\"])\n unless error_context == \"\"\n job_status[\"error\"][\"help\"] = error_context\n end\n job_status[\"error\"].each_pair do |key, value|\n job_display_entries[\"error - #{key}\"] = value\n end\n end\n \n if job_status[\"num_hadoop_jobs\"] && job_status[\"num_hadoop_jobs_succeeded\"]\n job_display_entries[\"hadoop jobs complete\"] = \n '%0.2f / %0.2f' % [job_status[\"num_hadoop_jobs_succeeded\"], job_status[\"num_hadoop_jobs\"]]\n end\n \n if job_status[\"outputs\"] && job_status[\"outputs\"].length > 0\n job_display_entries[\"outputs\"] = Hash[job_status[\"outputs\"].select{|o| o[\"alias\"]}.collect do |output|\n output_hash = {}\n output_hash[\"location\"] = output[\"location\"] if output[\"location\"]\n output_hash[\"records\"] = output[\"records\"] if output[\"records\"]\n [output['alias'], output_hash]\n end]\n end\n \n styled_header(\"#{job_status[\"project_name\"]}: #{job_status[\"pigscript_name\"]} (job_id: #{job_status[\"job_id\"]})\")\n styled_hash(job_display_entries)\n end", "def status(assignment, student)\n s = assignment.get_submission(student)\n if s\n if s.complete?\n return 'complete'\n # content_tag(:span, 'COMPLETE', class: \"radius success label\")\n # link_to \"Submitted URL\", s.url\n # link_to \"Review\", edit_assignment_submission_path(assignment.id, s)\n else\n return 'up_for_review'\n # content_tag(:span, 'UP FOR REVIEW', class: \"radius regular label\")\n # link_to \"Submitted URL\", s.url\n # link_to \"Review\", edit_assignment_submission_path(assignment.id, s)\n end\n else\n return 'no_submission'\n # content_tag(:span, 'NO SUBMISSION', class: \"radius alert label\")\n end\n end", "def ppg_status\n participant.ppg_status.local_code if participant && participant.ppg_status\n end", "def status_label label\n if label == \"assigned\"\n raw \"<span class='label'>Assigned</span>\"\n elsif label == \"progress\"\n raw \"<span class='label label-info'>In Progress</span>\"\n elsif label == \"submit\"\n raw \"<span class='label label-warning'>Submitted</span>\"\n elsif label == \"reopen\"\n raw \"<span class='label label-info'>Reopened and Now In Progress</span>\"\n elsif label == \"approve\"\n raw \"<span class='label label-success'>Approved</span>\"\n else\n \"\"\n end\n end", "def bug_status_stats_text(errata)\n params = {\n :issues => errata.bugs,\n :field_name => :bug_status,\n :always_shown => %w[VERIFIED ON_QA],\n }\n issue_status_stats_text(params)\n end", "def state_s\n # return \"审核中\" if approving?\n return \"等待激活中\" if unapproved?\n return \"审核被拒绝\" if rejected?\n return \"展示中\" if opened? and available?\n return \"高亮展示中\" if highlighted? and opened? and available?\n return \"已过期\" if !available?\n return \"未展示\" if closed?\n end", "def to_s\n\t\t\tstr = super() + \"\\n\"\n\t\t\tstr += \"\\tAppaleable? #{appaleable}\\n\" if appaleable\n\t\t\tstr += \"\\tDisapproved text: #{disapproved_text}\\n\" if disapproved_text\n\t\t\tstr += \"\\tLocation: #{location}\\n\" if location\n\t\t\tstr += \"\\tDisapproved text: #{disapproved_text}\\n\" if disapproved_text\n\t\t\tstr += \"\\tReason code: #{reason_code} (see: http://msdn.microsoft.com/en-US/library/bing-ads-editorialfailurereasoncodes.aspx)\\n\" if reason_code\n\n\t\tend", "def proposal_status(proposal)\n if proposal.key?(:decision)\n proposal.fetch(:decision)\n else\n proposal[:submitted_at].nil? ? 'draft' : 'submitted'\n end\n end", "def print_status\n super\n print_battle_commands unless battle_commands.empty?\n end", "def print_status\n super\n print_battle_commands unless battle_commands.empty?\n end", "def status\n $stdout.puts \"The current status of the pow server is:\\n\\n\"\n result = %x{curl localhost/status.json --silent --header host:pow}\n json = JSON.parse(result)\n json.each_pair { |k,v| $stdout.puts \" #{k}: #{v}\" }\n $stdout.puts \"\\n\"\n end", "def show_options\n head :ok\n end", "def print_out_line\n name = @run_name\n name += \" (res: #@restart_id)\" if @restart_id\n name += \" real_id: #@real_id\" if @real_id\n beginning = sprintf(\"%2d:%d %-60s %1s:%2.1f(%s) %3s%1s\", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s, percent_complete, \"%\")\n if ctd\n #beginning += sprintf(\"Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20\", fusionQ, pfus, ti0, te0, ne0)\n end\n beginning += \" ---#{@comment}\" if @comment\n beginning\n end", "def header_status_text\n\t\tif params[:status] == \"active\"\n\t\t\t'Active'\n\t\telsif params[:status] == \"inactive\"\n\t\t\t'Inactive'\n\t\telse\n\t\t\t'All'\n\t\tend\n\tend", "def display_status\n busy? ? 'busy' : 'available'\n end", "def status_options\n [\n {label: 'To-do', value: 'todo'},\n {label: 'In Progress', value: 'inprogress'},\n {label: 'To Verify', value: 'toverify'},\n {label: 'Done', value: 'done'}\n ]\n end", "def print_info\n params = Hash[\n :working, `pwd`.strip,\n :setting_file, ENV['SETTING_FILE'],\n :platform, @platform,\n :project_path, project_path,\n :unity_editor_platform, unity_editor_platform,\n :build_path, build_path,\n :ipa_path, ipa_path,\n :apk_path, apk_path,\n :build_version, build_version,\n :product_name, product_name,\n :bundle_version, bundle_version,\n :build_number, build_number,\n ]\n\n UI.message \"\\n#{Terminal::Table.new(\n title: 'Build info'.green,\n headings: %w[Option Value],\n rows: FastlaneCore::PrintTable.transform_output(params)\n )}\"\n\n print_help\nend", "def submission_status_label(status)\n case status\n when 'Queued'\n label_class = 'secondary'\n when 'Submitted'\n label_class = 'info'\n when 'Running'\n label_class = 'primary'\n when 'Done'\n label_class = 'success'\n when 'Aborting'\n label_class = 'warning'\n when 'Aborted'\n label_class = 'danger'\n else\n label_class = 'dark'\n end\n \"<span class='badge badge-#{label_class}'>#{status}</span>\".html_safe\n end", "def status_to_s\n \tSTATUSES[self.status].humanize\n end", "def status_panel(equipment, notification_level = 'primary')\n last_status = equipment.statuses.last\n render 'batches/equipment_status_panel',\n equipment: {\n title: equipment.panel_title,\n status: status_indicator_label_text(last_status),\n label: status_indicator_label_type(last_status),\n notification: notification_level\n }\n end", "def show_state\r\n puts \"#{@name} à #{@life_points} points de vie et une arme de niveau #{@weapon_level}\"\r\n end", "def status\n \"#{@name}: #{@lives}/3 \"\n end", "def show_state\n return \"#{@name} a #{@life_points} points de vie\"\n end", "def status\n return 'Appealed' if self.punishment.appealed?\n return 'Closed' if !self.open || self.locked\n return 'Escalated' if self.escalated\n return 'Open'\n end", "def get_status_string(status)\n case status\n when :started, :scheduled then \"#{Tty.green}#{status}#{Tty.reset}\"\n when :stopped, :none then \"#{Tty.default}#{status}#{Tty.reset}\"\n when :error then \"#{Tty.red}error #{Tty.reset}\"\n when :unknown then \"#{Tty.yellow}unknown#{Tty.reset}\"\n end\n end", "def show_state\n puts \"#{@name} a #{@life_points} points de vie et une arme de niveau #{@weapon_level}\"\n end", "def show_cucumber_status(text = nil)\n print \"Spork Cucumber: #{status(@cucumber_pid, text)}\\n\"\n end", "def display_status\n if is_incoming_message?\n status = self.calculated_state\n if !status.nil?\n if status == 'waiting_response'\n return \"Acknowledgement\"\n elsif status == 'waiting_clarification'\n return \"Clarification required\"\n elsif status == 'gone_postal'\n return \"Handled by post\"\n elsif status == 'not_held'\n return \"Information not held\"\n elsif status == 'rejected'\n return \"Rejection\"\n elsif status == 'partially_successful'\n return \"Some information sent\"\n elsif status == 'successful'\n return \"All information sent\"\n elsif status == 'internal_review'\n return \"Internal review acknowledgement\"\n elsif status == 'user_withdrawn'\n return \"Withdrawn by requester\"\n elsif status == 'error_message'\n return \"Delivery error\"\n elsif status == 'requires_admin'\n return \"Unusual response\"\n end\n raise \"unknown status \" + status\n end\n return \"Response\"\n end\n\n if is_outgoing_message?\n status = self.calculated_state\n if !status.nil?\n if status == 'internal_review'\n return \"Internal review request\"\n end\n if status == 'waiting_response'\n return \"Clarification\"\n end\n raise \"unknown status \" + status\n end\n return \"Follow up\"\n end\n\n raise \"display_status only works for incoming and outgoing messages right now\"\n end", "def show_state\n\t\treturn \"#{self.name} a #{self.life_points} points de vie.\"\n\tend", "def filtered_single_interview\n @user_company = JointUserCompany.find_by(user_id: @user.id, company_id: @company.id)\n @user_status = @user_company.status\n @submissions = @interview.submissions.where(current_no: 500, status: params[:status].to_i).paginate(:page => params[:page], :per_page => 24).order('created_at DESC')\n @meg = params[:status].to_i\n if (@meg == 0 )\n @peg = \"Shortlist\"\n @prefiled_mes = \"In response to the Interview you took with our company, we glad to inform you have been shorlisted\"\n elsif(@meg == 2)\n @peg = \"Reject\"\n @prefiled_mes = \"Thank you for taking interview with us.\n However, you did not make the final list\n We wish you best in future endeavors\"\n end\n render :action => 'single_interview_submissions', :layout => 'single_interview_submissions'\nend" ]
[ "0.58567435", "0.5784298", "0.57741016", "0.57447994", "0.56720454", "0.5654737", "0.55385166", "0.5510709", "0.54969966", "0.54466313", "0.5406813", "0.5391828", "0.53888786", "0.5383061", "0.5366101", "0.53650916", "0.5333901", "0.5333901", "0.5322467", "0.53190243", "0.5309751", "0.5299751", "0.5293982", "0.5282684", "0.5273117", "0.52604604", "0.52532667", "0.525253", "0.5250335", "0.52434283", "0.5241143", "0.5213125", "0.5200348", "0.51909083", "0.51905644", "0.5188419", "0.5186782", "0.51801014", "0.51793325", "0.5177187", "0.5177029", "0.51657003", "0.51643133", "0.5150024", "0.5141161", "0.5130806", "0.5125609", "0.5120391", "0.5120159", "0.5117239", "0.51068604", "0.51068604", "0.5101511", "0.50850296", "0.50707126", "0.5060397", "0.5046521", "0.50423384", "0.50341785", "0.50301075", "0.50286615", "0.5020595", "0.5013108", "0.50103366", "0.50094277", "0.5006207", "0.50052875", "0.49899966", "0.4984363", "0.49819866", "0.49790508", "0.4965349", "0.49545932", "0.49514312", "0.49512815", "0.49496073", "0.49456915", "0.49376446", "0.4935119", "0.4935119", "0.49341252", "0.49340612", "0.49295518", "0.49286804", "0.4926741", "0.49255627", "0.49246627", "0.492219", "0.49204662", "0.49203795", "0.49198285", "0.4919433", "0.4910784", "0.4910562", "0.49104735", "0.49054614", "0.48922396", "0.4890479", "0.48871735", "0.48859015" ]
0.76040083
0
GET /partners/1 Shows a particular partner's page
def show @partner = Partner.find(params[:id]) # because you can review either a company or a partner, both company and partner are considered a reviewable. # each review belongs to this phantom reviewable object that is indeed a partner @reviewable = @partner @reviews = @reviewable.reviews @review = Review.new respond_to do |format| format.html # show.html.erb format.json { render json: @partner } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n\t\t@partner = Partner.find(params[:id])\n\tend", "def index\n @partners = Partner.order(id: :desc).page(params[:page]).per(25)\n end", "def show\n @partner = Partner.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n end\n end", "def show\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner }\n end\n end", "def partners\n @users = User.get_users(:partner, @page)\n end", "def partners\n @page_title = I18n.t(:content_partners)\n # FIXME: missing association :content_partner below\n # content partners will have a username\n @partners = Agent.paginate(:conditions => 'username!=\"\" AND content_partners.show_on_partner_page = 1', :order => 'agents.full_name asc', :include => :content_partner, :page => params[:page] || 1)\n\n end", "def index\n @partners = Partner.all\n end", "def get_partner_by_identifier\n @partner = Partner.find_by!(partner_id: params[:id])\n rescue ActiveRecord::RecordNotFound\n render_404\n end", "def show\n @partner = Partner.find(params[:id])\n @page_title = @partner.name\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @partner.to_xml(:except => NB_CONFIG['api_exclude_fields']) }\n format.json { render :json => @partner.to_json(:except => NB_CONFIG['api_exclude_fields']) }\n end\n end", "def show\n @partner_type = PartnerType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner_type }\n end\n end", "def set_partner\n @partner = Partner.friendly.find(params[:id])\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 partners\n end", "def show\n @partner_person = PartnerPerson.find(params[:id])\n @title = \"association partners <--> peoples\"\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @partner_person }\n end\n end", "def index\n @partner_profiles = PartnerProfile.all\n end", "def set_partner\n @partner = Partner.find(params[:id])\n end", "def set_partner\n @partner = Partner.find(params[:id])\n end", "def show\n @partner_project = PartnerProject.find(params[:id])\n @project = @partner_project.project \n @partner = @partner_project.partner \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner_project }\n end\n end", "def index\n @contact_partners = ContactPartner.all\n @contact_partners = ContactPartner.paginate(:per_page => 15, :page => params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contact_partners }\n end\n end", "def show\n @optinpartner = Optinpartner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @optinpartner }\n end\n end", "def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @partners.to_xml }\n end\n end", "def display_partners\n\t\t# get an aggregate query of necessary info for the partnerships and their most recent encounter\n\t\tp_sorted = current_user_profile.partners_with_most_recent\n\t\tagg = p_sorted.map do |ship|\n\t\t\t# make a list item\n\t\t\tcontent_tag(:li, {class: \"button-list__item\"}) do\n\t\t\t\t# link to that partnership's show page\n\t\t\t\tlink_to(partnership_path(ship[\"_id\"]), class: 'cta cta--is-square partnership-link') do\n\t\t\t\t\tdisplay_partner(ship)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t# join and nest\n\t\tcontent_tag(:ul, safe_join(agg), {class: \"button-list container--has-centered-child__centered-child\"})\n\tend", "def partner_detail\n if params[:jeton] == 'grvpc'\n @query = Grvpc.find_by(id: params[:id])\n elsif params[:jeton] == 'metropolis'\n @query = Metropoli.find_by(id: params[:id])\n elsif params[:jeton] == 'member'\n @query = Member.find_by(id: params[:id])\n end\n #render layout: 'fylo'\n render layout: 'views/index'\n end", "def show\n @partner_link = PartnerLink.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @partner_link }\n end\n end", "def index\n @potential_partners = PotentialPartner.all\n end", "def new\n @page_title = t('partners.new.title', :government_name => current_government.name)\n @partner = Partner.new\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def show\n @contact_partner = ContactPartner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contact_partner }\n end\n end", "def edit\n @partner = Partner.find(params[:id])\n end", "def partner_service_request\n @service_requests = @user.get_partner_service_requests(@page)\n end", "def set_partner\n @partner = Partner.find_by(osra_id: params[:partner_id])\n end", "def new\n @partner = Partner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner }\n end\n end", "def index\n if params[:term]\n @partners = Partner.scoped.order(:name).where(\"name ILIKE ?\", \"%#{params[:term]}%\")\n else\n @partners = Partner.scoped\n end\n @partner = Partner.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners.map(&:name) }\n end\n end", "def set_partner_profile\n @partner_profile = PartnerProfile.find(params[:id])\n end", "def show\n @external_partnership = ExternalPartnership.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @external_partnership }\n end\n end", "def show\n redirect_to edit_partner_url()\n end", "def index\n @type_partners = TypePartner.all\n end", "def find_partners_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PartnerApi.find_partners ...'\n end\n # resource path\n local_var_path = '/partners'\n\n # query parameters\n query_params = {}\n query_params[:'tags'] = @api_client.build_collection_param(opts[:'tags'], :csv) if !opts[:'tags'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<Partner>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PartnerApi#find_partners\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @partner_payments = PartnerPayment.all\n end", "def show\n @business_partner = BusinessPartner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @business_partner }\n end\n end", "def trading_partners(params = {})\n trading_partner_id = params.delete :trading_partner_id\n\n response =\n default_scope.get(\"tradingpartners/#{trading_partner_id}\") do |request|\n request.params = params\n end\n JSON.parse(response.body)\n end", "def set_partner\n @partner = User.find(params[:id])\n end", "def find_partners(opts = {})\n data, _status_code, _headers = find_partners_with_http_info(opts)\n data\n end", "def index\n @partners = Partner.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 10, :page => params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.js \n format.xml { render :xml => @partners }\n end\n end", "def new\n @partner_person = PartnerPerson.new\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partner_person }\n end\n end", "def new\n @partner_project = PartnerProject.new\n @partners = Partner.all\n @projects = Project.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner_project }\n end\n end", "def show\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pago }\n end\n end", "def view\n \t@parent = params[:parent]\n\n @pages = Page.where(\"digital_edition_id = ?\", @parent).order(\"page_page ASC\").page( params[:page]).per(20)\n\n respond_to do |format|\n format.html # view.html.erb\n format.json { render json: @page }\n end\n end", "def fetch_page_part(name, part, options = {})\n fetch('/page/%s/%s' % [name, part], options)\n end", "def show\n @political_party = PoliticalParty.find(params[:id])\n @miembros = @political_party.miembros.paginate :page => params[:page], :per_page => 50\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @political_party }\n end\n end", "def partner_params\n params.fetch(:partner, {})\n end", "def index\n @page_count, @clients = Locomotive::Client.paginated(:page => (params[:page] || 1).to_i)\n display @clients\n end", "def get_partner\n partner = self.get_team_members.sample\n @user.set_partner(partner)\n partner\n end", "def show\n @user = User.find_by_name(params[:name])\n @participants = Participant.find_all_by_user_id(@user.id).paginate(:page => params[:page], :per_page => 5)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def approve_partner\n @partner = current_organization.partners.find(params[:id])\n\n # TODO: create a service that abstracts all of this from PartnersController, like PartnerDetailRetriever.call(id: params[:id])\n\n # TODO: move this code to new service,\n @diaper_partner = DiaperPartnerClient.get(id: params[:id])\n @diaper_partner = JSON.parse(@diaper_partner, symbolize_names: true) if @diaper_partner\n @agency = if @diaper_partner\n @diaper_partner[:agency]\n else\n autovivifying_hash\n end\n end", "def show\n @pokeparty = Pokeparty.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pokeparty }\n end\n end", "def show\n @partner = Partner.find(params[:id])\n @issueable = @partner\n @issues = @issueable.issues\n @issue = Issue.new\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner }\n end\n end", "def show\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def show\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def show\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def index\n @parties = Party.order(:name).all\n\n respond_to do |format|\n format.html\n format.json { render json: @parties }\n format.xml { render xml: @parties }\n end\n end", "def current_partner\n return nil if request.subdomains.size == 0 or request.host == current_government.base_url or request.subdomains.first == 'dev' or (request.host.include?(NB_CONFIG['multiple_government_base_url']) and request.subdomains.size == 1)\n @current_partner ||= Partner.find_by_short_name(request.subdomains.first)\n end", "def partner\n @services = Service.all\n @countries = Country.all\n @departments = Department.all\n end", "def show\n @counterparty = Counterparty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @counterparty }\n end\n end", "def destroy\n\t\t@partner = Partner.find(params[:id])\n\t\[email protected]\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(partners_url) }\n\t\t\tformat.xml { head :ok }\n\t\tend\n\tend", "def show\n @toyota_epc_part_number_list_child = ToyotaEpc::PartNumberListChild.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @toyota_epc_part_number_list_child }\n end\n end", "def index\n @participates = Participate.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @participates }\n end\n end", "def index\n @partnering_organizations = PartneringOrganization.all\n end", "def paid_user_verify(partner)\n go_to_plan(partner) # my plan page\n go_to_devices(partner) # devices\n go_to_profile(partner) # profile page\n go_to_downloads(partner)\n go_to_stash(partner)\n go_to_acct(partner) # default is to load this page w/o a 'go to account' link\n end", "def show\n @participants = Participant.where(lanparty_id: @lanparty.id)\n @games = Partygame.where(lanparty_id: @lanparty.id)\n if current_user and current_user.lanparties.include? @lanparty\n @participant = Participant.where(\"user_id = ? and lanparty_id = ?\", current_user.id, @lanparty.id).first\n else\n @participant = Participant.new\n @participant.lanparty = @lanparty\n end\n end", "def set_partner_payment\n @partner_payment = PartnerPayment.find(params[:id])\n end", "def show\n @partner_coordinator_association = PartnerCoordinatorAssociation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @partner_coordinator_association }\n end\n end", "def new\n @partner_type = PartnerType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner_type }\n end\n end", "def show\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientsOffers }\n end\n end", "def create\n @partner = Partner.new(partner_params)\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'You are partnered up!' }\n format.json { render :show, status: :created, location: @partner }\n else\n format.html { render :new }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n #@partnerships = Partnership.all\n @participant = Participant.find_by(user_id: current_user.id)\n @partnerships = @participant.partnerships.distinct\n end", "def view_partner_detail(search_key)\n find_link(search_key).click\n end", "def index\n @manufacturer_partners = ManufacturerPartner.all.order(:name)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @manufacturer_partners }\n format.json { render json: @manufacturer_partners }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n end", "def index\n @clients = Client.all.paginate(page: params[:page], per_page: 4)\n end", "def index\n @previous_parties = PreviousParty.all\n end", "def set_potential_partner\n @potential_partner = PotentialPartner.find(params[:id])\n end", "def index\n @crew_category_partners = CategoryPartner.all\n end", "def show\n @draft_partnership = DraftPartnership.find(params[:id])\n\n respond_to do |format|\n \n format.xml { render :xml => @draft_partnership }\n end\n end", "def index\n @participants = Participant.paginate :all, :page => params[:page], :order => \"lastname ASC, firstname ASC\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def index\n @participants = Participant.paginate :all, :page => params[:page], :order => \"lastname ASC, firstname ASC\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def destroy\n @partner = Partner.find(params[:id])\n @partner.destroy\n\n respond_to do |format|\n format.html { redirect_to(partners_url) }\n end\n end", "def parties(session_id)\n fetch \"eksport/partier/?sesjonid=#{session_id}\"\n end", "def new\n @optinpartner = Optinpartner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @optinpartner }\n end\n end", "def key_details(key_id)\n HTTParty.get(\"#{$base_url}/partners/#{$partner_id}/keys/#{key_id}\", {headers: $headers}).parsed_response\nend", "def show\n @party = Party.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @party }\n end\n end", "def view_partner_details(search_key)\n find_link(search_key).click\n end", "def create\n @practice = Practice.new(practice_params)\n if params[:recruiter_partner].present?\n @partner = Partner.find(params[:recruiter_partner])\n @practice.partners << @partner\n end\n\n @practice.site_id = @current_partner.site.id\n\n respond_to do |format|\n if @practice.save\n format.html { redirect_to partner_path(current_partner), notice: 'Practice was successfully created.' }\n format.json { render :show, status: :created, location: @practice }\n else\n format.html { render :new }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @parties = Party.all\n end", "def index\n @parties = Party.all\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @partenaire = Partenaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @partenaire }\n end\n end", "def show\n @partenaire = Partenaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @partenaire }\n end\n end" ]
[ "0.75801116", "0.7450938", "0.7346493", "0.72480327", "0.72442114", "0.72284573", "0.7019085", "0.699739", "0.69663185", "0.67077", "0.6596621", "0.65813583", "0.6550096", "0.65385556", "0.65384877", "0.6514343", "0.6514343", "0.65006644", "0.64846575", "0.6443035", "0.6419349", "0.64173335", "0.64058506", "0.63684446", "0.63556373", "0.6242423", "0.6200412", "0.6199013", "0.61927927", "0.6157592", "0.61348504", "0.60852945", "0.6042961", "0.6038264", "0.6031317", "0.5992805", "0.59296894", "0.5912592", "0.5902042", "0.58829", "0.5877202", "0.58358604", "0.5832992", "0.58152455", "0.5802111", "0.5796554", "0.5775683", "0.5766277", "0.5765579", "0.5744213", "0.57375133", "0.5734639", "0.5717227", "0.57168734", "0.56986725", "0.5694989", "0.5679526", "0.5679526", "0.5679526", "0.5675588", "0.5671175", "0.56374943", "0.56241316", "0.56227237", "0.5619486", "0.5618264", "0.56162876", "0.5606058", "0.5599243", "0.55958635", "0.558203", "0.558145", "0.5581188", "0.55661243", "0.55525744", "0.5538834", "0.5503215", "0.5502556", "0.54984444", "0.5496209", "0.5490121", "0.54859066", "0.54823726", "0.54790413", "0.54790413", "0.5476723", "0.5475334", "0.54718506", "0.54388136", "0.5432527", "0.5427413", "0.54235214", "0.5421826", "0.5421826", "0.5418575", "0.5418575", "0.5418575", "0.5418575", "0.541855", "0.541855" ]
0.6604026
10
GET /partners/1/edit Shows the edit page for a partner
def edit @partner = Partner.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n redirect_to edit_partner_url()\n end", "def update\n respond_to do |format|\n if @partner.update(partner_params)\n format.html { redirect_to [:admin, @partner], notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n\t\t@partner = Partner.find(params[:id])\n\tend", "def update\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n format.html { redirect_to @partner }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n format.html { redirect_to @partner, notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n format.html { redirect_to @partner, notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partner_person = PartnerPerson.find(params[:id])\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n if @partner_person.update_attributes(params[:partner_person])\n format.html { redirect_to(@partner_person, :notice => 'PartnerPerson was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @partner_person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @partner.update(partner_params)\n format.html { redirect_to @partner, notice: 'Partner was successfully updated.' }\n format.json { render :show, status: :ok, location: @partner }\n else\n format.html { render :edit }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @optinpartner = Optinpartner.find(params[:id])\n\n respond_to do |format|\n if @optinpartner.update_attributes(params[:optinpartner])\n format.html { redirect_to @optinpartner, notice: 'Optinpartner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @optinpartner.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @party = Party.find(params[:id])\n end", "def set_partner\n @partner = Partner.find(params[:id])\n end", "def set_partner\n @partner = Partner.find(params[:id])\n end", "def edit\n @offer = InternshipOffer.find(params[:id])\n end", "def show\n @partner = Partner.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n end\n end", "def update\n\t\t@partner = Partner.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @partner.update_attributes(params[:partner]) and @partner.contact.update_attributes(params[:contact])\n\t\t\t\tformat.html { redirect_to(@partner, :notice => 'Partner was successfully updated.') }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @partner.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def edit\n \t\t@leader = Leader.find(params[:id])\n \tend", "def set_partner\n @partner = Partner.friendly.find(params[:id])\n end", "def update\n @partner = Partner.find(params[:id])\n @page_title = t('partners.settings.title') \n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n flash[:notice] = t('partners.settings.success')\n format.html { \n if not @partner.has_picture?\n redirect_to picture_partner_path(@partner)\n elsif params[:partner][:name]\n redirect_to :action => \"edit\"\n else\n redirect_to :action => \"email\"\n end\n }\n else\n format.html { \n if params[:partner][:name]\n render :action => \"edit\" \n else # send them to the partner email update\n render :action => \"email\"\n end\n }\n end\n end\n end", "def edit\n @officer = Officer.find(params[:id])\n end", "def edit\n @clients = current_client\n end", "def edit\n @competitor = Competitor.find(params[:id])\n end", "def edit\n\n end", "def edit\n @profesor = Profesor.find(params[:id])\n end", "def edit\n @renter = Renter.find params[:id]\n end", "def edit\n @offer = Offer.find(params[:id])\n end", "def update\n @models = self.class.model_class.find(params[:id])\n\n respond_to do |format|\n if @models.update_attributes(params[:partners])\n flash[:notice] = 'Partners was successfully updated.'\n format.html { redirect_to(@models) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @models.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit(params)\n http_helper.send_post_request(\"#{@url_prefix}/edit\", params)\n end", "def update\n @partner_type = PartnerType.find(params[:id])\n\n respond_to do |format|\n if @partner_type.update_attributes(params[:partner_type])\n format.html { redirect_to @partner_type, notice: 'Partner type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n\t\t# must have admin access or be in the course\n\tend", "def edit(params = {})\n http_helper.send_post_request(\"#{@url_prefix}/edit\", params)\n end", "def show\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner }\n end\n end", "def edit\n # Renders the edit form\n end", "def edit\n render\n end", "def edit\n render\n end", "def set_partner\n @partner = Partner.find_by(osra_id: params[:partner_id])\n end", "def edit\n respond_with(page)\n end", "def edit\n @renter = Renter.find(params[:id])\n end", "def edit\n\t @team = Team.find(params[:id])\n\t\t@leaders = Leader.all.order(room: :asc)\n\tend", "def edit\n\t\t@provider_accounts = provider_accounts_for_user\n\t\t@server_profile_revision = ServerProfileRevision.find(params[:id])\n\t\t@users = User.find(:all, :order => :login)\n \n\t\trespond_to do |format|\n \t\t\tformat.html # edit.html.erb\n\t\t\tformat.json { render :json => @server_profile_revision }\n\t\tend\n\tend", "def set_partner_profile\n @partner_profile = PartnerProfile.find(params[:id])\n end", "def update\n @partenaire = Partenaire.find(params[:id])\n\n respond_to do |format|\n if @partenaire.update_attributes(params[:partenaire])\n flash[:notice] = I18n.t(:successfully_modified_partner)\n format.html { redirect_to(partenaires_path()) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @partenaire.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit\n\t\tPesqSecDep()\n\t\t# Validação para permitir o acesso de clientes logados.\n\t\tif session[:logged] == true\n\t\t\t@cliente = Cliente.find(params[:id])\n\t\telse\n\t\t\tif session[:logcli] != 0 and session[:logcli] != nil\n\t\t\t\t@cliente = Cliente.find(session[:logcli])\n\t\t\telse\n\t\t\t\tredirect_to(\"/loja\")\n\t\t\t\treturn\n\t\t\tend\t\n\t\tend\t\t\n\n\tend", "def edit\n @telefono = @persona.telefonos.find(params[:id])\n end", "def edit\n \n end", "def edit\n\n end", "def edit\r\n \r\n end", "def edit\r\n end", "def edit\n respond_with(account)\n end", "def edit\r\n render :edit\r\n end", "def edit_petsitter_personal_details\n\t\t@petsitter = Petsitter.find( params[:id] )\n\t\t# then renders view with next step(2nd) form\n\tend", "def update\n respond_to do |format|\n if @partner_profile.update(partner_profile_params)\n format.html { redirect_to @partner_profile, notice: 'Partner profile was successfully updated.' }\n format.json { render :show, status: :ok, location: @partner_profile }\n else\n format.html { render :edit }\n format.json { render json: @partner_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @person = Person.find(params[:id])\n end", "def edit\n @person = Person.find(params[:id])\n end", "def edit\n @person = Person.find(params[:id])\n end", "def edit\n respond_to do |format|\n format.html { render :action => resource_template(\"edit\") }\n end\n end", "def edit\n @opponent = Opponent.find(params[:id])\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n @leavetype = LeaveType.find(params[:id])\n @form_id = 'edit-form'\n \n respond_to do |fmt|\n fmt.html { render :partial => 'form' }\n fmt.json { render :json => @leavetype }\n end\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n @resume = Resume.find(params[:id])\n end", "def proposeedit(id, name, address, city, state, zip, ll, options = {})\n post(\"venues/#{id}/proposeedit\", {\n :name => name,\n :address => address,\n :city => city,\n :state => state,\n :zip => zip,\n :ll => ll\n }.merge(options))\n nil\n end", "def update\n @contact_partner = ContactPartner.find(params[:id])\n\n respond_to do |format|\n if @contact_partner.update_attributes(params[:contact_partner])\n format.html { redirect_to @contact_partner, notice: 'Ansprechpartner wurde erfolgreich bearbeitet.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n # @player = Player.find(params[:id])\n end", "def edit\n\t\t\n\tend", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end" ]
[ "0.732301", "0.71943516", "0.7008314", "0.69751185", "0.69623435", "0.69623435", "0.67821515", "0.67567277", "0.6735863", "0.67325735", "0.67162997", "0.67162997", "0.67014474", "0.6684075", "0.6663053", "0.66284734", "0.6620979", "0.66140807", "0.6533646", "0.6521306", "0.64769846", "0.64537823", "0.644314", "0.6427241", "0.64258355", "0.6412509", "0.640445", "0.63881445", "0.637457", "0.63709515", "0.63607776", "0.63500655", "0.6349571", "0.6349571", "0.63436127", "0.6339854", "0.63216347", "0.631523", "0.63146037", "0.6307334", "0.6301806", "0.62973225", "0.6297146", "0.6291781", "0.62886906", "0.6275122", "0.62657696", "0.6265569", "0.6255787", "0.6249091", "0.624728", "0.6235922", "0.6235922", "0.6235922", "0.6231573", "0.6218662", "0.621672", "0.621672", "0.621672", "0.621672", "0.621672", "0.621672", "0.621672", "0.621672", "0.621672", "0.621672", "0.621672", "0.621672", "0.621672", "0.6207717", "0.62026674", "0.62026674", "0.62026674", "0.62026674", "0.62026674", "0.62026674", "0.62026674", "0.62026674", "0.62026674", "0.62026674", "0.62026674", "0.62026674", "0.62026674", "0.62026674", "0.6194488", "0.6187302", "0.6182994", "0.6177273", "0.6171492", "0.6156538", "0.6156538", "0.6156538", "0.6156538", "0.6156538", "0.6156538", "0.6156538", "0.6156538", "0.6156538", "0.6156538", "0.6156538" ]
0.8616317
0
POST /partners Creates a partner that belongs to a company
def create @partner = Partner.new(params[:partner]) @company = Company.find(params[:company_id]) @partner.company = @company @partner.save respond_to do |format| if @partner.save format.html { redirect_to @partner} format.json { render json: @partner, status: :created, location: @partner } else format.html { render action: "new" } format.json { render json: @partner.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @partner = Partner.new(partner_params)\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'You are partnered up!' }\n format.json { render :show, status: :created, location: @partner }\n else\n format.html { render :new }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner = Partner.new(partner_params)\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'Partner was successfully created.' }\n format.json { render :show, status: :created, location: @partner }\n else\n format.html { render :new }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create!\n if @options[:id]\n @id = @options[:id]\n @model = TestChamber::Models::Partner.find(@id)\n else\n # The entire partners page has to render after a new partner is created\n # before we can proceed which takes a while.\n # Just submit the form with the rest client A dirty hack\n # but we create a lot of partners so it gets very slow.\n name = @company_name\n contact_name = 'John Smith'\n phone = '827-5309'\n\n\n if @use_ui\n visit \"#{TestChamber.target_url}/partners/new\"\n fill_in('partner[name]', :with => name)\n fill_in('partner[contact_name]', :with => contact_name)\n fill_in('partner[contact_phone]', :with => phone)\n select(\"United States\", :from => \"partner[country]\")\n\n Util.wait_for(5,1) { first('#partner_submit') }\n Util.trigger_click(first('#partner_submit')) do\n first('#partner_submit').nil?\n end\n else\n # yes, this is horrible, but it is VASTLY faster than using the browser to do this so when\n # we create lots of partners, like one before each test, we can use this.\n html = Nokogiri::HTML(authenticated_request(:get, \"dashboard/partners/new\", format: :html)[:body])\n\n begin\n authenticity_token = html.css(\"input[name=authenticity_token]\")[0][\"value\"]\n rescue\n # Sometimes the authenticity token doesn't exist; we need to catch that situation.\n # Usually due to a redirect to the login page because user auth is not working 100% of the time.\n # Raising makes this more visible.\n raise \"Didn't have the authenticity token. Html: #{html}\"\n end\n\n submit_form_with_rest(action: \"#{TestChamber.target_url}/dashboard/partners\",\n params: {'partner[name]' => name,\n 'partner[contact_name]' => contact_name,\n 'partner[contact_phone]' => phone,\n 'partner[country]' => \"US\",\n 'utf8' => \"✓\",\n 'authenticity_token' => authenticity_token,\n 'commit' => \"Create Partner\"\n },\n expected_redirect: \"#{TestChamber.target_url}/dashboard/partners\")\n end\n\n Util.wait_for(TestChamber.default_wait_for_timeout,\n TestChamber.default_wait_for_interval,\n {:partner_name => @company_name, :options => @options}) do\n @model = TestChamber::Models::Partner.where(:name => @company_name).order(:created_at => :desc).first\n end\n\n @id = @model.id\n TestChamber.created_partners << @id\n\n # Set reseller_id manually since no reliable way to set via UI.\n set_reseller\n\n configure_partner\n approve_partner\n # cache_object\n\n verify_partner\n end\n end", "def create\n @partner = Partner.new(params[:partner])\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'Partner was successfully created.' }\n format.json { render json: @partner, status: :created, location: @partner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner = Partner.new(params[:partner])\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'Partner was successfully created.' }\n format.json { render json: @partner, status: :created, location: @partner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @practice = Practice.new(practice_params)\n if params[:recruiter_partner].present?\n @partner = Partner.find(params[:recruiter_partner])\n @practice.partners << @partner\n end\n\n @practice.site_id = @current_partner.site.id\n\n respond_to do |format|\n if @practice.save\n format.html { redirect_to partner_path(current_partner), notice: 'Practice was successfully created.' }\n format.json { render :show, status: :created, location: @practice }\n else\n format.html { render :new }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner = Partner.new(partner_params)\n @partner.user.skip_confirmation_notification!\n\n respond_to do |format|\n if @partner.save!\n format.html { redirect_to [:admin, @partner], notice: 'Partner was successfully created.' }\n format.json { render action: 'show', status: :created, location: @partner }\n else\n format.html { render action: 'new' }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @potential_partner = PotentialPartner.new(potential_partner_params)\n\n respond_to do |format|\n if @potential_partner.save\n PartnerNotifier.partner_subscription_confirmation(@potential_partner).deliver\n format.html { redirect_to @potential_partner, notice: 'Potential partner was successfully created.' }\n format.json { render :show, status: :created, location: @potential_partner }\n else\n format.html { render :new }\n format.json { render json: @potential_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @optinpartner = Optinpartner.new(params[:optinpartner])\n\n respond_to do |format|\n if @optinpartner.save\n format.html { redirect_to @optinpartner, notice: 'Optinpartner was successfully created.' }\n format.json { render json: @optinpartner, status: :created, location: @optinpartner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @optinpartner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner = Partner.new(params[:partner])\n @partner.build_user(params[:user])\n\n is_ok = true\n begin\n Partner.transaction do\n @partner.save!\n @partner.user.save!\n end\n rescue ActiveRecord::RecordInvalid => e\n logger.error e\n is_ok = false\n end\n\n if is_ok\n flash[:notice] = 'Partner was successfully created.'\n redirect_to partner_url(@partner) \n else\n render :action => \"new\" \n end\n end", "def create\n @partner_project = PartnerProject.new(params[:partner_project])\n\n respond_to do |format|\n if @partner_project.save\n format.html { redirect_to @partner_project, notice: 'Partner project was successfully created.' }\n format.json { render json: @partner_project, status: :created, location: @partner_project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner = Partner.new(params[:partner])\n @partner.ip_address = request.remote_ip\n @page_title = t('partners.new.title', :government_name => current_government.name)\n respond_to do |format|\n if @partner.save\n @partner.register!\n current_user.update_attribute(:partner_id,@partner.id)\n @partner.activate!\n flash[:notice] = t('partners.new.success')\n session[:goal] = 'partner'\n format.html { redirect_to 'http://' + @partner.short_name + '.' + current_government.base_url + picture_partner_path(@partner)}\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def create\n @partner_person = PartnerPerson.new(params[:partner_person])\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n if @partner_person.save\n format.html { redirect_to(@partner_person, :notice => 'PartnerPerson was successfully created.') }\n format.xml { render :xml => @partner_person, :status => :created, :location => @partner_person }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @partner_person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @fitpartner = Fitpartner.new(fitpartner_params)\n\n respond_to do |format|\n if @fitpartner.save\n format.html { redirect_to @fitpartner, notice: 'Fitpartner was successfully created.' }\n format.json { render :show, status: :created, location: @fitpartner }\n else\n format.html { render :new }\n format.json { render json: @fitpartner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @type_partner = TypePartner.new(type_partner_params)\n\n respond_to do |format|\n if @type_partner.save\n format.html { redirect_to @type_partner, notice: 'Type partner was successfully created.' }\n format.json { render :show, status: :created, location: @type_partner }\n else\n format.html { render :new }\n format.json { render json: @type_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @crew_category_partner = CategoryPartner.new(crew_category_partner_params)\n\n respond_to do |format|\n if @crew_category_partner.save\n format.html { redirect_to crew_category_partners_path, notice: 'Category partner was successfully created.' }\n format.json { render :show, status: :created, location: @crew_category_partner }\n else\n format.html { render :new }\n format.json { render json: @crew_category_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner_type = PartnerType.new(params[:partner_type])\n\n respond_to do |format|\n if @partner_type.save\n format.html { redirect_to @partner_type, notice: 'Partner type was successfully created.' }\n format.json { render json: @partner_type, status: :created, location: @partner_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_partner(partners, opts = {})\n data, _status_code, _headers = add_partner_with_http_info(partners, opts)\n data\n end", "def add_partner_with_http_info(partners, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PartnerApi.add_partner ...'\n end\n # verify the required parameter 'partners' is set\n if @api_client.config.client_side_validation && partners.nil?\n fail ArgumentError, \"Missing the required parameter 'partners' when calling PartnerApi.add_partner\"\n end\n # resource path\n local_var_path = '/partners'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(partners)\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Partner')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PartnerApi#add_partner\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @models = self.class.model_class.new(params[:partners])\n\n respond_to do |format|\n if @models.save\n flash[:notice] = 'Model was successfully created.'\n format.html { redirect_to(@models) }\n format.xml { render :xml => @models, :status => :created, :location => @models }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @models.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @partner_profile = PartnerProfile.new(partner_profile_params)\n\n respond_to do |format|\n if @partner_profile.save\n format.html { redirect_to @partner_profile, notice: 'Partner profile was successfully created.' }\n format.json { render :show, status: :created, location: @partner_profile }\n else\n format.html { render :new }\n format.json { render json: @partner_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact_partner = ContactPartner.new(params[:contact_partner])\n\n respond_to do |format|\n if @contact_partner.save\n format.html { redirect_to @contact_partner, notice: 'Ansprechpartner wurde erfolgreich erzeugt' }\n format.json { render json: @contact_partner, status: :created, location: @contact_partner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def partner_params\n params.require(:partner).permit(:name, :address, :zipcode, :city)\n end", "def create\n @part_company = PartCompany.new(params[:part_company])\n\n respond_to do |format|\n if @part_company.save\n format.html { redirect_to @part_company, notice: 'Part company was successfully created.' }\n format.json { render json: @part_company, status: :created, location: @part_company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @part_company.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partnering_organization = PartneringOrganization.new(partnering_organization_params)\n respond_to do |format|\n if @partnering_organization.save\n format.html { redirect_to @partnering_organization, notice: 'Partnering organization was successfully created.' }\n format.json { render :show, status: :created, location: @partnering_organization }\n else\n format.html { render :new }\n format.json { render json: @partnering_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partnering_organization = PartneringOrganization.new(partnering_organization_params)\n\n respond_to do |format|\n if @partnering_organization.save\n format.html { redirect_to @partnering_organization, notice: 'Partnering organization was successfully created.' }\n format.json { render :show, status: :created, location: @partnering_organization }\n else\n format.html { render :new }\n format.json { render json: @partnering_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partenaire = Partenaire.new(params[:partenaire])\n\n respond_to do |format|\n if @partenaire.save\n flash[:notice] = I18n.t(:successfully_added_partner)\n format.html { redirect_to(partenaires_path()) }\n format.xml { render :xml => @partenaire, :status => :created, :location => @partenaire }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @partenaire.errors, :status => :unprocessable_entity }\n end\n end\n end", "def partner_params\n params.require(:partner).permit(:partner_name, :contact, :tel, :email, :qq, :status)\n end", "def create\n @external_partnership = ExternalPartnership.new(params[:external_partnership])\n\n respond_to do |format|\n if @external_partnership.save\n format.html { redirect_to @external_partnership, notice: 'External partnership was successfully created.' }\n format.json { render json: @external_partnership, status: :created, location: @external_partnership }\n else\n format.html { render action: \"new\" }\n format.json { render json: @external_partnership.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @company_part = CompanyPart.new(company_part_params)\n\n respond_to do |format|\n if @company_part.save\n format.html { redirect_to company_parts_path, notice: 'Company part was successfully created.' }\n format.json { render :show, status: :created, location: @company_part }\n else\n format.html { render :new }\n format.json { render json: @company_part.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_partner\n @partner = Partner.find(params[:id])\n end", "def set_partner\n @partner = Partner.find(params[:id])\n end", "def create\n @business_partner = BusinessPartner.new(params[:business_partner])\n\n respond_to do |format|\n if @business_partner.save\n format.html { redirect_to(@business_partner, :notice => 'Business partner was successfully created.') }\n format.xml { render :xml => @business_partner, :status => :created, :location => @business_partner }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @business_partner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def potential_partner_params\n params.require(:potential_partner).permit(:studio_name, :person_to_contact, :contact_number, :email, :web_address, :how_did_you_hear_partner)\n end", "def create\n company_name = params[:liner][:company_name]\n company = Company.find_or_create_by name: company_name\n @liner = company.liners.new(liner_params)\n\n respond_to do |format|\n if @liner.save\n format.html { redirect_to @liner, notice: 'Liner was successfully created.' }\n format.json { render :show, status: :created, location: @liner }\n else\n format.html { render :new }\n format.json { render json: @liner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \tif params[:cancel_button]\n \t\tsession[:partner_step] = session[:partner_params] = nil\n \t\tredirect_to(partners_url)\n \t\treturn\n \tend\n\t\tsession[:partner_params].deep_merge!(params[:partner]) if params[:partner]\n\t\t\n \tprint \"Partner Info:\"\n\t\tputs session[:partner_params]\n\n\t\tprint \"WorkPlan Params - params[:work_plan]: \"\n\t\tputs params[:work_plan]\n\n\t\t@partner = Partner.new(session[:partner_params])\n\t\[email protected]_step = session[:partner_step]\n\t\t\n\t\tif @partner.valid? \n\t\t\tif params[:back_button]\n\t\t\t\[email protected]_step\n\t\t\telsif @partner.last_step?\n\t\t\t\t#@partner.work_plan.update_attributes(params[:work_plan]) if @partner.save \n\t\t\t\tprint \"WorkPlan Params - params[:work_plan]: \"\n\t\t\t\tputs params[:work_plan]\n\t\t\t\twp = WorkPlan.new(params[:work_plan]) \n\t\t\t\tprint \"wp.valid? \"\n\t\t\t\tputs wp.valid?\n\t\t\t\tif wp.valid? and wp.save\n\t\t\t\t\tputs \"wp has been saved!\"\n\t\t\t\t\[email protected]_plan = wp\n\t\t\t\t\tprint \"WorkPlan weekly_rotas \"\n\t\t\t\t\twp.weekly_rotas.first.shift_templates.each do |st|\n\t\t\t\t\t\tputs st.start_at\n\t\t\t\t\tend\n\t\t\t\t\tif @partner.all_valid?\n\t\t\t\t\t\[email protected]\n\t\t\t\t\t\[email protected]_plan = wp\n\t\t\t\t\t\[email protected]\n\t\t\t\t\t\[email protected]_plan.weekly_rotas.first.shift_templates.each do |st|\n\t\t\t\t\t\t\tputs st.start_at\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\telse\n\t\t\t\[email protected]_step\n\t\t\tend\n\t\t\t\n\t\t\tif @partner.current_step == 'contact'\n\t\t\t\[email protected] = Contact.new(session[:partner_params][\"contact_attributes\"])\n\t\t\telsif @partner.current_step == 'workplan'\n\t\t\t\[email protected]_plan = WorkPlan.new()\n\t\t\t\t@work_plan = @partner.work_plan\n\t\t\t\tweekly_plan = @partner.work_plan.weekly_rotas.build\n\t\t\t\ttime_template = DateTime.parse(\"Sun, 01 Jan 2006 09:00:00 UTC +00:00\")\n\t\t\t\t7.times do |i|\n\t\t\t\t\tweekly_plan.shift_templates.build(:name => @partner.first_name + \" \" + @partner.last_name,:start_at => time_template + i, :end_at => time_template + i + 8.hours)\n\t\t\t\tend\n\t\t\tend\n\t\t\tsession[:partner_step] = @partner.current_step\n\t\t\tprint \"Next Step: \"\n\t\t\tputs @partner.current_step\n\t\tend\n\t\tif @partner.new_record?\n\t\t\trender \"new\"\n\t\telse\n\t\t\tsession[:partner_step] = session[:partner_params] = nil\n\t\t\tflash[:notice] = \"Partner saved!\"\n\t\t\tredirect_to @partner\n\t end\n end", "def create\n @person = Person.new(params[:person])\n @title = \"people\"\n @person.firstname = @person.firstname.upcase\n @person.lastname = @person.lastname.capitalize\n\n respond_to do |format|\n if @person.save\n\n begin\n #create association\n @asso = PartnerPerson.new()\n #@asso.person_id = @person.id\n @asso.person = @person\n if signed_in_and_master?\n @asso.partner_id = 1\n else\n @partner = Partner.all(:conditions => [\"user_id = ?\", current_user.id])\n @asso.partner_id = @partner[0].id\n end \n @asso.save\n\n rescue Exception => e\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asso.errors, :status => :unprocessable_entity }\n return\n end \n\n format.html { redirect_to(@person, :notice => 'Person was successfully created.') }\n format.xml { render :xml => @person, :status => :created, :location => @person }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @partner_project = PartnerProject.new\n @partners = Partner.all\n @projects = Project.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner_project }\n end\n end", "def create\n Party.create(party_params)\n redirect_to order_tickets_path\n end", "def partner_params\n params.require(:partner).permit(:website, :name, :sells_app_exchange_apps, :description)\n end", "def createPartnerSubmission(submission)\n updateModules()\n hasPartners = @modulesUsed.include?(\"Partners\")\n # return the submission created for partner\n if hasPartners then\n pSubmission = partnersAfterAutograde(submission)\n\n unless pSubmission.nil?\n pSubmission.save!\n end\n\n return pSubmission\n end\n end", "def new\n @partner = Partner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner }\n end\n end", "def set_partner\n @partner = Partner.find_by(osra_id: params[:partner_id])\n end", "def approve_partner\n @partner = current_organization.partners.find(params[:id])\n\n # TODO: create a service that abstracts all of this from PartnersController, like PartnerDetailRetriever.call(id: params[:id])\n\n # TODO: move this code to new service,\n @diaper_partner = DiaperPartnerClient.get(id: params[:id])\n @diaper_partner = JSON.parse(@diaper_partner, symbolize_names: true) if @diaper_partner\n @agency = if @diaper_partner\n @diaper_partner[:agency]\n else\n autovivifying_hash\n end\n end", "def set_partner\n @partner = Partner.friendly.find(params[:id])\n end", "def pbRegisterPartner(trainerid,trainername,partyid=0)\n Kernel.pbCancelVehicles\n trainer=pbLoadTrainer(trainerid,trainername,partyid)\n Events.onTrainerPartyLoad.trigger(nil,trainer)\n trainerobject=PokeBattle_Trainer.new(_INTL(trainer[0].name),trainerid)\n trainerobject.setForeignID($Trainer)\n for i in trainer[2]\n i.trainerID=trainerobject.id\n i.ot=trainerobject.name\n i.calcStats\n end\n $PokemonGlobal.partner=[trainerid,trainerobject.name,trainerobject.id,trainer[2]]\nend", "def pbRegisterPartner(trainerid,trainername,partyid=0)\n if trainerid.is_a?(String) || trainerid.is_a?(Symbol)\n trainerid = getID(PBTrainers,trainerid)\n end\n Kernel.pbCancelVehicles\n trainer = pbLoadTrainer(trainerid,trainername,partyid)\n Events.onTrainerPartyLoad.trigger(nil,trainer)\n trainerobject = PokeBattle_Trainer.new(_INTL(trainer[0].name),trainerid)\n trainerobject.setForeignID($Trainer)\n for i in trainer[2]\n i.trainerID = trainerobject.id\n i.ot = trainerobject.name\n i.calcStats\n end\n $PokemonGlobal.partner = [trainerid,trainerobject.name,trainerobject.id,trainer[2]]\nend", "def create\n @participant = Participant.new(participant_params)\n @participant.competences = @competence\n respond_to do |format|\n if @participant.save\n TeamParticipant.create(participant: @participant, team: @team)\n format.html { redirect_to participants_url }\n format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @clientsOffers = ClientsOffers.new(params[:clientsOffers])\n\n respond_to do |format|\n if @clientsOffers.save\n format.html { redirect_to @clientsOffers, notice: 'ClientsOffers was succesfully created.' }\n format.json { render json: @clientsOffers, status: :created, location: @clientsOffers }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clientsOffers.errors, status: :unprocesable_entity }\n end\n end\n end", "def add_partners_TEMP_DANGEROUS\n User.find(:all).each do |user|\n Partnership.create(:inviter => logged_in_user, :receiver => user) if logged_in_user.dealership != user.dealership\n end\n redirect_to :back\n end", "def create\n @partner_link = PartnerLink.new(params[:partner_link])\n\n respond_to do |format|\n if @partner_link.save\n flash[:notice] = 'PartnerLink was successfully created.'\n format.html { redirect_to(@partner_link) }\n format.xml { render :xml => @partner_link, :status => :created, :location => @partner_link }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @partner_link.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n # Use post to pass in user_id for new content partner otherwise you'll get access denied\n @partner = ContentPartner.new(params[:content_partner])\n access_denied unless current_user.can_create?(@partner)\n set_new_partner_options\n end", "def crew_category_partner_params\n params.require(:category_partner).permit(:name)\n end", "def partner_payment_params\n params.require(:partner_payment).permit(:payment_type, :date, :amount, :payment_method, :payment_desc, :partner_id)\n end", "def contact_us_partners_pipe_drive\n service_response = UserManagement::ContactUsPipeDrive::Partner.new(params).perform\n render_api_response(service_response)\n end", "def new\n \tsession[:partner_params] = session[:partner_step] = nil\n \tsession[:partner_params] ||= {}\n \tsession[:workplan_params] = session[:workplan_step] = nil\n \tsession[:workplan_params] ||= {}\n\t\t@partner = Partner.new(session[:partner_params])\n\t\[email protected]_step = session[:partner_step]\n end", "def create\n @previous_party = PreviousParty.new(previous_party_params)\n\n respond_to do |format|\n if @previous_party.save\n format.html { redirect_to @previous_party, notice: 'Previous party was successfully created.' }\n format.json { render :show, status: :created, location: @previous_party }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @previous_party.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @counterparty = Counterparty.new(counterparty_params)\n @counterparty.owner = current_user\n\n respond_to do |format|\n if @counterparty.save\n format.html { redirect_to @counterparty, notice: \"Counterparty was successfully created.\" }\n format.json { render :show, status: :created, location: @counterparty }\n else\n format.html { render :new }\n format.json { render json: @counterparty.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner_payment = PartnerPayment.new(partner_payment_params)\n session.delete(:return_to)\n session[:return_to] ||= request.referer\n\n respond_to do |format|\n if @partner_payment.save\n format.html { redirect_to session.delete(:return_to), notice: 'Partner payment was successfully Added.' }\n format.json { render :show, status: :created, location: @partner_payment }\n else\n format.html { render :new }\n format.json { render json: @partner_payment.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @partner_type = PartnerType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner_type }\n end\n end", "def create\n if @company = Company.find(entity_id_from_params(:company))\n respond_to do |format|\n current_user.account.companies << @company\n format.html { redirect_to root_path, notice: 'Company was successfully created.' }\n format.json\n end\n end\n end", "def partners\n end", "def partner_params\n params.require(:partner).permit(\n :name, :description, :info, :price, :location_id, \n :site, :phone, :active, :premium, :premium_to, :slug,\n :rating, category_ids: [], location_ids: [], \n user_attributes: [:id, :email, :avatar, :avatar_remote_url, :password, :password_confirmation]\n )\n end", "def create\n @company_client = CompanyClient.new(company_client_params)\n @company_client.company = current_user.companies.first\n\n respond_to do |format|\n if @company_client.save\n format.html { redirect_to company_path(@company_client.company), notice: 'Клиент успешно добавлен' }\n format.json { render :show, status: :created, location: @company_client }\n else\n format.html { render :new }\n format.json { render json: @company_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_partnership_potential(form_params)\n @form_params = form_params\n mail(subject: \"[team] New Partnership Potential\")\n end", "def create\n @party = Party.new(params[:party])\n\n respond_to do |format|\n if @party.save\n format.html { redirect_to @party, notice: 'Party was successfully created.' }\n format.json { render json: @party, status: :created, location: @party }\n else\n format.html { render action: \"new\" }\n format.json { render json: @party.errors, status: :unprocessable_entity }\n end\n end\n end", "def partner_invite_params\n params.require(:partner_invite).permit(:first_name, :last_name, :email)\n end", "def create\n @partner_event = PartnerEvent.new(partner_event_params)\n\n respond_to do |format|\n if @partner_event.save\n format.html { redirect_to @partner_event, notice: 'Partner event was successfully created.' }\n format.json { render :show, status: :created, location: @partner_event }\n else\n format.html { render :new }\n format.json { render json: @partner_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def partner_params\n params.fetch(:partner, {})\n end", "def create\n @participant = Participant.new(participant_create_params)\n @participant.save\n respond_with(@participant)\n end", "def create\n @participant = Participant.new(participant_create_params)\n @participant.save\n respond_with(@participant)\n end", "def create\n @party = Party.new(party_params)\n\n respond_to do |format|\n if @party.save\n format.html { redirect_to @party, notice: 'Party was successfully created.' }\n format.json { render :show, status: :created, location: @party }\n else\n format.html { render :new }\n format.json { render json: @party.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @participante = Participante.new(participante_params)\n\n respond_to do |format|\n if @participante.save\n format.html { redirect_to @participante, notice: 'Participante was successfully created.' }\n format.json { render :show, status: :created, location: @participante }\n else\n format.html { render :new }\n format.json { render json: @participante.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @offer = @company.offers.new(offer_params)\n @offer.user = current_user\n\n respond_to do |format|\n if @offer.save\n format.html { redirect_to @company, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @offer }\n else\n format.html { render :new }\n format.json { render json: @offer.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_partner_payment\n @partner_payment = PartnerPayment.find(params[:id])\n end", "def create\n @provider = current_company.providers.new(params[:provider])\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: 'Provider was successfully created.' }\n format.json { render json: @provider, status: :created, location: @provider }\n else\n format.html { render action: \"new\" }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end", "def adpartner_params\n params.require(:adpartner).permit(\n :name, :name_addon, :lastname, :firstname, :street, :zip, :city,\n :country, :email, :website, :commission_absolute, :commission_relative\n )\n end", "def create\n @pokeparty = Pokeparty.new(params[:pokeparty])\n\n respond_to do |format|\n if @pokeparty.save\n format.html { redirect_to @pokeparty, notice: 'Pokeparty was successfully created.' }\n format.json { render json: @pokeparty, status: :created, location: @pokeparty }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pokeparty.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :create, CompetenceTierGroup\n \n @competence_tier_group = CompetenceTierGroup.new(competence_tier_group_params)\n @competence_tier_group.save!\n render json: {status: :ok}\n end", "def create\n @company_investor = CompanyInvestor.new(company_investor_params)\n\n end", "def create\n @producer_company = ProducerCompany.new(producer_company_params)\n\n respond_to do |format|\n if @producer_company.save\n format.html { redirect_to @producer_company, notice: 'Producer company was successfully created.' }\n format.json { render :show, status: :created, location: @producer_company }\n else\n format.html { render :new }\n format.json { render json: @producer_company.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n p1 = current_user\n p2 = User.where(\"username = ?\", partida_params[:player2])[0]\n winp1 = partida_params[:winP1]\n winp2 = partida_params[:winP2]\n game = partida_params[:game]\n @partida = Partida.new(player1: p1, player2: p2, winP1: winp1, winP2: winp2, game: game)\n respond_to do |format|\n if @partida.save\n format.html { redirect_to @partida, notice: 'Partida was successfully created.' }\n format.json { render :show, status: :created, location: @partida }\n else\n format.html { render :new }\n format.json { render json: @partida.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_partner_invite\n @partner_invite = PartnerInvite.find(params[:id])\n end", "def create\n render json: Company.create(params[\"company\"])\n end", "def client_professional_params\n params.require(:client_professional).permit(:professional_id, :client_id, :name, :creator)\n end", "def partner_params\n params.require(:partner).permit(:title, :icon_id, :description, :is_active, :url_address, :position)\n end", "def create\n @company = @community.companies.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_new_itemized_partner(partner)\n # basic partner info\n fill_company_info(partner)\n # admin & company type info\n fill_partner_admin_info(partner)\n fill_partner_specific_info(partner)\n # itemized partner specific info\n fill_itemized_discounts(partner)\n fill_subscription_period(partner.subscription_period)\n fill_itemized_info(partner)\n # billing info\n fill_billing_info(partner)\n # submission\n create_partner_btn.click\n partner_created\n end", "def create\n @new_company = NewCompany.new(new_company_params)\n @new_company.user = current_user\n\n respond_to do |format|\n if @new_company.save\n format.html { redirect_to new_requesit_path, notice: 'Вы успешно добавили компанию!' }\n format.json { render :show, status: :created, location: @new_company }\n else\n format.html { render :new }\n format.json { render json: @new_company.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(params[:user])\n if params[:reservation].nil?\n @company = Company.new(params[:company])\n else\n\t # user has been invited, company already exists\n\t @company = Company.find(params[:company][:id])\n\t @user.company = @company\n\t Reservation.find_by_token(params[:reservation][:token]).delete\n\t end\n\n respond_to do |format|\n if @user.save\n\t if params[:reservation].nil?\n\t\t # set company owner\n\t @company.owner = @user\n\t @company.save\n\t @company.create_default_infos\n\t @user.company = @company\n\t end\n\t @user.save\n format.html { redirect_to :users, notice: 'Registration successful.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def invite(firm_name, firstname, lastname, email, phone)\n invite_params = vendor_params(firm_name, firstname, lastname, email, phone)\n @client.post(\"/#{@model}\", {}, invite_params)\n end", "def new\n @partner_person = PartnerPerson.new\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partner_person }\n end\n end", "def create\n @company = Company.create!(company_params)\n end", "def create\n @rail_company = RailCompany.new(rail_company_params)\n\n respond_to do |format|\n if @rail_company.save\n format.html { redirect_to @rail_company, notice: 'Rail company was successfully created.' }\n format.json { render action: 'show', status: :created, location: @rail_company }\n else\n format.html { render action: 'new' }\n format.json { render json: @rail_company.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @parent_id = params[:parent_id] #|| default_parent.id\n @partner = Partner.new\n @partner.parent_id = @parent_id\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner }\n format.js\n end\n end", "def create\n @vendedor_cliente = VendedorCliente.new(vendedor_cliente_params)\n\n respond_to do |format|\n if @vendedor_cliente.save\n format.html { redirect_to @vendedor_cliente, notice: 'Vendedor cliente was successfully created.' }\n format.json { render :show, status: :created, location: @vendedor_cliente }\n else\n format.html { render :new }\n format.json { render json: @vendedor_cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @opportunity = @opportunities.build(opportunity_params)\n\n respond_to do |format|\n if @opportunity.save\n format.html { redirect_to admin_employer_opportunities_path(@opportunity.employer), notice: 'Opportunity was successfully created.' }\n format.json { render :show, status: :created, location: @opportunity }\n else\n format.html { render :new }\n format.json { render json: @opportunity.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @employer = Employer.new(user_params)\n @employer.company = @company\n\n respond_to do |format|\n if @employer.save\n format.html { redirect_to admin_company_employers_url(@company), notice: 'Employer was successfully created.' }\n format.json { render :show, status: :created, location: @employer }\n else\n format.html { render :new }\n format.json { render json: @employer.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_partner\n @partner = User.find(params[:id])\n end", "def create\n @client = clients.new(params[:client])\n\n if @client.save\n flash[:notice] = 'Customer was successfully created.'\n redirect_to(user_company_clients_url(current_company))\n else\n render :action => \"new\"\n end\n end" ]
[ "0.7470335", "0.7422812", "0.7413604", "0.7409306", "0.7409306", "0.7398809", "0.7272806", "0.70434564", "0.70098275", "0.6808376", "0.67809975", "0.67753166", "0.67657083", "0.67507344", "0.66666055", "0.6655175", "0.6648353", "0.66167235", "0.6574595", "0.6573487", "0.6559229", "0.65540177", "0.646128", "0.6406322", "0.6258863", "0.6249367", "0.6242618", "0.61957216", "0.6175803", "0.6166147", "0.614657", "0.614657", "0.6112649", "0.61009157", "0.6094551", "0.60779864", "0.6074931", "0.606616", "0.60660934", "0.6065567", "0.60526824", "0.6030778", "0.60246754", "0.59725356", "0.5938407", "0.5934096", "0.5929788", "0.59184456", "0.5869875", "0.58691806", "0.58643305", "0.58337647", "0.58165395", "0.5773431", "0.5745956", "0.57302505", "0.5726109", "0.5721055", "0.5719378", "0.5718669", "0.5711607", "0.57048154", "0.5699138", "0.56957024", "0.5693814", "0.5685348", "0.5677133", "0.5675375", "0.5673273", "0.5670348", "0.5670348", "0.56626534", "0.5659882", "0.565598", "0.5652652", "0.5643799", "0.5622004", "0.5599629", "0.5589966", "0.555866", "0.5556313", "0.55465466", "0.5544655", "0.55383235", "0.55365324", "0.55355054", "0.5535351", "0.55350995", "0.5533759", "0.5526225", "0.55237645", "0.5518539", "0.55183464", "0.5516459", "0.5506066", "0.55034536", "0.55021995", "0.55000067", "0.5496695", "0.5481244" ]
0.8076154
0
PUT /partners/1 Updates a particular partner's information
def update @partner = Partner.find(params[:id]) respond_to do |format| if @partner.update_attributes(params[:partner]) format.html { redirect_to @partner } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @partner.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n format.html { redirect_to @partner, notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n format.html { redirect_to @partner, notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @partner.update(partner_params)\n format.html { redirect_to [:admin, @partner], notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_partner\n\t\tpartner.update(partner_id: self.id) if partner\n\tend", "def update\n respond_to do |format|\n if @partner.update(partner_params)\n format.html { redirect_to @partner, notice: 'Partner was successfully updated.' }\n format.json { render :show, status: :ok, location: @partner }\n else\n format.html { render :edit }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partner_person = PartnerPerson.find(params[:id])\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n if @partner_person.update_attributes(params[:partner_person])\n format.html { redirect_to(@partner_person, :notice => 'PartnerPerson was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @partner_person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_partner\n @partner = Partner.find(params[:id])\n end", "def set_partner\n @partner = Partner.find(params[:id])\n end", "def update\n @optinpartner = Optinpartner.find(params[:id])\n\n respond_to do |format|\n if @optinpartner.update_attributes(params[:optinpartner])\n format.html { redirect_to @optinpartner, notice: 'Optinpartner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @optinpartner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@partner = Partner.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @partner.update_attributes(params[:partner]) and @partner.contact.update_attributes(params[:contact])\n\t\t\t\tformat.html { redirect_to(@partner, :notice => 'Partner was successfully updated.') }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @partner.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def edit\n @partner = Partner.find(params[:id])\n end", "def update\n @partner_type = PartnerType.find(params[:id])\n\n respond_to do |format|\n if @partner_type.update_attributes(params[:partner_type])\n format.html { redirect_to @partner_type, notice: 'Partner type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @potential_partner.update(potential_partner_params)\n format.html { redirect_to @potential_partner, notice: 'Potential partner was successfully updated.' }\n format.json { render :show, status: :ok, location: @potential_partner }\n else\n format.html { render :edit }\n format.json { render json: @potential_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_partner\n @partner = Partner.find_by(osra_id: params[:partner_id])\n end", "def update\n @models = self.class.model_class.find(params[:id])\n\n respond_to do |format|\n if @models.update_attributes(params[:partners])\n flash[:notice] = 'Partners was successfully updated.'\n format.html { redirect_to(@models) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @models.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_partner\n @partner = Partner.friendly.find(params[:id])\n end", "def update(partner, allow_empty=false)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'partner', partner);\n\t\t\tclient.add_param(kparams, 'allowEmpty', allow_empty);\n\t\t\tclient.queue_service_action_call('partner', 'update', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend", "def update\n respond_to do |format|\n if @partner_profile.update(partner_profile_params)\n format.html { redirect_to @partner_profile, notice: 'Partner profile was successfully updated.' }\n format.json { render :show, status: :ok, location: @partner_profile }\n else\n format.html { render :edit }\n format.json { render json: @partner_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partner = Partner.find(params[:id])\n @partner.basic_profile = false # we're only editing basic info here, not extended partner info (see update_survey)\n is_ok = true\n begin\n Partner.transaction do\n #we want to 'validate' both models\n @partner.user.attributes = params[:user]\n @partner.attributes = params[:partner]\n @partner.update_multiple_answer_questions(params)\n @partner.update_attributes!(params[:partner]) \n @partner.save!\n @partner.user.save!\n end\n rescue ActiveRecord::RecordInvalid => e\n logger.error e\n is_ok = false\n end\n\n if is_ok\n flash[:notice] = 'Partner profile was successfully updated.'\n redirect_to :action => :edit\n else\n render :action => \"edit\"\n end\n end", "def update\n respond_to do |format|\n if @type_partner.update(type_partner_params)\n format.html { redirect_to @type_partner, notice: 'Type partner was successfully updated.' }\n format.json { render :show, status: :ok, location: @type_partner }\n else\n format.html { render :edit }\n format.json { render json: @type_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @practice.update(practice_params)\n # Delete the currently associated partner\n if params[:original_recruiter].present?\n delete_sql = \"DELETE FROM partners_practices WHERE \" +\n \"partner_id = #{params[:original_recruiter]} AND practice_id = #{@practice.id};\"\n ActiveRecord::Base.connection.execute delete_sql\n end\n # Add the new associated partner (if any)\n if params[:recruiter_partner].present?\n insert_sql = \"INSERT INTO partners_practices (partner_id, practice_id) \" +\n \"VALUES (#{params[:recruiter_partner]}, #{@practice.id});\"\n ActiveRecord::Base.connection.execute insert_sql\n end\n format.html { redirect_to partner_path(current_partner), notice: 'Practice was successfully updated.' }\n format.json { render :show, status: :ok, location: @practice }\n else\n format.html { render :edit }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contact_partner = ContactPartner.find(params[:id])\n\n respond_to do |format|\n if @contact_partner.update_attributes(params[:contact_partner])\n format.html { redirect_to @contact_partner, notice: 'Ansprechpartner wurde erfolgreich bearbeitet.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partner_project = PartnerProject.find(params[:id])\n\n respond_to do |format|\n if @partner_project.update_attributes(params[:partner_project])\n format.html { redirect_to @partner_project, notice: 'Partner project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fitpartner.update(fitpartner_params)\n format.html { redirect_to @fitpartner, notice: 'Fitpartner was successfully updated.' }\n format.json { render :show, status: :ok, location: @fitpartner }\n else\n format.html { render :edit }\n format.json { render json: @fitpartner.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_potential_partner\n @potential_partner = PotentialPartner.find(params[:id])\n end", "def set_partner\n @partner = User.find(params[:id])\n end", "def partner_params\n params.require(:partner).permit(:name, :address, :zipcode, :city)\n end", "def approve_partner\n @partner = current_organization.partners.find(params[:id])\n\n # TODO: create a service that abstracts all of this from PartnersController, like PartnerDetailRetriever.call(id: params[:id])\n\n # TODO: move this code to new service,\n @diaper_partner = DiaperPartnerClient.get(id: params[:id])\n @diaper_partner = JSON.parse(@diaper_partner, symbolize_names: true) if @diaper_partner\n @agency = if @diaper_partner\n @diaper_partner[:agency]\n else\n autovivifying_hash\n end\n end", "def set_partner_profile\n @partner_profile = PartnerProfile.find(params[:id])\n end", "def update\n respond_to do |format|\n if @partner_payment.update(partner_payment_params)\n format.html { redirect_to partner_path(@partner_payment.partner), notice: 'Partner payment was successfully updated.' }\n format.json { render :show, status: :ok, location: @partner_payment }\n else\n format.html { render :edit }\n format.json { render json: @partner_payment.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_partner_invite\n @partner_invite = PartnerInvite.find(params[:id])\n end", "def update\n @partner = Partner.find(params[:id])\n @page_title = t('partners.settings.title') \n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n flash[:notice] = t('partners.settings.success')\n format.html { \n if not @partner.has_picture?\n redirect_to picture_partner_path(@partner)\n elsif params[:partner][:name]\n redirect_to :action => \"edit\"\n else\n redirect_to :action => \"email\"\n end\n }\n else\n format.html { \n if params[:partner][:name]\n render :action => \"edit\" \n else # send them to the partner email update\n render :action => \"email\"\n end\n }\n end\n end\n end", "def add_partner_with_http_info(partners, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PartnerApi.add_partner ...'\n end\n # verify the required parameter 'partners' is set\n if @api_client.config.client_side_validation && partners.nil?\n fail ArgumentError, \"Missing the required parameter 'partners' when calling PartnerApi.add_partner\"\n end\n # resource path\n local_var_path = '/partners'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(partners)\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Partner')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PartnerApi#add_partner\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n @external_partnership = ExternalPartnership.find(params[:id])\n\n respond_to do |format|\n if @external_partnership.update_attributes(params[:external_partnership])\n format.html { redirect_to @external_partnership, notice: 'External partnership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @external_partnership.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partenaire = Partenaire.find(params[:id])\n\n respond_to do |format|\n if @partenaire.update_attributes(params[:partenaire])\n flash[:notice] = I18n.t(:successfully_modified_partner)\n format.html { redirect_to(partenaires_path()) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @partenaire.errors, :status => :unprocessable_entity }\n end\n end\n end", "def partner_params\n params.require(:partner).permit(:partner_name, :contact, :tel, :email, :qq, :status)\n end", "def update\n @business_partner = BusinessPartner.find(params[:id])\n\n respond_to do |format|\n if @business_partner.update_attributes(params[:business_partner])\n format.html { redirect_to(@business_partner, :notice => 'Business partner was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @business_partner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_partner_payment\n @partner_payment = PartnerPayment.find(params[:id])\n end", "def create\n @partner = Partner.new(partner_params)\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'You are partnered up!' }\n format.json { render :show, status: :created, location: @partner }\n else\n format.html { render :new }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_partner(partners, opts = {})\n data, _status_code, _headers = add_partner_with_http_info(partners, opts)\n data\n end", "def update\n @partner_coordinator_association = PartnerCoordinatorAssociation.find(params[:id])\n\n respond_to do |format|\n if @partner_coordinator_association.update_attributes(params[:partner_coordinator_association])\n flash[:notice] = 'PartnerCoordinatorAssociation was successfully updated.'\n format.html { redirect_to([:admin, @partner_coordinator_association]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @partner_coordinator_association.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @partner_link = PartnerLink.find(params[:id])\n\n respond_to do |format|\n if @partner_link.update_attributes(params[:partner_link])\n flash[:notice] = 'PartnerLink was successfully updated.'\n format.html { redirect_to(@partner_link) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @partner_link.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @partner = Partner.new(partner_params)\n @partner.user.skip_confirmation_notification!\n\n respond_to do |format|\n if @partner.save!\n format.html { redirect_to [:admin, @partner], notice: 'Partner was successfully created.' }\n format.json { render action: 'show', status: :created, location: @partner }\n else\n format.html { render action: 'new' }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @partnership.update(partnership_params)\n format.html { redirect_to @partnership, notice: 'Partnership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @partnership.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_Partner(value)\n set_input(\"Partner\", value)\n end", "def create\n @partner = Partner.new(params[:partner])\n @company = Company.find(params[:company_id])\n @partner.company = @company\n @partner.save\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner}\n format.json { render json: @partner, status: :created, location: @partner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def partner_params\n params.require(:partner).permit(:website, :name, :sells_app_exchange_apps, :description)\n end", "def create\n @partner = Partner.new(partner_params)\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'Partner was successfully created.' }\n format.json { render :show, status: :created, location: @partner }\n else\n format.html { render :new }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @draft_partnership = DraftPartnership.find(params[:id])\n\n respond_to do |format|\n if @draft_partnership.update_attributes(params[:partnership])\n\n format.xml \n else\n \n format.xml { render :xml => @draft_partnership.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n if @clientsOffers.update_attributes(params[:clientsOffers])\n format.html { redirect_to @clientsOffers, notice: 'ClientsOffers was succesfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clientsOffers.errors, status: :unprocesable_entity }\n end\n end\n end", "def update\n @participant.update(participant_update_params)\n respond_with(@participant)\n end", "def update\n @manufacturer_partner = ManufacturerPartner.find(params[:id])\n respond_to do |format|\n if @manufacturer_partner.update(manufacturer_partner_params)\n format.html { redirect_to([:admin, @manufacturer_partner], notice: 'Manufacturer Partner was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated a manufacturer partner: #{@manufacturer_partner.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @manufacturer_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_adpartner\n @adpartner = Adpartner.find(params[:id])\n end", "def create\n @partner = Partner.new(params[:partner])\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'Partner was successfully created.' }\n format.json { render json: @partner, status: :created, location: @partner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner = Partner.new(params[:partner])\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'Partner was successfully created.' }\n format.json { render json: @partner, status: :created, location: @partner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @participant = Participant.find(params[:id])\n # @participant.city = City.find(params[:participant][:city])\n\n respond_to do |format|\n if @participant.update_attributes(params[:participant])\n format.html { redirect_to participants_url, notice: 'Participant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @practice = Practice.new(practice_params)\n if params[:recruiter_partner].present?\n @partner = Partner.find(params[:recruiter_partner])\n @practice.partners << @partner\n end\n\n @practice.site_id = @current_partner.site.id\n\n respond_to do |format|\n if @practice.save\n format.html { redirect_to partner_path(current_partner), notice: 'Practice was successfully created.' }\n format.json { render :show, status: :created, location: @practice }\n else\n format.html { render :new }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def partner_params\n params.require(:partner).permit(\n :name, :description, :info, :price, :location_id, \n :site, :phone, :active, :premium, :premium_to, :slug,\n :rating, category_ids: [], location_ids: [], \n user_attributes: [:id, :email, :avatar, :avatar_remote_url, :password, :password_confirmation]\n )\n end", "def update\n @participant.update_attributes(participant_update_params)\n respond_with(@participant)\n end", "def set_fitpartner\n @fitpartner = Fitpartner.find(params[:id])\n end", "def update\n @pokeparty = Pokeparty.find(params[:id])\n\n respond_to do |format|\n if @pokeparty.update_attributes(params[:pokeparty])\n format.html { redirect_to @pokeparty, notice: 'Pokeparty was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pokeparty.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n\t\t@partner = Partner.find(params[:id])\n\t\[email protected]\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(partners_url) }\n\t\t\tformat.xml { head :ok }\n\t\tend\n\tend", "def partner_params\n params.fetch(:partner, {})\n end", "def potential_partner_params\n params.require(:potential_partner).permit(:studio_name, :person_to_contact, :contact_number, :email, :web_address, :how_did_you_hear_partner)\n end", "def update\n respond_to do |format|\n if @party.update(party_params)\n format.html { redirect_to @party, notice: 'Party was successfully updated.' }\n format.json { render :show, status: :ok, location: @party }\n else\n format.html { render :edit }\n format.json { render json: @party.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @available_partner_id = args[:available_partner_id] if args.key?(:available_partner_id)\n @log_only = args[:log_only] if args.key?(:log_only)\n end", "def update\n @person = Person.find(params[:id])\n @provider = Provider.find(params[:provider_id]) unless params[:provider_id].blank?\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n\n path = people_path\n msg = 'Person was successfully updated.'\n if @participant\n path = participant_path(@participant, :anchor => \"relationships_tab\")\n msg = 'Person was successfully updated.'\n end\n if @provider\n path = provider_path(@provider)\n msg = \"Person was successfully updated for #{@provider}.\"\n end\n\n format.html { redirect_to(path, :notice => msg) }\n format.json { render :json => @person }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_type_partner\n @type_partner = TypePartner.find(params[:id])\n end", "def update\n @participant = Participant.find(params[:id])\n respond_to do |format|\n if @participant.update_attributes(participant_params)\n format.html { redirect_to @participant, notice: 'Participant was successfully updated.' }\n format.json { render json: @participant }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n debugger\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n if @participants.update_attributes(params[:participant])\n AuditTrail.audit(\"Participant #{@participants.fullname} updated by #{current_user.login}\", edit_participant_url(@participants))\n flash[:notice] = 'Participants was successfully updated.'\n format.html { redirect_to(participants_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participants.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @party = Party.find(params[:id])\n\n respond_to do |format|\n if @party.update_attributes(params[:party])\n format.html { redirect_to @party, notice: 'Party was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @party.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@participant = Participant.find(params[:id])\n\n\t\tif @participant.update(participant_params)\n\t\t\thead :no_content\n\t\telse\n\t\t\trender json: @participant.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @previous_party.update(previous_party_params)\n format.html { redirect_to @previous_party, notice: 'Previous party was successfully updated.' }\n format.json { render :show, status: :ok, location: @previous_party }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @previous_party.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @counterparty = Counterparty.find(params[:id])\n\n respond_to do |format|\n if @counterparty.update_attributes(params[:counterparty])\n flash[:notice] = 'Counterparty was successfully updated.'\n format.html { redirect_to(@counterparty) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @counterparty.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @teleprovider.update(teleprovider_params)\n respond_with(@teleprovider, location: teleproviders_url, notice: 'Teleprovider was successfully updated.')\n else\n respond_with(@teleprovider)\n end\n end", "def update\n @trainer = Trainer.find(params[:id])\n\n if @trainer.update(trainer_params)\n head :no_content\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\n end", "def partner_params\n params.require(:partner).permit(:title, :icon_id, :description, :is_active, :url_address, :position)\n end", "def create\n @potential_partner = PotentialPartner.new(potential_partner_params)\n\n respond_to do |format|\n if @potential_partner.save\n PartnerNotifier.partner_subscription_confirmation(@potential_partner).deliver\n format.html { redirect_to @potential_partner, notice: 'Potential partner was successfully created.' }\n format.json { render :show, status: :created, location: @potential_partner }\n else\n format.html { render :new }\n format.json { render json: @potential_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @partnering_organization.update(partnering_organization_params)\n format.html { redirect_to @partnering_organization, notice: 'Partnering organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @partnering_organization }\n else\n format.html { render :edit }\n format.json { render json: @partnering_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n\t\t@partner = Partner.find(params[:id])\n\tend", "def update\n respond_to do |format|\n if @counterparty.update(counterparty_params)\n format.html { redirect_to @counterparty, notice: \"Counterparty was successfully updated.\" }\n format.json { render :show, status: :ok, location: @counterparty }\n else\n format.html { render :edit }\n format.json { render json: @counterparty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n game = Game.find(params[:game_id])\n participant = Participant.find(params[:participant_id])\n respond_to do |format|\n if participant.update(participant_params)\n format.html { redirect_to show_participant_path(game, participant) }\n format.json\n else\n format.html { render :edit }\n format.json\n end\n end\n end", "def destroy\n @partner = Partner.find(params[:id])\n @partner.destroy\n\n respond_to do |format|\n format.html { redirect_to(partners_url) }\n end\n end", "def update\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n if @participant.update_attributes(params[:participant])\n format.html { redirect_to @participant, notice: 'Participante actualizado.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def pbRegisterPartner(trainerid,trainername,partyid=0)\n Kernel.pbCancelVehicles\n trainer=pbLoadTrainer(trainerid,trainername,partyid)\n Events.onTrainerPartyLoad.trigger(nil,trainer)\n trainerobject=PokeBattle_Trainer.new(_INTL(trainer[0].name),trainerid)\n trainerobject.setForeignID($Trainer)\n for i in trainer[2]\n i.trainerID=trainerobject.id\n i.ot=trainerobject.name\n i.calcStats\n end\n $PokemonGlobal.partner=[trainerid,trainerobject.name,trainerobject.id,trainer[2]]\nend", "def update\n @votereply = Votereply.find(params[:id])\n\n respond_to do |format|\n if @votereply.update_attributes(params[:votereply])\n format.html { redirect_to(@votereply, :notice => 'Votereply was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @votereply.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_partnership\n @partnership = Partnership.find(params[:id])\n end", "def pbRegisterPartner(trainerid,trainername,partyid=0)\n if trainerid.is_a?(String) || trainerid.is_a?(Symbol)\n trainerid = getID(PBTrainers,trainerid)\n end\n Kernel.pbCancelVehicles\n trainer = pbLoadTrainer(trainerid,trainername,partyid)\n Events.onTrainerPartyLoad.trigger(nil,trainer)\n trainerobject = PokeBattle_Trainer.new(_INTL(trainer[0].name),trainerid)\n trainerobject.setForeignID($Trainer)\n for i in trainer[2]\n i.trainerID = trainerobject.id\n i.ot = trainerobject.name\n i.calcStats\n end\n $PokemonGlobal.partner = [trainerid,trainerobject.name,trainerobject.id,trainer[2]]\nend", "def destroy\n @partner = Partner.find(params[:id])\n @partner.destroy\n\n respond_to do |format|\n format.html { redirect_to partners_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @partner = Partner.find(params[:id])\n @partner.destroy\n\n respond_to do |format|\n format.html { redirect_to partners_url }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @crew_category_partner.update(crew_category_partner_params)\n format.html { redirect_to @crew_category_partner, notice: 'Category partner was successfully updated.' }\n format.json { render :show, status: :ok, location: @crew_category_partner }\n else\n format.html { render :edit }\n format.json { render json: @crew_category_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def partner_joined_update\n UpdateMailer.partner_joined_update\n end", "def update\n respond_to do |format|\n @participants = Participant.all\n @users = User.all\n if @lineitem.update(lineitem_params)\n format.html { redirect_to @lineitem, notice: 'Lineitem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lineitem.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_dealership(req)\n identity = Lynr::Model::Identity.new(dealership(req).identity.email, posted['password'])\n customer = create_customer(identity)\n dealer_dao.save(dealership(req).set(\n 'identity' => identity,\n 'customer_id' => customer.id,\n 'subscription' => Lynr::Model::Subscription.new(\n plan: Lynr.config('app').stripe.plan, status: 'trialing'\n ),\n ))\n end", "def update\n respond_to do |format|\n if @partner_event.update(partner_event_params)\n format.html { redirect_to @partner_event, notice: 'Partner event was successfully updated.' }\n format.json { render :show, status: :ok, location: @partner_event }\n else\n format.html { render :edit }\n format.json { render json: @partner_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_partnering_organization\n @partnering_organization = PartneringOrganization.find(params[:id])\n end", "def set_partnering_organization\n @partnering_organization = PartneringOrganization.find(params[:id])\n end", "def update\n update_resource @ride, ride_params\n end", "def update\n respond_to do |format|\n if @party.update(party_params)\n format.html { redirect_to @party, notice: '編集しました。' }\n format.json { render :show, status: :ok, location: @party }\n else\n format.html { render :edit }\n format.json { render json: @party.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @available_partner_info = args[:available_partner_info] if args.key?(:available_partner_info)\n @max_wait_time_sec = args[:max_wait_time_sec] if args.key?(:max_wait_time_sec)\n @min_delivery_fee = args[:min_delivery_fee] if args.key?(:min_delivery_fee)\n @min_wait_time_sec = args[:min_wait_time_sec] if args.key?(:min_wait_time_sec)\n @service_type = args[:service_type] if args.key?(:service_type)\n end" ]
[ "0.7806584", "0.7806584", "0.7683243", "0.7649199", "0.7616857", "0.7260612", "0.72279847", "0.72279847", "0.72263", "0.7210753", "0.70789826", "0.6987825", "0.69603235", "0.6947241", "0.69467074", "0.6937772", "0.6821978", "0.6802986", "0.67428565", "0.673897", "0.6645223", "0.66371256", "0.66211617", "0.66072816", "0.6568183", "0.6557985", "0.65312016", "0.6497529", "0.64878005", "0.6475659", "0.6465642", "0.64530146", "0.6426237", "0.6408652", "0.63672405", "0.63555616", "0.6320608", "0.6290576", "0.6289621", "0.6226686", "0.6140775", "0.6133779", "0.6119081", "0.61116487", "0.6087791", "0.6084154", "0.6055997", "0.605077", "0.60386145", "0.6027154", "0.6020986", "0.60125846", "0.6008374", "0.59824675", "0.59824675", "0.5981681", "0.59716606", "0.5960472", "0.59434587", "0.59380496", "0.5924689", "0.5871394", "0.5861052", "0.58597606", "0.583561", "0.5829013", "0.58233047", "0.58163685", "0.5810098", "0.5795329", "0.57939357", "0.57890344", "0.57834834", "0.5768368", "0.57680285", "0.5766921", "0.5752232", "0.57479817", "0.57451427", "0.57374823", "0.5735413", "0.569887", "0.56870335", "0.5674945", "0.5670956", "0.5670095", "0.5668042", "0.5648572", "0.56447524", "0.56447524", "0.564019", "0.5634928", "0.56328064", "0.562851", "0.56205755", "0.5603199", "0.5603199", "0.5598728", "0.5586906", "0.5583484" ]
0.7686307
2
numbers_to_add = Array.new numbers.size.times do |index| numbers_to_add += numbers[0..index] end numbers_to_add.reduce(:+) end alt w/ each_index
def sum_of_sums(numbers) numbers_to_add = Array.new numbers.each_index do |index| numbers_to_add += numbers[0..index] end numbers_to_add.reduce(:+) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_of_sums(numbers)\n sum = 0\n numbers.size.times do |idx|\n sum += numbers[0..idx].inject(:+)\n end\n \n sum\nend", "def sum_of_sums(numbers)\n (0...numbers.size).reduce(0) { |sum, idx| sum += numbers[0..idx].reduce(:+) }\nend", "def running_total(numbers)\n numbers.each.with_index do |num, i|\n if i != 0\n numbers[i] += numbers[i - 1]\n end\n end\n numbers\nend", "def running_total(numbers)\n numbers.map.with_index { |_, i| numbers[0..i].reduce(:+)}\nend", "def sum_of_sums(numbers)\n numbers.each_with_index.inject(0) do |result, (_, index)|\n result += numbers[0..index].sum\n result\n end\nend", "def sum_of_sums(numbers)\n sum_total = 0\n 1.upto(numbers.size) do |count|\n sum_total += numbers.slice(0, count).reduce(:+)\n end\n sum_total\nend", "def sum_of_sums(numbers)\n sum_total = 0\n 1.upto(numbers.size) do |count|\n sum_total += numbers.slice(0, count).reduce(:+)\n end\n sum_total\nend", "def sum_of_sums(numbers)\n sum_total = 0\n 1.upto(numbers.size) do |count|\n sum_total += numbers.slice(0, count).inject(:+)\n end\n sum_total\nend", "def sum_of_sums(arr)\n new_arr = []\n \n arr.each_with_index do |num, idx|\n new_arr << arr[0..idx].reduce(:+)\n end\n \n p new_arr.reduce(:+)\nend", "def sum_of_sums(numbers)\n sum = 0\n numbers.size.times { |counter| sum += numbers[0..counter].sum }\n sum\nend", "def running_total(numbers)\n index = 1\n while index < numbers.length\n numbers[index] = numbers[index] + numbers[index - 1]\n index += 1\n end\n numbers\nend", "def sum_of_sums1(numbers)\n result = 0\n index_end = 1\n loop do\n numbers[0, index_end].each { |number| result += number }\n break if index_end >= numbers.size\n\n index_end += 1\n end\n result\nend", "def sum_of_sums(array)\n sum = 0\n array.length.times do |index|\n sum += array[0, index + 1].reduce(&:+)\n end\n sum\nend", "def running_total4(numbers)\n sums = []\n numbers.each_with_index do |_, idx|\n current_total = numbers[0..idx].sum\n sums << current_total\n end\n\n sums\nend", "def sum_of_sums(numbers)\n 1.upto(numbers.size) do |num|\n num += 1\n end\n # num\nend", "def sum_of_sums(numbers)\n count = 1..numbers.size\n count.reduce(0) { |sum, cnt| sum += numbers[0, cnt].reduce(:+) }\nend", "def element_times_index(numbers)\n new_nums = []\n \n i = 0\n while i < numbers.length\n new_nums << numbers[i] * i\n \n i += 1\n end\n \n return new_nums\n end", "def running_total(array_of_nums)\n increment = 0\n running_total_array = []\n\n array_of_nums.each do |num|\n running_total_array << num + increment\n increment += num\n end\n\n running_total_array\nend", "def partial_sums(array)\n new_list = [0]\n array.each_with_index do |num, i|\n new_list.push(num + new_list[0 + i])\n end\n return new_list\nend", "def sum_of_sums(numbers)\n sum = 0\n idx = 0\n \n while idx < numbers.size\n idx2 = 0\n \n while idx2 < numbers[0..idx].size\n sum += numbers[0..idx][idx2]\n idx2 += 1\n end\n \n idx += 1\n end\n \n sum\nend", "def running_total(arr)\n tot = []\n arr.size.times do |i|\n tot << arr[0..i].reduce(&:+)\n end\n tot\nend", "def running_total_with_reduce_2(array)\n array.map.with_index do |el, idx|\n array[0..idx].reduce(:+)\n end\nend", "def sum_array( numbers )\r\n numbers.inject(0, :+)\r\nend", "def sum_of_sums(numbers)\n total = 0\n numbers.each_index { |index| total += numbers[0..index].sum }\n total\nend", "def sum_of_sums(array)\n elements = 1\n sums = 0 \n \n array.each_with_index do |element, index| \n counter = 0\n inner_sum = 0\n (index + 1).times do\n inner_sum += array[counter]\n counter += 1\n end\n\n sums += inner_sum\n end\n\n sums\nend", "def element_times_index(numbers)\n \n i = 0 # i represents to the index current index always\n \n new_array = []\n \n while i < numbers.length # We cant do less than or equal to here\n \n new_array << numbers[i] * i # You can shovel directly into a new array\n i += 1\n end\n return new_array\nend", "def sum_of_sums(numbers)\n sums = []\n 1.upto(numbers.size) do |length|\n sums << numbers[0, length].sum\n end\n \n sums.sum\nend", "def sum_of_sums(numbers)\n sum = 0\n idx = 0\n \n until idx == numbers.size\n idx2 = 0\n \n until idx2 == numbers[0..idx].size\n sum += numbers[0..idx][idx2]\n idx2 += 1\n end\n \n idx += 1\n end\n \n sum\nend", "def sum_of_sums(nums)\n sums = 0\n nums.each_with_index do |num, idx|\n sums += num * (nums.size - idx)\n end\n sums\nend", "def running_total(array)\n new_array = []\n i = 0\n while i <= array.length - 1\n new_array << array[0..i].reduce(:+)\n i += 1\n end\n new_array\nend", "def cust_red(array)\n total = 0 \n array.each_with_index do |el, i|\n total += el \n end \n total\nend", "def running_total(array)\n run_total = []\n \n index = 1\n while index <= array.length\n element = array.slice(0,index)\n run_total << element.inject(:+)\n index += 1\n end\n run_total\nend", "def running_total(array)\n array.map.with_index { |e, i| array[0..i].reduce(:+) }\nend", "def add_all_numbers(array)\n array.inject(:+)\nend", "def each_plus_one(array)\n array.map { |number|\n number += 1\n }\nend", "def element_times_index(numbers)\n new_arry = []\n i = 0\n while i < numbers.length\n new_arry << numbers[i] * i\n i += 1\n end\n return new_arry\n\nend", "def add_nums_iterative(arr)\n return nil if arr.length == 0\n total = 0\n arr.each do |num|\n total += num\n end\n total\nend", "def sum_of_sums(array)\n supersum = 0\n array.each_with_index do |_, index|\n supersum += array[0, index + 1].inject(:+)\n end\n supersum\nend", "def element_times_index(numbers)\n \n new_arr = []\n\n i = 0 \n while i < numbers.length\n new_num = numbers[i] * i\n new_arr << new_num\n i += 1\n end\n\n return new_arr\nend", "def sum_of_sums(numbers)\n sum_total = 0\n accumulator = 0\n\n numbers.each do |num|\n accumulator += num\n sum_total += accumulator\n end\n sum_total\nend", "def running_total_2 arr\n arr.each_with_index { |elm, idx| idx == 0 ? next : arr[idx] += arr [idx-1] }\nend", "def sum_of_sums(numbers)\n sum_total = 0\n accumulator = 0\n\n numbers.each do |num|\n accumulator += num\n sum_total += accumulator\n end\n\n sum_total\nend", "def sum_of_sums(numbers)\n sum_total = 0\n accumulator = 0\n\n numbers.each do |num|\n accumulator += num\n sum_total += accumulator\n end\n\n sum_total\nend", "def running_total_3(array)\n #total = 0\n #array_new = []\n array.each_with_object([]) do |i,x|\n next if i == 0\n x += array[i-1]\n end\nend", "def running_total(array)\n result = []\n sum = 0\n index = 0\n\n while array.size > index\n result << sum += array[index]\n index += 1\n end\n result\nend", "def element_times_index(numbers)\n\tnumber_multiplied = []\n\ti = 0\n\n\twhile i < numbers.length\n\t\tnumber = numbers[i] * i\n\t\tnumber_multiplied << number\n\n\t\ti += \n\tend\n\n\treturn number_multiplied\t\nend\n\n\n# ---------- Their Solution ----------\n# Line 37 is better than what I did in line 20-21\n\n# def element_times_index(numbers)\n# new_nums = []\n\n# i = 0\n# while i < numbers.length\n# new_nums << numbers[i] * i\n\n# i += 1\n# end\n\n# return new_nums\n# end\n\n# ---------- Tests ----------\nprint element_times_index([4, 7, 6, 5]) # => [0, 7, 12, 15]\nputs\nprint element_times_index([1, 1, 1, 1, 1, 1]) # => [0, 1, 2, 3, 4, 5]", "def sum_of_sums(array)\n total = 0\n\n 1.upto(array.size) do |num|\n total += array.slice(0, num).reduce(:+)\n end\n total\nend", "def sum_numbers(numbers)\r\n # Your code here\r\n #initalize the sum\r\n sum = 0\r\n #iterate through every element of a given array\r\n numbers.each do |number|\r\n #add the previous sum and next number in the array\r\n sum += number\r\n end\r\n \r\n return sum\r\nend", "def running_total(array)\n result = []\n array.each_index do |i|\n result[i] = (0..i).to_a.map { |e| array[e] }.inject(:+)\n end\n result\nend", "def running_total(array)\n p array.each_with_index { |_, index| array[0..index].reduce(:+) }\nend", "def array_to_sum(input)\n arr_sum = []\n\n input.each_with_index do |x,y| \n arr_sum << x*10**(input.size - (y + 1))\n end\n\n arr_sum.sum\nend", "def sum_of_sums(array)\n new_array = []\n array.size.times do |n|\n new_array << array[0..n]\n end\n new_array.flatten.reduce(:+)\nend", "def element_times_index(numbers)\n\tfor i in 0..numbers.length-1\n numbers[i] *= i\n end\n return numbers\nend", "def element_times_index(numbers)\n i = 0\n count = 0\n while i < numbers.length\n numbers[i] = numbers[i] * count\n count += 1\n i += 1\n end\n return numbers\nend", "def element_times_index(numbers)\n multiplied_numbers = []\n \n i = 0\n while i < numbers.length\n multiplied_numbers << numbers[i] * i\n \n i += 1\n end\n \n return multiplied_numbers\nend", "def running_total(input_array)\n sum = 0 # => 0, 0, 0, 0\n new_array = input_array.map do |value| # => [2, 5, 13], [14, 11, 7, 15, 20], [3], []\n sum += value # => 2, 7, 20, 14, 25, 32, 47, 67, 3\n end # => [2, 7, 20], [14, 25, 32, 47, 67], [3], []\nend", "def crazy_sum(numbers)\n i = 0\n sum = 0\n \n while i < numbers.length\n sum = sum + i * numbers[i]\n i = i + 1\n end\n \n return sum\nend", "def add_nums number\n i = number.digits.count - 1\n j = 0\n sum = 0\n array = number.digits\n p i\n loop do\n p array[i]\n sum += array[i]\n i -= 1\n j += 1\n break if i < 0 || j == 2\n end\n sum\nend", "def running_total(arr)\n new_arr = []\n running_total = arr[0]\n arr.each_with_index do |element, index|\n new_arr.push(running_total)\n running_total = running_total + arr[index + 1].to_s.to_i\n end\n new_arr\nend", "def running_total(numbers)\n sum = 0\n running_sums = []\n numbers.each_with_object(running_sums) do |number, array|\n sum += number\n array << sum\n end\n \n running_sums\nend", "def multiply_arrnums_by_index(numbers) # array of ints\n new_array = [] # empty array\n i = 0 # start at indice 0\n while i < numbers.length\n new_array << numbers[i] * i # shovel value of int val of the indice * the indice\n # numb_to_mult = numbers[i]\n # numb_multd = numbers[i] * numb_to_mult\n # new_array << numb_multd\n i += 1 # next iteration\n end\n return new_array\nend", "def adjacent_sum(arr)\n result = []\n\n arr.each_with_index do |num, idx|\n counter = 0\n if idx < arr.length-1\n counter += num + arr[idx+1]\n result << counter\n end\n end\n\n return result\n\nend", "def add_numbers(nums_array)\n nums_array.inject { |sum, el| sum + el }\nend", "def array_sum_with_index(arr)\n sum = 0\n arr.each_with_index {|n, i| sum += n*i}\n sum\nend", "def sum_it_up(array)\n return array if array.size == 1\n\n new_array = []\n\n array.size.times do |number|\n if (number + 1) < array.size\n new_array << (array[number] + array[number + 1])\n end\n end\n\n new_array\nend", "def sum_of_sums(numbers)\n sum = 0\n idx = 0\n \n loop do\n \n idx2 = 0\n loop do\n sum += numbers[0..idx][idx2]\n idx2 += 1\n break if idx2 == numbers[0..idx].size\n end\n \n idx += 1\n break if idx == numbers.size\n end\n \n sum\nend", "def array_sum_with_index(arr)\n acc = 0\n arr.each_with_index {|int, id| acc += (int * id)}\n acc\nend", "def sum(numbers)\n result = 0\n numbers.each do |num|\n result += num\n end\n result\nend", "def running_total(array)\n num = 0\n array.map do |number|\n num = number + num\n end\nend", "def running_total(array)\n sum = 0\n\n array.each_with_object([]) do |number, new_array|\n new_array << sum += number\n end\nend", "def my_sum(arr)\n accumulator = arr.first # store first element as accumulator\n\n arr.each_index do |idx|\n next if idx == 0 # skip first element: it's already the accumulator\n accumulator += arr[idx] # increment accumulator by current element\n end\n\n accumulator\nend", "def running_total(array)\n sum = 0\n new_array = []\n array.each do |num|\n sum += num\n new_array << sum\n end\n new_array\nend", "def running_total3(array)\n sum = 0\n array.map do |num|\n sum = [sum, num].inject(:+)\n end\nend", "def reduce_to_total(source_array, starting_point = 0)\n #source_array.reduce(starting_point) {|sum, n| sum + n}\n i = 0\n sum = starting_point\n while i < source_array.length do\n sum = sum + source_array[i]\n i += 1\n end\n return sum\nend", "def running_total(numbers)\n total = 0\n numbers.map { |number| total += number }\nend", "def running_total1(array)\n r_total = 0\n array.map { |n| r_total += n }\nend", "def running_total(array_nums)\n total = 0\n array_nums.map { |num| total += num }\nend", "def sum_of_sums_2(array)\n total_sum = 0\n i = 0\n len = array.size\n \n while i < len\n total_sum += array[0..i].inject { |sum, j| sum + j }\n i += 1\n end\n total_sum\nend", "def increase_array_values(array, number)\n array.map {|num| num + number}\nend", "def summation(num)\n sum = 0\n (0..num).each do |v|\n sum += v\n end\n return sum\nend", "def add_up(num)\n return (1..num).inject(:+)\nend", "def sum_array(numbers)\n total = 0\n for number in numbers\n total = total + number\n end\n return total\nend", "def sum_array a\n t = 0\n a.each{|i|t+=i.to_i}\n [a,t]\nend", "def sum_of_sums(arr)\n total_sum = 0\n idx = 0\n elements = 1\n while elements - 1 < arr.size\n total_sum += arr.slice(idx, elements).reduce(:+)\n elements += 1\n end\n total_sum\nend", "def summation(num)\n (1..num).reduce(:+)\nend", "def sum_of_sums(arr)\n total = 0\n (0..(arr.size - 1)).each { |i| total += arr[0..i].reduce(:+) }\n total\nend", "def sum_it_up(array)\n sum_of_array = 0\n array.each do |num|\n sum_of_array += num\n end\n return sum_of_array\nend", "def SimpleAdding(num)\n sum = 0\n (1..num).each do |number|\n sum += number\n end\n sum\nend", "def SimpleAdding(num)\n\n # code goes here\n range_num = *(1..num)\n return range_num.inject(:+)\n \nend", "def iterative_sum(arr)\n total = 0\n arr.each {|num| total += num}\n return total\nend", "def running_total(array)\n result = 0\n array.map {|num| result += num }\n array.map do |num|\n result += num\n end\nend", "def add_numbers(array)\n#add first in array to next in array. replace next in array\n#until array.length < 1\n return array[0] if array.length <= 1\n num1, num2 = array.pop, array.pop\n sum = num1.to_i + num2.to_i\n array.unshift(sum)\n add_numbers(array)\nend", "def running_total2(array)\n total = 0\n array.each_with_object([]) do |num, arr|\n total += num\n arr << total\n end\nend", "def add_up(i)\n sum = 0\n for item in 1..i do\n sum = sum + item\n end\n return sum\n end", "def running_total(array)\n new_array = []\n sum = 0\n count = 0\n\n while count < array.size\n array.each do |num|\n sum += num\n new_array << sum\n count += 1\n end\n end\n new_array\nend", "def running_total1(array)\n array_new = []\n loop do\n break if array.empty?\n array_new << array[0]\n array[1] = array[0] + array[1] if array.size >= 2\n array.shift\n end\n array_new\nend", "def running_total(arr)\n res = []\n running_total = 0\n\n arr.each do |element|\n running_total += element\n res << running_total\n end\n\n res\nend", "def iterative_sum(array)\n sum = 0\n array.each do |ele|\n sum += ele\n end\n sum\nend", "def sum_nums(num)\n (1..num).inject(&:+)\nend", "def sum_of_n(n)\n # your code here\n # result = []\n # if n >= 0\n # ary = (0..n).to_a\n # else\n # ary = (n..0).to_a.reverse\n # end\n # ary.each_with_index do |_numb, index|\n # somme = 0\n # result << somme += ary[0..index].sum + somme\n # end\n # result\n sum = 0\n (n.negative? ? 0.downto(n) : 0.upto(n)).map do |number|\n sum += number\n end\nend" ]
[ "0.81808513", "0.78774333", "0.7760235", "0.7748967", "0.7743926", "0.7690278", "0.76890254", "0.7683565", "0.76275915", "0.7602756", "0.75839686", "0.7567747", "0.75182885", "0.7517349", "0.74515843", "0.74444443", "0.74389607", "0.7426572", "0.7415172", "0.7404755", "0.7395899", "0.7383799", "0.73727065", "0.7357399", "0.73549646", "0.7351305", "0.7348334", "0.73313916", "0.73066926", "0.729753", "0.7291878", "0.72912115", "0.727931", "0.72760224", "0.72644454", "0.7261115", "0.72444063", "0.7240836", "0.7235396", "0.723396", "0.7233157", "0.7222404", "0.7222404", "0.71952623", "0.7190233", "0.71693873", "0.7167366", "0.7157957", "0.7155285", "0.71440464", "0.7142281", "0.7120787", "0.7116928", "0.7115103", "0.71128", "0.71007556", "0.70900816", "0.7088735", "0.70849836", "0.7069416", "0.7064937", "0.7062917", "0.70611227", "0.706087", "0.70574224", "0.70520043", "0.704728", "0.7046328", "0.7045828", "0.7036628", "0.70260817", "0.7023207", "0.7021505", "0.7014776", "0.7009258", "0.6997061", "0.6989525", "0.6988243", "0.697929", "0.6975312", "0.6965754", "0.6957347", "0.6948846", "0.6945735", "0.69437027", "0.69398654", "0.6936304", "0.6929161", "0.6926598", "0.6924021", "0.6923781", "0.6918496", "0.69160247", "0.691572", "0.6912788", "0.69071907", "0.6907048", "0.69032186", "0.6901537", "0.69011074" ]
0.832987
0
This method is highly questionable, but folks generally refer to a host by its ip address(es), and thus, this makes tasks easier to code.
def name ip_address end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def local_ip_2_host (ip)\n\t\tputs \"Reverse DNS lookup from the local host repository\" if @verbose\n\t\tip=ip.strip unless ip.nil?\n\t\tif @known_hosts.key?(ip)\n\t\t\treturn @known_hosts[ip]\n\t\telse\n\t\t\treturn nil\n\t\tend\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\t\treturn nil\n\tend", "def local_host_2_ip (host)\n\t\tputs \"DNS lookup from the local host repository\" if @verbose\n\t\thost=host.strip unless host.nil?\n\t\tif @known_hosts.key?(host)\n\t\t\treturn @known_hosts[host]\n\t\telse\n\t\t\treturn nil\n\t\tend\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\t\treturn nil\n\tend", "def search_host\n begin\n if @host_search\n @host = Resolv.getname self.ip.to_s\n else\n @host = nil\n end\n rescue Resolv::ResolvError\n @host = nil\n end\n end", "def ip_or_hostname\n super\n end", "def host=(_); end", "def normalized_host; end", "def host=(_arg0); end", "def host=(_arg0); end", "def host_ip\n Socket.gethostbyname(@backend.host)[3].unpack('CCCC') rescue [0, 0, 0, 0]\n end", "def host_2_ip (hostname)\n\t\tputs \"Perform DNS query on host: #{hostname}\" if @verbose\n\t\tbegin\n\t\t\tips=Array.new\n\t\t\tif is_ip?(hostname)\n\t\t\t\tputs \"No change - same IP is returned. \" if @verbose\n\t\t\t\treturn hostname.strip\n\t\t\telse\n\t\t\t\tips=Resolv.getaddresses(hostname)\n\t\t\t\tif (ips.empty?) then\n\t\t\t\t\tputs \"Failed to resolve #{hostname}\" if @verbose\n\t\t\t\t\treturn nil\n\t\t\t\telse\n\t\t\t\t\tputs \"IP found: #{ips.first}\" if @verbose\n\t\t\t\t\treturn ips.first.strip\n\t\t\t\tend\n\t\t\tend\n\t\trescue => ee\n\t\t\tputs \"Exception on method host_2_ip for host #{hostname}: #{ee}\" if @verbose\n\t\t\treturn nil\n\t\tend\n\tend", "def host; end", "def host; end", "def host; end", "def host; end", "def host; end", "def host; end", "def host; end", "def host; end", "def host; end", "def hostname_to_ip hostname\n begin \n ip = Resolv.getaddress(config[:host])\n rescue Resolv::ResolvError => resolv_err\n raise Exception.new(\"Resolver error: #{resolv_err}\")\n end\n return ip\n end", "def hosts=(_arg0); end", "def hosts=(_arg0); end", "def add_forward_lookup(_ip, _hostname)\n end", "def read_host_ip\n ip = read_machine_ip\n base_ip = ip.split(\".\")\n base_ip[3] = \"1\"\n base_ip.join(\".\")\n end", "def internal_host?(host)\n Resolv.getaddresses(host).all? { |ip| internal_ip?(ip) }\n rescue URI::Error\n false\n end", "def remote_ip; end", "def hosts; end", "def hosts; end", "def hosts; end", "def run_host(ip)\t\n\t\tbegin\n\n\t\t\tids = dcerpc_endpoint_list()\n\t\t\treturn if not ids\n\t\t\tids.each do |id|\n\t\t\t\tnext if not id[:prot]\n\t\t\t\tline = \"#{id[:uuid]} v#{id[:vers]} \"\n\t\t\t\tline << \"#{id[:prot].upcase} \"\n\t\t\t\tline << \"(#{id[:port]}) \" if id[:port]\n\t\t\t\tline << \"(#{id[:pipe]}) \" if id[:pipe]\n\t\t\t\tline << \"#{id[:host]} \" if id[:host]\n\t\t\t\tline << \"[#{id[:note]}]\" if id[:note]\n\t\t\t\tprint_status(line)\t\t\t\t\t\t\t\n\t\t\tend\n\t\t\t\n\t\trescue ::Interrupt\n\t\t\traise $!\n\t\trescue ::Exception => e\n\t\t\tprint_status(\"Error: #{e.to_s}\")\n\t\tend\n\tend", "def host_aliases (host)\n\t\tputs \"Search aliases in the local hosts data repository for host: #{host}\" if @verbose\n\t\thost.strip!\n\t\traise \"Unknown method input: #{host} We expect a FQDN host-name string from you. \" unless is_fqdn?(host)\n\t\taliases=Array.new\n\t\tif @known_hosts.key?(host)\n\t\t\tip=local_host_2_ip(host)\n\t\t\t@known_hosts.keys.map do |key|\n\t\t\t\tmy_ip=local_host_2_ip(key)\n\t\t\t\tif ip == my_ip\n\t\t\t\t\taliases.push(key)\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\traise \"Unknown host-name in the local hosts data repository: #{host}\"\n\t\tend\n\t\treturn aliases-[host]\n\trescue Exception => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\t\treturn nil\n\tend", "def hostip(ip)\n if GeoLocation::dev.nil? || GeoLocation::dev.empty?\n url = \"http://api.hostip.info/?ip=#{ip}\"\n uri = URI.parse(url) \n data_from_hostip_http_response(ip, Net::HTTP.get_response(uri).body)\n else\n data_from_maxmind_http_response(ip, GeoLocation::dev)\n end\n end", "def prime (host)\n\t\t\tbegin\n\t\t\t\traise \"Unknown hostname format: #{host}\" unless is_fqdn?(host)\n\t\t\t\tip=local_host_2_ip(host)\n\t\t\t\tip=host_2_ip(host) if ip.nil?\n\t\t\t\tif @known_ips.key?(ip)\n\t\t\t\t\treturn @known_hosts[ip]\n\t\t\t\tend\n\t\t\t\treturn host\n\t\t\trescue Exception => ee\n\t\t\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\t\t\t\treturn host\n\t\t\tend\n\t\tend", "def resolve!\n Resolv.each_address(host) do |address|\n return @ip = address if address =~ pattern\n end\n end", "def hostname; end", "def hostname; end", "def host_as_string; end", "def host\n @host\n end", "def host\n @host\n end", "def get_host\n @host\n end", "def host_2_ips (hostname)\n\t\tbegin\n\t\t\tips=Array.new\n\t\t\tif is_ip?(hostname)\n\t\t\t\tips.push(hostname)\n\t\t\t\treturn ips\n\t\t\telse\n\t\t\t\tips = Resolv.getaddresses(hostname)\n\t\t\t\tif (ips.empty?) then\n\t\t\t\t\tputs \"Failed to resolve #{hostname}\" if @verbose\n\t\t\t\t\treturn nil\n\t\t\t\telse\n\t\t\t\t\treturn ips\n\t\t\t\tend\n\t\t\tend\n\t\trescue => ee\n\t\t\tputs \"Exception on method host_2_ips for host #{hostname}: #{ee}\" if @verbose\n\t\t\treturn nil\n\t\tend\n\tend", "def host=(new_host); end", "def get_host( name )\n @hosts[ name ]\n end", "def lookup_hostname(host)\n Socket.getaddrinfo(host, nil, nil, Socket::SOCK_STREAM)[0][3]\n rescue SocketError\n raise(InvalidHostname, Errstr::INVALID_HOST % host)\n end", "def socket_host; end", "def host\n Socket.gethostname\n end", "def host\n Socket.gethostname\n end", "def host\n raise MethodMissingError\n end", "def ip; end", "def ip; end", "def host\n @host = self.hostuser\n end", "def hostname\n if resolution = CloudModel::AddressResolution.where(ip: ip).first\n resolution.name\n else\n begin\n Resolv.getname(ip)\n rescue\n ip\n end\n end\n end", "def read_host_ip(ip)\n\t UDPSocket.open do |s|\n\t if(ip.kind_of?(Array))\n\t s.connect(ip.last, 1)\n\t else\n\t s.connect(ip, 1)\n\t end\n\t s.addr.last\n\t end\n\tend", "def raw_host_with_port; end", "def remote_addr; end", "def ipaddr; end", "def hostname\n Resolv.getname(ip_address) rescue nil\n end", "def ipaddr?; end", "def check_ip; end", "def host(h = nil)\n if h\n @host = h\n else\n @host\n end\n end", "def block_unknown_hosts\n return if Rails.configuration.hosts.blank?\n raise UnsafeHostError, \"#{request.host} is not a safe host\" unless Rails.configuration.hosts.include?(request.host)\n end", "def [](hostname)\n return nil if @hosts[hostname].nil?\n @hosts[hostname][:host]\n end", "def ip_address; end", "def ip_address; end", "def ip_address; end", "def ip_address; end", "def ip_address; end", "def ip_address; end", "def get_host_info(s)\n\n # Prepare response array of aliases (IP and addresses)\n aliases = []\n\n # Get information from the given IP or name\n begin\n resp = Socket.getaddrinfo(s, nil)\n rescue\n aliases << s\n else\n\n fqdn = resp.first[2]\n ip = resp.first[3]\n aliases << fqdn\n\n if fqdn != ip\n host_dom = fqdn.split('.', 2)\n if $local_domain && host_dom.length == 2 && host_dom.last == $local_domain\n aliases << host_dom.first\n end\n aliases << ip\n end\n\n end\n\n return aliases\n\nend", "def host!(_arg0); end", "def host\n @host ||= target.split(':',2).first\n end", "def get_ip_address\n rpc_get_fact_direct('host_ip')\n end", "def host\n @host\n end", "def host_with_port; end", "def host\n\t\t\t# FIXME: This is both a hack and the best way I know to do this.\n\t\t\tSocket.getaddrinfo(Socket.gethostname, 0)[0][2]\n\t\tend", "def get_host_details\n @host = find_host_by_spoof || find_host_by_token || find_host_by_ip_or_mac\n unless @host\n logger.info \"#{controller_name}: unable to find a host that matches the request from #{request.env['REMOTE_ADDR']}\"\n head(:not_found) and return\n end\n unless @host.operatingsystem\n logger.error \"#{controller_name}: #{@host.name}'s operating system is missing!\"\n head(:conflict) and return\n end\n unless @host.operatingsystem.family\n # Then, for some reason, the OS has not been specialized into a Redhat or Debian class\n logger.error \"#{controller_name}: #{@host.name}'s operating system [#{@host.operatingsystem.fullname}] has no OS family!\"\n head(:conflict) and return\n end\n logger.info \"Found #{@host}\"\n end", "def full_host_record(ip:)\n load_cnames\n \n @forward_host_record ||= {} # Global, as we want to do name lookups.\n return_record = []\n unless( (host_records = @infoblox.get_host_by_ip(ip_address: ip)).nil? )\n host_records.each do |hosts|\n hosts.each do |hn|\n # Assign an empty record, if we haven't seen this host before\n @forward_host_record[hn] ||= { hostname: hn, ip: '', aliases: [], cnames: [] }\n \n # Record the IP. There may be multiple IPs with one hostname.\n @forward_host_record[hn][:ip] = ip\n \n # The hostname might have CNAMES point to it\n unless @reverse_cnames[hn].nil?\n @reverse_cnames[hn].each do |cn| \n @forward_host_record[hn][:cnames] << cn \n end\n end\n \n # The hostname may have alternate hostname A records, stored in IPAM as ALIASES\n @infoblox.get_alias(hostname: hn) do |a| \n short_alias = a.split('.',2)[0]\n @forward_host_record[hn][:aliases] << short_alias\n \n # The ALIASes might have CNAME records pointing to it\n unless @reverse_cnames[a].nil?\n # Record the ALIAS CNAMES against the parent hostname.\n @reverse_cnames[a].each do |cn| \n @forward_host_record[hn][:cnames] << cn \n end\n end\n end\n return_record << @forward_host_record[hn]\n \n # Add forward lookup entries for each ALIAS\n host_domain = hn.split('.',2)[1]\n @forward_host_record[hn][:aliases].each do |a|\n @forward_host_record[\"#{a}.#{host_domain}\"] = @forward_host_record[hn]\n end\n \n # Add forward lookup entries for each CNAME\n @forward_host_record[hn][:cnames].each do |cn|\n @forward_host_record[cn] = @forward_host_record[hn]\n end\n \n end\n end\n end\n return return_record\nend", "def unsafe_host?(item, _options = {})\n item = item.to_s.downcase\n return [:host, item] if in_pool?(:host, item)\n end", "def remote_addr=(_arg0); end", "def handle_hostip(bridge_name, hostip)\n # we should have a bridge with that name.\n hostip_resource = Wire::Resource::ResourceFactory\n .instance.create(:bridgeip, hostip, bridge_name)\n\n default_handle_resource(hostip_resource, :hostip,\n \"IP \\'#{hostip}\\' on bridge \\'#{bridge_name}\\'\", :up)\n rescue => e\n $log.error \"processing host ip: #{e}\"\n end", "def host_id; 'localhost' end", "def host?\n self.host\n end", "def resolve_hostname_on(host, hostname)\n match = curl_on(host, \"--verbose #{hostname}\", accept_all_exit_codes: true).stderr.match(ipv4_regex)\n match ? match[0] : nil\n end", "def has_required_host?\n true\n end", "def hostip\n static_network_config[\"ipAddress\"]\n end", "def hostname(ip_address)\n @resolver.getname(ip_address).to_s\n rescue\n 'IP address not found'\n end", "def remote_host\n # NOTE: Celluloid::IO does not yet support non-blocking reverse DNS\n @socket.peeraddr(true)[2]\n end", "def host\n self.host\n end", "def resolve_host(host)\n sleep_time = 5\n timeout_at = Time.now + 60\n msg = \"Waiting to resolve hostname '#{host}'; next attempt in #{sleep_time} seconds until #{timeout_at}\"\n resolved_host = \"\"\n wait_until(msg, timeout_at.to_i, sleep_time, {}) do\n resolved_host = `dig +short #{host} | head -n1`.rstrip\n !resolved_host.empty?\n end\n resolved_host\n end", "def peerip=(_arg0); end", "def hosts_entry\n \"#{@ip} #{name}\"\n end", "def read_host_ip(machine,env)\n nets = env[:libvirt_compute].list_networks\n if nets.size == 1\n net = nets.first\n else\n domain = env[:libvirt_compute].servers.get(machine.id.to_s)\n xml=Nokogiri::XML(domain.to_xml)\n networkname = xml.xpath('/domain/devices/interface/source').first.attributes['network'].value.to_s\n puts \"network name = #{networkname}\"\n net = env[:libvirt_compute].list_networks.find {|netw| netw[:name] == networkname}\n end\n # FIXME better implement by libvirt xml parsing\n `ip addr show | grep -A 2 #{net[:bridge_name]} | grep -i 'inet ' | tr -s ' ' | cut -d' ' -f3 | cut -d'/' -f 1`.chomp\n end", "def default_host\n host_list.first\n end", "def canonical_instance_host(opennebula_instance)\n fail 'Instance object not provided!' unless opennebula_instance\n hosts = []\n\n opennebula_instance.each('HISTORY_RECORDS/HISTORY') { |history| hosts << history['HOSTNAME'] }\n hosts.compact!\n\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Assigning hosts #{hosts.inspect} \" \\\n \"to #{opennebula_instance['ID'].inspect}\"\n hosts.last\n end", "def host\n nodes[0][0]\n end", "def run_host(ip)\n\n\t\tbegin\n\n\t\t\tconnect\n\n\t\t\tcert = OpenSSL::X509::Certificate.new(sock.peer_cert)\n\n\t\t\tdisconnect\n\n\t\t\tif cert\n\t\t\t\tprint_status(\"#{ip}:#{rport} Subject: #{cert.subject} Signature Alg: #{cert.signature_algorithm}\")\n\t\t\t\talg = cert.signature_algorithm\n\n\t\t\t\tif alg.downcase.include? \"md5\"\n\t\t\t\t\tprint_status(\"#{ip}:#{rport} WARNING: Signature algorithm using MD5 (#{alg})\")\n\t\t\t\tend\n\n\t\t\t\tvhostn = nil\n\t\t\t\tcert.subject.to_a.each do |n|\n\t\t\t\t\tvhostn = n[1] if n[0] == 'CN'\n\t\t\t\tend\n\n\t\t\t\tif vhostn\n\t\t\t\t\tprint_status(\"#{ip}:#{rport} has common name #{vhostn}\")\n\n\t\t\t\t\t# Store the virtual hostname for HTTP\n\t\t\t\t\treport_note(\n\t\t\t\t\t\t:host\t=> ip,\n\t\t\t\t\t\t:port\t=> rport,\n\t\t\t\t\t\t:proto => 'tcp',\n\t\t\t\t\t\t:type\t=> 'http.vhost',\n\t\t\t\t\t\t:data\t=> {:name => vhostn}\n\t\t\t\t\t)\n\n\t\t\t\t\t# Store the SSL certificate itself\n\t\t\t\t\treport_note(\n\t\t\t\t\t\t:host\t=> ip,\n\t\t\t\t\t\t:proto => 'tcp',\n\t\t\t\t\t\t:port\t=> rport,\n\t\t\t\t\t\t:type\t=> 'ssl.certificate',\n\t\t\t\t\t\t:data\t=> {\n\t\t\t\t\t\t\t:cn => vhostn,\n\t\t\t\t\t\t\t:subject => cert.subject.to_a,\n\t\t\t\t\t\t\t:algorithm => alg\n\n\t\t\t\t\t\t}\n\t\t\t\t\t)\n\n\t\t\t\t\t# Update the server hostname if necessary\n\t\t\t\t\tif vhostn !~ /localhost|snakeoil/i\n\t\t\t\t\t\treport_host(\n\t\t\t\t\t\t\t:host => ip,\n\t\t\t\t\t\t\t:name => vhostn\n\t\t\t\t\t\t)\n\t\t\t\t\tend\n\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tprint_status(\"#{ip}:#{rport}] No certificate subject or common name found\")\n\t\t\tend\n\t\trescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout\n\t\trescue ::Timeout::Error, ::Errno::EPIPE\n\t\tend\n\tend", "def report_host(opts)\n\n return if !active\n addr = opts.delete(:host) || return\n\n # Sometimes a host setup through a pivot will see the address as \"Remote Pipe\"\n if addr.eql? \"Remote Pipe\"\n return\n end\n\n ::ApplicationRecord.connection_pool.with_connection {\n wspace = Msf::Util::DBManager.process_opts_workspace(opts, framework)\n opts = opts.clone\n opts.delete(:workspace)\n\n begin\n retry_attempts ||= 0\n if !addr.kind_of? ::Mdm::Host\n addr = Msf::Util::Host.normalize_host(addr)\n\n unless ipv46_validator(addr)\n raise ::ArgumentError, \"Invalid IP address in report_host(): #{addr}\"\n end\n\n conditions = {address: addr}\n conditions[:comm] = opts[:comm] if !opts[:comm].nil? && opts[:comm].length > 0\n host = wspace.hosts.where(conditions).first_or_initialize\n else\n host = addr\n end\n\n ostate = host.state\n\n # Truncate the info field at the maximum field length\n if opts[:info]\n opts[:info] = opts[:info][0,65535]\n end\n\n # Truncate the name field at the maximum field length\n if opts[:name]\n opts[:name] = opts[:name][0,255]\n end\n\n if opts[:os_name]\n os_name, os_flavor = split_windows_os_name(opts[:os_name])\n opts[:os_name] = os_name if os_name.present?\n if opts[:os_flavor].present?\n if os_flavor.present? # only prepend if there is a value that needs it\n opts[:os_flavor] = os_flavor + opts[:os_flavor]\n end\n else\n opts[:os_flavor] = os_flavor\n end\n end\n\n opts.each do |k,v|\n if host.attribute_names.include?(k.to_s)\n unless host.attribute_locked?(k.to_s)\n host[k] = v.to_s.gsub(/[\\x00-\\x1f]/n, '')\n end\n elsif !v.blank?\n dlog(\"Unknown attribute for ::Mdm::Host: #{k}\")\n end\n end\n host.info = host.info[0,::Mdm::Host.columns_hash[\"info\"].limit] if host.info\n\n # Set default fields if needed\n host.state = Msf::HostState::Alive if host.state.nil? || host.state.empty?\n host.comm = '' unless host.comm\n host.workspace = wspace unless host.workspace\n\n begin\n framework.events.on_db_host(host) if host.new_record?\n rescue => e\n wlog(\"Exception in on_db_host event handler: #{e.class}: #{e}\")\n wlog(\"Call Stack\\n#{e.backtrace.join(\"\\n\")}\")\n end\n\n host_state_changed(host, ostate) if host.state != ostate\n\n if host.changed?\n msf_import_timestamps(opts, host)\n host.save!\n end\n rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid\n # two concurrent report requests for a new host could result in a RecordNotUnique or\n # RecordInvalid exception, simply retry the report once more as an optimistic approach\n retry if (retry_attempts+=1) <= 1\n raise\n end\n\n if opts[:task]\n Mdm::TaskHost.create(\n :task => opts[:task],\n :host => host\n )\n end\n\n host\n }\n end", "def inventario_portainer()\n $rango_ip = crear_rango_ip($ip_a, $ip_z) \n $rango_ip.each do | ip | \n if portainer?(ip) \n $portainer_hosts.push(ip) \n end\n end\nend", "def peer_ip; end", "def stub_hosts(ip_spec)\n stub_hosts_on(default, ip_spec)\n end", "def ssh_host_name( host )\n # This is included here for expected Space-wide policy settings.\n host[ :internet_name ] || host[ :internet_ip ] || host.name\n end" ]
[ "0.7512056", "0.7509218", "0.7114507", "0.6956967", "0.69539124", "0.68991584", "0.6895277", "0.6895277", "0.6853046", "0.6761145", "0.6748335", "0.6748335", "0.6748335", "0.6748335", "0.6748335", "0.6748335", "0.6748335", "0.6748335", "0.6748335", "0.67390376", "0.6729594", "0.6729594", "0.6713086", "0.6665981", "0.6608741", "0.66069144", "0.66056496", "0.66056496", "0.66056496", "0.65985334", "0.6598046", "0.6586414", "0.65547025", "0.65355074", "0.64998883", "0.64998883", "0.64834523", "0.6475883", "0.6475883", "0.64438725", "0.6439985", "0.64343506", "0.6429345", "0.6398879", "0.63958645", "0.6392071", "0.63903695", "0.6380726", "0.63786626", "0.63786626", "0.6377117", "0.6350315", "0.63410914", "0.6321762", "0.6316333", "0.6314481", "0.6311942", "0.63089585", "0.63076764", "0.6297733", "0.6296888", "0.62943184", "0.62881976", "0.62881976", "0.62881976", "0.62881976", "0.62881976", "0.62881976", "0.62840897", "0.62802684", "0.6277916", "0.6269838", "0.62669224", "0.62437683", "0.6242768", "0.6235089", "0.62341386", "0.62293583", "0.62186766", "0.62178564", "0.6216419", "0.62163943", "0.6209586", "0.62049216", "0.62030894", "0.62014496", "0.6199202", "0.6195603", "0.6187612", "0.6181503", "0.6178824", "0.6162081", "0.61598283", "0.61535454", "0.6150711", "0.6146109", "0.61440074", "0.6139703", "0.61383384", "0.6135535", "0.6132044" ]
0.0
-1
Create a new Command Object from a valid XML representation xmlDoc = an xml document (REXML::Document) object
def create_from(xmlDoc) begin # Set the Type @attributes[:CMDTYPE] = xmlDoc.expanded_name.to_sym # Parse the XML object xmlDoc.each_element { |e| # For the OMLCONFIG tag, add the XML value to this Command Object if e.expanded_name.upcase.to_sym == :OMLCONFIG @attributes[e.expanded_name.upcase.to_sym] = e # For the other tags, add the text value to this Command Object else @attributes[e.expanded_name.upcase.to_sym] = e.text end } rescue Exception => ex raise "Failed to create new OmfCommandObject from XML" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_from_xml(xmlDoc)\r\n @type = xmlDoc.expanded_name\r\n xmlDoc.each_element(\"ID\") { |e| @procID = e.text }\r\n xmlDoc.each_element(\"GROUP\") { |e| @group = e.text }\r\n xmlDoc.each_element(\"PATH\") { |e| @path = e.text }\r\n xmlDoc.each_element(\"ARGSLINE\") { |e| @cmdLineArgs = e.text }\r\n xmlDoc.each_element(\"ENV\") { |e| @env = e.text }\r\n # Dump the XML description of the OML configuration into a file\r\n xmlDoc.each_element(\"OML_CONFIG\") { |config|\r\n configPath = nil\r\n config.each_element(\"omlc\") { |omlc|\r\n configPath = \"/tmp/#{omlc.attributes['exp_id']}-#{@procID}.xml\"\r\n }\r\n f = File.new(configPath, \"w+\")\r\n config.each_element {|el|\r\n f << el.to_s\r\n }\r\n f.close\r\n # Set the OML_CONFIG environment with the path to the XML file\r\n @env << \" OML_CONFIG=#{configPath} \"\r\n }\r\n end", "def from_xml(xml)\n\t\tend", "def parse_xml(xml)\n new from_xml(xml)\n end", "def load_xml(str)\r\n @xml = REXML::Document.new(str.to_s)\r\n xml_to_instance\r\n self\r\n end", "def from_xml_elem(ctx, root)\n #p [:from_xml_elem, :ctx, root]\n attributes = root.attributes.inject({ }) { |hash, (k, v)| hash[k] = EscapeXML.unescape(v.to_s); hash}\n text, children = root.children.partition{ |x| text_node?(x) }\n text = text.map{ |x| x.to_s}.reject{ |s| s =~ /^\\s*$/}.join('')\n element_name = root.name\n if element_name !~ /[A-Z]/\n element_name = Doodle::Utils.camel_case(element_name)\n end\n klass = Utils.const_lookup(element_name, ctx)\n #p [:creating_new, klass, text, attributes]\n #p [:root1, root]\n # don't pass in empty text - screws up when class has only\n # child elements (and no attributes) because tries to\n # instantiate child element from empty string \"\"\n if text == \"\"\n text = nil\n end\n args = [text, attributes].compact\n oroot = klass.new(*args) {\n #p [:in_block]\n from_xml_elem(root)\n }\n #p [:oroot, oroot]\n oroot\n end", "def initialize(run, xml)\n @run = run\n\n parse_xml(xml)\n end", "def load_xml(xml)\n @mmdoc = REXML::Document.new(xml)\n end", "def command(*args, &_block)\n builder do |xml|\n xml.command do\n if block_given?\n yield xml\n else\n command = args.shift\n command.call(xml)\n args.each do |ext|\n xml.extension do\n ext.call(xml)\n end\n end\n end\n xml.clTRID(clTRID)\n end\n end\n end", "def initialize(xmldoc)\n @xmldoc = xmldoc\n @output = {}\n end", "def parse(doc)\n parser = parser_class.new\n parser.run(doc)\n end", "def execute_command\n begin\n if @cgi.has_key?('type') then\n doc = REXML::Document.new\n command = doc.add_element 'COMMAND'\n @cgi.params.each_pair { |key,value| command.attributes[key]=value}\n xmlCommand = doc.to_s\n socket = TCPSocket.new(@host,@port)\n socket.puts xmlCommand \n xmlResult = socket.gets.chop\n docResult = REXML::Document.new xmlResult\n end\n rescue\n puts 'Probleem bij uitvoeren commando'\n exit\n end\n end", "def initialize(options={})\n raise ValueError.new(\"You must include the an :xml or :doc option when creating a message\") unless options[:xml] || options[:doc]\n if (options[:xml])\n @document = REXML::Document.new(options[:xml])\n @xml = options[:xml]\n else\n @document = options[:doc]\n end \n \n end", "def build_command(action, object, attributes = nil, cookie = nil)\n xml = <<-XML\n\n <?xml version='1.0' encoding='UTF-8' standalone='no' ?>\n <!DOCTYPE OPS_envelope SYSTEM 'ops.dtd'>\n <OPS_envelope>\n <header>\n <version>0.9</version>\n </header>\n <body>\n <data_block>\n <dt_assoc>\n <item key=\"protocol\">XCP</item>\n <item key=\"action\">GET_BALANCE</item>\n <item key=\"object\">BALANCE</item>\n <item key=\"registrant_ip\"/>\n </dt_assoc>\n </data_block>\n </body>\n </OPS_envelope>\n XML\n\n doc = REXML::Document.new(xml)\n doc.root.elements[\"body/data_block/dt_assoc/item[@key='action']\"].text = action\n doc.root.elements[\"body/data_block/dt_assoc/item[@key='object']\"].text = object\n\n unless cookie.nil?\n cookie_elem = doc.root.elements[\"body/data_block/dt_assoc\"].add_element('item', {'key' => 'cookie'})\n cookie_elem.text = cookie\n end\n\n unless attributes.nil?\n elem = doc.root.elements[\"body/data_block/dt_assoc\"].add_element('item', {'key' => 'attributes'})\n elem = elem.add_element('dt_assoc')\n attributes.each_pair do |key, value|\n attrib_elem = elem.add_element('item', {'key' => key})\n if value.is_a?(Hash) || value.is_a?(Array)\n xml_add_collection_as_child(attrib_elem, value)\n else\n attrib_elem.text = (value.is_a?(String) ? value.dup : value)\n end\n end\n end\n\n doc.to_s\n end", "def create_document(xml)\n begin\n REXML::Document.new(xml) \n rescue REXML::ParseException\n # nil\n end \nend", "def xml_doc\n @xml_doc ||= unless @xml.blank?\n Nokogiri.parse(@xml)\n else\n Nokogiri::XML::Document.new\n end\n rescue\n raise RuntimeError, 'expected document to parse'\n end", "def initialize(xml)\n @doc = Nokogiri::XML(xml)\n parse_response\n end", "def initialize(xml)\n @doc = Nokogiri::XML(xml)\n parse_response\n end", "def make_document(xml)\n xml.is_a?(Atom::XML::Document) ? xml : Atom::XML::Document.string(xml)\n end", "def initialize(xml)\n @source = isxml?(xml) ? xml : File.read(xml)\n @doc_stream = AltoDocStream.new\n parser = Nokogiri::XML::SAX::Parser.new(doc_stream)\n parser.parse(@source)\n end", "def initialize\n\t@xml = '<?xml version=\"1.0\"?>\n<?misc:processingInstruction \"with arguments\"?>\n<?other:piNoArgs ?>\n<!DOCTYPE outer PUBLIC \"public id\" \"foobar\" [\n <!ENTITY foo \"bletch\">\n <!ELEMENT el>\n <!ATTLIST el EMPTY>\n <!NOTATION notation ignored>\n]>\n<!-- comment -->\n<outer>\n data&amp;&foo;\nmore on next line<simpleTag>text</simpleTag>\n<inner:tag a=\"tabs\tto\tspaces&foo;\"/><![CDATA[xx<z&xx</\nnewline in cdata\n]]>\n<p>text <b>bold café coffee</b> more text</p>\n</outer>'\n\n\temptyAttrs = Hash.new()\n\t@newlineTok = NQXML::Text.new(\"\\n\")\n\n\tattrs = Hash.new()\n\tattrs['version'] = '1.0'\n\t@xmlDecl = NQXML::XMLDecl.new('xml', attrs, '<?xml version=\"1.0\"?>')\n\n\tsrc = '<?misc:processingInstruction \"with arguments\"?>'\n\t@piWithArgs =\n\t NQXML::ProcessingInstruction.new('misc:processingInstruction',\n\t\t\t\t\t '\"with arguments\"', src)\n\n\t@piNoArgs = NQXML::ProcessingInstruction.new('other:piNoArgs', '',\n\t\t\t\t\t\t '<?other:piNoArgs ?>')\n\n\t@entityTag =\n\t NQXML::GeneralEntityTag.new('foo', 'bletch', nil, nil,\n\t\t\t\t\t'<!ENTITY foo \"bletch\">')\n\t@element = NQXML::Element.new('el', '', '<!ELEMENT el>')\n\t@attlist = NQXML::Attlist.new('el', 'EMPTY', '<!ATTLIST el EMPTY>')\n\t@notation = NQXML::Notation.new('notation', 'ignored',\n\t\t\t\t\t'<!NOTATION notation ignored>')\n\t@doctypePubid =\n\t NQXML::PublicExternalID.new('\"public id\"', '\"foobar\"',\n\t\t\t\t\t'PUBLIC \"public id\" \"foobar\"')\n\t@doctype =\n\t NQXML::Doctype.new('outer', @doctypePubid,\n\t\t\t [@entityTag, @element, @attlist, @notation],\n\t\t\t \"<!DOCTYPE outer PUBLIC \\\"public id\\\" \\\"foobar\\\" [\\n\" +\n\t\t\t \" <!ENTITY foo \\\"bletch\\\">\\n\" +\n\t\t\t \" <!ELEMENT el>\\n\" +\n\t\t\t \" <!ATTLIST el EMPTY>\\n\" +\n\t\t\t \" <!NOTATION notation ignored>\\n\" +\n\t\t\t \"]>\")\n\n\t@comment = NQXML::Comment.new('<!-- comment -->')\n\t@outerStart = NQXML::Tag.new('outer', emptyAttrs, false, '<outer>')\n\t@textDataWithSub = NQXML::Text.new(\"\\n data&bletch\\nmore on next line\")\n\t@simpleTagStart = NQXML::Tag.new('simpleTag', emptyAttrs, false,\n\t\t\t\t\t '<simpleTag>')\n\t@simpleTextData = NQXML::Text.new('text')\n\t@simpleTagEnd = NQXML::Tag.new('simpleTag', nil, true, '</simpleTag>')\n\n\tattrs = Hash.new()\n\tattrs['a'] = 'tabs to spacesbletch'\n\t@innerTagStart = NQXML::Tag.new('inner:tag', attrs, false,\n\t\t\t\t\t'<inner:tag a=\"tabs\tto\tspaces&foo;\"/>')\n\n\t@innerTagEnd = NQXML::Tag.new('inner:tag', nil, true,\n\t\t\t\t\t'<inner:tag a=\"tabs\tto\tspaces&foo;\"/>')\n\t@pTagStart = NQXML::Tag.new('p', emptyAttrs, false, '<p>')\n\t@pTagEnd = NQXML::Tag.new('p', nil, true, '</p>')\n\t@bTagStart = NQXML::Tag.new('b', emptyAttrs, false, '<b>')\n\t@bTagEnd = NQXML::Tag.new('b', nil, true, '</b>')\n\t@textText = NQXML::Text.new('text ')\n\t@boldText = NQXML::Text.new('bold café coffee')\n\t@moreTextText = NQXML::Text.new(' more text')\n\n\t@cdata = NQXML::Text.new(\"xx<z&xx</\\nnewline in cdata\\n\",\n\t\t\t\t \"<![CDATA[xx<z&xx</\\nnewline in cdata\\n]]>\")\n\t@outerEnd = NQXML::Tag.new('outer', nil, true, '</outer>')\n\n\t@sub1_xml = '<?xml version=\"1.0\"?>\n<!DOCTYPE outer SYSTEM \"foobar\" [\n <!ENTITY example \"<p>An ampersand (&#38;#38;) may be escaped numerically (&#38;#38;#38;) or with a general entity (&amp;amp;).</p>\" >\n]>\n'\n\tsrc = '<!ENTITY example \"<p>An ampersand (&#38;#38;) may be' +\n\t ' escaped numerically (&#38;#38;#38;) or with a general entity' +\n\t ' (&amp;amp;).</p> >'\n\tval = \"<p>An ampersand (&#38;) may be escaped numerically\" +\n\t \" (&#38;#38;) or with a general entity (&amp;amp;).</p>\"\n\t@sub1Entity = NQXML::GeneralEntityTag.new('example', val, nil, nil,\n\t\t\t\t\t\t src)\n\t\t\t\t\t\t\n\t@sub2_xml = '<?xml version=\"1.0\"?>\n<!DOCTYPE test [\n<!ELEMENT test (#PCDATA) >\n<!ENTITY % xx \\'&#37;zz;\\'>\n<!ENTITY % zz \\'&#60;!ENTITY tricky \"error-prone\" >\\' >\n%xx;\n]>\n<test>This sample shows a &tricky; method.</test>\n'\n\t@xxEntity =\n\t NQXML::ParameterEntityTag.new('xx', '%zz;', nil,\n\t\t\t\t\t '<!ENTITY % zz \\'&#37;zz;\\'>')\n\n\tsrc = '<!ENTITY % zz \\'&#60;!ENTITY tricky \"error-prone\" >\\' >'\n\tval = '<!ENTITY tricky \"error-prone\" >'\n\t@zzEntity = NQXML::ParameterEntityTag.new('zz', val, nil, src)\n end", "def initialize(xml_str, spec_yaml_str=nil)\n # Flag for the time string format\n @show_seconds = false\n\n raise ArgumentError.new('Parser initiation requires XML String argument') if xml_str.nil? or xml_str.empty?\n if spec_yaml_str.nil? or spec_yaml_str.empty?\n @@spec = YAML::load(File.read(File.expand_path('../../../conf/nemsis_spec.yml', __FILE__)))\n else\n @@spec = YAML::load(spec_yaml_str)\n end\n self.xml_str = xml_str\n self.xml_doc = Nokogiri::XML(xml_str)\n xml_doc.remove_namespaces!\n end", "def initialize(run, xml)\n super(run, xml)\n\n @error = false\n @structure = parse_data(xml_first_child(xml))\n\n # cached outputs\n @values = nil\n @refs = nil\n @types = nil\n @sizes = nil\n @total_size = nil\n end", "def initialize(res, opts = {})\n @data = res\n opts[:parser] ||= Nori.new(\n parser: :rexml,\n convert_tags_to: lambda { |tag| tag.snakecase.to_sym }\n )\n @opts = opts\n end", "def initialize \n @doc = Document.new \n @action = @doc.add_element('action')\n @param = Element.new('parameter')\n end", "def initialize(xml)\n #puts \"________________________________________\"\n #puts xml\n #puts \"________________________________________\"\n @doc = Nokogiri::XML(xml)\n parse_response\n end", "def from_xml(xml, opts=OPTS)\n from_xml_node(Nokogiri::XML(xml).children.first, opts)\n end", "def initialize(xml=nil, target=nil, options={}, &block)\n \n @read_at = Time.new\n @noko = nil\n @source_xml = nil\n \n ## Use XML to build object\n from_xml(xml) if xml\n \n ## Use block for further configuration or manual creation\n self.instance_eval(&block) if block\n\n end", "def command(*a)\n command = Command.new(*a)\n command.node = self\n command\n end", "def parse\n Ox.parse(@xml)\n end", "def call(cmd, *args, env: {})\n cmd = bin.join(cmd.to_s).to_s\n args = [\"--host=#{@host}\", \"--xml\"] + args.map(&:to_s)\n env = {\n \"LD_LIBRARY_PATH\" => \"#{lib}:#{ENV['LD_LIBRARY_PATH']}\",\n \"MOABHOMEDIR\" => \"#{moabhomedir}\"\n }.merge(env.to_h)\n o, e, s = Open3.capture3(env, cmd, *args)\n s.success? ? Nokogiri::XML(o) : raise(CommandFailed, e)\n rescue Errno::ENOENT => e\n raise InvalidCommand, e.message\n end", "def make_xml_request_object( opts={} )\n\t\tdata = make_xml_request( opts )\n\t\treturn Mongrel2::Request.parse( data )\n\tend", "def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end", "def shallow_parse(xml_document)\n @tokens = xml_document.scan(@@xml_spe)\n end", "def initialize(xml_node)\n @xml = xml_node\n end", "def initialize(xml_node)\n @xml = xml_node\n end", "def initialize(xml_node)\n @xml = xml_node\n end", "def new_parser_with_data\n\tdoc = load_sample_xml\n\tparser = GreenButton::Parser.new(doc)\nend", "def rexml_doc(obj)\n case obj\n when REXML::Document, REXML::Element\n obj\n else\n REXML::Document.new(obj)\n end\n end", "def get_builder_obj(shell_id, command_id, &block)\r\n body = { \"#{NS_WIN_SHELL}:DesiredStream\" => 'stdout stderr',\r\n :attributes! => {\"#{NS_WIN_SHELL}:DesiredStream\" => {'CommandId' => command_id}}}\r\n builder = Builder::XmlMarkup.new\r\n builder.instruct!(:xml, :encoding => 'UTF-8')\r\n builder.tag! :env, :Envelope, namespaces do |env|\r\n env.tag!(:env, :Header) { |h| h << Gyoku.xml(merge_headers(header,resource_uri_cmd,action_receive,selector_shell_id(shell_id))) }\r\n env.tag!(:env, :Body) do |env_body|\r\n env_body.tag!(\"#{NS_WIN_SHELL}:Receive\") { |cl| cl << Gyoku.xml(body) }\r\n end\r\n end\r\n builder\r\n end", "def _convertXML() \n\n require 'rexml/document'\n return REXML::Document.new(self.response)\n\n raise \"Unimplemented.\"\n \n\t#\t\t\tfrom xml.dom.ext.reader import PyExpat\n#\t\t\tParser = PyExpat.Reader\n#\t\texcept ImportError :\n#\t\t\tfrom xml.dom.ext.reader import Sax2\n#\t\t\tParser = Sax2.Reader\n#\t\t\t#import warnings\n#\t\t\t#warnings.warn(\"Expat parser could not be loaded, using Sax2. Might slow down things...\")\n#\t\treader = Parser()\n#\t\treturn reader.fromStream(self.response)\n\n end", "def initialize(doc)\n @doc = doc\n end", "def from_xml(*args, &block)\n create_represented(*args, &block).from_xml(*args)\n end", "def xml_document(obj)\n case obj\n when XML::Document\n XML::Document.document(obj)\n else\n XML::Document.new('1.0')\n end\n end", "def load_xml_document file_name\n xml_file = File.new file_name, \"r\"\n return Document.new xml_file\n end", "def initialize(data, changeset)\n @reader = XML::Reader.string(data)\n @changeset = changeset\n # document that's (re-)used to handle elements expanded out of the\n # diff processing stream.\n @doc = XML::Document.new\n @doc.root = XML::Node.new(\"osm\")\n end", "def from_xml_node(parent, opts=OPTS)\n new.from_xml_node(parent, opts)\n end", "def xml_document\n xml = XML::Document.new\n xml.root = self.to_xml\n xml\n end", "def to_xml_document(opts={}, doc=nil)\n doc ||= REXML::Document.new\n default_xml_element_name = lambda { Extlib::Inflection.underscore(self.class.name).tr(\"/\", \"-\") }\n root = doc.add_element(opts[:element_name] || default_xml_element_name[])\n\n #TODO old code base was converting single quote to double quote on attribs\n\n propset = properties_to_serialize(opts)\n propset.each do |property|\n value = send(property.name)\n node = root.add_element(property.name.to_s)\n unless property.type == String\n node.attributes[\"type\"] = property.type.to_s.downcase\n end\n node << REXML::Text.new(value.to_s) unless value.nil?\n end\n\n # add methods\n (opts[:methods] || []).each do |meth|\n if self.respond_to?(meth)\n xml_name = meth.to_s.gsub(/[^a-z0-9_]/, '')\n node = root.add_element(xml_name)\n value = send(meth)\n node << REXML::Text.new(value.to_s, :raw => true) unless value.nil?\n end\n end\n doc\n end", "def parse(io)\n self.doc = Nokogiri::XML(io)\n end", "def initialize(xml)\n @xml = xml.to_s\n @id = xml.at('id').inner_html\n @updated = DateTime.parse(xml.at('updated').inner_html)\n @title = xml.at('title').inner_html\n @dimensions = xml.search('dxp:dimension').collect do |dimension|\n { dimension.attributes['name'].split(':').last.to_sym => dimension.attributes['value'].split(':', 1).last }\n end\n @metrics = xml.search('dxp:metric').collect do |metric|\n { metric.attributes['name'].split(':').last.to_sym => metric.attributes['value'].split(':', 1).last.to_i }\n end\n end", "def test_provides_access_to_command_name_passed_in_constructor\n Crd::Flex::Command.new 'mxmlc' do |c|\n assert_equal( 'mxmlc', c.command )\n end\n end", "def initialize_xml(xml, root_element)\n @xml = XMLElement.build_xml(xml, root_element)\n\n if OpenNebula.is_error?(@xml)\n @xml = nil\n else\n if NOKOGIRI\n if @xml.size == 0\n @xml = nil\n end\n else\n if @xml.name != root_element\n @xml = nil\n end\n end\n end\n @xml\n end", "def load_XML(file)\n begin\n xml_file = File.open(file)\n xml_obj = Document.new(xml_file)\n xml_file.close\n rescue => e\n puts \"ERROR: Unable to create XML object from file: #{file}\"\n puts e.message\n puts e.backtrace\n exit 1\n end\n return xml_obj\nend", "def initialize(o)\r\n @xml = o\r\n \r\n # map element names to methods, prolly not the best way to do this\r\n @xml.elements.each do |e|\r\n Mb_obj.class_eval(\"def #{e.name.to_s}() REXML::XPath.first(self.xml, \\\"#{e.name.to_s}).text\\\").text end\") \t \r\n end\r\n end", "def from_qbxml(xml, opts = {})\n hash = Qbxml::Hash.from_xml(xml, underscore: true, schema: @doc)\n hash = opts[:no_namespace] ? hash : namespace_qbxml_hash(hash)\n hash.extend(DeepFind)\n end", "def parse_xml(string) #:doc:\n Nokogiri::XML::Document.parse(string) do |opts|\n opts.options = 0\n opts.noblanks\n end\n end", "def xml_to_instance\r\n ATTRIBUTES_MAP.each do |name, hash| \r\n elem = @xml.root.elements[hash[\"element\"]]\r\n unless elem.nil?\r\n val = (hash.has_key?(\"attribute\") ? elem.attributes[hash[\"attribute\"]] : elem.text)\r\n val = self.send(hash[\"from_xml\"], val) if hash.has_key?(\"from_xml\")\r\n self.send(name+\"=\", val)\r\n end\r\n end\r\n self.status = :old\r\n\r\n @xml.root.elements.each(\"link\") do |link|\r\n @feed = link.attributes[\"href\"] if link.attributes[\"rel\"] == \"edit\"\r\n end\r\n end", "def initialize(*args)\n\t\t\t@elements = []\n\t\t\tload_xml(args[0]) if args[0].kind_of? REXML::Element\n\t\tend", "def initialize( xml_file, *options )\n @node_name = \"00000\"\n\t @show_text = true\n\t @show_attributes = true\n\n if options and options[0]\n options[0].each do |xKey, xValue|\n case xKey.to_s\n when \"text\"\n @show_text = xValue\n\t\t options[0].delete( xKey )\n when \"attrs\"\n @show_attributes = xValue\n\t\t options[0].delete( xKey )\n end\n end\n end\n\n @rexml_document = REXML::Document::new( File::new( xml_file ) )\n @graph = GraphViz::new( \"XML\", *options )\n parse_xml_node( @rexml_document.root() )\n end", "def create_new_xml_document( options = nil)\n p \"new xml doc created!\"\n \n blog_doc = <<-eos\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. -->\n<!-- It contains information about your blog's posts, comments, and categories. -->\n<!-- You may use this file to transfer that content from one site to another. -->\n<!-- This file is not intended to serve as a complete backup of your blog. -->\n\n<!-- To import this information into a WordPress blog follow these steps. -->\n<!-- 1. Log into that blog as an administrator. -->\n<!-- 2. Go to Tools: Import in the blog's admin panels (or Manage: Import in older versions of WordPress). -->\n<!-- 3. Choose \"WordPress\" from the list. -->\n<!-- 4. Upload this file using the form provided on that page. -->\n<!-- 5. You will first be asked to map the authors in this export file to users -->\n<!-- on the blog. For each author, you may choose to map to an -->\n<!-- existing user on the blog or to create a new user -->\n<!-- 6. WordPress will then import each of the posts, comments, and categories -->\n<!-- contained in this file into your blog -->\n\n<!-- generator=\"WordPress/MU\" created=\"2009-03-10 00:13\"-->\n<rss version=\"2.0\"\n\txmlns:excerpt=\"http://wordpress.org/export/1.0/excerpt/\"\n\txmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\n\txmlns:wfw=\"http://wellformedweb.org/CommentAPI/\"\n\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n\txmlns:wp=\"http://wordpress.org/export/1.0/\"\n>\n\n<channel>\n\t<title>xxx</title>\n\t<link>xxx</link>\n\t<description>xxx</description>\n\t<pubDate>xxx</pubDate>\n\t<generator>http://wordpress.org/?v=MU</generator>\n\t<language>en</language>\n\t<wp:wxr_version>1.0</wp:wxr_version>\n\t<wp:base_site_url>http://wordpress.com/</wp:base_site_url>\n\t<wp:base_blog_url>xxx</wp:base_blog_url>\n\t<wp:category><wp:category_nicename>uncategorized</wp:category_nicename><wp:category_parent></wp:category_parent><wp:cat_name><![CDATA[Uncategorized]]></wp:cat_name></wp:category>\n\t<image>\n\t\t<url>http://www.gravatar.com/blavatar/bc8a29036e9d9925e702dcf90996d0cd?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>\n\t\t<title>xxx</title>\n\t\t<link>xxx</link>\n\t</image>\n \n</channel>\n</rss>\n eos\n \n doc = Hpricot.XML(blog_doc)\n \n #change created date to be right-now\n #element at fixed-offset 30\n #<!-- generator=\"WordPress/MU\" created=\"2009-03-10 00:13\"-->\n doc.search(\"*\")[30].swap(\n \"<!-- generator=\\\"WordPress/MU\\\" created=\\\"#{Time.now.strftime(\"%Y-%m-%d %H:%M\")}\\\"-->\"\n )\n \n #replace default_title, default_link, the name of the blog and link to blog (wordpress), respectively\n doc.search(\"title\")[0].inner_html = @options[:default_title]\n doc.search(\"title\")[1].inner_html = @options[:default_title]\n doc.search(\"link\")[0].inner_html = @options[:default_link]\n doc.search(\"link\")[1].inner_html = @options[:default_link]\n\n #replace default_description, pub_date\n doc.search(\"description\").inner_html = @options[:default_description]\n doc.search(\"pubDate\").inner_html = @options[:pub_date]\n doc.search(\"wp:base_blog_url\").inner_html = @options[:base_blog_url]\n\n @doc = doc\n end", "def initialize(xml_elem)\n @name = xml_elem.attributes['name']\n @num_bins = xml_elem.attributes['num-bins'].to_i\n @range_min = xml_elem.attributes['min'].to_f\n @range_max = xml_elem.attributes['max'].to_f\n @title = xml_elem.attributes['title']\n end", "def parse_xml(filename)\n @parser = Parser.new :pregenerated => filename\n @parser.parse\n end", "def _from_xml(xml)\n return XmlSimple.xml_in(xml, {\n 'ForceArray'=>['accessGroup'],\n 'GroupTags'=>{\n 'services'=>'service',\n 'metros'=>'metro',\n 'networkIdentifiers'=>'ni'\n },\n 'KeyAttr'=>['id','name']\n })\n end", "def import_xml(xml)\n if xml.is_a?(String)\n xml.force_encoding(\"UTF-8\") if xml.respond_to? :force_encoding\n xml.scrub!\n doc = REXML::Document.new xml.gsub(/>[\\s\\t]*\\n*[\\s\\t]*</, \"><\").strip\n elsif xml.is_a?(REXML::Document)\n doc = xml\n else\n raise ArgumentError, \"Argument must be an REXML::Document or well-formed XML string\"\n end\n\n # Cut to the context object\n ctx = REXML::XPath.first(doc, \".//ctx:context-object\", {\"ctx\" => \"info:ofi/fmt:xml:xsd:ctx\"})\n\n ctx.attributes.each do |attr, val|\n @admin.each do |adm, vals|\n set_administration_key(adm, val) if vals[\"label\"] == attr\n end\n end\n ctx.to_a.each do |ent|\n if @@defined_entities.value?(ent.name)\n import_entity(ent)\n else\n import_custom_node(ent)\n end\n end\n end", "def document_from_io(io)\n REXML::Document.new(io)\n end", "def from_xml(xml)\n @xml = xml\n self.before_from_xml if defined?(before_from_xml)\n from_xml_via_map(@xml)\n end", "def parse\n _build_document\n _close_open_block_commands\n @document\n end", "def factory(element_xml)\n OpenNebula::VirtualMachine.new(element_xml,@client)\n end", "def factory(element_xml)\n OpenNebula::VirtualMachine.new(element_xml,@client)\n end", "def new_empty_doc\n Atom::XML::Document.new\n end", "def initialize(content)\n document = REXML::Document.new content\n node = REXML::XPath.first document, '//soapenv:Body'\n @parsed = SoapResponse.parse node\n end", "def xml_doc version = nil\n Nokogiri::XML::Document.new version\n end", "def test_run_xml_input\n T2Server::Run.create($uri, WKF_XML, $creds, $conn_params) do |run|\n run.input_port(\"xml\").value =\n \"<hello><yes>hello</yes><no>everybody</no><yes>world</yes></hello>\"\n run.input_port(\"xpath\").value = \"//yes\"\n run.start\n run.wait\n assert_equal(run.output_port(\"nodes\").value, [\"hello\", \"world\"])\n assert(run.delete)\n end\n end", "def deserialize(xml, options = {})\n build_resource(REXML::Document.new(xml).root)\n end", "def initialize(nokogiri_xml, client)\n @xml = nokogiri_xml.to_xml\n @client = client\n @attributes = Vebra.parse(nokogiri_xml)\n end", "def initialize(str)\n @doc = AbstractDoc.new(correct_input_for_legacy_interface(str))\n dup_associations_and_attributes\n map_associations\n map_attributes\n end", "def initialize tag, cmd, *args\n @tag = tag\n @cmd = cmd\n @args = args\n end", "def initialize(xml, fileName, pa, responseDir)\r\n @responseDir = responseDir\r\n @xml = REXML::Document.new(xml) \r\n @fileName = fileName\r\n @nps = []\r\n @seed = 0\r\n\r\n \tif pa == nil\r\n\t \t@parseAdapter = ParseAdapter.new\r\n\t else\r\n\t \t@parseAdapter = pa\r\n \tend\r\n end", "def to_xml()\r\n msg = REXML::Document.new\r\n msg << REXML::Element.new(\"#{@type.to_s}\")\r\n msg.root << REXML::Element.new(\"GROUP\").add_text(\"#{@group}\") if @group != nil\r\n msg.root << REXML::Element.new(\"ID\").add_text(\"#{@procID}\") if @procID != nil\r\n msg.root << REXML::Element.new(\"PATH\").add_text(\"#{@path}\") if @path != nil\r\n msg.root << REXML::Element.new(\"ARGSLINE\").add_text(\"#{@cmdLineArgs.join(\" \")}\") if @cmdLineArgs != nil\r\n # Build the <ENV> child element\r\n if [email protected]? \r\n line = \"\"\r\n @env.each { |k,v|\r\n line << \"#{k.to_s}=#{v.to_s} \" \r\n }\r\n msg.root << REXML::Element.new(\"ENV\").add_text(\"#{line}\")\r\n end\r\n # Build the <OML_CONFIG> child element\r\n if @omlConfig != nil\r\n el = REXML::Element.new(\"OML_CONFIG\")\r\n el.add_element(@omlConfig)\r\n msg.root << el\r\n end\r\n return msg\r\n end", "def test_build_and_parse_xml\n contact = create_test_contact\n\n # Generate the XML message\n contact_as_xml = contact.to_xml\n\n # Parse the XML message and retrieve the contact element\n contact_element = REXML::XPath.first(REXML::Document.new(contact_as_xml), \"/Contact\")\n\n # Build a new contact from the XML\n result_contact = XeroGateway::Contact.from_xml(contact_element)\n\n # Check the contact details\n assert_equal contact, result_contact\n end", "def command cmd, target=nil, value=nil\r\n @xml.tr do\r\n _tdata cmd\r\n _tdata target\r\n _tdata value\r\n end\r\n end", "def load_from_xml(xml_text)\n item = parse_xml(xml_text)\n if block_given? then self.create(item) { |i| yield(i) }\n else self.create(item)\n end\n end", "def convert(str, op)\n document = RDoc::Markup::Parser.parse str\n\n document.accept op\n end", "def xml_document\n xml = XML::Document.new\n xml.root = self.to_xml\n xml\n end", "def initialize(run, xml)\n super(run, xml)\n\n @value = nil\n @file = nil\n @remote_file = false\n end", "def from_xml(data, *args)\n xml = Nokogiri::XML::Node.from(data)\n\n create_from_xml(*args).tap do |inst|\n refs = representable_attrs.map {|attr| XML.binding_for_definition(attr) }\n \n refs.each do |ref|\n value = ref.value_in(xml)\n \n inst.send(ref.definition.setter, value)\n end\n end\n end", "def initialize(arg = '')\n @root, @raw =\n if arg.instance_of? self.class\n arg.parsed? ? [arg.root, nil] : [nil, arg.raw]\n elsif arg.is_a? Document\n # For any other RichText object we take the root node\n [arg.root, nil]\n elsif arg.is_a? Entry\n # Also accept an Entry which will be used as the\n # document root\n [arg.root, nil]\n else\n [nil, arg.to_s]\n end\n end", "def initialize( sender_id, conn_id, path, headers, body, raw=nil )\n\t\tsuper\n\t\tself.log.debug \"Parsing XML request body\"\n\t\t@reader = LibXML::XML::Reader.string( body )\n\tend", "def from_xml(xml)\n parsed_status = \"unknown\"\n\n if xml\n build_names = []\n xml.elements.each(\"feed/entry/title\") {|entry| build_names << entry.text}\n\n build_master = build_names.find {|build_name| build_name.include?(@build_name) }\n parsed_status = build_master.match(/\\(.+\\)/).to_s\n end\n\n case parsed_status\n when \"(stable)\"\n \"stable\"\n when \"(back to normal)\"\n \"stable\"\n when \"(?)\"\n \"building\"\n when \"(aborted)\"\n \"aborted\"\n when /broken/\n \"broken\"\n when \"unknown\"\n \"unknown\"\n else\n \"failed\"\n end\n\n end", "def initialize(xoxo)\n @parser = REXML::Parsers::PullParser.new(xoxo)\n\n @textstack = ['']\n @xostack = []\n @structs = []\n @tags = []\n end", "def test_assembles_only_command_name_in_to_cmd_method\n Crd::Flex::Command.new 'mxmlc' do |c|\n assert_equal( 'mxmlc', c.to_cmd )\n end\n end", "def initialize( sender_id, conn_id, path, headers, body, raw=nil )\n\t\tsuper\n\t\tself.log.debug \"Parsing XML request body\"\n\t\t@data = Nokogiri::XML( body )\n\tend", "def build_xml(node, doc = nil, xml_node=nil)\n if doc.nil?\n doc = Nokogiri::XML('<opt></opt>')\n xml_node = doc.root\n end\n if node.respond_to?(:each)\n node.drop(1).each do |child|\n if position_node?(child)\n pos = Nokogiri::XML::Node.new(\"pos\", doc)\n pos['line'] = child.first.to_s\n pos['column'] = child[1].to_s\n xml_node.add_child(pos)\n else\n if child.respond_to?(:first)\n if child.first.respond_to?(:first) and\n child.first.first == :assoc_new\n child.each do |c|\n n = Nokogiri::XML::Node.new(\n c.first.to_s.gsub(/[^a-z_]/, ''), doc)\n c.drop(1).each do |a|\n xml_node.add_child(build_xml(a, doc, n))\n end\n end\n else\n n = Nokogiri::XML::Node.new(\n child.first.to_s.gsub(/[^a-z_]/, ''), doc)\n xml_node.add_child(build_xml(child, doc, n))\n end\n else\n xml_node['value'] = child.to_s unless child.nil?\n end\n end\n end\n end\n xml_node\n end", "def build_xml(node, doc = nil, xml_node=nil)\n if doc.nil?\n doc = Nokogiri::XML('<opt></opt>')\n xml_node = doc.root\n end\n if node.respond_to?(:each)\n node.drop(1).each do |child|\n if position_node?(child)\n pos = Nokogiri::XML::Node.new(\"pos\", doc)\n pos['line'] = child.first.to_s\n pos['column'] = child[1].to_s\n xml_node.add_child(pos)\n else\n if child.respond_to?(:first)\n n = Nokogiri::XML::Node.new(child.first.to_s.gsub(/[^a-z_]/, ''), doc)\n xml_node.add_child(build_xml(child, doc, n))\n else\n xml_node['value'] = child.to_s unless child.nil?\n end\n end\n end\n end\n xml_node\n end", "def build_xml(node, doc = nil, xml_node=nil)\n if doc.nil?\n doc = Nokogiri::XML('<opt></opt>')\n xml_node = doc.root\n end\n if node.respond_to?(:each)\n node.drop(1).each do |child|\n if position_node?(child)\n pos = Nokogiri::XML::Node.new(\"pos\", doc)\n pos['line'] = child.first.to_s\n pos['column'] = child[1].to_s\n xml_node.add_child(pos)\n else\n if child.respond_to?(:first)\n n = Nokogiri::XML::Node.new(child.first.to_s.gsub(/[^a-z_]/, ''), doc)\n xml_node.add_child(build_xml(child, doc, n))\n else\n xml_node['value'] = child.to_s unless child.nil?\n end\n end\n end\n end\n xml_node\n end", "def parse_xml(doc)\n data = []\n doc.elements.each('log/logentry') do |le|\n e = Entry.new\n e.author = le.elements[\"author\"].text\n e.time = DateTime.parse(le.elements[\"date\"].text).to_local_time\n e.paths = []\n le.elements.each('paths/path') do |pa|\n e.paths.push [pa.attributes[\"action\"], pa.text]\n end\t\n e.paths.sort! do |a, b|\n a[1] <=> b[1]\n end\n e.msg = le.elements[\"msg\"].text\n e.msg = htmlize(e.msg, @user_config[:msg_gsubs]) if e.msg\n e.rev = le.attributes[\"revision\"]\n data.push e\n end\n data\n end", "def initialize(file_content)\n # Open XML file\n self.fichero = file_content\n # Initialize XML Document\n @doc = Document.new self.fichero\n # Initialize attribute default values\n self.lista_devoluciones = []\n end", "def build\n ParsedInput.new(command: @config.name,\n actions: @actions,\n options: grouped_options,\n arguments: @arguments)\n end", "def initialize(doc); end", "def xml\n @xml ||= Nokogiri::XML.parse body\n end" ]
[ "0.6695541", "0.60271335", "0.60199404", "0.5854265", "0.58124804", "0.56513184", "0.5588628", "0.5556868", "0.55333805", "0.5444194", "0.5420735", "0.5406773", "0.53591406", "0.5357438", "0.53468853", "0.5336927", "0.5336927", "0.5329276", "0.53289604", "0.5321997", "0.52925146", "0.5273255", "0.52259165", "0.5201129", "0.5199134", "0.5196744", "0.51909673", "0.5184394", "0.5182222", "0.51596296", "0.51398176", "0.5135891", "0.51312786", "0.51290756", "0.51290756", "0.51290756", "0.5119471", "0.51001155", "0.5048939", "0.5042434", "0.50318676", "0.50059086", "0.500581", "0.4996411", "0.49806717", "0.49684358", "0.49453112", "0.49433964", "0.4934742", "0.49062622", "0.49024227", "0.4895471", "0.4894301", "0.4883785", "0.48803398", "0.4879376", "0.48630038", "0.48611313", "0.48514208", "0.48461217", "0.4846062", "0.48448867", "0.4843152", "0.48219094", "0.48215455", "0.48131284", "0.48057207", "0.47946474", "0.47946474", "0.4792684", "0.47878936", "0.47878826", "0.4782686", "0.47775432", "0.47608876", "0.47551215", "0.47527334", "0.4744322", "0.47418487", "0.47383654", "0.47370166", "0.4736682", "0.47359475", "0.47359103", "0.47300476", "0.47226655", "0.47142088", "0.47069174", "0.4701713", "0.46977404", "0.46884847", "0.46880624", "0.468508", "0.46836016", "0.46836016", "0.4668067", "0.466476", "0.46614462", "0.46608335", "0.4652956" ]
0.8126857
0
Return a String representation of the XML tree describing this Command Object. [Return] a String
def to_s return serialize.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n\t\treturn self.stringify_nodes( @output )\n\tend", "def to_s\n return command\n end", "def to_s\n\t\t\"<Node:#{@e}>\"\n\tend", "def to_s\n msg = ''\n msg += \"Command: #{name}\\n\"\n options.each { |o| msg += \" \" + o.inspect + \"\\n\"}\n msg += \"\\n\"\n commands.each { |k, v| msg += commands[k].inspect }\n msg\n end", "def to_s\n\t\t@node_string\n\tend", "def to_s\n object_identifier = \"#<#{self.class.to_s}:0x#{'%x' % (self.object_id << 1)}\\n\"\n close_object = \">\\n\"\n \n case self\n when RubyBBCode::BBTree\n object_identifier + \"Children: #{count_child_nodes}\\n\" + self.to_v + close_object\n when RubyBBCode::TagNode # when inspecting TagNodes, it's better not to show the tree display\n if self[:is_tag]\n object_identifier + \"Tag: #{self[:tag].to_s}, Children: #{count_child_nodes}\\n\" + close_object\n else\n object_identifier + '\"' + self[:text].to_s + \"\\\"\\n\" + close_object\n end\n end\n end", "def to_s\n root.to_tree_s\n end", "def to_s\n @node.to_s\n end", "def to_s\n NodePrinter.new(@root).to_s\n end", "def to_s\n return self.xml\n end", "def to_s\n @node.content\n end", "def to_s()\n r = \"\"\n t = \"\"\n\n # the parent node\n case @type\n when Type::NONE then t = ''\n when Type::TEXT then t = 't'\n when Type::NUMBER then t = 'n'\n when Type::OPERATOR then t = 'o'\n end\n r << t << '(' << \"#{@value}\"\n\n # childs nodes\n \n if !empty()\n size = @childs.size\n for i in 0..size\n r << @childs[i].to_s()\n if i < size-1\n r << ' '\n end\n end\n end\n\n r << \")\"\n end", "def to_s\n #N Without this we won't see the command as a command and a list of arguments\n return command.join(\" \")\n end", "def inspect\n if @name and [email protected]? then\n str = \"(Node:#{@name.inspect}\"\n else\n str = sprintf('(Node:%x', (self.__id__ << 1) & 0xffffffff)\n end\n if defined?(@bootstrap) and @bootstrap then\n str += \" bootstrap=#{@bootstrap.inspect}\"\n end\n str += \")\"\n str\n end", "def to_s\n \"#{@dir}> #{@cmd}\"\n end", "def to_s\n @xml\n end", "def nodes_to_s\n string = \"\"\n @nodes.each do |name, node|\n string +=\"#{name}:\\n\\t(#{node.name})\\n\"\n end\n string\n end", "def to_str\n str = \"\"\n REXML::Formatters::Pretty.new(1).write(@xml,str)\n \n return str \n end", "def to_s\n #\"\\#<#{self.class}-#{@name} - #{@top_dir}>\"\n \"\\#<#{self.class}-#{@name}>\"\n end", "def to_s\n stringified = \"#{@name}[\"\n @children.each { |kid| stringified += \"#{kid[:link]} -> #{kid[:residue]}\" }\n stringified += \"]\\n\" \n end", "def to_s\n \"id: #{self.object_id} start_node: #{start_node.id} end_node: #{end_node.id} type:#{@type}\"\n end", "def to_s\n @root.to_s\n end", "def to_xml\n Builder.new(self).to_s\n end", "def to_str\n str = \"\"\n REXML::Formatters::Pretty.new(1).write(@xml,str)\n\n return str \n end", "def to_s\n\t\tparts = [ self.oid ]\n\n\t\tparts << \"NAME %s\" % Treequel::Schema.qdescrs( self.names ) unless self.names.empty?\n\n\t\tparts << \"DESC '%s'\" % [ self.desc ] if self.desc\n\t\tparts << \"OBSOLETE\" if self.obsolete?\n\t\tparts << \"APPLIES %s\" % [ Treequel::Schema.oids(self.attr_oids) ]\n\t\tparts << self.extensions.strip unless self.extensions.empty?\n\n\t\treturn \"( %s )\" % [ parts.join(' ') ]\n\tend", "def basic_output()\n temp_string = String.new()\n\n if (@utype != \"\")\n temp_string = temp_string + \"#{@utype} = \"\n end\n temp_string = temp_string + @commandName\n temp_string = temp_string + \"\\n\"\n @keywordPairs.each {|array| temp_string = temp_string + \"\\t#{array[0]} = #{array[1]}\\n\" }\n temp_string = temp_string + \"..\\n\"\n\n temp_string = temp_string + \"$Parents\\n\"\n @parents.each do |array|\n temp_string = temp_string + \"$\\t#{array.utype} = #{array.commandName}\\n\"\n end\n temp_string = temp_string + \"..\\n\"\n\n temp_string = temp_string + \"$Children\\n\"\n @children.each {|array| temp_string = temp_string + \"$\\t#{array.utype} = #{array.commandName}\\n\" }\n temp_string = temp_string + \"..\\n\"\n\n end", "def to_s(options={})\n if self.is_leaf?\n location = self\n if !options[:without_edits]\n while !location.is_root? && location.parent.class < Natural::Alternative do\n location = location.parent\n end\n end\n location.text\n else\n self.children.inject('') {|result, item| (result += item.to_s + ' ')}.strip\n end\n end", "def inspect\n return self.class.to_s unless has_children\n \"(#{self.class} #{children.map {|c| c.inspect}.join(' ')})\"\n end", "def to_string_tree\n if ((@children).nil? || (@children.size).equal?(0))\n return self.to_s\n end\n buf = StringBuffer.new\n if (!is_nil)\n buf.append(\"(\")\n buf.append(self.to_s)\n buf.append(Character.new(?\\s.ord))\n end\n i = 0\n while !(@children).nil? && i < @children.size\n t = @children.get(i)\n if (i > 0)\n buf.append(Character.new(?\\s.ord))\n end\n buf.append(t.to_string_tree)\n i += 1\n end\n if (!is_nil)\n buf.append(\")\")\n end\n return buf.to_s\n end", "def to_s\n serialize_roots.children.to_s\n end", "def to_s\n \"#<OSM::Node id=\\\"#{@id}\\\" user=\\\"#{@user}\\\" timestamp=\\\"#{@timestamp}\\\" lon=\\\"#{@lon}\\\" lat=\\\"#{@lat}\\\">\"\n end", "def to_s\n \"Node: character=#{@character}\"\n end", "def to_s\n children.to_s\n end", "def to_s\n str = ''\n str << \"Command: #{@feature} #{@name}\\n\"\n @hash.each { |key, value| str << \" #{key}: #{value}\\n\" }\n str\n end", "def to_s\n 'Abstract Command'\n end", "def to_s\n self.inspect\n end", "def to_s\n \"Source Node children: #{@children.length}\"\n end", "def cmd_tree\n print_tree(Editor, 0)\n end", "def to_xml\n return to_s\n end", "def to_xml\n return to_s\n end", "def to_s\n %(<#{ @name }#{attributes}>)\n end", "def inspect\n return to_s if success?.nil?\n (success? ? \"success : \" : \"fail : \") + @command\n end", "def to_s\n \"<#{@name}\" + @attrs.sort.map{|k,v| \" #{k}='#{v.xml_attr_escape}'\"}.join +\n if @contents.size == 0\n \"/>\"\n else\n \">\" + @contents.map{|x| if x.is_a? String then x.xml_escape else x.to_s end}.join + \"</#{name}>\"\n end\n end", "def to_s(depth = 0)\n\t\tind = \" \" * depth\n\t\tind + \"[#{nonTerminal}/#{decision}\" +\n\t\tif(children.size == 0)\n\t\t\t\"]\\n\"\n\t\telse\n\t\t\t\"\\n\" + children.map { |c| if(c.is_a?(String)) then ind + \" \" + c.inspect + \"\\n\" else c.to_s(depth+1) end }.join(\"\") + ind + \"]\\n\"\n\t\tend\n\tend", "def to_s(depth = 0)\n\t\tind = \" \" * depth\n\t\tind + \"[#{nonTerminal}/#{decision}\" +\n\t\tif(children.size == 0)\n\t\t\t\"]\\n\"\n\t\telse\n\t\t\t\"\\n\" + children.map { |c| if(c.is_a?(String)) then ind + \" \" + c.inspect + \"\\n\" else c.to_s(depth+1) end }.join(\"\") + ind + \"]\\n\"\n\t\tend\n\tend", "def to_text\n self_and_descendants.map do |node|\n if block_given?\n inspect = yield(node)\n else\n inspect = node.class.inspect\n end\n \"#{'*'*(node.level+1)} #{inspect} (#{node.parent_id.inspect}, #{node.left}, #{node.right})\"\n end.join(\"\\n\")\n end", "def to_xml()\r\n msg = REXML::Document.new\r\n msg << REXML::Element.new(\"#{@type.to_s}\")\r\n msg.root << REXML::Element.new(\"GROUP\").add_text(\"#{@group}\") if @group != nil\r\n msg.root << REXML::Element.new(\"ID\").add_text(\"#{@procID}\") if @procID != nil\r\n msg.root << REXML::Element.new(\"PATH\").add_text(\"#{@path}\") if @path != nil\r\n msg.root << REXML::Element.new(\"ARGSLINE\").add_text(\"#{@cmdLineArgs.join(\" \")}\") if @cmdLineArgs != nil\r\n # Build the <ENV> child element\r\n if [email protected]? \r\n line = \"\"\r\n @env.each { |k,v|\r\n line << \"#{k.to_s}=#{v.to_s} \" \r\n }\r\n msg.root << REXML::Element.new(\"ENV\").add_text(\"#{line}\")\r\n end\r\n # Build the <OML_CONFIG> child element\r\n if @omlConfig != nil\r\n el = REXML::Element.new(\"OML_CONFIG\")\r\n el.add_element(@omlConfig)\r\n msg.root << el\r\n end\r\n return msg\r\n end", "def to_s\n \"#<#{self.class.name}:#{object_id} #{info}>\"\n end", "def to_s\n inspect\n end", "def to_s\n @root.to_s\n end", "def to_s\n return \"Empty 2-3 tree\" unless @root\n \"2-3 Tree\\nroot: \" + @root.to_s(0)\n end", "def output\n (value = parent.get(@name)).nil? ? @raw_command : value.to_s\n end", "def to_s\n puts @name\n puts @vcenter.to_yaml\n puts @components.to_yaml\n puts @nodenameconvention.to_yaml\n end", "def inspect\n to_s\n end", "def inspect\n to_s\n end", "def to_s\n \"#<#{ self.class.name } name=#{ name.inspect } path=#{ path.to_s }>\"\n end", "def inspect\n to_s\n end", "def to_s\n Alf::Renderer.text(self).execute(\"\")\n end", "def inspect\n to_s\n end", "def inspect\n to_s\n end", "def inspect\n to_s\n end", "def inspect\n to_s\n end", "def inspect\n to_s\n end", "def inspect\n to_s\n end", "def inspect\n to_s\n end", "def to_s\n out = ''\n self.metadata.each{|k,v| out << \"#{k}: #{v}\\n\"}\n out << \"--------------------\\n\"\n self.steps.each{|s| out << s.to_s }\n out\n end", "def to_s\n toString()\n end", "def inspect\n to_s.inspect\n end", "def to_s\n if ((@p).equal?(-1))\n fill_buffer\n end\n buf = StringBuffer.new\n i = 0\n while i < @nodes.size\n t = @nodes.get(i)\n buf.append(\" \")\n buf.append(@adaptor.get_type(t))\n i += 1\n end\n return buf.to_s\n end", "def to_s\n\t\tstr = \"\\n<\" + @type\n\t\[email protected]{ |key,value|\n\t\t\tstr += \" \" + key.to_s + \" = \" + value.to_s\n\t\t}\n\t\tif @type == 'text'\n\t\t\tstr += \"> \" + @content[0] + \" </\" + @type + \">\"\n\t\telse\n\t\t\tstr += \"> \"\n\t\t\[email protected] { |c|\n\t\t\t\tstr += c.to_s\n\t\t\t}\n\t\t\tstr += \"\\n</\" + @type + \">\"\n\t\tend\n\t\tstr\n\tend", "def to_xml\n return self.to_s\n end", "def to_s\r\n \"<#{self.class.name} id: #{self[:id]}, description: #{self[:description]}, definition: #{self[:definition]}, has_inverse: #{self[:has_inverse]} accuracy: #{self[:accuracy]}\"\r\n end", "def inspect\n obj_id = \"%x\" % (object_id << 1)\n \"#<#{self.class}:0x#{obj_id} @jid=\\\"#{jid}\\\" @node=#{node.inspect}>\"\n end", "def inspect\n attributes = [\n \"name=#{name.inspect}\",\n \"state=#{state.inspect}\",\n \"description=#{description.inspect}\",\n \"adapter=#{adapter.name.inspect}\",\n ]\n \"#<#{self.class.name}:#{object_id} #{attributes.join(', ')}>\"\n end", "def inspect\r\n line = \"<#{@key.gsub('_', '-')}>\"\r\n if (is_leaf?)\r\n line << @value\r\n else\r\n @children.each do |child|\r\n line << child.inspect\r\n end\r\n end\r\n line << \"</#{@key.gsub('_', '-')}>\"\r\n end", "def to_s\n return @to_s if instance_variable_defined? :@to_s\n @to_s = \"<#{configuration_name}\".tap do |string|\n definitions.each do |name, definition|\n string << \" #{name}=#{definition.get(self).inspect}\"\n end\n string << '>'\n end\n end", "def to_s\n @nodeSelector\n end", "def to_s\n ret = build_link\n ret << tree.to_s if tree\n\n ret\n end", "def inspect\n str = +\"#<#{self.class.name}:0x#{object_id}\"\n str << \" id=\\\"#{@id}\\\"\" if @id\n str << '>'\n end", "def to_str\n dir_syntax = (dir == :ahead) ? '' : '<'\n kind_syntax = (kind == :positive) ? '=' : '!'\n \"(?#{dir_syntax}#{kind_syntax}#{child.to_str})\"\n end", "def to_s\n @string\n end", "def to_s\n @string\n end", "def to_s\n @string\n end", "def to_s\n @string\n end", "def to_s\n Utils::Escape::SafeString.new(@nodes.map(&:to_s).join(NEWLINE))\n end", "def inspect\n \"#<#{self.class} options: #{options.inspect}, run_list: '#{node.run_list.to_s}'>\"\n end", "def to_s\n \"#{@loc}: #{@children}\"\n end", "def to_s\n toString\n end", "def inspect\n self.to_s\n end", "def inspect\n self.to_s\n end", "def to_s\n css = \"#{@name} {\\n\"\n @properties.each_pair { |k, v| css += \" #{k}: #{v};\\n\" }\n css += \"}\\n\\n\"\n @children.each { |c| css += c.to_s }\n css\n end", "def to_s\n result = \"[ \"\n @tree.each do | pair |\n result += \"(\"+ pair.key.to_s + \",\" + pair.value.to_s + \") \"\n end\n result += \"]\"\n return result\n end", "def to_s\n self\n end", "def serialize\n lf = \"\\n\"\n (@cmds.join lf) + lf\n end", "def string\n children[0]\n end", "def string\n children[0]\n end", "def string\n children[0]\n end", "def inspect\n return 'nil' if @model.nil?\n\n \"#<#{self.class.name}:#{@model.getName}>\"\n end", "def to_s\r\n dump\r\n end", "def to_xml\n \n text = \"<node id=\\\"#{self.id}\\\" label=\\\"#{self.label}\\\">\\n\"\n \n unless self.attributes.nil?\n text << \"\\t<attvalues>\\n\"\n self.attributes.each do |key, value|\n text << \"\\t\\t<attvalue for=\\\"#{key}\\\" value=\\\"#{value}\\\"></attvalue>\\n\"\n end\n text << \"\\t</attvalues>\\n\"\n end\n \n unless self.viz_size.nil?\n text << \"\\t<viz:size value=\\\"#{self.viz_size}\\\"/>\\n\"\n end\n \n unless self.viz_color.nil?\n text << \"\\t<viz:color b=\\\"#{self.viz_color[:b]}\\\" g=\\\"#{self.viz_color[:g]}\\\" r=\\\"#{self.viz_color[:r]}\\\"/>\\n\"\n end\n \n unless self.viz_position.nil?\n text << \"\\t<viz:position x=\\\"#{self.viz_position[:x]}\\\" y=\\\"#{self.viz_position[:z]}\\\"/>\\n\"\n end\n \n text << \"</node>\\n\"\n text \n end", "def inspect\n return 'nil' if @obj.nil?\n\n \"#<#{self.class.name}:#{@obj.getName}>\"\n end" ]
[ "0.7047565", "0.7036944", "0.7012967", "0.70049274", "0.6947582", "0.691891", "0.68938714", "0.685215", "0.67929476", "0.67617565", "0.66980183", "0.66948986", "0.6688535", "0.66788656", "0.66088593", "0.65903175", "0.6566926", "0.65399456", "0.65243316", "0.6519443", "0.6516392", "0.6508744", "0.6508553", "0.6497153", "0.64883417", "0.6472892", "0.64674735", "0.6463527", "0.64580667", "0.645235", "0.64456713", "0.6436532", "0.64228576", "0.6421397", "0.6418649", "0.6400194", "0.6381034", "0.6321999", "0.6303333", "0.6303333", "0.6297029", "0.6287067", "0.6282205", "0.62620133", "0.62620133", "0.6261261", "0.6236921", "0.62329656", "0.6224755", "0.62183475", "0.62131697", "0.620883", "0.61918133", "0.61872506", "0.61872506", "0.61848456", "0.61805063", "0.6178385", "0.6177053", "0.6177053", "0.6177053", "0.6177053", "0.6177053", "0.6177053", "0.6177053", "0.6163091", "0.6152977", "0.61451507", "0.6140885", "0.61369944", "0.61350656", "0.6134912", "0.61306745", "0.6129943", "0.6125824", "0.6118793", "0.61161554", "0.61136955", "0.6107893", "0.6101553", "0.61014056", "0.61014056", "0.61014056", "0.61014056", "0.61009616", "0.6099727", "0.6098771", "0.6093195", "0.608874", "0.608874", "0.60757047", "0.6074352", "0.6069183", "0.6063305", "0.60605925", "0.60605925", "0.60605925", "0.60602343", "0.6051843", "0.60394084", "0.60376674" ]
0.0
-1
check if user is the same as current_user
def is_current_user(user) if user == current_user return true else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_if_current_user\r\n User.current_user && User.current_user != self\r\n end", "def current_user?(user)\r\n user == current_user\r\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def is_current_user(user)\n if current_user\n current_user.id == user.id\n else\n false\n end\n end", "def correct_user(user)\n user == current_user\n end", "def current_user?(user)\n \t\tuser == current_user\n \tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n user && user == current_user\n end", "def current_user?(user)\n \t\tuser == current_user\n \tend", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n \tuser == current_user\n \tend", "def current_user?(user)\n \tuser == current_user\n \tend", "def current_user?(user)\n current_user == user\n end", "def current_user?(user)\n current_user == user\n end", "def current_user?(user)\n current_user == user\n end", "def current_user?(user)\n current_user == user\n end", "def current_user?(user)\n current_user == user\n end", "def current_user?(user)\n current_user == user\n end", "def current_user?(user)\n current_user == user\n end", "def current_user?(user)\n current_user == user\n end", "def current_user?(user)\n\t\tcurrent_user == user\n\tend", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end" ]
[ "0.8396463", "0.8244885", "0.82260275", "0.82260275", "0.82260275", "0.82260275", "0.82260275", "0.82260275", "0.82260275", "0.8221191", "0.8191692", "0.8173409", "0.81723726", "0.8170972", "0.8170972", "0.8170972", "0.8170972", "0.8170972", "0.8170972", "0.8170972", "0.8170972", "0.8170972", "0.8170972", "0.81701636", "0.816979", "0.8163198", "0.8153613", "0.8153613", "0.8152089", "0.8152089", "0.8152089", "0.8152089", "0.8152089", "0.8152089", "0.8152089", "0.8152089", "0.8149024", "0.8110018", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001", "0.8110001" ]
0.0
-1
get profile foto url
def get_profile_photo_url(photo) if photo != nil return photo.image.url(:thumb) else return 'user.png' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profile_pic_url\n result_hash['pic']\n end", "def get_image_url( account_profile ) \n account_profile['profile_image_url']\n end", "def profile_pic_url\n json[\"entry_data\"][\"ProfilePage\"].first[\"graphql\"][\"user\"][\"profile_pic_url\"]\n end", "def image_url\n url_for(object.profile_pic)\n end", "def profile_url\n if self.profile and self.profile != \"\"\n return self.profile\n end\n return \"/blank.png\"\n end", "def profile_photo\n photos = self.profile_photos\n photos.empty? ? 'http://ragatzi.s3.amazonaws.com/uploads/profile_default_1.png' : photos.last.photo.url\n end", "def profile_url\n @data[:profile_url]\n end", "def avatar_url\n if !self.fb_id.blank?\n return 'https://graph.facebook.com/%s/picture?width=90&height=90' % self.fb_id\n elsif !self.gpp_id.blank?\n return 'http://profiles.google.com/s2/photos/profile/%s?sz=90' % self.gpp_id\n else\n return ''\n end\n end", "def profile_photo_url(version)\n if self.photos.profile_photo.blank? \n \"#{version.to_s}_avtar.jpg\"\n else \n self.photos.profile_photo.first.name_url(version)\n end \n end", "def get_profile_picture_url\n\t\tidentity = self.identities.find_by_provider_id(ApplicationController.fb_app[:id])\n\t\treturn ApplicationController.fb_app[:graph][:query_root_url] + identity.uid + \"/\" + ApplicationController.fb_app[:graph][:query_mypic_suffix]\t\t\n\tend", "def profile_url\n @json['profile']['url'] rescue nil\n end", "def profile_url\r\n infoxml = get_info\r\n return infoxml.at('profileurl').inner_text\r\n end", "def facebookProfilePicURL\n # https://www.facebook.com/user_name\n if facebook_url\n return \"https://graph.facebook.com/[PROFILE_ID]/picture\"\n else\n None\n end\n end", "def profile_image_url(size=:normal)\n insecure_url(profile_image_url_https(size)) if profile_image_url?\n end", "def twitter_profile_image\n @profile_image ||= begin\n require 'open-uri'\n require 'json'\n buffer = open(\"http://twitter.com/users/show/#{self.twitter_screen_name}.json\").read\n result = JSON.parse(buffer)\n result['profile_image_url']\n end\n end", "def profile_picture_url\n hash = Digest::MD5.hexdigest(email)\n \"https://www.gravatar.com/avatar/#{hash}?d=mm\"\n end", "def avatar_url\n avatar_uri(object)\n end", "def api_profile_picture_url\n return nil unless (temp_api_profile_picture_url = read_attribute(:api_profile_picture_url))\n # logger.debug2 \"temp_api_profile_picture_url = #{temp_api_profile_picture_url}\"\n encrypt_remove_pre_and_postfix(temp_api_profile_picture_url, 'api_profile_picture_url', 40)\n end", "def api_profile_picture_url\n return nil unless (temp_api_profile_picture_url = read_attribute(:api_profile_picture_url))\n # logger.debug2 \"temp_api_profile_picture_url = #{temp_api_profile_picture_url}\"\n encrypt_remove_pre_and_postfix(temp_api_profile_picture_url, 'api_profile_picture_url', 40)\n end", "def profile_url(size: 'w300')\n if profile_path.present?\n \"#{h.configuration.base_url}#{size}#{object[\"profile_path\"]}\"\n else\n \"http://dummyimage.com/300x450/d9d9d9/000000.png&text=N/A\"\n end\n end", "def image_path\n uri_path = URI(profile_image_url).path\n extension = File.extname(uri_path)\n \"#{@base_path}/#{screen_name}#{extension}\"\n end", "def profile_picture\n profile_picture_file_name\n end", "def profile_url\n nil\n end", "def avatar_url\r\n return @user.avatar_url\r\n end", "def user_avatar_url\n @raw['user']['avatar_url']\n end", "def get_pic_url\n\t if !self.pic_url\n\t\t twit_u = User.get_twitter_user_from_name(self.screen_name)\n\t\t\tputs twit_u\n\t\t\tself.pic_url = twit_u[\"profile_image_url\"]\n\t\t\tself.save!\n\t\tend\n\tend", "def profile_url\n @json['user']['links']['self']\n end", "def avatar_url\n \"http://robohash.org/#{email}?gravatar=yes\"\n end", "def get_profile_url_linkedin\n profile_url = self[:info][:urls][:public_profile] if self[:info] and self[:info][:urls]\n profile_url.gsub!(/^http:/, 'https:') if profile_url # protect cookies\n profile_url\n end", "def get_image_profile_pic\n last_pic = images.where(\"kind = ?\", \"profile_pic\").last\n\n if last_pic.nil?\n return \"/assets/octacat-resized.png\"\n else\n last_pic.url\n end\n end", "def avatar_url\n @data['avatarUrl']\n end", "def avatar_url\n @attributes[:avatar_url]\n end", "def avatar_url\n @attributes[:avatar_url]\n end", "def avatar_url(type = :small)\n \"#{authentications.first.avatar_url}?type=#{type}\"\n end", "def avatar_url(style = :small)\n if avatar_file_name\n avatar.url(style)\n else\n url = avatar.url(style)\n providers.each do |e|\n next unless e.image_url\n\n url = e.image_url\n end\n url\n end\n end", "def direct_avatar(profile_url, http)\n resp = http.head('/pavatar.png')\n profile_url + (profile_url =~ /\\/$/ ? '' : '/') + 'pavatar.png' if resp.kind_of?(Net::HTTPSuccess)\n end", "def profile_picture\n if facebook_authentication && facebook_authentication.profile_picture\n return facebook_authentication.profile_picture\n end\n return '/images/unknown_user.png'\n end", "def profile_urls\n Enceladus::Configuration::Image.instance.url_for(\"profile\", profile_path)\n end", "def avatar_url\n root = Rails.application.routes.url_helpers.url_for(:root)\n uri = URI(root)\n uri.path = avatar_path\n uri.to_s\n end", "def avatar_url (size)\n if avatar.present?\n return avatar.url(size)\n # elsif provider == \"facebook\" and external_uid\n # return \"https://graph.facebook.com/#{external_uid}/picture\"\n else\n return \"http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.downcase)}\"\n end\n end", "def photo_url\r\n infoxml = get_info\r\n return infoxml.at('photosurl').inner_text\r\n end", "def avatar_url\n\t\t\"http://zombitar.com/#{id}.jpg\"\n\tend", "def profile_url\n \"#{Steam::API::COMMUNITY_URL}/profiles/#{steam_id}\"\n end", "def avatar_url\n self.avatar.attachment.nil? ? '' :\n \"#{Rails.configuration.api_url}#{Rails.application.routes.url_helpers.rails_blob_path(self.avatar, only_path: true)}\"\n end", "def set_profile_picture_url(user)\n case user.provider\n when 'facebook'\n x = open(\"http://graph.facebook.com/v2.6/#{user.uid}/picture?redirect=false\", &:read)\n user.profile_pic = eval(x)[:data][:url]\n else # 'twitter', 'google', 'linkedin'\n user.profile_pic = open(user.image_url)\n end\n user.profile_pic.url\n end", "def getPicturePath\n\t\t#return User.find(self.user_id)\n @profile = Profile.find(:first, :conditions => {:user_id => self.user_id})\n if @profile.avatar != '' and @profile.avatar!=nil\n return @profile.avatar\n else\n return @profile.picture_path\n end\n\t\t#return Profile.find(:first, :conditions => {:user_id => self.user_id}).picture_path\n\tend", "def profile_picture\n\t\tFbGraph::User.me(self.oauth_token).fetch.picture(width: 150, height: 200)\n\tend", "def profile_img(uid, type=\"normal\")\n \"http://graph.facebook.com/#{uid}/picture?type=#{type}\"\n end", "def avatar_url\n self.avatar.attachment.nil? ? '' :\n \"#{Rails.configuration.api_url}#{Rails.application.routes.url_helpers.rails_blob_path(self.avatar, only_path: true)}\"\n end", "def picture_url\n if avatar\n image_path(\"speakers/#{avatar}\")\n else\n image_path(\"default-avatar.png\")\n end\n end", "def url\n URI.join(request.url, @picture.image.url)\n end", "def photo_url\n gravatar_id = Digest::MD5.hexdigest(email.downcase)\n \"https://gravatar.com/avatar/#{gravatar_id}.png\"\n end", "def picture\n\t\tbegin\n\t\t\tcase provider\n\t\t\twhen \"facebook\"\n\t\t\t\tresponse = get(\"/me/picture?type=large&redirect=false\")\n\t\t\t\treturn response['data']['url']\n\t\t\t\t\n\t\t\twhen \"twitter\"\n\t\t\t\tresponse = get(\"/1.1/users/show.json?user_id=#{uid}\")\n\t\t\t\treturn response['profile_image_url_https']\n\t\t\t\t\n\t\t\twhen \"google_oauth2\"\n\t\t\t\tresponse = get(\"/oauth2/v1/userinfo\")\n\t\t\t\treturn response['picture'] if response['picture']\n\t\t\t\t\n\t\t\twhen \"myspace\"\n\t\t\t\tresponse = get(\"/v1.0/people/@me\")\n\t\t\t\treturn response['thumbnailUrl'] if response['thumbnailUrl']\n\t\t\t\t\n\t\t\twhen \"vimeo\"\n\t\t\t\tresponse = get(\"/api/v2/#{uid}/info.json\")\n\t\t\t\treturn response['portrait_medium']\n\t\t\t\t\n\t\t\twhen \"yahoo\"\n\t\t\t\tresponse = get(\"/v1/user/#{uid}/profile/tinyusercard\")\n\t\t\t\treturn response['profile']['image']['imageUrl']\n\t\t\t\t\n\t\t\twhen \"vkontakte\"\n\t\t\t\tresponse = get(\"api.php?method=getProfiles?uids=#{uid}&fields=photo_medium\")\n\t\t\t\treturn response['Response'][0]['Photo']\n\t\t\t\t\n\t\t\twhen \"lastfm\"\n\t\t\t\tresponse = get(\"/2.0/?method=user.getinfo&format=json&user=#{uid}&api_key=#{creds['id']}\")\n\t\t\t\treturn response['user']['image'][1]['#text']\n\t\t\t\t\n\t\t\twhen \"linkedin\"\n\t\t\t\tresponse = get(\"/v1/people/~\")\n\t\t\t\tlogger.debug response.inspect\n\t\t\t\t#return ???\n\t\t\t\t\n\t\t\twhen \"windowslive\"\n\t\t\t\tresponse = get(\"/v5.0/me/picture?access_token=#{access_token}\")\n\t\t\t\treturn response['person']['picture_url']\n\t\t\t\t\n\t\t\tend\n\t\trescue StandardError => e\n\t\t\tlogger.debug \"error fetching pictures from #{provider}\"\n\t\t\tlogger.debug e.to_yaml\n\t\tend\n\t\treturn nil\n\tend", "def avatar_url\n attachment = @object.avatar_attachment\n return if attachment.nil?\n\n Rails.application.routes.url_helpers.rails_blob_url(attachment, only_path: true)\n end", "def avatar_url\n return image_url if image_url\n return DEFAULT_AVATAR if email.nil?\n\n gravatar_url\n end", "def avatar_url(format = nil)\n return API::User.default_avatar(@discriminator) unless @avatar_id\n\n API::User.avatar_url(@id, @avatar_id, format)\n end", "def avatar_url_for(person, options = {})\n return nil if person.nil?\n options = parse_options(person, options)\n field = options[:twitter_field]\n return nil if field.nil?\n twitter_name = person.send(field)\n return nil if twitter_name.nil?\n Twitter.profile_image(twitter_name, :size => options[:size])\n end", "def profile_image_uri(size=:normal)\n ::URI.parse(insecure_uri(profile_image_uri_https(size))) if @attrs[:profile_image_url_https]\n end", "def author_picture_url\n @author_picture_url ||= begin\n if self.author_screenname\n \"http://twitter.com/api/users/profile_image/#{self.author_screenname}\"\n else\n image_path(\"default-avatar.png\")\n end\n end\n end", "def get_avatar\n u = User.find_by_id(self.id)\n if u.role == 'user'\n return u.avatar.url unless u.avatar.nil?\n else\n info = Info.find_by_email(self.email)\n return info.info_avatar.image.url unless info.nil?\n end\n return nil\n end", "def display_profile_image\n if self.picture.present? && self.picture.url(:small).present?\n self.picture.url(:small)\n else\n ActionController::Base.helpers.asset_path('user.png')\n end\n end", "def picture\n if self.avatar?\n self.avatar.url\n elsif self.image_url != nil\n self.image_url\n else\n 'generic_avatar'\n end\n end", "def avatar_url(avatar_size=\"small\")\n if self.has_shelby_avatar\n return self.shelby_avatar_url(avatar_size)\n else\n return self.user_image_original || self.user_image || \"#{Settings::ShelbyAPI.web_root}/images/assets/avatar.png\"\n end\n end", "def avatar_url\n \"https://avatars.githubusercontent.com/u/#{uid}?v=2\"\n end", "def blank_profile_pic_url(format = 'tiny')\n \"/images/profile_pictures/profile_blank_#{format}.png\"\n end", "def get_picture(type='square')\n if self.social_sessions.first.social_network.username == 'facebook'\n return \"http://graph.facebook.com/#{self.id_on_social}/picture?type=#{type}\"\n end\n end", "def avatar\n object.avatar.url\n end", "def avatar_url_for(person, options = {})\n person.nil? ? nil : url\n end", "def avatar_url(user)\n default_url = \"#{root_url}images/guest.jpg\"\n # BUG: Don't use gravatar as you can get someone else's gravatar with your name.\n # eg. Try signing up with name \"test meme\" ... it's some dude's distorted face\n # if user.profile\n # if user.profile.avatar_url.present?\n # user.profile.avatar_url\n # else\n # gravatar_id = Digest::MD5.hexdigest(user.email.downcase)\n # \"http://gravatar.com/avatar/#{gravatar_id}?s=200&d=#{CGI.escape(default_url)}\"\n # end\n # else\n # default_url\n # end\n end", "def user_avatar_url(user = nil, variant:)\n if user.nil? || Rails.application.show_dummy_image?\n UsersHelper.no_avatar_path\n else\n user.avatar_image_location(variant: variant) || UsersHelper.no_avatar_path\n end.to_s\n end", "def user_img_URL\n self.user.image_url\n end", "def avatar_url(options = {})\n options = {\n rating: 'pg',\n default: 'retro'\n }.merge(options)\n hash = Digest::MD5.hexdigest(object.email)\n\n uri = URI.parse(\"https://secure.gravatar.com/avatar/#{hash}\")\n uri.query = URI.encode_www_form(options)\n\n uri.normalize.to_s\n end", "def autodiscover_pavatar_url_from(profile_url)\n return nil if profile_url.blank?\n uri = URI.parse(profile_url)\n begin\n self.http_connection_factory.start(uri.host, uri.port) do |http|\n return avatar_from_header(http) || avatar_from_link_element(http) || direct_avatar(profile_url, http) || nil\n end\n rescue Errno::ECONNREFUSED => e\n nil\n end\n end", "def tw_image_url(type)\n \"http://api.twitter.com/1/users/profile_image?user_id=#{tw_user_id}&size=#{type}\"\n end", "def smol_avatar_url\n # Gravatar uses MD5 hashes of people's email addresses, so it works well here.\n hash = Digest::MD5.hexdigest(email)\n \"http://www.gravatar.com/avatar/#{hash}?size=50px\"\n end", "def avatar_url(user_id, avatar_id)\n \"#{api_base}/users/#{user_id}/avatars/#{avatar_id}.jpg\"\n end", "def image_url\n \"https://graph.facebook.com/#{id}/picture\"\n end", "def avatar_url(user)\n if user.avatar_url.present?\n user.avatar_url\n else\n default_url = \"#{root_url}images/guest.png\"\n gravatar_id = Digest::MD5.hexdigest(user.email.downcase)\n \"http://gravatar.com/avatar/#{gravatar_id}.png?s=48&d=#{CGI.escape(default_url)}\"\n end\n end", "def avatar_url(user)\n if user.avatar_url.present?\n user.avatar_url\n else\n default_url = \"#{root_url}images/guest.png\"\n gravatar_id = Digest::MD5.hexdigest(user.email.downcase)\n \"http://gravatar.com/avatar/#{gravatar_id}.png?s=48&d=#{CGI.escape(default_url)}\"\n end\n end", "def profile_image(profile)\n url = Gravatar.new(profile.display_email || '@').image_url size: 40,\n secure: true, default: :mm\n image_tag url, alt: \"gravatar for #{profile.name}\",\n style: 'width: 40px; height: 40px;'\n end", "def image_uri\n return \"/image_store/#{id}.#{profile_image}\"\n end", "def url(*args)\n avatar.url(*args)\n end", "def avatar_url\n hash = Digest::MD5.hexdigest(email)\n \"http://www.gravatar.com/avatar/#{hash}\"\n end", "def get_avatar_url(user_id)\n u = User.find_by_id( user_id)\n avatar = u.avatar.url(:thumb)\n unless u.avatar_file_size?\n avatar = false\n end\n return avatar || Settings.avatar_image \n end", "def api_profile_url\n return nil unless (temp_api_profile_url = read_attribute(:api_profile_url))\n # logger.debug2 \"temp_api_profile_url = #{temp_api_profile_url}\"\n encrypt_remove_pre_and_postfix(temp_api_profile_url, 'api_profile_url', 39)\n end", "def api_profile_url\n return nil unless (temp_api_profile_url = read_attribute(:api_profile_url))\n # logger.debug2 \"temp_api_profile_url = #{temp_api_profile_url}\"\n encrypt_remove_pre_and_postfix(temp_api_profile_url, 'api_profile_url', 39)\n end", "def external_url\n json[\"entry_data\"][\"ProfilePage\"].first[\"graphql\"][\"user\"][\"external_url\"]\n end", "def author_avatar\n anonymous? ? Avatar.default.url : user.profile.avatar.url\n end", "def fb_image_url(type='square')\n \"http://graph.facebook.com/#{fb_user_id}/picture?type=#{type}\" \n end", "def actual_url(url, options = {})\n response = Typhoeus::Request.head(url)\n if response.success?\n url\n elsif response.code == 302 || response.code == 301\n location = response.headers_hash[:location]\n (location =~ fb_ignore_pattern) ? nil : actual_url(location)\n elsif response.timed_out?\n Rails.logger.error(\"time out fetching profile photo from [#{url}]\")\n nil\n elsif response.code == 0\n Rails.logger.error(response.curl_error_message)\n nil\n elsif ((response.code == 403) || (response.code == 404)) && (options[:network] == :twitter)\n # Original size images for twitter may not exist\n Rails.logger.debug(\"Could not find image for twitter, url = #{url}\")\n nil\n else\n Rails.logger.error(\"HTTP request failed: \" + response.code.to_s)\n nil\n end\n end", "def author_avatar\n is_anonymous ? Avatar.default.url : user.profile.avatar.url\n end", "def image_avatar_path(person, options={})\n options = {:name => :thumb, :anonymous => false}.merge(options).symbolize_keys\n source = options.delete(:source)\n return source if source \n name = options.delete(:name)\n anonymous = options.delete(:anonymous)\n\n if person && !anonymous && person.avatar.file?\n source = person.avatar.url(name)\n end\n if source.blank?\n if :profile == name.to_sym\n source = person && person.is_female? ? image_path('icons/avatars/female_large_turquoise.png') : image_path('icons/avatars/male_large_turquoise.png')\n else\n if person && person.partner?\n source = person.is_male? ? image_path('icons/avatars/male_green.png') : image_path('icons/avatars/female_green.png')\n else\n source = person && person.is_female? ? image_path('icons/avatars/female_blue.png') : image_path('icons/avatars/male_blue.png')\n end\n end\n end\n source\n end", "def get_user_image(user_id)\n @user = User.find(:first,:select=>\"profile_image_url\",:conditions=>[\"id=#{user_id}\"])\n return @user.profile_image_url\n end", "def fb_profile_url\n \"http://www.facebook.com/profile.php?id=#{fb_user_id}\"\n end", "def avatar_url(options = {})\n base_url = if options[:ssl]\n \"https://secure.gravatar.com/avatar/\"\n else\n \"http://www.gravatar.com/avatar/\"\n end\n email_digest = Digest::MD5.hexdigest(email)\n \"#{base_url}#{email_digest}\"\n end", "def image_from_url(url)\n self.facebookprofile = open(url)\n end", "def set_facebook_url\n facebook_id = user.authorization.uid\n \"http://graph.facebook.com/#{facebook_id}/picture\"\n end", "def user_avatar(user)\n user.avatar ? user.avatar.photo.url(:thumb) : \"default-avatar.jpg\"\n end", "def url\n\t\t\"http://beta.stoffiplayer.com/profile/#{id}\"\n\tend", "def avatar_url\n uploaded ? avatar.url : \"/assets/no_avatar.png\"\n end" ]
[ "0.81313115", "0.81181884", "0.8045249", "0.8007603", "0.7930503", "0.7916256", "0.778549", "0.77480817", "0.7669478", "0.76416874", "0.7639152", "0.75990206", "0.7592406", "0.75500304", "0.7539818", "0.748586", "0.7464137", "0.7419884", "0.7419884", "0.74030614", "0.7401696", "0.7398087", "0.73958695", "0.73953277", "0.7362373", "0.73353636", "0.7331881", "0.7320951", "0.7284274", "0.72828335", "0.7276081", "0.72710484", "0.72710484", "0.7266798", "0.7264186", "0.72287494", "0.72206527", "0.7195004", "0.7179841", "0.7169003", "0.71224976", "0.7118733", "0.71127474", "0.71121943", "0.71100855", "0.71050566", "0.7102859", "0.70898026", "0.70886236", "0.7085749", "0.7084943", "0.70759416", "0.7066238", "0.70600957", "0.70436865", "0.7041554", "0.70346373", "0.7025351", "0.70144033", "0.69662917", "0.69641554", "0.69640255", "0.6937816", "0.69361633", "0.69348645", "0.69195104", "0.69142735", "0.690927", "0.6894126", "0.6873789", "0.6860939", "0.6834648", "0.6833552", "0.6822206", "0.6821044", "0.6819196", "0.6807828", "0.6803691", "0.680272", "0.68004525", "0.6794538", "0.678926", "0.6788449", "0.67865837", "0.67781264", "0.67781264", "0.6773913", "0.6758263", "0.67464393", "0.6736259", "0.67316717", "0.6727591", "0.6725317", "0.66898197", "0.66855294", "0.66844237", "0.667359", "0.6673035", "0.66704416", "0.66636586" ]
0.7863667
6
def get_possesive_pronoun(gender) if gender == "Male" return "his" elsif gender == "Female" return "her" else return "his/her" end end get permission name
def get_permission_name(permission) case permission when Footprint32::PRIVATE return "Private" when Footprint32::FRIENDS return "Friends" else return "Public" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def possessive_pronoun\n return @gender.possessive\n end", "def genderToObjectivePronoun(gender)\n if gender == nil\n return '(unknown gender)'\n end #TODO: Raise exception if unknown detected\n\n if gender == :male || gender.downcase == 'male'\n return 'him'\n else\n return 'her'\n end\n #TODO: Raise exception if unknown detected\n end", "def reflexive_pronoun\n return @gender.reflexive\n end", "def genderToPossessiveAdjective(gender)\n if gender == nil\n return '(unknown gender)'\n end #TODO: Raise exception if unknown detected\n\n if gender == :male || gender.downcase == 'male'\n return 'his'\n else\n return 'her'\n end\n end", "def personal_subjective_pronoun\n return @gender.personal_subjective\n end", "def gender_name\n case gender\n when 'm'\n 'male'\n when 'f'\n 'female'\n else\n ''\n end\n end", "def possessive(user)\n return 'your' if (user == current_user)\n return 'their' unless user.contact_information && user.contact_information.gender\n user.contact_information.gender == 'male' ? 'his' : 'her'\n end", "def personal_objective_pronoun\n return @gender.personal_objective\n end", "def the_sex_prefix\n sex == 0 ? 'his' : 'her'\n end", "def gender_from_name\n if name[/women|athena|girl/i]\n \"F\"\n else\n \"M\"\n end\n end", "def gender_displayname\n gender == MALE[:value] ? MALE[:display_name] : FEMALE[:display_name]\n end", "def gender_neutral_first_name; end", "def format_gender\n return gender == 'f' ? \"female\" : \"male\"\n end", "def gender_txt\n [\"Not Telling\", \"Male\", \"Female\"][self.gender - 1]\n end", "def gender_indirect\n case gender\n when 'm'\n when 'male'\n I18n.t('gender_indirect_m')\n\n when 'f'\n when 'female'\n I18n.t('gender_indirect_f')\n\n when 'd'\n when 'diverse'\n I18n.t('gender_indirect_diverse')\n\n when 'n'\n when 'noinfo'\n I18n.t('gender_indirect_noinfo')\n else\n \"\"\n end\n\n end", "def fullgender\n\t\tcase gender\n\t\t\twhen 'F': 'female'\n\t\t\twhen 'M': 'male'\n\t\t\telse 'unknown'\n\t\tend\n\tend", "def gender\n sex.to_s\n end", "def gender_mapping(gender)\n return 'male' if gender == 'Boy'\n 'female'\n end", "def gender(gender)\n case gender\n when 'F', 'female'\n t('patients.female')\n when 'M', 'male'\n t('patients.male')\n when 'O', 'other'\n t('patients.other')\n else\n t('patients.unknown')\n end\n end", "def gender_string\n case object.gender\n when Settings.gender.male.id\n Settings.gender.male.name\n when Settings.gender.female.id\n Settings.gender.female.name\n end\n end", "def gender\n self.female ? \"Female\" : \"Male\"\n end", "def gender\n case\n when male && female then :unisex\n when male then :male\n when female then :female\n end\n end", "def essay_writer(title, topic, date, thesis, pronoun)\n if pronoun == \"female\"\n return \"#{title}. #{topic} was born in #{date}. She changed the world and is someone we should all learn about further. \n #{thesis}. #{topic} is important to the world.\"\n elsif pronoun == \"male\"\n return \"#{title}. #{topic} was born in #{date}. He changed the world and is someone we should all learn about further. \n #{thesis}. #{topic} is important to the world.\"\n else \n return \"#{title}. #{topic} was important since #{date}. It changed the world and is something we should all learn about further. \n #{thesis}. #{topic} is important to the world.\"\n end \nend", "def gender_description\n case gender_id\n when 1\n 'Male'\n when 2\n 'Female'\n when 3\n 'It''s complicated'\n end\n end", "def female_name\n case rand(0..8)\n when 0, 5 then \"#{first_name(:female)} #{middle_name(:female)}\"\n else first_name(:female)\n end\n end", "def full_name(gender = :any)\n case gender\n when :any then rand(0..1).zero? ? male_full_name : female_full_name\n when :male then male_full_name\n when :female then female_full_name\n else raise ArgumentError, 'Invalid gender, must be one of :any, :male, :female'\n end\n end", "def male_name\n case rand(0..8)\n when 0, 5 then \"#{first_name(:male)} #{middle_name(:male)}\"\n else first_name(:male)\n end\n end", "def gender_abbreviation\n case gender_id\n when 1\n 'M'\n when 2\n 'F'\n when 3\n ''\n end\n end", "def default_male_name\n ext_text(9000, 2)\n end", "def gender; end", "def name(for_sex = :random)\n with_same_sex(for_sex) do\n case rand(0..1)\n when 0 then \"#{last_name} #{first_name} #{patronymic}\"\n else \"#{first_name} #{last_name}\"\n end\n end\n end", "def appellant_fullname_readable\n appellant_name&.titleize\n end", "def translate_gender(wanted)\n return -1 if wanted == 0\n\n return wanted\n end", "def essay_writer(title, topic, date, thesis_statement, pronoun)\n if pronoun == \"male\"\n who = \"He\" \n whose = \"His\"\n whom = \"Him\"\n \n elsif pronoun == \"female\"\n who = \"She\"\n whose = \"Her\"\n whom = \"Her\"\n \n else\n who = \"It\"\n whose = \"Its\"\n whom = \"Its\"\n end\n \n return who + \" was an important person in \" + date.to_s + \". \" + who + \" did a lot. I want to learn more about him. \" + thesis_statement + \" \" + topic.to_s + \"'s contribution is important.\"\n \nend", "def essay_writer(title, person, date, thesis_statement, gender)\n\nif gender == \"female\"\n pronoun_1 = \"she\"\n pronoun_2 = \"her\" \nelse \n pronoun_1 = \"he\"\n pronoun_2 = \"his\"\nend \n \n\"#{title}\n \n #{person.capitalize} was important in #{date}. #{pronoun_1.capitalize} were great because of #{pronoun_2} work. #{thesis_statement}.\" \n \n end", "def essay_writer(title, topic, date, thesis_statment, pronoun)\n\t if pronoun === \"male\"\n\t\treturn \"#{topic} was an important person in #{date}. He did a lot. I want to learn more about him. #{thesis_statment} #{topic}'s contribution was important.\"\n\t elsif pronun === \"female\"\n\t \treturn \"#{topic} was an important person in #{date}. She did a lot. I want to learn more about her. #{thesis_statment} #{topic}'s contribution was important.\"\n\t elsif pronun === \"place\"\n\t \treturn \"#{topic} was an important place in #{date}. It was very influential. I want to learn more about it. #{thesis_statment} #{topic}'s contribution was important.\"\n\t elsif pronoun === \"generic\"\n\t \treturn \"#{topic} was an important topic in #{date}. It was very influential. I want to learn more about it. #{thesis_statment} #{topic}'s contribution was important.\"\n\t end\nend", "def gender\n #TODO add check if char is 'm' or 'f' and if necessary\n # throw an exception\n @avatar_string[0].downcase\n end", "def generatePlayerName(gender)\n\t\tif gender == \"male\"\n\t\t\t\"#{@playerFirstName.sample}#{@playerSecondNameMale.sample}\"\n\t\telse\n\t\t\t\"#{@playerFirstName.sample}#{@playerSecondNameFemale.sample}\"\n\t\tend\n\tend", "def are_you_or_is_guardian_name\n guard_name = response_for(\"#{OperationalDataExtractor::ParticipantVerification::INTERVIEW_CHILD_PREFIX}.G_FNAME\") + ' ' +\n response_for(\"#{OperationalDataExtractor::ParticipantVerification::INTERVIEW_CHILD_PREFIX}.G_MNAME\") + ' ' +\n response_for(\"#{OperationalDataExtractor::ParticipantVerification::INTERVIEW_CHILD_PREFIX}.G_LNAME\")\n guard_name.blank? ? 'are you' : \"is #{guard_name}\"\n end", "def male_first_name; end", "def get_category_and_gender_short\n \"#{get_category_type_name} #{gender_type.i18n_short}\"\n end", "def default_female_name\n ext_text(9000, 3)\n end", "def resolve_personal_subjective_pronoun(target)\n if target == self\n return \"you\".freeze\n end\n if can_see?(target)\n return target.personal_subjective_pronoun\n else\n return target.indefinite_personal_subjective_pronoun\n end\n end", "def gender\n self[:gender] || \"\"\n end", "def show_gender\n Gender[gender.to_i]\n end", "def get_gender\n\t\tputs \"Is this person (m)ale or (f)emale?\"\n\t\tinput = gets.chomp.downcase\n\t\tif input == \"m\" || input == \"male\"\n\t\t\t@gender = \"male\"\n\t\telse\n\t\t\t@gender = \"female\"\n\t\tend\n\tend", "def name(gender = :random)\n name_for_gender(:full_name, gender)\n end", "def sex\n self[:gender]\n end", "def gender_color(sex)\n sex.to_i == 0 ? 'female' : 'male'\n end", "def indefinite_personal_subjective_pronoun\n return \"it\"\n end", "def full_name_no_prefix(gender = :any)\n case gender\n when :any\n case rand(0..8)\n when 0, 3, 6, 8 then \"#{female_name} #{paternal_last_names}\"\n else \"#{male_name} #{paternal_last_names}\"\n end\n when :male then \"#{male_name} #{paternal_last_names}\"\n when :female then \"#{female_name} #{paternal_last_names}\"\n else raise ArgumentError, 'Invalid gender, must be one of :any, :male, :female'\n end\n end", "def hisher\n hisher = human_gender == 'Male' ? 'his' : 'her'\n end", "def name_male\n case rand(10)\n when 7 then \"#{prefix_male} #{first_name_male} #{last_name}\"\n when 5 then \"#{prefix_male} #{first_name_male} #{last_name}\"\n when 3 then \"#{first_name_male} #{last_name}\"\n when 0 then \"#{first_name_male} #{last_name}\"\n else \"#{first_name_male} #{last_name}\"\n end\n end", "def gender\n GENDERS[gender_id]\n end", "def sex\n fetch('demographic.sex')\n end", "def gender\r\n infoxml = get_info \r\n return infoxml['gender']\r\n end", "def memer_degree\n\t\tstats = self.stats\n\t\tif stats[:general_stats].values.inject(0,:+) == 0\n\t\t\treturn \"Boring memer\"\n\t\tend\n\t\tnouns = {\n\t\t\t\"replier\" => stats[:general_stats][:comments_count], \n\t\t\t\"memer\" => stats[:general_stats][:memes_count], \n\t\t\t\"reposter\" => stats[:general_stats][:posts_count], \n\t\t\t\"reacter\" => stats[:general_stats][:reactions_count]\n\t\t}\n\t\tadjectives = {swipe_up: \"Wholesome\", swipe_down: \"Normie\", swipe_left: \"Dank\", swipe_right: \"Boring\"}\n\n\t\tuser_noun = nouns.max_by{|k,v| v }[0]\n\t\tuser_adjective = (stats[:general_stats][:reaction_counts])? adjectives[stats[:reactions_stats].max_by{|k,v| v }[0]] : \"Boring\"\n\t\tuser_adjective + \" \" + user_noun\n\tend", "def patronymic(for_sex = :random)\n fetch_sample(PATRONYMICS[select_sex(for_sex)])\n end", "def mr_name\n _mr_ = gender == 'female' ? 'Miss' : 'Mr.'\n _name_ = last_name\n if /\\p{Han}+/.match(last_name)\n _name_ = Pinyin.t(last_name).capitalize rescue last_name\n end\n \"#{_mr_} #{_name_}\"\n end", "def user_permission(paid, cancelled, signed_in, admin)\n\tif paid == \"no\" or cancelled == \"yes\"\n\treturn \"Go away!\"\n\telsif signed_in == \"yes\" and admin == \"yes\"\n\treturn \"You can see and change all the pages!\"\n\telsif signed_in == \"yes\" and admin == \"no\"\n\treturn \"You can see all the pages!\"\n\telsif signed_in == \"no\"\n\treturn \"You can't see any of the pages, please sign in!\"\n\tend\nend", "def female?\n self.gender == 'f'\n end", "def gender\n @gender\n end", "def get_gender_type_code\n gender_type ? gender_type.i18n_alternate : '?'\n end", "def get_gender(page)\n # Get the line that contains the player's race\n gender = page.grep(/chara_profile_title/)\n\n # Get the last word (which contains the gender)\n gender1 = gender[0].split[-1]\n\n if gender1[0] == \"♂\"\n gender = \"male\"\n elsif gender1[0] == \"♀\"\n gender = \"female\"\n else\n gender = nil\n end\n return gender\n end", "def get_gender(page)\n # Get the line that contains the player's race\n gender = page.grep(/chara_profile_title/)\n\n # Get the last word (which contains the gender)\n gender1 = gender[0].split[-1]\n\n if gender1[0] == \"♂\"\n gender = \"male\"\n elsif gender1[0] == \"♀\"\n gender = \"female\"\n else\n gender = nil\n end\n return gender\n end", "def gender\n get_attribute(Yoti::Attribute::GENDER)\n end", "def first_name_women; end", "def get_gender\n return @gender\n end", "def name_female\n case rand(10)\n when 7 then \"#{prefix_female} #{first_name_female} #{last_name}\"\n when 5 then \"#{prefix_female} #{first_name_female} #{last_name}\"\n when 3 then \"#{first_name_female} #{last_name}\"\n when 0 then \"#{first_name_female} #{last_name}\"\n else \"#{first_name_female} #{last_name}\"\n end\n end", "def parse_permission(name)\n if name.reverse.index(VIEWER.reverse)\n return VIEWER\n elsif name.reverse.index(EDITOR.reverse)\n return EDITOR\n elsif name.reverse.index(USER.reverse)\n return USER\n elsif name.reverse.index(ADMIN.reverse)\n return ADMIN\n else\n @logger.info \"Error in parsing permission\"\n end\n nil\n end", "def inflection\n ( self[ :inflect ] || \"#{pluralize}#{gender}\" ).to_s\n end", "def rights_facet\n raw = @xml.at('//userestrict[1]').to_s\n open('/tmp/output', 'a') { |f| f << \"!! #{raw}\\n\" } \n if raw=~/[Pp]ublic [Dd]omain/ \n return \"Public Domain\"\n elsif raw=~/[Pp]ublic [Rr]ecord/ \n return \"Public Records\"\n elsif raw=~/Creator retains literary rights/\n return \"Creator retains literary rights.\"\n else\n return \"Other\"\n end\n end", "def show_sex_label_method\n sex\n end", "def female?\n @sex == 'f'\n end", "def human_gender(value = nil)\n gender = value || self.gender\n Person.human_gender(gender)\n end", "def male?\n @sex == 'm'\n end", "def full_name\n full_name = object.first_name + \" \" + object.last_name\n if object.profile.try(:search_engine_privacy).present?\n display_name = object.profile.try(:search_engine_privacy) == \"Show my full name\" ? full_name : object.first_name + \" \" + object.last_name.chr\n else\n display_name = full_name\n end\n return display_name \n end", "def reverse_name\n reverse_lookup = Settings.relationship_reverse\n reverse_name = reverse_lookup[self.name]\n if reverse_name.kind_of?(Hash) then\n return reverse_name[self.relation.gender.downcase]\n else\n return reverse_name\n end\n end", "def gender\n attributes = attributes_before_type_cast\n if attributes[\"gender\"]\n read_attribute(:gender).to_sym\n else\n nil\n end\n end", "def is_male?\n gender && gender.first == 'm'\n end", "def gender\n\n if self.providers.size == 0\n return self.gender_custom\n end\n\n if self.gender_custom != \"none\"\n return self.gender_custom\n end\n\n return nil if self.providers.size == 0\n genders = self.providers.map(&:gender).compact\n return genders.first if !genders.empty?\n nil \n end", "def parse_permission(name)\n if name.reverse.index(VIEWER.reverse)\n return VIEWER\n elsif name.reverse.index(EDITOR.reverse)\n return EDITOR\n elsif name.reverse.index(USER.reverse)\n return USER\n elsif name.reverse.index(ADMIN.reverse)\n return ADMIN\n else\n @logger.info \"Error in parsing permission\"\n end\n nil\n end", "def male?\n self.gender == 'm'\n end", "def get_category_and_gender_short\n meeting_program ? meeting_program.get_category_and_gender_short : '?'\n end", "def show_sex_label_method\n self.sex\n end", "def gender_for(val, optional: false)\n return nil if val.nil? && optional\n\n val.to_s.split('.').last\n end", "def mood\n unless admin\n happiness > nausea ? 'happy' : 'sad'\n end\n end", "def full_name_prefix(gender = :any)\n case gender\n when :any\n case rand(0..8)\n when 0, 3, 6, 8 then \"#{female_prefix} #{female_name} #{paternal_last_names}\"\n else \"#{male_prefix} #{male_name} #{paternal_last_names}\"\n end\n when :male then \"#{male_prefix} #{male_name} #{paternal_last_names}\"\n when :female then \"#{female_prefix} #{female_name} #{paternal_last_names}\"\n else raise ArgumentError, 'Invalid gender, must be one of :any, :male, :female'\n end\n end", "def title\n if review?\n confidential? ? \"#{name} (Private Review)\" : \"#{name} (Shared Review)\"\n elsif verification?\n \"#{name} (Verification)\"\n elsif groups?\n \"#{name} (Group)\"\n elsif private_type?\n \"#{name} (Private)\"\n elsif government?\n \"#{name} (Government)\"\n else\n \"#{name} (Administrator)\"\n end\n end", "def speak_to_grandma(question)\n if question != question.upcase\n return \"HUH?! SPEAK UP, SONNY!\"\n elsif question == \"I LOVE YOU GRANDMA!\"\n return \"I LOVE YOU TOO PUMKIN!\"\n else\n return \"NO, NOT SINCE 1938!\"\n end\nend", "def gender_name=(value)\n case value\n when 'male'\n gender = 'm'\n when 'female'\n gender = 'f'\n end\n end", "def gender\n self.dig_for_string(\"agentSummary\", \"gender\")\n end", "def work_type_name(work)\n case work.person.gender\n when \"female\" then work.type.name_feminine\n when \"male\" then work.type.name_masculine\n end\n end", "def normalize(gender_str)\n\t\t\tMale.include?(gender_str.downcase) ? (:male) : (:female)\n\t\tend", "def gender\n return @poco_data[:gender] unless @poco_data == nil\n pick_first_node(@poco.xpath('./poco:gender'))\n end", "def get_signature_name(person)\n return person.to_s.gsub('_', ' ').namecase\n # case person\n # when :john_mcguire\n # return \"John McGuire\"\n # when :ted_mckeehan\n # return \"Ted McKeehan\"\n # when :casey_mckeehan\n # return \"Casey McKeehan\"\n # else\n # return person.to_s.gsub('_', ' ').titleize\n # end\n end", "def name(gender = :any)\n case gender\n when :any then rand(0..1).zero? ? name(:male) : name(:female)\n when :male then fetch_sample(MALE_FIRST_NAMES)\n when :female then fetch_sample(FEMALE_FIRST_NAMES)\n else raise ArgumentError, 'Invalid gender, must be one of :any, :male, :female'\n end\n end", "def formalname\n sprintf(\"%s's %s %s\", gender.camelize,\n varsity? ? \"Varsity\" : \"JV\", sport.name)\n end", "def essay_writer(title, person, gender, place, topic, date, thesis)\n if (gender == \"male\")\n \treturn\n \t\t\"#{person} isn't really a #{title}. They wish they were born in #{place} but not as a #{gender}. The topic of their thesis was #{topic}, writen on #{date}, while drunk, and this is what they came up with #{thesis}\"\n elsif \n \treturn\n \t\t\"#{person} is really a #{title}. They were born in #{place} as a #{gender}. The topic of their thesis was #{topic}, writen on #{date}, this is what they came up with #{thesis}\"\n end \nend", "def genders\n ['male','female','A being beyong comprehension']\n end" ]
[ "0.7487196", "0.73661214", "0.7308786", "0.71863526", "0.7171797", "0.7058161", "0.7038999", "0.69493514", "0.69390285", "0.69042563", "0.6830248", "0.67770284", "0.67543596", "0.675428", "0.6709431", "0.6706902", "0.6705201", "0.67002004", "0.66957444", "0.66066825", "0.65181345", "0.64815986", "0.6462004", "0.6457918", "0.6451651", "0.64489406", "0.64339846", "0.642376", "0.6406246", "0.64019847", "0.6391208", "0.6374261", "0.6366597", "0.63510966", "0.6346201", "0.6321449", "0.6320361", "0.63030386", "0.6293619", "0.6292252", "0.6282043", "0.62788254", "0.62164104", "0.6202984", "0.61992943", "0.61981696", "0.6191049", "0.618776", "0.61856925", "0.6175714", "0.61492693", "0.61420137", "0.6140218", "0.612238", "0.6114258", "0.6108625", "0.6108152", "0.6108101", "0.6083431", "0.60755557", "0.6066387", "0.60605747", "0.60588425", "0.60440356", "0.60440356", "0.6040524", "0.60375017", "0.60356003", "0.6033231", "0.60269874", "0.6022785", "0.60048485", "0.5999114", "0.5994735", "0.598694", "0.5984067", "0.5982557", "0.5980817", "0.5977495", "0.5969816", "0.59640163", "0.5963925", "0.59554785", "0.5951525", "0.5941446", "0.59413", "0.59402394", "0.59235793", "0.5913424", "0.5903476", "0.5901195", "0.58920383", "0.58893275", "0.58824164", "0.587207", "0.5858817", "0.5857556", "0.5852583", "0.58429384", "0.58420205" ]
0.67403656
14
statistics helpers user with most reviews def top_reviewers User.order("reviews_count DESC").includes(:profile, :profile_photo).limit(8) end user with most popular reviews def popular_reviewers User.limit(5).sort_by(&:total_votes).reverse end most reviewed places def most_reviewed_places Place.order("reviews_count DESC").limit(8) end def most_reviewed_places_in_a_week Review.weekly_top_places.limit(8) end def top_reviewers_in_a_week Review.weekly_top_reviewers.limit(8) end most liked places def most_popular_places Place.order("favorite_places_count DESC").limit(8) end most visited places def most_visited_places Place.order("visited_places_count DESC").limit(5) end
def share_with_facebook_url(opts) # Generates an url that will 'share with Facebook', and can includes title, url, summary, images without need of OG data. # # URL generate will be like # http://www.facebook.com/sharer.php?s=100&p[title]=We also do cookies&p[url]=http://www.wealsodocookies.com&p[images][0]=http://www.wealsodocookies.com/images/logo.jpg&p[summary]=Super developer company # # For this you'll need to pass the options as # # { :url => "http://www.wealsodocookies.com", # :title => "We also do cookies", # :images => {0 => "http://imagelink"} # You can have multiple images here # :summary => "My summary here" # } url = "http://www.facebook.com/sharer.php?s=100" parameters = [] opts.each do |k,v| key = "p[#{k}]" if v.is_a? Hash v.each do |sk, sv| parameters << "#{key}[#{sk}]=#{sv}" end else parameters << "#{key}=#{v}" end end url + parameters.join("&") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def most_reviews\n @top_five = Taxi.most_review_answers(current_user, params)\n end", "def most_active\n @users_comments = User.joins(:comment).\n select('user.user_id, user.user_name, user.first_name, user.last_name, count(user.user_id) as count').\n group('user.user_id').\n order('count DESC').take(10)\n\n @users_ratings = User.joins(:rating).\n select('user.user_id, user.user_name, user.first_name, user.last_name, count(user.user_id) as count').\n group('user.user_id').\n order('count DESC').take(10)\n end", "def analyze_most_popular_users(user)\n\n # calculate score\n most_popular = 1\n most_popular *= (val = user.num_radlib_views_received) > 0 ? val : 1\n most_popular *= (val = user.num_likes_received) > 0 ? val : 1\n most_popular *= (val = user.num_radlibs_filled_by_others) > 0 ? val : 1\n\n # scale it down to avoid too big a number, using 10000.1 (with decimal ensures that we extend the value's significant digits)\n most_popular /= 100.1\n\n # analyze result\n analyze_most_generic(user.uid, most_popular.to_f, DOCS[:most_popular_users])\n self\n end", "def statistics\n @user = User.find(params[:id])\n @pageTitle = @user.display_name + \" Site History\"\n @metaDescription = @user.description.blank? ? @user.display_name : @user.description\n @trip_report_visit_groups = @user.trip_report_visits.order(\"updated_at DESC\").limit(30).in_groups_of(3)\n @place_visit_groups = @user.place_visits.order(\"updated_at DESC\").limit(30).in_groups_of(3)\n @photo_visits = @user.photo_visits.order(\"updated_at DESC\").limit(30)\n @route_visit_groups = @user.route_visits.order(\"updated_at DESC\").limit(30).in_groups_of(3)\n @album_visit_groups = @user.album_visits.order(\"updated_at DESC\").limit(30).in_groups_of(3)\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @user }\n end\n end", "def index\n \t@ratings = Rating.includes(:user, beer: :brewery).all\n @top3Beers = topbeer @ratings, 3\n @top3Breweries = topbrewery @ratings, 3\n @top3Raters = User.top 3\n @top3Styles = topstyle @ratings, 3\n @recent = @ratings.order(created_at: :desc).limit(5)\n end", "def top_reviewers(p_topic, p_limit = 10)\n User.find(\n :all,\n :select => 'DISTINCT users.*',\n :joins => :reviews,\n :group => 'reviews.id',\n :order => 'count(reviews.id) DESC',\n :conditions => ['reviews.topic_id = ?', p_topic.id],\n :limit => p_limit\n )\n end", "def popularity\n views*1 + comments.size*1\n end", "def users_with_most_liked_comments\n User\n .preload(:likes)\n .joins(:likes)\n .group('users.id')\n .order(Arel.sql('count(likes.id) desc'))\n .limit(10)\n end", "def show\n @user = @profile.user.id \n @reviews = Review.where(:profile_id => @profile.id).order(\"created_at DESC\")\n @average_rating = @reviews.average(:rating)\n end", "def get_top_10_movies_for_user(user_hash)\n Movie.get_top_10_movies_for_user(user_hash)\nend", "def analyze_most_comments_made(user)\n user = User.new\n analyze_most_generic(user.uid, user.num_comments_made.to_i, DOCS[:most_comments_made])\n end", "def top_10_fans\n users_array = UserTeam.all.collect{|user| user.user_id}\n most_common_value = users_array.uniq.sort_by{ |i| users_array.count( i ) }.reverse\n biggest_fans = most_common_value.map {|user| User.find(user).name}[0..9]\n users_teams_count = most_common_value.map {|user| User.find(user).teams.count}[0..9]\n counter = 0\n return_hash = {}\n until counter == biggest_fans.length do\n return_hash[biggest_fans[counter].to_s] = users_teams_count[counter].to_s\n counter += 1\n end\n return_hash\nend", "def top_users(limit = 10)\n @users.sort_by{|user_id,user| -user.score}.first(limit).map do |t|\n {\n :id => t.first,\n :score => t.last.score,\n :common_tracks_count => t.last.common_tracks_count,\n :total_tracks_count => t.last.total_tracks_count\n }\n end\n end", "def display_stats\n \n if current_user && current_user.role == \"admin\"\n @valuesArray = params.values[0,(params.values).length-2]\n @keysArray = params.keys[0,(params.keys).length-2]\n @match_data = ClubMatch.joins(:club).where(:matched=>1).order('COUNT(club_matches.club_id)DESC').limit(5)\n @user_interest_data = UserInterest.joins(:interest).order('COUNT(user_interests.interest_id)DESC').limit(7)\n @club_interest_data = ClubInterest.joins(:interest).order('COUNT(club_interests.interest_id)DESC').limit(7)\n \n if @valuesArray[0] != \"All\" \n @users = User.where(\"#{@keysArray[0]}\": params[\"#{@keysArray[0]}\".to_sym])\n else\n @users = User.all\n end\n \n\n @title = ' users'\n @keysArray.each_index{|x|\n if x > 0 && @valuesArray[x] != \"\" \n @users = @users.where(\"#{@keysArray[x]}\": params[\"#{@keysArray[x]}\".to_sym])\n end\n\n if @keysArray[x] == \"gender\"\n @title = @valuesArray[x] + @title\n end\n\n if @keysArray[x] == \"grad_year\" && @valuesArray[x] != \"\"\n @title = @title + ' graduating in ' + @valuesArray[x]\n end\n } \n\n @total = @users.length\n else\n redirect_to new_user_session_path\n end \n \n end", "def analyze_user(user)\n analyze_most_prolific(user)\n analyze_most_active_users(user)\n analyze_most_comments_made(user)\n analyze_most_prolific_likers(user)\n analyze_most_radlib_fillins_by_others(user)\n analyze_most_radlib_fillins_by_user(user)\n analyze_most_radlibs_created(user)\n self\n end", "def highest_comment_count\n User.preload(:comments).joins(:comments).group('users.id').order(Arel.sql('count(comments.id) desc')).limit(10)\n end", "def stats\n @most_liked_post = @school.posts.complex_order('top').first\n @most_commented_post = @school.posts.order(\"comments_count DESC\").first\n @average_post_likes = @school.posts.average('likes_count + legacy_numlikes') || 0\n @average_post_comments = @school.posts.average('comments_count') || 0\n end", "def analyze_most_active_users(user)\n\n # calculate score\n most_active = 1\n most_active *= (val = user.num_site_visits) > 0 ? val : 1\n most_active *= (val = user.num_comments_made) > 0 ? val : 1\n most_active *= (val = user.num_likes_made) > 0 ? val : 1\n most_active *= (val = user.num_radlibs_filled_by_me) > 0 ? val : 1\n most_active *= (val = user.num_radlibs_created) > 0 ? val : 1\n\n # scale it down to avoid too big a number, using 10000.1 (with decimal ensures that we extend the value's significant digits)\n most_active /= 100.1\n\n # analyze result\n analyze_most_generic(user.uid, most_active.to_f, DOCS[:most_active_users])\n self\n end", "def users_ranking\n User.find_by_sql(\"SELECT U.id, U.name, COUNT(R.id) ediciones\n FROM users U, reviews R, species S, groups G, group_users GU, species_groups SG, models m\n WHERE U.id = R.user_id AND U.id = GU.user_id AND GU.group_id = G.id\n AND SG.group_id = G.id AND S.id=SG.species_id AND m.id =R.model_id\n AND m.species_id = S.id AND SG.species_group_state_id=1 AND GU.group_user_state_id=1\n AND G.id = \"+self.id.to_s+\"\n GROUP BY U.name\n ORDER BY COUNT(R.id) DESC\n LIMIT 10\")\n end", "def index\n @reviews = Review.all\n @latest_reviews = Review.latest\n @highest_score_reviews = Review.highest_score\n @lowest_score_reviews = Review.lowest_score\n end", "def show\n @user = User.find(params[:id])\n @reviews = @user.reviews\n\n if @reviews.length > 0\n \n @ob_score = 0\n @sub_score = 0\n @tot_score = 0\n @review_count = @reviews.length\n\n @reviews.each do |r|\n @ob_score += r.ob_score.to_i\n @sub_score += r.sub_score.to_i\n @tot_score += (r.sub_score.to_i + r.ob_score.to_i)\n end\n\n @ob_score = @ob_score / @review_count\n @sub_score = @sub_score / @review_count\n @tot_score = @tot_score / @review_count\n end\n\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def show\n @trending_videos = cache_videos_trending.take(10)\n @trending_tags = cache_tags_trending.take(10)\n\n @videos = @user.videos\n\n @videos_rank = @videos.sort_by {|array| Integer(array.video_interaction_count)}.first(10).reverse.to_a\n\n # @user_histries_posts_trans_following_count = cache_users_histories.select {|h|h.user_official_id == @user.user_official_id}.pluck(:created_at,:user_following_count).map { |e| [ e[0].strftime(\"%Y-%m-%d\"), e[1] ] }\n @user_histries_posts_trans_fans_count = cache_users_histories.select {|h|h.user_official_id == @user.user_official_id}.pluck(:created_at,:user_fans_count).map { |e| [ e[0].strftime(\"%Y-%m-%d\"), e[1] ] }\n @user_histries_posts_trans_heart_count = cache_users_histories.select {|h|h.user_official_id == @user.user_official_id}.pluck(:created_at,:user_heart_count).map { |e| [ e[0].strftime(\"%Y-%m-%d\"), e[1] ] }\n\n @recommend_tags = @videos.pluck(:video_tags).flatten.compact.uniq.sort.reverse\n end", "def top_10_followers\n users_array = UserLeague.all.collect{|user| user.user_id}\n most_common_value = users_array.uniq.sort_by{ |i| users_array.count( i ) }.reverse\n biggest_followers = most_common_value.map {|user| User.find(user).name}[0..9]\n users_league_count = most_common_value.map {|user| User.find(user).leagues.count}[0..9]\n counter = 0\n return_hash = {}\n until counter == biggest_followers.length do\n return_hash[biggest_followers[counter].to_s] = users_league_count[counter].to_s\n counter += 1\n end\n return_hash\nend", "def show\n @reviews = Review.where(tutor_profile_id: @tutor_profile.id).order(\"created_at DESC\")\n if @reviews.blank?\n avg_rating = 0 \n else\n @avg_rating = @reviews.average(:rating).round(2) \n end\n end", "def get_most_popular_users(num_users = 5)\n get_most_generic_for_users(DOCS[:most_popular_users], num_users)\n end", "def get_5_positive_grain\n\t\tplaceholder_review = CriticMovie.new\n\t\tplaceholder_review.score = 0 \n\t\ttop_5 \t\t\t=\t[placeholder_review,placeholder_review,placeholder_review,placeholder_review,\n\t\t\tplaceholder_review,placeholder_review,placeholder_review,placeholder_review,placeholder_review,\n\t\t\tplaceholder_review]\n\t\tpositive_grain_array = []\n\t\tcritics_movies_hash = {}\n\t\tcritic_id = params[:id]\n\t\treviews = Critic.find(critic_id).critic_movies\n\n\t\t# create array of movies to pull batch from because it's super expensive to hit the database 1300 times per user request\n\t\tmovies_array = []\n\t\treviews.each do | review |\n\t\t\tmovies_array.push(review.movie_id)\n\t\tend\n\n\t\t# Get an array of movie objects that the critic has seen\n\t\tcritics_movies = Movie.find(movies_array)\n\t\t# [{some movie}, {some other movie}]\n\n\t\t# create a hash with movie id as key so we can grab the metacritic score to create our new object\n\t\tcritics_movies.each do | movie | \n\t\t\tcritics_movies_hash[movie.id] = {\"metacritic_score\": movie.metacritic_score, \"movie_name\": movie.title.titleize}\n\t\tend\n\n\t\t# Create the unsorted result\n\t\t# reviews are all the objects showing the critics id, the movies id, and the score of the critic\n\t\t# we iterate through each of those reviews\n\t\t# we assign the movie's id to a variable\n\t\t# we then print object from the critics_movie_hash showing metascore and movie name\n\t\t# we then store the metacritic score from that object into a variable named metascore\n\t\t# we then store the movie name from that has into a movie name variable\n\t\t# we then print the critic score, movie name, metascore, movie id, calculate the difference\n\t\t# for critic and meta and then create an object that we will then sort through to get the top or bottom\n\t\t# 5 to then return as JSON\n\t\treviews.each do | review |\n\t\t\tmovie_id \t\t= \treview.movie_id\n\t\t\tmovie_name \t\t= critics_movies_hash[movie_id][:movie_name]\n\t\t\tcritic_score \t= review.score\n\t\t\tmetascore \t\t= critics_movies_hash[movie_id][:metacritic_score]\n\n\t\t\t# If the review is less than two years ago, it can be evaluated for our top 5 \n\t\t\tif review.date >= 3.year.ago\n\t\t\t\t# get the lowest value index and compare the review against that\n\t\t\t\ttop_5.sort_by! { |k| k[:score]}\n\t\t\t\tif critic_score > top_5[0][:score]\n\t\t\t\t\tmovie_name \t\t= critics_movies_hash[movie_id][:movie_name]\n\t\t\t\t\tcritic_score \t= review.score\n\t\t\t\t\tmetascore \t\t= critics_movies_hash[movie_id][:metacritic_score]\n\t\t\t\t\trecommend_object = { \"movie_name\": movie_name, score: critic_score,\n\t\t\t\t\t\t\"metascore\": metascore }\n\t\t\t\t\ttop_5[0] = recommend_object\n\t\t\t\tend\n\t\t\tend\t\n\t\t\t# if the score is 0 then that means it was a TBD meaning not enough critic votes and it was converted to 0\n\t\t\t# we do not want this in our array because it will create artificially high or low against the grain scores that are false so\n\t\t\t# we skip this loop iteration and evaluate the next one\n\t\t\tif metascore == 0\n\t\t\t\tnext\n\t\t\tend\n\t\t\tdifference\t= critic_score - metascore \n\t\t\tsingle_movie = {\"movie_name\": movie_name, \"metascore\": metascore, \"critic_score\": critic_score, \"difference\": difference, }\n\t\t\tpositive_grain_array.push(single_movie)\n\t\t\t# {movie_id: 3, critic_score: 34, metascore: 50, difference: -16, }\n\t\tend\n\n\t\t# if there were not enough reviews to establish a metacritic score it's set to TBD which translates to 0 when it's scraped into the \n\t\t# \tint type. So if the review is 0 we reject it\n\t\ttop_5.reject! {| review | review[:score] == 0} \n\n\t\t# Sort the result, put it into an array and convert to json\n\t\tpositive_grain_array.sort_by! { |k| k[:difference]}\n\t\ttop_5.sort_by! { |k| k[:score]}.reverse!\n\t\tnegative_grain = positive_grain_array.first(5)\n\t\tnegative_grain.reverse!\n\t\tpositive_grain = positive_grain_array.pop(5)\n\t\tnegative_positive = positive_grain.reverse! + negative_grain.reverse! + top_5\n\t\tnegative_positive = negative_positive.to_json\n\n\n\t\trender :json => negative_positive\n\tend", "def top_comm\n\t\t\t@commenters = User.all.order('comments.id DESC').joins('LEFT JOIN comments ON \n\t\t\t\tcomments.user_id == users.id').group('users.id').where('comments.created_at >= ?',\n\t\t\t\t1.week.ago.utc).limit(10)\n\t\tend", "def show\n review_score = {usefulness: 0,friendliness: 0,}\n @review_count = 0\n conversations = Conversation.where(stylist_id: @professional_profile.user)\n conversations.each do |conversation|\n reviews = Review.where(conversation_id: conversation)\n if reviews.present?\n reviews.each do |review|\n @review_count += 1\n review_score[:usefulness] += review.usefulness\n review_score[:friendliness] += review.friendliness\n end\n @reviews_present = true\n else\n\n end\n end\n #What should no reviews be\n @userfulness_score = review_score[:usefulness].to_f / @review_count if review_score[:usefulness] != 0\n @friendliness = review_score[:friendliness].to_f / @review_count if review_score[:friendliness] != 0\n end", "def index\n @profiles = Profile.search(params[:term]) & Profile.search(params[:location]) & Profile.search(params[:board])\n\n @reviews = []\n @profiles.each do |profile|\n @average_rating = Review.where(profile_id: profile).average(:rating)\n @reviews << @average_rating\n end\n\n # Sort profiles depending on params\n if params[:sort] == 'Rating'\n @profiles.sort_by! do |profile|\n @reviews[profile.id - 1]\n end\n @profiles = @profiles.reverse\n elsif params[:sort] == 'Price(lowest)'\n @profiles.sort_by! do |profile|\n profile[:price]\n end\n elsif params[:sort] == 'Price(highest)'\n @profiles.sort_by! do |profile|\n profile[:price]\n end\n @profiles = @profiles.reverse\n end\n end", "def topusers\n\t\t@topusers = User.find(:all, :order => \"points DESC\", :limit => \"10\")\n\tend", "def top_ten_users\n # Get top 3 dank ranks total scores\n top_danks = DankRank.order('total_score DESC').limit(6)\n # For each top dank_rank, retrieve [lvl, points, id]\n top_users = top_danks.map { |dank| [User.find(dank.user_id).dank_rank.total_score, User.find(dank.user_id).dank_rank.rank_up_xp_progress, User.find(dank.user_id).id] }\n # Sort that array by level and then points\n top_users.sort!{|a, b| b <=> a}\n # Return the users\n return top_users.map { |array| User.find(array[2]) }\n end", "def user_reviews\n list_of_reviews = self.reviews\n list_of_reviews.map{|review| \"User: #{review.user.name}, Rating: #{review.rating}, Review: #{review.description}\"}\n end", "def show\n @reviews = @general_course.reviews\n @courses = @general_course.courses.order(year: :desc, semester: :asc)\n @highest_rated_review = @reviews.ordered_by_rate_up.first\n @overall_stat = @general_course.as_json.merge! @general_course.get_average\n\n if current_user && current_user.preference\n score_analyzer = ScoreAnalyzer::MatchScore.new(@general_course, current_user.preference.likes_participation, current_user.preference.likes_workload, current_user.preference.likes_testing)\n @score = score_analyzer.match_score\n @indicator = score_analyzer.analyze_score\n end\n end", "def most_similar(u)\n\t\tmSimilar= {}\n\t\treviews_hash.each {|user, moveis|\tmSimilar[user] = similarity(u,user)} #find the similarity with every other user\n\t\tm = mSimilar.sort_by {|a,b| b}.reverse.transpose[0] #sort according to similarities and then choose the first ten (exclude itself)\n\t\treturn m[1..10]\n\tend", "def top\n totals = Workout.find(:first, :select => 'sum(workout_length) as total_mins, count(*) as total_count')\n @total_mins = totals.total_mins\n @total_count = totals.total_count\n @users = Workout.find(:all, \n :select => 'user_profile_id, SUM(workout_length) as workout_length, COUNT(*) as number_workouts', \n :group => 'user_profile_id',\n :order => 'number_workouts desc, workout_length desc',\n :limit => 10)\n end", "def show\n @reviews = Review.where(videogame_id: @videogame.id).order(\"created_at DESC\")\n \n if @reviews.blank?\n @avg_rating = 0\n else\n @avg_rating = @reviews.average(:rating).round(2)\n end\n end", "def bf_sort_point\n point = 0\n\n # recent review worth more points\n self.member_reviews.each do |r|\n point += 10 if r.created_at > 2.weeks.ago\n point += 3 if r.created_at > 6.weeks.ago and r.created_at <= 2.weeks.ago\n point += 1 if r.created_at <= 6.weeks.ago \n end\n\n point\n end", "def recent_reviews\n # 5 most recent reviews of this restaurant\n\n self.reviews.order(:date).limit(5)\n end", "def stats_compare \n if signed_in?\n if linkedin?\n @linkedin_int_connections = @linkedin_auth_user.connections_size\n @linkedin_int_group_memberships = @linkedin_auth_user.group_memberships_size\n @linkedin_int_job_suggestions = @linkedin_auth_user.job_suggestions_size\n @linkedin_int_job_bookmarks = @linkedin_auth_user.job_bookmarks_size\n @linkedin_int_shares = @linkedin_auth_user.shares_size\n else\n @linkedin_int_connections = 0\n @linkedin_int_group_memberships = 0\n @linkedin_int_job_suggestions = 0\n @linkedin_int_job_bookmarks = 0\n @linkedin_int_shares = 0\n end\n @other_linkedin = Authorization.find_by_user_id_and_provider(@user.id, 'linkedin')\n if !@other_linkedin.nil?\n @linkedin_other_user = LinkedinUser.find_by_uid(@other_linkedin.uid)\n if !@linkedin_other_user.nil?\n @linkedin_avg_connections = @linkedin_other_user.connections_size\n @linkedin_avg_group_memberships = @linkedin_other_user.group_memberships_size\n @linkedin_avg_job_suggestions = @linkedin_other_user.job_suggestions_size\n @linkedin_avg_job_bookmarks = @linkedin_other_user.job_bookmarks_size\n @linkedin_avg_shares = @linkedin_other_user.shares_size\n else\n @linkedin_avg_connections = 0\n @linkedin_avg_group_memberships = 0\n @linkedin_avg_job_suggestions = 0\n @linkedin_avg_job_bookmarks = 0\n @linkedin_avg_shares = 0\n end\n else\n @linkedin_avg_connections = 0\n @linkedin_avg_group_memberships = 0\n @linkedin_avg_job_suggestions = 0\n @linkedin_avg_job_bookmarks = 0\n @linkedin_avg_shares = 0\n end\n\n if @linkedin_int_connections.nil?\n @linkedin_int_connections = 0\n end\n if @linkedin_int_group_memberships.nil?\n @linkedin_int_group_memberships = 0\n end\n if @linkedin_int_job_suggestions.nil?\n @linkedin_int_job_suggestions = 0\n end\n if @linkedin_int_job_bookmarks.nil?\n @linkedin_int_job_bookmarks = 0\n end\n if @linkedin_int_shares.nil?\n @linkedin_int_shares = 0\n end\n if @linkedin_avg_connections.nil?\n @linkedin_avg_connections = 0\n end\n if @linkedin_avg_group_memberships.nil?\n @linkedin_avg_group_memberships = 0\n end\n if @linkedin_avg_job_suggestions.nil?\n @linkedin_avg_job_suggestions = 0\n end\n if @linkedin_avg_job_bookmarks.nil?\n @linkedin_avg_job_bookmarks = 0\n end\n if @linkedin_avg_shares.nil?\n @linkedin_avg_shares = 0\n end\n\n if twitter? # is current_user an authorized twitter user with data saved?\n @twitter_int_friends = @twitter_auth_user.friends_int_count\n @twitter_int_followers = @twitter_auth_user.followers_int_count\n @twitter_int_sent = @twitter_auth_user.tweet_int_count\n @twitter_int_favorites = @twitter_auth_user.favorite_int_count\n @twitter_int_lists = @twitter_auth_user.listed_int_count\n @twitter_num_retweets_of_me = @twitter_auth_user.num_retweets_of_me\n @twitter_num_mentions_of_me = @twitter_auth_user.num_mentions_of_me\n @twitter_num_retweets_by_me = @twitter_auth_user.num_retweets_by_me\n else\n @twitter_int_friends = 0\n @twitter_int_followers = 0\n @twitter_int_sent = 0\n @twitter_int_favorites = 0\n @twitter_int_lists = 0\n @twitter_num_retweets_of_me = 0\n @twitter_num_mentions_of_me = 0\n @twitter_num_retweets_by_me = 0\n end\n @other_twitter = Authorization.find_by_user_id_and_provider(@user.id, 'twitter')\n if !@other_twitter.nil?\n @twitter_other_user = TwitterUser.find_by_uid(@other_twitter.uid)\n if !@twitter_other_user.nil?\n @twitter_avg_friends = @twitter_other_user.friends_int_count\n @twitter_avg_followers = @twitter_other_user.followers_int_count\n @twitter_avg_sent = @twitter_other_user.tweet_int_count\n @twitter_avg_fav = @twitter_other_user.favorite_int_count\n @twitter_avg_lists = @twitter_other_user.listed_int_count\n @twitter_avg_retweets_of_me = @twitter_other_user.num_retweets_of_me\n @twitter_avg_mentions_of_me = @twitter_other_user.num_mentions_of_me\n @twitter_avg_retweets_by_me = @twitter_other_user.num_retweets_by_me\n else\n @twitter_avg_friends = 0\n @twitter_avg_followers = 0\n @twitter_avg_sent = 0\n @twitter_avg_fav = 0\n @twitter_avg_lists = 0\n @twitter_avg_retweets_of_me = 0\n @twitter_avg_mentions_of_me = 0\n @twitter_avg_retweets_by_me = 0\n end\n else\n @twitter_avg_friends = 0\n @twitter_avg_followers = 0\n @twitter_avg_sent = 0\n @twitter_avg_fav = 0\n @twitter_avg_lists = 0\n @twitter_avg_retweets_of_me = 0\n @twitter_avg_mentions_of_me = 0\n @twitter_avg_retweets_by_me = 0\n end\n\n if @twitter_int_friends.nil?\n @twitter_int_friends = 0\n end\n if @twitter_int_followers.nil?\n @twitter_int_followers = 0\n end\n if @twitter_int_sent.nil?\n @twitter_int_sent = 0\n end\n if @twitter_int_favorites.nil?\n @twitter_int_favorites = 0\n end\n if @twitter_int_lists.nil?\n @twitter_int_lists = 0\n end\n if @twitter_num_retweets_of_me.nil?\n @twitter_num_retweets_of_me = 0\n end\n if @twitter_num_mentions_of_me.nil?\n @twitter_num_mentions_of_me = 0\n end\n if @twitter_num_retweets_by_me.nil?\n @twitter_num_retweets_by_me = 0\n end\n if @twitter_avg_friends.nil?\n @twitter_avg_friends = 0\n end\n if @twitter_avg_followers.nil?\n @twitter_avg_followers = 0\n end\n if @twitter_avg_sent.nil?\n @twitter_avg_sent = 0\n end\n if @twitter_avg_fav.nil?\n @twitter_avg_fav = 0\n end\n if @twitter_avg_lists.nil?\n @twitter_avg_lists = 0\n end\n if @twitter_avg_retweets_of_me.nil?\n @twitter_avg_retweets_of_me = 0\n end\n if @twitter_avg_mentions_of_me.nil?\n @twitter_avg_mentions_of_me = 0\n end\n if @twitter_avg_retweets_by_me.nil?\n @twitter_avg_retweets_by_me = 0\n end\n \n if facebook? # is current_user an authorized facebook user with data saved?\n @facebook_int_friends = @facebook_auth_user.int_friends\n @facebook_int_likes = @facebook_auth_user.int_likes\n @facebook_int_posts = @facebook_auth_user.int_posts\n @facebook_int_statuses = @facebook_auth_user.int_statuses\n @facebook_int_achievements = @facebook_auth_user.int_achievements\n @facebook_int_subscribers = @facebook_auth_user.int_subscribers\n @facebook_int_subscribed_to = @facebook_auth_user.int_subscribed_to\n else\n @facebook_int_friends = 0\n @facebook_int_likes = 0\n @facebook_int_posts = 0\n @facebook_int_statuses = 0\n @facebook_int_achievements = 0\n @facebook_int_subscribers = 0\n @facebook_int_subscribed_to = 0\n end\n @other_facebook = Authorization.find_by_user_id_and_provider(@user.id, 'facebook')\n if !@other_facebook.nil?\n @facebook_other_user = FacebookUser.find_by_uid(@other_facebook.uid)\n if !@facebook_other_user.nil?\n @facebook_avg_friends = @facebook_other_user.int_friends\n @facebook_avg_likes = @facebook_other_user.int_likes\n @facebook_avg_posts = @facebook_other_user.int_posts\n @facebook_avg_statuses = @facebook_other_user.int_statuses\n @facebook_avg_achievements = @facebook_other_user.int_achievements\n @facebook_avg_subscribers = @facebook_other_user.int_subscribers\n @facebook_avg_subscribed_to = @facebook_other_user.int_subscribed_to\n else\n @facebook_avg_friends = 0\n @facebook_avg_likes = 0\n @facebook_avg_posts = 0\n @facebook_avg_statuses = 0\n @facebook_avg_achievements = 0\n @facebook_avg_subscribers = 0\n @facebook_avg_subscribed_to = 0\n end\n else\n @facebook_avg_friends = 0\n @facebook_avg_likes = 0\n @facebook_avg_posts = 0\n @facebook_avg_statuses = 0\n @facebook_avg_achievements = 0\n @facebook_avg_subscribers = 0\n @facebook_avg_subscribed_to = 0\n end\n\n if @facebook_int_friends.nil?\n @facebook_int_friends = 0\n end\n if @facebook_int_likes.nil?\n @facebook_int_likes = 0\n end\n if @facebook_int_posts.nil?\n @facebook_int_posts = 0\n end\n if @facebook_int_statuses.nil?\n @facebook_int_statuses = 0\n end\n if @facebook_int_achievements.nil?\n @facebook_int_achievements = 0\n end\n if @facebook_int_subscribers.nil?\n @facebook_int_subscribers = 0\n end\n if @facebook_int_subscribed_to.nil?\n @facebook_int_subscribed_to = 0\n end\n if @facebook_avg_friends.nil?\n @facebook_avg_friends = 0\n end\n if @facebook_avg_likes.nil?\n @facebook_avg_likes = 0\n end\n if @facebook_avg_posts.nil?\n @facebook_avg_posts = 0\n end\n if @facebook_avg_statuses.nil?\n @facebook_avg_statuses = 0\n end\n if @facebook_avg_achievements.nil?\n @facebook_avg_achievements = 0\n end\n if @facebook_avg_subscribers.nil?\n @facebook_avg_subscribers = 0\n end\n if @facebook_avg_subscribed_to.nil?\n @facebook_avg_subscribed_to = 0\n end\n \n if instagram?\n @instagram_int_followers = @instagram_auth_user.int_followers\n @instagram_int_following = @instagram_auth_user.int_following\n @instagram_int_media = @instagram_auth_user.int_media\n @instagram_int_likes_out = @instagram_auth_user.int_likes_out\n else\n @instagram_int_followers = 0\n @instagram_int_following = 0\n @instagram_int_media = 0\n @instagram_int_likes_out = 0\n end\n @other_instagram = Authorization.find_by_user_id_and_provider(@user.id, 'instagram')\n if !@other_instagram.nil?\n @instagram_other_user = InstagramUser.find_by_uid(@other_instagram.uid)\n if !@instagram_other_user.nil?\n @instagram_avg_followers = @instagram_other_user.int_followers\n @instagram_avg_following = @instagram_other_user.int_following\n @instagram_avg_media = @instagram_other_user.int_media\n @instagram_avg_likes_out = @instagram_other_user.int_likes_out\n else\n @instagram_avg_followers = 0\n @instagram_avg_following = 0\n @instagram_avg_media = 0\n @instagram_avg_likes_out = 0\n end\n else\n @instagram_avg_followers = 0\n @instagram_avg_following = 0\n @instagram_avg_media = 0\n @instagram_avg_likes_out = 0\n end\n\n if @instagram_int_followers.nil?\n @instagram_int_followers = 0\n end\n if @instagram_int_following.nil?\n @instagram_int_following = 0\n end\n if @instagram_int_media.nil?\n @instagram_int_media = 0\n end\n if @instagram_int_likes_out.nil?\n @instagram_int_likes_out = 0\n end\n if @instagram_avg_followers.nil?\n @instagram_avg_followers = 0\n end\n if @instagram_avg_following.nil?\n @instagram_avg_following = 0\n end\n if @instagram_avg_media.nil?\n @instagram_avg_media = 0\n end\n if @instagram_avg_likes_out.nil?\n @instagram_avg_likes_out = 0\n end\n\n if foursquare?\n @foursquare_friends_count = @foursquare_auth_user.friends_count\n @foursquare_following_count = @foursquare_auth_user.following_count\n @foursquare_checkins_count = @foursquare_auth_user.checkins_count\n @foursquare_badges_count = @foursquare_auth_user.badges_count\n @foursquare_mayor_count = @foursquare_auth_user.mayor_count\n @foursquare_tips_count = @foursquare_auth_user.tips_count\n @foursquare_photos_count = @foursquare_auth_user.photos_count\n else\n @foursquare_friends_count = 0\n @foursquare_following_count = 0\n @foursquare_checkins_count = 0\n @foursquare_badges_count = 0\n @foursquare_mayor_count = 0\n @foursquare_tips_count = 0\n @foursquare_photos_count = 0\n end\n @other_foursquare = Authorization.find_by_user_id_and_provider(@user.id, 'foursquare')\n if !@other_foursquare.nil?\n @foursquare_other_user = FoursquareUser.find_by_uid(@other_foursquare.uid)\n if !@foursquare_other_user.nil?\n @foursquare_avg_friends = @foursquare_other_user.friends_count\n @foursquare_avg_following = @foursquare_other_user.following_count\n @foursquare_avg_checkins = @foursquare_other_user.checkins_count\n @foursquare_avg_badges = @foursquare_other_user.badges_count\n @foursquare_avg_mayors = @foursquare_other_user.mayor_count\n @foursquare_avg_tips = @foursquare_other_user.tips_count\n @foursquare_avg_photos = @foursquare_other_user.photos_count\n else\n @foursquare_avg_friends = 0\n @foursquare_avg_following = 0\n @foursquare_avg_checkins = 0\n @foursquare_avg_badges = 0\n @foursquare_avg_mayors = 0\n @foursquare_avg_tips = 0\n @foursquare_avg_photos = 0\n end\n else\n @foursquare_avg_friends = 0\n @foursquare_avg_following = 0\n @foursquare_avg_checkins = 0\n @foursquare_avg_badges = 0\n @foursquare_avg_mayors = 0\n @foursquare_avg_tips = 0\n @foursquare_avg_photos = 0\n end\n\n if @foursquare_friends_count.nil?\n @foursquare_friends_count = 0\n end\n if @foursquare_following_count.nil?\n @foursquare_following_count = 0\n end\n if @foursquare_checkins_count.nil?\n @foursquare_checkins_count = 0\n end\n if @foursquare_badges_count.nil?\n @foursquare_badges_count = 0\n end\n if @foursquare_mayor_count.nil?\n @foursquare_mayor_count = 0\n end\n if @foursquare_tips_count.nil?\n @foursquare_tips_count = 0\n end\n if @foursquare_photos_count.nil?\n @foursquare_photos_count = 0\n end\n if @foursquare_avg_friends.nil?\n @foursquare_avg_friends = 0\n end\n if @foursquare_avg_following.nil?\n @foursquare_avg_following = 0\n end\n if @foursquare_avg_checkins.nil?\n @foursquare_avg_checkins = 0\n end\n if @foursquare_avg_badges.nil?\n @foursquare_avg_badges = 0\n end\n if @foursquare_avg_mayors.nil?\n @foursquare_avg_mayors = 0\n end\n if @foursquare_avg_tips.nil?\n @foursquare_avg_tips = 0\n end\n if @foursquare_avg_photos.nil?\n @foursquare_avg_photos = 0\n end\n \n if fitbit?\n @fitbit_height_int = @fitbit_auth_user.height_int\n @fitbit_weight_int = @fitbit_auth_user.weight_int\n @fitbit_stride_length_run_int = @fitbit_auth_user.stride_length_run_int\n @fitbit_stride_length_walk_int = @fitbit_auth_user.stride_length_walk_int\n @fitbit_lifetime_tot_active_score_int = @fitbit_auth_user.lifetime_tot_active_score_int\n @fitbit_best_tot_active_score_int = @fitbit_auth_user.best_tot_active_score_int\n @fitbit_lifetime_tot_cal_out_int = @fitbit_auth_user.lifetime_tot_cal_out_int\n @fitbit_best_tot_cal_out_int = @fitbit_auth_user.best_tot_cal_out_int\n @fitbit_lifetime_tot_dist_int = @fitbit_auth_user.lifetime_tot_dist_int\n @fitbit_best_tot_dist_int = @fitbit_auth_user.best_tot_dist_int\n @fitbit_lifetime_tot_steps_int = @fitbit_auth_user.lifetime_tot_steps_int\n @fitbit_best_tot_steps_int = @fitbit_auth_user.best_tot_steps_int\n else\n @fitbit_height_int = 0\n @fitbit_weight_int = 0\n @fitbit_stride_length_run_int = 0\n @fitbit_stride_length_walk_int = 0\n @fitbit_lifetime_tot_active_score_int = 0\n @fitbit_best_tot_active_score_int = 0\n @fitbit_best_tot_active_date = 0\n @fitbit_lifetime_tot_cal_out_int = 0\n @fitbit_best_tot_cal_out_int = 0\n @fitbit_best_tot_cal_out_date = 0\n @fitbit_lifetime_tot_dist_int = 0\n @fitbit_best_tot_dist_int = 0\n @fitbit_best_tot_dist_date = 0\n @fitbit_lifetime_tot_steps_int = 0\n @fitbit_best_tot_steps_int = 0\n @fitbit_best_tot_steps_date = 0\n end\n @other_fitbit = Authorization.find_by_user_id_and_provider(@user.id, 'fitbit')\n if !@other_fitbit.nil?\n @fitbit_other_user = FitbitUser.find_by_encoded_id(@other_fitbit.uid)\n if !@fitbit_other_user.nil?\n @fitbit_avg_height = @fitbit_other_user.height_int\n @fitbit_avg_weight = @fitbit_other_user.weight_int\n @fitbit_avg_length_run = @fitbit_other_user.stride_length_run_int\n @fitbit_avg_length_walk = @fitbit_other_user.stride_length_walk_int\n @fitbit_avg_life_active_score = @fitbit_other_user.lifetime_tot_active_score_int\n @fitbit_avg_best_active_score = @fitbit_other_user.best_tot_active_score_int\n @fitbit_avg_life_cal_out = @fitbit_other_user.lifetime_tot_cal_out_int\n @fitbit_avg_best_cal_out = @fitbit_other_user.best_tot_cal_out_int\n @fitbit_avg_life_tot_dist = @fitbit_other_user.lifetime_tot_dist_int\n @fitbit_avg_best_dist = @fitbit_other_user.best_tot_dist_int\n @fitbit_avg_life_tot_steps = @fitbit_other_user.lifetime_tot_steps_int\n @fitbit_avg_best_tot_steps = @fitbit_other_user.best_tot_steps_int\n else\n @fitbit_avg_height = 0\n @fitbit_avg_weight = 0\n @fitbit_avg_length_run = 0\n @fitbit_avg_length_walk = 0\n @fitbit_avg_life_active_score = 0\n @fitbit_avg_best_active_score = 0\n @fitbit_avg_life_cal_out = 0\n @fitbit_avg_best_cal_out = 0\n @fitbit_avg_life_tot_dist = 0\n @fitbit_avg_best_dist = 0\n @fitbit_avg_life_tot_steps = 0\n @fitbit_avg_best_tot_steps = 0\n end\n else\n @fitbit_avg_height = 0\n @fitbit_avg_weight = 0\n @fitbit_avg_length_run = 0\n @fitbit_avg_length_walk = 0\n @fitbit_avg_life_active_score = 0\n @fitbit_avg_best_active_score = 0\n @fitbit_avg_life_cal_out = 0\n @fitbit_avg_best_cal_out = 0\n @fitbit_avg_life_tot_dist = 0\n @fitbit_avg_best_dist = 0\n @fitbit_avg_life_tot_steps = 0\n @fitbit_avg_best_tot_steps = 0\n end\n\n if @fitbit_height_int.nil?\n @fitbit_height_int = 0\n end\n if @fitbit_weight_int.nil?\n @fitbit_weight_int = 0\n end\n if @fitbit_stride_length_run_int.nil?\n @fitbit_stride_length_run_int = 0\n end\n if @fitbit_stride_length_walk_int.nil?\n @fitbit_stride_length_walk_int = 0\n end\n if @fitbit_avg_height.nil?\n @fitbit_avg_height = 0\n end\n if @fitbit_avg_weight.nil?\n @fitbit_avg_weight = 0\n end\n if @fitbit_avg_length_run.nil?\n @fitbit_avg_length_run = 0\n end\n if @fitbit_avg_length_walk.nil?\n @fitbit_avg_length_walk = 0\n end\n end\n end", "def get_review_ratings\n ratings = {\n prof: 0,\n enjoy: 0,\n difficulty: 0,\n recommend: 0\n }\n\n @reviews.each do |r|\n ratings[:prof] += r.professor_rating\n ratings[:enjoy] += r.enjoyability\n ratings[:difficulty] += r.difficulty\n ratings[:recommend] += r.recommend\n end\n\n ratings[:overall] = (ratings[:prof] + ratings[:enjoy] + ratings[:recommend]) / 3\n\n num_reviews = @reviews.length\n\n ratings.each_with_object({}) { |(k, v), h|\n h[k] = (v / num_reviews).round(2)\n }\n end", "def popularity(movie_id)\n movie_id = movie_id.to_s\n @num_reviewers = @movie_database[movie_id].length.to_f\n @score_time = 0.0\n @temp_rating = 0.0\n \n @weight_users = 0.25\n @weight_rating = 0.25\n @weight_time = 0.50\n \n @movie_database[movie_id].each do |user, rating, time|\n #divided by 2 bil so that \"tim\" in UNIX seconds is less than 1\n @score_time += (time.to_f / 2000000000.0)\n @temp_rating += rating.to_f\n end\n \n @score_rating = (@temp_rating / @num_reviewers) * 20.0\n @score_time = (@score_time / @num_reviewers) * 100\n @score_reviewers = (@num_reviewers / @total_users) * 100.0\n \n @final_score = ( @weight_users * @score_reviewers + @weight_rating * @score_rating + @weight_time * @score_time)\n \n return @final_score \n end", "def index\n @most_played_artist = Song.most_played_artist\n @most_played_by_artist = Song.find_most_played_by_artist :limit => 3\n\n @most_played_players = User.find_players_of_artist(@most_played_artist, :limit => 4)\n\n @most_played_tags = Tag.find_top(:limit => 3, :conditions => {\n :taggable_type => 'song', :taggable_id => @most_played_by_artist.map(&:id)})\n\n @coolest_users = User.find_coolest :limit => 4\n @max_votes = @coolest_users.map(&:rating_count).max\n end", "def show\n @user = User.find(params[:id])\n @num_posts = @user.get_number_of_posts\n @num_comments = @user.get_number_of_comments\n @posts = Post.where(:user_id => @user.id)\n @avg_rcvd_comments_per_post = 0.0\n @posts.each do |post|\n @avg_rcvd_comments_per_post += post.comments.count\n end\n @avg_rcvd_comments_per_post /= @posts.count\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @user }\n end\n end", "def highest_bill\n \t@user = Review.order(totalbill: :desc).first(5)\n end", "def calculate_team_ratings(roster)\n ratings = Array.new\n roster.each do|player|\n if (player && player.profile && player.profile.rating)\n ratings.push(player.profile.rating.total)\n end\n end\n \n top_ratings = ratings.sort.reverse.take(10)\n top_ratings.sum\n end", "def recent_reviews\n\t\tself.reviews_as_reviewee.sort_by{|review| review.created_at}.reverse[0..4]\n\tend", "def most_commented\n @movies = Movie.joins(:comment).\n select('movie.movie_id, movie.title, count(movie.movie_id) as count').\n group('movie.movie_id').\n order('count DESC').take(10)\n end", "def show\n @users = User.without_admin\n # if current_user.is_admin\n # @users = User.all\n # elsif current_user.teams.first.team_lead\n # @users = User.joins(:employee_teams).where(\"employee_teams.team_id = ? \", current_user.teams.first.id)\n # end\n @team_reviews = UserReview.where(team_id: @team.id)\n @non_bonus_team_reviews = @team_reviews.joins(:review_item).where('review_items.is_weekly = false OR review_items.is_monthly_bonus = false')\n @team_reviews_pending = @team_reviews.where(rate_period: (Date.today -1.month).end_of_month, is_team: true)\n @user_reviews_pending = @team_reviews.where(rate_period: (Date.today -1.month).end_of_month, is_team: false)\n @rate_periods = UserReview.all.pluck(:rate_period).uniq.sort.map{ |x| x.strftime(\"%B %Y\") }\n @team_list = Team.unhidden.where(id: UserReview.joins(user: { employee_teams: :team }).pluck(:team_id).uniq)\n\n end", "def top_5_teams\n team_names = []\n teams = UserTeam.all.collect{|team| team.team_id}\n most_common_value = teams.uniq.sort_by{ |i| teams.count( i ) }.reverse[0..4]\n most_common_value.each do |team|\n team_names << get_team_name_by_id(Team.find(team).api_team_id)\n end\n team_names\nend", "def get_most_comments_made(num_users = 5)\n get_most_generic_for_users(DOCS[:most_comments_made], num_users)\n end", "def top_3_comments\n comments.order(rating: :desc).limit(3)\n end", "def analyze_most_prolific(user)\n\n # calculate score\n prolific_score = 1\n prolific_score *= (val = user.num_radlibs_created) > 0 ? val : 1 # loads value from db *once*, then compares, and uses 1 instead of 0\n prolific_score *= (val = user.num_radlibs_filled_by_me) > 0 ? val : 1\n prolific_score *= (val = user.num_comments_made) > 0 ? val : 1\n\n # scale it down to avoid too big a number, using 10000.1 (with decimal ensures that we extend the value's significant digits)\n prolific_score /= 100.1\n\n analyze_most_generic(user.uid, prolific_score.to_f, DOCS[:most_prolific])\n self\n end", "def past_popular\n if @page == 1 && @user.last_sign_out_at.present? && @user.last_sign_out_at <= 2.days.ago && @user.current_sign_in_at >= 1.minutes.ago\n popular_in(@user.last_sign_out_at, @user.last_sign_in_at).limit(6).includes(:hash_tags, :user, :owner).to_a\n else\n []\n end\n end", "def score_of_review_comments\n votes = 0\n self.reviews.each do |review|\n review.comments.each { |comment| votes += comment.vote_count }\n end\n votes\n end", "def highest_review \n\t\tself.reviews.sort_by{ |review| review.rating }.reverse.first\n\tend", "def top_users_locations_sql\n \"SELECT U.name AS name, COUNT(DISTINCT F.location_id) AS num_locations FROM Users U, Followings F WHERE U.id = F.user_id AND F.location_id IN (SELECT P.location_id FROM Posts P JOIN Locations L GROUP BY P.location_id HAVING COUNT(P.id) >= 2) GROUP BY F.user_id ORDER BY num_locations DESC LIMIT 5\"\n end", "def top_three_recipes\n self.find_user_recipe_cards.sort_by{|rcard| rcard.rating}.reverse![0..2]\n end", "def statistics\n # sort the product by brand then label\n product_brands = @current_knowledge.products.collect do |p|\n b = p.get_value(\"brand\")\n b = b.first if b\n b ||= \"\"\n [p, b] \n end\n product_brands.sort! do |pb1, pb2|\n x = (pb1.last <=> pb2.last)\n x == 0 ? pb1.first.label <=> pb2.first.label : x\n end\n @products = product_brands.collect(&:first)\n @hash_product_opinions = Opinion.all().inject({}) do |h, opinion|\n opinion.product_ids.each do |opinion_product_id|\n (h[opinion_product_id] ||= []) << opinion\n end\n h\n end\n\n @hash_product_reviews = Review.all(:knowledge_id => @current_knowledge.id).inject({}) do |h, r|\n r.product_ids.each { |pid| ((h[pid] ||= {})[r.category] ||= []) << r }\n h\n end\n \n @opinions_classes = [Rating, Tip, Ranking, Comparator, Neutral]\n @review_categories = [\"amazon\", \"expert\"]\n\n @overall_dimension_id = @current_knowledge.dimension_root.id\n end", "def average_reviews \n zmienna = self.reviews.sum(\"vote\") \n zmienna2 = self.reviews.count\n if zmienna2 == 0\n wynik = 0\n else \n wynik = zmienna/zmienna2\n end \n end", "def index\n @reviews = Review.includes(:user).limit(5)\n end", "def highest_review \n\t\tself.reviews.sort_by{|review| review.rating }.reverse.first\n\tend", "def calculate_stats\n # this one gets the anaylyzer\n analyzer_w_most_repeated_word = @analyzers.max_by { |analyzer| analyzer.highest_wf_count }\n #this one gets its highest word count\n @highest_count_across_lines = analyzer_w_most_repeated_word.highest_wf_count\n\n # this one gets all lines that match that highest word count - it will be an array of objects\n # containing one or more objects\n @highest_count_words_across_lines = @analyzers.select { |e| e.highest_wf_count == @highest_count_across_lines }\n\n # return a hash with some useful info\n { top_line: analyzer_w_most_repeated_word, repeat_word_count: @highest_count_across_lines,\n top_line_and_ties: @highest_count_words_across_lines }\n end", "def fetch_popular\n self.with_purchase_rate\n .viewed_by_people\n .reverse_order(:purchase_rate, :purchases_count)\n end", "def index\n \t@user = current_user\n \t@users = User.all\n \t@thisUser = User.find(@user)\n \t@invites = Invite.where(:user_id => @user).paginate(:page => params[:page], :per_page => 10).order('created_at DESC')\n \t@thisBiz = User.joins(:invite).where(:user_id => current_user.id)\n \t@feedbacks = PoorReview.where(:user_id => current_user.id).paginate(:page => params[:page], :per_page => 5).order('created_at DESC')\n\t\t@count = @feedbacks.count\n end", "def calculate_favorite_tweeter\n # Count each fav as 1 point\n scores = Hash[most_faved]\n scores.default = 0\n\n # Count each RT as 1.5 points\n most_retweeted.each { |screen_name, rts| scores[screen_name] += (rts * 1.5) }\n\n winning_screen_name, winning_score = scores.max_by { |_, score| score }\n\n {\n :screen_name => winning_screen_name,\n :favs_count => Hash[most_faved][winning_screen_name],\n :retweets_count => Hash[most_retweeted][winning_screen_name],\n :score => winning_score\n }\n end", "def get_most_radlibs_created(num_users = 5)\n get_most_generic_for_users(DOCS[:most_prolific], num_users)\n end", "def get_reviews(reviews)\n all_revs = reviews.map do |r|\n {\n status: r.state,\n reviewer: r.author.login,\n date: get_yyyymmdd_hhnnss(r.updated_at),\n age: age(r.updated_at)\n }\n end\n revs_by_person = all_revs.group_by { |r| r[:reviewer] }.values\n latest_revs = revs_by_person.map do |persons_reviews|\n persons_reviews.sort { |a, b| a[:date] <=> b[:date] }[-1]\n end\n \n # if (latest_revs.size() != all_revs.size) then\n # puts '------- CONDENSING to latest -------'\n # puts \"ALL:\\n#{all_revs}\"\n # puts \"LATEST:\\n#{latest_revs}\"\n # end\n \n latest_revs\n end", "def index\n @user_reviews = UserReview.all.order(:rate_period).page(params[:page])\n end", "def analyze_most_popular_radlibs(radlib)\n # calculate score\n most_popular = 1\n most_popular *= (val = radlib.num_likes) > 0 ? val : 1\n most_popular *= (val = radlib.num_fillins) > 0 ? val : 1\n most_popular *= (val = radlib.num_views) > 0 ? val : 1\n\n # scale it down to avoid too big a number, using 10000.1 (with decimal ensures that we extend the value's significant digits)\n most_popular /= 100.1\n\n analyze_most_generic(radlib.radlib_id, most_popular.to_f, DOCS[:most_popular_radlibs])\n self\n end", "def most_popular_show\n Show.highest_rating\nend", "def top_5_leagues\n league_names = []\n leagues = UserLeague.all.collect{|league| league.league_id}\n most_common_value = leagues.uniq.sort_by{ |i| leagues.count( i ) }.reverse[0..4]\n most_common_value.each do |league|\n league_names << get_league_name_by_id(League.find(league).api_league_id)\n end\n league_names\nend", "def twitter_user_data\n\t\t# IT WOULD BE NICE TO RE-FACTOR THIS SO IT IS THE SAME current_user as for other stats display...\n\t\t@twitter_graph = Authorization.where(\"user_id = ?\", current_user).where(\"provider = ?\", \"twitter\")\n\t\t@twitter_graph_user = TwitterUser.where(\"uid = ?\", @twitter_graph.first['uid'])\n\t\tdata_by_day = @twitter_graph_user.total_grouped_by_date(2.weeks.ago)\n\t\t#twitter_index_by_day = IvolveIndex.twitter_grouped_by_day(2.weeks.ago)\n\t\t(2.weeks.ago.to_date..Time.zone.today).map do |date|\n\t\t\tif !data_by_day[date].nil?\n\t\t\t\tcreated_at = date\n\t\t\t\tfriends_count = data_by_day[date].first.try(:friends_int_count)\n\t\t\t\tfollowers_count = data_by_day[date].first.try(:followers_int_count)\n\t\t\t\ttweets_count = data_by_day[date].first.try(:tweet_int_count)\n\t\t\t\tfavd_count = data_by_day[date].first.try(:favorite_int_count)\n\t\t\t\tlist_count = data_by_day[date].first.try(:listed_int_count)\n\t\t\telse\n\t\t\t\tcreated_at = date\n\t\t\t\tfriends_count = 0\n\t\t\t\tfollowers_count = 0\n\t\t\t\ttweets_count = 0\n\t\t\t\tfavd_count = 0\n\t\t\t\tlist_count = 0\n\t\t\tend\n\n\t\t\t{\n\t\t\t\tcreated_at: date,\n\t\t\t\tnum_friends: friends_count,\n\t\t\t\t#index_friends: twitter_index_friends,\n\t\t\t\tnum_followers: followers_count,\n\t\t\t\t#index_followers: twitter_index_followers,\n\t\t\t\ttweets_sent: tweets_count,\n\t\t\t\t#index_sent: twitter_index_sent,\n\t\t\t\ttweets_favd: favd_count,\n\t\t\t\t#index_favd: twitter_index_favd,\n\t\t\t\tnum_lists: list_count,\n\t\t\t\t#index_lists: twitter_index_lists,\n\t\t\t}\n\t\tend\n\tend", "def getAvgUserNumberRating(u)\n @count = 0\n @allR = getUserReviews(u)\n @allR.each do |r|\n @count += r.rating\n end\n return (@allR.count == 0) ? \"None\" : @count/@allR.count \n end", "def top_users_locations_sql\n \"SELECT users.name AS name, COUNT(DISTINCT locations.id) AS num_locations\n FROM users, locations, posts, locations_users lu\n WHERE users.id = lu.user_id AND lu.location_id = locations.id AND posts.location_id = locations.id\n GROUP BY users.id\n HAVING COUNT(DISTINCT posts.id)>2\n ORDER BY COUNT(DISTINCT locations.id) DESC\n LIMIT 5\"\n end", "def calculate_average_ratings\n total_reviews = self.reviews.count\n\n quality_total = 0\n study_total = 0\n laptop_total = 0\n hipster_total = 0\n\n self.reviews.each { |review| quality_total += review.qualityRating }\n self.reviews.each { |review| study_total += review.studyRating }\n self.reviews.each { |review| laptop_total += review.laptopRating }\n self.reviews.each { |review| hipster_total += review.hipsterRating }\n\n if total_reviews > 0\n self.average_hipster = hipster_total / total_reviews\n self.average_study = study_total / total_reviews\n self.average_laptop = laptop_total / total_reviews\n self.average_quality = quality_total / total_reviews\n self.overall_average = (average_hipster + average_study + average_laptop + average_quality)/4\n end\n self.save\n end", "def count_getted_like\n user = User.find_by id: self.id\n reviews = user.reviews\n total = 0\n reviews.each do |review|\n total += review.count_like\n end\n return total\n end", "def average_stats\n Review.find_by_sql([\"\n SELECT \n ROUND((AVG(rv.rating)::numeric),1) as total_rating,\n ROUND((AVG(rv.coffee_rating)::numeric),1) as total_coffee,\n ROUND((AVG(rv.food)::numeric),1) as total_food,\n ROUND((AVG(rv.noise_level)::numeric),1) as total_noise_level,\n ROUND((AVG(rv.work_friendly)::numeric),1) as total_work_friendly,\n COUNT(rv.rating) as total_reviews_count\n FROM reviews AS rv\n WHERE rv.coffee_shop_id = ?\n \", id]).first\n end", "def show\n if @game.reviews.blank?\n @average_review = 0\n else\n @average_review = @game.reviews.average(:rating).round(2)\n end\n end", "def profile\n \n if organization_account_signed_in?\n @organization_account = current_organization_account\n @organization = Organization.find(@organization_account.organization_id)\n @overall = 0\n @reviews = Review.where(:organization_id => @organization.id)\n if !(@reviews.count == 0)\n @reviews.each do |f|\n @overall = @overall + f.overall\n end\n @overall = @overall / @reviews.count\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization_account }\n end\n else\n redirect_to root_path\n end\n end", "def find_frequently_reviewed_restaurants(topic, reviewer)\n restaurants = reviewer.subscribed_restaurants.by_topic(topic.id)\n frequency_with_restaurants = {}\n restaurants.each do |restaurant|\n frequency_with_restaurants[restaurant] ||= 0\n frequency_with_restaurants[restaurant] += 1\n end\n\n sorted = frequency_with_restaurants.sort{|v1, v2| v2.last <=> v1.last}\n\n # Take top 5 restaurants\n sorted[0..5]\n end", "def profile\n @user = current_user\n @user_profile = true\n @group_invite_count = GroupInvite.where(inviter: @user).count\n @group_invite_accpeted_count = GroupInvite.where(inviter: @user).where.not(accepted_at: nil).count\n @event_count = Event.where(user: @user).count\n @event_invites_count = EventInvite.where(inviter: current_user).count\n @event_invite_accpeted_count = EventInvite.where(inviter: @user).where.not(accepted_at: nil).count\n @joined_around_me_event_count = @user.joined_events.count\n @message_count = Message.where(user: @user).count\n @feed_count = FeedingHistory.where(user: current_user).count\n end", "def review_count\n reviews.count\n end", "def show\n @movie = Movie.includes(\n :cover_photo, :created_by, movie_roles: [:actor], feedback: [:user]\n ).left_outer_joins(:ratings).select(\n 'movies.*, CAST(AVG(ratings.value) AS DECIMAL(10,2)) AS rating'\n ).find params[:id]\n @reviews = @movie.feedback.select { |item| item.type == 'Review' }\n @comments = @movie.feedback.select { |item| item.type == 'Comment' }\n comment_ids = @comments.map(&:id)\n @number_of_likes_on_comments = Comment.where_by_ids(comment_ids).calculate_number_of_likes\n @directors = @movie.movie_roles.select { |role| role.role_played == 'director' }\n @actors = @movie.movie_roles.select { |role| role.role_played == 'actor' }\n if current_user\n @liked_by_current_user = !(Like.movie_liked_by_current_user(params[:id],current_user.id).empty?)\n end\n end", "def driver_stats (driver, trip)\n\ttotal_money = 0 # Variable to track each driver's total earnings.\n\ttotal_ratings = 0 # Variable to track each driver's ratings.\n\n\thighest_date = ''\n\thighest_earning = 0\n\n\ttrip.each do |hash|\n\t\t# Find the total amount of money earned for each driver.\n\t\ttotal_money += hash[:cost]\n\t\n\t\t# Find the average rating for each driver.\n\t\ttotal_ratings += hash[:rating]\n\n\t\t# Find the date the driver made the most money.\n\t\tif hash[:date] == highest_date\n\t\t\thighest_earning += hash[:cost]\n\t\telsif hash[:date] != highest_date && hash[:cost] > highest_earning\n\t\t\thighest_date = hash[:date]\n\t\t\thighest_earning = hash[:cost]\n\t\tend\n\tend\n\n\t# Find the driver who earned the most.\n\tif total_money > $highest_total\n\t\t$richest_driver = driver.to_s\n\t\t$highest_total = total_money\n\tend\n\n\t# Calculate the average rating for each driver.\n\tavg_rating = total_ratings.to_f / trip.length\n\n\t# Find the driver with the highest average rating.\n\tif avg_rating > $highest_rating \n\t\t$highest_rating = avg_rating\n\t\t$best_driver = driver.to_s\n\tend\n\n\t# Prints individual stats for each driver.\n\tputs \"STATS FOR #{ driver.to_s }:\"\n\tputs \"Completed #{ trip.length } trip(s).\"\n\tputs \"Earned $#{ total_money }.\"\n\tputs \"Maintained an average rating of #{ avg_rating.round(1) }.\"\n\tputs \"#{ driver.to_s } earned the most money on #{ highest_date } at $#{ highest_earning }.\"\nend", "def show\n @fullwidth = true\n if @user.is_artist\n @artist = @user\n if user_signed_in?\n @review = Review.find_by(receiving_user_id: @artist.id, leaving_user_id: current_user.id)\n @review.nil? ? @review = Review.new : @review\n end\n @reviews = @artist.received_reviews.page(params[:page]).order('updated_at DESC').per(25)\n @artist.view_count.present? ? @artist.view_count += 1 : @artist.view_count = 0\n @artist.save\n else\n @reviews = @user.left_reviews.page(params[:page]).order('updated_at DESC').per(25)\n end\n if params[:review].present?\n top_review = Review.find(params[:review])\n if params[:response_link].present?\n render 'show', locals: {top_review: top_review, response_link: true}\n else\n render 'show', locals: {top_review: top_review}\n end\n else\n respond_to do |format|\n format.html { render 'show' }\n format.js { render action: 'paginate_reviews' }\n end\n end\n end", "def top_three_recipes\n top_three = RecipeCard.all.select {|atr| atr.user == self}\n top_three.sort_by {|atr| atr.rating}.reverse\n top_three[0..2]\n end", "def top_users_posts_sql\n \"SELECT name AS name, COUNT(posts.id) AS num_posts\n FROM users, posts\n WHERE users.id = user_id\n GROUP BY users.id\n ORDER BY COUNT(posts.id) DESC\n LIMIT 5\"\n end", "def show\n @reviews = @album.reviews.order(\"created_at DESC\")\n unless @reviews.present?\n @avg_review = 0\n else\n @avg_review = @reviews.average(:rating).present? ? @reviews.average(:rating).round(2) : 0\n end\n end", "def analyze_most_radlibs_created(user)\n analyze_most_generic(user.uid, user.num_radlibs_created.to_i, DOCS[:most_radlibs])\n self\n end", "def most_liked_comments\n Comment\n .preload(:likes)\n .joins(:likes)\n .group('comments.id')\n .order(Arel.sql('count(likes.id) desc'))\n .limit(10)\n end", "def top_buyer\n all_sales = Sale.count\n user = User.left_joins(:sales).group('users.id').order('COUNT(sales.id) DESC').first\n\n {\n user: UserSerializer.new(user),\n all_sales: all_sales,\n user_sales: user.sales.count,\n percentage: (user.sales.count * 100) / all_sales,\n }\n end", "def most_test_cases\n @most = User.most_test_cases\n end", "def recentreview\n return 'No reviews yet!' if self.reviews.length == 0\n self.reviews.reverse.each {|review| return review.body if review.rating >= 4}\n self.reviews.reverse.each {|review| return review.body if review.rating >= 3}\n self.reviews.reverse.each {|review| return review.body if review.rating >= 2}\n self.reviews.reverse.each {|review| return review.body if review.rating >= 1}\n end", "def user_average_rating(user)\n #av = promedio (avarage), counter = contador(para calcular el total de reviews realizada)\n av, counter = 0.0, 0.0\n \n Review.where(user_id: user.id).each_with_index do |review, i|\n if review.rating\n av = av + review.rating\n counter = counter + 1.0\n end\n end\n\n av / counter\n end", "def ratings\n if self.reviews.any?\n avg_rating = 0\n self.reviews.each do |review|\n avg_rating += review.rating\n end\n avg_rating = (avg_rating/self.reviews.length).ceil\n return avg_rating\n end\n end", "def top_users_posts_sql\n \"SELECT U.name AS name, COUNT(P.id) AS num_posts FROM Users U, Posts P WHERE U.id = P.user_id GROUP BY U.id, name ORDER BY num_posts DESC LIMIT 5\"\n end", "def analyze_most_prolific_likers(user)\n user = User.new\n analyze_most_generic(user.uid, user.num_likes_made.to_i, DOCS[:most_prolific_likers])\n self\n end", "def police \n if params[:sort_by] == \"score\"\n @reviews = @city.department_reviews.police.sort_by { |dr| dr.score }\n @reviews.reverse!\n render action: :index\n elsif params[:sort_by] == \"date\"\n @reviews = @city.department_reviews.police.order('created_at DESC')\n render action: :index\n elsif params[:sort_by] == \"endorsements\"\n @reviews = @city.department_reviews.police.sort_by { |dr| dr.votes_for.size }\n @reviews.reverse!\n render action: :index\n elsif params[:sort_by] == \"comments\"\n @reviews = @city.department_reviews.police.sort_by { |dr| dr.count_comments }\n @reviews.reverse!\n render action: :index\n elsif params[:sort_by] == \"trending\"\n @reviews = @city.department_reviews.police.sort_by { |dr| dr.hits }\n @reviews.reverse!\n render action: :index\n else \n @reviews = @city.department_reviews.police.sort_by { |dr| dr.hits }\n @reviews.reverse!\n render action: :index\n end \n end", "def average_review_rating\n self.reviews.all.average(:rating)\n end", "def get_best_users(n,factor = 1)\n\t return recommand(:get_best_users,:get_best_tags,n,factor){\n\t\t self.friends.collect{|f|\t\t\n\t\t\t# See comments about frienships relations to more information about f structure\n\t\t\t [f[:friend],f[:friend].screen_name,f[:weight]*factor]\n\t\t }\n\t\t}\t\n\tend", "def highest_averages\n @averages = Matchup.joins(:cornbowler).\n select(\"cornbowlers.name AS cornbowler_name, COUNT(*) AS count, AVG(matchups.final_score) AS average_score\").\n where(\"final_score IS NOT NULL\").\n group(\"cornbowler_name\").\n order(\"average_score DESC, cornbowler_name ASC\").\n limit(25)\n @averages_with_rank = object_hash_with_rank(@averages, :average_score)\n\n respond_to do |format|\n format.html # highest_averages.html.erb\n format.json { render json: @averages }\n end\n end" ]
[ "0.703726", "0.70285344", "0.69861525", "0.67632675", "0.6682334", "0.653646", "0.65061045", "0.6502863", "0.6465595", "0.6440021", "0.64062035", "0.6382894", "0.6349223", "0.6342745", "0.63236666", "0.6306002", "0.6296857", "0.6264244", "0.6259934", "0.62400794", "0.6237936", "0.62194663", "0.6214871", "0.6209241", "0.61947984", "0.6152755", "0.61444974", "0.61123", "0.6111178", "0.60740435", "0.6065684", "0.6059761", "0.6034836", "0.6015337", "0.60107124", "0.598675", "0.5985833", "0.5982348", "0.5981363", "0.59723693", "0.59509623", "0.59458154", "0.592126", "0.5915472", "0.5882702", "0.5868072", "0.5859357", "0.5851682", "0.5839004", "0.5831775", "0.5828598", "0.5818265", "0.5818119", "0.580919", "0.5785366", "0.57740957", "0.57730126", "0.57702065", "0.5769782", "0.57687676", "0.57654774", "0.5765457", "0.5763654", "0.5763504", "0.57581186", "0.57417786", "0.57417035", "0.57408005", "0.5726651", "0.5725079", "0.5724489", "0.5721859", "0.57180727", "0.5712917", "0.5711444", "0.57009387", "0.5697953", "0.56971246", "0.5696193", "0.5692472", "0.56862694", "0.5679687", "0.567744", "0.5673962", "0.56704426", "0.5666011", "0.56615114", "0.5656689", "0.564567", "0.5637276", "0.56353563", "0.5632002", "0.5627854", "0.56217736", "0.5620817", "0.5616521", "0.56162745", "0.5614215", "0.5601022", "0.55985236", "0.5597576" ]
0.0
-1
GET /projects GET /projects.json
def index @projects = current_user.projects end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def listprojects\n get('listprojects.json')['projects']\n end", "def list\n get 'projects'\n end", "def projects\n request(method: 'getAllProjects')\n end", "def projects\n resource 'projects'\n end", "def projects(params = {})\n make_get_request('/account/projects', params)\n end", "def projects\n Sifter.\n get(\"/api/projects\").\n parsed_response[\"projects\"].\n map { |p| Sifter::Project.new(p) }\n end", "def index\n @projects = Project.all\n render json: @projects\n end", "def index\n # @projects = @current_user.projects\n @projects = Project.all\n json_response(@projects)\n end", "def index\n @projects = Project.all\n render json: @projects, status: :ok\n end", "def get_projects\n me = request('/services/v5/me')\n me['projects']\n end", "def index\n @projects = current_user.projects\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def get\n CircleCi.request(conf, '/projects').get\n end", "def projects\n return forbidden unless current_account # already returns a 401 if credentials aren't supplied\n opts = { :include_document_ids => params[:include_document_ids] != 'false' }\n @response = {'projects' => Project.accessible(current_account).map {|p| p.canonical(opts) } }\n render_cross_origin_json\n end", "def projects\n records \"project\", \"/project/list\"\n end", "def index\n @projects = current_user.projects.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n render json: @projects, layout: false\n end", "def projects(params = {})\n fetch_all('projects', 'projects', params)\n end", "def index\n @projects = Project.all_for_user(current_user.id)\n render json: @projects.to_json(include: :project_detail), status: 200\n end", "def index\n @projects = Project.visible\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @user = User.find_by(id: params[:user_id])\n @project = @user.projects\n if @project \n render :json => @project\n else\n render :json => 422\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @projects }\n end\n end", "def all_projects()\n @endpoint = \"/projects.json?limit=100\"\n setup_get\n res = @http.request(@req)\n return JSON.load(res.body)[\"projects\"].sort_by { |proj| proj[\"name\"] }\n end", "def index\n \n @workspaces = current_user.workspaces\n # debugger\n @projects = Project.where(:workspace_id => @workspace)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def projects(options = {})\n get(\"projects\", options).projects\n end", "def list_projects\n handle_action_exceptions(__method__) do\n cmd_line = ['listprojects']\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end", "def index\n @projects = Project.includes(:user).all\n respond_with(@projects) do |format|\n format.json { render :json => {:list => @projects.as_json, :current_user => current_user.as_json} }\n format.html\n end\n end", "def projects(req_params = {})\n name = 'Projects'\n params = { req: req_params }\n\n data = endpoint(name: name, params: params).do_get\n\n collection name, data\n end", "def index \n\n @projects = Project.all\n respond_to do |format|\n format.html {render :template => \"projects/index\"}\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.with_permissions_to(:read)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def projects\n @projects ||= Harvest::API::Projects.new(credentials)\n end", "def show\n @project = @client.projects.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def index\n @projects = Project.where user: current_user\n render json: @projects, each_serializer: Projects::IndexSerializer\n end", "def index\n @projects = Project.order_by_company_and_project.paginate(page: params[:page] || 1, per_page: helpers.pager_per_page)\n respond_to do |format|\n message = @projects.present? ? \"\" : \"There are no projects available at this time\"\n format.json do\n status = @projects.present? ? :ok : :not_found\n render json: { response: @projects, status: status, message: message }\n end\n format.html do\n # Only authorize html format, json is okay because we use it as\n # an api.\n authorize(:project)\n flash[:alert] = message unless message.blank?\n @projects\n end\n end\n end", "def index\n if signed_in?\n @projects = current_user.projects\n respond_to do |format|\n format.html { render 'projects/index' }\n format.json { render template: 'projects/index.json.jbuilder' }\n end\n else\n redirect_to :projects\n end\n end", "def get_projects_of_user\n respond_to do |format|\n format.json {\n #param = params[:payload]\n #@user = User.find_by_id(param[:id])\n @projects = Project.where(:user_id => @current_user.id)\n if @projects\n render :json => @projects\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end", "def get_projects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectsApi.get_projects ...'\n end\n # resource path\n local_var_path = '/projects'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Token']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Projects')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectsApi#get_projects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show_all_projects\r\n json = GoodData.get GoodData.profile.projects\r\n puts \"You have this project available:\"\r\n json[\"projects\"].map do |project|\r\n pid = project[\"project\"][\"links\"][\"roles\"].to_s\r\n puts \"Project name: #{project[\"project\"][\"meta\"][\"title\"].bright} Project PID: #{pid.match(\"[^\\/]{32}\").to_s.bright}\"\r\n end\r\n end", "def init_projects\n @projects = []\n\n response = @conn.get do |req|\n req.url \"/api/v1/projects\"\n req.headers = rest_headers\n end\n\n @projects = json(response.body)[:projects]\n end", "def projects\n @projects ||= begin\n http = Net::HTTP.new(API_HOST, API_PORT)\n http.use_ssl = true\n http.ca_file = (Twigg.root + 'files' + 'github.pem').to_s\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n uri = ORG_REPOS_ENDPOINT % Config.github.organization\n headers = { 'Authorization' => \"token #{Config.github.token}\" }\n\n [].tap do |names|\n begin # loop: page through project list\n request = Net::HTTP::Get.new(uri, headers)\n response = http.request(request)\n raise \"Bad response #{response.inspect}\" unless response.is_a?(Net::HTTPOK)\n names.concat JSON[response.body].map { |repo| repo['name'] }\n uri = parse_link(response['Link'])\n end until uri.nil?\n end\n end\n end", "def projects\n @projects = Project.order(created_at: :desc).page(@page).per(10)\n respond_to do |format|\n format.html\n format.js { render :projects}\n end\n end", "def list_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:pattern] = '/projects'\n\t\targs[:query]['Action'] = 'ListProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :project_owner\n\t\t\targs[:query]['ProjectOwner'] = optional[:project_owner]\n\t\tend\n\t\tself.run(args)\n\tend", "def project(project_id, options={})\n response_body = nil\n begin\n response = connection.get do |req|\n req.url \"/api/v1/projects/#{project_id}\", options\n end\n response_body = response.body\n rescue MultiJson::DecodeError => e\n #p 'Unable to parse JSON.'\n end\n \n response_body\n end", "def index\n\t\tif present_user.role? 'admin'\n\t\t\t@projects = Project.all\n\t\telse\n\t\t\t@projects = present_user.projects\n\t\tend\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @projects }\n\t\tend\n\tend", "def show\n @projects = find_projects\n end", "def index\n projects = current_user.admin_projects.paginate(:page => params[:page])\n render json: projects\n end", "def list\r\n @projects = Project.where(user:current_user).order(created_at: :desc).page(params[:page])\r\n respond_with(@projects)\r\n end", "def index\n @user = User.find_by_id(session[:userid])\n @projects = current_user_projects\n respond_to do |format|\n format.html # index.html.erb\n format.json\n end\n end", "def index\n @user = get_user\n @projects = Project.all\n # render :inline => @projects.to_json\n end", "def project\n request :project\n end", "def show\n\n render json: Project.all\n\n end", "def listProjects \n uri = URI(RUNDECKSERVER + ':' + RUNDECKPORT + '/api/1/projects')\n http = Net::HTTP.new(uri.host, uri.port)\n headers = {\n 'Content-Type'=> 'application/json',\n 'X-RunDeck-Auth-Token'=> API_KEY \n}\n r = http.get(uri.path, headers)\n return r.body.force_encoding(\"UTF-8\")\n\nend", "def available_projects_list\n uri = \"#{@api_url}?access_token=#{@access_token}\"\n get uri\n end", "def index\n @projects = current_user.active_projects.includes(:project_errors)\n @project_invitations = current_user.user_projects.pending\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def project(project_id, params = {})\n make_get_request(\"/projects/#{project_id}\", params)\n end", "def list_projects # :nologin:\n query = create_query(:Project, :all, :by => :title)\n show_selected_projects(query)\n end", "def index\n @projects = Project.includes(:participants).all\n\n render json: @projects, include: :participants, status: 200\n end", "def show\n render json: @project\n end", "def projects\n @projects\n end", "def index\n @projects = @projects.includes(:latest_iteration).where(:tenant_id => current_user.tenant).order(\"name\").page(params[:page]).per(DEFAULT_ROWS_PER_PAGE)\n\n respond_with @projects\n end", "def index\n @projects = Service::JIRA.projects\n respond_with(@projects) do |format|\n format.json { render json: @projects.to_a.sort_by(&:name).map(&:attrs).to_json }\n end\n end", "def projects\n Harvest::Resources::Project\n end", "def project(project_id, query_params = nil)\n get(\"/projects/#{project_id}\", query_params)\n end", "def get_projects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ProjectsApi#get_projects ...\"\n end\n \n # resource path\n path = \"/Projects\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'brief'] = opts[:'brief'] if opts[:'brief']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<APIProject>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectsApi#get_projects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @projects = @namespace.projects.all\n end", "def projects\n tmp = client.get @json['user']['links']['projects']\n tmp['projects'].map do |project_meta|\n project_uri = project_meta['project']['links']['self']\n project = client.get project_uri\n client.factory.create(GoodData::Project, project)\n end\n end", "def get_projects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.get_projects ...'\n end\n # resource path\n local_var_path = '/v1/project'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'excludeInactive'] = opts[:'exclude_inactive'] if !opts[:'exclude_inactive'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Project>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectApi#get_projects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n\t\t@projects = Project.all\n\tend", "def index\n #@projects = []\n if current_user\n #@projects = current_user.projects.where(\"memberships.status >= ?\", 1)\n end\n\n if params[:id]\n @project = Project.find(params[:id])\n authorize! :read, @project\n else\n @project = @projects.first\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js { render :action => 'show'}\n format.json { render json: @projects }\n end\n end", "def index_participating\n projects = current_user.projects.paginate(:page => params[:page])\n render json: projects\n end", "def list_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:query]['Action'] = 'ListProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :project_owner\n\t\t\targs[:query]['ProjectOwner'] = optional[:project_owner]\n\t\tend\n\t\tself.run(args)\n\tend", "def project\n return forbidden unless current_account and params[:id] and (request.format.json? || request.format.js? || request.format.text?)\n project = Project.accessible(current_account).find(params[:id].to_i)\n return not_found unless project\n opts = { :include_document_ids => params[:include_document_ids] != 'false' }\n @response = {'project' => project.canonical(opts)}\n render_cross_origin_json\n end", "def show \n project= Project.find(params[:id])\n\n render json: project\n end", "def list_projects(company_id: )\n url = \"#{@base_url}/vapid/projects?company_id=#{company_id}\"\n HTTParty.get(url, headers: procore_headers(token: @customer_info[:token], company_id: @customer_info[:company_id] )).parsed_response\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects_people = ProjectsPerson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects_people }\n end\n end", "def projects\n PivotalTracker::Project.all\n end", "def show\n render json: Project.where(id: params.fetch(:id))\n end", "def get_projects\n @params=task_params\n @client=current_user.clients.find(@params[:client_id])\n counter=0\n @res=[]\n @client.projects.each do |c|\n if c.users.include? current_user\n @res[counter]={\n project_id: c.id, \n name: c.name\n }\n counter+=1\n end\n end\n respond_to do |format|\n format.json {render json: @res.uniq}\n end\n end", "def show\n @projects = Project.all\n end", "def projects\n @projects ||= begin\n user = api('user')\n api(\"users/#{user['id']}/projects\").sort_by { |p| p['id'] }\n end\nend", "def list_projects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: QcApi.list_projects ...\"\n end\n # resource path\n local_var_path = \"/projects.json\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<Project>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: QcApi#list_projects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def getProjectID()\n result = RestClient.get GITHUB_API + PROJECTS_PATH, :accept => 'application/vnd.github.inertia-preview+json', :'Authorization' => 'token ' + CONFIG['OAUTH']\n result = JSON.parse(result) \n end", "def index\n @projects = Project.all\n end", "def index\n @projects = Project.all\n end", "def index\n @projects = Project.all\n end" ]
[ "0.8574897", "0.8386689", "0.8355737", "0.8062607", "0.80368364", "0.8002139", "0.78593457", "0.7834634", "0.78324", "0.7799698", "0.77792805", "0.7748103", "0.77139485", "0.7700251", "0.7696023", "0.7695487", "0.7695487", "0.7695487", "0.7695487", "0.7695487", "0.7695487", "0.7695487", "0.7695384", "0.7677249", "0.7659848", "0.76413786", "0.7627596", "0.76157665", "0.76007134", "0.75998086", "0.7599048", "0.755127", "0.75476474", "0.7504184", "0.7464399", "0.7463047", "0.74520797", "0.7440121", "0.74273944", "0.74115896", "0.74086154", "0.7406792", "0.73953074", "0.73152006", "0.72899425", "0.7288984", "0.727693", "0.72592014", "0.725888", "0.72443324", "0.72430474", "0.7232267", "0.7224122", "0.7218089", "0.7194763", "0.7187098", "0.71705997", "0.7170378", "0.7167435", "0.7164896", "0.71607876", "0.7140332", "0.7130536", "0.7128779", "0.7127035", "0.7124004", "0.7118136", "0.711526", "0.7114364", "0.71083033", "0.71005213", "0.7098299", "0.70919305", "0.70723647", "0.70523155", "0.70496404", "0.70492387", "0.7042553", "0.70393467", "0.7036608", "0.7033363", "0.7031996", "0.7031996", "0.7031996", "0.7031996", "0.7031996", "0.7031996", "0.7031996", "0.7031996", "0.70277584", "0.7022911", "0.70143616", "0.70081574", "0.70047146", "0.70036596", "0.7003546", "0.7002825", "0.69961166", "0.69961166", "0.69961166" ]
0.7026879
90
GET /projects/1 GET /projects/1.json
def show @new_page = Page.new({project: @project, name: generate_new_page_name}) @new_data_source = DataSource.new({project: @project}) @pages_list = @project.pages.map {|i| [i.id, i.name]} @data_sources = @project.data_sources.includes(:data_source_type) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list\n get 'projects'\n end", "def listprojects\n get('listprojects.json')['projects']\n end", "def show\n @project = @client.projects.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def projects\n resource 'projects'\n end", "def index\n @projects = Project.all\n render json: @projects, status: :ok\n end", "def index\n @projects = Project.all\n render json: @projects\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @user = User.find_by(id: params[:user_id])\n @project = @user.projects\n if @project \n render :json => @project\n else\n render :json => 422\n end\n end", "def projects\n request(method: 'getAllProjects')\n end", "def project(project_id, params = {})\n make_get_request(\"/projects/#{project_id}\", params)\n end", "def index\n @projects = Project.visible\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @projects }\n end\n end", "def show\n render json: Project.where(id: params.fetch(:id))\n end", "def show \n project= Project.find(params[:id])\n\n render json: project\n end", "def index\n @projects = Project.all_for_user(current_user.id)\n render json: @projects.to_json(include: :project_detail), status: 200\n end", "def project(project_id, options={})\n response_body = nil\n begin\n response = connection.get do |req|\n req.url \"/api/v1/projects/#{project_id}\", options\n end\n response_body = response.body\n rescue MultiJson::DecodeError => e\n #p 'Unable to parse JSON.'\n end\n \n response_body\n end", "def index\n @projects = current_user.projects\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def project(project_id, query_params = nil)\n get(\"/projects/#{project_id}\", query_params)\n end", "def project(project_id)\n resource \"projects/#{project_id}\"\n end", "def index\n @projects = Project.all\n render json: @projects, layout: false\n end", "def getProjectID()\n result = RestClient.get GITHUB_API + PROJECTS_PATH, :accept => 'application/vnd.github.inertia-preview+json', :'Authorization' => 'token ' + CONFIG['OAUTH']\n result = JSON.parse(result) \n end", "def show\n @project = Project.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def get\n CircleCi.request(conf, '/projects').get\n end", "def index\n # @projects = @current_user.projects\n @projects = Project.all\n json_response(@projects)\n end", "def projects\n records \"project\", \"/project/list\"\n end", "def projects\n Sifter.\n get(\"/api/projects\").\n parsed_response[\"projects\"].\n map { |p| Sifter::Project.new(p) }\n end", "def index \n\n @projects = Project.all\n respond_to do |format|\n format.html {render :template => \"projects/index\"}\n format.json { render json: @projects }\n end\n end", "def index\n @projects = current_user.projects.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n \n @workspaces = current_user.workspaces\n # debugger\n @projects = Project.where(:workspace_id => @workspace)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def show\n @project = Project.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @project }\n end\n end", "def show\n render json: @project\n end", "def show\n repo = ProjectRepo.new current_user\n @v_project = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_project }\n end\n end", "def find_project(name)\n get(\"/projects/#{name}\")\n end", "def find_project(name)\n get(\"/projects/#{name}\")\n end", "def show\n @project = Project.find_by(id: params[:id])\n if @project\n render :json => @project\n else\n render :json => 422\n end\n end", "def projects(params = {})\n make_get_request('/account/projects', params)\n end", "def project\n request :project\n end", "def project\n return forbidden unless current_account and params[:id] and (request.format.json? || request.format.js? || request.format.text?)\n project = Project.accessible(current_account).find(params[:id].to_i)\n return not_found unless project\n opts = { :include_document_ids => params[:include_document_ids] != 'false' }\n @response = {'project' => project.canonical(opts)}\n render_cross_origin_json\n end", "def show \n render :json => Project.find_by_id(params[:id])\n end", "def show\n @ourproject = Ourproject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ourproject }\n end\n end", "def get_project(project_id)\n http = Net::HTTP.new(@city_db_url, @port)\n http.read_timeout = 1000\n if @city_db_is_https\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n request = Net::HTTP::Get.new(\"/projects/#{project_id}.json\")\n request.add_field('Content-Type', 'application/json')\n request.add_field('Accept', 'application/json')\n request.basic_auth(ENV['URBANOPT_USERNAME'], ENV['URBANOPT_PASSWORD'])\n\n response = http.request(request)\n if response.code != '200' # success\n @runner.registerError(\"Bad response #{response.code}\")\n @runner.registerError(response.body)\n @result = false\n return {}\n end\n\n result = JSON.parse(response.body, symbolize_names: true)\n return result\n end", "def index\n @projects = Project.with_permissions_to(:read)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def show\n @projectresource = Projectresource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @projectresource }\n end\n end", "def index\n @projects = Project.where user: current_user\n render json: @projects, each_serializer: Projects::IndexSerializer\n end", "def show \n respond_to do |format|\n format.json {\n\n @project = Project.find_by_id(params[:id])\n\n if @project\n render :json => @project\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @current_project = CurrentProject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @current_project }\n end\n end", "def show\n respond_with(@project) do |format|\n format.json { render json: @project.as_json }\n format.html\n end\n end", "def show\n @show_project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @show_project }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n respond_with @project do |format|\n format.json do\n render json: @project.as_json.merge(\n commits_url: project_commits_url(@project, format: 'json'),\n commits: @project.commits.order('committed_at DESC').limit(10).map { |commit|\n commit.as_json.merge(\n percent_done: commit.fraction_done.nan? ? 0.0 : commit.fraction_done*100,\n translations_done: commit.translations_done,\n translations_total: commit.translations_total,\n strings_total: commit.strings_total,\n import_url: import_project_commit_url(@project, commit, format: 'json'),\n sync_url: sync_project_commit_url(@project, commit, format: 'json'),\n url: project_commit_url(@project, commit),\n status_url: project_commit_url(@project, commit),\n )\n }\n )\n end\n end\n end", "def show\n # turn ruby database into json\n # route to the project 3 page with this json\n # id = 1\n end", "def projects(params = {})\n fetch_all('projects', 'projects', params)\n end", "def show\n\n render json: Project.all\n\n end", "def show\n set_surrogate_key_header \"api/platforms/#{@platform.id}/projects\"\n set_cache_control_headers 3600\n end", "def index\n @about_projects = AboutProject.last(1)\n\n respond_to do |format|\n format.json {render json: @about_projects[0], :only => [:description]}\n end\n end", "def show\n @projects = find_projects\n end", "def get_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'GetProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def show_by_gitpath\n @project = Project.includes(:users).includes(:technos).find_by_gitpath(params[:gitpath])\n\n respond_to do |format|\n format.json { render json: @project, status: 200 }\n end\n end", "def project\n @client.project(:id => project_id)\n end", "def list_projects\n handle_action_exceptions(__method__) do\n cmd_line = ['listprojects']\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end", "def index\n #@projects = []\n if current_user\n #@projects = current_user.projects.where(\"memberships.status >= ?\", 1)\n end\n\n if params[:id]\n @project = Project.find(params[:id])\n authorize! :read, @project\n else\n @project = @projects.first\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js { render :action => 'show'}\n format.json { render json: @projects }\n end\n end", "def projects\n return forbidden unless current_account # already returns a 401 if credentials aren't supplied\n opts = { :include_document_ids => params[:include_document_ids] != 'false' }\n @response = {'projects' => Project.accessible(current_account).map {|p| p.canonical(opts) } }\n render_cross_origin_json\n end", "def get_projects_of_user\n respond_to do |format|\n format.json {\n #param = params[:payload]\n #@user = User.find_by_id(param[:id])\n @projects = Project.where(:user_id => @current_user.id)\n if @projects\n render :json => @projects\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end", "def get\n render json: Project.select(:id, \"name as label\")\n end", "def index\n @projects = Project.includes(:user).all\n respond_with(@projects) do |format|\n format.json { render :json => {:list => @projects.as_json, :current_user => current_user.as_json} }\n format.html\n end\n end", "def details\n get(\"project/details\")[\"project\"]\n end", "def show\n @workspaces = current_user.workspaces\n @project = Project.find(params[:id])\n @workspace = Workspace.find(params[:workspace_id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def get(project_name)\n response = get_request(\"/projects/#{project_name}/\")\n TheShiningSource::Project.new(response)\n end", "def show\n @unfinished_project = UnfinishedProject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unfinished_project }\n end\n end", "def index\n @user = User.find_by_id(session[:userid])\n @projects = current_user_projects\n respond_to do |format|\n format.html # index.html.erb\n format.json\n end\n end", "def show_project\r\n @project = Project.find(params[:id])\r\n @id = @project.id\r\n respond_to do |format|\r\n format.html { render 'project_control/view' }\r\n format.json { render json: @project }\r\n end\r\n end", "def getProject(project)\r\n\t\t\t\tproject_json = JSON.parse project\r\n\t\t\t\tproject_array = project_json[\"projects\"]\r\n\t\t\t\treturn jsonToProject(project_array[0])\r\n\t\t\tend", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @projects }\n #format.json { render json: @project.as_json(:include => [:client, :project_participants] ) }\n end\n end", "def index\n if signed_in?\n @projects = current_user.projects\n respond_to do |format|\n format.html { render 'projects/index' }\n format.json { render template: 'projects/index.json.jbuilder' }\n end\n else\n redirect_to :projects\n end\n end", "def index\n @projects = @projects.includes(:latest_iteration).where(:tenant_id => current_user.tenant).order(\"name\").page(params[:page]).per(DEFAULT_ROWS_PER_PAGE)\n\n respond_with @projects\n end", "def show\n respond_to do |format|\n format.html {render :show}\n format.json {render json: @project}\n end\n end", "def show\n @project = Project.find(params[:id])\n\t@user = User.find(@project.user_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def find(project_id)\n raw_response = get_request(\"projects/#{project_id}\")\n parse_response(raw_response, :project)\n end" ]
[ "0.78697544", "0.7698408", "0.7680339", "0.7613705", "0.75337136", "0.7525879", "0.7493363", "0.7493363", "0.7493363", "0.7493363", "0.7493363", "0.7493363", "0.7493363", "0.74931365", "0.7483965", "0.74803555", "0.7446126", "0.7429718", "0.74231553", "0.7414986", "0.7385634", "0.7380362", "0.73794556", "0.7375584", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73619705", "0.73588735", "0.7354991", "0.7352316", "0.7343573", "0.73419714", "0.7326049", "0.7303268", "0.72901344", "0.727417", "0.7273762", "0.72540456", "0.7252145", "0.7251143", "0.7242956", "0.724223", "0.72293097", "0.72293097", "0.7213873", "0.72112584", "0.7204831", "0.7196271", "0.7184846", "0.71561235", "0.71503824", "0.71490365", "0.7121025", "0.7112306", "0.7106593", "0.7086883", "0.7084719", "0.70793617", "0.70527", "0.7050857", "0.70440745", "0.70436114", "0.70263803", "0.7026122", "0.7004827", "0.7004275", "0.70039594", "0.7001873", "0.69874394", "0.6986131", "0.6980996", "0.69805783", "0.6978405", "0.6976709", "0.69693714", "0.6965785", "0.6965646", "0.6962675", "0.6962555", "0.69625133", "0.69619524", "0.69581634", "0.6943415", "0.6935823", "0.6934703", "0.69173646", "0.69126534", "0.6910493", "0.6905561" ]
0.0
-1
POST /projects POST /projects.json
def create @project = current_user.projects.new(project_params) new_page = @project.pages.new({ name: generate_new_page_name}) @project.startpage = new_page @project.date_created = Time.now @project.last_modified = Time.now respond_to do |format| if @project.save format.html { redirect_to @project, notice: 'Project was successfully created.' } format.json { render action: 'show', status: :created, location: @project } else format.html { render action: 'new' } format.json { render json: @project.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render :json => @project, :status => :created, :location => @project }\n format.html { redirect_to(projects_path) }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_project(name)\n post('projects', {:name => name})[\"project\"]\n end", "def create\n @project = Project.new(project_params)\n\n if @project.save\n render json: @project, status: 200\n else\n render json: { errors: @project.errors.messages }, status: 200\n end\n end", "def create\n @project = Project.new(project_params)\n\n if @project.save\n render json: @project, status: :created\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def create\n @urlroot = Designax::Application.config.urlroot\n if params[:pk] == \"new\" and params[:name] == \"project_name\"\n project_name = params[:value]\n @project = Project.new()\n @project.project_name = project_name\n else\n @project = Project.new(params[:project])\n end\n\n respond_to do |format|\n if @project.save\n redirect_url = @urlroot + \"/projects\"\n response_url = { \"url\" => redirect_url }\n format.json { render json: response_url, status: 200 }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project] || JSON.parse(request.body.read))\n\n if (params[:id])\n @project.id = params[:id]\n end\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.xml { render :xml => @project, :status => :created, :location => @project }\n format.json { render :json => @project }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n format.json { render :text => \"error creating project via http/json\" }\n end\n end\n end", "def test_should_create_project_via_API_JSON\r\n get \"/logout\"\r\n post \"/projects.json\", :api_key => 'testapikey',\r\n :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response :created\r\n project = JSON.parse(response.body)\r\n check_new_project(project) \r\n end", "def create\n\t\t@project = current_user.projects.new(project_params)\n\n\t\trespond_to do |format|\n\t\t\tif @project.save\n\t\t\t\tformat.json { render :show, status: :created }\n\t\t\telse\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @projects = current_user.projects\n @project = current_user.projects.new(project_params)\n\n respond_to do |format|\n if @projects << @project\n format.html { redirect_to user_projects_path(current_user), notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render json: @project, status: :created, location: @project }\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n format.html { render action: \"new\" }\n end\n end\n end", "def create\n @project = current_user.projects.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(attributes={})\n raw_response = post_request('projects', project: attributes)\n parse_response(raw_response, :project)\n end", "def create\n #byebug\n @project = Project.new(create_params)\n @project.user_id = @current_user.id\n @project.save\n #@project = Project.create(name_project: \"prueba\", subsidy: true, parking: true, user_id: @current_user.id)\n #byebug\n render json: @project, status: :created\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.json { render :json => @project, :status => :created, :location => @project }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n if @project.save\n render json: @project, status: :ok\n else\n render json: {error: @project.errors.full_messages.to_sentence } , status: :unprocessable_entity\n end\n end", "def create\n @user = current_user\n @project = @user.projects.build(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html {redirect_to \"/projects\", notice: \"Project was successfully created.\"}\n format.json {render :show, status: :created, location: @project}\n else\n format.html {render :new, status: :unprocessable_entity}\n format.json {render json: @project.errors, status: :unprocessable_entity}\n end\n end\n end", "def create\n @project = current_user.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: \"Project was successfully created.\" }\n User.find(current_user.id).projects << Project.find(@project.id)\n @projects_user = ProjectsUser.find_by(user_id: current_user.id, project_id: @project.id)\n format.json { render :show, status: :created, location: @project }\n\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: t('models.project.create') }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_project = Project.new(api_project_params)\n\n respond_to do |format|\n if @api_project.save\n format.html { redirect_to @api_project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @api_project }\n else\n format.html { render :new }\n format.json { render json: @api_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: \"Project was successfully created.\" }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = @client.projects.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @client, notice: 'Project was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.json { render json: @project, status: 200 }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n @project.user_id = @user.id\n if @project.save\n render json: {status: :success, project: @project}\n else\n render json: {status: :failed, project: @project}\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render action: 'show', status: :created, location: @project }\n else\n format.html { render action: 'new' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if project.save\n format.html { redirect_to project, notice: 'Project was successfully created.' }\n format.json { render json: project, status: ':created', location: project }\n else\n format.html { render action: 'new' }\n format.json { render json: project.errors, status: ':unprocessable_entity' }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: 'new' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.new(project_params)\n if @project.save\n render :show\n else\n render json: { errors: @project.errors }\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to admin_projects_url, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, flash: {success: 'Project was successfully created.'} }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # authenticate_user!\n @project = Project.new\n @project[:category] = params[:category]\n @project[:title] = params[:title]\n @project[:body] = params[:body]\n @project[:location] = params[:location]\n @project[:image_link] = params[:image_link]\n @project[:project_url] = params[:project_url]\n @project[:year] = params[:year]\n @project[:likes] = params[:likes]\n @project.save\n\n render json: @project\n end", "def create\n @project = Project.new(project_params.merge(user_id: current_user.id))\n\n respond_to do |format|\n if @project.save\n format.json { render :show, status: :created, location: @project }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n \n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.find(params[:client_id])\n @project = @client.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to client_projects_path(@client), notice: 'Project was successfully created.' }\n format.json { render json: client_projects_path(@client), status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: client_projects_path(@client).errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to root_path, notice: 'Enhorabuena! Tienes un nuevo proyecto. A trabajar!' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.create project_params\n current_user.memberships.create(\n project_id: @project.id,\n owner_at: Time.now\n )\n\n if @project.save\n render 'projects/create', status: 201\n else\n render 'projects/error', status: 422\n end\n end", "def create\n @project = @client.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(client_projects_url(@client), notice: 'Project was successfully created.') }\n format.xml { render xml: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @create_project = current_user.projects.build(params[:project])\n flash[:notice] = \"Project #{@create_project.description} successfully created\" if @create_project.save\n respond_with(@create_project, layout: !request.xhr?)\n end", "def new_project\n @request = Request.new(data_type: :project)\n @request.build_contact\n @request.build_project\n @request.build_general_information\n\n render 'new'\n end", "def create\t\t\t\t\t\t\t\t\t# Creates record in db and redirects (porbably to index)\n\t\t@project = Project.new(projects_params)\t# Passes only title and desc.\n\n \trespond_to do |format|\t\t\t\t\t# All this is doing is rendering stuff in case of json\n \t\tif @project.save\n \t\tformat.html { redirect_to @project, notice: 'Created a new project!' }\n \t\tformat.json { render :show, status: :created, location: @project }\n \t\telse\n \t\tformat.html { render :new }\n \t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n\tend", "def create\n if params[:project_id]\n cloned_from = Project.find(params[:project_id])\n @project = cloned_from.clone(params, @cur_user.id)\n else\n @cloned_project = nil\n @project = Project.new project_params\n @project.user_id = @cur_user.id\n end\n\n respond_to do |format|\n if @project.save\n format.html do\n redirect_to @project, notice: 'Project was successfully created.'\n end\n format.json do\n render json: @project.to_hash(false),\n status: :created, location: @project\n end\n else\n flash[:error] = @project.errors.full_messages\n format.html { redirect_to projects_path }\n format.json do\n render json: @project.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def create_project(key, name, params = {})\n params[:key] = key\n params[:name] = name\n post('projects', params)\n end", "def create\n @project = Project.new(project_params)\n @project.owner = current_user unless @project.owner\n if @project.save\n render :show, status: :created, location: @project\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def create_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'POST'\n\t\targs[:pattern] = '/projects'\n\t\targs[:query]['Action'] = 'CreateProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project\n\t\t\targs[:body]['Project'] = optional[:project]\n\t\tend\n\t\tself.run(args)\n\tend", "def projects\n resource 'projects'\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n build_projects_user\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n project_attrs = params[:project].merge(validate_repo_connectivity: true)\n @project = current_user.owned_projects.create(project_attrs, as: :owner)\n respond_with @project do |format|\n format.json do\n if @project.valid?\n render json: decorate(@project).to_json, status: :created\n else\n render json: {project: @project.errors.as_json}.to_json, status: :unprocessable_entity\n end\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\t\[email protected]_id =current_user.id\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n @project.skills = params[:skills]\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.create(project_params)\n if @project.errors.blank?\n flash[:success] = t('controllers.projects.create.success', project: @project.name)\n else\n flash.now[:alert] = @project.errors.full_messages.unshift(t('controllers.projects.create.failure'))\n end\n respond_with @project, location: projects_url\n end", "def create\n @new_nav = true;\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n if params[:project_attachments]\n create_attachments\n end\n\n if params[:project_fields]\n create_fields\n end\n\n if params[:slider_objects]\n create_slider_objects\n end\n\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n @project.user = current_user\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n begin\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors.full_messages, status: :unprocessable_entity }\n end\n end\n rescue Exception => e\n @project.destroy\n respond_to do |format|\n format.html { render :new }\n format.json { render json: e.as_json, status: :service_unavailable }\n end\n end\n end", "def project_create(global_options, options)\n result = Excon.post(\n \"#{global_options[:fenton_server_url]}/projects.json\",\n body: project_json(options),\n headers: { 'Content-Type' => 'application/json' }\n )\n\n [result.status, JSON.parse(result.body)]\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n @project.user_projects.create(:user_id => current_user.id, :status => true, :role => 1)\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n respond_to do |format|\n if @project.save\n flash[:alert] = \"Project created successfully.\"\n format.html { redirect_back(fallback_location: root_path) }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n if is_organization_admin? and @project.save\n @project.team_members.create(user_id: @project.organization.owner_id)\n render json: {\n name: @project.name,\n organization: @project.organization.name,\n url: project_dashboard_path(@project.id)\n }\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def create\n @project = Project.new(project_params)\n\n if params[\"project\"][\"client_id\"] != \"\"\n @project.client = Client.find params[\"project\"][\"client_id\"]\n end\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Novo projeto cadastrado com sucesso.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.create(params[:project])\n \n if @project.save\n record_activity(\"created new project: \" + @project.id.to_s)\n redirect_to root_path, :notice => \"Project created successfully\"\n else\n render 'new'\n end\n end", "def create\n find_projects(params[:api_key])\n end", "def create\n\n @project = Project.new(project_params)\n @project.user_id = current_user.id\n\n respond_to do |format|\n if @project.save\n\n format.html { redirect_to @project, success: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(:project_title => params[:project_title], :start_date => params[:startDate], :end_date => params[:endDate],\n :status => params[:project_status])\n\n @project.user_id = current_user.id\n\n\n respond_to do |format|\n if @project.save\n p \"pass on projects controller\"\n format.html { redirect_to @project}\n format.json { render json: \"ok\" }\n else\n p \"fail on projects controller\"\n end\n end\n\n\n end", "def create_project_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.create_project ...'\n end\n # resource path\n local_var_path = '/projects'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'create_project_body'])\n\n # return_type\n return_type = opts[:debug_return_type] || 'Project'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['oryAccessToken']\n\n new_options = opts.merge(\n :operation => :\"ProjectApi.create_project\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectApi#create_project\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to :projects, notice: \"Project was successfully created.\" }\n format.json { render :show, status: :created, location: @project }\n else\n format.html do\n @teams = Team.order(:name)\n render :new\n end\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n @project.team.touch\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n render_errors(format, @project.errors, :new)\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to [:user, @project], notice: 'Project temp was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n render text: params[:project].inspect\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Proyecto creado sastifactoriamente' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n @project.status = \"Etat zero\"\n creator = current_user\n ProjectUser.create(:project => @project, :user => creator, :admin => true)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n @project.user_id = current_user.id\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = @projectable.projects.new(params[:project])\n\n respond_to do |format|\n if @project.save\n track_activity @project\n format.html { redirect_to [@projectable, @project], notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render layout: 'form', action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n #Acá se retorna de la vista New (o de cualquier lugar que llame a create con POST). Le llega el hash project_params con \n # los datos que retornó la vista.\n\n #Crea el nuevo usuario.\n @project = Project.new(project_params)\n\n respond_to do |format| #Esta linea es curiosa. Si el request le llegó por HTML, entonces fue un navegador. Si le llego\n #por JSON, entonces probablemente fue otra cosa, un app movil por ejemplo.\n if @project.save #Esto guarda el proyecto nuevo en la base de datos y retorna True si no hubo problema, y False si hubo un error.\n # Es importante notar que al llamar .save, primero pasa por el modelo, el cual revisa que no falte ningún dato.\n # Por ejemplo, si el modelo necesita que se incluya el nombre del proyecto, si o si, y no se le pasó el nombre,\n # Entonces el modelo va a guardar ese error en un hash llamado errors, dentro de el mismo (@projects.errors)\n # y va a hacer que .save retorne False.\n\n\n format.html { redirect_to :controller => \"misc\", :action =>\"about\", notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7338948", "0.73139244", "0.7308003", "0.7299582", "0.7227503", "0.7225945", "0.71982473", "0.71170384", "0.7104803", "0.7095263", "0.7070636", "0.70408624", "0.70358187", "0.7024969", "0.70191896", "0.7009597", "0.698481", "0.697517", "0.6963753", "0.6963096", "0.6948756", "0.6948756", "0.6948756", "0.6948756", "0.6948756", "0.6948756", "0.6948756", "0.6948756", "0.6948756", "0.6944626", "0.69397265", "0.6938008", "0.69204897", "0.6911497", "0.6908809", "0.6907813", "0.6894293", "0.689054", "0.68847734", "0.6879909", "0.68794346", "0.6879012", "0.68784195", "0.6868972", "0.68664163", "0.68660194", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.68657774", "0.6865554", "0.68598175", "0.6858278", "0.6846567", "0.6828604", "0.68193066", "0.6806436", "0.678643", "0.6784763", "0.6773288", "0.675545", "0.6750235", "0.67379624", "0.6718913", "0.6716745", "0.67009157", "0.66877806", "0.6686259", "0.668621", "0.66856426", "0.66838706", "0.6680505", "0.66770595", "0.6670888", "0.6668133", "0.66572726", "0.66528344", "0.66518456", "0.66511416", "0.6649628", "0.6649045", "0.6642436", "0.6638429", "0.6634081", "0.66324985", "0.6629944", "0.6628171", "0.66263485", "0.66259176", "0.66255814" ]
0.0
-1
PATCH/PUT /projects/1 PATCH/PUT /projects/1.json
def update respond_to do |format| if @project.update(project_params) format.html { redirect_to @project } format.json { respond_with_bip(@project) } else format.html { render action: 'edit' } format.json { respond_with_bip(@project) } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @project.update(project_params)\n render json: @project, status: 200\n else\n render json: { errors: @project.errors.messages }, status: 200\n end\n end", "def update\n authorize! :update, @project\n\n if @project.update(project_params)\n head :no_content\n else\n render 'projects/error', status: 422\n end\n end", "def update\n @project = Project.find(params[:id])\n\n if params[:name] == \"project_name\"\n project_name = params[:value]\n @project.project_name = project_name\n end\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n\n @projects = Project.all\n format.html {\n render :action => \"index\"\n }\n format.json { render json: @project }\n else\n logMessage = self.class.to_s + \"#\" + __method__.to_s + \" \" + current_user.username + \" errors:\" + @project.errors.full_messages.to_s\n logger.info logMessage\n\n format.html {\n flash[:error] = 'Project was not successfully updated.'\n redirect_to action: \"index\"\n }\n errorMsg = @project.errors.full_messages.to_s.split(\"\\\"\")\n format.json { render json: errorMsg[1], status: 500 }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, :notice => 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to(@project, :notice => 'Project was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_project\n\t\t@project = Project.find(params[:id])\n\n\t \trespond_to do |format|\n\t\t if @project.update_attributes(project_update_params)\n\t\t format.html { redirect_to(@project, :notice => 'Entry was successfully updated.') }\n\t\t format.json { respond_with_bip(@project) }\n\t\t else\n\t\t format.html { render :action => \"edit\" }\n\t\t format.json { respond_with_bip(@project) }\n\t\t end\n\n \t end\n\tend", "def update\t\t\t\t\t\t\t\t\t# Actually modifies the data and redirects (probably to index or show? depends)\n\t\t#@project = Project.find(params[:id])\t# Taken out because of the before action GENIUS!\n\n\t\trespond_to do |format|\n \t\t if @project.update(projects_params)\n \t\tformat.html { redirect_to @project, notice: 'Project was successfully updated.' }\n \t\tformat.json { render :show, status: :ok, location: @project }\n \t\telse\n \t\tformat.html { render :edit }\n \t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n\tend", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = current_user.projects.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = @client.projects.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to([@client, @project], notice: 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.json { render :show, status: :ok, location: @project }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.json { render json: @project, status: 200 }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\trespond_to do |format|\n\t\t\tif @project.update(project_params)\n\t\t\t\tformat.json { render :show, status: :ok }\n\t\t\telse\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n @client = Client.find(params[:client_id])\n @project = Project.find(params[:id])\n \n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to client_projects_path(@client), notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: client_projects_path(@client).errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render json: @project.as_json(:include => [:client, :project_participants ] ) }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if project.update(project_params)\n format.html { redirect_to project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: project.errors, status: ':unprocessable_entity' }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n @main_projects = Project.roots.where(creator_id: @project.creator_id)\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @project.update(project_params)\n render json: {status: :success, project: @project}\n else\n render json: {status: :failed, project: @project}\n end\n end", "def update\n @edit_project = Project.find(params[:id])\n\n respond_to do |format|\n if @edit_project.update_attributes(params[:project])\n format.html { redirect_to @edit_project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @edit_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_project.update(api_project_params)\n format.html { redirect_to @api_project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_project }\n else\n format.html { render :edit }\n format.json { render json: @api_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def project_update(project)\n raise Client::FileboundClientException.new('Id is required', 0) unless project[:projectId].greater_than_zero?\n put('/projects', nil, project)\n end", "def update\n\t\t@project = Project.find(params[:id])\n\t\tmake_breadcrumbs\n\t\t\n\t\trespond_to do |format|\n\t\t\tif @project.update_attributes(params[:project])\n\t\t\t\tformat.html { redirect_to @project, notice: t('app.projects.updated') }\n\t\t\t\tformat.json { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n if @project.update(project_params)\n render :show, status: :ok, location: api_v1_project_url(@project)\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n \t\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to add_path(@project), notice: 'Project was successfully updated.' }\n format.json { render :add, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n params[:project][:problem_ids] ||= []\n params[:project][:target_ids] ||= []\n params[:project][:factor_ids] ||= []\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to(projects_path, :notice => 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: projects_path }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authenticate_user!\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to(@project, :notice => 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'PUT'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'UpdateProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project\n\t\t\targs[:body]['Project'] = optional[:project]\n\t\tend\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to projects_path() }\n format.xml { head :ok }\n else\n @edit_mode = true\n @tasks = Task.find_all_by_project_id(@project.id)\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def project_updates\n @project = Project.find(params[:id])\n end", "def update\n if @project.update(project_params)\n render :show, status: :ok\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def update\n if @project.update(project_params)\n render :show, status: :ok\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def update\n @project = Project.find(params[:id])\n<<<<<<< HEAD:app/controllers/projects_controller.rb\n handle_disciplines_projects\n \n=======\n\n>>>>>>> 336471e6be257cf55c9afa2a65f928fde34e41fe:app/controllers/projects_controller.rb\n respond_to do |format|\n if @project.update_attributes(params[:project])\n flash[:notice] = 'Project was successfully updated.'\n format.html { redirect_to(@project) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch_project_with_http_info(project_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.patch_project ...'\n end\n # verify the required parameter 'project_id' is set\n if @api_client.config.client_side_validation && project_id.nil?\n fail ArgumentError, \"Missing the required parameter 'project_id' when calling ProjectApi.patch_project\"\n end\n # resource path\n local_var_path = '/projects/{project_id}'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'json_patch'])\n\n # return_type\n return_type = opts[:debug_return_type] || 'SuccessfulProjectUpdate'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['oryAccessToken']\n\n new_options = opts.merge(\n :operation => :\"ProjectApi.patch_project\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectApi#patch_project\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: \"Project was successfully updated.\" }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @project\n if @project.update(project_params)\n render json: @project, status: :ok\n else\n render json: {error: @project.errors.full_messages.to_sentence } , status: :unprocessable_entity\n end\n else\n render json: {error: \"Project does not exist\"} , status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.70004326", "0.69119745", "0.6911138", "0.6889052", "0.6888448", "0.6878091", "0.68675476", "0.6857582", "0.685334", "0.685334", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.6850255", "0.6842495", "0.684057", "0.684057", "0.684057", "0.684057", "0.68398464", "0.68397754", "0.6839175", "0.6829714", "0.6829413", "0.68209535", "0.68173355", "0.6808719", "0.68025875", "0.68025875", "0.6780633", "0.6771888", "0.67589355", "0.67586994", "0.67586994", "0.67561215", "0.6746647", "0.6735708", "0.67201793", "0.6706241", "0.6702684", "0.66779363", "0.66677266", "0.6659675", "0.66557306", "0.66467226", "0.6633223", "0.6633223", "0.66229934", "0.66225135", "0.66225135", "0.6615703", "0.661438", "0.66133374", "0.66015583", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113", "0.6600113" ]
0.66752994
52
DELETE /projects/1 DELETE /projects/1.json
def destroy @project.destroy respond_to do |format| format.html { redirect_to projects_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @project.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n \n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.delete\n\n respond_to do |format|\n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.status = 'deleted'\n @project.save!\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end", "def delete\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_path }\n format.json { head :no_content }\n end\n end", "def destroy\n project = Project.find(params[:id])\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n name = @project.name\n @project.destroy\n render json: [\"You have successfullly deleted '#{name}''\"], status: 200\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to admin_projects_url }\n format.json { head :no_content }\n end\n end", "def delete(projects)\n project_ids = projects.collect { |project| project.id } \n args = {ids: project_ids.to_json}\n return @client.api_helper.command(args, \"project_delete\")\n end", "def delete\r\n\t\t\trender json: Project.delete_by_id(params[:id])\r\n\t\tend", "def destroy\n\t\[email protected]\n\t\trespond_to do |format|\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to administration_projects_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = current_user.projects.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { render :json => {:message=>\"OK\",:id=>@project.id}, :staus=>:ok}\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n head :no_content\n end", "def destroy\t\t\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Successfully deleted project.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: t('models.project.destroy') }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = @client.projects.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to @client }\n end\n end", "def destroy\n @project.destroy\n\n head :no_content\n end", "def destroy\n @ourproject = Ourproject.find(params[:id])\n @ourproject.destroy\n\n respond_to do |format|\n format.html { redirect_to ourprojects_url }\n format.json { head :ok }\n end\n end", "def destroy\n authorize @project\n @project.destroy\n render json: [\"Deleted successfully.\"], status: :ok\n end", "def destroy\n @project.destroy_all\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'The project was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def delete_project(project)\n handle_action_exceptions(__method__) do\n cmd_line = [\"deleteproject '#{project}'\"]\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { render :json => {:valid => true} }\n end\n end", "def destroy\n @api_project.destroy\n respond_to do |format|\n format.html { redirect_to api_projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_path, notice: 'Project was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find_by_permalink(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def delproject(project)\n post('delproject.json', project: project)\n end", "def destroy\n authorize! :destroy, @project\n @project.destroy\n\n head :no_content\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_back(fallback_location: root_path) }\n format.json { head :no_content }\n end\n end", "def destroy\n Rails.logger.info \"We are deleting project\"\n @todo_project.destroy\n respond_to do |format|\n format.html { redirect_to todo_projects_url, notice: 'Project was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = @projectable.projects.find(params[:id])\n @project.destroy\n track_activity @project\n\n respond_to do |format|\n format.html { redirect_to [@projectable, :projects] }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n @project.users.delete_all\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n \t@project = Project.find(params[:id])\n \t#ap @project\n \t#abort\n \n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n authenticate_user!\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @project.destroy\n render json: {message: 'Projeto Excluido'}, status: :ok\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find_by_slug(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"Project was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"#{I18n.t 'project.project_destoy'}\"}\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Admin::Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_projects_url) }\n format.xml { head :ok }\n end\n end", "def delete_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'DELETE'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'DeleteProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def destroy\n @project = current_user.active_projects.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n standard_destroy(Project, params[:id])\n end", "def destroy\n authorize! :delete, @project\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"Project was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"Project was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"Project was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.78951", "0.78593713", "0.7778056", "0.7771693", "0.77585995", "0.7730887", "0.77305084", "0.77305084", "0.77305084", "0.77305084", "0.77305084", "0.77244985", "0.7718401", "0.7718401", "0.7718401", "0.7718401", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7700103", "0.76993084", "0.7682566", "0.7669082", "0.7659675", "0.764973", "0.7641442", "0.763269", "0.761519", "0.76147044", "0.7611191", "0.76066136", "0.7605034", "0.7598783", "0.75986093", "0.7593673", "0.7591231", "0.75896156", "0.7571706", "0.7571697", "0.7561333", "0.7543007", "0.7537952", "0.75324875", "0.75302756", "0.75237787", "0.75237787", "0.75189", "0.75063527", "0.7504202", "0.7499374", "0.7494583", "0.7487019", "0.74810386", "0.74776345", "0.7469382", "0.74652857", "0.7460907", "0.7460907", "0.74520767", "0.7448516", "0.744649", "0.74448746", "0.74421936", "0.7441719", "0.74374086", "0.7437005", "0.74365294", "0.74365294", "0.74365294", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244", "0.7436244" ]
0.76495475
44
Use callbacks to share common setup or constraints between actions.
def set_project @project = Project.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup\n #implement in subclass;\n end", "def after_set_callback; end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.53314966", "0.53114754", "0.52984965", "0.52977055", "0.5296272", "0.5260649", "0.5245076", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.5235081", "0.52321917", "0.5228592", "0.5220735", "0.52198535", "0.52139324", "0.5208539", "0.5206585", "0.5178542", "0.5175199", "0.5173538", "0.5167041", "0.51614195", "0.51577675", "0.5153909", "0.51528823", "0.5152225", "0.51429904", "0.5141399", "0.51345575", "0.51145", "0.5114052", "0.5114052", "0.5110216", "0.5108656", "0.50935394", "0.5089196", "0.5081936", "0.5079627", "0.50675833", "0.5056105", "0.5053687", "0.5050475", "0.5050475", "0.503471", "0.5028311", "0.501982", "0.50157547", "0.5013552", "0.50014806", "0.50011593", "0.49976763", "0.4990292", "0.4990292", "0.49882022", "0.4981269", "0.49792367", "0.49766538", "0.4967978", "0.49667212", "0.4958987", "0.49572337", "0.49550423", "0.4954479", "0.4952353", "0.494726", "0.4944055", "0.4935437", "0.4931248", "0.49283475", "0.49281213", "0.49268973", "0.4921738", "0.49204507", "0.4918924", "0.49182287", "0.4916538", "0.49158585", "0.49156788" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def project_params params.require(:project).permit(:background_colour, :foreground_colour, :panel_colour, :text_colour, :name, :date_created, :startpage_id, :last_modified, :description, :private, :screensize_x, :screensize_y, :user_id, pages_attributes: [ :id, :name, :_destroy, panels_attributes:[ :id, :_destroy, :x, :y, :properties ] ]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def filtering_params\n params.permit(:email)\n end", "def active_code_params\n params[:active_code].permit\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def url_whitelist; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.6978086", "0.6780264", "0.6742658", "0.6738813", "0.67338693", "0.65908474", "0.6501793", "0.6495506", "0.64796513", "0.64755446", "0.6454826", "0.6437561", "0.6377127", "0.63722163", "0.6364058", "0.63178706", "0.62979764", "0.62968165", "0.62913024", "0.6289789", "0.6289145", "0.62875307", "0.6280997", "0.62420976", "0.62388235", "0.6216686", "0.62122375", "0.6208949", "0.619173", "0.6176307", "0.6173907", "0.6170346", "0.616111", "0.6150513", "0.6150023", "0.61446756", "0.6120429", "0.6112975", "0.6104845", "0.6102966", "0.6087884", "0.6079323", "0.60699135", "0.60602236", "0.60191786", "0.60170597", "0.60100305", "0.6009527", "0.60052776", "0.60052776", "0.600042", "0.5999317", "0.59933805", "0.5991528", "0.5991221", "0.5990094", "0.5979497", "0.5966058", "0.5958738", "0.59579456", "0.5957759", "0.5956938", "0.5951788", "0.59511644", "0.59423065", "0.59373474", "0.59361076", "0.59361076", "0.59331447", "0.5928005", "0.5924882", "0.5924011", "0.59169155", "0.5908037", "0.5907541", "0.59061426", "0.59056246", "0.5897408", "0.58960444", "0.58951247", "0.5893136", "0.5892312", "0.5890385", "0.58853275", "0.58801144", "0.58784765", "0.5872648", "0.58682626", "0.5867028", "0.58661693", "0.586578", "0.58643955", "0.5863193", "0.58609086", "0.5859997", "0.5858935", "0.5858632", "0.5853379", "0.5852741", "0.584806", "0.5847703" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def profile_params params.require(:profile).permit(:first_name, :last_name, :graduation_year, :major, :trainer_name, :gpa) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
thanks to Yanis Triandaphilov for the recommendation, sourced from his blog
def should_see(text) expect(page).to have_content(text) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def schubert; end", "def formation; end", "def terpene; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def anchored; end", "def suivre; end", "def stderrs; end", "def berlioz; end", "def verdi; end", "def intensifier; end", "def who_we_are\r\n end", "def trd; end", "def custom; end", "def custom; end", "def villian; end", "def refutal()\n end", "def offences_by; end", "def weber; end", "def dh; end", "def jack_handey; end", "def malts; end", "def identify; end", "def blg; end", "def operations; end", "def operations; end", "def schumann; end", "def implementation; end", "def implementation; end", "def bs; end", "def transformations; end", "def celebration; end", "def isolated; end", "def isolated; end", "def gounod; end", "def romeo_and_juliet; end", "def r; end", "def r; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def mitch_hedberg; end", "def tld; end", "def tld; end", "def feruchemist; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def upc_e; end", "def strategy; end", "def herald; end", "def sitemaps; end", "def rassoc(p0) end", "def sld; end", "def hd\n \n end", "def parslet; end", "def parslet; end", "def parslet; end", "def parslet; end", "def silly_adjective; end", "def zuruecksetzen()\n end", "def escaper; end", "def ismn; end", "def strain; end", "def king_richard_iii; end", "def parts; end", "def parts; end", "def parts; end", "def guct\n end", "def internal; end", "def ibu; end", "def scientist; end", "def extra; end", "def alt; end", "def invention; end", "def loc; end", "def loc; end", "def loc; end", "def transforms; end", "def processor; end", "def hiss; end", "def rossini; end", "def user_os_complex\r\n end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def original; end", "def eplore\n end", "def in_law; end", "def same; end" ]
[ "0.72850204", "0.6739374", "0.651189", "0.6334494", "0.6247382", "0.6218363", "0.6218363", "0.6218363", "0.6218363", "0.61617327", "0.61543614", "0.6097425", "0.60290647", "0.60123974", "0.60090643", "0.60081697", "0.6002864", "0.59991914", "0.59991914", "0.5987713", "0.5947757", "0.591892", "0.58675826", "0.5832809", "0.5829221", "0.5828451", "0.5828195", "0.5798794", "0.57845044", "0.57845044", "0.5773968", "0.5767585", "0.5767585", "0.57124764", "0.5707181", "0.5666996", "0.5655342", "0.5655342", "0.5648526", "0.5619684", "0.5618712", "0.5618712", "0.56089795", "0.56089795", "0.5608978", "0.5602862", "0.5602862", "0.56025857", "0.55993515", "0.55993515", "0.55993515", "0.55993515", "0.55993515", "0.55993515", "0.55947065", "0.5586636", "0.5536993", "0.5529718", "0.55276716", "0.55247736", "0.5522732", "0.55199844", "0.55199844", "0.55199844", "0.55199844", "0.5518152", "0.5516394", "0.55076283", "0.55041856", "0.5495445", "0.549323", "0.54837227", "0.54837227", "0.54837227", "0.54827577", "0.5481355", "0.5479454", "0.54726845", "0.54613847", "0.5451597", "0.54507625", "0.54463863", "0.54463863", "0.54463863", "0.5445002", "0.5444901", "0.5441834", "0.5437596", "0.5437534", "0.54357374", "0.54357374", "0.54357374", "0.54357374", "0.54357374", "0.54357374", "0.54357374", "0.54357374", "0.5431811", "0.54312277", "0.54207253", "0.54160255" ]
0.0
-1
Use the Euclidean algorithm, but don't do it recursively because Ruby does not have TCO turned on by default.
def greatest_common_divisor(slice_dimension) width = slice_dimension[0] length = slice_dimension[1] while length != 0 remainder = width % length width = length length = remainder end width end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extended_euclidean_algorithm(a, b)\n s, old_s = 0, 1\n t, old_t = 1, 0\n r, old_r = b, a\n while r != 0\n quotient = old_r / r\n old_r, r = r, old_r - quotient * r\n old_s, s = s, old_s - quotient * s\n old_t, t = t, old_t - quotient * t\n end\n [old_r, old_s, old_t]\nend", "def euclidean_algorithm(x, y)\n smaller, larger = [x, y].sort\n quotient = larger / smaller\n remainder = larger % smaller\n puts \"#{remainder} = #{larger} - #{quotient} * #{smaller}\"\n case remainder\n when 0 then puts 'No solutions'\n when 1 then return\n else euclidean_algorithm smaller, remainder\n end\n end", "def euclidean(a, b, ctrl)\n rem = a % b\n if !rem.zero? && rem != 1\n euclidean(b, rem, rem)\n elsif rem.zero? && !(b == 1)\n b\n else\n 'Numbers are coprime'\n end\nend", "def euclidean_gcd(up, down)\n return up if down.zero?\n euclidean_gcd(down, up % down)\nend", "def euclidean_dist(c1,c2)\n Math.sqrt(c1.zip(c2).map{|p| (p[1]-p[0])**2}.reduce(:+))\n end", "def egcd(a, b)\n # let A, B = a, b \n s, t, u, v = 1, 0, 0, 1\n while 0 < b\n # loop invariant: a = sA + tB and b = uA + vB and gcd(a,b) = gcd(A,B)\n q = a/b\n a, b, s, t, u, v = b, (a%b), u, v, (s-u*q), (t-v*q) \n end \nreturn [a, s, t] \nend", "def sim_euclidean(prefs, person1, person2)\n #find items in common\n shared = {}\n prefs[person1].each do |k,v|\n if prefs[person2][k] != nil\n shared[k] = 1\n end\n end\n\n #both persons doesn't have anything in common\n if shared.length == 0\n return 0\n end\n\n #calculate sum of squares\n sum_of_squares = 0\n shared.each do |k,v|\n sum_of_squares += (prefs[person1][k] - prefs[person2][k]) ** 2\n end\n\n #return euclidean distance. 1 is added to denominator to avoid divide by zero\n 1/(1 + sqrt(sum_of_squares))\nend", "def euclidean(x1,x2,y1,y2,z1,z2,a1,a2)\n\t\n\tdistance= Math.sqrt(((x1 - x2) ** 2) + ((y1 - y2) ** 2) +((z1 - z2) ** 2) + ((a1 - a2) ** 2))\n\treturn distance\nend", "def euclideanDistance(obj1, obj2)\r\n\teuc = 0\r\n\tfor d in 0...obj1.length\r\n\t\teuc += (obj1[d] - obj2[d])**2\r\n\tend\r\n\tMath.sqrt(euc)\r\nend", "def gcd_euclides(a, b)\n while b != 0\n t = b\n b = a % b\n a = t\n end\n a\nend", "def euclid(a, b)\n\treturn a if b == 0\n\teuclid(b, a % b)\nend", "def euclidean_distance(other)\n # Create an array of pairs by merging each element of self with the corresponding element from other,\n # calculate (a - b) ^ 2 for all pairs, where a is the first element and b is the second element,\n # add the results together and return the square root of the result\n Math.sqrt zip(other).map { |a, b| (a - b) ** 2 }.sum\n end", "def euclidean_distance(a, b)\n Math.sqrt ( a.zip(b).map { |n| n.reduce(:-) }.map { |n| n**2 }.reduce(:+) )\nend", "def gcd(x, y) # finds greatest common factor of x,y\n while y != 0\n t = y\n y = x % y\n x = t\n end\n x\nend", "def sqrt_convergents()\r\n\tthe_div = [1, 2]\t\t# Numerator and Denominator\r\n\titerations = 1000\r\n\treturner = 0\r\n\r\n\twhile iterations > 0\r\n\t\t# Every next fraction has previouse one in the denominator.\r\n\t\tthe_div = [the_div[1], 2*the_div[1] + the_div[0]]\t\t# Simplify the fraction.\r\n\t\tto_test = the_div[0] + the_div[1]\t\t\t\t\t\t# 1 + fraction\r\n\t\treturner += 1 if to_test.to_s.size > the_div[1].to_s.size\r\n\t\titerations -= 1\r\n\tend\r\n\treturn returner\r\nend", "def extended_euclid(a, b)\n if a < b\n swap_values = true\n end\n\n if swap_values\n a, b = b, a\n end\n\n remainders = []\n quotients = []\n a_tmp, b_tmp = a, b\n while a_tmp % b_tmp > 0\n remainders.push(a_tmp % b_tmp)\n quotients.push(a_tmp / b_tmp)\n\n a_tmp, b_tmp = b_tmp, a_tmp % b_tmp\n end\n\n x_tmp, y_tmp = 1, -quotients[-1]\n quotients.take(quotients.size - 1).reverse.each do |quotient|\n x_tmp, y_tmp = y_tmp, x_tmp - y_tmp * quotient\n end\n\n unless x_tmp*a + y_tmp*b == remainders[-1]\n raise 'Failed to compute Bezout coefficients'\n end\n\n if swap_values\n x_tmp, y_tmp = y_tmp, x_tmp\n end\n\n return x_tmp, y_tmp\nend", "def cumulative_euclidean_distance(other_user)\n sum = common_bands(other_user).map { |band| square_of_rating_difference(other_user, band) }.sum\n Math.sqrt(sum)\n end", "def extended_lehmer_gcd(a, b)\r\n\t\td0 = a\r\n\t\tu0 = 1\t# d0 = a * u0 + b * v0\r\n\t\td1 = b\r\n\t\tu1 = 0\t# d1 = a * u1 + b * v1\r\n\r\n\t\tloop do\r\n\t\t\tif d1.instance_of?(Fixnum)\r\n\t\t\t\t_u, _v, d = extended_gcd(d0, d1)\r\n\r\n\t\t\t\t# here\r\n\t\t\t\t# d == _u * d0 + _v * d1\r\n\t\t\t\t# d0 == u0 * a + v0 * b\r\n\t\t\t\t# d1 == u1 * a + v1 * b\r\n\r\n\t\t\t\tu = _u * u0 + _v * u1\r\n\t\t\t\tv = (d - u * a) / b\r\n\r\n\t\t\t\treturn u, v, d\r\n\t\t\tend\r\n\r\n\t\t\t# Get most significant digits of d0 and d1\r\n\t\t\tshift_size = (d0 < d1 ? d1 : d0).bit_size - FIXNUM_BIT_SIZE\r\n\t\t\ta_ = d0 >> shift_size\r\n\t\t\tb_ = d1 >> shift_size\r\n\r\n\t\t\t# Initialize (Here a_ and b_ are next value of d0, d1)\r\n\t\t\t_A = 1\r\n\t\t\t_B = 0\t# a_ == msd(d0) * _A + msd(d1) * _B\r\n\t\t\t_C = 0\r\n\t\t\t_D = 1\t# b_ == msd(d0) * _C + msd(d1) * _D\r\n\r\n\t\t\t# Test Quotient\r\n\t\t\tuntil 0 == b_ + _C or 0 == b_ + _D\r\n\t\t\t\tq1 = (a_ + _B) / (b_ + _D)\r\n\t\t\t\tq2 = (a_ + _A) / (b_ + _C)\r\n\t\t\t\tbreak if q1 != q2\r\n\r\n\t\t\t\t# Euclidean step\r\n\t\t\t\t_A, _C = _C, _A - q1 * _C\r\n\t\t\t\t_B, _D = _D, _B - q1 * _D\r\n\t\t\t\ta_, b_ = b_, a_ - q1 * b_\r\n\t\t\tend\r\n\r\n\t\t\t# Multi-precision step\r\n\t\t\tif 0 == _B\r\n\t\t\t\tq, r = d0.divmod(d1)\r\n\t\t\t\td0, d1 = d1, r\r\n\t\t\t\tu0, u1 = u1, u0 - q * u1\r\n\t\t\telse\r\n\t\t\t\td0, d1 = d0 * _A + d1 * _B, d0 * _C + d1 * _D\r\n\t\t\t\tu0, u1 =u0 * _A + u1 * _B, u0 * _C + u1 * _D\r\n\t\t\tend\r\n\t\tend\r\n\tend", "def mandelbrot c, n\n result = c\n (1..n).each do |n|\n if result.abs > 2\n return n\n end\n result = result*result + c\n end\n return nil\nend", "def solution(n)\n # write your code in Ruby 2.2\n a = Math.sqrt(n).floor\n a -= 1 while n % a != 0\n b = n / a\n (a + b) * 2\nend", "def r\n v = 0\n # for e in @elements ; v += e*e ; end\n my_elems = @elements\n my_size = my_elems.size\n for i in 0..my_size-1 do\n e = my_elems[i]\n v += e * e\n end\n return Math.sqrt(v)\n end", "def gcd a,b\n if a<b\n gcd b,a\n elsif b==0\n a\n else\n gcd b,a%b\n end\nend", "def gcd2 a,b\n if a<b\n d,s,r = gcd2 b,a\n [d,r,s]\n elsif b==0\n [a,1,0]\n else\n x=a/b\n y=a%b\n d,r,s = gcd2 b,y\n # here we know that d = r*b+s*y, and a=x*b+y, so y=a-x*b\n # thus d=r*b+s*(a-x*b) = (r-s*x)*b + s*a\n # so we return [d,s,r-s*x]\n # uncomment the following three lines to see this work out\n # puts \"#{a}=#{x}*#{b}+#{y}\"\n # puts \"#{d}=#{s}*#{a} + #{(r-s*x)}*#{b}\"\n [d,s,(r-s*x)]\n end\nend", "def solve\n squares = (1..500).to_a.map{ |i| i*i }\n squares.each do |a2|\n squares.each do |b2|\n c2 = a2 + b2\n if squares.include? c2\n a = Math.sqrt(a2).to_i\n b = Math.sqrt(b2).to_i\n c = Math.sqrt(c2).to_i\n if ( a + b + c ) == 1000\n return a * b * c\n end\n end\n end\n end\nend", "def euclid point1, point2\n\treturn Math.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2)\nend", "def test_ce_deBoer_2\n NArray.srand(567) # must use NArray's generator, not Ruby's\n\n # Cost matrix\n n = 5\n c = NArray[[0,1,3,5,6],\n [1,0,3,6,5],\n [3,3,0,2,2],\n [5,6,2,0,2],\n [6,5,2,2,0]]\n\n mp = CrossEntropy::MatrixProblem.new\n mp.pr = NArray.float(2, n).fill!(0.5)\n mp.pr[true,0] = NArray[0.0,1.0] # put vertex 0 in subset 1\n mp.num_samples = 50\n mp.num_elite = 5\n mp.max_iters = 10\n smooth = 0.4\n\n max_cut_score = proc do |sample|\n weight = 0\n for i in 0...n\n for j in 0...n\n weight += c[j,i] if sample[i] < sample[j]\n end\n end\n -weight # to be minimized\n end\n best_cut = NArray[1,1,0,0,0]\n assert_equal(-15, max_cut_score.call(NArray[1,0,0,0,0]))\n assert_equal(-28, max_cut_score.call(best_cut))\n\n mp.to_score_sample(&max_cut_score)\n\n mp.to_update do |pr_iter|\n smooth*pr_iter + (1 - smooth)*mp.pr\n end\n\n mp.for_stop_decision do\n #p mp.pr\n mp.num_iters >= mp.max_iters\n end\n\n mp.solve\n\n if best_cut != mp.most_likely_solution\n warn \"expected #{best_cut}; found #{mp.most_likely_solution}\" \n end\n assert mp.num_iters <= mp.max_iters\n end", "def euclidean_priority(x)\n priority = 0\n 0.upto(x.size-1) { |i|\n priority += (x[i] - @instance.final_capacities[i])**2\n }\n return Math.sqrt(priority).round\n end", "def euc_2d(c1, c2)\n Math.sqrt((c1[0] - c2[0])**2.0 + (c1[1] - c2[1])**2.0).round\nend", "def gcd(u,v)\n u, v = u.abs, v.abs\n while v > 0\n u, v = v, u % v\n end\n u\nend", "def euler006\n square_of_sum = (1..100).reduce(:+) ** 2\n sum_of_squares = (1..100).inject { |sum, n| sum + n*n }\n\n return square_of_sum - sum_of_squares\nend", "def alg; end", "def gcd(p0) end", "def solution(a, b)\n # write your code in Ruby 1.9.3\n a = 0 if a < 0\n return 0 if b<0\n return Math.sqrt(b).floor - Math.sqrt(a).ceil + 1\nend", "def gcd_ex(x, y)\n s1 = t0 = 0\n s0 = t1 = 1\n until y.zero?\n x, (q, y) = y, divmod(x, y)\n s0, s1 = s1, s0 - q*s1\n t0, t1 = t1, t0 - q*t1\n # puts \"x=#{x} y=#{y} s0=#{s0} s1=#{s1} t0=#{t0} t1=#{t1} q=#{q}\"\n end\n return x, s0, t0, t1, s1\n end", "def egcd(a, n)\n t, newt = [0, 1]\n r, newr = [n, a]\n until newr == 0\n q = r / newr\n t, newt = [newt, t - q * newt]\n r, newr = [newr, r - q * newr]\n end\n [r, t]\nend", "def gcd (v,u)\n if (u==v)\n return v\n elsif (u>v)\n u-=v\n gcd(v,u)\n else\n gcd(u,v)\n end\nend", "def ext_euclid(a, b)\n if (a%b).zero?\n return [0, 1]\n else\n x, y = ext_euclid(b, a%b)\n return [y, x-y*(a/b)]\n end\nend", "def gcd( a, b )\n return a if b.zero?\n gcd b, a % b\nend", "def gcd x, y\n r = x % y # r - remainder\n if r == 0\n y\n else\n gcd(y, r)\n end\nend", "def cliquishness(node)\n neighbors = @graph[node].keys\n sg = subgraph(neighbors)\n if sg.graph.size != 0\n edges = sg.edges / 2.0\n nodes = sg.nodes\n complete = (nodes * (nodes - 1)) / 2.0\n return edges/complete\n else\n return 0.0\n end\n end", "def solve( n = 1_000_000_000_000 )\n # From the problem statement, n = dq + r and d = kr, q = kd for some k.\n # (We could set q = kr and d = kq instead, but it doesn't really matter\n # which convention we adopt.) From this we infer r < d < q. We also know\n # k must be rational or d, q wouldn't be integer values, so k = a/b. Then\n # d = ar/b and q = ad/b = (a^2)r/(b^2). Since a and b are coprime (other-\n # wise k could be reduced until they were), b^2 must divide r, which means\n # r = cb^2 for some c.\n #\n # Combining these facts, we have r = (b^2)c, d = ar/b = a(b^2)c/b = abc,\n # and q = (a^2)(b^2)c/(b^2) = (a^2)c. Substituting into n = dq + r we ob-\n # tain n = (abc)(a^2)c + (b^2)c = (a^3)b(c^2) + (b^2)c. The dominant term\n # is a^3, which must be < n, so use it as an outer limit as we search for\n # b, c values that generate perfect squares.\n\n # Create a hash of perfect squares to simplify future checks.\n sq = {}\n (1..Math.sqrt( n )).each {|i| sq[i*i] = i}\n\n # Upper bound on values of a.\n lim = Math.cbrt( n )\n sum = []\n\n (2...lim).each do |a|\n a3 = a*a*a\n (1...a).each do |b|\n m = b*(a3 + b)\n break if m > n\n next unless b.coprime?( a )\n\n c = 1\n while m < n\n sum << m if sq.has_key?( m )\n c += 1\n m = b*c*(a3*c + b)\n end\n end\n end\n\n sum.reduce( :+ )\n end", "def gcd(a,b)\n return b if a % b == 0\n return gcd(b, a % b)\nend", "def compute\n perimeter = 1000\n (1..(perimeter+ 1)).each do |a|\n ((a + 1)..(perimeter + 1)).each do |b|\n c = perimeter - a - b\n return (a * b * c).to_s if (a * a + b * b == c * c)\n end\n end\nend", "def dist(r1, c1, r2, c2)\r\n return Math.sqrt((c1-c2)**2 + (r1-r2)**2)\r\nend", "def solution1\n n = 1000\n\n (1..n).each do |a|\n (1..n).each do |b|\n (1..n).each do |c|\n # d = 3rd root of (a**3 + b**3 - c**3)\n d = (a**3 + b**3 - c**3)**(1 / 3)\n print [a, b, c, d] if a**3 + b**3 == c**3 + d**3\n end\n end\n end\nend", "def my_gcd(*args)\r\n\targs.inject do |memo, num|\r\n\t\tuntil [memo, num].include?(0)\r\n\t\t\tmod = memo % num\r\n\t\t\tmemo, num = num, mod\r\n\t\tend\r\n\t\t[memo, num].max\r\n\tend\r\nend", "def gcd(x, y)\n until y.zero?\n # puts \"#{x} #{y}\"\n x, y = y, mod(x, y)\n end\n x\n end", "def gcd(x, y)\n if (y == 0)\n return x\n else\n gcd(y, x%y)\n end\nend", "def gcd(a, b)\n if a % b == 0\n b\n else\n gcd(b, a % b)\n end\nend", "def gcd(a, b)\r\n if b == 0\r\n return a\r\n else\r\n return gcd(b, a % b)\r\n end\r\nend", "def solution(a, b, k)\n # write your code in Ruby 2.2\n e = b / k\n s = (a-1) / k\n\n e - s\nend", "def extended_binary_gcd(a, b)\r\n\t\tif a < b\r\n\t\t\ta, b = b, a\r\n\t\t\texchange_flag_1 = true\r\n\t\tend\r\n\r\n\t\tif 0 == b\r\n\t\t\treturn 0, 1, a if exchange_flag_1\r\n\t\t\treturn 1, 0, a\r\n\t\tend\r\n\r\n\t\t# Reduce size once\r\n\t\t_Q, r = a.divmod(b)\r\n\t\tif 0 == r\r\n\t\t\treturn 1, 0, b if exchange_flag_1\r\n\t\t\treturn 0, 1, b\r\n\t\tend\r\n\t\ta, b = b, r\r\n\r\n\t\t# Compute power of 2\r\n\t\t_K = 0\r\n\t\t_K += 1 while 0 == a[_K] and 0 == b[_K]\r\n\t\tif 0 < _K\r\n\t\t\ta >>= _K\r\n\t\t\tb >>= _K\r\n\t\tend\r\n\r\n\t\tif b.even?\r\n\t\t\ta, b = b, a\r\n\t\t\texchange_flag_2 = true\r\n\t\tend\r\n\r\n\t\t# Initialize\r\n\t\tu = 1\r\n\t\td = a\t# d == a * u + b * v, (v = 0)\r\n\t\tu_ = 0\r\n\t\td_ = b\t# d_ == a * u_ + b * v_, (v_ = 1)\r\n\r\n\t\t# Remove intial power of 2\r\n\t\twhile d.even?\r\n\t\t\td >>= 1\r\n\t\t\tu += b if u.odd?\r\n\t\t\tu >>= 1\r\n\t\tend\r\n\r\n\t\tloop do\r\n\t\t\t# Substract\r\n\t\t\tnext_u = u - u_\r\n\t\t\tnext_d = d - d_\t\t# next_d == a * next_u + b * next_v\r\n\t\t\tnext_u += b if next_u < 0\r\n\r\n\t\t\tbreak if 0 == next_d\r\n\r\n\t\t\t# Remove powers of 2\r\n\t\t\twhile next_d.even?\r\n\t\t\t\tnext_d >>= 1\r\n\t\t\t\tnext_u += b if next_u.odd?\r\n\t\t\t\tnext_u >>= 1\r\n\t\t\tend\r\n\r\n\t\t\tif 0 < next_d\r\n\t\t\t\tu = next_u\r\n\t\t\t\td = next_d\r\n\t\t\telse\r\n\t\t\t\tu_ = b - next_u\r\n\t\t\t\td_ = -next_d\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\tv = (d - a * u) / b\r\n\r\n\t\tu, v = v, u if exchange_flag_2\r\n\t\td <<= _K\r\n\t\tu, v = v, u - v * _Q\r\n\t\tu, v = v, u if exchange_flag_1\r\n\r\n\t\treturn u, v, d\r\n\tend", "def cost_of_transformation(magic_square, non_magic_square)\n cost = 0\n (0..2).each do |row|\n (0..2).each do |column|\n magic = magic_square[row][column]\n non_magic = non_magic_square[row][column]\n cost += (non_magic - magic).abs\n end\n end\n return cost\nend", "def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend", "def euler028 n\n (4*n**3 + 3*n**2 + 8*n - 9) / 6\nend", "def pythagorean_triplet(target)\n (1..1000).to_a.each do |a|\n (a..1000).to_a.each do |b|\n (b..1000).to_a.each do |c|\n if a + b + c == target && a**2 + b**2 == c**2\n return a * b * c\n end\n end\n end\n end\n\n nil\nend", "def common a\n a.reduce :gcd\nend", "def cliquishness(node)\n neighbors = @graph[node].keys\n sg = subgraph(neighbors)\n if sg.graph.size != 0\n edges = sg.edges\n nodes = neighbors.size\n complete = (nodes * (nodes - 1))\n return edges.quo(complete)\n else\n return 0.0\n end\n end", "def gcd(a,b)\n while a != b\n if a > b\n return gcd(a - b,b)\n else\n return gcd(a , b - a)\n end\n end\n return a\nend", "def sum_differences_between_products_and_LCMs(pairs)\n result = 0\n pairs.each do |pair|\n product = pair.inject(:*)\n lcm = product/gcd(pair.first, pair.last)\n result += product - lcm\n end\n result\nend", "def gcd(num1, num2)\n\n loop do\n remainder = num1 % num2\n break if remainder == 0\n num1 = num2\n num2 = remainder\n end\n\n num2\nend", "def gcd(a, b)\n return a if b == 0\n\n remiander = a % b\n return gcd(b, remiander)\nend", "def euclidian_distance array1, array2\n Math.sqrt(array1.zip(array2).inject(0){|a,(v1,v2)| a+(v2-v1)**2})\nend", "def crt(r, m)\n raise ArgumentError if r.size != m.size\n \n n = r.size\n r0, m0 = 0, 1\n n.times{ |i|\n raise ArgumentError if m[i] < 1\n\n r1, m1 = r[i]%m[i], m[i]\n if m0 < m1 then\n r0, r1 = r1, r0\n m0, m1 = m1, m0\n end\n\n if m0%m1 == 0 then\n return [0, 0] if r0%m1 != r1\n next\n end\n\n g, im = inv_gcd(m0, m1)\n u1 = m1/g\n return [0, 0] if (r1-r0)%g != 0\n\n x = (r1-r0)/g*im%u1\n r0 += x*m0\n m0 *= u1\n r0 += m0 if r0 < 0\n }\n\n return [r0, m0]\nend", "def special_pythag_trip(target_sum)\n\ta = 1\n\tb = 1\n\tfor a in (1..target_sum) do\n\t\tfor b in (1..target_sum) do\n\t\t\t#puts \"a : #{a}\"\n\t\t\t#puts \"b : #{b}\"\n\t\t\tsum_of_squares = a*a + b*b\n\t\t\tc = Math.sqrt(sum_of_squares).to_i\n\t\t\t\n\t\t\tif c*c == sum_of_squares\n\t\t\t\ttriple = [a,b,c] \n\t\t\t\tsum = triple.inject(0) {|sum,num| sum + num}\n\t\t\t\t\n\t\t\t\treturn triple[0]*triple[1]*triple[2] if sum == target_sum\n\t\t\tend\n\t\t\t\n\t\tend\n\t\n\tend\nend", "def gcd(x, y)\n x == 0 ? y : gcd(y % x, x)\nend", "def euler016\n (2 ** 1000).to_s.split('').map { |x| x.to_i }.reduce(:+)\nend", "def p9\n\ta, x = 1, 1000\n\tloop do\n\t\tb = (2.0 * x * a - x ** 2.0) / (2.0 * a - 2.0 * x)\n\t\tif (b % 1).zero?\n\t\t\tc = (a ** 2 + b ** 2) ** 0.5\n\t\t\tputs triplet = [a,b,c].to_a\n\t\t\treturn triplet.reduce(:*)\n\t\tend\n\t\ta += 1\n\tend\nend", "def extended_gcd(a, b)\r\n\t\tu0 = a.class.one\r\n\t\tu1 = a.class.zero\r\n\r\n\t\treturn u0, u1, a if b.zero?\r\n\r\n\t\td0 = a\t# d0 = a * u0 + b * v0\r\n\t\td1 = b\t# d1 = a * u1 + b * v1\r\n\r\n\t\tloop do\r\n\t\t\tq, r = d0.divmod(d1)\r\n\r\n\t\t\treturn u1, (d1 - a * u1) / b, d1 if r.zero?\r\n\r\n\t\t\td0, d1 = d1, r\r\n\t\t\tu0, u1 = u1, u0 - q * u1\r\n\t\tend\r\n\tend", "def euler_from_two(max, a, b)\n euler_product(max, a) + euler_product(max, b) - euler_rest_from_two(max, a, b)\nend", "def euclidean_distance(s1, s2)\n d2 = 0.0\n get_features.each do |f|\n if s1.has_key? f and s2.has_key? f\n d2 += (s1[f]-s2[f])**2\n end\n end\n \n Math.sqrt(d2)\n end", "def my_lcm(*args)\r\n\targs.inject do |memo, num|\r\n\t\tproduct = memo * num\r\n\t\tproduct / my_gcd(memo, num)\r\n\tend\r\nend", "def solve!\n mapping = [4, 7, 9]\n @matrix[0..2].each { |row| mapping.each { |idx| raise 'invalid equations system' unless (1 - row.fetch(idx)).zero_eps? }}\n\n first = @matrix.fetch(0)\n second = @matrix.fetch(1)\n third = @matrix.fetch(2)\n\n @matrix[1..2].each { |row| row.subtract!(first) }\n second.normalize_term!(2)\n third.normalize_term!(2).subtract!(second) unless third.fetch(2).zero_eps?\n third.normalize_term!(3)\n second.normalize_term!(3).subtract!(third).normalize_term!(2) unless second.fetch(3).zero_eps?\n\n mapping = [4, 1, 0]\n {1 => 7, 2 => 9}.each do |ri, ci|\n row = @matrix.fetch(ri)\n mapping.zip(sum_square(row.fetch(1), row.fetch(0))).each do |idx, val|\n first[idx] += val\n end\n first[ci] -= 1.0\n end\n\n first.normalize_term!(2).subtract!(second) unless first.fetch(2).zero_eps?\n first.normalize_term!(3).subtract!(third) unless first.fetch(3).zero_eps?\n first.normalize_term!(4)\n\n coefs = mapping.map { |idx| first.fetch(idx) }\n mapping = Set.new(mapping)\n first.each_with_index { |val, idx| raise 'calculating error' unless mapping.include?(idx) || val.zero_eps? }\n delta = coefs[1] ** 2 - 4 * coefs[0] * coefs[2]\n raise 'negative or zero discriminant' if delta <= 0 || delta.zero_eps?\n delta = Math.sqrt(delta)\n\n root_x = ->(delta_sqrt) { (delta_sqrt - coefs[1]) / (2 * coefs[0]) }\n root_yz = ->(x, row) { -(row.fetch(0) + x * row.fetch(1)) }\n @roots = [delta, -delta].map do |x|\n x = root_x.call(x)\n [x, root_yz.call(x, second), root_yz.call(x, third)]\n end\n end", "def euclides_extendido(a,b)\n #condicion para comprobar si el numero b es mayor que a si es asi se hace un swap\n x,z=[],[]\n t_primo=false\n if(b.to_i>a.to_i)\n x[1],x[2]=b.to_i,a.to_i\n else\n x[1],x[2]=a.to_i,b.to_i\n end\n z[0],z[1]=0,1\n i=1\n r=x[1]%x[2]\n #puts \"resto al comienzo: #{r}\"\n if r==0\n t_primo=false\n else\n while(r>0)\n #puts \"#{\"=\"*30}\"\n #puts \"ITERACION #{i}\"\n #puts \"x[i-1]=#{x[i-1]}\"\n #puts \"x[i]=#{x[i]}\"\n #puts \"z[i-1]=#{z[i-1]}\"\n #puts \"z[i]=#{z[i]}\"\n if(i>=2)\n #puts \"entre...\"\n z[i]=(-1*((x[i-1]/x[i]).to_i))*z[i-1]+z[i-2]\n x[i+1]=x[i-1]%x[i]\n #puts \"z[i]=#{z[i]}\"\n #puts \"x[i+1]=#{x[i+1]}\"\n end\n r=x[i+1]\n mcd=x[i]\n if(mcd==1)\n t_primo=true\n #en caso de que el inverso de negativo, se suma al numero mayor que se paso a la función.\n if(z[i-1]<0)\n @inverso=z[i-1]+x[1]\n else\n @inverso=z[i-1]\n end\n end\n i+=1\n #puts \"#{\"=\"*30}\"\n end\n\n end\n puts \"MCD: #{mcd}\"\n puts \"INVERSO: #{@inverso}\"\n t_primo\n end", "def findlcm(a,b)\n a.lcm(b)\nend", "def gcf(num1, num2)\n\tx = num1 < num2 ? num1 : num2\n\twhile x > 1 do\n\t\tif num1 % x == 0 && num2 % x == 0\n\t\t\treturn x\n\t\tend\n\t\tx -= 1\n\tend\n\treturn 1\nend", "def erlang_c(m, u)\n d = power_fact(m, u)\n s = 1.0\n (1..(m - 1)).each do |k|\n s += power_fact(k, u)\n end\n d / (d + (1 - u / m) * s)\n end", "def d(n)\r\n proper_divisors(n).reduce(:+)\r\nend", "def gcd(a,b)\n if (b==0)\n a\n else\n gcd(b,a%b)\n end\nend", "def gecos(*) end", "def calculateDistance(r1,c1,r2,c2)\r\n\treturn Math.sqrt(((c1-c2) ** 2 + (r1 -r2) ** 2))\r\nend", "def problem5 ( )\n lcm_1_to_n(20)\nend", "def find_concealed_square\n droot_endings = [\"1\",\"4\",\"7\",\"9\"]\n (0..9).each do |eighth|\n (0..9).each do |seventh|\n (0..9).each do |sixth|\n (0..9).each do |fifth|\n (0..9).each do |fourth|\n (0..9).each do |third|\n (0..9).each do |second|\n (0..9).each do |first|\n test_val = \"1#{first}2#{second}3#{third}4#{fourth}5#{fifth}6#{sixth}7#{seventh}8#{eighth}9\".to_i\n p test_val\n next if !droot_endings.include?(digital_root(test_val).to_s)\n if Math.sqrt(test_val) % 1 == 0\n return Math.sqrt(test_val) * 10\n end \n end\n end\n end\n end\n end\n end\n end\n end \n return \"not found!\"\nend", "def euc_2d(c1, c2)\n Math.sqrt((c1[0] - c2[0])**2.0 + (c1[1] - c2[1])**2.0).round\n end", "def gcd(a, b)\n return a if b == 0\n div = a % b\n gcd(b, div)\nend", "def lcm(*args)\n args.reduce(&:lcm)\nend", "def GCD(a, b)\n \n a, b = a.abs, b.abs\n\n # Always b => a\n if (a < b)\n a,b = b, a\n end\n while not (a == 0 or b == 0)\n a, b = b, a % b\n end\n\n if a == 0\n return b\n elsif b == 0\n return a\n end\n \nend", "def each_e\n (2...@phi).each{|e|\n next unless @phi.gcd(e) == 1\n yield(e)\n }\n end", "def gcd(a,b)\n return gcd(b, a) if a > b\n return b if a == 0\n gcd(b % a, a)\nend", "def gcd2test a,b\n d,r,s = gcd2 a,b\n z = r*a+s*b\n return z==d\nend", "def gcd(a,b)\n\treturn a if b === 0\n\treturn gcd(b, a % b)\nend", "def sum_of_cubes(a, b)\n=begin \n sum = 0\n (a..b).each do |n|\n sum += n*n*n\n end\n sum\n=end \n (a..b).reduce(0) { |a, b| a + b ** 3 }\nend", "def diophantine_solve(d)\n return nil if Math.sqrt(d).to_i ** 2 == d\n num = 0\n upto = 100_000_000\n df = d.factors.last\n x = df\n loop do\n# puts \"x -> #{x} df -> #{df}\"\n xxp = (x+1)**2\n xxn = (x-1)**2\n\n [xxp,xxn].each do |xxv| \n# puts \"try => #{xxv}\"\n# xxv = xv**2 - 1\n dd = xxv % d\n if dd == 1 || dd == (d-1)\n# puts \"A\"\n yyv = (xxv-1) / d\n y = Math.sqrt(yyv).to_i\n if y * y == yyv\n# puts \"(#{Math.sqrt(xxv).to_i},#{d},#{y})\"\n x = Math.sqrt(xxv).to_i\n return [x,d,y]\n end\n end\n end\n x += df\n if x > upto\n puts x\n upto += 100_000_000\n end\n end\n [x,d,y]\n end", "def qytt\n # procure the numbers\n arrNumbers = [ arrNumbersOfProcGivenMinMax( method(:intGetTriangleInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetSquareInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetPentagonalInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetHexagonalInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetHeptagonalInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetOctagonalInt), 1000, 10000) ]\n arrNumbers.map! do |arr|\n deletable = []\n arr.each do |num|\n if ( num / 10 % 10 == 0 )\n deletable << num\n end\n end\n arr -= deletable\n end\n\n # get the hash numbers which we will jump to and from\n hashNumbers = Array.new(6){ HashChained.new }\n (0..5).each do |i|\n arrNumbers[i].each do |num|\n hashNumbers[i][num/100] = num % 100\n end\n end\n\n threads = []\n # we're guaranteed only one solution\n superResult = 0\n\n # iterate through the octagonal numbers\n arrNumbers.last.each do | firstNum |\n checker = firstNum % 100\n hashNumbers[0..4].permutation.each do |perm|\n t = Thread.new do\n result = qyttRecursion( checker, perm )\n if result[0] > 0 && result[1] == firstNum / 100\n superResult = result[0] + firstNum\n end\n end\n threads << t\n end\n end\n\n threads.each do |t|\n t.join\n end\n superResult\n\nend", "def choleski(n, a)\n n = n - 1\n\n l = Array.new(n + 1) { Array.new(n + 1) { 0 } }\n l[0][0] = Math::sqrt(a[0][0])\n\n (1..n).each do |i|\n l[i][0] = a[i][0].fdiv(l[0][0])\n end\n\n l[1][1] = Math::sqrt(a[1][1] - l[1][0] ** 2)\n\n (2..n).each do |i|\n (1..i - 1).each do |j|\n sumatoria = (0..j - 1).inject(0) { |sum, k| sum + l[i][k] * l[j][k] }\n l[i][j] = (a[i][j] - sumatoria).fdiv(l[j][j])\n end\n\n sumatoria = (0..i - 1).inject(0) { |sum, k| sum + l[i][k] ** 2 }\n l[i][i] = Math::sqrt(a[i][i] - sumatoria)\n end\n\n puts \"Las componentes lij de la matriz L son #{l}.\"\n return l\nend", "def bench_my_algorithm\r\n assert_performance_linear 0.9999 do |n| # n is a range value\r\n n.times do\r\n @obj.my_algorithm\r\n end\r\n end\r\n end", "def ext_gcd(other)\n\t\tif @bits == 0\n\t\t\treturn F2_poly.new(other.bits), F2_poly.new(0), F2_poly.new(1)\n\t\tend\n\t\tif other.bits == 0\n\t\t\treturn F2_poly.new(@bits), F2_poly.new(1), F2_poly.new(0)\n\t\tend\n\n\t\tsprime = 1\n\t\tt = 1\n\t\ts = 0\n\t\ttprime = 0\n\t\tc = @bits\n\t\td = other.bits\n\n\t\twhile true\n\t\t\tq, r = F2_poly.iquot_and_rem(c, d)\n\t\t\tif r == 0\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tc = d\n\t\t\td = r\n\t\t\tsprime, s = s, sprime ^ F2_poly.bit_mul(q, s)\n\t\t\ttprime, t = t, tprime ^ F2_poly.bit_mul(q, t)\n\t\tend\n\t\treturn F2_poly.new(d), F2_poly.new(s), F2_poly.new(t)\n\tend", "def xgcd_iter(x, y)\n a, next_a = 1, 0\n b, next_b = 0, 1\n while y != 0\n a, next_a = next_a, a-x/y*next_a\n b, next_b = next_b, b-x/y*next_b\n x, y = y, x%y\n end\n [x, a, b]\nend", "def gcd(a, b)\n if (b == 0) then a\n else gcd(b, a % b)\n end\nend", "def gcd(a, b)\n if b == 0\n return a\n else\n return gcd(b, a%b)\n end\nend", "def euler012\n each_triangle_number do |n, index|\n return n if n.factors.size > 500\n end\nend" ]
[ "0.7206893", "0.7031616", "0.65744257", "0.6405042", "0.6133944", "0.60679626", "0.59150535", "0.5907035", "0.583164", "0.5831026", "0.58079976", "0.5768717", "0.57666224", "0.57657146", "0.5695695", "0.5643277", "0.5641509", "0.5627073", "0.5592513", "0.5559506", "0.54780376", "0.54688644", "0.5462515", "0.5454066", "0.5452203", "0.5450446", "0.542855", "0.5428104", "0.5399505", "0.53866434", "0.5361543", "0.53583777", "0.5331127", "0.5329195", "0.5312653", "0.5311945", "0.5304381", "0.5302229", "0.5301058", "0.5279024", "0.5275138", "0.52739346", "0.52710515", "0.52555645", "0.5254883", "0.52461076", "0.5237006", "0.52253306", "0.51955074", "0.51931036", "0.518841", "0.5185808", "0.5172242", "0.5172027", "0.5168", "0.5165492", "0.5163608", "0.51601243", "0.51575255", "0.5157002", "0.5154498", "0.51514524", "0.51512665", "0.5133921", "0.5132868", "0.5124534", "0.5119174", "0.51116323", "0.5109018", "0.5106906", "0.5104807", "0.5102761", "0.5095752", "0.50943524", "0.5091444", "0.50911963", "0.5088292", "0.5087021", "0.5085111", "0.5074326", "0.5071523", "0.50644565", "0.5062644", "0.5062606", "0.5055196", "0.5051604", "0.50472987", "0.5037149", "0.5015695", "0.5014565", "0.50140315", "0.5010489", "0.49957263", "0.49938756", "0.49932623", "0.49905637", "0.4990095", "0.49865934", "0.49841702", "0.49810043", "0.49795273" ]
0.0
-1
removes any illegal email headers
def scrub_headers(headers) headers.select {|h| UserMailer.legal_headers.include? h} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_headers\n %w(return-receipt-to domainkey-signature dkim-signature)\n end", "def remove_delayed_message_header(headers)\n headers.reject { |k| k == \"x-delay\" }\n end", "def unrecognized_headers\n extra_headers = @transformed_headers - valid_headers\n extra_headers.each do |header|\n @warnings << \"The field name \\\"#{header}\\\" is not supported. This field will be ignored, and the metadata for this field will not be imported.\"\n end\n end", "def headerlist; return ['X-ZohoMail']; end", "def unrecognized_headers\n extra_headers = headers - valid_headers\n extra_headers.each do |header|\n @warnings << \"The field name \\\"#{header}\\\" is not supported. This field will be ignored, and the metadata for this field will not be imported.\"\n end\n end", "def remove_listlibrary_headers str\n # Lots of messages have Message-Id headers added;\n # Date headers were added to 3 in ruby-list, 2 in chipy\n # 3 messages in ruby-list have Date headers added\n # 2 messages in chipy have Date headers added\n while str =~ /^X-ListLibrary-Added-Header: (.*)$/\n header = $1 # Thanks, Perl\n header.sub!('\\n','') # yes, remove a literal \\n that yaml didn't parse\n str.sub!(/^#{header}: .*\\n/, '')\n str.sub!(/^X-ListLibrary-Added-Header: .*\\n/, '')\n end\n str\nend", "def clear_headers\n self.headers.delete_if { |k,v| true }\n \"headers cleared\"\n end", "def headers\n @headers ||= begin\n @mail.header.fields.inject({}) do |memo, field|\n name = field.name.downcase.to_s\n next memo if self.class.skipped_headers.include?(name)\n\n header = unquoted_header(name)\n memo.update(name => self.class.unescape(header))\n end\n end\n end", "def remove_fws headers_with_fws\n\t\theaders = Array.new\n\t\theaders_with_fws.each_line do |line|\n\t\t\tnext if line =~ /^\\s+$/ # If line is empty\n\t\t\tnext if line =~ /^((?!:)[\\s\\S])*$/ && headers.size == 0 # If they're trying to pull a fast one\n\t\t\tline =~ /^\\s/ ? headers[-1] += line.strip : headers << line.strip\n\t\tend\n\t\theaders\n\tend", "def delete_empty_headers(res)\n res[1].delete_if{|_, v| v.is_a?(String) && v.empty?}\n res\n end", "def unquoted_header(key)\n if header = @mail[key]\n value = header.respond_to?(:map) ?\n header.map { |h| h.value }.join(\"\\n\") :\n header.value\n Mail::Encodings.value_decode(value)\n else\n ''\n end\n end", "def remove_fws headers_with_fws\n headers = Array.new\n headers_with_fws.each_line do |line|\n next if line =~ /^\\s+$/ # If line is empty\n next if line =~ /^((?!:)[\\s\\S])*$/ && headers.size == 0 # If they're trying to pull a fast one\n line =~ /^\\s/ ? headers[-1] += line.strip : headers << line.strip\n end\n headers\n end", "def clean_up_contents()\n # very minimal\n # elements = ['p', 'b', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'], attributes={})\n\n if self.contents?\n html = self.contents\n email_regex = /<p>Email:\\s+((\\w|\\-|\\_|\\.)+\\@((\\w|\\-|\\_)+\\.)+[a-zA-Z]{2,})/i\n\n html.gsub! /\\[endif\\]--/ , ''\n html.gsub! /[\\n|\\r]/ , ' '\n html.gsub! /&nbsp;/ , ' '\n\n # this will convert UNICODE into ASCII. \n #It will also strip any possiblity of using a foreign language!\n #converter = Iconv.new('ASCII//IGNORE//TRANSLIT', 'UTF-8') \n #html = converter.iconv(html).unpack('U*').select{ |cp| cp < 127 }.pack('U*')\n # keep only the things we want.\n unless (Sanitize::Config::RELAXED[:attributes][\"table\"].include?(\"align\"))\n Sanitize::Config::RELAXED[:attributes][\"table\"] << \"align\"\n end\n\n config = Sanitize::Config::RELAXED\n if (html.encoding.name == 'ASCII-8BIT')\n config[:output_encoding] = 'ASCII'\n end\n html = Sanitize.clean( html, config)\n\n # butt up any tags\n html.gsub! />\\s+</ , '><'\n\n #remove email address lines\n html.gsub! email_regex , '<p>'\n\n # post sanitize cleanup of empty blocks\n # the order of removal is import - this is the way word stacks these elements\n html.gsub! /<i><\\/i>/ , ''\n html.gsub! /<b><\\/b>/ , ''\n html.gsub! /<\\/b><b>/ , ''\n html.gsub! /<p><\\/p>/ , ''\n html.gsub! /<p><b><\\/b><\\/p>/ , ''\n\n # misc - fix butted times\n html.gsub! /(\\d)am / , '\\1 am '\n html.gsub! /(\\d)pm / , '\\1 pm '\n # misc - remove multiple space that may cause doc specific regexs to fail (in dates for example)\n html.gsub! /\\s+/ , ' '\n\n # add new lines at the end of lines\n html.gsub! /<\\/(p|h\\d|dt|dd|dl)>/, '</\\1>' + \"\\n\"\n html.gsub! /<dl>/ , '<dl>' + \"\\n\"\n\n self.contents = html\n end\n end", "def delete_pre_address(address)\n address = address.sub(/^\\s*mail\\:\\s*/i, '')\n address.gsub(/.*\\,\\s+(\\d+\\b\\s+\\w)/i, '\\1')\n end", "def body_clean\n text = \"\"\n\n # Iterate through each line\n body.split(/\\n/).each do |line|\n # Included replies \"> some text\"\n next if line.match(/^>+/) \n next if line.match(/On.*wrote:/)\n # Outlook reply style\n break if line.match(/-{4,}Original Message-{4,}/)\n # Signature break \"--\"\n break if line.match(/^\\s*\\-{2,}\\s*$/)\n # Lines with only whitespace - blank them\n line.gsub(/^\\s+$/, \"\")\n\n text += line + \"\\n\"\n end\n\n # Clean out multiple line breaks throughout (longer than one blank line)\n text.gsub!(/\\n{3,}/, \"\\n\\n\") \n # Clean up multiple line breaks at end (none)\n text.gsub!(/\\n{2,}$/, \"\\n\")\n\n return text\n end", "def prune_git_headers!(diff)\n GIT_HEADERS.each do |header|\n diff.gsub!(header, '')\n end\n diff\n end", "def sanitise_email(email)\n return nil if email.blank?\n #remove all non-word chars\n email.collect{ |e| e.gsub(/[^\\w]-/,'')}\n return email\n end", "def expected_headers_unmet\n unmet = []\n expected = test_case.expected_headers\n expected.each_pair do |k,v|\n got = response.headers[k]\n unmet << \"[headers] #{v} expected for #{k}, got #{got}\" unless (got == v)\n end\n unmet.empty? ? nil : unmet.join(\"\\n\")\n end", "def populate_headers\n\t\t\t# construct a From value\n\t\t\t# should this kind of thing only be done when headers don't exist already? maybe not. if its\n\t\t\t# sent, then modified and saved, the headers could be wrong?\n\t\t\t# hmmm. i just had an example where a mail is sent, from an internal user, but it has transport\n\t\t\t# headers, i think because one recipient was external. the only place the senders email address\n\t\t\t# exists is in the transport headers. so its maybe not good to overwrite from.\n\t\t\t# recipients however usually have smtp address available.\n\t\t\t# maybe we'll do it for all addresses that are smtp? (is that equivalent to \n\t\t\t# sender_email_address !~ /^\\//\n\t\t\tname, email = props.sender_name, props.sender_email_address\n\t\t\tif props.sender_addrtype == 'SMTP'\n\t\t\t\theaders['From'] = if name and email and name != email\n\t\t\t\t\t[%{\"#{name}\" <#{email}>}]\n\t\t\t\telse\n\t\t\t\t\t[email || name]\n\t\t\t\tend\n\t\t\telsif !headers.has_key?('From')\n\t\t\t\t# some messages were never sent, so that sender stuff isn't filled out. need to find another\n\t\t\t\t# way to get something\n\t\t\t\t# what about marking whether we thing the email was sent or not? or draft?\n\t\t\t\t# for partition into an eventual Inbox, Sent, Draft mbox set?\n\t\t\t\t# i've now seen cases where this stuff is missing, but exists in transport message headers,\n\t\t\t\t# so maybe i should inhibit this in that case.\n\t\t\t\tif email\n\t\t\t\t\t# disabling this warning for now\n\t\t\t\t\t#Log.warn \"* no smtp sender email address available (only X.400). creating fake one\"\n\t\t\t\t\t# this is crap. though i've specially picked the logic so that it generates the correct\n\t\t\t\t\t# email addresses in my case (for my organisation).\n\t\t\t\t\t# this user stuff will give valid email i think, based on alias.\n\t\t\t\t\tuser = name ? name.sub(/(.*), (.*)/, \"\\\\2.\\\\1\") : email[/\\w+$/].downcase\n\t\t\t\t\tdomain = (email[%r{^/O=([^/]+)}i, 1].downcase + '.com' rescue email)\n\t\t\t\t\theaders['From'] = [name ? %{\"#{name}\" <#{user}@#{domain}>} : \"<#{user}@#{domain}>\" ]\n\t\t\t\telsif name\n\t\t\t\t\t# we only have a name? thats screwed up.\n\t\t\t\t\t# disabling this warning for now\n\t\t\t\t\t#Log.warn \"* no smtp sender email address available (only name). creating fake one\"\n\t\t\t\t\theaders['From'] = [%{\"#{name}\"}]\n\t\t\t\telse\n\t\t\t\t\t# disabling this warning for now\n\t\t\t\t\t#Log.warn \"* no sender email address available at all. FIXME\"\n\t\t\t\tend\n\t\t\t# else we leave the transport message header version\n\t\t\tend\n\n\t\t\t# for all of this stuff, i'm assigning in utf8 strings.\n\t\t\t# thats ok i suppose, maybe i can say its the job of the mime class to handle that.\n\t\t\t# but a lot of the headers are overloaded in different ways. plain string, many strings\n\t\t\t# other stuff. what happens to a person who has a \" in their name etc etc. encoded words\n\t\t\t# i suppose. but that then happens before assignment. and can't be automatically undone\n\t\t\t# until the header is decomposed into recipients.\n\t\t\trecips_by_type = recipients.group_by { |r| r.type }\n\t\t\t# i want to the the types in a specific order.\n\t\t\t[:to, :cc, :bcc].each do |type|\n\t\t\t\t# for maximal (probably pointless) fidelity, we try to sort recipients by the\n\t\t\t\t# numerical part of the ole name\n\t\t\t\trecips = recips_by_type[type] || []\n\t\t\t\trecips = (recips.sort_by { |r| r.obj.name[/\\d{8}$/].hex } rescue recips)\n\t\t\t\t# switched to using , for separation, not ;. see issue #4\n\t\t\t\t# recips.empty? is strange. i wouldn't have thought it possible, but it was right?\n\t\t\t\theaders[type.to_s.sub(/^(.)/) { $1.upcase }] = [recips.join(', ')] unless recips.empty?\n\t\t\tend\n\t\t\theaders['Subject'] = [props.subject] if props.subject\n\n\t\t\t# fill in a date value. by default, we won't mess with existing value hear\n\t\t\tif !headers.has_key?('Date')\n\t\t\t\t# we want to get a received date, as i understand it.\n\t\t\t\t# use this preference order, or pull the most recent?\n\t\t\t\tkeys = %w[message_delivery_time client_submit_time last_modification_time creation_time]\n\t\t\t\ttime = keys.each { |key| break time if time = props.send(key) }\n\t\t\t\ttime = nil unless Date === time\n\n\t\t\t\t# now convert and store\n\t\t\t\t# this is a little funky. not sure about time zone stuff either?\n\t\t\t\t# actually seems ok. maybe its always UTC and interpreted anyway. or can be timezoneless.\n\t\t\t\t# i have no timezone info anyway.\n\t\t\t\t# in gmail, i see stuff like 15 Jan 2007 00:48:19 -0000, and it displays as 11:48.\n\t\t\t\t# can also add .localtime here if desired. but that feels wrong.\n\t\t\t\theaders['Date'] = [Time.iso8601(time.to_s).rfc2822] if time\n\t\t\tend\n\n\t\t\t# some very simplistic mapping between internet message headers and the\n\t\t\t# mapi properties\n\t\t\t# any of these could be causing duplicates due to case issues. the hack in #to_mime\n\t\t\t# just stops re-duplication at that point. need to move some smarts into the mime\n\t\t\t# code to handle it.\n\t\t\tmapi_header_map = [\n\t\t\t\t[:internet_message_id, 'Message-ID'],\n\t\t\t\t[:in_reply_to_id, 'In-Reply-To'],\n\t\t\t\t# don't set these values if they're equal to the defaults anyway\n\t\t\t\t[:importance, 'Importance', proc { |val| val.to_s == '1' ? nil : val }],\n\t\t\t\t[:priority, 'Priority', proc { |val| val.to_s == '1' ? nil : val }],\n\t\t\t\t[:sensitivity, 'Sensitivity', proc { |val| val.to_s == '0' ? nil : val }],\n\t\t\t\t# yeah?\n\t\t\t\t[:conversation_topic, 'Thread-Topic'],\n\t\t\t\t# not sure of the distinction here\n\t\t\t\t# :originator_delivery_report_requested ??\n\t\t\t\t[:read_receipt_requested, 'Disposition-Notification-To', proc { |val| from }]\n\t\t\t]\n\t\t\tmapi_header_map.each do |mapi, mime, *f|\n\t\t\t\tnext unless q = val = props.send(mapi) or headers.has_key?(mime)\n\t\t\t\tnext if f[0] and !(val = f[0].call(val))\n\t\t\t\theaders[mime] = [val.to_s]\n\t\t\tend\n\t\tend", "def parser_email(line)\n if line.include? MailHeader.from\n fields=line.split(MailHeader.key_separator)\n if fields.length>1\n\t\t\t\tvalue=fields[1].split(\" \")\n if value.length>1\n firstname_lastname=value[0];\n email_address=value[1].gsub(/[<>]/,'')\n company_url=\"www.\"+email_address.split('@')[1];\n # if the email address is not contains the '@',the address is not correct\n unless email_address.include? \"@\"\n mail_header_output.firstname_lastname=MailHeader.unknown\n mail_header_output.flastname=MailHeader.unknown\n end\n mail_header_output.company_url=company_url\n check_firstname_lastname(email_address)\n check_flastname(email_address)\n check_email_name_conflict()\n end #end value.length\n end #end fields.length\n end #end line include\n end", "def unquoted_address_header(key)\n if header = @mail[key]\n emails = if header.respond_to?(:value)\n [header.value]\n else\n header.map { |h| h.value }\n end\n address_list_for(emails)\n else\n []\n end\n end", "def ensure_no_email_auth_headers_on_swagger_route\n routes = Api::V2::Base.combined_namespace_routes[self.params.name]\n if routes.present?\n routes.each do |r| \n route_options = r.instance_variable_get(\"@options\")\n route_options[:headers] ||= {}\n route_options[:headers].delete(\"X-Auth-Email\")\n route_options[:headers].delete(\"X-Auth-Network\") \n end\n end \n end", "def clear_headers\n headers.clear # Yes, this returns an empty hash not nil\n end", "def check_email_name_conflict()\n mail_header_output.name_conflicts = mail_header_output.firstname_lastname && mail_header_output.flastname\n if (!mail_header_output.firstname_lastname && !mail_header_output.flastname)\n mail_header_output.correct_email_format=MailHeader.unknown\n end\n\tend", "def test_no_missing_headers\n headers = [\"File Name\", \"Format\", \"MIME\"]\n result = @validator.list_missing_headers(headers, @header_map)\n assert result.success?\n end", "def original_email(email)\n if email.match(/\\[\\w+-\\d+\\]/)\n email.sub(/\\[\\w+-\\d+\\]/, '')\n else\n email\n end\n end", "def empty_header_lines(txt)\n txt.gsub(/^\\[\\|[^\\]\\n]+\\](?=\\n)/, '')\n end", "def sanitize_email(email)\n email.gsub(/@/, \"_at_\").gsub(/\\./, \"_dot_\")\n end", "def normalized_headers\n\t\theaders = self.headers.dup\n\n\t\theaders[:date] ||= Time.now.httpdate\n\n\t\tif self.bodiless? && !self.extended_reply?\n\t\t\theaders.delete( :content_length )\n\t\t\theaders.delete( :content_type )\n\t\telse\n\t\t\theaders[:content_length] ||= self.get_content_length\n\t\t\theaders[:content_type] ||= DEFAULT_CONTENT_TYPE.dup\n\t\tend\n\n\t\treturn headers\n\tend", "def normalize_headers(headers)\n return {} unless headers\n\n headers = Hash[\n headers.map { |k, v| [k.gsub(HEADER_HTTP_PREFIX, '').capitalize, v] }\n ] # remove 'HTTP_' prefix in keys\n headers.delete_if { |_k, v| v.blank? } # remove pairs with empty values\n headers.keep_if { |k, _v| OCCI_KEYS.include?(k) } # drop non-OCCI pairs\n\n logger.debug \"Normalized headers #{headers.inspect}\" if logger_debug?\n headers\n end", "def prepare_custom_headers(header)\n header.end_with?(\"__c\") ? header.slice(0..-4).downcase : header.downcase\n end", "def sanitize_header_field(value)\n value.to_s\n .gsub(\"\\r\\n\", \"\\n\")\n .gsub(HEADER_FIELD_SANITIZER_PATTERN, HEADER_FIELD_SANITIZER_MAPPING)\n end", "def cleanup_body(body)\n delimiters = Setting.mail_handler_body_delimiters.to_s.split(/[\\r\\n]+/).reject(&:blank?).map {|s| Regexp.escape(s)}\n unless delimiters.empty?\n regex = Regexp.new(\"^[> ]*(#{ delimiters.join('|') })\\s*[\\r\\n].*\", Regexp::MULTILINE)\n body = body.gsub(regex, '')\n end\n body.strip\n end", "def lkey_strip(hdrs)\n hdrs.split(\": \")[0].downcase.gsub(\"-\", \"\").to_s.strip\n end", "def headers\n msg['headers']||{}\n end", "def sanitize_mail(mail)\n if mail.content_type.start_with? 'text/html'\n html = mail.body.decoded.encode('utf-8', mail.charset)\n Sanitize.fragment(html, Sanitize::Config.merge(Sanitize::Config::RELAXED,\n remove_contents: ['style']\n ))\n else\n Rack::Utils.escape_html(mail.body.decoded)\n end\n end", "def uncached_headers(id_set)\n log \"Fetching headers for #{id_set.size} messages\"\n results = reconnect_if_necessary do\n @imap.fetch(id_set, [\"FLAGS\", \"ENVELOPE\", \"RFC822.SIZE\", \"UID\"])\n end\n results.reverse.map do |x|\n envelope = x.attr[\"ENVELOPE\"]\n message_id = envelope.message_id\n subject = Mail::Encodings.unquote_and_convert_to((envelope.subject || ''), 'UTF-8')\n recipients = ((envelope.to || []) + (envelope.cc || [])).map {|a| extract_address(a)}.join(', ')\n sender = extract_address envelope.from.first\n uid = x.attr[\"UID\"]\n params = {\n subject: (subject || ''),\n flags: x.attr['FLAGS'].join(','),\n date: Time.parse(envelope.date).localtime.to_s,\n size: x.attr['RFC822.SIZE'],\n sender: sender,\n recipients: recipients\n }\n end\n end", "def proper_headers(arr)\n\t\tarr.first.map! {|i| i.split(/(?=[A-Z])/).join(' ')}\n\tend", "def uncached_headers(id_set)\n log \"Fetching headers for #{ id_set.size } messages\"\n results = reconnect_if_necessary do\n @imap.fetch(id_set, [\"FLAGS\", \"ENVELOPE\", \"RFC822.SIZE\", \"UID\"])\n end\n results.reverse.map do |x|\n envelope = x.attr[\"ENVELOPE\"]\n message_id = envelope.message_id\n subject = Mail::Encodings.unquote_and_convert_to((envelope.subject || ''), 'UTF-8')\n recipients = ((envelope.to || []) + (envelope.cc || [])).map {|a| extract_address(a)}.join(', ')\n sender = extract_address envelope.from.first\n uid = x.attr[\"UID\"]\n params = {\n subject: (subject || ''),\n flags: x.attr['FLAGS'].join(','),\n date: Time.parse(envelope.date).localtime.to_s,\n size: x.attr['RFC822.SIZE'],\n sender: sender,\n recipients: recipients\n }\n end\n end", "def headers\n @headers ||= begin\n mail = Mail.new(self.raw_headers)\n mail.header.fields.each_with_object({}) do |field, hash|\n hash[field.name.downcase] ||= []\n hash[field.name.downcase] << field.decoded\n end\n end\n end", "def header_unset(name)\n header_set name, nil\n end", "def remove_invalid_emails\n notification_emails.each do |email|\n if !email.valid?\n notification_emails.delete email\n end\n end\n end", "def parse_headers!(headers)\n @filename = headers[HEADER_CONTENT_DISPOSITION].split('filename=')[1]\n @filename = @filename[1...-1] if @filename[0] == '\"' # Unquote filenames\n end", "def unify_headers(headers)\n lines = []\n headers.each_pair do |k, v|\n lines << v.map { |val| \"#{k}: #{val}\" }\n end\n\n logger.debug \"Unified headers #{lines.inspect}\" if logger_debug?\n lines.flatten.sort\n end", "def fixup_headers\n\t\t\tif @content\n\t\t\t\t@headers[\"Content-length\"] = content.to_s.bytesize\n\t\t\telsif @chunks\n\t\t\t\t@headers[\"Transfer-encoding\"] = \"chunked\"\n\t\t\t\t# Might be nice to ENSURE there is no content-length header,\n\t\t\t\t# but how to detect all the possible permutations of upper/lower case?\n\t\t\telsif @multiparts\n\t\t\t\t@multipart_boundary = self.class.concoct_multipart_boundary\n\t\t\t\t@headers[\"Content-type\"] = \"multipart/x-mixed-replace; boundary=\\\"#{@multipart_boundary}\\\"\"\n\t\t\telse\n\t\t\t\t@headers[\"Content-length\"] = 0\n\t\t\tend\n\t\tend", "def remove_headers!\n response.headers['sid'] = nil\n response.headers['utoken'] = nil\n end", "def clean_message(message); end", "def strip_storehouse_headers(response)\n response[1].except!('X-Storehouse-Distribute', 'X-Storehouse', 'X-Storehouse-Expires-At')\n response\n end", "def headers\n @headers.reject {|k, v| k == :body }.map do |k, v|\n translate_header_name(k) + ': ' + v + \"\\n\"\n end.join\n end", "def filter(str)\n str = str.gsub(/^line.*trimming empty.*\\n/, '') # the messages about empty are overzealous, and not invalid\n str = str.gsub(/^line.*proprietary.*\\n/, '') if options[:ignore_proprietary] # if you use IE only attributes like wrap, or spellcheck or things not in standard\n str = str.gsub(/^line.*(?:Error|Warning):.*<\\/?(?:#{options[:ignored_tag_errors].join('|')})>.*\\n/, '') if options[:ignored_tag_errors] && options[:ignored_tag_errors].any?\n str = str.gsub(/^line.*(?:Error|Warning):.* attribute \\\"(?:#{options[:ignored_attribute_errors].join('|')})\\\".*\\n/, '') if options[:ignored_attribute_errors] && options[:ignored_attribute_errors].any?\n if options[:ignored_errors] && options[:ignored_errors].any? && str.gsub(/^line.*(?:Error|Warning):/, '') =~ ignored_errors_regex\n str = str.gsub(Regexp.new(/^line.*(?:Error|Warning):/.source + '.*' + ignored_errors_regex.source + '.*' + /\\n/.source), '')\n end\n str.gsub(/line [0-9]+ column [0-9]+ -/, '')\n # /line [0-9]+ column [0-9]+ - / + =~ \"line 1 column 1 - Warning: missing <!DOCTYPE> declaration\"\n end", "def filter_invalid_emails(emails)\n invalid_emails = ['[email protected]', 'asdasd']\n emails.select{|email| !invalid_emails.include? email.strip.downcase}\n end", "def unprefixed_headers\n {\"Content-Type\" => @request.content_type,\n \"Content-Length\" => @request.content_length}.compact\n end", "def unprettify(email)\n email && email.match(/\\<(.*)\\>/) ? $1 : email\n end", "def remove_headers(headers = {})\n headers.each do |header, value|\n @headers.delete(header)\n end\n end", "def clean_response(body)\n body.gsub!(/\\/\\//, '')\n\n # Google sends hex encoded data, we need to fix that\n (33..47).each do |char|\n body.gsub!(/\\\\x#{char.to_s(16)}/, char.chr)\n end\n\n body\n end", "def remove_header_declaration( xml )\r\n if xml.strip.start_with?( '<?xml')\r\n i = xml.index( '?>', 3 )\r\n xml[ i+2, xml.length-i ]\r\n else\r\n xml \r\n end\r\nend", "def headers\r\n {\r\n :subject => \"izmedi.ru - письмо с сайта\",\r\n :to => \"[email protected]\",\r\n :from => %(\"Измеди.ру\" <@[email protected]>)\r\n }\r\n end", "def str_early_hints(headers); end", "def prepend_header(name, value)\n original = tmail[name] || []\n tmail[name] = nil\n tmail[name] = sanitize_header(charset, name, value)\n tmail[name] = tmail[name] + original\n end", "def normalize_headers(headers)\n result = headers.inject({}) do |h, (k, v)|\n # value is in raw form as array of sequential header values\n h[normalize_header_key(k)] = v\n h\n end\n\n # eliminate headers that interfere with playback or don't make sense to\n # record.\n %w(\n connection status host user_agent content_encoding\n ).each { |key| result.delete(key) }\n\n # always obfuscate cookie headers as they won't be needed for playback and\n # would be non-trivial to configure for each service.\n %w(cookie set_cookie).each do |k|\n if cookies = result[k]\n if cookies.is_a?(::String)\n cookies = cookies.split(';').map { |c| c.strip }\n end\n result[k] = cookies.map do |cookie|\n if offset = cookie.index('=')\n cookie_name = cookie[0..(offset-1)]\n \"#{cookie_name}=#{HIDDEN_CREDENTIAL_VALUE}\"\n else\n cookie\n end\n end\n end\n end\n result\n end", "def headers; return {}; end", "def headers; return {}; end", "def all_without_email\n\n end", "def headers\n {\n :subject => \"Обратная связь Bender\",\n \"X-Priority\" => \"1 (Highest)\",\n \"X-MSMail-Priority\" => \"High\",\n :to => \"[email protected]\",\n :from => \"[email protected]\",\n :from_to => %(\"#{name}\" <#{email}>)\n }\n end", "def mask_special_emails!(text)\n # XXX can later display some of these special emails as actual emails,\n # if they are public anyway. For now just be precautionary and only\n # put in descriptions of them in square brackets.\n if self.info_request.public_body.is_followupable?\n text.gsub!(self.info_request.public_body.request_email, \"[\" + self.info_request.public_body.short_or_long_name + \" request email]\")\n end\n text.gsub!(self.info_request.incoming_email, \"[FOI #\" + self.info_request.id.to_s + \" email]\")\n text.gsub!(MySociety::Config.get(\"CONTACT_EMAIL\", 'contact@localhost'), \"[WhatDoTheyKnow contact email]\")\n end", "def headers\n {\n :subject => \"Message from WebsiteOne\",\n :to => \"[email protected]\",\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def remove_envelope(message)\n generator.strip(message)\n end", "def mail_header(path)\n @header = {}\n value = nil\n File.open(path) do |f|\n while l = f.gets.chomp\n next if /^From / =~ l\n break if /^$/ =~ l\n if /^\\s+/ !~ l\n (name, value) = l.split(/:\\s*/, 2)\n value = '' if value.nil? || value.empty?\n @header[name.downcase] = value\n else\n value << $'\n end\n end\n end\n return @header\nend", "def canonicalized_headers\n x_amz = headers.select{|name, value| name.to_s =~ /^x-amz-/i }\n x_amz = x_amz.collect{|name, value| [name.downcase, value] }\n x_amz = x_amz.sort_by{|name, value| name }\n x_amz = x_amz.collect{|name, value| \"#{name}:#{value}\" }.join(\"\\n\")\n x_amz == '' ? nil : x_amz\n end", "def skip_http_headers; end", "def headers\n {\n :subject => \"#{subject}\",\n :to => \"[email protected]\",\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def fix_mac_vs_pc!(email)\n email.gsub!(/&#38;/, \"&amp;\")\n email.gsub!(/ &#8212;/, \"&#8212;\")\n email.gsub!(/^\\s+/, \"\")\n email.gsub!(/\\r\\n?/, \"\\n\")\n end", "def headers\n {\n :subject => \"IRL Checklist\",\n :to => \"[email protected]; [email protected]; [email protected]; [email protected]; [email protected]\",\n :from => \"IRL Checklist <[email protected]>\"\n }\n end", "def headers\n {\n :subject => \"Nouvelle alerte acheteur\",\n :to => \"[email protected]\",\n :from => \"[email protected]\"\n }\n end", "def remove_appended_messages(text)\n return nil if text.nil? || text.empty?\n string = text.to_s # ensure we have a string\n\n # ------------ Original Message ------------\n string.gsub! /(<[\\w\\s=:\"#]+>|^)+[-=]+.*Original Message.*/mi, ''\n\n # ------------ Forwarded Message ------------\n string.gsub! /(<[\\w\\s=:\"#]+>|^)+[-=]+.*Forwarded Message.*/mi, ''\n\n # From: Seth Vargo <[email protected]>\n # Send: Tues, Oct 9, 2012\n # To: Robbin Stormer <[email protected]>\n # Subject: Cookies and Cream\n string.gsub! /(<[\\w\\s=:\"#]+>|^)+From:.*Sent:.*(To:.*)?.*(Cc:.*)?.*(Subject:.*)?.*/im, ''\n\n # On Oct 9, 2012, at 6:48 PM, Robbin Stormer wrote:\n string.gsub! /(<[\\w\\s=:\"#]+>|^)+On.+at.+wrote:.*/mi, ''\n\n # Begin forwarded message:\n string.gsub! /(<[\\w\\s=:\"#]+>|^)+Begin\\ forwarded\\ message:.*/mi, ''\n string.strip!\n string\n end", "def default_email_address_header\n default_email_address.nil? ? original_email_address_header : default_email_address.to_header\n end", "def headers\n {\n :subject => \"Contact ULAP Research\",\n :to => \"[email protected]\",\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def remove_nonprintable!\n replace(remove_nonprintable)\n end", "def not_dirty\n self.headers.first(:name => :dirty).destroy\n end", "def canonicalize_headers(headers)\n tmp = headers.inject({}) {|ret, h| ret[h.first.downcase] = h.last if h.first.match(/^x-tmrk/i) ; ret }\n tmp.reject! {|k,v| k == \"x-tmrk-authorization\" }\n tmp = tmp.sort.map{|e| \"#{e.first}:#{e.last}\" }.join(\"\\n\")\n tmp\n end", "def tabular_input_cleanse_header\n ignored_columns = tabular_input.header.cleanse!\n logger.warn('Stripped out invalid columns from custom header', ignored_columns) unless ignored_columns.empty?\n\n self.tabular_input_header = tabular_input.header.columns\n end", "def revalidate_headers(directives)\n [:if_modified_since, :if_none_match].inject({}) do | hrds, checker |\n hrd_prop = self.send(checker, directives)\n hrds[hrd_prop[0]] = hrd_prop[1] if hrd_prop\n hrds\n end\n end", "def sanitize_header(header, value)\n value\n end", "def remove_nonprintable\n gsub(/[^[:print:]\\n\\t]/i, '')\n end", "def normalize_email(email)\n raise \"E-mail address is blank\" if email.blank?\n raise \"Invalid e-mail address\" unless Authentication.email_regex =~ email\n email.strip\n end", "def headers\r\n {\r\n :subject => \"JP Health Insurance Contact Form\",\r\n :to => [\"[email protected]\", \"[email protected]\", \"[email protected]\"],\r\n :from => %(\"#{name}\" <#{email}>)\r\n }\r\n end", "def error_email_content(exception)\n email_opts = self.class.opts[:error_email]\n headers = email_opts[:default_headers].call(email_opts, exception)\n headers = headers.merge(email_opts[:headers])\n headers = headers.map{|k,v| \"#{k}: #{v.gsub(/\\r?\\n/m, \"\\r\\n \")}\"}.sort.join(\"\\r\\n\")\n body = email_opts[:body].call(self, exception)\n \"#{headers}\\r\\n\\r\\n#{body}\"\n end", "def processed_headers; end", "def sanitize\n\t\[email protected]!(/[^a-zA-Z]/, \"\")\n\t\[email protected]!\n\n\t\tremainder = @message.length % 5\n\t\tif remainder > 0\n\t\t\t(5 - remainder).times do\t\t\t\t\n\t\t\t\t@message << \"X\"\n\t\t\tend\n\t\tend\n\n\t\t@grouped = @message.scan(/...../)\n\tend", "def list_missing_headers(headers, header_map)\n missing = []\n\n header_map.each_pair do |required, aliases|\n missing.push(\"#{required} header missing\") if (headers & aliases).empty?\n end\n\n _result(missing)\n end", "def parse_rfc822_header(input)\n headers = Hash.new\n previous = nil\n input.each_line do |line|\n line = line.chomp\n break if line.empty? # Stop at first blank line\n case line\n when /^([^: \\t]+):\\s+(.*)$/\n raise \"Multiple definitions of header '#{$1}'.\" if headers.has_key?($1)\n headers[previous = $1] = $2\n when /^\\s+(.*)$/\n if not previous.nil? and headers.has_key?(previous)\n headers[previous] << \"\\n\" + $1.lstrip\n else\n raise \"Invalid header continuation.\"\n end\n else\n raise \"Invalid header format.\"\n end\n end\n return headers.empty? ? nil : headers\nend", "def unreceive message, headers={}\n end", "def remove_token_headers\n response.headers['sid'] = nil\n response.headers['utoken'] = nil\n end", "def readable_emails header\n\t\taddresses_in(header).join(\", \") rescue nil\n\tend", "def headers\n {\n :subject => %(<#{subject}>),\n\t\t\t:to => %(#{to}),\n :from => \"[email protected]\"\n }\n end", "def headers\n {\n :subject => \"Prise de contact - Chavanne & Witt\",\n :to => \"[email protected], [email protected], [email protected], [email protected], [email protected]\",\n :from => %(\"#{nom}\" <#{email}>)\n }\n end", "def clean_body(text)\n text = strip_bad_chars(text)\n text.gsub!(/(\\r)?\\n/, \"\");\n text.gsub!(/\\s+/, ' ');\n\n # clean start and end whitespace\n text = text.strip;\n return text\nend", "def clean_message\n self.message = Loofah.fragment(self.message).scrub!(:strip).text\n end", "def clean_col_header (hdr)\r\n\t\t\t# Conversion is:\r\n\t\t\t# - strip flanking space\r\n\t\t\t# - convert all internal non-alphanumerics to underscores\r\n\t\t\t# reduce consequetive underscores to a single one\r\n\t\t\t# TODO: strip flanking underscores\r\n\t\t\tclean_str = hdr.downcase.strip.gsub(/\\W+/, '_')\r\n\t\t\treturn clean_str.gsub(/_+/, '_')\r\n\t\tend", "def include_csv_in_email; include_csv_in_email? rescue include_csv_in_email; end" ]
[ "0.72072834", "0.6434472", "0.6386203", "0.62259036", "0.6174803", "0.61696625", "0.6146202", "0.61338484", "0.6133599", "0.60211575", "0.59882176", "0.598217", "0.5978966", "0.59235716", "0.5904892", "0.58889586", "0.5876147", "0.5861512", "0.58470446", "0.58243954", "0.58083546", "0.5787776", "0.57760566", "0.577601", "0.5742379", "0.57370573", "0.5699756", "0.5684643", "0.56733304", "0.567215", "0.5671294", "0.56666404", "0.5664451", "0.56303805", "0.5628626", "0.5617578", "0.5597879", "0.55908", "0.5586187", "0.5562937", "0.5560415", "0.5555403", "0.5546622", "0.5530444", "0.55170035", "0.54935014", "0.5492742", "0.549128", "0.54761463", "0.5471933", "0.54554224", "0.54514784", "0.54448766", "0.54416275", "0.5428363", "0.5428109", "0.54219013", "0.54209036", "0.5405679", "0.53965765", "0.53934175", "0.53934175", "0.537575", "0.5375323", "0.5363636", "0.5363593", "0.53513396", "0.534881", "0.5348272", "0.5347791", "0.53467077", "0.5339854", "0.5338604", "0.5329809", "0.532517", "0.5323265", "0.5318992", "0.5314455", "0.5311097", "0.5308153", "0.5302247", "0.5299105", "0.5292565", "0.5290171", "0.5281083", "0.5279016", "0.52772874", "0.5268931", "0.52661014", "0.5263744", "0.5257682", "0.525699", "0.5252943", "0.52511996", "0.524824", "0.52424634", "0.5239097", "0.52380455", "0.52335316", "0.5232899" ]
0.7699297
0
Produces and processes a report for use in the report method It takes the same arguments as report, and returns the same object as process_report
def produce_report(*args) # Check xcov availability, install it if needed `gem install xcov` unless xcov_available? unless xcov_available? puts "xcov is not available on this machine" return end require "xcov" require "fastlane_core" # Init Xcov config = FastlaneCore::Configuration.create(Xcov::Options.available_options, convert_options(args.first)) Xcov.config = config Xcov.ignore_handler = Xcov::IgnoreHandler.new # Init project report_json = nil manager = Xcov::Manager.new(config) if Xcov.config[:html_report] || Xcov.config[:markdown_report] || Xcov.config[:json_report] # Parse .xccoverage and create local report report_json = manager.run else # Parse .xccoverage report_json = manager.parse_xccoverage end # Map and process report process_report(Xcov::Report.map(report_json)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n @report = Report.new\n @report.plugin = self\n build_report\n rescue Exception => e\n @report.error e\n ensure\n return @report\n end", "def run_report(report)\n report.update! status: 'running'\n\n klass = report.name.constantize\n\n r = klass.new(report.parameters)\n if r.parameters_valid?\n record_set = r.query\n report_template = klass.template\n\n output = ApplicationController.new\n .render_to_string(template: report_template, formats: report.format,\n locals: { klass: klass, record_set: record_set,\n created_at: report.created_at })\n report.update! status: 'completed', output: output\n else\n report.update status: 'error'\n report.update status_message: r.error_message\n end\n end", "def report\n \n end", "def process\n profile(\"report#process\", [:puppetdb, :report, :process]) do\n current_time = Time.now\n submit_command(self.host, CommandStoreReport, 8, current_time.utc) do\n report_to_hash(current_time)\n end\n end\n\n nil\n end", "def report\n return @report\n end", "def write_report\n\n end", "def report\n\t\tend", "def create_new_report!; end", "def create_new_report!; end", "def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = BgWorkerReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end", "def report; end", "def report; end", "def report; end", "def report; end", "def report; end", "def perform(report)\n generate_excel_file(report)\n end", "def create\n data_report = DataReport.new(data_report_params)\n\n # For now the worker is synchronous. Eventually it can be run asynchronously\n if data_report.save && report_worker.perform(data_report.id)\n render json: {}, status: :ok\n elsif data_report.errors.present\n render json: data_report.errors, status: :unprocessable_entity\n else\n render json: {}, status: :internal_server_error\n end\n end", "def report_for(report, *args)\n load_reports! if @reports.blank?\n @reports.each do |klass|\n return klass.new(*args) if report == klass.name.underscore\n end\n end", "def report\n require File.join File.expand_path(File.dirname(__FILE__)), \"report\"\n Brakeman::Report.new(self)\n end", "def report(output)\n end", "def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = UserReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end", "def process\n ReportAdapter.new(report: runner.run(run_options), root: root).each do |issue|\n io.print issue.to_json\n io.print \"\\0\"\n end\n end", "def report(context, repo, dir)\n raise \"No report(context, repo, dir) function defined by report subclass\"\n end", "def build_report(report)\n current_date = 'today'\n report_settings_tab.click unless report_settings_tab[:class]== 'selected'\n wait_until{report_name_tb.visible?}\n case report\n when Bus::DataObj::BillingSummaryReport\n report_name_tb.type_text(report.name)\n frequency_select.select(report.frequency)\n set_report_start_date(report.start_date)\n is_active_cb.uncheck unless report.is_active\n when Bus::DataObj::BillingDetailReport\n report_name_tb.type_text(report.name)\n frequency_select.select(report.frequency)\n set_report_start_date(report.start_date)\n is_active_cb.uncheck unless report.is_active\n else\n report_name_tb.type_text(report.name)\n if report.type == 'Resources Added'\n # get current date from range end checkbox for the Date Applied in the report\n str_arr = range_end_checkbox[:onclick].scan(/'\\d+'/)\n current_date = 'yesterday' unless str_arr[2].match(/\\d+/)[0] == Time.now.day.to_s\n range_start_checkbox.check\n range_end_checkbox.check\n else\n frequency_select.select(report.frequency)\n set_report_start_date(report.start_date) unless report.start_date.nil?\n is_active_cb.uncheck unless report.is_active\n end\n\n if report.type == \"Machine Over Quota\"\n quota_percentage_input.type_text(report.threshold) unless report.threshold.nil?\n end\n end\n set_email_recipients(report.recipients) unless report.recipients.nil?\n save_btn.click\n current_date\n end", "def save_report\n Report.transaction do\n report = Report.create(name: @name,\n start_date: @start_date,\n end_date: @end_date,\n type: @type,\n creator: User.current.id,\n renderer_type: 'PDF')\n\n values = save_report_values(report)\n\n { report: report, values: values }\n end\n end", "def save_report\n report = Report.create(name: @name, start_date: @start_date,\n end_date: @end_date, type: @type,\n creator: User.current.id,\n renderer_type: 'PDF')\n\n values = save_report_values(report)\n\n { report: report, values: values }\n end", "def report_run(command)\n result = nil\n @run_report = Report.new(name: nil, target: command)\n begin\n result = yield @run_report\n ensure\n @run_report = nil\n end\n\n result\n end", "def report\n # generate_report()\n ReportWorker.perform_async(\"07-01-2018\", \"08-01-2018\")\n render \\\n json: {status: 'SUCCESS', message:'REQUEST TO GENERATE A REPORT ADDED TO THE QUEUE'},\n status: :ok\n end", "def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = DevFeedbackReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end", "def report_data\n ReportMailer.report_data\n end", "def generate_report\n self.consume_stdin\n self.data_sorter\n\n @drivers.each do |driver|\n driver.total_duration\n driver.distance_calculator\n driver.average_speed\n end\n\n self.compile_report\n end", "def report_worker\n @report_worker ||= DataReportWorker.new\n end", "def report(report, client = nil, clientip = nil)\n # Unescape the report\n report = CGI.unescape(report) unless @local\n\n Puppet.info \"Processing reports #{reports().join(\", \")} for #{client}\"\n begin\n process(report)\n rescue => detail\n Puppet.err \"Could not process report for #{client}: #{detail}\"\n puts detail.backtrace if Puppet[:trace]\n end\n end", "def run_report(options = {})\n options = argument_cleaner(required_params: %i( reportid entityid ), optional_params: %i( format content_disposition nodata AsOf), options: options )\n authenticated_get cmd: \"runreport\", **options\n end", "def report\n @report = Report.new(self)\n @results.keys.each do |key|\n yield key\n end\n @report.write\n end", "def set_report\n end", "def export_report\n @report.export_report\n end", "def export_report\n @report.export_report\n end", "def report\n @scan = find_scan( params.require( :id ) )\n\n format = URI( request.url ).path.split( '.' ).last\n render layout: false,\n content_type: FrameworkHelper.content_type_for_report( format ),\n text: FrameworkHelper.framework { |f| f.report_as format, @scan.report.object }\n end", "def create_report\n print_sales_report_ASCII\n print_date\n print_products_ASCII\n print_brands_ASCII\n end", "def create\n if current_user.company.reports.any?\n if [\"Queued\", \"Running\"].include? current_user.company.reports.last.status\n redirect_to dashboard_path, notice: \"Looks like you already have a report queued. We'll get to it asap, promise!\"\n return\n end\n end\n \n @report = Report.new(report_params) \n\n respond_to do |format|\n if @report.save\n \n @report.test_suite.test_cases.order('id ASC').each do |test_case|\n @report.results.create({ status: 'Queued', report_id: @report, test_case_id: test_case.id})\n end\n \n ReportMailer.admin_requested_report_triggered_email(@report).deliver\n #ReportMailer.requested_report_triggered_email(@report).deliver\n \n format.html { redirect_to dashboard_path }\n format.json { render action: 'show', status: :created, location: @report }\n else\n format.html { render action: 'new' }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@report = Report.create(params[:report])\n\t\t\n\t\trespond_to do |format|\n\t\t\tif @report.save\n\t\t\t\tformat.html { redirect_to @report, notice: 'Report was successfully created.' }\n\t\t\t\tformat.json { render json: @report, status: :created, location: @report }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @report.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def report_run(command)\n super do |report|\n @report = report\n yield report\n end\n end", "def deliver_report\n # The base class is just a stub and doesn't need to do anything.\n end", "def output_report\n\t\toutput_start\n\t\toutput_head\n\t\toutput_body_start\n\t\toutput_body\n\t\toutput_body_end\n\t\toutput_end\n\tend", "def render(format, user, *args)\n TasksheetReport.render(format, :report => self, :user => user)\n end", "def finalize_standard_report\n render_pdf\n end", "def send_report_data\n render_type = RENDER_TYPES[@sb[:render_type].to_s]\n raise \"Render type #{@sb[:render_type]} is not supported\" unless render_type\n\n assert_privileges(\"render_report_#{render_type}\")\n\n return unless @sb[:render_rr_id]\n\n disable_client_cache\n result = MiqReportResult.find(@sb[:render_rr_id])\n\n filename = filename_timestamp(result.report.title, 'export_filename')\n send_data(result.get_generated_result(@sb[:render_type]),\n :filename => \"#{filename}.#{@sb[:render_type]}\",\n :type => \"application/#{@sb[:render_type]}\")\n\n result.destroy\n end", "def report\n @scan = find_scan( params.require( :id ) )\n\n format = URI( request.url ).path.split( '.' ).last\n render layout: false,\n text: FrameworkHelper.\n framework { |f| f.report_as format, @scan.report.object }\n end", "def report(report_class, cron_def = nil)\n @reports << report_class.new(cron_def)\n end", "def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n \n @report.test_suite.test_cases.each do |test_case|\n @report.results.create({ status: 'Queued', report_id: @report, test_case_id: test_case.id})\n end\n \n format.html { redirect_to [:admin, @report], notice: 'Report was successfully created.' }\n format.json { render action: 'show', status: :created, location: @report }\n else\n format.html { render action: 'new' }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end", "def render_pdf\n render_pdf_internal(report_for_rendering)\n end", "def report\n respond_to do |format|\n format.pdf { \n # send_file TestPdfForm.new(PdfRecord.first).export, type: 'application/pdf'\n\n pdf = InvoicePdf.new(current_user, @invoice).export\n send_file pdf[:filename], type: 'application/pdf' \n\n # pdf = InvoicePdf.new(current_user, @invoice).export_02\n # send_data pdf[:body], type: 'application/pdf' \n }\n end\n end", "def create\n\t\t@report = Report.new(report_params)\n\t\[email protected]=current_user\n\t\trespond_to do |format|\n\t\t\tif @report.save\n\t\t\t\tformat.html { redirect_to reports_url, notice: 'Report was successfully created.' }\n\t\t\t\t# format.json { render :show, status: :created, location: @report }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @report.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create_report()\n report = <<STR_END\n#### STEPS TO REPRODUCE BUG ####\n\n#{@list_steps_text.get_value}\n\n\n#### DESCRIPTION OF BUG ####\n\n#{@description_text.get_value}\n\n--#{@reproduce_check.get_value}\n--#{@past_check.get_value}\n\n\n#### SESSION LOG ####\n\n#{@parent.log_text.get_value}\n\n\n--------------------------------------------------------------------------------\n#{IO.readlines($attr[:name]).join(\"\\n\") if $attr[:name]}\nSTR_END\n \n fname = \"bugs/#{Time.now.to_s.split(\" \").join(\"_\")}_#{$attr[:name].split(/[\\/\\\\]/).join(\"_\") if $attr[:name]}_bug\"\n File.open(fname, 'w') {|fout| fout.write(report)}\n prompt = MessageDialog.new(self, \"Bug report saved to file: #{fname}\\nPlease email this file to the developer!\",\n \"Bug Report Created\", OK)\n exit_dlg() if prompt.show_modal == ID_OK\n end", "def call\n all_cached_data.report_data_for(report_range)\n end", "def extract_reports\n #puts \" Document.extract_reports\"\n # consider changing this to use split on a raw array to split by \\f then by \\n\n @raw_reports = []\n pending_report = true\n lines # read all the lines in the document file\n \n @pages = []\n collect_pages\n #puts \" collect_pages returned #{@pages}\"\n # We now have all the lines of the file and an array of the sets of pages in the file\n # Now determine where a report ends and collect those pages.\n r = Report.new()\n @pages.each_with_index do |page, i|\n r.add_page(@lines[page.first_line..page.last_line])\n pending_report = true\n current_line = page.first_line\n while current_line <= page.last_line\n if @lines[current_line].end_of_report?\n @raw_reports << r\n r = Report.new()\n pending_report = false\n break #report was added to array of reports \n end \n current_line += 1 \n end\n \n end\n if pending_report\n @raw_reports << r\n end \n @raw_reports\n end", "def render_report_data\n render_type = RENDER_TYPES[params[:render_type]]\n raise \"Render type #{params[:render_type]} is not supported\" unless render_type\n\n assert_privileges(\"render_report_#{render_type}\")\n\n if params[:task_id]\n # We are waiting for a task to finish.\n render_report_data_continue(params[:task_id])\n else\n # First time thru, kick off the report generate task.\n render_report_data_init(render_type)\n end\n end", "def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"count_of_table_sid_by_field_sid\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = AccessReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end", "def send_report(report)\n headers = {\n \"Content-Type\" => \"application/json\",\n \"x-data-collector-auth\" => \"version=1.0\",\n \"x-data-collector-token\" => @token,\n }\n\n all_report_shas = report[:profiles].map { |p| p[:sha256] }\n missing_report_shas = missing_automate_profiles(headers, all_report_shas)\n\n full_report = truncate_controls_results(enriched_report(report), @control_results_limit)\n full_report = strip_profiles_meta(full_report, missing_report_shas, @run_time_limit)\n json_report = Chef::JSONCompat.to_json(full_report, validate_utf8: false)\n\n # Automate GRPC currently has a message limit of ~4MB\n # https://github.com/chef/automate/issues/1417#issuecomment-541908157\n if json_report.bytesize > 4 * 1024 * 1024\n Chef::Log.warn \"Generated report size is #{(json_report.bytesize / (1024 * 1024.0)).round(2)} MB. #{ChefUtils::Dist::Automate::PRODUCT} has an internal 4MB limit that is not currently configurable.\"\n end\n\n unless json_report\n Chef::Log.warn \"Something went wrong, report can't be nil\"\n return false\n end\n\n begin\n Chef::Log.info \"Report to #{ChefUtils::Dist::Automate::PRODUCT}: #{@url}\"\n Chef::Log.debug \"Compliance Phase report: #{json_report}\"\n http_client.post(nil, json_report, headers)\n true\n rescue => e\n Chef::Log.error \"send_report: POST to #{@url} returned: #{e.message}\"\n false\n end\n end", "def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to admin_reports_path, notice: t('shared.msgs.success_created',\n obj: t('activerecord.models.report', count: 1)) }\n format.json { render :show, status: :created, location: @report }\n else\n set_date\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate_pdf(report_data)\n Prawn::Document.new do\n text report_data\n end.render\n end", "def create\n # if report is valid, save it and set flag (no need to run it b/c it will be redirected)\n @report.just_created = true if @report.errors.empty?\n \n # return data in json format\n render(:json => {:report => @report}.to_json)\n end", "def update_reports\n\n\t\tremove_reports\n\n\t\texisting_report_ids = self.reports.map{|c|\n\t\t\tc.id.to_s\n\t\t}\n\n\t\t## after this the quantity issue\n\t\t## and then the test verification toggles, textual inference, and report generation ->\n\t\t## so only if the order is finalized, then \n\t\t## now the worth processing.\n\t\t## local item group\n\t\t## organization from \n\n\t\tself.template_report_ids.each do |r_id|\n\t\t\t#puts \"doing template report id: #{r_id}\"\n\t\t\tunless existing_report_ids.include? r_id\n\t\t\t\ttx = Time.now\n\t\t\t\tself.finalize_order = NO\n\t\t\t\t## unfinalize the order\n\t\t\t\t## \n\t\t\t\t## get teh report raw hash.\n\t\t\t\t## get rid of the non-applicable ranges\n\t\t\t\t## and only then initialize the object.\n\t\t\t\t## that will make it much faster.\n\t\t\t\treport = Diagnostics::Report.find(r_id)\n\t\t\t\t\n\t\t\t\tty = Time.now\n\t\t\t\tputs \"time to get report: #{(ty - tx).in_milliseconds}\"\n\t\t\t\treport.created_by_user = User.find(report.created_by_user_id)\n\t\t\t\treport.current_user = self.current_user\n\t\t\t\ttz = Time.now\n\t\t\t\tputs \"time to get created by user: #{(tz - ty).in_milliseconds}\"\n\t\t\t\treport.run_callbacks(:find)\n\t\t\t\tt1 = Time.now\n\t\t\t\tputs \"time to run callbacks: #{(t1 - tz).in_milliseconds}\"\n\t\t\t\treport.prune_test_ranges(self.patient)\n\t\t\t\tt2 = Time.now\n\t\t\t\tputs \"prune ranges took: #{(t2-t1).in_milliseconds}\"\n\t\t\t\tself.reports << report\n\t\t\t\tself.order_completed = NO\n\t\t\tend\n\t\tend\n\tend", "def report_report(opts)\n return if not active\n created = opts.delete(:created_at)\n updated = opts.delete(:updated_at)\n state = opts.delete(:state)\n\n ::ApplicationRecord.connection_pool.with_connection {\n report = Report.new(opts)\n report.created_at = created\n report.updated_at = updated\n\n unless report.valid?\n errors = report.errors.full_messages.join('; ')\n raise \"Report to be imported is not valid: #{errors}\"\n end\n report.state = :complete # Presume complete since it was exported\n report.save\n\n report.id\n }\n end", "def create_report\n\tcreate_rep_heading\n \tcreate_product_data\n \tcreate_brand_data\nend", "def create_new_report!\n File.write(report_filename, report_title + report_body)\n end", "def output_report\n report = \"\"\n report << '<html>'\n report << ' <head>'\n report << \" <title>#{@title}</title>\"\n report << ' </head>'\n report << ' <body>'\n @text.each { |line| report << \" <p>#{line}</p>\" }\n report << ' </body>'\n report << '</html>'\n end", "def generate_report(_callback_data)\n text_report = OrderReport.new.generate\n\n respond_with :message, text: text_report, parse_mode: :Markdown\n answer_callback_ok\n end", "def create_report()\n $report_file.truncate(0)\n print_date()\n brands = create_brands_hash()\n toys = create_products_hash()\n print_products_ascii()\n print_toys_hash(toys)\n print_brands_ascii()\n print_brands_hash(brands)\n $report_file.close\nend", "def raw_report\n @raw ||= build_data\n end", "def generate_report(filename, template)\n file = File.read(filename)\n data_hash = JSON.parse(file)\n rpt_data = transform(data_hash)\n\n # Re http://stackoverflow.com/questions/1887845/add-method-to-an-instanced-object\n d = TemplateSource.new(rpt_data)\n\n template = File.read(template) if File.exist?(template)\n renderer = ERB.new(template, nil, '<>')\n renderer.result(d.get_binding)\nend", "def report_only\n assert_privileges(\"report_only\")\n\n # Render error message if report doesn't exist\n if params[:rr_id].nil? && @sb.fetch_path(:pages, :rr_id).nil?\n add_flash(_(\"This report isn't generated yet. It cannot be rendered.\"), :error)\n render :partial => \"layouts/flash_msg\"\n return\n end\n # Dashboard widget will send in report result id else, find report result in the sandbox\n search_id = params[:rr_id] ? params[:rr_id].to_i : @sb[:pages][:rr_id]\n rr = MiqReportResult.for_user(current_user).find(search_id)\n\n session[:report_result_id] = rr.id # Save report result id for chart rendering\n session[:rpt_task_id] = nil # Clear out report task id, using a saved report\n\n @report = rr.report\n @report_result_id = rr.id # Passed in app/views/layouts/_report_html to the ReportDataTable\n @report_title = rr.friendly_title\n @html = report_build_html_table(rr.report_results, rr.html_rows.join)\n @ght_type = params[:type] || (@report.graph.blank? ? 'tabular' : 'hybrid')\n @render_chart = (@ght_type == 'hybrid')\n # Indicate stand alone report for views\n render 'shared/show_report', :layout => 'report_only'\n end", "def report\n @report || @schedule\n end", "def create\n begin\n\n ProcessCsvUploadService.call! nbs: report_params[:nbs_file].read,\n ovrs: report_params[:ovrs_file].read\n rescue => ex\n logger.error ex.message\n redirect_to new_report_path, alert: 'Failed to load files, csv format was not correct (csv headers may not be correct)'\n return\n end\n \n begin\n\n @report = BatchCompareService.call\n\n rescue => ex\n logger.error ex.message\n redirect_to new_report_path, alert: 'Failed to compare records, an error occured'\n return\n end\n\n begin\n if @report.save\n\n redirect_to @report, notice: 'Report was successfully created.'\n \n else\n redirect_to new_report_path, alert: 'Could not generate a report.'\n end\n rescue => ex\n logger.error ex.message\n redirect_to new_report_path, alert: 'Failed to save report, an error occured' \n end\n\n end", "def init_report\n raise if @report.new_record?\n \n # if not a new record, run it and record viewing\n @report.record_viewing\n \n return run_and_handle_errors\n end", "def create\n records = if file_upload?\n case file_upload_params['records']['file'].content_type\n when 'text/xml' then FileParser::XMLRecordParser.call( file_upload_params['records']['file'].path )\n when 'text/csv' then FileParser::CSVRecordParser.call( file_upload_params['records']['file'].path )\n when 'application/json' then FileParser::JSONRecordParser.call( file_upload_params['records']['file'].path )\n end\n else # non file upload\n form_submission_params['records'].is_a?(Array) ? form_submission_params['records'] : [ form_submission_params['records'] ]\n end\n\n begin\n @report = ReportCreator.new(records).results\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @report, status: :ok }\n end\n rescue => exception\n respond_to do |format|\n redirect_to :new, error: \"Invalid Information\", status: :unprocessable_entity\n\n format.json { render status: :unprocessable_entity }\n end\n end\n end", "def logReport\n @log.write( \"\\n\\n\\nFilter\\t\\t\\t\\t\\t\\t\\t\\t #{FILTER_NAME}\" + \"\\n________________________________________________________\\n\")\n @log.write( \"File name:\\t\\t\\t\\t\\t\\t\\t\" + QRY_FILE + \"\\n\")\n @log.write( \"Size: \\t\\t\\t\\t\\t\\t\\t\\t\" + File.stat(QRY_FILE).size.to_s + \" bytes\\n\")\n @log.write( \"Started:\\t\\t\\t\\t\\t\\t\\t\" + started_at.to_s + \"\\n\")\n @log.write( \"Completed:\\t\\t\\t\\t\\t\\t\\t\" + @completed_at.to_s + \"\\n\") \n @log.write( \"Input file count: \\t\\t\\t\\t\\t\" + \"%d\" % lines + \"\\n\")\n @log.write( \"Total seconds\\t\\t\\t\\t\\t\\t\" + \"%.3f\" % (completed_at - @started_at).to_f + \"\\n\" )\n @log.write( \"Average records per second:\\t\\t\\t\" + \"%.3f\" % (lines/(completed_at - started_at)).to_f + \"\\n\" )\n @log.write( \"__END__\\n\")\n @log.write( \"(c) Copyright 2009 VenueSoftware Corp. All Rights Reserved. \\n\")\n @log.close\n\n #\n # Report the results recorded in log.txt\n # \n puts \"\\n\"\n File.open(\"log.txt\", \"r\") do |f|\n while line = f.gets\n puts line\n end\n end\n Kernel.exit\nend", "def report_body; end", "def report_body; end", "def create_global_report\n super\n end", "def parseReport(reportText)\n # First, get credit summary\n creditSummary = getCredits(reportText)\n @totalEarnedCredits = creditSummary[:totalEarned]\n @totalInProgressCredits = creditSummary[:totalInProgress]\n @totalNeededCredits = creditSummary[:totalNeeded]\n @upperDivEarnedCredits = creditSummary[:upperDivEarned]\n @upperDivInProgressCredits = creditSummary[:upperDivInProgress]\n @upperDivNeededCredits = creditSummary[:upperDivNeeded]\n\n # Get GPA summary and color red or green based on min requirements\n gpaSummary = getGPA(reportText)\n @cumulativeGPA = gpaSummary[:cumulativeGPA]\n @majorGPA = gpaSummary[:majorGPA]\n\n if @cumulativeGPA.to_i > 2\n @cumulativeGPAStatus = 'color: green'\n @cumulativeGPAIconClass = 'glyphicon glyphicon-ok'\n else\n @cumulativeGPAStatus = 'color: red'\n @cumulativeGPAIconClass = 'glyphicon glyphicon-remove'\n end\n\n if @majorGPA.to_i > 2\n @majorGPAStatus = 'color: green'\n @majorGPAIconClass = 'glyphicon glyphicon-ok'\n else\n @majorGPAStatus = 'color: red'\n @majorGPAIconClass = 'glyphicon glyphicon-remove'\n end\n\n # Get general and sub requirement status\n @genRequirementsArray = getGeneralRequirements(reportText)\n @subRequirementsArray = getSubRequirements(reportText)\n @verboseSectionsArray = getVerboseSections(reportText)\nend", "def create_report(opts = {})\n data, _status_code, _headers = create_report_with_http_info(opts)\n data\n end", "def create\n\n\n @report = Report.new(params[:report])\n respond_to do |format|\n if @report.save\n format.html { redirect_to(@report, :notice => 'Report was successfully created.') }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @report = Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to(@report, :notice => 'Report was successfully created.') }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'El Reporte fue creado Exitosamente.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end", "def run\n @file_paths.each do |path|\n process_file(path)\n end\n @report\n end", "def create\n @report = Mg::Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { flash[:notice] = 'Your report was successfully created, now add some report items.'; redirect_to(edit_mg_report_url @report) }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end", "def process(yaml)\n return if Puppet[:reports] == \"none\"\n\n # First convert the report to real objects\n begin\n report = YAML.load(yaml)\n rescue => detail\n Puppet.warning \"Could not load report: #{detail}\"\n return\n end\n\n # Used for those reports that accept yaml\n client = report.host\n\n reports.each do |name|\n if mod = Puppet::Reports.report(name)\n # We have to use a dup because we're including a module in the\n # report.\n newrep = report.dup\n begin\n newrep.extend(mod)\n newrep.process\n rescue => detail\n puts detail.backtrace if Puppet[:trace]\n Puppet.err \"Report #{name} failed: #{detail}\"\n end\n else\n Puppet.warning \"No report named '#{name}'\"\n end\n end\n end", "def report\n super\n\n begin\n puts \"Writing HTML reports to #{@reports_path}\"\n erb_str = File.read(@erb_template)\n renderer = ERB.new(erb_str)\n\n tests_by_suites = tests.group_by { |test| test_class(test) } # taken from the JUnit reporter\n\n suites = tests_by_suites.map do |suite, tests|\n suite_summary = summarize_suite(suite, tests)\n suite_summary[:tests] = tests.sort { |a, b| compare_tests(a, b) }\n suite_summary\n end\n\n suites.sort! { |a, b| compare_suites(a, b) }\n\n result = renderer.result(binding)\n File.open(html_file, 'w') do |f|\n f.write(result)\n end\n\n # rubocop:disable Lint/RescueException\n rescue Exception => e\n puts 'There was an error writing the HTML report'\n puts 'This may have been caused by cancelling the test run'\n puts 'Use mode => :verbose in the HTML reporters constructor to see more detail' if @mode == :terse\n puts 'Use mode => :terse in the HTML reporters constructor to see less detail' if @mode != :terse\n raise e if @mode != :terse\n end\n # rubocop:enable Lint/RescueException\n end", "def report\n @report = Report.create(reports_params)\n if @report.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create report' }, status: :internal_server_error\n end\n end", "def parse_report(result_body)\n # The routin should be provided in the inherited class\n end", "def perform(report_id)\n report = Report.find(report_id)\n\n # Check if the report is already being processed or was processed (it has a parser_status)\n return if report.parser_status\n\n report.update!(parser_status: 'parsing')\n\n # Start a timeout worker for the parser\n ReportWorker::Parser::TimeoutChecker.perform_in(ReportWorker::Parser::TimeoutChecker::PARSING_TIMEOUT, report.id)\n\n parsers_for(report.data[\"reporter\"][\"type\"]).each do |parser|\n begin\n parser::REQUIRE.each do |requirement|\n raise InformationMissing, \"The #{parser} parser requires information from the #{requirement} collector.\" unless report.data[requirement.to_s]\n end\n p = parser.new(report)\n p.analyze\n # refresh the report object, in case the parser made any changes to it\n report.reload\n rescue => exception\n report.update!(parser_status: 'failure')\n raise exception\n end\n end\n\n # Everything went well\n report.update!(parser_status: 'success')\n end", "def create_report_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ReportApi.create_report ...'\n end\n # resource path\n local_var_path = '/api/3/reports'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=UTF-8'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'report'])\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'CreatedReferenceintLink')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ReportApi#create_report\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def report\n begin\n build_info = params.require(:build_info)\n issue_info = params.require(:issue_info)\n rescue ActionController::ParameterMissing\n return invalid_params('Missing parameter')\n end\n # Get the build for this issue. If it doesn't exist, create it\n build = Build.find_or_create_by(:product => build_info[:product], \n :branch => build_info[:branch], \n :name => build_info[:name])\n\n # Check if an issue with this signature and type exists for this build. If not, create one\n # This will result in some duplicate issues when found across different builds.\n # Those duplicates can be merged later when the issue is triaged.\n created = false\n issue = build.issues.where(:issue_type => issue_info[:issue_type], \n :signature => issue_info[:signature]).first_or_create do |obj|\n # If the issue gets created, the instance merging the issue and build will also get created\n created = true\n end\n\n # Create an instance that points to this build and issue\n if !created\n instance = issue.instances.create(:build => build)\n else\n instance = issue.instances.where(:build => build).first\n end\n\n # Return the created instance\n render json: instance\n end", "def create\n # debugger\n # reportable = params[:report][:reportable].split(',').collect {|s| s.strip}\n #\n # at this point params might be:\n #\n # {\"commit\"=>\"Create\", \"action\"=>\"create\", \"controller\"=>\"reports\", \n # \"report\"=>{\"name\"=>\"third report\", \"public\"=>\"0\", \"reportable_id\"=>\"1\", \"description\"=>\"another description\", \"otrunk_report_template_id\"=>\"1\"}}\n #\n # we can just create a new @report instance like this:\n #\n # \n # This way all the parameters are set that are present in the\n # hash value for \"report\" in params.\n #\n # but do need to handle hard-coding the reportable_type because\n # it isn't handled more generally yet by the view or the DIY\n #\n #\n # eot_id = params[:report][:reportable_id]\n # ort_id = params[:report][:otrunk_report_template_id]\n # @report = Report.new(:reportable_type => \"ExternalOtrunkActivity\", :reportable_id => eot_id, :otrunk_report_template_id => ort_id)\n #\n @report.user = current_user\n respond_to do |format|\n if @report.save\n flash[:notice] = 'Report was successfully created.' \n format.html { redirect_to reports_url }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n flash[:notice] = 'Errors creating Report.'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_report\n Report.create_for_team(id)\n end", "def create_report\n Report.create_for_team(id)\n end", "def report\n @logger\n end", "def report\r\n if Post.exists?(params[:id])\r\n if params[:reports]\r\n @new_report = Report.create_new(params, @usr)\r\n if @new_report.errors.empty?\r\n unless Configs.get_config('mailing_list').blank?\r\n Configs.get_config('mailing_list').split(',').each do |email|\r\n ReportMailer.deliver_email(@new_report.user.name, email.strip, @new_report, request.env['HTTP_HOST'])\r\n end\r\n end\r\n redirecting t(:redir), session[:last_page]\r\n return\r\n end\r\n end\r\n else\r\n redirect_to_info_page\r\n end\r\n end" ]
[ "0.7349697", "0.6893435", "0.6888932", "0.6838542", "0.6825587", "0.6707957", "0.6694205", "0.6666582", "0.6666582", "0.6665627", "0.6603604", "0.6603604", "0.6603604", "0.6603604", "0.6603604", "0.6582065", "0.6540434", "0.65082556", "0.6411238", "0.63838077", "0.6372985", "0.6335237", "0.63303363", "0.63119054", "0.63089633", "0.62946534", "0.6288554", "0.6286058", "0.62796515", "0.62672627", "0.6267216", "0.62395483", "0.623579", "0.6229291", "0.62169105", "0.6214118", "0.62026906", "0.62026906", "0.6196148", "0.6195535", "0.6178717", "0.61751056", "0.61460674", "0.6124648", "0.61210126", "0.6111688", "0.610535", "0.6097725", "0.6097087", "0.6052392", "0.60372746", "0.60347664", "0.60292834", "0.6023544", "0.6022377", "0.6016403", "0.5997962", "0.59952", "0.5993395", "0.59899443", "0.59870005", "0.5982268", "0.59796244", "0.59664744", "0.59640044", "0.5963083", "0.595391", "0.59463996", "0.59420943", "0.5934721", "0.5930223", "0.5930121", "0.5928166", "0.5927637", "0.5919893", "0.5918265", "0.5917682", "0.5915784", "0.59156466", "0.59156466", "0.5909833", "0.58999866", "0.589906", "0.58928955", "0.5890305", "0.5888949", "0.58829087", "0.58818406", "0.5881132", "0.58759165", "0.58756864", "0.5868839", "0.5854446", "0.5854334", "0.5850278", "0.5844101", "0.58319163", "0.58319163", "0.5823807", "0.58112854" ]
0.6175298
41
Outputs a processed report with Danger
def output_report(report) # Create markdown report_markdown = report.markdown_value # Send markdown markdown(report_markdown) # Notify failure if minimum coverage hasn't been reached threshold = Xcov.config[:minimum_coverage_percentage].to_i if !threshold.nil? && (report.coverage * 100) < threshold fail("Code coverage under minimum of #{threshold}%") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def report(output)\n end", "def write_report\n\n end", "def report; end", "def report; end", "def report; end", "def report; end", "def report; end", "def output_report\n\t\toutput_start\n\t\toutput_head\n\t\toutput_body_start\n\t\toutput_body\n\t\toutput_body_end\n\t\toutput_end\n\tend", "def report\n\t\tend", "def report\n \n end", "def output_report\n report = \"\"\n report << '<html>'\n report << ' <head>'\n report << \" <title>#{@title}</title>\"\n report << ' </head>'\n report << ' <body>'\n @text.each { |line| report << \" <p>#{line}</p>\" }\n report << ' </body>'\n report << '</html>'\n end", "def generate_report\n @notices << \"#{ActionController::Base.helpers.pluralize(@batch_ids.count, 'Item')} clearanced into batch #{batch.id}\" if batch.id\n @errors << \"#{ActionController::Base.helpers.pluralize(@errors.count, 'id')} raised errors and were not clearanced\" if errors.any?\n @errors << \"No new clearance batch was added\" unless batch.id\n @errors << \"No Item or CSV passed\" if !@item_id && !@file\n end", "def finalize_standard_report\n render_pdf\n end", "def report(output)\n output << self.inspect\n output << \"\\n\"\n end", "def report(output)\n output << self.inspect\n output << \"\\n\"\n end", "def report_body; end", "def report_body; end", "def create_report\n report_path = \"/tmp/metasploit_#{@workspace_name}.xml\"\n\n # Create the report using the db_export command\n _send_command(\"db_export #{report_path}\\n\")\n\n # We've sent the command, so let's sit back and wait for th\n # output to hit the disk.\n begin\n xml_string = \"\"\n status = Timeout::timeout(240) {\n # We don't know when the file is going to show up, so \n # wait for it...\n until File.exists? report_path do\n sleep 1\n end\n\n # Read and clean up the file when it exists...\n until xml_string.include? \"</MetasploitV4>\" do\n sleep 5\n xml_string = File.read(report_path)\n end\n \n File.delete(report_path)\n }\n rescue Timeout::Error\n xml_string = \"<MetasploitV4></MetasploitV4>\"\n end\n\n xml_string\n end", "def complaintsreport\n\t\t@complaints = Complaint.find(:all)\t\t\n html = render :layout => false \n\tkit = PDFKit.new(html)\n\n\tkit.stylesheets << RAILS_ROOT + '/public/stylesheets/styles.css' \n\n\tsend_data(kit.to_pdf, :filename => \"complaintsreport.pdf\", :type => 'application/pdf')\n\tend", "def create_report\n report_path = \"/tmp/metasploit_#{@workspace_name}.xml\"\n\n # Create the report using the db_export command\n _send_command(\"db_export #{report_path}\\n\")\n\n # We've sent the command, so let's sit back and wait for th\n # output to hit the disk.\n begin\n xml_string = \"\"\n status = Timeout::timeout(240) {\n # We don't know when the file is going to show up, so\n # wait for it...\n until File.exists? report_path do\n sleep 1\n end\n\n # Read and clean up the file when it exists...\n until xml_string.include? \"</MetasploitV4>\" do\n sleep 5\n xml_string = File.read(report_path)\n end\n\n File.delete(report_path)\n }\n rescue Timeout::Error\n xml_string = \"<MetasploitV4></MetasploitV4>\"\n end\n\n xml_string\n end", "def report(output)\n output.title('Request database created')\n \n output << \"A database file has been created with all parsed request information.\\n\"\n output << \"#{@request_count} requests have been added to the database.\\n\" \n output << \"To execute queries on this database, run the following command:\\n\"\n output << output.colorize(\" $ sqlite3 #{options[:database]}\\n\", :bold)\n output << \"\\n\"\n end", "def export_report\n @report.export_report\n end", "def export_report\n @report.export_report\n end", "def trash_report\n respond_to do |format|\n format.html\n @trash = Trash.all\n @user = current_user\n \n #generate pdf file\n pdf = TrashPdf.new(@trash, @user)\n send_data pdf.render, :filename => 'trashReport-' + Time.now.to_date.to_s + '.pdf', :type => 'application/pdf', :disposition => 'attachment'\n end\n end", "def output\n @output ||= report.display\n end", "def output_to_report_file message\n @spec_report_file.puts message\n end", "def loanaccountreport\n\t\t@loanaccounts = Loanaccount.find(:all, :order=>\"loanaccountno\")\t\t\n \t html = render :layout => false \n \tkit = PDFKit.new(html)\n \tkit.stylesheets << RAILS_ROOT + '/public/stylesheets/styles.css' \n \tsend_data(kit.to_pdf, :filename => \"loanaccountreport.pdf\", :type => 'application/pdf')\n\tend", "def generate_scan_report\n freshclam_stderr = IO.read($config[\"freshclam_stderr\"])\n freshclam_stdout = @freshclam_stdout\n template = IO.read(\"views/clamav.html.erb\")\n output = ERB.new(template).result(binding)\n File.open(\"clamav.html\", \"w\") {|file| file.write(output)}\nend", "def report\n respond_to do |format|\n format.pdf { \n # send_file TestPdfForm.new(PdfRecord.first).export, type: 'application/pdf'\n\n pdf = InvoicePdf.new(current_user, @invoice).export\n send_file pdf[:filename], type: 'application/pdf' \n\n # pdf = InvoicePdf.new(current_user, @invoice).export_02\n # send_data pdf[:body], type: 'application/pdf' \n }\n end\n end", "def output_report\n \t# Have user indicate the type of renewable energy system that generated the file\n \t# The Aurora is type-agnostic: it only reports power and energy regardless of the type.\n \t#\n \tputs \"Enter the number for the type of renewable production system?\\n\"\n \tputs \"1.\\tPV Solar\\n\"\n \tputs \"2.\\tThermal Solar\\n\"\n \tputs \"3.\\tOnshore Wind\\n\"\n \tputs \"4.\\tGeothermal\\n\"\n \tputs \"5.\\tHydroelectric\\n\"\n \tputs \"6.\\tBiomass\\n\"\n \tprint \"Your Choice: \"\n \twarning = \"\"\n\t\tinput = STDIN.gets.chomp\n\t\tcase input.to_i\n\t\twhen 1\n\t\t\t@system_type = :PV_Solar\n\t\twhen 2\n\t\t\t@system_type = :Thermal_Solar\n\t when 3\n\t \t@system_type = :Onshore_Wind\n\t\twhen 4\n\t\t\t@system_type = :Geothermal\n\t\twhen 5\n\t\t\t@system_type = :Hydroelectric\n\t\twhen 6\n\t\t\t@system_type = :Biomass\n\t else\n\t \twarning = \"Invalid energy type give. Default is \"\n\t \t@system_type = :PV_Solar\n\t\tend\n\t\t@carbon_savings = (@energy_amount / 1000.0) * (CO2_USGRID - ENERGY_TYPES[@system_type])\n\t\t@ave_power = (@energy_amount / @energy_run_time).round(2)\n\t\t# Write a new output file. Note that this overwrites any existing file.\n output_file = File.open(\"Energy Report.txt\", 'w+')\n text = create_text_report warning, TEXT_TEMPLATE\n output_file.write text\n output_file.close\n\n output_file = File.open(\"Energy Report.html\", 'w+')\n html = create_text_report warning, HTML_TEMPLATE\n output_file.write html\n output_file.close\n puts \"Created files: \\\"Engergy Report.txt\\\" and \\\"Engergy Report.html\\\"\"\n end", "def storeconsumptionreport\n\t\t@storecunsumptions = Storecunsumption.find(:all)\t\t\n html = render :layout => false \n\tkit = PDFKit.new(html)\n\n\tkit.stylesheets << RAILS_ROOT + '/public/stylesheets/styles.css' \n\n\tsend_data(kit.to_pdf, :filename => \"storeconsumptionreport.pdf\", :type => 'application/pdf')\n\tend", "def report_run(command)\n super do |report|\n @report = report\n yield report\n end\n end", "def end_report_app(app, report)\n all_reports = report.all_reports\n\n warning_reports = all_reports.select { |r| r.warnings.any? }.to_a\n if warning_reports.any?\n shell.newline\n shell.warn \"Warnings:\"\n warning_reports.each do |r|\n display_metadata = r.map { |k, v| \"#{k}: #{v}\" }.join(\", \")\n\n shell.warn \"* #{r.name}\"\n shell.warn \" #{display_metadata}\" unless display_metadata.empty?\n r.warnings.each do |warning|\n shell.warn \" - #{warning}\"\n end\n shell.newline\n end\n end\n\n errored_reports = all_reports.select { |r| r.errors.any? }.to_a\n\n dependency_count = all_reports.count { |r| r.target.is_a?(Licensed::Dependency) }\n error_count = errored_reports.reduce(0) { |count, r| count + r.errors.size }\n\n if error_count > 0\n shell.newline\n shell.error \"Errors:\"\n errored_reports.each do |r|\n display_metadata = r.map { |k, v| \"#{k}: #{v}\" }.join(\", \")\n\n shell.error \"* #{r.name}\"\n shell.error \" #{display_metadata}\" unless display_metadata.empty?\n r.errors.each do |error|\n shell.error \" - #{error}\"\n end\n shell.newline\n end\n end\n\n shell.newline\n shell.info \"#{dependency_count} dependencies checked, #{error_count} errors found.\"\n end", "def interpret_report(command)\n ensure_placed\n @ui.write_text @robot.report\n end", "def output_pdf\n siz = @report.size.to_i\n if siz < 500 || Dialog.confirm(\"Cela demandera environ #{siz / 250} secondes\")\n path = ask_path('.pdf')\n path ? build_and_save_pdf(path) : 'Annulé'\n else\n 'Annulé'\n end\n rescue\n pdf_error\n end", "def write_report\n @manager.atomic_file(report_file) do |file|\n file.write(JSON.pretty_generate(get_status))\n end\n end", "def report\n # Iterate over each qotd record and check if it is present verbatim\n # in the corresponding content AT file.\n discrepancies = []\n @qotd_records.each { |qotd_record|\n date_code = qotd_record[:title].downcase\n puts \" - processing #{ date_code }\"\n sanitized_qotd_content = sanitize_qotd_content(qotd_record[:contents])\n corresponding_content_at_file = RFile::ContentAt.find_by_date_code(\n date_code,\n \"at\",\n @content_type\n )\n\n if corresponding_content_at_file.nil?\n raise ArgumentError.new(\"Could not find content AT file for #{ date_code }\")\n end\n\n sanitized_content_at_plain_text = sanitize_content_at_plain_text(\n corresponding_content_at_file.plain_text_with_subtitles_contents({})\n )\n\n find_diffs_between_qotd_and_content_at(\n date_code,\n qotd_record[:publishdate],\n sanitized_qotd_content,\n sanitized_content_at_plain_text,\n discrepancies\n )\n }\n assign_discrepancy_types(discrepancies)\n discrepancies\n end", "def reportall\n\t\t@marriges = Marriage.find(:all, :order =>\"register_id\")\n \t\thtml = render :layout => false \n\t\tkit = PDFKit.new(html)\n\n\t\tkit.stylesheets << RAILS_ROOT + '/public/stylesheets/styles.css' \n\n\t\tsend_data(kit.to_pdf, :filename => \"marriagereport.pdf\", :type => 'application/pdf')\n\tend", "def reporters; end", "def reporters; end", "def reporters; end", "def reporters; end", "def reporters; end", "def hospitalreport\n\t\t@hospitals = Hospital.find (:all)\n html = render :layout => false \n\tkit = PDFKit.new(html)\n\n\tkit.stylesheets << RAILS_ROOT + '/public/stylesheets/styles.css' \n\n\tsend_data(kit.to_pdf, :filename => \"hospitalreport.pdf\", :type => 'application/pdf')\n\tend", "def display_report(report)\n super\n\n File.write(ConfigurationLoader::AUTO_GENERATED_FILE, config_file_contents)\n log.log \"Created #{ConfigurationLoader::AUTO_GENERATED_FILE}.\"\n log.log \"Run `haml-lint --config #{ConfigurationLoader::AUTO_GENERATED_FILE}`\" \\\n \", or add `inherits_from: #{ConfigurationLoader::AUTO_GENERATED_FILE}` in a \" \\\n '.haml-lint.yml file.'\n end", "def reporting\n # STUB\n end", "def report\n super\n\n begin\n puts \"Writing HTML reports to #{@reports_path}\"\n erb_str = File.read(@erb_template)\n renderer = ERB.new(erb_str)\n\n tests_by_suites = tests.group_by { |test| test_class(test) } # taken from the JUnit reporter\n\n suites = tests_by_suites.map do |suite, tests|\n suite_summary = summarize_suite(suite, tests)\n suite_summary[:tests] = tests.sort { |a, b| compare_tests(a, b) }\n suite_summary\n end\n\n suites.sort! { |a, b| compare_suites(a, b) }\n\n result = renderer.result(binding)\n File.open(html_file, 'w') do |f|\n f.write(result)\n end\n\n # rubocop:disable Lint/RescueException\n rescue Exception => e\n puts 'There was an error writing the HTML report'\n puts 'This may have been caused by cancelling the test run'\n puts 'Use mode => :verbose in the HTML reporters constructor to see more detail' if @mode == :terse\n puts 'Use mode => :terse in the HTML reporters constructor to see less detail' if @mode != :terse\n raise e if @mode != :terse\n end\n # rubocop:enable Lint/RescueException\n end", "def wardreport\n\t\t@wards = Ward.find(:all)\n\n\n html = render :layout => false \n\tkit = PDFKit.new(html)\n\n\tkit.stylesheets << RAILS_ROOT + '/public/stylesheets/styles.css' \n\n\tsend_data(kit.to_pdf, :filename => \"wardreport.pdf\", :type => 'application/pdf')\n\tend", "def show\n authorize :report, :show?\n if params[:finalizar]\n @resquest_criminal.status = 2\n @resquest_criminal.save\n end\n respond_to do |format|\n format.html\n format.pdf {render template: 'reports/report_pdf', pdf: \"laudo-#{@report.id}-#{@report.updated_at}\"}\n end\n end", "def parse_output(_report, _result, _targets); end", "def report\n message = [identification]\n\n message.concat(make_report('Original-Source', :original_source))\n message.concat(make_report('Generated-Source', :generated_source))\n message.concat(make_report('Original-Node', :original_node))\n message.concat(make_report('Generated-Node', :generated_node))\n message.concat(node_diff_report)\n\n message.join(\"\\n\")\n end", "def export_report\n @report_uris.each do |directive|\n # First create the string for the report.\n uri = directive['uri']\n verbose = directive['verbose'] || false\n report_string = case directive['format']\n when 'txt' then to_s(verbose: verbose)\n when 'json' then to_json\n when 'yaml' then to_yaml\n else\n raise ExportReportError, \"unknown report format #{directive['format']}\"\n end\n\n # Now send this string to its destination.\n if Salus::Config::REMOTE_URI_SCHEME_REGEX.match?(URI(uri).scheme)\n send_report(uri, report_string, directive['format'])\n else\n # must remove the file:// schema portion of the uri.\n uri_object = URI(uri)\n file_path = \"#{uri_object.host}#{uri_object.path}\"\n write_report_to_file(file_path, report_string)\n end\n end\n end", "def generate_report(_callback_data)\n text_report = OrderReport.new.generate\n\n respond_with :message, text: text_report, parse_mode: :Markdown\n answer_callback_ok\n end", "def output_to_file (products_hash, brands_hash)\n\t_sales_report_header\n\t_products_header\n\tproducts_section(products_hash)\n\tend_of_section\n\t_brands_header\n\tbrands_section(brands_hash)\n\tend_of_section\n\t$report_file.puts 'THIS REPORT HAS BEEN CREATED BY MROHDE'\nend", "def write!\n puts \"\\nOutputting file...\"\n verify_file_path(report_filename)\n if File.open(report_filename, \"wb\") { |f| f.write @pdf.render }\n return report_filename\n else\n raise \"ERROR\"\n nil\n end\n end", "def create_report\n print_sales_report_ASCII\n print_date\n print_products_ASCII\n print_brands_ASCII\n end", "def send_report_data\n render_type = RENDER_TYPES[@sb[:render_type].to_s]\n raise \"Render type #{@sb[:render_type]} is not supported\" unless render_type\n\n assert_privileges(\"render_report_#{render_type}\")\n\n return unless @sb[:render_rr_id]\n\n disable_client_cache\n result = MiqReportResult.find(@sb[:render_rr_id])\n\n filename = filename_timestamp(result.report.title, 'export_filename')\n send_data(result.get_generated_result(@sb[:render_type]),\n :filename => \"#{filename}.#{@sb[:render_type]}\",\n :type => \"application/#{@sb[:render_type]}\")\n\n result.destroy\n end", "def html_report\n begin\n require 'ruport'\n rescue LoadError\n abort(\"Couldn't load ruport, suggest that gem install ruport should help\")\n end\n\n unless @options.report_file\n html_report_file_name = 'Kismet-Wireless-Report-' + Time.now.to_s + '.html'\n end\n\n unless @options.report_file =~ /html$/\n html_report_file_name = @options.report_file + '.html'\n end\n\n @report = File.new(html_report_file_name,'w+')\n html_report_header\n html_report_stats\n \n if @options.create_map\n @report << '<hr /><br /><br />'\n html_report_map_body\n end\n @report << '<hr /><br /><br />'\n html_report_inf\n @report << '<hr /><br /><br />'\n html_report_adhoc\n @report << '<hr /><br /><br />'\n html_report_probe\n @report << \"</body>\"\n @report << \"</html>\"\n end", "def set_report\n end", "def __log_report(file)\n print \"Rendering `#{file}'...\" if @ocproblem.verbose\n yield\n puts \"done!\" if @ocproblem.verbose\n end", "def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = BgWorkerReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end", "def report\n @output.puts \"#{posx},#{posy},#{dir.to_s.upcase}\"\n activate\n end", "def report(out=$stderr)\n errors = expected_participants.collect(&:errors).flatten\n unless errors.empty?\n out.puts \"CSV Errors:\"\n errors.each do |error|\n out.puts \"* #{error}\"\n end\n out.puts\n end\n\n if differences.empty?\n out.puts \"Everything matches exactly.\"\n else\n differences.each do |code, p_ids|\n out.puts MESSAGES[code]\n p_ids.sort.each do |p_id|\n out.puts \"* #{p_id}\"\n end\n end\n end\n end", "def reporte\n puts \"======================================================================================================\"\n @agentes_pdf = Agente.all\n\n respond_to do |format| \n format.pdf do\n pdf = AgentesPdf.new(@agentes_pdf, view_context)\n send_data pdf.render, filename: \"agentes.pdf\",\n type: \"application/pdf\",\n disposition: \"inline\"\n end \n end\n end", "def process\n ReportAdapter.new(report: runner.run(run_options), root: root).each do |issue|\n io.print issue.to_json\n io.print \"\\0\"\n end\n end", "def report(file, result)\n Fast.report(result,\n file: file,\n show_link: @show_link,\n show_permalink: @show_permalink,\n show_sexp: @show_sexp,\n headless: @headless,\n bodyless: @bodyless,\n colorize: @colorize)\n end", "def mreport\r\n\t\tsystem (\"clear\")\r\n\t\tputs \"#@name\" + \" the \" + \"#@type \" + \"approaches!!\"\r\n\t\tputs \" \"\r\n\t\tputs \"#@name\" + \" has \" + \"#@health \" + \"health\"\r\n\t\tputs \" \"\r\n\t\tsleep 1\r\n\t\treturn\r\n\tend", "def output(review)\n @destination ||= 'checkstyle-report.xml'\n\n FileUtils.mkdir_p(File.dirname(@destination))\n File.open(@destination, 'w') do |outfile|\n outfile.write \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n<checkstyle version=\\\"5.0\\\">\\n\"\n review.warnings_by_file_and_line.each do |file, line|\n outfile.write \" <file name=\\\"#{file}\\\">\\n\"\n line.each do |line, violations|\n violations.each do |rule|\n severity = rule.tags.include?('correctness') ? 'error' : 'warning'\n source = rule.source.source_location.join(':') + ':RULE.' + rule.code\n outfile.write \" <error line=\\\"#{line}\\\" severity=\\\"#{severity}\\\" message=\\\"#{rule.code}: #{rule.name}\\\" source=\\\"#{source}\\\"/>\\n\"\n end\n end\n outfile.write \" </file>\\n\"\n end\n outfile.write '</checkstyle>'\n end\n end", "def show\n\t\tif params[:id] == 'pdf'\n render :pdf => \"file_name\",\n :orientation => 'Portrait',\n :margin => { :top => 8.5,\n :bottom => 8.5,\n :left => 6,\n :right => 6\n },\n :template => 'analyzers/report.erb',\n :disposition => 'attachment' \n return\n end\n\tend", "def print_sales_report\n$report_file.puts \"\n ##### ######\n # # ## # ###### #### # # ###### ##### #### ##### #####\n # # # # # # # # # # # # # # # #\n ##### # # # ##### #### ###### ##### # # # # # # #\n # ###### # # # # # # ##### # # ##### #\n # # # # # # # # # # # # # # # # #\n ##### # # ###### ###### #### # # ###### # #### # # #\n********************************************************************************\n\"\nend", "def report(msg, stdout) \n\t\[email protected] msg\n\t\tif (stdout==1)\n\t\t\t# puts \"entrei\"\n\t\t\tprint msg\n\t\tend\n\tend", "def report\n # generate_report()\n ReportWorker.perform_async(\"07-01-2018\", \"08-01-2018\")\n render \\\n json: {status: 'SUCCESS', message:'REQUEST TO GENERATE A REPORT ADDED TO THE QUEUE'},\n status: :ok\n end", "def report\n @report_file || \"kacl_report.json\"\n end", "def report\n require File.join File.expand_path(File.dirname(__FILE__)), \"report\"\n Brakeman::Report.new(self)\n end", "def report\n @logger\n end", "def print_final_report\n puts; puts; puts \"=== FINAL DATABASE COUNTS ===\"\n puts; puts end_of_task_report\n puts; puts; puts \"=== BY SCHOOL ===\"\n puts by_school_report\n puts; AssessmentsReport.new.print_report\n end", "def report_to_stdout\n @report_history.each do |report|\n puts(report)\n end\n end", "def final_report( registry = Deprecatable.registry )\n lines = [ \"Deprecatable 'at_exit' Report\",\n \"=============================\" ]\n lines << \"\"\n lines << \"To turn this report off do one of the following:\"\n lines << \"\"\n lines << \"* in your ruby code set `Deprecatable.options.has_at_exit_report = false`\"\n lines << \"* set the environment variable `DEPRECATABLE_HAS_AT_EXIT_REPORT=\\\"false\\\"`\"\n lines << \"\"\n\n registry.items.each do |dm|\n lines += deprecated_method_report( dm )\n end\n lines.each { |l| warn_without_prefix l }\n end", "def fee_reciepts_export_pdf\n parameters={:search => params[:search] ,:filename => filename, :controller_name => controller_name, :action_name => action_name}\n opts = {\n :margin => {:left => 10, :right => 10, :bottom => 5}, \n :template=>\"delayed_pdfs/fee_reciepts/fee_reciepts_export_pdf.html\",\n :layout => \"layouts/pdf.html\"\n } \n GenerateReportPdf.export_pdf('finance_transaction','fee_reciepts_export_to_pdf', parameters, opts)\n flash[:notice]=\"#{t('pdf_report_is_in_queue')}\"\n redirect_to :controller => :report, :action=>:pdf_reports,:model=>'finance_transaction',:method=>'fee_reciepts_export_to_pdf'\n end", "def report\n sprintf \"Number of paragraphs %d \\n\" <<\n \"Number of sentences %d \\n\" <<\n \"Number of words %d \\n\" <<\n \"Number of characters %d \\n\\n\" <<\n \"Average words per sentence %.2f \\n\" <<\n \"Average syllables per word %.2f \\n\\n\" <<\n \"Flesch score %2.2f \\n\" <<\n \"Flesh-Kincaid grade level %2.2f \\n\" <<\n \"Fog Index %2.2f \\n\",\n num_paragraphs, num_sentences, num_words, num_characters,\n words_per_sentence, syllables_per_word,\n flesch, kincaid, fog\n end", "def report\n puts \"Hello! My name is #{@name}, I've delivered #{@experience} papers\n today and I've earned $#{@earnings} so far!\"\n end", "def create_output(descriptions)\n# render view which will create actual mail report\n body = DcApplicationController.new.render_to_string(\n :template => 'models/dump_models',\n :locals => { descriptions: descriptions },\n :layout => 'models' \n ) \n File.open(Rails.root.join('public','models_dump.html'),'w') {|f| f.write(body)}\n#\n body = ''\n descriptions.each do |description|\n collection = description.first\n all_fields = description.last \n body << \"#\\n# == Schema information\\n#\\n\"\n body << \"# Collection name: #{collection['id']} : #{collection['description']}\\n#\\n\"\n \n all_fields.each do |field|\n body << \"# #{field['field'].ljust(20)} #{field['type'].to_s.ljust(20)} #{field['description']}\\n\"\n end\n body << \"\\n\\n\"\n end \n File.open(Rails.root.join('public','description_dump.html'),'w') {|f| f.write(body)}\nend", "def report\r\n @lock.synchronize {\r\n \"#@name\\nChecking: #@checking\\nSavings: #@savings\"\r\n }\r\n end", "def report(context, repo, dir)\n raise \"No report(context, repo, dir) function defined by report subclass\"\n end", "def verbose_report\n result = header\n result += \":\\n#{smell_list}\" if should_report\n result += \"\\n\"\n result\n end", "def generateReport\n filePath = \"#{@reportFolder}/report.csv\"\n file = File.open(filePath, 'w')\n file.puts ['Screen', 'Description', 'Automation Message', 'Status'].join(',')\n @report.each do |result|\n file.puts result.join(',')\n end\n file.close\n end", "def data_report(options={})\n puts \"\\n\\n\"\n puts \"**********************************\\n\"\n puts \"**********************************\"\n puts @last_log\nend", "def reporting_mode\n process_commands!(REPORTING)\n end", "def export\n @pdf = build_referral( @referral )\n @pdf.render_file @referral.filespec\n redirect_to referrals_path, alert: \"Referral PDF file generated for patient #{@referral.patient.full_name}\"\n end", "def output; end", "def output; end", "def output; end", "def output; end", "def output; end", "def output; end", "def output; end", "def output; end", "def output; end", "def output; end", "def output; end" ]
[ "0.72368264", "0.69831306", "0.6944469", "0.6944469", "0.6944469", "0.6944469", "0.6944469", "0.6942214", "0.6897387", "0.68120337", "0.65397424", "0.6529683", "0.6332955", "0.6303936", "0.6303936", "0.6285366", "0.6285366", "0.61532116", "0.611859", "0.61098444", "0.61035913", "0.6069419", "0.6069419", "0.6053105", "0.60249144", "0.6013816", "0.60089064", "0.5992204", "0.59898454", "0.59177846", "0.5908133", "0.58701885", "0.5864338", "0.5855813", "0.58526665", "0.5845299", "0.5839839", "0.58352506", "0.582563", "0.582563", "0.582563", "0.582563", "0.582563", "0.58119524", "0.580775", "0.58020467", "0.57905316", "0.5787194", "0.57741785", "0.5772637", "0.5771337", "0.57573885", "0.5743131", "0.5742322", "0.57276255", "0.5723107", "0.57157296", "0.57152414", "0.5705518", "0.56991464", "0.5697536", "0.56856066", "0.56842613", "0.5673553", "0.56716406", "0.5668431", "0.56667894", "0.5666387", "0.56488705", "0.5647618", "0.5647415", "0.56455994", "0.564208", "0.56420255", "0.5641531", "0.5640943", "0.56357604", "0.56307596", "0.5617066", "0.5606552", "0.56036323", "0.5600509", "0.5598866", "0.55909896", "0.55882514", "0.55858976", "0.5580389", "0.5578461", "0.5575924", "0.5575304", "0.5575304", "0.5575304", "0.5575304", "0.5575304", "0.5575304", "0.5575304", "0.5575304", "0.5575304", "0.5575304", "0.5575304" ]
0.6046528
24
Aux methods Checks whether xcov is available
def xcov_available? `which xcov`.split("/").count > 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def requires_cvv?\n @require_cvv_set ||= false\n if @require_cvv_set\n @require_cvv\n else\n self.class.requires_cvv?\n end\n end", "def cv_required?\n true\n end", "def report_coverage?\n config.report || config.no_coverage.nil? && config.coverage && config.test.nil? && config.args.empty?\n end", "def view_with_check_option_support\n # :nocov:\n :local if server_version >= 90400\n # :nocov:\n end", "def is_compliant()\n\t\tend", "def experimental?\n (@name.first == \"X\")\n end", "def vpiX?\n get_value(VpiScalarVal) == VpiX\n end", "def covered?; end", "def check()\n if @csr_data[:country] == \"\" \n raise EZSSLException.new(\"'Country' is missing\") \n end\n if @csr_data[:state] == \"\" \n raise EZSSLException.new(\"'State' is missing\") \n end\n if @csr_data[:location] == \"\" \n raise EZSSLException.new(\"'Location' is missing\") \n end\n if @csr_data[:org] == \"\" \n raise EZSSLException.new(\"'Organization' is missing\") \n end\n if @csr_data[:domain] == \"\" \n raise EZSSLException.new(\"'Domain' is missing\") \n end\n end", "def precheck\n end", "def missed?\n coverage.zero?\n end", "def check_license()\n return true\n end", "def scopus_available?\n !ENV['SCOPUS_KEY'].nil?\n end", "def valid_mx?\n @host.exchanger.mxers.size > 0\n end", "def has_csr_data?\n return (!country.nil? and !state.nil? and !location.nil? and !org.nil? and !domain.nil?)\n end", "def coverage_exceeding_source_warn; end", "def coverage( idx )\n if @cov_ab[ idx ] == nil\n @cov_ab[ idx ] = VcfTools.get_coverage( @data[:info], @data[:samples][idx] )\n end\n return @cov_ab[ idx ]\n end", "def installed?\n super && source_api.electricity_output_capacity.positive?\n end", "def check_required_features\n unless Puppet.features.yard?\n raise RuntimeError, \"The 'yard' gem must be installed in order to use this face.\"\n end\n\n unless Puppet.features.rgen?\n raise RuntimeError, \"The 'rgen' gem must be installed in order to use this face.\"\n end\n\n if RUBY_VERSION.match(/^1\\.8/)\n raise RuntimeError, \"This face requires Ruby 1.9 or greater.\"\n end\n end", "def pax_installed?\n cmd_exec('/bin/grep -q \"PaX:\" /proc/self/status && echo true').to_s.strip.include? 'true'\n rescue\n raise 'Could not determine PaX status'\n end", "def coverage; end", "def coverage; end", "def can_xp?\n false\n end", "def check_for_requirements; end", "def esxi_installed?\n os_image_type == \"vmware_esxi\" && os_installed?\n end", "def needs_certification?\n return (current_registration = self.current_registration) && !self.current_registration.certified?\n end", "def check_environment\n load_rscribd\n check_config\n check_fields\n end", "def installed?\n source_api.number_of_units.positive? && positive_availability?\n end", "def test_verify\n # Start out unavailabl\n assert_raise(Puppet::Network::InvalidClientRequest) do\n @obj.verify(@request)\n end\n class << @obj\n def available?(req)\n true\n end\n end\n assert_raise(Puppet::Network::InvalidClientRequest) do\n @obj.verify(@request)\n end\n class << @obj\n def authorized?(req)\n true\n end\n end\n assert_nothing_raised do\n @obj.verify(@request)\n end\n end", "def ocsp_no_check?\n (extensions.key?(R509::Cert::Extensions::OCSPNoCheck))\n end", "def has_mcx?\n self.has_key? 'mcx_settings' and self['mcx_settings'].is_a? Array and not self['mcx_settings'].empty?\n end", "def essential_checks\n checks.select { |ctx| !ctx.functional? && !ctx.dev? }\n end", "def dev_checks\n checks.select { |ctx| !ctx.functional? }\n end", "def check_inv(value,opt_failure_message = '')\n check_assertion(value,value.invariant?,CHECK_INV_VIOLATION_CLASS,'Class Invariant violated',opt_failure_message)\nend", "def estConsomable()\n\t\treturn false\n\tend", "def uncovered\n return true\n end", "def _expect_gc?\n !!@expect_gc\n end", "def dataProviderCheck()\n\n logger.debug \"#{self.class.to_s}:#{__method__}: #{__LINE__}: DataProviderCheck\"\n\n dataProviderInit\n\n check = @fileCheck.() if @useFileProvider\n check = @esbCheck.() if @useEsbProvider\n\n logIfUnavailable(check, \"verify the check url configuration\")\n\n check\n end", "def covered?\n coverage.positive?\n end", "def test_harness_dependencies(*)\n return unless platform[/n(5|6)k/]\n skip_if_nv_overlay_rejected(agent)\n\n # Vxlan has a hard requirement to disable feature fabricpath on n5/6k\n cmd = 'no feature-set fabricpath'\n command_config(agent, cmd, cmd)\nend", "def show\n\n authorize @cov_negative\n end", "def fully_covered\n return true\n end", "def needed_if_relevant?\n false\n end", "def require_product?\n !!!catalog_request?\n end", "def require_product?\n !!!catalog_request?\n end", "def check ; true ; end", "def confidence; end", "def needed_if_relevant?\n false\n end", "def test_args(aux_libraries, ci_gcc_config)\n # TODO: something with libraries?\n ret = include_args(aux_libraries)\n unless ci_gcc_config.nil?\n cgc = ci_gcc_config\n ret = feature_args(cgc) + warning_args(cgc) + define_args(cgc) + flag_args(cgc) + ret\n end\n ret\n end", "def is_cross_company?\n super && !is_anniversary?\n end", "def should_remove_librun_and_stc_sources\n !(core_developer? or ENV['RETAIN_STX_AND_LIBRUN_SOURCE'] == 'yespleaseretain!')\nend", "def has_license?\n !license.nil?\n end", "def start_coverage\n return unless sporkless? # Something funny about numbers right now under spork\n require 'simplecov'\nend", "def certified?\n @data['certifiedDev']\n end", "def applySupport(x)\n if ((x.minus_state_set.length > 0 || x.plus_state_set.length > 0) && \n x.base_damage == 0 && \n x.hp_recovery == 0 && x.hp_recovery_rate == 0 &&\n x.mp_recovery == 0 && x.mp_recovery_rate == 0) == @value\n return true\n else\n return false\n end\n end", "def dependency_unmet?(*args, &block); end", "def votable?\n # NOTE: it was requested by NCID staff to make all registrations automatically votable\n # regardless of certification status\n return true\n# return self.certification.present?\n end", "def has_catalog?\n false\n end", "def respond_to?(method_name, *)\n if method_name.eql? :coverage\n true\n else\n super\n end\n end", "def SanityCheck(silent)\n return true # FIXME!\n if !@init_pkg_data_complete\n if !silent\n Builtins.y2error(\n \"PackageSlideShow::SanityCheck(): Slide show not correctly initialized: \" +\n \"PackageSlideShow::InitPkgData() never called!\"\n )\n end\n return false\n end\n\n if Ops.less_than(@current_src_no, 1) || Ops.less_than(@current_cd_no, 1)\n # nothing to install but something is going to be deleted, so it's OK\n if Pkg.IsAnyResolvable(:package, :to_remove)\n return true\n elsif !silent\n Builtins.y2error(\n -1,\n \"PackageSlideShow::SanityCheck(): Illegal values for current_src_no (%1) or current_cd_no (%2)\",\n @current_src_no,\n @current_cd_no\n )\n Builtins.y2milestone(\"total sizes: %1\", @total_sizes_per_cd_per_src)\n end\n return false\n end\n\n true\n end", "def vendor?\n !vendor.empty?\n end", "def static_pxe?\n pxe_network.static\n end", "def is_variable_available\n super\n end", "def ceph_chef_ceph_chef_use_cephx?(type = nil)\n # Verify type is valid\n type = 'cluster' if %w(cluster service client).index(type).nil?\n\n # CephX is enabled if it's not configured at all, or explicity enabled\n node['ceph']['config'].nil? ||\n node['ceph']['config']['global'].nil? ||\n node['ceph']['config']['global'][\"auth #{type} required\"].nil? ||\n node['ceph']['config']['global'][\"auth #{type} required\"] == 'cephx'\nend", "def should_report? issue\n diagnose = self[issue]\n diagnose == :error || diagnose == :warning || diagnose == :deprecation\n end", "def checks; end", "def certificate_check_state\n super\n end", "def xenchk(session)\n vm = false\n xenprocs = [\n \"xenservice.exe\"\n ]\n session.sys.process.get_processes().each do |x|\n xenprocs.each do |p|\n if p == (x['name'].downcase)\n vm = true\n end\n end\n end\n if not vm\n srvvals = registry_enumkeys('HKLM\\HARDWARE\\ACPI\\DSDT')\n if srvvals and srvvals.include?(\"Xen\")\n vm = true\n end\n end\n if not vm\n srvvals = registry_enumkeys('HKLM\\HARDWARE\\ACPI\\FADT')\n if srvvals and srvvals.include?(\"Xen\")\n vm = true\n end\n end\n if not vm\n srvvals = registry_enumkeys('HKLM\\HARDWARE\\ACPI\\RSDT')\n if srvvals and srvvals.include?(\"Xen\")\n vm = true\n end\n end\n if not vm\n srvvals = registry_enumkeys('HKLM\\SYSTEM\\ControlSet001\\Services')\n if srvvals and srvvals.include?(\"xenevtchn\")\n vm = true\n elsif srvvals and srvvals.include?(\"xennet\")\n vm = true\n elsif srvvals and srvvals.include?(\"xennet6\")\n vm = true\n elsif srvvals and srvvals.include?(\"xensvc\")\n vm = true\n elsif srvvals and srvvals.include?(\"xenvdb\")\n vm = true\n end\n end\n if vm\n report_note(\n :host => session.session_host,\n :type => 'host.info.vm',\n :data => { :hypervisor => \"Xen\" },\n :update => :unique_data\n )\n print_good(\"This is a Xen Virtual Machine\")\n return \"Xen\"\n end\n end", "def check_requires_arc_attribute\n attribute = DSL.attributes.values.find { |attr| attr.name == :requires_arc }\n if attribute\n value = spec.send(attribute.name)\n if value == 'true' || value == 'false'\n results.add_warning('requires_arc', value + ' is considered to be the name of a file.')\n end\n end\n end", "def certificate_verification?\n [email protected][:ssl_cert_file].nil?\n end", "def check_fitness\r\n\t\tcourse = Course.find_by(courseID: courseID)\r\n\t\treturn course.intensity > 0\r\n\tend", "def test_version\n\n #prepare\n subject=Xcider::Xcodebuild.new\n\n #test\n v=subject.version\n\n #verify\n assert_not_nil v\n\n end", "def include_cdl?\n @include_cdl\n end", "def is_undefined()\n res = super(context,self)\n return res\n end", "def fcoe_and_esxi_installed_on?(server)\n server.fcoe? && server.os_image_type == \"vmware_esxi\" && server.os_installed?\n end", "def if_missing_dependencies\n #TODO: Test on Linux\n missing = []\n [['ffmpeg','-version'], ['mp3splt', '-v'], ['mp3wrap']].each do |cmdline|\n begin\n out, err, status = Open3.capture3(*cmdline)\n rescue\n missing.push(cmdline.first)\n end #begin\n end #...].each do |cmdline|\n yield(missing) unless missing.empty?\n end", "def consistency_checks\n unless certificate_serial_number == voucher_serial_number\n error_report << \"serial number mismatch certificate '#{certificate_serial_number}' vs '#{voucher_serial_number}'\"\n return false\n end\n # other tests here.\n return true\n end", "def jruby_excon_skip?\n defined?(JRUBY_VERSION) &&\n defined?(::Excon::VERSION) &&\n Gem::Version.new(::Excon::VERSION) < Gem::Version.new('0.20.0')\n end", "def pre_simplecov_0_18_result?(result)\n _key, data = result.first\n\n data.is_a?(Array)\n end", "def quick_verify!\n quick_verify or raise InvalidPackage, explain_error\n end", "def estimated_dynos\n raise \"ERROR: You must define estimated_dynos() in your plugin\"\n end", "def collect_exists?; collect_data_exists? || collect_module_exists?; end", "def not_before\n @cert.not_before\n end", "def not_before\n @cert.not_before\n end", "def test_bad_chicken_deps\n check_deps_fail BadChickenBall unless `/usr/bin/which csc`.chomp.empty?\n end", "def instrumentalists?\n true\n end", "def check_yard_coverage(stat_lines)\n if config['min_coverage_percentage']\n match = stat_lines.last.match(/^\\s*([\\d.]+)%\\s+documented\\s*$/)\n unless match\n return :warn\n end\n\n yard_coverage = match.captures[0].to_f\n if yard_coverage >= config['min_coverage_percentage'].to_f\n return :pass\n end\n\n yard_coverage\n end\n end", "def detected?\n raise LicenseScout::Exceptions::Error.new(\"All DependencyManagers must have a `#detected?` method\")\n end", "def test_parse\n result = Yadis.parseXRDS(read_data_file(XRD_FILE))\n assert_not_nil result\n end", "def tainted?() end", "def dependencies_satisfied?\n missing_dependencies.empty?\n end", "def has_own_providers?\n if is_reseller?\n common_use_provider_count > 0\n else\n raise \"User is not reseller, he cannot have providers\"\n end\n end", "def sanityCheck\n @executor.nil? and raise \"Executor has not been initialized.\"\n @manipulator.nil? and raise \"Manipulator has not been initialized.\"\n @monitor.nil? and raise \"Monitor has not been initialized.\"\n @subject.nil? and raise \"Subject has not been initialized.\"\n end", "def never?\n !skipped? && coverage.nil?\n end", "def dependency_met?\n true\n end", "def exists?\n Puppet.debug(\"Calling exists method of security_policy_cloakingprovider: \")\n @property_hash[:ensure] == :present\nend", "def test_bad_chicken_deps\n check_deps_fail \"notapackage\" => :chicken if which('csc')\n end", "def test_bad_chicken_deps\n check_deps_fail \"notapackage\" => :chicken if which('csc')\n end", "def check_for_libraries; end", "def start_coverage_tracking\n if ENV['CI']\n require 'codeclimate-test-reporter'\n CodeClimate::TestReporter.start\n else\n require 'simplecov'\n SimpleCov.start\n end\nend" ]
[ "0.5605479", "0.54056245", "0.52924585", "0.5273659", "0.51426345", "0.5137662", "0.51306504", "0.50896734", "0.50566614", "0.5024072", "0.501453", "0.50029063", "0.49940974", "0.49840552", "0.49833414", "0.49811834", "0.49790093", "0.49727163", "0.49674454", "0.49608478", "0.4953379", "0.4953379", "0.4935874", "0.49006256", "0.48983386", "0.48966813", "0.48904592", "0.4890128", "0.48847637", "0.48709697", "0.4868226", "0.48524344", "0.48512113", "0.4835004", "0.48300794", "0.48261276", "0.48151308", "0.48073426", "0.48034564", "0.480132", "0.47989157", "0.47952014", "0.47925997", "0.4791743", "0.4791743", "0.47898257", "0.47749418", "0.477202", "0.4771986", "0.47694564", "0.47601834", "0.47481865", "0.4743699", "0.47187883", "0.47081476", "0.46948108", "0.4689327", "0.4689011", "0.46776414", "0.46763498", "0.46686992", "0.46656674", "0.4663834", "0.46570614", "0.4651723", "0.46507618", "0.46485114", "0.46382686", "0.46293283", "0.46238503", "0.46237466", "0.46205378", "0.4619936", "0.46134302", "0.46110934", "0.46036354", "0.46023402", "0.46023244", "0.45952398", "0.4591231", "0.45910907", "0.45908976", "0.45882523", "0.45882523", "0.45833114", "0.45830068", "0.4582641", "0.45824888", "0.45797068", "0.4576417", "0.4575929", "0.4573546", "0.456827", "0.45653698", "0.45615244", "0.4559311", "0.45561624", "0.45561624", "0.45534894", "0.45478037" ]
0.7875712
0
Filters the files that haven't been modified in the current PR
def process_report(report) file_names = @dangerfile.git.modified_files.map { |file| File.expand_path(file) } file_names += @dangerfile.git.added_files.map { |file| File.expand_path(file) } report.targets.each do |target| target.files = target.files.select { |file| file_names.include?(file.location) } end report end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_nonexistent(modified_files); end", "def tracked_files\n all_files.reject { |f| ignore_matcher.matched?(f) }\n end", "def filter_directories(modified_files); end", "def filtered(files); end", "def filter_invalid_files\n real_files=[]\n @files.each do |file|\n if @edit_in_place\n if File.writable?(file)\n real_files << file \n else\n puts \"ERROR: File #{file} is not writable, ignoring.\"\n end\n else\n if File.readable?(file)\n real_files << file \n else\n puts \"ERROR: File #{file} is not readable, ignoring.\"\n end\n end\n end\n @files=real_files\n end", "def modified_files\n `git diff --cached --name-only --diff-filter=ACM --ignore-submodules=all`.split \"\\n\"\n end", "def modified_files\n @modified_files ||= begin\n @modified_files = []\n\n rewritten_commits.each do |rewritten_commit|\n refs = \"#{rewritten_commit.old_hash} #{rewritten_commit.new_hash}\"\n @modified_files |= Overcommit::GitRepo.modified_files(refs: refs)\n end\n\n filter_modified_files(@modified_files)\n end\n end", "def modified_files; end", "def uncommitted_files\n files = nil\n p4 (['change','-o']).each do |line|\n files << line.strip if files\n files = [] if line.start_with?('Files:')\n end\n files ||= []\n end", "def modified_files\n remote_details = @container.list_objects_info\n same_files.reject do |file|\n (remote_details[file][:last_modified] <=> File.mtime(CloudfileAsset::Local.make_absolute(file))) == 1\n end\n end", "def excluded_files() = []", "def filter_git_diff_issues(issues)\n modified_files_info = git_modified_files_info()\n return issues.select { |i| \n modified_files_info[\"#{i['file']}\"] != nil\n }\n end", "def pr_contains_code_changes\n files = danger_file.git.added_files + danger_file.git.modified_files\n\n !files.grep(/.swift/).empty?\n end", "def modified_files\n staged = squash?\n refs = 'HEAD^ HEAD' if merge_commit?\n @modified_files ||= Overcommit::GitRepo.modified_files(staged: staged, refs: refs)\n end", "def files_changed_as_set(files)\n changed_files = files.select { |file| git.modified_files.include? file }\n not_changed_files = files.select { |file| !changed_files.include? file }\n all_files_changed = not_changed_files.empty?\n no_files_changed = changed_files.empty?\n return all_files_changed || no_files_changed\nend", "def all_files_except_git\n Dir.glob('*', File::FNM_DOTMATCH).delete_if { |file| file =~ /\\A\\.{1,2}\\z|\\A\\.git\\z/ }\n end", "def uncommitted_files\n svn('status', '--ignore-externals').split(\"\\n\").reject { |line| line =~ /^X\\s/ }\n end", "def altered_files; (modified + added + removed).sort; end", "def ignored_files\n all_files.select { |f| ignore_matcher.matched?(f) }\n end", "def check_changed_files(git)\n git.status.select {|file| file.type || file.untracked }\n end", "def modified_files(options); end", "def modified_files(options); end", "def get_uncommitted_files\n\t\t\tlist = read_command_output( 'hg', 'status', '-n', '--color', 'never' )\n\t\t\tlist = list.split( /\\n/ )\n\n\t\t\ttrace \"Changed files: %p\" % [ list ]\n\t\t\treturn list\n\t\tend", "def files_filtering files\n return files unless @file_regexp\n f = files.select do |file|\n test_name_by_date file\n end\n f\n end", "def filter_git_diff_issues(issues)\n modified_files_info = git_modified_files_info\n return [] if modified_files_info.empty?\n\n filtered_issues = []\n issues.each do |issue|\n file = issue[\"file\"].to_s\n next if modified_files_info[file].nil? || modified_files_info[file].empty?\n\n filtered_errors = issue[\"errors\"].select { |error| modified_files_info[file].include?(error[\"line\"].to_i) }\n filtered_issues << { \"file\" => file, \"errors\" => filtered_errors } unless filtered_errors.empty?\n end\n filtered_issues\n end", "def uncommitted_files\n `hg status`.scan(/^(A|M|R|!|\\?) (\\S.*)$/).map{ |match| match.last.split.last }\n end", "def analyse_modified_files\n modified_files = ::RubyCritic::Config\n .feature_branch_collection\n .where(::RubyCritic::SourceControlSystem::Git.modified_files)\n ::RubyCritic::AnalysedModulesCollection.new(modified_files.map(&:path),\n modified_files)\n ::RubyCritic::Config.root = \"#{::RubyCritic::Config.root}/compare\"\n end", "def didModify(files_array)\n\tdid_modify_files = false\n\tfiles_array.each do |file_name|\n\t\tif git.modified_files.include?(file_name) || git.deleted_files.include?(file_name)\n\t\t\tdid_modify_files = true\n\n\t\t\tconfig_files = git.modified_files.select { |path| path.include? file_name }\n\n\t\t\tmessage \"This PR changes #{ github.html_link(config_files) }\"\n\t\tend\n\tend\n\n\treturn did_modify_files\nend", "def uncommitted_files\n `git status`.scan(/^#(\\t|\\s{7})(\\S.*)$/).map { |match| match.last.split.last }\n end", "def uncommitted_files\n `git status`.scan(/^#(\\t|\\s{7})(\\S.*)$/).map { |match| match.last.split.last }\n end", "def files_at_commit(pr, filter = lambda { |x| true })\n sha = pr[:base_commit]\n begin\n files = lslr(git.lookup(sha).tree)\n rescue StandardError => e\n log pr[:id]\n log \"Cannot find commit #{sha} in base repo\" # some are in the other branches\n return nil # not to the default branch\n end\n\n # # find the eariler than and closest to the creation time of commit\n # sha = commit_closest_earlier_pr(pr)\n # begin\n # files = sha.nil? ? [] : lslr(git.lookup(sha).tree)\n # rescue StandardError => e\n # log \"Cannot find commit #{sha} in base repo\" # some are in the other branches\n # files = [] # no files found before the pr\n # end\n\n\n if files.size <= 0\n log \"No files for commit #{sha}\"\n end\n files.select { |x| filter.call(x) }\n\n end", "def affected_files\n Dir[@result_dir + '/*.{ttf,eot,woff,svg}'].reject { |f| f[@file] }\n end", "def get_files_modified\r\n\tgit_result = IO.popen('git status -u --porcelain').read\r\n\tgit_result.split(/[\\r\\n]+/).uniq.map!{|file| file.slice 3..-1}\r\nend", "def staged\n @files.select { |k, f| f.sha_index != \"0000000000000000000000000000000000000000\" && f.type != nil }\n end", "def files_at_commit(pr_id, filter = lambda{true})\n q = <<-QUERY\n select c.sha\n from pull_requests p, commits c\n where c.id = p.base_commit_id\n and p.id = ?\n QUERY\n\n base_commit = db.fetch(q, pr_id).all[0][:sha]\n files = repo.lstree(base_commit, :recursive => true)\n\n files.select{|x| filter.call(x)}\n end", "def altered_files; raw_changeset.files; end", "def file_changes?\n all_files = git.modified_files + git.added_files\n Danger::Changelog::Config.ignore_files.each do |f|\n all_files.reject! { |modified_file| f.is_a?(Regexp) ? f.match?(modified_file) : f == modified_file }\n break if all_files.empty?\n end\n all_files.any?\n end", "def obsolete_files\n out = (existing_files - new_files - new_dirs + replaced_files).to_a\n Jekyll::Hooks.trigger :clean, :on_obsolete, out\n out\n end", "def compute_changed_and_risk_files(params)\n commit_hash, file_arr = commit_info(params)\n changed_file_freq = file_arr.flatten!.each_with_object(Hash.new(0)) {|file, freq_acc| freq_acc[file] += 1}\n changed_g2_files = []\n changed_file_freq.select {|file, freq| changed_g2_files << file if freq > 2}\n risk_files = changed_g2_files.dup\n rf = risk_files.each_with_object({}) do |file, acc|\n author_set = Set.new\n commit_hash.each do |file_arr, author|\n acc[file] = (author_set << author ) if file_arr.include? (file)\n end\n end\n rf.delete_if {|_file, author_arr| author_arr.length < 2}\n {\n \"changed_files\" => changed_g2_files,\n \"risk_files\" => rf\n }\n end", "def filter!\n @files = SimpleCov.filtered(files)\n end", "def filter!\n @files = SimpleCov.filtered(files)\n end", "def filter!\n @files = SimpleCov.filtered(files)\n end", "def check_for_file_edits(committed_files)\n check_for_changes = `git ls-files --modified`\n\n if check_for_changes.each_line { |line|\n # if the user modified any files while executing this hook, then ask for a re-commit and abort the user push\n if committed_files.include?(line.rstrip())\n puts \"**File have been edited. Please stage/re-commit your changes and push again**\"\n exit(1)\n end\n }\n else\n exit(0)\n end\nend", "def applicable_owners_files\n CACHE.cache_block('arb_commit/' + self.sha1 + '/' + 'applicable_owners_files', 0) do\n raise \"not in review repository\" unless exists_in_review_repository?\n\n affected_dirs = changed_files.map { |f| File.dirname(f) }.uniq\n \n owners_files = affected_dirs.\n map { |d| find_owners_file(d) }.\n reject { |d| d.nil? }.\n uniq\n end\n end", "def modified_files\n file_stats.count { |file| file.status == :modified }\n end", "def filter(fs)\n @filesets.each do |k, v|\n # puts \"Filtering #{k} #{v}\"\n fs.subtract!(v.files)\n end\n end", "def filter(files)\n ruleset.watchlist.filter(files)\n #case ruleset.ignore\n #when Ignore\n # ruleset.ignore.filter(list)\n #when Array\n # list.reject!{ |path| ignore.any?{ |ig| /^#{ig}/ =~ path } }\n #else\n # list\n #end\n end", "def all_changed_files\n Set.new\n .merge(git.added_files.to_a)\n .merge(git.modified_files.to_a)\n .merge(git.renamed_files.map { |x| x[:after] })\n .subtract(git.renamed_files.map { |x| x[:before] })\n .to_a\n .sort\n end", "def remove_files_we_dont_need\n say 'Remove files we don\\'t need'\n build :remove_public_index\n build :remove_readme_rdoc\n end", "def all_modified_files_coverage\n unless @project.nil?\n @all_modified_files_coverage ||= begin\n modified_files = git.modified_files.nil? ? [] : git.modified_files\n added_files = git.added_files.nil? ? [] : git.added_files\n all_changed_files = modified_files | added_files\n @project.coverage_files.select do |file|\n all_changed_files.include? file.source_file_pathname_relative_to_repo_root.to_s\n end\n end\n\n @all_modified_files_coverage\n end\n end", "def ignored_files=(_arg0); end", "def filter_matched_files\n matched_files = []\n\n unless file_extensions.empty?\n extensions = file_extensions.reduce do |total, extension|\n total + \"|\" + extension.downcase\n end\n extensions_regex = \"^(.+\" + extensions + \")$\"\n (git.modified_files + git.added_files).each do |file|\n matched_files += [file] unless file.downcase.match(extensions_regex).nil?\n end\n end\n\n unless file_patterns.empty?\n (git.modified_files + git.added_files).each do |line|\n file_patterns.each do |pattern|\n matched_files += [line] unless line.downcase.match(pattern.downcase).nil?\n end\n end\n end\n\n return [matched_files].flatten.compact\n end", "def commits_on_pr_files(pr, months_back)\n\n oldest = Time.at(Time.at(pr[:created_at]).to_i - 3600 * 24 * 30 * months_back)\n pr_against = pull_req_entry(pr[:id])['base']['sha']\n commits = commit_entries(pr[:id])\n\n commits_per_file = commits.flat_map { |c|\n c['files'].map { |f|\n [c['sha'], f['filename']]\n }\n }.group_by {|c|\n c[1]\n }\n\n commits_per_file.keys.reduce({}) do |acc, filename|\n commits_in_pr = commits_per_file[filename].map{|x| x[0]}\n\n walker = Rugged::Walker.new(repo)\n walker.sorting(Rugged::SORT_DATE)\n walker.push(pr_against)\n\n commit_list = walker.take_while do |c|\n c.time > oldest\n end.reduce([]) do |acc1, c|\n if c.diff(paths: [filename.to_s]).size > 0 and\n not commits_in_pr.include? c.oid\n acc1 << c.oid\n end\n acc1\n end\n acc.merge({filename => commit_list})\n end\n end", "def files_at_commit(pr_id, filter = lambda{true})\n q = <<-QUERY\n select c.sha\n from pull_requests p, commits c\n where c.id = p.base_commit_id\n and p.id = ?\n QUERY\n\n def lslr(tree, path = '')\n all_files = []\n for f in tree.map{|x| x}\n f[:path] = path + '/' + f[:name]\n if f[:type] == :tree\n begin\n all_files << lslr(repo.lookup(f[:oid]), f[:path])\n rescue Exception => e\n STDERR.puts e\n all_files\n end\n else\n all_files << f\n end\n end\n all_files.flatten\n end\n\n base_commit = db.fetch(q, pr_id).all[0][:sha]\n begin\n files = lslr(repo.lookup(base_commit).tree)\n files.select{|x| filter.call(x)}\n rescue Exception => e\n STDERR.puts \"Cannot find commit #{base_commit} in base repo\"\n []\n end\n end", "def changed_files_since_deploy\n if File.exists?(\"log/latest-REVISION-syntaxcheck\")\n revision = File.read(\"log/latest-REVISION-syntaxcheck\").chomp\n\n `git whatchanged #{revision}..HEAD`.split(\"\\n\").select{|l| l =~ /^\\:/}.collect {|l| l.split(\"\\t\")[1]}.sort.uniq\n else\n puts \"log/latest-REVISION-syntaxcheck not found. run 'cap fetch_currently_deployed_version' to get it\"\n []\n end\n end", "def changed_files\n DeliveryTruck::Helpers.changed_files(\n DeliveryTruck::Helpers.pre_change_sha(node),\n node['delivery']['change']['sha'],\n node\n )\n end", "def filter_illegal_changes\n return unless params[:description].is_a?(ActionController::Parameters)\n\n root = in_admin_mode?\n admin = @description.is_admin?(@user)\n author = @description.author?(@user)\n\n params[:description].delete(:source_type) unless root\n unless root ||\n ((admin || author) &&\n # originally was\n # (desc.source_type != \"project\" &&\n # desc.source_type != \"project\"))\n # see https://www.pivotaltracker.com/story/show/174566300\n @description.source_type != \"project\")\n params[:description].delete(:source_name)\n end\n params[:description].delete(:license_id) unless root || admin || author\n end", "def pr_contains_localization_changes\n files = danger_file.git.added_files + danger_file.git.modified_files\n\n !files.grep(/.strings/).empty?\n end", "def altered_files\n parse!\n @altered_files\n end", "def files_to_analyze\n require 'find'\n ignore_dirs = ['.git','bin','test','assets','lib','log','vendor','tmp','img', 'images', 'uploads', 'fonts']\n ignore_files = Regexp.union(/^\\..*$/i, /^.*(.md)$/i, /^.*(.json)$/i, /^.*(.yml)$/i, /^.*(.log)$/i, /^.*(.png)$/i, /^.*(.jpg)$/i, /^.*(.jpeg)$/i)\n final_files = []\n # for every file in repository - keep the files to process\n Find.find('.') do |path|\n path_name = File.basename(path)\n if FileTest.directory?(path)\n if ignore_dirs.include?(path_name)\n Find.prune\n else\n next\n end\n else\n if path_name.match(ignore_files)\n next\n else\n path.gsub!(/^\\.\\//, '')\n final_files.push(path)\n end\n end\n end\n return final_files\n end", "def modified_files\n diff = git.diff(local_branch, remote_branch(local_branch))\n diff.stats[:files].keys\n end", "def changed_files\n # FIXME: Implement properly once changed detection is available.\n files\n end", "def previously_changed_files\n `git show --pretty=\"format:\" --name-only`.split(\"\\n\")\n end", "def commits_on_files_touched(pr, months_back)\n commits_on_pr_files(pr, months_back).reduce([]) do |acc, commit_list|\n acc + commit_list[1]\n end.flatten.uniq.size\n end", "def obsolete_files; end", "def prune!(regexp)\n ret = false\n [:files_modified, :files_deleted, :files_added].each do |type|\n if array = self[type]\n array.reject! do |el| \n if path(el) =~ regexp \n ret = true\n true\n end\n end\n delete(type) if array.empty? \n end\n end\n if array = self[:files_renamed]\n array.reject! do |el| \n if el[:new_path] =~ regexp or el[:old_path] =~ regexp \n ret = true\n true\n end\n end\n delete(:files_renamed) if array.empty?\n end\n ret\n end", "def excluded_files\n # TODO: also append files marked as %{exclude} (or handle elsewhere?)\n missing_files_for(upstream_gem)\n end", "def process_primary_files_with_changes_only\n # We get the diff only so that we know which files have changed.\n # It's ok to use the reference commits because we're dealing with\n # content AT files only.\n diff = @repository.diff(@from_git_commit, @to_git_commit, context_lines: 0)\n fwc = []\n diff.patches.each { |patch|\n file_name = patch.delta.old_file[:path]\n # Skip non content_at files\n next if !@file_list.include?(file_name)\n # next if !file_name.index('63-0728')\n unless file_name =~ /\\/content\\/.+\\d{4}\\.at\\z/\n raise \"shouldn't get here: #{ file_name.inspect }\"\n end\n\n @logger.info(\" - process #{ file_name }\")\n\n absolute_file_path = File.join(@repository.base_dir, file_name)\n # Initialize content AT file `to` with contents as of `to_git_commit`.\n # It's fine to use the reference sync commit as the sync operation\n # doesn't touch content AT files, only STM CSV ones.\n content_at_file_to = Repositext::RFile::ContentAt.new(\n '_', # Contents are initialized later via `#as_of_git_commit`\n @language,\n absolute_file_path,\n @any_content_type\n ).as_of_git_commit(@to_git_commit)\n\n compute_st_ops_attrs = {\n from_git_commit: @from_git_commit,\n to_git_commit: @to_git_commit,\n prev_last_operation_id: @prev_last_operation_id,\n execution_context: @execution_context,\n }\n\n compute_st_ops_attrs = refine_compute_st_ops_attrs(\n compute_st_ops_attrs,\n {\n from_table_release_version: @from_table_release_version,\n to_table_release_version: @to_table_release_version,\n absolute_file_path: absolute_file_path\n }\n )\n soff = SubtitleOperationsForFile.new(\n content_at_file_to,\n @repository.base_dir,\n compute_st_ops_attrs\n ).compute\n\n if soff.operations.any?\n # Only collect files that have subtitle operations\n @prev_last_operation_id = soff.last_operation_id\n fwc << soff\n end\n }\n\n # Then we add any files that have st_sync_required set to true and are\n # not in fwc already.\n @file_list.each { |content_at_filename|\n # Skip files that we have captured already\n next if fwc.any? { |soff| soff.content_at_file.repo_relative_path == content_at_filename }\n # Skip files that don't have st_sync_required set to true at to_git_commit\n dj_filename = content_at_filename.sub(/\\.at\\z/, '.data.json')\n # We use dj file contents at to_git_commit :at_child_or_ref\n dj_file = Repositext::RFile::DataJson.new(\n '_', # Contents are initialized later via #as_of_git_commit\n @language,\n dj_filename,\n @any_content_type\n ).as_of_git_commit(\n @to_git_commit,\n :at_child_or_ref\n )\n next if(dj_file.nil? || !dj_file.read_data['st_sync_required'])\n # This file is not in the list of fwc yet, and it has st_sync_required.\n # We add an soff instance with no operations. This could be a file\n # that has changes to subtitle timeslices only.\n content_at_file_from = Repositext::RFile::ContentAt.new(\n '_', # Contents are initialized later via `#as_of_git_commit`\n @language,\n content_at_filename,\n @any_content_type\n ).as_of_git_commit(@from_git_commit)\n soff = Repositext::Subtitle::OperationsForFile.new(\n content_at_file_from,\n {\n file_path: content_at_file_from.repo_relative_path,\n from_git_commit: @from_git_commit,\n to_git_commit: @to_git_commit,\n },\n [] # No operations\n )\n fwc << soff\n }\n # Return list of unique files with changes\n fwc.uniq\n end", "def remove_stale_files() = stale_files.each { |file| remove_file(file) }", "def check_files\n updated = []\n files.each do |filename, mtime| \n begin\n current_mtime = File.stat(filename).mtime\n rescue Errno::ENOENT\n # file was not found and was probably deleted\n # remove the file from the file list \n files.delete(filename)\n next\n end\n if current_mtime != mtime \n updated << filename\n # update the mtime in file registry so we it's only send once\n files[filename] = current_mtime\n puts \"quick_serve: spotted change in #{filename}\"\n end\n end\n QuickServe::Rails::Snapshot.reset if updated != []\n false\n end", "def has_untracked_changes? \n not [repo.changed, repo.untracked].flatten.select do |k| \n k.include?(\".craft\") || k.eql?(\"persistent.sfs\") || k.eql?(\"quicksave.sfs\") \n end.empty?\n end", "def analyse_modified_files\n modified_files = Config.feature_branch_collection.where(SourceControlSystem::Git.modified_files)\n analysed_modules = AnalysedModulesCollection.new(modified_files.map(&:path), modified_files)\n Config.root = Config.compare_root_directory\n report(analysed_modules)\n end", "def commits_on_pr_files(pr, months_back)\n\n oldest = Time.at(Time.at(pr[:created_at]).to_i - 3600 * 24 * 30 * months_back)\n commits = commit_entries(pr, at_open = true)\n\n commits_per_file = commits.flat_map { |c|\n unless c[:files].nil?\n JSON.parse(c[:files]).map { |f|\n [c[:sha], f[\"filename\"]]\n }\n else\n []\n end\n }.select{|x| x.size > 1}.group_by {|c|\n c[1]\n }\n\n commits_per_file.keys.reduce({}) do |acc, filename|\n commits_in_pr = commits_per_file[filename].map{|x| x[0]} # get the shas of pr related commits\n\n walker = Rugged::Walker.new(git)\n walker.sorting(Rugged::SORT_DATE)\n walker.push(pr[:base_commit])\n\n commit_list = walker.select do |c|\n c.time > oldest\n end.reduce([]) do |acc1, c|\n if c.diff(paths: [filename.to_s]).size > 0 and\n not commits_in_pr.include? c.oid # (oid is the object id - c.oid gets the commit sha). this commit is not part of pr's commits\n acc1 << c.oid\n end\n acc1\n end\n acc.merge({filename => commit_list})\n end\n end", "def modified_files(options)\n flags = '--cached' if options[:staged]\n refs = options[:refs]\n subcmd = options[:subcmd] || 'diff'\n\n `git #{subcmd} --name-only -z --diff-filter=ACM --ignore-submodules=all #{flags} #{refs}`.\n split(\"\\0\").\n map(&:strip).\n reject(&:empty?).\n map { |relative_file| File.expand_path(relative_file) }\n end", "def commit_modified_files_task\n really_modified = `#{git} ls-files -m #{modified_files.entries.join(' ')}`.split(\"\\n\")\n if really_modified.any?\n really_modified.each { |file| sh git, 'add', file }\n sh git, 'commit', '-m', \"Released #{gemspec.name} gem version #{gemspec.version}.\"\n end\n end", "def target_files\n @target_files ||= git.modified_files + git.added_files\n end", "def didModify(files_array)\n\tdid_modify_files = false\n\tfiles_array.each do |file_name|\n\t\tif git.modified_files.include?(file_name) || git.deleted_files.include?(file_name)\n\t\t\tdid_modify_files = true\n\t\tend\n\tend\n\treturn did_modify_files\nend", "def check_files(files)\r\n files_before = @file_info.keys\r\n used_files = {} \r\n files.each do |file|\r\n begin\r\n if @file_info[file]\r\n if @file_info[file].timestamp != File.mtime(file)\r\n @file_info[file].timestamp = File.mtime(file)\r\n digest = calc_digest(file)\r\n if @file_info[file].digest != digest\r\n @file_info[file].digest = digest \r\n @file_changed && @file_changed.call(file)\r\n end\r\n end\r\n else\r\n @file_info[file] = FileInfo.new\r\n @file_info[file].timestamp = File.mtime(file)\r\n @file_info[file].digest = calc_digest(file)\r\n @file_added && @file_added.call(file)\r\n end\r\n used_files[file] = true\r\n # protect against missing files\r\n rescue Errno::ENOENT\r\n # used_files is not set and @file_info will be removed below\r\n # notification hook hasn't been called yet since it comes after file accesses\r\n end\r\n end\r\n files_before.each do |file|\r\n if !used_files[file]\r\n @file_info.delete(file)\r\n @file_removed && @file_removed.call(file)\r\n end\r\n end\r\n end", "def check_clean_status_task\n raise \"The current working copy contains modifications\" if `#{git} ls-files -m`.split(\"\\n\").any?\n end", "def altered_files; `git show --name-only #{node} 2> /dev/null`.split(\"\\n\"); end", "def files &filter_block\n Dir[File.join(path, '**/*')].\n reject{|f| File.directory?(f) }.\n select{|f| f =~ filter_re }.\n sort.reverse[0..MAX_FILES].\n select(&filter_block)\n end", "def target_files(changed_files)\n changed_files.select do |file|\n file.end_with?(\".kt\")\n end\n end", "def target_files\n @target_files ||= (git.modified_files - git.deleted_files) + git.added_files\n end", "def modified?(file)\n @modified.any?(file) || @untracked.any?(file)\n end", "def check_results\n bin = prettier_path\n raise \"prettier is not installed\" unless bin\n return run_check(bin, \".\") unless filtering\n ((git.modified_files - git.deleted_files) + git.added_files)\n .select { |f| f[matching_file_regex] }\n .map { |f| f.gsub(\"#{Dir.pwd}/\", \"\") }\n .map { |f| run_check(bin, f) }\n end", "def files; changeset.all_files; end", "def modified_files(options)\n flags = '--cached' if options[:staged]\n refs = options[:refs]\n subcmd = options[:subcmd] || 'diff'\n\n `git #{subcmd} --name-only -z --diff-filter=ACMR --ignore-submodules=all #{flags} #{refs}`.\n split(\"\\0\").\n map(&:strip).\n reject(&:empty?).\n map { |relative_file| File.expand_path(relative_file) }\n end", "def md_erb_files\n Dir.glob(\"**/*.md.erb\").reject do |path|\n [\"license\", \"readme\"].any? do |str|\n path.downcase.ends_with? \"#{str}.md.erb\"\n end\n end\n end", "def posts\n return @posts if defined? @posts\n\n diffable_files = `git diff -z --name-only --diff-filter=ACRTUXB origin/master -- content/changes/`.split(\"\\0\")\n\n @posts = diffable_files.select do |filename|\n ext = File.extname(filename)\n ext == \".md\" || ext == \".html\"\n end\nend", "def keep_files; end", "def currently_changed_files\n `git status --porcelain`.split(\"\\n\").map{ |file| file.split.last }\n end", "def files_omit\n %w(map.html)\nend", "def list_file_changed\n content = \"Files changed since last deploy:\\n\"\n IO.popen('find * -newer _last_deploy.txt -type f') do |io| \n while (line = io.gets) do\n filename = line.chomp\n if user_visible(filename) then\n content << \"* \\\"#{filename}\\\":{{site.url}}/#{file_change_ext(filename, \".html\")}\\n\"\n end\n end\n end \n content\nend", "def gather_files files\n files = [\".\"] if files.empty?\n\n file_list = normalized_file_list files, true, @options.exclude\n\n file_list = remove_unparseable(file_list)\n\n if file_list.count {|name, mtime|\n file_list[name] = @last_modified[name] unless mtime\n mtime\n } > 0\n @last_modified.replace file_list\n file_list.keys.sort\n else\n []\n end\n end", "def filter_all_but_videos(files)\n files.select { |f| video?(f) }\n end", "def clean_file_list( args )\n\t\tdirtyfiles = args\n\n\t\t# only allow .mp3 files into the clean list.\n\t\tfiles = Array.new\n\t\tdirtyfiles.each { |x|\n\t\t\tif ( x =~ /.*\\.[mM][pP]3$/ )\n\t\t\t\tfiles.push( x )\n\t\t\telse\n\t\t\t\tputs \"\\tWARNING: No .mp3 suffix in \\\"#{x}\\\"! *** skipping! ***\"\n\t\t\tend\n\t\t}\n\n\t\tfiles\n\tend", "def removed_infections\n return [] unless prev_scan\n current_infections = scan.infections.collect{|infection| infection.file}\n prev_scan.infections.select{|infection| !current_infections.include?(infection.file)}\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 filter_only_cookbook_files\n info(\"Removing non-cookbook files before transfer\")\n FileUtils.rm(all_files_in_cookbooks - only_cookbook_files)\n Util.list_directory(tmpbooks_dir, recurse: true)\n .reverse_each { |fn| FileUtils.rmdir(fn) if File.directory?(fn) && Dir.entries(fn).size == 2 }\n end", "def posts\n # diffable_files = `git status --porcelain | awk '!match($1, \"D\"){print $2}' | grep .md`.split(\"\\n\")\n diffable_files = `git diff --name-only --diff-filter=ACMRTUXB origin/master... | grep .md`.split(\"\\n\")\n\n posts = diffable_files.select do |filename|\n File.ctime(filename) > Time.new(2014,9,3)\n end\n\n posts\n end", "def remove_unparseable files\n files.reject do |file, *|\n file =~ /\\.(?:class|eps|erb|scpt\\.txt|svg|ttf|yml)$/i or\n (file =~ /tags$/i and\n File.open(file, 'rb') { |io|\n io.read(100) =~ /\\A(\\f\\n[^,]+,\\d+$|!_TAG_)/\n })\n end\n end" ]
[ "0.8168486", "0.6880407", "0.6852783", "0.6840195", "0.6751749", "0.67396086", "0.67028654", "0.6681759", "0.6669902", "0.6655551", "0.6636062", "0.64798445", "0.64056295", "0.63902515", "0.63408", "0.6320563", "0.63030326", "0.6299882", "0.62707156", "0.6257452", "0.62491584", "0.62491584", "0.6235726", "0.6217467", "0.62001014", "0.6196755", "0.61959577", "0.61950696", "0.618928", "0.618928", "0.61611694", "0.6091381", "0.6082592", "0.60752726", "0.60708845", "0.6048658", "0.60407066", "0.60372216", "0.60370594", "0.6028084", "0.6028084", "0.6028084", "0.60232896", "0.60069305", "0.59988564", "0.5998645", "0.59930724", "0.5989332", "0.59877205", "0.59700614", "0.5946799", "0.59291905", "0.5917037", "0.5907529", "0.59025955", "0.58841157", "0.5878248", "0.58781904", "0.58464944", "0.58400846", "0.58362544", "0.5836213", "0.5835316", "0.58265555", "0.5826549", "0.5824853", "0.5818176", "0.58116066", "0.5803425", "0.5793207", "0.5792899", "0.5786717", "0.5783481", "0.57827157", "0.5749471", "0.57334316", "0.5731745", "0.572562", "0.57211924", "0.5715801", "0.57106805", "0.57100767", "0.5708975", "0.57010907", "0.5681122", "0.567911", "0.56737494", "0.5669177", "0.5656567", "0.5648063", "0.56470835", "0.56433636", "0.56316364", "0.56184363", "0.5616365", "0.56160325", "0.5612065", "0.560996", "0.560541", "0.560491", "0.5602067" ]
0.0
-1
Processes the parameters passed to the plugin
def convert_options(options) converted_options = options.dup converted_options.delete(:verbose) converted_options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_parameters; end", "def process_params(args = {})\r\n args ||= {}\r\n end", "def process_parameters\n # Build and eval code to get option list. Using this yucky approach\n # because GetoptLong.new expects its parameters given individually;\n # I can't just build an array and pass it along.\n opts = nil\n cmd = \"opts = GetoptLong.new(\"\n @parms.each_index do |i|\n cmd += \"@parms[#{i}].get,\"\n end\n cmd.chop!\n cmd += \")\"\n eval(cmd)\n\n # Process each option\n begin\n opts.each do |opt, arg|\n parm = get_parm_named(opt)\n parm.action(parm, arg, self)\n end\n rescue UsageError\n usage_error\n rescue Exception => e\n $stderr.printf(\"Error: %s\", e)\n usage_error\n end\n\n # Look for missing required command-line parameters\n missing = false\n @parms.each do |parm|\n if parm.is_required and parm.value.nil?\n $stderr.printf(\"Error: %s is a required parameter\\n\", parm.long_form)\n missing = true\n end\n end\n usage_error if missing\n end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def process_options\n \n end", "def process_options\n \n end", "def process_options\n \n end", "def process_arguments\n @e_addr = @options.email\n @r_name = @options.run_names\n @m_name = @options.machine_names\n @action = @options.action\n @snfs = @options.snfs\n end", "def parsed_params\n \n end", "def parse_parameters\n @action = param(:action)\n @type = param(:type)\n @command = param(:command).join(\" \")\n end", "def process(params, component)\n Info << \"#{component.name.to_s.upcase} -> #{self.class}\"\n @component = component.dup\n @meta = params[:meta]\n fields.each do |hand|\n @result[hand.name.to_sym] =\n if hand.is_a?(:field)\n value = run(hand, params)\n ret = hand.run( value, params, tlog )\n ret\n elsif hand.is_a?(:plugin)\n # create plugin instance\n field = hand.run(params, tlog)\n field.plugin.dispatch(field, self)\n field.plugin.prepare\n field.plugin\n end\n end\n self\n rescue\n self\n end", "def process_arguments\n if @options.config != nil\n if File.exist?(@options.config)\n load_config_file \n @config.each do |k, v|\n @project = v\n\n#need to do \n\n end\n else\n error(\"Config file does not exist\")\n end\n else\n @project = @options.project || \"NA\"\n @sub_dir = @options.sub_dir || \"NA\"\n @outname = @options.outname || @options.sub_dir\n @outdir = @options.outdir || $config[\"outdir\"]\n @bams = @options.bams\n @c_design = @options.c_design || nil\n @queue = @options.queue || $config[\"queue\"]\n @ref = @options.ref || \"hg19\"\n @rg_id = @options.rg_id || $config[\"rg\"][\"rg_id\"]\n @sample = @options.sample || \"NA\"\n\n end\n end", "def process_params(exp)\n _, normal, defaults, splat, rest, kwargs, doublesplat, block = exp.shift 8\n\n args =\n handle_normal_arguments(normal) +\n handle_default_arguments(defaults) +\n handle_splat(splat) +\n handle_normal_arguments(rest) +\n handle_kwargs(kwargs) +\n handle_double_splat(doublesplat) +\n handle_block_argument(block)\n\n s(:args, *args)\n end", "def process_options\n \n end", "def get_parameters; end", "def get_parameters; end", "def process_params(opts)\n opts = opts.dup\n check_exclusivity(opts.keys, ['template_body', 'template_url'])\n check_exclusivity(opts.keys, ['disable_rollback', 'on_failure'])\n check_exclusivity(opts.keys, ['stack_policy_body', 'stack_policy_url'])\n check_exclusivity(opts.keys, ['parameters', 'parameters_file'])\n\n sync_stdout = consume_option(opts, 'sync_stdout')\n $stdout.sync = sync_stdout\n\n opts['template_body'] = file_or_content(opts['template_body']) if opts['template_body']\n opts['tags'] = process_stack_tags(opts['tags']) if opts['tags']\n opts['stack_policy_body'] = file_or_content(opts['stack_policy_body']) if opts['stack_policy_body']\n opts['parameters'] = process_stack_parameters(opts['parameters']) if opts['parameters']\n opts['parameters'] = process_stack_parameters_file(consume_option(opts, 'parameters_file')) if opts['parameters_file']\n\n opts\n end", "def parameters=(_arg0); end", "def blacklight_params\n params = super\n\n # This method needs to be idempotent.\n if params[\"processed\"]\n params\n else\n process_params!(params, params_process_chain)\n end\n end", "def process_params(opts)\n #nil should default to all for most of these, use empty strings here so we can check for allowed values easily below\n defaults = { #really, they're all nil, don't need any of this\n :type => nil, #public/private/both\n :report => nil, #what contaminant to report on, nil is simply a record in the db (ie all)\n :time => nil, #defaults to all records in existence\n :operation => nil #:count, reports, histogram, cot (change over time), coverage; defaults to counts of records\n #TODO if we're really just serving data, we should probably put a max number of records...\n #also be ready for a format\n }\n \n allowed_options = { # TODO the good way to do this would be to see if we respond_to?(:operation) or it's in the table\n :type => [:public, :private, nil],\n :report => [:arsenic,:tds,:salinity,:fluoride,:iron,:tc,:fc,:ph,:hardness,nil], #:all, :date?\n :time => [nil], \n :operation => [:count, :avg, :max, :min, :histogram],\n :gt => Numeric\n }\n #convert string values of keys to symbols and then load it into defaults\n ret = defaults.merge(opts.inject({}){|hsh,(k,v)| hsh[k.to_sym] = v; hsh}) \n #TODO the below is poorly executed, there's gotta be a better way to do this\n #TODO check all the geo data to make sure it exists/it's sanitary\n #check the type\n ret[:type] = check_allowed_param(defaults[:type], allowed_options[:type], ret[:type]) \n #check the report\n ret[:report] = check_allowed_param(defaults[:report], allowed_options[:report], ret[:report])\n #check the time\n ret[:time] = check_allowed_param(defaults[:time], allowed_options[:time], ret[:time])\n #check the operation,\n ret[:operation] = check_allowed_param(defaults[:operation], allowed_options[:operation], ret[:operation])\n ret[:gt] = check_allowed_param(defaults[:gt], allowed_options[:gt], ret[:gt])\n ret\n end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def arguments; end", "def arguments; end", "def arguments; end", "def parameters=(_); end", "def _process_args args, config, block_event, events #:nodoc:\n raise \"FIXME seems uncalled _process_args, remove it this does not come up within a month 2014-08-19 \"\n args.each do |arg| \n case arg\n when Array\n # please don't use this, keep it simple and use hash NOTE\n # we can use r,c, w, h\n row, col, width, height = arg\n config[:row] = row\n config[:col] = col\n config[:width] = width if width\n # width for most XXX ?\n config[:height] = height if height\n when Hash\n config.merge!(arg)\n if block_event \n block_event = config.delete(:block_event){ block_event }\n raise \"Invalid event. Use #{events}\" unless events.include? block_event\n end\n when String\n config[:name] = arg\n config[:title] = arg # some may not have title\n #config[:text] = arg # some may not have title\n end\n end\n end", "def process_params(hash = nil)\n hash ||= params\n hash.each do |k,v|\n if v.is_a?(String) && v.match(/^-?[\\d ]+,\\d+$/)\n hash[k] = v.sub(\",\", \".\").sub(\" \", \"\")\n elsif v.is_a?(ActionController::Parameters)\n process_params(hash[k])\n end\n end\n end", "def parameters()\n @melody = params[:melody].upcase.split(\",\") # create array of notes in melody parameter\n @shift = params[:shift] # shift parameter\nend", "def manage_args(*args)\n end", "def params=(_arg0); end", "def params=(_arg0); end", "def check_params; true; end", "def process_argument(arg)\n case arg\n when *@mapping[:all] then create_argument_entry(:all)\n when *@mapping[:coord] then create_two_argument_entry(:coord)\n when *@mapping[:delta] then create_two_argument_entry(:delta)\n when *@mapping[:extreme] then @parameters[:extreme] = true\n when *@mapping[:index] then create_argument_entry(:index)\n when *@mapping[:meta] then @parameters[:meta] = true\n when *@mapping[:option] then create_argument_entry(:option)\n when *@mapping[:range] then create_two_argument_entry(:range)\n when *@mapping[:section] then create_two_argument_entry(:section)\n when *@mapping[:time] then create_two_argument_entry(:time)\n else\n raise_invalid_parameter(arg)\n end\n end", "def _wrap_parameters(parameters); end", "def _process_options(options); end", "def _process_options(options); end", "def after_config_update(*_)\n config[:parameters] ||= Smash.new\n config[:compile_parameters] ||= Smash.new\n config[:apply_stack] ||= []\n config[:apply_mapping] ||= Smash.new\n stack_name = arguments.first\n content = load_file_for(stack_name)\n process_information_hash(content, [])\n nil\n end", "def plugins=(_arg0); end", "def filter_parameters; end", "def filter_parameters; end", "def parse_params\n modif = []\n @params.each do |param|\n case param\n when \"-nc\" then modif += [\"remove_colors\"]\n end\n end\n modif\n end", "def params=(value); end", "def process_common(args, phase_ids)\n stop_run \"No phases where selected from the options.\" if phase_ids.blank?\n @phase_scope = phase_class.where(id: phase_ids.uniq.sort)\n set_additional_options_and_convert(args)\n end", "def process_args args={}\n @type = args[:type] ? args[:type].to_sym : :all\n @server_type = args[:server_type] ? args[:server_type] : 'master'\n @server_id = args[:server_id] || @master[:server_id]\n @start_id = args[:start_id]\n\n if @server_type == 'master'\n @cur_server = @master\n else\n @cur_server = args\n end\n end", "def parse_user_arguments(runner, user_arguments)\n apply_measure = runner.getStringArgumentValue(\"apply_measure\",user_arguments)\n # This measure is not applicable if apply_measure is false\n if apply_measure == \"FALSE\"\n runner.registerAsNotApplicable(\"Not Applicable - User chose not to apply this measure via the apply_measure argument.\")\n return true\n end\n \n @cooled_beam_type = runner.getStringArgumentValue(\"cooled_beam_type\", user_arguments)\n @existing_plant_loop_name = runner.getStringArgumentValue(\"existing_plant_loop_name\", user_arguments)\n @new_loop_pump_head = runner.getDoubleArgumentValue(\"new_loop_pump_head\", user_arguments)\n @air_loop_name = runner.getStringArgumentValue(\"air_loop_name\", user_arguments)\n @new_airloop_fan_pressure_rise = runner.getDoubleArgumentValue(\"new_airloop_fan_pressure_rise\", user_arguments)\n @supply_air_vol_flow_rate = runner.getDoubleArgumentValue(\"supply_air_vol_flow_rate\", user_arguments)\n @max_tot_chw_vol_flow_rate = runner.getDoubleArgumentValue(\"max_tot_chw_vol_flow_rate\", user_arguments)\n @number_of_beams = runner.getIntegerArgumentValue(\"number_of_beams\", user_arguments)\n @beam_length = runner.getDoubleArgumentValue(\"beam_length\", user_arguments)\n @design_inlet_water_temperature = runner.getDoubleArgumentValue(\"design_inlet_water_temperature\", user_arguments)\n @design_outlet_water_temperature = runner.getDoubleArgumentValue(\"design_outlet_water_temperature\", user_arguments)\n @coil_surface_area_per_coil_length = runner.getDoubleArgumentValue(\"coil_surface_area_per_coil_length\", user_arguments)\n @coefficient_alpha = runner.getDoubleArgumentValue(\"coefficient_alpha\", user_arguments)\n @coefficient_n1 = runner.getDoubleArgumentValue(\"coefficient_n1\", user_arguments)\n @coefficient_n2 = runner.getDoubleArgumentValue(\"coefficient_n2\", user_arguments)\n @coefficient_n3 = runner.getDoubleArgumentValue(\"coefficient_n3\", user_arguments)\n @coefficient_a0 = runner.getDoubleArgumentValue(\"coefficient_a0\", user_arguments)\n @coefficient_k1 = runner.getDoubleArgumentValue(\"coefficient_k1\", user_arguments)\n @coefficient_n = runner.getDoubleArgumentValue(\"coefficient_n\", user_arguments)\n @coefficient_kin = runner.getDoubleArgumentValue(\"coefficient_kin\", user_arguments)\n @leaving_pipe_inside_dia = runner.getStringArgumentValue(\"leaving_pipe_inside_dia\", user_arguments)\n end", "def args(*) end", "def params=(_); end", "def process(options); end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def param; end", "def param; end", "def parse_input(params, resource); end", "def initialize_arguments\n # first make sure there is a script\n script = Script.find(params[:script_id]) rescue nil\n unless script.blank?\n #script type may be passed, though if this routine is being used it is like a ResourceAutomation\n script_type = params[:script_type] || \"ResourceAutomation\"\n # consider mocking up a step for compatibility reasons until the automation\n # controls can be properly generalized. Might be meaningful to also set the\n # script ids to something meaningful\n step = Step.new\n step.script_id = script.id\n step.script_type = script_type\n\n #\n # This is a HACK to make sure dependency loading\n # works when you load up a query in external tickets filters\n step.id = 0 if params[:query_mode] == \"true\"\n\n # we have some current argument values -- set perhaps by saved query -- to respect\n filled_argument_values = JSON.parse(params[:argument_values]) rescue nil\n\n # now render the generic form for automation properties to get the ball rolling\n render :partial => 'steps/step_script', :locals => { :script => script, :step => step, :installed_component => nil, :argument_values => filled_argument_values || script.filter_argument_values, :old_installed_component_id => nil }\n\n else\n # if something has gone very wrong and the @script is not found, show an error and send them to the home page\n flash[:error] = \"Unable to find script for id: #{params[:script_id] || \"blank\"}\"\n redirect_to root_url\n end\n end", "def process_value(code,text)\n\n\n # depending on the report code, process the values\n # this is done by reading parameter names and their values\n # and respong on it as needed \n\n case code \n\n # Report parameter value\n when 'R21'\n ard_par_id = -1\n ard_par_val = 0\n\n text.split(' ').each do |param|\n\n par_code = param[0..0].to_s\n par_value = param[1..-1].to_i\n\n case par_code\n when 'P'\n ard_par_id = par_value\n when 'V'\n ard_par_val = par_value\n end\n end\n\n if ard_par_id >= 0\n param = get_param_by_id(ard_par_id)\n if param != nil\n param['value_ar'] = ard_par_val\n end\n end\n\n # Report parameter value and save to database\n when 'R23'\n ard_par_id = -1\n ard_par_val = 0\n\n text.split(' ').each do |param|\n\n par_code = param[0..0].to_s\n par_value = param[1..-1].to_i\n\n case par_code\n when 'P'\n ard_par_id = par_value\n when 'V'\n ard_par_val = par_value\n end\n end\n\n if ard_par_id >= 0\n param = get_param_by_id(ard_par_id)\n if param != nil\n save_param_value(ard_par_id, :by_id, :from_db, ard_par_val)\n end\n end\n\n # Report pin values\n when 'R41'\n pin_id = -1\n pin_val = 0\n\n text.split(' ').each do |param|\n\n par_code = param[0..0].to_s\n par_value = param[1..-1].to_i\n\n case par_code\n when 'P'\n pin_id = par_value\n when 'V'\n pin_val = par_value\n end\n end\n\n if pin_id >= 0\n save_pin_value(pin_id, pin_val)\n end\n\n # Report end stops\n when 'R81'\n text.split(' ').each do |param|\n\n par_code = param[0..1].to_s\n par_value = param[2..-1].to_s\n end_stop_active = (par_value == \"1\")\n\n case par_code\n when 'XA'\n @axis_x_end_stop_a = end_stop_active\n $status.info_end_stop_x_a = end_stop_active\n when 'XB'\n @axis_x_end_stop_b = end_stop_active\n $status.info_end_stop_x_b = end_stop_active\n when 'YA'\n @axis_y_end_stop_a = end_stop_active\n $status.info_end_stop_y_a = end_stop_active\n when 'YB'\n @axis_y_end_stop_b = end_stop_active\n $status.info_end_stop_y_b = end_stop_active\n when 'ZA'\n @axis_z_end_stop_a = end_stop_active\n $status.info_end_stop_z_a = end_stop_active\n when 'ZB'\n @axis_z_end_stop_b = end_stop_active\n $status.info_end_stop_z_b = end_stop_active\n end\n end\n\n # Report position\n when 'R82' \n text.split(' ').each do |param|\n\n par_code = param[0..0].to_s\n par_value = param[1..-1].to_i\n\n case par_code\n when 'X'\n @axis_x_pos = par_value\n @axis_x_pos_conv = par_value / @axis_x_steps_per_unit\n $status.info_current_x = @axis_x_pos_conv\n when 'Y'\n @axis_y_pos = par_value\n @axis_y_pos_conv = par_value / @axis_y_steps_per_unit\n $status.info_current_y = @axis_y_pos_conv\n when 'Z'\n @axis_z_pos = par_value\n @axis_z_pos_conv = par_value / @axis_z_steps_per_unit\n $status.info_current_z = @axis_z_pos_conv\n end \n end\n\n # Report software version\n when 'R83'\n @device_version = text\n\n # Send a comment\n when 'R99'\n puts \">#{text}<\"\n\n end\n end", "def filter_parameters=(_arg0); end", "def filter_parameters=(_arg0); end", "def __get_params(data)\n \n # If named arguments used, assigns keys as symbols\n # but keeps numeric arguments as integers\n \n if @params.kind_of? Hash\n @params = @params.dup\n @keyword_params = JsonRpcObjects::Utils::Hash.remove!(@params) do |k, v|\n not JsonRpcObjects::Utils::String.numeric? k\n end\n \n @params = @params.sort_by { |i| i[0].to_i }.map { |i| i[1] }\n else\n @keyword_params = { }\n end\n \n JsonRpcObjects::Utils::Hash.keys_to_sym! @keyword_params\n \n end", "def process_arguments(args, sender, type_registry)\n variables = []\n @bareword_slots.each_with_index do |bareword, i|\n if bareword # Bare words must match all incoming arguments or fail.\n return nil if args[i] != bareword \n elsif @words[i].type # This is a typed variable (apply type converter).\n variables << process_typed_argument(args, i, sender, type_registry)\n else # Untyped-variable. \n variables << args[i]\n end\n end\n\n variables\n end", "def format_arguments; end" ]
[ "0.68187237", "0.67322344", "0.63737357", "0.6300978", "0.6300978", "0.6300978", "0.6300978", "0.6300978", "0.6300978", "0.6300978", "0.6300978", "0.6266761", "0.6266761", "0.6266761", "0.6208381", "0.62000185", "0.6189266", "0.60950744", "0.60454273", "0.6038895", "0.60025054", "0.59955263", "0.59955263", "0.5981658", "0.59534574", "0.59197915", "0.59136176", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5907953", "0.5818932", "0.5818932", "0.5818932", "0.5756667", "0.56707865", "0.5660399", "0.5650738", "0.55979246", "0.55446494", "0.55446494", "0.55091614", "0.5504083", "0.5483029", "0.5479461", "0.5479461", "0.54792976", "0.5464179", "0.5461866", "0.5461866", "0.54604423", "0.54556763", "0.5440584", "0.54397565", "0.54258925", "0.5420384", "0.5406121", "0.53963035", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.53923523", "0.5390791", "0.5390791", "0.5388339", "0.53749853", "0.5374597", "0.53666246", "0.53666246", "0.5364762", "0.53564495", "0.53489405" ]
0.0
-1
GET /metodologias GET /metodologias.json
def index @metodologias = Metodologia.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @mesasredondas = Mesasredonda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mesasredondas }\n end\n end", "def index\n \n if current_user.tipo == 2\n @receita_medicas = ReceitaMedica.where(:medico_id => current_user.id)\n elsif current_user.tipo == 1\n @receita_medicas = ReceitaMedica.where(:paciente_id => current_user.id)\n elsif current_user.tipo == 3\n @receita_medicas = Venda.receitas_medicas(current_user.id)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @receita_medicas }\n end\n end", "def show\n @logjuego = Logjuego.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @logjuego }\n end\n end", "def show\n @metodo = Metodo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @metodo }\n end\n end", "def index\n @mercado_meta = MercadoMetum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mercado_meta }\n end\n end", "def new\n @metodo = Metodo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @metodo }\n end\n end", "def index\n \treclamos = Reclamo.all\n \trender json: reclamos.to_json(include: [:tipo_reclamo, :ubicacion, :user], methods: [:valoracion])\n end", "def get_modelos\n marca = Marca.find(params[:marca_id])\n @modelos = Modelo.of_marca(marca.id)\n\n render json: @modelos\n\n end", "def new\n @logjuego = Logjuego.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @logjuego }\n end\n end", "def new\n @relogio = Relogio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @relogio }\n end\n end", "def show\n @relogio = Relogio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @relogio }\n end\n end", "def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\r\n @imobiliarias = Imobiliaria.all\r\n\r\n respond_to do |format|\r\n # format.html # index.html.erb\r\n format.json { render json: @imobiliarias }\r\n end\r\n end", "def index\n @unidade_medidas = UnidadeMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unidade_medidas }\n end\n end", "def index\n @relaciones_articulos_medida = RelacionArticuloMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @relaciones_articulos_medida }\n end\n end", "def index\n @tipo_usuarios = TipoUsuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_usuarios }\n end\n end", "def index\n @messies = Messy.all\n\n render json: @messies\n end", "def index\n @user = current_user;\n @toeic_logs = ToeicLog.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @toeic_logs }\n end\n end", "def index\n @tutorados = Tutorado.all\n\n render json: @tutorados, status: :ok\n end", "def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @deporte_usuarios = DeporteUsuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deporte_usuarios }\n end\n end", "def index\n @peticion_servicio_tis = Peticion::ServicioTi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peticion_servicio_tis }\n end\n end", "def index\n @mencions = Mencion.order(\"escuela_id\").paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mencions }\n end\n end", "def index\n @usuarios = Usuario.all\n # respond_to do |format|\n # format.html\n # format.json { render :json => @usuarios }\n # end\n end", "def show\n @mesasredonda = Mesasredonda.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mesasredonda }\n end\n end", "def new\n @servicio = Servicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @servicio }\n end\n end", "def new\n authorize! :new, @mesasredonda\n @mesasredonda = Mesasredonda.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mesasredonda }\n end\n end", "def index\n #para mostrar solo los post del usuario actual\n @posts = Post.where(usuario_id: current_usuario.id).all\n puts \"USUARIOOOO\"\n puts current_usuario.to_json\n\n #@posts = Post.all\n end", "def index\n @municipios = Municipio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @municipios }\n end\n end", "def new\n @mensaje_usuario = MensajeUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mensaje_usuario }\n end\n end", "def index\n if params[:user_id] != nil\n @memos = Memo.where(:user_id => current_user.id)\n else\n @memos = Memo.all\n end\n \n \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @memos }\n end\n end", "def index\n @ores = Ore.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ores }\n end\n end", "def new\n @motivobaja = MotivoBaja.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @motivobaja }\n end\n end", "def index \n @lancamentorapido = Lancamentorapido.new \n @lancamentorapidos = Lancamentorapido.all\n \n @categorias = Category.all\n @centrosdecusto = Centrodecusto.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lancamentorapidos }\n end\n end", "def index\n @memos = Memo.all.order(id: \"DESC\").limit(100)\n memo_list = []\n for memo in @memos\n user = memo.user.name\n memo_list << {\n memo: memo,\n user: user\n }\n end\n render json: memo_list\n end", "def index\n @minicursos = Minicurso.all\n\t\t#@minicursos = Minicurso.scoped\n\t\t#@users = Minicurso.inscritos(params[:id]) if params[:id].present?\n\n respond_to do |format|\n\t\t\t format.html # index.html.erb\n\t\t\t format.json { render json: @minicursos }\n end\n end", "def index\n @pagamentos = Pagamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end", "def index\n @articulos = Articulo.where(\"tipo = 'articulo'\").order(\"created_at desc\") \n @noticias = Articulo.where(\"tipo = 'noticia' and mostrar_carrusel='1'\").order(\"created_at desc\").limit(3)\n @articulos = @articulos.page(params[:page]).per_page(5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @articulos }\n end\n end", "def new\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @juzgado }\n end\n end", "def index\n @territorios = Territorio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @territorios }\n end\n end", "def index\n @meupedidos = Meupedido.where(:user_id => current_user)\n end", "def index\n @trabalhos = current_user.trabalhos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trabalhos }\n end\n end", "def index\n @programmes = Programme.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programmes }\n end\n end", "def index\n @listas_contato = ListaContato.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listas_contato }\n end\n end", "def index\n @ativo_outros = AtivoOutro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ativo_outros }\n end\n end", "def index\n @empresas = Empresa.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @empresas }\n end\n end", "def show\n @mensaje_usuario = MensajeUsuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mensaje_usuario }\n end\n end", "def show\n @mecanicacomplejo = Mecanicacomplejo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mecanicacomplejo }\n end\n end", "def index\n @seguridad_usuarios = Seguridad::Usuario.order('usuario')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @seguridad_usuarios }\n end\n end", "def show\r\n @imobiliaria = Imobiliaria.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.json { render json: @imobiliaria }\r\n end\r\n end", "def new\n @personaje_mision = PersonajeMision.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @personaje_mision }\n end\n end", "def new\n @personaje = Personaje.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @personaje }\n end\n end", "def index\n #@imovels = Imovel.all\n \n #Traz apenas os imoveis ativos\n # Isso vai no controller do cliente. Só os ativos aparecem\n #@imovels = Imovel.all.select { |i| i.ativo == true }\n \n @imovels = Imovel.paginate :page => params[:page], :order => 'created_at DESC', :per_page => 10\n \n # Mapa para guardar os valores das transacoes associadas a cada imovel.\n # key: imovel_id, value: lista com [0]:transacao, [1]: tipos, [2] responsavel\n @hash_informacoes_imoveis = Hash.new\n \n @imovels.each do |imovel|\n popular_imovel(imovel)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @imovels }\n end\n end", "def index\n @establecimientos = Establecimiento.all\n respond_to do |format|\n format.json { \n\n if (params[:appkey].eql? appkey) #si el appkey es correcto\n\n ests = @establecimientos.map { |establecimiento| { :nombre_establecimiento => establecimiento.nombre, :id => establecimiento.id, \n :descripcion => establecimiento.descripcion, :longitud => establecimiento.longitud,\n :latitud => establecimiento.latitud, :direccion => establecimiento.direccion, :imagen => establecimiento.foto.url(:small),\n :eventos => establecimiento.eventos.map { |evento| { :nombre => evento.nombre } } } } \n render json: ests\n else\n render json: {:error => \"No autorizado\"}\n end\n\n\n\n }\n format.html { redirect_to :controller=>'login', :action=>'login' } #solo el app movil puede revisar toda la lista de establecimientos.\n end\n end", "def index\n seleccionarMenu(:juzgados)\n @juzgados = Juzgado.order(:ciudad_id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @juzgados }\n end\n end", "def new\n @sistema = Sistema.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sistema }\n end\n end", "def index\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n render json: @usuario.productos\n else\n @productos = Producto.all\n render json: @productos\n end\n end", "def new\n @ministerio = Ministerio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ministerio }\n end\n end", "def index\n @uchronias = Uchronia.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @uchronias }\n end\n end", "def new\n @user = current_user;\n @toeic_log = ToeicLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @toeic_log }\n end\n end", "def consulta\n fiesta = Fiesta.all\n render json: fiesta\n end", "def index\n respond_to :html, :json\n @organismes = Organisme.all\n end", "def index\n #@users = User.all\n @respuesta = Consulta.new(300,params[0])\n\n respond_to do |format|\n format.json { render json: @respuesta }\n \n end\n end", "def new\n @ejercicio = Ejercicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ejercicio }\n end\n end", "def show\n @mensaje = Mensaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mensaje }\n end\n end", "def index\n @anuncios = Anuncio.all\n render json: @anuncios, status: :ok\n end", "def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario }\n end\n end", "def index\n if current_user.nil?\n redirect_to(log_in_path) and return\n end\n\n @alumnos_personas_vinculadas = AlumnoPersonaVinculada.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @alumnos_personas_vinculadas }\n end\n end", "def show\n @motivobaja = MotivoBaja.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @motivobaja }\n end\n end", "def show\n @usuario = Usuario.find(params[:id])\n clientesIds = Cliente.where(:usuario_id => params[:id])\n @clientes = clientesIds.map{|c| Usuario.find(c.cliente_id)}\n\n logs = Logsesion.new(:usuario_id => @usuario.id, \n :superu_id => current_usuario.id,\n :tipo => \"Visualizado\", \n :nusuario => @usuario.login, \n :nsuperu => current_usuario.login)\n\n if logs.save\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usuario }\n end\n else\n format.json { render json: @usuario, notice:\"La información no fue almacenada en el log.\" }\n end\n end", "def new\n @lista_contato = ListaContato.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lista_contato }\n end\n end", "def index\n if current_user.nil?\n redirect_to(log_in_path) and return\n end\n\n @personas_vinculadas = PersonaVinculada.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @personas_vinculadas }\n end\n end", "def new\n @mecanicacomplejo = Mecanicacomplejo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mecanicacomplejo }\n end\n end", "def index\n #authorize! :index, @login, :message => 'Not authorized as an administrator.'\n #É preciso ir buscar a clinica do gestor atual para carregar a informação\n manager = Manager.first(:conditions => \"login_id = #{current_login.id}\")\n @clinic = manager.clinic\n\n @managers = Manager.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @managers }\n end\n end", "def index\n seleccionarMenu(:rondas)\n @rondas = Ronda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rondas }\n end\n end", "def meals\n get(\"/user/#{@user_id}/meals.json\")\n end", "def index\n @usuarios = Usuario.all\n @usuarios_json = @usuarios.to_json\n end", "def index\n @projetos = Projeto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projetos }\n end\n end", "def new\n @medio_pago = MedioPago.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medio_pago }\n end\n end", "def index\n @palestrantes = Palestrante.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @palestrantes }\n end\n end", "def index\n @you_owe_mes = YouOweMe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @you_owe_mes }\n end\n end", "def show\r\n render json: @registro_medicion.to_json, status: :ok\r\n end", "def index\n @patrocinios = Patrocinio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patrocinios }\n end\n end", "def show\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @juzgado }\n end\n end", "def index\n @pagamentos = Pagamento.page(params[:page]).per(NUMERO_POR_PAGINA)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end", "def index\n @ultimo_grado_de_estudios = UltimoGradoDeEstudio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ultimo_grado_de_estudios }\n end\n end", "def new\n @empresa = Empresa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @empresa }\n end\n end", "def index\n code = :ok\n currentUser = {\n id: current_user.utilisateur.id,\n fullName: current_user.utilisateur.prenom_nom,\n }\n result = {\n signedIn: user_signed_in?,\n currentUser: currentUser,\n locations: Lieu.all\n }\n render json: result, status: code \n end", "def index\n @detalles = Detalle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @detalles }\n end\n end", "def index\n @grupoassuntos = Grupoassunto.all\n\n render json: @grupoassuntos\n end", "def index\n\t\trender json: { prueba: 'Funciona'}\n\tend", "def new\n @usuario = Usuario.new\n @data_inicio = I18n.l Date.today\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario }\n end\n end", "def new\n @comentario = Comentario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comentario }\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 index\n @mesas = Mesa.all\n end", "def new\n\tadd_breadcrumb \"Nuevo usuario\", :new_usuario_path\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @usuario }\n end\n end", "def index\n @itemtipos = Itemtipo.all\n\n render json: @itemtipos\n end" ]
[ "0.6706839", "0.66338074", "0.6615272", "0.6520149", "0.647888", "0.6470972", "0.646249", "0.6455874", "0.6441236", "0.6434453", "0.641009", "0.6399384", "0.6352109", "0.6329938", "0.6324526", "0.63174987", "0.6297443", "0.62691504", "0.62597245", "0.6251404", "0.6240971", "0.6240971", "0.6240971", "0.6234436", "0.622937", "0.62207484", "0.6218467", "0.6215906", "0.61893237", "0.6185499", "0.6164805", "0.6159202", "0.6147321", "0.6143863", "0.6135733", "0.6133327", "0.61275274", "0.61170703", "0.6113262", "0.6104252", "0.61008555", "0.60969234", "0.60909873", "0.6085563", "0.60842407", "0.6062996", "0.6060677", "0.60600746", "0.6053847", "0.60513586", "0.60483235", "0.6045761", "0.6036768", "0.6036459", "0.602512", "0.60248196", "0.6022803", "0.6022299", "0.60217804", "0.60151464", "0.60100293", "0.60037357", "0.6003692", "0.6002461", "0.6000998", "0.59905547", "0.5988073", "0.59820986", "0.5973995", "0.59734035", "0.59652615", "0.5963412", "0.59582496", "0.59579766", "0.5954175", "0.5953959", "0.59529024", "0.59505624", "0.5949453", "0.59456885", "0.59443885", "0.5942176", "0.5928985", "0.5928526", "0.59265304", "0.5924103", "0.5923309", "0.59143066", "0.5911138", "0.59108067", "0.5904936", "0.59027636", "0.5899186", "0.5892567", "0.58897626", "0.5888691", "0.5886863", "0.5885294", "0.588377", "0.58760893" ]
0.7024599
0
GET /metodologias/1 GET /metodologias/1.json
def show @metodologia = Metodologia.friendly.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @logjuego = Logjuego.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @logjuego }\n end\n end", "def index\n @metodologias = Metodologia.all\n end", "def show\n @relogio = Relogio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @relogio }\n end\n end", "def show\n @metodo = Metodo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @metodo }\n end\n end", "def index\n \n if current_user.tipo == 2\n @receita_medicas = ReceitaMedica.where(:medico_id => current_user.id)\n elsif current_user.tipo == 1\n @receita_medicas = ReceitaMedica.where(:paciente_id => current_user.id)\n elsif current_user.tipo == 3\n @receita_medicas = Venda.receitas_medicas(current_user.id)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @receita_medicas }\n end\n end", "def new\n @relogio = Relogio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @relogio }\n end\n end", "def new\n @logjuego = Logjuego.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @logjuego }\n end\n end", "def new\n @metodo = Metodo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @metodo }\n end\n end", "def index\n @mesasredondas = Mesasredonda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mesasredondas }\n end\n end", "def show\r\n @imobiliaria = Imobiliaria.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.json { render json: @imobiliaria }\r\n end\r\n end", "def index\n @mercado_meta = MercadoMetum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mercado_meta }\n end\n end", "def get_modelos\n marca = Marca.find(params[:marca_id])\n @modelos = Modelo.of_marca(marca.id)\n\n render json: @modelos\n\n end", "def index\n \treclamos = Reclamo.all\n \trender json: reclamos.to_json(include: [:tipo_reclamo, :ubicacion, :user], methods: [:valoracion])\n end", "def show\n @mecanicacomplejo = Mecanicacomplejo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mecanicacomplejo }\n end\n end", "def show\n @mesasredonda = Mesasredonda.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mesasredonda }\n end\n end", "def index\r\n @imobiliarias = Imobiliaria.all\r\n\r\n respond_to do |format|\r\n # format.html # index.html.erb\r\n format.json { render json: @imobiliarias }\r\n end\r\n end", "def new\n @servicio = Servicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @servicio }\n end\n end", "def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @relaciones_articulos_medida = RelacionArticuloMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @relaciones_articulos_medida }\n end\n end", "def show\n @motivobaja = MotivoBaja.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @motivobaja }\n end\n end", "def show\n @mensaje = Mensaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mensaje }\n end\n end", "def index\n @unidade_medidas = UnidadeMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unidade_medidas }\n end\n end", "def show\n @usuario = Usuario.find(params[:id])\n clientesIds = Cliente.where(:usuario_id => params[:id])\n @clientes = clientesIds.map{|c| Usuario.find(c.cliente_id)}\n\n logs = Logsesion.new(:usuario_id => @usuario.id, \n :superu_id => current_usuario.id,\n :tipo => \"Visualizado\", \n :nusuario => @usuario.login, \n :nsuperu => current_usuario.login)\n\n if logs.save\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usuario }\n end\n else\n format.json { render json: @usuario, notice:\"La información no fue almacenada en el log.\" }\n end\n end", "def index\n @mencions = Mencion.order(\"escuela_id\").paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mencions }\n end\n end", "def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end", "def new\n @motivobaja = MotivoBaja.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @motivobaja }\n end\n end", "def show\n @mensaje_usuario = MensajeUsuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mensaje_usuario }\n end\n end", "def show\n @leito = Leito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leito }\n end\n end", "def index\n @tipo_usuarios = TipoUsuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_usuarios }\n end\n end", "def index\n @user = current_user;\n @toeic_logs = ToeicLog.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @toeic_logs }\n end\n end", "def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end", "def index\n #@users = User.all\n @respuesta = Consulta.new(300,params[0])\n\n respond_to do |format|\n format.json { render json: @respuesta }\n \n end\n end", "def new\n @odontologia1 = Odontologia1.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @odontologia1 }\n end\n end", "def index\n @ores = Ore.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ores }\n end\n end", "def new\n @sistema = Sistema.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sistema }\n end\n end", "def show\r\n render json: @registro_medicion.to_json, status: :ok\r\n end", "def show\n @odontologia1 = Odontologia1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @odontologia1 }\n end\n end", "def new\n @personaje_mision = PersonajeMision.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @personaje_mision }\n end\n end", "def index\n @articulos = Articulo.where(\"tipo = 'articulo'\").order(\"created_at desc\") \n @noticias = Articulo.where(\"tipo = 'noticia' and mostrar_carrusel='1'\").order(\"created_at desc\").limit(3)\n @articulos = @articulos.page(params[:page]).per_page(5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @articulos }\n end\n end", "def show\n @historial = Historial.find(params[:id])\n @receta = Recete.histori(@historial.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @historial }\n end\n end", "def new\n @personaje = Personaje.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @personaje }\n end\n end", "def show\n @mapeamento = Mapeamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mapeamento }\n end\n end", "def new\n authorize! :new, @mesasredonda\n @mesasredonda = Mesasredonda.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mesasredonda }\n end\n end", "def show\n @ministerio = Ministerio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ministerio }\n end\n end", "def new\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @juzgado }\n end\n end", "def new\n @mensaje_usuario = MensajeUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mensaje_usuario }\n end\n end", "def show\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @juzgado }\n end\n end", "def index\n @minicursos = Minicurso.all\n\t\t#@minicursos = Minicurso.scoped\n\t\t#@users = Minicurso.inscritos(params[:id]) if params[:id].present?\n\n respond_to do |format|\n\t\t\t format.html # index.html.erb\n\t\t\t format.json { render json: @minicursos }\n end\n end", "def index\n @peticion_servicio_tis = Peticion::ServicioTi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peticion_servicio_tis }\n end\n end", "def new\n @ministerio = Ministerio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ministerio }\n end\n end", "def index\n #para mostrar solo los post del usuario actual\n @posts = Post.where(usuario_id: current_usuario.id).all\n puts \"USUARIOOOO\"\n puts current_usuario.to_json\n\n #@posts = Post.all\n end", "def index\n if params[:user_id] != nil\n @memos = Memo.where(:user_id => current_user.id)\n else\n @memos = Memo.all\n end\n \n \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @memos }\n end\n end", "def index\n @memos = Memo.all.order(id: \"DESC\").limit(100)\n memo_list = []\n for memo in @memos\n user = memo.user.name\n memo_list << {\n memo: memo,\n user: user\n }\n end\n render json: memo_list\n end", "def show\n @personaje_mision = PersonajeMision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personaje_mision }\n end\n end", "def new\n @ejercicio = Ejercicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ejercicio }\n end\n end", "def index\n @messies = Messy.all\n\n render json: @messies\n end", "def index\n @pagamentos = Pagamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end", "def new\n @user = current_user;\n @toeic_log = ToeicLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @toeic_log }\n end\n end", "def new\n @medio_pago = MedioPago.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medio_pago }\n end\n end", "def new\n @mecanicacomplejo = Mecanicacomplejo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mecanicacomplejo }\n end\n end", "def index\n @uchronias = Uchronia.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @uchronias }\n end\n end", "def show\n @remedio = Remedio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remedio }\n end\n end", "def show\n @user = current_user;\n @toeic_log = ToeicLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @toeic_log }\n end\n end", "def show\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @servicio }\n end\n end", "def show\n @remito = Remito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remito }\n end\n end", "def index \n @lancamentorapido = Lancamentorapido.new \n @lancamentorapidos = Lancamentorapido.all\n \n @categorias = Category.all\n @centrosdecusto = Centrodecusto.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lancamentorapidos }\n end\n end", "def index\n @deporte_usuarios = DeporteUsuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deporte_usuarios }\n end\n end", "def new\n @lista_contato = ListaContato.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lista_contato }\n end\n end", "def index\n @municipios = Municipio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @municipios }\n end\n end", "def show\n @colegio = Colegio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colegio }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @listas_contato = ListaContato.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listas_contato }\n end\n end", "def show\n @usuario = Usuario.find(params[:id])\n\n render json: @usuario\n end", "def index\n @tutorados = Tutorado.all\n\n render json: @tutorados, status: :ok\n end", "def show\n @sistema = Sistema.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sistema }\n end\n end", "def index\n @usuarios = Usuario.all\n # respond_to do |format|\n # format.html\n # format.json { render :json => @usuarios }\n # end\n end", "def show\n @medio_pago = MedioPago.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medio_pago }\n end\n end", "def show\n @mercado_metum = MercadoMetum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mercado_metum }\n end\n end", "def new\n @empresa = Empresa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @empresa }\n end\n end", "def show\n @musique = Musique.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @musique }\n end\n end", "def show\n @lieu = Lieu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lieu }\n end\n end", "def new\n @medicamento = Medicamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medicamento }\n end\n end", "def show\n @medio = Medio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @medio }\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 index\n @ativo_outros = AtivoOutro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ativo_outros }\n end\n end", "def new\n @medio = Medio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @medio }\n end\n end", "def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario }\n end\n end", "def show\n @pologeno = Pologeno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pologeno }\n end\n end", "def index\n @pagamentos = Pagamento.page(params[:page]).per(NUMERO_POR_PAGINA)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end", "def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end", "def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end", "def new\n @remedio = Remedio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @remedio }\n end\n end", "def index\n @programmes = Programme.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programmes }\n end\n end", "def index\n\t\trender json: { prueba: 'Funciona'}\n\tend", "def show\n @personaje = Personaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personaje }\n end\n end", "def new\n @colegio = Colegio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @colegio }\n end\n end", "def show\n @medicamento = Medicamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medicamento }\n end\n end", "def index\n #@imovels = Imovel.all\n \n #Traz apenas os imoveis ativos\n # Isso vai no controller do cliente. Só os ativos aparecem\n #@imovels = Imovel.all.select { |i| i.ativo == true }\n \n @imovels = Imovel.paginate :page => params[:page], :order => 'created_at DESC', :per_page => 10\n \n # Mapa para guardar os valores das transacoes associadas a cada imovel.\n # key: imovel_id, value: lista com [0]:transacao, [1]: tipos, [2] responsavel\n @hash_informacoes_imoveis = Hash.new\n \n @imovels.each do |imovel|\n popular_imovel(imovel)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @imovels }\n end\n end", "def new\n @tecnico = Tecnico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tecnico }\n end\n end" ]
[ "0.7023441", "0.68950266", "0.6876304", "0.68315804", "0.6711144", "0.67087495", "0.6616755", "0.66129297", "0.65941334", "0.647492", "0.64690983", "0.64596504", "0.64440084", "0.6426259", "0.64167756", "0.6416013", "0.6413856", "0.6367413", "0.6336719", "0.6316877", "0.63042843", "0.63038355", "0.6302259", "0.6301017", "0.6286716", "0.6282135", "0.62789136", "0.6253892", "0.6249853", "0.6242232", "0.6239747", "0.6235565", "0.6233974", "0.6227488", "0.61954635", "0.6188174", "0.61860645", "0.6185573", "0.6184028", "0.6178716", "0.6176473", "0.61689365", "0.6168697", "0.616474", "0.6164477", "0.6160145", "0.61593497", "0.6153098", "0.6146513", "0.6144129", "0.6140423", "0.61402607", "0.6133441", "0.61290383", "0.6128695", "0.612597", "0.61254245", "0.612354", "0.6122643", "0.6119086", "0.6117027", "0.6112041", "0.6109586", "0.6104864", "0.6103597", "0.6100152", "0.6096632", "0.6095376", "0.6092131", "0.6087138", "0.60849625", "0.60849625", "0.60849625", "0.6081923", "0.60801965", "0.6079016", "0.6077446", "0.60641074", "0.60626256", "0.6059684", "0.6058235", "0.605158", "0.6050403", "0.60490936", "0.6048765", "0.60473657", "0.60441035", "0.60429883", "0.60425216", "0.60409296", "0.60401344", "0.60380834", "0.60380834", "0.60375035", "0.60355383", "0.6035411", "0.60332495", "0.6029563", "0.602776", "0.6027514", "0.6027254" ]
0.0
-1
POST /metodologias POST /metodologias.json
def create @metodologia = Metodologia.new(metodologia_params) respond_to do |format| if @metodologia.save format.html { redirect_to @metodologia, notice: 'Metodologia was successfully created.' } format.json { render action: 'show', status: :created, location: @metodologia } else format.html { render action: 'new' } format.json { render json: @metodologia.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @metodo = Metodo.new(params[:metodo])\n\n respond_to do |format|\n if @metodo.save\n format.html { redirect_to metodos_url }\n format.json { render json: @metodo, status: :created, location: @metodo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @metodo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :create, @mesasredonda\n @mesasredonda = Mesasredonda.new(params[:mesasredonda])\n\n respond_to do |format|\n if @mesasredonda.save\n format.html { redirect_to @mesasredonda, notice: 'Mesa redonda cadastrada com sucesso.' }\n format.json { render json: @mesasredonda, status: :created, location: @mesasredonda }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mesasredonda.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @relogio = Relogio.new(params[:relogio])\n\n respond_to do |format|\n if @relogio.save\n format.html { redirect_to @relogio, notice: 'Relogio was successfully created.' }\n format.json { render json: @relogio, status: :created, location: @relogio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @relogio.errors, status: :unprocessable_entity }\n end\n end\n end", "def metodologia_params\n params.require(:metodologia).permit(:name, :descripcion)\n end", "def create\n @logjuego = Logjuego.new(params[:logjuego])\n\n respond_to do |format|\n if @logjuego.save\n format.html { redirect_to @logjuego, notice: 'Logjuego was successfully created.' }\n format.json { render json: @logjuego, status: :created, location: @logjuego }\n else\n format.html { render action: \"new\" }\n format.json { render json: @logjuego.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @imobiliaria = Imobiliaria.new(imobiliaria_params)\r\n\r\n respond_to do |format|\r\n if @imobiliaria.save\r\n format.json { render json: @imobiliaria, status: :created }\r\n else \r\n format.json { render json: @imobiliaria.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @laboratorio = Laboratorio.new(laboratorio_params)\n get_responsavel\n puts \"O responsavel é: #{@laboratorio.responsavel_id}\"\n if (@responsavel != \"sem_responsavel\")\n @laboratorio.docentes << Docente.find(@laboratorio.responsavel_id)\n puts \"Add relação entre #{@laboratorio.nome} e #{Docente.find(@laboratorio.responsavel_id).user.nome}\"\n end\n respond_to do |format|\n if @laboratorio.save\n format.html { redirect_to @laboratorio, notice: 'Laboratorio was successfully created.' }\n format.json { render :show, status: :created, location: @laboratorio }\n else\n format.html { render :new }\n format.json { render json: @laboratorio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @mundo = Mundo.new(mundo_params)\n\n respond_to do |format|\n if @mundo.save\n format.html { redirect_to @mundo, notice: 'Mundo was successfully created.' }\n format.json { render :show, status: :created, location: @mundo }\n else\n format.html { render :new }\n format.json { render json: @mundo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def create\n @mensaje_usuario = MensajeUsuario.new(params[:mensaje_usuario])\n\n respond_to do |format|\n if @mensaje_usuario.save\n format.html { redirect_to @mensaje_usuario, notice: 'Mensaje usuario was successfully created.' }\n format.json { render json: @mensaje_usuario, status: :created, location: @mensaje_usuario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mensaje_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @metodo = Metodo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @metodo }\n end\n end", "def create\n @novedad_mecanica = @unidad.novedades_mecanicas.build(novedad_mecanica_params)\n\n respond_to do |format|\n if @novedad_mecanica.save\n format.html { redirect_to [@unidad,@novedad_mecanica], notice: 'Novedad mecanica was successfully created.' }\n format.json { render :show, status: :created, location: @novedad_mecanica }\n else\n format.html { render :new }\n format.json { render json: @novedad_mecanica.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meupedido = Meupedido.new(meupedido_params)\n\n respond_to do |format|\n if @meupedido.save\n format.html { redirect_to @meupedido, notice: 'Meupedido was successfully created.' }\n format.json { render :show, status: :created, location: @meupedido }\n else\n format.html { render :new }\n format.json { render json: @meupedido.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @logradouro = Logradouro.new(logradouro_params)\n\n respond_to do |format|\n if @logradouro.save\n format.html { redirect_to @logradouro, notice: 'Logradouro criado com sucesso.' }\n format.json { render :show, status: :created, location: @logradouro }\n else\n format.html { render :new }\n format.json { render json: @logradouro.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @medico = Medico.new(medico_params)\n\n respond_to do |format|\n if @medico.save\n format.html { redirect_to @medico, notice: \"Medico criado com SUCESSO.\" }\n format.json { render :show, status: :created, location: @medico }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @medico.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @logjuego = Logjuego.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @logjuego }\n end\n end", "def create\n\n puts request.body.string\n\n if request.body.string.include? %q[\"id\"]\n render json: %q[{\"error\": \"No se puede crear usuario con id\"}], status: 400\n else\n @usuario = Usuario.new(usuario_params)\n #Tuve que hacerlo asi, pq por alguna razon no me dejaba de la forma tradicional!\n #@usuario = Usuario.new\n #@usuario.usuario = params[:usuario]\n #@usuario.nombre = params[:nombre]\n #@usuario.apellido = params[:apellido]\n #@usuario.twitter = params[:twitter]\n\n\n respond_to do |format|\n if @usuario.save\n #format.html { redirect_to @usuario, notice: 'Usuario was successfully created.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n #format.html { render :new }\n format.json { render json: @usuario.errors, status: 404}# status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @mecanico_especialidad = MecanicoEspecialidad.new(mecanico_especialidad_params)\n\n respond_to do |format|\n if @mecanico_especialidad.save\n format.html { redirect_to @mecanico_especialidad, notice: 'Mecanico especialidad was successfully created.' }\n format.json { render :show, status: :created, location: @mecanico_especialidad }\n else\n format.html { render :new }\n format.json { render json: @mecanico_especialidad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.create(post_params)\n puts \"LLLLLOOOOOOOLLLLLL\"\n puts current_usuario.to_json\n @post = current_usuario.posts.create(post_params)\n \n @post.sangre = current_usuario.tipoDeSangre\n\n\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @mensagem = Mensagem.new(params[:mensagem])\n @mensagem.autor = session[:current_user]\n id_to_post = String.new\n \n case @mensagem.recebedor_type\n when \"Turma\"\n aux = Turma.find(@mensagem.recebedor_id)\n id_to_post = aux.group_id\n end\n \n @mensagem.post_id = api_client.put_wall_post(@mensagem.conteudo, {}, id_to_post)['id']\n\n respond_to do |format|\n if @mensagem.save\n #format.html { redirect_to(@mensagem, :notice => 'Mensagem was successfully created.') }\n format.xml { render :xml => @mensagem, :status => :created, :location => @mensagem }\n format.js {}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mensagem.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @quinto = Quinto.new(quinto_params)\n \n @quinto.anio = params[:anio]\n @quinto.mes = params[:mes]\n \n \n respond_to do |format|\n if @quinto.save\n format.html { redirect_to @quinto, notice: 'Quinto was successfully created.' }\n format.json { render :show, status: :created, location: @quinto }\n else\n format.html { render :new }\n format.json { render json: @quinto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @motivo = Motivo.new(motivo_params)\n\n respond_to do |format|\n if @motivo.save\n format.html { redirect_to @motivo, notice: 'Motivo was successfully created.' }\n format.json { render :show, status: :created, location: @motivo }\n else\n format.html { render :new }\n format.json { render json: @motivo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @matriz = Matriz.new(matriz_params)\n\n respond_to do |format|\n if @matriz.save\n format.html { redirect_to @matriz, notice: 'Matriz was successfully created.' }\n format.json { render :show, status: :created, location: @matriz }\n else\n format.html { render :new }\n format.json { render json: @matriz.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @mensaje = Mensaje.new(mensaje_params)\n\n respond_to do |format|\n if @mensaje.save\n format.html { redirect_to @mensaje, notice: \"Mensaje was successfully created.\" }\n format.json { render :show, status: :created, location: @mensaje }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @mensaje.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @relogio = Relogio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @relogio }\n end\n end", "def create\n @motivobaja = MotivoBaja.new(motivo_baja_params)\n\n respond_to do |format|\n if @motivobaja.save\n format.html { redirect_to @motivobaja, notice: 'Motivo Baja was successfully created.' }\n format.json { render json: @motivobaja, status: :created, location: @motivobaja }\n else\n format.html { render action: \"new\" }\n format.json { render json: @motivobaja.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @mensagem = Mensagem.new(mensagem_params)\n\n respond_to do |format|\n if @mensagem.save\n format.html { redirect_to @mensagem.presente.lista, notice: 'Mensagem Adicionada. Após aprovação do proprietário da lista será exibida.' }\n format.json { render action: 'show', status: :created, location: @mensagem }\n else\n format.html { render action: 'new' }\n format.json { render json: @mensagem.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params.permit(:pseudo_administrateur, :email_administrateur, :motDePasse_administrateur)\n ajout = AdministrateurService.instance.creerNouveauAdmin(params[:pseudo_administrateur], params[:email_administrateur], params[:motDePasse_administrateur])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end", "def create\n @medio = Medio.new(params[:medio])\n\n respond_to do |format|\n if @medio.save\n format.html { redirect_to @medio, :notice => 'Medio was successfully created.' }\n format.json { render :json => @medio, :status => :created, :location => @medio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @medio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @mensaje_usuario = MensajeUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mensaje_usuario }\n end\n end", "def create\n @manteni = Manteni.new(manteni_params)\n\n respond_to do |format|\n if @manteni.save\n format.html { redirect_to @manteni, notice: 'Manteni was successfully created.' }\n format.json { render :show, status: :created, location: @manteni }\n else\n format.html { render :new }\n format.json { render json: @manteni.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @usuario = Usuario.new(usuario_params)\n\n if @usuario.save\n render json: @usuario, status: :created, location: @usuario\n else\n render json: @usuario.errors, status: :unprocessable_entity\n end\n end", "def create\n @filme = Filme.new(filme_params)\n @diretor = Diretor.order('nome')\n @ator = Ator.order('nome')\n\n respond_to do |format|\n if @filme.save\n format.html { redirect_to @filme, notice: 'Um novo filme foi criado com sucesso.' }\n format.json { render json: @filme, status: :created, location: @filme }\n else\n format.html { render action: \"new\" }\n format.json { render json: @filme.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tema_modulo = TemaModulo.new(tema_modulo_params)\n\n respond_to do |format|\n if @tema_modulo.save\n format.html { redirect_to @tema_modulo, notice: 'Tema modulo was successfully created.' }\n format.json { render :show, status: :created, location: @tema_modulo }\n else\n format.html { render :new }\n format.json { render json: @tema_modulo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @personaje_mision = PersonajeMision.new(params[:personaje_mision])\n\n respond_to do |format|\n if @personaje_mision.save\n format.html { redirect_to @personaje_mision, notice: 'Personaje mision was successfully created.' }\n format.json { render json: @personaje_mision, status: :created, location: @personaje_mision }\n else\n format.html { render action: \"new\" }\n format.json { render json: @personaje_mision.errors, status: :unprocessable_entity }\n end\n end\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 new\n @trabalho = current_user.trabalhos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trabalho }\n end\n end", "def create\n @receita_medica = ReceitaMedica.new(params[:receita_medica])\n @receita_medica.medico = current_user\n\n respond_to do |format|\n if @receita_medica.save\n format.html { redirect_to @receita_medica, notice: 'Receita medica was successfully created.' }\n format.json { render json: @receita_medica, status: :created, location: @receita_medica }\n else\n format.html { render action: \"new\" }\n format.json { render json: @receita_medica.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @logueo = Logueo.new(logueo_params)\n\n respond_to do |format|\n if @logueo.save\n format.html { redirect_to @logueo, notice: 'Registro exitoso.' }\n format.json { render :show, status: :created, location: @logueo }\n else\n format.html { render :new }\n format.json { render json: @logueo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @registro_medicion = Api::RegistroMedicion.new(registro_medicion_params)\r\n @registro_medicion.microcontrolador = Api::Microcontrolador.find_or_create_by(nivel: params[:nivel], area: params[:area])\r\n #TODO Mande que tipo de variable ambiental es\r\n\r\n @registro_medicion.variable_ambiental = Api::VariableAmbiental.where(tipo: params[:tipo]).first\r\n\r\n if @registro_medicion.save && Api::RegistroMedicionesHelper.verify(@registro_medicion, params[:promedio])\r\n render json: @registro_medicion.to_json, status: :ok\r\n else\r\n render :json => { :mssg => 'Hubo un error creando el registro medicion.' }, status: :unprocessable_entity\r\n end\r\n end", "def create\n @memo = Memo.new(memo_params)\n @memo.save\n @memos = Memo.all.order(id: \"DESC\")\n memo_list = []\n for memo in @memos\n user = memo.user.name\n memo_list << {\n memo: memo,\n user: user\n }\n end\n render json: memo_list\n # render json: @memos\n end", "def create\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.new(params[:juzgado])\n\n respond_to do |format|\n if @juzgado.save\n format.html { redirect_to @juzgado, notice: 'Juzgado fue creado satisfactoriamente.' }\n format.json { render json: @juzgado, status: :created, location: @juzgado }\n else\n format.html { render action: \"new\" }\n format.json { render json: @juzgado.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @marca = Marca.new(marca_params)\n if @marca.save\n render json: @marca\n else\n render json: @marca.errors, status: :unprocessable_entity \n end\n end", "def create\n @alumno = Alumno.new(params[:alumno])\n\n respond_to do |format|\n if @alumno.save\n render json: @alumno.as_json(include: :persona), status: :created, location: @alumno\n else\n render json: @alumno.errors, status: :unprocessable_entity\n end\n end\n end", "def create\n @personerium = Personerium.new(params[:personerium])\n\n respond_to do |format|\n if @personerium.save\n\tlog = Log.new(:NombreTable => \"personeria\", :Fecha => Date.today, :Hora => Time.now, :Usuario => current_user.username, :AccionRealizada => \"Create\")\n\tlog.save\n format.html { redirect_to @personerium, notice: 'Personerium was successfully created.' }\n format.json { render json: @personerium, status: :created, location: @personerium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @personerium.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @juzgado }\n end\n end", "def create\n @mapeamento = Mapeamento.new(params[:mapeamento])\n\n respond_to do |format|\n if @mapeamento.save\n format.html { redirect_to @mapeamento, notice: 'Mapeamento was successfully created.' }\n format.json { render json: @mapeamento, status: :created, location: @mapeamento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mapeamento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @datos_usuario = DatosUsuario.new(datos_usuario_params)\n\n respond_to do |format|\n if @datos_usuario.save\n format.html { redirect_to \"/inicio/success\", success: 'Datos usuario was successfully created.' }\n \n else\n format.html { render action: 'new' }\n format.json { render json: @datos_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cautela = Cautela.new(cautela_params)\n @cautela.user = current_user\n @cautela.data = Time.now\n respond_to do |format|\n if @cautela.save\n format.html { redirect_to @cautela, notice: 'Cautela criada com sucesso, adicione agora os materiais à lista.' }\n format.json { render action: 'additem', status: :created, location: @cautela }\n else\n format.html { render action: 'new' }\n format.json { render json: @cautela.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @municao = Municao.new(municao_params)\n\n respond_to do |format|\n if @municao.save\n format.html { redirect_to @municao, notice: 'A Munição foi criada com sucesso!' }\n format.json { render :show, status: :created, location: @municao }\n else\n format.html { render :new }\n format.json { render json: @municao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @mantenimiento = Mantenimiento.new(mantenimiento_params)\n\n respond_to do |format|\n if @mantenimiento.save\n format.html { redirect_to @mantenimiento, notice: 'Mantenimiento was successfully created.' }\n format.json { render action: 'show', status: :created, location: @mantenimiento }\n else\n format.html { render action: 'new' }\n format.json { render json: @mantenimiento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ministerio = Ministerio.new(params[:ministerio])\n\n respond_to do |format|\n if @ministerio.save\n format.html { redirect_to @ministerio, notice: 'Ministerio was successfully created.' }\n format.json { render json: @ministerio, status: :created, location: @ministerio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ministerio.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n authorize! :new, @mesasredonda\n @mesasredonda = Mesasredonda.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mesasredonda }\n end\n end", "def new\n seleccionarMenu(:rondas)\n @ronda = current_usuario.rondas.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ronda }\n end\n end", "def create\n pessoa = Pessoa.new(pessoa_params) \n \n if pessoa.save\n render json: {status: 'SUCCESSO', message:'Usuário cadastrado com sucesso!', data:pessoa},status: :ok\n else\n render json: {status: 'ERRO', message:'Usuário não pode ser cadastrado. Tente novamente mais tarde.', data:pessoa.errors},status: :unprocessable_entity\n end\n end", "def create\n @recordatorio = current_user.recordatorios.new(recordatorio_params)\n\n respond_to do |format|\n if @recordatorio.save\n format.html { redirect_to root_path, notice: 'Creado exitosamente' }\n format.json { render action: 'show', status: :created, location: @recordatorio }\n else\n format.html { render action: 'new' }\n format.json { render json: @recordatorio.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n raise 'Operacao invalida' unless current_user.tipo == 2\n @receita_medica = ReceitaMedica.new\n @medicamentos = Medicamento.all\n @users = User.Pacientes\n @historicos = Historico.all\n @receita_medica.item_receitas.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @receita_medica }\n end\n end", "def create\n @personaje = Personaje.new(params[:personaje])\n\n respond_to do |format|\n if @personaje.save\n format.html { redirect_to @personaje, notice: 'Personaje was successfully created.' }\n format.json { render json: @personaje, status: :created, location: @personaje }\n else\n format.html { render action: \"new\" }\n format.json { render json: @personaje.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params.permit(:intitule, :estObligatoire, :nombreDeCaractere, :ordre, :sondage_id)\n ajout = QuestionOuverteService.instance.creerQuestionOuverte(params[:intitule], params[:estObligatoire], params[:nombreDeCaractere], params[:ordre], params[:sondage_id])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end", "def create\n @puntaje = Puntaje.new(params[:puntaje])\n\n respond_to do |format|\n if @puntaje.save\n format.html { redirect_to @puntaje, notice: 'El puntaje ha sido registrado con exito. ' }\n CustomLogger.info(\"Un nuevo puntaje: #{@puntaje.puntaje.to_i.inspect} correspondiente a la tarea: #{@puntaje.planificacion_tarea.inspect} del alumno: #{@puntaje.alumno.user_full_name.inspect} , Descripcion:#{@puntaje.descripcion.inspect} ha sido registrado por el usuario: #{current_user.full_name.inspect}, #{Time.now}\")\n format.json { render json: @puntaje, status: :created, location: @puntaje }\n else\n atributos\n format.html { render action: \"new\" }\n CustomLogger.error(\"Se ha producido un error al querer registrar el puntaje: #{@puntaje.puntaje.to_i.inspect} y sus demas atributos, por el usuario: #{current_user.full_name.inspect}, #{Time.now}\")\n format.json { render json: @puntaje.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @remedio = Remedio.new(params[:remedio])\n\n respond_to do |format|\n if @remedio.save\n format.html { redirect_to @remedio, notice: 'Remedio was successfully created.' }\n format.json { render json: @remedio, status: :created, location: @remedio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @remedio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @mutacao = Mutacao.new(params[:mutacao])\n\n respond_to do |format|\n if @mutacao.save\n format.html { redirect_to mutacaos_path, notice: 'Mutacao was successfully created.' }\n format.json { render json: @mutacao, status: :created, location: @mutacao }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mutacao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @entrada_blog = EntradaBlog.new(entrada_blog_params)\n\n\n \n\n\n respond_to do |format|\n if @entrada_blog.save\n\n @tipoentrada = TipoContenido.find_by_entrada_blog_id( @entrada_blog.id)\n\n # Seleccionamos los usuarios a los que hay que enviar el correo electrónico\n #dependiendo de sus suscripciones.\n\n if @tipoentrada.metematica\n @usuarios = Usuario.where({codigo: [\"todo\", \"mates\"]})\n elsif @tipoentrada.astrofoto\n @usuarios = Usuario.where({codigo: [\"todo\", \"foto\"]})\n else \n @usuario = Usuario.all\n end\n\n\n @usuarios.each do |usuario| \n @usuario_correo = usuario\n Actualizacion.notificacion(@entrada_blog, @usuario_correo).deliver_now\n end\n\n format.html { redirect_to @entrada_blog, notice: 'Entrada blog was successfully created.' }\n format.json { render :show, status: :created, location: @entrada_blog }\n else\n format.html { render :new }\n format.json { render json: @entrada_blog.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @tecnico = current_user.tecnicos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tecnico }\n end\n end", "def create\n @meibo = Meibo.new(meibo_params)\n\n respond_to do |format|\n if @meibo.save\n format.html { redirect_to @meibo, notice: '名簿は正常に作成されました。' }\n format.json { render :show, status: :created, location: @meibo }\n else\n format.html { @meibos = Meibo.page(params[:page]).per(@@kensu) ; render :index }\n format.json { render json: @meibo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tomaturno = Tomaturno.new(tomaturno_params)\n\n respond_to do |format|\n if @tomaturno.save\n format.html { redirect_to @tomaturno, notice: 'Tomaturno was successfully created.' }\n format.json { render :show, status: :created, location: @tomaturno }\n else\n format.html { render :new }\n format.json { render json: @tomaturno.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @biometria = Biometria.new(biometria_params)\n\n respond_to do |format|\n if @biometria.save\n format.html { redirect_to index_biometria_path(params[:biometria][:paciente_id]), notice: 'Datos de biometria guardados correctamente'}\n format.json { render :show, status: :created, location: @biometria }\n else\n format.html { render :new }\n format.json { render json: @biometria.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @reclamacao = Reclamacao.new(reclamacao_params)\r\n user = Usuario.get_usuario_logado\r\n @reclamacao.write_attribute(:usuario_id, user.id)\r\n respond_to do |format|\r\n if @reclamacao.save\r\n format.html { redirect_to root_path, notice: 'RECLAMAÇÃO EFETUADA COM SUCESSO' }\r\n format.json { render :show, status: :created, location: @reclamacao }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @reclamacao.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @tecnico = Tecnico.new(params[:tecnico])\n\n respond_to do |format|\n if @tecnico.save\n format.html { redirect_to @tecnico, :notice => 'Tecnico was successfully created.' }\n format.json { render :json => @tecnico, :status => :created, :location => @tecnico }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tecnico.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @formulario = Formulario.new(params[:formulario])\n\n respond_to do |format|\n if @formulario.save\n format.html { redirect_to @formulario, notice: 'Formulario was successfully created.' }\n format.json { render json: @formulario, status: :created, location: @formulario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @formulario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @Empresa = Empresa.find(params[:empresa_id])\n p simulacion_params[:id]\n if simulacion_params[:id]!=nil\n respond_to do |format| \n format.html { render json: 1 and return}\n end\n end\n [email protected](simulacion_params)\n respond_to do |format|\n if simulacion.save\n format.html { render json: {simulacion:simulacion}}\n else\n format.html { render action: simulacion.errors }\n end\n end\n end", "def create\n @medio_pago = MedioPago.new({ :medio_pago => params[:medio_pago], :odontologo_id => params[:odontologo_id] })\n #@medio_pago = MedioPago.new(params[:medio_pago])\n\n respond_to do |format|\n if @medio_pago.save\n format.html { redirect_to @medio_pago, notice: 'Medio pago was successfully created.' }\n format.json { render json: @medio_pago, status: :created, location: @medio_pago }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medio_pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tecnico = Tecnico.new(params[:tecnico])\n @tecnico.user = current_user\n\n respond_to do |format|\n if @tecnico.save\n format.html { redirect_to @tecnico, notice: 'Técnico foi criado com sucesso.' }\n format.json { render json: @tecnico, status: :created, location: @tecnico }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @mecanicacomplejo = Mecanicacomplejo.new(params[:mecanicacomplejo])\n\n respond_to do |format|\n if @mecanicacomplejo.save\n format.html { redirect_to @mecanicacomplejo, notice: 'Mecanicacomplejo was successfully created.' }\n format.json { render json: @mecanicacomplejo, status: :created, location: @mecanicacomplejo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mecanicacomplejo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @matome = Matome.new(matome_params)\n\n respond_to do |format|\n if @matome.save\n format.html { redirect_to @matome, notice: 'Matome was successfully created.' }\n format.json { render :show, status: :created, location: @matome }\n else\n format.html { render :new }\n format.json { render json: @matome.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @matome = Matome.new(matome_params)\n\n respond_to do |format|\n if @matome.save\n format.html { redirect_to @matome, notice: 'Matome was successfully created.' }\n format.json { render :show, status: :created, location: @matome }\n else\n format.html { render :new }\n format.json { render json: @matome.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @inicio = Inicio.new(inicio_params)\n\n respond_to do |format|\n if @inicio.save\n format.html { redirect_to @inicio, notice: 'Inicio was successfully created.' }\n format.json { render :show, status: :created, location: @inicio }\n else\n format.html { render :new }\n format.json { render json: @inicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @alegeri_user_tema = AlegeriUserTema.new(alegeri_user_tema_params)\n\n respond_to do |format|\n if @alegeri_user_tema.save\n format.html { redirect_to @alegeri_user_tema, notice: 'Alegeri user tema was successfully created.' }\n format.json { render action: 'show', status: :created, location: @alegeri_user_tema }\n else\n format.html { render action: 'new' }\n format.json { render json: @alegeri_user_tema.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sumario = Sumario.new(sumario_params)\n\n respond_to do |format|\n if @sumario.save\n format.html { redirect_to @sumario, notice: 'Sumario was successfully created.' }\n format.json { render :show, status: :created, location: @sumario }\n else\n format.html { render :new }\n format.json { render json: @sumario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @unidad_medida.user_id = current_user.id\n respond_to do |format|\n if @unidad_medida.save\n format.html { redirect_to @unidad_medida, notice: 'Unidad medida was successfully created.' }\n format.json { render :show, status: :created, location: @unidad_medida }\n else\n format.html { render :new }\n format.json { render json: @unidad_medida.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @unidad_medida.user_id = current_user.id\n respond_to do |format|\n if @unidad_medida.save\n format.html { redirect_to @unidad_medida, notice: 'Unidad medida was successfully created.' }\n format.json { render :show, status: :created, location: @unidad_medida }\n else\n format.html { render :new }\n format.json { render json: @unidad_medida.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ejercicio = Ejercicio.new(params[:ejercicio])\n\n respond_to do |format|\n if @ejercicio.save\n format.html { redirect_to @ejercicio, notice: 'Ejercicio was successfully created.' }\n format.json { render json: @ejercicio, status: :created, location: @ejercicio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ejercicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @itemtipo = Itemtipo.new(itemtipo_params)\n\n if @itemtipo.save\n render json: @itemtipo, status: :created, location: @itemtipo\n else\n render json: @itemtipo.errors, status: :unprocessable_entity\n end\n end", "def new\n @motivobaja = MotivoBaja.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @motivobaja }\n end\n end", "def create\n @leito = Leito.new(params[:leito])\n\n respond_to do |format|\n if @leito.save\n format.html { redirect_to @leito, notice: 'Leito was successfully created.' }\n format.json { render json: @leito, status: :created, location: @leito }\n else\n format.html { render action: \"new\" }\n format.json { render json: @leito.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tecnico = Tecnico.new(params[:tecnico])\n\n respond_to do |format|\n if @tecnico.save\n format.html { redirect_to @tecnico, notice: 'Tecnico criado com sucesso.' }\n format.json { render json: @tecnico, status: :created, location: @tecnico }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end", "def novedad_mecanica_params\n params.require(:novedad_mecanica).permit(:observacion, :fecha)\n end", "def create\n\n respond_to do |format|\n if @especialidad.save\n format.html { redirect_to @especialidad, notice: 'Servicio creado exitosamente.' }\n format.json { render :show, status: :created, location: @especialidad }\n else\n format.html { render :new }\n format.json { render json: @especialidad.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @usuario = Usuario.new\n @data_inicio = I18n.l Date.today\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario }\n end\n end", "def create\n authorize! :create, Tipo\n @tipo = Tipo.new(tipo_params)\n log(\"Se ha creado la nomina #{@lt}\", 0)\n\n respond_to do |format|\n if @tipo.save\n format.html { redirect_to tipos_path, notice: 'La nómina fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @tipo }\n else\n format.html { render :new }\n format.json { render json: @tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @orden_cobro = OrdenCobro.new(params[:orden_cobro])\n\n respond_to do |format|\n if @orden_cobro.save\n\tlog = Log.new(:NombreTable => \"orden_cobros\", :Fecha => Date.today, :Hora => Time.now, :Usuario => current_user.username, :AccionRealizada => \"Create\")\n\tlog.save\n format.html { redirect_to @orden_cobro, notice: 'Orden cobro was successfully created.' }\n format.json { render json: @orden_cobro, status: :created, location: @orden_cobro }\n else\n format.html { render action: \"new\" }\n format.json { render json: @orden_cobro.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @traslado = Traslado.new(traslado_params)\n\n respond_to do |format|\n if @traslado.save\n format.html { redirect_to @traslado, notice: 'Traslado was successfully created.' }\n format.json { render :show, status: :created, location: @traslado }\n else\n format.html { render :new }\n format.json { render json: @traslado.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @objetos_mensura = ObjetosMensura.new(objetos_mensura_params)\n\n respond_to do |format|\n if @objetos_mensura.save\n format.html { redirect_to @objetos_mensura, notice: 'Objetos mensura was successfully created.' }\n format.json { render :show, status: :created, location: @objetos_mensura }\n else\n format.html { render :new }\n format.json { render json: @objetos_mensura.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @mensagem = @campanha.mensagens.create(mensagem_params)\n\n @mensagem.enviada = false\n\n respond_to do |format|\n if @mensagem.save\n format.html do\n redirect_to campanha_mensagem_path(@campanha, @mensagem), notice: {\n type: 'info',\n message: 'Mensagem adicionada com sucesso.'\n }\n end\n format.json { render :show, status: :created, location: @mensagem }\n else\n format.html { render :new }\n format.json { render json: @mensagem.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tablero = Tablero.new(tablero_params)\n m= params.require(:tablero).permit(:idusuario, :grupo, :descripcion, :e1, :e2, :e3, :puntaje)\n\n params[idusuario.each] do |i|\n miembros=[params[:idusuario[i]]:grupo[i], :descripcion[i], :e1[i], :e2[i], :e3[i], :puntaje[i]]\n end\n\n respond_to do |format|\n if @tablero.save\n format.html { redirect_to @tablero, notice: \"El tablero se creó correctamente\" }\n format.json { render :show, status: :created, location: @tablero }\n else\n format.html { render :new }\n format.json { render json: @tablero.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @mario = Mario.new(mario_params)\n\n respond_to do |format|\n if @mario.save\n format.html { redirect_to @mario, notice: 'Mario was successfully created.' }\n format.json { render :show, status: :created, location: @mario }\n else\n format.html { render :new }\n format.json { render json: @mario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end", "def create\n @tipo_usuario = TipoUsuario.new(params[:tipo_usuario])\n\n respond_to do |format|\n if @tipo_usuario.save\n format.html { redirect_to tipo_usuarios_path, notice: 'Tipo usuario fue creado exitosamente.' }\n format.json { render json: @tipo_usuario, status: :created, location: @tipo_usuario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def meupedido_params\n params.require(:meupedido).permit(:user_id, :obs, :status, :total, :descricao)\n end", "def create\n @parametro = Parametro.new(parametro_params)\n @parametro.observacion = @parametro.multiparametro('Ingresa 1', 'Ingresa 2', 'Ingresa 3')\n respond_to do |format|\n if @parametro.save\n format.html { redirect_to @parametro, notice: \"Parametro was successfully created.\" }\n format.json { render :show, status: :created, location: @parametro }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @parametro.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.67429745", "0.6460018", "0.6419304", "0.6323174", "0.6312466", "0.62000996", "0.6176149", "0.61474586", "0.614646", "0.6128271", "0.6125315", "0.6123741", "0.61165315", "0.6114368", "0.6101276", "0.6099468", "0.6087822", "0.6079654", "0.6068045", "0.6054051", "0.60446644", "0.60319513", "0.60145074", "0.6004181", "0.5998505", "0.59926087", "0.5984475", "0.59809434", "0.59784836", "0.59776086", "0.5967661", "0.5963639", "0.5963243", "0.5962813", "0.5961871", "0.59611344", "0.5954718", "0.59531915", "0.5948949", "0.59435993", "0.59302866", "0.5930217", "0.5926251", "0.592324", "0.59147674", "0.5912624", "0.59097856", "0.58975875", "0.5896415", "0.58911526", "0.588987", "0.588524", "0.5884694", "0.5884168", "0.5881953", "0.58786714", "0.5877123", "0.58755827", "0.5872241", "0.586766", "0.5863676", "0.5862732", "0.586201", "0.58544767", "0.5852481", "0.5844236", "0.58340126", "0.58337504", "0.5825913", "0.58245534", "0.5823518", "0.5823059", "0.582251", "0.5822439", "0.5821802", "0.5821802", "0.5820383", "0.5819103", "0.58179164", "0.5817244", "0.5817244", "0.581492", "0.5811969", "0.58054525", "0.5798576", "0.5796386", "0.5793193", "0.5792533", "0.57919526", "0.5787897", "0.5787047", "0.57852435", "0.5782135", "0.57810813", "0.5779469", "0.5776026", "0.5775891", "0.57710385", "0.57679236", "0.5765263" ]
0.7096514
0
PATCH/PUT /metodologias/1 PATCH/PUT /metodologias/1.json
def update respond_to do |format| if @metodologia.update(metodologia_params) format.html { redirect_to @metodologia, notice: 'Metodologia was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @metodologia.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @metodo = Metodo.find(params[:id])\n\n respond_to do |format|\n if @metodo.update_attributes(params[:metodo])\n format.html { redirect_to metodos_url }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @metodo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @relogio = Relogio.find(params[:id])\n\n respond_to do |format|\n if @relogio.update_attributes(params[:relogio])\n format.html { redirect_to @relogio, notice: 'Relogio was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @relogio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @usuario = Usuario.find_by_id(params[:id])\n if @usuario.nil?\n render :json => {:error => \"Usuario no encontrado\"}.to_json, :status => 404\n\n #render :json => {:error => \"id no es modificable\"}.to_json, :status => 400\n else\n if usuario_params.count==1\n respond_to do |format|\n # format.json { render json: usuario_params.count}\n if @usuario.update(usuario_params)\n #format.json { render json: @usuario}\n\n #format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n #el segundo\n format.json { render :show, status: :ok, location: @usuario }\n end\n end\n elsif usuario_params.count==0\n # JSON.parse(usuario_params)\n respond_to do |format|\n format.json { render :json => {:error => \"id no es modificable\"}.to_json, :status => 400 }\n end\n else\n respond_to do |format|\n format.json { render :json => {:error => \"La modificación ha fallado\"}.to_json, :status => 500 }\n end\n end\n end\n end", "def update\n authorize! :update, @mesasredonda\n @mesasredonda = Mesasredonda.find(params[:id])\n\n respond_to do |format|\n if @mesasredonda.update_attributes(params[:mesasredonda])\n format.html { redirect_to @mesasredonda, notice: 'Mesa redonda modificada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mesasredonda.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @protocolo.update(protocolo_params)\n addlog(\"Protocolo alterado\")\n format.html { redirect_to @protocolo, notice: 'Protocolo foi atualizado.' }\n format.json { render :show, status: :ok, location: @protocolo }\n else\n format.html { render :edit }\n format.json { render json: @protocolo.errors, status: :unprocessable_entity }\n end\n end\n end", "def activo_update\n respond_to do |format|\n activo = params[:laboratorio][:activo]\n id = params[:id]\n Laboratorio.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def update\n respond_to do |format|\n if @prueba_json.update(prueba_json_params)\n format.html { redirect_to @prueba_json, notice: 'Prueba json was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prueba_json.errors, status: :unprocessable_entity }\n end\n end\n end", "def update \n retorno = {erro: \"322\" ,body: \"\"}\n if @usuario.update(valid_request?)\n retorno = {erro: \"000\", body: {evento_id: @usuario.id, usuario_nome: @usuario.nome}}\n end\n render json: retorno.to_json\n end", "def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipoapreensao.update(tipoapreensao_params)\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @servico_pacote.update(servico_pacote_params)\n format.html { redirect_to @servico_pacote, notice: 'Pacote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @servico_pacote.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n respond_to do |format|\n if @objeto.update(etiqueta_params)\n format.html { redirect_to @objeto, notice: 'Etiqueta was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n log(\"Se ha editado la nomina #{@lt}\", 1)\n format.html { redirect_to tipos_path, notice: 'Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\n end\n end\n end", "def update\n respond_to do |format|\n if @tiposveiculo.update(tiposveiculo_params)\n format.html { redirect_to tiposveiculos_url, notice: 'Tipo de Veículo editado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @tiposveiculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @mensagem.update(mensagem_params)\n format.html { redirect_to @mensagem, notice: 'Mensagem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mensagem.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sistema = Sistema.find(params[:id])\n\n respond_to do |format|\n if @sistema.update_attributes(params[:sistema])\n format.html { redirect_to @sistema, notice: 'Sistema was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sistema.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n if @veiculo.update_attributes(params[:veiculo])\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @oferta = Oferta.find(params[:id])\n\n respond_to do |format|\n if @oferta.update_attributes(params[:oferta])\n format.html { redirect_to [:admin, @oferta], :notice => 'Exemplo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @oferta.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @registro_servicio.update(registro_servicio_params)\n format.html { redirect_to @registro_servicio, notice: 'Servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @registro_servicio }\n else\n format.html { render :edit }\n format.json { render json: @registro_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update\n @formulario = Formulario.find(params[:id])\n\n respond_to do |format|\n if @formulario.update_attributes(params[:formulario])\n format.html { redirect_to @formulario, notice: 'Formulario was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @formulario.errors, status: :unprocessable_entity }\n end\n end\n end", "def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end", "def update\n respond_to do |format|\n if @oficio.update(oficio_params)\n format.html { redirect_to oficios_url, notice: 'Oficio actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: oficios_url }\n else\n format.html { render :edit }\n format.json { render json: @oficio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topico.update(topico_params)\n format.html { redirect_to set_path, notice: 'Tópico atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topico.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def update\n respond_to do |format|\n if @servico.update(servico_params)\n format.html { redirect_to servicos_url, notice: 'Serviço atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @servico }\n else\n format.html { render :edit }\n format.json { render json: @servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @matriz.update(matriz_params)\n format.html { redirect_to @matriz, notice: 'Matriz was successfully updated.' }\n format.json { render :show, status: :ok, location: @matriz }\n else\n format.html { render :edit }\n format.json { render json: @matriz.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_de_servicio.update(tipo_de_servicio_params)\n format.html { redirect_to @tipo_de_servicio, notice: 'Tipo de servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_de_servicio }\n else\n format.html { render :edit }\n format.json { render json: @tipo_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @mecanico_especialidad.update(mecanico_especialidad_params)\n format.html { redirect_to @mecanico_especialidad, notice: 'Mecanico especialidad was successfully updated.' }\n format.json { render :show, status: :ok, location: @mecanico_especialidad }\n else\n format.html { render :edit }\n format.json { render json: @mecanico_especialidad.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end", "def update\n respond_to do |format|\n if @voluntario.update(voluntario_params) and @voluntario.update_attributes(:modificador => current_user.id)\n format.html { redirect_to @voluntario, notice: 'Voluntario was successfully updated.' }\n format.json { render :show, status: :ok, location: @voluntario }\n else\n format.html { render :edit }\n format.json { render json: @voluntario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @mundo.update(mundo_params)\n format.html { redirect_to @mundo, notice: 'Mundo was successfully updated.' }\n format.json { render :show, status: :ok, location: @mundo }\n else\n format.html { render :edit }\n format.json { render json: @mundo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @logjuego = Logjuego.find(params[:id])\n\n respond_to do |format|\n if @logjuego.update_attributes(params[:logjuego])\n format.html { redirect_to @logjuego, notice: 'Logjuego was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @logjuego.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inicio.update(inicio_params)\n format.html { redirect_to @inicio, notice: 'Inicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @inicio }\n else\n format.html { render :edit }\n format.json { render json: @inicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @personaje = Personaje.find(params[:id])\n\n respond_to do |format|\n if @personaje.update_attributes(params[:personaje])\n format.html { redirect_to @personaje, notice: 'Personaje was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @personaje.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @respuesta = Respuesta.find(params[:id])\n\n if @respuesta.update(params[:respuesta])\n head :no_content\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def update\n if !Usuario.exists?(params[:id])\n render json: %q[{\"error\": \"Usuario no encontrado\"}], status: 404\n elsif request.body.string.include? %q[\"id\"] # id is set\n render json: %q[{\"error\": \"id no es modificable\"}], status: 400\n\n\n\n\n\n\n else\n @usuario = Usuario.find(params[:id])\n respond_to do |format|\n if @usuario.update(usuario_params)\n #format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n #format.json { render :show, status: :ok, location: @usuario}\n format.json {render json: @usuario}\n else\n #format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n\n end\n end", "def update\n respond_to do |format|\n if @ejemplo.update(ejemplo_params)\n format.html { redirect_to @ejemplo, notice: 'Ejemplo was successfully updated.' }\n format.json { render :show, status: :ok, location: @ejemplo }\n else\n format.html { render :edit }\n format.json { render json: @ejemplo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @todo = Todo.find(params[:todo][:id])\n if @todo.update_attributes(user_params)\n render json: @todo\n else\n render nothing: true, status: :bad_request\n end\n end", "def update\n @ministerio = Ministerio.find(params[:id])\n\n respond_to do |format|\n if @ministerio.update_attributes(params[:ministerio])\n format.html { redirect_to @ministerio, notice: 'Ministerio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ministerio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tb_servicio.update(tb_servicio_params)\n format.html { redirect_to @tb_servicio, notice: 'Tb servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tb_servicio }\n else\n format.html { render :edit }\n format.json { render json: @tb_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meupedido.update(meupedido_params)\n format.html { redirect_to @meupedido, notice: 'Meupedido was successfully updated.' }\n format.json { render :show, status: :ok, location: @meupedido }\n else\n format.html { render :edit }\n format.json { render json: @meupedido.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n if @solicitud_servicio.update_attributes(params[:solicitud_servicio])\n format.html { redirect_to @solicitud_servicio, notice: 'Solicitud servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @solicitud_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @empresa_servicio = EmpresaServicio.find(params[:id])\n respond_to do |format|\n if @empresa_servicio.update_attributes(params[:empresa_servicio])\n\n format.html { redirect_to empresa_empresa_servicios_path, notice: \"Los datos del servicio fueron actualizados para la empresa #{@empresa_servicio.empresa.nombre_empresa}\"}\n \n else\n format.html { render action: \"edit\" }\n format.json { render json: @empresa_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, notice: 'Tecnico atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n if @respuesta.update_attributes(params[:respuesta])\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @mensaje_usuario = MensajeUsuario.find(params[:id])\n\n respond_to do |format|\n if @mensaje_usuario.update_attributes(params[:mensaje_usuario])\n format.html { redirect_to @mensaje_usuario, notice: 'Mensaje usuario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mensaje_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n set_funcionario\n if @ordem_servico.update(ordem_servico_params)\n format.html { redirect_to @ordem_servico, notice: t('messages.cadastro_atualizado') }\n format.json { render :show, status: :ok, location: @ordem_servico }\n else\n format.html { render :edit }\n format.json { render json: @ordem_servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @alumno = Alumno.find(params[:id])\n\n respond_to do |format|\n if @alumno.update_attributes(params[:alumno])\n head :no_content\n else\n render json: @alumno.errors, status: :unprocessable_entity\n end\n end\n end", "def update\n respond_to do |format|\n if @repuesto_servicio.update(repuesto_servicio_params)\n format.html { redirect_to @repuesto_servicio, notice: 'Repuesto o servicio fue actualizado con éxito.' }\n format.json { render :show, status: :ok, location: @repuesto_servicio }\n else\n format.html { render :edit }\n format.json { render json: @repuesto_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @empresa.update(empresa_params) and @empresa.update_attributes(:modificador => current_user.id)\n format.html { redirect_to @empresa, notice: 'Empresa was successfully updated.' }\n format.json { render :show, status: :ok, location: @empresa }\n else\n format.html { render :edit }\n format.json { render json: @empresa.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @empresario.update(empresario_params) and @empresario.update_attributes(:modificador => current_user.id)\n format.html { redirect_to @empresario, notice: 'Empresario was successfully updated.' }\n format.json { render :show, status: :ok, location: @empresario }\n else\n format.html { render :edit }\n format.json { render json: @empresario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipomedalla = Tipomedalla.find(params[:id])\n\n respond_to do |format|\n if @tipomedalla.update_attributes(params[:tipomedalla])\n format.html { redirect_to @tipomedalla, notice: 'Tipomedalla was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipomedalla.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @sivic_ministerio.update(sivic_ministerio_params)\r\n format.html { redirect_to @sivic_ministerio, notice: 'Registro alterado com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_ministerio.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @telefono.update(telefono_params)\n format.html { redirect_to @telefono, notice: 'Telefono was successfully updated.' }\n format.json { render :show, status: :ok, location: @telefono }\n else\n format.html { render :edit }\n format.json { render json: @telefono.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @problema.update(problema_params)\n format.html { redirect_to @problema, notice: 'Problema was successfully updated.' }\n format.json { render :show, status: :ok, location: @problema }\n else\n format.html { render :edit }\n format.json { render json: @problema.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ministerios = Ministerios.find(params[:id])\n @title = \"Edição do Ministério: \" + @ministerios.nome\n respond_to do |format|\n if @ministerios.update_attributes(params[:ministerios])\n Ministerios.update(@ministerios.id, :respmod => self.current_usuarios.login.upcase)\n \tflash[:notice] = 'Ministerios was successfully updated.'\n format.html { redirect_to(ministerios_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ministerios.errors, :status => :unprocessable_entity }\n end\n end\n end", "def activo_update\n respond_to do |format|\n activo = params[:producto][:activo]\n id = params[:id]\n Producto.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def update\n @solicitudrecurso = Solicitudrecurso.find(params[:id])\n \n\n respond_to do |format|\n\n \n if @solicitudrecurso.update_attributes(:motivos => params[:motivos])\n \n @solicitudrecursos = Solicitudrecurso.find_all_by_usuario_id(@usuario_actual.id)\n format.html { redirect_to :action => \"index\" }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @solicitudrecurso.errors, :status => :unprocessable_entity }\n end\n \n end\n end", "def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\n end\n end", "def update\n respond_to do |format|\n if @mario.update(mario_params)\n format.html { redirect_to @mario, notice: 'Mario was successfully updated.' }\n format.json { render :show, status: :ok, location: @mario }\n else\n format.html { render :edit }\n format.json { render json: @mario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @diretor = Diretor.order('nome')\n @ator = Ator.order('nome')\n\n respond_to do |format|\n if @filme.update_attributes(filme_params)\n format.html { redirect_to @filme, notice: 'O filme foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @filme.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, :notice => 'Tecnico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tecnico.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @motivo.update(motivo_params)\n format.html { redirect_to @motivo, notice: 'Motivo was successfully updated.' }\n format.json { render :show, status: :ok, location: @motivo }\n else\n format.html { render :edit }\n format.json { render json: @motivo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, :notice => 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @sivic_celula.update(sivic_celula_params)\r\n format.html { redirect_to @sivic_celula, notice: 'Registro alterado com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_celula.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @mensaje = Mensaje.find(params[:id])\n\n respond_to do |format|\n if @mensaje.update_attributes(:titulo => params[:mensaje][:titulo], :cuerpo => params[:mensaje][:cuerpo], :caracter => params[:mensaje][:caracter])\n @mensaje.eliminar_receptores\n if params[:user_ids] != nil && params[:user_ids].kind_of?(Array)\n params[:user_ids].each do |user_id|\n MensajeUsuario.create(:usuario_id => user_id, :mensaje_id => @mensaje.id)\n end\n end\n format.html { redirect_to mensajes_path }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mensaje.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @os_nivel_servico.update(os_nivel_servico_params)\n format.html { redirect_to @os_nivel_servico, notice: 'Os nivel servico foi atualizado(a)' }\n format.json { render :show, status: :ok, location: @os_nivel_servico }\n else\n format.html { render :edit }\n format.json { render json: @os_nivel_servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @noto = Noto.find(params[:id])\n\n respond_to do |format|\n if @noto.update_attributes(params[:noto])\n format.html { redirect_to @noto, :notice => 'Noto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @noto.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @plato = Plato.find(params[:id])\n\n if @plato.update(plato_params)\n head :no_content\n else\n render json: @plato.errors, status: :unprocessable_entity\n end\n end", "def update\n @colegio = Colegio.find(params[:id])\n\n respond_to do |format|\n if @colegio.update_attributes(params[:colegio])\n format.html { redirect_to @colegio, notice: 'El Colegio fue actualizado satisfactoriamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @colegio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @objeto.update(objeto_params)\n format.html { redirect_to @objeto, notice: 'Objeto was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @objeto.update(objeto_params)\n format.html { redirect_to @objeto, notice: 'Objeto was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @mecanicacomplejo = Mecanicacomplejo.find(params[:id])\n\n respond_to do |format|\n if @mecanicacomplejo.update_attributes(params[:mecanicacomplejo])\n format.html { redirect_to @mecanicacomplejo, notice: 'Mecanicacomplejo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mecanicacomplejo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @datos_usuario.update(datos_usuario_params)\n format.html { redirect_to root_path, notice: 'Datos usuario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @datos_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @problema.update(problema_params)\n format.html { redirect_to consulta_problema_path(@consulta), notice: 'Problema Actualizado' }\n format.json { render :show, status: :ok, location: @problema }\n else\n format.html { render :edit }\n format.json { render json: @problema.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipocambio.update(tipocambio_params)\n format.html { redirect_to @tipocambio, notice: 'Tipocambio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipocambio }\n else\n format.html { render :edit }\n format.json { render json: @tipocambio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @modelo = Modelo.find(params[:id])\n\n respond_to do |format|\n if @modelo.update_attributes(params[:modelo])\n format.html { redirect_to @modelo, notice: 'Modelo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @modelo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @loja = Loja.find(params[:id])\n\n respond_to do |format|\n if @loja.update_attributes(params[:loja])\n format.html { redirect_to @loja, notice: 'Loja actualizada com sucesso' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @loja.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @matome.update(matome_params)\n format.html { redirect_to @matome, notice: 'Matome was successfully updated.' }\n format.json { render :show, status: :ok, location: @matome }\n else\n format.html { render :edit }\n format.json { render json: @matome.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @matome.update(matome_params)\n format.html { redirect_to @matome, notice: 'Matome was successfully updated.' }\n format.json { render :show, status: :ok, location: @matome }\n else\n format.html { render :edit }\n format.json { render json: @matome.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @objeto.update(requisito_params)\n format.html { redirect_to @objeto, notice: \"Requisito was successfully updated.\" }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n format.html { redirect_to tipos_path, notice: '<i class=\"fa fa-check-square fa-lg\"></i> Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\n end\n end\n end", "def update\n respond_to do |format|\n if @biometria.update(biometria_params)\n format.html { redirect_to index_biometria_path(params[:biometria][:paciente_id]), notice: 'Biometria se actualizo correctamente'}\n format.json { render :show, status: :ok, location: @biometria }\n else\n format.html { render :edit }\n format.json { render json: @biometria.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @usuario = Usuario.find(params[:id])\n\n if @usuario.update(usuario_params)\n head :no_content\n else\n render json: @usuario.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @sumario.update(sumario_params)\n format.html { redirect_to @sumario, notice: 'Sumario was successfully updated.' }\n format.json { render :show, status: :ok, location: @sumario }\n else\n format.html { render :edit }\n format.json { render json: @sumario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @politico.update(politico_params) and @politico.update_attributes(:modificador => current_user.id)\n format.html { redirect_to @politico, notice: 'Politico was successfully updated.' }\n format.json { render :show, status: :ok, location: @politico }\n else\n format.html { render :edit }\n format.json { render json: @politico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @clientes_servico.update(clientes_servico_params)\n format.html { redirect_to @clientes_servico, notice: 'Clientes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clientes_servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tecnico = Tecnico.find(params[:id])\n @tecnico.user = current_user\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, notice: 'Técnico foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipoveiculo.update(tipoveiculo_params)\n format.html { redirect_to @tipoveiculo, notice: 'Tipoveiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoveiculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @methodology.update(methodology_params)\n User.post_feed(current_user, \"#{current_user.full_name} editou uma metodologia - #{@methodology.title}\")\n format.html { redirect_to @methodology, notice: 'Metodologia atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @methodology.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @medico.update(medico_params)\n format.html { redirect_to @medico, notice: \"Medico atualizado com SUCESSO.\" }\n format.json { render :show, status: :ok, location: @medico }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @medico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_de_imposto.update(tipo_de_imposto_params)\n format.html { redirect_to @empresa, notice: 'Tipo de imposto actualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @tipo_de_imposto }\n else\n format.html { render :edit }\n format.json { render json: @tipo_de_imposto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @asiento_de_servicio.update(asiento_de_servicio_params)\n format.html { redirect_to @asiento_de_servicio, notice: 'Asiento de servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @asiento_de_servicio }\n else\n format.html { render :edit }\n format.json { render json: @asiento_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @formulario.update(formulario_params)\n format.html { redirect_to @formulario, notice: 'Formulario was successfully updated.' }\n format.json { render :show, status: :ok, location: @formulario }\n else\n format.html { render :edit }\n format.json { render json: @formulario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @laboratorio.update(laboratorio_params)\n format.html { redirect_to \"/laboratorios\", notice: 'Laboratorio actualizado con éxito.' }\n format.json { render :show, status: :ok, location: @laboratorio }\n else\n format.html { render :edit }\n format.json { render json: @laboratorio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @fio_titulo.update(fio_titulo_params)\r\n format.html { redirect_to fio_titulo_path(@fio_titulo), notice: 'Materia prima atualizada com sucesso.' }\r\n format.json { render :show, status: :ok, location: @fio_titulo }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @fio_titulo.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end" ]
[ "0.67807484", "0.63534105", "0.62647784", "0.6174062", "0.61529464", "0.6142683", "0.6128223", "0.6101664", "0.6094204", "0.6093889", "0.60876095", "0.6077678", "0.60763264", "0.60653436", "0.6057624", "0.60565454", "0.60504746", "0.60328144", "0.60276836", "0.60161614", "0.60135007", "0.6010145", "0.6007506", "0.6004937", "0.60048455", "0.60019654", "0.59848887", "0.5982237", "0.5970869", "0.5967528", "0.5954594", "0.5946467", "0.5945629", "0.59328395", "0.5927175", "0.5925982", "0.5925506", "0.59235656", "0.592325", "0.5920358", "0.5919969", "0.5917507", "0.59165215", "0.5915977", "0.5915696", "0.59141976", "0.59087014", "0.5907317", "0.59033304", "0.5899345", "0.58967346", "0.5893193", "0.5892746", "0.5886806", "0.5883001", "0.58802986", "0.58781415", "0.587677", "0.5876318", "0.5875263", "0.58743656", "0.587137", "0.5870306", "0.5869157", "0.58598804", "0.5855399", "0.5854526", "0.5854256", "0.585194", "0.5850004", "0.58484095", "0.58478564", "0.5840087", "0.5839875", "0.5836001", "0.5836001", "0.5831353", "0.5830126", "0.582953", "0.5828738", "0.5825542", "0.5821451", "0.58206916", "0.58206916", "0.5820654", "0.58146894", "0.5813065", "0.5810988", "0.58106285", "0.581052", "0.58097386", "0.5807138", "0.5806976", "0.58058465", "0.58050704", "0.580369", "0.5803131", "0.5801907", "0.5799152", "0.5798385" ]
0.6838462
0
DELETE /metodologias/1 DELETE /metodologias/1.json
def destroy @metodologia.destroy respond_to do |format| format.html { redirect_to metodologias_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @relogio = Relogio.find(params[:id])\n @relogio.destroy\n\n respond_to do |format|\n format.html { redirect_to relogios_url }\n format.json { head :ok }\n end\n end", "def destroy\n @metodo = Metodo.find(params[:id])\n @metodo.destroy\n\n respond_to do |format|\n format.html { redirect_to metodos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @logjuego = Logjuego.find(params[:id])\n @logjuego.destroy\n\n respond_to do |format|\n format.html { redirect_to logjuegos_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to datos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reconocimiento = Reconocimiento.find(params[:id])\n @reconocimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to reconocimientos_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 @datosgenerale.destroy\n respond_to do |format|\n format.html { redirect_to datosgenerales_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meupedido.destroy\n respond_to do |format|\n format.html { redirect_to meupedidos_url, notice: 'Meupedido was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @remito = Remito.find(params[:id])\n @remito.destroy\n\n respond_to do |format|\n format.html { redirect_to remitos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @limpeza = LogLimpeza.find(params[:id])\n @limpeza.destroy\n respond_to do |format|\n format.html { redirect_to index_limpezas_url, notice: 'Limpeza removida.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mecanico_especialidad.destroy\n respond_to do |format|\n format.html { redirect_to mecanico_especialidads_url, notice: 'Mecanico especialidad was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :destroy, @mesasredonda\n @mesasredonda = Mesasredonda.find(params[:id])\n @mesasredonda.destroy\n\n respond_to do |format|\n format.html { redirect_to mesasredondas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @biometria.destroy\n respond_to do |format|\n format.html { redirect_to index_biometria_path(params[:paciente_id]), notice: 'Biometria elimino correctamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mensagem = Mensagem.find(params[:id])\n api_client.delete_object(@mensagem.post_id)\n @mensagem.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.js { head :ok }\n end\n end", "def destroy\n @medico.destroy\n respond_to do |format|\n format.html { redirect_to medicos_url, notice: \"Medico deletado com SUCESSO.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @logueo.destroy\n respond_to do |format|\n format.html { redirect_to logueos_url, notice: 'Registro eliminado.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @oficio.destroy\n respond_to do |format|\n format.html { redirect_to oficios_url, notice: 'Oficio eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @logradouro.destroy\n respond_to do |format|\n format.html { redirect_to logradouros_url, notice: 'Logradouro deletado com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sistema = Sistema.find(params[:id])\n @sistema.destroy\n\n respond_to do |format|\n format.html { redirect_to sistemas_url }\n format.json { head :no_content }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @novedad_mecanica.destroy\n respond_to do |format|\n format.html { redirect_to unidad_url(@unidad), notice: 'Novedad mecanica was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mantenimiento.destroy\n respond_to do |format|\n format.html { redirect_to mantenimientos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @remedio = Remedio.find(params[:id])\n @remedio.destroy\n\n respond_to do |format|\n format.html { redirect_to remedios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recurso = Recurso.find(params[:id])\n @recurso.destroy\n\n respond_to do |format|\n format.html { redirect_to recursos_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @imobiliaria = Imobiliaria.find(params[:id])\r\n @imobiliaria.destroy\r\n\r\n respond_to do |format|\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @dynamique = Dynamique.find(params[:id])\n @dynamique.destroy\n\n respond_to do |format|\n format.html { redirect_to dynamiques_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datos_usuario.destroy\n respond_to do |format|\n format.html { redirect_to datos_usuarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sumario.destroy\n respond_to do |format|\n format.html { redirect_to sumarios_url, notice: 'Sumario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mecanicacomplejo = Mecanicacomplejo.find(params[:id])\n @mecanicacomplejo.destroy\n\n respond_to do |format|\n format.html { redirect_to mecanicacomplejos_url }\n format.json { head :no_content }\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 @servico_pacote.destroy\n respond_to do |format|\n format.html { redirect_to servico_pacotes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @receita_medica = ReceitaMedica.find(params[:id])\n @receita_medica.destroy\n\n respond_to do |format|\n format.html { redirect_to receita_medicas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @odontologia1 = Odontologia1.find(params[:id])\n @odontologia1.destroy\n\n respond_to do |format|\n format.html { redirect_to odontologia1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nota_tecnica.destroy\n respond_to do |format|\n format.html { redirect_to nota_tecnicas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item_de_despesa.destroy\n addlog(\"Item de despesa apagado\")\n respond_to do |format|\n format.html { redirect_to itens_de_despesa_url, notice: 'Item de despesa apagado com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mensaje_usuario = MensajeUsuario.find(params[:id])\n @mensaje_usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to mensaje_usuarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @estatuto = Estatuto.find(params[:id])\n @estatuto.destroy\n\n respond_to do |format|\n format.html { redirect_to estatutos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lixotodo.destroy\n respond_to do |format|\n format.html {redirect_to lixotodos_url, notice: 'Registro excluído com sucesso.'}\n format.json {head :no_content}\n end\n end", "def destroy\n @seguidore = Seguidore.find(params[:id])\n @seguidore.destroy\n\n respond_to do |format|\n format.html { redirect_to seguidores_url }\n format.json { head :ok }\n end\n end", "def destroy\n @colegio = Colegio.find(params[:id])\n @colegio.destroy\n\n respond_to do |format|\n format.html { redirect_to colegios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ejemplo.destroy\n respond_to do |format|\n format.html { redirect_to ejemplos_url, notice: 'Ejemplo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @unidad.destroy\n respond_to do |format|\n format.html { redirect_to unidades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @requerimiento = Requerimiento.find(params[:id])\n @requerimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to requerimientos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @datoscontacto = Datoscontacto.find(params[:id])\n @datoscontacto.destroy\n\n respond_to do |format|\n format.html { redirect_to datoscontactos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @personaje_mision = PersonajeMision.find(params[:id])\n @personaje_mision.destroy\n\n respond_to do |format|\n format.html { redirect_to personaje_misions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @medida_talla.destroy\n respond_to do |format|\n format.html { redirect_to fichatecnica_medida_tallas_url(@fichatecnica), notice: 'Medida talla was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n category = Formulario::REFERENCES_CATEGORY[@formulario.categoria]\n file = File.join(\"#{Formulario::ROUTE_PATH}\",category, @formulario.title)\n FileUtils.rm file\n @formulario.destroy\n respond_to do |format|\n puts \"----------> #{formularios_url}\"\n format.html { redirect_to formularios_url, notice: 'Formulario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ministerio = Ministerio.find(params[:id])\n @ministerio.destroy\n\n respond_to do |format|\n format.html { redirect_to ministerios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ocorrencia.destroy\n respond_to do |format|\n format.html { redirect_to ocorrencias_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @veiculo = Veiculo.find(params[:id])\n @veiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to veiculos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipoapreensao.destroy\n respond_to do |format|\n format.html { redirect_to tipoapreensoes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @humanidades1 = Humanidades1.find(params[:id])\n @humanidades1.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mutacao = Mutacao.find(params[:id])\n @mutacao.destroy\n\n respond_to do |format|\n format.html { redirect_to mutacaos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipoveiculo.destroy\n respond_to do |format|\n format.html { redirect_to tipoveiculos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aactio = Aactio.find(params[:id])\n @aactio.destroy\n\n respond_to do |format|\n format.html { redirect_to aactios_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @reclamacao.destroy\r\n respond_to do |format|\r\n format.html { redirect_to usuario_path(Usuario.get_usuario_logado), notice: 'RECLAMAÇÃO APAGADA! ' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @user = current_user;\n @toeic_log = ToeicLog.find(params[:id])\n @toeic_log.destroy\n\n respond_to do |format|\n format.html { redirect_to toeic_logs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @leito = Leito.find(params[:id])\n @leito.destroy\n\n respond_to do |format|\n format.html { redirect_to leitos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @etiquetum.destroy\n respond_to do |format|\n format.html { redirect_to etiqueta_url, notice: 'Etiqueta borrada!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_de_imposto.destroy\n respond_to do |format|\n format.html { redirect_to @empresa, notice: 'Tipo de imposto removido com sucesso.' }\n format.json { head :no_content }\n end\n end", "def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end", "def destroy\n @matriz.destroy\n respond_to do |format|\n format.html { redirect_to matrizs_url, notice: 'Matriz was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @orcamento.destroy\n respond_to do |format|\n format.html { redirect_to orcamentos_url, notice: 'Orçamento apagado com sucesso!' }\n format.json { head :no_content }\n end\n end", "def delete(path)\n request(:delete, path)\n end", "def delete(path)\n request 'DELETE', path\n end", "def destroy\n @motivo.destroy\n respond_to do |format|\n format.html { redirect_to motivos_url, notice: 'Motivo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ordem_servico.destroy\n respond_to do |format|\n format.html { redirect_to ordem_servicos_url, notice: t('messages.cadastro_removido') }\n format.json { head :no_content }\n end\n end", "def delete(path)\n\t\trequest(path, :delete)\n\tend", "def destroy\n @crediario.destroy\n respond_to do |format|\n format.html { redirect_to crediarios_url, notice: 'Parcela excluida com sucesso!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @realiza = Realiza.find(params[:id])\n @realiza.destroy\n\n respond_to do |format|\n format.html { redirect_to realizas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n \n @lancamentorapido = Lancamentorapido.find(params[:id])\n @lancamentorapido.destroy \n\n respond_to do |format|\n format.html { redirect_to lancamentorapidos_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @foodlog = Foodlog.find(params[:id])\n @foodlog.destroy\n\n respond_to do |format|\n format.html { redirect_to foodlogs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n head :no_content\n end", "def destroy\n @donante.destroy\n respond_to do |format|\n format.html { redirect_to donantes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @documentacion.destroy\n respond_to do |format|\n format.html { redirect_to @mem, notice: 'Documentación eliminada correctamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_documento = TipoDocumento.find(params[:id])\n @tipo_documento.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_documentos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @musique = Musique.find(params[:id])\n @musique.destroy\n\n respond_to do |format|\n format.html { redirect_to musiques_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @inicio.destroy\n respond_to do |format|\n format.html { redirect_to inicios_url, notice: 'Inicio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @respuestum.destroy\n respond_to do |format|\n format.html { redirect_to comentarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @diario.destroy\n respond_to do |format|\n format.html { redirect_to diarios_url, notice: \"Diario was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @mundo.destroy\n respond_to do |format|\n format.html { redirect_to mundos_url, notice: 'Mundo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @api_v1_todo.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @detalle_documento_de_compra.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Linea eliminada' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sotrudniki = Sotrudniki.find(params[:id])\n @sotrudniki.destroy\n\n respond_to do |format|\n format.html { redirect_to sotrudnikis_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @uchronia = Uchronia.find(params[:id])\n @uchronia.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronias_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @amministrazione.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Amministrazione was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @datos_personal.destroy\n respond_to do |format|\n format.html { redirect_to datos_personals_url, notice: 'Datos personal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @visitante.destroy\n respond_to do |format|\n format.html { redirect_to visitantes_url, notice: 'Visitante was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tiposveiculo.destroy\n respond_to do |format|\n format.html { redirect_to tiposveiculos_url, notice: 'Tipo de Veículo excluído com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.find(params[:id])\n @juzgado.destroy\n\n respond_to do |format|\n format.html { redirect_to juzgados_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7326798", "0.72428715", "0.7159269", "0.71088237", "0.69946104", "0.6892742", "0.68869674", "0.68810207", "0.6866423", "0.6851632", "0.68507266", "0.68432856", "0.683257", "0.6828975", "0.68283284", "0.6827685", "0.6827329", "0.68240404", "0.68222696", "0.6814585", "0.68128204", "0.68114656", "0.6809857", "0.6804984", "0.67961395", "0.6788708", "0.67778695", "0.6777818", "0.677548", "0.6775196", "0.67745596", "0.67648613", "0.67638457", "0.67589337", "0.67528075", "0.67504907", "0.6746753", "0.67454565", "0.67425334", "0.6739124", "0.67359555", "0.6735759", "0.67341506", "0.672714", "0.67250717", "0.67214525", "0.67208457", "0.67152566", "0.6709491", "0.6709491", "0.67091215", "0.67066824", "0.6706463", "0.6705848", "0.670416", "0.67016506", "0.669948", "0.669866", "0.6696439", "0.6696365", "0.6695384", "0.6693969", "0.6688879", "0.6688845", "0.6685824", "0.668388", "0.66835713", "0.6682859", "0.6678503", "0.66732645", "0.6672058", "0.6671274", "0.6670638", "0.66704386", "0.6664764", "0.6659764", "0.6659672", "0.66583276", "0.6657375", "0.6655644", "0.66550213", "0.6654655", "0.66514426", "0.6648982", "0.66477406", "0.6644333", "0.6643733", "0.6642738", "0.66419536", "0.6640676", "0.6638384", "0.6637539", "0.66348267", "0.6633078", "0.6632069", "0.66317344", "0.6631648", "0.6630269", "0.66300726", "0.66299987" ]
0.73762846
0
Use callbacks to share common setup or constraints between actions.
def set_metodologia @metodologia = Metodologia.friendly.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup\n #implement in subclass;\n end", "def after_set_callback; end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.53314966", "0.53114754", "0.52984965", "0.52977055", "0.5296272", "0.5260649", "0.5245076", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.5235081", "0.52321917", "0.5228592", "0.5220735", "0.52198535", "0.52139324", "0.5208539", "0.5206585", "0.5178542", "0.5175199", "0.5173538", "0.5167041", "0.51614195", "0.51577675", "0.5153909", "0.51528823", "0.5152225", "0.51429904", "0.5141399", "0.51345575", "0.51145", "0.5114052", "0.5114052", "0.5110216", "0.5108656", "0.50935394", "0.5089196", "0.5081936", "0.5079627", "0.50675833", "0.5056105", "0.5053687", "0.5050475", "0.5050475", "0.503471", "0.5028311", "0.501982", "0.50157547", "0.5013552", "0.50014806", "0.50011593", "0.49976763", "0.4990292", "0.4990292", "0.49882022", "0.4981269", "0.49792367", "0.49766538", "0.4967978", "0.49667212", "0.4958987", "0.49572337", "0.49550423", "0.4954479", "0.4952353", "0.494726", "0.4944055", "0.4935437", "0.4931248", "0.49283475", "0.49281213", "0.49268973", "0.4921738", "0.49204507", "0.4918924", "0.49182287", "0.4916538", "0.49158585", "0.49156788" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def metodologia_params params.require(:metodologia).permit(:name, :descripcion) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def filtering_params\n params.permit(:email)\n end", "def active_code_params\n params[:active_code].permit\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def url_whitelist; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.6978086", "0.6780264", "0.6742658", "0.6738813", "0.67338693", "0.65908474", "0.6501793", "0.6495506", "0.64796513", "0.64755446", "0.6454826", "0.6437561", "0.6377127", "0.63722163", "0.6364058", "0.63178706", "0.62979764", "0.62968165", "0.62913024", "0.6289789", "0.6289145", "0.62875307", "0.6280997", "0.62420976", "0.62388235", "0.6216686", "0.62122375", "0.6208949", "0.619173", "0.6176307", "0.6173907", "0.6170346", "0.616111", "0.6150513", "0.6150023", "0.61446756", "0.6120429", "0.6112975", "0.6104845", "0.6102966", "0.6087884", "0.6079323", "0.60699135", "0.60602236", "0.60191786", "0.60170597", "0.60100305", "0.6009527", "0.60052776", "0.60052776", "0.600042", "0.5999317", "0.59933805", "0.5991528", "0.5991221", "0.5990094", "0.5979497", "0.5966058", "0.5958738", "0.59579456", "0.5957759", "0.5956938", "0.5951788", "0.59511644", "0.59423065", "0.59373474", "0.59361076", "0.59361076", "0.59331447", "0.5928005", "0.5924882", "0.5924011", "0.59169155", "0.5908037", "0.5907541", "0.59061426", "0.59056246", "0.5897408", "0.58960444", "0.58951247", "0.5893136", "0.5892312", "0.5890385", "0.58853275", "0.58801144", "0.58784765", "0.5872648", "0.58682626", "0.5867028", "0.58661693", "0.586578", "0.58643955", "0.5863193", "0.58609086", "0.5859997", "0.5858935", "0.5858632", "0.5853379", "0.5852741", "0.584806", "0.5847703" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_formula_herb_action @formula_herb_action = FormulaHerbAction.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1